keybindings: Simplify interface for VT switching

This commit is contained in:
Jasper St. Pierre 2014-02-01 19:34:24 -05:00
parent e04a55d1a2
commit 7e7b671b8e
3 changed files with 25 additions and 25 deletions

View File

@ -4090,26 +4090,13 @@ handle_switch_vt (MetaDisplay *display,
gpointer dummy) gpointer dummy)
{ {
gint vt = binding->handler->data; gint vt = binding->handler->data;
MetaWaylandCompositor *compositor; MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
MetaLauncher *launcher; GError *error = NULL;
compositor = meta_wayland_compositor_get_default (); if (!meta_wayland_compositor_activate_vt (compositor, vt, &error))
launcher = meta_wayland_compositor_get_launcher (compositor);
if (launcher)
{ {
GError *error; g_warning ("Failed to switch VT: %s", error->message);
g_error_free (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 #endif

View File

@ -99,7 +99,6 @@ void meta_wayland_compositor_set_input_focus (MetaWaylandComp
gboolean meta_wayland_compositor_handle_event (MetaWaylandCompositor *compositor, gboolean meta_wayland_compositor_handle_event (MetaWaylandCompositor *compositor,
const ClutterEvent *event); const ClutterEvent *event);
MetaLauncher *meta_wayland_compositor_get_launcher (MetaWaylandCompositor *compositor);
gboolean meta_wayland_compositor_is_native (MetaWaylandCompositor *compositor); gboolean meta_wayland_compositor_is_native (MetaWaylandCompositor *compositor);
MetaWaylandBuffer * meta_wayland_buffer_from_resource (struct wl_resource *resource); MetaWaylandBuffer * meta_wayland_buffer_from_resource (struct wl_resource *resource);
@ -110,4 +109,8 @@ void meta_wayland_compositor_update (MetaWaylandComp
const ClutterEvent *event); const ClutterEvent *event);
void meta_wayland_compositor_paint_finished (MetaWaylandCompositor *compositor); void meta_wayland_compositor_paint_finished (MetaWaylandCompositor *compositor);
gboolean meta_wayland_compositor_activate_vt (MetaWaylandCompositor *compositor,
int vt,
GError **error);
#endif /* META_WAYLAND_PRIVATE_H */ #endif /* META_WAYLAND_PRIVATE_H */

View File

@ -743,14 +743,24 @@ meta_wayland_finalize (void)
meta_launcher_free (compositor->launcher); meta_launcher_free (compositor->launcher);
} }
MetaLauncher *
meta_wayland_compositor_get_launcher (MetaWaylandCompositor *compositor)
{
return compositor->launcher;
}
gboolean gboolean
meta_wayland_compositor_is_native (MetaWaylandCompositor *compositor) meta_wayland_compositor_is_native (MetaWaylandCompositor *compositor)
{ {
return compositor->native; return compositor->native;
} }
gboolean
meta_wayland_compositor_activate_vt (MetaWaylandCompositor *compositor,
int vt,
GError **error)
{
if (compositor->launcher)
{
return meta_launcher_activate_vt (compositor->launcher, vt, error);
}
else
{
g_debug ("Ignoring VT switch keybinding, not running as VT manager");
return TRUE;
}
}