mirror of
https://github.com/ocornut/imgui.git
synced 2025-09-14 15:28:23 +00:00
- Implement _NET_WM_WINDOW_TYPE_DIALOG for viewports - Fix override_redirect for proper WM control - Tested on i3wm and xfce4
This commit is contained in:
@@ -127,6 +127,16 @@
|
|||||||
#define GLFW_EXPOSE_NATIVE_COCOA
|
#define GLFW_EXPOSE_NATIVE_COCOA
|
||||||
#endif
|
#endif
|
||||||
#include <GLFW/glfw3native.h> // for glfwGetCocoaWindow()
|
#include <GLFW/glfw3native.h> // for glfwGetCocoaWindow()
|
||||||
|
#elif !defined(__EMSCRIPTEN__)
|
||||||
|
// Freedesktop(Linux, BSD, etc)
|
||||||
|
#ifndef GLFW_EXPOSE_NATIVE_X11
|
||||||
|
#define GLFW_EXPOSE_NATIVE_X11
|
||||||
|
#include <X11/Xatom.h>
|
||||||
|
#endif
|
||||||
|
#ifndef GLFW_EXPOSE_NATIVE_WAYLAND
|
||||||
|
#define GLFW_EXPOSE_NATIVE_WAYLAND
|
||||||
|
#endif
|
||||||
|
#include <GLFW/glfw3native.h> // for getting the X11/Wayland window
|
||||||
#endif
|
#endif
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <unistd.h> // for usleep()
|
#include <unistd.h> // 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)
|
static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
|
||||||
{
|
{
|
||||||
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
ImGui_ImplGlfw_Data* bd = ImGui_ImplGlfw_GetBackendData();
|
||||||
@@ -1207,7 +1241,7 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
|
|||||||
glfwWindowHint(GLFW_FOCUSED, false);
|
glfwWindowHint(GLFW_FOCUSED, false);
|
||||||
#if GLFW_HAS_FOCUS_ON_SHOW
|
#if GLFW_HAS_FOCUS_ON_SHOW
|
||||||
glfwWindowHint(GLFW_FOCUS_ON_SHOW, false);
|
glfwWindowHint(GLFW_FOCUS_ON_SHOW, false);
|
||||||
#endif
|
#endif
|
||||||
glfwWindowHint(GLFW_DECORATED, (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? false : true);
|
glfwWindowHint(GLFW_DECORATED, (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? false : true);
|
||||||
#if GLFW_HAS_WINDOW_TOPMOST
|
#if GLFW_HAS_WINDOW_TOPMOST
|
||||||
glfwWindowHint(GLFW_FLOATING, (viewport->Flags & ImGuiViewportFlags_TopMost) ? true : false);
|
glfwWindowHint(GLFW_FLOATING, (viewport->Flags & ImGuiViewportFlags_TopMost) ? true : false);
|
||||||
@@ -1217,6 +1251,9 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
|
|||||||
vd->WindowOwned = true;
|
vd->WindowOwned = true;
|
||||||
ImGui_ImplGlfw_ContextMap_Add(vd->Window, bd->Context);
|
ImGui_ImplGlfw_ContextMap_Add(vd->Window, bd->Context);
|
||||||
viewport->PlatformHandle = (void*)vd->Window;
|
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
|
#ifdef _WIN32
|
||||||
viewport->PlatformHandleRaw = glfwGetWin32Window(vd->Window);
|
viewport->PlatformHandleRaw = glfwGetWin32Window(vd->Window);
|
||||||
::SetPropA((HWND)viewport->PlatformHandleRaw, "IMGUI_BACKEND_DATA", bd);
|
::SetPropA((HWND)viewport->PlatformHandleRaw, "IMGUI_BACKEND_DATA", bd);
|
||||||
|
@@ -41,7 +41,7 @@ LIBS =
|
|||||||
|
|
||||||
ifeq ($(UNAME_S), Linux) #LINUX
|
ifeq ($(UNAME_S), Linux) #LINUX
|
||||||
ECHO_MESSAGE = "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`
|
CXXFLAGS += `pkg-config --cflags glfw3`
|
||||||
CFLAGS = $(CXXFLAGS)
|
CFLAGS = $(CXXFLAGS)
|
||||||
|
Reference in New Issue
Block a user