Update modifier state as input devices enter and leave

dev
Kristian Høgsberg 14 years ago
parent 0b9334a51a
commit f512d07e2d
  1. 51
      compositor/compositor.c

@ -1189,24 +1189,11 @@ wlsc_binding_destroy(struct wlsc_binding *binding)
free(binding); free(binding);
} }
void static void
notify_key(struct wl_input_device *device, update_modifier_state(struct wlsc_input_device *device,
uint32_t time, uint32_t key, uint32_t state) uint32_t key, uint32_t state)
{ {
struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
struct wlsc_compositor *compositor =
(struct wlsc_compositor *) device->compositor;
uint32_t *k, *end;
uint32_t modifier; uint32_t modifier;
struct wlsc_binding *b;
wl_list_for_each(b, &compositor->binding_list, link) {
if (b->key == key &&
b->modifier == wd->modifier_state && state) {
b->handler(wd, time, key, state, b->data);
break;
}
}
switch (key) { switch (key) {
case KEY_LEFTCTRL: case KEY_LEFTCTRL:
@ -1230,10 +1217,30 @@ notify_key(struct wl_input_device *device,
} }
if (state) if (state)
wd->modifier_state |= modifier; device->modifier_state |= modifier;
else else
wd->modifier_state &= ~modifier; device->modifier_state &= ~modifier;
}
void
notify_key(struct wl_input_device *device,
uint32_t time, uint32_t key, uint32_t state)
{
struct wlsc_input_device *wd = (struct wlsc_input_device *) device;
struct wlsc_compositor *compositor =
(struct wlsc_compositor *) device->compositor;
uint32_t *k, *end;
struct wlsc_binding *b;
wl_list_for_each(b, &compositor->binding_list, link) {
if (b->key == key &&
b->modifier == wd->modifier_state && state) {
b->handler(wd, time, key, state, b->data);
break;
}
}
update_modifier_state(wd, key, state);
end = device->keys.data + device->keys.size; end = device->keys.data + device->keys.size;
for (k = device->keys.data; k < end; k++) { for (k = device->keys.data; k < end; k++) {
if (*k == key) if (*k == key)
@ -1294,6 +1301,7 @@ notify_keyboard_focus(struct wl_input_device *device,
struct wlsc_compositor *compositor = struct wlsc_compositor *compositor =
(struct wlsc_compositor *) device->compositor; (struct wlsc_compositor *) device->compositor;
struct wlsc_surface *es; struct wlsc_surface *es;
uint32_t *k, *end;
if (!wl_list_empty(&compositor->surface_list)) if (!wl_list_empty(&compositor->surface_list))
es = container_of(compositor->surface_list.next, es = container_of(compositor->surface_list.next,
@ -1303,9 +1311,16 @@ notify_keyboard_focus(struct wl_input_device *device,
if (output) { if (output) {
wl_array_copy(&wd->input_device.keys, keys); wl_array_copy(&wd->input_device.keys, keys);
wd->modifier_state = 0;
end = device->keys.data + device->keys.size;
for (k = device->keys.data; k < end; k++) {
update_modifier_state(wd, *k, 1);
}
wl_input_device_set_keyboard_focus(&wd->input_device, wl_input_device_set_keyboard_focus(&wd->input_device,
&es->surface, time); &es->surface, time);
} else { } else {
wd->modifier_state = 0;
wl_input_device_set_keyboard_focus(&wd->input_device, wl_input_device_set_keyboard_focus(&wd->input_device,
NULL, time); NULL, time);
} }

Loading…
Cancel
Save