diff options
32 files changed, 332 insertions, 212 deletions
@@ -11,7 +11,7 @@ packages: - pixman - clang sources: - - https://git.sr.ht/~sircmpwn/wlroots + - https://github.com/swaywm/wlroots tasks: - setup: | mkdir wlroots/build-{gcc,clang} @@ -1,8 +1,3 @@ -CMakeCache.txt -CMakeFiles -Makefile -cmake_install.cmake -install_manifest.txt .clang_complete *.o *.a @@ -11,3 +6,4 @@ test/ build/ wayland-*-protocol.* wlr-example.ini +rootston.ini diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 0028de93..00000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -sudo: required - -language: c - -compiler: - - gcc - - clang - -# Settings to try -env: - matrix: - - OPTIONS="-Denable_libcap=true -Denable_systemd=true -Denable_elogind=false -Denable_xwayland=true" - - OPTIONS="-Denable_libcap=false -Denable_systemd=false -Denable_elogind=false -Denable_xwayland=false" - -arch: - packages: - - meson - - ninja - - wayland - - wayland-protocols - - mesa - - libinput - - pixman - - libxkbcommon - - xcb-util-image - - libcap - script: - - "meson build $OPTIONS" - - "ninja -C build" - -script: - - "curl -s https://raw.githubusercontent.com/mikkeloscar/arch-travis/master/arch-travis.sh | bash" @@ -1,4 +1,4 @@ -# wlroots [![](https://api.travis-ci.org/swaywm/wlroots.svg)](https://travis-ci.org/swaywm/wlroots) +# wlroots Pluggable, composable modules for building a [Wayland](http://wayland.freedesktop.org/) compositor. @@ -46,4 +46,4 @@ After building, run rootston from a terminal or VT with: Now you can run windows in the compositor from the command line or by configuring bindings in your [`rootston.ini`](https://github.com/swaywm/wlroots/blob/master/rootston/rootston.ini.example) -file. +file. diff --git a/backend/drm/backend.c b/backend/drm/backend.c index fec14da9..75b44210 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -81,7 +81,7 @@ static void session_signal(struct wl_listener *listener, void *data) { struct wlr_drm_connector *conn; wl_list_for_each(conn, &drm->outputs, link){ - if (conn->output.current_mode) { + if (conn->output.enabled) { wlr_output_set_mode(&conn->output, conn->output.current_mode); } else { wlr_drm_connector_enable(&conn->output, false); diff --git a/backend/drm/drm.c b/backend/drm/drm.c index d6388597..0d1d527d 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -296,8 +296,6 @@ void wlr_drm_connector_enable(struct wlr_output *output, bool enable) { if (enable) { wlr_drm_connector_start_renderer(conn); - } else { - output->current_mode = NULL; } wlr_output_update_enabled(&conn->output, enable); @@ -546,10 +544,10 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output, if (!crtc) { return false; } - struct wlr_drm_plane *plane = crtc->cursor; - // We don't have a real cursor plane, so we make a fake one + struct wlr_drm_plane *plane = crtc->cursor; if (!plane) { + // We don't have a real cursor plane, so we make a fake one plane = calloc(1, sizeof(*plane)); if (!plane) { wlr_log_errno(L_ERROR, "Allocation failed"); @@ -558,16 +556,6 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output, crtc->cursor = plane; } - if (!buf && update_pixels) { - // Hide the cursor - plane->cursor_enabled = false; - if (!drm->session->active) { - return true; - } - return drm->iface->crtc_set_cursor(drm, crtc, NULL); - } - plane->cursor_enabled = true; - if (!plane->surf.gbm) { int ret; uint64_t w, h; @@ -609,62 +597,77 @@ static bool wlr_drm_connector_set_cursor(struct wlr_output *output, } } - struct wlr_box hotspot = { - .x = hotspot_x, - .y = hotspot_y, - }; + struct wlr_box hotspot = { .x = hotspot_x, .y = hotspot_y }; enum wl_output_transform transform = wlr_output_transform_invert(output->transform); wlr_box_transform(&hotspot, transform, plane->surf.width, plane->surf.height, &hotspot); - plane->cursor_hotspot_x = hotspot.x; - plane->cursor_hotspot_y = hotspot.y; + + if (plane->cursor_hotspot_x != hotspot.x || + plane->cursor_hotspot_y != hotspot.y) { + // Update cursor hotspot + conn->cursor_x -= hotspot.x - plane->cursor_hotspot_x; + conn->cursor_y -= hotspot.y - plane->cursor_hotspot_y; + plane->cursor_hotspot_x = hotspot.x; + plane->cursor_hotspot_y = hotspot.y; + + if (!drm->iface->crtc_move_cursor(drm, conn->crtc, conn->cursor_x, + conn->cursor_y)) { + return false; + } + + wlr_output_update_needs_swap(output); + } if (!update_pixels) { - // Only update the cursor hotspot + // Don't update cursor image return true; } - struct gbm_bo *bo = plane->cursor_bo; - uint32_t bo_width = gbm_bo_get_width(bo); - uint32_t bo_height = gbm_bo_get_height(bo); - uint32_t bo_stride; - void *bo_data; + plane->cursor_enabled = buf != NULL; - if (!gbm_bo_map(bo, 0, 0, bo_width, bo_height, - GBM_BO_TRANSFER_WRITE, &bo_stride, &bo_data)) { - wlr_log_errno(L_ERROR, "Unable to map buffer"); - return false; - } + if (buf != NULL) { + uint32_t bo_width = gbm_bo_get_width(plane->cursor_bo); + uint32_t bo_height = gbm_bo_get_height(plane->cursor_bo); - wlr_drm_surface_make_current(&plane->surf, NULL); + uint32_t bo_stride; + void *bo_data; + if (!gbm_bo_map(plane->cursor_bo, 0, 0, bo_width, bo_height, + GBM_BO_TRANSFER_WRITE, &bo_stride, &bo_data)) { + wlr_log_errno(L_ERROR, "Unable to map buffer"); + return false; + } + + wlr_drm_surface_make_current(&plane->surf, NULL); - wlr_texture_upload_pixels(plane->wlr_tex, WL_SHM_FORMAT_ARGB8888, - stride, width, height, buf); + wlr_texture_upload_pixels(plane->wlr_tex, WL_SHM_FORMAT_ARGB8888, + stride, width, height, buf); - glViewport(0, 0, plane->surf.width, plane->surf.height); - glClearColor(0.0, 0.0, 0.0, 0.0); - glClear(GL_COLOR_BUFFER_BIT); + glViewport(0, 0, plane->surf.width, plane->surf.height); + glClearColor(0.0, 0.0, 0.0, 0.0); + glClear(GL_COLOR_BUFFER_BIT); - float matrix[16]; - wlr_texture_get_matrix(plane->wlr_tex, &matrix, &plane->matrix, 0, 0); - wlr_render_with_matrix(plane->surf.renderer->wlr_rend, plane->wlr_tex, - &matrix, 1.0f); + float matrix[16]; + wlr_texture_get_matrix(plane->wlr_tex, &matrix, &plane->matrix, 0, 0); + wlr_render_with_matrix(plane->surf.renderer->wlr_rend, plane->wlr_tex, + &matrix, 1.0f); - glFinish(); - glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, bo_stride); - glReadPixels(0, 0, plane->surf.width, plane->surf.height, GL_BGRA_EXT, - GL_UNSIGNED_BYTE, bo_data); - glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, 0); + glFinish(); + glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, bo_stride); + glReadPixels(0, 0, plane->surf.width, plane->surf.height, GL_BGRA_EXT, + GL_UNSIGNED_BYTE, bo_data); + glPixelStorei(GL_UNPACK_ROW_LENGTH_EXT, 0); - wlr_drm_surface_swap_buffers(&plane->surf, NULL); + wlr_drm_surface_swap_buffers(&plane->surf, NULL); - gbm_bo_unmap(bo, bo_data); + gbm_bo_unmap(plane->cursor_bo, bo_data); + } if (!drm->session->active) { - return true; + return true; // will be committed when session is resumed } + struct gbm_bo *bo = plane->cursor_enabled ? plane->cursor_bo : NULL; bool ok = drm->iface->crtc_set_cursor(drm, crtc, bo); if (ok) { wlr_output_update_needs_swap(output); @@ -699,7 +702,7 @@ static bool wlr_drm_connector_move_cursor(struct wlr_output *output, conn->cursor_y = box.y; if (!drm->session->active) { - return true; + return true; // will be committed when session is resumed } bool ok = drm->iface->crtc_move_cursor(drm, conn->crtc, box.x, box.y); diff --git a/backend/headless/input_device.c b/backend/headless/input_device.c index ea335aff..daa22436 100644 --- a/backend/headless/input_device.c +++ b/backend/headless/input_device.c @@ -15,7 +15,7 @@ static void input_device_destroy(struct wlr_input_device *wlr_dev) { free(device); } -static struct wlr_input_device_impl input_device_impl = { +static const struct wlr_input_device_impl input_device_impl = { .destroy = input_device_destroy, }; diff --git a/backend/libinput/events.c b/backend/libinput/events.c index 603eed07..d92de830 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -31,7 +31,7 @@ static void wlr_libinput_device_destroy(struct wlr_input_device *_dev) { free(dev); } -static struct wlr_input_device_impl input_device_impl = { +static const struct wlr_input_device_impl input_device_impl = { .destroy = wlr_libinput_device_destroy }; diff --git a/backend/libinput/tablet_pad.c b/backend/libinput/tablet_pad.c index 70e4c677..f71e1efa 100644 --- a/backend/libinput/tablet_pad.c +++ b/backend/libinput/tablet_pad.c @@ -34,6 +34,7 @@ void handle_tablet_pad_button(struct libinput_event *event, wlr_event.time_msec = usec_to_msec(libinput_event_tablet_pad_get_time_usec(pevent)); wlr_event.button = libinput_event_tablet_pad_get_button_number(pevent); + wlr_event.mode = libinput_event_tablet_pad_get_mode(pevent); switch (libinput_event_tablet_pad_get_button_state(pevent)) { case LIBINPUT_BUTTON_STATE_PRESSED: wlr_event.state = WLR_BUTTON_PRESSED; @@ -60,6 +61,7 @@ void handle_tablet_pad_ring(struct libinput_event *event, usec_to_msec(libinput_event_tablet_pad_get_time_usec(pevent)); wlr_event.ring = libinput_event_tablet_pad_get_ring_number(pevent); wlr_event.position = libinput_event_tablet_pad_get_ring_position(pevent); + wlr_event.mode = libinput_event_tablet_pad_get_mode(pevent); switch (libinput_event_tablet_pad_get_ring_source(pevent)) { case LIBINPUT_TABLET_PAD_RING_SOURCE_UNKNOWN: wlr_event.source = WLR_TABLET_PAD_RING_SOURCE_UNKNOWN; @@ -86,6 +88,7 @@ void handle_tablet_pad_strip(struct libinput_event *event, usec_to_msec(libinput_event_tablet_pad_get_time_usec(pevent)); wlr_event.strip = libinput_event_tablet_pad_get_strip_number(pevent); wlr_event.position = libinput_event_tablet_pad_get_strip_position(pevent); + wlr_event.mode = libinput_event_tablet_pad_get_mode(pevent); switch (libinput_event_tablet_pad_get_strip_source(pevent)) { case LIBINPUT_TABLET_PAD_STRIP_SOURCE_UNKNOWN: wlr_event.source = WLR_TABLET_PAD_STRIP_SOURCE_UNKNOWN; diff --git a/backend/libinput/tablet_tool.c b/backend/libinput/tablet_tool.c index 4e60367f..27cf7c81 100644 --- a/backend/libinput/tablet_tool.c +++ b/backend/libinput/tablet_tool.c @@ -71,8 +71,6 @@ void handle_tablet_tool_axis(struct libinput_event *event, wlr_event.updated_axes |= WLR_TABLET_TOOL_AXIS_WHEEL; wlr_event.wheel_delta = libinput_event_tablet_tool_get_wheel_delta(tevent); } - wlr_log(L_DEBUG, "Tablet tool axis event %d @ %f,%f", - wlr_event.updated_axes, wlr_event.x_mm, wlr_event.y_mm); wlr_signal_emit_safe(&wlr_dev->tablet_tool->events.axis, &wlr_event); } diff --git a/backend/x11/backend.c b/backend/x11/backend.c index 8633ece3..cb29e518 100644 --- a/backend/x11/backend.c +++ b/backend/x11/backend.c @@ -15,7 +15,6 @@ #include <wlr/render/gles2.h> #include <wlr/util/log.h> #include <X11/Xlib-xcb.h> -#include <xcb/glx.h> #include <xcb/xcb.h> #ifdef __linux__ #include <linux/input-event-codes.h> @@ -25,9 +24,11 @@ #include "backend/x11.h" #include "util/signal.h" -static struct wlr_backend_impl backend_impl; -static struct wlr_output_impl output_impl; -static struct wlr_input_device_impl input_device_impl = { 0 }; +#define XCB_EVENT_RESPONSE_TYPE_MASK 0x7f + +static const struct wlr_backend_impl backend_impl; +static const struct wlr_output_impl output_impl; +static const struct wlr_input_device_impl input_device_impl = { 0 }; static uint32_t xcb_button_to_wl(uint32_t button) { switch (button) { @@ -44,7 +45,7 @@ static uint32_t xcb_button_to_wl(uint32_t button) { static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *event) { struct wlr_x11_output *output = &x11->output; - switch (event->response_type) { + switch (event->response_type & XCB_EVENT_RESPONSE_TYPE_MASK) { case XCB_EXPOSE: { wlr_output_send_frame(&output->wlr_output); break; @@ -144,9 +145,14 @@ static bool handle_x11_event(struct wlr_x11_backend *x11, xcb_generic_event_t *e wlr_signal_emit_safe(&x11->pointer.events.motion_absolute, &abs); break; } - case XCB_GLX_DELETE_QUERIES_ARB: { - wl_display_terminate(x11->wl_display); - return true; + case XCB_CLIENT_MESSAGE: { + xcb_client_message_event_t *ev = (xcb_client_message_event_t *)event; + + if (ev->data.data32[0] == x11->atoms.wm_delete_window) { + wl_display_terminate(x11->wl_display); + return true; + } + break; } default: @@ -181,13 +187,6 @@ static int signal_frame(void *data) { return 0; } -static void init_atom(struct wlr_x11_backend *x11, struct wlr_x11_atom *atom, - uint8_t only_if_exists, const char *name) { - atom->cookie = xcb_intern_atom(x11->xcb_conn, only_if_exists, strlen(name), - name); - atom->reply = xcb_intern_atom_reply(x11->xcb_conn, atom->cookie, NULL); -} - static void parse_xcb_setup(struct wlr_output *output, xcb_connection_t *xcb_conn) { const xcb_setup_t *xcb_setup = xcb_get_setup(xcb_conn); @@ -231,20 +230,54 @@ static bool wlr_x11_backend_start(struct wlr_backend *backend) { return false; } - init_atom(x11, &x11->atoms.wm_protocols, 1, "WM_PROTOCOLS"); - init_atom(x11, &x11->atoms.wm_delete_window, 0, "WM_DELETE_WINDOW"); - init_atom(x11, &x11->atoms.net_wm_name, 1, "_NET_WM_NAME"); - init_atom(x11, &x11->atoms.utf8_string, 0, "UTF8_STRING"); + struct { + const char *name; + xcb_intern_atom_cookie_t cookie; + xcb_atom_t *atom; + } atom[] = { + { + .name = "WM_PROTOCOLS", + .atom = &x11->atoms.wm_protocols, + }, + { + .name = "WM_DELETE_WINDOW", + .atom = &x11->atoms.wm_delete_window, + }, + { + .name = "_NET_WM_NAME", + .atom = &x11->atoms.net_wm_name, + }, + { + .name = "UTF8_STRING", + .atom = &x11->atoms.utf8_string, + }, + }; + + for (size_t i = 0; i < sizeof(atom) / sizeof(atom[0]); ++i) { + atom[i].cookie = xcb_intern_atom(x11->xcb_conn, + true, strlen(atom[i].name), atom[i].name); + } + + for (size_t i = 0; i < sizeof(atom) / sizeof(atom[0]); ++i) { + xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply( + x11->xcb_conn, atom[i].cookie, NULL); + + if (reply) { + *atom[i].atom = reply->atom; + free(reply); + } else { + *atom[i].atom = XCB_ATOM_NONE; + } + } xcb_change_property(x11->xcb_conn, XCB_PROP_MODE_REPLACE, output->win, - x11->atoms.wm_protocols.reply->atom, XCB_ATOM_ATOM, 32, 1, - &x11->atoms.wm_delete_window.reply->atom); + x11->atoms.wm_protocols, XCB_ATOM_ATOM, 32, 1, + &x11->atoms.wm_delete_window); char title[32]; if (snprintf(title, sizeof(title), "wlroots - %s", output->wlr_output.name)) { xcb_change_property(x11->xcb_conn, XCB_PROP_MODE_REPLACE, output->win, - x11->atoms.net_wm_name.reply->atom, - x11->atoms.utf8_string.reply->atom, 8, + x11->atoms.net_wm_name, x11->atoms.utf8_string, 8, strlen(title), title); } @@ -304,7 +337,7 @@ static struct wlr_renderer *wlr_x11_backend_get_renderer( return x11->renderer; } -static struct wlr_backend_impl backend_impl = { +static const struct wlr_backend_impl backend_impl = { .start = wlr_x11_backend_start, .destroy = wlr_x11_backend_destroy, .get_egl = wlr_x11_backend_get_egl, @@ -432,7 +465,7 @@ static bool output_swap_buffers(struct wlr_output *wlr_output, return wlr_egl_swap_buffers(&x11->egl, output->surf, damage); } -static struct wlr_output_impl output_impl = { +static const struct wlr_output_impl output_impl = { .set_custom_mode = output_set_custom_mode, .transform = output_transform, .destroy = output_destroy, diff --git a/examples/support/shared.c b/examples/support/shared.c index c4f9288d..e6233206 100644 --- a/examples/support/shared.c +++ b/examples/support/shared.c @@ -294,6 +294,14 @@ static void tablet_pad_button_notify(struct wl_listener *listener, void *data) { } } +static void tablet_pad_ring_notify(struct wl_listener *listener, void *data) { + struct wlr_event_tablet_pad_ring *event = data; + struct tablet_pad_state *pstate = wl_container_of(listener, pstate, ring); + if (pstate->compositor->pad_ring_cb) { + pstate->compositor->pad_ring_cb(pstate, event->ring, event->position); + } +} + 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; @@ -315,6 +323,8 @@ static void tablet_pad_add(struct wlr_input_device *device, wl_signal_add(&device->events.destroy, &pstate->destroy); pstate->button.notify = tablet_pad_button_notify; wl_signal_add(&device->tablet_pad->events.button, &pstate->button); + pstate->ring.notify = tablet_pad_ring_notify; + wl_signal_add(&device->tablet_pad->events.ring, &pstate->ring); wl_list_insert(&state->tablet_pads, &pstate->link); } diff --git a/examples/support/shared.h b/examples/support/shared.h index 8cdea301..d00e75b3 100644 --- a/examples/support/shared.h +++ b/examples/support/shared.h @@ -73,6 +73,7 @@ struct tablet_pad_state { struct wlr_input_device *device; struct wl_listener destroy; struct wl_listener button; + struct wl_listener ring; struct wl_list link; void *data; }; @@ -117,6 +118,8 @@ struct compositor_state { uint32_t button, enum wlr_button_state state); void (*pad_button_cb)(struct tablet_pad_state *s, uint32_t button, enum wlr_button_state state); + void (*pad_ring_cb)(struct tablet_pad_state *s, + uint32_t ring, double position); struct wl_display *display; struct wl_event_loop *event_loop; diff --git a/examples/tablet.c b/examples/tablet.c index ca76ec5a..5bfa1271 100644 --- a/examples/tablet.c +++ b/examples/tablet.c @@ -14,6 +14,7 @@ #include <wlr/render.h> #include <wlr/backend.h> #include <wlr/backend/session.h> +#include <wlr/types/wlr_box.h> #include <wlr/types/wlr_output.h> #include <wlr/types/wlr_tablet_tool.h> #include <wlr/types/wlr_tablet_pad.h> @@ -28,7 +29,9 @@ struct sample_state { double distance; double pressure; double x_mm, y_mm; + double x_tilt, y_tilt; double width_mm, height_mm; + double ring; struct wl_list link; float tool_color[4]; float pad_color[4]; @@ -46,7 +49,7 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts wlr_renderer_begin(sample->renderer, wlr_output); wlr_renderer_clear(sample->renderer, &(float[]){0.25f, 0.25f, 0.25f, 1}); - float matrix[16], view[16]; + float matrix[16]; float distance = 0.8f * (1 - sample->distance); float tool_color[4] = { distance, distance, distance, 1 }; for (size_t i = 0; sample->button && i < 4; ++i) { @@ -58,22 +61,31 @@ static void handle_output_frame(struct output_state *output, struct timespec *ts float pad_height = sample->height_mm * scale; float left = width / 2.0f - pad_width / 2.0f; float top = height / 2.0f - pad_height / 2.0f; - wlr_matrix_translate(&matrix, left, top, 0); - wlr_matrix_scale(&view, pad_width, pad_height, 1); - wlr_matrix_mul(&matrix, &view, &view); - wlr_matrix_mul(&wlr_output->transform_matrix, &view, &matrix); + struct wlr_box box = { + .x = left, .y = top, + .width = pad_width, .height = pad_height, + }; + wlr_matrix_project_box(&matrix, &box, 0, 0, + &wlr_output->transform_matrix); wlr_render_colored_quad(sample->renderer, &sample->pad_color, &matrix); if (sample->proximity) { - wlr_matrix_translate(&matrix, - sample->x_mm * scale - 8 * (sample->pressure + 1) + left, - sample->y_mm * scale - 8 * (sample->pressure + 1) + top, 0); - wlr_matrix_scale(&view, - 16 * (sample->pressure + 1), - 16 * (sample->pressure + 1), 1); - wlr_matrix_mul(&matrix, &view, &view); - wlr_matrix_mul(&wlr_output->transform_matrix, &view, &matrix); - wlr_render_colored_ellipse(sample->renderer, &tool_color, &matrix); + struct wlr_box box = { + .x = sample->x_mm * scale - 8 * (sample->pressure + 1) + left, + .y = sample->y_mm * scale - 8 * (sample->pressure + 1) + top, + .width = 16 * (sample->pressure + 1), + .height = 16 * (sample->pressure + 1), + }; + wlr_matrix_project_box(&matrix, &box, 0, sample->ring, + &wlr_output->transform_matrix); + wlr_render_colored_quad(sample->renderer, &tool_color, &matrix); + box.x += sample->x_tilt; + box.y += sample->y_tilt; + box.width /= 2; + box.height /= 2; + wlr_matrix_project_box(&matrix, &box, 0, 0, + &wlr_output->transform_matrix); + wlr_render_colored_quad(sample->renderer, &tool_color, &matrix); } wlr_renderer_end(sample->renderer); @@ -97,6 +109,12 @@ static void handle_tool_axis(struct tablet_tool_state *tstate, if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_PRESSURE)) { sample->pressure = event->pressure; } + if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_TILT_X)) { + sample->x_tilt = event->tilt_x; + } + if ((event->updated_axes & WLR_TABLET_TOOL_AXIS_TILT_Y)) { + sample->y_tilt = event->tilt_y; + } } static void handle_tool_proximity(struct tablet_tool_state *tstate, @@ -125,7 +143,7 @@ static void handle_tool_button(struct tablet_tool_state *tstate, static void handle_pad_button(struct tablet_pad_state *pstate, uint32_t button, enum wlr_button_state state) { struct sample_state *sample = pstate->compositor->data; - float default_color[4] = { 0.75, 0.75, 0.75, 1.0 }; + float default_color[4] = { 0.5, 0.5, 0.5, 1.0 }; if (state == WLR_BUTTON_RELEASED) { memcpy(sample->pad_color, default_color, sizeof(default_color)); } else { @@ -139,11 +157,19 @@ static void handle_pad_button(struct tablet_pad_state *pstate, } } +static void handle_pad_ring(struct tablet_pad_state *pstate, + uint32_t ring, double position) { + struct sample_state *sample = pstate->compositor->data; + if (position != -1) { + sample->ring = -(position * (M_PI / 180.0)); + } +} + int main(int argc, char *argv[]) { wlr_log_init(L_DEBUG, NULL); struct sample_state state = { .tool_color = { 1, 1, 1, 1 }, - .pad_color = { 0.75, 0.75, 0.75, 1.0 } + .pad_color = { 0.5, 0.5, 0.5, 1.0 } }; struct compositor_state compositor = { 0, .data = &state, @@ -152,6 +178,7 @@ int main(int argc, char *argv[]) { .tool_proximity_cb = handle_tool_proximity, .tool_button_cb = handle_tool_button, .pad_button_cb = handle_pad_button, + .pad_ring_cb = handle_pad_ring, }; compositor_init(&compositor); diff --git a/include/backend/x11.h b/include/backend/x11.h index 9e1c8146..840509bf 100644 --- a/include/backend/x11.h +++ b/include/backend/x11.h @@ -17,11 +17,6 @@ struct wlr_x11_output { EGLSurface surf; }; -struct wlr_x11_atom { - xcb_intern_atom_cookie_t cookie; - xcb_intern_atom_reply_t *reply; -}; - struct wlr_x11_backend { struct wlr_backend backend; struct wl_display *wl_display; @@ -44,10 +39,10 @@ struct wlr_x11_backend { struct wl_event_source *frame_timer; struct { - struct wlr_x11_atom wm_protocols; - struct wlr_x11_atom wm_delete_window; - struct wlr_x11_atom net_wm_name; - struct wlr_x11_atom utf8_string; + xcb_atom_t wm_protocols; + xcb_atom_t wm_delete_window; + xcb_atom_t net_wm_name; + xcb_atom_t utf8_string; } atoms; // The time we last received an event diff --git a/include/wlr/interfaces/wlr_input_device.h b/include/wlr/interfaces/wlr_input_device.h index 2a681ff8..a5c513b7 100644 --- a/include/wlr/interfaces/wlr_input_device.h +++ b/include/wlr/interfaces/wlr_input_device.h @@ -10,7 +10,7 @@ struct wlr_input_device_impl { void wlr_input_device_init( struct wlr_input_device *wlr_device, enum wlr_input_device_type type, - struct wlr_input_device_impl *impl, + const struct wlr_input_device_impl *impl, const char *name, int vendor, int product); void wlr_input_device_destroy(struct wlr_input_device *dev); diff --git a/include/wlr/types/wlr_input_device.h b/include/wlr/types/wlr_input_device.h index 306a1166..6d8e3631 100644 --- a/include/wlr/types/wlr_input_device.h +++ b/include/wlr/types/wlr_input_device.h @@ -24,7 +24,7 @@ enum wlr_input_device_type { struct wlr_input_device_impl; struct wlr_input_device { - struct wlr_input_device_impl *impl; + const struct wlr_input_device_impl *impl; enum wlr_input_device_type type; int vendor, product; diff --git a/include/wlr/types/wlr_tablet_pad.h b/include/wlr/types/wlr_tablet_pad.h index e70db516..73082c56 100644 --- a/include/wlr/types/wlr_tablet_pad.h +++ b/include/wlr/types/wlr_tablet_pad.h @@ -29,6 +29,7 @@ struct wlr_event_tablet_pad_button { uint32_t time_msec; uint32_t button; enum wlr_button_state state; + unsigned int mode; }; enum wlr_tablet_pad_ring_source { @@ -41,6 +42,7 @@ struct wlr_event_tablet_pad_ring { enum wlr_tablet_pad_ring_source source; uint32_t ring; double position; + unsigned int mode; }; enum wlr_tablet_pad_strip_source { @@ -53,6 +55,7 @@ struct wlr_event_tablet_pad_strip { enum wlr_tablet_pad_strip_source source; uint32_t strip; double position; + unsigned int mode; }; #endif diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h index 0d4b91ed..f34860aa 100644 --- a/include/wlr/xwayland.h +++ b/include/wlr/xwayland.h @@ -8,10 +8,6 @@ #include <wlr/types/wlr_seat.h> #include <xcb/xcb.h> -#ifdef WLR_HAS_XCB_ICCCM - #include <xcb/xcb_icccm.h> -#endif - struct wlr_xwm; struct wlr_xwayland_cursor; diff --git a/include/wlr/xwm.h b/include/xwayland/xwm.h index 7d518f7e..4b15cc84 100644 --- a/include/wlr/xwm.h +++ b/include/xwayland/xwm.h @@ -1,10 +1,17 @@ -#ifndef WLR_XWM_H -#define WLR_XWM_H +#ifndef XWAYLAND_XWM_H +#define XWAYLAND_XWM_H #include <wayland-server-core.h> #include <wlr/xwayland.h> #include <xcb/render.h> +#ifdef WLR_HAS_XCB_ICCCM + #include <xcb/xcb_icccm.h> +#endif +#ifdef WLR_HAS_XCB_ERRORS + #include <xcb/xcb_errors.h> +#endif + enum atom_name { WL_SURFACE_ID, WM_DELETE_WINDOW, @@ -98,6 +105,9 @@ struct wlr_xwm { struct wl_list unpaired_surfaces; // wlr_xwayland_surface::unpaired_link const xcb_query_extension_reply_t *xfixes; +#ifdef WLR_HAS_XCB_ERRORS + xcb_errors_context_t *errors_context; +#endif struct wl_listener compositor_new_surface; struct wl_listener compositor_destroy; @@ -119,7 +129,7 @@ void xwm_selection_finish(struct wlr_xwm *xwm); void xwm_set_seat(struct wlr_xwm *xwm, struct wlr_seat *seat); -bool wlr_xwm_atoms_contains(struct wlr_xwm *xwm, xcb_atom_t *atoms, +bool xwm_atoms_contains(struct wlr_xwm *xwm, xcb_atom_t *atoms, size_t num_atoms, enum atom_name needle); #endif diff --git a/meson.build b/meson.build index d5ae7863..c7ca038c 100644 --- a/meson.build +++ b/meson.build @@ -64,6 +64,7 @@ xcb_xfixes = dependency('xcb-xfixes') xcb_image = dependency('xcb-image') xcb_render = dependency('xcb-render') xcb_icccm = dependency('xcb-icccm', required: false) +xcb_errors = dependency('xcb-errors', required: get_option('enable_xcb_errors') == 'true') x11_xcb = dependency('x11-xcb') libcap = dependency('libcap', required: get_option('enable_libcap') == 'true') systemd = dependency('libsystemd', required: get_option('enable_systemd') == 'true') @@ -78,6 +79,10 @@ if xcb_icccm.found() conf_data.set('WLR_HAS_XCB_ICCCM', true) endif +if xcb_errors.found() and get_option('enable_xcb_errors') != 'false' + conf_data.set('WLR_HAS_XCB_ERRORS', true) +endif + if libcap.found() and get_option('enable_libcap') != 'false' conf_data.set('WLR_HAS_LIBCAP', true) wlr_deps += libcap @@ -98,7 +103,6 @@ if get_option('enable_xwayland') conf_data.set('WLR_HAS_XWAYLAND', true) else exclude_headers += 'xwayland.h' - exclude_headers += 'xwm.h' endif exclude_headers += 'meson.build' install_subdir('include/wlr', install_dir: 'include', exclude_files: exclude_headers) @@ -164,10 +168,12 @@ summary = [ '----------------', 'wlroots @0@'.format(meson.project_version()), '', - ' libcap: @0@'.format(conf_data.get('WLR_HAS_LIBCAP', false)), - ' systemd: @0@'.format(conf_data.get('WLR_HAS_SYSTEMD', false)), - ' elogind: @0@'.format(conf_data.get('WLR_HAS_ELOGIND', false)), - ' xwayland: @0@'.format(conf_data.get('WLR_HAS_XWAYLAND', false)), + ' libcap: @0@'.format(conf_data.get('WLR_HAS_LIBCAP', false)), + ' systemd: @0@'.format(conf_data.get('WLR_HAS_SYSTEMD', false)), + ' elogind: @0@'.format(conf_data.get('WLR_HAS_ELOGIND', false)), + ' xwayland: @0@'.format(conf_data.get('WLR_HAS_XWAYLAND', false)), + ' xcb-icccm: @0@'.format(conf_data.get('WLR_HAS_XCB_ICCCM', false)), + ' xcb-errors: @0@'.format(conf_data.get('WLR_HAS_XCB_ERRORS', false)), '----------------', '' ] @@ -190,7 +196,7 @@ git = find_program('git', required: false) if git.found() all_files = run_command( git, - ['--git-dir=@0@/.git'.format(meson.source_root()), + ['--git-dir=@0@/.git'.format(meson.current_source_dir()), 'ls-files', ':/*.[ch]']) all_files = files(all_files.stdout().split()) diff --git a/meson_options.txt b/meson_options.txt index 6434b43d..4812b6f8 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,4 +1,5 @@ option('enable_libcap', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'Enable support for capabilities') option('enable_systemd', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'Enable support for logind') option('enable_elogind', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'Enable support for logind') +option('enable_xcb_errors', type: 'combo', choices: ['auto', 'true', 'false'], value: 'auto', description: 'Use xcb-errors util library') option('enable_xwayland', type: 'boolean', value: true, description: 'Enable support X11 applications') diff --git a/rootston/seat.c b/rootston/seat.c index 9acbb737..8ac41f6c 100644 --- a/rootston/seat.c +++ b/rootston/seat.c @@ -514,13 +514,13 @@ static void seat_add_tablet_pad(struct roots_seat *seat, static void handle_tablet_tool_destroy(struct wl_listener *listener, void *data) { - struct roots_pointer *tablet_tool = + struct roots_tablet_tool *tablet_tool = wl_container_of(listener, tablet_tool, device_destroy); struct roots_seat *seat = tablet_tool->seat; - wl_list_remove(&tablet_tool->link); wlr_cursor_detach_input_device(seat->cursor->cursor, tablet_tool->device); wl_list_remove(&tablet_tool->device_destroy.link); + wl_list_remove(&tablet_tool->link); free(tablet_tool); seat_update_capabilities(seat); diff --git a/types/wlr_input_device.c b/types/wlr_input_device.c index 65d4b1d6..713d911a 100644 --- a/types/wlr_input_device.c +++ b/types/wlr_input_device.c @@ -14,7 +14,7 @@ void wlr_input_device_init(struct wlr_input_device *dev, enum wlr_input_device_type type, - struct wlr_input_device_impl *impl, + const struct wlr_input_device_impl *impl, const char *name, int vendor, int product) { dev->type = type; dev->impl = impl; diff --git a/types/wlr_output.c b/types/wlr_output.c index 5a2886c7..7f19d1fe 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -16,9 +16,7 @@ #include "util/signal.h" static void wl_output_send_to_resource(struct wl_resource *resource) { - assert(resource); struct wlr_output *output = wlr_output_from_resource(resource); - assert(output); const uint32_t version = wl_resource_get_version(resource); if (version >= WL_OUTPUT_GEOMETRY_SINCE_VERSION) { wl_output_send_geometry(resource, output->lx, output->ly, @@ -52,9 +50,7 @@ static void wl_output_send_to_resource(struct wl_resource *resource) { static void wlr_output_send_current_mode_to_resource( struct wl_resource *resource) { - assert(resource); struct wlr_output *output = wlr_output_from_resource(resource); - assert(output); const uint32_t version = wl_resource_get_version(resource); if (version < WL_OUTPUT_MODE_SINCE_VERSION) { return; @@ -76,7 +72,7 @@ static void wlr_output_send_current_mode_to_resource( static void wl_output_destroy(struct wl_resource *resource) { struct wlr_output *output = wlr_output_from_resource(resource); - struct wl_resource *_resource = NULL; + struct wl_resource *_resource; wl_resource_for_each(_resource, &output->wl_resources) { if (_resource == resource) { struct wl_list *link = wl_resource_get_link(_resource); @@ -98,7 +94,6 @@ static struct wl_output_interface wl_output_impl = { static void wl_output_bind(struct wl_client *wl_client, void *data, uint32_t version, uint32_t id) { struct wlr_output *wlr_output = data; - assert(wl_client && wlr_output); struct wl_resource *wl_resource = wl_resource_create(wl_client, &wl_output_interface, version, id); @@ -674,6 +669,31 @@ static void output_cursor_reset(struct wlr_output_cursor *cursor) { } } +static void output_cursor_update_visible(struct wlr_output_cursor *cursor) { + struct wlr_box output_box; + output_box.x = output_box.y = 0; + wlr_output_transformed_resolution(cursor->output, &output_box.width, + &output_box.height); + + struct wlr_box cursor_box; + output_cursor_get_box(cursor, &cursor_box); + + struct wlr_box intersection; + bool visible = + wlr_box_intersection(&output_box, &cursor_box, &intersection); + + if (cursor->surface != NULL) { + if (cursor->visible && !visible) { + wlr_surface_send_leave(cursor->surface, cursor->output); + } + if (!cursor->visible && visible) { + wlr_surface_send_enter(cursor->surface, cursor->output); + } + } + + cursor->visible = visible; +} + bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor, const uint8_t *pixels, int32_t stride, uint32_t width, uint32_t height, int32_t hotspot_x, int32_t hotspot_y) { @@ -687,6 +707,7 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor, cursor->height = height; cursor->hotspot_x = hotspot_x; cursor->hotspot_y = hotspot_y; + output_cursor_update_visible(cursor); struct wlr_output_cursor *hwcur = cursor->output->hardware_cursor; if (cursor->output->impl->set_cursor && (hwcur == NULL || hwcur == cursor)) { @@ -721,31 +742,6 @@ bool wlr_output_cursor_set_image(struct wlr_output_cursor *cursor, stride, width, height, pixels); } -static void output_cursor_update_visible(struct wlr_output_cursor *cursor) { - struct wlr_box output_box; - output_box.x = output_box.y = 0; - wlr_output_transformed_resolution(cursor->output, &output_box.width, - &output_box.height); - - struct wlr_box cursor_box; - output_cursor_get_box(cursor, &cursor_box); - - struct wlr_box intersection; - bool visible = - wlr_box_intersection(&output_box, &cursor_box, &intersection); - - if (cursor->surface != NULL) { - if (cursor->visible && !visible) { - wlr_surface_send_leave(cursor->surface, cursor->output); - } - if (!cursor->visible && visible) { - wlr_surface_send_enter(cursor->surface, cursor->output); - } - } - - cursor->visible = visible; -} - static void output_cursor_commit(struct wlr_output_cursor *cursor) { if (cursor->output->hardware_cursor != cursor) { output_cursor_damage_whole(cursor); @@ -851,12 +847,18 @@ bool wlr_output_cursor_move(struct wlr_output_cursor *cursor, output_cursor_damage_whole(cursor); } + bool was_visible = cursor->visible; x *= cursor->output->scale; y *= cursor->output->scale; cursor->x = x; cursor->y = y; output_cursor_update_visible(cursor); + if (!was_visible && !cursor->visible) { + // Cursor is still hidden, do nothing + return true; + } + if (cursor->output->hardware_cursor != cursor) { output_cursor_damage_whole(cursor); return true; @@ -881,6 +883,7 @@ struct wlr_output_cursor *wlr_output_cursor_create(struct wlr_output *output) { wl_list_init(&cursor->surface_destroy.link); cursor->surface_destroy.notify = output_cursor_handle_destroy; wl_list_insert(&output->cursors, &cursor->link); + cursor->visible = true; // default position is at (0, 0) return cursor; } diff --git a/types/wlr_output_layout.c b/types/wlr_output_layout.c index c305f04d..2462bdd2 100644 --- a/types/wlr_output_layout.c +++ b/types/wlr_output_layout.c @@ -48,6 +48,7 @@ struct wlr_output_layout *wlr_output_layout_create() { static void wlr_output_layout_output_destroy( struct wlr_output_layout_output *l_output) { wlr_signal_emit_safe(&l_output->events.destroy, l_output); + wlr_output_destroy_global(l_output->output); wl_list_remove(&l_output->state->mode.link); wl_list_remove(&l_output->state->scale.link); wl_list_remove(&l_output->state->transform.link); @@ -64,7 +65,7 @@ void wlr_output_layout_destroy(struct wlr_output_layout *layout) { wlr_signal_emit_safe(&layout->events.destroy, layout); - struct wlr_output_layout_output *l_output, *temp = NULL; + struct wlr_output_layout_output *l_output, *temp; wl_list_for_each_safe(l_output, temp, &layout->outputs, link) { wlr_output_layout_output_destroy(l_output); } @@ -291,7 +292,6 @@ void wlr_output_layout_remove(struct wlr_output_layout *layout, wlr_output_layout_output_destroy(l_output); wlr_output_layout_reconfigure(layout); } - wlr_output_destroy_global(output); } void wlr_output_layout_output_coords(struct wlr_output_layout *layout, diff --git a/types/wlr_surface.c b/types/wlr_surface.c index fd5bf4f1..51bd47bc 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -905,7 +905,6 @@ void wlr_surface_send_enter(struct wlr_surface *surface, wl_resource_for_each(resource, &output->wl_resources) { if (client == wl_resource_get_client(resource)) { wl_surface_send_enter(surface->resource, resource); - break; } } } @@ -917,7 +916,6 @@ void wlr_surface_send_leave(struct wlr_surface *surface, wl_resource_for_each(resource, &output->wl_resources) { if (client == wl_resource_get_client(resource)) { wl_surface_send_leave(surface->resource, resource); - break; } } } diff --git a/types/wlr_xdg_shell_v6.c b/types/wlr_xdg_shell_v6.c index e07d78a1..48dfa3ac 100644 --- a/types/wlr_xdg_shell_v6.c +++ b/types/wlr_xdg_shell_v6.c @@ -13,8 +13,8 @@ #include "util/signal.h" #include "xdg-shell-unstable-v6-protocol.h" -static const char *wlr_desktop_xdg_toplevel_role = "xdg_toplevel"; -static const char *wlr_desktop_xdg_popup_role = "xdg_popup"; +static const char *wlr_desktop_xdg_toplevel_role = "xdg_toplevel_v6"; +static const char *wlr_desktop_xdg_popup_role = "xdg_popup_v6"; struct wlr_xdg_positioner_v6 { struct wl_resource *resource; diff --git a/xwayland/meson.build b/xwayland/meson.build index 2ccdf4cb..9d7f3f4a 100644 --- a/xwayland/meson.build +++ b/xwayland/meson.build @@ -15,6 +15,7 @@ lib_wlr_xwayland = static_library( xcb_image, xcb_render, xcb_icccm, + xcb_errors, xkbcommon, pixman, ], diff --git a/xwayland/selection.c b/xwayland/selection.c index ffcde4d0..1d390026 100644 --- a/xwayland/selection.c +++ b/xwayland/selection.c @@ -7,8 +7,8 @@ #include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_primary_selection.h> #include <wlr/util/log.h> -#include <wlr/xwm.h> #include <xcb/xfixes.h> +#include "xwayland/xwm.h" static const size_t incr_chunk_size = 64 * 1024; diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c index 8dffd040..765e17d0 100644 --- a/xwayland/xwayland.c +++ b/xwayland/xwayland.c @@ -18,9 +18,9 @@ #include <wayland-server.h> #include <wlr/util/log.h> #include <wlr/xwayland.h> -#include <wlr/xwm.h> #include "sockets.h" #include "util/signal.h" +#include "xwayland/xwm.h" #ifdef __FreeBSD__ static inline int clearenv(void) { @@ -418,7 +418,7 @@ bool wlr_xwayland_surface_is_unmanaged(const struct wlr_xwayland_surface *surfac }; for (size_t i = 0; i < sizeof(needles) / sizeof(needles[0]); ++i) { - if (wlr_xwm_atoms_contains(surface->xwm, surface->window_type, + if (xwm_atoms_contains(surface->xwm, surface->window_type, surface->window_type_len, needles[i])) { return true; } diff --git a/xwayland/xwm.c b/xwayland/xwm.c index c41b8d47..8911c553 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -9,16 +9,12 @@ #include <wlr/util/log.h> #include <wlr/xcursor.h> #include <wlr/xwayland.h> -#include <wlr/xwm.h> #include <xcb/composite.h> #include <xcb/render.h> #include <xcb/xcb_image.h> #include <xcb/xfixes.h> #include "util/signal.h" - -#ifdef WLR_HAS_XCB_ICCCM - #include <xcb/xcb_icccm.h> -#endif +#include "xwayland/xwm.h" const char *atom_map[ATOM_LAST] = { "WL_SURFACE_ID", @@ -93,7 +89,7 @@ static struct wlr_xwayland_surface *wlr_xwayland_surface_create( XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE; xcb_change_window_attributes(xwm->xcb_conn, window_id, - XCB_CW_EVENT_MASK, &values); + XCB_CW_EVENT_MASK, values); surface->xwm = xwm; surface->window_id = window_id; @@ -954,6 +950,62 @@ static void xwm_handle_focus_in(struct wlr_xwm *xwm, } } +static void xwm_handle_xcb_error(struct wlr_xwm *xwm, xcb_value_error_t *ev) { +#ifdef WLR_HAS_XCB_ERRORS + const char *major_name = + xcb_errors_get_name_for_major_code(xwm->errors_context, + ev->major_opcode); + if (!major_name) { + wlr_log(L_DEBUG, "xcb error happened, but could not get major name"); + goto log_raw; + } + + const char *minor_name = + xcb_errors_get_name_for_minor_code(xwm->errors_context, + ev->major_opcode, ev->minor_opcode); + + const char *extension; + const char *error_name = + xcb_errors_get_name_for_error(xwm->errors_context, + ev->error_code, &extension); + if (!error_name) { + wlr_log(L_DEBUG, "xcb error happened, but could not get error name"); + goto log_raw; + } + + wlr_log(L_ERROR, "xcb error: op %s (%s), code %s (%s), sequence %"PRIu16", value %"PRIu32, + major_name, minor_name ? minor_name : "no minor", + error_name, extension ? extension : "no extension", + ev->sequence, ev->bad_value); + + return; +log_raw: +#endif + wlr_log(L_ERROR, + "xcb error: op %"PRIu8":%"PRIu16", code %"PRIu8", sequence %"PRIu16", value %"PRIu32, + ev->major_opcode, ev->minor_opcode, ev->error_code, + ev->sequence, ev->bad_value); + +} + +static void xwm_handle_unhandled_event(struct wlr_xwm *xwm, xcb_generic_event_t *ev) { +#ifdef WLR_HAS_XCB_ERRORS + const char *extension; + const char *event_name = + xcb_errors_get_name_for_xcb_event(xwm->errors_context, + ev, &extension); + if (!event_name) { + wlr_log(L_DEBUG, "no name for unhandled event: %u", + ev->response_type); + return; + } + + wlr_log(L_DEBUG, "unhandled X11 event: %s (%u)", event_name, ev->response_type); +#else + wlr_log(L_DEBUG, "unhandled X11 event: %u", ev->response_type); +#endif +} + /* This is in xcb/xcb_event.h, but pulling xcb-util just for a constant * others redefine anyway is meh */ @@ -1010,9 +1062,11 @@ static int x11_event_handler(int fd, uint32_t mask, void *data) { case XCB_FOCUS_IN: xwm_handle_focus_in(xwm, (xcb_focus_in_event_t *)event); break; + case 0: + xwm_handle_xcb_error(xwm, (xcb_value_error_t *)event); + break; default: - wlr_log(L_DEBUG, "X11 event: %d", - event->response_type & XCB_EVENT_RESPONSE_TYPE_MASK); + xwm_handle_unhandled_event(xwm, event); break; } free(event); @@ -1133,6 +1187,11 @@ void xwm_destroy(struct wlr_xwm *xwm) { if (xwm->event_source) { wl_event_source_remove(xwm->event_source); } +#ifdef WLR_HAS_XCB_ERRORS + if (xwm->errors_context) { + xcb_errors_context_free(xwm->errors_context); + } +#endif struct wlr_xwayland_surface *xsurface, *tmp; wl_list_for_each_safe(xsurface, tmp, &xwm->surfaces, link) { wlr_xwayland_surface_destroy(xsurface); @@ -1369,6 +1428,13 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) { return NULL; } +#ifdef WLR_HAS_XCB_ERRORS + if (xcb_errors_context_new(xwm->xcb_conn, &xwm->errors_context)) { + wlr_log(L_ERROR, "Could not allocate error context"); + xwm_destroy(xwm); + return NULL; + } +#endif xcb_screen_iterator_t screen_iterator = xcb_setup_roots_iterator(xcb_get_setup(xwm->xcb_conn)); xwm->screen = screen_iterator.data; @@ -1453,7 +1519,7 @@ void wlr_xwayland_surface_set_fullscreen(struct wlr_xwayland_surface *surface, xcb_flush(surface->xwm->xcb_conn); } -bool wlr_xwm_atoms_contains(struct wlr_xwm *xwm, xcb_atom_t *atoms, +bool xwm_atoms_contains(struct wlr_xwm *xwm, xcb_atom_t *atoms, size_t num_atoms, enum atom_name needle) { xcb_atom_t atom = xwm->atoms[needle]; |