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
This commit is contained in:
Bastien Nocera 2016-10-11 13:41:16 +02:00
parent 1ea7c182eb
commit 83c8c57761
4 changed files with 93 additions and 14 deletions

View file

@ -340,6 +340,17 @@ AC_SUBST(KRB5_LIBS)
USER_ACCOUNTS_PANEL_CFLAGS="$USER_ACCOUNTS_PANEL_CFLAGS $KRB5_CFLAGS" USER_ACCOUNTS_PANEL_CFLAGS="$USER_ACCOUNTS_PANEL_CFLAGS $KRB5_CFLAGS"
USER_ACCOUNTS_PANEL_LIBS="$USER_ACCOUNTS_PANEL_LIBS $KRB5_LIBS" 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 =======================================
dnl Panels dnl Panels
dnl ======================================= dnl =======================================
@ -589,4 +600,5 @@ if test "x$enable_ibus" = "xyes"; then
else else
AC_MSG_NOTICE([ Region panel IBus support disabled]) AC_MSG_NOTICE([ Region panel IBus support disabled])
fi fi
AC_MSG_NOTICE([** gnome-session libexecdir: $GNOMESESSIONDIR])
AC_MSG_NOTICE([End options]) AC_MSG_NOTICE([End options])

43
m4/as-ac-expand.m4 Normal file
View file

@ -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
])

View file

@ -1,11 +1,12 @@
cappletname = info cappletname = info
AM_CPPFLAGS = \ AM_CPPFLAGS = \
$(PANEL_CFLAGS) \ $(PANEL_CFLAGS) \
$(INFO_PANEL_CFLAGS) \ $(INFO_PANEL_CFLAGS) \
-DGNOMELOCALEDIR="\"$(datadir)/locale\"" \ -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
-DDATADIR="\"$(datadir)\"" \ -DDATADIR="\"$(datadir)\"" \
-DBINDIR="\"$(bindir)\"" \ -DGNOME_SESSION_DIR="\"$(gnome_session_libexecdir)\"" \
-DBINDIR="\"$(bindir)\"" \
$(NULL) $(NULL)
noinst_LTLIBRARIES = libinfo.la noinst_LTLIBRARIES = libinfo.la

View file

@ -235,6 +235,9 @@ prettify_info (const char *info)
{ "Graphics Controller", "Graphics"}, { "Graphics Controller", "Graphics"},
}; };
if (*info == '\0')
return NULL;
pretty = g_markup_escape_text (info, -1); pretty = g_markup_escape_text (info, -1);
for (i = 0; i < G_N_ELEMENTS (rs); i++) for (i = 0; i < G_N_ELEMENTS (rs); i++)
@ -322,6 +325,27 @@ get_renderer_from_session (void)
return renderer; 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 * static GraphicsData *
get_graphics_data (void) get_graphics_data (void)
{ {
@ -332,19 +356,18 @@ get_graphics_data (void)
display = gdk_display_get_default (); display = gdk_display_get_default ();
#ifdef GDK_WINDOWING_X11 #if defined(GDK_WINDOWING_X11) || defined(GDK_WINDOWING_WAYLAND)
if (GDK_IS_X11_DISPLAY (display)) if (GDK_IS_X11_DISPLAY (display) ||
GDK_IS_WAYLAND_DISPLAY (display))
{ {
result->renderer = get_renderer_from_session (); result->renderer = get_renderer_from_session ();
if (!result->renderer)
result->renderer = get_renderer_from_helper ();
result->hardware_string = result->renderer; result->hardware_string = result->renderer;
} }
else
#endif
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DISPLAY (display))
result->hardware_string = _("Wayland");
else
#endif #endif
if (!result->renderer)
result->hardware_string = _("Unknown"); result->hardware_string = _("Unknown");
return result; return result;