Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

new ver of monsterwm

  • Loading branch information...
commit f08541b0e2261288f8cc5ef945271ddb1b9dbe65 1 parent 0d090ae
@redlotus authored
Showing with 103 additions and 103 deletions.
  1. +16 −14 config.h
  2. +1 −1  monsterwm.1
  3. +86 −88 monsterwm.c
View
30 config.h
@@ -19,6 +19,7 @@
#define FOLLOW_WINDOW False /* follow the window when moved to a different desktop */
#define FOLLOW_MOUSE False /* focus the window the mouse just entered */
#define CLICK_TO_FOCUS True /* focus an unfocused window when clicked */
+#define FOCUS_BUTTON Button3 /* mouse button to be used along with CLICK_TO_FOCUS */
#define BORDER_WIDTH 2 /* window border width */
#define FOCUS "#8fe3ff" /* focused window border color */
#define UNFOCUS "#444444" /* unfocused window border color */
@@ -60,9 +61,9 @@ static const char *shutdowncmd[] = { "dbus-send", "--system", "--print-reply"
static Key keys[] = {
/* modifier key function argument */
/* Basic commands */
- { MOD4, XK_b, togglepanel, {NULL}},
+ { MOD4|SHIFT, XK_b, togglepanel, {NULL}},
{ MOD4, XK_u, focusurgent, {NULL}},
- { MOD4|SHIFT, XK_c, killclient, {NULL}},
+ { MOD4, XK_c, killclient, {NULL}},
{ MOD4, XK_j, next_win, {NULL}},
{ MOD4, XK_k, prev_win, {NULL}},
{ MOD4, XK_h, resize_master, {.i = -10}}, /* decrease size in px */
@@ -78,10 +79,10 @@ static Key keys[] = {
{ MOD4|SHIFT, XK_j, move_down, {NULL}},
{ MOD4|SHIFT, XK_k, move_up, {NULL}},
{ MOD4|SHIFT, XK_t, switch_mode, {.i = TILE}},
- { MOD4|SHIFT, XK_m, switch_mode, {.i = MONOCLE}},
- { MOD4|SHIFT, XK_b, switch_mode, {.i = BSTACK}},
- { MOD4|SHIFT, XK_g, switch_mode, {.i = GRID}},
- { MOD4|SHIFT, XK_f, switch_mode, {.i = FLOAT}},
+ { MOD4, XK_m, switch_mode, {.i = MONOCLE}},
+ { MOD4, XK_b, switch_mode, {.i = BSTACK}},
+ { MOD4, XK_g, switch_mode, {.i = GRID}},
+ { MOD4, XK_f, switch_mode, {.i = FLOAT}},
{ MOD4|CONTROL, XK_r, quit, {.i = 0}}, /* quit with exit value 0 */
{ MOD4|CONTROL, XK_q, quit, {.i = 1}}, /* quit with exit value 1 */
/* Other commands */
@@ -92,14 +93,15 @@ static Key keys[] = {
{ MOD1|CONTROL, XK_h, spawn, {.com = hibernatecmd}},
{ MOD1|CONTROL, XK_r, spawn, {.com = rebootcmd}},
{ MOD1|CONTROL, XK_q, spawn, {.com = shutdowncmd}},
- //~ { MOD4, XK_j, moveresize, {.v = (int []){ 0, 25, 0, 0 }}}, /* move up */
- //~ { MOD4, XK_k, moveresize, {.v = (int []){ 0, -25, 0, 0 }}}, /* move down */
- //~ { MOD4, XK_l, moveresize, {.v = (int []){ 25, 0, 0, 0 }}}, /* move right */
- //~ { MOD4, XK_h, moveresize, {.v = (int []){ -25, 0, 0, 0 }}}, /* move left */
- //~ { MOD4|SHIFT, XK_j, moveresize, {.v = (int []){ 0, 0, 0, 25 }}}, /* height grow */
- //~ { MOD4|SHIFT, XK_k, moveresize, {.v = (int []){ 0, 0, 0, -25 }}}, /* height shrink */
- //~ { MOD4|SHIFT, XK_l, moveresize, {.v = (int []){ 0, 0, 25, 0 }}}, /* width grow */
- //~ { MOD4|SHIFT, XK_h, moveresize, {.v = (int []){ 0, 0, -25, 0 }}}, /* width shrink */
+ /* Moves, resizes + changes layout*/
+ { MOD1|SHIFT, XK_j, moveresize, {.v = (int []){ 0, 25, 0, 0 }}}, /* move up */
+ { MOD1|SHIFT, XK_k, moveresize, {.v = (int []){ 0, -25, 0, 0 }}}, /* move down */
+ { MOD1|SHIFT, XK_l, moveresize, {.v = (int []){ 25, 0, 0, 0 }}}, /* move right */
+ { MOD1|SHIFT, XK_h, moveresize, {.v = (int []){ -25, 0, 0, 0 }}}, /* move left */
+ { MOD1|CONTROL, XK_j, moveresize, {.v = (int []){ 0, 0, 0, 25 }}}, /* height grow */
+ { MOD1|CONTROL, XK_k, moveresize, {.v = (int []){ 0, 0, 0, -25 }}}, /* height shrink */
+ { MOD1|CONTROL, XK_l, moveresize, {.v = (int []){ 0, 0, 25, 0 }}}, /* width grow */
+ { MOD1|CONTROL, XK_h, moveresize, {.v = (int []){ 0, 0, -25, 0 }}}, /* width shrink */
DESKTOPCHANGE( XK_1, 0)
DESKTOPCHANGE( XK_2, 1)
DESKTOPCHANGE( XK_3, 2)
View
2  monsterwm.1
@@ -6,7 +6,7 @@ monsterwm \- minimal and dynamic tiling window manager
.RB [ \-v ]
.SH DESCRIPTION
.I monsterwm
-is a minimal, lightweight, tiny but monsterous, dynamic tiling window manager.
+is a minimal, lightweight, tiny but monstrous, dynamic tiling window manager.
.P
.SH MODES
.I monsterwm
View
174 monsterwm.c
@@ -13,10 +13,12 @@
#include <X11/Xproto.h>
#include <X11/Xatom.h>
-#define LENGTH(x) (sizeof(x)/sizeof(*x))
-#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
-#define BUTTONMASK ButtonPressMask|ButtonReleaseMask
-#define ISFFT(c) (c->isfull || c->isfloat || c->istrans)
+#define LENGTH(x) (sizeof(x)/sizeof(*x))
+#define CLEANMASK(mask) (mask & ~(numlockmask | LockMask))
+#define BUTTONMASK ButtonPressMask|ButtonReleaseMask
+#define ISFFT(c) (c->isfull || c->isfloat || c->istrans)
+#define MVRSZ(c, _x, _y, _w, _h) XMoveResizeWindow(dis, c->win, c->x = _x, c->y = _y, _w, _h)
+#define MV(c, _x, _y) XMoveWindow(dis, c->win, c->x = _x, c->y = _y)
enum { RESIZE, MOVE };
enum { TILE, MONOCLE, BSTACK, GRID, FLOAT, MODES };
@@ -118,6 +120,7 @@ typedef struct Client {
struct Client *next;
Bool isurgn, isfull, isfloat, istrans;
Window win;
+ int x, y;
} Client;
/**
@@ -178,14 +181,14 @@ static int xerrorstart(Display *dis, XErrorEvent *ee);
* ww - screen width
* dis - the display aka dpy
* root - the root window
- * wmatons - array holding atoms for ICCCM support
+ * wmatoms - array holding atoms for ICCCM support
* netatoms - array holding atoms for EWMH support
* dekstops - array of managed desktops
* currdeskidx - which desktop is currently active
*/
static Bool running = True;
-static int wh, ww, currdeskidx = 0, prevdeskidx = 0, retval = 0;
-static unsigned int numlockmask = 0, win_unfocus, win_focus;
+static int wh, ww, off_x, off_y, currdeskidx, prevdeskidx, retval;
+static unsigned int numlockmask, win_unfocus, win_focus;
static Display *dis;
static Window root;
static Atom wmatoms[WM_COUNT], netatoms[NET_COUNT];
@@ -245,11 +248,10 @@ Client* addwindow(Window w, Desktop *d) {
* call the appropriate handler
*/
void buttonpress(XEvent *e) {
- Desktop *d = NULL;
- Client *c = NULL;
+ Desktop *d = NULL; Client *c = NULL;
+ Bool w = wintoclient(e->xbutton.window, &c, &d);
- if (wintoclient(e->xbutton.window, &c, &d) && CLICK_TO_FOCUS &&
- c != d->curr && e->xbutton.button == Button1) focus(c, d);
+ if (w && CLICK_TO_FOCUS && c != d->curr && e->xbutton.button == FOCUS_BUTTON) focus(c, d);
for (unsigned int i = 0; i < LENGTH(buttons); i++)
if (CLEANMASK(buttons[i].mask) == CLEANMASK(e->xbutton.state) &&
@@ -261,21 +263,15 @@ void buttonpress(XEvent *e) {
/**
* focus another desktop
- *
- * to avoid flickering (esp. monocle mode):
- * first map the new windows
- * first the current window and then all other
- * then unmap the old windows
- * first all others then the current
+ * move in new windows
+ * move out old windows
*/
void change_desktop(const Arg *arg) {
if (arg->i == currdeskidx || arg->i < 0 || arg->i >= DESKTOPS) return;
Desktop *d = &desktops[(prevdeskidx = currdeskidx)], *n = &desktops[(currdeskidx = arg->i)];
- if (n->curr) XMapWindow(dis, n->curr->win);
- for (Client *c = n->head; c; c = c->next) XMapWindow(dis, c->win);
- for (Client *c = d->head; c; c = c->next) if (c != d->curr) XUnmapWindow(dis, c->win);
- if (d->curr) XUnmapWindow(dis, d->curr->win);
+ for (Client *c = n->head; c; c = c->next) MV(c, c->x - off_x, c->y - off_y);
if (n->head) { tile(n); focus(n->curr, n); }
+ for (Client *c = d->head; c; c = c->next) MV(c, c->x + off_x, c->y + off_y);
desktopinfo();
}
@@ -307,7 +303,7 @@ void client_to_desktop(const Arg *arg) {
/* unlink current client from current desktop */
if (d->head == c || !p) d->head = c->next; else p->next = c->next;
c->next = NULL;
- if (XUnmapWindow(dis, c->win)) focus(d->prev, d);
+ if (MV(c, c->x + off_x, c->y + off_y)) focus(d->prev, d);
if (!(c->isfloat || c->istrans) || (d->head && !d->head->next)) tile(d);
/* link client to new desktop and make it the current */
@@ -338,9 +334,7 @@ void client_to_desktop(const Arg *arg) {
* on its desktop.
*/
void clientmessage(XEvent *e) {
- Desktop *d = NULL;
- Client *c = NULL;
-
+ Desktop *d = NULL; Client *c = NULL;
if (!wintoclient(e->xclient.window, &c, &d)) return;
if (e->xclient.message_type == netatoms[NET_WM_STATE] && (
@@ -359,27 +353,29 @@ void clientmessage(XEvent *e) {
* a configure request attempts to reconfigure those properties for a window.
*
* we don't really care about those values, because a tiling wm will impose
- * by its own, the position, size and stacking order of windows.
- * however the requested values must be set initially, or
- * the window will misbehave (see gedit, geany, gvim etc).
+ * its own values for those properties.
+ * however the requested values must be set initially for some windows,
+ * otherwise the window will misbehave or even crash (see gedit, geany, gvim).
*
- * this is actually not respecting the prefered size of the windows,
* some windows depend on the number of columns and rows to set their
- * size, and not on pixels (terminals, consoles, some editors).
+ * size, and not on pixels (terminals, consoles, some editors etc).
* normally those clients when tiled and respecting the prefered size
* will create gaps around them (window_hints).
- * when the configure request is sent and processed,
- * clients are tiled to match the wm's prefered size.
+ * however, clients are tiled to match the wm's prefered size,
+ * not respecting those prefered values.
*
- * set the appropriate values as requested,
- * then tile the desktop that contain that window.
+ * some windows implement window manager functions themselves.
+ * that is windows explicitly steal focus, or manage subwindows,
+ * or move windows around w/o the window manager's help, etc..
+ * to disallow this behavior, we 'tile()' the desktop to which
+ * the window that sent the configure request belongs.
*/
void configurerequest(XEvent *e) {
XConfigureRequestEvent *ev = &e->xconfigurerequest;
XWindowChanges wc = { ev->x, ev->y, ev->width, ev->height, ev->border_width, ev->above, ev->detail };
- XConfigureWindow(dis, ev->window, ev->value_mask, &wc);
- XSync(dis, False);
- tile(&desktops[currdeskidx]);
+ if (XConfigureWindow(dis, ev->window, ev->value_mask, &wc)) XSync(dis, False);
+ Desktop *d = NULL; Client *c = NULL;
+ if (wintoclient(ev->window, &c, &d)) tile(d);
}
/**
@@ -431,8 +427,7 @@ void desktopinfo(void) {
* on receival, remove the client that held that window
*/
void destroynotify(XEvent *e) {
- Desktop *d = NULL;
- Client *c = NULL;
+ Desktop *d = NULL; Client *c = NULL;
if (wintoclient(e->xdestroywindow.window, &c, &d)) removeclient(c, d);
}
@@ -443,8 +438,7 @@ void destroynotify(XEvent *e) {
* and will get focus if FOLLOW_MOUSE is set in the config.
*/
void enternotify(XEvent *e) {
- Desktop *d = NULL;
- Client *c = NULL;
+ Desktop *d = NULL; Client *c = NULL;
if (FOLLOW_MOUSE && wintoclient(e->xcrossing.window, &c, &d) && e->xcrossing.mode == NotifyNormal
&& e->xcrossing.detail != NotifyInferior && e->xcrossing.window != d->curr->win) focus(c, d);
@@ -541,7 +535,7 @@ void focus(Client *c, Desktop *d) {
}
XRestackWindows(dis, w, LENGTH(w));
- XSetInputFocus(dis, d->curr->win, RevertToPointerRoot, CurrentTime);
+ if (&desktops[currdeskidx] == d) XSetInputFocus(dis, d->curr->win, RevertToPointerRoot, CurrentTime);
XChangeProperty(dis, root, netatoms[NET_ACTIVE], XA_WINDOW, 32,
PropModeReplace, (unsigned char *)&d->curr->win, 1);
@@ -559,9 +553,7 @@ void focus(Client *c, Desktop *d) {
* client, by the user, through the wm.
*/
void focusin(XEvent *e) {
- Desktop *d = NULL;
- Client *c = NULL;
-
+ Desktop *d = NULL; Client *c = NULL;
if (wintoclient(e->xfocus.window, &c, &d) && d->curr &&
e->xfocus.window != d->curr->win) focus(d->curr, d);
}
@@ -599,9 +591,9 @@ void grabbuttons(Client *c) {
unsigned int b, m, modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
for (m = 0; CLICK_TO_FOCUS && m < LENGTH(modifiers); m++)
- if (c != desktops[currdeskidx].curr) XGrabButton(dis, Button1, modifiers[m],
+ if (c != desktops[currdeskidx].curr) XGrabButton(dis, FOCUS_BUTTON, modifiers[m],
c->win, False, BUTTONMASK, GrabModeAsync, GrabModeAsync, None, None);
- else XUngrabButton(dis, Button1, modifiers[m], c->win);
+ else XUngrabButton(dis, FOCUS_BUTTON, modifiers[m], c->win);
for (b = 0, m = 0; b < LENGTH(buttons); b++, m = 0) while (m < LENGTH(modifiers))
XGrabButton(dis, buttons[b].button, buttons[b].mask|modifiers[m++], c->win,
@@ -639,7 +631,7 @@ void grid(int x, int y, int w, int h, const Desktop *d) {
for (Client *c = d->head; c; c = c->next) {
if (ISFFT(c)) continue; else ++i;
if (i/rows + 1 > cols - n%cols) rows = n/cols + 1;
- XMoveResizeWindow(dis, c->win, x + cn*cw, y + rn*ch/rows, cw - BORDER_WIDTH, ch/rows - BORDER_WIDTH);
+ MVRSZ(c, (x + cn*cw), (y + rn*ch/rows), (cw - BORDER_WIDTH), (ch/rows - BORDER_WIDTH));
if (++rn >= rows) { rn = 0; cn++; }
}
}
@@ -673,7 +665,7 @@ void killclient(void) {
}
/**
- * focus the previously focused desktop
+ * focus the previously/last focused desktop
*/
void last_desktop(void) {
change_desktop(&(Arg){.i = prevdeskidx});
@@ -692,16 +684,15 @@ void last_desktop(void) {
* then display/map the window, else, if follow is set, focus the new desktop.
*/
void maprequest(XEvent *e) {
- Desktop *d = NULL;
- Client *c = NULL;
+ Desktop *d = NULL; Client *c = NULL;
Window w = e->xmaprequest.window;
XWindowAttributes wa = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ if (wintoclient(w, &c, &d) || (XGetWindowAttributes(dis, w, &wa) && wa.override_redirect)) return;
+
XClassHint ch = {0, 0};
Bool follow = False, floating = False;
int newdsk = currdeskidx;
- if (wintoclient(w, &c, &d) || (XGetWindowAttributes(dis, w, &wa) && wa.override_redirect)) return;
-
if (XGetClassHint(dis, w, &ch)) for (unsigned int i = 0; i < LENGTH(rules); i++)
if (strstr(ch.res_class, rules[i].class) || strstr(ch.res_name, rules[i].class)) {
if (rules[i].desktop >= 0 && rules[i].desktop < DESKTOPS) newdsk = rules[i].desktop;
@@ -714,7 +705,7 @@ void maprequest(XEvent *e) {
c = addwindow(w, (d = &desktops[newdsk])); /* from now on, use c->win */
c->istrans = XGetTransientForHint(dis, c->win, &w);
if ((c->isfloat = (floating || d->mode == FLOAT)) && !c->istrans)
- XMoveWindow(dis, c->win, (ww - wa.width)/2, (wh - wa.height)/2);
+ MV(c, (ww - wa.width)/2, (wh - wa.height)/2);
int i; unsigned long l; unsigned char *state = NULL; Atom a;
if (XGetWindowProperty(dis, c->win, netatoms[NET_WM_STATE], 0L, sizeof a,
@@ -722,8 +713,9 @@ void maprequest(XEvent *e) {
setfullscreen(c, d, (*(Atom *)state == netatoms[NET_FULLSCREEN]));
if (state) XFree(state);
- if (currdeskidx == newdsk) { if (!ISFFT(c)) tile(d); XMapWindow(dis, c->win); }
- else if (follow) change_desktop(&(Arg){.i = newdsk});
+ if (currdeskidx != newdsk) MV(c, c->x + off_x, c->y + off_y); else if (!ISFFT(c)) tile(d);
+ if (follow) change_desktop(&(Arg){.i = newdsk});
+ XMapWindow(dis, c->win);
focus(c, d);
if (!follow) desktopinfo();
@@ -752,14 +744,13 @@ void mousemotion(const Arg *arg) {
if (!d->curr || !XGetWindowAttributes(dis, d->curr->win, &wa)) return;
- if (arg->i == RESIZE) XWarpPointer(dis, d->curr->win, d->curr->win, 0, 0, 0, 0, wa.width, wa.height);
+ if (arg->i == RESIZE) XWarpPointer(dis, d->curr->win, d->curr->win, 0, 0, 0, 0, --wa.width, --wa.height);
int rx, ry, c, xw, yh; unsigned int v; Window w;
if (!XQueryPointer(dis, root, &w, &w, &rx, &ry, &c, &c, &v) || w != d->curr->win) return;
if (XGrabPointer(dis, root, False, BUTTONMASK|PointerMotionMask, GrabModeAsync,
GrabModeAsync, None, None, CurrentTime) != GrabSuccess) return;
-
if (!d->curr->isfloat && !d->curr->istrans) { d->curr->isfloat = True; tile(d); focus(d->curr, d); }
do {
@@ -769,7 +760,7 @@ void mousemotion(const Arg *arg) {
yh = (arg->i == MOVE ? wa.y:wa.height) + ev.xmotion.y - ry;
if (arg->i == RESIZE) XResizeWindow(dis, d->curr->win,
xw > MINWSZ ? xw:wa.width, yh > MINWSZ ? yh:wa.height);
- else if (arg->i == MOVE) XMoveWindow(dis, d->curr->win, xw, yh);
+ else if (arg->i == MOVE) MV(d->curr, xw, yh);
} else if (ev.type == ConfigureRequest || ev.type == MapRequest) events[ev.type](&ev);
} while (ev.type != ButtonRelease);
@@ -781,7 +772,7 @@ void mousemotion(const Arg *arg) {
* each window should cover all the available screen space
*/
void monocle(int x, int y, int w, int h, const Desktop *d) {
- for (Client *c = d->head; c; c = c->next) if (!ISFFT(c)) XMoveResizeWindow(dis, c->win, x, y, w, h);
+ for (Client *c = d->head; c; c = c->next) if (!ISFFT(c)) MVRSZ(c, x, y, w, h);
}
/**
@@ -872,8 +863,8 @@ void moveresize(const Arg *arg) {
XWindowAttributes wa;
if (!d->curr || !XGetWindowAttributes(dis, d->curr->win, &wa)) return;
if (!d->curr->isfloat && !d->curr->istrans) { d->curr->isfloat = True; tile(d); focus(d->curr, d); }
- XMoveResizeWindow(dis, d->curr->win, wa.x + ((int *)arg->v)[0], wa.y + ((int *)arg->v)[1],
- wa.width + ((int *)arg->v)[2], wa.height + ((int *)arg->v)[3]);
+ MVRSZ(d->curr, wa.x + ((int *)arg->v)[0], wa.y + ((int *)arg->v)[1],
+ wa.width + ((int *)arg->v)[2], wa.height + ((int *)arg->v)[3]);
}
/**
@@ -908,11 +899,12 @@ void prev_win(void) {
* set unrgent hint for a window
*/
void propertynotify(XEvent *e) {
- Desktop *d = NULL;
- Client *c = NULL;
+ Desktop *d = NULL; Client *c = NULL;
if (e->xproperty.atom != XA_WM_HINTS || !wintoclient(e->xproperty.window, &c, &d)) return;
+
XWMHints *wmh = XGetWMHints(dis, c->win);
c->isurgn = (c != desktops[currdeskidx].curr && wmh && (wmh->flags & XUrgencyHint));
+
if (wmh) XFree(wmh);
desktopinfo();
}
@@ -1003,7 +995,8 @@ void setfullscreen(Client *c, Desktop *d, Bool fullscrn) {
if (fullscrn != c->isfull) XChangeProperty(dis, c->win,
netatoms[NET_WM_STATE], XA_ATOM, 32, PropModeReplace, (unsigned char*)
((c->isfull = fullscrn) ? &netatoms[NET_FULLSCREEN]:0), fullscrn);
- if (fullscrn) XMoveResizeWindow(dis, c->win, 0, 0, ww, wh + PANEL_HEIGHT);
+ Bool b = (&desktops[currdeskidx] == d);
+ if (fullscrn) MVRSZ(c, b ? 0:off_x, b ? 0:off_y, ww, wh + PANEL_HEIGHT);
XSetWindowBorderWidth(dis, c->win, (c->isfull || !d->head->next ? 0:BORDER_WIDTH));
}
@@ -1025,6 +1018,10 @@ void setup(void) {
for (unsigned int d = 0; d < DESKTOPS; d++)
desktops[d] = (Desktop){ .mode = DEFAULT_MODE, .sbar = SHOW_PANEL };
+ /* set offset values used to move windows out of view */
+ off_x = 2 * ww;
+ off_y = 2 * wh;
+
/* get color for focused and unfocused client borders */
win_focus = getcolor(FOCUS, screen);
win_unfocus = getcolor(UNFOCUS, screen);
@@ -1120,24 +1117,24 @@ void stack(int x, int y, int w, int h, const Desktop *d) {
* should be added to the first stack client (p) so that it satisfies sasz,
* and also, does not result in gaps created on the bottom of the screen.
*/
- if (c && !n) XMoveResizeWindow(dis, c->win, x, y, w - 2*BORDER_WIDTH, h - 2*BORDER_WIDTH);
+ if (c && !n) MVRSZ(c, x, y, w - 2*BORDER_WIDTH, h - 2*BORDER_WIDTH);
if (!c || !n) return; else if (n > 1) { p = (z - d->sasz)%n + d->sasz; z = (z - d->sasz)/n; }
/* tile the first non-floating, non-fullscreen window to cover the master area */
- if (b) XMoveResizeWindow(dis, c->win, x, y, w - 2*BORDER_WIDTH, ma - BORDER_WIDTH);
- else XMoveResizeWindow(dis, c->win, x, y, ma - BORDER_WIDTH, h - 2*BORDER_WIDTH);
+ if (b) MVRSZ(c, x, y, w - 2*BORDER_WIDTH, ma - BORDER_WIDTH);
+ else MVRSZ(c, x, y, ma - BORDER_WIDTH, h - 2*BORDER_WIDTH);
/* tile the next non-floating, non-fullscreen (and first) stack window adding p */
for (c = c->next; c && ISFFT(c); c = c->next);
int cw = (b ? h:w) - 2*BORDER_WIDTH - ma, ch = z - BORDER_WIDTH;
- if (b) XMoveResizeWindow(dis, c->win, x, y += ma, ch - BORDER_WIDTH + p, cw);
- else XMoveResizeWindow(dis, c->win, x += ma, y, cw, ch - BORDER_WIDTH + p);
+ if (b) MVRSZ(c, x, y += ma, ch - BORDER_WIDTH + p, cw);
+ else MVRSZ(c, x += ma, y, cw, ch - BORDER_WIDTH + p);
/* tile the rest of the non-floating, non-fullscreen stack windows */
for (b ? (x += ch+p):(y += ch+p), c = c->next; c; c = c->next) {
if (ISFFT(c)) continue;
- if (b) { XMoveResizeWindow(dis, c->win, x, y, ch, cw); x += z; }
- else { XMoveResizeWindow(dis, c->win, x, y, cw, ch); y += z; }
+ if (b) { MVRSZ(c, x, y, ch, cw); x += z; }
+ else { MVRSZ(c, x, y, cw, ch); y += z; }
}
}
@@ -1164,10 +1161,8 @@ void swap_master(void) {
*/
void switch_mode(const Arg *arg) {
Desktop *d = &desktops[currdeskidx];
- if (d->mode == arg->i && d->mode != FLOAT)
- for (Client *c = d->head; c; c = c->next) c->isfloat = False;
- if ((d->mode = arg->i) == FLOAT)
- for (Client *c = d->head; c; c = c->next) c->isfloat = True;
+ if (d->mode != arg->i) d->mode = arg->i;
+ else if (d->mode != FLOAT) for (Client *c = d->head; c; c = c->next) c->isfloat = False;
if (d->head) { tile(d); focus(d->curr, d); }
desktopinfo();
}
@@ -1177,7 +1172,7 @@ void switch_mode(const Arg *arg) {
* call the tiling handler fucntion taking account the panel height
*/
void tile(Desktop *d) {
- if (!d->head || d->mode == FLOAT) return; /* nothing to arange */
+ if (&desktops[currdeskidx] != d || !d->head || d->mode == FLOAT) return;
layout[d->head->next ? d->mode:MONOCLE](0, TOP_PANEL && d->sbar ? PANEL_HEIGHT:0,
ww, wh + (d->sbar ? 0:PANEL_HEIGHT), d);
}
@@ -1191,13 +1186,12 @@ void togglepanel(void) {
}
/**
- * windows that request to unmap should lose their
- * client, so invisible windows do not exist on screen
+ * windows that request to unmap should lose their client
+ * so invisible windows do not exist on screen
*/
void unmapnotify(XEvent *e) {
- Desktop *d = NULL;
- Client *c = NULL;
- if (e->xunmap.send_event && wintoclient(e->xunmap.window, &c, &d)) removeclient(c, d);
+ Desktop *d = NULL; Client *c = NULL;
+ if (wintoclient(e->xunmap.window, &c, &d)) removeclient(c, d);
}
/**
@@ -1214,12 +1208,14 @@ Bool wintoclient(Window w, Client **c, Desktop **d) {
* thus those cases are ignored (especially on UnmapNotify's).
*/
int xerror(__attribute__((unused)) Display *dis, XErrorEvent *ee) {
- if (ee->error_code == BadWindow || (ee->error_code == BadAccess && ee->request_code == X_GrabKey)
- || (ee->error_code == BadMatch && (ee->request_code == X_SetInputFocus
- || ee->request_code == X_ConfigureWindow))
- || (ee->error_code == BadDrawable && (ee->request_code == X_PolyFillRectangle
- || ee->request_code == X_CopyArea || ee->request_code == X_PolySegment
- || ee->request_code == X_PolyText8))) return 0;
+ if ((ee->error_code == BadAccess && (ee->request_code == X_GrabKey
+ || ee->request_code == X_GrabButton))
+ || (ee->error_code == BadMatch && (ee->request_code == X_SetInputFocus
+ || ee->request_code == X_ConfigureWindow))
+ || (ee->error_code == BadDrawable && (ee->request_code == X_PolyFillRectangle
+ || ee->request_code == X_CopyArea || ee->request_code == X_PolySegment
+ || ee->request_code == X_PolyText8))
+ || ee->error_code == BadWindow) return 0;
err(EXIT_FAILURE, "xerror: request: %d code: %d", ee->request_code, ee->error_code);
}
@@ -1243,3 +1239,5 @@ int main(int argc, char *argv[]) {
XCloseDisplay(dis);
return retval;
}
+
+/* vim: set expandtab ts=4 sts=4 sw=4 : */
Please sign in to comment.
Something went wrong with that request. Please try again.