diff --git a/0001-info-Get-renderer-from-gnome-session-under-Wayland.patch b/0001-info-Get-renderer-from-gnome-session-under-Wayland.patch new file mode 100644 index 0000000..915517a --- /dev/null +++ b/0001-info-Get-renderer-from-gnome-session-under-Wayland.patch @@ -0,0 +1,195 @@ +From 83c8c57761f849d535da554bc2362608eb4c1bf9 Mon Sep 17 00:00:00 2001 +From: Bastien Nocera +Date: Tue, 11 Oct 2016 13:41:16 +0200 +Subject: [PATCH 1/2] 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(-) + create mode 100644 m4/as-ac-expand.m4 + +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; +-- +2.9.3 + diff --git a/0002-info-Show-both-GPUs-on-dual-GPU-machines.patch b/0002-info-Show-both-GPUs-on-dual-GPU-machines.patch new file mode 100644 index 0000000..f9c56a0 --- /dev/null +++ b/0002-info-Show-both-GPUs-on-dual-GPU-machines.patch @@ -0,0 +1,157 @@ +From 3312e428635d81d08cf5ab720de9a650ed967d6e Mon Sep 17 00:00:00 2001 +From: Bastien Nocera +Date: Wed, 19 Oct 2016 12:38:17 +0200 +Subject: [PATCH 2/2] info: Show both GPUs on dual-GPU machines + +Use "DRI_PRIME=1" trick to launch gnome-session's accelerated checks. + +https://bugzilla.gnome.org/show_bug.cgi?id=773213 +--- + panels/info/cc-info-panel.c | 96 +++++++++++++++++++++++++++++++++++++-------- + 1 file changed, 79 insertions(+), 17 deletions(-) + +diff --git a/panels/info/cc-info-panel.c b/panels/info/cc-info-panel.c +index 943b4a3..96129dc 100644 +--- a/panels/info/cc-info-panel.c ++++ b/panels/info/cc-info-panel.c +@@ -63,10 +63,8 @@ CC_PANEL_REGISTER (CcInfoPanel, cc_info_panel) + (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_INFO_PANEL, CcInfoPanelPrivate)) + + typedef struct { +- /* Will be the string below, or "Unknown" */ +- const char *hardware_string; +- +- char *renderer; ++ /* Will be one or 2 GPU name strings, or "Unknown" */ ++ char *hardware_string; + } GraphicsData; + + typedef struct +@@ -283,7 +281,7 @@ prettify_info (const char *info) + static void + graphics_data_free (GraphicsData *gdata) + { +- g_free (gdata->renderer); ++ g_free (gdata->hardware_string); + g_slice_free (GraphicsData, gdata); + } + +@@ -326,23 +324,75 @@ get_renderer_from_session (void) + } + + static char * +-get_renderer_from_helper (void) ++get_renderer_from_helper (gboolean discrete_gpu) + { + int status; + char *argv[] = { GNOME_SESSION_DIR "/gnome-session-check-accelerated", NULL }; +- char *renderer, *ret; ++ char **envp = NULL; ++ char *renderer = NULL; ++ char *ret = NULL; + +- if (!g_spawn_sync (NULL, (char **) argv, NULL, 0, NULL, NULL, &renderer, NULL, &status, NULL)) +- return NULL; ++ if (discrete_gpu) ++ { ++ envp = g_get_environ (); ++ envp = g_environ_setenv (envp, "DRI_PRIME", "1", TRUE); ++ } ++ ++ if (!g_spawn_sync (NULL, (char **) argv, envp, 0, NULL, NULL, &renderer, NULL, &status, NULL)) ++ goto out; + + if (!g_spawn_check_exit_status (status, NULL)) +- return NULL; ++ goto out; + + if (renderer == NULL || *renderer == '\0') +- return NULL; ++ goto out; + + ret = prettify_info (renderer); ++ ++out: + g_free (renderer); ++ g_strfreev (envp); ++ return ret; ++} ++ ++static gboolean ++has_dual_gpu (void) ++{ ++ GDBusProxy *switcheroo_proxy; ++ GVariant *dualgpu_variant; ++ gboolean ret; ++ GError *error = NULL; ++ ++ switcheroo_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM, ++ G_DBUS_PROXY_FLAGS_NONE, ++ NULL, ++ "net.hadess.SwitcherooControl", ++ "/net/hadess/SwitcherooControl", ++ "net.hadess.SwitcherooControl", ++ NULL, &error); ++ if (switcheroo_proxy == NULL) ++ { ++ g_debug ("Unable to connect to create a proxy for net.hadess.SwitcherooControl: %s", ++ error->message); ++ g_error_free (error); ++ return FALSE; ++ } ++ ++ dualgpu_variant = g_dbus_proxy_get_cached_property (switcheroo_proxy, "HasDualGpu"); ++ g_object_unref (switcheroo_proxy); ++ ++ if (!dualgpu_variant) ++ { ++ g_debug ("Unable to retrieve net.hadess.SwitcherooControl.HasDualGpu property, the daemon is likely not running"); ++ return FALSE; ++ } ++ ++ ret = g_variant_get_boolean (dualgpu_variant); ++ g_variant_unref (dualgpu_variant); ++ ++ if (ret) ++ g_debug ("Dual-GPU machine detected"); ++ + return ret; + } + +@@ -360,15 +410,27 @@ get_graphics_data (void) + 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; ++ char *discrete_renderer = NULL; ++ char *renderer; ++ ++ renderer = get_renderer_from_session (); ++ if (!renderer) ++ renderer = get_renderer_from_helper (FALSE); ++ if (has_dual_gpu ()) ++ discrete_renderer = get_renderer_from_helper (TRUE); ++ if (!discrete_renderer) ++ result->hardware_string = g_strdup (renderer); ++ else ++ result->hardware_string = g_strdup_printf ("%s / %s", ++ renderer, ++ discrete_renderer); ++ g_free (renderer); ++ g_free (discrete_renderer); + } + #endif + +- if (!result->renderer) +- result->hardware_string = _("Unknown"); ++ if (!result->hardware_string) ++ result->hardware_string = g_strdup (_("Unknown")); + + return result; + } +-- +2.9.3 + diff --git a/control-center.spec b/control-center.spec index e6183fe..3d8f9da 100644 --- a/control-center.spec +++ b/control-center.spec @@ -10,7 +10,7 @@ Name: control-center Epoch: 1 Version: 3.22.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Utilities to configure the GNOME desktop License: GPLv2+ and GFDL @@ -20,6 +20,11 @@ Source0: https://download.gnome.org/sources/gnome-control-center/3.22/gnome-cont # https://bugzilla.gnome.org/show_bug.cgi?id=695691 Patch0: distro-logo.patch +# https://bugzilla.gnome.org/show_bug.cgi?id=756914 +# https://bugzilla.gnome.org/show_bug.cgi?id=773213 +Patch1: 0001-info-Get-renderer-from-gnome-session-under-Wayland.patch +Patch2: 0002-info-Show-both-GPUs-on-dual-GPU-machines.patch + BuildRequires: pkgconfig(accountsservice) BuildRequires: pkgconfig(cheese-gtk) >= 3.5.91 BuildRequires: pkgconfig(clutter-gtk-1.0) @@ -91,6 +96,7 @@ Requires: cups-pk-helper Requires: nm-connection-editor # For the info/details panel Requires: glx-utils +Requires: switcheroo-control # For the keyboard panel Requires: /usr/bin/gkbd-keyboard-display # For the color panel @@ -127,6 +133,8 @@ utilities. %prep %setup -q -n gnome-control-center-%{version} %patch0 -p1 -b .distro-logo +%patch1 -p1 +%patch2 -p1 %build %configure \ @@ -212,6 +220,10 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || : %changelog +* Fri Oct 21 2016 Bastien Nocera - 1:3.22.1-2 ++ control-center-3.22.1-2 +- Show the correct GPUs available when under Wayland or with dual GPUs + * Wed Oct 12 2016 Kalev Lember - 1:3.22.1-1 - Update to 3.22.1