aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Wittamore <philip@wittamore.com>2025-06-03 15:40:37 +0200
committerPhilip Wittamore <philip@wittamore.com>2025-06-03 15:40:37 +0200
commitd861b36018e978de024586f8a0a095a07f29ebf2 (patch)
treed1f401930825383c8dbbaf6ae70def988c8739b6
parent9473946e6ce11ca360621bad7beac3dd41b9038e (diff)
downloaddwm-d861b36018e978de024586f8a0a095a07f29ebf2.tar.gz
dwm-d861b36018e978de024586f8a0a095a07f29ebf2.tar.bz2
dwm-d861b36018e978de024586f8a0a095a07f29ebf2.zip
update
-rw-r--r--config.def.h11
-rw-r--r--config.h11
-rw-r--r--dwm.c15
-rw-r--r--patches/dwm-center-6.2.diff90
-rw-r--r--patches/dwmblocks-statuscmd-fork.diff77
-rw-r--r--patches/dwmblocks-statuscmd-signal.diff93
6 files changed, 284 insertions, 13 deletions
diff --git a/config.def.h b/config.def.h
index 34f7b90..675c740 100644
--- a/config.def.h
+++ b/config.def.h
@@ -29,11 +29,12 @@ 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 },
- { "Ghostty", 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 },
+ { "Ghostty", NULL, NULL, 0, 0, 0, 1, 0, -1 },
+ { "orage", NULL, NULL, 0, 1, 1, 0, 1, -1 },
+ { NULL, NULL, "Event Tester", 0, 0, 0, 0, 1, -1 }, /* xev */
};
/* layout(s) */
diff --git a/config.h b/config.h
index 34f7b90..675c740 100644
--- a/config.h
+++ b/config.h
@@ -29,11 +29,12 @@ 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 },
- { "Ghostty", 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 },
+ { "Ghostty", NULL, NULL, 0, 0, 0, 1, 0, -1 },
+ { "orage", NULL, NULL, 0, 1, 1, 0, 1, -1 },
+ { NULL, NULL, "Event Tester", 0, 0, 0, 0, 1, -1 }, /* xev */
};
/* layout(s) */
diff --git a/dwm.c b/dwm.c
index cecd7bd..25006c2 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;
@@ -161,6 +161,7 @@ typedef struct {
const char *instance;
const char *title;
unsigned int tags;
+ int iscentered;
int isfloating;
int isterminal;
int noswallow;
@@ -339,6 +340,7 @@ applyrules(Client *c)
XClassHint ch = { NULL, NULL };
/* rule matching */
+ c->iscentered = 0;
c->isfloating = 0;
c->tags = 0;
XGetClassHint(dpy, c->win, &ch);
@@ -351,9 +353,10 @@ applyrules(Client *c)
&& (!r->class || strstr(class, r->class))
&& (!r->instance || strstr(instance, r->instance)))
{
+ c->iscentered = r->iscentered;
+ c->isfloating = r->isfloating;
c->isterminal = r->isterminal;
c->noswallow = r->noswallow;
- c->isfloating = r->isfloating;
c->tags |= r->tags;
for (m = mons; m && m->num != r->monitor; m = m->next);
if (m)
@@ -1328,6 +1331,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;
+ }
{
int format;
unsigned long *data, n, extra;
@@ -2468,8 +2475,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
diff --git a/patches/dwm-center-6.2.diff b/patches/dwm-center-6.2.diff
new file mode 100644
index 0000000..0dfe156
--- /dev/null
+++ b/patches/dwm-center-6.2.diff
@@ -0,0 +1,90 @@
+From 69f91089d9248fa9695eb925956e255a215171b8 Mon Sep 17 00:00:00 2001
+From: bakkeby <bakkeby@gmail.com>
+Date: Tue, 7 Apr 2020 12:29:08 +0200
+Subject: [PATCH] Adding 6.2 center patch with multi-monitor fix and
+ auto-centering of floating popup windows
+---
+ config.def.h | 6 +++---
+ dwm.c | 13 +++++++++++--
+ 2 files changed, 14 insertions(+), 5 deletions(-)
+
+diff --git a/config.def.h b/config.def.h
+index 1c0b587..44b46e5 100644
+--- a/config.def.h
++++ b/config.def.h
+@@ -26,9 +26,9 @@ static const Rule rules[] = {
+ * WM_CLASS(STRING) = instance, class
+ * WM_NAME(STRING) = title
+ */
+- /* class instance title tags mask isfloating monitor */
+- { "Gimp", NULL, NULL, 0, 1, -1 },
+- { "Firefox", NULL, NULL, 1 << 8, 0, -1 },
++ /* class instance title tags mask iscentered isfloating monitor */
++ { "Gimp", NULL, NULL, 0, 0, 1, -1 },
++ { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1 },
+ };
+
+ /* layout(s) */
+diff --git a/dwm.c b/dwm.c
+index 4465af1..ab33757 100644
+--- a/dwm.c
++++ b/dwm.c
+@@ -92,7 +92,7 @@ struct Client {
+ int basew, baseh, incw, inch, maxw, maxh, minw, minh;
+ int bw, oldbw;
+ unsigned int tags;
+- int isfixed, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
++ int isfixed, iscentered, isfloating, isurgent, neverfocus, oldstate, isfullscreen;
+ Client *next;
+ Client *snext;
+ Monitor *mon;
+@@ -137,6 +137,7 @@ typedef struct {
+ const char *instance;
+ const char *title;
+ unsigned int tags;
++ int iscentered;
+ int isfloating;
+ int monitor;
+ } Rule;
+@@ -285,6 +286,7 @@ applyrules(Client *c)
+ XClassHint ch = { NULL, NULL };
+
+ /* rule matching */
++ c->iscentered = 0;
+ c->isfloating = 0;
+ c->tags = 0;
+ XGetClassHint(dpy, c->win, &ch);
+@@ -297,6 +299,7 @@ applyrules(Client *c)
+ && (!r->class || strstr(class, r->class))
+ && (!r->instance || strstr(instance, r->instance)))
+ {
++ c->iscentered = r->iscentered;
+ c->isfloating = r->isfloating;
+ c->tags |= r->tags;
+ for (m = mons; m && m->num != r->monitor; m = m->next);
+@@ -1056,6 +1059,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)
+@@ -2009,8 +2016,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
+--
+2.17.1
+
diff --git a/patches/dwmblocks-statuscmd-fork.diff b/patches/dwmblocks-statuscmd-fork.diff
new file mode 100644
index 0000000..1ae7d7a
--- /dev/null
+++ b/patches/dwmblocks-statuscmd-fork.diff
@@ -0,0 +1,77 @@
+diff --git a/dwmblocks.c b/dwmblocks.c
+index 7d7a564..e2c5dd0 100644
+--- a/dwmblocks.c
++++ b/dwmblocks.c
+@@ -34,8 +34,6 @@ static int screen;
+ static Window root;
+ static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0};
+ static char statusstr[2][256];
+-static char exportstring[CMDLENGTH + 22] = "export BLOCK_BUTTON=-;";
+-static int button = 0;
+ static int statusContinue = 1;
+ static void (*writestatus) () = setroot;
+
+@@ -55,21 +53,8 @@ void getcmd(const Block *block, char *output)
+ output[0] = block->signal;
+ output++;
+ }
+- char* cmd;
+- FILE *cmdf;
+- if (button)
+- {
+- cmd = strcat(exportstring, block->command);
+- cmd[20] = '0' + button;
+- button = 0;
+- cmdf = popen(cmd,"r");
+- cmd[22] = '\0';
+- }
+- else
+- {
+- cmd = block->command;
+- cmdf = popen(cmd,"r");
+- }
++ char *cmd = block->command;
++ FILE *cmdf = popen(cmd,"r");
+ if (!cmdf)
+ return;
+ fgets(output, CMDLENGTH, cmdf);
+@@ -117,6 +102,7 @@ void setupsignals()
+ sa.sa_sigaction = buttonhandler;
+ sa.sa_flags = SA_SIGINFO;
+ sigaction(SIGUSR1, &sa, NULL);
++ signal(SIGCHLD, SIG_IGN);
+
+ }
+ #endif
+@@ -179,9 +165,29 @@ void sighandler(int signum)
+
+ void buttonhandler(int sig, siginfo_t *si, void *ucontext)
+ {
+- button = si->si_value.sival_int & 0xff;
+- getsigcmds(si->si_value.sival_int >> 8);
++ int button = si->si_value.sival_int & 0xff;
++ sig = si->si_value.sival_int >> 8;
++ getsigcmds(sig);
+ writestatus();
++ if (fork() == 0)
++ {
++ static char exportstring[CMDLENGTH + 22] = "export BLOCK_BUTTON=-;";
++ const Block *current;
++ int i;
++ for (i = 0; i < LENGTH(blocks); i++)
++ {
++ current = blocks + i;
++ if (current->signal == sig)
++ break;
++ }
++ char *cmd = strcat(exportstring, blocks[i].command);
++ cmd[20] = '0' + button;
++ char *command[] = { "/bin/sh", "-c", cmd, NULL };
++ setsid();
++ execvp(command[0], command);
++ exit(EXIT_SUCCESS);
++ cmd[22] = '\0';
++ }
+ }
+
+ #endif
diff --git a/patches/dwmblocks-statuscmd-signal.diff b/patches/dwmblocks-statuscmd-signal.diff
new file mode 100644
index 0000000..c2092e7
--- /dev/null
+++ b/patches/dwmblocks-statuscmd-signal.diff
@@ -0,0 +1,93 @@
+diff --git a/dwmblocks.c b/dwmblocks.c
+index 88bdfb0..7bd14df 100644
+--- a/dwmblocks.c
++++ b/dwmblocks.c
+@@ -14,6 +14,7 @@ typedef struct {
+ unsigned int signal;
+ } Block;
+ void sighandler(int num);
++void buttonhandler(int sig, siginfo_t *si, void *ucontext);
+ void replace(char *str, char old, char new);
+ void getcmds(int time);
+ #ifndef __OpenBSD__
+@@ -34,6 +35,8 @@ static int screen;
+ static Window root;
+ static char statusbar[LENGTH(blocks)][CMDLENGTH] = {0};
+ static char statusstr[2][256];
++static char exportstring[CMDLENGTH + 16] = "export BUTTON=-;";
++static int button = 0;
+ static int statusContinue = 1;
+ static void (*writestatus) () = setroot;
+
+@@ -48,16 +51,34 @@ void replace(char *str, char old, char new)
+ //opens process *cmd and stores output in *output
+ void getcmd(const Block *block, char *output)
+ {
++ if (block->signal)
++ {
++ output[0] = block->signal;
++ output++;
++ }
+ strcpy(output, block->icon);
+- char *cmd = block->command;
+- FILE *cmdf = popen(cmd,"r");
++ char* cmd;
++ FILE *cmdf;
++ if (button)
++ {
++ cmd = strcat(exportstring, block->command);
++ cmd[14] = '0' + button;
++ button = 0;
++ cmdf = popen(cmd,"r");
++ cmd[16] = '\0';
++ }
++ else
++ {
++ cmd = block->command;
++ cmdf = popen(cmd,"r");
++ }
+ if (!cmdf)
+ return;
+ char c;
+ int i = strlen(block->icon);
+ fgets(output+i, CMDLENGTH-i, cmdf);
+ i = strlen(output);
+- if (delim != '\0' && --i)
++ if (delim != '\0' && i)
+ output[i++] = delim;
+ output[i++] = '\0';
+ pclose(cmdf);
+@@ -88,11 +106,18 @@ void getsigcmds(int signal)
+
+ void setupsignals()
+ {
++ struct sigaction sa;
+ for(int i = 0; i < LENGTH(blocks); i++)
+ {
+ if (blocks[i].signal > 0)
++ {
+ signal(SIGRTMIN+blocks[i].signal, sighandler);
++ sigaddset(&sa.sa_mask, SIGRTMIN+blocks[i].signal);
++ }
+ }
++ sa.sa_sigaction = buttonhandler;
++ sa.sa_flags = SA_SIGINFO;
++ sigaction(SIGUSR1, &sa, NULL);
+
+ }
+ #endif
+@@ -152,6 +177,14 @@ void sighandler(int signum)
+ getsigcmds(signum-SIGRTMIN);
+ writestatus();
+ }
++
++void buttonhandler(int sig, siginfo_t *si, void *ucontext)
++{
++ button = si->si_value.sival_int & 0xff;
++ getsigcmds(si->si_value.sival_int >> 8);
++ writestatus();
++}
++
+ #endif
+
+ void termhandler(int signum)