Linux/Wayland new feature: Accept native parent window handle - #153
Merged
Conversation
btzy
force-pushed
the
nativewindow-wayland
branch
9 times, most recently
from
December 9, 2024 17:44
e703e7a to
4c40579
Compare
btzy
force-pushed
the
nativewindow-wayland
branch
from
January 1, 2025 17:11
4c40579 to
cdb7b25
Compare
btzy
force-pushed
the
nativewindow-wayland
branch
6 times, most recently
from
March 15, 2025 10:45
373c0f7 to
b39eea4
Compare
btzy
force-pushed
the
master
branch
2 times, most recently
from
March 15, 2025 16:17
6fc3f6c to
a1a4010
Compare
btzy
force-pushed
the
nativewindow-wayland
branch
7 times, most recently
from
March 16, 2025 06:06
79af96c to
06096fa
Compare
btzy
force-pushed
the
nativewindow-wayland
branch
2 times, most recently
from
April 5, 2025 10:46
ce1a059 to
0537750
Compare
btzy
force-pushed
the
nativewindow-wayland
branch
from
February 8, 2026 08:22
c172bb4 to
266c283
Compare
btzy
force-pushed
the
nativewindow-wayland
branch
from
February 8, 2026 08:26
266c283 to
853e207
Compare
btzy
force-pushed
the
nativewindow-wayland
branch
18 times, most recently
from
February 14, 2026 10:47
bd3856b to
5b20d54
Compare
Owner
Author
Turns out this is not a concern, and most Linux applications simply link both X11 and Wayland libraries. |
btzy
force-pushed
the
nativewindow-wayland
branch
from
February 14, 2026 11:26
5b20d54 to
74a6900
Compare
Tom94
pushed a commit
to mitsuba-renderer/nativefiledialog-extended
that referenced
this pull request
Jun 29, 2026
* Linux/Wayland: Support parent windows * Set screen from display server * Update readme * Add GLFW3 test
This is not true. (KDE 6.7.2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#136 added support for passing a parent window handle, ensuring that the file dialog always stays on top of the parent window and other platform-specific effects. Support was not added for Wayland then, due to implementation complexity and the scarcity of good documentation for the unstable xdg-foreign protocol for Wayland. This PR adds this missing support, using the xdg_foreign_unstable_v1 protocol. (There is a xdg_foreign_unstable_v2 protocol, but it seems that all platforms supporting v2 also support v1.)
Under Wayland, a client cannot simply hand over a window handle to another client. The sending client calls a Wayland function that takes a window handle and returns a string token representing it (known as exporting the window), and then sends that token over to the receiving client. The receiving client then calls another Wayland function that takes the string token and returns a "foreign" window handle (known as importing the window). The receiving client can then make this "foreign" window the transient parent of its own windows. On Portal, the receiving client is a different process (the xdg-desktop-portal implementor); on GTK, the receiving client is wrapped in a GdkDisplay on the same process.
Due to the need to call a Wayland function, Native File Dialog Extended now depends on the wayland-protocols repository (https://gitlab.freedesktop.org/wayland/wayland-protocols) as a git submodule (checked out to v1.47, but it shouldn't really matter much since Wayland protocols are meant to be backward compatible). New CMake feature flags
NFD_X11andNFD_WAYLANDhave also been added to control whether the library is built with X11 and Wayland support respectively. By default both X11 and Wayland are supported, and this will lead to a runtime dependency on libwayland-client.The GTK implementation has also been adjusted somewhat to do things more correctly. Before the dialog is realized (i.e. is made into a real GdkWindow), it needs to be told the GdkScreen to use (which can be any GdkScreen that uses the correct display server (X11 or Wayland)), but we can only set the transient parent after realization.
Note: Under XWayland, window parenting does not work (it behaves as if you did not pass a parent window handle). It behaves this way on both GTK and Portal. I'm not sure why, but since this is the behaviour for Portal, it's probably a limitation of XWayland.
Note: On GLFW < 3.4, the GLFW library on Linux either comes with X11 or Wayland, but not both. This means that on a system that supports both X11 and Wayland, an application using GLFW < 3.4 will only work with one display server.