diff --git a/backends/imgui_impl_glfw.cpp b/backends/imgui_impl_glfw.cpp index cd8e0587a..72753bcdb 100644 --- a/backends/imgui_impl_glfw.cpp +++ b/backends/imgui_impl_glfw.cpp @@ -127,6 +127,16 @@ #define GLFW_EXPOSE_NATIVE_COCOA #endif #include // for glfwGetCocoaWindow() +#elif !defined(__EMSCRIPTEN__) +// Freedesktop(Linux, BSD, etc) +#ifndef GLFW_EXPOSE_NATIVE_X11 +#define GLFW_EXPOSE_NATIVE_X11 +#include +#endif +#ifndef GLFW_EXPOSE_NATIVE_WAYLAND +#define GLFW_EXPOSE_NATIVE_WAYLAND +#endif +#include // for getting the X11/Wayland window #endif #ifndef _WIN32 #include // for usleep() @@ -1190,6 +1200,30 @@ static void ImGui_ImplGlfw_WindowSizeCallback(GLFWwindow* window, int, int) } } +#if !defined(__APPLE__) && !defined(_WIN32) && !defined(__EMSCRIPTEN__) && (GLFW_VERSION_MAJOR > 3 || (GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4)) +static void ImGui_ImplGlfw_SetWindowFloating(GLFWwindow* window) +{ +#ifdef GLFW_EXPOSE_NATIVE_X11 + if (glfwGetPlatform() == GLFW_PLATFORM_X11) + { + Display* display = glfwGetX11Display(); + Window xwindow = glfwGetX11Window(window); + + Atom wm_type = XInternAtom(display, "_NET_WM_WINDOW_TYPE", False); + Atom wm_type_dialog = XInternAtom(display, "_NET_WM_WINDOW_TYPE_DIALOG", False); + XChangeProperty(display, xwindow, wm_type, XA_ATOM, 32, + PropModeReplace, (unsigned char*)&wm_type_dialog, 1); + + XSetWindowAttributes attrs; + attrs.override_redirect = False; + XChangeWindowAttributes(display, xwindow, CWOverrideRedirect, &attrs); + + XFlush(display); + } +#endif +} +#endif + static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport) { ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData(); @@ -1207,7 +1241,7 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport) glfwWindowHint(GLFW_FOCUSED, false); #if GLFW_HAS_FOCUS_ON_SHOW glfwWindowHint(GLFW_FOCUS_ON_SHOW, false); - #endif +#endif glfwWindowHint(GLFW_DECORATED, (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? false : true); #if GLFW_HAS_WINDOW_TOPMOST glfwWindowHint(GLFW_FLOATING, (viewport->Flags & ImGuiViewportFlags_TopMost) ? true : false); @@ -1217,6 +1251,9 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport) vd->WindowOwned = true; ImGui_ImplGlfw_ContextMap_Add(vd->Window, bd->Context); viewport->PlatformHandle = (void*)vd->Window; +#if !defined(__APPLE__) && !defined(_WIN31) && !defined(__EMSCRIPTEN__) && (GLFW_VERSION_MAJOR > 3 || (GLFW_VERSION_MAJOR == 3 && GLFW_VERSION_MINOR >= 4)) + ImGui_ImplGlfw_SetWindowFloating(vd->Window); +#endif #ifdef _WIN32 viewport->PlatformHandleRaw = glfwGetWin32Window(vd->Window); ::SetPropA((HWND)viewport->PlatformHandleRaw, "IMGUI_BACKEND_DATA", bd); diff --git a/examples/example_glfw_opengl3/Makefile b/examples/example_glfw_opengl3/Makefile index 252ce5714..4c2dc523f 100644 --- a/examples/example_glfw_opengl3/Makefile +++ b/examples/example_glfw_opengl3/Makefile @@ -41,7 +41,7 @@ LIBS = ifeq ($(UNAME_S), Linux) #LINUX ECHO_MESSAGE = "Linux" - LIBS += $(LINUX_GL_LIBS) `pkg-config --static --libs glfw3` + LIBS += $(LINUX_GL_LIBS) -lX11 `pkg-config --static --libs glfw3` CXXFLAGS += `pkg-config --cflags glfw3` CFLAGS = $(CXXFLAGS)