mirror of
https://gitlab.freedesktop.org/wayland/weston.git
synced 2026-05-07 14:18:32 +02:00
clients: keyboard: Implement config
Allow configuring the look of the keyboard. This patch does not make use of the colors. Without configuration nothing should change to the old default look. Signed-off-by: Torben Hohn <torben.hohn@bruker.com>
This commit is contained in:
parent
f30eb47b04
commit
26258b348f
1 changed files with 57 additions and 0 deletions
|
|
@ -62,6 +62,8 @@ struct virtual_keyboard {
|
|||
bool toplevel;
|
||||
bool overlay;
|
||||
struct zwp_input_panel_surface_v1 *ips;
|
||||
|
||||
struct weston_config *config;
|
||||
};
|
||||
|
||||
enum key_type {
|
||||
|
|
@ -271,6 +273,19 @@ struct keyboard {
|
|||
struct widget *widget;
|
||||
|
||||
enum keyboard_state state;
|
||||
uint32_t key_margin;
|
||||
uint32_t key_radius;
|
||||
|
||||
uint32_t key_fg_color;
|
||||
uint32_t key_bg_color;
|
||||
uint32_t key_pressed_fg_color;
|
||||
uint32_t key_pressed_bg_color;
|
||||
uint32_t special_key_fg_color;
|
||||
uint32_t special_key_bg_color;
|
||||
uint32_t special_key_pressed_fg_color;
|
||||
uint32_t special_key_pressed_bg_color;
|
||||
uint32_t panel_fg_color;
|
||||
uint32_t panel_bg_color;
|
||||
};
|
||||
|
||||
static void __attribute__ ((format (printf, 1, 2)))
|
||||
|
|
@ -1052,6 +1067,45 @@ keyboard_destroy(struct virtual_keyboard *virtual_keyboard)
|
|||
free(virtual_keyboard->keyboard);
|
||||
}
|
||||
|
||||
static void
|
||||
config_load(struct virtual_keyboard *virtual_keyboard)
|
||||
{
|
||||
struct weston_config_section *s;
|
||||
const char *config_file;
|
||||
config_file = weston_config_get_name_from_env();
|
||||
virtual_keyboard->config = weston_config_parse(config_file);
|
||||
s = weston_config_get_section(virtual_keyboard->config, "keyboard", NULL, NULL);
|
||||
|
||||
weston_config_section_get_uint(s, "key-margin", &virtual_keyboard->keyboard->key_margin, 0);
|
||||
weston_config_section_get_uint(s, "key-radius", &virtual_keyboard->keyboard->key_radius, 0);
|
||||
|
||||
weston_config_section_get_color(s, "key-fg",
|
||||
&virtual_keyboard->keyboard->key_fg_color, 0xcc000000);
|
||||
weston_config_section_get_color(s, "key-bg",
|
||||
&virtual_keyboard->keyboard->key_bg_color, 0xccffffff);
|
||||
weston_config_section_get_color(s, "key-pressed-fg",
|
||||
&virtual_keyboard->keyboard->key_pressed_fg_color, 0xcc000000);
|
||||
weston_config_section_get_color(s, "key-pressed-bg",
|
||||
&virtual_keyboard->keyboard->key_pressed_bg_color, 0xccffffff);
|
||||
weston_config_section_get_color(s, "special-key-fg",
|
||||
&virtual_keyboard->keyboard->special_key_fg_color, 0xcc000000);
|
||||
weston_config_section_get_color(s, "special-key-bg",
|
||||
&virtual_keyboard->keyboard->special_key_bg_color, 0xccffffff);
|
||||
weston_config_section_get_color(s, "special-key-pressed-fg",
|
||||
&virtual_keyboard->keyboard->special_key_pressed_fg_color, 0xcc000000);
|
||||
weston_config_section_get_color(s, "special-key-pressed-bg",
|
||||
&virtual_keyboard->keyboard->special_key_pressed_bg_color, 0xccffffff);
|
||||
weston_config_section_get_color(s, "panel-bg",
|
||||
&virtual_keyboard->keyboard->panel_bg_color, 0xccffffff);
|
||||
weston_config_section_get_color(s, "panel-fg",
|
||||
&virtual_keyboard->keyboard->panel_fg_color, 0xcc000000);
|
||||
}
|
||||
|
||||
static void config_destroy(struct virtual_keyboard *virtual_keyboard)
|
||||
{
|
||||
weston_config_destroy(virtual_keyboard->config);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
|
@ -1076,10 +1130,13 @@ main(int argc, char *argv[])
|
|||
|
||||
keyboard_create(&virtual_keyboard);
|
||||
|
||||
config_load(&virtual_keyboard);
|
||||
|
||||
display_run(virtual_keyboard.display);
|
||||
|
||||
keyboard_destroy(&virtual_keyboard);
|
||||
display_destroy(virtual_keyboard.display);
|
||||
config_destroy(&virtual_keyboard);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue