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
17
src/tint.c
17
src/tint.c
|
@ -224,6 +224,8 @@ void init_X11_post_config()
|
|||
if (pipe(sn_pipe) != 0) {
|
||||
fprintf(stderr, "Creating pipe failed.\n");
|
||||
} 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;
|
||||
struct sigaction act;
|
||||
memset(&act, 0, sizeof(struct sigaction));
|
||||
|
@ -1173,14 +1175,17 @@ start:
|
|||
timeout = 0;
|
||||
|
||||
// Wait for X Event or a Timer
|
||||
if (select(maxfd+1, &fdset, 0, 0, timeout) > 0) {
|
||||
if (FD_ISSET(sn_pipe[0], &fdset)) {
|
||||
if (systray_profile)
|
||||
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];
|
||||
ssize_t wur = read(sn_pipe[0], buffer, 1);
|
||||
(void) wur;
|
||||
while (read(sn_pipe[0], buffer, sizeof(buffer)) > 0) {
|
||||
sigchld_handler_async();
|
||||
}
|
||||
if (FD_ISSET(x11_fd, &fdset)) {
|
||||
}
|
||||
while (XPending(server.dsp)) {
|
||||
XNextEvent(server.dsp, &e);
|
||||
#if HAVE_SN
|
||||
|
@ -1417,7 +1422,6 @@ start:
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
callback_timeout_expired();
|
||||
|
||||
|
@ -1426,7 +1430,6 @@ start:
|
|||
if (signal_pending == SIGUSR1) {
|
||||
// restart tint2
|
||||
// SIGUSR1 used when : user's signal, composite manager stop/start or xrandr
|
||||
FD_CLR (x11_fd, &fdset); // not sure if needed
|
||||
goto start;
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in a new issue