aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-11-16 16:19:17 -0500
committerTony Crisci <tony@dubstepdish.com>2017-11-16 16:19:17 -0500
commit584ff1df4c4151994410f4c82fabab32d352975c (patch)
tree06f2933b03384ad904ee214ba2c305d3ac63f3f8 /backend
parent12758a00a2d388b050386f017a3a273c1302e648 (diff)
parent10f3be73843250c400531873b4dd27dba44919fd (diff)
Merge branch 'master' into feature/wlr-seat-touch
Diffstat (limited to 'backend')
-rw-r--r--backend/libinput/events.c5
-rw-r--r--backend/session/session.c2
-rw-r--r--backend/wayland/backend.c14
-rw-r--r--backend/x11/backend.c10
4 files changed, 21 insertions, 10 deletions
diff --git a/backend/libinput/events.c b/backend/libinput/events.c
index 5da45c67..3ca41124 100644
--- a/backend/libinput/events.c
+++ b/backend/libinput/events.c
@@ -66,10 +66,11 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
int product = libinput_device_get_id_product(libinput_dev);
const char *name = libinput_device_get_name(libinput_dev);
struct wl_list *wlr_devices = calloc(1, sizeof(struct wl_list));
- wl_list_init(wlr_devices);
if (!wlr_devices) {
- goto fail;
+ wlr_log(L_ERROR, "Allocation failed");
+ return;
}
+ wl_list_init(wlr_devices);
wlr_log(L_DEBUG, "Added %s [%d:%d]", name, vendor, product);
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_KEYBOARD)) {
diff --git a/backend/session/session.c b/backend/session/session.c
index 760830c3..657558fd 100644
--- a/backend/session/session.c
+++ b/backend/session/session.c
@@ -249,7 +249,7 @@ static size_t explicit_find_gpus(struct wlr_session *session,
}
} while ((ptr = strtok_r(NULL, ":", &save)));
- free(ptr);
+ free(gpus);
return i;
}
diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c
index 532935b8..1801f3e0 100644
--- a/backend/wayland/backend.c
+++ b/backend/wayland/backend.c
@@ -12,10 +12,15 @@
#include "backend/wayland.h"
#include "xdg-shell-unstable-v6-client-protocol.h"
-
static int dispatch_events(int fd, uint32_t mask, void *data) {
struct wlr_wl_backend *backend = data;
int count = 0;
+
+ if ((mask & WL_EVENT_HANGUP) || (mask & WL_EVENT_ERROR)) {
+ wl_display_terminate(backend->local_display);
+ return 0;
+ }
+
if (mask & WL_EVENT_READABLE) {
count = wl_display_dispatch(backend->remote_display);
}
@@ -36,7 +41,7 @@ static bool wlr_wl_backend_start(struct wlr_backend *_backend) {
wlr_log(L_INFO, "Initializating wayland backend");
wlr_wl_registry_poll(backend);
- if (!(backend->compositor) || (!(backend->shell))) {
+ if (!backend->compositor || !backend->shell) {
wlr_log_errno(L_ERROR, "Could not obtain retrieve required globals");
return false;
}
@@ -49,10 +54,9 @@ static bool wlr_wl_backend_start(struct wlr_backend *_backend) {
struct wl_event_loop *loop = wl_display_get_event_loop(backend->local_display);
int fd = wl_display_get_fd(backend->remote_display);
- int events = WL_EVENT_READABLE | WL_EVENT_ERROR |
- WL_EVENT_HANGUP;
+ int events = WL_EVENT_READABLE | WL_EVENT_ERROR | WL_EVENT_HANGUP;
backend->remote_display_src = wl_event_loop_add_fd(loop, fd, events,
- dispatch_events, backend);
+ dispatch_events, backend);
wl_event_source_check(backend->remote_display_src);
return true;
diff --git a/backend/x11/backend.c b/backend/x11/backend.c
index 97b0dd8c..b798daf6 100644
--- a/backend/x11/backend.c
+++ b/backend/x11/backend.c
@@ -155,9 +155,14 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e
static int x11_event(int fd, uint32_t mask, void *data) {
struct wlr_x11_backend *x11 = data;
+
+ if ((mask & WL_EVENT_HANGUP) || (mask & WL_EVENT_ERROR)) {
+ wl_display_terminate(x11->wl_display);
+ return 0;
+ }
+
xcb_generic_event_t *e;
bool quit = false;
-
while (!quit && (e = xcb_poll_for_event(x11->xcb_conn))) {
quit = handle_x11_event(x11, e);
free(e);
@@ -205,7 +210,8 @@ struct wlr_backend *wlr_x11_backend_create(struct wl_display *display,
int fd = xcb_get_file_descriptor(x11->xcb_conn);
struct wl_event_loop *ev = wl_display_get_event_loop(display);
- x11->event_source = wl_event_loop_add_fd(ev, fd, WL_EVENT_READABLE, x11_event, x11);
+ int events = WL_EVENT_READABLE | WL_EVENT_ERROR | WL_EVENT_HANGUP;
+ x11->event_source = wl_event_loop_add_fd(ev, fd, events, x11_event, x11);
if (!x11->event_source) {
wlr_log(L_ERROR, "Could not create event source");
goto error_x11;