From 9b85650c1dd6c43afb752edc22d2e038abac00ac Mon Sep 17 00:00:00 2001 From: bakkeby Date: Thu, 21 Nov 2019 12:15:16 +0100 Subject: [PATCH] Adding fakefullscreeenclient patch --- README.md | 7 +++++++ config.def.h | 3 +++ dwm.c | 39 ++++++++++++++++++++++++++++++++++++ patch/fakefullscreenclient.c | 17 ++++++++++++++++ patch/fakefullscreenclient.h | 1 + patch/include.c | 3 +++ patch/include.h | 3 +++ patches.h | 7 +++++++ 8 files changed, 80 insertions(+) create mode 100644 patch/fakefullscreenclient.c create mode 100644 patch/fakefullscreenclient.h diff --git a/README.md b/README.md index 587c3dd..76bc114 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t ### Changelog: +2019-11-21 - Added fakefullscreenclient patch + 2019-10-24 - Added dragmfact, extrabar, exresize and nodmenu patches 2019-10-22 - Added ispermanent and swallow patches @@ -140,6 +142,11 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t - only allow clients to "fullscreen" into the space currently given to them - as an example, this will allow you to view a fullscreen video in your browser on one half of the screen, while having the other half available for other tasks + - fakefullscreenclient + - similarly to the fakefullscreen patch this patch only allows clients to "fullscreen" into the space currently given to them + - as an example, this will allow you to view a fullscreen video in your browser on one half of the screen, while having the other half available for other tasks + - the "twist" with this patch is that fake fullscreen can be toggled on a per client basis rather than applying to all clients globally + - [fancybar](https://dwm.suckless.org/patches/fancybar/) - shows the titles of all visible windows in the status bar diff --git a/config.def.h b/config.def.h index ac4a8e4..a45a9a8 100644 --- a/config.def.h +++ b/config.def.h @@ -614,6 +614,9 @@ static Key keys[] = { #if TOGGLEFULLSCREEN_PATCH { MODKEY, XK_y, togglefullscreen, {0} }, #endif // TOGGLEFULLSCREEN_PATCH + #if FAKEFULLSCREEN_CLIENT_PATCH + { MODKEY|ShiftMask, XK_y, togglefakefullscreen, {0} }, + #endif // FAKEFULLSCREEN_CLIENT_PATCH #if FULLSCREEN_PATCH { MODKEY|ShiftMask, XK_f, fullscreen, {0} }, #endif // FULLSCREEN_PATCH diff --git a/dwm.c b/dwm.c index 2c27ba5..468f5dc 100644 --- a/dwm.c +++ b/dwm.c @@ -150,6 +150,9 @@ struct Client { int bw, oldbw; unsigned int tags; int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen; + #if FAKEFULLSCREEN_CLIENT_PATCH + int fakefullscreen; + #endif // FAKEFULLSCREEN_CLIENT_PATCH #if EXRESIZE_PATCH unsigned char expandmask; int expandx1, expandy1, expandx2, expandy2; @@ -1034,7 +1037,11 @@ configurenotify(XEvent *e) for (m = mons; m; m = m->next) { #if !FAKEFULLSCREEN_PATCH for (c = m->clients; c; c = c->next) + #if FAKEFULLSCREEN_CLIENT_PATCH + if (c->isfullscreen && !c->fakefullscreen) + #else if (c->isfullscreen) + #endif // FAKEFULLSCREEN_CLIENT_PATCH resizeclient(c, m->mx, m->my, m->mw, m->mh); #endif // !FAKEFULLSCREEN_PATCH XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); @@ -1668,8 +1675,13 @@ focus(Client *c) #if LOSEFULLSCREEN_PATCH Client *at; for (at = selmon->clients; at; at = at->next) + #if FAKEFULLSCREEN_CLIENT_PATCH + if (at != c && at->isfullscreen && !at->fakefullscreen && ISVISIBLE(at)) + setfullscreen(at, 0); + #else if (at != c && at->isfullscreen && ISVISIBLE(at)) setfullscreen(at, 0); + #endif // FAKEFULLSCREEN_CLIENT_PATCH #endif // LOSEFULLSCREEN_PATCH drawbars(); } @@ -2119,8 +2131,13 @@ movemouse(const Arg *arg) if (!(c = selmon->sel)) return; #if !FAKEFULLSCREEN_PATCH + #if FAKEFULLSCREEN_CLIENT_PATCH + if (c->isfullscreen && !c->fakefullscreen) /* no support moving fullscreen windows by mouse */ + return; + #else if (c->isfullscreen) /* no support moving fullscreen windows by mouse */ return; + #endif // FAKEFULLSCREEN_CLIENT_PATCH #endif // FAKEFULLSCREEN_PATCH restack(selmon); ocx = c->x; @@ -2353,8 +2370,13 @@ resizemouse(const Arg *arg) if (!(c = selmon->sel)) return; #if !FAKEFULLSCREEN_PATCH + #if FAKEFULLSCREEN_CLIENT_PATCH + if (c->isfullscreen && !c->fakefullscreen) /* no support resizing fullscreen windows by mouse */ + return; + #else if (c->isfullscreen) /* no support resizing fullscreen windows by mouse */ return; + #endif // FAKEFULLSCREEN_CLIENT_PATCH #endif // !FAKEFULLSCREEN_PATCH restack(selmon); ocx = c->x; @@ -2677,18 +2699,27 @@ setfullscreen(Client *c, int fullscreen) PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1); c->isfullscreen = 1; #if !FAKEFULLSCREEN_PATCH + #if FAKEFULLSCREEN_CLIENT_PATCH + if (!c->fakefullscreen) { + #endif // FAKEFULLSCREEN_CLIENT_PATCH 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); + #if FAKEFULLSCREEN_CLIENT_PATCH + } + #endif // FAKEFULLSCREEN_CLIENT_PATCH #endif // !FAKEFULLSCREEN_PATCH } else if (!fullscreen && c->isfullscreen){ XChangeProperty(dpy, c->win, netatom[NetWMState], XA_ATOM, 32, PropModeReplace, (unsigned char*)0, 0); c->isfullscreen = 0; #if !FAKEFULLSCREEN_PATCH + #if FAKEFULLSCREEN_CLIENT_PATCH + if (!c->fakefullscreen) { + #endif // FAKEFULLSCREEN_CLIENT_PATCH c->isfloating = c->oldstate; c->bw = c->oldbw; c->x = c->oldx; @@ -2697,6 +2728,9 @@ setfullscreen(Client *c, int fullscreen) c->h = c->oldh; resizeclient(c, c->x, c->y, c->w, c->h); arrange(c->mon); + #if FAKEFULLSCREEN_CLIENT_PATCH + } + #endif // FAKEFULLSCREEN_CLIENT_PATCH #endif // !FAKEFULLSCREEN_PATCH } } @@ -3083,8 +3117,13 @@ togglefloating(const Arg *arg) if (!selmon->sel) return; #if !FAKEFULLSCREEN_PATCH + #if FAKEFULLSCREEN_CLIENT_PATCH + if (selmon->sel->isfullscreen && !selmon->sel->fakefullscreen) /* no support for fullscreen windows */ + return; + #else if (selmon->sel->isfullscreen) /* no support for fullscreen windows */ return; + #endif // FAKEFULLSCREEN_CLIENT_PATCH #endif // !FAKEFULLSCREEN_PATCH selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; #if FLOAT_BORDER_COLOR_PATCH diff --git a/patch/fakefullscreenclient.c b/patch/fakefullscreenclient.c new file mode 100644 index 0000000..5b3d7af --- /dev/null +++ b/patch/fakefullscreenclient.c @@ -0,0 +1,17 @@ +void +togglefakefullscreen(const Arg *arg) +{ + if (!selmon->sel) + return; + + if (selmon->sel->fakefullscreen) { + if (selmon->sel->isfullscreen) + selmon->sel->fakefullscreen = 0; + else + selmon->sel->isfullscreen = 0; + } else { + selmon->sel->fakefullscreen = 1; + selmon->sel->isfullscreen = 0; + } + setfullscreen(selmon->sel, !selmon->sel->isfullscreen); +} \ No newline at end of file diff --git a/patch/fakefullscreenclient.h b/patch/fakefullscreenclient.h new file mode 100644 index 0000000..e2a36d1 --- /dev/null +++ b/patch/fakefullscreenclient.h @@ -0,0 +1 @@ +static void togglefakefullscreen(const Arg *arg); \ No newline at end of file diff --git a/patch/include.c b/patch/include.c index 9b0fd0d..346839c 100644 --- a/patch/include.c +++ b/patch/include.c @@ -32,6 +32,9 @@ #if EWMHTAGS_PATCH #include "ewmhtags.c" #endif +#if FAKEFULLSCREEN_CLIENT_PATCH +#include "fakefullscreenclient.c" +#endif #if FOCUSADJACENTTAG_PATCH #include "focusadjacenttag.c" #endif diff --git a/patch/include.h b/patch/include.h index 4ae5675..bce929e 100644 --- a/patch/include.h +++ b/patch/include.h @@ -35,6 +35,9 @@ #if EXRESIZE_PATCH #include "exresize.h" #endif +#if FAKEFULLSCREEN_CLIENT_PATCH +#include "fakefullscreenclient.h" +#endif #if FOCUSADJACENTTAG_PATCH #include "focusadjacenttag.h" #endif diff --git a/patches.h b/patches.h index a7d58d0..83f60d5 100644 --- a/patches.h +++ b/patches.h @@ -164,6 +164,13 @@ */ #define FAKEFULLSCREEN_PATCH 0 +/* Similarly to the fakefullscreen patch this patch only allows clients to "fullscreen" into + * the space currently given to them. + * The "twist" with this patch is that fake fullscreen can be toggled on a per client basis + * rather than applying to all clients globally. + */ +#define FAKEFULLSCREEN_CLIENT_PATCH 0 + /* This patch shows the titles of all visible windows in the status bar * (as opposed to showing only the selected one). * Awesomebar takes precedence over fancybar. Fancybar takes precedence over