Weston under X in Ubuntu has this bad behavior, mixing Unity's key bindings with the ones in Weston. So I'd like to see the modifiers configurable on Weston.
- I changed two key combination bindings, the rotation and the brightness. - would be cool also to make surface_opacity and zoom bindings configurable, But for both it's just awesome to use the vertical scroll, and if we want to make configurable then we would need two modifiers keys in weston.ini - you see that the binding-modifier key on weston.ini's in under screensaver section, which is quite weird. We probably want to rename that section for something better. - (BTW, the fact of being opening three times weston.ini in a regular session is not cool either. Ideas?) this is sensible? Or should I just forget about this all and disable the bindings in Ubuntu somehow when doing my hacking? Signed-off-by: Tiago Vignatti <[email protected]> --- src/shell.c | 98 +++++++++++++++++++++++++++++++++++++++-------------------- weston.ini | 1 + 2 files changed, 66 insertions(+), 33 deletions(-) diff --git a/src/shell.c b/src/shell.c index e5870b4..ab5e7ff 100644 --- a/src/shell.c +++ b/src/shell.c @@ -77,6 +77,7 @@ struct desktop_shell { struct weston_process process; } screensaver; + uint32_t binding_modifier; struct weston_surface *debug_repaint_surface; }; @@ -227,16 +228,34 @@ static void center_on_output(struct weston_surface *surface, struct weston_output *output); +static uint32_t +get_modifier(char *modifier) +{ + if (!modifier) + return -1; + + if (!strcmp("MODIFIER_CTRL", modifier)) + return MODIFIER_CTRL; + else if (!strcmp("MODIFIER_ALT", modifier)) + return MODIFIER_ALT; + else if (!strcmp("MODIFIER_SUPER", modifier)) + return MODIFIER_SUPER; + else + return -1; +} + static void shell_configuration(struct desktop_shell *shell) { char *config_file; char *path = NULL; int duration = 60; + char *modifier = NULL; struct config_key saver_keys[] = { { "path", CONFIG_KEY_STRING, &path }, { "duration", CONFIG_KEY_INTEGER, &duration }, + { "binding-modifier", CONFIG_KEY_STRING, &modifier }, }; struct config_section cs[] = { @@ -249,6 +268,9 @@ shell_configuration(struct desktop_shell *shell) shell->screensaver.path = path; shell->screensaver.duration = duration; + if (!modifier) + modifier = "MODIFIER_SUPER"; + shell->binding_modifier = get_modifier(modifier); } static void @@ -2276,7 +2298,7 @@ switcher_key(struct wl_keyboard_grab *grab, struct weston_input_device *device = (struct weston_input_device *) grab->input_device; - if ((device->modifier_state & MODIFIER_SUPER) == 0) { + if ((device->modifier_state & switcher->shell->binding_modifier) == 0) { switcher_destroy(switcher, time); } else if (key == KEY_TAB && state) { switcher_next(switcher); @@ -2387,6 +2409,47 @@ shell_destroy(struct wl_listener *listener, void *data) free(shell); } +static void +shell_add_binding(struct weston_compositor *ec, struct desktop_shell *shell) +{ + uint32_t mod; + + /* fixed bindings */ + weston_compositor_add_binding(ec, KEY_BACKSPACE, 0, 0, + MODIFIER_CTRL | MODIFIER_ALT, + terminate_binding, ec); + weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, 0, + click_to_activate_binding, shell); + weston_compositor_add_binding(ec, 0, 0, + WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, + MODIFIER_SUPER | MODIFIER_ALT, + surface_opacity_binding, NULL); + weston_compositor_add_binding(ec, 0, 0, + WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, + MODIFIER_SUPER, zoom_binding, NULL); + + /* configurable bindings */ + mod = shell->binding_modifier; + weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, mod, + move_binding, shell); + weston_compositor_add_binding(ec, 0, BTN_MIDDLE, 0, mod, + resize_binding, shell); + weston_compositor_add_binding(ec, 0, BTN_RIGHT, 0, mod, + rotate_binding, NULL); + weston_compositor_add_binding(ec, KEY_TAB, 0, 0, mod, + switcher_binding, shell); + weston_compositor_add_binding(ec, KEY_F9, 0, 0, mod, + backlight_binding, ec); + weston_compositor_add_binding(ec, KEY_BRIGHTNESSDOWN, 0, 0, 0, + backlight_binding, ec); + weston_compositor_add_binding(ec, KEY_F10, 0, 0, mod, + backlight_binding, ec); + weston_compositor_add_binding(ec, KEY_BRIGHTNESSUP, 0, 0, 0, + backlight_binding, ec); + weston_compositor_add_binding(ec, KEY_SPACE, 0, 0, mod, + debug_repaint_binding, shell); +} + int shell_init(struct weston_compositor *ec); @@ -2440,38 +2503,7 @@ shell_init(struct weston_compositor *ec) if (launch_desktop_shell_process(shell) != 0) return -1; - weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, MODIFIER_SUPER, - move_binding, shell); - weston_compositor_add_binding(ec, 0, BTN_MIDDLE, 0, MODIFIER_SUPER, - resize_binding, shell); - weston_compositor_add_binding(ec, KEY_BACKSPACE, 0, 0, - MODIFIER_CTRL | MODIFIER_ALT, - terminate_binding, ec); - weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, 0, - click_to_activate_binding, shell); - weston_compositor_add_binding(ec, 0, 0, WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, - MODIFIER_SUPER | MODIFIER_ALT, - surface_opacity_binding, NULL); - weston_compositor_add_binding(ec, 0, 0, WL_INPUT_DEVICE_AXIS_VERTICAL_SCROLL, - MODIFIER_SUPER, zoom_binding, NULL); - weston_compositor_add_binding(ec, 0, BTN_LEFT, 0, - MODIFIER_SUPER | MODIFIER_ALT, - rotate_binding, NULL); - weston_compositor_add_binding(ec, KEY_TAB, 0, 0, MODIFIER_SUPER, - switcher_binding, shell); - - /* brightness */ - weston_compositor_add_binding(ec, KEY_F9, 0, 0, MODIFIER_CTRL, - backlight_binding, ec); - weston_compositor_add_binding(ec, KEY_BRIGHTNESSDOWN, 0, 0, 0, - backlight_binding, ec); - weston_compositor_add_binding(ec, KEY_F10, 0, 0, MODIFIER_CTRL, - backlight_binding, ec); - weston_compositor_add_binding(ec, KEY_BRIGHTNESSUP, 0, 0, 0, - backlight_binding, ec); - - weston_compositor_add_binding(ec, KEY_SPACE, 0, 0, MODIFIER_SUPER, - debug_repaint_binding, shell); + shell_add_binding(ec, shell); return 0; } diff --git a/weston.ini b/weston.ini index 69c7321..197e9b4 100644 --- a/weston.ini +++ b/weston.ini @@ -28,4 +28,5 @@ path=./clients/flower [screensaver] #path=./clients/wscreensaver duration=600 +#binding-modifier=MODIFIER_CTRL -- 1.7.5.4 _______________________________________________ wayland-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/wayland-devel
