mirror of
https://github.com/mintycube/dwmblocks.git
synced 2024-10-22 14:05:47 +02:00
Fix mouse click handling
This commit is contained in:
parent
968ceac7f3
commit
9b42cdba27
5
config.h
5
config.h
@ -1,5 +1,5 @@
|
|||||||
#define CMDLENGTH 50
|
#define CMDLENGTH 50
|
||||||
#define DELIMITER " "
|
#define DELIMITER "<"
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* command;
|
char* command;
|
||||||
@ -18,4 +18,5 @@ static Block blocks[] = {
|
|||||||
{"sb-volume", 0, 5},
|
{"sb-volume", 0, 5},
|
||||||
{"sb-battery", 5, 6},
|
{"sb-battery", 5, 6},
|
||||||
{"sb-date", 20, 7},
|
{"sb-date", 20, 7},
|
||||||
{"sb-network", 5, 8}};
|
{"sb-network", 5, 8}
|
||||||
|
};
|
||||||
|
22
main.c
22
main.c
@ -100,17 +100,14 @@ void setRoot() {
|
|||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
void buttonHandler(int sig, siginfo_t *si, void *ucontext) {
|
void signalHandler(int sig, siginfo_t *si, void *ucontext) {
|
||||||
sig = si->si_value.sival_int >> 8;
|
sig -= SIGRTMIN;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (blocks[i].signal != sig) i++;
|
while (blocks[i].signal != sig) i++;
|
||||||
const char button[2] = {'0' + si->si_value.sival_int & 0xff, '\0'};
|
const char button[2] = {'0' + si->si_value.sival_int & 0xff, '\0'};
|
||||||
getCommand(i, button);
|
getCommand(i, button);
|
||||||
}
|
}
|
||||||
|
|
||||||
void signalHandler(int signal) { getSignalCommand(signal - SIGRTMIN); }
|
|
||||||
|
|
||||||
void termHandler(int signal) {
|
void termHandler(int signal) {
|
||||||
statusContinue = 0;
|
statusContinue = 0;
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
@ -142,17 +139,12 @@ void setupSignals() {
|
|||||||
|
|
||||||
// Handle block update signals
|
// Handle block update signals
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
for (int i = 0; i < LEN(blocks); i++) {
|
|
||||||
if (blocks[i].signal > 0) {
|
|
||||||
signal(SIGRTMIN + blocks[i].signal, signalHandler);
|
|
||||||
sigaddset(&sa.sa_mask, SIGRTMIN + blocks[i].signal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle mouse events
|
|
||||||
sa.sa_sigaction = buttonHandler;
|
|
||||||
sa.sa_flags = SA_SIGINFO;
|
sa.sa_flags = SA_SIGINFO;
|
||||||
sigaction(SIGUSR1, &sa, NULL);
|
sa.sa_sigaction = signalHandler;
|
||||||
|
for (int i = 0; i < LEN(blocks); i++) {
|
||||||
|
if (blocks[i].signal > 0)
|
||||||
|
sigaction(SIGRTMIN + blocks[i].signal, &sa, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
// Handle exit of forks
|
// Handle exit of forks
|
||||||
struct sigaction sigchld_action = {
|
struct sigaction sigchld_action = {
|
||||||
|
Loading…
Reference in New Issue
Block a user