summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimo@endlessm.com>2016-04-08 12:50:38 -0700
committerCosimo Cecchi <cosimoc@gnome.org>2016-04-08 21:05:34 -0700
commit122fa5731be915c6a8f02114f3422f0c3bb4e5a7 (patch)
tree2dd59e8625717d3c4c206d7e46f667787a31bc9a /tools
parentf144cd28e7cc2425c9df8e8c44ef70041f2d6404 (diff)
downloadgnome-session-122fa5731be915c6a8f02114f3422f0c3bb4e5a7.tar.gz
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
Diffstat (limited to 'tools')
-rw-r--r--tools/gnome-session-check-accelerated.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/tools/gnome-session-check-accelerated.c b/tools/gnome-session-check-accelerated.c
index d21744f6..b0557b0a 100644
--- a/tools/gnome-session-check-accelerated.c
+++ b/tools/gnome-session-check-accelerated.c
@@ -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) {