diff options
-rw-r--r-- | calmwm.c | 14 | ||||
-rw-r--r-- | xevents.c | 14 |
2 files changed, 20 insertions, 8 deletions
@@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.c,v 1.103 2017/12/22 21:30:01 okan Exp $ + * $OpenBSD: calmwm.c,v 1.104 2017/12/27 17:04:35 okan Exp $ */ #include <sys/types.h> @@ -27,6 +27,7 @@ #include <getopt.h> #include <limits.h> #include <locale.h> +#include <poll.h> #include <pwd.h> #include <signal.h> #include <stdio.h> @@ -56,6 +57,7 @@ main(int argc, char **argv) const char *conf_file = NULL; char *conf_path, *display_name = NULL; int ch, xfd; + struct pollfd pfd[1]; struct passwd *pw; if (!setlocale(LC_CTYPE, "") || !XSupportsLocale()) @@ -114,8 +116,16 @@ main(int argc, char **argv) if (pledge("stdio rpath proc exec", NULL) == -1) err(1, "pledge"); - while (cwm_status == CWM_RUNNING) + memset(&pfd, 0, sizeof(pfd)); + pfd[0].fd = xfd; + pfd[0].events = POLLIN; + while (cwm_status == CWM_RUNNING) { xev_process(); + if (poll(pfd, 1, INFTIM) == -1) { + if (errno != EINTR) + warn("poll"); + } + } x_teardown(); if (cwm_status == CWM_EXEC_WM) u_exec(Conf.wm_argv); @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: xevents.c,v 1.128 2017/05/09 18:43:40 okan Exp $ + * $OpenBSD: xevents.c,v 1.129 2017/12/27 17:04:35 okan Exp $ */ /* @@ -436,9 +436,11 @@ xev_process(void) { XEvent e; - XNextEvent(X_Dpy, &e); - if (e.type - Conf.xrandr_event_base == RRScreenChangeNotify) - xev_handle_randr(&e); - else if (e.type < LASTEvent && xev_handlers[e.type] != NULL) - (*xev_handlers[e.type])(&e); + while (XPending(X_Dpy)) { + XNextEvent(X_Dpy, &e); + if (e.type - Conf.xrandr_event_base == RRScreenChangeNotify) + xev_handle_randr(&e); + else if (e.type < LASTEvent && xev_handlers[e.type] != NULL) + (*xev_handlers[e.type])(&e); + } } |