gnome-shell/SOURCES/0004-background-refresh-bac...

246 lines
8.0 KiB
Diff
Raw Normal View History

2019-05-07 12:23:00 +00:00
From b440c4c529aee18ecc36a7b8a24809bc684cfe5b Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Mon, 21 Jan 2019 15:07:15 -0500
Subject: [PATCH 4/4] background: refresh background on gl-video-memory-purged
signal
Right now we refresh the background when resuming and when NVIDIA.
But mutter has a signal to tell us specifically when to refresh,
and the signal is only emitted for NVIDIA, so use that instead.
---
js/ui/background.js | 9 +++++++--
js/ui/layout.js | 12 ------------
src/shell-util.c | 9 ---------
3 files changed, 7 insertions(+), 23 deletions(-)
diff --git a/js/ui/background.js b/js/ui/background.js
index c61d946a4..ae7ef275e 100644
--- a/js/ui/background.js
+++ b/js/ui/background.js
@@ -512,64 +512,69 @@ var SystemBackground = new Lang.Class({
let image = cache.load(file);
if (image.is_loaded()) {
image = null;
let id = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
this.emit('loaded');
return GLib.SOURCE_REMOVE;
});
GLib.Source.set_name_by_id(id, '[gnome-shell] SystemBackground.loaded');
} else {
let id = image.connect('loaded', () => {
this.emit('loaded');
image.disconnect(id);
image = null;
});
}
},
});
Signals.addSignalMethods(SystemBackground.prototype);
var BackgroundSource = new Lang.Class({
Name: 'BackgroundSource',
_init(layoutManager, settingsSchema) {
// Allow override the background image setting for performance testing
this._layoutManager = layoutManager;
this._overrideImage = GLib.getenv('SHELL_BACKGROUND_IMAGE');
this._settings = new Gio.Settings({ schema_id: settingsSchema });
this._backgrounds = [];
this._monitorsChangedId = global.screen.connect('monitors-changed',
- this._onMonitorsChanged.bind(this));
+ this._refresh.bind(this));
+
+ global.display.connect('gl-video-memory-purged', () => {
+ Meta.Background.refresh_all();
+ this._refresh();
+ });
},
- _onMonitorsChanged() {
+ _refresh() {
for (let monitorIndex in this._backgrounds) {
let background = this._backgrounds[monitorIndex];
if (monitorIndex < this._layoutManager.monitors.length) {
background.updateResolution();
} else {
background.disconnect(background._changedId);
background.destroy();
delete this._backgrounds[monitorIndex];
}
}
},
getBackground(monitorIndex) {
let file = null;
let style;
// We don't watch changes to settings here,
// instead we rely on Background to watch those
// and emit 'changed' at the right time
if (this._overrideImage != null) {
file = Gio.File.new_for_path(this._overrideImage);
style = GDesktopEnums.BackgroundStyle.ZOOM; // Hardcode
} else {
style = this._settings.get_enum(BACKGROUND_STYLE_KEY);
if (style != GDesktopEnums.BackgroundStyle.NONE) {
let uri = this._settings.get_string(PICTURE_URI_KEY);
file = Gio.File.new_for_commandline_arg(uri);
}
diff --git a/js/ui/layout.js b/js/ui/layout.js
index 6f810395d..2cd1e5bd3 100644
--- a/js/ui/layout.js
+++ b/js/ui/layout.js
@@ -251,72 +251,60 @@ var LayoutManager = new Lang.Class({
this.addChrome(this.keyboardBox);
this._keyboardHeightNotifyId = 0;
// A dummy actor that tracks the mouse or text cursor, based on the
// position and size set in setDummyCursorGeometry.
this.dummyCursor = new St.Widget({ width: 0, height: 0, visible: false });
this.uiGroup.add_actor(this.dummyCursor);
global.stage.remove_actor(global.top_window_group);
this.uiGroup.add_actor(global.top_window_group);
let feedbackGroup = Meta.get_feedback_group_for_screen(global.screen);
global.stage.remove_actor(feedbackGroup);
this.uiGroup.add_actor(feedbackGroup);
this._backgroundGroup = new Meta.BackgroundGroup();
global.window_group.add_child(this._backgroundGroup);
this._backgroundGroup.lower_bottom();
this._bgManagers = [];
// Need to update struts on new workspaces when they are added
global.screen.connect('notify::n-workspaces',
this._queueUpdateRegions.bind(this));
global.screen.connect('restacked',
this._windowsRestacked.bind(this));
global.screen.connect('monitors-changed',
this._monitorsChanged.bind(this));
global.screen.connect('in-fullscreen-changed',
this._updateFullscreen.bind(this));
this._monitorsChanged();
-
- // NVIDIA drivers don't preserve FBO contents across
- // suspend/resume, see
- // https://bugzilla.gnome.org/show_bug.cgi?id=739178
- if (Shell.util_need_background_refresh()) {
- LoginManager.getLoginManager().connect('prepare-for-sleep',
- (lm, suspending) => {
- if (suspending)
- return;
- Meta.Background.refresh_all();
- });
- }
},
// This is called by Main after everything else is constructed
init() {
Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
this._loadBackground();
},
showOverview() {
this.overviewGroup.show();
this._inOverview = true;
this._updateVisibility();
},
hideOverview() {
this.overviewGroup.hide();
this._inOverview = false;
this._updateVisibility();
},
_sessionUpdated() {
this._updateVisibility();
this._queueUpdateRegions();
},
_updateMonitors() {
let screen = global.screen;
diff --git a/src/shell-util.c b/src/shell-util.c
index c43bf4cc5..c63c6efb7 100644
--- a/src/shell-util.c
+++ b/src/shell-util.c
@@ -369,69 +369,60 @@ shell_util_cursor_tracker_to_clutter (MetaCursorTracker *tracker,
sprite = meta_cursor_tracker_get_sprite (tracker);
if (sprite)
{
clutter_actor_show (CLUTTER_ACTOR (texture));
clutter_texture_set_cogl_texture (texture, sprite);
}
else
{
clutter_actor_hide (CLUTTER_ACTOR (texture));
}
}
typedef const gchar *(*ShellGLGetString) (GLenum);
static const gchar *
get_gl_vendor (void)
{
static const gchar *vendor = NULL;
if (!vendor)
{
ShellGLGetString gl_get_string;
gl_get_string = (ShellGLGetString) cogl_get_proc_address ("glGetString");
if (gl_get_string)
vendor = gl_get_string (GL_VENDOR);
}
return vendor;
}
-gboolean
-shell_util_need_background_refresh (void)
-{
- if (g_strcmp0 (get_gl_vendor (), "NVIDIA Corporation") == 0)
- return TRUE;
-
- return FALSE;
-}
-
static gboolean
canvas_draw_cb (ClutterContent *content,
cairo_t *cr,
gint width,
gint height,
gpointer user_data)
{
cairo_surface_t *surface = user_data;
cairo_set_source_surface (cr, surface, 0, 0);
cairo_paint (cr);
return FALSE;
}
/**
* shell_util_get_content_for_window_actor:
* @window_actor: a #MetaWindowActor
* @window_rect: a #MetaRectangle
*
* Returns: (transfer full): a new #ClutterContent
*/
ClutterContent *
shell_util_get_content_for_window_actor (MetaWindowActor *window_actor,
MetaRectangle *window_rect)
{
ClutterActor *texture;
ClutterContent *content;
cairo_surface_t *surface;
cairo_rectangle_int_t clip;
--
2.18.1