Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An incorrect monitor is chosen for the top panel blur at session start #697

Open
5h4d307 opened this issue Dec 18, 2024 · 0 comments
Open

Comments

@5h4d307
Copy link

5h4d307 commented Dec 18, 2024

Gnome Shell version: 45.5
Extension version: 58 (67 most likely affected too)
Setup: 1080p laptop with a 4K monitor connected as primary

Expected result: top panel is blurred across the full width at session start
Screenshot from 2024-12-18 03-07-00

Actual result: top panel is blurred only to the laptop screen's width at session start
Screenshot from 2024-12-18 03-06-50

While investigating the issue, I noticed that one of the child actors has the width param set to 1920.
If I toggle the panel blur or the entire extension, everything works correctly (as show in the ER screenshot).

I found that in the current implementation, find_monitor_for() returns an incorrect monitor at session start.
However, the v67 approach w/ findMonitorForActor() works the same way (I made similar adjustments in v58 and tested).

Below is a workaround patch that I'm currently using to overcome the issue.
Nevertheless, I'm not sure whether this solution is optimal, and most likely there are some caveats I may have missed.

Please share your thoughts.

The mentioned patch:

diff --git a/src/components/panel.js b/src/components/panel.js
index 0a335b5..2921b9d 100644
--- a/src/components/panel.js
+++ b/src/components/panel.js
@@ -145,7 +145,7 @@ export const PanelBlur = class PanelBlur {
             panel_box = panel_box.get_parent();
         }
 
-        let monitor = this.find_monitor_for(panel);
+        let monitor = Main.layoutManager.primaryMonitor;
         if (!monitor)
             return;
 
@@ -247,7 +247,7 @@ export const PanelBlur = class PanelBlur {
         actors.widgets.background = is_static
             ? new Meta.BackgroundActor({
                 meta_display: global.display,
-                monitor: this.find_monitor_for(actors.widgets.panel).index
+                monitor: Main.layoutManager.primaryMonitor.index
             })
             : new St.Widget;
 
@@ -317,7 +317,7 @@ export const PanelBlur = class PanelBlur {
         if (this.settings.panel.STATIC_BLUR) {
             let bg = Main.layoutManager._backgroundGroup.get_child_at_index(
                 Main.layoutManager.monitors.length
-                - this.find_monitor_for(actors.widgets.panel).index - 1
+                - Main.layoutManager.primaryMonitor.index - 1
             );
             if (bg && bg.get_content())
                 actors.widgets.background.content.set({
@@ -332,7 +332,7 @@ export const PanelBlur = class PanelBlur {
         let panel = actors.widgets.panel;
         let panel_box = actors.widgets.panel_box;
         let background = actors.widgets.background;
-        let monitor = this.find_monitor_for(panel);
+        let monitor = Main.layoutManager.primaryMonitor;
         if (!monitor)
             return;
 
@@ -362,23 +362,7 @@ export const PanelBlur = class PanelBlur {
         }
 
         // update the monitor panel is on
-        actors.monitor = this.find_monitor_for(panel);
-    }
-
-    /// An helper function to find the monitor in which an actor is situated,
-    /// there might be a pre-existing function in GLib already
-    find_monitor_for(actor) {
-        let extents = actor.get_transformed_extents();
-        let rect = new Mtk.Rectangle({
-            x: extents.get_x(),
-            y: extents.get_y(),
-            width: extents.get_width(),
-            height: extents.get_height(),
-        });
-
-        let index = global.display.get_monitor_index_for_rect(rect);
-
-        return Main.layoutManager.monitors[index];
+        actors.monitor = Main.layoutManager.primaryMonitor;
     }
 
     /// Connect when overview if opened/closed to hide/show the blur accordingly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant