From b3bafa75ff1e321ada3528023fe2c91555337193 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Tue, 22 Jan 2008 17:47:56 +0000 Subject: [PATCH] never move a window outside the screen. fixes #3501 --- src/dialogs.py | 6 +++--- src/gtkgui_helpers.py | 5 +++++ src/message_window.py | 2 +- src/roster_window.py | 6 +++--- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/dialogs.py b/src/dialogs.py index 64695c16a..c5cba1ea7 100644 --- a/src/dialogs.py +++ b/src/dialogs.py @@ -2063,12 +2063,12 @@ class SingleMessageWindow: if gajim.config.get('saveposition'): # get window position and size from config - gtkgui_helpers.move_window(self.window, - gajim.config.get('single-msg-x-position'), - gajim.config.get('single-msg-y-position')) gtkgui_helpers.resize_window(self.window, gajim.config.get('single-msg-width'), gajim.config.get('single-msg-height')) + gtkgui_helpers.move_window(self.window, + gajim.config.get('single-msg-x-position'), + gajim.config.get('single-msg-y-position')) self.window.show_all() def on_single_message_window_destroy(self, widget): diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py index c69716460..1bfe3955f 100644 --- a/src/gtkgui_helpers.py +++ b/src/gtkgui_helpers.py @@ -247,6 +247,11 @@ def move_window(window, x, y): x = 0 if y < 0: y = 0 + w, h = window.get_size() + if x + w > screen_w: + x = screen_w - w + if y + h > screen_h: + y = screen_h - h window.move(x, y) def resize_window(window, w, h): diff --git a/src/message_window.py b/src/message_window.py index c1eaf8fc6..1a7ce786c 100644 --- a/src/message_window.py +++ b/src/message_window.py @@ -870,8 +870,8 @@ class MessageWindowMgr(gobject.GObject): # Position and size window based on saved state and window mode if not self.one_window_opened(contact, acct, type): - self._position_window(win, acct, type) self._resize_window(win, acct, type) + self._position_window(win, acct, type) self._windows[win_key] = win return win diff --git a/src/roster_window.py b/src/roster_window.py index 7da8e5293..039309550 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -5420,12 +5420,12 @@ class RosterWindow: # no need of this variable self.have_new_chat_accel = False # Is the "Ctrl+N" shown ? if gajim.config.get('saveposition'): - gtkgui_helpers.move_window(self.window, - gajim.config.get('roster_x-position'), - gajim.config.get('roster_y-position')) gtkgui_helpers.resize_window(self.window, gajim.config.get('roster_width'), gajim.config.get('roster_height')) + gtkgui_helpers.move_window(self.window, + gajim.config.get('roster_x-position'), + gajim.config.get('roster_y-position')) self.popups_notification_height = 0 self.popup_notification_windows = []