about summary refs log tree commit diff
diff options
context:
space:
mode:
authorManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2019-06-18 13:12:55 +0200
committerManuel Palenzuela <manuelpalenzuelamerino@gmail.com>2019-06-18 13:12:55 +0200
commitd149050886e7d4e6c0f57bf8fc75e77e6a809cff (patch)
tree9d9f87ad80569961b860e44487bb9adc0e24b938
parentAdded togglefullscreen patch and keybinding [Patch] (diff)
downloaddwm-d149050886e7d4e6c0f57bf8fc75e77e6a809cff.tar.gz
dwm-d149050886e7d4e6c0f57bf8fc75e77e6a809cff.tar.bz2
dwm-d149050886e7d4e6c0f57bf8fc75e77e6a809cff.zip
Modified togglefullscreen patch
-rw-r--r--dwm.c27
-rw-r--r--patches/dwm-togglefullscreen.diff51
-rw-r--r--patches/dwm-togglefullscreen.diff.old59
3 files changed, 74 insertions, 63 deletions
diff --git a/dwm.c b/dwm.c
index c05ef8c..501661f 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1773,29 +1773,10 @@ togglefloating(const Arg *arg)
 void
 togglefullscreen(const Arg *arg)
 {
-  if (!selmon->sel->isfullscreen) {
-		XChangeProperty(dpy, selmon->sel->win, netatom[NetWMState], XA_ATOM, 32,
-			PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
-		selmon->sel->isfullscreen = 1;
-		selmon->sel->oldstate = selmon->sel->isfloating;
-		selmon->sel->oldbw = selmon->sel->bw;
-		selmon->sel->bw = 0;
-		selmon->sel->isfloating = 1;
-		resizeclient(selmon->sel, selmon->sel->mon->mx, selmon->sel->mon->my, selmon->sel->mon->mw, selmon->sel->mon->mh);
-		XRaiseWindow(dpy, selmon->sel->win);
-	} else if (selmon->sel->isfullscreen){
-		XChangeProperty(dpy, selmon->sel->win, netatom[NetWMState], XA_ATOM, 32,
-			PropModeReplace, (unsigned char*)0, 0);
-		selmon->sel->isfullscreen = 0;
-		selmon->sel->isfloating = selmon->sel->oldstate;
-		selmon->sel->bw = selmon->sel->oldbw;
-		selmon->sel->x = selmon->sel->oldx;
-		selmon->sel->y = selmon->sel->oldy;
-		selmon->sel->w = selmon->sel->oldw;
-		selmon->sel->h = selmon->sel->oldh;
-		resizeclient(selmon->sel, selmon->sel->x, selmon->sel->y, selmon->sel->w, selmon->sel->h);
-		arrange(selmon->sel->mon);
-	}
+  if (!selmon->sel)
+    return;
+
+  setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
 }
 
 void
diff --git a/patches/dwm-togglefullscreen.diff b/patches/dwm-togglefullscreen.diff
index 78de821..d91632b 100644
--- a/patches/dwm-togglefullscreen.diff
+++ b/patches/dwm-togglefullscreen.diff
@@ -1,22 +1,8 @@
-diff --git a/config.h b/config.h
-index 04fc97f..657e8f2 100644
---- a/config.h
-+++ b/config.h
-
- /* tagging */
-@@ -90,6 +90,7 @@ static Key keys[] = {
-        { MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
-        { MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
-        { MODKEY,                       XK_Return, zoom,           {0} },
-+       { MODKEY,                       XK_f,      togglefullscreen,  {0} },
-        { MODKEY,                       XK_Tab,    view,           {0} },
-        { MODKEY,                       XK_q,      killclient,     {0} },
-        /*
 diff --git a/dwm.c b/dwm.c
-index cdba5eb..c05ef8c 100644
+index 4465af1..7b63b1f 100644
 --- a/dwm.c
 +++ b/dwm.c
-@@ -218,6 +218,7 @@ static void tagmon(const Arg *arg);
+@@ -211,6 +211,7 @@ static void tagmon(const Arg *arg);
  static void tile(Monitor *);
  static void togglebar(const Arg *arg);
  static void togglefloating(const Arg *arg);
@@ -24,36 +10,21 @@ index cdba5eb..c05ef8c 100644
  static void toggletag(const Arg *arg);
  static void toggleview(const Arg *arg);
  static void unfocus(Client *c, int setfocus);
-
+@@ -1719,6 +1720,15 @@ togglefloating(const Arg *arg)
+        arrange(selmon);
+ }
 
 +void
 +togglefullscreen(const Arg *arg)
 +{
-+  if (!selmon->sel->isfullscreen) {
-+               XChangeProperty(dpy, selmon->sel->win, netatom[NetWMState], XA_ATOM, 32,
-+                       PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
-+               selmon->sel->isfullscreen = 1;
-+               selmon->sel->oldstate = selmon->sel->isfloating;
-+               selmon->sel->oldbw = selmon->sel->bw;
-+               selmon->sel->bw = 0;
-+               selmon->sel->isfloating = 1;
-+               resizeclient(selmon->sel, selmon->sel->mon->mx, selmon->sel->mon->my, selmon->sel->mon->mw, selmon->sel->mon->mh);
-+               XRaiseWindow(dpy, selmon->sel->win);
-+       } else if (selmon->sel->isfullscreen){
-+               XChangeProperty(dpy, selmon->sel->win, netatom[NetWMState], XA_ATOM, 32,
-+                       PropModeReplace, (unsigned char*)0, 0);
-+               selmon->sel->isfullscreen = 0;
-+               selmon->sel->isfloating = selmon->sel->oldstate;
-+               selmon->sel->bw = selmon->sel->oldbw;
-+               selmon->sel->x = selmon->sel->oldx;
-+               selmon->sel->y = selmon->sel->oldy;
-+               selmon->sel->w = selmon->sel->oldw;
-+               selmon->sel->h = selmon->sel->oldh;
-+               resizeclient(selmon->sel, selmon->sel->x, selmon->sel->y, selmon->sel->w, selmon->sel->h);
-+               arrange(selmon->sel->mon);
-+       }
++       if (!selmon->sel)
++               return;
++
++       setfullscreen(selmon->sel, !selmon->sel->isfullscreen);
 +}
 +
  void
  toggletag(const Arg *arg)
  {
+--
+2.21.0
diff --git a/patches/dwm-togglefullscreen.diff.old b/patches/dwm-togglefullscreen.diff.old
new file mode 100644
index 0000000..78de821
--- /dev/null
+++ b/patches/dwm-togglefullscreen.diff.old
@@ -0,0 +1,59 @@
+diff --git a/config.h b/config.h
+index 04fc97f..657e8f2 100644
+--- a/config.h
++++ b/config.h
+
+ /* tagging */
+@@ -90,6 +90,7 @@ static Key keys[] = {
+        { MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
+        { MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
+        { MODKEY,                       XK_Return, zoom,           {0} },
++       { MODKEY,                       XK_f,      togglefullscreen,  {0} },
+        { MODKEY,                       XK_Tab,    view,           {0} },
+        { MODKEY,                       XK_q,      killclient,     {0} },
+        /*
+diff --git a/dwm.c b/dwm.c
+index cdba5eb..c05ef8c 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -218,6 +218,7 @@ static void tagmon(const Arg *arg);
+ static void tile(Monitor *);
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
++static void togglefullscreen(const Arg *arg);
+ static void toggletag(const Arg *arg);
+ static void toggleview(const Arg *arg);
+ static void unfocus(Client *c, int setfocus);
+
+
++void
++togglefullscreen(const Arg *arg)
++{
++  if (!selmon->sel->isfullscreen) {
++               XChangeProperty(dpy, selmon->sel->win, netatom[NetWMState], XA_ATOM, 32,
++                       PropModeReplace, (unsigned char*)&netatom[NetWMFullscreen], 1);
++               selmon->sel->isfullscreen = 1;
++               selmon->sel->oldstate = selmon->sel->isfloating;
++               selmon->sel->oldbw = selmon->sel->bw;
++               selmon->sel->bw = 0;
++               selmon->sel->isfloating = 1;
++               resizeclient(selmon->sel, selmon->sel->mon->mx, selmon->sel->mon->my, selmon->sel->mon->mw, selmon->sel->mon->mh);
++               XRaiseWindow(dpy, selmon->sel->win);
++       } else if (selmon->sel->isfullscreen){
++               XChangeProperty(dpy, selmon->sel->win, netatom[NetWMState], XA_ATOM, 32,
++                       PropModeReplace, (unsigned char*)0, 0);
++               selmon->sel->isfullscreen = 0;
++               selmon->sel->isfloating = selmon->sel->oldstate;
++               selmon->sel->bw = selmon->sel->oldbw;
++               selmon->sel->x = selmon->sel->oldx;
++               selmon->sel->y = selmon->sel->oldy;
++               selmon->sel->w = selmon->sel->oldw;
++               selmon->sel->h = selmon->sel->oldh;
++               resizeclient(selmon->sel, selmon->sel->x, selmon->sel->y, selmon->sel->w, selmon->sel->h);
++               arrange(selmon->sel->mon);
++       }
++}
++
+ void
+ toggletag(const Arg *arg)
+ {