Hi Alex,

On 5/7/2018 8:46 PM, Alex Harsanyi wrote:
I have a problem with the Racket GUI where the main application window looses focus if two dialog boxes are opened than closed.  The problem occurs when the
main window opens the first dialog box and the first dialog box opens the
second one on top of it.  Once both dialog boxes are closed, the main window
looses focus and goes to the bottom of the window stack (i.e. behind other
windows).  This does not seem to happen if only one dialog box is opened than
closed -- in that case the main window will have the focus.

Could someone confirm if this behaviour is seen on other platforms (I use
Windows), and perhaps offer a workaround?

Using 6.11 (64-bit), it works fine on CentOS 6.9 with Gnome2 if that matters.   Fails as advertised on Win7.


... find the code here:
https://gist.github.com/alex-hhh/20b3f1000813677330bbd2b85c57d319

Too see the problem, this code needs to be compiled into a stand-alone
executable (using the Racket/Create Executable... from DrRacket).

Works the same running from DrRacket or as a separate executable.


I don't know what's happening in Racket, but I have seen some odd focus behavior in Windows when windows are improperly created (or improperly linked).


An application's windows normally form a tree by parent-child relation, rooted at a single top level frame.  But it is not an error to create a window that has no parent ... that is, in fact, how you get a top level frame.

The issue is that Windows doesn't maintain window Z-order per application ... all the windows on the desk, visible or not, are intermingled together on a single Z stack.  When the top window closes or becomes invisible, GetNextWindow() is called to find the next lower window to focus.  If the current window has no parent, GetNextWindow() searches only among (other) top level windows ... and then when the switch is made to whatever window it finds, you can end up in another application or back on the desktop itself.  So you need to make sure all your application's windows have appropriate parent-child relationships, or else changing focus can F_ up.

So I guess the 1st question to answer is: does the GDI object have the correct parent HWND?  [The Racket dialog% object has a parent, but does the underlying display object?]   If it does, there's something weird going on in finding the right window to switch to.


Sorry I can't be more help.  I have done quite a bit of Windows GUI programming, but unfortunately not very much using Racket.  I don't know how much it abstracts away from the GDI.

George

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to