Philipp Hörist pushed to branch master at gajim / gajim

Commits:
c6172c86 by Andrey Gursky at 2018-03-21T19:40:54+01:00
Fix window position restore on multi-head setups

Gajim stopped to properly restore roster and dialogs windows positions
after restart with more than one monitor attached.

Gajim saves the absolute window positions, i.e. based on the total screen size
of all monitors attached. Despite Gtk deprecated Gdk.Screen.width() and 
height(),
we cannot just use width() and height() for one monitor, as recommended.
We still need the total screen size, which was the base for saving the 
positions.

[1] 
https://stackoverflow.com/questions/30207586/gdk-screen-vs-monitor-vs-display

- - - - -


2 changed files:

- gajim/dialogs.py
- gajim/gtkgui_helpers.py


Changes:

=====================================
gajim/dialogs.py
=====================================
--- a/gajim/dialogs.py
+++ b/gajim/dialogs.py
@@ -3179,7 +3179,7 @@ class PopupNotificationWindow:
         window_width, self.window_height = self.window.get_size()
         app.interface.roster.popups_notification_height += self.window_height
         pos_x = app.config.get('notification_position_x')
-        screen_w, screen_h = gtkgui_helpers.get_display_geometry()
+        screen_w, screen_h = gtkgui_helpers.get_total_screen_geometry()
         if pos_x < 0:
             pos_x = screen_w - window_width + pos_x + 1
         pos_y = app.config.get('notification_position_y')
@@ -3216,7 +3216,7 @@ class PopupNotificationWindow:
             current_index += 1
             window_width, window_height = window_instance.window.get_size()
             app.interface.roster.popups_notification_height += window_height
-            screen_w, screen_h = gtkgui_helpers.get_display_geometry()
+            screen_w, screen_h = gtkgui_helpers.get_total_screen_geometry()
             window_instance.window.move(screen_w - window_width,
                 screen_h - \
                 app.interface.roster.popups_notification_height)


=====================================
gajim/gtkgui_helpers.py
=====================================
--- a/gajim/gtkgui_helpers.py
+++ b/gajim/gtkgui_helpers.py
@@ -100,11 +100,10 @@ if os.name == 'nt':
 
 from gajim.common import helpers
 
-def get_display_geometry():
-    display = Gdk.Display.get_default()
-    monitor = display.get_monitor(0)
-    geometry = monitor.get_geometry()
-    return geometry.width, geometry.height
+def get_total_screen_geometry():
+    screen = Gdk.Screen.get_default()
+    window = Gdk.Screen.get_root_window(screen)
+    return window.get_width(), window.get_height()
 
 def add_image_to_button(button, icon_name):
     img = Gtk.Image()
@@ -175,7 +174,7 @@ def move_window(window, x, y):
     """
     Move the window, but also check if out of screen
     """
-    screen_w, screen_h = get_display_geometry()
+    screen_w, screen_h = get_total_screen_geometry()
     if x < 0:
         x = 0
     if y < 0:
@@ -191,7 +190,7 @@ def resize_window(window, w, h):
     """
     Resize window, but also checks if huge window or negative values
     """
-    screen_w, screen_h = get_display_geometry()
+    screen_w, screen_h = get_total_screen_geometry()
     if not w or not h:
         return
     if w > screen_w:



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/commit/c6172c86adc07ad2a4be1fd84004c00af3c42162

---
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/commit/c6172c86adc07ad2a4be1fd84004c00af3c42162
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to