From d9cf3e064c0972102921dae2280fff1c5272b435 Mon Sep 17 00:00:00 2001 From: Stivvo Date: Fri, 4 Sep 2020 23:32:29 +0200 Subject: Handle new windows Windows lose fullscreen state when a new window is created in the same tag --- dwl.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/dwl.c b/dwl.c index bdc1e69..c72533a 100644 --- a/dwl.c +++ b/dwl.c @@ -198,11 +198,11 @@ static void createxdeco(struct wl_listener *listener, void *data); static void cursorframe(struct wl_listener *listener, void *data); static void destroynotify(struct wl_listener *listener, void *data); static void destroyxdeco(struct wl_listener *listener, void *data); -static void fullscreenotify(struct wl_listener *listener, void *data); static Monitor *dirtomon(int dir); static void focusclient(Client *old, Client *c, int lift); static void focusmon(const Arg *arg); static void focusstack(const Arg *arg); +static void fullscreenotify(struct wl_listener *listener, void *data); static Client *focustop(Monitor *m); static void getxdecomode(struct wl_listener *listener, void *data); static void incnmaster(const Arg *arg); @@ -217,6 +217,7 @@ static void motionabsolute(struct wl_listener *listener, void *data); static void motionnotify(uint32_t time); static void motionrelative(struct wl_listener *listener, void *data); static void moveresize(const Arg *arg); +static void quitfullscreen(Client *c); static void pointerfocus(Client *c, struct wlr_surface *surface, double sx, double sy, uint32_t time); static void quit(const Arg *arg); @@ -576,6 +577,24 @@ createmon(struct wl_listener *listener, void *data) sgeom = *wlr_output_layout_get_box(output_layout, NULL); } +void +quitfullscreen(Client *c) +{ + wl_list_for_each(c, &clients, link) { + if (c->isfullscreen && VISIBLEON(c, c->mon)) { +#ifdef XWAYLAND + if (c->type == X11Managed) + wlr_xwayland_surface_set_fullscreen(c->surface.xwayland, false); + else +#endif + wlr_xdg_toplevel_set_fullscreen(c->surface.xdg, false); + c->bw = borderpx; + resize(c, c->prevx, c->prevy, c->prevwidth, c->prevheight, 0); + c->isfullscreen = 0; + } + } +} + void createnotify(struct wl_listener *listener, void *data) { @@ -591,6 +610,7 @@ createnotify(struct wl_listener *listener, void *data) c = xdg_surface->data = calloc(1, sizeof(*c)); c->surface.xdg = xdg_surface; c->bw = borderpx; + quitfullscreen(c); /* Tell the client not to try anything fancy */ wlr_xdg_toplevel_set_tiled(c->surface.xdg, WLR_EDGE_TOP | @@ -635,7 +655,6 @@ createxdeco(struct wl_listener *listener, void *data) getxdecomode(&d->request_mode, wlr_deco); } - void cursorframe(struct wl_listener *listener, void *data) { @@ -1846,6 +1865,7 @@ createnotifyx11(struct wl_listener *listener, void *data) c->surface.xwayland = xwayland_surface; c->type = xwayland_surface->override_redirect ? X11Unmanaged : X11Managed; c->bw = borderpx; + quitfullscreen(c); /* Listen to the various events it can emit */ c->map.notify = maprequest; -- cgit v1.2.3