summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagn@redhat.com>2013-07-16 14:37:49 +0200
committerGiovanni Campagna <gcampagn@redhat.com>2013-07-17 15:14:48 +0200
commit918e6a78c3e0f3247878566fb8dce24a93b0a9ba (patch)
tree06d06d632a049cfe8cf486deb7c43482831359b5
parent114b74c656d11e793dfb6bb441c0fd225508f74c (diff)
downloadmutter-918e6a78c3e0f3247878566fb8dce24a93b0a9ba.tar.gz
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.
-rw-r--r--src/core/keybindings.c85
-rw-r--r--src/org.gnome.mutter.gschema.xml.in29
-rw-r--r--src/wayland/meta-tty.c17
-rw-r--r--src/wayland/meta-tty.h4
-rw-r--r--src/wayland/meta-wayland-private.h4
-rw-r--r--src/wayland/meta-wayland.c6
6 files changed, 138 insertions, 7 deletions
diff --git a/src/core/keybindings.c b/src/core/keybindings.c
index 5455344f9..c17e670ec 100644
--- a/src/core/keybindings.c
+++ b/src/core/keybindings.c
@@ -4098,6 +4098,38 @@ handle_set_spew_mark (MetaDisplay *display,
meta_verbose ("-- MARK MARK MARK MARK --\n");
}
+static void
+handle_switch_vt (MetaDisplay *display,
+ MetaScreen *screen,
+ MetaWindow *window,
+ XIDeviceEvent *event,
+ MetaKeyBinding *binding,
+ gpointer dummy)
+{
+ gint vt = binding->handler->data;
+ MetaWaylandCompositor *compositor;
+ MetaTTY *tty;
+
+ compositor = meta_wayland_compositor_get_default ();
+ tty = meta_wayland_compositor_get_tty (compositor);
+
+ if (tty)
+ {
+ GError *error;
+
+ error = NULL;
+ if (!meta_tty_activate_vt (tty, 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");
+ }
+}
+
void
meta_set_keybindings_disabled (gboolean setting)
{
@@ -4430,6 +4462,59 @@ init_builtin_key_bindings (MetaDisplay *display)
META_KEYBINDING_ACTION_SET_SPEW_MARK,
handle_set_spew_mark, 0);
+ if (meta_is_display_server ())
+ {
+ add_builtin_keybinding (display,
+ "switch-to-session-1",
+ mutter_keybindings,
+ META_KEY_BINDING_NONE,
+ META_KEYBINDING_ACTION_NONE,
+ handle_switch_vt, 1);
+
+ add_builtin_keybinding (display,
+ "switch-to-session-2",
+ mutter_keybindings,
+ META_KEY_BINDING_NONE,
+ META_KEYBINDING_ACTION_NONE,
+ handle_switch_vt, 2);
+
+ add_builtin_keybinding (display,
+ "switch-to-session-3",
+ mutter_keybindings,
+ META_KEY_BINDING_NONE,
+ META_KEYBINDING_ACTION_NONE,
+ handle_switch_vt, 3);
+
+ add_builtin_keybinding (display,
+ "switch-to-session-4",
+ mutter_keybindings,
+ META_KEY_BINDING_NONE,
+ META_KEYBINDING_ACTION_NONE,
+ handle_switch_vt, 4);
+
+ add_builtin_keybinding (display,
+ "switch-to-session-5",
+ mutter_keybindings,
+ META_KEY_BINDING_NONE,
+ META_KEYBINDING_ACTION_NONE,
+ handle_switch_vt, 5);
+
+ add_builtin_keybinding (display,
+ "switch-to-session-6",
+ mutter_keybindings,
+ META_KEY_BINDING_NONE,
+ META_KEYBINDING_ACTION_NONE,
+ handle_switch_vt, 6);
+
+ add_builtin_keybinding (display,
+ "switch-to-session-7",
+ mutter_keybindings,
+ META_KEY_BINDING_NONE,
+ META_KEYBINDING_ACTION_NONE,
+ handle_switch_vt, 7);
+ }
+
+
#undef REVERSES_AND_REVERSED
/************************ PER WINDOW BINDINGS ************************/
diff --git a/src/org.gnome.mutter.gschema.xml.in b/src/org.gnome.mutter.gschema.xml.in
index 9d83cf3aa..81566cf2b 100644
--- a/src/org.gnome.mutter.gschema.xml.in
+++ b/src/org.gnome.mutter.gschema.xml.in
@@ -116,5 +116,34 @@
<_summary>Cancel tab popup</_summary>
</key>
+ <key name="switch-to-session-1" type="as">
+ <default><![CDATA[['<Primary><Alt>F1']]]></default>
+ <_summary>Switch to VT 1</_summary>
+ </key>
+ <key name="switch-to-session-2" type="as">
+ <default><![CDATA[['<Primary><Alt>F2']]]></default>
+ <_summary>Switch to VT 2</_summary>
+ </key>
+ <key name="switch-to-session-3" type="as">
+ <default><![CDATA[['<Primary><Alt>F3']]]></default>
+ <_summary>Switch to VT 3</_summary>
+ </key>
+ <key name="switch-to-session-4" type="as">
+ <default><![CDATA[['<Primary><Alt>F4']]]></default>
+ <_summary>Switch to VT 4</_summary>
+ </key>
+ <key name="switch-to-session-5" type="as">
+ <default><![CDATA[['<Primary><Alt>F5']]]></default>
+ <_summary>Switch to VT 5</_summary>
+ </key>
+ <key name="switch-to-session-6" type="as">
+ <default><![CDATA[['<Primary><Alt>F6']]]></default>
+ <_summary>Switch to VT 6</_summary>
+ </key>
+ <key name="switch-to-session-7" type="as">
+ <default><![CDATA[['<Primary><Alt>F7']]]></default>
+ <_summary>Switch to VT 7</_summary>
+ </key>
+
</schema>
</schemalist>
diff --git a/src/wayland/meta-tty.c b/src/wayland/meta-tty.c
index 82967fe68..31a63598b 100644
--- a/src/wayland/meta-tty.c
+++ b/src/wayland/meta-tty.c
@@ -157,12 +157,19 @@ try_open_vt (MetaTTY *tty,
return fd;
}
-/* FIXME? */
-static int
-tty_activate_vt (MetaTTY *tty,
- int vt)
+gboolean
+meta_tty_activate_vt (MetaTTY *tty,
+ int vt,
+ GError **error)
{
- return ioctl(tty->fd, VT_ACTIVATE, vt);
+ if (ioctl(tty->fd, VT_ACTIVATE, vt) < 0)
+ {
+ g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
+ strerror (errno));
+ return FALSE;
+ }
+ else
+ return TRUE;
}
static int
diff --git a/src/wayland/meta-tty.h b/src/wayland/meta-tty.h
index 2c3bf2adc..f5a24644b 100644
--- a/src/wayland/meta-tty.h
+++ b/src/wayland/meta-tty.h
@@ -38,6 +38,10 @@ GType meta_tty_get_type (void) G_GNUC_CONST;
MetaTTY *meta_tty_new (void);
+gboolean meta_tty_activate_vt (MetaTTY *self,
+ int number,
+ GError **error);
+
G_END_DECLS
#endif /* META_TTY_H */
diff --git a/src/wayland/meta-wayland-private.h b/src/wayland/meta-wayland-private.h
index 9fed56094..db24448d0 100644
--- a/src/wayland/meta-wayland-private.h
+++ b/src/wayland/meta-wayland-private.h
@@ -355,8 +355,6 @@ void meta_wayland_finalize (void);
* API after meta_wayland_init() has been called. */
MetaWaylandCompositor *meta_wayland_compositor_get_default (void);
-void meta_wayland_handle_sig_child (void);
-
MetaWaylandSurface *meta_wayland_lookup_surface_for_xid (guint32 xid);
void meta_wayland_compositor_repick (MetaWaylandCompositor *compositor);
@@ -364,4 +362,6 @@ void meta_wayland_compositor_repick (MetaWaylandComp
void meta_wayland_compositor_set_input_focus (MetaWaylandCompositor *compositor,
MetaWindow *window);
+MetaTTY *meta_wayland_compositor_get_tty (MetaWaylandCompositor *compositor);
+
#endif /* META_WAYLAND_PRIVATE_H */
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index b8515ea56..076967015 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -1953,3 +1953,9 @@ meta_wayland_finalize (void)
stop_xwayland (compositor);
g_clear_object (&compositor->tty);
}
+
+MetaTTY *
+meta_wayland_compositor_get_tty (MetaWaylandCompositor *compositor)
+{
+ return compositor->tty;
+}