Add conveniece API to set trasient-parent for Proxy Windows

On macOS, a transient parant should only be set for a single child
window. sibling windows to a single parent cannot be re-stacked.
This commit is contained in:
Robin Gareus 2022-11-15 03:03:49 +01:00
parent 4a9e8b5211
commit f107c063e7
2 changed files with 25 additions and 0 deletions

View File

@ -62,6 +62,8 @@ public:
void drop_window ();
void use_window (Gtk::Window&);
void set_transient_for (Gtk::Window&);
virtual Gtk::Window* get (bool create = false) = 0;
virtual int set_state (const XMLNode&, int version);

View File

@ -409,3 +409,26 @@ WindowProxy::set_state_mask (StateMask sm)
{
_state_mask = sm;
}
void
WindowProxy::set_transient_for (Gtk::Window& win)
{
/* on macOS set_transient() calls _gdk_quartz_window_attach_to_parent()
* which attaches the windows as child window to the parent. As side-effect
* the child becomes the same window-level as the parent.
*
* This makes it hard to re-order siblings of the parent without explicit call to
* re-order those (gdk_window_restack gdk_window_quartz_restack_toplevel).
*
* macOS has a rich concept of z-axis stacking per application, explict transient parents
* are not required.
*
* https://developer.apple.com/documentation/appkit/nswindow/1419152-addchildwindow?language=objc
* https://developer.apple.com/documentation/appkit/nswindowlevel?language=objc
*/
#ifndef __APPLE__
if (_window) {
_window->set_transient_for (win);
}
#endif
}