Merge pull request #627 from emersion/wlr-signal-emit-safe

Remove wlr_backend.events.{output_remove,device_remove}
This commit is contained in:
Drew DeVault 2018-02-13 08:30:54 -05:00 committed by GitHub
commit 71cba94e73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
143 changed files with 912 additions and 956 deletions

View file

@ -1,17 +1,17 @@
#include <wayland-server.h> #include <assert.h>
#include <unistd.h> #include <errno.h>
#include <libinput.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <unistd.h>
#include <assert.h> #include <wayland-server.h>
#include <libinput.h>
#include <wlr/backend/session.h>
#include <wlr/backend/interface.h>
#include <wlr/backend/drm.h> #include <wlr/backend/drm.h>
#include <wlr/backend/interface.h>
#include <wlr/backend/libinput.h> #include <wlr/backend/libinput.h>
#include <wlr/backend/multi.h>
#include <wlr/backend/session.h>
#include <wlr/backend/wayland.h> #include <wlr/backend/wayland.h>
#include <wlr/backend/x11.h> #include <wlr/backend/x11.h>
#include <wlr/backend/multi.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
void wlr_backend_init(struct wlr_backend *backend, void wlr_backend_init(struct wlr_backend *backend,
@ -19,10 +19,8 @@ void wlr_backend_init(struct wlr_backend *backend,
assert(backend); assert(backend);
backend->impl = impl; backend->impl = impl;
wl_signal_init(&backend->events.destroy); wl_signal_init(&backend->events.destroy);
wl_signal_init(&backend->events.input_add); wl_signal_init(&backend->events.new_input);
wl_signal_init(&backend->events.input_remove); wl_signal_init(&backend->events.new_output);
wl_signal_init(&backend->events.output_add);
wl_signal_init(&backend->events.output_remove);
} }
bool wlr_backend_start(struct wlr_backend *backend) { bool wlr_backend_start(struct wlr_backend *backend) {

View file

@ -1,8 +1,8 @@
#include <stdlib.h>
#include <gbm.h> #include <gbm.h>
#include <stdlib.h>
#include <wlr/util/log.h>
#include <xf86drm.h> #include <xf86drm.h>
#include <xf86drmMode.h> #include <xf86drmMode.h>
#include <wlr/util/log.h>
#include "backend/drm/drm.h" #include "backend/drm/drm.h"
#include "backend/drm/iface.h" #include "backend/drm/iface.h"
#include "backend/drm/util.h" #include "backend/drm/util.h"

View file

@ -1,18 +1,19 @@
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <assert.h> #include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <xf86drm.h>
#include <wlr/backend/session.h>
#include <wlr/backend/interface.h> #include <wlr/backend/interface.h>
#include <wlr/backend/session.h>
#include <wlr/interfaces/wlr_output.h> #include <wlr/interfaces/wlr_output.h>
#include <wlr/render/egl.h>
#include <wlr/types/wlr_list.h> #include <wlr/types/wlr_list.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <wlr/render/egl.h> #include <xf86drm.h>
#include "backend/drm/drm.h" #include "backend/drm/drm.h"
#include "util/signal.h"
static bool wlr_drm_backend_start(struct wlr_backend *backend) { static bool wlr_drm_backend_start(struct wlr_backend *backend) {
struct wlr_drm_backend *drm = (struct wlr_drm_backend *)backend; struct wlr_drm_backend *drm = (struct wlr_drm_backend *)backend;
@ -34,7 +35,7 @@ static void wlr_drm_backend_destroy(struct wlr_backend *backend) {
wlr_output_destroy(&conn->output); wlr_output_destroy(&conn->output);
} }
wl_signal_emit(&backend->events.destroy, backend); wlr_signal_emit_safe(&backend->events.destroy, backend);
wl_list_remove(&drm->display_destroy.link); wl_list_remove(&drm->display_destroy.link);
wl_list_remove(&drm->session_signal.link); wl_list_remove(&drm->session_signal.link);

View file

@ -1,29 +1,30 @@
#include <assert.h> #include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <errno.h>
#include <time.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <drm_mode.h> #include <drm_mode.h>
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include <errno.h>
#include <gbm.h> #include <gbm.h>
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <GLES2/gl2ext.h> #include <GLES2/gl2ext.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wayland-util.h> #include <wayland-util.h>
#include <wlr/backend/interface.h> #include <wlr/backend/interface.h>
#include <wlr/interfaces/wlr_output.h> #include <wlr/interfaces/wlr_output.h>
#include <wlr/util/log.h>
#include <wlr/render/matrix.h>
#include <wlr/render/gles2.h>
#include <wlr/render.h> #include <wlr/render.h>
#include <wlr/render/gles2.h>
#include <wlr/render/matrix.h>
#include <wlr/util/log.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include "backend/drm/drm.h" #include "backend/drm/drm.h"
#include "backend/drm/iface.h" #include "backend/drm/iface.h"
#include "backend/drm/util.h" #include "backend/drm/util.h"
#include "util/signal.h"
bool wlr_drm_check_features(struct wlr_drm_backend *drm) { bool wlr_drm_check_features(struct wlr_drm_backend *drm) {
if (drmSetClientCap(drm->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1)) { if (drmSetClientCap(drm->fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1)) {
@ -870,7 +871,8 @@ void wlr_drm_scan_connectors(struct wlr_drm_backend *drm) {
wlr_conn->state = WLR_DRM_CONN_NEEDS_MODESET; wlr_conn->state = WLR_DRM_CONN_NEEDS_MODESET;
wlr_log(L_INFO, "Sending modesetting signal for '%s'", wlr_log(L_INFO, "Sending modesetting signal for '%s'",
wlr_conn->output.name); wlr_conn->output.name);
wl_signal_emit(&drm->backend.events.output_add, &wlr_conn->output); wlr_signal_emit_safe(&drm->backend.events.new_output,
&wlr_conn->output);
} else if (wlr_conn->state == WLR_DRM_CONN_CONNECTED && } else if (wlr_conn->state == WLR_DRM_CONN_CONNECTED &&
drm_conn->connection != DRM_MODE_CONNECTED) { drm_conn->connection != DRM_MODE_CONNECTED) {
wlr_log(L_INFO, "'%s' disconnected", wlr_conn->output.name); wlr_log(L_INFO, "'%s' disconnected", wlr_conn->output.name);
@ -978,8 +980,6 @@ void wlr_drm_connector_cleanup(struct wlr_drm_connector *conn) {
return; return;
} }
struct wlr_drm_backend *drm = (struct wlr_drm_backend *)conn->output.backend;
switch (conn->state) { switch (conn->state) {
case WLR_DRM_CONN_CONNECTED: case WLR_DRM_CONN_CONNECTED:
case WLR_DRM_CONN_CLEANUP:; case WLR_DRM_CONN_CLEANUP:;
@ -1013,8 +1013,8 @@ void wlr_drm_connector_cleanup(struct wlr_drm_connector *conn) {
/* Fallthrough */ /* Fallthrough */
case WLR_DRM_CONN_NEEDS_MODESET: case WLR_DRM_CONN_NEEDS_MODESET:
wlr_log(L_INFO, "Emitting destruction signal for '%s'", wlr_log(L_INFO, "Emitting destruction signal for '%s'",
conn->output.name); conn->output.name);
wl_signal_emit(&drm->backend.events.output_remove, &conn->output); wlr_signal_emit_safe(&conn->output.events.destroy, &conn->output);
break; break;
case WLR_DRM_CONN_DISCONNECTED: case WLR_DRM_CONN_DISCONNECTED:
break; break;

View file

@ -1,7 +1,7 @@
#include <gbm.h> #include <gbm.h>
#include <wlr/util/log.h>
#include <xf86drm.h> #include <xf86drm.h>
#include <xf86drmMode.h> #include <xf86drmMode.h>
#include <wlr/util/log.h>
#include "backend/drm/drm.h" #include "backend/drm/drm.h"
#include "backend/drm/iface.h" #include "backend/drm/iface.h"
#include "backend/drm/util.h" #include "backend/drm/util.h"

View file

@ -2,9 +2,9 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <wlr/util/log.h>
#include <xf86drm.h> #include <xf86drm.h>
#include <xf86drmMode.h> #include <xf86drmMode.h>
#include <wlr/util/log.h>
#include "backend/drm/properties.h" #include "backend/drm/properties.h"
/* /*

View file

@ -1,18 +1,16 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <gbm.h>
#include <GLES2/gl2.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <gbm.h>
#include <GLES2/gl2.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <wayland-util.h> #include <wayland-util.h>
#include <wlr/util/log.h>
#include <wlr/render/egl.h>
#include <wlr/render/matrix.h>
#include <wlr/render/gles2.h>
#include <wlr/render.h> #include <wlr/render.h>
#include <wlr/render/egl.h>
#include <wlr/render/gles2.h>
#include <wlr/render/matrix.h>
#include <wlr/util/log.h>
#include "backend/drm/drm.h" #include "backend/drm/drm.h"
#include "glapi.h" #include "glapi.h"

View file

@ -1,10 +1,10 @@
#include <drm_mode.h>
#include <drm.h>
#include <gbm.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <drm.h>
#include <drm_mode.h>
#include <gbm.h>
#include "backend/drm/util.h"
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "backend/drm/util.h"
int32_t calculate_refresh_rate(drmModeModeInfo *mode) { int32_t calculate_refresh_rate(drmModeModeInfo *mode) {
int32_t refresh = (mode->clock * 1000000LL / mode->htotal + int32_t refresh = (mode->clock * 1000000LL / mode->htotal +

View file

@ -1,9 +1,10 @@
#include "util/signal.h"
#include <stdlib.h> #include <stdlib.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/render/egl.h> #include <wlr/render/egl.h>
#include <wlr/render/gles2.h> #include <wlr/render/gles2.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/interfaces/wlr_input_device.h>
#include "backend/headless.h" #include "backend/headless.h"
#include "glapi.h" #include "glapi.h"
@ -16,14 +17,14 @@ static bool backend_start(struct wlr_backend *wlr_backend) {
wl_list_for_each(output, &backend->outputs, link) { wl_list_for_each(output, &backend->outputs, link) {
wl_event_source_timer_update(output->frame_timer, output->frame_delay); wl_event_source_timer_update(output->frame_timer, output->frame_delay);
wlr_output_update_enabled(&output->wlr_output, true); wlr_output_update_enabled(&output->wlr_output, true);
wl_signal_emit(&backend->backend.events.output_add, wlr_signal_emit_safe(&backend->backend.events.new_output,
&output->wlr_output); &output->wlr_output);
} }
struct wlr_headless_input_device *input_device; struct wlr_headless_input_device *input_device;
wl_list_for_each(input_device, &backend->input_devices, wl_list_for_each(input_device, &backend->input_devices,
wlr_input_device.link) { wlr_input_device.link) {
wl_signal_emit(&backend->backend.events.input_add, wlr_signal_emit_safe(&backend->backend.events.new_input,
&input_device->wlr_input_device); &input_device->wlr_input_device);
} }
@ -51,7 +52,7 @@ static void backend_destroy(struct wlr_backend *wlr_backend) {
wlr_input_device_destroy(&input_device->wlr_input_device); wlr_input_device_destroy(&input_device->wlr_input_device);
} }
wl_signal_emit(&wlr_backend->events.destroy, backend); wlr_signal_emit_safe(&wlr_backend->events.destroy, backend);
wlr_egl_finish(&backend->egl); wlr_egl_finish(&backend->egl);
free(backend); free(backend);

View file

@ -1,17 +1,17 @@
#include <stdlib.h> #include <stdlib.h>
#include <wlr/interfaces/wlr_input_device.h> #include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_pointer.h>
#include <wlr/interfaces/wlr_keyboard.h> #include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/interfaces/wlr_touch.h> #include <wlr/interfaces/wlr_pointer.h>
#include <wlr/interfaces/wlr_tablet_tool.h>
#include <wlr/interfaces/wlr_tablet_pad.h> #include <wlr/interfaces/wlr_tablet_pad.h>
#include <wlr/interfaces/wlr_tablet_tool.h>
#include <wlr/interfaces/wlr_touch.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "backend/headless.h" #include "backend/headless.h"
#include "util/signal.h"
static void input_device_destroy(struct wlr_input_device *wlr_dev) { static void input_device_destroy(struct wlr_input_device *wlr_dev) {
struct wlr_headless_input_device *device = struct wlr_headless_input_device *device =
(struct wlr_headless_input_device *)wlr_dev; (struct wlr_headless_input_device *)wlr_dev;
wl_signal_emit(&device->backend->backend.events.input_remove, wlr_dev);
free(device); free(device);
} }
@ -88,7 +88,7 @@ struct wlr_input_device *wlr_headless_add_input_device(
wl_list_insert(&backend->input_devices, &wlr_device->link); wl_list_insert(&backend->input_devices, &wlr_device->link);
if (backend->started) { if (backend->started) {
wl_signal_emit(&backend->backend.events.input_add, wlr_device); wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_device);
} }
return wlr_device; return wlr_device;

View file

@ -1,10 +1,11 @@
#include <stdlib.h>
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <stdlib.h>
#include <wlr/interfaces/wlr_output.h> #include <wlr/interfaces/wlr_output.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "backend/headless.h" #include "backend/headless.h"
#include "util/signal.h"
static EGLSurface egl_create_surface(struct wlr_egl *egl, unsigned int width, static EGLSurface egl_create_surface(struct wlr_egl *egl, unsigned int width,
unsigned int height) { unsigned int height) {
@ -136,7 +137,7 @@ struct wlr_output *wlr_headless_add_output(struct wlr_backend *wlr_backend,
if (backend->started) { if (backend->started) {
wl_event_source_timer_update(output->frame_timer, output->frame_delay); wl_event_source_timer_update(output->frame_timer, output->frame_delay);
wlr_output_update_enabled(wlr_output, true); wlr_output_update_enabled(wlr_output, true);
wl_signal_emit(&backend->backend.events.output_add, wlr_output); wlr_signal_emit_safe(&backend->backend.events.new_output, wlr_output);
} }
return wlr_output; return wlr_output;

View file

@ -1,10 +1,11 @@
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <libinput.h> #include <libinput.h>
#include <wlr/backend/session.h> #include <stdlib.h>
#include <wlr/backend/interface.h> #include <wlr/backend/interface.h>
#include <wlr/backend/session.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "backend/libinput.h" #include "backend/libinput.h"
#include "util/signal.h"
static int wlr_libinput_open_restricted(const char *path, static int wlr_libinput_open_restricted(const char *path,
int flags, void *_backend) { int flags, void *_backend) {
@ -106,13 +107,12 @@ static void wlr_libinput_backend_destroy(struct wlr_backend *wlr_backend) {
struct wl_list *wlr_devices = backend->wlr_device_lists.items[i]; struct wl_list *wlr_devices = backend->wlr_device_lists.items[i];
struct wlr_input_device *wlr_dev, *next; struct wlr_input_device *wlr_dev, *next;
wl_list_for_each_safe(wlr_dev, next, wlr_devices, link) { wl_list_for_each_safe(wlr_dev, next, wlr_devices, link) {
wl_signal_emit(&backend->backend.events.input_remove, wlr_dev);
wlr_input_device_destroy(wlr_dev); wlr_input_device_destroy(wlr_dev);
} }
free(wlr_devices); free(wlr_devices);
} }
wl_signal_emit(&wlr_backend->events.destroy, wlr_backend); wlr_signal_emit_safe(&wlr_backend->events.destroy, wlr_backend);
wl_list_remove(&backend->display_destroy.link); wl_list_remove(&backend->display_destroy.link);
wl_list_remove(&backend->session_signal.link); wl_list_remove(&backend->session_signal.link);

View file

@ -1,11 +1,12 @@
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <libinput.h> #include <libinput.h>
#include <stdlib.h>
#include <wayland-util.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
#include <wlr/interfaces/wlr_input_device.h> #include <wlr/interfaces/wlr_input_device.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <wayland-util.h>
#include "backend/libinput.h" #include "backend/libinput.h"
#include "util/signal.h"
struct wlr_input_device *get_appropriate_device( struct wlr_input_device *get_appropriate_device(
enum wlr_input_device_type desired_type, enum wlr_input_device_type desired_type,
@ -88,7 +89,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
free(wlr_dev); free(wlr_dev);
goto fail; goto fail;
} }
wl_signal_emit(&backend->backend.events.input_add, wlr_dev); wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
} }
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_POINTER)) { if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_POINTER)) {
struct wlr_input_device *wlr_dev = allocate_device(backend, struct wlr_input_device *wlr_dev = allocate_device(backend,
@ -101,7 +102,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
free(wlr_dev); free(wlr_dev);
goto fail; goto fail;
} }
wl_signal_emit(&backend->backend.events.input_add, wlr_dev); wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
} }
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_TOUCH)) { if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_TOUCH)) {
struct wlr_input_device *wlr_dev = allocate_device(backend, struct wlr_input_device *wlr_dev = allocate_device(backend,
@ -114,7 +115,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
free(wlr_dev); free(wlr_dev);
goto fail; goto fail;
} }
wl_signal_emit(&backend->backend.events.input_add, wlr_dev); wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
} }
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_TABLET_TOOL)) { if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_TABLET_TOOL)) {
struct wlr_input_device *wlr_dev = allocate_device(backend, struct wlr_input_device *wlr_dev = allocate_device(backend,
@ -127,7 +128,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
free(wlr_dev); free(wlr_dev);
goto fail; goto fail;
} }
wl_signal_emit(&backend->backend.events.input_add, wlr_dev); wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
} }
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_TABLET_PAD)) { if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_TABLET_PAD)) {
struct wlr_input_device *wlr_dev = allocate_device(backend, struct wlr_input_device *wlr_dev = allocate_device(backend,
@ -140,7 +141,7 @@ static void handle_device_added(struct wlr_libinput_backend *backend,
free(wlr_dev); free(wlr_dev);
goto fail; goto fail;
} }
wl_signal_emit(&backend->backend.events.input_add, wlr_dev); wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_dev);
} }
if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_GESTURE)) { if (libinput_device_has_capability(libinput_dev, LIBINPUT_DEVICE_CAP_GESTURE)) {
// TODO // TODO
@ -178,7 +179,6 @@ static void handle_device_removed(struct wlr_libinput_backend *backend,
} }
struct wlr_input_device *dev, *tmp_dev; struct wlr_input_device *dev, *tmp_dev;
wl_list_for_each_safe(dev, tmp_dev, wlr_devices, link) { wl_list_for_each_safe(dev, tmp_dev, wlr_devices, link) {
wl_signal_emit(&backend->backend.events.input_remove, dev);
wlr_input_device_destroy(dev); wlr_input_device_destroy(dev);
} }
for (size_t i = 0; i < backend->wlr_device_lists.length; i++) { for (size_t i = 0; i < backend->wlr_device_lists.length; i++) {

View file

@ -1,9 +1,9 @@
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <libinput.h> #include <libinput.h>
#include <stdlib.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/interfaces/wlr_keyboard.h> #include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "backend/libinput.h" #include "backend/libinput.h"
@ -57,7 +57,7 @@ void handle_keyboard_key(struct libinput_event *event,
wlr_event.time_msec = wlr_event.time_msec =
usec_to_msec(libinput_event_keyboard_get_time_usec(kbevent)); usec_to_msec(libinput_event_keyboard_get_time_usec(kbevent));
wlr_event.keycode = libinput_event_keyboard_get_key(kbevent); wlr_event.keycode = libinput_event_keyboard_get_key(kbevent);
enum libinput_key_state state = enum libinput_key_state state =
libinput_event_keyboard_get_key_state(kbevent); libinput_event_keyboard_get_key_state(kbevent);
switch (state) { switch (state) {
case LIBINPUT_KEY_STATE_RELEASED: case LIBINPUT_KEY_STATE_RELEASED:

View file

@ -1,11 +1,12 @@
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <libinput.h> #include <libinput.h>
#include <stdlib.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/interfaces/wlr_pointer.h> #include <wlr/interfaces/wlr_pointer.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "backend/libinput.h" #include "backend/libinput.h"
#include "util/signal.h"
struct wlr_pointer *wlr_libinput_pointer_create( struct wlr_pointer *wlr_libinput_pointer_create(
struct libinput_device *libinput_dev) { struct libinput_device *libinput_dev) {
@ -35,7 +36,7 @@ void handle_pointer_motion(struct libinput_event *event,
usec_to_msec(libinput_event_pointer_get_time_usec(pevent)); usec_to_msec(libinput_event_pointer_get_time_usec(pevent));
wlr_event.delta_x = libinput_event_pointer_get_dx(pevent); wlr_event.delta_x = libinput_event_pointer_get_dx(pevent);
wlr_event.delta_y = libinput_event_pointer_get_dy(pevent); wlr_event.delta_y = libinput_event_pointer_get_dy(pevent);
wl_signal_emit(&wlr_dev->pointer->events.motion, &wlr_event); wlr_signal_emit_safe(&wlr_dev->pointer->events.motion, &wlr_event);
} }
void handle_pointer_motion_abs(struct libinput_event *event, void handle_pointer_motion_abs(struct libinput_event *event,
@ -55,7 +56,7 @@ void handle_pointer_motion_abs(struct libinput_event *event,
wlr_event.x_mm = libinput_event_pointer_get_absolute_x(pevent); wlr_event.x_mm = libinput_event_pointer_get_absolute_x(pevent);
wlr_event.y_mm = libinput_event_pointer_get_absolute_y(pevent); wlr_event.y_mm = libinput_event_pointer_get_absolute_y(pevent);
libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm); libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm);
wl_signal_emit(&wlr_dev->pointer->events.motion_absolute, &wlr_event); wlr_signal_emit_safe(&wlr_dev->pointer->events.motion_absolute, &wlr_event);
} }
void handle_pointer_button(struct libinput_event *event, void handle_pointer_button(struct libinput_event *event,
@ -81,7 +82,7 @@ void handle_pointer_button(struct libinput_event *event,
wlr_event.state = WLR_BUTTON_RELEASED; wlr_event.state = WLR_BUTTON_RELEASED;
break; break;
} }
wl_signal_emit(&wlr_dev->pointer->events.button, &wlr_event); wlr_signal_emit_safe(&wlr_dev->pointer->events.button, &wlr_event);
} }
void handle_pointer_axis(struct libinput_event *event, void handle_pointer_axis(struct libinput_event *event,
@ -128,7 +129,7 @@ void handle_pointer_axis(struct libinput_event *event,
} }
wlr_event.delta = libinput_event_pointer_get_axis_value( wlr_event.delta = libinput_event_pointer_get_axis_value(
pevent, axies[i]); pevent, axies[i]);
wl_signal_emit(&wlr_dev->pointer->events.axis, &wlr_event); wlr_signal_emit_safe(&wlr_dev->pointer->events.axis, &wlr_event);
} }
} }
} }

View file

@ -1,11 +1,12 @@
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <libinput.h> #include <libinput.h>
#include <stdlib.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/interfaces/wlr_tablet_pad.h> #include <wlr/interfaces/wlr_tablet_pad.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "backend/libinput.h" #include "backend/libinput.h"
#include "util/signal.h"
struct wlr_tablet_pad *wlr_libinput_tablet_pad_create( struct wlr_tablet_pad *wlr_libinput_tablet_pad_create(
struct libinput_device *libinput_dev) { struct libinput_device *libinput_dev) {
@ -41,7 +42,7 @@ void handle_tablet_pad_button(struct libinput_event *event,
wlr_event.state = WLR_BUTTON_RELEASED; wlr_event.state = WLR_BUTTON_RELEASED;
break; break;
} }
wl_signal_emit(&wlr_dev->tablet_pad->events.button, &wlr_event); wlr_signal_emit_safe(&wlr_dev->tablet_pad->events.button, &wlr_event);
} }
void handle_tablet_pad_ring(struct libinput_event *event, void handle_tablet_pad_ring(struct libinput_event *event,
@ -67,7 +68,7 @@ void handle_tablet_pad_ring(struct libinput_event *event,
wlr_event.source = WLR_TABLET_PAD_RING_SOURCE_FINGER; wlr_event.source = WLR_TABLET_PAD_RING_SOURCE_FINGER;
break; break;
} }
wl_signal_emit(&wlr_dev->tablet_pad->events.ring, &wlr_event); wlr_signal_emit_safe(&wlr_dev->tablet_pad->events.ring, &wlr_event);
} }
void handle_tablet_pad_strip(struct libinput_event *event, void handle_tablet_pad_strip(struct libinput_event *event,
@ -93,5 +94,5 @@ void handle_tablet_pad_strip(struct libinput_event *event,
wlr_event.source = WLR_TABLET_PAD_STRIP_SOURCE_FINGER; wlr_event.source = WLR_TABLET_PAD_STRIP_SOURCE_FINGER;
break; break;
} }
wl_signal_emit(&wlr_dev->tablet_pad->events.strip, &wlr_event); wlr_signal_emit_safe(&wlr_dev->tablet_pad->events.strip, &wlr_event);
} }

View file

@ -1,11 +1,12 @@
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <libinput.h> #include <libinput.h>
#include <stdlib.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/interfaces/wlr_tablet_tool.h> #include <wlr/interfaces/wlr_tablet_tool.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "backend/libinput.h" #include "backend/libinput.h"
#include "util/signal.h"
struct wlr_tablet_tool *wlr_libinput_tablet_tool_create( struct wlr_tablet_tool *wlr_libinput_tablet_tool_create(
struct libinput_device *libinput_dev) { struct libinput_device *libinput_dev) {
@ -72,7 +73,7 @@ void handle_tablet_tool_axis(struct libinput_event *event,
} }
wlr_log(L_DEBUG, "Tablet tool axis event %d @ %f,%f", wlr_log(L_DEBUG, "Tablet tool axis event %d @ %f,%f",
wlr_event.updated_axes, wlr_event.x_mm, wlr_event.y_mm); wlr_event.updated_axes, wlr_event.x_mm, wlr_event.y_mm);
wl_signal_emit(&wlr_dev->tablet_tool->events.axis, &wlr_event); wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.axis, &wlr_event);
} }
void handle_tablet_tool_proximity(struct libinput_event *event, void handle_tablet_tool_proximity(struct libinput_event *event,
@ -98,7 +99,7 @@ void handle_tablet_tool_proximity(struct libinput_event *event,
handle_tablet_tool_axis(event, libinput_dev); handle_tablet_tool_axis(event, libinput_dev);
break; break;
} }
wl_signal_emit(&wlr_dev->tablet_tool->events.proximity, &wlr_event); wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.proximity, &wlr_event);
} }
void handle_tablet_tool_tip(struct libinput_event *event, void handle_tablet_tool_tip(struct libinput_event *event,
@ -124,7 +125,7 @@ void handle_tablet_tool_tip(struct libinput_event *event,
wlr_event.state = WLR_TABLET_TOOL_TIP_DOWN; wlr_event.state = WLR_TABLET_TOOL_TIP_DOWN;
break; break;
} }
wl_signal_emit(&wlr_dev->tablet_tool->events.tip, &wlr_event); wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.tip, &wlr_event);
} }
void handle_tablet_tool_button(struct libinput_event *event, void handle_tablet_tool_button(struct libinput_event *event,
@ -151,5 +152,5 @@ void handle_tablet_tool_button(struct libinput_event *event,
wlr_event.state = WLR_BUTTON_PRESSED; wlr_event.state = WLR_BUTTON_PRESSED;
break; break;
} }
wl_signal_emit(&wlr_dev->tablet_tool->events.button, &wlr_event); wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.button, &wlr_event);
} }

View file

@ -1,11 +1,12 @@
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <libinput.h> #include <libinput.h>
#include <stdlib.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/interfaces/wlr_touch.h> #include <wlr/interfaces/wlr_touch.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "backend/libinput.h" #include "backend/libinput.h"
#include "util/signal.h"
struct wlr_touch *wlr_libinput_touch_create( struct wlr_touch *wlr_libinput_touch_create(
struct libinput_device *libinput_dev) { struct libinput_device *libinput_dev) {
@ -37,7 +38,7 @@ void handle_touch_down(struct libinput_event *event,
wlr_event.x_mm = libinput_event_touch_get_x(tevent); wlr_event.x_mm = libinput_event_touch_get_x(tevent);
wlr_event.y_mm = libinput_event_touch_get_y(tevent); wlr_event.y_mm = libinput_event_touch_get_y(tevent);
libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm); libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm);
wl_signal_emit(&wlr_dev->touch->events.down, &wlr_event); wlr_signal_emit_safe(&wlr_dev->touch->events.down, &wlr_event);
} }
void handle_touch_up(struct libinput_event *event, void handle_touch_up(struct libinput_event *event,
@ -55,7 +56,7 @@ void handle_touch_up(struct libinput_event *event,
wlr_event.time_msec = wlr_event.time_msec =
usec_to_msec(libinput_event_touch_get_time_usec(tevent)); usec_to_msec(libinput_event_touch_get_time_usec(tevent));
wlr_event.touch_id = libinput_event_touch_get_slot(tevent); wlr_event.touch_id = libinput_event_touch_get_slot(tevent);
wl_signal_emit(&wlr_dev->touch->events.up, &wlr_event); wlr_signal_emit_safe(&wlr_dev->touch->events.up, &wlr_event);
} }
void handle_touch_motion(struct libinput_event *event, void handle_touch_motion(struct libinput_event *event,
@ -76,7 +77,7 @@ void handle_touch_motion(struct libinput_event *event,
wlr_event.x_mm = libinput_event_touch_get_x(tevent); wlr_event.x_mm = libinput_event_touch_get_x(tevent);
wlr_event.y_mm = libinput_event_touch_get_y(tevent); wlr_event.y_mm = libinput_event_touch_get_y(tevent);
libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm); libinput_device_get_size(libinput_dev, &wlr_event.width_mm, &wlr_event.height_mm);
wl_signal_emit(&wlr_dev->touch->events.motion, &wlr_event); wlr_signal_emit_safe(&wlr_dev->touch->events.motion, &wlr_event);
} }
void handle_touch_cancel(struct libinput_event *event, void handle_touch_cancel(struct libinput_event *event,
@ -94,5 +95,5 @@ void handle_touch_cancel(struct libinput_event *event,
wlr_event.time_msec = wlr_event.time_msec =
usec_to_msec(libinput_event_touch_get_time_usec(tevent)); usec_to_msec(libinput_event_touch_get_time_usec(tevent));
wlr_event.touch_id = libinput_event_touch_get_slot(tevent); wlr_event.touch_id = libinput_event_touch_get_slot(tevent);
wl_signal_emit(&wlr_dev->touch->events.cancel, &wlr_event); wlr_signal_emit_safe(&wlr_dev->touch->events.cancel, &wlr_event);
} }

View file

@ -1,7 +1,5 @@
backend_files = files( backend_files = files(
'backend.c', 'backend.c',
'session/direct-ipc.c',
'session/session.c',
'drm/atomic.c', 'drm/atomic.c',
'drm/backend.c', 'drm/backend.c',
'drm/drm.c', 'drm/drm.c',
@ -10,8 +8,8 @@ backend_files = files(
'drm/renderer.c', 'drm/renderer.c',
'drm/util.c', 'drm/util.c',
'headless/backend.c', 'headless/backend.c',
'headless/output.c',
'headless/input_device.c', 'headless/input_device.c',
'headless/output.c',
'libinput/backend.c', 'libinput/backend.c',
'libinput/events.c', 'libinput/events.c',
'libinput/keyboard.c', 'libinput/keyboard.c',
@ -20,6 +18,8 @@ backend_files = files(
'libinput/tablet_tool.c', 'libinput/tablet_tool.c',
'libinput/touch.c', 'libinput/touch.c',
'multi/backend.c', 'multi/backend.c',
'session/direct-ipc.c',
'session/session.c',
'wayland/backend.c', 'wayland/backend.c',
'wayland/output.c', 'wayland/output.c',
'wayland/registry.c', 'wayland/registry.c',

View file

@ -4,17 +4,16 @@
#include <wlr/backend/interface.h> #include <wlr/backend/interface.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "backend/multi.h"
#include "backend/drm/drm.h" #include "backend/drm/drm.h"
#include "backend/multi.h"
#include "util/signal.h"
struct subbackend_state { struct subbackend_state {
struct wlr_backend *backend; struct wlr_backend *backend;
struct wlr_backend *container; struct wlr_backend *container;
struct wl_listener input_add; struct wl_listener new_input;
struct wl_listener input_remove; struct wl_listener new_output;
struct wl_listener output_add; struct wl_listener destroy;
struct wl_listener output_remove;
struct wl_listener backend_destroy;
struct wl_list link; struct wl_list link;
}; };
@ -31,11 +30,9 @@ static bool multi_backend_start(struct wlr_backend *wlr_backend) {
} }
static void subbackend_state_destroy(struct subbackend_state *sub) { static void subbackend_state_destroy(struct subbackend_state *sub) {
wl_list_remove(&sub->input_add.link); wl_list_remove(&sub->new_input.link);
wl_list_remove(&sub->input_remove.link); wl_list_remove(&sub->new_output.link);
wl_list_remove(&sub->output_add.link); wl_list_remove(&sub->destroy.link);
wl_list_remove(&sub->output_remove.link);
wl_list_remove(&sub->backend_destroy.link);
wl_list_remove(&sub->link); wl_list_remove(&sub->link);
free(sub); free(sub);
} }
@ -51,7 +48,7 @@ static void multi_backend_destroy(struct wlr_backend *wlr_backend) {
} }
// Destroy this backend only after removing all sub-backends // Destroy this backend only after removing all sub-backends
wl_signal_emit(&wlr_backend->events.destroy, backend); wlr_signal_emit_safe(&wlr_backend->events.destroy, backend);
free(backend); free(backend);
} }
@ -117,34 +114,21 @@ bool wlr_backend_is_multi(struct wlr_backend *b) {
return b->impl == &backend_impl; return b->impl == &backend_impl;
} }
static void input_add_reemit(struct wl_listener *listener, void *data) { static void new_input_reemit(struct wl_listener *listener, void *data) {
struct subbackend_state *state = wl_container_of(listener, struct subbackend_state *state = wl_container_of(listener,
state, input_add); state, new_input);
wl_signal_emit(&state->container->events.input_add, data); wlr_signal_emit_safe(&state->container->events.new_input, data);
} }
static void input_remove_reemit(struct wl_listener *listener, void *data) { static void new_output_reemit(struct wl_listener *listener, void *data) {
struct subbackend_state *state = wl_container_of(listener, struct subbackend_state *state = wl_container_of(listener,
state, input_remove); state, new_output);
wl_signal_emit(&state->container->events.input_remove, data); wlr_signal_emit_safe(&state->container->events.new_output, data);
}
static void output_add_reemit(struct wl_listener *listener, void *data) {
struct subbackend_state *state = wl_container_of(listener,
state, output_add);
wl_signal_emit(&state->container->events.output_add, data);
}
static void output_remove_reemit(struct wl_listener *listener, void *data) {
struct subbackend_state *state = wl_container_of(listener,
state, output_remove);
wl_signal_emit(&state->container->events.output_remove, data);
} }
static void handle_subbackend_destroy(struct wl_listener *listener, static void handle_subbackend_destroy(struct wl_listener *listener,
void *data) { void *data) {
struct subbackend_state *state = wl_container_of(listener, struct subbackend_state *state = wl_container_of(listener, state, destroy);
state, backend_destroy);
subbackend_state_destroy(state); subbackend_state_destroy(state);
} }
@ -179,22 +163,16 @@ void wlr_multi_backend_add(struct wlr_backend *_multi,
sub->backend = backend; sub->backend = backend;
sub->container = &multi->backend; sub->container = &multi->backend;
wl_signal_add(&backend->events.destroy, &sub->backend_destroy); wl_signal_add(&backend->events.destroy, &sub->destroy);
sub->backend_destroy.notify = handle_subbackend_destroy; sub->destroy.notify = handle_subbackend_destroy;
wl_signal_add(&backend->events.input_add, &sub->input_add); wl_signal_add(&backend->events.new_input, &sub->new_input);
sub->input_add.notify = input_add_reemit; sub->new_input.notify = new_input_reemit;
wl_signal_add(&backend->events.input_remove, &sub->input_remove); wl_signal_add(&backend->events.new_output, &sub->new_output);
sub->input_remove.notify = input_remove_reemit; sub->new_output.notify = new_output_reemit;
wl_signal_add(&backend->events.output_add, &sub->output_add); wlr_signal_emit_safe(&multi->events.backend_add, backend);
sub->output_add.notify = output_add_reemit;
wl_signal_add(&backend->events.output_remove, &sub->output_remove);
sub->output_remove.notify = output_remove_reemit;
wl_signal_emit(&multi->events.backend_add, backend);
} }
void wlr_multi_backend_remove(struct wlr_backend *_multi, void wlr_multi_backend_remove(struct wlr_backend *_multi,
@ -206,7 +184,7 @@ void wlr_multi_backend_remove(struct wlr_backend *_multi,
multi_backend_get_subbackend(multi, backend); multi_backend_get_subbackend(multi, backend);
if (sub) { if (sub) {
wl_signal_emit(&multi->events.backend_remove, backend); wlr_signal_emit_safe(&multi->events.backend_remove, backend);
subbackend_state_destroy(sub); subbackend_state_destroy(sub);
} }
} }

View file

@ -1,21 +1,22 @@
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <unistd.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <termios.h>
#include <fcntl.h>
#include <sys/types.h>
#include <dev/evdev/input.h> #include <dev/evdev/input.h>
#include <sys/kbio.h> #include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/consio.h> #include <sys/consio.h>
#include <sys/ioctl.h>
#include <sys/kbio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <termios.h>
#include <unistd.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/backend/session/interface.h> #include <wlr/backend/session/interface.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "backend/session/direct-ipc.h" #include "backend/session/direct-ipc.h"
#include "util/signal.h"
const struct session_impl session_direct; const struct session_impl session_direct;
@ -95,12 +96,12 @@ static int vt_handler(int signo, void *data) {
if (session->base.active) { if (session->base.active) {
session->base.active = false; session->base.active = false;
wl_signal_emit(&session->base.session_signal, session); wlr_signal_emit_safe(&session->base.session_signal, session);
ioctl(session->tty_fd, VT_RELDISP, 1); ioctl(session->tty_fd, VT_RELDISP, 1);
} else { } else {
ioctl(session->tty_fd, VT_RELDISP, VT_ACKACQ); ioctl(session->tty_fd, VT_RELDISP, VT_ACKACQ);
session->base.active = true; session->base.active = true;
wl_signal_emit(&session->base.session_signal, session); wlr_signal_emit_safe(&session->base.session_signal, session);
} }
return 1; return 1;

View file

@ -4,22 +4,22 @@
#define INPUT_MAJOR 0 #define INPUT_MAJOR 0
#endif #endif
#include <errno.h> #include <errno.h>
#include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h>
#include <wlr/config.h>
#include <wlr/util/log.h>
#include <xf86drm.h>
#ifdef __linux__ #ifdef __linux__
#include <sys/sysmacros.h> #include <sys/sysmacros.h>
#include <linux/major.h> #include <linux/major.h>
#endif #endif
#include <xf86drm.h>
#include <wlr/config.h>
#include <wlr/util/log.h>
#include "backend/session/direct-ipc.h" #include "backend/session/direct-ipc.h"
enum { DRM_MAJOR = 226 }; enum { DRM_MAJOR = 226 };

View file

@ -1,21 +1,22 @@
#define _POSIX_C_SOURCE 200809L #define _POSIX_C_SOURCE 200809L
#include <errno.h> #include <errno.h>
#include <stdlib.h> #include <linux/input.h>
#include <stdio.h> #include <linux/kd.h>
#include <stdbool.h> #include <linux/major.h>
#include <unistd.h> #include <linux/vt.h>
#include <signal.h> #include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/sysmacros.h> #include <sys/sysmacros.h>
#include <linux/kd.h> #include <unistd.h>
#include <linux/major.h>
#include <linux/input.h>
#include <linux/vt.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/backend/session/interface.h> #include <wlr/backend/session/interface.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "backend/session/direct-ipc.h" #include "backend/session/direct-ipc.h"
#include "util/signal.h"
enum { DRM_MAJOR = 226 }; enum { DRM_MAJOR = 226 };
@ -107,7 +108,7 @@ static int vt_handler(int signo, void *data) {
if (session->base.active) { if (session->base.active) {
session->base.active = false; session->base.active = false;
wl_signal_emit(&session->base.session_signal, session); wlr_signal_emit_safe(&session->base.session_signal, session);
struct wlr_device *dev; struct wlr_device *dev;
wl_list_for_each(dev, &session->base.devices, link) { wl_list_for_each(dev, &session->base.devices, link) {
@ -130,7 +131,7 @@ static int vt_handler(int signo, void *data) {
} }
session->base.active = true; session->base.active = true;
wl_signal_emit(&session->base.session_signal, session); wlr_signal_emit_safe(&session->base.session_signal, session);
} }
return 1; return 1;

View file

@ -1,25 +1,26 @@
#define _POSIX_C_SOURCE 200809L #define _POSIX_C_SOURCE 200809L
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <errno.h>
#include <fcntl.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/sysmacros.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <sys/sysmacros.h>
#include <unistd.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/config.h>
#include <wlr/backend/session/interface.h> #include <wlr/backend/session/interface.h>
#include <wlr/config.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "util/signal.h"
#ifdef WLR_HAS_SYSTEMD #ifdef WLR_HAS_SYSTEMD
#include <systemd/sd-bus.h> #include <systemd/sd-bus.h>
#include <systemd/sd-login.h> #include <systemd/sd-login.h>
#elif defined(WLR_HAS_ELOGIND) #elif defined(WLR_HAS_ELOGIND)
#include <elogind/sd-bus.h> #include <elogind/sd-bus.h>
#include <elogind/sd-login.h> #include <elogind/sd-login.h>
#endif #endif
enum { DRM_MAJOR = 226 }; enum { DRM_MAJOR = 226 };
@ -250,7 +251,7 @@ static int pause_device(sd_bus_message *msg, void *userdata, sd_bus_error *ret_e
if (major == DRM_MAJOR) { if (major == DRM_MAJOR) {
session->base.active = false; session->base.active = false;
wl_signal_emit(&session->base.session_signal, session); wlr_signal_emit_safe(&session->base.session_signal, session);
} }
if (strcmp(type, "pause") == 0) { if (strcmp(type, "pause") == 0) {
@ -286,7 +287,7 @@ static int resume_device(sd_bus_message *msg, void *userdata, sd_bus_error *ret_
if (!session->base.active) { if (!session->base.active) {
session->base.active = true; session->base.active = true;
wl_signal_emit(&session->base.session_signal, session); wlr_signal_emit_safe(&session->base.session_signal, session);
} }
} }

View file

@ -1,18 +1,19 @@
#define _POSIX_C_SOURCE 200809L #define _POSIX_C_SOURCE 200809L
#include <assert.h> #include <assert.h>
#include <libudev.h>
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <libudev.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include <wlr/config.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
#include <wlr/backend/session/interface.h> #include <wlr/backend/session/interface.h>
#include <wlr/config.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <xf86drm.h>
#include <xf86drmMode.h>
#include "util/signal.h"
extern const struct session_impl session_logind; extern const struct session_impl session_logind;
extern const struct session_impl session_direct; extern const struct session_impl session_direct;
@ -49,7 +50,7 @@ static int udev_event(int fd, uint32_t mask, void *data) {
wl_list_for_each(dev, &session->devices, link) { wl_list_for_each(dev, &session->devices, link) {
if (dev->dev == devnum) { if (dev->dev == devnum) {
wl_signal_emit(&dev->signal, session); wlr_signal_emit_safe(&dev->signal, session);
break; break;
} }
} }

View file

@ -1,17 +1,18 @@
#include <stdlib.h>
#include <stdint.h>
#include <assert.h> #include <assert.h>
#include <limits.h>
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/backend/interface.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/render/egl.h> #include <wlr/render/egl.h>
#include <wlr/render/gles2.h> #include <wlr/render/gles2.h>
#include <wlr/backend/interface.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "backend/wayland.h" #include "backend/wayland.h"
#include "util/signal.h"
#include "xdg-shell-unstable-v6-client-protocol.h" #include "xdg-shell-unstable-v6-client-protocol.h"
static int dispatch_events(int fd, uint32_t mask, void *data) { static int dispatch_events(int fd, uint32_t mask, void *data) {
@ -80,7 +81,7 @@ static void wlr_wl_backend_destroy(struct wlr_backend *wlr_backend) {
wlr_input_device_destroy(input_device); wlr_input_device_destroy(input_device);
} }
wl_signal_emit(&wlr_backend->events.destroy, wlr_backend); wlr_signal_emit_safe(&wlr_backend->events.destroy, wlr_backend);
wl_list_remove(&backend->local_display_destroy.link); wl_list_remove(&backend->local_display_destroy.link);

View file

@ -1,16 +1,17 @@
#include <stdio.h>
#include <assert.h> #include <assert.h>
#include <GLES2/gl2.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>
#include <wayland-client.h> #include <wayland-client.h>
#include <GLES2/gl2.h>
#include <wlr/interfaces/wlr_output.h> #include <wlr/interfaces/wlr_output.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "backend/wayland.h" #include "backend/wayland.h"
#include "util/signal.h"
#include "xdg-shell-unstable-v6-client-protocol.h" #include "xdg-shell-unstable-v6-client-protocol.h"
int os_create_anonymous_file(off_t size); int os_create_anonymous_file(off_t size);
@ -338,7 +339,7 @@ struct wlr_output *wlr_wl_output_create(struct wlr_backend *_backend) {
wl_list_insert(&backend->outputs, &output->link); wl_list_insert(&backend->outputs, &output->link);
wlr_output_update_enabled(wlr_output, true); wlr_output_update_enabled(wlr_output, true);
wl_signal_emit(&backend->backend.events.output_add, wlr_output); wlr_signal_emit_safe(&backend->backend.events.new_output, wlr_output);
return wlr_output; return wlr_output;
error: error:

View file

@ -6,7 +6,6 @@
#include "backend/wayland.h" #include "backend/wayland.h"
#include "xdg-shell-unstable-v6-client-protocol.h" #include "xdg-shell-unstable-v6-client-protocol.h"
static void xdg_shell_handle_ping(void *data, struct zxdg_shell_v6 *shell, static void xdg_shell_handle_ping(void *data, struct zxdg_shell_v6 *shell,
uint32_t serial) { uint32_t serial) {
zxdg_shell_v6_pong(shell, serial); zxdg_shell_v6_pong(shell, serial);

View file

@ -1,16 +1,17 @@
#define _XOPEN_SOURCE 500 #define _XOPEN_SOURCE 500
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <wayland-client.h> #include <wayland-client.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/interfaces/wlr_input_device.h> #include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_pointer.h>
#include <wlr/interfaces/wlr_keyboard.h> #include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/interfaces/wlr_pointer.h>
#include <wlr/interfaces/wlr_touch.h> #include <wlr/interfaces/wlr_touch.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "backend/wayland.h" #include "backend/wayland.h"
#include "util/signal.h"
static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer, static void pointer_handle_enter(void *data, struct wl_pointer *wl_pointer,
uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x, uint32_t serial, struct wl_surface *surface, wl_fixed_t surface_x,
@ -78,7 +79,7 @@ static void pointer_handle_motion(void *data, struct wl_pointer *wl_pointer,
wlr_event.height_mm = layout_box.height; wlr_event.height_mm = layout_box.height;
wlr_event.x_mm = transformed.x + wlr_output->lx - layout_box.x; wlr_event.x_mm = transformed.x + wlr_output->lx - layout_box.x;
wlr_event.y_mm = transformed.y + wlr_output->ly - layout_box.y; wlr_event.y_mm = transformed.y + wlr_output->ly - layout_box.y;
wl_signal_emit(&dev->pointer->events.motion_absolute, &wlr_event); wlr_signal_emit_safe(&dev->pointer->events.motion_absolute, &wlr_event);
} }
static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer, static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
@ -91,7 +92,7 @@ static void pointer_handle_button(void *data, struct wl_pointer *wl_pointer,
wlr_event.button = button; wlr_event.button = button;
wlr_event.state = state; wlr_event.state = state;
wlr_event.time_msec = time; wlr_event.time_msec = time;
wl_signal_emit(&dev->pointer->events.button, &wlr_event); wlr_signal_emit_safe(&dev->pointer->events.button, &wlr_event);
} }
static void pointer_handle_axis(void *data, struct wl_pointer *wl_pointer, static void pointer_handle_axis(void *data, struct wl_pointer *wl_pointer,
@ -106,7 +107,7 @@ static void pointer_handle_axis(void *data, struct wl_pointer *wl_pointer,
wlr_event.orientation = axis; wlr_event.orientation = axis;
wlr_event.time_msec = time; wlr_event.time_msec = time;
wlr_event.source = wlr_wl_pointer->axis_source; wlr_event.source = wlr_wl_pointer->axis_source;
wl_signal_emit(&dev->pointer->events.axis, &wlr_event); wlr_signal_emit_safe(&dev->pointer->events.axis, &wlr_event);
} }
static void pointer_handle_frame(void *data, struct wl_pointer *wl_pointer) { static void pointer_handle_frame(void *data, struct wl_pointer *wl_pointer) {
@ -192,9 +193,8 @@ static struct wl_keyboard_listener keyboard_listener = {
.repeat_info = keyboard_handle_repeat_info .repeat_info = keyboard_handle_repeat_info
}; };
static void input_device_destroy(struct wlr_input_device *_dev) { static void input_device_destroy(struct wlr_input_device *wlr_dev) {
struct wlr_wl_input_device *dev = (struct wlr_wl_input_device *)_dev; struct wlr_wl_input_device *dev = (struct wlr_wl_input_device *)wlr_dev;
wl_signal_emit(&dev->backend->backend.events.input_remove, &dev->wlr_input_device);
if (dev->resource) { if (dev->resource) {
wl_proxy_destroy(dev->resource); wl_proxy_destroy(dev->resource);
} }
@ -256,7 +256,7 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
wlr_device->pointer = &wlr_wl_pointer->wlr_pointer; wlr_device->pointer = &wlr_wl_pointer->wlr_pointer;
wlr_pointer_init(wlr_device->pointer, NULL); wlr_pointer_init(wlr_device->pointer, NULL);
wlr_wl_device->resource = wl_pointer; wlr_wl_device->resource = wl_pointer;
wl_signal_emit(&backend->backend.events.input_add, wlr_device); wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_device);
backend->pointer = wl_pointer; backend->pointer = wl_pointer;
} }
if ((caps & WL_SEAT_CAPABILITY_KEYBOARD)) { if ((caps & WL_SEAT_CAPABILITY_KEYBOARD)) {
@ -280,7 +280,7 @@ static void seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
struct wl_keyboard *wl_keyboard = wl_seat_get_keyboard(wl_seat); struct wl_keyboard *wl_keyboard = wl_seat_get_keyboard(wl_seat);
wl_keyboard_add_listener(wl_keyboard, &keyboard_listener, wlr_device); wl_keyboard_add_listener(wl_keyboard, &keyboard_listener, wlr_device);
wlr_wl_device->resource = wl_keyboard; wlr_wl_device->resource = wl_keyboard;
wl_signal_emit(&backend->backend.events.input_add, wlr_device); wlr_signal_emit_safe(&backend->backend.events.new_input, wlr_device);
} }
} }

View file

@ -1,28 +1,29 @@
#define _POSIX_C_SOURCE 200112L #define _POSIX_C_SOURCE 200112L
#include <EGL/egl.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <EGL/egl.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <xcb/xcb.h> #include <wlr/backend/interface.h>
#include <xcb/glx.h> #include <wlr/backend/x11.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/interfaces/wlr_pointer.h>
#include <wlr/render/egl.h>
#include <wlr/render/gles2.h>
#include <wlr/util/log.h>
#include <X11/Xlib-xcb.h> #include <X11/Xlib-xcb.h>
#include <xcb/glx.h>
#include <xcb/xcb.h>
#ifdef __linux__ #ifdef __linux__
#include <linux/input-event-codes.h> #include <linux/input-event-codes.h>
#elif __FreeBSD__ #elif __FreeBSD__
#include <dev/evdev/input-event-codes.h> #include <dev/evdev/input-event-codes.h>
#endif #endif
#include <wlr/backend/interface.h>
#include <wlr/backend/x11.h>
#include <wlr/render/egl.h>
#include <wlr/render/gles2.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/interfaces/wlr_pointer.h>
#include <wlr/util/log.h>
#include "backend/x11.h" #include "backend/x11.h"
#include "util/signal.h"
static struct wlr_backend_impl backend_impl; static struct wlr_backend_impl backend_impl;
static struct wlr_output_impl output_impl; static struct wlr_output_impl output_impl;
@ -77,7 +78,7 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e
.orientation = WLR_AXIS_ORIENTATION_VERTICAL, .orientation = WLR_AXIS_ORIENTATION_VERTICAL,
.delta = delta, .delta = delta,
}; };
wl_signal_emit(&x11->pointer.events.axis, &axis); wlr_signal_emit_safe(&x11->pointer.events.axis, &axis);
x11->time = ev->time; x11->time = ev->time;
break; break;
} }
@ -96,7 +97,7 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e
WLR_BUTTON_PRESSED : WLR_BUTTON_RELEASED, WLR_BUTTON_PRESSED : WLR_BUTTON_RELEASED,
}; };
wl_signal_emit(&x11->pointer.events.button, &button); wlr_signal_emit_safe(&x11->pointer.events.button, &button);
} }
x11->time = ev->time; x11->time = ev->time;
break; break;
@ -112,7 +113,7 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e
.height_mm = output->wlr_output.height, .height_mm = output->wlr_output.height,
}; };
wl_signal_emit(&x11->pointer.events.motion_absolute, &abs); wlr_signal_emit_safe(&x11->pointer.events.motion_absolute, &abs);
x11->time = ev->time; x11->time = ev->time;
break; break;
} }
@ -140,7 +141,7 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e
.height_mm = output->wlr_output.height, .height_mm = output->wlr_output.height,
}; };
wl_signal_emit(&x11->pointer.events.motion_absolute, &abs); wlr_signal_emit_safe(&x11->pointer.events.motion_absolute, &abs);
break; break;
} }
case XCB_GLX_DELETE_QUERIES_ARB: { case XCB_GLX_DELETE_QUERIES_ARB: {
@ -229,9 +230,9 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) {
xcb_flush(x11->xcb_conn); xcb_flush(x11->xcb_conn);
wlr_output_update_enabled(&output->wlr_output, true); wlr_output_update_enabled(&output->wlr_output, true);
wl_signal_emit(&x11->backend.events.output_add, output); wlr_signal_emit_safe(&x11->backend.events.new_output, output);
wl_signal_emit(&x11->backend.events.input_add, &x11->keyboard_dev); wlr_signal_emit_safe(&x11->backend.events.new_input, &x11->keyboard_dev);
wl_signal_emit(&x11->backend.events.input_add, &x11->pointer_dev); wlr_signal_emit_safe(&x11->backend.events.new_input, &x11->pointer_dev);
wl_event_source_timer_update(x11->frame_timer, 16); wl_event_source_timer_update(x11->frame_timer, 16);
@ -248,8 +249,8 @@ static void wlr_x11_backend_destroy(struct wlr_backend *backend) {
struct wlr_x11_output *output = &x11->output; struct wlr_x11_output *output = &x11->output;
wlr_output_destroy(&output->wlr_output); wlr_output_destroy(&output->wlr_output);
wl_signal_emit(&backend->events.input_remove, &x11->pointer_dev); wlr_signal_emit_safe(&x11->pointer_dev.events.destroy, &x11->pointer_dev);
wl_signal_emit(&backend->events.input_remove, &x11->keyboard_dev); wlr_signal_emit_safe(&x11->keyboard_dev.events.destroy, &x11->keyboard_dev);
// TODO probably need to use wlr_keyboard_destroy, but the devices need to // TODO probably need to use wlr_keyboard_destroy, but the devices need to
// be malloced for that to work // be malloced for that to work
if (x11->keyboard_dev.keyboard->keymap) { if (x11->keyboard_dev.keyboard->keymap) {
@ -259,7 +260,7 @@ static void wlr_x11_backend_destroy(struct wlr_backend *backend) {
xkb_state_unref(x11->keyboard_dev.keyboard->xkb_state); xkb_state_unref(x11->keyboard_dev.keyboard->xkb_state);
} }
wl_signal_emit(&backend->events.destroy, backend); wlr_signal_emit_safe(&backend->events.destroy, backend);
wl_list_remove(&x11->display_destroy.link); wl_list_remove(&x11->display_destroy.link);

View file

@ -56,10 +56,24 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) {
} }
} }
static void keyboard_destroy_notify(struct wl_listener *listener, void *data) {
struct keyboard_state *kbstate = wl_container_of(listener, kbstate, destroy);
struct compositor_state *state = kbstate->compositor;
if (state->input_remove_cb) {
state->input_remove_cb(state, kbstate->device);
}
wl_list_remove(&kbstate->link);
wl_list_remove(&kbstate->destroy.link);
wl_list_remove(&kbstate->key.link);
free(kbstate);
}
static void keyboard_add(struct wlr_input_device *device, struct compositor_state *state) { static void keyboard_add(struct wlr_input_device *device, struct compositor_state *state) {
struct keyboard_state *kbstate = calloc(sizeof(struct keyboard_state), 1); struct keyboard_state *kbstate = calloc(sizeof(struct keyboard_state), 1);
kbstate->device = device; kbstate->device = device;
kbstate->compositor = state; kbstate->compositor = state;
kbstate->destroy.notify = keyboard_destroy_notify;
wl_signal_add(&device->events.destroy, &kbstate->destroy);
kbstate->key.notify = keyboard_key_notify; kbstate->key.notify = keyboard_key_notify;
wl_signal_add(&device->keyboard->events.key, &kbstate->key); wl_signal_add(&device->keyboard->events.key, &kbstate->key);
wl_list_insert(&state->keyboards, &kbstate->link); wl_list_insert(&state->keyboards, &kbstate->link);
@ -117,17 +131,34 @@ static void pointer_axis_notify(struct wl_listener *listener, void *data) {
} }
} }
static void pointer_destroy_notify(struct wl_listener *listener, void *data) {
struct pointer_state *pstate = wl_container_of(listener, pstate, destroy);
struct compositor_state *state = pstate->compositor;
if (state->input_remove_cb) {
state->input_remove_cb(state, pstate->device);
}
wl_list_remove(&pstate->link);
wl_list_remove(&pstate->destroy.link);
wl_list_remove(&pstate->motion.link);
wl_list_remove(&pstate->motion_absolute.link);
wl_list_remove(&pstate->button.link);
wl_list_remove(&pstate->axis.link);
free(pstate);
}
static void pointer_add(struct wlr_input_device *device, struct compositor_state *state) { static void pointer_add(struct wlr_input_device *device, struct compositor_state *state) {
struct pointer_state *pstate = calloc(sizeof(struct pointer_state), 1); struct pointer_state *pstate = calloc(sizeof(struct pointer_state), 1);
pstate->device = device; pstate->device = device;
pstate->compositor = state; pstate->compositor = state;
pstate->destroy.notify = pointer_destroy_notify;
wl_signal_add(&device->events.destroy, &pstate->destroy);
pstate->motion.notify = pointer_motion_notify; pstate->motion.notify = pointer_motion_notify;
pstate->motion_absolute.notify = pointer_motion_absolute_notify;
pstate->button.notify = pointer_button_notify;
pstate->axis.notify = pointer_axis_notify;
wl_signal_add(&device->pointer->events.motion, &pstate->motion); wl_signal_add(&device->pointer->events.motion, &pstate->motion);
pstate->motion_absolute.notify = pointer_motion_absolute_notify;
wl_signal_add(&device->pointer->events.motion_absolute, &pstate->motion_absolute); wl_signal_add(&device->pointer->events.motion_absolute, &pstate->motion_absolute);
pstate->button.notify = pointer_button_notify;
wl_signal_add(&device->pointer->events.button, &pstate->button); wl_signal_add(&device->pointer->events.button, &pstate->button);
pstate->axis.notify = pointer_axis_notify;
wl_signal_add(&device->pointer->events.axis, &pstate->axis); wl_signal_add(&device->pointer->events.axis, &pstate->axis);
wl_list_insert(&state->pointers, &pstate->link); wl_list_insert(&state->pointers, &pstate->link);
} }
@ -166,17 +197,34 @@ static void touch_cancel_notify(struct wl_listener *listener, void *data) {
} }
} }
static void touch_destroy_notify(struct wl_listener *listener, void *data) {
struct touch_state *tstate = wl_container_of(listener, tstate, destroy);
struct compositor_state *state = tstate->compositor;
if (state->input_remove_cb) {
state->input_remove_cb(state, tstate->device);
}
wl_list_remove(&tstate->link);
wl_list_remove(&tstate->destroy.link);
wl_list_remove(&tstate->down.link);
wl_list_remove(&tstate->motion.link);
wl_list_remove(&tstate->up.link);
wl_list_remove(&tstate->cancel.link);
free(tstate);
}
static void touch_add(struct wlr_input_device *device, struct compositor_state *state) { static void touch_add(struct wlr_input_device *device, struct compositor_state *state) {
struct touch_state *tstate = calloc(sizeof(struct touch_state), 1); struct touch_state *tstate = calloc(sizeof(struct touch_state), 1);
tstate->device = device; tstate->device = device;
tstate->compositor = state; tstate->compositor = state;
tstate->destroy.notify = touch_destroy_notify;
wl_signal_add(&device->events.destroy, &tstate->destroy);
tstate->down.notify = touch_down_notify; tstate->down.notify = touch_down_notify;
tstate->motion.notify = touch_motion_notify;
tstate->up.notify = touch_up_notify;
tstate->cancel.notify = touch_cancel_notify;
wl_signal_add(&device->touch->events.down, &tstate->down); wl_signal_add(&device->touch->events.down, &tstate->down);
tstate->motion.notify = touch_motion_notify;
wl_signal_add(&device->touch->events.motion, &tstate->motion); wl_signal_add(&device->touch->events.motion, &tstate->motion);
tstate->up.notify = touch_up_notify;
wl_signal_add(&device->touch->events.up, &tstate->up); wl_signal_add(&device->touch->events.up, &tstate->up);
tstate->cancel.notify = touch_cancel_notify;
wl_signal_add(&device->touch->events.cancel, &tstate->cancel); wl_signal_add(&device->touch->events.cancel, &tstate->cancel);
wl_list_insert(&state->touch, &tstate->link); wl_list_insert(&state->touch, &tstate->link);
} }
@ -205,18 +253,35 @@ static void tablet_tool_button_notify(struct wl_listener *listener, void *data)
} }
} }
static void tablet_tool_destroy_notify(struct wl_listener *listener, void *data) {
struct tablet_tool_state *tstate = wl_container_of(listener, tstate, destroy);
struct compositor_state *state = tstate->compositor;
if (state->input_remove_cb) {
state->input_remove_cb(state, tstate->device);
}
wl_list_remove(&tstate->link);
wl_list_remove(&tstate->destroy.link);
wl_list_remove(&tstate->axis.link);
wl_list_remove(&tstate->proximity.link);
//wl_list_remove(&tstate->tip.link);
wl_list_remove(&tstate->button.link);
free(tstate);
}
static void tablet_tool_add(struct wlr_input_device *device, static void tablet_tool_add(struct wlr_input_device *device,
struct compositor_state *state) { struct compositor_state *state) {
struct tablet_tool_state *tstate = calloc(sizeof(struct tablet_tool_state), 1); struct tablet_tool_state *tstate = calloc(sizeof(struct tablet_tool_state), 1);
tstate->device = device; tstate->device = device;
tstate->compositor = state; tstate->compositor = state;
tstate->destroy.notify = tablet_tool_destroy_notify;
wl_signal_add(&device->events.destroy, &tstate->destroy);
tstate->axis.notify = tablet_tool_axis_notify; tstate->axis.notify = tablet_tool_axis_notify;
tstate->proximity.notify = tablet_tool_proximity_notify;
//tstate->tip.notify = tablet_tool_tip_notify;
tstate->button.notify = tablet_tool_button_notify;
wl_signal_add(&device->tablet_tool->events.axis, &tstate->axis); wl_signal_add(&device->tablet_tool->events.axis, &tstate->axis);
tstate->proximity.notify = tablet_tool_proximity_notify;
wl_signal_add(&device->tablet_tool->events.proximity, &tstate->proximity); wl_signal_add(&device->tablet_tool->events.proximity, &tstate->proximity);
//tstate->tip.notify = tablet_tool_tip_notify;
//wl_signal_add(&device->tablet_tool->events.tip, &tstate->tip); //wl_signal_add(&device->tablet_tool->events.tip, &tstate->tip);
tstate->button.notify = tablet_tool_button_notify;
wl_signal_add(&device->tablet_tool->events.button, &tstate->button); wl_signal_add(&device->tablet_tool->events.button, &tstate->button);
wl_list_insert(&state->tablet_tools, &tstate->link); wl_list_insert(&state->tablet_tools, &tstate->link);
} }
@ -229,19 +294,33 @@ static void tablet_pad_button_notify(struct wl_listener *listener, void *data) {
} }
} }
static void tablet_pad_destroy_notify(struct wl_listener *listener, void *data) {
struct tablet_pad_state *pstate = wl_container_of(listener, pstate, destroy);
struct compositor_state *state = pstate->compositor;
if (state->input_remove_cb) {
state->input_remove_cb(state, pstate->device);
}
wl_list_remove(&pstate->link);
wl_list_remove(&pstate->destroy.link);
wl_list_remove(&pstate->button.link);
free(pstate);
}
static void tablet_pad_add(struct wlr_input_device *device, static void tablet_pad_add(struct wlr_input_device *device,
struct compositor_state *state) { struct compositor_state *state) {
struct tablet_pad_state *pstate = calloc(sizeof(struct tablet_pad_state), 1); struct tablet_pad_state *pstate = calloc(sizeof(struct tablet_pad_state), 1);
pstate->device = device; pstate->device = device;
pstate->compositor = state; pstate->compositor = state;
pstate->destroy.notify = tablet_pad_destroy_notify;
wl_signal_add(&device->events.destroy, &pstate->destroy);
pstate->button.notify = tablet_pad_button_notify; pstate->button.notify = tablet_pad_button_notify;
wl_signal_add(&device->tablet_pad->events.button, &pstate->button); wl_signal_add(&device->tablet_pad->events.button, &pstate->button);
wl_list_insert(&state->tablet_pads, &pstate->link); wl_list_insert(&state->tablet_pads, &pstate->link);
} }
static void input_add_notify(struct wl_listener *listener, void *data) { static void new_input_notify(struct wl_listener *listener, void *data) {
struct wlr_input_device *device = data; struct wlr_input_device *device = data;
struct compositor_state *state = wl_container_of(listener, state, input_add); struct compositor_state *state = wl_container_of(listener, state, new_input);
switch (device->type) { switch (device->type) {
case WLR_INPUT_DEVICE_KEYBOARD: case WLR_INPUT_DEVICE_KEYBOARD:
keyboard_add(device, state); keyboard_add(device, state);
@ -267,123 +346,6 @@ static void input_add_notify(struct wl_listener *listener, void *data) {
} }
} }
static void keyboard_remove(struct wlr_input_device *device, struct compositor_state *state) {
struct keyboard_state *kbstate = NULL, *_kbstate;
wl_list_for_each(_kbstate, &state->keyboards, link) {
if (_kbstate->device == device) {
kbstate = _kbstate;
break;
}
}
if (!kbstate) {
return;
}
wl_list_remove(&kbstate->link);
wl_list_remove(&kbstate->key.link);
free(kbstate);
}
static void pointer_remove(struct wlr_input_device *device, struct compositor_state *state) {
struct pointer_state *pstate = NULL, *_pstate;
wl_list_for_each(_pstate, &state->pointers, link) {
if (_pstate->device == device) {
pstate = _pstate;
break;
}
}
if (!pstate) {
return;
}
wl_list_remove(&pstate->link);
wl_list_remove(&pstate->motion.link);
wl_list_remove(&pstate->motion_absolute.link);
wl_list_remove(&pstate->button.link);
wl_list_remove(&pstate->axis.link);
free(pstate);
}
static void touch_remove(struct wlr_input_device *device, struct compositor_state *state) {
struct touch_state *tstate = NULL, *_tstate;
wl_list_for_each(_tstate, &state->touch, link) {
if (_tstate->device == device) {
tstate = _tstate;
break;
}
}
if (!tstate) {
return;
}
wl_list_remove(&tstate->link);
wl_list_remove(&tstate->down.link);
wl_list_remove(&tstate->motion.link);
wl_list_remove(&tstate->up.link);
wl_list_remove(&tstate->cancel.link);
free(tstate);
}
static void tablet_tool_remove(struct wlr_input_device *device, struct compositor_state *state) {
struct tablet_tool_state *tstate = NULL, *_tstate;
wl_list_for_each(_tstate, &state->tablet_tools, link) {
if (_tstate->device == device) {
tstate = _tstate;
break;
}
}
if (!tstate) {
return;
}
wl_list_remove(&tstate->link);
wl_list_remove(&tstate->axis.link);
wl_list_remove(&tstate->proximity.link);
//wl_list_remove(&tstate->tip.link);
wl_list_remove(&tstate->button.link);
free(tstate);
}
static void tablet_pad_remove(struct wlr_input_device *device, struct compositor_state *state) {
struct tablet_pad_state *pstate = NULL, *_pstate;
wl_list_for_each(_pstate, &state->tablet_pads, link) {
if (_pstate->device ==device) {
pstate = _pstate;
break;
}
}
if (!pstate) {
return;
}
wl_list_remove(&pstate->button.link);
free(pstate);
}
static void input_remove_notify(struct wl_listener *listener, void *data) {
struct wlr_input_device *device = data;
struct compositor_state *state = wl_container_of(listener, state, input_remove);
if (state->input_remove_cb) {
state->input_remove_cb(state, device);
}
switch (device->type) {
case WLR_INPUT_DEVICE_KEYBOARD:
keyboard_remove(device, state);
break;
case WLR_INPUT_DEVICE_POINTER:
pointer_remove(device, state);
break;
case WLR_INPUT_DEVICE_TOUCH:
touch_remove(device, state);
break;
case WLR_INPUT_DEVICE_TABLET_TOOL:
tablet_tool_remove(device, state);
break;
case WLR_INPUT_DEVICE_TABLET_PAD:
tablet_pad_remove(device, state);
break;
default:
break;
}
}
static void output_frame_notify(struct wl_listener *listener, void *data) { static void output_frame_notify(struct wl_listener *listener, void *data) {
struct output_state *output = wl_container_of(listener, output, frame); struct output_state *output = wl_container_of(listener, output, frame);
struct compositor_state *compositor = output->compositor; struct compositor_state *compositor = output->compositor;
@ -407,9 +369,21 @@ static void output_resolution_notify(struct wl_listener *listener, void *data) {
} }
} }
static void output_add_notify(struct wl_listener *listener, void *data) { static void output_destroy_notify(struct wl_listener *listener, void *data) {
struct output_state *ostate = wl_container_of(listener, ostate, destroy);
struct compositor_state *state = ostate->compositor;
if (state->output_remove_cb) {
state->output_remove_cb(ostate);
}
wl_list_remove(&ostate->link);
wl_list_remove(&ostate->frame.link);
wl_list_remove(&ostate->resolution.link);
free(ostate);
}
static void new_output_notify(struct wl_listener *listener, void *data) {
struct wlr_output *output = data; struct wlr_output *output = data;
struct compositor_state *state = wl_container_of(listener, state, output_add); struct compositor_state *state = wl_container_of(listener, state, new_output);
wlr_log(L_DEBUG, "Output '%s' added", output->name); wlr_log(L_DEBUG, "Output '%s' added", output->name);
wlr_log(L_DEBUG, "%s %s %"PRId32"mm x %"PRId32"mm", output->make, output->model, wlr_log(L_DEBUG, "%s %s %"PRId32"mm x %"PRId32"mm", output->make, output->model,
output->phys_width, output->phys_height); output->phys_width, output->phys_height);
@ -422,9 +396,11 @@ static void output_add_notify(struct wl_listener *listener, void *data) {
clock_gettime(CLOCK_MONOTONIC, &ostate->last_frame); clock_gettime(CLOCK_MONOTONIC, &ostate->last_frame);
ostate->output = output; ostate->output = output;
ostate->compositor = state; ostate->compositor = state;
ostate->destroy.notify = output_destroy_notify;
wl_signal_add(&output->events.destroy, &ostate->destroy);
ostate->frame.notify = output_frame_notify; ostate->frame.notify = output_frame_notify;
ostate->resolution.notify = output_resolution_notify;
wl_signal_add(&output->events.frame, &ostate->frame); wl_signal_add(&output->events.frame, &ostate->frame);
ostate->resolution.notify = output_resolution_notify;
wl_signal_add(&output->events.mode, &ostate->resolution); wl_signal_add(&output->events.mode, &ostate->resolution);
wl_list_insert(&state->outputs, &ostate->link); wl_list_insert(&state->outputs, &ostate->link);
if (state->output_add_cb) { if (state->output_add_cb) {
@ -432,28 +408,6 @@ static void output_add_notify(struct wl_listener *listener, void *data) {
} }
} }
static void output_remove_notify(struct wl_listener *listener, void *data) {
struct wlr_output *output = data;
struct compositor_state *state = wl_container_of(listener, state, output_remove);
struct output_state *ostate = NULL, *_ostate;
wl_list_for_each(_ostate, &state->outputs, link) {
if (_ostate->output == output) {
ostate = _ostate;
break;
}
}
if (!ostate) {
return; // We are unfamiliar with this output
}
if (state->output_remove_cb) {
state->output_remove_cb(ostate);
}
wl_list_remove(&ostate->link);
wl_list_remove(&ostate->frame.link);
wl_list_remove(&ostate->resolution.link);
free(ostate);
}
void compositor_init(struct compositor_state *state) { void compositor_init(struct compositor_state *state) {
state->display = wl_display_create(); state->display = wl_display_create();
state->event_loop = wl_display_get_event_loop(state->display); state->event_loop = wl_display_get_event_loop(state->display);
@ -463,23 +417,19 @@ void compositor_init(struct compositor_state *state) {
wl_list_init(&state->touch); wl_list_init(&state->touch);
wl_list_init(&state->tablet_tools); wl_list_init(&state->tablet_tools);
wl_list_init(&state->tablet_pads); wl_list_init(&state->tablet_pads);
state->input_add.notify = input_add_notify;
state->input_remove.notify = input_remove_notify;
wl_list_init(&state->outputs); wl_list_init(&state->outputs);
state->output_add.notify = output_add_notify;
state->output_remove.notify = output_remove_notify;
struct wlr_backend *wlr = wlr_backend_autocreate(state->display); struct wlr_backend *wlr = wlr_backend_autocreate(state->display);
if (!wlr) { if (!wlr) {
exit(1); exit(1);
} }
wl_signal_add(&wlr->events.input_add, &state->input_add);
wl_signal_add(&wlr->events.input_remove, &state->input_remove);
wl_signal_add(&wlr->events.output_add, &state->output_add);
wl_signal_add(&wlr->events.output_remove, &state->output_remove);
state->backend = wlr; state->backend = wlr;
wl_signal_add(&wlr->events.new_input, &state->new_input);
state->new_input.notify = new_input_notify;
wl_signal_add(&wlr->events.new_output, &state->new_output);
state->new_output.notify = new_output_notify;
clock_gettime(CLOCK_MONOTONIC, &state->last_frame); clock_gettime(CLOCK_MONOTONIC, &state->last_frame);
const char *socket = wl_display_add_socket_auto(state->display); const char *socket = wl_display_add_socket_auto(state->display);

View file

@ -15,6 +15,7 @@
struct output_state { struct output_state {
struct compositor_state *compositor; struct compositor_state *compositor;
struct wlr_output *output; struct wlr_output *output;
struct wl_listener destroy;
struct wl_listener frame; struct wl_listener frame;
struct wl_listener resolution; struct wl_listener resolution;
struct timespec last_frame; struct timespec last_frame;
@ -25,6 +26,7 @@ struct output_state {
struct keyboard_state { struct keyboard_state {
struct compositor_state *compositor; struct compositor_state *compositor;
struct wlr_input_device *device; struct wlr_input_device *device;
struct wl_listener destroy;
struct wl_listener key; struct wl_listener key;
struct wl_list link; struct wl_list link;
void *data; void *data;
@ -33,6 +35,7 @@ struct keyboard_state {
struct pointer_state { struct pointer_state {
struct compositor_state *compositor; struct compositor_state *compositor;
struct wlr_input_device *device; struct wlr_input_device *device;
struct wl_listener destroy;
struct wl_listener motion; struct wl_listener motion;
struct wl_listener motion_absolute; struct wl_listener motion_absolute;
struct wl_listener button; struct wl_listener button;
@ -44,6 +47,7 @@ struct pointer_state {
struct touch_state { struct touch_state {
struct compositor_state *compositor; struct compositor_state *compositor;
struct wlr_input_device *device; struct wlr_input_device *device;
struct wl_listener destroy;
struct wl_listener down; struct wl_listener down;
struct wl_listener up; struct wl_listener up;
struct wl_listener motion; struct wl_listener motion;
@ -55,6 +59,7 @@ struct touch_state {
struct tablet_tool_state { struct tablet_tool_state {
struct compositor_state *compositor; struct compositor_state *compositor;
struct wlr_input_device *device; struct wlr_input_device *device;
struct wl_listener destroy;
struct wl_listener axis; struct wl_listener axis;
struct wl_listener proximity; struct wl_listener proximity;
struct wl_listener tip; struct wl_listener tip;
@ -66,6 +71,7 @@ struct tablet_tool_state {
struct tablet_pad_state { struct tablet_pad_state {
struct compositor_state *compositor; struct compositor_state *compositor;
struct wlr_input_device *device; struct wlr_input_device *device;
struct wl_listener destroy;
struct wl_listener button; struct wl_listener button;
struct wl_list link; struct wl_list link;
void *data; void *data;
@ -122,12 +128,10 @@ struct compositor_state {
struct wl_list touch; struct wl_list touch;
struct wl_list tablet_tools; struct wl_list tablet_tools;
struct wl_list tablet_pads; struct wl_list tablet_pads;
struct wl_listener input_add; struct wl_listener new_input;
struct wl_listener input_remove;
struct timespec last_frame; struct timespec last_frame;
struct wl_listener output_add; struct wl_listener new_output;
struct wl_listener output_remove;
struct wl_list outputs; struct wl_list outputs;
void *data; void *data;

View file

@ -1,19 +1,17 @@
#ifndef BACKEND_DRM_DRM_H #ifndef BACKEND_DRM_DRM_H
#define BACKEND_DRM_DRM_H #define BACKEND_DRM_DRM_H
#include <EGL/egl.h>
#include <gbm.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <xf86drmMode.h>
#include <EGL/egl.h>
#include <gbm.h>
#include <wayland-util.h> #include <wayland-util.h>
#include <wlr/backend/session.h>
#include <wlr/backend/drm.h> #include <wlr/backend/drm.h>
#include <wlr/backend/session.h>
#include <wlr/render/egl.h> #include <wlr/render/egl.h>
#include <xf86drmMode.h>
#include "iface.h" #include "iface.h"
#include "properties.h" #include "properties.h"
#include "renderer.h" #include "renderer.h"

View file

@ -1,10 +1,9 @@
#ifndef BACKEND_DRM_IFACE_H #ifndef BACKEND_DRM_IFACE_H
#define BACKEND_DRM_IFACE_H #define BACKEND_DRM_IFACE_H
#include <gbm.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <gbm.h>
#include <xf86drm.h> #include <xf86drm.h>
#include <xf86drmMode.h> #include <xf86drmMode.h>

View file

@ -1,12 +1,10 @@
#ifndef BACKEND_DRM_RENDERER_H #ifndef BACKEND_DRM_RENDERER_H
#define BACKEND_DRM_RENDERER_H #define BACKEND_DRM_RENDERER_H
#include <stdbool.h>
#include <stdint.h>
#include <EGL/egl.h> #include <EGL/egl.h>
#include <gbm.h> #include <gbm.h>
#include <stdbool.h>
#include <stdint.h>
#include <wlr/render.h> #include <wlr/render.h>
struct wlr_drm_backend; struct wlr_drm_backend;

View file

@ -2,9 +2,9 @@
#define BACKEND_DRM_UTIL_H #define BACKEND_DRM_UTIL_H
#include <stdint.h> #include <stdint.h>
#include <wlr/types/wlr_output.h>
#include <xf86drm.h> #include <xf86drm.h>
#include <xf86drmMode.h> #include <xf86drmMode.h>
#include <wlr/types/wlr_output.h>
// Calculates a more accurate refresh rate (mHz) than what mode itself provides // Calculates a more accurate refresh rate (mHz) than what mode itself provides
int32_t calculate_refresh_rate(drmModeModeInfo *mode); int32_t calculate_refresh_rate(drmModeModeInfo *mode);

View file

@ -1,8 +1,8 @@
#ifndef BACKEND_HEADLESS_H #ifndef BACKEND_HEADLESS_H
#define BACKEND_HEADLESS_H #define BACKEND_HEADLESS_H
#include <wlr/backend/interface.h>
#include <wlr/backend/headless.h> #include <wlr/backend/headless.h>
#include <wlr/backend/interface.h>
struct wlr_headless_backend { struct wlr_headless_backend {
struct wlr_backend backend; struct wlr_backend backend;

View file

@ -1,10 +1,11 @@
#ifndef BACKEND_LIBINPUT_H #ifndef BACKEND_LIBINPUT_H
#define BACKEND_LIBINPUT_H #define BACKEND_LIBINPUT_H
#include <libinput.h> #include <libinput.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/backend/interface.h> #include <wlr/backend/interface.h>
#include <wlr/interfaces/wlr_input_device.h> #include <wlr/interfaces/wlr_input_device.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_list.h> #include <wlr/types/wlr_list.h>
struct wlr_libinput_backend { struct wlr_libinput_backend {

View file

@ -1,10 +1,10 @@
#ifndef BACKEND_MULTI_H #ifndef BACKEND_MULTI_H
#define BACKEND_MULTI_H #define BACKEND_MULTI_H
#include <wayland-util.h>
#include <wlr/backend/interface.h> #include <wlr/backend/interface.h>
#include <wlr/backend/multi.h> #include <wlr/backend/multi.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
#include <wayland-util.h>
struct wlr_multi_backend { struct wlr_multi_backend {
struct wlr_backend backend; struct wlr_backend backend;

View file

@ -3,13 +3,13 @@
#include <stdbool.h> #include <stdbool.h>
#include <wayland-client.h> #include <wayland-client.h>
#include <wayland-server.h>
#include <wayland-egl.h> #include <wayland-egl.h>
#include <wlr/render/egl.h> #include <wayland-server.h>
#include <wlr/render.h>
#include <wlr/backend/wayland.h>
#include <wlr/types/wlr_box.h>
#include <wayland-util.h> #include <wayland-util.h>
#include <wlr/backend/wayland.h>
#include <wlr/render.h>
#include <wlr/render/egl.h>
#include <wlr/types/wlr_box.h>
struct wlr_wl_backend { struct wlr_wl_backend {
struct wlr_backend backend; struct wlr_backend backend;

View file

@ -1,11 +1,11 @@
#ifndef WLR_X11_H #ifndef BACKEND_X11_H
#define WLR_X11_H #define BACKEND_X11_H
#include <stdbool.h> #include <stdbool.h>
#include <xcb/xcb.h>
#include <X11/Xlib-xcb.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/render/egl.h> #include <wlr/render/egl.h>
#include <X11/Xlib-xcb.h>
#include <xcb/xcb.h>
struct wlr_x11_backend; struct wlr_x11_backend;

View file

@ -1,13 +1,13 @@
#ifndef RENDER_GLES2_H #ifndef RENDER_GLES2_H
#define RENDER_GLES2_H #define RENDER_GLES2_H
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/render.h> #include <wlr/render.h>
#include <wlr/render/egl.h> #include <wlr/render/egl.h>

View file

@ -1,7 +1,8 @@
#ifndef _ROOTSTON_CONFIG_H #ifndef ROOTSTON_CONFIG_H
#define _ROOTSTON_CONFIG_H #define ROOTSTON_CONFIG_H
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_output_layout.h>
#define ROOTS_CONFIG_DEFAULT_SEAT_NAME "seat0" #define ROOTS_CONFIG_DEFAULT_SEAT_NAME "seat0"

View file

@ -1,5 +1,5 @@
#ifndef _ROOTSTON_CURSOR_H #ifndef ROOTSTON_CURSOR_H
#define _ROOTSTON_CURSOR_H #define ROOTSTON_CURSOR_H
#include "rootston/seat.h" #include "rootston/seat.h"

View file

@ -1,22 +1,23 @@
#ifndef _ROOTSTON_DESKTOP_H #ifndef ROOTSTON_DESKTOP_H
#define _ROOTSTON_DESKTOP_H #define ROOTSTON_DESKTOP_H
#include <time.h> #include <time.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/config.h> #include <wlr/config.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_wl_shell.h>
#include <wlr/types/wlr_xdg_shell_v6.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/types/wlr_gamma_control.h> #include <wlr/types/wlr_gamma_control.h>
#include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_list.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_primary_selection.h> #include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_screenshooter.h> #include <wlr/types/wlr_screenshooter.h>
#include <wlr/types/wlr_list.h> #include <wlr/types/wlr_wl_shell.h>
#include <wlr/types/wlr_idle.h> #include <wlr/types/wlr_xcursor_manager.h>
#include "rootston/view.h" #include <wlr/types/wlr_xdg_shell_v6.h>
#include "rootston/config.h" #include "rootston/config.h"
#include "rootston/output.h" #include "rootston/output.h"
#include "rootston/view.h"
struct roots_desktop { struct roots_desktop {
struct wl_list views; // roots_view::link struct wl_list views; // roots_view::link
@ -39,8 +40,7 @@ struct roots_desktop {
struct wlr_primary_selection_device_manager *primary_selection_device_manager; struct wlr_primary_selection_device_manager *primary_selection_device_manager;
struct wlr_idle *idle; struct wlr_idle *idle;
struct wl_listener output_add; struct wl_listener new_output;
struct wl_listener output_remove;
struct wl_listener layout_change; struct wl_listener layout_change;
struct wl_listener xdg_shell_v6_surface; struct wl_listener xdg_shell_v6_surface;
struct wl_listener wl_shell_surface; struct wl_listener wl_shell_surface;

View file

@ -1,20 +1,20 @@
#ifndef _ROOTSTON_INPUT_H #ifndef ROOTSTON_INPUT_H
#define _ROOTSTON_INPUT_H #define ROOTSTON_INPUT_H
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_cursor.h> #include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_seat.h> #include <wlr/types/wlr_seat.h>
#include "rootston/cursor.h"
#include "rootston/config.h" #include "rootston/config.h"
#include "rootston/view.h" #include "rootston/cursor.h"
#include "rootston/server.h" #include "rootston/server.h"
#include "rootston/view.h"
struct roots_input { struct roots_input {
struct roots_config *config; struct roots_config *config;
struct roots_server *server; struct roots_server *server;
struct wl_listener input_add; struct wl_listener new_input;
struct wl_listener input_remove;
struct wl_list seats; struct wl_list seats;
}; };

View file

@ -1,5 +1,5 @@
#ifndef _ROOTSTON_KEYBOARD_H #ifndef ROOTSTON_KEYBOARD_H
#define _ROOTSTON_KEYBOARD_H #define ROOTSTON_KEYBOARD_H
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#include "rootston/input.h" #include "rootston/input.h"
@ -13,6 +13,7 @@ struct roots_keyboard {
struct roots_keyboard_config *config; struct roots_keyboard_config *config;
struct wl_list link; struct wl_list link;
struct wl_listener device_destroy;
struct wl_listener keyboard_key; struct wl_listener keyboard_key;
struct wl_listener keyboard_modifiers; struct wl_listener keyboard_modifiers;

View file

@ -1,8 +1,8 @@
#ifndef _ROOTSTON_OUTPUT_H #ifndef ROOTSTON_OUTPUT_H
#define _ROOTSTON_OUTPUT_H #define ROOTSTON_OUTPUT_H
#include <time.h>
#include <pixman.h> #include <pixman.h>
#include <time.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/types/wlr_output_damage.h> #include <wlr/types/wlr_output_damage.h>
@ -18,11 +18,11 @@ struct roots_output {
struct timespec last_frame; struct timespec last_frame;
struct wlr_output_damage *damage; struct wlr_output_damage *damage;
struct wl_listener destroy;
struct wl_listener frame; struct wl_listener frame;
}; };
void output_add_notify(struct wl_listener *listener, void *data); void handle_new_output(struct wl_listener *listener, void *data);
void output_remove_notify(struct wl_listener *listener, void *data);
struct roots_view; struct roots_view;
struct roots_drag_icon; struct roots_drag_icon;

View file

@ -1,5 +1,6 @@
#ifndef _ROOTSTON_SEAT_H #ifndef ROOTSTON_SEAT_H
#define _ROOTSTON_SEAT_H #define ROOTSTON_SEAT_H
#include <wayland-server.h> #include <wayland-server.h>
#include "rootston/input.h" #include "rootston/input.h"
#include "rootston/keyboard.h" #include "rootston/keyboard.h"
@ -56,18 +57,21 @@ struct roots_drag_icon {
struct roots_pointer { struct roots_pointer {
struct roots_seat *seat; struct roots_seat *seat;
struct wlr_input_device *device; struct wlr_input_device *device;
struct wl_listener device_destroy;
struct wl_list link; struct wl_list link;
}; };
struct roots_touch { struct roots_touch {
struct roots_seat *seat; struct roots_seat *seat;
struct wlr_input_device *device; struct wlr_input_device *device;
struct wl_listener device_destroy;
struct wl_list link; struct wl_list link;
}; };
struct roots_tablet_tool { struct roots_tablet_tool {
struct roots_seat *seat; struct roots_seat *seat;
struct wlr_input_device *device; struct wlr_input_device *device;
struct wl_listener device_destroy;
struct wl_listener axis; struct wl_listener axis;
struct wl_listener proximity; struct wl_listener proximity;
struct wl_listener tip; struct wl_listener tip;

View file

@ -1,11 +1,12 @@
#ifndef _ROOTSTON_SERVER_H #ifndef _ROOTSTON_SERVER_H
#define _ROOTSTON_SERVER_H #define _ROOTSTON_SERVER_H
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/config.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
#include <wlr/types/wlr_data_device.h> #include <wlr/config.h>
#include <wlr/render.h> #include <wlr/render.h>
#include <wlr/types/wlr_data_device.h>
#ifdef WLR_HAS_XWAYLAND #ifdef WLR_HAS_XWAYLAND
#include <wlr/xwayland.h> #include <wlr/xwayland.h>
#endif #endif

View file

@ -1,5 +1,5 @@
#ifndef _ROOTSTON_VIEW_H #ifndef ROOTSTON_VIEW_H
#define _ROOTSTON_VIEW_H #define ROOTSTON_VIEW_H
#include <stdbool.h> #include <stdbool.h>
#include <wlr/config.h> #include <wlr/config.h>

View file

@ -1,5 +1,5 @@
#ifndef _ROOTSTON_XCURSOR_H #ifndef ROOTSTON_XCURSOR_H
#define _ROOTSTON_XCURSOR_H #define ROOTSTON_XCURSOR_H
#include <stdint.h> #include <stdint.h>

View file

@ -1,12 +1,9 @@
#ifndef _WLR_UTIL_OS_COMPATIBILITY_H #ifndef UTIL_OS_COMPATIBILITY_H
#define _WLR_UTIL_OS_COMPATIBILITY_H #define UTIL_OS_COMPATIBILITY_H
int os_fd_set_cloexec(int fd); int os_fd_set_cloexec(int fd);
int set_cloexec_or_close(int fd); int set_cloexec_or_close(int fd);
int create_tmpfile_cloexec(char *tmpname); int create_tmpfile_cloexec(char *tmpname);
int os_create_anonymous_file(off_t size); int os_create_anonymous_file(off_t size);
#endif #endif

8
include/util/signal.h Normal file
View file

@ -0,0 +1,8 @@
#ifndef UTIL_SIGNAL_H
#define UTIL_SIGNAL_H
#include <wayland-server.h>
void wlr_signal_emit_safe(struct wl_signal *signal, void *data);
#endif

View file

@ -12,10 +12,8 @@ struct wlr_backend {
struct { struct {
struct wl_signal destroy; struct wl_signal destroy;
struct wl_signal input_add; struct wl_signal new_input;
struct wl_signal input_remove; struct wl_signal new_output;
struct wl_signal output_add;
struct wl_signal output_remove;
} events; } events;
}; };

View file

@ -2,8 +2,8 @@
#define WLR_BACKEND_DRM_H #define WLR_BACKEND_DRM_H
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/backend/session.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/backend/session.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
struct wlr_backend *wlr_drm_backend_create(struct wl_display *display, struct wlr_backend *wlr_drm_backend_create(struct wl_display *display,

View file

@ -3,8 +3,8 @@
#include <libinput.h> #include <libinput.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/backend/session.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/backend/session.h>
#include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_input_device.h>
struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display, struct wlr_backend *wlr_libinput_backend_create(struct wl_display *display,

View file

@ -5,17 +5,12 @@
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
struct wlr_backend *wlr_multi_backend_create(struct wl_display *display); struct wlr_backend *wlr_multi_backend_create(struct wl_display *display);
void wlr_multi_backend_add(struct wlr_backend *multi, void wlr_multi_backend_add(struct wlr_backend *multi,
struct wlr_backend *backend); struct wlr_backend *backend);
void wlr_multi_backend_remove(struct wlr_backend *multi, void wlr_multi_backend_remove(struct wlr_backend *multi,
struct wlr_backend *backend); struct wlr_backend *backend);
bool wlr_backend_is_multi(struct wlr_backend *backend); bool wlr_backend_is_multi(struct wlr_backend *backend);
struct wlr_session *wlr_multi_get_session(struct wlr_backend *base); struct wlr_session *wlr_multi_get_session(struct wlr_backend *base);
bool wlr_multi_is_empty(struct wlr_backend *backend); bool wlr_multi_is_empty(struct wlr_backend *backend);
#endif #endif

View file

@ -1,10 +1,10 @@
#ifndef WLR_BACKEND_SESSION_H #ifndef WLR_BACKEND_SESSION_H
#define WLR_BACKEND_SESSION_H #define WLR_BACKEND_SESSION_H
#include <stdbool.h>
#include <wayland-server.h>
#include <libudev.h> #include <libudev.h>
#include <stdbool.h>
#include <sys/types.h> #include <sys/types.h>
#include <wayland-server.h>
struct session_impl; struct session_impl;

View file

@ -1,12 +1,12 @@
#ifndef WLR_BACKEND_WAYLAND_H #ifndef WLR_BACKEND_WAYLAND_H
#define WLR_BACKEND_WAYLAND_H #define WLR_BACKEND_WAYLAND_H
#include <stdbool.h>
#include <wayland-client.h> #include <wayland-client.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <stdbool.h>
/** /**
* Creates a new wlr_wl_backend. This backend will be created with no outputs; * Creates a new wlr_wl_backend. This backend will be created with no outputs;

View file

@ -1,8 +1,8 @@
#ifndef WLR_INTERFACES_WLR_KEYBOARD_H #ifndef WLR_INTERFACES_WLR_KEYBOARD_H
#define WLR_INTERFACES_WLR_KEYBOARD_H #define WLR_INTERFACES_WLR_KEYBOARD_H
#include <wlr/types/wlr_keyboard.h>
#include <stdint.h> #include <stdint.h>
#include <wlr/types/wlr_keyboard.h>
struct wlr_keyboard_impl { struct wlr_keyboard_impl {
void (*destroy)(struct wlr_keyboard *keyboard); void (*destroy)(struct wlr_keyboard *keyboard);

View file

@ -2,9 +2,9 @@
#define WLR_INTERFACES_WLR_OUTPUT_H #define WLR_INTERFACES_WLR_OUTPUT_H
#include <stdbool.h> #include <stdbool.h>
#include <wlr/backend.h>
#include <wlr/types/wlr_box.h> #include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/backend.h>
struct wlr_output_impl { struct wlr_output_impl {
void (*enable)(struct wlr_output *output, bool enable); void (*enable)(struct wlr_output *output, bool enable);

View file

@ -1,9 +1,9 @@
#ifndef WLR_RENDER_H #ifndef WLR_RENDER_H
#define WLR_RENDER_H #define WLR_RENDER_H
#include <stdint.h>
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include <stdint.h>
#include <wayland-server-protocol.h> #include <wayland-server-protocol.h>
#include <wlr/types/wlr_box.h> #include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>

View file

@ -1,10 +1,10 @@
#ifndef WLR_EGL_H #ifndef WLR_RENDER_EGL_H
#define WLR_EGL_H #define WLR_RENDER_EGL_H
#include <stdbool.h>
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include <pixman.h> #include <pixman.h>
#include <stdbool.h>
#include <wayland-server.h> #include <wayland-server.h>
struct wlr_egl { struct wlr_egl {

View file

@ -1,8 +1,8 @@
#ifndef WLR_RENDER_GLES2_H #ifndef WLR_RENDER_GLES2_H
#define WLR_RENDER_GLES2_H #define WLR_RENDER_GLES2_H
#include <wlr/render.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/render.h>
struct wlr_egl; struct wlr_egl;
struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_backend *backend); struct wlr_renderer *wlr_gles2_renderer_create(struct wlr_backend *backend);

View file

@ -1,10 +1,10 @@
#ifndef WLR_RENDER_INTERFACE_H #ifndef WLR_RENDER_INTERFACE_H
#define WLR_RENDER_INTERFACE_H #define WLR_RENDER_INTERFACE_H
#include <wayland-server-protocol.h>
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include <stdbool.h> #include <stdbool.h>
#include <wayland-server-protocol.h>
#include <wlr/render.h> #include <wlr/render.h>
#include <wlr/types/wlr_box.h> #include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>

View file

@ -2,10 +2,10 @@
#define WLR_TYPES_WLR_CURSOR_H #define WLR_TYPES_WLR_CURSOR_H
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_box.h> #include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output.h>
struct wlr_cursor_state; struct wlr_cursor_state;

View file

@ -1,9 +1,9 @@
#ifndef WLR_TYPES_WLR_KEYBOARD_H #ifndef WLR_TYPES_WLR_KEYBOARD_H
#define WLR_TYPES_WLR_KEYBOARD_H #define WLR_TYPES_WLR_KEYBOARD_H
#include <wayland-server.h>
#include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h>
#include <wayland-server.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>

View file

@ -1,8 +1,8 @@
#ifndef WLR_UTIL_LIST_H #ifndef WLR_TYPES_WLR_LIST_H
#define WLR_UTIL_LIST_H #define WLR_TYPES_WLR_LIST_H
#include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h>
struct wlr_list { struct wlr_list {
size_t capacity; size_t capacity;

View file

@ -1,11 +1,11 @@
#ifndef WLR_TYPES_WLR_OUTPUT_H #ifndef WLR_TYPES_WLR_OUTPUT_H
#define WLR_TYPES_WLR_OUTPUT_H #define WLR_TYPES_WLR_OUTPUT_H
#include <pixman.h>
#include <stdbool.h> #include <stdbool.h>
#include <time.h> #include <time.h>
#include <pixman.h>
#include <wayland-util.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wayland-util.h>
struct wlr_output_mode { struct wlr_output_mode {
uint32_t flags; // enum wl_output_mode uint32_t flags; // enum wl_output_mode

View file

@ -1,8 +1,8 @@
#ifndef WLR_TYPES_WLR_OUTPUT_DAMAGE_H #ifndef WLR_TYPES_WLR_OUTPUT_DAMAGE_H
#define WLR_TYPES_WLR_OUTPUT_DAMAGE_H #define WLR_TYPES_WLR_OUTPUT_DAMAGE_H
#include <time.h>
#include <pixman.h> #include <pixman.h>
#include <time.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
/** /**

View file

@ -1,10 +1,10 @@
#ifndef WLR_TYPES_WLR_OUTPUT_LAYOUT_H #ifndef WLR_TYPES_WLR_OUTPUT_LAYOUT_H
#define WLR_TYPES_WLR_OUTPUT_LAYOUT_H #define WLR_TYPES_WLR_OUTPUT_LAYOUT_H
#include <stdbool.h>
#include <wayland-util.h>
#include <wlr/types/wlr_box.h> #include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wayland-util.h>
#include <stdbool.h>
struct wlr_output_layout_state; struct wlr_output_layout_state;

View file

@ -1,9 +1,9 @@
#ifndef WLR_TYPES_WLR_POINTER_H #ifndef WLR_TYPES_WLR_POINTER_H
#define WLR_TYPES_WLR_POINTER_H #define WLR_TYPES_WLR_POINTER_H
#include <wlr/types/wlr_input_device.h>
#include <wayland-server.h>
#include <stdint.h> #include <stdint.h>
#include <wayland-server.h>
#include <wlr/types/wlr_input_device.h>
struct wlr_pointer_impl; struct wlr_pointer_impl;

View file

@ -1,8 +1,8 @@
#ifndef WLR_TYPES_WLR_PRIMARY_SELECTION_H #ifndef WLR_TYPES_WLR_PRIMARY_SELECTION_H
#define WLR_TYPES_WLR_PRIMARY_SELECTION_H #define WLR_TYPES_WLR_PRIMARY_SELECTION_H
#include <wlr/types/wlr_seat.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/types/wlr_seat.h>
struct wlr_primary_selection_device_manager { struct wlr_primary_selection_device_manager {
struct wl_global *global; struct wl_global *global;

View file

@ -1,5 +1,6 @@
#ifndef _WLR_SCREENSHOOTER_H #ifndef WLR_TYPES_WLR_SCREENSHOOTER_H
#define _WLR_SCREENSHOOTER_H #define WLR_TYPES_WLR_SCREENSHOOTER_H
#include <wayland-server.h> #include <wayland-server.h>
struct wlr_screenshooter { struct wlr_screenshooter {

View file

@ -1,10 +1,11 @@
#ifndef WLR_TYPES_WLR_SEAT_H #ifndef WLR_TYPES_WLR_SEAT_H
#define WLR_TYPES_WLR_SEAT_H #define WLR_TYPES_WLR_SEAT_H
#include <time.h> #include <time.h>
#include <wlr/types/wlr_surface.h> #include <wayland-server.h>
#include <wlr/types/wlr_input_device.h> #include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_keyboard.h> #include <wlr/types/wlr_keyboard.h>
#include <wayland-server.h> #include <wlr/types/wlr_surface.h>
/** /**
* Contains state for a single client's bound wl_seat resource and can be used * Contains state for a single client's bound wl_seat resource and can be used

View file

@ -1,9 +1,10 @@
#ifndef WLR_TYPES_WLR_SURFACE_H #ifndef WLR_TYPES_WLR_SURFACE_H
#define WLR_TYPES_WLR_SURFACE_H #define WLR_TYPES_WLR_SURFACE_H
#include <stdint.h>
#include <stdbool.h>
#include <time.h>
#include <pixman.h> #include <pixman.h>
#include <stdbool.h>
#include <stdint.h>
#include <time.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>

View file

@ -1,9 +1,9 @@
#ifndef WLR_TYPES_WLR_TABLET_PAD_H #ifndef WLR_TYPES_WLR_TABLET_PAD_H
#define WLR_TYPES_WLR_TABLET_PAD_H #define WLR_TYPES_WLR_TABLET_PAD_H
#include <wlr/types/wlr_input_device.h>
#include <wayland-server.h>
#include <stdint.h> #include <stdint.h>
#include <wayland-server.h>
#include <wlr/types/wlr_input_device.h>
/* /*
* NOTE: the wlr tablet pad implementation does not currently support tablets * NOTE: the wlr tablet pad implementation does not currently support tablets

View file

@ -1,9 +1,9 @@
#ifndef WLR_TYPES_TABLET_TOOL_H #ifndef WLR_TYPES_TABLET_TOOL_H
#define WLR_TYPES_TABLET_TOOL_H #define WLR_TYPES_TABLET_TOOL_H
#include <wlr/types/wlr_input_device.h>
#include <wayland-server.h>
#include <stdint.h> #include <stdint.h>
#include <wayland-server.h>
#include <wlr/types/wlr_input_device.h>
struct wlr_tablet_tool_impl; struct wlr_tablet_tool_impl;

View file

@ -1,8 +1,8 @@
#ifndef WLR_TYPES_WLR_TOUCH_H #ifndef WLR_TYPES_WLR_TOUCH_H
#define WLR_TYPES_WLR_TOUCH_H #define WLR_TYPES_WLR_TOUCH_H
#include <wayland-server.h>
#include <stdint.h> #include <stdint.h>
#include <wayland-server.h>
struct wlr_touch_impl; struct wlr_touch_impl;

View file

@ -1,9 +1,9 @@
#ifndef WLR_TYPES_WLR_XDG_SHELL_V6_H #ifndef WLR_TYPES_WLR_XDG_SHELL_V6_H
#define WLR_TYPES_WLR_XDG_SHELL_V6_H #define WLR_TYPES_WLR_XDG_SHELL_V6_H
#include <wayland-server.h>
#include <wlr/types/wlr_box.h> #include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_seat.h> #include <wlr/types/wlr_seat.h>
#include <wayland-server.h>
struct wlr_xdg_shell_v6 { struct wlr_xdg_shell_v6 {
struct wl_global *wl_global; struct wl_global *wl_global;

View file

@ -1,8 +1,8 @@
#ifndef WLR_XWAYLAND_H #ifndef WLR_XWAYLAND_H
#define WLR_XWAYLAND_H #define WLR_XWAYLAND_H
#include <time.h>
#include <stdbool.h> #include <stdbool.h>
#include <time.h>
#include <wlr/config.h> #include <wlr/config.h>
#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_seat.h> #include <wlr/types/wlr_seat.h>

View file

@ -1,9 +1,9 @@
#ifndef XWAYLAND_INTERNALS_H #ifndef WLR_XWM_H
#define XWAYLAND_INTERNALS_H #define WLR_XWM_H
#include <xcb/render.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/xwayland.h> #include <wlr/xwayland.h>
#include <xcb/render.h>
enum atom_name { enum atom_name {
WL_SURFACE_ID, WL_SURFACE_ID,

View file

@ -157,16 +157,16 @@ wlroots = declare_dependency(
summary = [ summary = [
'', '',
'----------------', '----------------',
'wlroots @0@'.format(meson.project_version()), 'wlroots @0@'.format(meson.project_version()),
'', '',
' libcap: @0@'.format(conf_data.get('WLR_HAS_LIBCAP', false)), ' libcap: @0@'.format(conf_data.get('WLR_HAS_LIBCAP', false)),
' systemd: @0@'.format(conf_data.get('WLR_HAS_SYSTEMD', false)), ' systemd: @0@'.format(conf_data.get('WLR_HAS_SYSTEMD', false)),
' elogind: @0@'.format(conf_data.get('WLR_HAS_ELOGIND', false)), ' elogind: @0@'.format(conf_data.get('WLR_HAS_ELOGIND', false)),
' xwayland: @0@'.format(conf_data.get('WLR_HAS_XWAYLAND', false)), ' xwayland: @0@'.format(conf_data.get('WLR_HAS_XWAYLAND', false)),
'----------------', '----------------',
'' ''
] ]
message('\n'.join(summary)) message('\n'.join(summary))
@ -195,18 +195,18 @@ if git.found()
etags = find_program('etags', required: false) etags = find_program('etags', required: false)
if etags.found() and all_files.length() > 0 if etags.found() and all_files.length() > 0
custom_target('etags', custom_target('etags',
build_by_default: true, build_by_default: true,
input: all_files, input: all_files,
output: 'TAGS', output: 'TAGS',
command: [etags.path(), '-o', 'TAGS'] + all_files) command: [etags.path(), '-o', 'TAGS'] + all_files)
endif endif
ctags = find_program('ctags', required: false) ctags = find_program('ctags', required: false)
if ctags.found() and all_files.length() > 0 if ctags.found() and all_files.length() > 0
custom_target('ctags', custom_target('ctags',
build_by_default: true, build_by_default: true,
input: all_files, input: all_files,
output: 'tags', output: 'tags',
command: [ctags.path(), '-o', 'tags'] + all_files) command: [ctags.path(), '-o', 'tags'] + all_files)
endif endif
endif endif

View file

@ -24,18 +24,18 @@ protocols = [
[wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'], [wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'],
'gamma-control.xml', 'gamma-control.xml',
'gtk-primary-selection.xml', 'gtk-primary-selection.xml',
'idle.xml',
'screenshooter.xml', 'screenshooter.xml',
'server-decoration.xml', 'server-decoration.xml',
'idle.xml',
] ]
client_protocols = [ client_protocols = [
[wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'], [wl_protocol_dir, 'unstable/xdg-shell/xdg-shell-unstable-v6.xml'],
'gamma-control.xml', 'gamma-control.xml',
'gtk-primary-selection.xml', 'gtk-primary-selection.xml',
'idle.xml',
'screenshooter.xml', 'screenshooter.xml',
'server-decoration.xml', 'server-decoration.xml',
'idle.xml',
] ]
wl_protos_src = [] wl_protos_src = []

View file

@ -1,10 +1,10 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <EGL/egl.h> #include <EGL/egl.h>
#include <EGL/eglext.h> #include <EGL/eglext.h>
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <wlr/util/log.h> #include <stdlib.h>
#include <wlr/render/egl.h> #include <wlr/render/egl.h>
#include <wlr/util/log.h>
#include "glapi.h" #include "glapi.h"
// Extension documentation // Extension documentation

View file

@ -1,10 +1,10 @@
#include <stdint.h>
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <GLES2/gl2ext.h> #include <GLES2/gl2ext.h>
#include <wayland-util.h> #include <stdint.h>
#include <stdlib.h>
#include <wayland-server-protocol.h> #include <wayland-server-protocol.h>
#include <wayland-util.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/render.h> #include <wlr/render.h>
#include <wlr/render/egl.h> #include <wlr/render/egl.h>

View file

@ -1,5 +1,5 @@
#include "render/gles2.h"
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include "render/gles2.h"
// Colored quads // Colored quads
const GLchar quad_vertex_src[] = const GLchar quad_vertex_src[] =

View file

@ -1,16 +1,17 @@
#include <stdint.h>
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <GLES2/gl2ext.h> #include <GLES2/gl2ext.h>
#include <wayland-util.h> #include <stdint.h>
#include <stdlib.h>
#include <wayland-server-protocol.h> #include <wayland-server-protocol.h>
#include <wayland-util.h>
#include <wlr/render.h> #include <wlr/render.h>
#include <wlr/render/egl.h> #include <wlr/render/egl.h>
#include <wlr/render/interface.h> #include <wlr/render/interface.h>
#include <wlr/render/matrix.h> #include <wlr/render/matrix.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "render/gles2.h" #include "render/gles2.h"
#include "util/signal.h"
static struct pixel_format external_pixel_format = { static struct pixel_format external_pixel_format = {
.wl_format = 0, .wl_format = 0,
@ -271,7 +272,7 @@ static void gles2_texture_bind(struct wlr_texture *_texture) {
static void gles2_texture_destroy(struct wlr_texture *_texture) { static void gles2_texture_destroy(struct wlr_texture *_texture) {
struct wlr_gles2_texture *texture = (struct wlr_gles2_texture *)_texture; struct wlr_gles2_texture *texture = (struct wlr_gles2_texture *)_texture;
wl_signal_emit(&texture->wlr_texture.destroy_signal, &texture->wlr_texture); wlr_signal_emit_safe(&texture->wlr_texture.destroy_signal, &texture->wlr_texture);
if (texture->tex_id) { if (texture->tex_id) {
GL_CALL(glDeleteTextures(1, &texture->tex_id)); GL_CALL(glDeleteTextures(1, &texture->tex_id));
} }

View file

@ -1,6 +1,6 @@
#include <stdlib.h>
#include <stdbool.h>
#include <GLES2/gl2.h> #include <GLES2/gl2.h>
#include <stdbool.h>
#include <stdlib.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "render/gles2.h" #include "render/gles2.h"

View file

@ -1,9 +1,9 @@
#include <string.h>
#include <math.h> #include <math.h>
#include <string.h>
#include <wayland-server-protocol.h> #include <wayland-server-protocol.h>
#include <wlr/render/matrix.h>
#include <wlr/types/wlr_box.h> #include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/render/matrix.h>
/* Obtains the index for the given row/column */ /* Obtains the index for the given row/column */
static inline int mind(int row, int col) { static inline int mind(int row, int col) {

View file

@ -10,12 +10,12 @@ lib_wlr_render = static_library(
'wlr_render', 'wlr_render',
files( files(
'egl.c', 'egl.c',
'matrix.c',
'gles2/pixel_format.c', 'gles2/pixel_format.c',
'gles2/renderer.c', 'gles2/renderer.c',
'gles2/shaders.c', 'gles2/shaders.c',
'gles2/texture.c', 'gles2/texture.c',
'gles2/util.c', 'gles2/util.c',
'matrix.c',
'wlr_renderer.c', 'wlr_renderer.c',
'wlr_texture.c', 'wlr_texture.c',
), ),

View file

@ -1,5 +1,5 @@
#include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h>
#include <wlr/render/interface.h> #include <wlr/render/interface.h>
void wlr_renderer_init(struct wlr_renderer *renderer, void wlr_renderer_init(struct wlr_renderer *renderer,

View file

@ -1,5 +1,5 @@
#include <stdlib.h>
#include <stdbool.h> #include <stdbool.h>
#include <stdlib.h>
#include <wlr/render/interface.h> #include <wlr/render/interface.h>
void wlr_texture_init(struct wlr_texture *texture, void wlr_texture_init(struct wlr_texture *texture,

View file

@ -2,20 +2,20 @@
#define _POSIX_C_SOURCE 200809L #define _POSIX_C_SOURCE 200809L
#endif #endif
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <limits.h>
#include <getopt.h> #include <getopt.h>
#include <limits.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include <strings.h> #include <strings.h>
#include <unistd.h>
#include <sys/param.h> #include <sys/param.h>
#include <unistd.h>
#include <wlr/config.h> #include <wlr/config.h>
#include <wlr/util/log.h>
#include <wlr/types/wlr_box.h> #include <wlr/types/wlr_box.h>
#include <wlr/util/log.h>
#include "rootston/config.h" #include "rootston/config.h"
#include "rootston/ini.h"
#include "rootston/input.h" #include "rootston/input.h"
#include "rootston/keyboard.h" #include "rootston/keyboard.h"
#include "rootston/ini.h"
static void usage(const char *name, int ret) { static void usage(const char *name, int ret) {
fprintf(stderr, fprintf(stderr,

View file

@ -1,16 +1,16 @@
#define _XOPEN_SOURCE 700 #define _XOPEN_SOURCE 700
#include <stdlib.h>
#include <math.h> #include <math.h>
#include <stdlib.h>
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/util/edges.h>
#include <wlr/util/log.h>
#ifdef __linux__ #ifdef __linux__
#include <linux/input-event-codes.h> #include <linux/input-event-codes.h>
#elif __FreeBSD__ #elif __FreeBSD__
#include <dev/evdev/input-event-codes.h> #include <dev/evdev/input-event-codes.h>
#endif #endif
#include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/util/log.h>
#include <wlr/util/edges.h>
#include "rootston/xcursor.h"
#include "rootston/cursor.h" #include "rootston/cursor.h"
#include "rootston/xcursor.h"
struct roots_cursor *roots_cursor_create(struct roots_seat *seat) { struct roots_cursor *roots_cursor_create(struct roots_seat *seat) {
struct roots_cursor *cursor = calloc(1, sizeof(struct roots_cursor)); struct roots_cursor *cursor = calloc(1, sizeof(struct roots_cursor));

View file

@ -1,25 +1,25 @@
#define _POSIX_C_SOURCE 199309L #define _POSIX_C_SOURCE 199309L
#include <assert.h> #include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <math.h> #include <math.h>
#include <stdlib.h>
#include <time.h>
#include <wlr/config.h> #include <wlr/config.h>
#include <wlr/types/wlr_box.h> #include <wlr/types/wlr_box.h>
#include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_compositor.h>
#include <wlr/types/wlr_cursor.h> #include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_gamma_control.h> #include <wlr/types/wlr_gamma_control.h>
#include <wlr/types/wlr_idle.h> #include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_primary_selection.h> #include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_server_decoration.h> #include <wlr/types/wlr_server_decoration.h>
#include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_wl_shell.h> #include <wlr/types/wlr_wl_shell.h>
#include <wlr/types/wlr_xcursor_manager.h> #include <wlr/types/wlr_xcursor_manager.h>
#include <wlr/types/wlr_xdg_shell_v6.h> #include <wlr/types/wlr_xdg_shell_v6.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "rootston/server.h"
#include "rootston/seat.h" #include "rootston/seat.h"
#include "rootston/xcursor.h" #include "rootston/server.h"
#include "rootston/view.h" #include "rootston/view.h"
#include "rootston/xcursor.h"
void view_get_box(const struct roots_view *view, struct wlr_box *box) { void view_get_box(const struct roots_view *view, struct wlr_box *box) {
box->x = view->x; box->x = view->x;
@ -621,11 +621,8 @@ struct roots_desktop *desktop_create(struct roots_server *server,
wl_list_init(&desktop->views); wl_list_init(&desktop->views);
wl_list_init(&desktop->outputs); wl_list_init(&desktop->outputs);
desktop->output_add.notify = output_add_notify; desktop->new_output.notify = handle_new_output;
wl_signal_add(&server->backend->events.output_add, &desktop->output_add); wl_signal_add(&server->backend->events.new_output, &desktop->new_output);
desktop->output_remove.notify = output_remove_notify;
wl_signal_add(&server->backend->events.output_remove,
&desktop->output_remove);
desktop->server = server; desktop->server = server;
desktop->config = config; desktop->config = config;

View file

@ -1,16 +1,16 @@
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/backend/libinput.h>
#include <wlr/types/wlr_cursor.h> #include <wlr/types/wlr_cursor.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <wlr/xcursor.h> #include <wlr/xcursor.h>
#include <wlr/xwayland.h> #include <wlr/xwayland.h>
#include <wlr/backend/libinput.h>
#include "rootston/server.h"
#include "rootston/config.h" #include "rootston/config.h"
#include "rootston/input.h" #include "rootston/input.h"
#include "rootston/keyboard.h" #include "rootston/keyboard.h"
#include "rootston/seat.h" #include "rootston/seat.h"
#include "rootston/server.h"
static const char *device_type(enum wlr_input_device_type type) { static const char *device_type(enum wlr_input_device_type type) {
switch (type) { switch (type) {
@ -40,9 +40,9 @@ struct roots_seat *input_get_seat(struct roots_input *input, char *name) {
return seat; return seat;
} }
static void input_add_notify(struct wl_listener *listener, void *data) { static void handle_new_input(struct wl_listener *listener, void *data) {
struct wlr_input_device *device = data; struct wlr_input_device *device = data;
struct roots_input *input = wl_container_of(listener, input, input_add); struct roots_input *input = wl_container_of(listener, input, new_input);
char *seat_name = ROOTS_CONFIG_DEFAULT_SEAT_NAME; char *seat_name = ROOTS_CONFIG_DEFAULT_SEAT_NAME;
struct roots_device_config *dc = struct roots_device_config *dc =
@ -74,16 +74,6 @@ static void input_add_notify(struct wl_listener *listener, void *data) {
} }
} }
static void input_remove_notify(struct wl_listener *listener, void *data) {
struct wlr_input_device *device = data;
struct roots_input *input = wl_container_of(listener, input, input_remove);
struct roots_seat *seat;
wl_list_for_each(seat, &input->seats, link) {
roots_seat_remove_device(seat, device);
}
}
struct roots_input *input_create(struct roots_server *server, struct roots_input *input_create(struct roots_server *server,
struct roots_config *config) { struct roots_config *config) {
wlr_log(L_DEBUG, "Initializing roots input"); wlr_log(L_DEBUG, "Initializing roots input");
@ -99,10 +89,8 @@ struct roots_input *input_create(struct roots_server *server,
wl_list_init(&input->seats); wl_list_init(&input->seats);
input->input_add.notify = input_add_notify; input->new_input.notify = handle_new_input;
wl_signal_add(&server->backend->events.input_add, &input->input_add); wl_signal_add(&server->backend->events.new_input, &input->new_input);
input->input_remove.notify = input_remove_notify;
wl_signal_add(&server->backend->events.input_remove, &input->input_remove);
return input; return input;
} }

View file

@ -1,18 +1,18 @@
#include <assert.h> #include <assert.h>
#include <stdbool.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <stdbool.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_pointer.h>
#include <wlr/backend/multi.h> #include <wlr/backend/multi.h>
#include <wlr/backend/session.h> #include <wlr/backend/session.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_pointer.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include <xkbcommon/xkbcommon.h> #include <xkbcommon/xkbcommon.h>
#include "rootston/input.h" #include "rootston/input.h"
#include "rootston/seat.h"
#include "rootston/keyboard.h" #include "rootston/keyboard.h"
#include "rootston/seat.h"
static ssize_t pressed_keysyms_index(xkb_keysym_t *pressed_keysyms, static ssize_t pressed_keysyms_index(xkb_keysym_t *pressed_keysyms,
xkb_keysym_t keysym) { xkb_keysym_t keysym) {

View file

@ -3,10 +3,10 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <wayland-server.h> #include <wayland-server.h>
#include <wlr/config.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/backend/headless.h> #include <wlr/backend/headless.h>
#include <wlr/backend/multi.h> #include <wlr/backend/multi.h>
#include <wlr/config.h>
#include <wlr/render.h> #include <wlr/render.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "rootston/config.h" #include "rootston/config.h"

Some files were not shown because too many files have changed in this diff Show more