mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-22 12:55:58 +01:00
backend/wayland: tag wl_surface
When integrating wlroots with another toolkit, wlroots may receive wl_pointer.enter events for surfaces not backed by a wlr_output. Ignore such surfaces by tagging the ones we're aware of with wl_proxy_set_tag().
This commit is contained in:
parent
dd24991c9e
commit
4f88886199
4 changed files with 32 additions and 5 deletions
|
@ -36,6 +36,8 @@ static const uint32_t SUPPORTED_OUTPUT_STATE =
|
||||||
|
|
||||||
static size_t last_output_num = 0;
|
static size_t last_output_num = 0;
|
||||||
|
|
||||||
|
static const char *surface_tag = "wlr_wl_output";
|
||||||
|
|
||||||
static struct wlr_wl_output *get_wl_output_from_output(
|
static struct wlr_wl_output *get_wl_output_from_output(
|
||||||
struct wlr_output *wlr_output) {
|
struct wlr_output *wlr_output) {
|
||||||
assert(wlr_output_is_wl(wlr_output));
|
assert(wlr_output_is_wl(wlr_output));
|
||||||
|
@ -43,6 +45,19 @@ static struct wlr_wl_output *get_wl_output_from_output(
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct wlr_wl_output *get_wl_output_from_surface(struct wlr_wl_backend *wl,
|
||||||
|
struct wl_surface *surface) {
|
||||||
|
if (wl_proxy_get_tag((struct wl_proxy *)surface) != &surface_tag) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
struct wlr_wl_output *output = wl_surface_get_user_data(surface);
|
||||||
|
assert(output != NULL);
|
||||||
|
if (output->backend != wl) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
static void surface_frame_callback(void *data, struct wl_callback *cb,
|
static void surface_frame_callback(void *data, struct wl_callback *cb,
|
||||||
uint32_t time) {
|
uint32_t time) {
|
||||||
struct wlr_wl_output *output = data;
|
struct wlr_wl_output *output = data;
|
||||||
|
@ -774,6 +789,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *wlr_backend) {
|
||||||
wlr_log_errno(WLR_ERROR, "Could not create output surface");
|
wlr_log_errno(WLR_ERROR, "Could not create output surface");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
wl_proxy_set_tag((struct wl_proxy *)output->surface, &surface_tag);
|
||||||
wl_surface_set_user_data(output->surface, output);
|
wl_surface_set_user_data(output->surface, output);
|
||||||
output->xdg_surface =
|
output->xdg_surface =
|
||||||
xdg_wm_base_get_xdg_surface(backend->xdg_wm_base, output->surface);
|
xdg_wm_base_get_xdg_surface(backend->xdg_wm_base, output->surface);
|
||||||
|
|
|
@ -38,8 +38,10 @@ static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_wl_output *output = wl_surface_get_user_data(surface);
|
struct wlr_wl_output *output = get_wl_output_from_surface(seat->backend, surface);
|
||||||
assert(output);
|
if (output == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
struct wlr_wl_pointer *pointer = output_get_pointer(output, wl_pointer);
|
struct wlr_wl_pointer *pointer = output_get_pointer(output, wl_pointer);
|
||||||
seat->active_pointer = pointer;
|
seat->active_pointer = pointer;
|
||||||
|
@ -64,8 +66,10 @@ static void pointer_handle_leave(void *data, struct wl_pointer *wl_pointer,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_wl_output *output = wl_surface_get_user_data(surface);
|
struct wlr_wl_output *output = get_wl_output_from_surface(seat->backend, surface);
|
||||||
assert(output);
|
if (output == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (seat->active_pointer != NULL &&
|
if (seat->active_pointer != NULL &&
|
||||||
seat->active_pointer->output == output) {
|
seat->active_pointer->output == output) {
|
||||||
|
|
|
@ -504,8 +504,13 @@ static void handle_tablet_tool_proximity_in(void *data,
|
||||||
struct tablet_tool *tool = data;
|
struct tablet_tool *tool = data;
|
||||||
assert(tablet_id == tool->seat->zwp_tablet_v2);
|
assert(tablet_id == tool->seat->zwp_tablet_v2);
|
||||||
|
|
||||||
|
struct wlr_wl_output *output = get_wl_output_from_surface(tool->seat->backend, surface);
|
||||||
|
if (output == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tool->is_in = true;
|
tool->is_in = true;
|
||||||
tool->output = wl_surface_get_user_data(surface);
|
tool->output = output;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handle_tablet_tool_proximity_out(void *data,
|
static void handle_tablet_tool_proximity_out(void *data,
|
||||||
|
|
|
@ -154,6 +154,8 @@ struct wlr_wl_seat {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct wlr_wl_backend *get_wl_backend_from_backend(struct wlr_backend *backend);
|
struct wlr_wl_backend *get_wl_backend_from_backend(struct wlr_backend *backend);
|
||||||
|
struct wlr_wl_output *get_wl_output_from_surface(struct wlr_wl_backend *wl,
|
||||||
|
struct wl_surface *surface);
|
||||||
void update_wl_output_cursor(struct wlr_wl_output *output);
|
void update_wl_output_cursor(struct wlr_wl_output *output);
|
||||||
|
|
||||||
void init_seat_keyboard(struct wlr_wl_seat *seat);
|
void init_seat_keyboard(struct wlr_wl_seat *seat);
|
||||||
|
|
Loading…
Reference in a new issue