From 7ae5039b4f35c6f5fd09f2d650c62dc7304ce6fe Mon Sep 17 00:00:00 2001 From: Job79 Date: Wed, 1 Feb 2023 20:09:45 +0100 Subject: follow upstream xwayland_surface changes wlroots removed the `wlr_surface_is_xwayland_surface` function, and renamed `wlr_xwayland_surface_from_wlr_surface` to `wlr_xwayland_surface_try_from_wlr_surface`. related commit: https://gitlab.freedesktop.org/wlroots/wlroots/-/commit/fbf5982e3838ee28b5345e98832f6956c402b225 --- client.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index 5a45edc..558dd03 100644 --- a/client.h +++ b/client.h @@ -69,8 +69,7 @@ toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl) 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))) { + if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(root_surface))) { c = xsurface->data; type = c->type; goto end; @@ -121,8 +120,7 @@ client_activate_surface(struct wlr_surface *s, int activated) struct wlr_xdg_surface *surface; #ifdef XWAYLAND struct wlr_xwayland_surface *xsurface; - if (wlr_surface_is_xwayland_surface(s) - && (xsurface = wlr_xwayland_surface_from_wlr_surface(s))) { + if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(s))) { wlr_xwayland_surface_activate(xsurface, activated); return; } -- cgit v1.2.3 From e7f736ccc9435138d9921ba1f3ba5ebed142523b Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Thu, 2 Feb 2023 10:30:24 -0600 Subject: chase wlroots!3391 References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3991 --- client.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index 558dd03..5fe31b1 100644 --- a/client.h +++ b/client.h @@ -76,24 +76,22 @@ toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl) } #endif - if (wlr_surface_is_layer_surface(root_surface) - && (layer_surface = wlr_layer_surface_v1_from_wlr_surface(root_surface))) { + if ((layer_surface = wlr_layer_surface_v1_try_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))) { + if ((xdg_surface = wlr_xdg_surface_try_from_wlr_surface(root_surface))) { while (1) { switch (xdg_surface->role) { case WLR_XDG_SURFACE_ROLE_POPUP: if (!xdg_surface->popup->parent) return -1; - else if (!wlr_surface_is_xdg_surface(xdg_surface->popup->parent)) + else if (!wlr_xdg_surface_try_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); + xdg_surface = wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent); break; case WLR_XDG_SURFACE_ROLE_TOPLEVEL: c = xdg_surface->data; @@ -125,8 +123,7 @@ client_activate_surface(struct wlr_surface *s, int activated) return; } #endif - if (wlr_surface_is_xdg_surface(s) - && (surface = wlr_xdg_surface_from_wlr_surface(s)) + if ((surface = wlr_xdg_surface_try_from_wlr_surface(s)) && surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) wlr_xdg_toplevel_set_activated(surface->toplevel, activated); } -- cgit v1.2.3 From 06bc65549f42bcfa2f0b119149eacb7e5adc9073 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Fri, 2 Jun 2023 21:34:22 -0600 Subject: chase wlroots map logic unification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Leonardo Hernández Hernández --- client.h | 10 ---------- dwl.c | 53 +++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 39 insertions(+), 24 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index 5fe31b1..ef56ee6 100644 --- a/client.h +++ b/client.h @@ -225,16 +225,6 @@ client_is_float_type(Client *c) && (min.width == max.width || min.height == max.height)); } -static inline int -client_is_mapped(Client *c) -{ -#ifdef XWAYLAND - if (client_is_x11(c)) - return c->surface.xwayland->mapped; -#endif - return c->surface.xdg->mapped; -} - static inline int client_is_rendered_on_mon(Client *c, Monitor *m) { diff --git a/dwl.c b/dwl.c index fd93ec5..c28ce42 100644 --- a/dwl.c +++ b/dwl.c @@ -122,6 +122,8 @@ typedef struct { struct wlr_box prev; /* layout-relative, includes border */ #ifdef XWAYLAND struct wl_listener activate; + struct wl_listener associate; + struct wl_listener dissociate; struct wl_listener configure; struct wl_listener set_hints; #endif @@ -399,8 +401,10 @@ static struct wl_listener session_lock_mgr_destroy = {.notify = destroysessionmg #ifdef XWAYLAND static void activatex11(struct wl_listener *listener, void *data); +static void associatex11(struct wl_listener *listener, void *data); static void configurex11(struct wl_listener *listener, void *data); static void createnotifyx11(struct wl_listener *listener, void *data); +static void dissociatex11(struct wl_listener *listener, void *data); static Atom getatom(xcb_connection_t *xc, const char *name); static void sethints(struct wl_listener *listener, void *data); static void sigchld(int unused); @@ -762,9 +766,9 @@ commitlayersurfacenotify(struct wl_listener *listener, void *data) wlr_scene_node_reparent(&layersurface->popups->node, layers[LyrTop]); if (wlr_layer_surface->current.committed == 0 - && layersurface->mapped == wlr_layer_surface->mapped) + && layersurface->mapped == wlr_layer_surface->surface->mapped) return; - layersurface->mapped = wlr_layer_surface->mapped; + layersurface->mapped = wlr_layer_surface->surface->mapped; arrangelayers(layersurface->mon); } @@ -854,9 +858,9 @@ createlayersurface(struct wl_listener *listener, void *data) &layersurface->surface_commit, commitlayersurfacenotify); LISTEN(&wlr_layer_surface->events.destroy, &layersurface->destroy, destroylayersurfacenotify); - LISTEN(&wlr_layer_surface->events.map, &layersurface->map, + LISTEN(&wlr_layer_surface->surface->events.map, &layersurface->map, maplayersurfacenotify); - LISTEN(&wlr_layer_surface->events.unmap, &layersurface->unmap, + LISTEN(&wlr_layer_surface->surface->events.unmap, &layersurface->unmap, unmaplayersurfacenotify); layersurface->layer_surface = wlr_layer_surface; @@ -1017,8 +1021,8 @@ createnotify(struct wl_listener *listener, void *data) c->surface.xdg = xdg_surface; c->bw = borderpx; - LISTEN(&xdg_surface->events.map, &c->map, mapnotify); - LISTEN(&xdg_surface->events.unmap, &c->unmap, unmapnotify); + LISTEN(&xdg_surface->surface->events.map, &c->map, mapnotify); + LISTEN(&xdg_surface->surface->events.unmap, &c->unmap, unmapnotify); LISTEN(&xdg_surface->events.destroy, &c->destroy, destroynotify); LISTEN(&xdg_surface->toplevel->events.set_title, &c->set_title, updatetitle); LISTEN(&xdg_surface->toplevel->events.request_fullscreen, &c->fullscreen, @@ -1055,7 +1059,7 @@ createpointer(struct wlr_pointer *pointer) if (libinput_device_config_scroll_get_methods(libinput_device) != LIBINPUT_CONFIG_SCROLL_NO_SCROLL) libinput_device_config_scroll_set_method (libinput_device, scroll_method); - + if (libinput_device_config_click_get_methods(libinput_device) != LIBINPUT_CONFIG_CLICK_METHOD_NONE) libinput_device_config_click_set_method (libinput_device, click_method); @@ -1160,18 +1164,22 @@ destroynotify(struct wl_listener *listener, void *data) { /* Called when the surface is destroyed and should never be shown again. */ Client *c = wl_container_of(listener, c, destroy); - wl_list_remove(&c->map.link); - wl_list_remove(&c->unmap.link); wl_list_remove(&c->destroy.link); wl_list_remove(&c->set_title.link); wl_list_remove(&c->fullscreen.link); #ifdef XWAYLAND if (c->type != XDGShell) { + wl_list_remove(&c->activate.link); + wl_list_remove(&c->associate.link); wl_list_remove(&c->configure.link); + wl_list_remove(&c->dissociate.link); wl_list_remove(&c->set_hints.link); - wl_list_remove(&c->activate.link); - } + } else #endif + { + wl_list_remove(&c->map.link); + wl_list_remove(&c->unmap.link); + } free(c); } @@ -2597,7 +2605,7 @@ updatemons(struct wl_listener *listener, void *data) if (selmon && selmon->wlr_output->enabled) { wl_list_for_each(c, &clients, link) - if (!c->mon && client_is_mapped(c)) + if (!c->mon && client_surface(c)->mapped) setmon(c, selmon, c->tags); focusclient(focustop(selmon), 1); if (selmon->lock_surface) { @@ -2734,6 +2742,15 @@ activatex11(struct wl_listener *listener, void *data) wlr_xwayland_surface_activate(c->surface.xwayland, 1); } +void +associatex11(struct wl_listener *listener, void *data) +{ + Client *c = wl_container_of(listener, c, associate); + + LISTEN(&client_surface(c)->events.map, &c->map, mapnotify); + LISTEN(&client_surface(c)->events.unmap, &c->unmap, unmapnotify); +} + void configurex11(struct wl_listener *listener, void *data) { @@ -2761,8 +2778,8 @@ createnotifyx11(struct wl_listener *listener, void *data) c->bw = borderpx; /* Listen to the various events it can emit */ - LISTEN(&xsurface->events.map, &c->map, mapnotify); - LISTEN(&xsurface->events.unmap, &c->unmap, unmapnotify); + LISTEN(&xsurface->events.associate, &c->associate, associatex11); + LISTEN(&xsurface->events.dissociate, &c->dissociate, dissociatex11); LISTEN(&xsurface->events.request_activate, &c->activate, activatex11); LISTEN(&xsurface->events.request_configure, &c->configure, configurex11); LISTEN(&xsurface->events.set_hints, &c->set_hints, sethints); @@ -2771,6 +2788,14 @@ createnotifyx11(struct wl_listener *listener, void *data) LISTEN(&xsurface->events.request_fullscreen, &c->fullscreen, fullscreennotify); } +void +dissociatex11(struct wl_listener *listener, void *data) +{ + Client *c = wl_container_of(listener, c, dissociate); + wl_list_remove(&c->map.link); + wl_list_remove(&c->unmap.link); +} + Atom getatom(xcb_connection_t *xc, const char *name) { -- cgit v1.2.3 From 78cf88670f3410782f5c90895c3c4586d3485a67 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Sun, 23 Jul 2023 20:59:29 -0600 Subject: add support for xdg-shell v6 --- client.h | 11 +++++++++++ dwl.c | 9 ++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index ef56ee6..fc999f1 100644 --- a/client.h +++ b/client.h @@ -346,6 +346,17 @@ client_set_tiled(Client *c, uint32_t edges) wlr_xdg_toplevel_set_tiled(c->surface.xdg->toplevel, edges); } +static inline void +client_set_suspended(Client *c, int suspended) +{ +#ifdef XWAYLAND + if (client_is_x11(c)) + return; +#endif + + wlr_xdg_toplevel_set_suspended(c->surface.xdg->toplevel, suspended); +} + static inline struct wlr_surface * client_surface_at(Client *c, double cx, double cy, double *sx, double *sy) { diff --git a/dwl.c b/dwl.c index 436d082..91abe11 100644 --- a/dwl.c +++ b/dwl.c @@ -457,9 +457,12 @@ void arrange(Monitor *m) { Client *c; - wl_list_for_each(c, &clients, link) - if (c->mon == m) + wl_list_for_each(c, &clients, link) { + if (c->mon == m) { wlr_scene_node_set_enabled(&c->scene->node, VISIBLEON(c, m)); + client_set_suspended(c, !VISIBLEON(c, m)); + } + } wlr_scene_node_set_enabled(&m->fullscreen_bg->node, (c = focustop(m)) && c->isfullscreen); @@ -2257,7 +2260,7 @@ setup(void) layer_shell = wlr_layer_shell_v1_create(dpy, 3); LISTEN_STATIC(&layer_shell->events.new_surface, createlayersurface); - xdg_shell = wlr_xdg_shell_create(dpy, 5); + xdg_shell = wlr_xdg_shell_create(dpy, 6); LISTEN_STATIC(&xdg_shell->events.new_surface, createnotify); session_lock_mgr = wlr_session_lock_manager_v1_create(dpy); -- cgit v1.2.3 From 25db04539216fa6bf05ad39cdeeeca6df6b69e60 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Tue, 25 Jul 2023 19:45:18 -0600 Subject: set withdrawn state for xwayland invisible clients --- client.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'client.h') diff --git a/client.h b/client.h index fc999f1..6a46151 100644 --- a/client.h +++ b/client.h @@ -350,8 +350,10 @@ static inline void client_set_suspended(Client *c, int suspended) { #ifdef XWAYLAND - if (client_is_x11(c)) + if (client_is_x11(c)) { + wlr_xwayland_surface_set_withdrawn(c->surface.xwayland, suspended); return; + } #endif wlr_xdg_toplevel_set_suspended(c->surface.xdg->toplevel, suspended); -- cgit v1.2.3 From d4f2c6bfd638d45736512691f06081cf314370bd Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Mon, 21 Aug 2023 17:53:24 -0600 Subject: chase wlroots!4288 References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4288 --- client.h | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index 6a46151..80152cc 100644 --- a/client.h +++ b/client.h @@ -54,7 +54,7 @@ client_surface(Client *c) static inline int toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl) { - struct wlr_xdg_surface *xdg_surface; + struct wlr_xdg_surface *xdg_surface, *tmp_xdg_surface; struct wlr_surface *root_surface; struct wlr_layer_surface_v1 *layer_surface; Client *c = NULL; @@ -82,24 +82,27 @@ toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl) goto end; } - if ((xdg_surface = wlr_xdg_surface_try_from_wlr_surface(root_surface))) { - while (1) { - switch (xdg_surface->role) { - case WLR_XDG_SURFACE_ROLE_POPUP: - if (!xdg_surface->popup->parent) - return -1; - else if (!wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent)) - return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc, pl); - - xdg_surface = wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent); - break; - case WLR_XDG_SURFACE_ROLE_TOPLEVEL: - c = xdg_surface->data; - type = c->type; - goto end; - case WLR_XDG_SURFACE_ROLE_NONE: + xdg_surface = wlr_xdg_surface_try_from_wlr_surface(root_surface); + while (xdg_surface) { + tmp_xdg_surface = NULL; + switch (xdg_surface->role) { + case WLR_XDG_SURFACE_ROLE_POPUP: + if (!xdg_surface->popup || !xdg_surface->popup->parent) return -1; - } + + tmp_xdg_surface = wlr_xdg_surface_try_from_wlr_surface(xdg_surface->popup->parent); + + if (!tmp_xdg_surface) + return toplevel_from_wlr_surface(xdg_surface->popup->parent, pc, pl); + + xdg_surface = tmp_xdg_surface; + break; + case WLR_XDG_SURFACE_ROLE_TOPLEVEL: + c = xdg_surface->data; + type = c->type; + goto end; + case WLR_XDG_SURFACE_ROLE_NONE: + return -1; } } -- cgit v1.2.3 From e5e74acfce05502181a0eaa6e252140e1572d925 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Wed, 1 Nov 2023 12:04:59 -0600 Subject: send maximized if tiled isn't supported (XDG shell) wlroots doesn't do it automatically anymore References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4409 --- client.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'client.h') diff --git a/client.h b/client.h index 6fc7c93..b49032e 100644 --- a/client.h +++ b/client.h @@ -354,7 +354,12 @@ client_set_tiled(Client *c, uint32_t edges) if (client_is_x11(c)) return; #endif - wlr_xdg_toplevel_set_tiled(c->surface.xdg->toplevel, edges); + if (wl_resource_get_version(c->surface.xdg->resource) + >= XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) { + wlr_xdg_toplevel_set_tiled(c->surface.xdg->toplevel, edges); + } else { + wlr_xdg_toplevel_set_maximized(c->surface.xdg->toplevel, edges != 0); + } } static inline void -- cgit v1.2.3 From 31bf1cbaf6418a6fb39e41b21cadc5c20826a663 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Sat, 8 Jul 2023 20:07:27 -0600 Subject: Revert "respect size hints" This reverts commit 72e0a560d9836c5e8658003f548203bcd722e565. --- client.h | 53 +++++++++++++++++++---------------------------------- dwl.c | 16 +++------------- 2 files changed, 22 insertions(+), 47 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index b49032e..6a870b4 100644 --- a/client.h +++ b/client.h @@ -16,31 +16,6 @@ client_is_x11(Client *c) #endif } -static inline void -client_get_size_hints(Client *c, struct wlr_box *max, struct wlr_box *min) -{ - struct wlr_xdg_toplevel *toplevel; - struct wlr_xdg_toplevel_state *state; -#ifdef XWAYLAND - if (client_is_x11(c)) { - xcb_size_hints_t *size_hints = c->surface.xwayland->size_hints; - if (size_hints) { - max->width = size_hints->max_width; - max->height = size_hints->max_height; - min->width = size_hints->min_width; - min->height = size_hints->min_height; - } - return; - } -#endif - toplevel = c->surface.xdg->toplevel; - state = &toplevel->current; - max->width = state->max_width; - max->height = state->max_height; - min->width = state->min_width; - min->height = state->min_height; -} - static inline struct wlr_surface * client_surface(Client *c) { @@ -190,7 +165,6 @@ client_get_parent(Client *c) #endif if (c->surface.xdg->toplevel->parent) toplevel_from_wlr_surface(c->surface.xdg->toplevel->parent->base->surface, &p, NULL); - return p; } @@ -207,25 +181,36 @@ client_get_title(Client *c) static inline int client_is_float_type(Client *c) { - struct wlr_box min = {0}, max = {0}; - client_get_size_hints(c, &max, &min); + struct wlr_xdg_toplevel *toplevel; + struct wlr_xdg_toplevel_state state; #ifdef XWAYLAND if (client_is_x11(c)) { struct wlr_xwayland_surface *surface = c->surface.xwayland; + xcb_size_hints_t *size_hints; if (surface->modal) return 1; for (size_t i = 0; i < surface->window_type_len; i++) - if (surface->window_type[i] == netatom[NetWMWindowTypeDialog] - || surface->window_type[i] == netatom[NetWMWindowTypeSplash] - || surface->window_type[i] == netatom[NetWMWindowTypeToolbar] - || surface->window_type[i] == netatom[NetWMWindowTypeUtility]) + if (surface->window_type[i] == netatom[NetWMWindowTypeDialog] || + surface->window_type[i] == netatom[NetWMWindowTypeSplash] || + surface->window_type[i] == netatom[NetWMWindowTypeToolbar] || + surface->window_type[i] == netatom[NetWMWindowTypeUtility]) return 1; + + size_hints = surface->size_hints; + return size_hints && size_hints->min_width > 0 && size_hints->min_height > 0 + && (size_hints->max_width == size_hints->min_width + || size_hints->max_height == size_hints->min_height); } #endif - return ((min.width > 0 || min.height > 0 || max.width > 0 || max.height > 0) - && (min.width == max.width || min.height == max.height)); + + toplevel = c->surface.xdg->toplevel; + state = toplevel->current; + return (state.min_width != 0 && state.min_height != 0 + && (state.min_width == state.max_width + || state.min_height == state.max_height)) + || toplevel->parent; } static inline int diff --git a/dwl.c b/dwl.c index 5d3c63d..b379305 100644 --- a/dwl.c +++ b/dwl.c @@ -399,19 +399,9 @@ static xcb_atom_t netatom[NetLast]; void applybounds(Client *c, struct wlr_box *bbox) { - if (!c->isfullscreen) { - struct wlr_box min = {0}, max = {0}; - client_get_size_hints(c, &max, &min); - /* try to set size hints */ - c->geom.width = MAX(min.width + (2 * (int)c->bw), c->geom.width); - c->geom.height = MAX(min.height + (2 * (int)c->bw), c->geom.height); - /* Some clients set their max size to INT_MAX, which does not violate the - * protocol but it's unnecesary, as they can set their max size to zero. */ - if (max.width > 0 && !(2 * c->bw > INT_MAX - max.width)) /* Checks for overflow */ - c->geom.width = MIN(max.width + (2 * c->bw), c->geom.width); - if (max.height > 0 && !(2 * c->bw > INT_MAX - max.height)) /* Checks for overflow */ - c->geom.height = MIN(max.height + (2 * c->bw), c->geom.height); - } + /* set minimum possible */ + c->geom.width = MAX(1, c->geom.width); + c->geom.height = MAX(1, c->geom.height); if (c->geom.x >= bbox->x + bbox->width) c->geom.x = bbox->x + bbox->width - c->geom.width; -- cgit v1.2.3 From e1f3983bf8a548f0357a92d9023c90aa4c273f64 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Sat, 8 Jul 2023 20:08:45 -0600 Subject: use wlr_scene_subsurface_tree_set_clip References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4131 Closes: https://github.com/djpohly/dwl/issues/411 --- client.h | 22 ++++++++++++++++++++++ dwl.c | 3 +++ 2 files changed, 25 insertions(+) (limited to 'client.h') diff --git a/client.h b/client.h index 6a870b4..012ba74 100644 --- a/client.h +++ b/client.h @@ -140,6 +140,28 @@ client_get_appid(Client *c) return c->surface.xdg->toplevel->app_id; } +static inline void +client_get_clip(Client *c, struct wlr_box *clip) +{ +#ifdef XWAYLAND + if (client_is_x11(c)) { + *clip = (struct wlr_box){ + .x = 0, + .y = 0, + .width = c->geom.width - c->bw, + .height = c->geom.height - c->bw}; + return; + } +#endif + + *clip = (struct wlr_box){ + .x = c->surface.xdg->pending.geometry.x, + .y = c->surface.xdg->pending.geometry.y, + .width = c->geom.width - c->bw, + .height = c->geom.height - c->bw}; + +} + static inline void client_get_geometry(Client *c, struct wlr_box *geom) { diff --git a/dwl.c b/dwl.c index b379305..00d22e8 100644 --- a/dwl.c +++ b/dwl.c @@ -1909,6 +1909,7 @@ void resize(Client *c, struct wlr_box geo, int interact) { struct wlr_box *bbox = interact ? &sgeom : &c->mon->w; + struct wlr_box clip; client_set_bounds(c, geo.width, geo.height); c->geom = geo; applybounds(c, bbox); @@ -1927,6 +1928,8 @@ resize(Client *c, struct wlr_box geo, int interact) /* this is a no-op if size hasn't changed */ c->resize = client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw); + client_get_clip(c, &clip); + wlr_scene_subsurface_tree_set_clip(&c->scene_surface->node, &clip); } void -- cgit v1.2.3 From 6d0ec595d3f3ba6977ea117681861713fbc1de5f Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Thu, 16 Nov 2023 21:12:50 -0600 Subject: simplify client_get_clip the clips for xwayland and xdg clients are pretty similar, after all we only need to adjust x and y for xdg clients --- client.h | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index 012ba74..2ffb92c 100644 --- a/client.h +++ b/client.h @@ -143,23 +143,22 @@ client_get_appid(Client *c) static inline void client_get_clip(Client *c, struct wlr_box *clip) { + struct wlr_box xdg_geom = {0}; + *clip = (struct wlr_box){ + .x = 0, + .y = 0, + .width = c->geom.width - c->bw, + .height = c->geom.height - c->bw, + }; + #ifdef XWAYLAND - if (client_is_x11(c)) { - *clip = (struct wlr_box){ - .x = 0, - .y = 0, - .width = c->geom.width - c->bw, - .height = c->geom.height - c->bw}; + if (client_is_x11(c)) return; - } #endif - *clip = (struct wlr_box){ - .x = c->surface.xdg->pending.geometry.x, - .y = c->surface.xdg->pending.geometry.y, - .width = c->geom.width - c->bw, - .height = c->geom.height - c->bw}; - + wlr_xdg_surface_get_geometry(c->surface.xdg, &xdg_geom); + clip->x = xdg_geom.x; + clip->y = xdg_geom.y; } static inline void -- cgit v1.2.3 From 0e897608a151da10f4ddcd2a528c618e5f60d9cd Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Thu, 16 Nov 2023 21:17:39 -0600 Subject: do not use magical numbers to check edges the interface is declared stable, which means we could just use 0 anyway --- client.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client.h') diff --git a/client.h b/client.h index 2ffb92c..0fdd774 100644 --- a/client.h +++ b/client.h @@ -364,7 +364,7 @@ client_set_tiled(Client *c, uint32_t edges) >= XDG_TOPLEVEL_STATE_TILED_RIGHT_SINCE_VERSION) { wlr_xdg_toplevel_set_tiled(c->surface.xdg->toplevel, edges); } else { - wlr_xdg_toplevel_set_maximized(c->surface.xdg->toplevel, edges != 0); + wlr_xdg_toplevel_set_maximized(c->surface.xdg->toplevel, edges != WLR_EDGE_NONE); } } -- cgit v1.2.3 From d6c102d9db2a2f3dc9d1da96d87e306129237a8e Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Thu, 16 Nov 2023 21:21:40 -0600 Subject: correctly check if the scene node is enabled in client_is_rendered_on_mon --- client.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'client.h') diff --git a/client.h b/client.h index 0fdd774..a5bec71 100644 --- a/client.h +++ b/client.h @@ -241,7 +241,8 @@ client_is_rendered_on_mon(Client *c, Monitor *m) * but rather actual displaying of the pixels. * Usually VISIBLEON suffices and is also faster. */ struct wlr_surface_output *s; - if (!c->scene->node.enabled) + int unused_lx, unused_ly; + if (!wlr_scene_node_coords(&c->scene->node, &unused_lx, &unused_ly)) return 0; wl_list_for_each(s, &client_surface(c)->current_outputs, link) if (s->output == m->wlr_output) -- cgit v1.2.3 From 22d21676b016a03fe3f2d988618d0c2acca48de5 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Thu, 16 Nov 2023 21:27:49 -0600 Subject: style fixes in client_is_float_type --- client.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index a5bec71..7d9ff8c 100644 --- a/client.h +++ b/client.h @@ -208,18 +208,18 @@ client_is_float_type(Client *c) #ifdef XWAYLAND if (client_is_x11(c)) { struct wlr_xwayland_surface *surface = c->surface.xwayland; - xcb_size_hints_t *size_hints; + xcb_size_hints_t *size_hints = surface->size_hints; + size_t i; if (surface->modal) return 1; - for (size_t i = 0; i < surface->window_type_len; i++) - if (surface->window_type[i] == netatom[NetWMWindowTypeDialog] || - surface->window_type[i] == netatom[NetWMWindowTypeSplash] || - surface->window_type[i] == netatom[NetWMWindowTypeToolbar] || - surface->window_type[i] == netatom[NetWMWindowTypeUtility]) + for (i = 0; i < surface->window_type_len; i++) + if (surface->window_type[i] == netatom[NetWMWindowTypeDialog] + || surface->window_type[i] == netatom[NetWMWindowTypeSplash] + || surface->window_type[i] == netatom[NetWMWindowTypeToolbar] + || surface->window_type[i] == netatom[NetWMWindowTypeUtility]) return 1; - size_hints = surface->size_hints; return size_hints && size_hints->min_width > 0 && size_hints->min_height > 0 && (size_hints->max_width == size_hints->min_width || size_hints->max_height == size_hints->min_height); @@ -228,10 +228,9 @@ client_is_float_type(Client *c) toplevel = c->surface.xdg->toplevel; state = toplevel->current; - return (state.min_width != 0 && state.min_height != 0 + return toplevel->parent || (state.min_width != 0 && state.min_height != 0 && (state.min_width == state.max_width - || state.min_height == state.max_height)) - || toplevel->parent; + || state.min_height == state.max_height)); } static inline int -- cgit v1.2.3 From 0067c76caba464c0636183a8318fee6d63cd2b35 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Thu, 16 Nov 2023 21:43:31 -0600 Subject: delete unused functions --- client.h | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index 7d9ff8c..186c23d 100644 --- a/client.h +++ b/client.h @@ -119,17 +119,6 @@ client_set_bounds(Client *c, int32_t width, int32_t height) return 0; } -static inline void -client_for_each_surface(Client *c, wlr_surface_iterator_func_t fn, void *data) -{ - wlr_surface_for_each_surface(client_surface(c), fn, data); -#ifdef XWAYLAND - if (client_is_x11(c)) - return; -#endif - wlr_xdg_surface_for_each_popup_surface(c->surface.xdg, fn, data); -} - static inline const char * client_get_appid(Client *c) { @@ -381,17 +370,6 @@ client_set_suspended(Client *c, int suspended) wlr_xdg_toplevel_set_suspended(c->surface.xdg->toplevel, suspended); } -static inline struct wlr_surface * -client_surface_at(Client *c, double cx, double cy, double *sx, double *sy) -{ -#ifdef XWAYLAND - if (client_is_x11(c)) - return wlr_surface_surface_at(c->surface.xwayland->surface, - cx, cy, sx, sy); -#endif - return wlr_xdg_surface_surface_at(c->surface.xdg, cx, cy, sx, sy); -} - static inline int client_wants_focus(Client *c) { -- cgit v1.2.3 From b1740056d5e9f81888fc9cb3e016bdb8eff054c1 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Thu, 16 Nov 2023 21:45:08 -0600 Subject: do not use #ifdef -> #else -> #endif in client_is_x11 all other funcions use #ifdef -> #endif --- client.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index 186c23d..efb3e0d 100644 --- a/client.h +++ b/client.h @@ -11,9 +11,8 @@ client_is_x11(Client *c) { #ifdef XWAYLAND return c->type == X11Managed || c->type == X11Unmanaged; -#else - return 0; #endif + return 0; } static inline struct wlr_surface * -- cgit v1.2.3 From caac2d664db998beddeeececd7253a11a665c162 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Thu, 16 Nov 2023 21:46:46 -0600 Subject: explicitly return -1 in the first check in toplevel_from_wlr_surface --- client.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client.h') diff --git a/client.h b/client.h index efb3e0d..9a9f0e0 100644 --- a/client.h +++ b/client.h @@ -39,7 +39,7 @@ toplevel_from_wlr_surface(struct wlr_surface *s, Client **pc, LayerSurface **pl) #endif if (!s) - return type; + return -1; root_surface = wlr_surface_get_root_surface(s); #ifdef XWAYLAND -- cgit v1.2.3 From dd25cdb56e00586281b6d8e79f3af91db2f747ee Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Thu, 16 Nov 2023 21:47:29 -0600 Subject: use the new wlroots function to get a toplevel from a wlr_surface References: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4419 --- client.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'client.h') diff --git a/client.h b/client.h index 9a9f0e0..7a77df0 100644 --- a/client.h +++ b/client.h @@ -92,7 +92,7 @@ end: static inline void client_activate_surface(struct wlr_surface *s, int activated) { - struct wlr_xdg_surface *surface; + struct wlr_xdg_toplevel *toplevel; #ifdef XWAYLAND struct wlr_xwayland_surface *xsurface; if ((xsurface = wlr_xwayland_surface_try_from_wlr_surface(s))) { @@ -100,9 +100,8 @@ client_activate_surface(struct wlr_surface *s, int activated) return; } #endif - if ((surface = wlr_xdg_surface_try_from_wlr_surface(s)) - && surface->role == WLR_XDG_SURFACE_ROLE_TOPLEVEL) - wlr_xdg_toplevel_set_activated(surface->toplevel, activated); + if ((toplevel = wlr_xdg_toplevel_try_from_wlr_surface(s))) + wlr_xdg_toplevel_set_activated(toplevel, activated); } static inline uint32_t -- cgit v1.2.3 From 7bdbab04000c23638afeb8dbeddd628c4f15117c Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Thu, 16 Nov 2023 21:48:56 -0600 Subject: check toplevel resource instead of client's xdg_shell to set bounds --- client.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'client.h') diff --git a/client.h b/client.h index 7a77df0..b0f2900 100644 --- a/client.h +++ b/client.h @@ -111,7 +111,7 @@ client_set_bounds(Client *c, int32_t width, int32_t height) if (client_is_x11(c)) return 0; #endif - if (c->surface.xdg->client->shell->version >= + if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >= XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION && width >= 0 && height >= 0) return wlr_xdg_toplevel_set_bounds(c->surface.xdg->toplevel, width, height); return 0; -- cgit v1.2.3 From a0e79d81452049aaad2d3081d9c689fb9f4253a8 Mon Sep 17 00:00:00 2001 From: Leonardo Hernández Hernández Date: Tue, 21 Nov 2023 20:08:20 -0600 Subject: Do not send repeated xdg_toplevel.configure_bounds Fixes: 32e66f45827cc8016ca2cef65ba61840f43fcc85 --- client.h | 6 +++++- dwl.c | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'client.h') diff --git a/client.h b/client.h index b0f2900..71c7d76 100644 --- a/client.h +++ b/client.h @@ -112,8 +112,12 @@ client_set_bounds(Client *c, int32_t width, int32_t height) return 0; #endif if (wl_resource_get_version(c->surface.xdg->toplevel->resource) >= - XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION && width >= 0 && height >= 0) + XDG_TOPLEVEL_CONFIGURE_BOUNDS_SINCE_VERSION && width >= 0 && height >= 0 + && (c->bounds.width != width || c->bounds.height != height)) { + c->bounds.width = width; + c->bounds.height = height; return wlr_xdg_toplevel_set_bounds(c->surface.xdg->toplevel, width, height); + } return 0; } diff --git a/dwl.c b/dwl.c index 517062a..9e870cc 100644 --- a/dwl.c +++ b/dwl.c @@ -118,6 +118,7 @@ typedef struct { struct wl_listener set_title; struct wl_listener fullscreen; struct wlr_box prev; /* layout-relative, includes border */ + struct wlr_box bounds; #ifdef XWAYLAND struct wl_listener activate; struct wl_listener associate; -- cgit v1.2.3