mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 20:18:47 +02:00
Viewport, Platform: Added ImGuiViewportFlags_TopMost that will be used by tooltip window (without it, clicking and holding the window emitting the tooltip would move the tooltip to the back) + GLFW backend fixes for non-win32 platforms. (#1542)
This commit is contained in:
@ -41,8 +41,10 @@
|
||||
#define GLFW_HAS_GLFW_HOVERED 0
|
||||
#endif
|
||||
#define GLFW_HAS_WINDOW_ALPHA (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3300) // 3.3+
|
||||
#define GLFW_HAS_WINDOW_TOPMOST (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+
|
||||
#define GLFW_HAS_VULKAN (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3200) // 3.2+
|
||||
|
||||
|
||||
// Data
|
||||
enum GlfwClientApi
|
||||
{
|
||||
@ -357,6 +359,9 @@ static void ImGui_ImplGlfw_CreateWindow(ImGuiViewport* viewport)
|
||||
glfwWindowHint(GLFW_VISIBLE, false);
|
||||
glfwWindowHint(GLFW_FOCUSED, false);
|
||||
glfwWindowHint(GLFW_DECORATED, (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? false : true);
|
||||
#if GLFW_HAS_WINDOW_TOPMOST
|
||||
glfwWindowHint(GLFW_FLOATING, (viewport->Flags & imGuiViewportFlags_TopMost) ? true : false);
|
||||
#endif
|
||||
GLFWwindow* share_window = (g_ClientApi == GlfwClientApi_OpenGL) ? g_Window : NULL;
|
||||
data->Window = glfwCreateWindow((int)viewport->Size.x, (int)viewport->Size.y, "No Title Yet", NULL, share_window);
|
||||
data->WindowOwned = true;
|
||||
@ -373,7 +378,7 @@ static void ImGui_ImplGlfw_DestroyWindow(ImGuiViewport* viewport)
|
||||
{
|
||||
if (data->WindowOwned)
|
||||
{
|
||||
#if GLFW_HAS_GLFW_HOVERED
|
||||
#if GLFW_HAS_GLFW_HOVERED && defined(_WIN32)
|
||||
HWND hwnd = glfwGetWin32Window(data->Window);
|
||||
::RemovePropA(hwnd, "IMGUI_VIEWPORT");
|
||||
#endif
|
||||
@ -419,7 +424,7 @@ static void ImGui_ImplGlfw_ShowWindow(ImGuiViewport* viewport)
|
||||
}
|
||||
|
||||
// GLFW hack: install hook for WM_NCHITTEST message handler
|
||||
#if GLFW_HAS_GLFW_HOVERED
|
||||
#if GLFW_HAS_GLFW_HOVERED && defined(_WIN32)
|
||||
::SetPropA(hwnd, "IMGUI_VIEWPORT", viewport);
|
||||
if (g_GlfwWndProc == NULL)
|
||||
g_GlfwWndProc = (WNDPROC)::GetWindowLongPtr(hwnd, GWLP_WNDPROC);
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include <SDL_syswm.h>
|
||||
#define SDL_HAS_CAPTURE_MOUSE SDL_VERSION_ATLEAST(2,0,4)
|
||||
#define SDL_HAS_WINDOW_OPACITY SDL_VERSION_ATLEAST(2,0,5)
|
||||
#define SDL_HAS_ALWAYS_ON_TOP SDL_VERSION_ATLEAST(2,0,5)
|
||||
#define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6)
|
||||
#if !SDL_HAS_VULKAN
|
||||
static const Uint32 SDL_WINDOW_VULKAN = 0x10000000;
|
||||
@ -317,6 +318,9 @@ static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport)
|
||||
sdl_flags |= SDL_WINDOW_HIDDEN;
|
||||
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? SDL_WINDOW_BORDERLESS : 0;
|
||||
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_NoDecoration) ? 0 : SDL_WINDOW_RESIZABLE;
|
||||
#if SDL_HAS_ALWAYS_ON_TOP
|
||||
sdl_flags |= (viewport->Flags & imGuiViewportFlags_TopMost) ? SDL_WINDOW_ALWAYS_ON_TOP : 0;
|
||||
#endif
|
||||
data->Window = SDL_CreateWindow("No Title Yet", (int)viewport->PlatformPos.x, (int)viewport->PlatformPos.y, (int)viewport->Size.x, (int)viewport->Size.y, sdl_flags);
|
||||
data->WindowOwned = true;
|
||||
if (use_opengl)
|
||||
|
@ -389,6 +389,8 @@ static void ImGui_ImplWin32_CreateWindow(ImGuiViewport* viewport)
|
||||
data->DwStyle = WS_OVERLAPPEDWINDOW;
|
||||
data->DwExStyle = no_task_bar_icon ? WS_EX_TOOLWINDOW : WS_EX_APPWINDOW;
|
||||
}
|
||||
if (viewport->Flags & imGuiViewportFlags_TopMost)
|
||||
data->DwExStyle |= WS_EX_TOPMOST;
|
||||
|
||||
// Create window
|
||||
RECT rect = { (LONG)viewport->PlatformPos.x, (LONG)viewport->PlatformPos.y, (LONG)(viewport->PlatformPos.x + viewport->Size.x), (LONG)(viewport->PlatformPos.y + viewport->Size.y) };
|
||||
|
Reference in New Issue
Block a user