From b886656f61150953c286de6fefdc85113bb375dd Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 3 Sep 2014 16:03:24 +0200 Subject: [PATCH] workspace: Take a MetaWindow as argument to setReservedSlot() And use it to lookup the local WindowClone that applies. Otherwise, WorkspaceThumbnail.WindowClone objects may be mistakenly set, which are not usable interchangeably with Workspace.WindowClone ones. This may lead to several misbehaviors as fields available in the second object but not in the first one are accessed, some those undefined values get used in math ops, which result in NaNs over the place. Likewise, the similar functions in WorkspacesViewBase subclasses take now MetaWindow arguments too. https://bugzilla.gnome.org/show_bug.cgi?id=735972 --- js/ui/workspace.js | 14 +++++++++----- js/ui/workspacesView.js | 10 +++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/js/ui/workspace.js b/js/ui/workspace.js index 66058b93d..cee9ae538 100644 --- a/js/ui/workspace.js +++ b/js/ui/workspace.js @@ -1209,14 +1209,18 @@ const Workspace = new Lang.Class({ return this._windows.length == 0; }, - setReservedSlot: function(clone) { - if (this._reservedSlot == clone) + setReservedSlot: function(metaWindow) { + if (this._reservedSlotWindow == metaWindow) return; - if (clone && this.containsMetaWindow(clone.metaWindow)) - clone = null; + if (!metaWindow || this.containsMetaWindow(metaWindow)) { + this._reservedSlotWindow = null; + this._reservedSlot = null; + } else { + this._reservedSlotWindow = metaWindow; + this._reservedSlot = this._windows[this._lookupIndex(metaWindow)]; + } - this._reservedSlot = clone; this._recalculateWindowPositions(WindowPositionFlags.ANIMATE); }, diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js index 004ac81ae..9e75661f6 100644 --- a/js/ui/workspacesView.js +++ b/js/ui/workspacesView.js @@ -65,7 +65,7 @@ const WorkspacesViewBase = new Lang.Class({ _dragBegin: function(overview, clone) { this._inDrag = true; - this._setReservedSlot(clone); + this._setReservedSlot(clone.metaWindow); }, _dragEnd: function() { @@ -127,9 +127,9 @@ const WorkspacesView = new Lang.Class({ Lang.bind(this, this._activeWorkspaceChanged)); }, - _setReservedSlot: function(clone) { + _setReservedSlot: function(window) { for (let i = 0; i < this._workspaces.length; i++) - this._workspaces[i].setReservedSlot(clone); + this._workspaces[i].setReservedSlot(window); }, _syncFullGeometry: function() { @@ -366,8 +366,8 @@ const ExtraWorkspaceView = new Lang.Class({ this.actor.add_actor(this._workspace.actor); }, - _setReservedSlot: function(clone) { - this._workspace.setReservedSlot(clone); + _setReservedSlot: function(window) { + this._workspace.setReservedSlot(window); }, _syncFullGeometry: function() {