From 126da56a6884a4fb255afe3add45f28d1edd7951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20J=C3=B8rgen=20Br=C3=B8nner?= Date: Fri, 29 Sep 2017 18:40:15 +0200 Subject: [PATCH] WIP: Two working alternatives for a wrapper that let us use "frame coordinates" Note: the allocation method is called ALOT WindowCloneLayout based on the one in workspace.js, but the original calulates the offset based on a static frame_rect. Unless that's updated the clone's position will follow the source. The containers position (using the layout manager) will _not_ follow it though. So the clone is not properly contained inside the container.. --- minimap.js | 51 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/minimap.js b/minimap.js index a38155f..f46cc06 100644 --- a/minimap.js +++ b/minimap.js @@ -18,23 +18,37 @@ allocationChanged = function allocationChanged(actor, propertySpec) { const notifySignal = Symbol(); -var WindowCloneLayout = new Lang.Class({ - Name: 'WindowCloneLayout2', +WindowClone = new Lang.Class({ + Name: 'WindowClone', + Extends: Clutter.Actor, + + _init: function(metaWindow) { + this.parent(); + this.metaWindow = metaWindow; + this.clone = new Clutter.Clone({source: metaWindow.get_compositor_private()}); + let [dx, dy] = calcOffset(metaWindow); + this.add_actor(this.clone); + this.clone.x = -dx; + this.clone.y = -dy; + }, + + vfunc_get_preferred_height: function(forWidth) { + let frame = this.metaWindow.get_frame_rect(); + return [frame.height, frame.height]; + }, + + vfunc_get_preferred_width: function(forHeight) { + let frame = this.metaWindow.get_frame_rect(); + return [frame.width, frame.width]; + } +}); + +WindowCloneLayout = new Lang.Class({ + Name: 'WindowCloneLayout', Extends: Clutter.LayoutManager, - _init: function(boundingBox) { + _init: function() { this.parent(); - - this._boundingBox = boundingBox; - }, - - get boundingBox() { - return this._boundingBox; - }, - - set boundingBox(b) { - this._boundingBox = b; - this.layout_changed(); }, _makeBoxForWindow: function(window) { @@ -52,10 +66,9 @@ var WindowCloneLayout = new Lang.Class({ let box = new Clutter.ActorBox(); - box.set_origin(-(inputRect.x - frame.x), - -(inputRect.y - frame.y)); - box.set_size(frame.width, frame.height); - // debug("box", box.get_x(), box.get_y(), box.get_width(), box.get_height()) + box.set_origin((inputRect.x - frame.x), + (inputRect.y - frame.y)); + box.set_size(inputRect.width, inputRect.height); return box; }, @@ -84,7 +97,6 @@ var WindowCloneLayout = new Lang.Class({ } }); - function Minimap(space) { let viewport = new Clutter.Actor(); viewport.space = space; @@ -162,7 +174,6 @@ function Minimap(space) { let selectedIndex = space.selectedIndex(); viewport.restack(selectedIndex); viewport.layout(viewport.clones); - viewport.clones[selectedIndex].set_style_class_name("paper-mm-selected-window"); } viewport.visible = !viewport.visible; }