xdg-seat: keyboard grabs

This commit is contained in:
Tony Crisci 2017-10-07 11:02:11 -04:00
parent 27ee171d25
commit 4680943e74
5 changed files with 211 additions and 18 deletions

View file

@ -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.
*/
@ -231,10 +258,48 @@ 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);

View file

@ -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