My program opens a wxFrame-based window and multiple modeless and parentless wxDialog-based windows. It all works beautifully, except that the wxDialog-based windows insist on always being on top of the wxFrame-based one.
I know about wxDIALOG_NO_PARENT, and I’m using it. The dialogs stay open when I close the wxFrame, so they definitely don’t have the wxFrame window as a parent.
(If it matters, I’m using C++, wxWidgets 2.8.something, and running it on Ubuntu Linux. My program isn’t ready to compile on any other platform, so I haven’t tested it on others yet.)
I want all the windows to operate entirely independently, so the user can use the wxFrame window as well as the wxDialog ones. Can anyone point me in the right direction?
It seems that this behavior comes from a difference in how Gnome handles windows with different “type hints”…it puts them into their own z-index groupings:
https://developer.gnome.org/gdk3/stable/gdk3-Windows.html#GdkWindowTypeHint
The dialog is created with
GDK_WINDOW_TYPE_HINT_DIALOGwhile your other window is most likely created withGDK_WINDOW_TYPE_HINT_NORMAL. The point where this decision is made is ingtk/toplevel.cppand it’s being cued by the fact that the “extra” style flags containwxTOPLEVEL_EX_DIALOG:toplevel.cpp#L594
Those are the only two calls to
gtk_window_set_type_hintin the wxWidgets GTK codebase, except for in the splash screen code. So changing the “extra” style bits after the fact isn’t going to help. (The “correct” solution would be to patch wxWidgets so that adjustingwxTOPLEVEL_EX_DIALOGin the extra styles would do the proper adjustment to the window type hint.)You can’t use the wxDialog class without running through its constructor, which calls the non-virtual method
wxDialog::Create, which sets the extra style towxTOPLEVEL_EX_DIALOGand then goes directly to top level window creation:dialog.cpp#L54
So I guess you have the option of trying this, which works if you haven’t shown the dialog window yet:
…and if you have shown the dialog already, you need to use this for it to work:
Both cases will require you to add an include file into your source:
…and you’ll have to update your build to find the GTK includes. On the command line for G++ I tried this and it worked: