mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Use poll and XNextEvent to replace XNextEvent blocking inside the x11 event
handler.
This commit is contained in:
parent
03e5d86952
commit
3d7c82936e
12
calmwm.c
12
calmwm.c
@ -27,6 +27,7 @@
|
|||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
#include <poll.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -56,6 +57,7 @@ main(int argc, char **argv)
|
|||||||
const char *conf_file = NULL;
|
const char *conf_file = NULL;
|
||||||
char *conf_path, *display_name = NULL;
|
char *conf_path, *display_name = NULL;
|
||||||
int ch, xfd;
|
int ch, xfd;
|
||||||
|
struct pollfd pfd[1];
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
|
|
||||||
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
|
||||||
@ -114,8 +116,16 @@ main(int argc, char **argv)
|
|||||||
if (pledge("stdio rpath proc exec", NULL) == -1)
|
if (pledge("stdio rpath proc exec", NULL) == -1)
|
||||||
err(1, "pledge");
|
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();
|
xev_process();
|
||||||
|
if (poll(pfd, 1, INFTIM) == -1) {
|
||||||
|
if (errno != EINTR)
|
||||||
|
warn("poll");
|
||||||
|
}
|
||||||
|
}
|
||||||
x_teardown();
|
x_teardown();
|
||||||
if (cwm_status == CWM_EXEC_WM)
|
if (cwm_status == CWM_EXEC_WM)
|
||||||
u_exec(Conf.wm_argv);
|
u_exec(Conf.wm_argv);
|
||||||
|
12
xevents.c
12
xevents.c
@ -436,9 +436,11 @@ xev_process(void)
|
|||||||
{
|
{
|
||||||
XEvent e;
|
XEvent e;
|
||||||
|
|
||||||
XNextEvent(X_Dpy, &e);
|
while (XPending(X_Dpy)) {
|
||||||
if (e.type - Conf.xrandr_event_base == RRScreenChangeNotify)
|
XNextEvent(X_Dpy, &e);
|
||||||
xev_handle_randr(&e);
|
if (e.type - Conf.xrandr_event_base == RRScreenChangeNotify)
|
||||||
else if (e.type < LASTEvent && xev_handlers[e.type] != NULL)
|
xev_handle_randr(&e);
|
||||||
(*xev_handlers[e.type])(&e);
|
else if (e.type < LASTEvent && xev_handlers[e.type] != NULL)
|
||||||
|
(*xev_handlers[e.type])(&e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user