mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-12-22 18:09:49 +01:00
backend/wayland: add assertions
This commit is contained in:
parent
07ea98dab9
commit
e98cb7c5ab
4 changed files with 54 additions and 33 deletions
|
@ -15,6 +15,12 @@
|
|||
#include "util/signal.h"
|
||||
#include "xdg-shell-unstable-v6-client-protocol.h"
|
||||
|
||||
struct wlr_wl_backend *get_wl_backend_from_backend(
|
||||
struct wlr_backend *wlr_backend) {
|
||||
assert(wlr_backend_is_wl(wlr_backend));
|
||||
return (struct wlr_wl_backend *)wlr_backend;
|
||||
}
|
||||
|
||||
static int dispatch_events(int fd, uint32_t mask, void *data) {
|
||||
struct wlr_wl_backend *backend = data;
|
||||
int count = 0;
|
||||
|
@ -39,8 +45,8 @@ static int dispatch_events(int fd, uint32_t mask, void *data) {
|
|||
* compositor and creates surfaces for each output, then registers globals on
|
||||
* the specified display.
|
||||
*/
|
||||
static bool backend_start(struct wlr_backend *_backend) {
|
||||
struct wlr_wl_backend *backend = (struct wlr_wl_backend *)_backend;
|
||||
static bool backend_start(struct wlr_backend *wlr_backend) {
|
||||
struct wlr_wl_backend *backend = get_wl_backend_from_backend(wlr_backend);
|
||||
wlr_log(WLR_INFO, "Initializating wayland backend");
|
||||
|
||||
poll_wl_registry(backend);
|
||||
|
@ -66,7 +72,7 @@ static bool backend_start(struct wlr_backend *_backend) {
|
|||
}
|
||||
|
||||
static void backend_destroy(struct wlr_backend *wlr_backend) {
|
||||
struct wlr_wl_backend *backend = (struct wlr_wl_backend *)wlr_backend;
|
||||
struct wlr_wl_backend *backend = get_wl_backend_from_backend(wlr_backend);
|
||||
if (backend == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -118,7 +124,7 @@ static void backend_destroy(struct wlr_backend *wlr_backend) {
|
|||
|
||||
static struct wlr_renderer *backend_get_renderer(
|
||||
struct wlr_backend *wlr_backend) {
|
||||
struct wlr_wl_backend *backend = (struct wlr_wl_backend *)wlr_backend;
|
||||
struct wlr_wl_backend *backend = get_wl_backend_from_backend(wlr_backend);
|
||||
return backend->renderer;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,11 @@
|
|||
#include "util/signal.h"
|
||||
#include "xdg-shell-unstable-v6-client-protocol.h"
|
||||
|
||||
int os_create_anonymous_file(off_t size);
|
||||
static struct wlr_wl_output *get_wl_output_from_output(
|
||||
struct wlr_output *wlr_output) {
|
||||
assert(wlr_output_is_wl(wlr_output));
|
||||
return (struct wlr_wl_output *)wlr_output;
|
||||
}
|
||||
|
||||
static struct wl_callback_listener frame_listener;
|
||||
|
||||
|
@ -33,9 +37,9 @@ static struct wl_callback_listener frame_listener = {
|
|||
.done = surface_frame_callback
|
||||
};
|
||||
|
||||
static bool output_set_custom_mode(struct wlr_output *_output,
|
||||
static bool output_set_custom_mode(struct wlr_output *wlr_output,
|
||||
int32_t width, int32_t height, int32_t refresh) {
|
||||
struct wlr_wl_output *output = (struct wlr_wl_output *)_output;
|
||||
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
|
||||
wl_egl_window_resize(output->egl_window, width, height, 0, 0);
|
||||
wlr_output_update_custom_mode(&output->wlr_output, width, height, 0);
|
||||
return true;
|
||||
|
@ -44,7 +48,7 @@ static bool output_set_custom_mode(struct wlr_output *_output,
|
|||
static bool output_make_current(struct wlr_output *wlr_output,
|
||||
int *buffer_age) {
|
||||
struct wlr_wl_output *output =
|
||||
(struct wlr_wl_output *)wlr_output;
|
||||
get_wl_output_from_output(wlr_output);
|
||||
return wlr_egl_make_current(&output->backend->egl, output->egl_surface,
|
||||
buffer_age);
|
||||
}
|
||||
|
@ -52,7 +56,7 @@ static bool output_make_current(struct wlr_output *wlr_output,
|
|||
static bool output_swap_buffers(struct wlr_output *wlr_output,
|
||||
pixman_region32_t *damage) {
|
||||
struct wlr_wl_output *output =
|
||||
(struct wlr_wl_output *)wlr_output;
|
||||
get_wl_output_from_output(wlr_output);
|
||||
|
||||
if (output->frame_callback != NULL) {
|
||||
wlr_log(WLR_ERROR, "Skipping buffer swap");
|
||||
|
@ -66,21 +70,22 @@ static bool output_swap_buffers(struct wlr_output *wlr_output,
|
|||
damage);
|
||||
}
|
||||
|
||||
static void output_transform(struct wlr_output *_output,
|
||||
static void output_transform(struct wlr_output *wlr_output,
|
||||
enum wl_output_transform transform) {
|
||||
struct wlr_wl_output *output = (struct wlr_wl_output *)_output;
|
||||
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
|
||||
output->wlr_output.transform = transform;
|
||||
}
|
||||
|
||||
static bool output_set_cursor(struct wlr_output *wlr_output,
|
||||
struct wlr_texture *texture, int32_t scale,
|
||||
enum wl_output_transform transform, int32_t hotspot_x, int32_t hotspot_y,
|
||||
bool update_texture) {
|
||||
struct wlr_wl_output *output = (struct wlr_wl_output *)wlr_output;
|
||||
enum wl_output_transform transform,
|
||||
int32_t hotspot_x, int32_t hotspot_y, bool update_texture) {
|
||||
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
|
||||
struct wlr_wl_backend *backend = output->backend;
|
||||
|
||||
struct wlr_box hotspot = { .x = hotspot_x, .y = hotspot_y };
|
||||
wlr_box_transform(&hotspot, wlr_output_transform_invert(wlr_output->transform),
|
||||
wlr_box_transform(&hotspot,
|
||||
wlr_output_transform_invert(wlr_output->transform),
|
||||
output->cursor.width, output->cursor.height, &hotspot);
|
||||
|
||||
// TODO: use output->wlr_output.transform to transform pixels and hotpot
|
||||
|
@ -147,8 +152,7 @@ static bool output_set_cursor(struct wlr_output *wlr_output,
|
|||
}
|
||||
|
||||
static void output_destroy(struct wlr_output *wlr_output) {
|
||||
struct wlr_wl_output *output =
|
||||
(struct wlr_wl_output *)wlr_output;
|
||||
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
|
||||
if (output == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -215,7 +219,8 @@ static struct zxdg_surface_v6_listener xdg_surface_listener = {
|
|||
.configure = xdg_surface_handle_configure,
|
||||
};
|
||||
|
||||
static void xdg_toplevel_handle_configure(void *data, struct zxdg_toplevel_v6 *xdg_toplevel,
|
||||
static void xdg_toplevel_handle_configure(void *data,
|
||||
struct zxdg_toplevel_v6 *xdg_toplevel,
|
||||
int32_t width, int32_t height, struct wl_array *states) {
|
||||
struct wlr_wl_output *output = data;
|
||||
assert(output && output->xdg_toplevel == xdg_toplevel);
|
||||
|
@ -228,7 +233,8 @@ static void xdg_toplevel_handle_configure(void *data, struct zxdg_toplevel_v6 *x
|
|||
wlr_output_update_custom_mode(&output->wlr_output, width, height, 0);
|
||||
}
|
||||
|
||||
static void xdg_toplevel_handle_close(void *data, struct zxdg_toplevel_v6 *xdg_toplevel) {
|
||||
static void xdg_toplevel_handle_close(void *data,
|
||||
struct zxdg_toplevel_v6 *xdg_toplevel) {
|
||||
struct wlr_wl_output *output = data;
|
||||
assert(output && output->xdg_toplevel == xdg_toplevel);
|
||||
|
||||
|
@ -240,9 +246,8 @@ static struct zxdg_toplevel_v6_listener xdg_toplevel_listener = {
|
|||
.close = xdg_toplevel_handle_close,
|
||||
};
|
||||
|
||||
struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
|
||||
assert(wlr_backend_is_wl(_backend));
|
||||
struct wlr_wl_backend *backend = (struct wlr_wl_backend *)_backend;
|
||||
struct wlr_output *wlr_wl_output_create(struct wlr_backend *wlr_backend) {
|
||||
struct wlr_wl_backend *backend = get_wl_backend_from_backend(wlr_backend);
|
||||
if (!backend->started) {
|
||||
++backend->requested_outputs;
|
||||
return NULL;
|
||||
|
|
|
@ -122,11 +122,11 @@ static void pointer_handle_axis(void *data, struct wl_pointer *wl_pointer,
|
|||
}
|
||||
|
||||
static void pointer_handle_frame(void *data, struct wl_pointer *wl_pointer) {
|
||||
|
||||
// This space is intentionally left blank
|
||||
}
|
||||
|
||||
static void pointer_handle_axis_source(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t axis_source) {
|
||||
static void pointer_handle_axis_source(void *data,
|
||||
struct wl_pointer *wl_pointer, uint32_t axis_source) {
|
||||
struct wlr_wl_backend *backend = data;
|
||||
struct wlr_wl_pointer *pointer = backend->current_pointer;
|
||||
if (pointer == NULL) {
|
||||
|
@ -138,11 +138,11 @@ static void pointer_handle_axis_source(void *data, struct wl_pointer *wl_pointer
|
|||
|
||||
static void pointer_handle_axis_stop(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t time, uint32_t axis) {
|
||||
|
||||
// This space is intentionally left blank
|
||||
}
|
||||
|
||||
static void pointer_handle_axis_discrete(void *data, struct wl_pointer *wl_pointer,
|
||||
uint32_t axis, int32_t discrete) {
|
||||
static void pointer_handle_axis_discrete(void *data,
|
||||
struct wl_pointer *wl_pointer, uint32_t axis, int32_t discrete) {
|
||||
struct wlr_wl_backend *backend = data;
|
||||
struct wlr_wl_pointer *pointer = backend->current_pointer;
|
||||
if (pointer == NULL) {
|
||||
|
@ -239,9 +239,9 @@ static void keyboard_handle_modifiers(void *data, struct wl_keyboard *wl_keyboar
|
|||
mods_locked, group);
|
||||
}
|
||||
|
||||
static void keyboard_handle_repeat_info(void *data, struct wl_keyboard *wl_keyboard,
|
||||
int32_t rate, int32_t delay) {
|
||||
|
||||
static void keyboard_handle_repeat_info(void *data,
|
||||
struct wl_keyboard *wl_keyboard, int32_t rate, int32_t delay) {
|
||||
// This space is intentionally left blank
|
||||
}
|
||||
|
||||
static struct wl_keyboard_listener keyboard_listener = {
|
||||
|
@ -253,8 +253,15 @@ static struct wl_keyboard_listener keyboard_listener = {
|
|||
.repeat_info = keyboard_handle_repeat_info
|
||||
};
|
||||
|
||||
static struct wlr_wl_input_device *get_wl_input_device_from_input_device(
|
||||
struct wlr_input_device *wlr_dev) {
|
||||
assert(wlr_input_device_is_wl(wlr_dev));
|
||||
return (struct wlr_wl_input_device *)wlr_dev;
|
||||
}
|
||||
|
||||
static void input_device_destroy(struct wlr_input_device *wlr_dev) {
|
||||
struct wlr_wl_input_device *dev = (struct wlr_wl_input_device *)wlr_dev;
|
||||
struct wlr_wl_input_device *dev =
|
||||
get_wl_input_device_from_input_device(wlr_dev);
|
||||
if (dev->resource) {
|
||||
wl_proxy_destroy(dev->resource);
|
||||
}
|
||||
|
@ -399,7 +406,8 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
|
|||
}
|
||||
}
|
||||
|
||||
static void seat_handle_name(void *data, struct wl_seat *wl_seat, const char *name) {
|
||||
static void seat_handle_name(void *data, struct wl_seat *wl_seat,
|
||||
const char *name) {
|
||||
struct wlr_wl_backend *backend = data;
|
||||
assert(backend->seat == wl_seat);
|
||||
// Do we need to check if seatName was previously set for name change?
|
||||
|
|
|
@ -78,6 +78,8 @@ struct wlr_wl_pointer {
|
|||
struct wl_listener output_destroy;
|
||||
};
|
||||
|
||||
struct wlr_wl_backend *get_wl_backend_from_backend(
|
||||
struct wlr_backend *wlr_backend);
|
||||
void poll_wl_registry(struct wlr_wl_backend *backend);
|
||||
void update_wl_output_cursor(struct wlr_wl_output *output);
|
||||
struct wlr_wl_pointer *pointer_get_wl(struct wlr_pointer *wlr_pointer);
|
||||
|
|
Loading…
Reference in a new issue