tint2: Do not rely only on select() to detect new X events, since we sync the socket in the system tray which messes up select
This commit is contained in:
parent
222eca4099
commit
4d69a0bc33
1 changed files with 220 additions and 217 deletions
21
src/tint.c
21
src/tint.c
|
@ -224,9 +224,11 @@ void init_X11_post_config()
|
||||||
if (pipe(sn_pipe) != 0) {
|
if (pipe(sn_pipe) != 0) {
|
||||||
fprintf(stderr, "Creating pipe failed.\n");
|
fprintf(stderr, "Creating pipe failed.\n");
|
||||||
} else {
|
} else {
|
||||||
|
fcntl(sn_pipe[0], F_SETFL, O_NONBLOCK | fcntl(sn_pipe[0], F_GETFL));
|
||||||
|
fcntl(sn_pipe[1], F_SETFL, O_NONBLOCK | fcntl(sn_pipe[1], F_GETFL));
|
||||||
sn_pipe_valid = 1;
|
sn_pipe_valid = 1;
|
||||||
struct sigaction act;
|
struct sigaction act;
|
||||||
memset (&act, 0, sizeof (struct sigaction));
|
memset(&act, 0, sizeof(struct sigaction));
|
||||||
act.sa_handler = sigchld_handler;
|
act.sa_handler = sigchld_handler;
|
||||||
if (sigaction(SIGCHLD, &act, 0)) {
|
if (sigaction(SIGCHLD, &act, 0)) {
|
||||||
perror("sigaction");
|
perror("sigaction");
|
||||||
|
@ -1173,15 +1175,18 @@ start:
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
|
|
||||||
// Wait for X Event or a Timer
|
// Wait for X Event or a Timer
|
||||||
if (select(maxfd+1, &fdset, 0, 0, timeout) > 0) {
|
if (systray_profile)
|
||||||
if (FD_ISSET(sn_pipe[0], &fdset)) {
|
fprintf(stderr, "[%f] %s:%d waiting for events...\n", profiling_get_time(), __FUNCTION__, __LINE__);
|
||||||
|
if (XPending(server.dsp) > 0 || select(maxfd+1, &fdset, 0, 0, timeout) >= 0) {
|
||||||
|
if (systray_profile)
|
||||||
|
fprintf(stderr, "[%f] %s:%d processing events\n", profiling_get_time(), __FUNCTION__, __LINE__);
|
||||||
|
if (sn_pipe_valid) {
|
||||||
char buffer[1];
|
char buffer[1];
|
||||||
ssize_t wur = read(sn_pipe[0], buffer, 1);
|
while (read(sn_pipe[0], buffer, sizeof(buffer)) > 0) {
|
||||||
(void) wur;
|
|
||||||
sigchld_handler_async();
|
sigchld_handler_async();
|
||||||
}
|
}
|
||||||
if (FD_ISSET(x11_fd, &fdset)) {
|
}
|
||||||
while (XPending (server.dsp)) {
|
while (XPending(server.dsp)) {
|
||||||
XNextEvent(server.dsp, &e);
|
XNextEvent(server.dsp, &e);
|
||||||
#if HAVE_SN
|
#if HAVE_SN
|
||||||
if (startup_notifications)
|
if (startup_notifications)
|
||||||
|
@ -1417,7 +1422,6 @@ start:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
callback_timeout_expired();
|
callback_timeout_expired();
|
||||||
|
|
||||||
|
@ -1426,7 +1430,6 @@ start:
|
||||||
if (signal_pending == SIGUSR1) {
|
if (signal_pending == SIGUSR1) {
|
||||||
// restart tint2
|
// restart tint2
|
||||||
// SIGUSR1 used when : user's signal, composite manager stop/start or xrandr
|
// SIGUSR1 used when : user's signal, composite manager stop/start or xrandr
|
||||||
FD_CLR (x11_fd, &fdset); // not sure if needed
|
|
||||||
goto start;
|
goto start;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in a new issue