[gnome-shell-extensions] naturalWindowPlacement: Don't copy relayout() function



commit 97d1cbca190efda23654a516bab18ee412a49c77
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Sep 20 02:30:06 2017 +0200

    naturalWindowPlacement: Don't copy relayout() function
    
    To move title captions to the top, we can simply apply a translation
    before calling the unmodified original function.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=787934

 extensions/native-window-placement/extension.js |   37 ++---------------------
 1 files changed, 3 insertions(+), 34 deletions(-)
---
diff --git a/extensions/native-window-placement/extension.js b/extensions/native-window-placement/extension.js
index ca48939..e19ad64 100644
--- a/extensions/native-window-placement/extension.js
+++ b/extensions/native-window-placement/extension.js
@@ -371,43 +371,12 @@ function enable() {
 
     /// position window titles on top of windows in overlay ////
     if (windowCaptionsOnTop) {
-
-        /// This is almost a direct copy of the original relayout function. Differences are marked.
         winInjections['relayout'] = Workspace.WindowOverlay.prototype.relayout;
         Workspace.WindowOverlay.prototype.relayout = function(animate) {
-            winInjections['relayout'].call(this, animate);
-            let title = this.title;
-            let border = this.border;
-
-            this._parentActor.set_child_above_sibling(title, border);
-
-            Tweener.removeTweens(title);
-
-            let [cloneX, cloneY, cloneWidth, cloneHeight] = this._windowClone.slot;
+            let [, , , cloneHeight] = this._windowClone.slot;
+            this.title.translation_y = -cloneHeight;
 
-            // Clutter.Actor.get_preferred_width() will return the fixed width if one
-            // is set, so we need to reset the width by calling set_width(-1), to forward
-            // the call down to StLabel.
-            // We also need to save and restore the current width, otherwise the animation
-            // starts from the wrong point.
-            let prevTitleWidth = title.width;
-            title.set_width(-1);
-            let [titleMinWidth, titleNatWidth] = title.get_preferred_width(-1);
-            let titleWidth = Math.max(titleMinWidth, Math.min(titleNatWidth, cloneWidth));
-            title.width = prevTitleWidth;
-
-            let titleX = cloneX + (cloneWidth - titleWidth) / 2;
-
-            /// this is the actual difference to original gnome-shell:
-            //let titleY = cloneY + cloneHeight - (title.height - this.borderSize) / 2;
-            let titleY = cloneY - (title.height - this.borderSize) / 2;
-
-            if (animate)
-                this._animateOverlayActor(title, Math.floor(titleX), Math.floor(titleY), titleWidth);
-            else {
-                title.width = titleWidth;
-                title.set_position(Math.floor(titleX), Math.floor(titleY));
-            }
+            winInjections['relayout'].call(this, animate);
         };
     }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]