aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsinanmohd <pcmsinan@gmail.com>2021-11-15 23:55:06 +0530
committersinanmohd <pcmsinan@gmail.com>2023-01-11 18:39:55 +0530
commitdee204c48e5c926913f280d1b09458079dab9117 (patch)
tree4d61589e240dc445e72e21616d024ca06312c365
parentfb8e23bff58678072618c3b36acceed7be7fdf6d (diff)
added center patch
-rw-r--r--README.md1
-rw-r--r--config.def.h10
-rw-r--r--dwm.c14
3 files changed, 18 insertions, 7 deletions
diff --git a/README.md b/README.md
index 5111d47..1097b6a 100644
--- a/README.md
+++ b/README.md
@@ -8,3 +8,4 @@ dwm is an extremely fast, small, and dynamic window manager for X.
- [swallow](https://dwm.suckless.org/patches/swallow/dwm-swallow-20201211-61bb8b2.diff). enable window swallowing
- [xrdb](https://dwm.suckless.org/patches/xrdb/dwm-xrdb-6.2.diff). allows dwm to read colors from xrdb
- [titlecolor](https://dwm.suckless.org/patches/titlecolor/dwm-titlecolor-20210815-ed3ab6b4.diff). adds a new color scheme used by the window title in the bar
+- [center](https://dwm.suckless.org/patches/center/dwm-center-6.2.diff). automatically center clients
diff --git a/config.def.h b/config.def.h
index af69dee..dbe468d 100644
--- a/config.def.h
+++ b/config.def.h
@@ -30,11 +30,11 @@ static const Rule rules[] = {
* WM_CLASS(STRING) = instance, class
* WM_NAME(STRING) = title
*/
- /* class instance title tags mask isfloating isterminal noswallow monitor */
- { "Gimp", NULL, NULL, 0, 1, 0, 0, -1 },
- { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 },
- { "St", NULL, NULL, 0, 0, 1, 0, -1 },
- { NULL, NULL, "Event Tester", 0, 0, 0, 1, -1 }, /* xev */
+ /* class instance title tags mask iscentered isfloating isterminal noswallow monitor */
+ { "Gimp", NULL, NULL, 0, 0, 1, 0, 0, -1 },
+ { "Firefox", NULL, NULL, 1 << 8, 0, 0, 0, -1, -1 },
+ { "St", NULL, NULL, 0, 0, 0, 1, 0, -1 },
+ { NULL, NULL, "Event Tester", 0, 0, 0, 0, 1, -1 }, /* xev */
};
/* layout(s) */
diff --git a/dwm.c b/dwm.c
index 9e95b47..f7067a9 100644
--- a/dwm.c
+++ b/dwm.c
@@ -114,7 +114,7 @@ struct Client {
int basew, baseh, incw, inch, maxw, maxh, minw, minh, hintsvalid;
int bw, oldbw;
unsigned int tags;
- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow;
+ int isfixed, iscentered, isfloating, isurgent, neverfocus, oldstate, isfullscreen, isterminal, noswallow;
pid_t pid;
Client *next;
Client *snext;
@@ -162,6 +162,7 @@ typedef struct {
const char *instance;
const char *title;
unsigned int tags;
+ int iscentered;
int isfloating;
int isterminal;
int noswallow;
@@ -324,6 +325,7 @@ applyrules(Client *c)
XClassHint ch = { NULL, NULL };
/* rule matching */
+ c->iscentered = 0;
c->isfloating = 0;
c->tags = 0;
XGetClassHint(dpy, c->win, &ch);
@@ -338,6 +340,7 @@ applyrules(Client *c)
{
c->isterminal = r->isterminal;
c->noswallow = r->noswallow;
+ c->iscentered = r->iscentered;
c->isfloating = r->isfloating;
c->tags |= r->tags;
for (m = mons; m && m->num != r->monitor; m = m->next);
@@ -1193,6 +1196,10 @@ manage(Window w, XWindowAttributes *wa)
updatewindowtype(c);
updatesizehints(c);
updatewmhints(c);
+ if (c->iscentered) {
+ c->x = c->mon->mx + (c->mon->mw - WIDTH(c)) / 2;
+ c->y = c->mon->my + (c->mon->mh - HEIGHT(c)) / 2;
+ }
XSelectInput(dpy, w, EnterWindowMask|FocusChangeMask|PropertyChangeMask|StructureNotifyMask);
grabbuttons(c, 0);
if (!c->isfloating)
@@ -2174,8 +2181,10 @@ updatewindowtype(Client *c)
if (state == netatom[NetWMFullscreen])
setfullscreen(c, 1);
- if (wtype == netatom[NetWMWindowTypeDialog])
+ if (wtype == netatom[NetWMWindowTypeDialog]) {
+ c->iscentered = 1;
c->isfloating = 1;
+ }
}
void
@@ -2455,3 +2464,4 @@ main(int argc, char *argv[])
XCloseDisplay(dpy);
return EXIT_SUCCESS;
}
+