Adding fsignal patch and moved dwmc signal settings to config.def.h
This commit is contained in:
29
patch/dwmc.c
29
patch/dwmc.c
@@ -40,35 +40,6 @@ tagallex(const Arg *arg)
|
||||
tag(&((Arg){.ui = ~0}));
|
||||
}
|
||||
|
||||
/* signal definitions */
|
||||
/* signum must be greater than 0 */
|
||||
/* trigger signals using `xsetroot -name "fsignal:<signame> [<type> <value>]"` */
|
||||
static Signal signals[] = {
|
||||
/* signum function */
|
||||
{ "focusstack", focusstack },
|
||||
{ "setmfact", setmfact },
|
||||
{ "togglebar", togglebar },
|
||||
{ "incnmaster", incnmaster },
|
||||
{ "togglefloating", togglefloating },
|
||||
{ "focusmon", focusmon },
|
||||
{ "tagmon", tagmon },
|
||||
{ "zoom", zoom },
|
||||
{ "view", view },
|
||||
{ "viewall", viewallex },
|
||||
{ "viewex", viewex },
|
||||
{ "toggleview", view },
|
||||
{ "toggleviewex", toggleviewex },
|
||||
{ "tag", tag },
|
||||
{ "tagall", tagallex },
|
||||
{ "tagex", tagex },
|
||||
{ "toggletag", tag },
|
||||
{ "toggletagex", toggletagex },
|
||||
{ "killclient", killclient },
|
||||
{ "quit", quit },
|
||||
{ "setlayout", setlayout },
|
||||
{ "setlayoutex", setlayoutex },
|
||||
};
|
||||
|
||||
int
|
||||
fake_signal(void)
|
||||
{
|
||||
|
40
patch/fsignal.c
Normal file
40
patch/fsignal.c
Normal file
@@ -0,0 +1,40 @@
|
||||
int
|
||||
fake_signal(void)
|
||||
{
|
||||
char fsignal[256];
|
||||
char indicator[9] = "fsignal:";
|
||||
char str_signum[16];
|
||||
int i, v, signum;
|
||||
size_t len_fsignal, len_indicator = strlen(indicator);
|
||||
|
||||
// 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) {
|
||||
memcpy(str_signum, &fsignal[len_indicator], len_fsignal - len_indicator);
|
||||
str_signum[len_fsignal - len_indicator] = '\0';
|
||||
|
||||
// Convert string value into managable integer
|
||||
for (i = signum = 0; i < strlen(str_signum); i++) {
|
||||
v = str_signum[i] - '0';
|
||||
if (v >= 0 && v <= 9) {
|
||||
signum = signum * 10 + v;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if a signal was found, and if so handle it
|
||||
if (signum)
|
||||
for (i = 0; i < LENGTH(signals); i++)
|
||||
if (signum == signals[i].signum && signals[i].func)
|
||||
signals[i].func(&(signals[i].arg));
|
||||
|
||||
// A fake signal was sent
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// No fake signal was sent, so proceed with update
|
||||
return 0;
|
||||
}
|
7
patch/fsignal.h
Normal file
7
patch/fsignal.h
Normal file
@@ -0,0 +1,7 @@
|
||||
typedef struct {
|
||||
unsigned int signum;
|
||||
void (*func)(const Arg *);
|
||||
const Arg arg;
|
||||
} Signal;
|
||||
|
||||
static int fake_signal(void);
|
@@ -28,6 +28,8 @@
|
||||
#endif
|
||||
#if DWMC_PATCH
|
||||
#include "dwmc.c"
|
||||
#elif FSIGNAL_PATCH
|
||||
#include "fsignal.c"
|
||||
#endif
|
||||
#if EWMHTAGS_PATCH
|
||||
#include "ewmhtags.c"
|
||||
|
@@ -28,6 +28,8 @@
|
||||
#endif
|
||||
#if DWMC_PATCH
|
||||
#include "dwmc.h"
|
||||
#elif FSIGNAL_PATCH
|
||||
#include "fsignal.h"
|
||||
#endif
|
||||
#if EWMHTAGS_PATCH
|
||||
#include "ewmhtags.h"
|
||||
|
Reference in New Issue
Block a user