Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use opacity to hide/show the window not iconifying #33

Open
wants to merge 1 commit into
base: app
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions pick/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to wait anymore as we are not iconifying


def set_magnifier_cursor(self):
root = Gdk.get_default_root_window()
Expand Down Expand Up @@ -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()

Expand Down