-
Notifications
You must be signed in to change notification settings - Fork 10
/
04-centredfloating.diff
53 lines (51 loc) · 1.61 KB
/
04-centredfloating.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
diff -up a/dwm.c b/dwm.c
--- a/dwm.c 2012-07-17 17:33:17.308540211 +1000
+++ b/dwm.c 2012-07-17 17:34:23.618180981 +1000
@@ -91,7 +91,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh;
int bw, oldbw;
unsigned int tags;
- Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, iscentred;
Client *next;
Client *snext;
Monitor *mon;
@@ -151,6 +151,7 @@ typedef struct {
const char *title;
unsigned int tags;
Bool isfloating;
+ Bool iscentred;
int monitor;
} Rule;
@@ -302,6 +303,7 @@ applyrules(Client *c) {
/* rule matching */
c->isfloating = c->tags = 0;
+ c->iscentred = 1;
XGetClassHint(dpy, c->win, &ch);
class = ch.res_class ? ch.res_class : broken;
instance = ch.res_name ? ch.res_name : broken;
@@ -313,6 +315,7 @@ applyrules(Client *c) {
&& (!r->instance || strstr(instance, r->instance)))
{
c->isfloating = r->isfloating;
+ c->iscentred = r->iscentred;
c->tags |= r->tags;
for(m = mons; m && m->num != r->monitor; m = m->next);
if(m)
@@ -1162,8 +1165,14 @@ manage(Window w, XWindowAttributes *wa)
applyrules(c);
}
/* geometry */
- c->x = c->oldx = wa->x;
- c->y = c->oldy = wa->y;
+ if((!c->mon->lt[c->mon->sellt]->arrange || c->isfloating) && c->iscentred) {
+ c->x = c->oldx = c->mon->wx + (c->mon->ww / 2 - wa->width / 2);
+ c->y = c->oldy = c->mon->wy + (c->mon->wh / 2 - wa->height / 2);
+ }
+ else {
+ c->x = c->oldx = wa->x;
+ c->y = c->oldy = wa->y;
+ }
c->w = c->oldw = wa->width;
c->h = c->oldh = wa->height;
c->oldbw = wa->border_width;