dwm.c
changeset 1447 4fff5050c835
parent 1446 c3ea02998d91
child 1448 d012c6babc13
equal deleted inserted replaced
1446:c3ea02998d91 1447:4fff5050c835
   235 static void zoom(const Arg *arg);
   235 static void zoom(const Arg *arg);
   236 
   236 
   237 /* variables */
   237 /* variables */
   238 static char stext[256];
   238 static char stext[256];
   239 static int screen;
   239 static int screen;
   240 static int sw, sh;   /* X display screen geometry x, y, width, height */
   240 static int sw, sh;           /* X display screen geometry x, y, width, height */
   241 static int bh, blw = 0;      /* bar geometry */
   241 static int bh, blw = 0;      /* bar geometry */
   242 static int (*xerrorxlib)(Display *, XErrorEvent *);
   242 static int (*xerrorxlib)(Display *, XErrorEvent *);
   243 static unsigned int numlockmask = 0;
   243 static unsigned int numlockmask = 0;
   244 static void (*handler[LASTEvent]) (XEvent *) = {
   244 static void (*handler[LASTEvent]) (XEvent *) = {
   245 	[ButtonPress] = buttonpress,
   245 	[ButtonPress] = buttonpress,
   262 static Display *dpy;
   262 static Display *dpy;
   263 static DC dc;
   263 static DC dc;
   264 static Layout *lt[] = { NULL, NULL };
   264 static Layout *lt[] = { NULL, NULL };
   265 static Monitor *mons = NULL, *selmon = NULL;
   265 static Monitor *mons = NULL, *selmon = NULL;
   266 static Window root;
   266 static Window root;
       
   267 
   267 /* configuration, allows nested code to access above variables */
   268 /* configuration, allows nested code to access above variables */
   268 #include "config.h"
   269 #include "config.h"
   269 
   270 
   270 /* compile-time check if all tags fit into an unsigned int bit array. */
   271 /* compile-time check if all tags fit into an unsigned int bit array. */
   271 struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 : 1]; };
   272 struct NumTags { char limitexceeded[sizeof(unsigned int) * 8 < LENGTH(tags) ? -1 : 1]; };
   282 	if(XGetClassHint(dpy, c->win, &ch)) {
   283 	if(XGetClassHint(dpy, c->win, &ch)) {
   283 		for(i = 0; i < LENGTH(rules); i++) {
   284 		for(i = 0; i < LENGTH(rules); i++) {
   284 			r = &rules[i];
   285 			r = &rules[i];
   285 			if((!r->title || strstr(c->name, r->title))
   286 			if((!r->title || strstr(c->name, r->title))
   286 			&& (!r->class || (ch.res_class && strstr(ch.res_class, r->class)))
   287 			&& (!r->class || (ch.res_class && strstr(ch.res_class, r->class)))
   287 			&& (!r->instance || (ch.res_name && strstr(ch.res_name, r->instance)))) {
   288 			&& (!r->instance || (ch.res_name && strstr(ch.res_name, r->instance))))
       
   289 			{
   288 				c->isfloating = r->isfloating;
   290 				c->isfloating = r->isfloating;
   289 				c->tags |= r->tags;
   291 				c->tags |= r->tags;
   290 			}
   292 			}
   291 		}
   293 		}
   292 		if(ch.res_class)
   294 		if(ch.res_class)
   303 	Monitor *m = c->mon;
   305 	Monitor *m = c->mon;
   304 
   306 
   305 	/* set minimum possible */
   307 	/* set minimum possible */
   306 	*w = MAX(1, *w);
   308 	*w = MAX(1, *w);
   307 	*h = MAX(1, *h);
   309 	*h = MAX(1, *h);
   308 
       
   309 	if(interact) {
   310 	if(interact) {
   310 		if(*x > sw)
   311 		if(*x > sw)
   311 			*x = sw - WIDTH(c);
   312 			*x = sw - WIDTH(c);
   312 		if(*y > sh)
   313 		if(*y > sh)
   313 			*y = sh - HEIGHT(c);
   314 			*y = sh - HEIGHT(c);
   901 		return False;
   902 		return False;
   902 	if(name.encoding == XA_STRING)
   903 	if(name.encoding == XA_STRING)
   903 		strncpy(text, (char *)name.value, size - 1);
   904 		strncpy(text, (char *)name.value, size - 1);
   904 	else {
   905 	else {
   905 		if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
   906 		if(XmbTextPropertyToTextList(dpy, &name, &list, &n) >= Success
   906 		&& n > 0 && *list) {
   907 		&& n > 0 && *list)
       
   908 		{
   907 			strncpy(text, *list, size - 1);
   909 			strncpy(text, *list, size - 1);
   908 			XFreeStringList(list);
   910 			XFreeStringList(list);
   909 		}
   911 		}
   910 	}
   912 	}
   911 	text[size - 1] = '\0';
   913 	text[size - 1] = '\0';
   926 					for(j = 0; j < LENGTH(modifiers); j++)
   928 					for(j = 0; j < LENGTH(modifiers); j++)
   927 						XGrabButton(dpy, buttons[i].button,
   929 						XGrabButton(dpy, buttons[i].button,
   928 						            buttons[i].mask | modifiers[j],
   930 						            buttons[i].mask | modifiers[j],
   929 						            c->win, False, BUTTONMASK,
   931 						            c->win, False, BUTTONMASK,
   930 						            GrabModeAsync, GrabModeSync, None, None);
   932 						            GrabModeAsync, GrabModeSync, None, None);
   931 		} else
   933 		}
       
   934 		else
   932 			XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
   935 			XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
   933 			            BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
   936 			            BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
   934 	}
   937 	}
   935 }
   938 }
   936 
   939 
  1383 	arrange();
  1386 	arrange();
  1384 }
  1387 }
  1385 
  1388 
  1386 void
  1389 void
  1387 setclientstate(Client *c, long state) {
  1390 setclientstate(Client *c, long state) {
  1388 	long data[] = {state, None};
  1391 	long data[] = { state, None };
  1389 
  1392 
  1390 	XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
  1393 	XChangeProperty(dpy, c->win, wmatom[WMState], wmatom[WMState], 32,
  1391 			PropModeReplace, (unsigned char *)data, 2);
  1394 			PropModeReplace, (unsigned char *)data, 2);
  1392 }
  1395 }
  1393 
  1396