diff --git a/examples/imgui_impl_sdl2.cpp b/examples/imgui_impl_sdl2.cpp index b1c757db..7cd47f63 100644 --- a/examples/imgui_impl_sdl2.cpp +++ b/examples/imgui_impl_sdl2.cpp @@ -27,7 +27,6 @@ #include "imgui.h" #include "imgui_impl_sdl2.h" - #include "imgui_internal.h" // FIXME-PLATFORM // SDL @@ -149,11 +148,14 @@ bool ImGui_ImplSDL2_Init(SDL_Window* window, void* sdl_gl_context) // Our mouse update function expect PlatformHandle to be filled for the main viewport ImGuiViewport* main_viewport = ImGui::GetMainViewport(); main_viewport->PlatformHandle = (void*)window; + + // We need SDL_CaptureMouse(), SDL_GetGlobalMouseState() from SDL 2.0.4+ to support multiple viewports. + // We left the call to ImGui_ImplSDL2_InitPlatformInterface() outside of #ifdef to avoid unused-function warnings. #if SDL_VERSION_ATLEAST(2,0,4) io.ConfigFlags |= ImGuiConfigFlags_PlatformHasViewports; - if (io.ConfigFlags & ImGuiConfigFlags_EnableViewports) - ImGui_ImplSDL2_InitPlatformInterface(window, sdl_gl_context); #endif + if ((io.ConfigFlags & ImGuiConfigFlags_EnableViewports) && (io.ConfigFlags & ImGuiConfigFlags_PlatformHasViewports)) + ImGui_ImplSDL2_InitPlatformInterface(window, sdl_gl_context); return true; } @@ -252,9 +254,7 @@ void ImGui_ImplSDL2_NewFrame(SDL_Window* window) // Platform Windows // -------------------------------------------------------------------------------------------------------- -#include "imgui_internal.h" - -#define SDL_HAS_WINDOW_OPACITY SDL_VERSION_ATLEAST(2,0,5) +#define SDL_HAS_WINDOW_OPACITY SDL_VERSION_ATLEAST(2,0,5) struct ImGuiPlatformDataSDL2 { @@ -331,8 +331,8 @@ static void ImGui_ImplSDL2_ShowWindow(ImGuiViewport* viewport) return; } } - #endif + SDL_ShowWindow(data->Window); } diff --git a/imgui.cpp b/imgui.cpp index eaf8d7bd..bfc85340 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5194,12 +5194,6 @@ ImVec2 ImGui::GetItemRectSize() return window->DC.LastItemRect.GetSize(); } -static ImRect GetViewportRect() -{ - ImGuiContext& g = *GImGui; - return ImRect(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y); -} - // Not exposed publicly as BeginTooltip() because bool parameters are evil. Let's see if other needs arise first. void ImGui::BeginTooltipEx(ImGuiWindowFlags extra_flags, bool override_previous_tooltip) {