From 61e451ea1b36435341d02ae34548bd0ea3abdd57 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 24 Sep 2017 14:12:56 -0400 Subject: Move keyboard logic to wlr_{keyboard,seat} --- include/wlr/interfaces/wlr_keyboard.h | 2 ++ include/wlr/types/wlr_keyboard.h | 14 +++++++++++++- include/wlr/types/wlr_seat.h | 27 ++++++++++++++++++++++++++- 3 files changed, 41 insertions(+), 2 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/interfaces/wlr_keyboard.h b/include/wlr/interfaces/wlr_keyboard.h index 779b302f..ffa99b3b 100644 --- a/include/wlr/interfaces/wlr_keyboard.h +++ b/include/wlr/interfaces/wlr_keyboard.h @@ -10,5 +10,7 @@ struct wlr_keyboard_impl { void wlr_keyboard_init(struct wlr_keyboard *keyboard, struct wlr_keyboard_impl *impl); void wlr_keyboard_destroy(struct wlr_keyboard *keyboard); +void wlr_keyboard_update_state(struct wlr_keyboard *keyboard, + struct wlr_event_keyboard_key *event); #endif diff --git a/include/wlr/types/wlr_keyboard.h b/include/wlr/types/wlr_keyboard.h index ce7d6659..89e44f96 100644 --- a/include/wlr/types/wlr_keyboard.h +++ b/include/wlr/types/wlr_keyboard.h @@ -1,7 +1,8 @@ #ifndef _WLR_TYPES_KEYBOARD_H #define _WLR_TYPES_KEYBOARD_H -#include #include +#include +#include enum WLR_KEYBOARD_LED { WLR_LED_NUM_LOCK = 1, @@ -14,9 +15,17 @@ struct wlr_keyboard_impl; struct wlr_keyboard { struct wlr_keyboard_impl *impl; + // TODO: Should this store key repeat info too? + + int keymap_fd; + size_t keymap_size; + struct xkb_keymap *keymap; + struct xkb_state *xkb_state; + xkb_led_index_t leds[WLR_LED_LAST]; struct { struct wl_signal key; + struct wl_signal keymap; } events; void *data; @@ -36,4 +45,7 @@ struct wlr_event_keyboard_key { enum wlr_key_state state; }; +void wlr_keyboard_set_keymap(struct wlr_keyboard *kb, + struct xkb_keymap *keymap); + #endif diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index aa17d650..dfb1d398 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -2,6 +2,7 @@ #define _WLR_TYPES_SEAT_H #include #include +#include #include /** @@ -12,6 +13,7 @@ struct wlr_seat_handle { struct wl_resource *wl_resource; struct wlr_seat *wlr_seat; + struct wlr_seat_keyboard *seat_keyboard; struct wl_resource *pointer; struct wl_resource *keyboard; @@ -30,10 +32,20 @@ struct wlr_seat_pointer_state { struct wl_listener focus_resource_destroy_listener; }; +struct wlr_seat_keyboard { + struct wlr_seat *seat; + struct wlr_keyboard *keyboard; + struct wl_listener key; + struct wl_listener keymap; + struct wl_listener destroy; + struct wl_list link; +}; + struct wlr_seat { struct wl_global *wl_global; struct wl_display *display; struct wl_list handles; + struct wl_list keyboards; char *name; uint32_t capabilities; struct wlr_data_device *data_device; @@ -43,7 +55,6 @@ struct wlr_seat { struct { struct wl_signal client_bound; struct wl_signal client_unbound; - struct wl_signal keyboard_bound; } events; void *data; @@ -112,4 +123,18 @@ uint32_t wlr_seat_pointer_send_button(struct wlr_seat *wlr_seat, uint32_t time, void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time, enum wlr_axis_orientation orientation, double value); +/** + * Attaches this keyboard to the seat. Key events from this keyboard will be + * propegated to the focused client. + */ +void wlr_seat_attach_keyboard(struct wlr_seat *seat, + struct wlr_input_device *dev); + +/** + * Detaches this keyboard from the seat. This is done automatically when the + * keyboard is destroyed; you only need to use this if you want to remove it for + * some other reason. + */ +void wlr_seat_detach_keyboard(struct wlr_seat *seat, struct wlr_keyboard *kb); + #endif -- cgit v1.2.3 From e6a6634bc50bc65e5813a9ebc336869e6e85e816 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 25 Sep 2017 08:47:00 -0400 Subject: Minor tweaks to (broken) keyboard support --- examples/compositor.c | 5 +- include/wlr/types/wlr_seat.h | 7 +-- types/wlr_keyboard.c | 2 +- types/wlr_seat.c | 117 ++++++++++++------------------------------- 4 files changed, 35 insertions(+), 96 deletions(-) (limited to 'include/wlr') diff --git a/examples/compositor.c b/examples/compositor.c index 8c1f9b09..6f28b193 100644 --- a/examples/compositor.c +++ b/examples/compositor.c @@ -122,10 +122,7 @@ static void example_set_focused_surface(struct sample_state *sample, } if (surface) { - // TODO: send array of currently pressed keys - struct wl_array keys; - wl_array_init(&keys); - wlr_seat_keyboard_enter(sample->wl_seat, surface->surface, keys); + wlr_seat_keyboard_enter(sample->wl_seat, surface->surface); } else { wlr_seat_keyboard_clear_focus(sample->wl_seat); } diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 86fd36dd..6927cd16 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -29,8 +29,8 @@ struct wlr_seat_pointer_state { struct wlr_seat_handle *focused_handle; struct wlr_surface *focused_surface; - struct wl_listener focus_surface_destroy_listener; - struct wl_listener focus_resource_destroy_listener; + struct wl_listener surface_destroy; + struct wl_listener resource_destroy; }; struct wlr_seat_keyboard { @@ -47,9 +47,6 @@ struct wlr_seat_keyboard_state { struct wlr_seat_handle *focused_handle; struct wlr_surface *focused_surface; - int keymap_fd; - size_t keymap_size; - struct wl_listener surface_destroy; struct wl_listener resource_destroy; }; diff --git a/types/wlr_keyboard.c b/types/wlr_keyboard.c index 08b098d2..f9b26a36 100644 --- a/types/wlr_keyboard.c +++ b/types/wlr_keyboard.c @@ -66,7 +66,7 @@ void wlr_keyboard_set_keymap(struct wlr_keyboard *kb, } char *keymap_str = xkb_keymap_get_as_string(kb->keymap, XKB_KEYMAP_FORMAT_TEXT_V1); - kb->keymap_size = strlen(keymap_str); + kb->keymap_size = strlen(keymap_str) + 1; kb->keymap_fd = os_create_anonymous_file(kb->keymap_size); void *ptr = mmap(NULL, kb->keymap_size, PROT_READ | PROT_WRITE, MAP_SHARED, kb->keymap_fd, 0); diff --git a/types/wlr_seat.c b/types/wlr_seat.c index 8e24886b..4fbe56c2 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -171,14 +171,13 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) { } wlr_seat->pointer_state.wlr_seat = wlr_seat; - wl_list_init(&wlr_seat->pointer_state.focus_resource_destroy_listener.link); - wl_list_init(&wlr_seat->pointer_state.focus_surface_destroy_listener.link); + wl_list_init(&wlr_seat->pointer_state.surface_destroy.link); + wl_list_init(&wlr_seat->pointer_state.resource_destroy.link); wlr_seat->keyboard_state.wlr_seat = wlr_seat; + wl_list_init(&wlr_seat->keyboard_state.resource_destroy.link); wl_list_init( - &wlr_seat->keyboard_state.focus_resource_destroy_listener.link); - wl_list_init( - &wlr_seat->keyboard_state.focus_surface_destroy_listener.link); + &wlr_seat->keyboard_state.surface_destroy.link); struct wl_global *wl_global = wl_global_create(display, &wl_seat_interface, 6, wlr_seat, wl_seat_bind); @@ -250,20 +249,18 @@ bool wlr_seat_pointer_surface_has_focus(struct wlr_seat *wlr_seat, return surface == wlr_seat->pointer_state.focused_surface; } -static void handle_pointer_focus_surface_destroyed( - struct wl_listener *listener, void *data) { - struct wlr_seat_pointer_state *state = - wl_container_of(listener, state, focus_surface_destroy_listener); - +static void pointer_surface_destroy_notify(struct wl_listener *listener, + void *data) { + struct wlr_seat_pointer_state *state = wl_container_of( + listener, state, surface_destroy); state->focused_surface = NULL; wlr_seat_pointer_clear_focus(state->wlr_seat); } -static void handle_pointer_focus_resource_destroyed( - struct wl_listener *listener, void *data) { - struct wlr_seat_pointer_state *state = - wl_container_of(listener, state, focus_resource_destroy_listener); - +static void pointer_resource_destroy_notify(struct wl_listener *listener, + void *data) { + struct wlr_seat_pointer_state *state = wl_container_of( + listener, state, resource_destroy); state->focused_surface = NULL; wlr_seat_pointer_clear_focus(state->wlr_seat); } @@ -311,21 +308,19 @@ void wlr_seat_pointer_enter(struct wlr_seat *wlr_seat, } // reinitialize the focus destroy events - wl_list_remove( - &wlr_seat->pointer_state.focus_surface_destroy_listener.link); - wl_list_init(&wlr_seat->pointer_state.focus_surface_destroy_listener.link); - wl_list_remove( - &wlr_seat->pointer_state.focus_resource_destroy_listener.link); - wl_list_init(&wlr_seat->pointer_state.focus_resource_destroy_listener.link); + wl_list_remove(&wlr_seat->pointer_state.surface_destroy.link); + wl_list_init(&wlr_seat->pointer_state.surface_destroy.link); + wl_list_remove(&wlr_seat->pointer_state.resource_destroy.link); + wl_list_init(&wlr_seat->pointer_state.resource_destroy.link); if (surface) { wl_signal_add(&surface->signals.destroy, - &wlr_seat->pointer_state.focus_surface_destroy_listener); + &wlr_seat->pointer_state.surface_destroy); wl_resource_add_destroy_listener(surface->resource, - &wlr_seat->pointer_state.focus_resource_destroy_listener); - wlr_seat->pointer_state.focus_resource_destroy_listener.notify = - handle_pointer_focus_resource_destroyed; - wlr_seat->pointer_state.focus_surface_destroy_listener.notify = - handle_pointer_focus_surface_destroyed; + &wlr_seat->pointer_state.resource_destroy); + wlr_seat->pointer_state.resource_destroy.notify = + pointer_resource_destroy_notify; + wlr_seat->pointer_state.surface_destroy.notify = + pointer_surface_destroy_notify; } wlr_seat->pointer_state.focused_handle = handle; @@ -385,7 +380,7 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) { struct wlr_seat_keyboard *seat_kb = wl_container_of( listener, seat_kb, key); struct wlr_seat *seat = seat_kb->seat; - struct wlr_seat_handle *handle = seat->pointer_state.focused_handle; + struct wlr_seat_handle *handle = seat->keyboard_state.focused_handle; if (!handle || !handle->keyboard) { return; } @@ -395,7 +390,8 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) { if (handle->seat_keyboard != seat_kb) { // TODO: We should probably lift all of the keys set by the other // keyboard - wlr_log(L_DEBUG, "Sending key map"); + wlr_log(L_DEBUG, "Sending key map %d %zd", + seat_kb->keyboard->keymap_fd, seat_kb->keyboard->keymap_size); wl_keyboard_send_keymap(handle->keyboard, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, seat_kb->keyboard->keymap_fd, @@ -451,6 +447,7 @@ void wlr_seat_attach_keyboard(struct wlr_seat *seat, wl_list_init(&seat_kb->keymap.link); seat_kb->keymap.notify = keyboard_keymap_notify; wl_signal_add(&kb->events.keymap, &seat_kb->keymap); + // TODO: update keymap as necessary wl_list_init(&seat_kb->destroy.link); seat_kb->destroy.notify = keyboard_destroy_notify; wl_signal_add(&dev->events.destroy, &seat_kb->destroy); @@ -524,13 +521,10 @@ void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat, } // reinitialize the focus destroy events - wl_list_remove( - &wlr_seat->keyboard_state.focus_surface_destroy_listener.link); - wl_list_init(&wlr_seat->keyboard_state.focus_surface_destroy_listener.link); - wl_list_remove( - &wlr_seat->keyboard_state.focus_resource_destroy_listener.link); - wl_list_init( - &wlr_seat->keyboard_state.focus_resource_destroy_listener.link); + wl_list_remove(&wlr_seat->keyboard_state.surface_destroy.link); + wl_list_init(&wlr_seat->keyboard_state.surface_destroy.link); + wl_list_remove(&wlr_seat->keyboard_state.resource_destroy.link); + wl_list_init(&wlr_seat->keyboard_state.resource_destroy.link); if (surface) { wl_signal_add(&surface->signals.destroy, &wlr_seat->keyboard_state.surface_destroy); @@ -549,54 +543,5 @@ void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat, void wlr_seat_keyboard_clear_focus(struct wlr_seat *wlr_seat) { struct wl_array keys; wl_array_init(&keys); - wlr_seat_keyboard_enter(wlr_seat, NULL, keys); -} - -static bool wlr_seat_keyboard_has_focus_resource(struct wlr_seat *wlr_seat) { - return wlr_seat->keyboard_state.focused_handle && - wlr_seat->keyboard_state.focused_handle->keyboard; -} - -/* -void wlr_seat_keyboard_send_modifiers(struct wlr_seat *wlr_seat, - uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, - uint32_t group) { - uint32_t serial = 0; - struct wl_resource *keyboard; - - if (wlr_seat_keyboard_has_focus_resource(wlr_seat)) { - serial = wl_display_next_serial(wlr_seat->display); - keyboard = wlr_seat->keyboard_state.focused_handle->keyboard; - wl_keyboard_send_modifiers(keyboard, serial, mods_depressed, - mods_latched, mods_locked, group); - } - - if (wlr_seat_pointer_has_focus_resource(wlr_seat) && - wlr_seat->pointer_state.focused_handle->keyboard && - wlr_seat->pointer_state.focused_handle != - wlr_seat->keyboard_state.focused_handle) { - if (serial == 0) { - serial = wl_display_next_serial(wlr_seat->display); - } - keyboard = wlr_seat->pointer_state.focused_handle->keyboard; - - wl_keyboard_send_modifiers(keyboard, serial, mods_depressed, - mods_latched, mods_locked, group); - } -} - -void wlr_seat_keyboard_set_keymap(struct wlr_seat *wlr_seat, int keymap_fd, - size_t keymap_size) { - // TODO: we probably should wait to send the keymap if keys are pressed - struct wlr_seat_handle *handle; - wl_list_for_each(handle, &wlr_seat->handles, link) { - if (handle->keyboard) { - wl_keyboard_send_keymap(handle->keyboard, - WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, keymap_fd, keymap_size); - } - } - - wlr_seat->keyboard_state.keymap_fd = keymap_fd; - wlr_seat->keyboard_state.keymap_size = keymap_size; + wlr_seat_keyboard_enter(wlr_seat, NULL); } -*/ -- cgit v1.2.3 From ed9a43c2134f19ddaa4d8e7c9f680d8a3d8329a6 Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 26 Sep 2017 23:59:25 +0200 Subject: Add first try to add wl_shell to rootston --- include/rootston/desktop.h | 2 ++ include/wlr/types/wlr_wl_shell.h | 17 ++++++++++++- rootston/desktop.c | 6 ++++- rootston/meson.build | 3 ++- rootston/wl_shell.c | 20 ++++++++++++++++ types/wlr_wl_shell.c | 52 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 rootston/wl_shell.c (limited to 'include/wlr') diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h index 62050972..ef361d87 100644 --- a/include/rootston/desktop.h +++ b/include/rootston/desktop.h @@ -39,6 +39,7 @@ struct roots_desktop { struct wl_listener output_add; struct wl_listener output_remove; struct wl_listener xdg_shell_v6_surface; + struct wl_listener wl_shell_surface; }; struct roots_server; @@ -55,5 +56,6 @@ void output_add_notify(struct wl_listener *listener, void *data); void output_remove_notify(struct wl_listener *listener, void *data); void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data); +void handle_wl_shell_surface(struct wl_listener *listener, void *data); #endif diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h index 1443bbf0..614d785b 100644 --- a/include/wlr/types/wlr_wl_shell.h +++ b/include/wlr/types/wlr_wl_shell.h @@ -7,20 +7,35 @@ struct wlr_wl_shell { struct wl_global *wl_global; struct wl_list wl_resources; struct wl_list surfaces; + uint32_t ping_timeout; + + struct { + struct wl_signal new_surface; + } events; void *data; }; struct wlr_wl_shell_surface { + struct wlr_wl_shell *shell; + struct wl_client *client; struct wl_resource *surface; struct wlr_texture *wlr_texture; struct wl_list link; + uint32_t ping_serial; + struct wl_event_source *ping_timer; + + struct { + struct wl_signal ping_timeout; + } events; + void *data; }; - struct wlr_wl_shell *wlr_wl_shell_create(struct wl_display *display); void wlr_wl_shell_destroy(struct wlr_wl_shell *wlr_wl_shell); +void wlr_wl_shell_surface_ping(struct wlr_wl_shell_surface *surface); + #endif diff --git a/rootston/desktop.c b/rootston/desktop.c index f0495fa1..f9af3b8e 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -67,7 +67,6 @@ struct roots_desktop *desktop_create(struct roots_server *server, desktop->layout = wlr_output_layout_create(); desktop->compositor = wlr_compositor_create( server->wl_display, server->renderer); - desktop->wl_shell = wlr_wl_shell_create(server->wl_display); wlr_cursor_attach_output_layout(server->input->cursor, desktop->layout); wlr_cursor_map_to_region(server->input->cursor, config->cursor.mapped_box); @@ -79,6 +78,11 @@ struct roots_desktop *desktop_create(struct roots_server *server, &desktop->xdg_shell_v6_surface); desktop->xdg_shell_v6_surface.notify = handle_xdg_shell_v6_surface; + desktop->wl_shell = wlr_wl_shell_create(server->wl_display); + wl_signal_add(&desktop->wl_shell->events.new_surface, + &desktop->wl_shell_surface); + desktop->wl_shell_surface.notify = handle_wl_shell_surface; + desktop->gamma_control_manager = wlr_gamma_control_manager_create( server->wl_display); diff --git a/rootston/meson.build b/rootston/meson.build index 30ae1548..de2d04de 100644 --- a/rootston/meson.build +++ b/rootston/meson.build @@ -9,6 +9,7 @@ executable( 'main.c', 'output.c', 'pointer.c', - 'xdg_shell_v6.c' + 'xdg_shell_v6.c', + 'wl_shell.c' ], dependencies: wlroots ) diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c new file mode 100644 index 00000000..0dcc0565 --- /dev/null +++ b/rootston/wl_shell.c @@ -0,0 +1,20 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include "rootston/desktop.h" +#include "rootston/server.h" +#include "rootston/input.h" + +void handle_wl_shell_surface(struct wl_listener *listener, void *data) { + struct roots_desktop *desktop = + wl_container_of(listener, desktop, wl_shell_surface); + + struct wlr_wl_shell_surface *surface = data; + wlr_log(L_DEBUG, "new wl_shell surface"); + wlr_wl_shell_surface_ping(surface); +} diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index 84b40fc3..745299bf 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -3,10 +3,19 @@ #include #include #include +#include static void shell_surface_pong(struct wl_client *client, struct wl_resource *resource, uint32_t serial) { wlr_log(L_DEBUG, "TODO: implement shell surface pong"); + struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); + + if (surface->ping_serial != serial) { + return; + } + + wl_event_source_timer_update(surface->ping_timer, 0); + surface->ping_serial = 0; } static void shell_surface_move(struct wl_client *client, struct wl_resource @@ -77,6 +86,14 @@ static void destroy_shell_surface(struct wl_resource *resource) { free(state); } +static int wlr_wl_shell_surface_ping_timeout(void *user_data) { + struct wlr_wl_shell_surface *surface = user_data; + wl_signal_emit(&surface->events.ping_timeout, surface); + + surface->ping_serial = 0; + return 1; +} + static void wl_shell_get_shell_surface(struct wl_client *client, struct wl_resource *resource, uint32_t id, struct wl_resource *surface) { @@ -84,14 +101,33 @@ static void wl_shell_get_shell_surface(struct wl_client *client, struct wlr_wl_shell *wlr_wl_shell = wl_resource_get_user_data(resource); struct wlr_wl_shell_surface *state = calloc(1, sizeof(struct wlr_wl_shell_surface)); + if (state == NULL) { + wl_client_post_no_memory(client); + return; + } + + state->shell = wlr_wl_shell; + state->client = client; state->wlr_texture = wlr_texture; state->surface = surface; + struct wl_resource *shell_surface_resource = wl_resource_create(client, &wl_shell_surface_interface, wl_resource_get_version(resource), id); wlr_log(L_DEBUG, "New wl_shell %p (res %p)", state, shell_surface_resource); wl_resource_set_implementation(shell_surface_resource, &shell_surface_interface, state, destroy_shell_surface); wl_list_insert(&wlr_wl_shell->surfaces, &state->link); + wl_signal_emit(&wlr_wl_shell->events.new_surface, state); + + wl_signal_init(&state->events.ping_timeout); + + struct wl_display *display = wl_client_get_display(client); + struct wl_event_loop *loop = wl_display_get_event_loop(display); + state->ping_timer = wl_event_loop_add_timer(loop, + wlr_wl_shell_surface_ping_timeout, state); + if (state->ping_timer == NULL) { + wl_client_post_no_memory(client); + } } static struct wl_shell_interface wl_shell_impl = { @@ -124,6 +160,7 @@ struct wlr_wl_shell *wlr_wl_shell_create(struct wl_display *display) { if (!wlr_wl_shell) { return NULL; } + wlr_wl_shell->ping_timeout = 10000; struct wl_global *wl_global = wl_global_create(display, &wl_shell_interface, 1, wlr_wl_shell, wl_shell_bind); if (!wl_global) { @@ -133,6 +170,7 @@ struct wlr_wl_shell *wlr_wl_shell_create(struct wl_display *display) { wlr_wl_shell->wl_global = wl_global; wl_list_init(&wlr_wl_shell->wl_resources); wl_list_init(&wlr_wl_shell->surfaces); + wl_signal_init(&wlr_wl_shell->events.new_surface); return wlr_wl_shell; } @@ -150,3 +188,17 @@ void wlr_wl_shell_destroy(struct wlr_wl_shell *wlr_wl_shell) { // wl_global_destroy(wlr_wl_shell->wl_global); free(wlr_wl_shell); } + +void wlr_wl_shell_surface_ping(struct wlr_wl_shell_surface *surface) { + if (surface->ping_serial != 0) { + // already pinged + return; + } + + surface->ping_serial = + wl_display_next_serial(wl_client_get_display(surface->client)); + wl_event_source_timer_update(surface->ping_timer, + surface->shell->ping_timeout); + wl_shell_surface_send_ping(surface->surface, + surface->ping_serial); +} -- cgit v1.2.3 From e001e400221115b0fe41fb48df48e85a2ec4f6ba Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 27 Sep 2017 15:03:35 +0200 Subject: Set view->surface --- examples/compositor.c | 2 +- include/wlr/types/wlr_wl_shell.h | 4 ++-- rootston/wl_shell.c | 2 +- types/wlr_wl_shell.c | 16 ++++++++-------- 4 files changed, 12 insertions(+), 12 deletions(-) (limited to 'include/wlr') diff --git a/examples/compositor.c b/examples/compositor.c index 6f28b193..14831820 100644 --- a/examples/compositor.c +++ b/examples/compositor.c @@ -290,7 +290,7 @@ static void handle_output_frame(struct output_state *output, struct wlr_wl_shell_surface *wl_shell_surface; wl_list_for_each(wl_shell_surface, &sample->wl_shell->surfaces, link) { output_frame_handle_surface(sample, wlr_output, ts, - wl_shell_surface->surface, 200, 200); + wl_shell_surface->resource, 200, 200); } struct wlr_xdg_surface_v6 *xdg_surface; struct wlr_xdg_client_v6 *xdg_client; diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h index 614d785b..d5b8a982 100644 --- a/include/wlr/types/wlr_wl_shell.h +++ b/include/wlr/types/wlr_wl_shell.h @@ -19,8 +19,8 @@ struct wlr_wl_shell { struct wlr_wl_shell_surface { struct wlr_wl_shell *shell; struct wl_client *client; - struct wl_resource *surface; - struct wlr_texture *wlr_texture; + struct wl_resource *resource; + struct wlr_surface *surface; struct wl_list link; uint32_t ping_serial; diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c index 0929a999..67c8f609 100644 --- a/rootston/wl_shell.c +++ b/rootston/wl_shell.c @@ -27,7 +27,7 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { view->x = view->y = 200; view->wl_shell_surface = surface; view->roots_wl_shell_surface = roots_surface; - //view->wlr_surface = surface->surface; + view->wlr_surface = surface->surface; //view->get_input_bounds = get_input_bounds; //view->activate = activate; view->desktop = desktop; diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index 42a906c9..b2a4dc28 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -96,9 +96,9 @@ static int wlr_wl_shell_surface_ping_timeout(void *user_data) { static void wl_shell_get_shell_surface(struct wl_client *client, struct wl_resource *resource, uint32_t id, - struct wl_resource *surface) { - struct wlr_texture *wlr_texture = wl_resource_get_user_data(surface); - struct wlr_wl_shell *wlr_wl_shell = wl_resource_get_user_data(resource); + struct wl_resource *surface_resource) { + struct wlr_surface *surface = wl_resource_get_user_data(surface_resource); + struct wlr_wl_shell *wl_shell = wl_resource_get_user_data(resource); struct wlr_wl_shell_surface *state = calloc(1, sizeof(struct wlr_wl_shell_surface)); if (state == NULL) { @@ -106,9 +106,9 @@ static void wl_shell_get_shell_surface(struct wl_client *client, return; } - state->shell = wlr_wl_shell; + state->shell = wl_shell; state->client = client; - state->wlr_texture = wlr_texture; + state->resource = surface_resource; state->surface = surface; struct wl_resource *shell_surface_resource = wl_resource_create(client, @@ -127,8 +127,8 @@ static void wl_shell_get_shell_surface(struct wl_client *client, wl_client_post_no_memory(client); } - wl_list_insert(&wlr_wl_shell->surfaces, &state->link); - wl_signal_emit(&wlr_wl_shell->events.new_surface, state); + wl_list_insert(&wl_shell->surfaces, &state->link); + wl_signal_emit(&wl_shell->events.new_surface, state); } static struct wl_shell_interface wl_shell_impl = { @@ -200,5 +200,5 @@ void wlr_wl_shell_surface_ping(struct wlr_wl_shell_surface *surface) { wl_display_next_serial(wl_client_get_display(surface->client)); wl_event_source_timer_update(surface->ping_timer, surface->shell->ping_timeout); - wl_shell_surface_send_ping(surface->surface, surface->ping_serial); + wl_shell_surface_send_ping(surface->resource, surface->ping_serial); } -- cgit v1.2.3 From 663bfe4cd8a8c2c9f0de285c8112b108e9a61bae Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 27 Sep 2017 21:15:31 +0200 Subject: wlr_wl_shell: implement all requests except set_popup --- include/rootston/view.h | 5 +- include/wlr/types/wlr_wl_shell.h | 52 +++++++++ rootston/wl_shell.c | 17 ++- types/wlr_wl_shell.c | 228 ++++++++++++++++++++++++++++++++------- 4 files changed, 262 insertions(+), 40 deletions(-) (limited to 'include/wlr') diff --git a/include/rootston/view.h b/include/rootston/view.h index eee61563..67ca9b62 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -7,7 +7,10 @@ struct roots_wl_shell_surface { struct roots_view *view; - // TODO + // TODO: Maybe destroy listener should go in roots_view + struct wl_listener destroy; + struct wl_listener ping_timeout; + // TODO: other stuff }; struct roots_xdg_surface_v6 { diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h index d5b8a982..612e5811 100644 --- a/include/wlr/types/wlr_wl_shell.h +++ b/include/wlr/types/wlr_wl_shell.h @@ -16,6 +16,13 @@ struct wlr_wl_shell { void *data; }; +struct wlr_wl_shell_surface_transient_state { + struct wlr_wl_shell_surface *parent; + int32_t x; + int32_t y; + uint32_t flags; +}; + struct wlr_wl_shell_surface { struct wlr_wl_shell *shell; struct wl_client *client; @@ -26,13 +33,58 @@ struct wlr_wl_shell_surface { uint32_t ping_serial; struct wl_event_source *ping_timer; + bool toplevel; + struct wlr_wl_shell_surface_transient_state *transient_state; + char *title; + char *class_; + struct { + struct wl_signal destroy; struct wl_signal ping_timeout; + + struct wl_signal request_move; + struct wl_signal request_resize; + struct wl_signal request_set_fullscreen; + struct wl_signal request_set_popup; + struct wl_signal request_set_maximized; + struct wl_signal set_toplevel; + struct wl_signal set_transient; + struct wl_signal set_title; + struct wl_signal set_class; } events; void *data; }; +struct wlr_wl_shell_surface_move_event { + struct wl_client *client; + struct wlr_wl_shell_surface *surface; + struct wlr_seat_handle *seat_handle; + uint32_t serial; +}; + +struct wlr_wl_shell_surface_resize_event { + struct wl_client *client; + struct wlr_wl_shell_surface *surface; + struct wlr_seat_handle *seat_handle; + uint32_t serial; + uint32_t edges; +}; + +struct wlr_wl_shell_surface_set_fullscreen_event { + struct wl_client *client; + struct wlr_wl_shell_surface *surface; + uint32_t method; + uint32_t framerate; + struct wlr_output *output; +}; + +struct wlr_wl_shell_surface_set_maximized_event { + struct wl_client *client; + struct wlr_wl_shell_surface *surface; + struct wlr_output *output; +}; + struct wlr_wl_shell *wlr_wl_shell_create(struct wl_display *display); void wlr_wl_shell_destroy(struct wlr_wl_shell *wlr_wl_shell); diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c index 67c8f609..fffd9fc9 100644 --- a/rootston/wl_shell.c +++ b/rootston/wl_shell.c @@ -10,17 +10,30 @@ #include "rootston/server.h" #include "rootston/input.h" +static void handle_destroy(struct wl_listener *listener, void *data) { + struct roots_wl_shell_surface *roots_surface = + wl_container_of(listener, roots_surface, destroy); + wl_list_remove(&roots_surface->destroy.link); + wl_list_remove(&roots_surface->ping_timeout.link); + view_destroy(roots_surface->view); + free(roots_surface); +} + void handle_wl_shell_surface(struct wl_listener *listener, void *data) { struct roots_desktop *desktop = wl_container_of(listener, desktop, wl_shell_surface); struct wlr_wl_shell_surface *surface = data; - wlr_log(L_DEBUG, "new wl_shell surface"); - //wlr_wl_shell_surface_ping(surface); + wlr_log(L_DEBUG, "new shell surface: title=%s, class=%s", + surface->title, surface->class_); + //wlr_wl_shell_surface_ping(surface); // TODO: segfaults struct roots_wl_shell_surface *roots_surface = calloc(1, sizeof(struct roots_wl_shell_surface)); // TODO: all of the trimmings + wl_list_init(&roots_surface->destroy.link); + roots_surface->destroy.notify = handle_destroy; + wl_list_init(&roots_surface->ping_timeout.link); struct roots_view *view = calloc(1, sizeof(struct roots_view)); view->type = ROOTS_WL_SHELL_VIEW; diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index b2a4dc28..972131ae 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -1,3 +1,6 @@ +#ifndef _POSIX_C_SOURCE +#define _POSIX_C_SOURCE 200809L +#endif #include #include #include @@ -5,11 +8,10 @@ #include #include -static void shell_surface_pong(struct wl_client *client, struct wl_resource - *resource, uint32_t serial) { - wlr_log(L_DEBUG, "TODO: implement shell surface pong"); +static void shell_surface_pong(struct wl_client *client, + struct wl_resource *resource, uint32_t serial) { + wlr_log(L_DEBUG, "got shell surface pong"); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); - if (surface->ping_serial != serial) { return; } @@ -18,32 +20,128 @@ static void shell_surface_pong(struct wl_client *client, struct wl_resource surface->ping_serial = 0; } -static void shell_surface_move(struct wl_client *client, struct wl_resource - *resource, struct wl_resource *seat, uint32_t serial) { - wlr_log(L_DEBUG, "TODO: implement shell surface move"); +static void shell_surface_move(struct wl_client *client, + struct wl_resource *resource, struct wl_resource *seat_resource, + uint32_t serial) { + wlr_log(L_DEBUG, "got shell surface move"); + struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); + struct wlr_seat_handle *seat_handle = + wl_resource_get_user_data(seat_resource); + + struct wlr_wl_shell_surface_move_event *event = + calloc(1, sizeof(struct wlr_wl_shell_surface_move_event)); + if (event == NULL) { + wl_client_post_no_memory(client); + return; + } + + event->client = client; + event->surface = surface; + event->seat_handle = seat_handle; + event->serial = serial; + + wl_signal_emit(&surface->events.request_move, event); + + free(event); } static void shell_surface_resize(struct wl_client *client, - struct wl_resource *resource, struct wl_resource *seat, uint32_t serial, - uint32_t edges) { - wlr_log(L_DEBUG, "TODO: implement shell surface resize"); + struct wl_resource *resource, struct wl_resource *seat_resource, + uint32_t serial, uint32_t edges) { + wlr_log(L_DEBUG, "got shell surface resize"); + struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); + struct wlr_seat_handle *seat_handle = + wl_resource_get_user_data(seat_resource); + + struct wlr_wl_shell_surface_resize_event *event = + calloc(1, sizeof(struct wlr_wl_shell_surface_resize_event)); + if (event == NULL) { + wl_client_post_no_memory(client); + return; + } + + event->client = client; + event->surface = surface; + event->seat_handle = seat_handle; + event->serial = serial; + event->edges = edges; + + wl_signal_emit(&surface->events.request_resize, event); + + free(event); } static void shell_surface_set_toplevel(struct wl_client *client, struct wl_resource *resource) { - wlr_log(L_DEBUG, "TODO: implement shell surface set_toplevel"); + wlr_log(L_DEBUG, "got shell surface toplevel"); + struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); + + if (surface->transient_state != NULL) { + return; + } + + surface->toplevel = true; + + wl_signal_emit(&surface->events.set_toplevel, surface); } static void shell_surface_set_transient(struct wl_client *client, - struct wl_resource *resource, struct wl_resource *parent, int32_t x, - int32_t y, uint32_t flags) { - wlr_log(L_DEBUG, "TODO: implement shell surface set_transient"); + struct wl_resource *resource, struct wl_resource *parent_resource, + int32_t x, int32_t y, uint32_t flags) { + wlr_log(L_DEBUG, "got shell surface transient"); + struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); + struct wlr_wl_shell_surface *parent = + wl_resource_get_user_data(parent_resource); + + if (surface->toplevel) { + return; + } + + struct wlr_wl_shell_surface_transient_state *state = + calloc(1, sizeof(struct wlr_wl_shell_surface_transient_state)); + if (state == NULL) { + wl_client_post_no_memory(client); + return; + } + + state->parent = parent; + state->x = x; + state->y = y; + state->flags = flags; + + free(surface->transient_state); + surface->transient_state = state; + + wl_signal_emit(&surface->events.set_transient, surface); } static void shell_surface_set_fullscreen(struct wl_client *client, struct wl_resource *resource, uint32_t method, uint32_t framerate, - struct wl_resource *output) { - wlr_log(L_DEBUG, "TODO: implement shell surface set_fullscreen"); + struct wl_resource *output_resource) { + wlr_log(L_DEBUG, "got shell surface fullscreen"); + struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); + struct wlr_output *output = wl_resource_get_user_data(output_resource); + + if (surface->toplevel) { + return; + } + + struct wlr_wl_shell_surface_set_fullscreen_event *event = + calloc(1, sizeof(struct wlr_wl_shell_surface_set_fullscreen_event)); + if (event == NULL) { + wl_client_post_no_memory(client); + return; + } + + event->client = client; + event->surface = surface; + event->method = method; + event->framerate = framerate; + event->output = output; + + wl_signal_emit(&surface->events.request_set_fullscreen, event); + + free(event); } static void shell_surface_set_popup(struct wl_client *client, @@ -53,18 +151,61 @@ static void shell_surface_set_popup(struct wl_client *client, } static void shell_surface_set_maximized(struct wl_client *client, - struct wl_resource *resource, struct wl_resource *output) { - wlr_log(L_DEBUG, "TODO: implement shell surface set_maximized"); + struct wl_resource *resource, struct wl_resource *output_resource) { + wlr_log(L_DEBUG, "got shell surface maximized"); + struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); + struct wlr_output *output = wl_resource_get_user_data(output_resource); + + if (surface->toplevel) { + return; + } + + struct wlr_wl_shell_surface_set_maximized_event *event = + calloc(1, sizeof(struct wlr_wl_shell_surface_set_maximized_event)); + if (event == NULL) { + wl_client_post_no_memory(client); + return; + } + + event->client = client; + event->surface = surface; + event->output = output; + + wl_signal_emit(&surface->events.request_set_maximized, event); + + free(event); } static void shell_surface_set_title(struct wl_client *client, struct wl_resource *resource, const char *title) { - wlr_log(L_DEBUG, "TODO: implement shell surface set_title"); + wlr_log(L_DEBUG, "new shell surface title: %s", title); + struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); + + char *tmp = strdup(title); + if (tmp == NULL) { + return; + } + + free(surface->title); + surface->title = tmp; + + wl_signal_emit(&surface->events.set_title, surface); } static void shell_surface_set_class(struct wl_client *client, struct wl_resource *resource, const char *class_) { - wlr_log(L_DEBUG, "TODO: implement shell surface set_class"); + wlr_log(L_DEBUG, "new shell surface class: %s", class_); + struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); + + char *tmp = strdup(class_); + if (tmp == NULL) { + return; + } + + free(surface->class_); + surface->class_ = tmp; + + wl_signal_emit(&surface->events.set_class, surface); } struct wl_shell_surface_interface shell_surface_interface = { @@ -81,9 +222,12 @@ struct wl_shell_surface_interface shell_surface_interface = { }; static void destroy_shell_surface(struct wl_resource *resource) { - struct wlr_wl_shell_surface *state = wl_resource_get_user_data(resource); - wl_list_remove(&state->link); - free(state); + struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); + wl_signal_emit(&surface->events.destroy, surface); + wl_list_remove(&surface->link); + free(surface->title); + free(surface->class_); + free(surface); } static int wlr_wl_shell_surface_ping_timeout(void *user_data) { @@ -99,36 +243,46 @@ static void wl_shell_get_shell_surface(struct wl_client *client, struct wl_resource *surface_resource) { struct wlr_surface *surface = wl_resource_get_user_data(surface_resource); struct wlr_wl_shell *wl_shell = wl_resource_get_user_data(resource); - struct wlr_wl_shell_surface *state = + struct wlr_wl_shell_surface *wl_surface = calloc(1, sizeof(struct wlr_wl_shell_surface)); - if (state == NULL) { + if (wl_surface == NULL) { wl_client_post_no_memory(client); return; } - state->shell = wl_shell; - state->client = client; - state->resource = surface_resource; - state->surface = surface; + wl_surface->shell = wl_shell; + wl_surface->client = client; + wl_surface->resource = surface_resource; + wl_surface->surface = surface; struct wl_resource *shell_surface_resource = wl_resource_create(client, &wl_shell_surface_interface, wl_resource_get_version(resource), id); - wlr_log(L_DEBUG, "New wl_shell %p (res %p)", state, shell_surface_resource); + wlr_log(L_DEBUG, "New wl_shell %p (res %p)", wl_surface, shell_surface_resource); wl_resource_set_implementation(shell_surface_resource, - &shell_surface_interface, state, destroy_shell_surface); + &shell_surface_interface, wl_surface, destroy_shell_surface); - wl_signal_init(&state->events.ping_timeout); + wl_signal_init(&wl_surface->events.destroy); + wl_signal_init(&wl_surface->events.ping_timeout); + wl_signal_init(&wl_surface->events.request_move); + wl_signal_init(&wl_surface->events.request_resize); + wl_signal_init(&wl_surface->events.request_set_fullscreen); + wl_signal_init(&wl_surface->events.request_set_popup); + wl_signal_init(&wl_surface->events.request_set_maximized); + wl_signal_init(&wl_surface->events.set_toplevel); + wl_signal_init(&wl_surface->events.set_transient); + wl_signal_init(&wl_surface->events.set_title); + wl_signal_init(&wl_surface->events.set_class); struct wl_display *display = wl_client_get_display(client); struct wl_event_loop *loop = wl_display_get_event_loop(display); - state->ping_timer = wl_event_loop_add_timer(loop, - wlr_wl_shell_surface_ping_timeout, state); - if (state->ping_timer == NULL) { + wl_surface->ping_timer = wl_event_loop_add_timer(loop, + wlr_wl_shell_surface_ping_timeout, wl_surface); + if (wl_surface->ping_timer == NULL) { wl_client_post_no_memory(client); } - wl_list_insert(&wl_shell->surfaces, &state->link); - wl_signal_emit(&wl_shell->events.new_surface, state); + wl_list_insert(&wl_shell->surfaces, &wl_surface->link); + wl_signal_emit(&wl_shell->events.new_surface, wl_surface); } static struct wl_shell_interface wl_shell_impl = { -- cgit v1.2.3 From 14ab56b6c5a782653c0d9d421196926ed534eab1 Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 27 Sep 2017 23:10:33 +0200 Subject: wl_shell: implement set_popup request --- include/wlr/types/wlr_wl_shell.h | 22 +++++++++-- types/wlr_wl_shell.c | 80 ++++++++++++++++++++++++++++++++-------- 2 files changed, 83 insertions(+), 19 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h index 612e5811..92c35d7d 100644 --- a/include/wlr/types/wlr_wl_shell.h +++ b/include/wlr/types/wlr_wl_shell.h @@ -1,6 +1,7 @@ #ifndef WLR_TYPES_WLR_WL_SHELL_H #define WLR_TYPES_WLR_WL_SHELL_H +#include #include struct wlr_wl_shell { @@ -23,6 +24,18 @@ struct wlr_wl_shell_surface_transient_state { uint32_t flags; }; +struct wlr_wl_shell_surface_popup_state { + struct wlr_seat_handle *seat_handle; + uint32_t serial; +}; + +enum wlr_wl_shell_surface_role { + WLR_WL_SHELL_SURFACE_ROLE_NONE, + WLR_WL_SHELL_SURFACE_ROLE_TOPLEVEL, + WLR_WL_SHELL_SURFACE_ROLE_TRANSCIENT, + WLR_WL_SHELL_SURFACE_ROLE_POPUP, +}; + struct wlr_wl_shell_surface { struct wlr_wl_shell *shell; struct wl_client *client; @@ -33,8 +46,10 @@ struct wlr_wl_shell_surface { uint32_t ping_serial; struct wl_event_source *ping_timer; - bool toplevel; + enum wlr_wl_shell_surface_role role; struct wlr_wl_shell_surface_transient_state *transient_state; + struct wlr_wl_shell_surface_popup_state *popup_state; + char *title; char *class_; @@ -45,10 +60,9 @@ struct wlr_wl_shell_surface { struct wl_signal request_move; struct wl_signal request_resize; struct wl_signal request_set_fullscreen; - struct wl_signal request_set_popup; struct wl_signal request_set_maximized; - struct wl_signal set_toplevel; - struct wl_signal set_transient; + + struct wl_signal set_role; struct wl_signal set_title; struct wl_signal set_class; } events; diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index 972131ae..4c3aaefc 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -76,13 +76,13 @@ static void shell_surface_set_toplevel(struct wl_client *client, wlr_log(L_DEBUG, "got shell surface toplevel"); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); - if (surface->transient_state != NULL) { + if (surface->role != WLR_WL_SHELL_SURFACE_ROLE_NONE) { return; } - surface->toplevel = true; + surface->role = WLR_WL_SHELL_SURFACE_ROLE_TOPLEVEL; - wl_signal_emit(&surface->events.set_toplevel, surface); + wl_signal_emit(&surface->events.set_role, surface); } static void shell_surface_set_transient(struct wl_client *client, @@ -92,8 +92,9 @@ static void shell_surface_set_transient(struct wl_client *client, struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); struct wlr_wl_shell_surface *parent = wl_resource_get_user_data(parent_resource); + // TODO: check if parent_resource == NULL? - if (surface->toplevel) { + if (surface->role != WLR_WL_SHELL_SURFACE_ROLE_NONE) { return; } @@ -112,7 +113,9 @@ static void shell_surface_set_transient(struct wl_client *client, free(surface->transient_state); surface->transient_state = state; - wl_signal_emit(&surface->events.set_transient, surface); + surface->role = WLR_WL_SHELL_SURFACE_ROLE_TRANSCIENT; + + wl_signal_emit(&surface->events.set_role, surface); } static void shell_surface_set_fullscreen(struct wl_client *client, @@ -120,9 +123,12 @@ static void shell_surface_set_fullscreen(struct wl_client *client, struct wl_resource *output_resource) { wlr_log(L_DEBUG, "got shell surface fullscreen"); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); - struct wlr_output *output = wl_resource_get_user_data(output_resource); + struct wlr_output *output = NULL; + if (output_resource != NULL) { + output = wl_resource_get_user_data(output_resource); + } - if (surface->toplevel) { + if (surface->role == WLR_WL_SHELL_SURFACE_ROLE_TOPLEVEL) { return; } @@ -145,18 +151,64 @@ static void shell_surface_set_fullscreen(struct wl_client *client, } static void shell_surface_set_popup(struct wl_client *client, - struct wl_resource *resource, struct wl_resource *seat, uint32_t serial, - struct wl_resource *parent, int32_t x, int32_t y, uint32_t flags) { - wlr_log(L_DEBUG, "TODO: implement shell surface set_popup"); + struct wl_resource *resource, struct wl_resource *seat_resource, + uint32_t serial, struct wl_resource *parent_resource, int32_t x, int32_t y, + uint32_t flags) { + wlr_log(L_DEBUG, "got shell surface popup"); + struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); + struct wlr_seat_handle *seat_handle = + wl_resource_get_user_data(seat_resource); + struct wlr_wl_shell_surface *parent = + wl_resource_get_user_data(parent_resource); + // TODO: check if parent_resource == NULL? + + if (surface->role != WLR_WL_SHELL_SURFACE_ROLE_NONE) { + return; + } + + struct wlr_wl_shell_surface_transient_state *transcient_state = + calloc(1, sizeof(struct wlr_wl_shell_surface_transient_state)); + if (transcient_state == NULL) { + wl_client_post_no_memory(client); + return; + } + + transcient_state->parent = parent; + transcient_state->x = x; + transcient_state->y = y; + transcient_state->flags = flags; + + struct wlr_wl_shell_surface_popup_state *popup_state = + calloc(1, sizeof(struct wlr_wl_shell_surface_transient_state)); + if (popup_state == NULL) { + wl_client_post_no_memory(client); + return; + } + + popup_state->seat_handle = seat_handle; + popup_state->serial = serial; + + free(surface->transient_state); + surface->transient_state = transcient_state; + + free(surface->popup_state); + surface->popup_state = popup_state; + + surface->role = WLR_WL_SHELL_SURFACE_ROLE_POPUP; + + wl_signal_emit(&surface->events.set_role, surface); } static void shell_surface_set_maximized(struct wl_client *client, struct wl_resource *resource, struct wl_resource *output_resource) { wlr_log(L_DEBUG, "got shell surface maximized"); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); - struct wlr_output *output = wl_resource_get_user_data(output_resource); + struct wlr_output *output = NULL; + if (output_resource != NULL) { + output = wl_resource_get_user_data(output_resource); + } - if (surface->toplevel) { + if (surface->role == WLR_WL_SHELL_SURFACE_ROLE_TOPLEVEL) { return; } @@ -266,10 +318,8 @@ static void wl_shell_get_shell_surface(struct wl_client *client, wl_signal_init(&wl_surface->events.request_move); wl_signal_init(&wl_surface->events.request_resize); wl_signal_init(&wl_surface->events.request_set_fullscreen); - wl_signal_init(&wl_surface->events.request_set_popup); wl_signal_init(&wl_surface->events.request_set_maximized); - wl_signal_init(&wl_surface->events.set_toplevel); - wl_signal_init(&wl_surface->events.set_transient); + wl_signal_init(&wl_surface->events.set_role); wl_signal_init(&wl_surface->events.set_title); wl_signal_init(&wl_surface->events.set_class); -- cgit v1.2.3 From 241fec4d8786a0c86507d41f401ac70ec2c0c150 Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 27 Sep 2017 23:45:09 +0200 Subject: wl_shell: add wlr_wl_shell_surface_{configure,popup_done} --- include/wlr/types/wlr_wl_shell.h | 3 +++ types/wlr_wl_shell.c | 9 +++++++++ 2 files changed, 12 insertions(+) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h index 92c35d7d..03c0da34 100644 --- a/include/wlr/types/wlr_wl_shell.h +++ b/include/wlr/types/wlr_wl_shell.h @@ -103,5 +103,8 @@ struct wlr_wl_shell *wlr_wl_shell_create(struct wl_display *display); void wlr_wl_shell_destroy(struct wlr_wl_shell *wlr_wl_shell); void wlr_wl_shell_surface_ping(struct wlr_wl_shell_surface *surface); +void wlr_wl_shell_surface_configure(struct wlr_wl_shell_surface *surface, + uint32_t edges, int32_t width, int32_t height); +void wlr_wl_shell_surface_popup_done(struct wlr_wl_shell_surface *surface); #endif diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index 4c3aaefc..e418b3d7 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -406,3 +406,12 @@ void wlr_wl_shell_surface_ping(struct wlr_wl_shell_surface *surface) { surface->shell->ping_timeout); wl_shell_surface_send_ping(surface->resource, surface->ping_serial); } + +void wlr_wl_shell_surface_configure(struct wlr_wl_shell_surface *surface, + uint32_t edges, int32_t width, int32_t height) { + wl_shell_surface_send_configure(surface->resource, edges, width, height); +} + +void wlr_wl_shell_surface_popup_done(struct wlr_wl_shell_surface *surface) { + wl_shell_surface_send_popup_done(surface->resource); +} -- cgit v1.2.3 From d6c6b7c506547d9d409e9c064dba9e613d14fc59 Mon Sep 17 00:00:00 2001 From: emersion Date: Wed, 27 Sep 2017 23:47:39 +0200 Subject: class_ -> class, free more stuff in destroy_shell_surface --- include/wlr/types/wlr_wl_shell.h | 2 +- rootston/wl_shell.c | 2 +- types/wlr_wl_shell.c | 14 ++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h index 03c0da34..3d190588 100644 --- a/include/wlr/types/wlr_wl_shell.h +++ b/include/wlr/types/wlr_wl_shell.h @@ -51,7 +51,7 @@ struct wlr_wl_shell_surface { struct wlr_wl_shell_surface_popup_state *popup_state; char *title; - char *class_; + char *class; struct { struct wl_signal destroy; diff --git a/rootston/wl_shell.c b/rootston/wl_shell.c index fffd9fc9..817d8b95 100644 --- a/rootston/wl_shell.c +++ b/rootston/wl_shell.c @@ -25,7 +25,7 @@ void handle_wl_shell_surface(struct wl_listener *listener, void *data) { struct wlr_wl_shell_surface *surface = data; wlr_log(L_DEBUG, "new shell surface: title=%s, class=%s", - surface->title, surface->class_); + surface->title, surface->class); //wlr_wl_shell_surface_ping(surface); // TODO: segfaults struct roots_wl_shell_surface *roots_surface = diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index e418b3d7..1384c995 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -245,17 +245,17 @@ static void shell_surface_set_title(struct wl_client *client, } static void shell_surface_set_class(struct wl_client *client, - struct wl_resource *resource, const char *class_) { - wlr_log(L_DEBUG, "new shell surface class: %s", class_); + struct wl_resource *resource, const char *class) { + wlr_log(L_DEBUG, "new shell surface class: %s", class); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); - char *tmp = strdup(class_); + char *tmp = strdup(class); if (tmp == NULL) { return; } - free(surface->class_); - surface->class_ = tmp; + free(surface->class); + surface->class = tmp; wl_signal_emit(&surface->events.set_class, surface); } @@ -277,8 +277,10 @@ static void destroy_shell_surface(struct wl_resource *resource) { struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); wl_signal_emit(&surface->events.destroy, surface); wl_list_remove(&surface->link); + free(surface->transient_state); + free(surface->popup_state); free(surface->title); - free(surface->class_); + free(surface->class); free(surface); } -- cgit v1.2.3 From a04462ba8be00640a4a17c096f61c556e488847e Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 28 Sep 2017 01:31:31 +0200 Subject: wl_shell: listen for wlr_surface destroy signal --- include/wlr/types/wlr_wl_shell.h | 2 ++ types/wlr_wl_shell.c | 26 +++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h index 3d190588..11d30d95 100644 --- a/include/wlr/types/wlr_wl_shell.h +++ b/include/wlr/types/wlr_wl_shell.h @@ -53,6 +53,8 @@ struct wlr_wl_shell_surface { char *title; char *class; + struct wl_listener surface_destroy_listener; + struct { struct wl_signal destroy; struct wl_signal ping_timeout; diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index 5040850f..99371fb4 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -273,10 +274,11 @@ struct wl_shell_surface_interface shell_surface_interface = { .set_class = shell_surface_set_class, }; -static void destroy_shell_surface(struct wl_resource *resource) { - struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); +static void wl_shell_surface_destroy(struct wlr_wl_shell_surface *surface) { wl_signal_emit(&surface->events.destroy, surface); + wl_resource_set_user_data(surface->resource, NULL); wl_list_remove(&surface->link); + wl_list_remove(&surface->surface_destroy_listener.link); free(surface->transient_state); free(surface->popup_state); free(surface->title); @@ -284,6 +286,20 @@ static void destroy_shell_surface(struct wl_resource *resource) { free(surface); } +static void wl_shell_surface_resource_destroy(struct wl_resource *resource) { + struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); + if (surface != NULL) { + wl_shell_surface_destroy(surface); + } +} + +static void handle_wlr_surface_destroyed(struct wl_listener *listener, + void *data) { + struct wlr_wl_shell_surface *surface = + wl_container_of(listener, surface, surface_destroy_listener); + wl_shell_surface_destroy(surface); +} + static int wlr_wl_shell_surface_ping_timeout(void *user_data) { struct wlr_wl_shell_surface *surface = user_data; wl_signal_emit(&surface->events.ping_timeout, surface); @@ -312,7 +328,7 @@ static void wl_shell_get_shell_surface(struct wl_client *client, wl_resource_get_version(resource), id); wlr_log(L_DEBUG, "new wl_shell %p (res %p)", wl_surface, wl_surface->resource); wl_resource_set_implementation(wl_surface->resource, - &shell_surface_interface, wl_surface, destroy_shell_surface); + &shell_surface_interface, wl_surface, wl_shell_surface_resource_destroy); wl_signal_init(&wl_surface->events.destroy); wl_signal_init(&wl_surface->events.ping_timeout); @@ -324,6 +340,10 @@ static void wl_shell_get_shell_surface(struct wl_client *client, wl_signal_init(&wl_surface->events.set_title); wl_signal_init(&wl_surface->events.set_class); + wl_signal_add(&wl_surface->surface->signals.destroy, + &wl_surface->surface_destroy_listener); + wl_surface->surface_destroy_listener.notify = handle_wlr_surface_destroyed; + struct wl_display *display = wl_client_get_display(client); struct wl_event_loop *loop = wl_display_get_event_loop(display); wl_surface->ping_timer = wl_event_loop_add_timer(loop, -- cgit v1.2.3 From 27ca8eaced73ee6478c42c2b4083c5fe81fc8ff8 Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 28 Sep 2017 12:38:41 +0200 Subject: Fix typo: s/transcient/transient/ --- include/wlr/types/wlr_wl_shell.h | 2 +- types/wlr_wl_shell.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h index 11d30d95..60398629 100644 --- a/include/wlr/types/wlr_wl_shell.h +++ b/include/wlr/types/wlr_wl_shell.h @@ -32,7 +32,7 @@ struct wlr_wl_shell_surface_popup_state { enum wlr_wl_shell_surface_role { WLR_WL_SHELL_SURFACE_ROLE_NONE, WLR_WL_SHELL_SURFACE_ROLE_TOPLEVEL, - WLR_WL_SHELL_SURFACE_ROLE_TRANSCIENT, + WLR_WL_SHELL_SURFACE_ROLE_TRANSIENT, WLR_WL_SHELL_SURFACE_ROLE_POPUP, }; diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index 99371fb4..5c78deff 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -114,7 +114,7 @@ static void shell_surface_set_transient(struct wl_client *client, free(surface->transient_state); surface->transient_state = state; - surface->role = WLR_WL_SHELL_SURFACE_ROLE_TRANSCIENT; + surface->role = WLR_WL_SHELL_SURFACE_ROLE_TRANSIENT; wl_signal_emit(&surface->events.set_role, surface); } @@ -167,17 +167,17 @@ static void shell_surface_set_popup(struct wl_client *client, return; } - struct wlr_wl_shell_surface_transient_state *transcient_state = + struct wlr_wl_shell_surface_transient_state *transient_state = calloc(1, sizeof(struct wlr_wl_shell_surface_transient_state)); - if (transcient_state == NULL) { + if (transient_state == NULL) { wl_client_post_no_memory(client); return; } - transcient_state->parent = parent; - transcient_state->x = x; - transcient_state->y = y; - transcient_state->flags = flags; + transient_state->parent = parent; + transient_state->x = x; + transient_state->y = y; + transient_state->flags = flags; struct wlr_wl_shell_surface_popup_state *popup_state = calloc(1, sizeof(struct wlr_wl_shell_surface_transient_state)); @@ -190,7 +190,7 @@ static void shell_surface_set_popup(struct wl_client *client, popup_state->serial = serial; free(surface->transient_state); - surface->transient_state = transcient_state; + surface->transient_state = transient_state; free(surface->popup_state); surface->popup_state = popup_state; -- cgit v1.2.3 From 3d03ef2d024add0cb663ab69946da310cd2338ab Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 28 Sep 2017 12:45:47 +0200 Subject: role -> state --- include/wlr/types/wlr_wl_shell.h | 14 +++++++------- types/wlr_wl_shell.c | 24 ++++++++++++------------ 2 files changed, 19 insertions(+), 19 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h index 60398629..d6791247 100644 --- a/include/wlr/types/wlr_wl_shell.h +++ b/include/wlr/types/wlr_wl_shell.h @@ -29,11 +29,11 @@ struct wlr_wl_shell_surface_popup_state { uint32_t serial; }; -enum wlr_wl_shell_surface_role { - WLR_WL_SHELL_SURFACE_ROLE_NONE, - WLR_WL_SHELL_SURFACE_ROLE_TOPLEVEL, - WLR_WL_SHELL_SURFACE_ROLE_TRANSIENT, - WLR_WL_SHELL_SURFACE_ROLE_POPUP, +enum wlr_wl_shell_surface_state { + WLR_WL_SHELL_SURFACE_STATE_NONE, + WLR_WL_SHELL_SURFACE_STATE_TOPLEVEL, + WLR_WL_SHELL_SURFACE_STATE_TRANSIENT, + WLR_WL_SHELL_SURFACE_STATE_POPUP, }; struct wlr_wl_shell_surface { @@ -46,7 +46,7 @@ struct wlr_wl_shell_surface { uint32_t ping_serial; struct wl_event_source *ping_timer; - enum wlr_wl_shell_surface_role role; + enum wlr_wl_shell_surface_state state; struct wlr_wl_shell_surface_transient_state *transient_state; struct wlr_wl_shell_surface_popup_state *popup_state; @@ -64,7 +64,7 @@ struct wlr_wl_shell_surface { struct wl_signal request_set_fullscreen; struct wl_signal request_set_maximized; - struct wl_signal set_role; + struct wl_signal set_state; struct wl_signal set_title; struct wl_signal set_class; } events; diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index 5c78deff..4abec95e 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -77,13 +77,13 @@ static void shell_surface_set_toplevel(struct wl_client *client, wlr_log(L_DEBUG, "got shell surface toplevel"); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); - if (surface->role != WLR_WL_SHELL_SURFACE_ROLE_NONE) { + if (surface->state != WLR_WL_SHELL_SURFACE_STATE_NONE) { return; } - surface->role = WLR_WL_SHELL_SURFACE_ROLE_TOPLEVEL; + surface->state = WLR_WL_SHELL_SURFACE_STATE_TOPLEVEL; - wl_signal_emit(&surface->events.set_role, surface); + wl_signal_emit(&surface->events.set_state, surface); } static void shell_surface_set_transient(struct wl_client *client, @@ -95,7 +95,7 @@ static void shell_surface_set_transient(struct wl_client *client, wl_resource_get_user_data(parent_resource); // TODO: check if parent_resource == NULL? - if (surface->role != WLR_WL_SHELL_SURFACE_ROLE_NONE) { + if (surface->state != WLR_WL_SHELL_SURFACE_STATE_NONE) { return; } @@ -114,9 +114,9 @@ static void shell_surface_set_transient(struct wl_client *client, free(surface->transient_state); surface->transient_state = state; - surface->role = WLR_WL_SHELL_SURFACE_ROLE_TRANSIENT; + surface->state = WLR_WL_SHELL_SURFACE_STATE_TRANSIENT; - wl_signal_emit(&surface->events.set_role, surface); + wl_signal_emit(&surface->events.set_state, surface); } static void shell_surface_set_fullscreen(struct wl_client *client, @@ -129,7 +129,7 @@ static void shell_surface_set_fullscreen(struct wl_client *client, output = wl_resource_get_user_data(output_resource); } - if (surface->role == WLR_WL_SHELL_SURFACE_ROLE_TOPLEVEL) { + if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TOPLEVEL) { return; } @@ -163,7 +163,7 @@ static void shell_surface_set_popup(struct wl_client *client, wl_resource_get_user_data(parent_resource); // TODO: check if parent_resource == NULL? - if (surface->role != WLR_WL_SHELL_SURFACE_ROLE_NONE) { + if (surface->state != WLR_WL_SHELL_SURFACE_STATE_NONE) { return; } @@ -195,9 +195,9 @@ static void shell_surface_set_popup(struct wl_client *client, free(surface->popup_state); surface->popup_state = popup_state; - surface->role = WLR_WL_SHELL_SURFACE_ROLE_POPUP; + surface->state = WLR_WL_SHELL_SURFACE_STATE_POPUP; - wl_signal_emit(&surface->events.set_role, surface); + wl_signal_emit(&surface->events.set_state, surface); } static void shell_surface_set_maximized(struct wl_client *client, @@ -209,7 +209,7 @@ static void shell_surface_set_maximized(struct wl_client *client, output = wl_resource_get_user_data(output_resource); } - if (surface->role == WLR_WL_SHELL_SURFACE_ROLE_TOPLEVEL) { + if (surface->state == WLR_WL_SHELL_SURFACE_STATE_TOPLEVEL) { return; } @@ -336,7 +336,7 @@ static void wl_shell_get_shell_surface(struct wl_client *client, wl_signal_init(&wl_surface->events.request_resize); wl_signal_init(&wl_surface->events.request_set_fullscreen); wl_signal_init(&wl_surface->events.request_set_maximized); - wl_signal_init(&wl_surface->events.set_role); + wl_signal_init(&wl_surface->events.set_state); wl_signal_init(&wl_surface->events.set_title); wl_signal_init(&wl_surface->events.set_class); -- cgit v1.2.3 From 9d405cffa79d8de6378eca84fcd3881a5f68107c Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 28 Sep 2017 13:12:01 +0200 Subject: Use enums instead of uint32_t where applicable --- include/wlr/types/wlr_wl_shell.h | 6 +++--- types/wlr_wl_shell.c | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h index d6791247..0b18a131 100644 --- a/include/wlr/types/wlr_wl_shell.h +++ b/include/wlr/types/wlr_wl_shell.h @@ -21,7 +21,7 @@ struct wlr_wl_shell_surface_transient_state { struct wlr_wl_shell_surface *parent; int32_t x; int32_t y; - uint32_t flags; + enum wl_shell_surface_transient flags; }; struct wlr_wl_shell_surface_popup_state { @@ -84,13 +84,13 @@ struct wlr_wl_shell_surface_resize_event { struct wlr_wl_shell_surface *surface; struct wlr_seat_handle *seat_handle; uint32_t serial; - uint32_t edges; + enum wl_shell_surface_resize edges; }; struct wlr_wl_shell_surface_set_fullscreen_event { struct wl_client *client; struct wlr_wl_shell_surface *surface; - uint32_t method; + enum wl_shell_surface_fullscreen_method method; uint32_t framerate; struct wlr_output *output; }; diff --git a/types/wlr_wl_shell.c b/types/wlr_wl_shell.c index 5bf1ec80..9283a635 100644 --- a/types/wlr_wl_shell.c +++ b/types/wlr_wl_shell.c @@ -47,7 +47,7 @@ static void shell_surface_move(struct wl_client *client, static void shell_surface_resize(struct wl_client *client, struct wl_resource *resource, struct wl_resource *seat_resource, - uint32_t serial, uint32_t edges) { + uint32_t serial, enum wl_shell_surface_resize edges) { wlr_log(L_DEBUG, "got shell surface resize"); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); struct wlr_seat_handle *seat_handle = @@ -93,7 +93,7 @@ static void shell_surface_set_toplevel(struct wl_client *client, static void shell_surface_set_transient(struct wl_client *client, struct wl_resource *resource, struct wl_resource *parent_resource, - int32_t x, int32_t y, uint32_t flags) { + int32_t x, int32_t y, enum wl_shell_surface_transient flags) { wlr_log(L_DEBUG, "got shell surface transient"); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); struct wlr_wl_shell_surface *parent = @@ -116,7 +116,8 @@ static void shell_surface_set_transient(struct wl_client *client, } static void shell_surface_set_fullscreen(struct wl_client *client, - struct wl_resource *resource, uint32_t method, uint32_t framerate, + struct wl_resource *resource, + enum wl_shell_surface_fullscreen_method method, uint32_t framerate, struct wl_resource *output_resource) { wlr_log(L_DEBUG, "got shell surface fullscreen"); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); @@ -149,7 +150,7 @@ static void shell_surface_set_fullscreen(struct wl_client *client, static void shell_surface_set_popup(struct wl_client *client, struct wl_resource *resource, struct wl_resource *seat_resource, uint32_t serial, struct wl_resource *parent_resource, int32_t x, int32_t y, - uint32_t flags) { + enum wl_shell_surface_transient flags) { wlr_log(L_DEBUG, "got shell surface popup"); struct wlr_wl_shell_surface *surface = wl_resource_get_user_data(resource); struct wlr_seat_handle *seat_handle = -- cgit v1.2.3 From 906a816abf812445ec9e514e6115872632fb3ee1 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 28 Sep 2017 08:54:57 -0400 Subject: Fix rootston keyboard, add Xwayland --- examples/compositor.c | 2 +- include/rootston/desktop.h | 3 +++ include/rootston/input.h | 5 ----- include/rootston/server.h | 1 - include/rootston/view.h | 8 ++++++++ include/wlr/xwayland.h | 14 +++++++++++++- rootston/cursor.c | 1 + rootston/desktop.c | 6 ++++++ rootston/keyboard.c | 40 +++++++--------------------------------- rootston/meson.build | 1 + rootston/xwayland.c | 43 +++++++++++++++++++++++++++++++++++++++++++ types/wlr_keyboard.c | 1 + types/wlr_seat.c | 1 + xwayland/xwayland.c | 1 + xwayland/xwm.c | 6 +++++- 15 files changed, 91 insertions(+), 42 deletions(-) create mode 100644 rootston/xwayland.c (limited to 'include/wlr') diff --git a/examples/compositor.c b/examples/compositor.c index ae21697a..7d6efdb6 100644 --- a/examples/compositor.c +++ b/examples/compositor.c @@ -323,7 +323,7 @@ static void handle_output_frame(struct output_state *output, struct wlr_x11_window *x11_window; wl_list_for_each(x11_window, &sample->xwayland->displayable_windows, link) { output_frame_handle_surface(sample, wlr_output, ts, - x11_window->surface, 200, 200); + x11_window->surface->resource, 200, 200); } wlr_renderer_end(sample->renderer); diff --git a/include/rootston/desktop.h b/include/rootston/desktop.h index ef361d87..5e138c11 100644 --- a/include/rootston/desktop.h +++ b/include/rootston/desktop.h @@ -34,11 +34,13 @@ struct roots_desktop { struct wlr_compositor *compositor; struct wlr_wl_shell *wl_shell; struct wlr_xdg_shell_v6 *xdg_shell_v6; + struct wlr_xwayland *xwayland; struct wlr_gamma_control_manager *gamma_control_manager; struct wl_listener output_add; struct wl_listener output_remove; struct wl_listener xdg_shell_v6_surface; + struct wl_listener xwayland_surface; struct wl_listener wl_shell_surface; }; @@ -57,5 +59,6 @@ void output_remove_notify(struct wl_listener *listener, void *data); void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data); void handle_wl_shell_surface(struct wl_listener *listener, void *data); +void handle_xwayland_surface(struct wl_listener *listener, void *data); #endif diff --git a/include/rootston/input.h b/include/rootston/input.h index ec1cd32d..b3ce84d7 100644 --- a/include/rootston/input.h +++ b/include/rootston/input.h @@ -15,11 +15,6 @@ struct roots_keyboard { struct wlr_input_device *device; struct wl_listener key; struct wl_list link; - struct xkb_keymap *keymap; - struct xkb_state *xkb_state; - xkb_led_index_t leds[WLR_LED_LAST]; - int keymap_fd; - size_t keymap_size; }; struct roots_pointer { diff --git a/include/rootston/server.h b/include/rootston/server.h index d9fa8f9e..15e3a4ee 100644 --- a/include/rootston/server.h +++ b/include/rootston/server.h @@ -23,7 +23,6 @@ struct roots_server { /* WLR tools */ struct wlr_backend *backend; struct wlr_renderer *renderer; - struct wlr_xwayland *xwayland; /* Global resources */ struct wlr_data_device_manager *data_device_manager; diff --git a/include/rootston/view.h b/include/rootston/view.h index 1010566a..8d4d69c5 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -27,6 +27,12 @@ struct roots_xdg_surface_v6 { struct wl_listener request_show_window_menu; }; +struct roots_x11_surface { + struct roots_view *view; + // TODO: Maybe destroy listener should go in roots_view + struct wl_listener destroy; +}; + enum roots_view_type { ROOTS_WL_SHELL_VIEW, ROOTS_XDG_SHELL_V6_VIEW, @@ -42,10 +48,12 @@ struct roots_view { union { struct wlr_wl_shell_surface *wl_shell_surface; struct wlr_xdg_surface_v6 *xdg_surface_v6; + struct wlr_x11_window *x11_window; }; union { struct roots_wl_shell_surface *roots_wl_shell_surface; struct roots_xdg_surface_v6 *roots_xdg_surface_v6; + struct roots_x11_surface *roots_x11_surface; }; struct wlr_surface *wlr_surface; struct wl_list link; diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h index 41b8042f..e3eadc2d 100644 --- a/include/wlr/xwayland.h +++ b/include/wlr/xwayland.h @@ -21,6 +21,12 @@ struct wlr_xwayland { struct wl_listener destroy_listener; struct wlr_xwm *xwm; struct wl_list displayable_windows; + + struct { + struct wl_signal new_surface; + } events; + + void *data; }; struct wlr_x11_window { @@ -28,11 +34,17 @@ struct wlr_x11_window { uint32_t surface_id; struct wl_list link; - struct wl_resource *surface; + struct wlr_surface *surface; struct wl_listener surface_destroy_listener; int16_t x, y; uint16_t width, height; bool override_redirect; + + struct { + struct wl_signal destroy; + } events; + + void *data; }; void wlr_xwayland_destroy(struct wlr_xwayland *wlr_xwayland); diff --git a/rootston/cursor.c b/rootston/cursor.c index 0e9bf748..226fe412 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -100,6 +100,7 @@ static void do_cursor_button_press(struct roots_input *input, input->input_events_idx = (i + 1) % (sizeof(input->input_events) / sizeof(input->input_events[0])); set_view_focus(input, desktop, view); + wlr_seat_keyboard_enter(input->wl_seat, view->wlr_surface); break; } } diff --git a/rootston/desktop.c b/rootston/desktop.c index f9af3b8e..0224dd19 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -83,6 +83,12 @@ struct roots_desktop *desktop_create(struct roots_server *server, &desktop->wl_shell_surface); desktop->wl_shell_surface.notify = handle_wl_shell_surface; + desktop->xwayland = wlr_xwayland_create(server->wl_display, + desktop->compositor); + wl_signal_add(&desktop->xwayland->events.new_surface, + &desktop->xwayland_surface); + desktop->xwayland_surface.notify = handle_xwayland_surface; + desktop->gamma_control_manager = wlr_gamma_control_manager_create( server->wl_display); diff --git a/rootston/keyboard.c b/rootston/keyboard.c index 54ae3f8f..57e0d14e 100644 --- a/rootston/keyboard.c +++ b/rootston/keyboard.c @@ -10,38 +10,19 @@ #include #include "rootston/input.h" -static void keyboard_led_update(struct roots_keyboard *keyboard) { - uint32_t leds = 0; - for (uint32_t i = 0; i < WLR_LED_LAST; ++i) { - if (xkb_state_led_index_is_active( - keyboard->xkb_state, keyboard->leds[i])) { - leds |= (1 << i); - } - } - wlr_keyboard_led_update(keyboard->device->keyboard, leds); -} - static void keyboard_key_notify(struct wl_listener *listener, void *data) { struct wlr_event_keyboard_key *event = data; struct roots_keyboard *keyboard = wl_container_of(listener, keyboard, key); struct roots_input *input = keyboard->input; struct roots_server *server = input->server; - uint32_t keycode = event->keycode + 8; + enum wlr_key_state key_state = event->state; + uint32_t keycode = event->keycode + 8; const xkb_keysym_t *syms; - int nsyms = xkb_state_key_get_syms(keyboard->xkb_state, keycode, &syms); - xkb_state_update_key(keyboard->xkb_state, keycode, - event->state == WLR_KEY_PRESSED ? XKB_KEY_DOWN : XKB_KEY_UP); - keyboard_led_update(keyboard); + int nsyms = xkb_state_key_get_syms(keyboard->device->keyboard->xkb_state, + keycode, &syms); for (int i = 0; i < nsyms; ++i) { xkb_keysym_t sym = syms[i]; - char name[64]; - int l = xkb_keysym_get_name(sym, name, sizeof(name)); - if (l != -1 && l != sizeof(name)) { - wlr_log(L_DEBUG, "Key event: %s %s", name, - key_state == WLR_KEY_PRESSED ? "pressed" : "released"); - } - // TODO: pass key to clients if (sym == XKB_KEY_Escape) { // TEMPORARY, probably wl_display_terminate(server->wl_display); @@ -77,16 +58,9 @@ void keyboard_add(struct wlr_input_device *device, struct roots_input *input) { rules.options = getenv("XKB_DEFAULT_OPTIONS"); struct xkb_context *context; assert(context = xkb_context_new(XKB_CONTEXT_NO_FLAGS)); - assert(keyboard->keymap = xkb_map_new_from_names(context, &rules, + wlr_keyboard_set_keymap(device->keyboard, + xkb_map_new_from_names(context, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS)); xkb_context_unref(context); - assert(keyboard->xkb_state = xkb_state_new(keyboard->keymap)); - const char *led_names[3] = { - XKB_LED_NAME_NUM, - XKB_LED_NAME_CAPS, - XKB_LED_NAME_SCROLL - }; - for (uint32_t i = 0; i < 3; ++i) { - keyboard->leds[i] = xkb_map_led_get_index(keyboard->keymap, led_names[i]); - } + wlr_seat_attach_keyboard(input->wl_seat, device); } diff --git a/rootston/meson.build b/rootston/meson.build index 6e9e0041..59f73e96 100644 --- a/rootston/meson.build +++ b/rootston/meson.build @@ -10,6 +10,7 @@ executable( 'output.c', 'pointer.c', 'xdg_shell_v6.c', + 'xwayland.c', 'wl_shell.c', ], dependencies: wlroots ) diff --git a/rootston/xwayland.c b/rootston/xwayland.c new file mode 100644 index 00000000..e68af907 --- /dev/null +++ b/rootston/xwayland.c @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include "rootston/desktop.h" +#include "rootston/server.h" + +static void handle_destroy(struct wl_listener *listener, void *data) { + struct roots_wl_shell_surface *roots_surface = + wl_container_of(listener, roots_surface, destroy); + wl_list_remove(&roots_surface->destroy.link); + view_destroy(roots_surface->view); + free(roots_surface); +} + +void handle_xwayland_surface(struct wl_listener *listener, void *data) { + struct roots_desktop *desktop = + wl_container_of(listener, desktop, xwayland_surface); + + struct wlr_x11_window *surface = data; + // TODO: get and log title, class, etc + wlr_log(L_DEBUG, "new xwayland surface"); + + struct roots_x11_surface *roots_surface = + calloc(1, sizeof(struct roots_wl_shell_surface)); + wl_list_init(&roots_surface->destroy.link); + roots_surface->destroy.notify = handle_destroy; + wl_signal_add(&surface->events.destroy, &roots_surface->destroy); + + struct roots_view *view = calloc(1, sizeof(struct roots_view)); + view->type = ROOTS_XWAYLAND_VIEW; + view->x = view->y = 200; + view->x11_window = surface; + view->roots_x11_surface = roots_surface; + view->wlr_surface = surface->surface; + view->desktop = desktop; + roots_surface->view = view; + wl_list_insert(&desktop->views, &view->link); +} diff --git a/types/wlr_keyboard.c b/types/wlr_keyboard.c index 057f4ce3..dd90b38f 100644 --- a/types/wlr_keyboard.c +++ b/types/wlr_keyboard.c @@ -54,6 +54,7 @@ void wlr_keyboard_led_update(struct wlr_keyboard *kb, uint32_t leds) { void wlr_keyboard_set_keymap(struct wlr_keyboard *kb, struct xkb_keymap *keymap) { + wlr_log(L_DEBUG, "Keymap set"); kb->keymap = keymap; assert(kb->xkb_state = xkb_state_new(kb->keymap)); const char *led_names[3] = { diff --git a/types/wlr_seat.c b/types/wlr_seat.c index aaff6005..e473064a 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -377,6 +377,7 @@ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time, } static void keyboard_key_notify(struct wl_listener *listener, void *data) { + wlr_log(L_DEBUG, "Updating keyboard"); struct wlr_seat_keyboard *seat_kb = wl_container_of( listener, seat_kb, key); struct wlr_seat *seat = seat_kb->seat; diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c index bed2e00e..6a521393 100644 --- a/xwayland/xwayland.c +++ b/xwayland/xwayland.c @@ -194,6 +194,7 @@ static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland, wlr_xwayland->wl_fd[0] = wlr_xwayland->wl_fd[1] = -1; wlr_xwayland->wm_fd[0] = wlr_xwayland->wm_fd[1] = -1; wl_list_init(&wlr_xwayland->displayable_windows); + wl_signal_init(&wlr_xwayland->events.new_surface); wlr_xwayland->display = open_display_sockets(wlr_xwayland->x_fd); if (wlr_xwayland->display < 0) { diff --git a/xwayland/xwm.c b/xwayland/xwm.c index be8fe123..88be0d99 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -16,6 +16,7 @@ static struct wlr_x11_window *lookup_window(struct wl_list *list, xcb_window_t w } return NULL; } + static struct wlr_x11_window *lookup_window_any(struct wlr_xwm *xwm, xcb_window_t window_id) { struct wlr_x11_window *window; if ((window = lookup_window(&xwm->xwayland->displayable_windows, window_id)) || @@ -43,10 +44,12 @@ static struct wlr_x11_window *wlr_x11_window_create(struct wlr_xwm *xwm, window->height = height; window->override_redirect = override_redirect; wl_list_insert(&xwm->new_windows, &window->link); + wl_signal_init(&window->events.destroy); return window; } static void wlr_x11_window_destroy(struct wlr_x11_window *window) { + wl_signal_emit(&window->events.destroy, window); wl_list_remove(&window->link); free(window); } @@ -69,10 +72,11 @@ static bool xcb_call(struct wlr_xwm *xwm, const char *func, uint32_t line, static void map_shell_surface(struct wlr_xwm *xwm, struct wlr_x11_window *window, struct wlr_surface *surface) { // get xcb geometry for depth = alpha channel - window->surface = surface->resource; + window->surface = surface; wl_list_remove(&window->link); wl_list_insert(&xwm->xwayland->displayable_windows, &window->link); + wl_signal_emit(&xwm->xwayland->events.new_surface, window); } /* xcb event handlers */ -- cgit v1.2.3 From 220a6e9bf637471f3f5e392d3c3fb76ae9b7e138 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 28 Sep 2017 09:11:16 -0400 Subject: Add xwayland activate and fix EGL bug --- include/wlr/xwayland.h | 2 ++ render/gles2/texture.c | 4 ++-- rootston/cursor.c | 4 +++- rootston/desktop.c | 2 ++ rootston/xwayland.c | 5 +++++ types/wlr_surface.c | 1 + xwayland/xwm.c | 19 +++++++++++++++++++ xwayland/xwm.h | 3 ++- 8 files changed, 36 insertions(+), 4 deletions(-) (limited to 'include/wlr') diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h index e3eadc2d..3c893c72 100644 --- a/include/wlr/xwayland.h +++ b/include/wlr/xwayland.h @@ -50,5 +50,7 @@ struct wlr_x11_window { void wlr_xwayland_destroy(struct wlr_xwayland *wlr_xwayland); struct wlr_xwayland *wlr_xwayland_create(struct wl_display *wl_display, struct wlr_compositor *compositor); +void wlr_x11_window_activate(struct wlr_xwayland *wlr_xwayland, + struct wlr_x11_window *window); #endif diff --git a/render/gles2/texture.c b/render/gles2/texture.c index f6a9d7eb..98d1a112 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -227,13 +227,13 @@ static void gles2_texture_get_buffer_size(struct wlr_texture *texture, struct return; } if (!wlr_egl_query_buffer(tex->egl, resource, EGL_WIDTH, - (EGLint*)&width)) { + (EGLint*)width)) { wlr_log(L_ERROR, "could not get size of the buffer " "(no buffer found)"); return; }; wlr_egl_query_buffer(tex->egl, resource, EGL_HEIGHT, - (EGLint*)&height); + (EGLint*)height); return; } diff --git a/rootston/cursor.c b/rootston/cursor.c index 226fe412..89f5874e 100644 --- a/rootston/cursor.c +++ b/rootston/cursor.c @@ -100,7 +100,9 @@ static void do_cursor_button_press(struct roots_input *input, input->input_events_idx = (i + 1) % (sizeof(input->input_events) / sizeof(input->input_events[0])); set_view_focus(input, desktop, view); - wlr_seat_keyboard_enter(input->wl_seat, view->wlr_surface); + if (view) { + wlr_seat_keyboard_enter(input->wl_seat, view->wlr_surface); + } break; } } diff --git a/rootston/desktop.c b/rootston/desktop.c index 0224dd19..697c83df 100644 --- a/rootston/desktop.c +++ b/rootston/desktop.c @@ -23,6 +23,8 @@ void view_get_input_bounds(struct roots_view *view, struct wlr_box *box) { return; } box->x = box->y = 0; + box->width = view->wlr_surface->current.width; + box->height = view->wlr_surface->current.height; } void view_activate(struct roots_view *view, bool activate) { diff --git a/rootston/xwayland.c b/rootston/xwayland.c index e68af907..f9ad2a22 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -17,6 +17,10 @@ static void handle_destroy(struct wl_listener *listener, void *data) { free(roots_surface); } +static void x11_activate(struct roots_view *view, bool active) { + wlr_x11_window_activate(view->desktop->xwayland, view->x11_window); +} + void handle_xwayland_surface(struct wl_listener *listener, void *data) { struct roots_desktop *desktop = wl_container_of(listener, desktop, xwayland_surface); @@ -38,6 +42,7 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { view->roots_x11_surface = roots_surface; view->wlr_surface = surface->surface; view->desktop = desktop; + view->activate = x11_activate; roots_surface->view = view; wl_list_insert(&desktop->views, &view->link); } diff --git a/types/wlr_surface.c b/types/wlr_surface.c index a9a54abe..09002d2d 100644 --- a/types/wlr_surface.c +++ b/types/wlr_surface.c @@ -117,6 +117,7 @@ static void wlr_surface_update_size(struct wlr_surface *surface) { surface->current.width = _width; surface->current.height = _height; + wlr_log(L_DEBUG, "%dx%d", _width, _height); } static void wlr_surface_to_buffer_region(struct wlr_surface *surface, diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 88be0d99..bda9f882 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -308,6 +308,25 @@ static void xcb_init_wm(struct wlr_xwm *xwm) { xcb_flush(xwm->xcb_conn); } +void wlr_x11_window_activate(struct wlr_xwayland *wlr_xwayland, + struct wlr_x11_window *window) { + struct wlr_xwm *xwm = wlr_xwayland->xwm; + xcb_client_message_event_t m = {0}; + m.response_type = XCB_CLIENT_MESSAGE; + m.format = 32; + m.window = window->window_id; + m.type = xwm->atoms[WM_PROTOCOLS]; + m.data.data32[0] = xwm->atoms[WM_TAKE_FOCUS]; + m.data.data32[1] = XCB_TIME_CURRENT_TIME; + xcb_send_event_checked(xwm->xcb_conn, 0, window->window_id, + XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (char*)&m); + xcb_set_input_focus_checked(xwm->xcb_conn, XCB_INPUT_FOCUS_POINTER_ROOT, + window->window_id, XCB_CURRENT_TIME); + xcb_configure_window_checked(xwm->xcb_conn, window->window_id, + XCB_CONFIG_WINDOW_STACK_MODE, (uint32_t[]){XCB_STACK_MODE_ABOVE}); + xcb_flush(xwm->xcb_conn); +} + void xwm_destroy(struct wlr_xwm *xwm) { if (!xwm) { return; diff --git a/xwayland/xwm.h b/xwayland/xwm.h index 235145b9..679ff128 100644 --- a/xwayland/xwm.h +++ b/xwayland/xwm.h @@ -52,7 +52,8 @@ enum atom_name { NET_SUPPORTED, NET_WM_S0, NET_WM_STATE, - ATOM_LAST + ATOM_LAST, + WM_TAKE_FOCUS, }; static const char * const atom_map[ATOM_LAST] = { -- cgit v1.2.3 From b7927078e9b2dec995eaec8240a87b683349aefb Mon Sep 17 00:00:00 2001 From: emersion Date: Thu, 28 Sep 2017 23:26:31 +0200 Subject: x11 -> xwayland, window -> surface, fix some calloc sizes and wrong types --- examples/compositor.c | 7 +- include/rootston/view.h | 6 +- include/wlr/xwayland.h | 10 +- rootston/xwayland.c | 15 +-- xwayland/xwayland.c | 6 +- xwayland/xwm.c | 251 ++++++++++++++++++++++++++---------------------- xwayland/xwm.h | 4 +- 7 files changed, 159 insertions(+), 140 deletions(-) (limited to 'include/wlr') diff --git a/examples/compositor.c b/examples/compositor.c index 7d6efdb6..b1b55190 100644 --- a/examples/compositor.c +++ b/examples/compositor.c @@ -320,10 +320,11 @@ static void handle_output_frame(struct output_state *output, } } } - struct wlr_x11_window *x11_window; - wl_list_for_each(x11_window, &sample->xwayland->displayable_windows, link) { + struct wlr_xwayland_surface *xwayland_surface; + wl_list_for_each(xwayland_surface, &sample->xwayland->displayable_surfaces, + link) { output_frame_handle_surface(sample, wlr_output, ts, - x11_window->surface->resource, 200, 200); + xwayland_surface->surface->resource, 200, 200); } wlr_renderer_end(sample->renderer); diff --git a/include/rootston/view.h b/include/rootston/view.h index 8d4d69c5..9cc2fe04 100644 --- a/include/rootston/view.h +++ b/include/rootston/view.h @@ -27,7 +27,7 @@ struct roots_xdg_surface_v6 { struct wl_listener request_show_window_menu; }; -struct roots_x11_surface { +struct roots_xwayland_surface { struct roots_view *view; // TODO: Maybe destroy listener should go in roots_view struct wl_listener destroy; @@ -48,12 +48,12 @@ struct roots_view { union { struct wlr_wl_shell_surface *wl_shell_surface; struct wlr_xdg_surface_v6 *xdg_surface_v6; - struct wlr_x11_window *x11_window; + struct wlr_xwayland_surface *xwayland_surface; }; union { struct roots_wl_shell_surface *roots_wl_shell_surface; struct roots_xdg_surface_v6 *roots_xdg_surface_v6; - struct roots_x11_surface *roots_x11_surface; + struct roots_xwayland_surface *roots_xwayland_surface; }; struct wlr_surface *wlr_surface; struct wl_list link; diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h index 3c893c72..2b9d4e81 100644 --- a/include/wlr/xwayland.h +++ b/include/wlr/xwayland.h @@ -20,7 +20,7 @@ struct wlr_xwayland { struct wl_event_source *sigusr1_source; struct wl_listener destroy_listener; struct wlr_xwm *xwm; - struct wl_list displayable_windows; + struct wl_list displayable_surfaces; struct { struct wl_signal new_surface; @@ -29,7 +29,7 @@ struct wlr_xwayland { void *data; }; -struct wlr_x11_window { +struct wlr_xwayland_surface { xcb_window_t window_id; uint32_t surface_id; struct wl_list link; @@ -49,8 +49,8 @@ struct wlr_x11_window { void wlr_xwayland_destroy(struct wlr_xwayland *wlr_xwayland); struct wlr_xwayland *wlr_xwayland_create(struct wl_display *wl_display, - struct wlr_compositor *compositor); -void wlr_x11_window_activate(struct wlr_xwayland *wlr_xwayland, - struct wlr_x11_window *window); + struct wlr_compositor *compositor); +void wlr_xwayland_surface_activate(struct wlr_xwayland *wlr_xwayland, + struct wlr_xwayland_surface *surface); #endif diff --git a/rootston/xwayland.c b/rootston/xwayland.c index f9ad2a22..88965f0d 100644 --- a/rootston/xwayland.c +++ b/rootston/xwayland.c @@ -10,7 +10,7 @@ #include "rootston/server.h" static void handle_destroy(struct wl_listener *listener, void *data) { - struct roots_wl_shell_surface *roots_surface = + struct roots_xwayland_surface *roots_surface = wl_container_of(listener, roots_surface, destroy); wl_list_remove(&roots_surface->destroy.link); view_destroy(roots_surface->view); @@ -18,19 +18,20 @@ static void handle_destroy(struct wl_listener *listener, void *data) { } static void x11_activate(struct roots_view *view, bool active) { - wlr_x11_window_activate(view->desktop->xwayland, view->x11_window); + wlr_xwayland_surface_activate(view->desktop->xwayland, + view->xwayland_surface); } void handle_xwayland_surface(struct wl_listener *listener, void *data) { struct roots_desktop *desktop = wl_container_of(listener, desktop, xwayland_surface); - struct wlr_x11_window *surface = data; + struct wlr_xwayland_surface *surface = data; // TODO: get and log title, class, etc wlr_log(L_DEBUG, "new xwayland surface"); - struct roots_x11_surface *roots_surface = - calloc(1, sizeof(struct roots_wl_shell_surface)); + struct roots_xwayland_surface *roots_surface = + calloc(1, sizeof(struct roots_xwayland_surface)); wl_list_init(&roots_surface->destroy.link); roots_surface->destroy.notify = handle_destroy; wl_signal_add(&surface->events.destroy, &roots_surface->destroy); @@ -38,8 +39,8 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) { struct roots_view *view = calloc(1, sizeof(struct roots_view)); view->type = ROOTS_XWAYLAND_VIEW; view->x = view->y = 200; - view->x11_window = surface; - view->roots_x11_surface = roots_surface; + view->xwayland_surface = surface; + view->roots_xwayland_surface = roots_surface; view->wlr_surface = surface->surface; view->desktop = desktop; view->activate = x11_activate; diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c index 6a521393..d3bb41a0 100644 --- a/xwayland/xwayland.c +++ b/xwayland/xwayland.c @@ -86,7 +86,7 @@ static void exec_xwayland(struct wlr_xwayland *wlr_xwayland) { _exit(EXIT_FAILURE); } - if (clearenv()) { + if (clearenv()) { wlr_log_errno(L_ERROR, "clearenv failed"); _exit(EXIT_FAILURE); } @@ -105,7 +105,7 @@ static void exec_xwayland(struct wlr_xwayland *wlr_xwayland) { } static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland, - struct wl_display *wl_display, struct wlr_compositor *compositor); + struct wl_display *wl_display, struct wlr_compositor *compositor); static void wlr_xwayland_finish(struct wlr_xwayland *wlr_xwayland); static void xwayland_destroy_event(struct wl_listener *listener, void *data) { @@ -193,7 +193,7 @@ static bool wlr_xwayland_init(struct wlr_xwayland *wlr_xwayland, wlr_xwayland->x_fd[0] = wlr_xwayland->x_fd[1] = -1; wlr_xwayland->wl_fd[0] = wlr_xwayland->wl_fd[1] = -1; wlr_xwayland->wm_fd[0] = wlr_xwayland->wm_fd[1] = -1; - wl_list_init(&wlr_xwayland->displayable_windows); + wl_list_init(&wlr_xwayland->displayable_surfaces); wl_signal_init(&wlr_xwayland->events.new_surface); wlr_xwayland->display = open_display_sockets(wlr_xwayland->x_fd); diff --git a/xwayland/xwm.c b/xwayland/xwm.c index bda9f882..1feb4bd0 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -7,51 +7,52 @@ /* General helpers */ // TODO: replace this with hash table? -static struct wlr_x11_window *lookup_window(struct wl_list *list, xcb_window_t window_id) { - struct wlr_x11_window *window; - wl_list_for_each(window, list, link) { - if (window->window_id == window_id) { - return window; +static struct wlr_xwayland_surface *lookup_surface(struct wl_list *list, + xcb_window_t window_id) { + struct wlr_xwayland_surface *surface; + wl_list_for_each(surface, list, link) { + if (surface->window_id == window_id) { + return surface; } } return NULL; } -static struct wlr_x11_window *lookup_window_any(struct wlr_xwm *xwm, xcb_window_t window_id) { - struct wlr_x11_window *window; - if ((window = lookup_window(&xwm->xwayland->displayable_windows, window_id)) || - (window = lookup_window(&xwm->unpaired_windows, window_id)) || - (window = lookup_window(&xwm->new_windows, window_id))) { - return window; +static struct wlr_xwayland_surface *lookup_surface_any(struct wlr_xwm *xwm, + xcb_window_t window_id) { + struct wlr_xwayland_surface *surface; + if ((surface = lookup_surface(&xwm->xwayland->displayable_surfaces, window_id)) || + (surface = lookup_surface(&xwm->unpaired_surfaces, window_id)) || + (surface = lookup_surface(&xwm->new_surfaces, window_id))) { + return surface; } return NULL; } -static struct wlr_x11_window *wlr_x11_window_create(struct wlr_xwm *xwm, - xcb_window_t window_id, int16_t x, int16_t y, +static struct wlr_xwayland_surface *wlr_xwayland_surface_create( + struct wlr_xwm *xwm, xcb_window_t window_id, int16_t x, int16_t y, uint16_t width, uint16_t height, bool override_redirect) { - struct wlr_x11_window *window; - - window = calloc(1, sizeof(struct wlr_x11_window)); - if (!window) { - wlr_log(L_ERROR, "Could not allocate wlr x11 window"); + struct wlr_xwayland_surface *surface = + calloc(1, sizeof(struct wlr_xwayland_surface)); + if (!surface) { + wlr_log(L_ERROR, "Could not allocate wlr xwayland surface"); return NULL; } - window->window_id = window_id; - window->x = x; - window->y = y; - window->width = width; - window->height = height; - window->override_redirect = override_redirect; - wl_list_insert(&xwm->new_windows, &window->link); - wl_signal_init(&window->events.destroy); - return window; + surface->window_id = window_id; + surface->x = x; + surface->y = y; + surface->width = width; + surface->height = height; + surface->override_redirect = override_redirect; + wl_list_insert(&xwm->new_surfaces, &surface->link); + wl_signal_init(&surface->events.destroy); + return surface; } -static void wlr_x11_window_destroy(struct wlr_x11_window *window) { - wl_signal_emit(&window->events.destroy, window); - wl_list_remove(&window->link); - free(window); +static void wlr_xwayland_surface_destroy(struct wlr_xwayland_surface *surface) { + wl_signal_emit(&surface->events.destroy, surface); + wl_list_remove(&surface->link); + free(surface); } /* xcb helpers */ @@ -69,106 +70,117 @@ static bool xcb_call(struct wlr_xwm *xwm, const char *func, uint32_t line, return false; } -static void map_shell_surface(struct wlr_xwm *xwm, struct wlr_x11_window *window, +static void map_shell_surface(struct wlr_xwm *xwm, + struct wlr_xwayland_surface *xwayland_surface, struct wlr_surface *surface) { // get xcb geometry for depth = alpha channel - window->surface = surface; + xwayland_surface->surface = surface; - wl_list_remove(&window->link); - wl_list_insert(&xwm->xwayland->displayable_windows, &window->link); - wl_signal_emit(&xwm->xwayland->events.new_surface, window); + wl_list_remove(&xwayland_surface->link); + wl_list_insert(&xwm->xwayland->displayable_surfaces, + &xwayland_surface->link); + wl_signal_emit(&xwm->xwayland->events.new_surface, xwayland_surface); } /* xcb event handlers */ -static void handle_create_notify(struct wlr_xwm *xwm, xcb_create_notify_event_t *ev) { +static void handle_create_notify(struct wlr_xwm *xwm, + xcb_create_notify_event_t *ev) { wlr_log(L_DEBUG, "XCB_CREATE_NOTIFY (%u)", ev->window); - wlr_x11_window_create(xwm, ev->window, ev->x, ev->y, + wlr_xwayland_surface_create(xwm, ev->window, ev->x, ev->y, ev->width, ev->height, ev->override_redirect); } -static void handle_destroy_notify(struct wlr_xwm *xwm, xcb_destroy_notify_event_t *ev) { - struct wlr_x11_window *window; +static void handle_destroy_notify(struct wlr_xwm *xwm, + xcb_destroy_notify_event_t *ev) { wlr_log(L_DEBUG, "XCB_DESTROY_NOTIFY (%u)", ev->window); - if (!(window = lookup_window_any(xwm, ev->window))) { + struct wlr_xwayland_surface *surface = lookup_surface_any(xwm, ev->window); + if (surface == NULL) { return; } - wlr_x11_window_destroy(window); + wlr_xwayland_surface_destroy(surface); } -static void handle_configure_request(struct wlr_xwm *xwm, xcb_configure_request_event_t *ev) { - struct wlr_x11_window *window; +static void handle_configure_request(struct wlr_xwm *xwm, + xcb_configure_request_event_t *ev) { wlr_log(L_DEBUG, "XCB_CONFIGURE_REQUEST (%u) [%ux%u+%d,%d]", ev->window, ev->width, ev->height, ev->x, ev->y); - if (!(window = lookup_window_any(xwm, ev->window))) { + struct wlr_xwayland_surface *surface = lookup_surface_any(xwm, ev->window); + if (surface == NULL) { return; } - window->x = ev->x; - window->y = ev->y; - window->width = ev->width; - window->height = ev->height; + surface->x = ev->x; + surface->y = ev->y; + surface->width = ev->width; + surface->height = ev->height; // handle parent/sibling? - uint32_t values[] = { ev->x, ev->y, ev->width, ev->height, 0 }; + uint32_t values[] = {ev->x, ev->y, ev->width, ev->height, 0}; uint32_t mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT | XCB_CONFIG_WINDOW_BORDER_WIDTH; xcb_configure_window(xwm->xcb_conn, ev->window, mask, values); } -static void handle_map_request(struct wlr_xwm *xwm, xcb_map_request_event_t *ev) { +static void handle_map_request(struct wlr_xwm *xwm, + xcb_map_request_event_t *ev) { wlr_log(L_DEBUG, "XCB_MAP_REQUEST (%u)", ev->window); + const uint32_t value_list = XCB_EVENT_MASK_FOCUS_CHANGE | + XCB_EVENT_MASK_PROPERTY_CHANGE; XCB_CALL(xwm, xcb_change_window_attributes_checked(xwm->xcb_conn, - ev->window, XCB_CW_EVENT_MASK, - &(uint32_t){XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_PROPERTY_CHANGE})); + ev->window, XCB_CW_EVENT_MASK, &value_list)); XCB_CALL(xwm, xcb_map_window_checked(xwm->xcb_conn, ev->window)); } static void handle_map_notify(struct wlr_xwm *xwm, xcb_map_notify_event_t *ev) { - struct wlr_x11_window *window; wlr_log(L_DEBUG, "XCB_MAP_NOTIFY (%u)", ev->window); - if ((window = lookup_window_any(xwm, ev->window))) { - window->override_redirect = ev->override_redirect; + struct wlr_xwayland_surface *surface = lookup_surface_any(xwm, ev->window); + if (surface != NULL) { + surface->override_redirect = ev->override_redirect; } else { - wlr_x11_window_create(xwm, ev->window, 0, 0, 1, 1, ev->override_redirect); + wlr_xwayland_surface_create(xwm, ev->window, 0, 0, 1, 1, + ev->override_redirect); } } -static void handle_unmap_notify(struct wlr_xwm *xwm, xcb_unmap_notify_event_t *ev) { - struct wlr_x11_window *window; +static void handle_unmap_notify(struct wlr_xwm *xwm, + xcb_unmap_notify_event_t *ev) { wlr_log(L_DEBUG, "XCB_UNMAP_NOTIFY (%u)", ev->window); - if (!(window = lookup_window_any(xwm, ev->window))) { + struct wlr_xwayland_surface *surface = lookup_surface_any(xwm, ev->window); + if (surface == NULL) { return; } - // remove pointer to surface only? - wlr_x11_window_destroy(window); + // TODO: remove pointer to surface only? + wlr_xwayland_surface_destroy(surface); } -static void handle_property_notify(struct wlr_xwm *xwm, xcb_property_notify_event_t *ev) { +static void handle_property_notify(struct wlr_xwm *xwm, + xcb_property_notify_event_t *ev) { wlr_log(L_DEBUG, "XCB_PROPERTY_NOTIFY (%u)", ev->window); // TODO lookup window & get properties } -static void handle_client_message(struct wlr_xwm *xwm, xcb_client_message_event_t *ev) { +static void handle_client_message(struct wlr_xwm *xwm, + xcb_client_message_event_t *ev) { wlr_log(L_DEBUG, "XCB_CLIENT_MESSAGE (%u)", ev->window); if (ev->type == xwm->atoms[WL_SURFACE_ID]) { - struct wlr_x11_window *window; - struct wl_resource *resource; - window = lookup_window(&xwm->new_windows, ev->window); - if (!window) { + struct wlr_xwayland_surface *surface = lookup_surface( + &xwm->new_surfaces, ev->window); + if (surface == NULL) { wlr_log(L_DEBUG, "client message WL_SURFACE_ID but no new window %u ?", ev->window); return; } - window->surface_id = ev->data.data32[0]; + surface->surface_id = ev->data.data32[0]; /* Check if we got notified after wayland surface create event */ - resource = wl_client_get_object(xwm->xwayland->client, window->surface_id); + struct wl_resource *resource = wl_client_get_object( + xwm->xwayland->client, surface->surface_id); if (resource) { - map_shell_surface(xwm, window, wl_resource_get_user_data(resource)); + map_shell_surface(xwm, surface, wl_resource_get_user_data(resource)); } else { - wl_list_remove(&window->link); - wl_list_insert(&xwm->unpaired_windows, &window->link); + wl_list_remove(&surface->link); + wl_list_insert(&xwm->unpaired_surfaces, &surface->link); } } wlr_log(L_DEBUG, "unhandled client message %u", ev->type); @@ -224,20 +236,19 @@ static int x11_event_handler(int fd, uint32_t mask, void *data) { static void create_surface_handler(struct wl_listener *listener, void *data) { struct wlr_surface *surface = data; - struct wlr_xwm *xwm = wl_container_of(listener, xwm, surface_create_listener); - struct wlr_x11_window *window; - uint32_t surface_id; - + struct wlr_xwm *xwm = wl_container_of(listener, xwm, + surface_create_listener); if (wl_resource_get_client(surface->resource) != xwm->xwayland->client) { return; } wlr_log(L_DEBUG, "New x11 surface: %p", surface); - surface_id = wl_resource_get_id(surface->resource); - wl_list_for_each(window, &xwm->unpaired_windows, link) { - if (window->surface_id == surface_id) { - map_shell_surface(xwm, window, surface); + uint32_t surface_id = wl_resource_get_id(surface->resource); + struct wlr_xwayland_surface *xwayland_surface; + wl_list_for_each(xwayland_surface, &xwm->unpaired_surfaces, link) { + if (xwayland_surface->surface_id == surface_id) { + map_shell_surface(xwm, xwayland_surface, surface); xcb_flush(xwm->xcb_conn); return; } @@ -273,57 +284,57 @@ static void xcb_get_resources(struct wlr_xwm *xwm) { } static void xcb_init_wm(struct wlr_xwm *xwm) { - xcb_screen_iterator_t screen_iterator; - screen_iterator = xcb_setup_roots_iterator(xcb_get_setup(xwm->xcb_conn)); + xcb_screen_iterator_t screen_iterator = + xcb_setup_roots_iterator(xcb_get_setup(xwm->xcb_conn)); xwm->screen = screen_iterator.data; xwm->window = xcb_generate_id(xwm->xcb_conn); uint32_t values[] = { - XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | + XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | XCB_EVENT_MASK_PROPERTY_CHANGE, /* xwm->cursor, */ }; - XCB_CALL(xwm, xcb_change_window_attributes_checked(xwm->xcb_conn, xwm->screen->root, - XCB_CW_EVENT_MASK /* | XCB_CW_CURSOR */, values)); + XCB_CALL(xwm, xcb_change_window_attributes_checked(xwm->xcb_conn, + xwm->screen->root, XCB_CW_EVENT_MASK /* | XCB_CW_CURSOR */, values)); XCB_CALL(xwm, xcb_composite_redirect_subwindows_checked(xwm->xcb_conn, - xwm->screen->root, XCB_COMPOSITE_REDIRECT_MANUAL)); + xwm->screen->root, XCB_COMPOSITE_REDIRECT_MANUAL)); XCB_CALL(xwm, xcb_create_window_checked(xwm->xcb_conn, XCB_COPY_FROM_PARENT, - xwm->window, xwm->screen->root, 0, 0, 1, 1, 0, - XCB_WINDOW_CLASS_INPUT_OUTPUT, xwm->screen->root_visual, - XCB_CW_EVENT_MASK, (uint32_t[]){XCB_EVENT_MASK_PROPERTY_CHANGE})); + xwm->window, xwm->screen->root, 0, 0, 1, 1, 0, + XCB_WINDOW_CLASS_INPUT_OUTPUT, xwm->screen->root_visual, + XCB_CW_EVENT_MASK, (uint32_t[]){XCB_EVENT_MASK_PROPERTY_CHANGE})); xcb_atom_t supported[] = { xwm->atoms[NET_WM_STATE], }; - XCB_CALL(xwm, xcb_change_property_checked(xwm->xcb_conn, XCB_PROP_MODE_REPLACE, - xwm->screen->root, xwm->atoms[NET_SUPPORTED], XCB_ATOM_ATOM, - 32, sizeof(supported)/sizeof(*supported), supported)); + XCB_CALL(xwm, xcb_change_property_checked(xwm->xcb_conn, + XCB_PROP_MODE_REPLACE, xwm->screen->root, xwm->atoms[NET_SUPPORTED], + XCB_ATOM_ATOM, 32, sizeof(supported)/sizeof(*supported), supported)); XCB_CALL(xwm, xcb_set_selection_owner_checked(xwm->xcb_conn, xwm->window, - xwm->atoms[WM_S0], XCB_CURRENT_TIME)); + xwm->atoms[WM_S0], XCB_CURRENT_TIME)); XCB_CALL(xwm, xcb_set_selection_owner_checked(xwm->xcb_conn, xwm->window, - xwm->atoms[NET_WM_S0], XCB_CURRENT_TIME)); + xwm->atoms[NET_WM_S0], XCB_CURRENT_TIME)); xcb_flush(xwm->xcb_conn); } -void wlr_x11_window_activate(struct wlr_xwayland *wlr_xwayland, - struct wlr_x11_window *window) { +void wlr_xwayland_surface_activate(struct wlr_xwayland *wlr_xwayland, + struct wlr_xwayland_surface *surface) { struct wlr_xwm *xwm = wlr_xwayland->xwm; xcb_client_message_event_t m = {0}; m.response_type = XCB_CLIENT_MESSAGE; m.format = 32; - m.window = window->window_id; + m.window = surface->window_id; m.type = xwm->atoms[WM_PROTOCOLS]; m.data.data32[0] = xwm->atoms[WM_TAKE_FOCUS]; m.data.data32[1] = XCB_TIME_CURRENT_TIME; - xcb_send_event_checked(xwm->xcb_conn, 0, window->window_id, - XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (char*)&m); + xcb_send_event_checked(xwm->xcb_conn, 0, surface->window_id, + XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, (char*)&m); xcb_set_input_focus_checked(xwm->xcb_conn, XCB_INPUT_FOCUS_POINTER_ROOT, - window->window_id, XCB_CURRENT_TIME); - xcb_configure_window_checked(xwm->xcb_conn, window->window_id, - XCB_CONFIG_WINDOW_STACK_MODE, (uint32_t[]){XCB_STACK_MODE_ABOVE}); + surface->window_id, XCB_CURRENT_TIME); + xcb_configure_window_checked(xwm->xcb_conn, surface->window_id, + XCB_CONFIG_WINDOW_STACK_MODE, (uint32_t[]){XCB_STACK_MODE_ABOVE}); xcb_flush(xwm->xcb_conn); } @@ -334,15 +345,16 @@ void xwm_destroy(struct wlr_xwm *xwm) { if (xwm->event_source) { wl_event_source_remove(xwm->event_source); } - struct wlr_x11_window *window, *tmp; - wl_list_for_each_safe(window, tmp, &xwm->xwayland->displayable_windows, link) { - wlr_x11_window_destroy(window); + struct wlr_xwayland_surface *surface, *tmp; + wl_list_for_each_safe(surface, tmp, &xwm->xwayland->displayable_surfaces, + link) { + wlr_xwayland_surface_destroy(surface); } - wl_list_for_each_safe(window, tmp, &xwm->new_windows, link) { - wlr_x11_window_destroy(window); + wl_list_for_each_safe(surface, tmp, &xwm->new_surfaces, link) { + wlr_xwayland_surface_destroy(surface); } - wl_list_for_each_safe(window, tmp, &xwm->unpaired_windows, link) { - wlr_x11_window_destroy(window); + wl_list_for_each_safe(surface, tmp, &xwm->unpaired_surfaces, link) { + wlr_xwayland_surface_destroy(surface); } wl_list_remove(&xwm->surface_create_listener.link); xcb_disconnect(xwm->xcb_conn); @@ -352,22 +364,27 @@ void xwm_destroy(struct wlr_xwm *xwm) { struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) { struct wlr_xwm *xwm = calloc(1, sizeof(struct wlr_xwm)); - int rc; + if (xwm == NULL) { + return NULL; + } xwm->xwayland = wlr_xwayland; - wl_list_init(&xwm->new_windows); - wl_list_init(&xwm->unpaired_windows); + wl_list_init(&xwm->new_surfaces); + wl_list_init(&xwm->unpaired_surfaces); xwm->xcb_conn = xcb_connect_to_fd(wlr_xwayland->wm_fd[0], NULL); - if ((rc = xcb_connection_has_error(xwm->xcb_conn))) { + + int rc = xcb_connection_has_error(xwm->xcb_conn); + if (rc) { wlr_log(L_ERROR, "xcb connect failed: %d", rc); free(xwm); return NULL; } - struct wl_event_loop *event_loop = wl_display_get_event_loop(wlr_xwayland->wl_display); + struct wl_event_loop *event_loop = wl_display_get_event_loop( + wlr_xwayland->wl_display); xwm->event_source = wl_event_loop_add_fd(event_loop, wlr_xwayland->wm_fd[0], - WL_EVENT_READABLE, x11_event_handler, xwm); + WL_EVENT_READABLE, x11_event_handler, xwm); // probably not needed // wl_event_source_check(xwm->event_source); @@ -378,7 +395,7 @@ struct wlr_xwm *xwm_create(struct wlr_xwayland *wlr_xwayland) { xwm->surface_create_listener.notify = create_surface_handler; wl_signal_add(&wlr_xwayland->compositor->events.create_surface, - &xwm->surface_create_listener); + &xwm->surface_create_listener); return xwm; } diff --git a/xwayland/xwm.h b/xwayland/xwm.h index 7fc6f3bf..869eb303 100644 --- a/xwayland/xwm.h +++ b/xwayland/xwm.h @@ -75,8 +75,8 @@ struct wlr_xwm { xcb_screen_t *screen; xcb_window_t window; - struct wl_list new_windows; - struct wl_list unpaired_windows; + struct wl_list new_surfaces; + struct wl_list unpaired_surfaces; }; void xwm_destroy(struct wlr_xwm *xwm); -- cgit v1.2.3