aboutsummaryrefslogtreecommitdiff
path: root/include/wlr
diff options
context:
space:
mode:
authorTony Crisci <tony@dubstepdish.com>2017-10-07 11:02:11 -0400
committerTony Crisci <tony@dubstepdish.com>2017-10-07 12:52:02 -0400
commit4680943e749bfd441d31c988faa50f2b1ae043ad (patch)
treeaf373f358e51f430d04926a6972775a1bd555718 /include/wlr
parent27ee171d251e60d302f063196ccc5100028dcfff (diff)
xdg-seat: keyboard grabs
Diffstat (limited to 'include/wlr')
-rw-r--r--include/wlr/types/wlr_seat.h69
-rw-r--r--include/wlr/types/wlr_xdg_shell_v6.h1
2 files changed, 68 insertions, 2 deletions
diff --git a/include/wlr/types/wlr_seat.h b/include/wlr/types/wlr_seat.h
index 6b66fd69..d3d3e00d 100644
--- a/include/wlr/types/wlr_seat.h
+++ b/include/wlr/types/wlr_seat.h
@@ -38,6 +38,28 @@ struct wlr_pointer_grab_interface {
void (*cancel)(struct wlr_seat_pointer_grab *grab);
};
+struct wlr_seat_keyboard_grab;
+
+struct wlr_keyboard_grab_interface {
+ void (*enter)(struct wlr_seat_keyboard_grab *grab, struct wlr_surface *surface);
+ void (*key)(struct wlr_seat_keyboard_grab *grab, uint32_t time,
+ uint32_t key, uint32_t state);
+ void (*modifiers)(struct wlr_seat_keyboard_grab *grab,
+ uint32_t mods_depressed, uint32_t mods_latched,
+ uint32_t mods_locked, uint32_t group);
+ void (*cancel)(struct wlr_seat_keyboard_grab *grab);
+};
+
+/**
+ * Passed to `wlr_seat_keyboard_start_grab()` to start a grab of the keyboard.
+ * The grabber is responsible for handling keyboard events for the seat.
+ */
+struct wlr_seat_keyboard_grab {
+ const struct wlr_keyboard_grab_interface *interface;
+ struct wlr_seat *seat;
+ void *data;
+};
+
/**
* Passed to `wlr_seat_pointer_start_grab()` to start a grab of the pointer. The
* grabber is responsible for handling pointer events for the seat.
@@ -77,6 +99,9 @@ struct wlr_seat_keyboard_state {
struct wl_listener surface_destroy;
struct wl_listener resource_destroy;
+
+ struct wlr_seat_keyboard_grab *grab;
+ struct wlr_seat_keyboard_grab *default_grab;
};
struct wlr_seat {
@@ -97,12 +122,14 @@ struct wlr_seat {
struct wl_signal pointer_grab_begin;
struct wl_signal pointer_grab_end;
+
+ struct wl_signal keyboard_grab_begin;
+ struct wl_signal keyboard_grab_end;
} events;
void *data;
};
-
/**
* Allocates a new wlr_seat and adds a wl_seat global to the display.
*/
@@ -232,9 +259,47 @@ void wlr_seat_attach_keyboard(struct wlr_seat *seat,
void wlr_seat_detach_keyboard(struct wlr_seat *seat, struct wlr_keyboard *kb);
/**
+ * Start a grab of the keyboard of this seat. The grabber is responsible for
+ * handling all keyboard events until the grab ends.
+ */
+void wlr_seat_keyboard_start_grab(struct wlr_seat *wlr_seat,
+ struct wlr_seat_keyboard_grab *grab);
+
+/**
+ * End the grab of the keyboard of this seat. This reverts the grab back to the
+ * default grab for the keyboard.
+ */
+void wlr_seat_keyboard_end_grab(struct wlr_seat *wlr_seat);
+
+/**
+ * Send the keyboard key to focused keyboard resources. Compositors should use
+ * `wlr_seat_attach_keyboard()` to automatically handle keyboard events.
+ */
+void wlr_seat_keyboard_send_key(struct wlr_seat *seat, uint32_t time,
+ uint32_t key, uint32_t state);
+
+/**
+ * Send the modifier state to focused keyboard resources. Compositors should use
+ * `wlr_seat_attach_keyboard()` to automatically handle keyboard events.
+ */
+void wlr_seat_keyboard_send_modifiers(struct wlr_seat *seat,
+ uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked,
+ uint32_t group);
+
+/**
+ * Notify the seat that the keyboard focus has changed and request it to be the
+ * focused surface for this keyboard. Defers to any current grab of the seat's
+ * keyboard.
+ */
+void wlr_seat_keyboard_notify_enter(struct wlr_seat *wlr_seat,
+ struct wlr_surface *surface);
+
+/**
* 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. Pass an array of currently pressed keys.
+ * surface that was entered. Compositors should use
+ * `wlr_seat_keyboard_notify_enter()` to change keyboard focus to respect
+ * keyboard grabs.
*/
void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat,
struct wlr_surface *surface);
diff --git a/include/wlr/types/wlr_xdg_shell_v6.h b/include/wlr/types/wlr_xdg_shell_v6.h
index c7067e80..0a633822 100644
--- a/include/wlr/types/wlr_xdg_shell_v6.h
+++ b/include/wlr/types/wlr_xdg_shell_v6.h
@@ -46,6 +46,7 @@ struct wlr_xdg_popup_v6 {
struct wlr_xdg_popup_grab_v6 {
struct wl_client *client;
struct wlr_seat_pointer_grab pointer_grab;
+ struct wlr_seat_keyboard_grab keyboard_grab;
struct wlr_seat *seat;
struct wl_list popups;
struct wl_list link; // wlr_xdg_shell_v6::popup_grabs