For setting applications that is launched by the control center, there used to be environment variable where you can get the parent window’s ID and then set yourself to be a “child” of it.
from os import environ
import gi
from gi.repository import Gdk, GdkX11
...
if 'GNOME_CONTROL_CENTER_XID' in environ:
xid = int(environ['GNOME_CONTROL_CENTER_XID'])
window.set_modal(True)
window.connect('notify::window', self.set_transient)
window.set_type_hint(Gdk.WindowTypeHint.DIALOG)
w = window.get_window()
if w != None:
parent = GdkX11.X11Window.foreign_new_for_display(
Gdk.Display.get_default(), xid)
In wayland, is this not possible anymore?
GtkWayland have a set_transient_for_exported function. It takes a parent_handle_str
, which I have no idea how to get. Nor do I know if it works the way as expected.