You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
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; |
|
} |
|
|
|
|