From c6172c86adc07ad2a4be1fd84004c00af3c42162 Mon Sep 17 00:00:00 2001 From: Andrey Gursky Date: Fri, 16 Mar 2018 16:59:54 +0100 Subject: [PATCH] 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 --- gajim/dialogs.py | 4 ++-- gajim/gtkgui_helpers.py | 13 ++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/gajim/dialogs.py b/gajim/dialogs.py index fd8cd4833..3a3af2b63 100644 --- 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) diff --git a/gajim/gtkgui_helpers.py b/gajim/gtkgui_helpers.py index 28cb7f8e1..fc201a600 100644 --- 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: