From 12156f7970e808210848a7d0177082667215b5e5 Mon Sep 17 00:00:00 2001 From: Nicholas Shiell Date: Mon, 17 Apr 2017 13:47:37 +0100 Subject: [PATCH] Use opacity to hide/show the window not iconifying --- pick/__main__.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/pick/__main__.py b/pick/__main__.py index 7f5ba4f..5132c2c 100644 --- a/pick/__main__.py +++ b/pick/__main__.py @@ -981,7 +981,12 @@ def clear_history(self, button): def grab(self, btn): self.grabbed = True - self.w.iconify() + + # Don't iconify (minimize) the window as some Window Managers + # (KDE and possibly Xfce) won't allow selecting a colour + # Instead just leave the window here but make it invisibile + self.w.set_opacity(0) + # we grab the keyboard so that we get the Escape keypress to cancel a pick even though we're iconified if self.keyboard: self.keyboard.grab( @@ -991,7 +996,8 @@ def grab(self, btn): Gdk.EventMask.KEY_PRESS_MASK, None, Gdk.CURRENT_TIME) - GLib.timeout_add(150, self.set_magnifier_cursor) # give the window time to iconify + + self.set_magnifier_cursor() def set_magnifier_cursor(self): root = Gdk.get_default_root_window() @@ -1118,6 +1124,11 @@ def ungrab(self, *args, **kwargs): if self.keyboard: self.keyboard.ungrab(Gdk.CURRENT_TIME) self.grabbed = False # deiconify doesn't seem to work, but http://stackoverflow.com/questions/24061029/how-to-deiconify-a-window-after-the-click-of-minimize-button-in-gtk + # The window will be 0% opaque + # minimize then set back to 100, then deiconify + # that way the window manager will nicely restore the window + self.w.iconify() + self.w.set_opacity(100) self.w.deiconify() self.w.present()