Blame SOURCES/0004-background-refresh-background-on-gl-video-memory-pur.patch

21e770
From 055bc14c70af66fe1893dcd4c42c65662ae1f9d0 Mon Sep 17 00:00:00 2001
c7fac9
From: Ray Strode <rstrode@redhat.com>
c7fac9
Date: Mon, 21 Jan 2019 15:07:15 -0500
c7fac9
Subject: [PATCH 4/4] background: refresh background on gl-video-memory-purged
c7fac9
 signal
c7fac9
c7fac9
Right now we refresh the background when resuming and when NVIDIA.
c7fac9
But mutter has a signal to tell us specifically when to refresh,
c7fac9
and the signal is only emitted for NVIDIA, so use that instead.
c7fac9
---
c7fac9
 js/ui/background.js |  9 +++++++--
c7fac9
 js/ui/layout.js     | 12 ------------
21e770
 src/shell-util.c    | 27 ---------------------------
21e770
 src/shell-util.h    |  2 --
21e770
 4 files changed, 7 insertions(+), 43 deletions(-)
c7fac9
c7fac9
diff --git a/js/ui/background.js b/js/ui/background.js
21e770
index 75b76a57e..466cc4de7 100644
c7fac9
--- a/js/ui/background.js
c7fac9
+++ b/js/ui/background.js
21e770
@@ -527,10 +527,15 @@ var BackgroundSource = class BackgroundSource {
21e770
         let monitorManager = Meta.MonitorManager.get();
21e770
         this._monitorsChangedId =
21e770
             monitorManager.connect('monitors-changed',
21e770
-                                   this._onMonitorsChanged.bind(this));
21e770
+                                   this._refresh.bind(this));
c7fac9
+
c7fac9
+        global.display.connect('gl-video-memory-purged', () => {
21e770
+            Meta.Background.refresh_all();
21e770
+            this._refresh();
21e770
+        });
21e770
     }
c7fac9
 
c7fac9
-    _onMonitorsChanged() {
c7fac9
+    _refresh() {
c7fac9
         for (let monitorIndex in this._backgrounds) {
c7fac9
             let background = this._backgrounds[monitorIndex];
c7fac9
 
c7fac9
diff --git a/js/ui/layout.js b/js/ui/layout.js
21e770
index 30e750dc5..2b3bb7442 100644
c7fac9
--- a/js/ui/layout.js
c7fac9
+++ b/js/ui/layout.js
21e770
@@ -282,18 +282,6 @@ var LayoutManager = GObject.registerClass({
21e770
         monitorManager.connect('monitors-changed',
21e770
                                this._monitorsChanged.bind(this));
c7fac9
         this._monitorsChanged();
c7fac9
-
c7fac9
-        // NVIDIA drivers don't preserve FBO contents across
c7fac9
-        // suspend/resume, see
c7fac9
-        // https://bugzilla.gnome.org/show_bug.cgi?id=739178
c7fac9
-        if (Shell.util_need_background_refresh()) {
c7fac9
-            LoginManager.getLoginManager().connect('prepare-for-sleep',
c7fac9
-                (lm, suspending) => {
c7fac9
-                    if (suspending)
c7fac9
-                        return;
c7fac9
-                    Meta.Background.refresh_all();
c7fac9
-                });
c7fac9
-        }
21e770
     }
c7fac9
 
c7fac9
     // This is called by Main after everything else is constructed
c7fac9
diff --git a/src/shell-util.c b/src/shell-util.c
21e770
index c6e5abed6..9c25643c6 100644
c7fac9
--- a/src/shell-util.c
c7fac9
+++ b/src/shell-util.c
21e770
@@ -374,33 +374,6 @@ shell_util_create_pixbuf_from_data (const guchar      *data,
21e770
                                    (GdkPixbufDestroyNotify) g_free, NULL);
c7fac9
 }
c7fac9
 
21e770
-typedef const gchar *(*ShellGLGetString) (GLenum);
21e770
-
21e770
-static const gchar *
21e770
-get_gl_vendor (void)
21e770
-{
21e770
-  static const gchar *vendor = NULL;
21e770
-
21e770
-  if (!vendor)
21e770
-    {
21e770
-      ShellGLGetString gl_get_string;
21e770
-      gl_get_string = (ShellGLGetString) cogl_get_proc_address ("glGetString");
21e770
-      if (gl_get_string)
21e770
-        vendor = gl_get_string (GL_VENDOR);
21e770
-    }
21e770
-
21e770
-  return vendor;
21e770
-}
21e770
-
c7fac9
-gboolean
c7fac9
-shell_util_need_background_refresh (void)
c7fac9
-{
c7fac9
-  if (g_strcmp0 (get_gl_vendor (), "NVIDIA Corporation") == 0)
c7fac9
-    return TRUE;
c7fac9
-
c7fac9
-  return FALSE;
c7fac9
-}
c7fac9
-
c7fac9
 static gboolean
c7fac9
 canvas_draw_cb (ClutterContent *content,
c7fac9
                 cairo_t        *cr,
21e770
diff --git a/src/shell-util.h b/src/shell-util.h
21e770
index 6904f43bc..049c3fe18 100644
21e770
--- a/src/shell-util.h
21e770
+++ b/src/shell-util.h
21e770
@@ -44,8 +44,6 @@ GdkPixbuf *shell_util_create_pixbuf_from_data (const guchar      *data,
21e770
                                                int                height,
21e770
                                                int                rowstride);
21e770
 
21e770
-gboolean shell_util_need_background_refresh (void);
21e770
-
21e770
 ClutterContent * shell_util_get_content_for_window_actor (MetaWindowActor *window_actor,
21e770
                                                           MetaRectangle   *window_rect);
c7fac9
 
c7fac9
-- 
21e770
2.21.0
c7fac9