Heidi stealing focus when connecting

lemon_juice's profile image lemon_juice posted 11 years ago in Feature discussion Permalink
When I open Heidi or start the session manager and choose a server to connect to then after the connection is made Heidi's window steals focus in the OS. Would it be possible to disable this behaviour?

The reason is that sometimes connecting to a server takes a while, especially on SSH connections, so I choose a server to connect to and switch to another application to do some work and then after a while Heidi suddenly jumps out at me to the foreground interrupting my work, which is a bit annoying. It would be great if this didn't happen. If I leave the connection manager in focus (that is I wait for the connection) then it's fine that the new Heidi window gets focus. But when I switch to another application before the new Heidi window is created then it should open in the background without interfering with what I'm doing. Is this a reasonable request?
ansgar's profile image ansgar posted 11 years ago Permalink
Can confirm that. Only I can't seem to be able to programatically prevent HeidiSQL from stealing OS focus when the main form shows up. I just tried
ShowWindow(Handle, SW_SHOWNOACTIVATE)

and disable code like
MakeFullyVisible(Screen.Monitors[MonitorIndex])

... all with no luck.
lemon_juice's profile image lemon_juice posted 11 years ago Permalink
So perhaps a workaround could be to make Heidi open its new window immediately without waiting for the connection? Then we could avoid the issue.

It would have the added of being able to see messages in the log pane while connecting. Currently, the first connection is happening in an invisible way, be it from the connection manager or a jump list and we get the problem of focus stealing.

But notice how connecting works when Heidi is running and I disconnect from the server with the disconnect button - the connection manager opens but the main Heidi window is in the background and when I choose to connect I get to see the log messages of the connection process in the main window. If it could work like that even on first connection it would be even better than fixing the stealing focus problem. Just open the main window beforehand. What do you think?
ansgar's profile image ansgar posted 11 years ago Permalink
I think the first connection should not show up an empty window in the background. That would make it quite ugly. And I'm not even sure if that works for your focus problem. No clue.
lemon_juice's profile image lemon_juice posted 11 years ago Permalink
Ugly is subjective and I think we use Heidi not for prettiness but mainly for its functionality. Having the log messages showing connection status is much more useful than not seeing anything. And yes, it solves the focus problem - see it for yourself: connect to a server and then disconnect - what happens is that the object tree in the main window disappears but the log page is still there and the connection window appears on top. Now when you connect to any server and it takes time Heidi doesn't steal focus any more.

So there's nothing really more to add, the solution is already there. I find connecting with the main window open behind more user friendly than without it at the current state of things. If only the same happened on the first connect it would be great.
ansgar's profile image ansgar posted 11 years ago Permalink
I'll go and try out if that really works.

Prettiness is always important, not only functionality. Well, perhaps it's not that ugly as I might think. Let me check that.
lemon_juice's profile image lemon_juice posted 11 years ago Permalink
Thanks - it's not some super important thing but any improvement would be nice.

As to ugliness - I should have said that functionality is more important than prettiness. I must admit Heidi's interface is actually very pretty - the fonts, colours, icons, element sizes - I appreciate all of that so I would be wrong to say that prettiness is not important :)
Code modification/commit bd35beb from ansgar.becker, 11 years ago, revision 8.1.0.4652
Show session manager with a visible main form in the background. Should prevent HeidiSQL from stealing focus in OnShow, or wherever that happens. See http://www.heidisql.com/forum.php?t=14133
ansgar's profile image ansgar posted 11 years ago Permalink
Try out r4652
ansgar's profile image ansgar posted 11 years ago Permalink
Reverted in r4654. Causes an access violation at start up. See here: http://www.heidisql.com/forum.php?t=13962#p14160
lemon_juice's profile image lemon_juice posted 11 years ago Permalink
Yes, something was broken in r4652, the session manager windows seemed to open one after another in an endless loop and nothing could be done apart from ending the process. It's a pity it didn't work out... Maybe opening the main window just after pressing Open in the session manager would work better?
ansgar's profile image ansgar posted 11 years ago Permalink
Let me test some workaround for the bugs in r4652. I mainly reverted it for deployment reasons, so that not a myriad of users download that build, ending up in a non-working HeidiSQL at the beginning of this Thursday.
[expired user #5816]'s profile image [expired user #5816] posted 10 years ago Permalink
I too find it inconvenient that Heidisqul steals the focus as lemon_juice has described. Is there any hope of this behavior being fixed?

Heidisql is otherwise an excellent program. Thanks for making it!


Please login to leave a reply, or register at first.