dwm-center-6.2.diff - sites - public wiki contents of suckless.org | |
git clone git://git.suckless.org/sites | |
Log | |
Files | |
Refs | |
--- | |
dwm-center-6.2.diff (2865B) | |
--- | |
1 From 69f91089d9248fa9695eb925956e255a215171b8 Mon Sep 17 00:00:00 2001 | |
2 From: bakkeby <[email protected]> | |
3 Date: Tue, 7 Apr 2020 12:29:08 +0200 | |
4 Subject: [PATCH] Adding 6.2 center patch with multi-monitor fix and | |
5 auto-centering of floating popup windows | |
6 --- | |
7 config.def.h | 6 +++--- | |
8 dwm.c | 13 +++++++++++-- | |
9 2 files changed, 14 insertions(+), 5 deletions(-) | |
10 | |
11 diff --git a/config.def.h b/config.def.h | |
12 index 1c0b587..44b46e5 100644 | |
13 --- a/config.def.h | |
14 +++ b/config.def.h | |
15 @@ -26,9 +26,9 @@ static const Rule rules[] = { | |
16 * WM_CLASS(STRING) = instance, class | |
17 * WM_NAME(STRING) = title | |
18 */ | |
19 - /* class instance title tags mask isfloating … | |
20 - { "Gimp", NULL, NULL, 0, 1, … | |
21 - { "Firefox", NULL, NULL, 1 << 8, 0, … | |
22 + /* class instance title tags mask iscentered … | |
23 + { "Gimp", NULL, NULL, 0, 0, … | |
24 + { "Firefox", NULL, NULL, 1 << 8, 0, … | |
25 }; | |
26 | |
27 /* layout(s) */ | |
28 diff --git a/dwm.c b/dwm.c | |
29 index 4465af1..ab33757 100644 | |
30 --- a/dwm.c | |
31 +++ b/dwm.c | |
32 @@ -92,7 +92,7 @@ struct Client { | |
33 int basew, baseh, incw, inch, maxw, maxh, minw, minh; | |
34 int bw, oldbw; | |
35 unsigned int tags; | |
36 - int isfixed, isfloating, isurgent, neverfocus, oldstate, isfull… | |
37 + int isfixed, iscentered, isfloating, isurgent, neverfocus, olds… | |
38 Client *next; | |
39 Client *snext; | |
40 Monitor *mon; | |
41 @@ -137,6 +137,7 @@ typedef struct { | |
42 const char *instance; | |
43 const char *title; | |
44 unsigned int tags; | |
45 + int iscentered; | |
46 int isfloating; | |
47 int monitor; | |
48 } Rule; | |
49 @@ -285,6 +286,7 @@ applyrules(Client *c) | |
50 XClassHint ch = { NULL, NULL }; | |
51 | |
52 /* rule matching */ | |
53 + c->iscentered = 0; | |
54 c->isfloating = 0; | |
55 c->tags = 0; | |
56 XGetClassHint(dpy, c->win, &ch); | |
57 @@ -297,6 +299,7 @@ applyrules(Client *c) | |
58 && (!r->class || strstr(class, r->class)) | |
59 && (!r->instance || strstr(instance, r->instance))) | |
60 { | |
61 + c->iscentered = r->iscentered; | |
62 c->isfloating = r->isfloating; | |
63 c->tags |= r->tags; | |
64 for (m = mons; m && m->num != r->monitor; m = m… | |
65 @@ -1056,6 +1059,10 @@ manage(Window w, XWindowAttributes *wa) | |
66 updatewindowtype(c); | |
67 updatesizehints(c); | |
68 updatewmhints(c); | |
69 + if (c->iscentered) { | |
70 + c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2; | |
71 + c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2; | |
72 + } | |
73 XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyCh… | |
74 grabbuttons(c, 0); | |
75 if (!c->isfloating) | |
76 @@ -2009,8 +2016,10 @@ updatewindowtype(Client *c) | |
77 | |
78 if (state == netatom[NetWMFullscreen]) | |
79 setfullscreen(c, 1); | |
80 - if (wtype == netatom[NetWMWindowTypeDialog]) | |
81 + if (wtype == netatom[NetWMWindowTypeDialog]) { | |
82 + c->iscentered = 1; | |
83 c->isfloating = 1; | |
84 + } | |
85 } | |
86 | |
87 void | |
88 -- | |
89 2.17.1 | |
90 |