|
32 | 32 | // CHANGELOG |
33 | 33 | // (minor and older changes stripped away, please see git history for details) |
34 | 34 | // 2025-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface. |
| 35 | +// 2025-09-10: [Docking] Improve multi-viewport behavior in tiling WMs on X11 via the ImGui_ImplGlfw_SetWindowFloating() function. Note: using GLFW backend on Linux/BSD etc. requires linking with -lX11. (#8884, #8474, #8289) |
35 | 36 | // 2025-07-08: Made ImGui_ImplGlfw_GetContentScaleForWindow(), ImGui_ImplGlfw_GetContentScaleForMonitor() helpers return 1.0f on Emscripten and Android platforms, matching macOS logic. (#8742, #8733) |
36 | 37 | // 2025-06-18: Added support for multiple Dear ImGui contexts. (#8676, #8239, #8069) |
37 | 38 | // 2025-06-11: Added ImGui_ImplGlfw_GetContentScaleForWindow(GLFWwindow* window) and ImGui_ImplGlfw_GetContentScaleForMonitor(GLFWmonitor* monitor) helper to facilitate making DPI-aware apps. |
|
121 | 122 | #define GLFW_EXPOSE_NATIVE_WIN32 |
122 | 123 | #endif |
123 | 124 | #include <GLFW/glfw3native.h> // for glfwGetWin32Window() |
124 | | -#endif |
125 | | -#ifdef __APPLE__ |
| 125 | +#elif defined(__APPLE__) |
126 | 126 | #ifndef GLFW_EXPOSE_NATIVE_COCOA |
127 | 127 | #define GLFW_EXPOSE_NATIVE_COCOA |
128 | 128 | #endif |
129 | 129 | #include <GLFW/glfw3native.h> // for glfwGetCocoaWindow() |
130 | 130 | #elif !defined(__EMSCRIPTEN__) |
131 | | -// Freedesktop(Linux, BSD, etc) |
| 131 | +// Freedesktop (Linux, BSD, etc) |
132 | 132 | #ifndef GLFW_EXPOSE_NATIVE_X11 |
133 | 133 | #define GLFW_EXPOSE_NATIVE_X11 |
134 | 134 | #include <X11/Xatom.h> |
|
183 | 183 | #define GLFW_HAS_GETERROR (GLFW_VERSION_COMBINED >= 3300) // 3.3+ glfwGetError() |
184 | 184 | #define GLFW_HAS_GETPLATFORM (GLFW_VERSION_COMBINED >= 3400) // 3.4+ glfwGetPlatform() |
185 | 185 |
|
186 | | -// Map GLFWWindow* to ImGuiContext*. |
| 186 | +// Map GLFWWindow* to ImGuiContext*. |
187 | 187 | // - Would be simpler if we could use glfwSetWindowUserPointer()/glfwGetWindowUserPointer(), but this is a single and shared resource. |
188 | 188 | // - Would be simpler if we could use e.g. std::map<> as well. But we don't. |
189 | 189 | // - This is not particularly optimized as we expect size to be small and queries to be rare. |
@@ -1200,29 +1200,29 @@ static void ImGui_ImplGlfw_WindowSizeCallback(GLFWwindow* window, int, int) |
1200 | 1200 | } |
1201 | 1201 | } |
1202 | 1202 |
|
1203 | | -#if !defined(__APPLE__) && !defined(_WIN32) && !defined(__EMSCRIPTEN__) && (GLFW_VERSION_MAJOR > 3 || (GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4)) |
| 1203 | +#if !defined(__APPLE__) && !defined(_WIN32) && !defined(__EMSCRIPTEN__) && GLFW_HAS_GETPLATFORM |
| 1204 | +#define IMGUI_GLFW_HAS_SETWINDOWFLOATING |
1204 | 1205 | static void ImGui_ImplGlfw_SetWindowFloating(GLFWwindow* window) |
1205 | 1206 | { |
1206 | 1207 | #ifdef GLFW_EXPOSE_NATIVE_X11 |
1207 | 1208 | if (glfwGetPlatform() == GLFW_PLATFORM_X11) |
1208 | 1209 | { |
1209 | 1210 | Display* display = glfwGetX11Display(); |
1210 | 1211 | Window xwindow = glfwGetX11Window(window); |
1211 | | - |
1212 | 1212 | Atom wm_type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False); |
1213 | 1213 | Atom wm_type_dialog = XInternAtom(display, "_NET_WM_WINDOW_TYPE_DIALOG", False); |
1214 | | - XChangeProperty(display, xwindow, wm_type, XA_ATOM, 32, |
1215 | | - PropModeReplace, (unsigned char*)&wm_type_dialog, 1); |
1216 | | - |
| 1214 | + XChangeProperty(display, xwindow, wm_type, XA_ATOM, 32, PropModeReplace, (unsigned char*)&wm_type_dialog, 1); |
1217 | 1215 | XSetWindowAttributes attrs; |
1218 | 1216 | attrs.override_redirect = False; |
1219 | 1217 | XChangeWindowAttributes(display, xwindow, CWOverrideRedirect, &attrs); |
1220 | | - |
1221 | 1218 | XFlush(display); |
1222 | 1219 | } |
1223 | | -#endif |
| 1220 | +#endif // GLFW_EXPOSE_NATIVE_X11 |
| 1221 | +#ifdef GLFW_EXPOSE_NATIVE_WAYLAND |
| 1222 | + // FIXME: Help needed, see #8884, #8474 for discussions about this. |
| 1223 | +#endif // GLFW_EXPOSE_NATIVE_X11 |
1224 | 1224 | } |
1225 | | -#endif |
| 1225 | +#endif // IMGUI_GLFW_HAS_SETWINDOWFLOATING |
1226 | 1226 |
|
1227 | 1227 | static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport) |
1228 | 1228 | { |
@@ -1251,7 +1251,7 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport) |
1251 | 1251 | vd->WindowOwned = true; |
1252 | 1252 | ImGui_ImplGlfw_ContextMap_Add(vd->Window, bd->Context); |
1253 | 1253 | viewport->PlatformHandle = (void*)vd->Window; |
1254 | | -#if !defined(__APPLE__) && !defined(_WIN31) && !defined(__EMSCRIPTEN__) && (GLFW_VERSION_MAJOR > 3 || (GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4)) |
| 1254 | +#ifdef IMGUI_GLFW_HAS_SETWINDOWFLOATING |
1255 | 1255 | ImGui_ImplGlfw_SetWindowFloating(vd->Window); |
1256 | 1256 | #endif |
1257 | 1257 | #ifdef _WIN32 |
|
0 commit comments