summaryrefslogtreecommitdiff
path: root/src/compositor-x11.c
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2015-07-31 16:55:32 -0500
committerBryce Harrington <bryce@osg.samsung.com>2015-07-31 15:16:09 -0700
commit1281a36e3bcd27345bd4a107f282213ecca56f0e (patch)
tree5d797ffcd96f5542da153bec095a1c7800ce9cda /src/compositor-x11.c
parentb41b59e2fae83124f90ce54b6ae3f088bfec3338 (diff)
downloadweston-1281a36e3bcd27345bd4a107f282213ecca56f0e.tar.gz
input: Don't test keyboard/pointer/touch pointers
Keyboards and pointers aren't freed when devices are removed, so we should really be testing keyboard_device_count and pointer_device_count in most cases, not the actual pointers. Otherwise we end up with different behaviour after removing a device than we had before it was inserted. This commit renames the touch/keyboard/pointer pointers and adds helper functions to get them that hide this complexity and return NULL when *_device_count is 0. Signed-off-by: Derek Foreman <derekf@osg.samsung.com> Reviewed-by: Jonas Ã…dahl <jadahl@gmail.com>
Diffstat (limited to 'src/compositor-x11.c')
-rw-r--r--src/compositor-x11.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index 55c85edc..73ba783f 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -174,7 +174,9 @@ x11_backend_get_keymap(struct x11_backend *b)
static uint32_t
get_xkb_mod_mask(struct x11_backend *b, uint32_t in)
{
- struct weston_xkb_info *info = b->core_seat.keyboard->xkb_info;
+ struct weston_keyboard *keyboard =
+ weston_seat_get_keyboard(&b->core_seat);
+ struct weston_xkb_info *info = keyboard->xkb_info;
uint32_t ret = 0;
if ((in & ShiftMask) && info->shift_mod != XKB_MOD_INVALID)
@@ -206,6 +208,7 @@ x11_backend_setup_xkb(struct x11_backend *b)
b->xkb_event_base = 0;
return;
#else
+ struct weston_keyboard *keyboard;
const xcb_query_extension_reply_t *ext;
xcb_generic_error_t *error;
xcb_void_cookie_t select;
@@ -285,7 +288,8 @@ x11_backend_setup_xkb(struct x11_backend *b)
return;
}
- xkb_state_update_mask(b->core_seat.keyboard->xkb_state.state,
+ keyboard = weston_seat_get_keyboard(&b->core_seat);
+ xkb_state_update_mask(keyboard->xkb_state.state,
get_xkb_mod_mask(b, state_reply->baseMods),
get_xkb_mod_mask(b, state_reply->latchedMods),
get_xkb_mod_mask(b, state_reply->lockedMods),
@@ -975,7 +979,10 @@ static void delete_cb(void *data)
static void
update_xkb_state(struct x11_backend *b, xcb_xkb_state_notify_event_t *state)
{
- xkb_state_update_mask(b->core_seat.keyboard->xkb_state.state,
+ struct weston_keyboard *keyboard =
+ weston_seat_get_keyboard(&b->core_seat);
+
+ xkb_state_update_mask(keyboard->xkb_state.state,
get_xkb_mod_mask(b, state->baseMods),
get_xkb_mod_mask(b, state->latchedMods),
get_xkb_mod_mask(b, state->lockedMods),
@@ -1003,9 +1010,10 @@ static void
update_xkb_state_from_core(struct x11_backend *b, uint16_t x11_mask)
{
uint32_t mask = get_xkb_mod_mask(b, x11_mask);
- struct weston_keyboard *keyboard = b->core_seat.keyboard;
+ struct weston_keyboard *keyboard
+ = weston_seat_get_keyboard(&b->core_seat);
- xkb_state_update_mask(b->core_seat.keyboard->xkb_state.state,
+ xkb_state_update_mask(keyboard->xkb_state.state,
keyboard->modifiers.mods_depressed & mask,
keyboard->modifiers.mods_latched & mask,
keyboard->modifiers.mods_locked & mask,