quitallfullscreen() even when enabling fullscreen

Disable fullscreen on all visible clients in that monitor also before
enabling it on another client.

quitallfullscreen() is reintroduced becouse is now more useful

set c->isfullscreen later to avoid making quitallfullscreen() disable
fullscreen on the current client
This commit is contained in:
Stivvo 2020-12-24 01:02:45 +01:00
parent 86ba4c8526
commit 707c1710b7
1 changed files with 14 additions and 7 deletions

21
dwl.c
View File

@ -220,6 +220,7 @@ static void moveresize(const Arg *arg);
static void pointerfocus(Client *c, struct wlr_surface *surface, static void pointerfocus(Client *c, struct wlr_surface *surface,
double sx, double sy, uint32_t time); double sx, double sy, uint32_t time);
static void quit(const Arg *arg); static void quit(const Arg *arg);
static void quitallfullscreen();
static void render(struct wlr_surface *surface, int sx, int sy, void *data); static void render(struct wlr_surface *surface, int sx, int sy, void *data);
static void renderclients(Monitor *m, struct timespec *now); static void renderclients(Monitor *m, struct timespec *now);
static void rendermon(struct wl_listener *listener, void *data); static void rendermon(struct wl_listener *listener, void *data);
@ -588,9 +589,7 @@ createnotify(struct wl_listener *listener, void *data)
if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL) if (xdg_surface->role != WLR_XDG_SURFACE_ROLE_TOPLEVEL)
return; return;
wl_list_for_each(c, &clients, link) quitallfullscreen();
if (c->isfullscreen && VISIBLEON(c, c->mon))
setfullscreen(c, 0);
/* Allocate a Client for this surface */ /* Allocate a Client for this surface */
c = xdg_surface->data = calloc(1, sizeof(*c)); c = xdg_surface->data = calloc(1, sizeof(*c));
@ -687,10 +686,18 @@ togglefullscreen(const Arg *arg)
setfullscreen(sel, !sel->isfullscreen); setfullscreen(sel, !sel->isfullscreen);
} }
void
quitallfullscreen()
{
Client *c;
wl_list_for_each(c, &clients, link)
if (c->isfullscreen && VISIBLEON(c, selmon))
setfullscreen(c, 0);
}
void void
setfullscreen(Client *c, int fullscreen) setfullscreen(Client *c, int fullscreen)
{ {
c->isfullscreen = fullscreen;
c->bw = (1 - fullscreen) * borderpx; c->bw = (1 - fullscreen) * borderpx;
#ifdef XWAYLAND #ifdef XWAYLAND
@ -702,6 +709,7 @@ setfullscreen(Client *c, int fullscreen)
// restore previous size instead of arrange to work with floating windows // restore previous size instead of arrange to work with floating windows
if (fullscreen) { if (fullscreen) {
quitallfullscreen();
c->prevx = c->geom.x; c->prevx = c->geom.x;
c->prevy = c->geom.y; c->prevy = c->geom.y;
c->prevheight = c->geom.height; c->prevheight = c->geom.height;
@ -710,6 +718,7 @@ setfullscreen(Client *c, int fullscreen)
} else { } else {
resize(c, c->prevx, c->prevy, c->prevwidth, c->prevheight, 0); resize(c, c->prevx, c->prevy, c->prevwidth, c->prevheight, 0);
} }
c->isfullscreen = fullscreen;
} }
void void
@ -1864,9 +1873,7 @@ createnotifyx11(struct wl_listener *listener, void *data)
{ {
struct wlr_xwayland_surface *xwayland_surface = data; struct wlr_xwayland_surface *xwayland_surface = data;
Client *c; Client *c;
wl_list_for_each(c, &clients, link) quitallfullscreen();
if (c->isfullscreen && VISIBLEON(c, c->mon))
setfullscreen(c, 0);
/* Allocate a Client for this surface */ /* Allocate a Client for this surface */
c = xwayland_surface->data = calloc(1, sizeof(*c)); c = xwayland_surface->data = calloc(1, sizeof(*c));