meta-weston-launch: Call VT_ACTIVATE ourselves

We don't need any special permissions, so we don't need to go through
weston-launch to do so...
This commit is contained in:
Jasper St. Pierre
2013-12-31 17:44:35 -05:00
parent a3de799939
commit ebe6e3180e
7 changed files with 19 additions and 85 deletions

View File

@@ -56,6 +56,9 @@
#ifdef HAVE_WAYLAND
#include "meta-wayland-private.h"
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/vt.h>
#endif
#define SCHEMA_COMMON_KEYBINDINGS "org.gnome.desktop.wm.keybindings"
@@ -4083,6 +4086,18 @@ handle_set_spew_mark (MetaDisplay *display,
}
#ifdef HAVE_WAYLAND
static gboolean
activate_vt (int vt)
{
int tty, reply;
tty = open ("/dev/tty", O_RDWR | O_NOCTTY | O_CLOEXEC);
reply = ioctl (tty, VT_ACTIVATE, vt);
close (tty);
return (reply == 0);
}
static void
handle_switch_vt (MetaDisplay *display,
MetaScreen *screen,
@@ -4091,28 +4106,10 @@ handle_switch_vt (MetaDisplay *display,
MetaKeyBinding *binding,
gpointer dummy)
{
gint vt = binding->handler->data;
MetaWaylandCompositor *compositor;
MetaLauncher *launcher;
gint vt = binding->handler->data;
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");
}
if (!activate_vt (vt))
g_warning ("Failed to switch VT");
}
#endif