Commit 122fa573 authored by Cosimo Cecchi's avatar Cosimo Cecchi Committed by Cosimo Cecchi

Export GL/GLES renderer string over DBus

This is useful to avoid repeating the same code e.g. in the Details
settings panel.

Note that it's possible that both the display manager and the user
session run gnome-session, and that they both share the same X server.
In that case, we need to store the renderer string as an X property on
the root window (like the helper already does for other properties).

https://bugzilla.gnome.org/show_bug.cgi?id=686806
parent f144cd28
......@@ -1415,6 +1415,13 @@ _gsm_manager_set_active_session (GsmManager *manager,
gsm_exported_manager_set_session_name (manager->priv->skeleton, session_name);
}
void
_gsm_manager_set_renderer (GsmManager *manager,
const char *renderer)
{
gsm_exported_manager_set_renderer (manager->priv->skeleton, renderer);
}
static gboolean
_app_has_app_id (const char *id,
GsmApp *app,
......
......@@ -120,6 +120,9 @@ void _gsm_manager_set_active_session (GsmManager *
const char *session_name,
gboolean is_fallback);
void _gsm_manager_set_renderer (GsmManager *manager,
const char *renderer);
gboolean gsm_manager_logout (GsmManager *manager,
guint logout_mode,
GError **error);
......
......@@ -54,6 +54,7 @@ static gboolean please_fail = FALSE;
static gboolean disable_acceleration_check = FALSE;
static const char *session_name = NULL;
static GsmManager *manager = NULL;
static char *gl_renderer;
static GMainLoop *loop;
......@@ -146,6 +147,7 @@ create_manager (void)
gsm_fail_whale_dialog_we_failed (FALSE, TRUE, NULL);
}
_gsm_manager_set_renderer (manager, gl_renderer);
gsm_manager_start (manager);
}
......@@ -220,7 +222,7 @@ check_gl (GError **error)
return TRUE;
}
if (!g_spawn_sync (NULL, (char **) argv, NULL, 0, NULL, NULL, NULL, NULL,
if (!g_spawn_sync (NULL, (char **) argv, NULL, 0, NULL, NULL, &gl_renderer, NULL,
&status, error)) {
return FALSE;
}
......@@ -446,6 +448,7 @@ main (int argc, char **argv)
gsm_main ();
g_clear_object (&manager);
g_free (gl_renderer);
g_bus_unown_name (name_owner_id);
gdm_log_shutdown ();
......
......@@ -424,6 +424,16 @@
</doc:doc>
</property>
<property name="Renderer" type="s" access="read">
<doc:doc>
<doc:description>
<doc:para>The renderer for the session that has been loaded.
At the moment this supports GL and GLES, and is only used for the
X session.</doc:para>
</doc:description>
</doc:doc>
</property>
<property name="SessionIsActive" type="b" access="read">
<doc:doc>
<doc:description>
......
......@@ -42,6 +42,7 @@
static Atom is_accelerated_atom;
static Atom is_software_rendering_atom;
static Atom renderer_atom;
static gboolean property_changed;
static gboolean
......@@ -95,8 +96,9 @@ main (int argc, char **argv)
{
GdkDisplay *display = NULL;
int estatus;
char *gl_helper_argv[] = { LIBEXECDIR "/gnome-session-check-accelerated-gl-helper", NULL };
char *gles_helper_argv[] = { LIBEXECDIR "/gnome-session-check-accelerated-gles-helper", NULL };
char *gl_helper_argv[] = { LIBEXECDIR "/gnome-session-check-accelerated-gl-helper", "--print-renderer", NULL };
char *gles_helper_argv[] = { LIBEXECDIR "/gnome-session-check-accelerated-gles-helper", "--print-renderer", NULL };
char *renderer_string = NULL;
Window rootwin;
glong is_accelerated, is_software_rendering;
GError *gl_error = NULL, *gles_error = NULL;
......@@ -116,6 +118,7 @@ main (int argc, char **argv)
is_accelerated_atom = gdk_x11_get_xatom_by_name_for_display (display, "_GNOME_SESSION_ACCELERATED");
is_software_rendering_atom = gdk_x11_get_xatom_by_name_for_display (display, "_GNOME_IS_SOFTWARE_RENDERING");
renderer_atom = gdk_x11_get_xatom_by_name_for_display (display, "_GNOME_SESSION_RENDERER");
{
Atom type;
......@@ -142,6 +145,17 @@ main (int argc, char **argv)
/* else fall through and do the check ourselves */
} else {
gdk_x11_display_error_trap_push (display);
XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display), rootwin,
renderer_atom,
0, G_MAXLONG, False, XA_STRING, &type, &format, &nitems,
&bytes_after, &data);
gdk_x11_display_error_trap_pop_ignored (display);
if (type == XA_STRING) {
g_print ("%s", data);
}
return (*is_accelerated_ptr == 0 ? 1 : 0);
}
}
......@@ -165,22 +179,24 @@ main (int argc, char **argv)
/* First, try the GL helper */
if (g_spawn_sync (NULL, (char **) gl_helper_argv, NULL, 0,
NULL, NULL, NULL, NULL, &estatus, &gl_error)) {
NULL, NULL, &renderer_string, NULL, &estatus, &gl_error)) {
is_accelerated = (WEXITSTATUS(estatus) == HELPER_ACCEL) || (WEXITSTATUS(estatus) == HELPER_SOFTWARE_RENDERING);
is_software_rendering = (WEXITSTATUS(estatus) == HELPER_SOFTWARE_RENDERING);
if (is_accelerated)
goto finish;
g_clear_pointer (&renderer_string, g_free);
g_printerr ("gnome-session-check-accelerated: GL Helper exited with code %d\n", estatus);
}
/* Then, try the GLES helper */
if (g_spawn_sync (NULL, (char **) gles_helper_argv, NULL, 0,
NULL, NULL, NULL, NULL, &estatus, &gles_error)) {
NULL, NULL, &renderer_string, NULL, &estatus, &gles_error)) {
is_accelerated = (WEXITSTATUS(estatus) == HELPER_ACCEL);
if (is_accelerated)
goto finish;
g_clear_pointer (&renderer_string, g_free);
g_printerr ("gnome-session-check-accelerated: GLES Helper exited with code %d\n", estatus);
}
......@@ -201,6 +217,14 @@ main (int argc, char **argv)
rootwin,
is_accelerated_atom,
XA_CARDINAL, 32, PropModeReplace, (guchar *) &is_accelerated, 1);
XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
rootwin,
renderer_atom,
XA_STRING, 8, PropModeReplace, (guchar *) renderer_string, strlen (renderer_string));
/* Print the renderer */
g_print ("%s", renderer_string);
}
if (is_software_rendering) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment