ZaneA / HashTWM

An automatic Tiling Window Manager for the Windows OS.
Other
457 stars 33 forks source link

[ Focus Stealing ] HashTWM handling windows stealing focus #11

Open sirjaren opened 11 years ago

sirjaren commented 11 years ago

It seems applications may steal focus for various reasons, leaving HashTWM almost unusable for any reasonable length of time.

With Windows 7, the various tweaks/fixes to prevent windows from stealing focus have been removed and/or unchangeable.

I've noticed this happening a lot with KiTTY (PuTTY) as well as with Outlook 2010, as example applications.

Some applications have fine-grained controls in handling how pop-ups and window focus affect the user. Unfortunately, it appears HashTWM is fleshing out the bugs with the various applications' settings or there is a bug within HashTWM.

Would a command line argument to ignore any and all applications from stealing focus be something reasonable to implement? I'd prefer to only focus on the window I've highlighted with mod+j or mod+k.

Thank you.

ZaneA commented 11 years ago

I certainly agree that you shouldn't have to be fighting against windows that are stealing focus. I'll look into it and see what I can do!

ZaneA commented 11 years ago

Hi there,

So far I'm unable to reproduce the focus stealing... I wrote an example to open a MessageBox to try and steal focus, if I run this from the command-line it DOES take focus, but this is to be expected as I'm invoking it directly. However if I change this utility to wait 10 seconds before opening the MessageBox, then it does NOT steal focus, even if I add a flag telling it to set itself as the foreground window.

I tried out PuTTY as well by trying to open a connection to a non-existing address, if I switch to another window and wait for it to timeout it still does not steal focus while opening its error dialog.

I have however noticed that the usual WINDOWACTIVATED hook does not seem to get called at all on newer versions of Windows, and have added the RUDEAPPACTIVATED hook there which does get called. I don't expect this to help in this case however.

If you're able to reproduce the focus stealing through some code then that would be the best chance for me to be able to fix it, otherwise I will keep investigating.

For what it's worth the examples I tried were:

#include <windows.h>

int main() {
    MessageBox(NULL, "test", "test", MB_OK);
    return 0;
}

followed by:

#include <windows.h>

int main() {
    Sleep(10000);
    MessageBox(NULL, "test", "test", MB_OK | MB_SETFOREGROUND);
    return 0;
}
ZaneA commented 1 year ago

This should be fixed as of the most recent commit (assuming it is the same issue as https://github.com/ZaneA/HashTWM/issues/30), have pushed a new binary here https://github.com/ZaneA/HashTWM/blob/master/hashtwm.exe (although I suspect you would have well moved on by now :D)

sirjaren commented 1 year ago

Unbelievable!

Almost exactly 10 years!

Yes, my workflow is different these days but what a fond blast from the past!

Congratulations on fixing this! 🥳