dwm-fullscreen-20260112-f4fdaff.diff (1997B)
1 From f4fdaff5cf85287ad11272902054cdbaf44535fe Mon Sep 17 00:00:00 2001 2 From: Savar <savar95x@gmail.com> 3 Date: Mon, 12 Jan 2026 17:26:41 +0530 4 Subject: [PATCH] fullscreen: fix toggle logic loop by checking active layout 5 6 --- 7 config.def.h | 1 + 8 dwm.c | 17 +++++++++++++++++ 9 2 files changed, 18 insertions(+) 10 11 diff --git a/config.def.h b/config.def.h 12 index 81c3fc0..ef36491 100644 13 --- a/config.def.h 14 +++ b/config.def.h 15 @@ -78,6 +78,7 @@ static const Key keys[] = { 16 { MODKEY, XK_t, setlayout, {.v = &layouts[0]} }, 17 { MODKEY, XK_f, setlayout, {.v = &layouts[1]} }, 18 { MODKEY, XK_m, setlayout, {.v = &layouts[2]} }, 19 + { MODKEY|ShiftMask, XK_f, fullscreen, {0} }, 20 { MODKEY, XK_space, setlayout, {0} }, 21 { MODKEY|ShiftMask, XK_space, togglefloating, {0} }, 22 { MODKEY, XK_0, view, {.ui = ~0 } }, 23 diff --git a/dwm.c b/dwm.c 24 index 8f4fa75..a2237a9 100644 25 --- a/dwm.c 26 +++ b/dwm.c 27 @@ -199,6 +199,7 @@ static void sendmon(Client *c, Monitor *m); 28 static void setclientstate(Client *c, long state); 29 static void setfocus(Client *c); 30 static void setfullscreen(Client *c, int fullscreen); 31 +static void fullscreen(const Arg *arg); 32 static void setlayout(const Arg *arg); 33 static void setmfact(const Arg *arg); 34 static void setup(void); 35 @@ -1507,6 +1508,22 @@ setfullscreen(Client *c, int fullscreen) 36 } 37 } 38 39 +Layout *last_layout; 40 +void 41 +fullscreen(const Arg *arg) 42 +{ 43 + if (selmon->pertag->ltidxs[selmon->pertag->curtag][selmon->sellt] != &layouts[2]) { 44 + for(last_layout = (Layout *)layouts; last_layout != selmon->lt[selmon->sellt]; last_layout++); 45 + setlayout(&((Arg) { .v = &layouts[2] })); 46 + if (selmon->showbar) 47 + togglebar(arg); 48 + } else { 49 + setlayout(&((Arg) { .v = last_layout })); 50 + if (!selmon->showbar) 51 + togglebar(arg); 52 + } 53 +} 54 + 55 void 56 setlayout(const Arg *arg) 57 { 58 -- 59 2.51.2 60