Always read state from wlr_keyboard in the seat
This commit is contained in:
parent
84d5e6bbb4
commit
882e620639
|
@ -45,9 +45,7 @@ struct wlr_keyboard_grab_interface {
|
||||||
struct wlr_surface *surface);
|
struct wlr_surface *surface);
|
||||||
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);
|
||||||
uint32_t mods_depressed, uint32_t mods_latched,
|
|
||||||
uint32_t mods_locked, uint32_t group);
|
|
||||||
void (*cancel)(struct wlr_seat_keyboard_grab *grab);
|
void (*cancel)(struct wlr_seat_keyboard_grab *grab);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -296,17 +294,13 @@ void wlr_seat_keyboard_notify_key(struct wlr_seat *seat, uint32_t time,
|
||||||
* Send the modifier state to focused keyboard resources. Compositors should use
|
* Send the modifier state to focused keyboard resources. Compositors should use
|
||||||
* `wlr_seat_keyboard_notify_modifiers()` to respect any keyboard grabs.
|
* `wlr_seat_keyboard_notify_modifiers()` to respect any keyboard grabs.
|
||||||
*/
|
*/
|
||||||
void wlr_seat_keyboard_send_modifiers(struct wlr_seat *seat,
|
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 modifiers for the keyboard have changed. Defers to
|
* Notify the seat that the modifiers for the keyboard have changed. Defers to
|
||||||
* any keyboard grabs.
|
* any keyboard grabs.
|
||||||
*/
|
*/
|
||||||
void wlr_seat_keyboard_notify_modifiers(struct wlr_seat *seat,
|
void wlr_seat_keyboard_notify_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
|
* Notify the seat that the keyboard focus has changed and request it to be the
|
||||||
|
|
|
@ -133,7 +133,6 @@ void view_teardown(struct roots_view *view) {
|
||||||
struct roots_view *prev_view = views->items[views->length-2];
|
struct roots_view *prev_view = views->items[views->length-2];
|
||||||
struct roots_input *input = prev_view->desktop->server->input;
|
struct roots_input *input = prev_view->desktop->server->input;
|
||||||
set_view_focus(input, prev_view->desktop, prev_view);
|
set_view_focus(input, prev_view->desktop, prev_view);
|
||||||
wlr_seat_keyboard_notify_enter(input->wl_seat, prev_view->wlr_surface);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
|
struct roots_view *view_at(struct roots_desktop *desktop, double lx, double ly,
|
||||||
|
|
|
@ -135,8 +135,8 @@ static bool keyboard_keysyms_simple(struct roots_keyboard *keyboard,
|
||||||
const xkb_keysym_t *syms;
|
const xkb_keysym_t *syms;
|
||||||
xkb_layout_index_t layout_index = xkb_state_key_get_layout(
|
xkb_layout_index_t layout_index = xkb_state_key_get_layout(
|
||||||
keyboard->device->keyboard->xkb_state, keycode);
|
keyboard->device->keyboard->xkb_state, keycode);
|
||||||
int syms_len = xkb_keymap_key_get_syms_by_level(keyboard->device->keyboard->keymap,
|
int syms_len = xkb_keymap_key_get_syms_by_level(
|
||||||
keycode, layout_index, 0, &syms);
|
keyboard->device->keyboard->keymap, keycode, layout_index, 0, &syms);
|
||||||
|
|
||||||
bool handled = false;
|
bool handled = false;
|
||||||
for (int i = 0; i < syms_len; i++) {
|
for (int i = 0; i < syms_len; i++) {
|
||||||
|
@ -195,7 +195,8 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) {
|
||||||
bool handled = keyboard_keysyms_xkb(keyboard, keycode, event->state);
|
bool handled = keyboard_keysyms_xkb(keyboard, keycode, event->state);
|
||||||
|
|
||||||
if (!handled) {
|
if (!handled) {
|
||||||
bool key_handled = keyboard_keysyms_simple(keyboard, keycode, event->state);
|
bool key_handled = keyboard_keysyms_simple(keyboard, keycode,
|
||||||
|
event->state);
|
||||||
handled = handled || key_handled;
|
handled = handled || key_handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,17 +208,11 @@ static void keyboard_key_notify(struct wl_listener *listener, void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void keyboard_modifiers_notify(struct wl_listener *listener, void *data) {
|
static void keyboard_modifiers_notify(struct wl_listener *listener, void *data) {
|
||||||
struct roots_keyboard *r_keyboard =
|
struct roots_keyboard *keyboard =
|
||||||
wl_container_of(listener, r_keyboard, modifiers);
|
wl_container_of(listener, keyboard, modifiers);
|
||||||
struct wlr_seat *seat = r_keyboard->input->wl_seat;
|
struct wlr_seat *seat = keyboard->input->wl_seat;
|
||||||
struct wlr_keyboard *keyboard = r_keyboard->device->keyboard;
|
wlr_seat_set_keyboard(seat, keyboard->device);
|
||||||
wlr_seat_set_keyboard(seat, r_keyboard->device);
|
wlr_seat_keyboard_notify_modifiers(seat);
|
||||||
wlr_seat_keyboard_notify_modifiers(seat,
|
|
||||||
keyboard->modifiers.depressed,
|
|
||||||
keyboard->modifiers.latched,
|
|
||||||
keyboard->modifiers.locked,
|
|
||||||
keyboard->modifiers.group);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void keyboard_config_merge(struct keyboard_config *config,
|
static void keyboard_config_merge(struct keyboard_config *config,
|
||||||
|
|
|
@ -531,9 +531,8 @@ static void keyboard_drag_key(struct wlr_seat_keyboard_grab *grab,
|
||||||
// no keyboard input during drags
|
// no keyboard input during drags
|
||||||
}
|
}
|
||||||
|
|
||||||
static void keyboard_drag_modifiers(struct wlr_seat_keyboard_grab *grab,
|
static void keyboard_drag_modifiers(struct wlr_seat_keyboard_grab *grab) {
|
||||||
uint32_t mods_depressed, uint32_t mods_latched,
|
//struct wlr_keyboard *keyboard = grab->seat->keyboard_state.keyboard;
|
||||||
uint32_t mods_locked, uint32_t group) {
|
|
||||||
// TODO change the dnd action based on what modifier is pressed on the
|
// TODO change the dnd action based on what modifier is pressed on the
|
||||||
// keyboard
|
// keyboard
|
||||||
}
|
}
|
||||||
|
|
|
@ -284,11 +284,8 @@ static void default_keyboard_key(struct wlr_seat_keyboard_grab *grab,
|
||||||
wlr_seat_keyboard_send_key(grab->seat, time, key, state);
|
wlr_seat_keyboard_send_key(grab->seat, time, key, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void default_keyboard_modifiers(struct wlr_seat_keyboard_grab *grab,
|
static void default_keyboard_modifiers(struct wlr_seat_keyboard_grab *grab) {
|
||||||
uint32_t mods_depressed, uint32_t mods_latched,
|
wlr_seat_keyboard_send_modifiers(grab->seat);
|
||||||
uint32_t mods_locked, uint32_t group) {
|
|
||||||
wlr_seat_keyboard_send_modifiers(grab->seat, mods_depressed,
|
|
||||||
mods_latched, mods_locked, group);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void default_keyboard_cancel(struct wlr_seat_keyboard_grab *grab) {
|
static void default_keyboard_cancel(struct wlr_seat_keyboard_grab *grab) {
|
||||||
|
@ -708,24 +705,26 @@ static void keyboard_resource_destroy_notify(struct wl_listener *listener,
|
||||||
wlr_seat_keyboard_clear_focus(state->seat);
|
wlr_seat_keyboard_clear_focus(state->seat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_seat_keyboard_send_modifiers(struct wlr_seat *seat,
|
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) {
|
|
||||||
struct wlr_seat_client *client = seat->keyboard_state.focused_client;
|
struct wlr_seat_client *client = seat->keyboard_state.focused_client;
|
||||||
if (!client || !client->keyboard) {
|
if (!client || !client->keyboard) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t serial = wl_display_next_serial(seat->display);
|
struct wlr_keyboard *keyboard = seat->keyboard_state.keyboard;
|
||||||
|
if (!keyboard) {
|
||||||
wl_keyboard_send_modifiers(client->keyboard, serial,
|
return;
|
||||||
mods_depressed, mods_latched,
|
|
||||||
mods_locked, group);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat,
|
uint32_t serial = wl_display_next_serial(seat->display);
|
||||||
|
wl_keyboard_send_modifiers(client->keyboard, serial,
|
||||||
|
keyboard->modifiers.depressed, keyboard->modifiers.latched,
|
||||||
|
keyboard->modifiers.locked, keyboard->modifiers.group);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wlr_seat_keyboard_enter(struct wlr_seat *seat,
|
||||||
struct wlr_surface *surface) {
|
struct wlr_surface *surface) {
|
||||||
if (wlr_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;
|
||||||
}
|
}
|
||||||
|
@ -734,24 +733,24 @@ void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat,
|
||||||
|
|
||||||
if (surface) {
|
if (surface) {
|
||||||
struct wl_client *wl_client = wl_resource_get_client(surface->resource);
|
struct wl_client *wl_client = wl_resource_get_client(surface->resource);
|
||||||
client = wlr_seat_client_for_wl_client(wlr_seat, wl_client);
|
client = wlr_seat_client_for_wl_client(seat, wl_client);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct wlr_seat_client *focused_client =
|
struct wlr_seat_client *focused_client =
|
||||||
wlr_seat->keyboard_state.focused_client;
|
seat->keyboard_state.focused_client;
|
||||||
struct wlr_surface *focused_surface =
|
struct wlr_surface *focused_surface =
|
||||||
wlr_seat->keyboard_state.focused_surface;
|
seat->keyboard_state.focused_surface;
|
||||||
|
|
||||||
// leave the previously entered surface
|
// leave the previously entered surface
|
||||||
if (focused_client && focused_client->keyboard && focused_surface) {
|
if (focused_client && focused_client->keyboard && focused_surface) {
|
||||||
uint32_t serial = wl_display_next_serial(wlr_seat->display);
|
uint32_t serial = wl_display_next_serial(seat->display);
|
||||||
wl_keyboard_send_leave(focused_client->keyboard, serial,
|
wl_keyboard_send_leave(focused_client->keyboard, serial,
|
||||||
focused_surface->resource);
|
focused_surface->resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
// enter the current surface
|
// enter the current surface
|
||||||
if (client && client->keyboard) {
|
if (client && client->keyboard && seat->keyboard_state.keyboard) {
|
||||||
struct wlr_keyboard *keyboard = wlr_seat->keyboard_state.keyboard;
|
struct wlr_keyboard *keyboard = seat->keyboard_state.keyboard;
|
||||||
|
|
||||||
struct wl_array keys;
|
struct wl_array keys;
|
||||||
wl_array_init(&keys);
|
wl_array_init(&keys);
|
||||||
|
@ -763,55 +762,50 @@ void wlr_seat_keyboard_enter(struct wlr_seat *wlr_seat,
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint32_t serial = wl_display_next_serial(wlr_seat->display);
|
uint32_t serial = wl_display_next_serial(seat->display);
|
||||||
wl_keyboard_send_enter(client->keyboard, serial,
|
wl_keyboard_send_enter(client->keyboard, serial,
|
||||||
surface->resource, &keys);
|
surface->resource, &keys);
|
||||||
wl_array_release(&keys);
|
wl_array_release(&keys);
|
||||||
|
|
||||||
wlr_seat_keyboard_send_modifiers(wlr_seat,
|
wlr_seat_keyboard_send_modifiers(seat);
|
||||||
keyboard->modifiers.depressed, keyboard->modifiers.latched,
|
|
||||||
keyboard->modifiers.locked, keyboard->modifiers.group);
|
|
||||||
wlr_seat_client_send_selection(client);
|
wlr_seat_client_send_selection(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reinitialize the focus destroy events
|
// reinitialize the focus destroy events
|
||||||
wl_list_remove(&wlr_seat->keyboard_state.surface_destroy.link);
|
wl_list_remove(&seat->keyboard_state.surface_destroy.link);
|
||||||
wl_list_init(&wlr_seat->keyboard_state.surface_destroy.link);
|
wl_list_init(&seat->keyboard_state.surface_destroy.link);
|
||||||
wl_list_remove(&wlr_seat->keyboard_state.resource_destroy.link);
|
wl_list_remove(&seat->keyboard_state.resource_destroy.link);
|
||||||
wl_list_init(&wlr_seat->keyboard_state.resource_destroy.link);
|
wl_list_init(&seat->keyboard_state.resource_destroy.link);
|
||||||
if (surface) {
|
if (surface) {
|
||||||
wl_signal_add(&surface->events.destroy,
|
wl_signal_add(&surface->events.destroy,
|
||||||
&wlr_seat->keyboard_state.surface_destroy);
|
&seat->keyboard_state.surface_destroy);
|
||||||
wl_resource_add_destroy_listener(surface->resource,
|
wl_resource_add_destroy_listener(surface->resource,
|
||||||
&wlr_seat->keyboard_state.resource_destroy);
|
&seat->keyboard_state.resource_destroy);
|
||||||
wlr_seat->keyboard_state.resource_destroy.notify =
|
seat->keyboard_state.resource_destroy.notify =
|
||||||
keyboard_resource_destroy_notify;
|
keyboard_resource_destroy_notify;
|
||||||
wlr_seat->keyboard_state.surface_destroy.notify =
|
seat->keyboard_state.surface_destroy.notify =
|
||||||
keyboard_surface_destroy_notify;
|
keyboard_surface_destroy_notify;
|
||||||
}
|
}
|
||||||
|
|
||||||
wlr_seat->keyboard_state.focused_client = client;
|
seat->keyboard_state.focused_client = client;
|
||||||
wlr_seat->keyboard_state.focused_surface = surface;
|
seat->keyboard_state.focused_surface = surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_seat_keyboard_notify_enter(struct wlr_seat *wlr_seat, struct
|
void wlr_seat_keyboard_notify_enter(struct wlr_seat *seat, struct
|
||||||
wlr_surface *surface) {
|
wlr_surface *surface) {
|
||||||
struct wlr_seat_keyboard_grab *grab = wlr_seat->keyboard_state.grab;
|
struct wlr_seat_keyboard_grab *grab = seat->keyboard_state.grab;
|
||||||
grab->interface->enter(grab, surface);
|
grab->interface->enter(grab, surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_seat_keyboard_clear_focus(struct wlr_seat *wlr_seat) {
|
void wlr_seat_keyboard_clear_focus(struct wlr_seat *seat) {
|
||||||
struct wl_array keys;
|
struct wl_array keys;
|
||||||
wl_array_init(&keys);
|
wl_array_init(&keys);
|
||||||
wlr_seat_keyboard_enter(wlr_seat, NULL);
|
wlr_seat_keyboard_enter(seat, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_seat_keyboard_notify_modifiers(struct wlr_seat *seat,
|
void wlr_seat_keyboard_notify_modifiers(struct wlr_seat *seat) {
|
||||||
uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked,
|
|
||||||
uint32_t group) {
|
|
||||||
struct wlr_seat_keyboard_grab *grab = seat->keyboard_state.grab;
|
struct wlr_seat_keyboard_grab *grab = seat->keyboard_state.grab;
|
||||||
grab->interface->modifiers(grab,
|
grab->interface->modifiers(grab);
|
||||||
mods_depressed, mods_latched, mods_locked, group);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wlr_seat_keyboard_notify_key(struct wlr_seat *seat, uint32_t time,
|
void wlr_seat_keyboard_notify_key(struct wlr_seat *seat, uint32_t time,
|
||||||
|
|
|
@ -111,11 +111,8 @@ static void xdg_keyboard_grab_key(struct wlr_seat_keyboard_grab *grab, uint32_t
|
||||||
wlr_seat_keyboard_send_key(grab->seat, time, key, state);
|
wlr_seat_keyboard_send_key(grab->seat, time, key, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_keyboard_grab_modifiers(struct wlr_seat_keyboard_grab *grab,
|
static void xdg_keyboard_grab_modifiers(struct wlr_seat_keyboard_grab *grab) {
|
||||||
uint32_t mods_depressed, uint32_t mods_latched,
|
wlr_seat_keyboard_send_modifiers(grab->seat);
|
||||||
uint32_t mods_locked, uint32_t group) {
|
|
||||||
wlr_seat_keyboard_send_modifiers(grab->seat, mods_depressed, mods_latched,
|
|
||||||
mods_locked, group);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void xdg_keyboard_grab_cancel(struct wlr_seat_keyboard_grab *grab) {
|
static void xdg_keyboard_grab_cancel(struct wlr_seat_keyboard_grab *grab) {
|
||||||
|
|
Loading…
Reference in New Issue