dwm-center-20160719-56a31dc.diff - sites - public wiki contents of suckless.org
(HTM) git clone git://git.suckless.org/sites
(DIR) Log
(DIR) Files
(DIR) Refs
---
dwm-center-20160719-56a31dc.diff (2043B)
---
1 diff --git a/config.def.h b/config.def.h
2 index fd77a07..5bf4860 100644
3 --- a/config.def.h
4 +++ b/config.def.h
5 @@ -26,9 +26,9 @@ static const Rule rules[] = {
6 * WM_CLASS(STRING) = instance, class
7 * WM_NAME(STRING) = title
8 */
9 - /* class instance title tags mask isfloating monitor */
10 - { "Gimp", NULL, NULL, 0, 1, -1 },
11 - { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
12 + /* class instance title tags mask iscentered isfloating monitor */
13 + { "Gimp", NULL, NULL, 0, 0, 1, -1 },
14 + { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1 },
15 };
16
17 /* layout(s) */
18 diff --git a/dwm.c b/dwm.c
19 index b2bc9bd..72c9497 100644
20 --- a/dwm.c
21 +++ b/dwm.c
22 @@ -93,7 +93,7 @@ struct Client {
23 int basew, baseh, incw, inch, maxw, maxh, minw, minh;
24 int bw, oldbw;
25 unsigned int tags;
26 - int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
27 + int isfixed, iscentered, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
28 Client *next;
29 Client *snext;
30 Monitor *mon;
31 @@ -138,6 +138,7 @@ typedef struct {
32 const char *instance;
33 const char *title;
34 unsigned int tags;
35 + int iscentered;
36 int isfloating;
37 int monitor;
38 } Rule;
39 @@ -298,6 +299,7 @@ applyrules(Client *c)
40 && (!r->class || strstr(class, r->class))
41 && (!r->instance || strstr(instance, r->instance)))
42 {
43 + c->iscentered = r->iscentered;
44 c->isfloating = r->isfloating;
45 c->tags |= r->tags;
46 for (m = mons; m && m->num != r->monitor; m = m->next);
47 @@ -1066,6 +1068,11 @@ manage(Window w, XWindowAttributes *wa)
48 && (c->x + (c->w / 2) < c->mon->wx + c->mon->ww)) ? bh : c->mon->my);
49 c->bw = borderpx;
50
51 + if(c->iscentered) {
52 + c->x = (c->mon->mw - WIDTH(c)) / 2;
53 + c->y = (c->mon->mh - HEIGHT(c)) / 2;
54 + }
55 +
56 wc.border_width = c->bw;
57 XConfigureWindow(dpy, w, CWBorderWidth, &wc);
58 XSetWindowBorder(dpy, w, scheme[SchemeNorm][ColBorder].pixel);