Add meta_activate_session

This will be used on startup to switch to the newly activated session.
This commit is contained in:
Jasper St. Pierre 2014-03-11 17:04:22 -04:00
parent f21312e2fd
commit d47b7ba038
6 changed files with 46 additions and 2 deletions

View File

@ -502,6 +502,32 @@ meta_register_with_session (void)
g_free (opt_client_id); g_free (opt_client_id);
} }
/**
* meta_activate_session:
*
* Tells mutter to activate the session. When mutter is a
* Wayland compositor, this tells logind to switch over to
* the new session.
*/
gboolean
meta_activate_session (void)
{
if (meta_is_wayland_compositor ())
{
MetaWaylandCompositor *compositor = meta_wayland_compositor_get_default ();
GError *error = NULL;
if (!meta_wayland_compositor_activate_session (compositor, &error))
{
g_warning ("Could not activate session: %s\n", error->message);
g_error_free (error);
return FALSE;
}
}
return TRUE;
}
/** /**
* meta_run: (skip) * meta_run: (skip)
* *

View File

@ -28,6 +28,7 @@ GOptionContext *meta_get_option_context (void);
void meta_init (void); void meta_init (void);
int meta_run (void); int meta_run (void);
void meta_register_with_session (void); void meta_register_with_session (void);
gboolean meta_activate_session (void);
gboolean meta_get_replace_current_wm (void); /* Actually defined in util.c */ gboolean meta_get_replace_current_wm (void); /* Actually defined in util.c */
void meta_set_wm_name (const char *wm_name); void meta_set_wm_name (const char *wm_name);

View File

@ -734,3 +734,18 @@ meta_wayland_compositor_activate_vt (MetaWaylandCompositor *compositor,
return TRUE; return TRUE;
} }
} }
gboolean
meta_wayland_compositor_activate_session (MetaWaylandCompositor *compositor,
GError **error)
{
if (compositor->launcher)
{
return meta_launcher_activate_vt (compositor->launcher, -1, error);
}
else
{
g_debug ("Ignoring activate_session, not running as display server");
return TRUE;
}
}

View File

@ -46,6 +46,8 @@ void meta_wayland_compositor_paint_finished (MetaWaylandComp
gboolean meta_wayland_compositor_activate_vt (MetaWaylandCompositor *compositor, gboolean meta_wayland_compositor_activate_vt (MetaWaylandCompositor *compositor,
int vt, int vt,
GError **error); GError **error);
gboolean meta_wayland_compositor_activate_session (MetaWaylandCompositor *compositor,
GError **error);
#endif #endif

View File

@ -399,7 +399,7 @@ meta_launcher_free (MetaLauncher *launcher)
gboolean gboolean
meta_launcher_activate_vt (MetaLauncher *launcher, meta_launcher_activate_vt (MetaLauncher *launcher,
int vt, signed char vt,
GError **error) GError **error)
{ {
struct weston_launcher_activate_vt message; struct weston_launcher_activate_vt message;

View File

@ -29,7 +29,7 @@ MetaLauncher *meta_launcher_new (void);
void meta_launcher_free (MetaLauncher *self); void meta_launcher_free (MetaLauncher *self);
gboolean meta_launcher_activate_vt (MetaLauncher *self, gboolean meta_launcher_activate_vt (MetaLauncher *self,
int number, signed char vt,
GError **error); GError **error);
gboolean meta_launcher_set_drm_fd (MetaLauncher *self, gboolean meta_launcher_set_drm_fd (MetaLauncher *self,