aboutsummaryrefslogtreecommitdiffstats
path: root/calmwm.c
diff options
context:
space:
mode:
authorokan2017-12-27 17:04:35 +0000
committerokan2017-12-27 17:04:35 +0000
commit73cf1b91165b5fcb06a93997af95f6f0cabddc2f (patch)
treee20d9e8e14f5bee9c05119c0649dbd44ff634e0d /calmwm.c
parent0b735864a54eb32d38a6e68dd818c9db4d91fdf9 (diff)
downloadcwm-73cf1b91165b5fcb06a93997af95f6f0cabddc2f.tar.gz
Use poll and XNextEvent to replace XNextEvent blocking inside the x11 event
handler.
Diffstat (limited to 'calmwm.c')
-rw-r--r--calmwm.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/calmwm.c b/calmwm.c
index df9cbc8..20e3346 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -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);