-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path15-dwm-6.0-centred-floating.diff
54 lines (51 loc) · 1.66 KB
/
15-dwm-6.0-centred-floating.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
54
Homepage: http://hg.punctweb.ro
--- a/dwm.c 2013-02-11 22:11:39.302773224 +0200
+++ b/dwm.c 2013-02-11 22:11:39.304773224 +0200
@@ -92,7 +92,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, needresize;
+ Bool isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, needresize, iscentred;
Client *next;
Client *snext;
Monitor *mon;
@@ -163,6 +163,7 @@ typedef struct {
const char *title;
unsigned int tags;
Bool isfloating;
+ Bool iscentred;
int monitor;
} Rule;
@@ -327,6 +328,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;
@@ -338,6 +340,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)
@@ -1192,8 +1195,14 @@ manage(Window w, XWindowAttributes *wa)
}
settagsatom(c->win, c->tags);
/* 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;