[gnome-shell] workspaceThumbnails: Pass monitor index to constructor



commit 2731d3572301d4639e623a14eb8fee6b0fcd45d4
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Feb 26 14:09:15 2021 +0100

    workspaceThumbnails: Pass monitor index to constructor
    
    We'll soon add workspace thumbnails on secondary monitors as well,
    so set the monitor explicitly instead of assuming the primary one.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1735>

 js/ui/overviewControls.js   |  4 ++--
 js/ui/workspaceThumbnail.js | 19 +++++++++++--------
 2 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/js/ui/overviewControls.js b/js/ui/overviewControls.js
index d595facae7..5e2f8f9f83 100644
--- a/js/ui/overviewControls.js
+++ b/js/ui/overviewControls.js
@@ -305,8 +305,8 @@ class ControlsManager extends St.Widget {
             this.dash.showAppsButton);
         this._searchController.connect('notify::search-active', this._onSearchChanged.bind(this));
 
-        this._thumbnailsBox =
-            new WorkspaceThumbnail.ThumbnailsBox(this._workspaceAdjustment);
+        this._thumbnailsBox = new WorkspaceThumbnail.ThumbnailsBox(
+            this._workspaceAdjustment, Main.layoutManager.primaryIndex);
         this._thumbnailsBox.connect('notify::should-show', () => {
             this._thumbnailsBox.show();
             this._thumbnailsBox.ease_property('expand-fraction',
diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js
index e54e8ab1d3..e805c4f522 100644
--- a/js/ui/workspaceThumbnail.js
+++ b/js/ui/workspaceThumbnail.js
@@ -258,7 +258,7 @@ var WorkspaceThumbnail = GObject.registerClass({
             0, 1, 0),
     },
 }, class WorkspaceThumbnail extends St.Widget {
-    _init(metaWorkspace) {
+    _init(metaWorkspace, monitorIndex) {
         super._init({
             clip_to_allocation: true,
             style_class: 'workspace-thumbnail',
@@ -267,7 +267,7 @@ var WorkspaceThumbnail = GObject.registerClass({
         this._delegate = this;
 
         this.metaWorkspace = metaWorkspace;
-        this.monitorIndex = Main.layoutManager.primaryIndex;
+        this.monitorIndex = monitorIndex;
 
         this._removed = false;
 
@@ -623,7 +623,7 @@ var ThumbnailsBox = GObject.registerClass({
             true),
     },
 }, class ThumbnailsBox extends St.Widget {
-    _init(scrollAdjustment) {
+    _init(scrollAdjustment, monitorIndex) {
         super._init({
             style_class: 'workspace-thumbnails',
             reactive: true,
@@ -641,6 +641,8 @@ var ThumbnailsBox = GObject.registerClass({
         this._indicator = indicator;
         this.add_actor(indicator);
 
+        this._monitorIndex = monitorIndex;
+
         this._dropWorkspace = -1;
         this._dropPlaceholderPos = -1;
         this._dropPlaceholder = new St.Bin({ style_class: 'placeholder' });
@@ -1069,7 +1071,7 @@ var ThumbnailsBox = GObject.registerClass({
 
         for (let k = start; k < start + count; k++) {
             let metaWorkspace = workspaceManager.get_workspace_by_index(k);
-            let thumbnail = new WorkspaceThumbnail(metaWorkspace);
+            let thumbnail = new WorkspaceThumbnail(metaWorkspace, this._monitorIndex);
             thumbnail.setPorthole(this._porthole.x, this._porthole.y,
                                   this._porthole.width, this._porthole.height);
             this._thumbnails.push(thumbnail);
@@ -1297,11 +1299,12 @@ var ThumbnailsBox = GObject.registerClass({
     }
 
     _updatePorthole() {
-        if (!Main.layoutManager.primaryMonitor) {
-            this._porthole = { width: global.stage.width, height: global.stage.height,
-                               x: global.stage.x, y: global.stage.y };
+        if (!Main.layoutManager.monitors[this._monitorIndex]) {
+            const { x, y, width, height } = global.stage;
+            this._porthole = { x, y, width, height };
         } else {
-            this._porthole = Main.layoutManager.getWorkAreaForMonitor(Main.layoutManager.primaryIndex);
+            this._porthole =
+                Main.layoutManager.getWorkAreaForMonitor(this._monitorIndex);
         }
 
         this.queue_relayout();


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