Assortment of fullscreen improvements (togglefullscreen / fakefullscreenclient / tagallmon / tagswapmon)

This commit is contained in:
bakkeby 2020-09-05 11:38:09 +02:00
parent dcf7b049ba
commit 5f5dc7ab9c
4 changed files with 94 additions and 53 deletions

57
dwm.c
View File

@ -578,7 +578,7 @@ static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg); static void togglefloating(const Arg *arg);
static void toggletag(const Arg *arg); static void toggletag(const Arg *arg);
static void toggleview(const Arg *arg); static void toggleview(const Arg *arg);
static void unfocus(Client *c, int setfocus); static void unfocus(Client *c, int setfocus, Client *nextfocus);
static void unmanage(Client *c, int destroyed); static void unmanage(Client *c, int destroyed);
static void unmapnotify(XEvent *e); static void unmapnotify(XEvent *e);
static void updatebarpos(Monitor *m); static void updatebarpos(Monitor *m);
@ -938,7 +938,7 @@ buttonpress(XEvent *e)
&& (focusonwheel || (ev->button != Button4 && ev->button != Button5)) && (focusonwheel || (ev->button != Button4 && ev->button != Button5))
#endif // FOCUSONCLICK_PATCH #endif // FOCUSONCLICK_PATCH
) { ) {
unfocus(selmon->sel, 1); unfocus(selmon->sel, 1, NULL);
selmon = m; selmon = m;
focus(NULL); focus(NULL);
} }
@ -1656,9 +1656,9 @@ enternotify(XEvent *e)
#if LOSEFULLSCREEN_PATCH #if LOSEFULLSCREEN_PATCH
sel = selmon->sel; sel = selmon->sel;
selmon = m; selmon = m;
unfocus(sel, 1); unfocus(sel, 1, c);
#else #else
unfocus(selmon->sel, 1); unfocus(selmon->sel, 1, c);
selmon = m; selmon = m;
#endif // LOSEFULLSCREEN_PATCH #endif // LOSEFULLSCREEN_PATCH
} else if (!c || c == selmon->sel) } else if (!c || c == selmon->sel)
@ -1683,7 +1683,7 @@ focus(Client *c)
if (!c || !ISVISIBLE(c)) if (!c || !ISVISIBLE(c))
for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); for (c = selmon->stack; c && !ISVISIBLE(c); c = c->snext);
if (selmon->sel && selmon->sel != c) if (selmon->sel && selmon->sel != c)
unfocus(selmon->sel, 0); unfocus(selmon->sel, 0, c);
if (c) { if (c) {
if (c->mon != selmon) if (c->mon != selmon)
selmon = c->mon; selmon = c->mon;
@ -1732,9 +1732,9 @@ focusmon(const Arg *arg)
#if LOSEFULLSCREEN_PATCH #if LOSEFULLSCREEN_PATCH
sel = selmon->sel; sel = selmon->sel;
selmon = m; selmon = m;
unfocus(sel, 0); unfocus(sel, 0, NULL);
#else #else
unfocus(selmon->sel, 0); unfocus(selmon->sel, 0, NULL);
selmon = m; selmon = m;
#endif // LOSEFULLSCREEN_PATCH #endif // LOSEFULLSCREEN_PATCH
focus(NULL); focus(NULL);
@ -2126,7 +2126,7 @@ manage(Window w, XWindowAttributes *wa)
setclientstate(c, NormalState); setclientstate(c, NormalState);
#endif // BAR_WINTITLEACTIONS_PATCH #endif // BAR_WINTITLEACTIONS_PATCH
if (c->mon == selmon) if (c->mon == selmon)
unfocus(selmon->sel, 0); unfocus(selmon->sel, 0, c);
c->mon->sel = c; c->mon->sel = c;
arrange(c->mon); arrange(c->mon);
#if BAR_WINTITLEACTIONS_PATCH #if BAR_WINTITLEACTIONS_PATCH
@ -2191,9 +2191,9 @@ motionnotify(XEvent *e)
#if LOSEFULLSCREEN_PATCH #if LOSEFULLSCREEN_PATCH
sel = selmon->sel; sel = selmon->sel;
selmon = m; selmon = m;
unfocus(sel, 1); unfocus(sel, 1, NULL);
#else #else
unfocus(selmon->sel, 1); unfocus(selmon->sel, 1, NULL);
selmon = m; selmon = m;
#endif // LOSEFULLSCREEN_PATCH #endif // LOSEFULLSCREEN_PATCH
focus(NULL); focus(NULL);
@ -2686,7 +2686,7 @@ sendmon(Client *c, Monitor *m)
#if SENDMON_KEEPFOCUS_PATCH && !EXRESIZE_PATCH #if SENDMON_KEEPFOCUS_PATCH && !EXRESIZE_PATCH
int hadfocus = (c == selmon->sel); int hadfocus = (c == selmon->sel);
#endif // SENDMON_KEEPFOCUS_PATCH #endif // SENDMON_KEEPFOCUS_PATCH
unfocus(c, 1); unfocus(c, 1, NULL);
detach(c); detach(c);
detachstack(c); detachstack(c);
#if SENDMON_KEEPFOCUS_PATCH && !EXRESIZE_PATCH #if SENDMON_KEEPFOCUS_PATCH && !EXRESIZE_PATCH
@ -2821,7 +2821,8 @@ setfullscreen(Client *c, int fullscreen)
c->isfullscreen = 1; c->isfullscreen = 1;
#if !FAKEFULLSCREEN_PATCH #if !FAKEFULLSCREEN_PATCH
#if FAKEFULLSCREEN_CLIENT_PATCH #if FAKEFULLSCREEN_CLIENT_PATCH
if (!c->fakefullscreen) { if (c->fakefullscreen == 1)
return;
#endif // FAKEFULLSCREEN_CLIENT_PATCH #endif // FAKEFULLSCREEN_CLIENT_PATCH
c->oldstate = c->isfloating; c->oldstate = c->isfloating;
c->oldbw = c->bw; c->oldbw = c->bw;
@ -2829,9 +2830,6 @@ setfullscreen(Client *c, int fullscreen)
c->isfloating = 1; c->isfloating = 1;
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh); resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win); XRaiseWindow(dpy, c->win);
#if FAKEFULLSCREEN_CLIENT_PATCH
}
#endif // FAKEFULLSCREEN_CLIENT_PATCH
#endif // !FAKEFULLSCREEN_PATCH #endif // !FAKEFULLSCREEN_PATCH
} else if (!fullscreen && c->isfullscreen){ } else if (!fullscreen && c->isfullscreen){
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
@ -2839,7 +2837,10 @@ setfullscreen(Client *c, int fullscreen)
c->isfullscreen = 0; c->isfullscreen = 0;
#if !FAKEFULLSCREEN_PATCH #if !FAKEFULLSCREEN_PATCH
#if FAKEFULLSCREEN_CLIENT_PATCH #if FAKEFULLSCREEN_CLIENT_PATCH
if (!c->fakefullscreen) { if (c->fakefullscreen == 1)
return;
if (c->fakefullscreen == 2)
c->fakefullscreen = 1;
#endif // FAKEFULLSCREEN_CLIENT_PATCH #endif // FAKEFULLSCREEN_CLIENT_PATCH
c->isfloating = c->oldstate; c->isfloating = c->oldstate;
c->bw = c->oldbw; c->bw = c->oldbw;
@ -2849,9 +2850,6 @@ setfullscreen(Client *c, int fullscreen)
c->h = c->oldh; c->h = c->oldh;
resizeclient(c, c->x, c->y, c->w, c->h); resizeclient(c, c->x, c->y, c->w, c->h);
arrange(c->mon); arrange(c->mon);
#if FAKEFULLSCREEN_CLIENT_PATCH
}
#endif // FAKEFULLSCREEN_CLIENT_PATCH
#endif // !FAKEFULLSCREEN_PATCH #endif // !FAKEFULLSCREEN_PATCH
} }
} }
@ -3299,7 +3297,7 @@ tagmon(const Arg *arg)
sendmon(c, dirtomon(arg->i)); sendmon(c, dirtomon(arg->i));
c->isfullscreen = 1; c->isfullscreen = 1;
#if !FAKEFULLSCREEN_PATCH && FAKEFULLSCREEN_CLIENT_PATCH #if !FAKEFULLSCREEN_PATCH && FAKEFULLSCREEN_CLIENT_PATCH
if (!c->fakefullscreen) { if (c->fakefullscreen != 1) {
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh); resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win); XRaiseWindow(dpy, c->win);
} }
@ -3487,7 +3485,7 @@ toggleview(const Arg *arg)
} }
void void
unfocus(Client *c, int setfocus) unfocus(Client *c, int setfocus, Client *nextfocus)
{ {
if (!c) if (!c)
return; return;
@ -3495,13 +3493,18 @@ unfocus(Client *c, int setfocus)
selmon->pertag->prevclient[selmon->pertag->curtag] = c; selmon->pertag->prevclient[selmon->pertag->curtag] = c;
#endif // SWAPFOCUS_PATCH #endif // SWAPFOCUS_PATCH
#if LOSEFULLSCREEN_PATCH #if LOSEFULLSCREEN_PATCH
#if !FAKEFULLSCREEN_PATCH && FAKEFULLSCREEN_CLIENT_PATCH if (c->isfullscreen && ISVISIBLE(c) && c->mon == selmon && nextfocus && !nextfocus->isfloating) {
if (c->isfullscreen && !c->fakefullscreen && ISVISIBLE(c) && c->mon == selmon) #if !FAKEFULLSCREEN_PATCH && FAKEFULLSCREEN_CLIENT_PATCH
if (!c->fakefullscreen)
setfullscreen(c, 0);
else if (c->fakefullscreen == 2) {
c->fakefullscreen = 0;
togglefakefullscreen(NULL);
}
#else
setfullscreen(c, 0); setfullscreen(c, 0);
#else #endif // FAKEFULLSCREEN_CLIENT_PATCH
if (c->isfullscreen && ISVISIBLE(c) && c->mon == selmon) }
setfullscreen(c, 0);
#endif // FAKEFULLSCREEN_CLIENT_PATCH
#endif // LOSEFULLSCREEN_PATCH #endif // LOSEFULLSCREEN_PATCH
grabbuttons(c, 0); grabbuttons(c, 0);
#if !BAR_FLEXWINTITLE_PATCH #if !BAR_FLEXWINTITLE_PATCH

View File

@ -2,27 +2,44 @@ void
tagallmon(const Arg *arg) tagallmon(const Arg *arg)
{ {
Monitor *m; Monitor *m;
Client *c; Client *c, *last, *slast, *next;
Client *next;
if (!mons->next) if (!mons->next)
return; return;
m = dirtomon(arg->i); m = dirtomon(arg->i);
for (last = m->clients; last && last->next; last = last->next);
for (slast = m->stack; slast && slast->snext; slast = slast->snext);
for (c = selmon->clients; c; c = next) { for (c = selmon->clients; c; c = next) {
next = c->next; next = c->next;
if (!ISVISIBLE(c)) if (!ISVISIBLE(c))
continue; continue;
unfocus(c, 1); unfocus(c, 1, NULL);
detach(c); detach(c);
detachstack(c); detachstack(c);
c->mon = m; c->mon = m;
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */ c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
attach(c); c->next = NULL;
attachstack(c); c->snext = NULL;
if (last)
last = last->next = c;
else
m->clients = last = c;
if (slast)
slast = slast->snext = c;
else
m->stack = slast = c;
if (c->isfullscreen) { if (c->isfullscreen) {
setfullscreen(c, 0); #if !FAKEFULLSCREEN_PATCH && FAKEFULLSCREEN_CLIENT_PATCH
setfullscreen(c, 1); if (c->fakefullscreen != 1) {
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win);
}
#elif !FAKEFULLSCREEN_PATCH
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win);
#endif // FAKEFULLSCREEN_CLIENT_PATCH
} }
} }

View File

@ -13,7 +13,7 @@ tagswapmon(const Arg *arg)
next = c->next; next = c->next;
if (!ISVISIBLE(c)) if (!ISVISIBLE(c))
continue; continue;
unfocus(c, 1); unfocus(c, 1, NULL);
detach(c); detach(c);
detachstack(c); detachstack(c);
c->next = sc; c->next = sc;
@ -24,7 +24,7 @@ tagswapmon(const Arg *arg)
next = c->next; next = c->next;
if (!ISVISIBLE(c)) if (!ISVISIBLE(c))
continue; continue;
unfocus(c, 1); unfocus(c, 1, NULL);
detach(c); detach(c);
detachstack(c); detachstack(c);
c->next = mc; c->next = mc;
@ -38,20 +38,34 @@ tagswapmon(const Arg *arg)
attach(c); attach(c);
attachstack(c); attachstack(c);
if (c->isfullscreen) { if (c->isfullscreen) {
setfullscreen(c, 0); #if !FAKEFULLSCREEN_PATCH && FAKEFULLSCREEN_CLIENT_PATCH
setfullscreen(c, 1); if (c->fakefullscreen != 1) {
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win);
}
#elif !FAKEFULLSCREEN_PATCH
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win);
#endif // FAKEFULLSCREEN_CLIENT_PATCH
} }
} }
for (c = mc; c; c = next) { for (c = mc; c; c = next) {
next = c->next; next = ;
c->mon = selmon; c->mon = selmon;
c->tags = selmon->tagset[selmon->seltags]; /* assign tags of target monitor */ c->tags = selmon->tagset[selmon->seltags]; /* assign tags of target monitor */
attach(c); attach(c);
attachstack(c); attachstack(c);
if (c->isfullscreen) { if (c->isfullscreen) {
setfullscreen(c, 0); #if !FAKEFULLSCREEN_PATCH && FAKEFULLSCREEN_CLIENT_PATCH
setfullscreen(c, 1); if (c->fakefullscreen != 1) {
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win);
}
#elif !FAKEFULLSCREEN_PATCH
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win);
#endif // FAKEFULLSCREEN_CLIENT_PATCH
} }
} }

View File

@ -1,17 +1,24 @@
void void
togglefullscreen(const Arg *arg) togglefullscreen(const Arg *arg)
{ {
if (!selmon->sel) if (!selmon->sel)
return; return;
#if !FAKEFULLSCREEN_PATCH && FAKEFULLSCREEN_CLIENT_PATCH #if !FAKEFULLSCREEN_PATCH && FAKEFULLSCREEN_CLIENT_PATCH
if (selmon->sel->fakefullscreen) { if (selmon->sel->fakefullscreen == 1) {
selmon->sel->fakefullscreen = 0; selmon->sel->fakefullscreen = 2;
if (selmon->sel->isfullscreen) { if (selmon->sel->isfullscreen) {
selmon->sel->isfullscreen = 0; selmon->sel->isfullscreen = 0;
} }
} } else if (selmon->sel->fakefullscreen == 2) {
#endif // FAKEFULLSCREEN_CLIENT_PATCH selmon->sel->fakefullscreen = 0;
togglefakefullscreen(NULL);
arrange(selmon);
return;
}
#endif // FAKEFULLSCREEN_CLIENT_PATCH
setfullscreen(selmon->sel, !selmon->sel->isfullscreen); setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
} if (!selmon->sel->isfullscreen)
arrange(selmon);
}