dwm

My fork of dwm.
git clone git://git.alex.balgavy.eu/dwm.git
Log | Files | Refs | README | LICENSE

commit 263571431f2c1b7b421a02547924bfb41075fc0d
parent 3d7a69a8547869a875b6291dc762a0e63808abae
Author: Alex Balgavy <alex@balgavy.eu>
Date:   Fri,  8 Oct 2021 13:21:51 +0200

Patch - fakefullscreenclient

Clients only fullscreen into the area that they have. Toggleable.

Diffstat:
Mconfig.def.h | 1+
Mconfig.h | 1+
Mdwm.c | 61++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
3 files changed, 56 insertions(+), 7 deletions(-)

diff --git a/config.def.h b/config.def.h @@ -150,6 +150,7 @@ static Key keys[] = { { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, { MODKEY, XK_space, setlayout, {0} }, + { MODKEY|ShiftMask, XK_f, togglefakefullscreen, {0} }, { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, { MODKEY, XK_0, view, {.ui = ~0 } }, { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } }, diff --git a/config.h b/config.h @@ -159,6 +159,7 @@ static Key keys[] = { { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, // tile { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, // monocle { MODKEY|ShiftMask, XK_f, togglefullscr, {0} }, + { MODKEY|ControlMask, XK_f, togglefakefullscreen, {0} }, { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, // spiral { MODKEY, XK_s, setlayout, {.v = &layouts[5]} }, // bstack { MODKEY, XK_space, setlayout, {0} }, diff --git a/dwm.c b/dwm.c @@ -106,6 +106,7 @@ struct Client { int bw, oldbw; unsigned int tags; int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow, issticky; + int fakefullscreen; pid_t pid; Client *next; Client *snext; @@ -250,6 +251,7 @@ static int stackpos(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); static void togglebar(const Arg *arg); +static void togglefakefullscreen(const Arg *arg); static void togglefloating(const Arg *arg); static void togglesticky(const Arg *arg); static void togglescratch(const Arg *arg); @@ -702,7 +704,7 @@ 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->fakefullscreen != 1) resizeclient(c, m->mx, m->my, m->mw, m->mh); XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); } @@ -1344,7 +1346,7 @@ movemouse(const Arg *arg) if (!(c = selmon->sel)) return; - if (c->isfullscreen) /* no support moving fullscreen windows by mouse */ + if (c->isfullscreen && c->fakefullscreen != 1) /* no support moving fullscreen windows by mouse */ return; restack(selmon); ocx = c->x; @@ -1508,7 +1510,10 @@ resizeclient(Client *c, int x, int y, int w, int h) wc.border_width = c->bw; XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); configure(c); - XSync(dpy, False); + if (c->fakefullscreen == 1) + XSync(dpy, True); + else + XSync(dpy, False); } void @@ -1522,7 +1527,7 @@ resizemouse(const Arg *arg) if (!(c = selmon->sel)) return; - if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */ + if (c->isfullscreen && c->fakefullscreen != 1) /* no support resizing fullscreen windows by mouse */ return; restack(selmon); ocx = c->x; @@ -1700,8 +1705,10 @@ setfullscreen(Client *c, int fullscreen) XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1); c->isfullscreen = 1; - c->oldstate = c->isfloating; c->oldbw = c->bw; + if (c->fakefullscreen == 1) + return; + c->oldstate = c->isfloating; c->bw = 0; c->isfloating = 1; resizeclient(c, c->mon->mx, c->mon->my, c->mon->mw, c->mon->mh); @@ -1710,8 +1717,12 @@ setfullscreen(Client *c, int fullscreen) XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, PropModeReplace, (unsigned char*)0, 0); c->isfullscreen = 0; - c->isfloating = c->oldstate; c->bw = c->oldbw; + if (c->fakefullscreen == 1) + return; + if (c->fakefullscreen == 2) + c->fakefullscreen = 1; + c->isfloating = c->oldstate; c->x = c->oldx; c->y = c->oldy; c->w = c->oldw; @@ -1949,11 +1960,47 @@ togglebar(const Arg *arg) } void +togglefakefullscreen(const Arg *arg) +{ + Client *c = selmon->sel; + if (!c) + return; + + if (c->fakefullscreen) { + if (c->isfullscreen) { + if (c->isfloating && c->fakefullscreen == 1) { + c->oldstate = c->isfloating; + c->oldx = c->x; + c->oldy = c->y; + c->oldw = c->w; + c->oldh = c->h; + } + c->fakefullscreen = 0; + } + else + c->isfullscreen = 0; + } else { + c->fakefullscreen = 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); + } + c->isfullscreen = 0; + } + setfullscreen(c, !c->isfullscreen); +} + +void togglefloating(const Arg *arg) { if (!selmon->sel) return; - if (selmon->sel->isfullscreen) /* no support for fullscreen windows */ + if (selmon->sel->isfullscreen && selmon->sel->fakefullscreen != 1) /* no support for fullscreen windows */ return; selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; if (selmon->sel->isfloating)