From b1cd52b67439a696b29e694f45cb317a7b3dfc19 Mon Sep 17 00:00:00 2001 From: omar Date: Fri, 21 Dec 2018 16:33:50 +0100 Subject: [PATCH] Examples: SDL: Avoid testing for SDL_GetKeyboardFocus() on Android and iOS (like Emscripten). (#421) --- examples/imgui_impl_sdl.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/imgui_impl_sdl.cpp b/examples/imgui_impl_sdl.cpp index 873c50f8..28253db0 100644 --- a/examples/imgui_impl_sdl.cpp +++ b/examples/imgui_impl_sdl.cpp @@ -16,6 +16,7 @@ // CHANGELOG // (minor and older changes stripped away, please see git history for details) +// 2018-12-21: Inputs: Workaround for Android/iOS which don't seem to handle focus related calls. // 2018-11-30: Misc: Setting up io.BackendPlatformName so it can be displayed in the About Window. // 2018-11-14: Changed the signature of ImGui_ImplSDL2_ProcessEvent() to take a 'const SDL_Event*'. // 2018-08-01: Inputs: Workaround for Emscripten which doesn't seem to handle focus related calls. @@ -42,8 +43,11 @@ // (the multi-viewports feature requires SDL features supported from SDL 2.0.5+) #include #include +#if defined(__APPLE__) +#include "TargetConditionals.h" +#endif -#define SDL_HAS_CAPTURE_MOUSE SDL_VERSION_ATLEAST(2,0,4) +#define SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE SDL_VERSION_ATLEAST(2,0,4) #define SDL_HAS_VULKAN SDL_VERSION_ATLEAST(2,0,6) #define SDL_HAS_MOUSE_FOCUS_CLICKTHROUGH SDL_VERSION_ATLEAST(2,0,5) #if !SDL_HAS_VULKAN @@ -182,9 +186,9 @@ bool ImGui_ImplSDL2_InitForOpenGL(SDL_Window* window, void* sdl_gl_context) bool ImGui_ImplSDL2_InitForVulkan(SDL_Window* window) { - #if !SDL_HAS_VULKAN +#if !SDL_HAS_VULKAN IM_ASSERT(0 && "Unsupported"); - #endif +#endif return ImGui_ImplSDL2_Init(window); } @@ -220,7 +224,7 @@ static void ImGui_ImplSDL2_UpdateMousePosAndButtons() io.MouseDown[2] = g_MousePressed[2] || (mouse_buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0; g_MousePressed[0] = g_MousePressed[1] = g_MousePressed[2] = false; -#if SDL_HAS_CAPTURE_MOUSE && !defined(__EMSCRIPTEN__) +#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE && !defined(__EMSCRIPTEN__) && !defined(__ANDROID__) && !(defined(__APPLE__) && TARGET_OS_IOS)) SDL_Window* focused_window = SDL_GetKeyboardFocus(); if (g_Window == focused_window) {