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
This commit is contained in:
Andrey Gursky 2018-03-16 16:59:54 +01:00 committed by Philipp Hörist
parent 8d583a1801
commit c6172c86ad
2 changed files with 8 additions and 9 deletions

View File

@ -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)

View File

@ -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: