From c3f041e980ca8488a57ff4290eb91d0b2d6ce848 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Thu, 8 Dec 2022 21:10:13 -0600 Subject: [PATCH 1/2] rename Client.resize --- dwl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dwl.c b/dwl.c index 9ee3c76..f4a9074 100644 --- a/dwl.c +++ b/dwl.c @@ -125,7 +125,7 @@ typedef struct { unsigned int bw; unsigned int tags; int isfloating, isurgent, isfullscreen; - uint32_t resize; /* configure serial of a pending resize */ + uint32_t resize_serial; /* configure serial of a pending resize */ } Client; typedef struct { @@ -764,10 +764,10 @@ commitnotify(struct wl_listener *listener, void *data) arrange(c->mon); /* mark a pending resize as completed */ - if (c->resize && (c->resize <= c->surface.xdg->current.configure_serial + if (c->resize_serial && (c->resize_serial <= c->surface.xdg->current.configure_serial || (c->surface.xdg->current.geometry.width == c->surface.xdg->pending.geometry.width && c->surface.xdg->current.geometry.height == c->surface.xdg->pending.geometry.height))) - c->resize = 0; + c->resize_serial = 0; } void @@ -1833,7 +1833,7 @@ rendermon(struct wl_listener *listener, void *data) * this monitor. */ /* Checking m->un_map for every client is not optimal but works */ wl_list_for_each(c, &clients, link) { - if ((c->resize && m->un_map) || (c->type == XDGShell + if ((c->resize_serial && m->un_map) || (c->type == XDGShell && (c->surface.xdg->pending.geometry.width != c->surface.xdg->current.geometry.width || c->surface.xdg->pending.geometry.height != @@ -1882,7 +1882,7 @@ resize(Client *c, struct wlr_box geo, int interact) wlr_scene_node_set_position(&c->border[3]->node, c->geom.width - c->bw, c->bw); /* wlroots makes this a no-op if size hasn't changed */ - c->resize = client_set_size(c, c->geom.width - 2 * c->bw, + c->resize_serial = client_set_size(c, c->geom.width - 2 * c->bw, c->geom.height - 2 * c->bw); } From b419e38006aff05d5c7f6f1abb3b2bc7db669673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Hern=C3=A1ndez=20Hern=C3=A1ndez?= Date: Thu, 8 Dec 2022 21:16:15 -0600 Subject: [PATCH 2/2] disallow clients to resize themselves Closes: https://github.com/djpohly/dwl/issues/337 --- dwl.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dwl.c b/dwl.c index f4a9074..ff99d35 100644 --- a/dwl.c +++ b/dwl.c @@ -114,6 +114,7 @@ typedef struct { struct wl_listener maximize; struct wl_listener unmap; struct wl_listener destroy; + struct wl_listener resize; struct wl_listener set_title; struct wl_listener fullscreen; struct wlr_box prev; /* layout-relative, includes border */ @@ -279,6 +280,7 @@ static void quitsignal(int signo); static void rendermon(struct wl_listener *listener, void *data); static void requeststartdrag(struct wl_listener *listener, void *data); static void resize(Client *c, struct wlr_box geo, int interact); +static void resizenotify(struct wl_listener *listener, void *data); static void run(char *startup_cmd); static Client *selclient(void); static void setcursor(struct wl_listener *listener, void *data); @@ -984,6 +986,7 @@ createnotify(struct wl_listener *listener, void *data) c->bw = borderpx; LISTEN(&xdg_surface->events.map, &c->map, mapnotify); + LISTEN(&xdg_surface->toplevel->events.request_resize, &c->resize, resizenotify); LISTEN(&xdg_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); @@ -1131,6 +1134,7 @@ destroynotify(struct wl_listener *listener, void *data) wl_list_remove(&c->map.link); wl_list_remove(&c->unmap.link); wl_list_remove(&c->destroy.link); + wl_list_remove(&c->resize.link); wl_list_remove(&c->set_title.link); wl_list_remove(&c->fullscreen.link); #ifdef XWAYLAND @@ -1886,6 +1890,13 @@ resize(Client *c, struct wlr_box geo, int interact) c->geom.height - 2 * c->bw); } +void +resizenotify(struct wl_listener *listener, void *data) +{ + Client *c = wl_container_of(listener, c, resize); + resize(c, c->geom, 0); +} + void run(char *startup_cmd) { @@ -2679,6 +2690,7 @@ createnotifyx11(struct wl_listener *listener, void *data) LISTEN(&xsurface->events.unmap, &c->unmap, unmapnotify); LISTEN(&xsurface->events.request_activate, &c->activate, activatex11); LISTEN(&xsurface->events.request_configure, &c->configure, configurex11); + LISTEN(&xsurface->events.request_resize, &c->resize, resizenotify); LISTEN(&xsurface->events.set_hints, &c->set_hints, sethints); LISTEN(&xsurface->events.set_title, &c->set_title, updatetitle); LISTEN(&xsurface->events.destroy, &c->destroy, destroynotify);