aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2019-08-15 18:49:54 +0100
committerHarry Jeffery <harry@exec64.co.uk>2019-08-15 18:49:54 +0100
commitc7e391d65c14c484ed4c4b34cad0fa9e3f06aa55 (patch)
tree67b2d539b2dad4449b5442d477b8ade05c442ea1 /src
parentaa17fbf0e8bba4bf9fa765f1225076976f8eba16 (diff)
downloadimv-c7e391d65c14c484ed4c4b34cad0fa9e3f06aa55.tar.gz
wl/x11: Ensure event writes are always atomic
Diffstat (limited to 'src')
-rw-r--r--src/wl_window.c6
-rw-r--r--src/x11_window.c4
2 files changed, 9 insertions, 1 deletions
diff --git a/src/wl_window.c b/src/wl_window.c
index b5aac22..021d9aa 100644
--- a/src/wl_window.c
+++ b/src/wl_window.c
@@ -4,12 +4,13 @@
#include <assert.h>
#include <fcntl.h>
+#include <limits.h>
#include <poll.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
#include <sys/mman.h>
+#include <unistd.h>
#include <wayland-client.h>
#include <wayland-egl.h>
@@ -687,6 +688,9 @@ static void shutdown_wayland(struct imv_window *window)
struct imv_window *imv_window_create(int width, int height, const char *title)
{
+ /* Ensure event writes will always be atomic */
+ assert(sizeof(struct imv_event) <= PIPE_BUF);
+
struct imv_window *window = calloc(1, sizeof *window);
window->scale = 1;
window->wl_outputs = list_create();
diff --git a/src/x11_window.c b/src/x11_window.c
index 7bf7d2b..1b7f724 100644
--- a/src/x11_window.c
+++ b/src/x11_window.c
@@ -2,6 +2,7 @@
#include <assert.h>
#include <fcntl.h>
+#include <limits.h>
#include <poll.h>
#include <stdlib.h>
#include <string.h>
@@ -44,6 +45,9 @@ static void set_nonblocking(int fd)
struct imv_window *imv_window_create(int w, int h, const char *title)
{
+ /* Ensure event writes will always be atomic */
+ assert(sizeof(struct imv_event) <= PIPE_BUF);
+
struct imv_window *window = calloc(1, sizeof *window);
window->pointer.last.x = -1;
window->pointer.last.y = -1;