summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compositor-x11.c6
-rw-r--r--src/compositor.c45
-rw-r--r--src/compositor.h24
3 files changed, 41 insertions, 34 deletions
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index ac914be..0599269 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -749,9 +749,9 @@ x11_compositor_get_keymap(struct x11_compositor *c)
#define copy_prop_value(to) \
length_part = strlen(value_part); \
if (value_part + length_part > (value_all + length_all) && \
- length_part > 0 && c->base.xkb_info.names.to == NULL) { \
- free((char *) c->base.xkb_info.names.to); \
- c->base.xkb_info.names.to = strdup(value_part); \
+ length_part > 0 && c->base.xkb_names.to == NULL) { \
+ free((char *) c->base.xkb_names.to); \
+ c->base.xkb_names.to = strdup(value_part); \
} \
value_part += length_part + 1;
diff --git a/src/compositor.c b/src/compositor.c
index e15f1ed..45a1f7c 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2227,35 +2227,40 @@ device_handle_new_drag_icon(struct wl_listener *listener, void *data)
static int weston_compositor_xkb_init(struct weston_compositor *ec,
struct xkb_rule_names *names)
{
- ec->xkb_info.context = xkb_context_new(0);
- if (ec->xkb_info.context == NULL) {
+ ec->xkb_context = xkb_context_new(0);
+ if (ec->xkb_context == NULL) {
fprintf(stderr, "failed to create XKB context\n");
return -1;
}
if (names)
- ec->xkb_info.names = *names;
- if (!ec->xkb_info.names.rules)
- ec->xkb_info.names.rules = strdup("evdev");
- if (!ec->xkb_info.names.model)
- ec->xkb_info.names.model = strdup("pc105");
- if (!ec->xkb_info.names.layout)
- ec->xkb_info.names.layout = strdup("us");
+ ec->xkb_names = *names;
+ if (!ec->xkb_names.rules)
+ ec->xkb_names.rules = strdup("evdev");
+ if (!ec->xkb_names.model)
+ ec->xkb_names.model = strdup("pc105");
+ if (!ec->xkb_names.layout)
+ ec->xkb_names.layout = strdup("us");
return 0;
}
+static void xkb_info_destroy(struct weston_xkb_info *xkb_info)
+{
+ if (xkb_info->keymap)
+ xkb_map_unref(xkb_info->keymap);
+}
+
static void weston_compositor_xkb_destroy(struct weston_compositor *ec)
{
- free((char *) ec->xkb_info.names.rules);
- free((char *) ec->xkb_info.names.model);
- free((char *) ec->xkb_info.names.layout);
- free((char *) ec->xkb_info.names.variant);
- free((char *) ec->xkb_info.names.options);
+ free((char *) ec->xkb_names.rules);
+ free((char *) ec->xkb_names.model);
+ free((char *) ec->xkb_names.layout);
+ free((char *) ec->xkb_names.variant);
+ free((char *) ec->xkb_names.options);
- if (ec->xkb_info.keymap)
- xkb_map_unref(ec->xkb_info.keymap);
- xkb_context_unref(ec->xkb_info.context);
+ xkb_info_destroy(&ec->xkb_info);
+ xkb_context_unref(ec->xkb_context);
}
static int
@@ -2264,8 +2269,8 @@ weston_compositor_build_global_keymap(struct weston_compositor *ec)
if (ec->xkb_info.keymap != NULL)
return 0;
- ec->xkb_info.keymap = xkb_map_new_from_names(ec->xkb_info.context,
- &ec->xkb_info.names, 0);
+ ec->xkb_info.keymap = xkb_map_new_from_names(ec->xkb_context,
+ &ec->xkb_names, 0);
if (ec->xkb_info.keymap == NULL) {
fprintf(stderr, "failed to compile XKB keymap\n");
return -1;
@@ -2356,7 +2361,7 @@ weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec)
wl_signal_add(&seat->seat.drag_icon_signal,
&seat->new_drag_icon_listener);
- if (!ec->xkb_info.context)
+ if (!ec->xkb_context)
weston_compositor_xkb_init(ec, NULL);
seat->xkb_state.mods_depressed = 0;
diff --git a/src/compositor.h b/src/compositor.h
index 0aa8a76..af6af24 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -241,6 +241,16 @@ 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;
@@ -316,17 +326,9 @@ struct weston_compositor {
uint32_t output_id_pool;
- struct {
- struct xkb_rule_names names;
- struct xkb_context *context;
- 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;
- } xkb_info;
+ struct xkb_rule_names xkb_names;
+ struct xkb_context *xkb_context;
+ struct weston_xkb_info xkb_info;
};
enum weston_output_flags {