extended rule to apply monitors if set up accordingly 758b100d
Anselm R Garbe · 2009-07-09 21:52 2 file(s) · +12 −7
config.def.h +3 −3
17 17
static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
18 18
19 19
static const Rule rules[] = {
20 -
	/* class      instance    title       tags mask     isfloating */
21 -
	{ "Gimp",     NULL,       NULL,       0,            True },
22 -
	{ "Firefox",  NULL,       NULL,       1 << 8,       False },
20 +
	/* class      instance    title       tags mask     isfloating   monitor */
21 +
	{ "Gimp",     NULL,       NULL,       0,            True,        -1 },
22 +
	{ "Firefox",  NULL,       NULL,       1 << 8,       False,       -1 },
23 23
};
24 24
25 25
/* layout(s) */
dwm.c +9 −4
121 121
} Layout;
122 122
123 123
struct Monitor {
124 -
	int screen_number;
125 124
	float mfact;
125 +
	int num;
126 126
	int by;               /* bar geometry */
127 127
	int mx, my, mw, mh;   /* screen size */
128 128
	int wx, wy, ww, wh;   /* window area  */
145 145
	const char *title;
146 146
	unsigned int tags;
147 147
	Bool isfloating;
148 +
	int monitor;
148 149
} Rule;
149 150
150 151
/* function declarations */
238 239
/* variables */
239 240
static char stext[256], ntext[8];
240 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 243
static int bh, blw = 0;      /* bar geometry */
243 244
static int (*xerrorxlib)(Display *, XErrorEvent *);
244 245
static unsigned int numlockmask = 0;
276 277
applyrules(Client *c) {
277 278
	unsigned int i;
278 279
	const Rule *r;
280 +
	Monitor *m;
279 281
	XClassHint ch = { 0 };
280 282
281 283
	/* rule matching */
289 291
			{
290 292
				c->isfloating = r->isfloating;
291 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 299
		if(ch.res_class)
1698 1703
#ifdef XINERAMA
1699 1704
	if(XineramaIsActive(dpy)) {
1700 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 1707
			m->mx = m->wx = info[i].x_org;
1703 1708
			m->my = m->wy = info[i].y_org;
1704 1709
			m->mw = m->ww = info[i].width;
1710 1715
#endif /* XINERAMA */
1711 1716
	/* default monitor setup */
1712 1717
	{
1713 -
		m->screen_number = 0;
1718 +
		m->num = 0;
1714 1719
		m->mx = m->wx = 0;
1715 1720
		m->my = m->wy = 0;
1716 1721
		m->mw = m->ww = sw;