diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2022-04-16 15:41:14 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2022-04-16 15:41:14 +0000 |
| commit | 129deaffa82650a1383f5816aa46f4a78a73b2ed (patch) | |
| tree | b2b7e138757555893bbc8f99ed290edb92739c8f /wayland.c | |
| parent | changelog: [csd].hide-when-maximized (diff) | |
wayland: optionally disable pointer input on subsurfaces
We have a number of sub-surfaces for which we are *not* interrested in
pointer (or touch) input.
Up until now, we’ve manually dealt with these, by recognizing these
surfaces in all pointer events, and ignoring them.
But, lo and behold, there are better ways of doing this. By clearing
the subsurface’s input region, the compositor will do this for us -
when a pointer is outside a surface’s input region, the event is
passed to the next surface underneath it.
This is exactly what we want! Do this for all subsurfaces, *except*
the CSDs.
Diffstat (limited to 'wayland.c')
| -rw-r--r-- | wayland.c | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -67,13 +67,14 @@ csd_instantiate(struct wl_window *win) xassert(wayl != NULL); for (size_t i = 0; i < CSD_SURF_MINIMIZE; i++) { - bool ret = wayl_win_subsurface_new(win, &win->csd.surface[i]); + bool ret = wayl_win_subsurface_new(win, &win->csd.surface[i], true); xassert(ret); } for (size_t i = CSD_SURF_MINIMIZE; i < CSD_SURF_COUNT; i++) { bool ret = wayl_win_subsurface_new_with_custom_parent( - win, win->csd.surface[CSD_SURF_TITLE].surf, &win->csd.surface[i]); + win, win->csd.surface[CSD_SURF_TITLE].surf, &win->csd.surface[i], + true); xassert(ret); } @@ -1478,7 +1479,7 @@ wayl_win_init(struct terminal *term, const char *token) switch (conf->tweak.render_timer) { case RENDER_TIMER_OSD: case RENDER_TIMER_BOTH: - if (!wayl_win_subsurface_new(win, &win->render_timer)) { + if (!wayl_win_subsurface_new(win, &win->render_timer, false)) { LOG_ERR("failed to create render timer surface"); goto out; } @@ -1783,7 +1784,7 @@ wayl_win_csd_borders_visible(const struct wl_window *win) bool wayl_win_subsurface_new_with_custom_parent( struct wl_window *win, struct wl_surface *parent, - struct wl_surf_subsurf *surf) + struct wl_surf_subsurf *surf, bool allow_pointer_input) { struct wayland *wayl = win->term->wl; @@ -1807,15 +1808,25 @@ wayl_win_subsurface_new_with_custom_parent( wl_surface_set_user_data(main_surface, win); wl_subsurface_set_sync(sub); + /* Disable pointer and touch events */ + if (!allow_pointer_input) { + struct wl_region *empty = + wl_compositor_create_region(wayl->compositor); + wl_surface_set_input_region(main_surface, empty); + wl_region_destroy(empty); + } + surf->surf = main_surface; surf->sub = sub; return true; } bool -wayl_win_subsurface_new(struct wl_window *win, struct wl_surf_subsurf *surf) +wayl_win_subsurface_new(struct wl_window *win, struct wl_surf_subsurf *surf, + bool allow_pointer_input) { - return wayl_win_subsurface_new_with_custom_parent(win, win->surface, surf); + return wayl_win_subsurface_new_with_custom_parent( + win, win->surface, surf, allow_pointer_input); } void |
