diff --git a/js/ui/main.js b/js/ui/main.js index 81ab67268..4a7fe32c3 100644 --- a/js/ui/main.js +++ b/js/ui/main.js @@ -46,6 +46,10 @@ let modalActorFocusStack = []; let _errorLogStack = []; let _startDate; +let background = null; +let _windowAddedSignalId = null; +let _windowRemovedSignalId = null; + function start() { // Add a binding for "global" in the global JS namespace; (gjs // keeps the web browser convention of having that namespace be @@ -134,7 +138,12 @@ function start() { } }); - _relayout(); + background = global.create_root_pixmap_actor(); + global.screen.connect('workspace-switched', _onWorkspaceSwitched); + global.stage.add_actor(background); + background.lower_bottom(); + _onWorkspaceSwitched(global.screen, -1); + global.connect('screen-size-changed', _relayout); ExtensionSystem.init(); @@ -195,12 +204,53 @@ function _getAndClearErrorStack() { return errors; } +function showBackground() { + background.show(); +} + +function hideBackground() { + background.hide(); +} + +function _onWorkspaceSwitched(screen, from) { + let workspace = screen.get_active_workspace(); + + if (from != -1) { + let old_workspace = screen.get_workspace_by_index(from); + + if (_windowAddedSignalId !== null) + old_workspace.disconnect(_windowAddedSignalId); + if (background.windowRemovedSignalId !== null) + old_workspace.disconnect(_windowRemovedSignalId); + } + + _windowAddedSignalId = workspace.connect('window-added', function(win) { + if (win.window_type == Meta.WindowType.DESKTOP) + hideBackground(); + }); + _windowRemovedSignalId = workspace.connect('window-removed', function(win) { + if (win.window_type == Meta.WindowType.DESKTOP) + showBackground(); + }); + + function _isDesktop(win) { + return win.window_type == Meta.WindowType.DESKTOP; + } + + if (workspace.list_windows().some(_isDesktop)) + hideBackground(); + else + showBackground(); +} + function _relayout() { let primary = global.get_primary_monitor(); panel.actor.set_position(primary.x, primary.y); panel.actor.set_size(primary.width, Panel.PANEL_HEIGHT); overview.relayout(); + background.set_size(global.screen_width, global.screen_height); + // To avoid updating the position and size of the workspaces // in the overview, we just hide the overview. The positions // will be updated when it is next shown. We do the same for diff --git a/js/ui/workspace.js b/js/ui/workspace.js index 219ab6e89..9a7f019bb 100644 --- a/js/ui/workspace.js +++ b/js/ui/workspace.js @@ -287,10 +287,10 @@ DesktopClone.prototype = { this.actor = new Clutter.Clone({ source: window.get_texture(), reactive: true }); } else { - this.actor = new Clutter.Rectangle({ color: global.stage.color, - reactive: true, - width: global.screen_width, - height: global.screen_height }); + this.actor = new Clutter.Clone({ source: Main.background.source, + reactive: true, + width: global.screen_width, + height: global.screen_height }); } this.actor.connect('button-release-event', diff --git a/src/shell-global.c b/src/shell-global.c index 25aa06dda..0385b6fa4 100644 --- a/src/shell-global.c +++ b/src/shell-global.c @@ -28,6 +28,7 @@ #define SHELL_DBUS_SERVICE "org.gnome.Shell" static void grab_notify (GtkWidget *widget, gboolean is_grab, gpointer user_data); +static void update_root_window_pixmap (ShellGlobal *global); struct _ShellGlobal { GObject parent; @@ -481,11 +482,7 @@ global_stage_notify_width (GObject *gobject, gpointer data) { ShellGlobal *global = SHELL_GLOBAL (data); - ClutterActor *stage = CLUTTER_ACTOR (gobject); - if (global->root_pixmap) - clutter_actor_set_width (CLUTTER_ACTOR (global->root_pixmap), - clutter_actor_get_width (stage)); g_object_notify (G_OBJECT (global), "screen-width"); meta_later_add (META_LATER_BEFORE_REDRAW, @@ -500,11 +497,7 @@ global_stage_notify_height (GObject *gobject, gpointer data) { ShellGlobal *global = SHELL_GLOBAL (data); - ClutterActor *stage = CLUTTER_ACTOR (gobject); - if (global->root_pixmap) - clutter_actor_set_height (CLUTTER_ACTOR (global->root_pixmap), - clutter_actor_get_height (stage)); g_object_notify (G_OBJECT (global), "screen-height"); meta_later_add (META_LATER_BEFORE_REDRAW, @@ -1042,6 +1035,9 @@ shell_global_create_root_pixmap_actor (ShellGlobal *global) { global->root_pixmap = clutter_glx_texture_pixmap_new (); + clutter_texture_set_repeat (CLUTTER_TEXTURE (global->root_pixmap), + TRUE, TRUE); + /* The low and medium quality filters give nearest-neighbor resizing. */ clutter_texture_set_filter_quality (CLUTTER_TEXTURE (global->root_pixmap), CLUTTER_TEXTURE_QUALITY_HIGH);