From e311cef0135b63ee709c754d89b749e8474a186c Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Tue, 16 Jul 2013 14:37:49 +0200 Subject: [PATCH] Add keybindings for switching VTs Once mutter is started from weston-launch on its own VT, there is no way to change VT again (for example to actually start an application), because the keyboard is put in raw mode. So introduce some keybindings mimicking the standard X ones (Ctrl+Alt+Fn) that switch the VT manually when activated. https://bugzilla.gnome.org/show_bug.cgi?id=705861 --- src/Makefile.am | 2 +- src/core/keybindings.c | 94 +++++++++++++++++++++ src/org.gnome.mutter.wayland.gschema.xml.in | 33 ++++++++ 3 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 src/org.gnome.mutter.wayland.gschema.xml.in diff --git a/src/Makefile.am b/src/Makefile.am index 462e8a82d..a2648f8d5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -319,7 +319,7 @@ xml_DATA = $(xml_in_files:.xml.in=.xml) dbus_idle_built_sources = meta-dbus-idle-monitor.c meta-dbus-idle-monitor.h -gsettings_SCHEMAS = org.gnome.mutter.gschema.xml +gsettings_SCHEMAS = org.gnome.mutter.gschema.xml org.gnome.mutter.wayland.gschema.xml @INTLTOOL_XML_NOMERGE_RULE@ @GSETTINGS_RULES@ diff --git a/src/core/keybindings.c b/src/core/keybindings.c index 7f58334f8..5b8be79e8 100644 --- a/src/core/keybindings.c +++ b/src/core/keybindings.c @@ -53,8 +53,13 @@ #include #endif +#ifdef HAVE_WAYLAND +#include "meta-wayland-private.h" +#endif + #define SCHEMA_COMMON_KEYBINDINGS "org.gnome.desktop.wm.keybindings" #define SCHEMA_MUTTER_KEYBINDINGS "org.gnome.mutter.keybindings" +#define SCHEMA_MUTTER_WAYLAND_KEYBINDINGS "org.gnome.mutter.wayland.keybindings" static gboolean add_builtin_keybinding (MetaDisplay *display, const char *name, @@ -4098,6 +4103,40 @@ handle_set_spew_mark (MetaDisplay *display, meta_verbose ("-- MARK MARK MARK MARK --\n"); } +#ifdef HAVE_WAYLAND +static void +handle_switch_vt (MetaDisplay *display, + MetaScreen *screen, + MetaWindow *window, + XIDeviceEvent *event, + MetaKeyBinding *binding, + gpointer dummy) +{ + gint vt = binding->handler->data; + MetaWaylandCompositor *compositor; + MetaLauncher *launcher; + + compositor = meta_wayland_compositor_get_default (); + launcher = meta_wayland_compositor_get_launcher (compositor); + + if (launcher) + { + GError *error; + + error = NULL; + if (!meta_launcher_activate_vt (launcher, vt, &error)) + { + g_warning ("Failed to switch VT: %s", error->message); + g_error_free (error); + } + } + else + { + g_debug ("Ignoring VT switch keybinding, not running as VT manager"); + } +} +#endif + /** * meta_keybindings_set_custom_handler: * @name: The name of the keybinding to set @@ -4161,6 +4200,7 @@ init_builtin_key_bindings (MetaDisplay *display) META_KEY_BINDING_IS_REVERSED) GSettings *common_keybindings = g_settings_new (SCHEMA_COMMON_KEYBINDINGS); GSettings *mutter_keybindings = g_settings_new (SCHEMA_MUTTER_KEYBINDINGS); + GSettings *mutter_wayland_keybindings = g_settings_new (SCHEMA_MUTTER_WAYLAND_KEYBINDINGS); add_builtin_keybinding (display, "switch-to-workspace-1", @@ -4422,6 +4462,60 @@ init_builtin_key_bindings (MetaDisplay *display) META_KEYBINDING_ACTION_SET_SPEW_MARK, handle_set_spew_mark, 0); +#ifdef HAVE_WAYLAND + if (meta_is_wayland_compositor ()) + { + add_builtin_keybinding (display, + "switch-to-session-1", + mutter_wayland_keybindings, + META_KEY_BINDING_NONE, + META_KEYBINDING_ACTION_NONE, + handle_switch_vt, 1); + + add_builtin_keybinding (display, + "switch-to-session-2", + mutter_wayland_keybindings, + META_KEY_BINDING_NONE, + META_KEYBINDING_ACTION_NONE, + handle_switch_vt, 2); + + add_builtin_keybinding (display, + "switch-to-session-3", + mutter_wayland_keybindings, + META_KEY_BINDING_NONE, + META_KEYBINDING_ACTION_NONE, + handle_switch_vt, 3); + + add_builtin_keybinding (display, + "switch-to-session-4", + mutter_wayland_keybindings, + META_KEY_BINDING_NONE, + META_KEYBINDING_ACTION_NONE, + handle_switch_vt, 4); + + add_builtin_keybinding (display, + "switch-to-session-5", + mutter_wayland_keybindings, + META_KEY_BINDING_NONE, + META_KEYBINDING_ACTION_NONE, + handle_switch_vt, 5); + + add_builtin_keybinding (display, + "switch-to-session-6", + mutter_wayland_keybindings, + META_KEY_BINDING_NONE, + META_KEYBINDING_ACTION_NONE, + handle_switch_vt, 6); + + add_builtin_keybinding (display, + "switch-to-session-7", + mutter_wayland_keybindings, + META_KEY_BINDING_NONE, + META_KEYBINDING_ACTION_NONE, + handle_switch_vt, 7); + } +#endif + #undef REVERSES_AND_REVERSED /************************ PER WINDOW BINDINGS ************************/ diff --git a/src/org.gnome.mutter.wayland.gschema.xml.in b/src/org.gnome.mutter.wayland.gschema.xml.in new file mode 100644 index 000000000..4bb5c1dfd --- /dev/null +++ b/src/org.gnome.mutter.wayland.gschema.xml.in @@ -0,0 +1,33 @@ + + + + F1']]]> + <_summary>Switch to VT 1 + + + F2']]]> + <_summary>Switch to VT 2 + + + F3']]]> + <_summary>Switch to VT 3 + + + F4']]]> + <_summary>Switch to VT 4 + + + F5']]]> + <_summary>Switch to VT 5 + + + F6']]]> + <_summary>Switch to VT 6 + + + F7']]]> + <_summary>Switch to VT 7 + + +