keyboard grab enter with modifiers
This commit is contained in:
parent
2bd3a75f80
commit
b40a5f084a
|
@ -68,7 +68,8 @@ struct wlr_seat_keyboard_grab;
|
||||||
|
|
||||||
struct wlr_keyboard_grab_interface {
|
struct wlr_keyboard_grab_interface {
|
||||||
void (*enter)(struct wlr_seat_keyboard_grab *grab,
|
void (*enter)(struct wlr_seat_keyboard_grab *grab,
|
||||||
struct wlr_surface *surface);
|
struct wlr_surface *surface, uint32_t keycodes[],
|
||||||
|
size_t num_keycodes, struct wlr_keyboard_modifiers *modifiers);
|
||||||
void (*key)(struct wlr_seat_keyboard_grab *grab, uint32_t time,
|
void (*key)(struct wlr_seat_keyboard_grab *grab, uint32_t time,
|
||||||
uint32_t key, uint32_t state);
|
uint32_t key, uint32_t state);
|
||||||
void (*modifiers)(struct wlr_seat_keyboard_grab *grab,
|
void (*modifiers)(struct wlr_seat_keyboard_grab *grab,
|
||||||
|
@ -396,8 +397,9 @@ void wlr_seat_keyboard_notify_modifiers(struct wlr_seat *seat,
|
||||||
* focused surface for this keyboard. Defers to any current grab of the seat's
|
* focused surface for this keyboard. Defers to any current grab of the seat's
|
||||||
* keyboard.
|
* keyboard.
|
||||||
*/
|
*/
|
||||||
void wlr_seat_keyboard_notify_enter(struct wlr_seat *wlr_seat,
|
void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat,
|
||||||
struct wlr_surface *surface);
|
struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes,
|
||||||
|
struct wlr_keyboard_modifiers *modifiers);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a keyboard enter event to the given surface and consider it to be the
|
* Send a keyboard enter event to the given surface and consider it to be the
|
||||||
|
@ -406,8 +408,9 @@ void wlr_seat_keyboard_notify_enter(struct wlr_seat *wlr_seat,
|
||||||
* `wlr_seat_keyboard_notify_enter()` to change keyboard focus to respect
|
* `wlr_seat_keyboard_notify_enter()` to change keyboard focus to respect
|
||||||
* keyboard grabs.
|
* keyboard grabs.
|
||||||
*/
|
*/
|
||||||
void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat,
|
void wlr_seat_keyboard_enter(struct wlr_seat *seat,
|
||||||
struct wlr_surface *surface);
|
struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes,
|
||||||
|
struct wlr_keyboard_modifiers *modifiers);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the focused surface for the keyboard and leave all entered surfaces.
|
* Clear the focused surface for the keyboard and leave all entered surfaces.
|
||||||
|
|
|
@ -616,7 +616,16 @@ void roots_seat_set_focus(struct roots_seat *seat, struct roots_view *view) {
|
||||||
seat->has_focus = true;
|
seat->has_focus = true;
|
||||||
wl_list_remove(&seat_view->link);
|
wl_list_remove(&seat_view->link);
|
||||||
wl_list_insert(&seat->views, &seat_view->link);
|
wl_list_insert(&seat->views, &seat_view->link);
|
||||||
wlr_seat_keyboard_notify_enter(seat->seat, view->wlr_surface);
|
|
||||||
|
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->seat);
|
||||||
|
if (keyboard != NULL) {
|
||||||
|
wlr_seat_keyboard_notify_enter(seat->seat, view->wlr_surface,
|
||||||
|
keyboard->keycodes, keyboard->num_keycodes,
|
||||||
|
keyboard->modifiers);
|
||||||
|
} else {
|
||||||
|
wlr_seat_keyboard_notify_enter(seat->seat, view->wlr_surface,
|
||||||
|
NULL, 0, NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void roots_seat_cycle_focus(struct roots_seat *seat) {
|
void roots_seat_cycle_focus(struct roots_seat *seat) {
|
||||||
|
|
|
@ -585,7 +585,8 @@ const struct wlr_touch_grab_interface wlr_data_device_touch_drag_interface = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void keyboard_drag_enter(struct wlr_seat_keyboard_grab *grab,
|
static void keyboard_drag_enter(struct wlr_seat_keyboard_grab *grab,
|
||||||
struct wlr_surface *surface) {
|
struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes,
|
||||||
|
struct wlr_keyboard_modifiers *modifiers) {
|
||||||
// nothing has keyboard focus during drags
|
// nothing has keyboard focus during drags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -282,8 +282,9 @@ static const struct wlr_pointer_grab_interface default_pointer_grab_impl = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void default_keyboard_enter(struct wlr_seat_keyboard_grab *grab,
|
static void default_keyboard_enter(struct wlr_seat_keyboard_grab *grab,
|
||||||
struct wlr_surface *surface) {
|
struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes,
|
||||||
wlr_seat_keyboard_enter(grab->seat, surface);
|
struct wlr_keyboard_modifiers *modifiers) {
|
||||||
|
wlr_seat_keyboard_enter(grab->seat, surface, keycodes, num_keycodes, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void default_keyboard_key(struct wlr_seat_keyboard_grab *grab,
|
static void default_keyboard_key(struct wlr_seat_keyboard_grab *grab,
|
||||||
|
@ -851,14 +852,19 @@ void wlr_seat_keyboard_send_modifiers(struct wlr_seat *seat,
|
||||||
uint32_t serial = wl_display_next_serial(seat->display);
|
uint32_t serial = wl_display_next_serial(seat->display);
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
wl_resource_for_each(resource, &client->keyboards) {
|
wl_resource_for_each(resource, &client->keyboards) {
|
||||||
wl_keyboard_send_modifiers(resource, serial,
|
if (modifiers == NULL) {
|
||||||
modifiers->depressed, modifiers->latched,
|
wl_keyboard_send_modifiers(resource, serial, 0, 0, 0, 0);
|
||||||
modifiers->locked, modifiers->group);
|
} else {
|
||||||
|
wl_keyboard_send_modifiers(resource, serial,
|
||||||
|
modifiers->depressed, modifiers->latched,
|
||||||
|
modifiers->locked, modifiers->group);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_seat_keyboard_enter(struct wlr_seat *seat,
|
void wlr_seat_keyboard_enter(struct wlr_seat *seat,
|
||||||
struct wlr_surface *surface) {
|
struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes,
|
||||||
|
struct wlr_keyboard_modifiers *modifiers) {
|
||||||
if (seat->keyboard_state.focused_surface == surface) {
|
if (seat->keyboard_state.focused_surface == surface) {
|
||||||
// this surface already got an enter notify
|
// this surface already got an enter notify
|
||||||
return;
|
return;
|
||||||
|
@ -886,19 +892,17 @@ void wlr_seat_keyboard_enter(struct wlr_seat *seat,
|
||||||
}
|
}
|
||||||
|
|
||||||
// enter the current surface
|
// enter the current surface
|
||||||
if (client != NULL && seat->keyboard_state.keyboard != NULL) {
|
if (client != NULL) {
|
||||||
struct wlr_keyboard *keyboard = seat->keyboard_state.keyboard;
|
|
||||||
|
|
||||||
struct wl_array keys;
|
struct wl_array keys;
|
||||||
wl_array_init(&keys);
|
wl_array_init(&keys);
|
||||||
for (size_t i = 0; i < keyboard->num_keycodes; ++i) {
|
for (size_t i = 0; i < num_keycodes; ++i) {
|
||||||
uint32_t *p = wl_array_add(&keys, sizeof(uint32_t));
|
uint32_t *p = wl_array_add(&keys, sizeof(uint32_t));
|
||||||
if (!p) {
|
if (!p) {
|
||||||
wlr_log(L_ERROR, "Cannot allocate memory, skipping keycode: %d\n",
|
wlr_log(L_ERROR, "Cannot allocate memory, skipping keycode: %d\n",
|
||||||
keyboard->keycodes[i]);
|
keycodes[i]);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
*p = keyboard->keycodes[i];
|
*p = keycodes[i];
|
||||||
}
|
}
|
||||||
uint32_t serial = wl_display_next_serial(seat->display);
|
uint32_t serial = wl_display_next_serial(seat->display);
|
||||||
struct wl_resource *resource;
|
struct wl_resource *resource;
|
||||||
|
@ -930,24 +934,23 @@ void wlr_seat_keyboard_enter(struct wlr_seat *seat,
|
||||||
seat->keyboard_state.focused_client = client;
|
seat->keyboard_state.focused_client = client;
|
||||||
seat->keyboard_state.focused_surface = surface;
|
seat->keyboard_state.focused_surface = surface;
|
||||||
|
|
||||||
if (client != NULL && seat->keyboard_state.keyboard != NULL) {
|
if (client != NULL) {
|
||||||
// tell new client about any modifier change last,
|
// tell new client about any modifier change last,
|
||||||
// as it targets seat->keyboard_state.focused_client
|
// as it targets seat->keyboard_state.focused_client
|
||||||
wlr_seat_keyboard_send_modifiers(seat,
|
wlr_seat_keyboard_send_modifiers(seat, modifiers);
|
||||||
seat->keyboard_state.keyboard->modifiers);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat, struct
|
void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat,
|
||||||
wlr_surface *surface) {
|
struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes,
|
||||||
|
struct wlr_keyboard_modifiers *modifiers) {
|
||||||
struct wlr_seat_keyboard_grab *grab = seat->keyboard_state.grab;
|
struct wlr_seat_keyboard_grab *grab = seat->keyboard_state.grab;
|
||||||
grab->interface->enter(grab, surface);
|
grab->interface->enter(grab, surface, keycodes, num_keycodes, modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_seat_keyboard_clear_focus(struct wlr_seat *seat) {
|
void wlr_seat_keyboard_clear_focus(struct wlr_seat *seat) {
|
||||||
struct wl_array keys;
|
// TODO respect grabs here?
|
||||||
wl_array_init(&keys);
|
wlr_seat_keyboard_enter(seat, NULL, NULL, 0, NULL);
|
||||||
wlr_seat_keyboard_enter(seat, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wlr_seat_keyboard_has_grab(struct wlr_seat *seat) {
|
bool wlr_seat_keyboard_has_grab(struct wlr_seat *seat) {
|
||||||
|
|
|
@ -103,7 +103,9 @@ static const struct wlr_pointer_grab_interface xdg_pointer_grab_impl = {
|
||||||
.axis = xdg_pointer_grab_axis,
|
.axis = xdg_pointer_grab_axis,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void xdg_keyboard_grab_enter(struct wlr_seat_keyboard_grab *grab, struct wlr_surface *surface) {
|
static void xdg_keyboard_grab_enter(struct wlr_seat_keyboard_grab *grab,
|
||||||
|
struct wlr_surface *surface, uint32_t keycodes[], size_t num_keycodes,
|
||||||
|
struct wlr_keyboard_modifiers *modifiers) {
|
||||||
// keyboard focus should remain on the popup
|
// keyboard focus should remain on the popup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue