Skip to content

Commit

Permalink
Backends: OSX: Implement ImGui_ImplOSX_ShowWindow(). (#5299)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocornut authored May 9, 2022
1 parent d666a1d commit 693b4c5
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions backends/imgui_impl_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -825,12 +825,6 @@ static void ImGui_ImplOSX_CreateWindow(ImGuiViewport* viewport)

window.title = @"Untitled";
window.opaque = YES;
if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing)
[window orderFront:nil];
else
[window makeKeyAndOrderFront:nil];

[window setIsVisible:YES];

KeyEventResponder* view = [[KeyEventResponder alloc] initWithFrame:rect];
if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6)
Expand Down Expand Up @@ -864,6 +858,19 @@ static void ImGui_ImplOSX_DestroyWindow(ImGuiViewport* viewport)
viewport->PlatformUserData = viewport->PlatformHandle = viewport->PlatformHandleRaw = NULL;
}

static void ImGui_ImplOSX_ShowWindow(ImGuiViewport* viewport)
{
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
IM_ASSERT(data->Window != 0);

if (viewport->Flags & ImGuiViewportFlags_NoFocusOnAppearing)
[data->Window orderFront:nil];
else
[data->Window makeKeyAndOrderFront:nil];

[data->Window setIsVisible:YES];
}

static ImVec2 ImGui_ImplOSX_GetWindowPos(ImGuiViewport* viewport)
{
ImGuiViewportDataOSX* data = (ImGuiViewportDataOSX*)viewport->PlatformUserData;
Expand Down Expand Up @@ -992,6 +999,7 @@ static void ImGui_ImplOSX_InitPlatformInterface()
ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO();
platform_io.Platform_CreateWindow = ImGui_ImplOSX_CreateWindow;
platform_io.Platform_DestroyWindow = ImGui_ImplOSX_DestroyWindow;
platform_io.Platform_ShowWindow = ImGui_ImplOSX_ShowWindow;
platform_io.Platform_SetWindowPos = ImGui_ImplOSX_SetWindowPos;
platform_io.Platform_GetWindowPos = ImGui_ImplOSX_GetWindowPos;
platform_io.Platform_SetWindowSize = ImGui_ImplOSX_SetWindowSize;
Expand Down

0 comments on commit 693b4c5

Please sign in to comment.