lanoxx / tilda

A Gtk based drop down terminal for Linux and Unix
GNU General Public License v2.0
1.28k stars 161 forks source link

Prevent repetitive PULL_TOGGLE when autohide option is used #116

Closed furkanmustafa closed 9 years ago

furkanmustafa commented 9 years ago

I had a problem hiding tilda with toggle hot key when auto_hide_on_focus_lost was enabled. Autohide was working perfectly. But if I try to hide with the toggle key, it was getting back instantly. When I compiled it with the debug mode, the following output happened (in an instant way) when I tried toggle hiding the window.

tilda_window.c: FUNCTION ENTERED: focus_out_event_cb
tilda_window.c: FUNCTION ENTERED: start_auto_hide_tick
key_grabber.c: FUNCTION ENTERED: pull
key_grabber.c: FUNCTION ENTERED: onKeybindingPull
key_grabber.c: FUNCTION ENTERED: pull
tilda_window.c: FUNCTION ENTERED: focus_term
key_grabber.c: FUNCTION ENTERED: tilda_window_set_active

The main reason is a false alarm of losing focus when toggle key is used. So it quickly does two things in order; 1) Autohide (lost focus) 2) Toggle, which is reverting it again.

My solution here might be an ugly workaround, not sure. I've added a small timeout (150ms) for a PULL_TOGGLE action to be able to happen after a PULL_UP action.

Had to move enum pull_state into tilda_window.h, please relocate if you dislike it there.

And thanks for nice piece for software :)

bnkr commented 9 years ago

Great! This is a possible fix for #57 and its duplicate #106. I will try and confirm this when I next get a chance to rebuild. Perhaps these bugs might give you some more information if you didn't already seem them.

furkanmustafa commented 9 years ago

Yea, #57 and #106 also looks like the same issue. And as it's said in the other issues, this might be a window manager bug actually, a global hotkey shouldn't blur/unfocus the current window. And my solution here then, really is a workaround, since it doesn't (and cannot) fix the main issue.

Please let me know if it works for you! Thanks.

bnkr commented 9 years ago

I've tried out this build and it seems to fix my problem. Great work!

I didn't consider that this was a window manager bug because I've used kde's yakuake on the same window manager without problems but I suppose it's possible.

I'm not really convinced that tilda is properly taking or giving up focus at the right points. Sometimes I can have tilda in a state where I am interacting with another window and press F11 (fullscreen) and it will pop tilda up in fullscreen. Your time delay thing seems to work fine but it seems to me like there needs to be some kind of lock on focus changes while the animation is happening.... I'm really not good enough at X11 or GTK to know the best answer here. Perhaps this can give you some more ideas though.

lanoxx commented 9 years ago

Merged. Thanks for the patch.