selective fake fullscreen patch w/ per client toggling

This commit is contained in:
Jakub 2024-07-08 00:54:24 -04:00
parent aaef347d15
commit 7f64fe2ae1
3 changed files with 215 additions and 12 deletions

View File

@ -63,11 +63,11 @@ static const Rule rules[] = {
* WM_CLASS(STRING) = instance, class * WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title * WM_NAME(STRING) = title
*/ */
/* class instance title tags mask isfloating isterminal noswallow monitor */ /* class instance title tags mask isfloating isfakefullscreen isterminal noswallow monitor */
{ "Gimp", NULL, NULL, 0, 1, 0, 0, -1 }, { "Gimp", NULL, NULL, 0, 1, 0, 0, 0, -1 },
{ "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 }, { "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1, -1 },
{ "St", NULL, NULL, 0, 0, 1, 0, -1 }, { "St", NULL, NULL, 0, 0, 0, 1, 0, -1 },
{ NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */ { NULL, NULL, "Event Tester", 0, 0, 0, 0, 1, -1 }, /* xev */
}; };
/* window following */ /* window following */
@ -149,6 +149,7 @@ static const Key keys[] = {
{ MODKEY|ControlMask|ShiftMask, XK_Left, moveresizeedge, {.v = "L"} }, { MODKEY|ControlMask|ShiftMask, XK_Left, moveresizeedge, {.v = "L"} },
{ MODKEY|ControlMask|ShiftMask, XK_Right, moveresizeedge, {.v = "R"} }, { MODKEY|ControlMask|ShiftMask, XK_Right, moveresizeedge, {.v = "R"} },
{ MODKEY|ShiftMask, XK_f, togglefullscr, {0} }, { MODKEY|ShiftMask, XK_f, togglefullscr, {0} },
{ MODKEY|Mod1Mask, XK_f, togglefakefullscr, {0} },
{ MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY, XK_0, view, {.ui = ~0 } },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
{ MODKEY, XK_comma, focusmon, {.i = -1 } }, { MODKEY, XK_comma, focusmon, {.i = -1 } },

71
dwm.c
View File

@ -102,7 +102,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid; int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
int bw, oldbw; int bw, oldbw;
unsigned int tags; unsigned int tags;
int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow; int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isfakefullscreen, isterminal, noswallow;
pid_t pid; pid_t pid;
Client *next; Client *next;
Client *snext; Client *snext;
@ -158,6 +158,7 @@ typedef struct {
const char *title; const char *title;
unsigned int tags; unsigned int tags;
int isfloating; int isfloating;
int isfakefullscreen;
int isterminal; int isterminal;
int noswallow; int noswallow;
int monitor; int monitor;
@ -240,6 +241,7 @@ static void sendmon(Client *c, Monitor *m);
static void setclientstate(Client *c, long state); static void setclientstate(Client *c, long state);
static void setclienttagprop(Client *c); static void setclienttagprop(Client *c);
static void setfocus(Client *c); static void setfocus(Client *c);
static void setfakefullscreen(Client *c, int fullscreen);
static void setfullscreen(Client *c, int fullscreen); static void setfullscreen(Client *c, int fullscreen);
static void setlayout(const Arg *arg); static void setlayout(const Arg *arg);
static void setmfact(const Arg *arg); static void setmfact(const Arg *arg);
@ -256,6 +258,7 @@ static void tag(const Arg *arg);
static void tagmon(const Arg *arg); static void tagmon(const Arg *arg);
static void tile(Monitor *m); static void tile(Monitor *m);
static void togglebar(const Arg *arg); static void togglebar(const Arg *arg);
static void togglefakefullscr(const Arg *arg);
static void togglefullscr(const Arg *arg); static void togglefullscr(const Arg *arg);
static void toggleextrabar(const Arg *arg); static void toggleextrabar(const Arg *arg);
static void togglefloating(const Arg *arg); static void togglefloating(const Arg *arg);
@ -412,6 +415,7 @@ applyrules(Client *c)
c->isterminal = r->isterminal; c->isterminal = r->isterminal;
c->noswallow = r->noswallow; c->noswallow = r->noswallow;
c->isfloating = r->isfloating; c->isfloating = r->isfloating;
c->isfakefullscreen = r->isfakefullscreen;
c->tags |= r->tags; c->tags |= r->tags;
for (m = mons; m && m->num != r->monitor; m = m->next); for (m = mons; m && m->num != r->monitor; m = m->next);
if (m) if (m)
@ -731,7 +735,8 @@ clientmessage(XEvent *e)
if (cme->data.l[1] == netatom[NetWMFullscreen] if (cme->data.l[1] == netatom[NetWMFullscreen]
|| cme->data.l[2] == netatom[NetWMFullscreen]) || cme->data.l[2] == netatom[NetWMFullscreen])
setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */ setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */
|| (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen))); || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */
&& (!c->isfullscreen || c->isfakefullscreen))));
} else if (cme->message_type == netatom[NetActiveWindow]) { } else if (cme->message_type == netatom[NetActiveWindow]) {
if (c != selmon->sel && !c->isurgent) if (c != selmon->sel && !c->isurgent)
seturgent(c, 1); seturgent(c, 1);
@ -775,7 +780,8 @@ configurenotify(XEvent *e)
updatebars(); updatebars();
for (m = mons; m; m = m->next) { for (m = mons; m; m = m->next) {
for (c = m->clients; c; c = c->next) for (c = m->clients; c; c = c->next)
if (c->isfullscreen) if (c->isfullscreen
&& !c->isfakefullscreen)
resizeclient(c, m->mx, m->my, m->mw, m->mh); resizeclient(c, m->mx, m->my, m->mw, m->mh);
XMoveResizeWindow(dpy, m->barwin, m->wx + sp, m->by + vp, m->ww - 2 * sp, bh); XMoveResizeWindow(dpy, m->barwin, m->wx + sp, m->by + vp, m->ww - 2 * sp, bh);
XMoveResizeWindow(dpy, m->extrabarwin, m->wx + sp, m->eby - vp, m->ww - 2 * sp, bh); XMoveResizeWindow(dpy, m->extrabarwin, m->wx + sp, m->eby - vp, m->ww - 2 * sp, bh);
@ -1501,7 +1507,7 @@ manage(Window w, XWindowAttributes *wa)
XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */ XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
if (!HIDDEN(c)) if (!HIDDEN(c))
setclientstate(c, NormalState); setclientstate(c, NormalState);
if (selmon->sel && selmon->sel->isfullscreen) if (selmon->sel && selmon->sel->isfullscreen && !selmon->sel->isfakefullscreen)
setfullscreen(selmon->sel, 0); setfullscreen(selmon->sel, 0);
if (c->mon == selmon) if (c->mon == selmon)
unfocus(selmon->sel, 0); unfocus(selmon->sel, 0);
@ -1582,7 +1588,8 @@ movemouse(const Arg *arg)
if (!(c = selmon->sel)) if (!(c = selmon->sel))
return; return;
if (c->isfullscreen) /* no support moving fullscreen windows by mouse */ if (c->isfullscreen
&& !c->isfakefullscreen) /* no support moving fullscreen windows by mouse */
return; return;
restack(selmon); restack(selmon);
ocx = c->x; ocx = c->x;
@ -2070,7 +2077,8 @@ resizemouse(const Arg *arg)
if (!(c = selmon->sel)) if (!(c = selmon->sel))
return; return;
if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */ if (c->isfullscreen
&& !c->isfakefullscreen) /* no support resizing fullscreen windows by mouse */
return; return;
restack(selmon); restack(selmon);
ocx = c->x; ocx = c->x;
@ -2286,13 +2294,48 @@ setfocus(Client *c)
sendevent(c, wmatom[WMTakeFocus]); sendevent(c, wmatom[WMTakeFocus]);
} }
void
setfakefullscreen(Client *c, int fakefullscreen)
{
if (fakefullscreen && !c->isfakefullscreen) {
c->isfakefullscreen = 1;
if (c->isfullscreen) {
c->isfloating = c->oldstate;
c->bw = c->oldbw;
c->x = c->oldx;
c->y = c->oldy;
c->w = c->oldw;
c->h = c->oldh;
resizeclient(c, c->x, c->y, c->w, c->h);
arrange(c->mon);
}
} else if (!fakefullscreen && c->isfakefullscreen){
c->isfakefullscreen = 0;
if (c->isfullscreen) {
c->oldstate = c->isfloating;
c->oldbw = c->bw;
c->bw = 0;
c->isfloating = 1;
resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh);
XRaiseWindow(dpy, c->win);
}
}
}
void void
setfullscreen(Client *c, int fullscreen) setfullscreen(Client *c, int fullscreen)
{ {
if (fullscreen && !c->isfullscreen) { if (fullscreen && !c->isfullscreen) {
// make non fs win a fs win
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1); PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
c->isfullscreen = 1; c->isfullscreen = 1;
if (c->isfakefullscreen) {
resizeclient(c, c->x, c->y, c->w, c->h);
return;
}
c->oldstate = c->isfloating; c->oldstate = c->isfloating;
c->oldbw = c->bw; c->oldbw = c->bw;
c->bw = 0; c->bw = 0;
@ -2300,9 +2343,14 @@ setfullscreen(Client *c, int fullscreen)
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);
} else if (!fullscreen && c->isfullscreen){ } else if (!fullscreen && c->isfullscreen){
// make a fs win a non fs win
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)0, 0); PropModeReplace, (unsigned char*)0, 0);
c->isfullscreen = 0; c->isfullscreen = 0;
if (c->isfakefullscreen) {
resizeclient(c, c->x, c->y, c->w, c->h);
return;
}
c->isfloating = c->oldstate; c->isfloating = c->oldstate;
c->bw = c->oldbw; c->bw = c->oldbw;
c->x = c->oldx; c->x = c->oldx;
@ -2673,7 +2721,8 @@ togglefloating(const Arg *arg)
{ {
if (!selmon->sel) if (!selmon->sel)
return; return;
if (selmon->sel->isfullscreen) /* no support for fullscreen windows */ if (selmon->sel->isfullscreen
&& !selmon->sel->isfakefullscreen) /* no support for fullscreen windows */
return; return;
selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
if (selmon->sel->isfloating) if (selmon->sel->isfloating)
@ -2694,6 +2743,13 @@ togglefloating(const Arg *arg)
arrange(selmon); arrange(selmon);
} }
void
togglefakefullscr(const Arg *arg)
{
if (selmon->sel)
setfakefullscreen(selmon->sel, !selmon->sel->isfakefullscreen);
}
void void
togglefullscr(const Arg *arg) togglefullscr(const Arg *arg)
{ {
@ -2701,6 +2757,7 @@ togglefullscr(const Arg *arg)
setfullscreen(selmon->sel, !selmon->sel->isfullscreen); setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
} }
void void
toggletag(const Arg *arg) toggletag(const Arg *arg)
{ {

View File

@ -0,0 +1,145 @@
From 7b7230cba4a3b886aa4239edecb86665dffcd9d8 Mon Sep 17 00:00:00 2001
From: Francisco Tapia <link_1232@yahoo.com.mx>
Date: Mon, 30 Nov 2020 12:43:18 -0600
Subject: [PATCH] Fix for selectivefakefullscreen resize issue
Fixed a problem where entering a fake full screen caused the client
to resize incorrectly, resulting in a truncated window, and
requiring the user to force a whole screen update, e.g. toggling
on and off the bar, to correctly draw the whole window.
---
config.def.h | 6 +++---
dwm.c | 30 +++++++++++++++++++++++-------
2 files changed, 26 insertions(+), 10 deletions(-)
diff --git a/config.def.h b/config.def.h
index 1c0b587..b7a445b 100644
--- a/config.def.h
+++ b/config.def.h
@@ -26,9 +26,9 @@ static const Rule rules[] = {
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
- /* class instance title tags mask isfloating monitor */
- { "Gimp", NULL, NULL, 0, 1, -1 },
- { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
+ /* class instance title tags mask isfloating isfakefullscreen monitor */
+ { "Gimp", NULL, NULL, 0, 1, 0, -1 },
+ { "Firefox", NULL, NULL, 1 << 8, 0, 1, -1 },
};
/* layout(s) */
diff --git a/dwm.c b/dwm.c
index 664c527..a7418aa 100644
--- a/dwm.c
+++ b/dwm.c
@@ -92,7 +92,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
unsigned int tags;
- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isfakefullscreen;
Client *next;
Client *snext;
Monitor *mon;
@@ -138,6 +138,7 @@ typedef struct {
const char *title;
unsigned int tags;
int isfloating;
+ int isfakefullscreen;
int monitor;
} Rule;
@@ -299,6 +300,7 @@ applyrules(Client *c)
&& (!r->instance || strstr(instance, r->instance)))
{
c->isfloating = r->isfloating;
+ c->isfakefullscreen = r->isfakefullscreen;
c->tags |= r->tags;
for (m = mons; m && m->num != r->monitor; m = m->next);
if (m)
@@ -522,7 +524,8 @@ clientmessage(XEvent *e)
if (cme->data.l[1] == netatom[NetWMFullscreen]
|| cme->data.l[2] == netatom[NetWMFullscreen])
setfullscreen(c, (cme->data.l[0] == 1 /* _NET_WM_STATE_ADD */
- || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */ && !c->isfullscreen)));
+ || (cme->data.l[0] == 2 /* _NET_WM_STATE_TOGGLE */
+ && (!c->isfullscreen || c->isfakefullscreen))));
} else if (cme->message_type == netatom[NetActiveWindow]) {
if (c != selmon->sel && !c->isurgent)
seturgent(c, 1);
@@ -566,7 +569,8 @@ configurenotify(XEvent *e)
updatebars();
for (m = mons; m; m = m->next) {
for (c = m->clients; c; c = c->next)
- if (c->isfullscreen)
+ if (c->isfullscreen
+ && !c->isfakefullscreen)
resizeclient(c, m->mx, m->my, m->mw, m->mh);
XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
}
@@ -1144,7 +1148,8 @@ movemouse(const Arg *arg)
if (!(c = selmon->sel))
return;
- if (c->isfullscreen) /* no support moving fullscreen windows by mouse */
+ if (c->isfullscreen
+ && !c->isfakefullscreen) /* no support moving fullscreen windows by mouse */
return;
restack(selmon);
ocx = c->x;
@@ -1299,7 +1304,8 @@ resizemouse(const Arg *arg)
if (!(c = selmon->sel))
return;
- if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */
+ if (c->isfullscreen
+ && !c->isfakefullscreen) /* no support resizing fullscreen windows by mouse */
return;
restack(selmon);
ocx = c->x;
@@ -1477,6 +1483,10 @@ setfullscreen(Client *c, int fullscreen)
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
c->isfullscreen = 1;
+ if (c->isfakefullscreen) {
+ resizeclient(c, c->x, c->y, c->w, c->h);
+ return;
+ }
c->oldstate = c->isfloating;
c->oldbw = c->bw;
c->bw = 0;
@@ -1487,6 +1497,10 @@ setfullscreen(Client *c, int fullscreen)
XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32,
PropModeReplace, (unsigned char*)0, 0);
c->isfullscreen = 0;
+ if (c->isfakefullscreen) {
+ resizeclient(c, c->x, c->y, c->w, c->h);
+ return;
+ }
c->isfloating = c->oldstate;
c->bw = c->oldbw;
c->x = c->oldx;
@@ -1619,7 +1633,8 @@ showhide(Client *c)
if (ISVISIBLE(c)) {
/* show clients top down */
XMoveWindow(dpy, c->win, c->x, c->y);
- if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && !c->isfullscreen)
+ if ((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating)
+ && (!c->isfullscreen || c->isfakefullscreen))
resize(c, c->x, c->y, c->w, c->h, 0);
showhide(c->snext);
} else {
@@ -1713,7 +1728,8 @@ togglefloating(const Arg *arg)
{
if (!selmon->sel)
return;
- if (selmon->sel->isfullscreen) /* no support for fullscreen windows */
+ if (selmon->sel->isfullscreen
+ && !selmon->sel->isfakefullscreen) /* no support for fullscreen windows */
return;
selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
if (selmon->sel->isfloating)
--
2.20.1