From cef1f60522141f3e1a4fe5278d89bb77118735d4 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Fri, 22 Sep 2017 16:07:00 -0400 Subject: [PATCH 1/9] wlr-seat-keyboard: basic events --- examples/compositor.c | 46 +++----------- examples/output-layout.c | 3 +- examples/rotation.c | 3 +- examples/shared.c | 3 +- examples/shared.h | 2 +- include/wlr/types/wlr_seat.h | 30 +++++++++ types/wlr_seat.c | 115 ++++++++++++++++++++++++++++++++++- 7 files changed, 159 insertions(+), 43 deletions(-) diff --git a/examples/compositor.c b/examples/compositor.c index 53b385b7..cd334dc6 100644 --- a/examples/compositor.c +++ b/examples/compositor.c @@ -128,6 +128,12 @@ static void example_set_focused_surface(struct sample_state *sample, } } + if (surface) { + wlr_seat_keyboard_enter(sample->wl_seat, surface->surface); + } else { + wlr_seat_keyboard_clear_focus(sample->wl_seat); + } + sample->focused_surface = surface; } @@ -332,45 +338,13 @@ static void handle_output_frame(struct output_state *output, } static void handle_keyboard_key(struct keyboard_state *keyboard, - uint32_t keycode, xkb_keysym_t sym, enum wlr_key_state key_state) { + uint32_t keycode, xkb_keysym_t sym, enum wlr_key_state key_state, + uint64_t time_usec) { struct compositor_state *state = keyboard->compositor; struct sample_state *sample = state->data; - struct wl_resource *res = NULL; - struct wlr_seat_handle *seat_handle = NULL; - wl_list_for_each(res, &sample->wlr_compositor->surfaces, link) { - break; - } - - if (res) { - seat_handle = wlr_seat_handle_for_client(sample->wl_seat, - wl_resource_get_client(res)); - } - - if (res != sample->focus && seat_handle && seat_handle->keyboard) { - struct wl_array keys; - wl_array_init(&keys); - uint32_t serial = wl_display_next_serial(state->display); - wl_keyboard_send_enter(seat_handle->keyboard, serial, res, &keys); - sample->focus = res; - } - - if (seat_handle && seat_handle->keyboard) { - uint32_t depressed = xkb_state_serialize_mods(keyboard->xkb_state, - XKB_STATE_MODS_DEPRESSED); - uint32_t latched = xkb_state_serialize_mods(keyboard->xkb_state, - XKB_STATE_MODS_LATCHED); - uint32_t locked = xkb_state_serialize_mods(keyboard->xkb_state, - XKB_STATE_MODS_LOCKED); - uint32_t group = xkb_state_serialize_layout(keyboard->xkb_state, - XKB_STATE_LAYOUT_EFFECTIVE); - uint32_t modifiers_serial = wl_display_next_serial(state->display); - uint32_t key_serial = wl_display_next_serial(state->display); - wl_keyboard_send_modifiers(seat_handle->keyboard, modifiers_serial, - depressed, latched, locked, group); - wl_keyboard_send_key(seat_handle->keyboard, key_serial, 0, keycode, - key_state); - } + wlr_seat_keyboard_send_key(sample->wl_seat, (uint32_t)time_usec, keycode, + key_state); if (sym == XKB_KEY_Super_L || sym == XKB_KEY_Super_R) { sample->mod_down = key_state == WLR_KEY_PRESSED; diff --git a/examples/output-layout.c b/examples/output-layout.c index be542630..69cb241a 100644 --- a/examples/output-layout.c +++ b/examples/output-layout.c @@ -157,7 +157,8 @@ static void update_velocities(struct compositor_state *state, } static void handle_keyboard_key(struct keyboard_state *kbstate, - uint32_t keycode, xkb_keysym_t sym, enum wlr_key_state key_state) { + uint32_t keycode, xkb_keysym_t sym, enum wlr_key_state key_state, + uint64_t time_usec) { // NOTE: It may be better to simply refer to our key state during each frame // and make this change in pixels/sec^2 // Also, key repeat diff --git a/examples/rotation.c b/examples/rotation.c index 2596e492..dfb81e59 100644 --- a/examples/rotation.c +++ b/examples/rotation.c @@ -99,7 +99,8 @@ static void update_velocities(struct compositor_state *state, } static void handle_keyboard_key(struct keyboard_state *kbstate, - uint32_t keycode, xkb_keysym_t sym, enum wlr_key_state key_state) { + uint32_t keycode, xkb_keysym_t sym, enum wlr_key_state key_state, + uint64_t time_usec) { // NOTE: It may be better to simply refer to our key state during each frame // and make this change in pixels/sec^2 // Also, key repeat diff --git a/examples/shared.c b/examples/shared.c index 0346c96d..19cf83f0 100644 --- a/examples/shared.c +++ b/examples/shared.c @@ -48,7 +48,8 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) { key_state == WLR_KEY_PRESSED ? "pressed" : "released"); } if (kbstate->compositor->keyboard_key_cb) { - kbstate->compositor->keyboard_key_cb(kbstate, event->keycode, sym, key_state); + kbstate->compositor->keyboard_key_cb(kbstate, event->keycode, sym, + key_state, event->time_usec); } if (sym == XKB_KEY_Escape) { wl_display_terminate(kbstate->compositor->display); diff --git a/examples/shared.h b/examples/shared.h index 7cf4db63..f564bffa 100644 --- a/examples/shared.h +++ b/examples/shared.h @@ -87,7 +87,7 @@ struct compositor_state { struct output_state *s); void (*keyboard_remove_cb)(struct keyboard_state *s); void (*keyboard_key_cb)(struct keyboard_state *s, uint32_t keycode, - xkb_keysym_t sym, enum wlr_key_state key_state); + xkb_keysym_t sym, enum wlr_key_state key_state, uint64_t time_usec); void (*pointer_motion_cb)(struct pointer_state *s, double d_x, double d_y); void (*pointer_motion_absolute_cb)(struct pointer_state *s, diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index aa17d650..15aa6ad8 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -30,6 +30,15 @@ struct wlr_seat_pointer_state { struct wl_listener focus_resource_destroy_listener; }; +struct wlr_seat_keyboard_state { + struct wlr_seat *wlr_seat; + 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 wlr_seat { struct wl_global *wl_global; struct wl_display *display; @@ -39,6 +48,7 @@ struct wlr_seat { struct wlr_data_device *data_device; struct wlr_seat_pointer_state pointer_state; + struct wlr_seat_keyboard_state keyboard_state; struct { struct wl_signal client_bound; @@ -112,4 +122,24 @@ 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); +/** + * Send a keyboard enter event to the given surface and consider it to be the + * focused surface for the keyboard. This will send a leave event to the last + * surface that was entered. + */ +void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat, + struct wlr_surface *surface); + +/** + * Clear the focused surface for the keyboard and leave all entered surfaces. + */ +void wlr_seat_keyboard_clear_focus(struct wlr_seat *wlr_seat); + +/** + * Send a key event to the surface with keyboard focus. Returns the event + * serial. + */ +uint32_t wlr_seat_keyboard_send_key(struct wlr_seat *wlr_seat, uint32_t time, + uint32_t key, uint32_t state); + #endif diff --git a/types/wlr_seat.c b/types/wlr_seat.c index cbf1abc7..2aa94922 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -115,6 +115,9 @@ static void wlr_seat_handle_resource_destroy(struct wl_resource *resource) { if (handle == handle->wlr_seat->pointer_state.focused_handle) { handle->wlr_seat->pointer_state.focused_handle = NULL; } + if (handle == handle->wlr_seat->keyboard_state.focused_handle) { + handle->wlr_seat->keyboard_state.focused_handle = NULL; + } if (handle->pointer) { wl_resource_destroy(handle->pointer); @@ -168,6 +171,14 @@ 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); + + wlr_seat->keyboard_state.wlr_seat = wlr_seat; + wl_list_init( + &wlr_seat->keyboard_state.focus_resource_destroy_listener.link); + wl_list_init( + &wlr_seat->keyboard_state.focus_surface_destroy_listener.link); struct wl_global *wl_global = wl_global_create(display, &wl_seat_interface, 6, wlr_seat, wl_seat_bind); @@ -184,9 +195,6 @@ struct wlr_seat *wlr_seat_create(struct wl_display *display, const char *name) { wl_signal_init(&wlr_seat->events.client_unbound); wl_signal_init(&wlr_seat->events.keyboard_bound); - wl_list_init(&wlr_seat->pointer_state.focus_resource_destroy_listener.link); - wl_list_init(&wlr_seat->pointer_state.focus_surface_destroy_listener.link); - return wlr_seat; } @@ -372,3 +380,104 @@ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time, wl_pointer_send_frame(pointer); } + +static void handle_keyboard_focus_surface_destroyed( + struct wl_listener *listener, void *data) { + struct wlr_seat_keyboard_state *state = + wl_container_of(listener, state, focus_surface_destroy_listener); + + state->focused_surface = NULL; + wlr_seat_keyboard_clear_focus(state->wlr_seat); +} + +static void handle_keyboard_focus_resource_destroyed( + struct wl_listener *listener, void *data) { + struct wlr_seat_pointer_state *state = + wl_container_of(listener, state, focus_resource_destroy_listener); + + state->focused_surface = NULL; + wlr_seat_keyboard_clear_focus(state->wlr_seat); +} + +void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat, + struct wlr_surface *surface) { + if (wlr_seat->keyboard_state.focused_surface == surface) { + // this surface already got an enter notify + return; + } + + struct wlr_seat_handle *handle = NULL; + + if (surface) { + struct wl_client *client = wl_resource_get_client(surface->resource); + handle = wlr_seat_handle_for_client(wlr_seat, client); + } + + struct wlr_seat_handle *focused_handle = + wlr_seat->keyboard_state.focused_handle; + struct wlr_surface *focused_surface = + wlr_seat->keyboard_state.focused_surface; + + // leave the previously entered surface + if (focused_handle && focused_handle->keyboard && focused_surface) { + uint32_t serial = wl_display_next_serial(wlr_seat->display); + wl_keyboard_send_leave(focused_handle->keyboard, serial, + focused_surface->resource); + } + + // enter the current surface + if (handle && handle->keyboard) { + uint32_t serial = wl_display_next_serial(wlr_seat->display); + // TODO: send currently pressed keys + struct wl_array keys; + wl_array_init(&keys); + wl_keyboard_send_enter(handle->keyboard, serial, + surface->resource, &keys); + + // TODO: send modifiers + } + + // 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); + if (surface) { + wl_signal_add(&surface->signals.destroy, + &wlr_seat->keyboard_state.focus_surface_destroy_listener); + wl_resource_add_destroy_listener(surface->resource, + &wlr_seat->keyboard_state.focus_resource_destroy_listener); + wlr_seat->keyboard_state.focus_resource_destroy_listener.notify = + handle_keyboard_focus_resource_destroyed; + wlr_seat->keyboard_state.focus_surface_destroy_listener.notify = + handle_keyboard_focus_surface_destroyed; + } + + wlr_seat->keyboard_state.focused_handle = handle; + wlr_seat->keyboard_state.focused_surface = surface; +} + +void wlr_seat_keyboard_clear_focus(struct wlr_seat *wlr_seat) { + wlr_seat_keyboard_enter(wlr_seat, NULL); +} + +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; +} + +uint32_t wlr_seat_keyboard_send_key(struct wlr_seat *wlr_seat, uint32_t time, + uint32_t key, uint32_t state) { + if (!wlr_seat_keyboard_has_focus_resource(wlr_seat)) { + return 0; + } + + uint32_t serial = wl_display_next_serial(wlr_seat->display); + wl_keyboard_send_key(wlr_seat->keyboard_state.focused_handle->keyboard, + serial, time, key, state); + + return serial; +} From 30b5d764265b689d6247a04e9bbef8efb0204e2f Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Fri, 22 Sep 2017 17:09:47 -0400 Subject: [PATCH 2/9] wlr-seat: keyboard modifiers --- examples/compositor.c | 11 +++++++++++ include/wlr/types/wlr_seat.h | 8 ++++++++ types/wlr_seat.c | 27 +++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/examples/compositor.c b/examples/compositor.c index cd334dc6..0d0df88c 100644 --- a/examples/compositor.c +++ b/examples/compositor.c @@ -343,6 +343,17 @@ static void handle_keyboard_key(struct keyboard_state *keyboard, struct compositor_state *state = keyboard->compositor; struct sample_state *sample = state->data; + uint32_t depressed = xkb_state_serialize_mods(keyboard->xkb_state, + XKB_STATE_MODS_DEPRESSED); + uint32_t latched = xkb_state_serialize_mods(keyboard->xkb_state, + XKB_STATE_MODS_LATCHED); + uint32_t locked = xkb_state_serialize_mods(keyboard->xkb_state, + XKB_STATE_MODS_LOCKED); + uint32_t group = xkb_state_serialize_layout(keyboard->xkb_state, + XKB_STATE_LAYOUT_EFFECTIVE); + + wlr_seat_keyboard_send_modifiers(sample->wl_seat, depressed, latched, + locked, group); wlr_seat_keyboard_send_key(sample->wl_seat, (uint32_t)time_usec, keycode, key_state); diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 15aa6ad8..21f2350d 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -142,4 +142,12 @@ void wlr_seat_keyboard_clear_focus(struct wlr_seat *wlr_seat); uint32_t wlr_seat_keyboard_send_key(struct wlr_seat *wlr_seat, uint32_t time, uint32_t key, uint32_t state); +/** + * Send the modifiers event to the surface with keyboard focus. Also sends the + * event to the surface with pointer focus. + */ +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); + #endif diff --git a/types/wlr_seat.c b/types/wlr_seat.c index 2aa94922..d0955959 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -481,3 +481,30 @@ uint32_t wlr_seat_keyboard_send_key(struct wlr_seat *wlr_seat, uint32_t time, return serial; } + +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); + } +} From 427bdb5b558b995e556ed3e708dfbe91f257d091 Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 23 Sep 2017 10:26:01 +0200 Subject: [PATCH 3/9] Use more consistent include guard names --- include/backend/drm-properties.h | 4 ++-- include/backend/drm-util.h | 4 ++-- include/backend/drm.h | 4 ++-- include/backend/libinput.h | 4 ++-- include/backend/multi.h | 4 ++-- include/backend/session/direct-ipc.h | 4 ++-- include/backend/wayland.h | 4 ++-- include/render/gles2.h | 5 +++-- include/wlr/backend.h | 4 ++-- include/wlr/backend/interface.h | 4 ++-- include/wlr/backend/multi.h | 4 ++-- include/wlr/backend/session.h | 4 ++-- include/wlr/backend/session/interface.h | 4 ++-- include/wlr/interfaces/wlr_data_source.h | 5 +++-- include/wlr/interfaces/wlr_input_device.h | 5 +++-- include/wlr/interfaces/wlr_keyboard.h | 5 +++-- include/wlr/interfaces/wlr_output.h | 5 +++-- include/wlr/interfaces/wlr_pointer.h | 5 +++-- include/wlr/interfaces/wlr_tablet_pad.h | 5 +++-- include/wlr/interfaces/wlr_tablet_tool.h | 5 +++-- include/wlr/interfaces/wlr_touch.h | 5 +++-- include/wlr/render.h | 5 +++-- include/wlr/render/gles2.h | 5 +++-- include/wlr/render/interface.h | 5 +++-- include/wlr/render/matrix.h | 4 ++-- include/wlr/types/wlr_box.h | 5 +++-- include/wlr/types/wlr_compositor.h | 6 ++++-- include/wlr/types/wlr_cursor.h | 5 +++-- include/wlr/types/wlr_data_device_manager.h | 4 ++-- include/wlr/types/wlr_data_source.h | 4 ++-- include/wlr/types/wlr_gamma_control.h | 5 +++-- include/wlr/types/wlr_input_device.h | 4 ++-- include/wlr/types/wlr_keyboard.h | 5 +++-- include/wlr/types/wlr_output.h | 5 +++-- include/wlr/types/wlr_output_layout.h | 5 +++-- include/wlr/types/wlr_pointer.h | 5 +++-- include/wlr/types/wlr_region.h | 4 ++-- include/wlr/types/wlr_seat.h | 5 +++-- include/wlr/types/wlr_surface.h | 5 +++-- include/wlr/types/wlr_tablet_pad.h | 5 +++-- include/wlr/types/wlr_tablet_tool.h | 5 +++-- include/wlr/types/wlr_touch.h | 5 +++-- include/wlr/types/wlr_wl_shell.h | 5 +++-- include/wlr/types/wlr_xdg_shell_v6.h | 5 +++-- include/wlr/util/list.h | 4 ++-- include/wlr/util/log.h | 5 +++-- include/wlr/xcursor.h | 6 ++++-- include/wlr/xwayland.h | 5 +++-- 48 files changed, 128 insertions(+), 96 deletions(-) diff --git a/include/backend/drm-properties.h b/include/backend/drm-properties.h index 7a061dd3..7de386ea 100644 --- a/include/backend/drm-properties.h +++ b/include/backend/drm-properties.h @@ -1,5 +1,5 @@ -#ifndef DRM_PROPERTIES_H -#define DRM_PROPERTIES_H +#ifndef BACKEND_DRM_PROPERTIES_H +#define BACKEND_DRM_PROPERTIES_H #include #include diff --git a/include/backend/drm-util.h b/include/backend/drm-util.h index 9abee6ea..6818b4db 100644 --- a/include/backend/drm-util.h +++ b/include/backend/drm-util.h @@ -1,5 +1,5 @@ -#ifndef WLR_DRM_UTIL_H -#define WLR_DRM_UTIL_H +#ifndef BACKEND_DRM_UTIL_H +#define BACKEND_DRM_UTIL_H #include #include diff --git a/include/backend/drm.h b/include/backend/drm.h index 342a980c..122d49ef 100644 --- a/include/backend/drm.h +++ b/include/backend/drm.h @@ -1,5 +1,5 @@ -#ifndef DRM_BACKEND_H -#define DRM_BACKEND_H +#ifndef BACKEND_DRM_H +#define BACKEND_DRM_H #include #include diff --git a/include/backend/libinput.h b/include/backend/libinput.h index f484ea8d..bb6083a4 100644 --- a/include/backend/libinput.h +++ b/include/backend/libinput.h @@ -1,5 +1,5 @@ -#ifndef _WLR_BACKEND_LIBINPUT_INTERNAL_H -#define _WLR_BACKEND_LIBINPUT_INTERNAL_H +#ifndef BACKEND_LIBINPUT_H +#define BACKEND_LIBINPUT_H #include #include #include diff --git a/include/backend/multi.h b/include/backend/multi.h index c7a2198e..2c409b3a 100644 --- a/include/backend/multi.h +++ b/include/backend/multi.h @@ -1,5 +1,5 @@ -#ifndef _WLR_MULTI_BACKEND_INTERNAL -#define _WLR_MULTI_BACKEND_INTERNAL +#ifndef BACKEND_MULTI_H +#define BACKEND_MULTI_H #include #include diff --git a/include/backend/session/direct-ipc.h b/include/backend/session/direct-ipc.h index 2189d6fa..c660b58f 100644 --- a/include/backend/session/direct-ipc.h +++ b/include/backend/session/direct-ipc.h @@ -1,5 +1,5 @@ -#ifndef SESSION_DIRECT_IPC -#define SESSION_DIRECT_IPC +#ifndef BACKEND_SESSION_DIRECT_IPC_H +#define BACKEND_SESSION_DIRECT_IPC_H #include diff --git a/include/backend/wayland.h b/include/backend/wayland.h index 5e278dc9..917a798a 100644 --- a/include/backend/wayland.h +++ b/include/backend/wayland.h @@ -1,5 +1,5 @@ -#ifndef _WLR_INTERNAL_BACKEND_WAYLAND_H -#define _WLR_INTERNAL_BACKEND_WAYLAND_H +#ifndef BACKEND_WAYLAND_H +#define BACKEND_WAYLAND_H #include #include diff --git a/include/render/gles2.h b/include/render/gles2.h index 79f13ed9..688a51dd 100644 --- a/include/render/gles2.h +++ b/include/render/gles2.h @@ -1,5 +1,6 @@ -#ifndef _WLR_RENDER_GLES2_INTERNAL_H -#define _WLR_RENDER_GLES2_INTERNAL_H +#ifndef RENDER_GLES2_H +#define RENDER_GLES2_H + #include #include #include diff --git a/include/wlr/backend.h b/include/wlr/backend.h index f92857eb..6c11152f 100644 --- a/include/wlr/backend.h +++ b/include/wlr/backend.h @@ -1,5 +1,5 @@ -#ifndef _WLR_BACKEND_H -#define _WLR_BACKEND_H +#ifndef WLR_BACKEND_H +#define WLR_BACKEND_H #include #include diff --git a/include/wlr/backend/interface.h b/include/wlr/backend/interface.h index b0814da5..ea41400a 100644 --- a/include/wlr/backend/interface.h +++ b/include/wlr/backend/interface.h @@ -1,5 +1,5 @@ -#ifndef _WLR_BACKEND_INTERFACE_H -#define _WLR_BACKEND_INTERFACE_H +#ifndef WLR_BACKEND_INTERFACE_H +#define WLR_BACKEND_INTERFACE_H #include #include diff --git a/include/wlr/backend/multi.h b/include/wlr/backend/multi.h index 3fcaaf1e..5559f2c1 100644 --- a/include/wlr/backend/multi.h +++ b/include/wlr/backend/multi.h @@ -1,5 +1,5 @@ -#ifndef _WLR_BACKEND_MULTI_H -#define _WLR_BACKEND_MULTI_H +#ifndef WLR_BACKEND_MULTI_H +#define WLR_BACKEND_MULTI_H #include #include diff --git a/include/wlr/backend/session.h b/include/wlr/backend/session.h index 04e701b0..52cf13b7 100644 --- a/include/wlr/backend/session.h +++ b/include/wlr/backend/session.h @@ -1,5 +1,5 @@ -#ifndef WLR_SESSION_H -#define WLR_SESSION_H +#ifndef WLR_BACKEND_SESSION_H +#define WLR_BACKEND_SESSION_H #include #include diff --git a/include/wlr/backend/session/interface.h b/include/wlr/backend/session/interface.h index 1a029c54..b35ed71d 100644 --- a/include/wlr/backend/session/interface.h +++ b/include/wlr/backend/session/interface.h @@ -1,5 +1,5 @@ -#ifndef WLR_SESSION_INTERFACE_H -#define WLR_SESSION_INTERFACE_H +#ifndef WLR_BACKEND_SESSION_INTERFACE_H +#define WLR_BACKEND_SESSION_INTERFACE_H #include diff --git a/include/wlr/interfaces/wlr_data_source.h b/include/wlr/interfaces/wlr_data_source.h index 221c8007..821bdea0 100644 --- a/include/wlr/interfaces/wlr_data_source.h +++ b/include/wlr/interfaces/wlr_data_source.h @@ -1,5 +1,6 @@ -#ifndef _WLR_INTERFACES_DATA_SOURCE_H -#define _WLR_INTERFACES_DATA_SOURCE_H +#ifndef WLR_INTERFACES_WLR_DATA_SOURCE_H +#define WLR_INTERFACES_WLR_DATA_SOURCE_H + #include struct wlr_data_source_impl { diff --git a/include/wlr/interfaces/wlr_input_device.h b/include/wlr/interfaces/wlr_input_device.h index b236a24a..2a681ff8 100644 --- a/include/wlr/interfaces/wlr_input_device.h +++ b/include/wlr/interfaces/wlr_input_device.h @@ -1,5 +1,6 @@ -#ifndef _WLR_INTERFACES_INPUT_DEVICE_H -#define _WLR_INTERFACES_INPUT_DEVICE_H +#ifndef WLR_INTERFACES_WLR_INPUT_DEVICE_H +#define WLR_INTERFACES_WLR_INPUT_DEVICE_H + #include struct wlr_input_device_impl { diff --git a/include/wlr/interfaces/wlr_keyboard.h b/include/wlr/interfaces/wlr_keyboard.h index 779b302f..6fbb3f68 100644 --- a/include/wlr/interfaces/wlr_keyboard.h +++ b/include/wlr/interfaces/wlr_keyboard.h @@ -1,5 +1,6 @@ -#ifndef _WLR_INTERFACE_KEYBOARD_H -#define _WLR_INTERFACE_KEYBOARD_H +#ifndef WLR_INTERFACE_WLR_KEYBOARD_H +#define WLR_INTERFACE_WLR_KEYBOARD_H + #include #include diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h index a95fe588..15a3a619 100644 --- a/include/wlr/interfaces/wlr_output.h +++ b/include/wlr/interfaces/wlr_output.h @@ -1,5 +1,6 @@ -#ifndef _WLR_INTERFACE_OUTPUT_H -#define _WLR_INTERFACE_OUTPUT_H +#ifndef WLR_INTERFACE_WLR_OUTPUT_H +#define WLR_INTERFACE_WLR_OUTPUT_H + #include #include diff --git a/include/wlr/interfaces/wlr_pointer.h b/include/wlr/interfaces/wlr_pointer.h index 8d4bf703..af677b97 100644 --- a/include/wlr/interfaces/wlr_pointer.h +++ b/include/wlr/interfaces/wlr_pointer.h @@ -1,5 +1,6 @@ -#ifndef _WLR_INTERFACES_POINTER_H -#define _WLR_INTERFACES_POINTER_H +#ifndef WLR_INTERFACES_WLR_POINTER_H +#define WLR_INTERFACES_WLR_POINTER_H + #include struct wlr_pointer_impl { diff --git a/include/wlr/interfaces/wlr_tablet_pad.h b/include/wlr/interfaces/wlr_tablet_pad.h index 81af3c3f..5ec1e3eb 100644 --- a/include/wlr/interfaces/wlr_tablet_pad.h +++ b/include/wlr/interfaces/wlr_tablet_pad.h @@ -1,5 +1,6 @@ -#ifndef _WLR_INTERFACES_TABLET_PAD_H -#define _WLR_INTERFACES_TABLET_PAD_H +#ifndef WLR_INTERFACES_WLR_TABLET_PAD_H +#define WLR_INTERFACES_WLR_TABLET_PAD_H + #include struct wlr_tablet_pad_impl { diff --git a/include/wlr/interfaces/wlr_tablet_tool.h b/include/wlr/interfaces/wlr_tablet_tool.h index 43a24fd0..347a0003 100644 --- a/include/wlr/interfaces/wlr_tablet_tool.h +++ b/include/wlr/interfaces/wlr_tablet_tool.h @@ -1,5 +1,6 @@ -#ifndef _WLR_INTERFACES_TABLET_TOOL_H -#define _WLR_INTERFACES_TABLET_TOOL_H +#ifndef WLR_INTERFACES_WLR_TABLET_TOOL_H +#define WLR_INTERFACES_WLR_TABLET_TOOL_H + #include struct wlr_tablet_tool_impl { diff --git a/include/wlr/interfaces/wlr_touch.h b/include/wlr/interfaces/wlr_touch.h index b5fcef18..63bac6b8 100644 --- a/include/wlr/interfaces/wlr_touch.h +++ b/include/wlr/interfaces/wlr_touch.h @@ -1,5 +1,6 @@ -#ifndef _WLR_INTERFACES_TOUCH_H -#define _WLR_INTERFACES_TOUCH_H +#ifndef WLR_INTERFACES_WLR_TOUCH_H +#define WLR_INTERFACES_WLR_TOUCH_H + #include struct wlr_touch_impl { diff --git a/include/wlr/render.h b/include/wlr/render.h index b7924928..325f8c01 100644 --- a/include/wlr/render.h +++ b/include/wlr/render.h @@ -1,5 +1,6 @@ -#ifndef _WLR_RENDER_H -#define _WLR_RENDER_H +#ifndef WLR_RENDER_H +#define WLR_RENDER_H + #include #include #include diff --git a/include/wlr/render/gles2.h b/include/wlr/render/gles2.h index 4a944eb7..25e760d5 100644 --- a/include/wlr/render/gles2.h +++ b/include/wlr/render/gles2.h @@ -1,5 +1,6 @@ -#ifndef _WLR_GLES2_RENDERER_H -#define _WLR_GLES2_RENDERER_H +#ifndef WLR_RENDER_GLES2_H +#define WLR_RENDER_GLES2_H + #include #include diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h index c00e0701..e3ba0414 100644 --- a/include/wlr/render/interface.h +++ b/include/wlr/render/interface.h @@ -1,5 +1,6 @@ -#ifndef _WLR_RENDER_INTERFACE_H -#define _WLR_RENDER_INTERFACE_H +#ifndef WLR_RENDER_INTERFACE_H +#define WLR_RENDER_INTERFACE_H + #include #include #include diff --git a/include/wlr/render/matrix.h b/include/wlr/render/matrix.h index 789f7341..177af4b3 100644 --- a/include/wlr/render/matrix.h +++ b/include/wlr/render/matrix.h @@ -1,5 +1,5 @@ -#ifndef _WLR_RENDER_MATRIX_H -#define _WLR_RENDER_MATRIX_H +#ifndef WLR_RENDER_MATRIX_H +#define WLR_RENDER_MATRIX_H #include diff --git a/include/wlr/types/wlr_box.h b/include/wlr/types/wlr_box.h index e2b1ab4e..5b8b00c9 100644 --- a/include/wlr/types/wlr_box.h +++ b/include/wlr/types/wlr_box.h @@ -1,5 +1,6 @@ -#ifndef _WLR_TYPES_GEOMETRY_H -#define _WLR_TYPES_GEOMETRY_H +#ifndef WLR_TYPES_WLR_BOX_H +#define WLR_TYPES_WLR_BOX_H + #include struct wlr_box { diff --git a/include/wlr/types/wlr_compositor.h b/include/wlr/types/wlr_compositor.h index 58a93760..b2f5a972 100644 --- a/include/wlr/types/wlr_compositor.h +++ b/include/wlr/types/wlr_compositor.h @@ -1,5 +1,6 @@ -#ifndef _EXAMPLE_COMPOSITOR_H -#define _EXAMPLE_COMPOSITOR_H +#ifndef WLR_TYPES_WLR_COMPOSITOR_H +#define WLR_TYPES_WLR_COMPOSITOR_H + #include #include @@ -22,4 +23,5 @@ struct wlr_compositor *wlr_compositor_create(struct wl_display *display, struct wlr_surface; void wl_compositor_surface_destroyed(struct wlr_compositor *wlr_compositor, struct wlr_surface *surface); + #endif diff --git a/include/wlr/types/wlr_cursor.h b/include/wlr/types/wlr_cursor.h index 88390e0d..e8c13b1d 100644 --- a/include/wlr/types/wlr_cursor.h +++ b/include/wlr/types/wlr_cursor.h @@ -1,5 +1,6 @@ -#ifndef _WLR_TYPES_CURSOR_H -#define _WLR_TYPES_CURSOR_H +#ifndef WLR_TYPES_WLR_CURSOR_H +#define WLR_TYPES_WLR_CURSOR_H + #include #include #include diff --git a/include/wlr/types/wlr_data_device_manager.h b/include/wlr/types/wlr_data_device_manager.h index d7ae46c8..500f8acd 100644 --- a/include/wlr/types/wlr_data_device_manager.h +++ b/include/wlr/types/wlr_data_device_manager.h @@ -1,5 +1,5 @@ -#ifndef _WLR_TYPES_DATA_DEVICE_MANAGER_H -#define _WLR_TYPES_DATA_DEVICE_MANAGER_H +#ifndef WLR_TYPES_WLR_DATA_DEVICE_MANAGER_H +#define WLR_TYPES_WLR_DATA_DEVICE_MANAGER_H #include diff --git a/include/wlr/types/wlr_data_source.h b/include/wlr/types/wlr_data_source.h index 63b0fe2a..19834cb6 100644 --- a/include/wlr/types/wlr_data_source.h +++ b/include/wlr/types/wlr_data_source.h @@ -1,5 +1,5 @@ -#ifndef _WLR_TYPES_DATA_SOURCE_H -#define _WLR_TYPES_DATA_SOURCE_H +#ifndef WLR_TYPES_WLR_DATA_SOURCE_H +#define WLR_TYPES_WLR_DATA_SOURCE_H #include #include diff --git a/include/wlr/types/wlr_gamma_control.h b/include/wlr/types/wlr_gamma_control.h index 259c6474..96c9f545 100644 --- a/include/wlr/types/wlr_gamma_control.h +++ b/include/wlr/types/wlr_gamma_control.h @@ -1,5 +1,6 @@ -#ifndef _WLR_GAMMA_CONTROL_H -#define _WLR_GAMMA_CONTROL_H +#ifndef WLR_TYPES_WLR_GAMMA_CONTROL_H +#define WLR_TYPES_WLR_GAMMA_CONTROL_H + #include struct wlr_gamma_control_manager { diff --git a/include/wlr/types/wlr_input_device.h b/include/wlr/types/wlr_input_device.h index 5a41ce9d..50b0fb88 100644 --- a/include/wlr/types/wlr_input_device.h +++ b/include/wlr/types/wlr_input_device.h @@ -1,5 +1,5 @@ -#ifndef _WLR_TYPES_INPUT_H -#define _WLR_TYPES_INPUT_H +#ifndef WLR_TYPES_WLR_INPUT_DEVICE_H +#define WLR_TYPES_WLR_INPUT_DEVICE_H enum wlr_button_state { WLR_BUTTON_RELEASED, diff --git a/include/wlr/types/wlr_keyboard.h b/include/wlr/types/wlr_keyboard.h index ce7d6659..3f5d0d0c 100644 --- a/include/wlr/types/wlr_keyboard.h +++ b/include/wlr/types/wlr_keyboard.h @@ -1,5 +1,6 @@ -#ifndef _WLR_TYPES_KEYBOARD_H -#define _WLR_TYPES_KEYBOARD_H +#ifndef WLR_TYPES_WLR_KEYBOARD_H +#define WLR_TYPES_WLR_KEYBOARD_H + #include #include diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index b70bd19e..3208acac 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -1,5 +1,6 @@ -#ifndef _WLR_TYPES_OUTPUT_H -#define _WLR_TYPES_OUTPUT_H +#ifndef WLR_TYPES_WLR_OUTPUT_H +#define WLR_TYPES_WLR_OUTPUT_H + #include #include #include diff --git a/include/wlr/types/wlr_output_layout.h b/include/wlr/types/wlr_output_layout.h index 1f4a96d5..fe09106f 100644 --- a/include/wlr/types/wlr_output_layout.h +++ b/include/wlr/types/wlr_output_layout.h @@ -1,5 +1,6 @@ -#ifndef _WLR_TYPES_OUTPUT_LAYOUT_H -#define _WLR_TYPES_OUTPUT_LAYOUT_H +#ifndef WLR_TYPES_WLR_OUTPUT_LAYOUT_H +#define WLR_TYPES_WLR_OUTPUT_LAYOUT_H + #include #include #include diff --git a/include/wlr/types/wlr_pointer.h b/include/wlr/types/wlr_pointer.h index 9153963a..a59d8817 100644 --- a/include/wlr/types/wlr_pointer.h +++ b/include/wlr/types/wlr_pointer.h @@ -1,5 +1,6 @@ -#ifndef _WLR_TYPES_POINTER_H -#define _WLR_TYPES_POINTER_H +#ifndef WLR_TYPES_WLR_POINTER_H +#define WLR_TYPES_WLR_POINTER_H + #include #include #include diff --git a/include/wlr/types/wlr_region.h b/include/wlr/types/wlr_region.h index 9a64ac13..6d59ee5e 100644 --- a/include/wlr/types/wlr_region.h +++ b/include/wlr/types/wlr_region.h @@ -1,5 +1,5 @@ -#ifndef _WLR_TYPES_REGION_H -#define _WLR_TYPES_REGION_H +#ifndef WLR_TYPES_WLR_REGION_H +#define WLR_TYPES_WLR_REGION_H struct wl_resource; diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index aa17d650..e7bd82fb 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -1,5 +1,6 @@ -#ifndef _WLR_TYPES_SEAT_H -#define _WLR_TYPES_SEAT_H +#ifndef WLR_TYPES_WLR_SEAT_H +#define WLR_TYPES_WLR_SEAT_H + #include #include #include diff --git a/include/wlr/types/wlr_surface.h b/include/wlr/types/wlr_surface.h index 5fb648be..87d421e3 100644 --- a/include/wlr/types/wlr_surface.h +++ b/include/wlr/types/wlr_surface.h @@ -1,5 +1,6 @@ -#ifndef _WLR_TYPES_WLR_SURFACE_H -#define _WLR_TYPES_WLR_SURFACE_H +#ifndef WLR_TYPES_WLR_SURFACE_H +#define WLR_TYPES_WLR_SURFACE_H + #include #include #include diff --git a/include/wlr/types/wlr_tablet_pad.h b/include/wlr/types/wlr_tablet_pad.h index 6c14c669..b747e6f1 100644 --- a/include/wlr/types/wlr_tablet_pad.h +++ b/include/wlr/types/wlr_tablet_pad.h @@ -1,5 +1,6 @@ -#ifndef _WLR_TYPES_TABLET_PAD_H -#define _WLR_TYPES_TABLET_PAD_H +#ifndef WLR_TYPES_WLR_TABLET_PAD_H +#define WLR_TYPES_WLR_TABLET_PAD_H + #include #include #include diff --git a/include/wlr/types/wlr_tablet_tool.h b/include/wlr/types/wlr_tablet_tool.h index 9090828a..f04dfe15 100644 --- a/include/wlr/types/wlr_tablet_tool.h +++ b/include/wlr/types/wlr_tablet_tool.h @@ -1,5 +1,6 @@ -#ifndef _WLR_TYPES_TABLET_TOOL_H -#define _WLR_TYPES_TABLET_TOOL_H +#ifndef WLR_TYPES_TABLET_TOOL_H +#define WLR_TYPES_TABLET_TOOL_H + #include #include #include diff --git a/include/wlr/types/wlr_touch.h b/include/wlr/types/wlr_touch.h index 1a27cad3..f1165c87 100644 --- a/include/wlr/types/wlr_touch.h +++ b/include/wlr/types/wlr_touch.h @@ -1,5 +1,6 @@ -#ifndef _WLR_TYPES_TOUCH_H -#define _WLR_TYPES_TOUCH_H +#ifndef WLR_TYPES_WLR_TOUCH_H +#define WLR_TYPES_WLR_TOUCH_H + #include #include diff --git a/include/wlr/types/wlr_wl_shell.h b/include/wlr/types/wlr_wl_shell.h index a085711b..1443bbf0 100644 --- a/include/wlr/types/wlr_wl_shell.h +++ b/include/wlr/types/wlr_wl_shell.h @@ -1,5 +1,6 @@ -#ifndef _WLR_WL_SHELL_H -#define _WLR_WL_SHELL_H +#ifndef WLR_TYPES_WLR_WL_SHELL_H +#define WLR_TYPES_WLR_WL_SHELL_H + #include struct wlr_wl_shell { diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h index 786bf4e6..cc52d9c7 100644 --- a/include/wlr/types/wlr_xdg_shell_v6.h +++ b/include/wlr/types/wlr_xdg_shell_v6.h @@ -1,5 +1,6 @@ -#ifndef _WLR_XDG_SHELL_V6_H -#define _WLR_XDG_SHELL_V6_H +#ifndef WLR_TYPES_WLR_XDG_SHELL_V6_H +#define WLR_TYPES_WLR_XDG_SHELL_V6_H + #include #include diff --git a/include/wlr/util/list.h b/include/wlr/util/list.h index 6e746ec4..02039d89 100644 --- a/include/wlr/util/list.h +++ b/include/wlr/util/list.h @@ -1,5 +1,5 @@ -#ifndef _WLR_UTIL_LIST_H -#define _WLR_UTIL_LIST_H +#ifndef WLR_UTIL_LIST_H +#define WLR_UTIL_LIST_H #include diff --git a/include/wlr/util/log.h b/include/wlr/util/log.h index 2acaa2ed..3de2cacf 100644 --- a/include/wlr/util/log.h +++ b/include/wlr/util/log.h @@ -1,5 +1,6 @@ -#ifndef _WLR_UTIL_LOG_H -#define _WLR_UTIL_LOG_H +#ifndef WLR_UTIL_LOG_H +#define WLR_UTIL_LOG_H + #include #include #include diff --git a/include/wlr/xcursor.h b/include/wlr/xcursor.h index ae07b4fa..c12d5405 100644 --- a/include/wlr/xcursor.h +++ b/include/wlr/xcursor.h @@ -27,8 +27,10 @@ * This is adapted from wayland-cursor, but with the wl_shm client stuff removed * so we can use it on the compositor, too. */ -#ifndef _WLR_XCURSOR_H -#define _WLR_XCURSOR_H + +#ifndef WLR_XCURSOR_H +#define WLR_XCURSOR_H + #include struct wlr_xcursor_image { diff --git a/include/wlr/xwayland.h b/include/wlr/xwayland.h index a0fb34ce..41b8042f 100644 --- a/include/wlr/xwayland.h +++ b/include/wlr/xwayland.h @@ -1,5 +1,6 @@ -#ifndef _WLR_XWAYLAND_H -#define _WLR_XWAYLAND_H +#ifndef WLR_XWAYLAND_H +#define WLR_XWAYLAND_H + #include #include #include From 4809b7b3e44e8e3ce6a5cc38294f5796baec8166 Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 23 Sep 2017 13:10:10 +0200 Subject: [PATCH 4/9] Fix some include guard names in interfaces/ --- include/wlr/interfaces/wlr_keyboard.h | 4 ++-- include/wlr/interfaces/wlr_output.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/wlr/interfaces/wlr_keyboard.h b/include/wlr/interfaces/wlr_keyboard.h index 6fbb3f68..4958e2b8 100644 --- a/include/wlr/interfaces/wlr_keyboard.h +++ b/include/wlr/interfaces/wlr_keyboard.h @@ -1,5 +1,5 @@ -#ifndef WLR_INTERFACE_WLR_KEYBOARD_H -#define WLR_INTERFACE_WLR_KEYBOARD_H +#ifndef WLR_INTERFACES_WLR_KEYBOARD_H +#define WLR_INTERFACES_WLR_KEYBOARD_H #include #include diff --git a/include/wlr/interfaces/wlr_output.h b/include/wlr/interfaces/wlr_output.h index 15a3a619..7ed19ed9 100644 --- a/include/wlr/interfaces/wlr_output.h +++ b/include/wlr/interfaces/wlr_output.h @@ -1,5 +1,5 @@ -#ifndef WLR_INTERFACE_WLR_OUTPUT_H -#define WLR_INTERFACE_WLR_OUTPUT_H +#ifndef WLR_INTERFACES_WLR_OUTPUT_H +#define WLR_INTERFACES_WLR_OUTPUT_H #include #include From 389559399830c89eee01028a9029f1f3a49a8455 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sat, 23 Sep 2017 13:21:57 -0400 Subject: [PATCH 5/9] wlr-seat: keyboard layout --- examples/compositor.c | 19 ++++--------------- include/wlr/types/wlr_seat.h | 9 +++++++++ types/wlr_seat.c | 31 ++++++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 16 deletions(-) diff --git a/examples/compositor.c b/examples/compositor.c index 0d0df88c..e09fdc14 100644 --- a/examples/compositor.c +++ b/examples/compositor.c @@ -362,19 +362,6 @@ static void handle_keyboard_key(struct keyboard_state *keyboard, } } -static void handle_keyboard_bound(struct wl_listener *listener, void *data) { - struct wlr_seat_handle *handle = data; - struct sample_state *state = - wl_container_of(listener, state, keyboard_bound); - - wl_keyboard_send_keymap(handle->keyboard, WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, - state->keymap_fd, state->keymap_size); - - if (wl_resource_get_version(handle->keyboard) >= 2) { - wl_keyboard_send_repeat_info(handle->keyboard, 25, 600); - } -} - static struct wlr_xdg_surface_v6 *example_xdg_surface_at( struct sample_state *sample, int lx, int ly) { struct wlr_xdg_surface_v6 *xdg_surface; @@ -654,8 +641,6 @@ int main(int argc, char *argv[]) { state.wl_seat = wlr_seat_create(compositor.display, "seat0"); assert(state.wl_seat); - state.keyboard_bound.notify = handle_keyboard_bound; - wl_signal_add(&state.wl_seat->events.keyboard_bound, &state.keyboard_bound); wlr_seat_set_capabilities(state.wl_seat, WL_SEAT_CAPABILITY_KEYBOARD | WL_SEAT_CAPABILITY_POINTER | WL_SEAT_CAPABILITY_TOUCH); @@ -672,6 +657,10 @@ int main(int argc, char *argv[]) { free(keymap); break; } + + wlr_seat_keyboard_set_keymap(state.wl_seat, state.keymap_fd, + state.keymap_size); + state.xwayland = wlr_xwayland_create(compositor.display, state.wlr_compositor); diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h index 21f2350d..c6bab180 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -35,6 +35,9 @@ 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 focus_surface_destroy_listener; struct wl_listener focus_resource_destroy_listener; }; @@ -150,4 +153,10 @@ 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); +/** + * Set the keymap and send it to seat keyboard resources. + */ +void wlr_seat_keyboard_set_keymap(struct wlr_seat *wlr_seat, int keymap_fd, + size_t keymap_size); + #endif diff --git a/types/wlr_seat.c b/types/wlr_seat.c index d0955959..1028cf09 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -70,7 +70,7 @@ static void wl_seat_get_keyboard(struct wl_client *client, } if (handle->keyboard) { // TODO: this is probably a protocol violation but it simplifies our - // code and it'd be stupid for clients to create several pointers for + // code and it'd be stupid for clients to create several keyboards for // the same seat wl_resource_destroy(handle->keyboard); } @@ -78,6 +78,20 @@ static void wl_seat_get_keyboard(struct wl_client *client, wl_resource_get_version(_handle), id); wl_resource_set_implementation(handle->keyboard, &wl_keyboard_impl, handle, &wl_keyboard_destroy); + + if (wl_resource_get_version(handle->keyboard) >= + WL_KEYBOARD_REPEAT_INFO_SINCE_VERSION) { + wl_keyboard_send_repeat_info(handle->keyboard, 25, 600); + } + + if (handle->wlr_seat->keyboard_state.keymap_size) { + // TODO: handle no keymap + wl_keyboard_send_keymap(handle->keyboard, + WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1, + handle->wlr_seat->keyboard_state.keymap_fd, + handle->wlr_seat->keyboard_state.keymap_size); + } + wl_signal_emit(&handle->wlr_seat->events.keyboard_bound, handle); } @@ -508,3 +522,18 @@ void wlr_seat_keyboard_send_modifiers(struct wlr_seat *wlr_seat, 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; +} From 9cde828c9491b67fb8cacdc227168dcadaa36e00 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sat, 23 Sep 2017 14:10:17 -0400 Subject: [PATCH 6/9] bugfix: correct type in keyboard resource destroy --- types/wlr_seat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/wlr_seat.c b/types/wlr_seat.c index 1028cf09..fc3b1c76 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -406,7 +406,7 @@ static void handle_keyboard_focus_surface_destroyed( static void handle_keyboard_focus_resource_destroyed( struct wl_listener *listener, void *data) { - struct wlr_seat_pointer_state *state = + struct wlr_seat_keyboard_state *state = wl_container_of(listener, state, focus_resource_destroy_listener); state->focused_surface = NULL; From 84a8f1b42dbd1882bef295cff66cd0c24afeb978 Mon Sep 17 00:00:00 2001 From: Tony Crisci Date: Sat, 23 Sep 2017 14:40:56 -0400 Subject: [PATCH 7/9] add keys array param to seat keyboard enter --- examples/compositor.c | 5 ++++- include/wlr/types/wlr_seat.h | 4 ++-- types/wlr_seat.c | 9 ++++----- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/examples/compositor.c b/examples/compositor.c index e09fdc14..8154c2e3 100644 --- a/examples/compositor.c +++ b/examples/compositor.c @@ -129,7 +129,10 @@ static void example_set_focused_surface(struct sample_state *sample, } if (surface) { - wlr_seat_keyboard_enter(sample->wl_seat, surface->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); } 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 c6bab180..a8df7131 100644 --- a/include/wlr/types/wlr_seat.h +++ b/include/wlr/types/wlr_seat.h @@ -128,10 +128,10 @@ void wlr_seat_pointer_send_axis(struct wlr_seat *wlr_seat, uint32_t time, /** * Send a keyboard enter event to the given surface and consider it to be the * focused surface for the keyboard. This will send a leave event to the last - * surface that was entered. + * surface that was entered. Pass an array of currently pressed keys. */ void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat, - struct wlr_surface *surface); + struct wlr_surface *surface, struct wl_array keys); /** * Clear the focused surface for the keyboard and leave all entered surfaces. diff --git a/types/wlr_seat.c b/types/wlr_seat.c index fc3b1c76..1d544902 100644 --- a/types/wlr_seat.c +++ b/types/wlr_seat.c @@ -414,7 +414,7 @@ static void handle_keyboard_focus_resource_destroyed( } void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat, - struct wlr_surface *surface) { + struct wlr_surface *surface, struct wl_array keys) { if (wlr_seat->keyboard_state.focused_surface == surface) { // this surface already got an enter notify return; @@ -442,9 +442,6 @@ void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat, // enter the current surface if (handle && handle->keyboard) { uint32_t serial = wl_display_next_serial(wlr_seat->display); - // TODO: send currently pressed keys - struct wl_array keys; - wl_array_init(&keys); wl_keyboard_send_enter(handle->keyboard, serial, surface->resource, &keys); @@ -475,7 +472,9 @@ void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat, } void wlr_seat_keyboard_clear_focus(struct wlr_seat *wlr_seat) { - wlr_seat_keyboard_enter(wlr_seat, NULL); + 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) { From 7288d3b2c3397448553b177a1cada1f84604654f Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Sun, 24 Sep 2017 13:57:15 +1300 Subject: [PATCH 8/9] Install library, headers, and pkg-config --- meson.build | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/meson.build b/meson.build index 4a3c670a..194e7111 100644 --- a/meson.build +++ b/meson.build @@ -20,6 +20,7 @@ add_project_link_arguments( ) wlr_inc = include_directories('include') +install_subdir('include/wlr', install_dir: 'include') cc = meson.get_compiler('c') @@ -103,6 +104,7 @@ lib_wlr = library( ], dependencies: wlr_deps, include_directories: wlr_inc, + install: true, ) wlroots = declare_dependency( @@ -112,3 +114,12 @@ wlroots = declare_dependency( ) subdir('examples') + +pkgconfig = import('pkgconfig') +pkgconfig.generate( + libraries: lib_wlr, + version: '0.0.1', + filebase: 'wlroots', + name: 'wlroots', + description: 'Wayland compositor library', +) From 91107f553a477c6eb49588bb04c2c71b7bf83e08 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Sun, 24 Sep 2017 14:52:09 +1300 Subject: [PATCH 9/9] Add Archlinux PKGBUILD script --- dist/archlinux/PKGBUILD | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 dist/archlinux/PKGBUILD diff --git a/dist/archlinux/PKGBUILD b/dist/archlinux/PKGBUILD new file mode 100644 index 00000000..a65fc7ff --- /dev/null +++ b/dist/archlinux/PKGBUILD @@ -0,0 +1,48 @@ +pkgname=wlroots +pkgver=r600.d89272d +pkgrel=1 +license=('MIT') +pkgdesc='Wayland compositor library' +makedepends=("meson") +depends=( + "wayland" + "wayland-protocols" + "mesa" + "libdrm" + "libinput" + "libxkbcommon" + "libsystemd" + "pixman" + "libxcb" +) +arch=("x86_64") +url="https://github.com/SirCmpwn/wlroots" +source=("${pkgname}::git+https://github.com/SirCmpwn/wlroots.git") +sha1sums=('SKIP') +provides=('wlroots') +conflicts=('wlroots') + +pkgver() { + cd "${srcdir}/${pkgname}" + printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" +} + +build() { + cd "${srcdir}/${pkgname}" + + meson build \ + --prefix=/usr \ + -Dbuildtype=debugoptimized \ + -Db_lto=True \ + -Denable-systemd=True \ + -Denable-elogind=False \ + -Denable-libcap=False + + ninja -C build +} + +package() { + cd "${srcdir}/${pkgname}" + + DESTDIR="${pkgdir}" ninja -C build install +}