Separate out weston_xkb_info struct
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
This commit is contained in:
committed by
Kristian Høgsberg
parent
9a9ee2c779
commit
e379da9532
@@ -749,9 +749,9 @@ x11_compositor_get_keymap(struct x11_compositor *c)
|
|||||||
#define copy_prop_value(to) \
|
#define copy_prop_value(to) \
|
||||||
length_part = strlen(value_part); \
|
length_part = strlen(value_part); \
|
||||||
if (value_part + length_part > (value_all + length_all) && \
|
if (value_part + length_part > (value_all + length_all) && \
|
||||||
length_part > 0 && c->base.xkb_info.names.to == NULL) { \
|
length_part > 0 && c->base.xkb_names.to == NULL) { \
|
||||||
free((char *) c->base.xkb_info.names.to); \
|
free((char *) c->base.xkb_names.to); \
|
||||||
c->base.xkb_info.names.to = strdup(value_part); \
|
c->base.xkb_names.to = strdup(value_part); \
|
||||||
} \
|
} \
|
||||||
value_part += length_part + 1;
|
value_part += length_part + 1;
|
||||||
|
|
||||||
|
|||||||
+25
-20
@@ -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,
|
static int weston_compositor_xkb_init(struct weston_compositor *ec,
|
||||||
struct xkb_rule_names *names)
|
struct xkb_rule_names *names)
|
||||||
{
|
{
|
||||||
ec->xkb_info.context = xkb_context_new(0);
|
ec->xkb_context = xkb_context_new(0);
|
||||||
if (ec->xkb_info.context == NULL) {
|
if (ec->xkb_context == NULL) {
|
||||||
fprintf(stderr, "failed to create XKB context\n");
|
fprintf(stderr, "failed to create XKB context\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (names)
|
if (names)
|
||||||
ec->xkb_info.names = *names;
|
ec->xkb_names = *names;
|
||||||
if (!ec->xkb_info.names.rules)
|
if (!ec->xkb_names.rules)
|
||||||
ec->xkb_info.names.rules = strdup("evdev");
|
ec->xkb_names.rules = strdup("evdev");
|
||||||
if (!ec->xkb_info.names.model)
|
if (!ec->xkb_names.model)
|
||||||
ec->xkb_info.names.model = strdup("pc105");
|
ec->xkb_names.model = strdup("pc105");
|
||||||
if (!ec->xkb_info.names.layout)
|
if (!ec->xkb_names.layout)
|
||||||
ec->xkb_info.names.layout = strdup("us");
|
ec->xkb_names.layout = strdup("us");
|
||||||
|
|
||||||
return 0;
|
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)
|
static void weston_compositor_xkb_destroy(struct weston_compositor *ec)
|
||||||
{
|
{
|
||||||
free((char *) ec->xkb_info.names.rules);
|
free((char *) ec->xkb_names.rules);
|
||||||
free((char *) ec->xkb_info.names.model);
|
free((char *) ec->xkb_names.model);
|
||||||
free((char *) ec->xkb_info.names.layout);
|
free((char *) ec->xkb_names.layout);
|
||||||
free((char *) ec->xkb_info.names.variant);
|
free((char *) ec->xkb_names.variant);
|
||||||
free((char *) ec->xkb_info.names.options);
|
free((char *) ec->xkb_names.options);
|
||||||
|
|
||||||
if (ec->xkb_info.keymap)
|
xkb_info_destroy(&ec->xkb_info);
|
||||||
xkb_map_unref(ec->xkb_info.keymap);
|
xkb_context_unref(ec->xkb_context);
|
||||||
xkb_context_unref(ec->xkb_info.context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@@ -2264,8 +2269,8 @@ weston_compositor_build_global_keymap(struct weston_compositor *ec)
|
|||||||
if (ec->xkb_info.keymap != NULL)
|
if (ec->xkb_info.keymap != NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ec->xkb_info.keymap = xkb_map_new_from_names(ec->xkb_info.context,
|
ec->xkb_info.keymap = xkb_map_new_from_names(ec->xkb_context,
|
||||||
&ec->xkb_info.names, 0);
|
&ec->xkb_names, 0);
|
||||||
if (ec->xkb_info.keymap == NULL) {
|
if (ec->xkb_info.keymap == NULL) {
|
||||||
fprintf(stderr, "failed to compile XKB keymap\n");
|
fprintf(stderr, "failed to compile XKB keymap\n");
|
||||||
return -1;
|
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,
|
wl_signal_add(&seat->seat.drag_icon_signal,
|
||||||
&seat->new_drag_icon_listener);
|
&seat->new_drag_icon_listener);
|
||||||
|
|
||||||
if (!ec->xkb_info.context)
|
if (!ec->xkb_context)
|
||||||
weston_compositor_xkb_init(ec, NULL);
|
weston_compositor_xkb_init(ec, NULL);
|
||||||
|
|
||||||
seat->xkb_state.mods_depressed = 0;
|
seat->xkb_state.mods_depressed = 0;
|
||||||
|
|||||||
+13
-11
@@ -241,6 +241,16 @@ struct weston_layer {
|
|||||||
struct wl_list link;
|
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 weston_compositor {
|
||||||
struct wl_shm *shm;
|
struct wl_shm *shm;
|
||||||
struct wl_signal destroy_signal;
|
struct wl_signal destroy_signal;
|
||||||
@@ -316,17 +326,9 @@ struct weston_compositor {
|
|||||||
|
|
||||||
uint32_t output_id_pool;
|
uint32_t output_id_pool;
|
||||||
|
|
||||||
struct {
|
struct xkb_rule_names xkb_names;
|
||||||
struct xkb_rule_names names;
|
struct xkb_context *xkb_context;
|
||||||
struct xkb_context *context;
|
struct weston_xkb_info 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;
|
|
||||||
} xkb_info;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum weston_output_flags {
|
enum weston_output_flags {
|
||||||
|
|||||||
Reference in New Issue
Block a user