[kupfer: 18/51] ui: Put the monitors-changed callback into place



commit 483fae5593d55bef5fc21dd65d00842725447759
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Mon Mar 28 16:51:43 2011 +0200

    ui: Put the monitors-changed callback into place

 kupfer/ui/browser.py |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/kupfer/ui/browser.py b/kupfer/ui/browser.py
index 5bb4908..0c6fbe8 100644
--- a/kupfer/ui/browser.py
+++ b/kupfer/ui/browser.py
@@ -1751,6 +1751,7 @@ class WindowController (pretty.OutputMixin):
 		# GdkDisplay and GdkScreen
 		self.screens = set()
 		self.displays = set()
+		self.current_screen_handler = 0
 
 		data_controller = data.DataController()
 		data_controller.connect("launched-action", self.launch_callback)
@@ -1972,6 +1973,9 @@ class WindowController (pretty.OutputMixin):
 		return norm_name(cur_disp) == norm_name(displayname)
 
 	def _window_put_on_screen(self, screen):
+		if self.current_screen_handler:
+			scr = self.window.get_screen()
+			scr.disconnect(self.current_screen_handler)
 		rgba = screen.get_rgba_colormap()
 		if rgba:
 			self.window.unrealize()
@@ -1980,6 +1984,8 @@ class WindowController (pretty.OutputMixin):
 			self.window.realize()
 		else:
 			self.window.set_screen(screen)
+		self.current_screen_handler = \
+			screen.connect("monitors-changed", self._monitors_changed)
 
 	def _center_window(self, displayname=None):
 		"""Center Window on the monitor the pointer is currently on"""
@@ -2166,10 +2172,6 @@ class WindowController (pretty.OutputMixin):
 		client.connect("save-yourself", self._session_save)
 		client.connect("die", self._session_die)
 
-		# GTK Screen callbacks
-		scr = gtk.gdk.screen_get_default()
-		scr.connect("monitors-changed", self._monitors_changed)
-
 		self.output_debug("finished lazy_setup")
 
 	def main(self, quiet=False):



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