mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-11 08:21:34 -04: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 const char *surface_tag = "wlr_wl_output";
|
||||
|
||||
static struct wlr_wl_output *get_wl_output_from_output(
|
||||
struct wlr_output *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;
|
||||
}
|
||||
|
||||
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,
|
||||
uint32_t time) {
|
||||
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");
|
||||
goto error;
|
||||
}
|
||||
wl_proxy_set_tag((struct wl_proxy *)output->surface, &surface_tag);
|
||||
wl_surface_set_user_data(output->surface, output);
|
||||
output->xdg_surface =
|
||||
xdg_wm_base_get_xdg_surface(backend->xdg_wm_base, output->surface);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue