From 017bb7d7521f68d37bfe656c10f45edbcc92dd61 Mon Sep 17 00:00:00 2001 From: Palanix Date: Wed, 31 Aug 2022 06:11:07 +0200 Subject: fix flickering when resizing/spawning windows Fixes: https://github.com/djpohly/dwl/issues/306 --- client.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'client.h') diff --git a/client.h b/client.h index c18d01a..4dc9e1a 100644 --- a/client.h +++ b/client.h @@ -197,6 +197,21 @@ client_is_mapped(Client *c) return c->surface.xdg->mapped; } +static inline int +client_is_rendered_on_mon(Client *c, Monitor *m) +{ + /* This is needed for when you don't want to check formal assignment, + * but rather actual displaying of the pixels. + * Usually VISIBLEON suffices and is also faster. */ + struct wlr_surface_output *s; + if (!c->scene->node.enabled) + return 0; + wl_list_for_each(s, &client_surface(c)->current_outputs, link) + if (s->output == m->wlr_output) + return 1; + return 0; +} + static inline int client_is_unmanaged(Client *c) { -- cgit v1.2.1 From c56bc42eb5480783f3bc97f769bac3d9eebcb373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Sat, 3 Dec 2022 14:30:38 -0600 Subject: sort client_get_parent() --- client.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index 4dc9e1a..b443a8d 100644 --- a/client.h +++ b/client.h @@ -37,19 +37,6 @@ client_from_wlr_surface(struct wlr_surface *s) return NULL; } -static inline Client * -client_get_parent(Client *c) -{ -#ifdef XWAYLAND - if (client_is_x11(c) && c->surface.xwayland->parent) - return client_from_wlr_surface(c->surface.xwayland->parent->surface); -#endif - if (c->surface.xdg->toplevel->parent) - return client_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface); - - return NULL; -} - static inline void client_get_size_hints(Client *c, struct wlr_box *max, struct wlr_box *min) { @@ -153,6 +140,19 @@ client_get_geometry(Client *c, struct wlr_box *geom) wlr_xdg_surface_get_geometry(c->surface.xdg, geom); } +static inline Client * +client_get_parent(Client *c) +{ +#ifdef XWAYLAND + if (client_is_x11(c) && c->surface.xwayland->parent) + return toplevel_from_wlr_surface(c->surface.xwayland->parent->surface); +#endif + if (c->surface.xdg->toplevel->parent) + return toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface); + + return NULL; +} + static inline const char * client_get_title(Client *c) { -- cgit v1.2.1 From 38bd00351a444d37184716d6124bb47817758bc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Sat, 3 Dec 2022 14:31:18 -0600 Subject: merge toplevel_from_{wlr_layer_surface,popup} into client_from_wlr_surface now it is a big function called toplevel_from_wlr_surface --- client.h | 108 +++++++++++++++++++++++++++------------------------------------ 1 file changed, 47 insertions(+), 61 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index b443a8d..c12a107 100644 --- a/client.h +++ b/client.h @@ -16,27 +16,6 @@ client_is_x11(Client *c) #endif } -static inline Client * -client_from_wlr_surface(struct wlr_surface *s) -{ - struct wlr_xdg_surface *surface; - -#ifdef XWAYLAND - struct wlr_xwayland_surface *xsurface; - if (s && wlr_surface_is_xwayland_surface(s) - && (xsurface = wlr_xwayland_surface_from_wlr_surface(s))) - return xsurface->data; -#endif - if (s && wlr_surface_is_xdg_surface(s) - && (surface = wlr_xdg_surface_from_wlr_surface(s)) - && surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) - return surface->data; - - if (s && wlr_surface_is_subsurface(s)) - return client_from_wlr_surface(wlr_surface_get_root_surface(s)); - return NULL; -} - static inline void client_get_size_hints(Client *c, struct wlr_box *max, struct wlr_box *min) { @@ -72,6 +51,53 @@ client_surface(Client *c) return c->surface.xdg->surface; } +static inline void * +toplevel_from_wlr_surface(struct wlr_surface *s) +{ + struct wlr_xdg_surface *xdg_surface; + struct wlr_surface *root_surface; + struct wlr_layer_surface_v1 *layer_surface; +#ifdef XWAYLAND + struct wlr_xwayland_surface *xsurface; +#endif + + if (!s) + return NULL; + root_surface = wlr_surface_get_root_surface(s); + +#ifdef XWAYLAND + if (wlr_surface_is_xwayland_surface(root_surface) + && (xsurface = wlr_xwayland_surface_from_wlr_surface(root_surface))) + return xsurface->data; +#endif + + if (wlr_surface_is_layer_surface(root_surface) + && (layer_surface = wlr_layer_surface_v1_from_wlr_surface(root_surface))) + return layer_surface->data; + + if (wlr_surface_is_xdg_surface(root_surface) + && (xdg_surface = wlr_xdg_surface_from_wlr_surface(root_surface))) { + while (1) { + switch (xdg_surface->role) { + case WLR_XDG_SURFACE_ROLE_POPUP: + if (!xdg_surface->popup->parent) + return NULL; + else if (!wlr_surface_is_xdg_surface(xdg_surface->popup->parent)) + return toplevel_from_wlr_surface(xdg_surface->popup->parent); + + xdg_surface = wlr_xdg_surface_from_wlr_surface(xdg_surface->popup->parent); + break; + case WLR_XDG_SURFACE_ROLE_TOPLEVEL: + return xdg_surface->data; + case WLR_XDG_SURFACE_ROLE_NONE: + return NULL; + } + } + } + + return NULL; +} + /* The others */ static inline void client_activate_surface(struct wlr_surface *s, int activated) @@ -320,43 +346,3 @@ client_wants_fullscreen(Client *c) #endif return c->surface.xdg->toplevel->requested.fullscreen; } - -static inline void * -toplevel_from_popup(struct wlr_xdg_popup *popup) -{ - struct wlr_xdg_surface *surface = popup->base; - - while (1) { - switch (surface->role) { - case WLR_XDG_SURFACE_ROLE_POPUP: - if (!surface->popup->parent) - return NULL; - else if (wlr_surface_is_layer_surface(surface->popup->parent)) - return wlr_layer_surface_v1_from_wlr_surface(surface->popup->parent)->data; - else if (!wlr_surface_is_xdg_surface(surface->popup->parent)) - return NULL; - - surface = wlr_xdg_surface_from_wlr_surface(surface->popup->parent); - break; - case WLR_XDG_SURFACE_ROLE_TOPLEVEL: - return surface->data; - case WLR_XDG_SURFACE_ROLE_NONE: - return NULL; - } - } -} - -static inline void * -toplevel_from_wlr_layer_surface(struct wlr_surface *s) -{ - Client *c; - struct wlr_layer_surface_v1 *wlr_layer_surface; - - if ((c = client_from_wlr_surface(s))) - return c; - else if (s && wlr_surface_is_layer_surface(s) - && (wlr_layer_surface = wlr_layer_surface_v1_from_wlr_surface(s))) - return wlr_layer_surface->data; - - return NULL; -} -- cgit v1.2.1 From 22336612ae75954c68a7d4cd3f30fbebf94f441f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Sat, 3 Dec 2022 15:17:43 -0600 Subject: improve type safety of toplevel_from_wlr_surface() --- client.h | 47 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index c12a107..77cde58 100644 --- a/client.h +++ b/client.h @@ -51,29 +51,38 @@ client_surface(Client *c) return c->surface.xdg->surface; } -static inline void * -toplevel_from_wlr_surface(struct wlr_surface *s) +static inline int +toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl) { struct wlr_xdg_surface *xdg_surface; struct wlr_surface *root_surface; struct wlr_layer_surface_v1 *layer_surface; + Client *c = NULL; + LayerSurface *l = NULL; + int type = -1; #ifdef XWAYLAND struct wlr_xwayland_surface *xsurface; #endif if (!s) - return NULL; + return type; root_surface = wlr_surface_get_root_surface(s); #ifdef XWAYLAND if (wlr_surface_is_xwayland_surface(root_surface) - && (xsurface = wlr_xwayland_surface_from_wlr_surface(root_surface))) - return xsurface->data; + && (xsurface = wlr_xwayland_surface_from_wlr_surface(root_surface))) { + c = xsurface->data; + type = c->type; + goto end; + } #endif if (wlr_surface_is_layer_surface(root_surface) - && (layer_surface = wlr_layer_surface_v1_from_wlr_surface(root_surface))) - return layer_surface->data; + && (layer_surface = wlr_layer_surface_v1_from_wlr_surface(root_surface))) { + l = layer_surface->data; + type = LayerShell; + goto end; + } if (wlr_surface_is_xdg_surface(root_surface) && (xdg_surface = wlr_xdg_surface_from_wlr_surface(root_surface))) { @@ -81,21 +90,28 @@ toplevel_from_wlr_surface(struct wlr_surface *s) switch (xdg_surface->role) { case WLR_XDG_SURFACE_ROLE_POPUP: if (!xdg_surface->popup->parent) - return NULL; + return -1; else if (!wlr_surface_is_xdg_surface(xdg_surface->popup->parent)) - return toplevel_from_wlr_surface(xdg_surface->popup->parent); + return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc, pl); xdg_surface = wlr_xdg_surface_from_wlr_surface(xdg_surface->popup->parent); break; case WLR_XDG_SURFACE_ROLE_TOPLEVEL: - return xdg_surface->data; + c = xdg_surface->data; + type = c->type; + goto end; case WLR_XDG_SURFACE_ROLE_NONE: - return NULL; + return -1; } } } - return NULL; +end: + if (pl) + *pl = l; + if (pc) + *pc = c; + return type; } /* The others */ @@ -169,14 +185,15 @@ client_get_geometry(Client *c, struct wlr_box *geom) static inline Client * client_get_parent(Client *c) { + Client *p = NULL; #ifdef XWAYLAND if (client_is_x11(c) && c->surface.xwayland->parent) - return toplevel_from_wlr_surface(c->surface.xwayland->parent->surface); + toplevel_from_wlr_surface(c->surface.xwayland->parent->surface, &p, NULL); #endif if (c->surface.xdg->toplevel->parent) - return toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface); + toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface, &p, NULL); - return NULL; + return p; } static inline const char * -- cgit v1.2.1