[kupfer: 23/51] ui: Close unused GdkDisplays if possible
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer: 23/51] ui: Close unused GdkDisplays if possible
- Date: Mon, 28 Mar 2011 15:03:00 +0000 (UTC)
commit 374452d08dbe21f31b2b4e58e2ee16038beca2f9
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Mon Mar 28 16:51:45 2011 +0200
ui: Close unused GdkDisplays if possible
Opportunistically close non-default displays if they are unused. This
allows Kupfer to not be killed when an auxiliary display is closed,
*if* we had time to move away our GtkWindows.
kupfer/ui/browser.py | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/kupfer/ui/browser.py b/kupfer/ui/browser.py
index 0c6fbe8..19f1845 100644
--- a/kupfer/ui/browser.py
+++ b/kupfer/ui/browser.py
@@ -1987,6 +1987,35 @@ class WindowController (pretty.OutputMixin):
self.current_screen_handler = \
screen.connect("monitors-changed", self._monitors_changed)
+ def _try_close_unused_displays(self, screen):
+ """@screen is current GdkScreen
+
+ Try to close inactive displays...
+ Take all GtkWindow that are hidden, and move to the
+ current screen. If no windows remain then we close
+ the display, but we never close the default display.
+ """
+ display = screen.get_display()
+ dm = gtk.gdk.display_manager_get()
+ for disp in list(dm.list_displays()):
+ if disp != display and disp != gtk.gdk.display_get_default():
+ self.output_debug("Trying to close", disp.get_name())
+ open_windows = 0
+ for window in gtk.window_list_toplevels():
+ # find windows on @disp
+ if window.get_screen().get_display() != disp:
+ continue
+ if not window.get_property("visible"):
+ self.output_debug("Moving window", window.get_name())
+ self.output_debug("Moving", window.get_title())
+ window.set_screen(screen)
+ else:
+ self.output_debug("Open window blocks close")
+ open_windows += 1
+ if not open_windows:
+ self.output_debug("Closing display", disp.get_name())
+ disp.close()
+
def _center_window(self, displayname=None):
"""Center Window on the monitor the pointer is currently on"""
def norm_name(name):
@@ -2022,6 +2051,7 @@ class WindowController (pretty.OutputMixin):
midx = geo.x + geo.width / 2 - wid / 2
midy = geo.y + geo.height / 2 - hei / 2
self.window.move(midx, midy)
+ self._try_close_unused_displays(screen)
def _should_recenter_window(self):
"""Return True if the mouse pointer and the window
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]