|
@@ -408,12 +408,16 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window, SDL_Renderer* renderer, void
|
|
// Our mouse update function expect PlatformHandle to be filled for the main viewport
|
|
// Our mouse update function expect PlatformHandle to be filled for the main viewport
|
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
|
ImGuiViewport* main_viewport = ImGui::GetMainViewport();
|
|
main_viewport->PlatformHandle = (void*)window;
|
|
main_viewport->PlatformHandle = (void*)window;
|
|
-#ifdef _WIN32
|
|
|
|
SDL_SysWMinfo info;
|
|
SDL_SysWMinfo info;
|
|
SDL_VERSION(&info.version);
|
|
SDL_VERSION(&info.version);
|
|
if (SDL_GetWindowWMInfo(window, &info))
|
|
if (SDL_GetWindowWMInfo(window, &info))
|
|
|
|
+ {
|
|
|
|
+#ifdef _WIN32
|
|
main_viewport->PlatformHandleRaw = (void*)info.info.win.window;
|
|
main_viewport->PlatformHandleRaw = (void*)info.info.win.window;
|
|
|
|
+#elif defined(__APPLE__)
|
|
|
|
+ main_viewport->PlatformHandleRaw = (void*)info.info.cocoa.window;
|
|
#endif
|
|
#endif
|
|
|
|
+ }
|
|
|
|
|
|
// Set SDL hint to receive mouse click events on window focus, otherwise SDL doesn't emit the event.
|
|
// Set SDL hint to receive mouse click events on window focus, otherwise SDL doesn't emit the event.
|
|
// Without this, when clicking to gain focus, our widgets wouldn't activate even though they showed as hovered.
|
|
// Without this, when clicking to gain focus, our widgets wouldn't activate even though they showed as hovered.
|
|
@@ -639,6 +643,8 @@ static void ImGui_ImplSDL2_UpdateMonitors()
|
|
monitor.WorkSize = ImVec2((float)r.w, (float)r.h);
|
|
monitor.WorkSize = ImVec2((float)r.w, (float)r.h);
|
|
#endif
|
|
#endif
|
|
#if SDL_HAS_PER_MONITOR_DPI
|
|
#if SDL_HAS_PER_MONITOR_DPI
|
|
|
|
+ // FIXME-VIEWPORT: On MacOS SDL reports actual monitor DPI scale, ignoring OS configuration. We may want to set
|
|
|
|
+ // DpiScale to cocoa_window.backingScaleFactor here.
|
|
float dpi = 0.0f;
|
|
float dpi = 0.0f;
|
|
if (!SDL_GetDisplayDPI(n, &dpi, NULL, NULL))
|
|
if (!SDL_GetDisplayDPI(n, &dpi, NULL, NULL))
|
|
monitor.DpiScale = dpi / 96.0f;
|
|
monitor.DpiScale = dpi / 96.0f;
|
|
@@ -748,12 +754,16 @@ static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport)
|
|
SDL_GL_MakeCurrent(vd->Window, backup_context);
|
|
SDL_GL_MakeCurrent(vd->Window, backup_context);
|
|
|
|
|
|
viewport->PlatformHandle = (void*)vd->Window;
|
|
viewport->PlatformHandle = (void*)vd->Window;
|
|
-#if defined(_WIN32)
|
|
|
|
SDL_SysWMinfo info;
|
|
SDL_SysWMinfo info;
|
|
SDL_VERSION(&info.version);
|
|
SDL_VERSION(&info.version);
|
|
if (SDL_GetWindowWMInfo(vd->Window, &info))
|
|
if (SDL_GetWindowWMInfo(vd->Window, &info))
|
|
|
|
+ {
|
|
|
|
+#if defined(_WIN32)
|
|
viewport->PlatformHandleRaw = info.info.win.window;
|
|
viewport->PlatformHandleRaw = info.info.win.window;
|
|
|
|
+#elif defined(__APPLE__)
|
|
|
|
+ viewport->PlatformHandleRaw = (void*)info.info.cocoa.window;
|
|
#endif
|
|
#endif
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
static void ImGui_ImplSDL2_DestroyWindow(ImGuiViewport* viewport)
|
|
static void ImGui_ImplSDL2_DestroyWindow(ImGuiViewport* viewport)
|