about summary refs log tree commit diff
path: root/patches/dwm-togglefullscreen.diff.old
blob: 78de821687b54b4334b3c58f4ff4930d615c3285 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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)
 {