summaryrefslogtreecommitdiff
path: root/src/platform/wayland/keyboard.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform/wayland/keyboard.c')
-rw-r--r--src/platform/wayland/keyboard.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/platform/wayland/keyboard.c b/src/platform/wayland/keyboard.c
index 86c8f07..0913079 100644
--- a/src/platform/wayland/keyboard.c
+++ b/src/platform/wayland/keyboard.c
@@ -41,11 +41,6 @@ static const char *const input_mod_names[5] = {
XKB_MOD_NAME_CAPS
};
-static bool mod_active(const struct seat *s, const char *name)
-{
- return xkb_state_mod_name_is_active(s->xkb_state, name, XKB_STATE_MODS_EFFECTIVE) > 0;
-}
-
static void resolve_input_mod_masks(struct seat *s)
{
memset(s->input_mod_masks, 0, sizeof(s->input_mod_masks));
@@ -150,7 +145,8 @@ static void keyboard_enter(void *data, struct wl_keyboard *keyboard,
{
(void)keyboard; (void)serial; (void)keys;
struct seat *s = data;
- struct wayland_surface *w = surface_root(conn_surface_for(s->conn, surface));
+ struct wayland_surface *w = surface_root(surface ?
+ (struct wayland_surface *)wl_surface_get_user_data(surface) : NULL);
bool same_window = w && w == s->focus_leaving;
if (same_window)
s->focus_leaving = NULL;
@@ -204,7 +200,9 @@ static unsigned input_modifiers(struct seat *s)
xkb_mod_mask_t reported = 0;
for (unsigned i = 0; i < 5; i++) {
xkb_mod_mask_t mask = s->input_mod_masks[i];
- if (mask && (mask & ~reported) && mod_active(s, input_mod_names[i])) {
+ if (mask && (mask & ~reported) &&
+ xkb_state_mod_name_is_active(s->xkb_state, input_mod_names[i],
+ XKB_STATE_MODS_EFFECTIVE) > 0) {
mods |= 1u << i;
reported |= mask;
}
@@ -402,31 +400,33 @@ int keyboard_repeat_init(struct seat *s)
return 0;
}
-static bool mod_index_active(const struct seat *s, xkb_mod_index_t mod)
-{
- return mod != XKB_MOD_INVALID &&
- xkb_state_mod_index_is_active(s->xkb_state, mod,
- XKB_STATE_MODS_EFFECTIVE) > 0;
-}
-
int seat_modifiers(const struct seat *s)
{
if (unlikely(!s || !s->xkb_state)) return 0;
- return (mod_index_active(s, s->mod_shift) * YASL_MOD_SHIFT) |
- (mod_index_active(s, s->mod_alt) * YASL_MOD_ALT) |
- (mod_index_active(s, s->mod_ctrl) * YASL_MOD_CTRL) |
- (mod_index_active(s, s->mod_super) * YASL_MOD_SUPER) |
- (mod_active(s, XKB_MOD_NAME_CAPS) * YASL_MOD_CAPS);
+ return ((s->mod_shift != XKB_MOD_INVALID &&
+ xkb_state_mod_index_is_active(s->xkb_state, s->mod_shift,
+ XKB_STATE_MODS_EFFECTIVE) > 0) * YASL_MOD_SHIFT) |
+ ((s->mod_alt != XKB_MOD_INVALID &&
+ xkb_state_mod_index_is_active(s->xkb_state, s->mod_alt,
+ XKB_STATE_MODS_EFFECTIVE) > 0) * YASL_MOD_ALT) |
+ ((s->mod_ctrl != XKB_MOD_INVALID &&
+ xkb_state_mod_index_is_active(s->xkb_state, s->mod_ctrl,
+ XKB_STATE_MODS_EFFECTIVE) > 0) * YASL_MOD_CTRL) |
+ ((s->mod_super != XKB_MOD_INVALID &&
+ xkb_state_mod_index_is_active(s->xkb_state, s->mod_super,
+ XKB_STATE_MODS_EFFECTIVE) > 0) * YASL_MOD_SUPER) |
+ ((xkb_state_mod_name_is_active(s->xkb_state, XKB_MOD_NAME_CAPS,
+ XKB_STATE_MODS_EFFECTIVE) > 0) * YASL_MOD_CAPS);
}
int wayland_display_modifiers(const struct wayland_display *c)
{
- return c ? seat_modifiers(conn_active_seat(c)) : 0;
+ return c ? seat_modifiers(c->active_seat ? c->active_seat : c->seats) : 0;
}
void wayland_display_copy(struct wayland_display *c, enum yasl_selection sel, const char *text)
{
- struct seat *s = c ? conn_active_seat(c) : NULL;
+ struct seat *s = c ? (c->active_seat ? c->active_seat : c->seats) : NULL;
if (!s || !s->clipboard)
return;
if (sel == YASL_PRIMARY)
@@ -437,7 +437,7 @@ void wayland_display_copy(struct wayland_display *c, enum yasl_selection sel, co
void wayland_display_paste(struct wayland_display *c, enum yasl_selection sel, struct wayland_surface *target)
{
- struct seat *s = c ? conn_active_seat(c) : NULL;
+ struct seat *s = c ? (c->active_seat ? c->active_seat : c->seats) : NULL;
if (!s || !s->clipboard)
return;
if (!target || target->closed) return;