Skip to content

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

Merged
PolyMeilex merged 3 commits into
PolyMeilex:masterfrom
bet4it:feat-gtk3-parent-binding
Jul 17, 2026
Merged

feat(gtk3): bind dialog transient parent using RawWindowHandle#327
PolyMeilex merged 3 commits into
PolyMeilex:masterfrom
bet4it:feat-gtk3-parent-binding

Conversation

@bet4it

@bet4it bet4it commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

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.

bet4it and others added 2 commits July 17, 2026 02:24
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."
@PolyMeilex
PolyMeilex force-pushed the feat-gtk3-parent-binding branch from 9d7dd30 to dec4e6a Compare July 17, 2026 00:24

@PolyMeilex PolyMeilex left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@PolyMeilex
PolyMeilex merged commit 3792ffe into PolyMeilex:master Jul 17, 2026
13 of 14 checks passed
@bet4it
bet4it deleted the feat-gtk3-parent-binding branch July 17, 2026 00:58
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.

2 participants