summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2012-05-30 16:32:05 +0100
committerKristian Høgsberg <krh@bitplanet.net>2012-05-31 15:49:54 -0400
commitd65b909778e2f2d70c409e473572d0f5cc31562d (patch)
treea64d200fde18a02b76eba8b108d074680f72c301
parente379da953217a0172b428b80561341e28e08dd9c (diff)
Move keymaps to weston_seat
In practice this doesn't mean much right now, since they all just take an extra reference on the global keymap. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
-rw-r--r--src/compositor.c44
-rw-r--r--src/compositor.h21
2 files changed, 35 insertions, 30 deletions
diff --git a/src/compositor.c b/src/compositor.c
index 45a1f7c..f6676a7 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -1768,22 +1768,22 @@ update_modifier_state(struct weston_seat *seat, uint32_t key, uint32_t state)
/* And update the modifier_state for bindings. */
mods_lookup = mods_depressed | mods_latched;
seat->modifier_state = 0;
- if ((mods_lookup & seat->compositor->xkb_info.ctrl_mod))
+ if ((mods_lookup & seat->xkb_info.ctrl_mod))
seat->modifier_state |= MODIFIER_CTRL;
- if ((mods_lookup & seat->compositor->xkb_info.alt_mod))
+ if ((mods_lookup & seat->xkb_info.alt_mod))
seat->modifier_state |= MODIFIER_ALT;
- if ((mods_lookup & seat->compositor->xkb_info.super_mod))
+ if ((mods_lookup & seat->xkb_info.super_mod))
seat->modifier_state |= MODIFIER_SUPER;
/* Finally, notify the compositor that LEDs have changed. */
if (xkb_state_led_index_is_active(seat->xkb_state.state,
- seat->compositor->xkb_info.num_led))
+ seat->xkb_info.num_led))
leds |= LED_NUM_LOCK;
if (xkb_state_led_index_is_active(seat->xkb_state.state,
- seat->compositor->xkb_info.caps_led))
+ seat->xkb_info.caps_led))
leds |= LED_CAPS_LOCK;
if (xkb_state_led_index_is_active(seat->xkb_state.state,
- seat->compositor->xkb_info.scroll_led))
+ seat->xkb_info.scroll_led))
leds |= LED_SCROLL_LOCK;
if (leds != seat->xkb_state.leds && seat->led_update)
seat->led_update(seat, seat->xkb_state.leds);
@@ -2266,6 +2266,9 @@ static void weston_compositor_xkb_destroy(struct weston_compositor *ec)
static int
weston_compositor_build_global_keymap(struct weston_compositor *ec)
{
+ if (!ec->xkb_context)
+ weston_compositor_xkb_init(ec, NULL);
+
if (ec->xkb_info.keymap != NULL)
return 0;
@@ -2302,6 +2305,20 @@ weston_seat_init_keyboard(struct weston_seat *seat)
if (weston_compositor_build_global_keymap(seat->compositor) == -1)
return;
+ seat->xkb_info = seat->compositor->xkb_info;
+ seat->xkb_info.keymap = xkb_map_ref(seat->xkb_info.keymap);
+
+ seat->xkb_state.state = xkb_state_new(seat->xkb_info.keymap);
+ if (seat->xkb_state.state == NULL) {
+ fprintf(stderr, "failed to initialise XKB state\n");
+ exit(1);
+ }
+
+ seat->xkb_state.mods_depressed = 0;
+ seat->xkb_state.mods_latched = 0;
+ seat->xkb_state.mods_locked = 0;
+ seat->xkb_state.group = 0;
+
wl_keyboard_init(&seat->keyboard);
wl_seat_set_keyboard(&seat->seat, &seat->keyboard);
@@ -2360,20 +2377,6 @@ weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec)
seat->new_drag_icon_listener.notify = device_handle_new_drag_icon;
wl_signal_add(&seat->seat.drag_icon_signal,
&seat->new_drag_icon_listener);
-
- if (!ec->xkb_context)
- weston_compositor_xkb_init(ec, NULL);
-
- seat->xkb_state.mods_depressed = 0;
- seat->xkb_state.mods_latched = 0;
- seat->xkb_state.mods_locked = 0;
- seat->xkb_state.group = 0;
-
- seat->xkb_state.state = xkb_state_new(ec->xkb_info.keymap);
- if (seat->xkb_state.state == NULL) {
- fprintf(stderr, "failed to initialise XKB state\n");
- exit(1);
- }
}
WL_EXPORT void
@@ -2387,6 +2390,7 @@ weston_seat_release(struct weston_seat *seat)
if (seat->xkb_state.state != NULL)
xkb_state_unref(seat->xkb_state.state);
+ xkb_info_destroy(&seat->xkb_info);
wl_seat_release(&seat->seat);
}
diff --git a/src/compositor.h b/src/compositor.h
index af6af24..f0dbddc 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -162,6 +162,16 @@ struct weston_output {
void (*set_dpms)(struct weston_output *output, enum dpms_enum level);
};
+struct weston_xkb_info {
+ struct xkb_keymap *keymap;
+ xkb_mod_index_t ctrl_mod;
+ xkb_mod_index_t alt_mod;
+ xkb_mod_index_t super_mod;
+ xkb_led_index_t num_led;
+ xkb_led_index_t caps_led;
+ xkb_led_index_t scroll_led;
+};
+
struct weston_seat {
struct wl_seat seat;
struct wl_pointer pointer;
@@ -192,6 +202,7 @@ struct weston_seat {
void (*led_update)(struct weston_seat *ws, enum weston_led leds);
+ struct weston_xkb_info xkb_info;
struct {
struct xkb_state *state;
uint32_t mods_depressed;
@@ -241,16 +252,6 @@ struct weston_layer {
struct wl_list link;
};
-struct weston_xkb_info {
- struct xkb_keymap *keymap;
- xkb_mod_index_t ctrl_mod;
- xkb_mod_index_t alt_mod;
- xkb_mod_index_t super_mod;
- xkb_led_index_t num_led;
- xkb_led_index_t caps_led;
- xkb_led_index_t scroll_led;
-};
-
struct weston_compositor {
struct wl_shm *shm;
struct wl_signal destroy_signal;