Skip to content

feat(gtk3): bind dialog transient parent using RawWindowHandle#327

Open
bet4it wants to merge 1 commit into
PolyMeilex:masterfrom
bet4it:feat-gtk3-parent-binding
Open

feat(gtk3): bind dialog transient parent using RawWindowHandle#327
bet4it wants to merge 1 commit into
PolyMeilex:masterfrom
bet4it:feat-gtk3-parent-binding

Conversation

@bet4it

@bet4it bet4it commented Jun 25, 2026

Copy link
Copy Markdown

Summary

Implement parent window binding in the GTK3 backend using RawWindowHandle (supporting X11 and Wayland).

Currently, rfd has a cross-platform API for setting a parent window via .set_parent(). However, while this was supported on Windows, macOS, and the XDG portal backend, the native GTK3 backend completely ignored the parent window parameter and hardcoded ptr::null_mut().

This PR dynamically resolves the GtkWindow pointer corresponding to the provided RawWindowHandle by searching the list of top-levels using gdk_x11_window_get_xid (X11) and gdk_wayland_window_get_wl_surface (Wayland) resolved at runtime via dlsym.

This ensures that:

  • Dialogs are properly transient/modal to their parent window.
  • Under CSD (Client-Side Decoration) desktops like GNOME Shell, modal dialogs are presented as modal sheets attached to the parent window.

Resolve RawWindowHandle to GtkWindow at runtime by iterating
gtk_window_list_toplevels and matching via dlsym-loaded
gdk_x11_window_get_xid (Xlib/XCB) or
gdk_wayland_window_get_wl_surface (Wayland).

Set the resolved GtkWindow as transient parent for both file
chooser and message dialogs, enabling proper window manager
modality and GNOME CSD sheet-style dialog attachment.

Per GNOME HIG: "Dialogs should always have a parent window,
to which they are modal."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant