[gnome-session] Export GL/GLES renderer string over DBus
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-session] Export GL/GLES renderer string over DBus
- Date: Sat, 9 Apr 2016 04:08:45 +0000 (UTC)
commit 122fa5731be915c6a8f02114f3422f0c3bb4e5a7
Author: Cosimo Cecchi <cosimo endlessm com>
Date: Fri Apr 8 12:50:38 2016 -0700
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
gnome-session/gsm-manager.c | 7 ++++++
gnome-session/gsm-manager.h | 3 ++
gnome-session/main.c | 5 +++-
gnome-session/org.gnome.SessionManager.xml | 10 ++++++++
tools/gnome-session-check-accelerated.c | 32 ++++++++++++++++++++++++---
5 files changed, 52 insertions(+), 5 deletions(-)
---
diff --git a/gnome-session/gsm-manager.c b/gnome-session/gsm-manager.c
index a378cd9..49aa31e 100644
--- a/gnome-session/gsm-manager.c
+++ b/gnome-session/gsm-manager.c
@@ -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,
diff --git a/gnome-session/gsm-manager.h b/gnome-session/gsm-manager.h
index 8fa8fed..bc440cb 100644
--- a/gnome-session/gsm-manager.h
+++ b/gnome-session/gsm-manager.h
@@ -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);
diff --git a/gnome-session/main.c b/gnome-session/main.c
index 615b4ce..a98a8d0 100644
--- a/gnome-session/main.c
+++ b/gnome-session/main.c
@@ -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 ();
diff --git a/gnome-session/org.gnome.SessionManager.xml b/gnome-session/org.gnome.SessionManager.xml
index ccf44bb..580ec35 100644
--- a/gnome-session/org.gnome.SessionManager.xml
+++ b/gnome-session/org.gnome.SessionManager.xml
@@ -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>
diff --git a/tools/gnome-session-check-accelerated.c b/tools/gnome-session-check-accelerated.c
index d21744f..b0557b0 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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]