From 38ba6d2277cb521c1366c99f4845659e7b5ba451 Mon Sep 17 00:00:00 2001 From: Stivvo Date: Thu, 25 Mar 2021 10:05:12 -0500 Subject: Fullscreen: simplifications and fixes Merges #69. --- dwl.c | 44 ++++++++------------------------------------ 1 file changed, 8 insertions(+), 36 deletions(-) diff --git a/dwl.c b/dwl.c index e807330..ead6ec2 100644 --- a/dwl.c +++ b/dwl.c @@ -175,7 +175,6 @@ struct Monitor { unsigned int tagset[2]; double mfact; int nmaster; - Client *fullscreenclient; }; typedef struct { @@ -249,7 +248,6 @@ static void keypressmod(struct wl_listener *listener, void *data); static void killclient(const Arg *arg); static void maplayersurfacenotify(struct wl_listener *listener, void *data); static void mapnotify(struct wl_listener *listener, void *data); -static void maximizeclient(Client *c); static void monocle(Monitor *m); static void motionabsolute(struct wl_listener *listener, void *data); static void motionnotify(uint32_t time); @@ -485,8 +483,6 @@ arrange(Monitor *m) { if (m->lt[m->sellt]->arrange) m->lt[m->sellt]->arrange(m); - else if (m->fullscreenclient) - maximizeclient(m->fullscreenclient); /* TODO recheck pointer focus here... or in resize()? */ } @@ -885,9 +881,6 @@ createnotify(struct wl_listener *listener, void *data) if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) return; - wl_list_for_each(c, &clients, link) - if (c->isfullscreen && VISIBLEON(c, c->mon)) - setfullscreen(c, 0); /* Allocate a Client for this surface */ c = xdg_surface->data = calloc(1, sizeof(*c)); @@ -1042,14 +1035,8 @@ void togglefullscreen(const Arg *arg) { Client *sel = selclient(); - setfullscreen(sel, !sel->isfullscreen); -} - -void -maximizeclient(Client *c) -{ - resize(c, c->mon->m.x, c->mon->m.y, c->mon->m.width, c->mon->m.height, 0); - /* used for fullscreen clients */ + if (sel) + setfullscreen(sel, !sel->isfullscreen); } void @@ -1064,13 +1051,11 @@ setfullscreen(Client *c, int fullscreen) c->prevy = c->geom.y; c->prevheight = c->geom.height; c->prevwidth = c->geom.width; - c->mon->fullscreenclient = c; - maximizeclient(c); + resize(c, c->mon->m.x, c->mon->m.y, c->mon->m.width, c->mon->m.height, 0); } else { /* restore previous size instead of arrange for floating windows since * client positions are set by the user and cannot be recalculated */ resize(c, c->prevx, c->prevy, c->prevwidth, c->prevheight, 0); - c->mon->fullscreenclient = NULL; arrange(c->mon); } } @@ -1337,7 +1322,7 @@ void mapnotify(struct wl_listener *listener, void *data) { /* Called when the surface is mapped, or ready to display on-screen. */ - Client *c = wl_container_of(listener, c, map), *oldfocus = selclient(); + Client *c = wl_container_of(listener, c, map); if (client_is_unmanaged(c)) { /* Insert this independent into independents lists. */ @@ -1356,14 +1341,6 @@ mapnotify(struct wl_listener *listener, void *data) /* Set initial monitor, tags, floating status, and focus */ applyrules(c); - - if (c->mon->fullscreenclient && c->mon->fullscreenclient == oldfocus - && !c->isfloating && c->mon->lt[c->mon->sellt]->arrange) { - maximizeclient(c->mon->fullscreenclient); - focusclient(c->mon->fullscreenclient, 1); - /* give the focus back the fullscreen client on that monitor if exists, - * is focused and the new client isn't floating */ - } } void @@ -1372,12 +1349,9 @@ monocle(Monitor *m) Client *c; wl_list_for_each(c, &clients, link) { - if (!VISIBLEON(c, m) || c->isfloating) + if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) continue; - if (c->isfullscreen) - maximizeclient(c); - else - resize(c, m->w.x, m->w.y, m->w.width, m->w.height, 0); + resize(c, m->w.x, m->w.y, m->w.width, m->w.height, 0); } } @@ -2229,11 +2203,9 @@ tile(Monitor *m) mw = m->w.width; i = my = ty = 0; wl_list_for_each(c, &clients, link) { - if (!VISIBLEON(c, m) || c->isfloating) + if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) continue; - if (c->isfullscreen) - maximizeclient(c); - else if (i < m->nmaster) { + if (i < m->nmaster) { h = (m->w.height - my) / (MIN(n, m->nmaster) - i); resize(c, m->w.x, m->w.y + my, mw, h, 0); my += c->geom.height; -- cgit v1.2.3