dwm.c
changeset 1458 e30739eebeed
parent 1457 96862665fd92
child 1459 a5eecc6d674f
equal deleted inserted replaced
1457:96862665fd92 1458:e30739eebeed
   119 	const char *symbol;
   119 	const char *symbol;
   120 	void (*arrange)(Monitor *);
   120 	void (*arrange)(Monitor *);
   121 } Layout;
   121 } Layout;
   122 
   122 
   123 struct Monitor {
   123 struct Monitor {
   124 	int screen_number;
       
   125 	float mfact;
   124 	float mfact;
       
   125 	int num;
   126 	int by;               /* bar geometry */
   126 	int by;               /* bar geometry */
   127 	int mx, my, mw, mh;   /* screen size */
   127 	int mx, my, mw, mh;   /* screen size */
   128 	int wx, wy, ww, wh;   /* window area  */
   128 	int wx, wy, ww, wh;   /* window area  */
   129 	unsigned int seltags;
   129 	unsigned int seltags;
   130 	unsigned int sellt;
   130 	unsigned int sellt;
   143 	const char *class;
   143 	const char *class;
   144 	const char *instance;
   144 	const char *instance;
   145 	const char *title;
   145 	const char *title;
   146 	unsigned int tags;
   146 	unsigned int tags;
   147 	Bool isfloating;
   147 	Bool isfloating;
       
   148 	int monitor;
   148 } Rule;
   149 } Rule;
   149 
   150 
   150 /* function declarations */
   151 /* function declarations */
   151 static void applyrules(Client *c);
   152 static void applyrules(Client *c);
   152 static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact);
   153 static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact);
   236 static void zoom(const Arg *arg);
   237 static void zoom(const Arg *arg);
   237 
   238 
   238 /* variables */
   239 /* variables */
   239 static char stext[256], ntext[8];
   240 static char stext[256], ntext[8];
   240 static int screen;
   241 static int screen;
   241 static int sw, sh;           /* X display screen geometry x, y, width, height */
   242 static int sw, sh;           /* X display screen geometry width, height */
   242 static int bh, blw = 0;      /* bar geometry */
   243 static int bh, blw = 0;      /* bar geometry */
   243 static int (*xerrorxlib)(Display *, XErrorEvent *);
   244 static int (*xerrorxlib)(Display *, XErrorEvent *);
   244 static unsigned int numlockmask = 0;
   245 static unsigned int numlockmask = 0;
   245 static void (*handler[LASTEvent]) (XEvent *) = {
   246 static void (*handler[LASTEvent]) (XEvent *) = {
   246 	[ButtonPress] = buttonpress,
   247 	[ButtonPress] = buttonpress,
   274 /* function implementations */
   275 /* function implementations */
   275 void
   276 void
   276 applyrules(Client *c) {
   277 applyrules(Client *c) {
   277 	unsigned int i;
   278 	unsigned int i;
   278 	const Rule *r;
   279 	const Rule *r;
       
   280 	Monitor *m;
   279 	XClassHint ch = { 0 };
   281 	XClassHint ch = { 0 };
   280 
   282 
   281 	/* rule matching */
   283 	/* rule matching */
   282 	c->isfloating = c->tags = 0;
   284 	c->isfloating = c->tags = 0;
   283 	if(XGetClassHint(dpy, c->win, &ch)) {
   285 	if(XGetClassHint(dpy, c->win, &ch)) {
   287 			&& (!r->class || (ch.res_class && strstr(ch.res_class, r->class)))
   289 			&& (!r->class || (ch.res_class && strstr(ch.res_class, r->class)))
   288 			&& (!r->instance || (ch.res_name && strstr(ch.res_name, r->instance))))
   290 			&& (!r->instance || (ch.res_name && strstr(ch.res_name, r->instance))))
   289 			{
   291 			{
   290 				c->isfloating = r->isfloating;
   292 				c->isfloating = r->isfloating;
   291 				c->tags |= r->tags;
   293 				c->tags |= r->tags;
       
   294 				for(m = mons; m && m->num != r->monitor; m = m->next);
       
   295 				if(m)
       
   296 					c->mon = m;
   292 			}
   297 			}
   293 		}
   298 		}
   294 		if(ch.res_class)
   299 		if(ch.res_class)
   295 			XFree(ch.res_class);
   300 			XFree(ch.res_class);
   296 		if(ch.res_name)
   301 		if(ch.res_name)
  1696 	}
  1701 	}
  1697 	/* initialise monitor(s) */
  1702 	/* initialise monitor(s) */
  1698 #ifdef XINERAMA
  1703 #ifdef XINERAMA
  1699 	if(XineramaIsActive(dpy)) {
  1704 	if(XineramaIsActive(dpy)) {
  1700 		for(i = 0, m = newmons; m; m = m->next, i++) {
  1705 		for(i = 0, m = newmons; m; m = m->next, i++) {
  1701 			m->screen_number = info[i].screen_number;
  1706 			m->num = info[i].screen_number;
  1702 			m->mx = m->wx = info[i].x_org;
  1707 			m->mx = m->wx = info[i].x_org;
  1703 			m->my = m->wy = info[i].y_org;
  1708 			m->my = m->wy = info[i].y_org;
  1704 			m->mw = m->ww = info[i].width;
  1709 			m->mw = m->ww = info[i].width;
  1705 			m->mh = m->wh = info[i].height;
  1710 			m->mh = m->wh = info[i].height;
  1706 		}
  1711 		}
  1708 	}
  1713 	}
  1709 	else
  1714 	else
  1710 #endif /* XINERAMA */
  1715 #endif /* XINERAMA */
  1711 	/* default monitor setup */
  1716 	/* default monitor setup */
  1712 	{
  1717 	{
  1713 		m->screen_number = 0;
  1718 		m->num = 0;
  1714 		m->mx = m->wx = 0;
  1719 		m->mx = m->wx = 0;
  1715 		m->my = m->wy = 0;
  1720 		m->my = m->wy = 0;
  1716 		m->mw = m->ww = sw;
  1721 		m->mw = m->ww = sw;
  1717 		m->mh = m->wh = sh;
  1722 		m->mh = m->wh = sh;
  1718 	}
  1723 	}