tabbed-client-fullscreen.diff (3631B)
1 diff --git a/config.def.h b/config.def.h 2 index 51bb13d..30ad1a2 100644 3 --- a/config.def.h 4 +++ b/config.def.h 5 @@ -63,4 +63,5 @@ static const Key keys[] = { 6 { MODKEY|ShiftMask, XK_u, toggle, { .v = (void*) &urgentswitch } }, 7 8 { 0, XK_F11, fullscreen, { 0 } }, 9 + { MODKEY, XK_b, togglebar, { 0 } }, 10 }; 11 diff --git a/tabbed.c b/tabbed.c 12 index 2fb5aa7..cf97cc1 100644 13 --- a/tabbed.c 14 +++ b/tabbed.c 15 @@ -125,10 +125,12 @@ static void rotate(const Arg *arg); 16 static void run(void); 17 static void sendxembed(int c, long msg, long detail, long d1, long d2); 18 static void setcmd(int argc, char *argv[], int); 19 +static void setfullscreen(Bool fs); 20 static void setup(void); 21 static void spawn(const Arg *arg); 22 static int textnw(const char *text, unsigned int len); 23 static void toggle(const Arg *arg); 24 +static void togglebar(const Arg *arg); 25 static void unmanage(int c); 26 static void unmapnotify(const XEvent *e); 27 static void updatenumlockmask(void); 28 @@ -156,7 +158,7 @@ static int bh, obh, wx, wy, ww, wh; 29 static unsigned int numlockmask; 30 static Bool running = True, nextfocus, doinitspawn = True, 31 fillagain = False, closelastclient = False, 32 - killclientsfirst = False; 33 + killclientsfirst = False, isfullscreen = False; 34 static Display *dpy; 35 static DC dc; 36 static Atom wmatom[WMLast]; 37 @@ -257,12 +259,14 @@ configurenotify(const XEvent *e) 38 dc.drawable = XCreatePixmap(dpy, root, ww, wh, 39 DefaultDepth(dpy, screen)); 40 41 - if (!obh && (wh <= bh)) { 42 - obh = bh; 43 - bh = 0; 44 - } else if (!bh && (wh > obh)) { 45 - bh = obh; 46 - obh = 0; 47 + if (!isfullscreen) { 48 + if (!obh && (wh <= bh)) { 49 + obh = bh; 50 + bh = 0; 51 + } else if (!bh && (wh > obh)) { 52 + bh = obh; 53 + obh = 0; 54 + } 55 } 56 57 if (sel > -1) 58 @@ -883,6 +887,40 @@ propertynotify(const XEvent *e) 59 } else if (ev->state != PropertyDelete && ev->atom == XA_WM_NAME && 60 (c = getclient(ev->window)) > -1) { 61 updatetitle(c); 62 + } else if (ev->atom == wmatom[WMState] && 63 + (c = getclient(ev->window)) > -1) { 64 + Atom type; 65 + int fmt; 66 + unsigned long nitems, after; 67 + Atom *states = NULL; 68 + Bool wantfs = False; 69 + unsigned long i; 70 + 71 + if (XGetWindowProperty(dpy, clients[c]->win, wmatom[WMState], 72 + 0L, 32L, False, XA_ATOM, &type, &fmt, &nitems, &after, 73 + (unsigned char **)&states) == Success && states) { 74 + for (i = 0; i < nitems; i++) { 75 + if (states[i] == wmatom[WMFullscreen]) { 76 + wantfs = True; 77 + break; 78 + } 79 + } 80 + XFree(states); 81 + } 82 + if (wantfs != isfullscreen) { 83 + isfullscreen = wantfs; 84 + if (isfullscreen) { 85 + obh = bh; 86 + bh = 0; 87 + } else { 88 + bh = obh; 89 + obh = 0; 90 + } 91 + if (sel > -1) 92 + resize(sel, ww, wh - bh); 93 + drawbar(); 94 + setfullscreen(isfullscreen); 95 + } 96 } 97 } 98 99 @@ -981,6 +1019,21 @@ setcmd(int argc, char *argv[], int replace) 100 cmd[cmd_append_pos] = cmd[cmd_append_pos + 1] = NULL; 101 } 102 103 +void 104 +setfullscreen(Bool fs) 105 +{ 106 + XEvent e; 107 + 108 + e.type = ClientMessage; 109 + e.xclient.window = win; 110 + e.xclient.message_type = wmatom[WMState]; 111 + e.xclient.format = 32; 112 + e.xclient.data.l[0] = fs ? 1 : 0; 113 + e.xclient.data.l[1] = wmatom[WMFullscreen]; 114 + e.xclient.data.l[2] = 0; 115 + XSendEvent(dpy, root, False, SubstructureNotifyMask, &e); 116 +} 117 + 118 void 119 setup(void) 120 { 121 @@ -1141,6 +1194,23 @@ toggle(const Arg *arg) 122 *(Bool*) arg->v = !*(Bool*) arg->v; 123 } 124 125 +void 126 +togglebar(const Arg *arg) 127 +{ 128 + if (bh) { 129 + obh = bh; 130 + bh = 0; 131 + } else { 132 + bh = obh; 133 + obh = 0; 134 + } 135 + 136 + if (sel > -1) 137 + resize(sel, ww, wh - bh); 138 + 139 + drawbar(); 140 +} 141 + 142 void 143 unmanage(int c) 144 {