You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A small C library that portably invokes native file open, folder select and file save dialogs. Write dialog code once and have it pop up native dialogs on all supported platforms. Avoid linking large dependencies like wxWidgets and Qt.
7
7
@@ -322,11 +322,20 @@ See `test_sdl.c` for an example.
322
322
323
323
#### GLFW3
324
324
325
-
If using GLFW3, define the appropriate `GLFW_EXPOSE_NATIVE_*` macros described on the [GLFW native access page](https://www.glfw.org/docs/latest/group__native.html), and then include `<nfd_glfw3.h>` and call the following function to set the parent window handle:
325
+
If using GLFW3, define the appropriate `GLFW_EXPOSE_NATIVE_*` macros described on the [GLFW native access page](https://www.glfw.org/docs/latest/group__native.html), and then include `<nfd_glfw3.h>` and do the following:
326
+
327
+
Call the following function once, after `glfwInit()` and `NFD_Init()` but before opening any file dialogs, to tell NFDe the `wl_display` your application is using (this is a no-op if your application isn't using Wayland):
328
+
```C
329
+
NFD_SetDisplayPropertiesFromGLFW();
330
+
```
331
+
332
+
Each time you want to show a dialog, call the following function to retrieve the parent window handle and set the corresponding argument:
If you are using another platform abstraction framework, or not using any such framework, you can do the following:
@@ -344,7 +353,7 @@ To make a window (in this case the file dialog) stay above another window, we ne
344
353
345
354
#### Why is Wayland special?
346
355
347
-
Linux has two differences when compared with Windows and macOS: Linux applications open a connection with a display server (X11 or Wayland) to show their windows, and windows are owned by this connection. It is possible to open multiple connections at the same time (including multiple connections to the same display server), and windows are not shared between those connections. GTK needs to use a connection opened by itself, and so it opens a new connection if it hasn't previously opened a connection (which will be the case if your application doesn't create its own GTK windows). Using portals essentially causes the file dialog to be shown by a separate helper process, which also opens its own connection. In either case, the window handle needs to be passed to a different connection. On X11, window handles are global identifiers that can be used as-is by another connection, but on Wayland, the handles need to be _exported_ to a string and then _imported_ by the receiving connection, and performing the export operation requires the owner's Wayland display handle.
356
+
Linux has two differences when compared with Windows and macOS: Linux applications open a connection with a display server (X11 or Wayland) to show their windows, and windows are owned by this connection. It is possible to open multiple connections at the same time (including multiple connections to the same display server), and windows are not shared between those connections. GTK needs to use a connection opened by itself, and so it opens a new connection if it hasn't previously opened a connection (which will be the case if your application doesn't create its own GTK windows). Portals work by opening the file dialog in a separate helper process, which also opens its own connection. In either case, the window handle needs to be passed to a different connection. On X11, window handles are global identifiers that can be used as-is by another connection, but on Wayland, the handles need to be _exported_ to a string and then _imported_ by the receiving connection, and performing the export operation requires the owner's Wayland display handle.
0 commit comments