summaryrefslogtreecommitdiff
path: root/panels/info
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2013-01-12 17:43:21 +0100
committerGiovanni Campagna <gcampagna@src.gnome.org>2013-01-15 17:47:15 +0100
commitc60221e0b4187a6eaa34dd1ec31e92cccab57349 (patch)
treee35c389a8165c509e1c219812a4e7bd5a7e42100 /panels/info
parent7e94eca2fbe460435af2d49380846e41b95fdf9d (diff)
downloadgnome-control-center-c60221e0b4187a6eaa34dd1ec31e92cccab57349.tar.gz
Don't use glxinfo to access the graphic driver name
glxinfo is part of mesa-demos, and installing it pulls a lot of unnecessary programs. We can get the same informations by querying the driver directly. https://bugzilla.gnome.org/show_bug.cgi?id=691613
Diffstat (limited to 'panels/info')
-rw-r--r--panels/info/cc-info-panel.c87
1 files changed, 48 insertions, 39 deletions
diff --git a/panels/info/cc-info-panel.c b/panels/info/cc-info-panel.c
index ff8c1bd87..1b92881fc 100644
--- a/panels/info/cc-info-panel.c
+++ b/panels/info/cc-info-panel.c
@@ -35,6 +35,10 @@
#include <glibtop/mem.h>
#include <glibtop/sysinfo.h>
+#include <gdk/gdkx.h>
+#include <GL/gl.h>
+#include <GL/glx.h>
+
#include "gsd-disk-space-helper.h"
/* Autorun options */
@@ -297,54 +301,59 @@ graphics_data_free (GraphicsData *gdata)
}
static char *
-get_graphics_data_glx_renderer (void)
+get_graphics_data_glx_renderer ()
{
- GError *error;
- GRegex *re;
- GMatchInfo *match_info;
- char *output;
- char *result;
- GString *info;
+ Display *display;
+ int attributes[] = {
+ GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
+ GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
+ GLX_RENDER_TYPE, GLX_RGBA_BIT,
+ None
+ };
+ int nconfigs;
+ Window window;
+ GLXFBConfig *config;
+ GLXWindow glxwin;
+ GLXContext context;
+ char *renderer;
- info = g_string_new (NULL);
+ gdk_error_trap_push ();
- error = NULL;
- g_spawn_command_line_sync ("glxinfo -l", &output, NULL, NULL, &error);
- if (error != NULL)
- {
- g_warning ("Unable to get graphics info: %s", error->message);
- g_error_free (error);
- return NULL;
- }
+ display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
- re = g_regex_new ("^OpenGL renderer string: (.+)$", G_REGEX_MULTILINE, 0, &error);
- if (re == NULL)
- {
- g_warning ("Error building regex: %s", error->message);
- g_error_free (error);
- goto out;
- }
+ config = glXChooseFBConfig (display, DefaultScreen (display),
+ attributes, &nconfigs);
+ if (config == NULL) {
+ g_warning ("Failed to get OpenGL configuration");
- g_regex_match (re, output, 0, &match_info);
- while (g_match_info_matches (match_info))
- {
- char *device;
+ gdk_error_trap_pop_ignored ();
+ return NULL;
+ }
- device = g_match_info_fetch (match_info, 1);
- g_string_append_printf (info, "%s ", device);
- g_free (device);
+ window = XCreateSimpleWindow (display, DefaultRootWindow (display),
+ 0, 0, /* x, y */
+ 1, 1, /* width, height */
+ 0, 0, 0 /* border_width, border, background */);
+ glxwin = glXCreateWindow (display, *config, window, NULL);
- g_match_info_next (match_info, NULL);
- }
- g_match_info_free (match_info);
- g_regex_unref (re);
+ context = glXCreateNewContext (display, *config, GLX_RGBA_TYPE,
+ NULL, TRUE);
- out:
- g_free (output);
- result = prettify_info (info->str);
- g_string_free (info, TRUE);
+ glXMakeContextCurrent (display, glxwin, glxwin, context);
+ renderer = (char *) glGetString (GL_RENDERER);
+ renderer = renderer ? prettify_info (renderer) : NULL;
- return result;
+ glXMakeContextCurrent (display, None, None, NULL);
+ glXDestroyContext (display, context);
+ glXDestroyWindow (display, glxwin);
+ XDestroyWindow (display, window);
+
+ if (gdk_error_trap_pop () != Success) {
+ g_warning ("Failed to get OpenGL driver info");
+ return NULL;
+ }
+
+ return renderer;
}
static char *