dwm.c
changeset 1107 589074fac88d
parent 1106 084b17f96d9b
child 1108 aab1c3addbaf
equal deleted inserted replaced
1106:084b17f96d9b 1107:589074fac88d
    69 	int minax, maxax, minay, maxay;
    69 	int minax, maxax, minay, maxay;
    70 	long flags;
    70 	long flags;
    71 	unsigned int border, oldborder;
    71 	unsigned int border, oldborder;
    72 	Bool isbanned, isfixed, isfloating, isurgent;
    72 	Bool isbanned, isfixed, isfloating, isurgent;
    73 	Bool *tags;
    73 	Bool *tags;
       
    74 	View *view;
    74 	Client *next;
    75 	Client *next;
    75 	Client *prev;
    76 	Client *prev;
    76 	Client *snext;
    77 	Client *snext;
    77 	Window win;
    78 	Window win;
    78 };
    79 };
   108 	const char *prop;
   109 	const char *prop;
   109 	const char *tag;
   110 	const char *tag;
   110 	Bool isfloating;
   111 	Bool isfloating;
   111 } Rule;
   112 } Rule;
   112 
   113 
   113 typedef struct {
       
   114 	const char name[MAXTAGLEN];
       
   115 	unsigned int view;
       
   116 } Tag;
       
   117 
       
   118 struct View {
   114 struct View {
       
   115 	unsigned int id;
   119 	int x, y, w, h, wax, way, wah, waw;
   116 	int x, y, w, h, wax, way, wah, waw;
   120 	double mwfact;
   117 	double mwfact;
   121 	Layout *layout;
   118 	Layout *layout;
   122 	Window barwin;
   119 	Window barwin;
   123 };
   120 };
   137 void configurerequest(XEvent *e);
   134 void configurerequest(XEvent *e);
   138 void destroynotify(XEvent *e);
   135 void destroynotify(XEvent *e);
   139 void detach(Client *c);
   136 void detach(Client *c);
   140 void detachstack(Client *c);
   137 void detachstack(Client *c);
   141 void drawbar(View *v);
   138 void drawbar(View *v);
   142 void drawsquare(View *v, Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
   139 void drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]);
   143 void drawtext(View *v, const char *text, unsigned long col[ColLast], Bool invert);
   140 void drawtext(const char *text, unsigned long col[ColLast], Bool invert);
   144 void *emallocz(unsigned int size);
   141 void *emallocz(unsigned int size);
   145 void enternotify(XEvent *e);
   142 void enternotify(XEvent *e);
   146 void eprint(const char *errstr, ...);
   143 void eprint(const char *errstr, ...);
   147 void expose(XEvent *e);
   144 void expose(XEvent *e);
   148 void floating(View *v); /* default floating layout */
   145 void floating(View *v); /* default floating layout */
   151 void focusnext(const char *arg);
   148 void focusnext(const char *arg);
   152 void focusprev(const char *arg);
   149 void focusprev(const char *arg);
   153 Client *getclient(Window w);
   150 Client *getclient(Window w);
   154 unsigned long getcolor(const char *colstr);
   151 unsigned long getcolor(const char *colstr);
   155 View *getviewbar(Window barwin);
   152 View *getviewbar(Window barwin);
   156 View *getview(Client *c);
       
   157 long getstate(Window w);
   153 long getstate(Window w);
   158 Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
   154 Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
   159 void grabbuttons(Client *c, Bool focused);
   155 void grabbuttons(Client *c, Bool focused);
   160 void grabkeys(void);
   156 void grabkeys(void);
   161 unsigned int idxoftag(const char *t);
   157 unsigned int idxoftag(const char *t);
   209 void selectview(const char *arg);
   205 void selectview(const char *arg);
   210 
   206 
   211 /* variables */
   207 /* variables */
   212 char stext[256], buf[256];
   208 char stext[256], buf[256];
   213 int nviews = 1;
   209 int nviews = 1;
   214 View *selview;
       
   215 int screen;
   210 int screen;
   216 int (*xerrorxlib)(Display *, XErrorEvent *);
   211 int (*xerrorxlib)(Display *, XErrorEvent *);
   217 unsigned int bh, bpos;
   212 unsigned int bh, bpos;
   218 unsigned int blw = 0;
   213 unsigned int blw = 0;
   219 unsigned int numlockmask = 0;
   214 unsigned int numlockmask = 0;
   244 Client *stack = NULL;
   239 Client *stack = NULL;
   245 Cursor cursor[CurLast];
   240 Cursor cursor[CurLast];
   246 Display *dpy;
   241 Display *dpy;
   247 DC dc = {0};
   242 DC dc = {0};
   248 View *views;
   243 View *views;
       
   244 View *selview;
   249 Window root;
   245 Window root;
   250 
   246 
   251 /* configuration, allows nested code to access above variables */
   247 /* configuration, allows nested code to access above variables */
   252 #include "config.h"
   248 #include "config.h"
   253 
   249 
   258 
   254 
   259 	for(i = 0; i < LENGTH(tags); i++)
   255 	for(i = 0; i < LENGTH(tags); i++)
   260 		if(c->tags[i] && vtags[i] != vtags[tidx])
   256 		if(c->tags[i] && vtags[i] != vtags[tidx])
   261 			return; /* conflict */
   257 			return; /* conflict */
   262 	c->tags[tidx] = True;
   258 	c->tags[tidx] = True;
       
   259 	c->view = &views[vtags[tidx]];
   263 }
   260 }
   264 
   261 
   265 void
   262 void
   266 applyrules(Client *c) {
   263 applyrules(Client *c) {
   267 	unsigned int i;
   264 	unsigned int i;
   286 	}
   283 	}
   287 	if(ch.res_class)
   284 	if(ch.res_class)
   288 		XFree(ch.res_class);
   285 		XFree(ch.res_class);
   289 	if(ch.res_name)
   286 	if(ch.res_name)
   290 		XFree(ch.res_name);
   287 		XFree(ch.res_name);
   291 	if(!matched)
   288 	if(!matched) {
   292 		memcpy(c->tags, seltags, sizeof initags);
   289 		memcpy(c->tags, seltags, sizeof initags);
       
   290 		c->view = selview;
       
   291 	}
   293 }
   292 }
   294 
   293 
   295 
   294 
   296 
   295 
   297 void
   296 void
   328 
   327 
   329 void
   328 void
   330 ban(Client *c) {
   329 ban(Client *c) {
   331 	if(c->isbanned)
   330 	if(c->isbanned)
   332 		return;
   331 		return;
   333 	XMoveWindow(dpy, c->win, c->x + 3 * getview(c)->w, c->y);
   332 	XMoveWindow(dpy, c->win, c->x + 3 * c->view->w, c->y);
   334 	c->isbanned = True;
   333 	c->isbanned = True;
   335 }
   334 }
   336 
   335 
   337 void
   336 void
   338 buttonpress(XEvent *e) {
   337 buttonpress(XEvent *e) {
   339 	unsigned int i, x;
   338 	unsigned int i, x;
   340 	Client *c;
   339 	Client *c;
   341 	XButtonPressedEvent *ev = &e->xbutton;
   340 	XButtonPressedEvent *ev = &e->xbutton;
   342 
   341 
   343 	View *v = selview;
   342 	if(ev->window == selview->barwin) {
   344 
       
   345 	if(ev->window == v->barwin) {
       
   346 		x = 0;
   343 		x = 0;
   347 		for(i = 0; i < LENGTH(tags); i++) {
   344 		for(i = 0; i < LENGTH(tags); i++) {
   348 			x += textw(tags[i]);
   345 			x += textw(tags[i]);
   349 			if(ev->x < x) {
   346 			if(ev->x < x) {
   350 				if(ev->button == Button1) {
   347 				if(ev->button == Button1) {
   368 	else if((c = getclient(ev->window))) {
   365 	else if((c = getclient(ev->window))) {
   369 		focus(c);
   366 		focus(c);
   370 		if(CLEANMASK(ev->state) != MODKEY)
   367 		if(CLEANMASK(ev->state) != MODKEY)
   371 			return;
   368 			return;
   372 		if(ev->button == Button1) {
   369 		if(ev->button == Button1) {
   373 			restack(getview(c));
   370 			restack(c->view);
   374 			movemouse(c);
   371 			movemouse(c);
   375 		}
   372 		}
   376 		else if(ev->button == Button2) {
   373 		else if(ev->button == Button2) {
   377 			if((floating != v->layout->arrange) && c->isfloating)
   374 			if((floating != c->view->layout->arrange) && c->isfloating)
   378 				togglefloating(NULL);
   375 				togglefloating(NULL);
   379 			else
   376 			else
   380 				zoom(NULL);
   377 				zoom(NULL);
   381 		}
   378 		}
   382 		else if(ev->button == Button3 && !c->isfixed) {
   379 		else if(ev->button == Button3 && !c->isfixed) {
   383 			restack(getview(c));
   380 			restack(c->view);
   384 			resizemouse(c);
   381 			resizemouse(c);
   385 		}
   382 		}
   386 	}
   383 	}
   387 }
   384 }
   388 
   385 
   455 		v->w = ev->width;
   452 		v->w = ev->width;
   456 		v->h = ev->height;
   453 		v->h = ev->height;
   457 		XFreePixmap(dpy, dc.drawable);
   454 		XFreePixmap(dpy, dc.drawable);
   458 		dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(root, screen), bh, DefaultDepth(dpy, screen));
   455 		dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(root, screen), bh, DefaultDepth(dpy, screen));
   459 		XResizeWindow(dpy, v->barwin, v->w, bh);
   456 		XResizeWindow(dpy, v->barwin, v->w, bh);
   460 		updatebarpos(v);
   457 		updatebarpos(selview);
   461 		arrange();
   458 		arrange();
   462 	}
   459 	}
   463 }
   460 }
   464 
   461 
   465 void
   462 void
   467 	Client *c;
   464 	Client *c;
   468 	XConfigureRequestEvent *ev = &e->xconfigurerequest;
   465 	XConfigureRequestEvent *ev = &e->xconfigurerequest;
   469 	XWindowChanges wc;
   466 	XWindowChanges wc;
   470 
   467 
   471 	if((c = getclient(ev->window))) {
   468 	if((c = getclient(ev->window))) {
   472 		View *v = getview(c);
   469 		View *v = c->view;
   473 		if(ev->value_mask & CWBorderWidth)
   470 		if(ev->value_mask & CWBorderWidth)
   474 			c->border = ev->border_width;
   471 			c->border = ev->border_width;
   475 		if(c->isfixed || c->isfloating || (floating == v->layout->arrange)) {
   472 		if(c->isfixed || c->isfloating || (floating == v->layout->arrange)) {
   476 			if(ev->value_mask & CWX)
   473 			if(ev->value_mask & CWX)
   477 				c->x = v->x + ev->x;
   474 				c->x = v->x + ev->x;
   539 drawbar(View *v) {
   536 drawbar(View *v) {
   540 	int i, x;
   537 	int i, x;
   541 	Client *c;
   538 	Client *c;
   542 
   539 
   543 	dc.x = 0;
   540 	dc.x = 0;
   544 	for(c = stack; c && (!isvisible(c) || getview(c) != v); c = c->snext);
   541 	for(c = stack; c && (!isvisible(c) || c->view != v); c = c->snext);
   545 	for(i = 0; i < LENGTH(tags); i++) {
   542 	for(i = 0; i < LENGTH(tags); i++) {
       
   543 		if(&views[vtags[i]] != v)
       
   544 			continue;
   546 		dc.w = textw(tags[i]);
   545 		dc.w = textw(tags[i]);
   547 		if(seltags[i]) {
   546 		if(seltags[i]) {
   548 			drawtext(v, tags[i], dc.sel, isurgent(i));
   547 			drawtext(tags[i], dc.sel, isurgent(i));
   549 			drawsquare(v, c && c->tags[i], isoccupied(i), isurgent(i), dc.sel);
   548 			drawsquare(c && c->tags[i], isoccupied(i), isurgent(i), dc.sel);
   550 		}
   549 		}
   551 		else {
   550 		else {
   552 			drawtext(v, tags[i], dc.norm, isurgent(i));
   551 			drawtext(tags[i], dc.norm, isurgent(i));
   553 			drawsquare(v, c && c->tags[i], isoccupied(i), isurgent(i), dc.norm);
   552 			drawsquare(c && c->tags[i], isoccupied(i), isurgent(i), dc.norm);
   554 		}
   553 		}
   555 		dc.x += dc.w;
   554 		dc.x += dc.w;
   556 	}
   555 	}
   557 	dc.w = blw;
   556 	dc.w = blw;
   558 	drawtext(v, v->layout->symbol, dc.norm, False);
   557 	drawtext(v->layout->symbol, dc.norm, False);
   559 	x = dc.x + dc.w;
   558 	x = dc.x + dc.w;
   560 	if(v == selview) {
   559 	if(v == selview) {
   561 		dc.w = textw(stext);
   560 		dc.w = textw(stext);
   562 		dc.x = v->w - dc.w;
   561 		dc.x = v->w - dc.w;
   563 		if(dc.x < x) {
   562 		if(dc.x < x) {
   564 			dc.x = x;
   563 			dc.x = x;
   565 			dc.w = v->w - x;
   564 			dc.w = v->w - x;
   566 		}
   565 		}
   567 		drawtext(v, stext, dc.norm, False);
   566 		drawtext(stext, dc.norm, False);
   568 	}
   567 	}
   569 	else
   568 	else
   570 		dc.x = v->w;
   569 		dc.x = v->w;
   571 	if((dc.w = dc.x - x) > bh) {
   570 	if((dc.w = dc.x - x) > bh) {
   572 		dc.x = x;
   571 		dc.x = x;
   573 		if(c) {
   572 		if(c) {
   574 			drawtext(v, c->name, dc.sel, False);
   573 			drawtext(c->name, dc.sel, False);
   575 			drawsquare(v, False, c->isfloating, False, dc.sel);
   574 			drawsquare(False, c->isfloating, False, dc.sel);
   576 		}
   575 		}
   577 		else
   576 		else
   578 			drawtext(v, NULL, dc.norm, False);
   577 			drawtext(NULL, dc.norm, False);
   579 	}
   578 	}
   580 	XCopyArea(dpy, dc.drawable, v->barwin, dc.gc, 0, 0, v->w, bh, 0, 0);
   579 	XCopyArea(dpy, dc.drawable, v->barwin, dc.gc, 0, 0, v->w, bh, 0, 0);
   581 	XSync(dpy, False);
   580 	XSync(dpy, False);
   582 }
   581 }
   583 
   582 
   584 void
   583 void
   585 drawsquare(View *v, Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
   584 drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
   586 	int x;
   585 	int x;
   587 	XGCValues gcv;
   586 	XGCValues gcv;
   588 	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
   587 	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
   589 
   588 
   590 	gcv.foreground = col[invert ? ColBG : ColFG];
   589 	gcv.foreground = col[invert ? ColBG : ColFG];
   601 		XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1);
   600 		XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1);
   602 	}
   601 	}
   603 }
   602 }
   604 
   603 
   605 void
   604 void
   606 drawtext(View *v, const char *text, unsigned long col[ColLast], Bool invert) {
   605 drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
   607 	int x, y, w, h;
   606 	int x, y, w, h;
   608 	unsigned int len, olen;
   607 	unsigned int len, olen;
   609 	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
   608 	XRectangle r = { dc.x, dc.y, dc.w, dc.h };
   610 
   609 
   611 	XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
   610 	XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
   678 void
   677 void
   679 expose(XEvent *e) {
   678 expose(XEvent *e) {
   680 	View *v;
   679 	View *v;
   681 	XExposeEvent *ev = &e->xexpose;
   680 	XExposeEvent *ev = &e->xexpose;
   682 
   681 
   683 	if(ev->count == 0 && (v = getviewbar(ev->window)))
   682 	if(ev->count == 0 && ((v = getviewbar(ev->window))))
   684 		drawbar(v);
   683 		drawbar(v);
   685 }
   684 }
   686 
   685 
   687 void
   686 void
   688 floating(View *v) { /* default floating layout */
   687 floating(View *v) { /* default floating layout */
   696 
   695 
   697 void
   696 void
   698 focus(Client *c) {
   697 focus(Client *c) {
   699 	View *v = selview;
   698 	View *v = selview;
   700 	if(c)
   699 	if(c)
   701 		selview = getview(c);
   700 		selview = c->view;
   702 	else
   701 	else
   703 		selview = viewat();
   702 		selview = viewat();
   704 	if(selview != v)
   703 	if(selview != v)
   705 		drawbar(v);
   704 		drawbar(v);
   706 	if(!c || (c && !isvisible(c)))
   705 	if(!c || (c && !isvisible(c)))
   707 		for(c = stack; c && (!isvisible(c) || getview(c) != selview); c = c->snext);
   706 		for(c = stack; c && (!isvisible(c) || c->view != selview); c = c->snext);
   708 	if(sel && sel != c) {
   707 	if(sel && sel != c) {
   709 		grabbuttons(sel, False);
   708 		grabbuttons(sel, False);
   710 		XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
   709 		XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
   711 	}
   710 	}
   712 	if(c) {
   711 	if(c) {
   716 	}
   715 	}
   717 	sel = c;
   716 	sel = c;
   718 	if(c) {
   717 	if(c) {
   719 		XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
   718 		XSetWindowBorder(dpy, c->win, dc.sel[ColBorder]);
   720 		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
   719 		XSetInputFocus(dpy, c->win, RevertToPointerRoot, CurrentTime);
   721 		selview = getview(c);
   720 		selview = c->view;
   722 	}
   721 	}
   723 	else
   722 	else
   724 		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
   723 		XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
   725 	drawbar(selview);
   724 	drawbar(selview);
   726 }
   725 }
   742 	for(c = sel->next; c && !isvisible(c); c = c->next);
   741 	for(c = sel->next; c && !isvisible(c); c = c->next);
   743 	if(!c)
   742 	if(!c)
   744 		for(c = clients; c && !isvisible(c); c = c->next);
   743 		for(c = clients; c && !isvisible(c); c = c->next);
   745 	if(c) {
   744 	if(c) {
   746 		focus(c);
   745 		focus(c);
   747 		restack(getview(c));
   746 		restack(c->view);
   748 	}
   747 	}
   749 }
   748 }
   750 
   749 
   751 void
   750 void
   752 focusprev(const char *arg) {
   751 focusprev(const char *arg) {
   759 		for(c = clients; c && c->next; c = c->next);
   758 		for(c = clients; c && c->next; c = c->next);
   760 		for(; c && !isvisible(c); c = c->prev);
   759 		for(; c && !isvisible(c); c = c->prev);
   761 	}
   760 	}
   762 	if(c) {
   761 	if(c) {
   763 		focus(c);
   762 		focus(c);
   764 		restack(getview(c));
   763 		restack(c->view);
   765 	}
   764 	}
   766 }
   765 }
   767 
   766 
   768 Client *
   767 Client *
   769 getclient(Window w) {
   768 getclient(Window w) {
   789 
   788 
   790 	for(i = 0; i < nviews; i++)
   789 	for(i = 0; i < nviews; i++)
   791 		if(views[i].barwin == barwin)
   790 		if(views[i].barwin == barwin)
   792 			return &views[i];
   791 			return &views[i];
   793 	return NULL;
   792 	return NULL;
   794 }
       
   795 
       
   796 View *
       
   797 getview(Client *c) {
       
   798 	unsigned int i;
       
   799 
       
   800 	for(i = 0; i < LENGTH(tags); i++)
       
   801 		if(c->tags[i])
       
   802 			return &views[c->tags[i] - 1];
       
   803 	return &views[0]; /* fallback */
       
   804 }
   793 }
   805 
   794 
   806 long
   795 long
   807 getstate(Window w) {
   796 getstate(Window w) {
   808 	int format, status;
   797 	int format, status;
  1056 	c->tags = emallocz(sizeof initags);
  1045 	c->tags = emallocz(sizeof initags);
  1057 	c->win = w;
  1046 	c->win = w;
  1058 
  1047 
  1059 	applyrules(c);
  1048 	applyrules(c);
  1060 
  1049 
  1061 	v = getview(c);
  1050 	v = c->view;
  1062 
  1051 
  1063 	c->x = wa->x + v->x;
  1052 	c->x = wa->x + v->x;
  1064 	c->y = wa->y + v->y;
  1053 	c->y = wa->y + v->y;
  1065 	c->w = wa->width;
  1054 	c->w = wa->width;
  1066 	c->h = wa->height;
  1055 	c->h = wa->height;
  1135 	Window dummy;
  1124 	Window dummy;
  1136 	XEvent ev;
  1125 	XEvent ev;
  1137 
  1126 
  1138 	ocx = nx = c->x;
  1127 	ocx = nx = c->x;
  1139 	ocy = ny = c->y;
  1128 	ocy = ny = c->y;
  1140 	v = getview(c);
  1129 	v = c->view;
  1141 	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
  1130 	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
  1142 			None, cursor[CurMove], CurrentTime) != GrabSuccess)
  1131 			None, cursor[CurMove], CurrentTime) != GrabSuccess)
  1143 		return;
  1132 		return;
  1144 	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
  1133 	XQueryPointer(dpy, root, &dummy, &dummy, &x1, &y1, &di, &di, &dui);
  1145 	for(;;) {
  1134 	for(;;) {
  1174 	}
  1163 	}
  1175 }
  1164 }
  1176 
  1165 
  1177 Client *
  1166 Client *
  1178 nexttiled(Client *c, View *v) {
  1167 nexttiled(Client *c, View *v) {
  1179 	for(; c && (c->isfloating || getview(c) != v || !isvisible(c)); c = c->next);
  1168 	for(; c && (c->isfloating || c->view != v || !isvisible(c)); c = c->next);
  1180 	return c;
  1169 	return c;
  1181 }
  1170 }
  1182 
  1171 
  1183 void
  1172 void
  1184 propertynotify(XEvent *e) {
  1173 propertynotify(XEvent *e) {
  1199 		case XA_WM_NORMAL_HINTS:
  1188 		case XA_WM_NORMAL_HINTS:
  1200 			updatesizehints(c);
  1189 			updatesizehints(c);
  1201 			break;
  1190 			break;
  1202 		case XA_WM_HINTS:
  1191 		case XA_WM_HINTS:
  1203 			updatewmhints(c);
  1192 			updatewmhints(c);
  1204 			drawbar(getview(c));
  1193 			drawbar(c->view);
  1205 			break;
  1194 			break;
  1206 		}
  1195 		}
  1207 		if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
  1196 		if(ev->atom == XA_WM_NAME || ev->atom == netatom[NetWMName]) {
  1208 			updatetitle(c);
  1197 			updatetitle(c);
  1209 			if(c == sel)
  1198 			if(c == sel)
  1232 void
  1221 void
  1233 resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
  1222 resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
  1234 	View *v;
  1223 	View *v;
  1235 	XWindowChanges wc;
  1224 	XWindowChanges wc;
  1236 
  1225 
  1237 	v = getview(c);
  1226 	v = c->view;
  1238 	if(sizehints) {
  1227 	if(sizehints) {
  1239 		/* set minimum possible */
  1228 		/* set minimum possible */
  1240 		if (w < 1)
  1229 		if (w < 1)
  1241 			w = 1;
  1230 			w = 1;
  1242 		if (h < 1)
  1231 		if (h < 1)
  1303 	View *v;
  1292 	View *v;
  1304 	XEvent ev;
  1293 	XEvent ev;
  1305 
  1294 
  1306 	ocx = c->x;
  1295 	ocx = c->x;
  1307 	ocy = c->y;
  1296 	ocy = c->y;
  1308 	v = getview(c);
  1297 	v = c->view;
  1309 	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
  1298 	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
  1310 			None, cursor[CurResize], CurrentTime) != GrabSuccess)
  1299 			None, cursor[CurResize], CurrentTime) != GrabSuccess)
  1311 		return;
  1300 		return;
  1312 	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
  1301 	XWarpPointer(dpy, None, c->win, 0, 0, 0, 0, c->w + c->border - 1, c->h + c->border - 1);
  1313 	for(;;) {
  1302 	for(;;) {
  1482 		v->layout = &layouts[i];
  1471 		v->layout = &layouts[i];
  1483 	}
  1472 	}
  1484 	if(sel)
  1473 	if(sel)
  1485 		arrange();
  1474 		arrange();
  1486 	else
  1475 	else
  1487 		drawbar(v);
  1476 		drawbar(selview);
  1488 }
  1477 }
  1489 
  1478 
  1490 void
  1479 void
  1491 setmwfact(const char *arg) {
  1480 setmwfact(const char *arg) {
  1492 	double delta;
  1481 	double delta;
  1493 
       
  1494 	View *v = selview;
  1482 	View *v = selview;
  1495 
  1483 
  1496 	if(!domwfact)
  1484 	if(!domwfact)
  1497 		return;
  1485 		return;
  1498 	/* arg handling, manipulate mwfact */
  1486 	/* arg handling, manipulate mwfact */
  1535 		info = XineramaQueryScreens(dpy, &nviews);
  1523 		info = XineramaQueryScreens(dpy, &nviews);
  1536 #if defined(AIM_XINERAMA)
  1524 #if defined(AIM_XINERAMA)
  1537 isxinerama = True;
  1525 isxinerama = True;
  1538 nviews = 2; /* aim Xinerama */
  1526 nviews = 2; /* aim Xinerama */
  1539 #endif
  1527 #endif
  1540 	selview = views = emallocz(nviews * sizeof(View));
  1528 	views = emallocz(nviews * sizeof(View));
  1541 
  1529 
  1542 	screen = DefaultScreen(dpy);
  1530 	screen = DefaultScreen(dpy);
  1543 	root = RootWindow(dpy, screen);
  1531 	root = RootWindow(dpy, screen);
  1544 
  1532 
  1545 	/* init appearance */
  1533 	/* init appearance */
  1625 		drawbar(v);
  1613 		drawbar(v);
  1626 	}
  1614 	}
  1627 	if(info)
  1615 	if(info)
  1628 		XFree(info);
  1616 		XFree(info);
  1629 
  1617 
       
  1618 	selview = viewat();
       
  1619 
  1630 	/* grab keys */
  1620 	/* grab keys */
  1631 	grabkeys();
  1621 	grabkeys();
  1632 
       
  1633 	selview = &views[0];
       
  1634 }
  1622 }
  1635 
  1623 
  1636 void
  1624 void
  1637 spawn(const char *arg) {
  1625 spawn(const char *arg) {
  1638 	static char *shell = NULL;
  1626 	static char *shell = NULL;
  1988 zoom(const char *arg) {
  1976 zoom(const char *arg) {
  1989 	Client *c = sel;
  1977 	Client *c = sel;
  1990 
  1978 
  1991 	if(!sel || !dozoom || sel->isfloating)
  1979 	if(!sel || !dozoom || sel->isfloating)
  1992 		return;
  1980 		return;
  1993 	if(c == nexttiled(clients, getview(c)))
  1981 	if(c == nexttiled(clients, c->view))
  1994 		if(!(c = nexttiled(c->next, getview(c))))
  1982 		if(!(c = nexttiled(c->next, c->view)))
  1995 			return;
  1983 			return;
  1996 	detach(c);
  1984 	detach(c);
  1997 	attach(c);
  1985 	attach(c);
  1998 	focus(c);
  1986 	focus(c);
  1999 	arrange();
  1987 	arrange();