[gnome-shell] boxpointer: Compute source allocation and work area just once



commit 244a329ee76b90c912b90f367ced166abc8d0356
Author: Marco Trevisan (Treviño) <mail 3v1n0 net>
Date:   Fri Mar 8 14:36:23 2019 -0600

    boxpointer: Compute source allocation and work area just once
    
    Compute the source actor workarea and allocation when repositioning and keep it
    cached so that we've not to calculating it again in _calculateArrowSide.
    
    Since _calculateArrowSide only is called inside _updateFlip that is always
    called just after reposition, we can be sure that the computed values are still
    correct.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/435

 js/ui/boxpointer.js | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/js/ui/boxpointer.js b/js/ui/boxpointer.js
index 82dbbaf6a..c8e5ceda7 100644
--- a/js/ui/boxpointer.js
+++ b/js/ui/boxpointer.js
@@ -473,11 +473,15 @@ var BoxPointer = GObject.registerClass({
     _reposition() {
         let sourceActor = this._sourceActor;
         let alignment = this._arrowAlignment;
+        let monitorIndex = Main.layoutManager.findIndexForActor(sourceActor);
+
+        this._sourceAllocation = Shell.util_get_transformed_allocation(sourceActor);
+        this._workArea = Main.layoutManager.getWorkAreaForMonitor(monitorIndex);
 
         // Position correctly relative to the sourceActor
         let sourceNode = sourceActor.get_theme_node();
         let sourceContentBox = sourceNode.get_content_box(sourceActor.get_allocation_box());
-        let sourceAllocation = Shell.util_get_transformed_allocation(sourceActor);
+        let sourceAllocation = this._sourceAllocation;
         let sourceCenterX = sourceAllocation.x1 + sourceContentBox.x1 + (sourceContentBox.x2 - 
sourceContentBox.x1) * this._sourceAlignment;
         let sourceCenterY = sourceAllocation.y1 + sourceContentBox.y1 + (sourceContentBox.y2 - 
sourceContentBox.y1) * this._sourceAlignment;
         let [minWidth, minHeight, natWidth, natHeight] = this.get_preferred_size();
@@ -485,8 +489,7 @@ var BoxPointer = GObject.registerClass({
         // We also want to keep it onscreen, and separated from the
         // edge by the same distance as the main part of the box is
         // separated from its sourceActor
-        let monitorIndex = Main.layoutManager.findIndexForActor(sourceActor);
-        let workarea = Main.layoutManager.getWorkAreaForMonitor(monitorIndex);
+        let workarea = this._workArea;
         let themeNode = this.get_theme_node();
         let borderWidth = themeNode.get_length('-arrow-border-width');
         let arrowBase = themeNode.get_length('-arrow-base');
@@ -606,10 +609,9 @@ var BoxPointer = GObject.registerClass({
     }
 
     _calculateArrowSide(arrowSide) {
-        let sourceAllocation = Shell.util_get_transformed_allocation(this._sourceActor);
+        let sourceAllocation = this._sourceAllocation;
         let [minWidth, minHeight, boxWidth, boxHeight] = this.get_preferred_size();
-        let monitorIndex = Main.layoutManager.findIndexForActor(this._sourceActor);
-        let workarea = Main.layoutManager.getWorkAreaForMonitor(monitorIndex);
+        let workarea = this._workArea;
 
         switch (arrowSide) {
         case St.Side.TOP:


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