[gnome-control-center] info: Get renderer from gnome-session under Wayland
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] info: Get renderer from gnome-session under Wayland
- Date: Thu, 20 Oct 2016 18:10:45 +0000 (UTC)
commit 83c8c57761f849d535da554bc2362608eb4c1bf9
Author: Bastien Nocera <hadess hadess net>
Date: Tue Oct 11 13:41:16 2016 +0200
info: Get renderer from gnome-session under Wayland
Now that gnome-session's acceleration helper can print the renderer
under Wayland, launch it locally. We need to launch it locally as
Wayland is not available at the time gnome-session would launch the
helper, as there's no Wayland compositor yet.
Note that this code expects the gnome-session helper scripts to live
in $libexecdir, but distributions can use
--with-gnome-session-libexecdir=DIR to pass another one.
https://bugzilla.gnome.org/show_bug.cgi?id=756914
configure.ac | 12 ++++++++++++
m4/as-ac-expand.m4 | 43 +++++++++++++++++++++++++++++++++++++++++++
panels/info/Makefile.am | 13 +++++++------
panels/info/cc-info-panel.c | 39 +++++++++++++++++++++++++++++++--------
4 files changed, 93 insertions(+), 14 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 079777b..709f271 100644
--- a/configure.ac
+++ b/configure.ac
@@ -340,6 +340,17 @@ AC_SUBST(KRB5_LIBS)
USER_ACCOUNTS_PANEL_CFLAGS="$USER_ACCOUNTS_PANEL_CFLAGS $KRB5_CFLAGS"
USER_ACCOUNTS_PANEL_LIBS="$USER_ACCOUNTS_PANEL_LIBS $KRB5_LIBS"
+dnl Check for info panel
+AC_ARG_WITH([gnome-session-libexecdir],
+ AS_HELP_STRING([--with-gnome-session-libexecdir=DIR], [Directory for gnome-session s libexecdir]),
+ [],
+ [with_gnome_session_libexecdir=${libexecdir}])
+if test x$with_gnome_session_libexecdir == xno; then
+ with_gnome_session_libexecdir=${libexecdir}
+fi
+AS_AC_EXPAND(GNOMESESSIONDIR, $with_gnome_session_libexecdir)
+AC_SUBST([gnome_session_libexecdir], [$GNOMESESSIONDIR])
+
dnl =======================================
dnl Panels
dnl =======================================
@@ -589,4 +600,5 @@ if test "x$enable_ibus" = "xyes"; then
else
AC_MSG_NOTICE([ Region panel IBus support disabled])
fi
+AC_MSG_NOTICE([** gnome-session libexecdir: $GNOMESESSIONDIR])
AC_MSG_NOTICE([End options])
diff --git a/m4/as-ac-expand.m4 b/m4/as-ac-expand.m4
new file mode 100644
index 0000000..d6c9e33
--- /dev/null
+++ b/m4/as-ac-expand.m4
@@ -0,0 +1,43 @@
+dnl as-ac-expand.m4 0.2.0
+dnl autostars m4 macro for expanding directories using configure's prefix
+dnl thomas apestaart org
+
+dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
+dnl example
+dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
+dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
+
+AC_DEFUN([AS_AC_EXPAND],
+[
+ EXP_VAR=[$1]
+ FROM_VAR=[$2]
+
+ dnl first expand prefix and exec_prefix if necessary
+ prefix_save=$prefix
+ exec_prefix_save=$exec_prefix
+
+ dnl if no prefix given, then use /usr/local, the default prefix
+ if test "x$prefix" = "xNONE"; then
+ prefix="$ac_default_prefix"
+ fi
+ dnl if no exec_prefix given, then use prefix
+ if test "x$exec_prefix" = "xNONE"; then
+ exec_prefix=$prefix
+ fi
+
+ full_var="$FROM_VAR"
+ dnl loop until it doesn't change anymore
+ while true; do
+ new_full_var="`eval echo $full_var`"
+ if test "x$new_full_var" = "x$full_var"; then break; fi
+ full_var=$new_full_var
+ done
+
+ dnl clean up
+ full_var=$new_full_var
+ AC_SUBST([$1], "$full_var")
+
+ dnl restore prefix and exec_prefix
+ prefix=$prefix_save
+ exec_prefix=$exec_prefix_save
+])
diff --git a/panels/info/Makefile.am b/panels/info/Makefile.am
index 4569fa2..6e6f460 100644
--- a/panels/info/Makefile.am
+++ b/panels/info/Makefile.am
@@ -1,11 +1,12 @@
cappletname = info
-AM_CPPFLAGS = \
- $(PANEL_CFLAGS) \
- $(INFO_PANEL_CFLAGS) \
- -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
- -DDATADIR="\"$(datadir)\"" \
- -DBINDIR="\"$(bindir)\"" \
+AM_CPPFLAGS = \
+ $(PANEL_CFLAGS) \
+ $(INFO_PANEL_CFLAGS) \
+ -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
+ -DDATADIR="\"$(datadir)\"" \
+ -DGNOME_SESSION_DIR="\"$(gnome_session_libexecdir)\"" \
+ -DBINDIR="\"$(bindir)\"" \
$(NULL)
noinst_LTLIBRARIES = libinfo.la
diff --git a/panels/info/cc-info-panel.c b/panels/info/cc-info-panel.c
index 79729dd..943b4a3 100644
--- a/panels/info/cc-info-panel.c
+++ b/panels/info/cc-info-panel.c
@@ -235,6 +235,9 @@ prettify_info (const char *info)
{ "Graphics Controller", "Graphics"},
};
+ if (*info == '\0')
+ return NULL;
+
pretty = g_markup_escape_text (info, -1);
for (i = 0; i < G_N_ELEMENTS (rs); i++)
@@ -322,6 +325,27 @@ get_renderer_from_session (void)
return renderer;
}
+static char *
+get_renderer_from_helper (void)
+{
+ int status;
+ char *argv[] = { GNOME_SESSION_DIR "/gnome-session-check-accelerated", NULL };
+ char *renderer, *ret;
+
+ if (!g_spawn_sync (NULL, (char **) argv, NULL, 0, NULL, NULL, &renderer, NULL, &status, NULL))
+ return NULL;
+
+ if (!g_spawn_check_exit_status (status, NULL))
+ return NULL;
+
+ if (renderer == NULL || *renderer == '\0')
+ return NULL;
+
+ ret = prettify_info (renderer);
+ g_free (renderer);
+ return ret;
+}
+
static GraphicsData *
get_graphics_data (void)
{
@@ -332,19 +356,18 @@ get_graphics_data (void)
display = gdk_display_get_default ();
-#ifdef GDK_WINDOWING_X11
- if (GDK_IS_X11_DISPLAY (display))
+#if defined(GDK_WINDOWING_X11) || defined(GDK_WINDOWING_WAYLAND)
+ if (GDK_IS_X11_DISPLAY (display) ||
+ GDK_IS_WAYLAND_DISPLAY (display))
{
result->renderer = get_renderer_from_session ();
+ if (!result->renderer)
+ result->renderer = get_renderer_from_helper ();
result->hardware_string = result->renderer;
}
- else
-#endif
-#ifdef GDK_WINDOWING_WAYLAND
- if (GDK_IS_WAYLAND_DISPLAY (display))
- result->hardware_string = _("Wayland");
- else
#endif
+
+ if (!result->renderer)
result->hardware_string = _("Unknown");
return result;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]