Rename modifier_state_changed to notify_modifiers
notify_modifiers will now synchronise Weston's internal state with the XKB state, and send a modifier event if necessary. This eliminates the need for update_modifier_state to have a return value at all. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
committed by
Kristian Høgsberg
parent
1b4e11f38e
commit
05d58682b3
+28
-19
@@ -1756,13 +1756,16 @@ notify_axis(struct wl_seat *seat, uint32_t time, uint32_t axis,
|
|||||||
value);
|
value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
WL_EXPORT void
|
||||||
modifier_state_changed(struct weston_seat *seat)
|
notify_modifiers(struct wl_seat *wl_seat, uint32_t serial)
|
||||||
{
|
{
|
||||||
|
struct weston_seat *seat = (struct weston_seat *) wl_seat;
|
||||||
|
struct wl_keyboard *keyboard = &seat->keyboard;
|
||||||
|
struct wl_keyboard_grab *grab = keyboard->grab;
|
||||||
uint32_t mods_depressed, mods_latched, mods_locked, group;
|
uint32_t mods_depressed, mods_latched, mods_locked, group;
|
||||||
uint32_t mods_lookup;
|
uint32_t mods_lookup;
|
||||||
enum weston_led leds = 0;
|
enum weston_led leds = 0;
|
||||||
int ret = 0;
|
int changed = 0;
|
||||||
|
|
||||||
/* Serialize and update our internal state, checking to see if it's
|
/* Serialize and update our internal state, checking to see if it's
|
||||||
* different to the previous state. */
|
* different to the previous state. */
|
||||||
@@ -1779,7 +1782,7 @@ modifier_state_changed(struct weston_seat *seat)
|
|||||||
mods_latched != seat->seat.keyboard->modifiers.mods_latched ||
|
mods_latched != seat->seat.keyboard->modifiers.mods_latched ||
|
||||||
mods_locked != seat->seat.keyboard->modifiers.mods_locked ||
|
mods_locked != seat->seat.keyboard->modifiers.mods_locked ||
|
||||||
group != seat->seat.keyboard->modifiers.group)
|
group != seat->seat.keyboard->modifiers.group)
|
||||||
ret = 1;
|
changed = 1;
|
||||||
|
|
||||||
seat->seat.keyboard->modifiers.mods_depressed = mods_depressed;
|
seat->seat.keyboard->modifiers.mods_depressed = mods_depressed;
|
||||||
seat->seat.keyboard->modifiers.mods_latched = mods_latched;
|
seat->seat.keyboard->modifiers.mods_latched = mods_latched;
|
||||||
@@ -1810,11 +1813,18 @@ modifier_state_changed(struct weston_seat *seat)
|
|||||||
seat->led_update(seat, leds);
|
seat->led_update(seat, leds);
|
||||||
seat->xkb_state.leds = leds;
|
seat->xkb_state.leds = leds;
|
||||||
|
|
||||||
return ret;
|
if (changed) {
|
||||||
|
grab->interface->modifiers(grab,
|
||||||
|
serial,
|
||||||
|
keyboard->modifiers.mods_depressed,
|
||||||
|
keyboard->modifiers.mods_latched,
|
||||||
|
keyboard->modifiers.mods_locked,
|
||||||
|
keyboard->modifiers.group);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
update_modifier_state(struct weston_seat *seat, uint32_t key,
|
update_modifier_state(struct weston_seat *seat, uint32_t serial, uint32_t key,
|
||||||
enum wl_keyboard_key_state state)
|
enum wl_keyboard_key_state state)
|
||||||
{
|
{
|
||||||
enum xkb_key_direction direction;
|
enum xkb_key_direction direction;
|
||||||
@@ -1828,7 +1838,7 @@ update_modifier_state(struct weston_seat *seat, uint32_t key,
|
|||||||
* broken keycode system, which starts at 8. */
|
* broken keycode system, which starts at 8. */
|
||||||
xkb_state_update_key(seat->xkb_state.state, key + 8, direction);
|
xkb_state_update_key(seat->xkb_state.state, key + 8, direction);
|
||||||
|
|
||||||
return modifier_state_changed(seat);
|
notify_modifiers(&seat->seat, serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
@@ -1843,7 +1853,6 @@ notify_key(struct wl_seat *seat, uint32_t time, uint32_t key,
|
|||||||
struct wl_keyboard_grab *grab = seat->keyboard->grab;
|
struct wl_keyboard_grab *grab = seat->keyboard->grab;
|
||||||
uint32_t serial = wl_display_next_serial(compositor->wl_display);
|
uint32_t serial = wl_display_next_serial(compositor->wl_display);
|
||||||
uint32_t *k, *end;
|
uint32_t *k, *end;
|
||||||
int mods = 0;
|
|
||||||
|
|
||||||
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
|
||||||
if (compositor->ping_handler && focus)
|
if (compositor->ping_handler && focus)
|
||||||
@@ -1856,8 +1865,6 @@ notify_key(struct wl_seat *seat, uint32_t time, uint32_t key,
|
|||||||
weston_compositor_idle_release(compositor);
|
weston_compositor_idle_release(compositor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update_state == STATE_UPDATE_AUTOMATIC)
|
|
||||||
mods = update_modifier_state(ws, key, state);
|
|
||||||
end = seat->keyboard->keys.data + seat->keyboard->keys.size;
|
end = seat->keyboard->keys.data + seat->keyboard->keys.size;
|
||||||
for (k = seat->keyboard->keys.data; k < end; k++) {
|
for (k = seat->keyboard->keys.data; k < end; k++) {
|
||||||
if (*k == key) {
|
if (*k == key) {
|
||||||
@@ -1880,13 +1887,13 @@ notify_key(struct wl_seat *seat, uint32_t time, uint32_t key,
|
|||||||
}
|
}
|
||||||
|
|
||||||
grab->interface->key(grab, time, key, state);
|
grab->interface->key(grab, time, key, state);
|
||||||
if (mods)
|
|
||||||
grab->interface->modifiers(grab,
|
if (update_state == STATE_UPDATE_AUTOMATIC) {
|
||||||
wl_display_get_serial(compositor->wl_display),
|
update_modifier_state(ws,
|
||||||
seat->keyboard->modifiers.mods_depressed,
|
wl_display_get_serial(compositor->wl_display),
|
||||||
seat->keyboard->modifiers.mods_latched,
|
key,
|
||||||
seat->keyboard->modifiers.mods_locked,
|
state);
|
||||||
seat->keyboard->modifiers.group);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
@@ -1935,7 +1942,9 @@ notify_keyboard_focus_in(struct wl_seat *seat, struct wl_array *keys,
|
|||||||
wl_array_for_each(k, &seat->keyboard->keys) {
|
wl_array_for_each(k, &seat->keyboard->keys) {
|
||||||
weston_compositor_idle_inhibit(compositor);
|
weston_compositor_idle_inhibit(compositor);
|
||||||
if (update_state == STATE_UPDATE_AUTOMATIC)
|
if (update_state == STATE_UPDATE_AUTOMATIC)
|
||||||
update_modifier_state(ws, *k,
|
update_modifier_state(ws,
|
||||||
|
wl_display_next_serial(compositor->wl_display),
|
||||||
|
*k,
|
||||||
WL_KEYBOARD_KEY_STATE_PRESSED);
|
WL_KEYBOARD_KEY_STATE_PRESSED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -511,6 +511,8 @@ void
|
|||||||
notify_key(struct wl_seat *seat, uint32_t time, uint32_t key,
|
notify_key(struct wl_seat *seat, uint32_t time, uint32_t key,
|
||||||
enum wl_keyboard_key_state state,
|
enum wl_keyboard_key_state state,
|
||||||
enum weston_key_state_update update_state);
|
enum weston_key_state_update update_state);
|
||||||
|
void
|
||||||
|
notify_modifiers(struct wl_seat *seat, uint32_t serial);
|
||||||
|
|
||||||
void
|
void
|
||||||
notify_pointer_focus(struct wl_seat *seat, struct weston_output *output,
|
notify_pointer_focus(struct wl_seat *seat, struct weston_output *output,
|
||||||
|
|||||||
Reference in New Issue
Block a user