summaryrefslogtreecommitdiff
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/dwm.c b/dwm.c
index d8dcf90..f5f3638 100644
--- a/dwm.c
+++ b/dwm.c
@@ -109,6 +109,11 @@ typedef struct {
} Key;
typedef struct {
+ const char * sig;
+ void (*func)(const Arg *);
+} Signal;
+
+typedef struct {
const char *symbol;
void (*arrange)(Monitor *);
} Layout;
@@ -155,6 +160,7 @@ static void arrange(Monitor *m);
static void arrangemon(Monitor *m);
static void attach(Client *c);
static void attachstack(Client *c);
+static int fake_signal(void);
static void buttonpress(XEvent *e);
static void checkotherwm(void);
static void cleanup(void);
@@ -1135,6 +1141,49 @@ keypress(XEvent *e)
keys[i].func(&(keys[i].arg));
}
+int
+fake_signal(void)
+{
+ char fsignal[256];
+ char indicator[9] = "fsignal:";
+ char str_sig[50];
+ char param[16];
+ int i, len_str_sig, n, paramn;
+ size_t len_fsignal, len_indicator = strlen(indicator);
+ Arg arg;
+
+ // Get root name property
+ if (gettextprop(root, XA_WM_NAME, fsignal, sizeof(fsignal))) {
+ len_fsignal = strlen(fsignal);
+
+ // Check if this is indeed a fake signal
+ if (len_indicator > len_fsignal ? 0 : strncmp(indicator, fsignal, len_indicator) == 0) {
+ paramn = sscanf(fsignal+len_indicator, "%s%n%s%n", str_sig, &len_str_sig, param, &n);
+
+ if (paramn == 1) arg = (Arg) {0};
+ else if (paramn > 2) return 1;
+ else if (strncmp(param, "i", n - len_str_sig) == 0)
+ sscanf(fsignal + len_indicator + n, "%i", &(arg.i));
+ else if (strncmp(param, "ui", n - len_str_sig) == 0)
+ sscanf(fsignal + len_indicator + n, "%u", &(arg.ui));
+ else if (strncmp(param, "f", n - len_str_sig) == 0)
+ sscanf(fsignal + len_indicator + n, "%f", &(arg.f));
+ else return 1;
+
+ // Check if a signal was found, and if so handle it
+ for (i = 0; i < LENGTH(signals); i++)
+ if (strncmp(str_sig, signals[i].sig, len_str_sig) == 0 && signals[i].func)
+ signals[i].func(&(arg));
+
+ // A fake signal was sent
+ return 1;
+ }
+ }
+
+ // No fake signal was sent, so proceed with update
+ return 0;
+}
+
void
killclient(const Arg *arg)
{
@@ -1351,8 +1400,10 @@ propertynotify(XEvent *e)
Window trans;
XPropertyEvent *ev = &e->xproperty;
- if ((ev->window == root) && (ev->atom == XA_WM_NAME))
- updatestatus();
+ if ((ev->window == root) && (ev->atom == XA_WM_NAME)) {
+ if (!fake_signal())
+ updatestatus();
+ }
else if (ev->state == PropertyDelete)
return; /* ignore */
else if ((c = wintoclient(ev->window))) {