[gnome-shell] AppDisplay: fix folder popup arrow



commit 37700b4b1aa0488d9ad37215e6c08c66b006eb2e
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Wed Feb 20 14:13:46 2013 +0100

    AppDisplay: fix folder popup arrow
    
    The arrow origin must be in the coordinate space of the box pointer,
    but it cannot be calculated when the box pointer is shown, because it's
    not allocated yet, so pass the source to the boxpointer and adjust
    the arrow at the next paint.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=694264

 js/ui/appDisplay.js |    3 ++-
 js/ui/boxpointer.js |   24 ++++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index c38e328..c247189 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -648,7 +648,8 @@ const AppFolderPopup = new Lang.Class({
             return;
 
         this.actor.show();
-        this._boxPointer.setArrowOrigin(this._source.actor.x + this._source.actor.width / 2);
+
+        this._boxPointer.setArrowActor(this._source.actor);
         this._boxPointer.show(BoxPointer.PopupAnimation.FADE |
                               BoxPointer.PopupAnimation.SLIDE);
 
diff --git a/js/ui/boxpointer.js b/js/ui/boxpointer.js
index 233432e..9f85e02 100644
--- a/js/ui/boxpointer.js
+++ b/js/ui/boxpointer.js
@@ -38,6 +38,7 @@ const BoxPointer = new Lang.Class({
         this._arrowSide = arrowSide;
         this._userArrowSide = arrowSide;
         this._arrowOrigin = 0;
+        this._arrowActor = null;
         this.actor = new St.Bin({ x_fill: true,
                                   y_fill: true });
         this._container = new Shell.GenericContainer();
@@ -228,6 +229,19 @@ const BoxPointer = new Lang.Class({
     _drawBorder: function(area) {
         let themeNode = this.actor.get_theme_node();
 
+        if (this._arrowActor) {
+            let [sourceX, sourceY] = this._arrowActor.get_transformed_position();
+            let [sourceWidth, sourceHeight] = this._arrowActor.get_transformed_size();
+            let [absX, absY] = this.actor.get_transformed_position();
+
+            if (this._arrowSide == St.Side.TOP ||
+                this._arrowSide == St.Side.BOTTOM) {
+                this._arrowOrigin = sourceX - absX + sourceWidth / 2;
+            } else {
+                this._arrowOrigin = sourceY - absY + sourceHeight / 2;
+            }
+        }
+
         let borderWidth = themeNode.get_length('-arrow-border-width');
         let base = themeNode.get_length('-arrow-base');
         let rise = themeNode.get_length('-arrow-rise');
@@ -537,6 +551,16 @@ const BoxPointer = new Lang.Class({
         }
     },
 
+    // @actor: an actor relative to which the arrow is positioned.
+    // Differently from setPosition, this will not move the boxpointer itself,
+    // on the arrow
+    setArrowActor: function(actor) {
+        if (this._arrowActor != actor) {
+            this._arrowActor = actor;
+            this._border.queue_repaint();
+        }
+    },
+
     _shiftActor : function() {
         // Since the position of the BoxPointer depends on the allocated size
         // of the BoxPointer and the position of the source actor, trying


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