[gnome-shell/gnome-41] magnifier: Include SSD when calculating screen coordinates for events



commit a09432340873dddb4ee1cea67de2f156ad4e2e07
Author: Sebastian Keller <skeller gnome org>
Date:   Tue May 31 18:18:45 2022 +0200

    magnifier: Include SSD when calculating screen coordinates for events
    
    When calculating the on screen coordinates of events from the window
    relative coordinates, using the frame rect will include the decorations
    added by the WM for SSD windows. This was causing the calculated
    coordinates to be slightly off. Fix this by using the client rect for
    SSD windows.
    
    Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2319>
    (cherry picked from commit 1952549788f9f9dad31359d9d00d827e1cd3d453)

 js/ui/magnifier.js | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/magnifier.js b/js/ui/magnifier.js
index ed55592083..188a45fdc6 100644
--- a/js/ui/magnifier.js
+++ b/js/ui/magnifier.js
@@ -830,14 +830,18 @@ var ZoomRegion = class ZoomRegion {
             throw new Error(`Failed to validate parent window: ${e}`);
         }
 
-        const focusWindowRect = global.display.focus_window?.get_frame_rect();
-        if (!focusWindowRect)
+        const { focusWindow } = global.display;
+        if (!focusWindow)
             return null;
 
+        let windowRect = focusWindow.get_frame_rect();
+        if (!focusWindow.is_client_decorated())
+            windowRect = focusWindow.frame_rect_to_client_rect(windowRect);
+
         const scaleFactor = St.ThemeContext.get_for_stage(global.stage).scale_factor;
         const screenSpaceExtents = new Atspi.Rect({
-            x: focusWindowRect.x + (scaleFactor * extents.x),
-            y: focusWindowRect.y + (scaleFactor * extents.y),
+            x: windowRect.x + (scaleFactor * extents.x),
+            y: windowRect.y + (scaleFactor * extents.y),
             width: scaleFactor * extents.width,
             height: scaleFactor * extents.height,
         });


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