[gnome-shell] boxpointer: Don't set actor position during allocation



commit 5481c1899f3d477bbf9f8319fe6ef933f77fc4e1
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date:   Thu Jun 13 19:24:01 2019 +0200

    boxpointer: Don't set actor position during allocation
    
    As per commit 044572cb60 boxpointer uses its own coordinates to position itself.
    However this would lead to warning when mutter-clutter is compiled with debug
    options as we'd might try to set the box coordinates during the allocation
    cycle.
    
    So, when calling _reposition during allocation, instead of setting the actor's
    coordinates we just pass the allocation box and we adjust its origin, in order
    to set it properly in the vfunc.
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/1382
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/576

 js/ui/boxpointer.js | 25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/js/ui/boxpointer.js b/js/ui/boxpointer.js
index 5615614e1..9939a5abf 100644
--- a/js/ui/boxpointer.js
+++ b/js/ui/boxpointer.js
@@ -234,13 +234,10 @@ var BoxPointer = GObject.registerClass({
         this.set_allocation(box, flags);
 
         let themeNode = this.get_theme_node();
-        box = themeNode.get_content_box(box);
-
         let borderWidth = themeNode.get_length('-arrow-border-width');
         let rise = themeNode.get_length('-arrow-rise');
         let childBox = new Clutter.ActorBox();
-        let availWidth = box.x2 - box.x1;
-        let availHeight = box.y2 - box.y1;
+        let [availWidth, availHeight] = themeNode.get_content_box(box).get_size();
 
         childBox.x1 = 0;
         childBox.y1 = 0;
@@ -269,8 +266,9 @@ var BoxPointer = GObject.registerClass({
         this.bin.allocate(childBox, flags);
 
         if (this._sourceActor && this._sourceActor.mapped) {
-            this._reposition();
-            this._updateFlip();
+            this._reposition(box);
+            this._updateFlip(box);
+            this.set_allocation(box, flags);
         }
     }
 
@@ -494,7 +492,7 @@ var BoxPointer = GObject.registerClass({
         this.setPosition(this._sourceActor, this._arrowAlignment);
     }
 
-    _reposition() {
+    _reposition(allocationBox) {
         let sourceActor = this._sourceActor;
         let alignment = this._arrowAlignment;
         let monitorIndex = Main.layoutManager.findIndexForActor(sourceActor);
@@ -607,9 +605,14 @@ var BoxPointer = GObject.registerClass({
             parent = parent.get_parent();
         }
 
+        x = Math.floor(x);
+        y = Math.floor(y);
+
         // Actually set the position
-        this.x = Math.floor(x);
-        this.y = Math.floor(y);
+        if (!allocationBox)
+            this.set_position(x, y);
+        else
+            allocationBox.set_origin(x, y);
     }
 
     // @origin: Coordinate specifying middle of the arrow, along
@@ -663,11 +666,11 @@ var BoxPointer = GObject.registerClass({
         return arrowSide;
     }
 
-    _updateFlip() {
+    _updateFlip(allocationBox) {
         let arrowSide = this._calculateArrowSide(this._userArrowSide);
         if (this._arrowSide != arrowSide) {
             this._arrowSide = arrowSide;
-            this._reposition();
+            this._reposition(allocationBox);
             Meta.later_add(Meta.LaterType.BEFORE_REDRAW, () => {
                 this.queue_relayout();
                 return false;


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