This commit is contained in:
Kenny Levinsen 2023-12-12 21:32:46 +01:00 committed by GitHub
commit 5479028ffb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 66 additions and 80 deletions

View file

@ -11,19 +11,15 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
CC: [ gcc, clang ]
OS: [ "alpine:edge", "archlinux:base-devel" ] OS: [ "alpine:edge", "archlinux:base-devel" ]
xwayland: [ true, false ]
container: ${{ matrix.OS }} container: ${{ matrix.OS }}
env:
CC: ${{ matrix.CC }}
steps: steps:
- name: Checkout Cage - name: Checkout Cage
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Install dependencies (Alpine) - name: Install dependencies (Alpine)
if: "matrix.OS == 'alpine:edge'" if: "matrix.OS == 'alpine:edge'"
run: apk add build-base xcb-util-wm-dev libseat-dev clang git eudev-dev mesa-dev libdrm-dev libinput-dev libxkbcommon-dev pixman-dev wayland-dev meson wayland-protocols xwayland scdoc-doc hwdata run: apk add build-base xcb-util-wm-dev libseat-dev clang git eudev-dev mesa-dev libdrm-dev libinput-dev libxkbcommon-dev pixman-dev wayland-dev meson wayland-protocols xwayland-dev scdoc-doc hwdata
- name: Install dependencies (Arch) - name: Install dependencies (Arch)
if: "matrix.OS == 'archlinux:base-devel'" if: "matrix.OS == 'archlinux:base-devel'"
@ -32,13 +28,17 @@ jobs:
pacman -Syu --noconfirm xcb-util-wm seatd git clang meson libinput libdrm mesa libxkbcommon wayland wayland-protocols xorg-server-xwayland scdoc pacman -Syu --noconfirm xcb-util-wm seatd git clang meson libinput libdrm mesa libxkbcommon wayland wayland-protocols xorg-server-xwayland scdoc
- name: Fetch wlroots as a subproject - name: Fetch wlroots as a subproject
run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b 0.16.0 run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b 0.17.0
# TODO: use --fatal-meson-warnings when on wlroots 0.15.0 - name: Compile Cage
- name: Compile Cage (XWayland=${{ matrix.xwayland }})
run: | run: |
meson build-${{ matrix.CC }}-${{matrix.xwayland }} -Dxwayland=${{ matrix.xwayland }} meson setup build -Dxwayland=enabled
ninja -C build-${{ matrix.CC }}-${{matrix.xwayland }} ninja -C build
- name: Compile cage (no xwayland)
run: |
meson configure build -Dxwayland=disabled
ninja -C build
format: format:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -51,10 +51,10 @@ jobs:
pacman-key --init pacman-key --init
pacman -Syu --noconfirm xcb-util-wm seatd git clang meson libinput libdrm mesa libxkbcommon wayland wayland-protocols xorg-server-xwayland scdoc hwdata pacman -Syu --noconfirm xcb-util-wm seatd git clang meson libinput libdrm mesa libxkbcommon wayland wayland-protocols xorg-server-xwayland scdoc hwdata
- name: Fetch wlroots as a subproject - name: Fetch wlroots as a subproject
run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b 0.16.0 run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b 0.17.0
- name: Check for formatting changes - name: Check for formatting changes
run: | run: |
meson build-clang-format -Dxwayland=true meson build-clang-format -Dxwayland=enabled
ninja -C build-clang-format clang-format-check ninja -C build-clang-format clang-format-check
scan-build: scan-build:
@ -70,8 +70,8 @@ jobs:
pacman-key --init pacman-key --init
pacman -Syu --noconfirm xcb-util-wm seatd git clang meson libinput libdrm mesa libxkbcommon wayland wayland-protocols xorg-server-xwayland scdoc hwdata pacman -Syu --noconfirm xcb-util-wm seatd git clang meson libinput libdrm mesa libxkbcommon wayland wayland-protocols xorg-server-xwayland scdoc hwdata
- name: Fetch wlroots as a subproject - name: Fetch wlroots as a subproject
run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b 0.16.0 run: git clone https://gitlab.freedesktop.org/wlroots/wlroots.git subprojects/wlroots -b 0.17.0
- name: Run scan-build - name: Run scan-build
run: | run: |
meson build-scan-build -Dxwayland=true meson build-scan-build -Dxwayland=enabled
ninja -C build-scan-build scan-build ninja -C build-scan-build scan-build

8
cage.c
View file

@ -25,8 +25,8 @@
#include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_export_dmabuf_v1.h> #include <wlr/types/wlr_export_dmabuf_v1.h>
#include <wlr/types/wlr_gamma_control_v1.h> #include <wlr/types/wlr_gamma_control_v1.h>
#include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_idle_inhibit_v1.h> #include <wlr/types/wlr_idle_inhibit_v1.h>
#include <wlr/types/wlr_idle_notify_v1.h>
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output_management_v1.h> #include <wlr/types/wlr_output_management_v1.h>
#include <wlr/types/wlr_presentation_time.h> #include <wlr/types/wlr_presentation_time.h>
@ -293,7 +293,7 @@ main(int argc, char *argv[])
struct wl_event_source *sigterm_source = struct wl_event_source *sigterm_source =
wl_event_loop_add_signal(event_loop, SIGTERM, handle_signal, &server.wl_display); wl_event_loop_add_signal(event_loop, SIGTERM, handle_signal, &server.wl_display);
server.backend = wlr_backend_autocreate(server.wl_display); server.backend = wlr_backend_autocreate(server.wl_display, &server.session);
if (!server.backend) { if (!server.backend) {
wlr_log(WLR_ERROR, "Unable to create the wlroots backend"); wlr_log(WLR_ERROR, "Unable to create the wlroots backend");
ret = 1; ret = 1;
@ -342,7 +342,7 @@ main(int argc, char *argv[])
wlr_scene_attach_output_layout(server.scene, server.output_layout); wlr_scene_attach_output_layout(server.scene, server.output_layout);
struct wlr_compositor *compositor = wlr_compositor_create(server.wl_display, server.renderer); struct wlr_compositor *compositor = wlr_compositor_create(server.wl_display, 6, server.renderer);
if (!compositor) { if (!compositor) {
wlr_log(WLR_ERROR, "Unable to create the wlroots compositor"); wlr_log(WLR_ERROR, "Unable to create the wlroots compositor");
ret = 1; ret = 1;
@ -374,7 +374,7 @@ main(int argc, char *argv[])
goto end; goto end;
} }
server.idle = wlr_idle_create(server.wl_display); server.idle = wlr_idle_notifier_v1_create(server.wl_display);
if (!server.idle) { if (!server.idle) {
wlr_log(WLR_ERROR, "Unable to create the idle tracker"); wlr_log(WLR_ERROR, "Unable to create the idle tracker");
ret = 1; ret = 1;

View file

@ -8,8 +8,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_idle_inhibit_v1.h> #include <wlr/types/wlr_idle_inhibit_v1.h>
#include <wlr/types/wlr_idle_notify_v1.h>
#include "idle_inhibit_v1.h" #include "idle_inhibit_v1.h"
#include "server.h" #include "server.h"
@ -32,7 +32,7 @@ idle_inhibit_v1_check_active(struct cg_server *server)
Hence, we simply check for any inhibitors and inhibit Hence, we simply check for any inhibitors and inhibit
accordingly. */ accordingly. */
bool inhibited = !wl_list_empty(&server->inhibitors); bool inhibited = !wl_list_empty(&server->inhibitors);
wlr_idle_set_enabled(server->idle, NULL, !inhibited); wlr_idle_notifier_v1_set_inhibited(server->idle, inhibited);
} }
static void static void

View file

@ -35,7 +35,7 @@ if is_freebsd
) )
endif endif
wlroots = dependency('wlroots', version: '>= 0.16.0', fallback: ['wlroots', 'wlroots']) wlroots = dependency('wlroots', version: '>= 0.17.0', fallback: ['wlroots', 'wlroots'])
wayland_protos = dependency('wayland-protocols', version: '>=1.14') wayland_protos = dependency('wayland-protocols', version: '>=1.14')
wayland_server = dependency('wayland-server') wayland_server = dependency('wayland-server')
xkbcommon = dependency('xkbcommon') xkbcommon = dependency('xkbcommon')
@ -64,9 +64,9 @@ server_protos = declare_dependency(
sources: server_protos_headers, sources: server_protos_headers,
) )
if get_option('xwayland') if not get_option('xwayland').disabled()
wlroots_has_xwayland = wlroots.get_variable(pkgconfig: 'have_xwayland', internal: 'have_xwayland') == 'true' wlroots_has_xwayland = wlroots.get_variable(pkgconfig: 'have_xwayland', internal: 'have_xwayland') == 'true'
if not wlroots_has_xwayland if get_option('xwayland').enabled() and not wlroots_has_xwayland
error('Cannot build Cage with XWayland support: wlroots has been built without it') error('Cannot build Cage with XWayland support: wlroots has been built without it')
endif endif
have_xwayland = true have_xwayland = true

View file

@ -1,2 +1,2 @@
option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages') option('man-pages', type: 'feature', value: 'auto', description: 'Generate and install man pages')
option('xwayland', type: 'boolean', value: false, description: 'Enable support for X11 applications') option('xwayland', type: 'feature', value: 'auto', description: 'Enable support for X11 applications')

View file

@ -26,7 +26,6 @@
#include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_matrix.h> #include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_damage.h>
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_output_management_v1.h> #include <wlr/types/wlr_output_management_v1.h>
#include <wlr/types/wlr_scene.h> #include <wlr/types/wlr_scene.h>
@ -71,24 +70,21 @@ update_output_manager_config(struct cg_server *server)
static inline void static inline void
output_layout_add_auto(struct cg_output *output) output_layout_add_auto(struct cg_output *output)
{ {
wlr_output_layout_add_auto(output->server->output_layout, output->wlr_output);
output->scene_output = wlr_scene_get_scene_output(output->server->scene, output->wlr_output);
assert(output->scene_output != NULL); assert(output->scene_output != NULL);
wlr_output_layout_add_auto(output->server->output_layout, output->wlr_output);
} }
static inline void static inline void
output_layout_add(struct cg_output *output, int32_t x, int32_t y) output_layout_add(struct cg_output *output, int32_t x, int32_t y)
{ {
wlr_output_layout_add(output->server->output_layout, output->wlr_output, x, y);
output->scene_output = wlr_scene_get_scene_output(output->server->scene, output->wlr_output);
assert(output->scene_output != NULL); assert(output->scene_output != NULL);
wlr_output_layout_add(output->server->output_layout, output->wlr_output, x, y);
} }
static inline void static inline void
output_layout_remove(struct cg_output *output) output_layout_remove(struct cg_output *output)
{ {
wlr_output_layout_remove(output->server->output_layout, output->wlr_output); wlr_output_layout_remove(output->server->output_layout, output->wlr_output);
output->scene_output = NULL;
} }
static void static void
@ -173,7 +169,7 @@ handle_output_frame(struct wl_listener *listener, void *data)
return; return;
} }
wlr_scene_output_commit(output->scene_output); wlr_scene_output_commit(output->scene_output, NULL);
struct timespec now = {0}; struct timespec now = {0};
clock_gettime(CLOCK_MONOTONIC, &now); clock_gettime(CLOCK_MONOTONIC, &now);
@ -190,24 +186,11 @@ handle_output_commit(struct wl_listener *listener, void *data)
* - output layout change will also be called if needed to position the views * - output layout change will also be called if needed to position the views
* - always update output manager configuration even if the output is now disabled */ * - always update output manager configuration even if the output is now disabled */
if (event->committed & OUTPUT_CONFIG_UPDATED) { if (event->state->committed & OUTPUT_CONFIG_UPDATED) {
update_output_manager_config(output->server); update_output_manager_config(output->server);
} }
} }
static void
handle_output_mode(struct wl_listener *listener, void *data)
{
struct cg_output *output = wl_container_of(listener, output, mode);
if (!output->wlr_output->enabled) {
return;
}
view_position_all(output->server);
update_output_manager_config(output->server);
}
void void
handle_output_layout_change(struct wl_listener *listener, void *data) handle_output_layout_change(struct wl_listener *listener, void *data)
{ {
@ -241,7 +224,6 @@ output_destroy(struct cg_output *output)
wl_list_remove(&output->destroy.link); wl_list_remove(&output->destroy.link);
wl_list_remove(&output->commit.link); wl_list_remove(&output->commit.link);
wl_list_remove(&output->mode.link);
wl_list_remove(&output->frame.link); wl_list_remove(&output->frame.link);
wl_list_remove(&output->link); wl_list_remove(&output->link);
@ -290,13 +272,13 @@ handle_new_output(struct wl_listener *listener, void *data)
output->commit.notify = handle_output_commit; output->commit.notify = handle_output_commit;
wl_signal_add(&wlr_output->events.commit, &output->commit); wl_signal_add(&wlr_output->events.commit, &output->commit);
output->mode.notify = handle_output_mode;
wl_signal_add(&wlr_output->events.mode, &output->mode);
output->destroy.notify = handle_output_destroy; output->destroy.notify = handle_output_destroy;
wl_signal_add(&wlr_output->events.destroy, &output->destroy); wl_signal_add(&wlr_output->events.destroy, &output->destroy);
output->frame.notify = handle_output_frame; output->frame.notify = handle_output_frame;
wl_signal_add(&wlr_output->events.frame, &output->frame); wl_signal_add(&wlr_output->events.frame, &output->frame);
output->scene_output = wlr_scene_output_create(server->scene, wlr_output);
if (!wl_list_empty(&wlr_output->modes)) { if (!wl_list_empty(&wlr_output->modes)) {
/* Ensure the output is marked as enabled before trying to set mode */ /* Ensure the output is marked as enabled before trying to set mode */
wlr_output_enable(wlr_output, true); wlr_output_enable(wlr_output, true);

View file

@ -3,7 +3,6 @@
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_output.h> #include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_damage.h>
#include "server.h" #include "server.h"
#include "view.h" #include "view.h"
@ -14,7 +13,6 @@ struct cg_output {
struct wlr_scene_output *scene_output; struct wlr_scene_output *scene_output;
struct wl_listener commit; struct wl_listener commit;
struct wl_listener mode;
struct wl_listener destroy; struct wl_listener destroy;
struct wl_listener frame; struct wl_listener frame;

40
seat.c
View file

@ -17,9 +17,10 @@
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/backend.h> #include <wlr/backend.h>
#include <wlr/backend/multi.h> #include <wlr/backend/multi.h>
#include <wlr/backend/session.h>
#include <wlr/types/wlr_cursor.h> #include <wlr/types/wlr_cursor.h>
#include <wlr/types/wlr_data_device.h> #include <wlr/types/wlr_data_device.h>
#include <wlr/types/wlr_idle.h> #include <wlr/types/wlr_idle_notify_v1.h>
#include <wlr/types/wlr_keyboard_group.h> #include <wlr/types/wlr_keyboard_group.h>
#include <wlr/types/wlr_primary_selection.h> #include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_relative_pointer_v1.h> #include <wlr/types/wlr_relative_pointer_v1.h>
@ -64,7 +65,7 @@ desktop_view_at(struct cg_server *server, double lx, double ly, struct wlr_surfa
} }
struct wlr_scene_buffer *scene_buffer = wlr_scene_buffer_from_node(node); struct wlr_scene_buffer *scene_buffer = wlr_scene_buffer_from_node(node);
struct wlr_scene_surface *scene_surface = wlr_scene_surface_from_buffer(scene_buffer); struct wlr_scene_surface *scene_surface = wlr_scene_surface_try_from_buffer(scene_buffer);
if (!scene_surface) { if (!scene_surface) {
return NULL; return NULL;
} }
@ -127,9 +128,9 @@ update_capabilities(struct cg_seat *seat)
/* Hide cursor if the seat doesn't have pointer capability. */ /* Hide cursor if the seat doesn't have pointer capability. */
if ((caps & WL_SEAT_CAPABILITY_POINTER) == 0) { if ((caps & WL_SEAT_CAPABILITY_POINTER) == 0) {
wlr_cursor_set_image(seat->cursor, NULL, 0, 0, 0, 0, 0, 0); wlr_cursor_unset_image(seat->cursor);
} else { } else {
wlr_xcursor_manager_set_cursor_image(seat->xcursor_manager, DEFAULT_XCURSOR, seat->cursor); wlr_cursor_set_xcursor(seat->cursor, seat->xcursor_manager, DEFAULT_XCURSOR);
} }
} }
@ -249,7 +250,7 @@ handle_modifier_event(struct wlr_keyboard *keyboard, struct cg_seat *seat)
wlr_seat_set_keyboard(seat->seat, keyboard); wlr_seat_set_keyboard(seat->seat, keyboard);
wlr_seat_keyboard_notify_modifiers(seat->seat, &keyboard->modifiers); wlr_seat_keyboard_notify_modifiers(seat->seat, &keyboard->modifiers);
wlr_idle_notify_activity(seat->server->idle, seat->seat); wlr_idle_notifier_v1_notify_activity(seat->server->idle, seat->seat);
} }
static bool static bool
@ -263,16 +264,15 @@ handle_keybinding(struct cg_server *server, xkb_keysym_t sym)
#endif #endif
if (server->allow_vt_switch && sym >= XKB_KEY_XF86Switch_VT_1 && sym <= XKB_KEY_XF86Switch_VT_12) { if (server->allow_vt_switch && sym >= XKB_KEY_XF86Switch_VT_1 && sym <= XKB_KEY_XF86Switch_VT_12) {
if (wlr_backend_is_multi(server->backend)) { if (wlr_backend_is_multi(server->backend)) {
struct wlr_session *session = wlr_backend_get_session(server->backend); if (server->session) {
if (session) {
unsigned vt = sym - XKB_KEY_XF86Switch_VT_1 + 1; unsigned vt = sym - XKB_KEY_XF86Switch_VT_1 + 1;
wlr_session_change_vt(session, vt); wlr_session_change_vt(server->session, vt);
} }
} }
} else { } else {
return false; return false;
} }
wlr_idle_notify_activity(server->idle, server->seat->seat); wlr_idle_notifier_v1_notify_activity(server->idle, server->seat->seat);
return true; return true;
} }
@ -304,7 +304,7 @@ handle_key_event(struct wlr_keyboard *keyboard, struct cg_seat *seat, void *data
wlr_seat_keyboard_notify_key(seat->seat, event->time_msec, event->keycode, event->state); wlr_seat_keyboard_notify_key(seat->seat, event->time_msec, event->keycode, event->state);
} }
wlr_idle_notify_activity(seat->server->idle, seat->seat); wlr_idle_notifier_v1_notify_activity(seat->server->idle, seat->seat);
} }
static void static void
@ -512,7 +512,7 @@ handle_touch_down(struct wl_listener *listener, void *data)
press_cursor_button(seat, &event->touch->base, event->time_msec, BTN_LEFT, WLR_BUTTON_PRESSED, lx, ly); press_cursor_button(seat, &event->touch->base, event->time_msec, BTN_LEFT, WLR_BUTTON_PRESSED, lx, ly);
} }
wlr_idle_notify_activity(seat->server->idle, seat->seat); wlr_idle_notifier_v1_notify_activity(seat->server->idle, seat->seat);
} }
static void static void
@ -531,7 +531,7 @@ handle_touch_up(struct wl_listener *listener, void *data)
} }
wlr_seat_touch_notify_up(seat->seat, event->time_msec, event->touch_id); wlr_seat_touch_notify_up(seat->seat, event->time_msec, event->touch_id);
wlr_idle_notify_activity(seat->server->idle, seat->seat); wlr_idle_notifier_v1_notify_activity(seat->server->idle, seat->seat);
} }
static void static void
@ -563,7 +563,7 @@ handle_touch_motion(struct wl_listener *listener, void *data)
seat->touch_ly = ly; seat->touch_ly = ly;
} }
wlr_idle_notify_activity(seat->server->idle, seat->seat); wlr_idle_notifier_v1_notify_activity(seat->server->idle, seat->seat);
} }
static void static void
@ -572,7 +572,7 @@ handle_touch_frame(struct wl_listener *listener, void *data)
struct cg_seat *seat = wl_container_of(listener, seat, touch_frame); struct cg_seat *seat = wl_container_of(listener, seat, touch_frame);
wlr_seat_touch_notify_frame(seat->seat); wlr_seat_touch_notify_frame(seat->seat);
wlr_idle_notify_activity(seat->server->idle, seat->seat); wlr_idle_notifier_v1_notify_activity(seat->server->idle, seat->seat);
} }
static void static void
@ -581,7 +581,7 @@ handle_cursor_frame(struct wl_listener *listener, void *data)
struct cg_seat *seat = wl_container_of(listener, seat, cursor_frame); struct cg_seat *seat = wl_container_of(listener, seat, cursor_frame);
wlr_seat_pointer_notify_frame(seat->seat); wlr_seat_pointer_notify_frame(seat->seat);
wlr_idle_notify_activity(seat->server->idle, seat->seat); wlr_idle_notifier_v1_notify_activity(seat->server->idle, seat->seat);
} }
static void static void
@ -592,7 +592,7 @@ handle_cursor_axis(struct wl_listener *listener, void *data)
wlr_seat_pointer_notify_axis(seat->seat, event->time_msec, event->orientation, event->delta, wlr_seat_pointer_notify_axis(seat->seat, event->time_msec, event->orientation, event->delta,
event->delta_discrete, event->source); event->delta_discrete, event->source);
wlr_idle_notify_activity(seat->server->idle, seat->seat); wlr_idle_notifier_v1_notify_activity(seat->server->idle, seat->seat);
} }
static void static void
@ -604,7 +604,7 @@ handle_cursor_button(struct wl_listener *listener, void *data)
wlr_seat_pointer_notify_button(seat->seat, event->time_msec, event->button, event->state); wlr_seat_pointer_notify_button(seat->seat, event->time_msec, event->button, event->state);
press_cursor_button(seat, &event->pointer->base, event->time_msec, event->button, event->state, seat->cursor->x, press_cursor_button(seat, &event->pointer->base, event->time_msec, event->button, event->state, seat->cursor->x,
seat->cursor->y); seat->cursor->y);
wlr_idle_notify_activity(seat->server->idle, seat->seat); wlr_idle_notifier_v1_notify_activity(seat->server->idle, seat->seat);
} }
static void static void
@ -634,7 +634,7 @@ process_cursor_motion(struct cg_seat *seat, uint32_t time_msec, double dx, doubl
drag_icon_update_position(drag_icon); drag_icon_update_position(drag_icon);
} }
wlr_idle_notify_activity(seat->server->idle, seat->seat); wlr_idle_notifier_v1_notify_activity(seat->server->idle, seat->seat);
} }
static void static void
@ -651,7 +651,7 @@ handle_cursor_motion_absolute(struct wl_listener *listener, void *data)
wlr_cursor_warp_absolute(seat->cursor, &event->pointer->base, event->x, event->y); wlr_cursor_warp_absolute(seat->cursor, &event->pointer->base, event->x, event->y);
process_cursor_motion(seat, event->time_msec, dx, dy, dx, dy); process_cursor_motion(seat, event->time_msec, dx, dy, dx, dy);
wlr_idle_notify_activity(seat->server->idle, seat->seat); wlr_idle_notifier_v1_notify_activity(seat->server->idle, seat->seat);
} }
static void static void
@ -663,7 +663,7 @@ handle_cursor_motion_relative(struct wl_listener *listener, void *data)
wlr_cursor_move(seat->cursor, &event->pointer->base, event->delta_x, event->delta_y); wlr_cursor_move(seat->cursor, &event->pointer->base, event->delta_x, event->delta_y);
process_cursor_motion(seat, event->time_msec, event->delta_x, event->delta_y, event->unaccel_dx, process_cursor_motion(seat, event->time_msec, event->delta_x, event->delta_y, event->unaccel_dx,
event->unaccel_dy); event->unaccel_dy);
wlr_idle_notify_activity(seat->server->idle, seat->seat); wlr_idle_notifier_v1_notify_activity(seat->server->idle, seat->seat);
} }
static void static void

View file

@ -4,8 +4,8 @@
#include "config.h" #include "config.h"
#include <wayland-server-core.h> #include <wayland-server-core.h>
#include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_idle_inhibit_v1.h> #include <wlr/types/wlr_idle_inhibit_v1.h>
#include <wlr/types/wlr_idle_notify_v1.h>
#include <wlr/types/wlr_output_layout.h> #include <wlr/types/wlr_output_layout.h>
#include <wlr/types/wlr_relative_pointer_v1.h> #include <wlr/types/wlr_relative_pointer_v1.h>
#include <wlr/types/wlr_xdg_decoration_v1.h> #include <wlr/types/wlr_xdg_decoration_v1.h>
@ -24,9 +24,10 @@ struct cg_server {
struct wlr_backend *backend; struct wlr_backend *backend;
struct wlr_renderer *renderer; struct wlr_renderer *renderer;
struct wlr_allocator *allocator; struct wlr_allocator *allocator;
struct wlr_session *session;
struct cg_seat *seat; struct cg_seat *seat;
struct wlr_idle *idle; struct wlr_idle_notifier_v1 *idle;
struct wlr_idle_inhibit_manager_v1 *idle_inhibit_v1; struct wlr_idle_inhibit_manager_v1 *idle_inhibit_v1;
struct wl_listener new_idle_inhibitor_v1; struct wl_listener new_idle_inhibitor_v1;
struct wl_list inhibitors; struct wl_list inhibitors;

View file

@ -46,11 +46,13 @@ static struct cg_view *
popup_get_view(struct wlr_xdg_popup *popup) popup_get_view(struct wlr_xdg_popup *popup)
{ {
while (true) { while (true) {
if (popup->parent == NULL || !wlr_surface_is_xdg_surface(popup->parent)) { if (popup->parent == NULL) {
return NULL;
}
struct wlr_xdg_surface *xdg_surface = wlr_xdg_surface_try_from_wlr_surface(popup->parent);
if (xdg_surface == NULL) {
return NULL; return NULL;
} }
struct wlr_xdg_surface *xdg_surface = wlr_xdg_surface_from_wlr_surface(popup->parent);
switch (xdg_surface->role) { switch (xdg_surface->role) {
case WLR_XDG_SURFACE_ROLE_TOPLEVEL: case WLR_XDG_SURFACE_ROLE_TOPLEVEL:
return xdg_surface->data; return xdg_surface->data;
@ -236,9 +238,9 @@ handle_xdg_shell_surface_new(struct wl_listener *listener, void *data)
xdg_shell_view->xdg_toplevel = xdg_surface->toplevel; xdg_shell_view->xdg_toplevel = xdg_surface->toplevel;
xdg_shell_view->map.notify = handle_xdg_shell_surface_map; xdg_shell_view->map.notify = handle_xdg_shell_surface_map;
wl_signal_add(&xdg_surface->events.map, &xdg_shell_view->map); wl_signal_add(&xdg_surface->surface->events.map, &xdg_shell_view->map);
xdg_shell_view->unmap.notify = handle_xdg_shell_surface_unmap; xdg_shell_view->unmap.notify = handle_xdg_shell_surface_unmap;
wl_signal_add(&xdg_surface->events.unmap, &xdg_shell_view->unmap); wl_signal_add(&xdg_surface->surface->events.unmap, &xdg_shell_view->unmap);
xdg_shell_view->destroy.notify = handle_xdg_shell_surface_destroy; xdg_shell_view->destroy.notify = handle_xdg_shell_surface_destroy;
wl_signal_add(&xdg_surface->events.destroy, &xdg_shell_view->destroy); wl_signal_add(&xdg_surface->events.destroy, &xdg_shell_view->destroy);
xdg_shell_view->request_fullscreen.notify = handle_xdg_shell_surface_request_fullscreen; xdg_shell_view->request_fullscreen.notify = handle_xdg_shell_surface_request_fullscreen;
@ -254,7 +256,10 @@ handle_xdg_shell_surface_new(struct wl_listener *listener, void *data)
} }
struct wlr_scene_tree *parent_scene_tree = NULL; struct wlr_scene_tree *parent_scene_tree = NULL;
struct wlr_xdg_surface *parent = wlr_xdg_surface_from_wlr_surface(popup->parent); struct wlr_xdg_surface *parent = wlr_xdg_surface_try_from_wlr_surface(popup->parent);
if (parent == NULL) {
return;
}
switch (parent->role) { switch (parent->role) {
case WLR_XDG_SURFACE_ROLE_TOPLEVEL:; case WLR_XDG_SURFACE_ROLE_TOPLEVEL:;
parent_scene_tree = view->scene_tree; parent_scene_tree = view->scene_tree;

View file

@ -167,9 +167,9 @@ handle_xwayland_surface_new(struct wl_listener *listener, void *data)
xwayland_view->xwayland_surface = xwayland_surface; xwayland_view->xwayland_surface = xwayland_surface;
xwayland_view->map.notify = handle_xwayland_surface_map; xwayland_view->map.notify = handle_xwayland_surface_map;
wl_signal_add(&xwayland_surface->events.map, &xwayland_view->map); wl_signal_add(&xwayland_surface->surface->events.map, &xwayland_view->map);
xwayland_view->unmap.notify = handle_xwayland_surface_unmap; xwayland_view->unmap.notify = handle_xwayland_surface_unmap;
wl_signal_add(&xwayland_surface->events.unmap, &xwayland_view->unmap); wl_signal_add(&xwayland_surface->surface->events.unmap, &xwayland_view->unmap);
xwayland_view->destroy.notify = handle_xwayland_surface_destroy; xwayland_view->destroy.notify = handle_xwayland_surface_destroy;
wl_signal_add(&xwayland_surface->events.destroy, &xwayland_view->destroy); wl_signal_add(&xwayland_surface->events.destroy, &xwayland_view->destroy);
xwayland_view->request_fullscreen.notify = handle_xwayland_surface_request_fullscreen; xwayland_view->request_fullscreen.notify = handle_xwayland_surface_request_fullscreen;