Skip to content

Commit

Permalink
Reverted unnecessary MicroStrain edits to ImGui source/files
Browse files Browse the repository at this point in the history
Reverting changes to reflect the real ImGui repo files/source to avoid merge conflicts
Added better MicroStrain modification tags
  • Loading branch information
dacuster committed Jul 25, 2024
1 parent 67d29ea commit 13d8753
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 347 deletions.
232 changes: 0 additions & 232 deletions CMakeLists.txt

This file was deleted.

24 changes: 5 additions & 19 deletions backends/imgui_impl_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,6 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
// - In some cases, when detaching a window from main viewport SDL may send SDL_WINDOWEVENT_ENTER one frame too late,
// causing SDL_WINDOWEVENT_LEAVE on previous frame to interrupt drag operation by clear mouse position. This is why
// we delay process the SDL_WINDOWEVENT_LEAVE events by one frame. See issue #5012 for details.

Uint8 window_event = event->window.event;
if (window_event == SDL_WINDOWEVENT_ENTER)
{
Expand All @@ -420,33 +419,20 @@ bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event)
if (window_event == SDL_WINDOWEVENT_LEAVE)
bd->MouseLastLeaveFrame = ImGui::GetFrameCount() + 1;
if (window_event == SDL_WINDOWEVENT_FOCUS_GAINED)
{
io.AddFocusEvent(true);
}
else if (window_event == SDL_WINDOWEVENT_FOCUS_LOST)
{
io.AddFocusEvent(false);
}
if (window_event == SDL_WINDOWEVENT_CLOSE || window_event == SDL_WINDOWEVENT_MOVED || window_event == SDL_WINDOWEVENT_RESIZED)
{
if (ImGuiViewport* viewport = ImGui::FindViewportByPlatformHandle((void*)SDL_GetWindowFromID(event->window.windowID)))
{
if (window_event == SDL_WINDOWEVENT_CLOSE)
{
viewport->PlatformRequestClose = true;
}
if (window_event == SDL_WINDOWEVENT_MOVED)
{
viewport->PlatformRequestMove = true;
}
if (window_event == SDL_WINDOWEVENT_RESIZED)
{
viewport->PlatformRequestResize = true;
}
return true;
}

}
return true;
}
case SDL_CONTROLLERDEVICEADDED:
Expand Down Expand Up @@ -632,12 +618,14 @@ static void ImGui_ImplSDL2_UpdateMouseData()

// We forward mouse input when hovered or captured (via SDL_MOUSEMOTION) or when focused (below)
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
// MicroStrain start
#if !defined(_WIN32) && defined(NDEBUG)
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
// On linux, this can get the mouse stuck when a breakpoint is hit, so disable for debug builds.
// See https://github.com/ocornut/imgui/issues/4197 and https://github.com/ocornut/imgui/issues/3650
// MicroStrain end
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
SDL_CaptureMouse((bd->MouseButtonsDown != 0) ? SDL_TRUE : SDL_FALSE);
#endif
#endif // MicroStrain
SDL_Window* focused_window = SDL_GetKeyboardFocus();
const bool is_app_focused = (focused_window && (bd->Window == focused_window || ImGui::FindViewportByPlatformHandle((void*)focused_window)));
#else
Expand Down Expand Up @@ -923,6 +911,7 @@ struct ImGui_ImplSDL2_ViewportData
Uint32 WindowID;
bool WindowOwned;
SDL_GLContext GLContext;

ImGui_ImplSDL2_ViewportData() { Window = nullptr; WindowID = 0; WindowOwned = false; GLContext = nullptr; }
~ImGui_ImplSDL2_ViewportData() { IM_ASSERT(Window == nullptr && GLContext == nullptr); }
};
Expand Down Expand Up @@ -959,9 +948,7 @@ static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport)
#if SDL_HAS_ALWAYS_ON_TOP
sdl_flags |= (viewport->Flags & ImGuiViewportFlags_TopMost) ? SDL_WINDOW_ALWAYS_ON_TOP : 0;
#endif

vd->Window = SDL_CreateWindow("No Title Yet", (int)viewport->Pos.x, (int)viewport->Pos.y, (int)viewport->Size.x, (int)viewport->Size.y, sdl_flags);

vd->WindowOwned = true;
if (use_opengl)
{
Expand All @@ -973,7 +960,6 @@ static void ImGui_ImplSDL2_CreateWindow(ImGuiViewport* viewport)

viewport->PlatformHandle = (void*)vd->Window;
viewport->PlatformHandleRaw = nullptr;

SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if (SDL_GetWindowWMInfo(vd->Window, &info))
Expand Down
7 changes: 5 additions & 2 deletions backends/imgui_impl_sdl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -559,11 +559,14 @@ static void ImGui_ImplSDL3_UpdateMouseData()

// We forward mouse input when hovered or captured (via SDL_EVENT_MOUSE_MOTION) or when focused (below)
#if SDL_HAS_CAPTURE_AND_GLOBAL_MOUSE
// MicroStrain start
#if !defined(_WIN32) && defined(NDEBUG)
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
// On linux, this can get the mouse stuck when a breakpoint is hit, so disable for debug builds.
// See https://github.com/ocornut/imgui/issues/4197 and https://github.com/ocornut/imgui/issues/3650
// MicroStrain end
// SDL_CaptureMouse() let the OS know e.g. that our imgui drag outside the SDL window boundaries shouldn't e.g. trigger other operations outside
SDL_CaptureMouse((bd->MouseButtonsDown != 0) ? SDL_TRUE : SDL_FALSE);
#endif
#endif // MicroStrain
SDL_Window* focused_window = SDL_GetKeyboardFocus();
const bool is_app_focused = (focused_window && (bd->Window == focused_window || ImGui::FindViewportByPlatformHandle((void*)focused_window)));
#else
Expand Down
8 changes: 3 additions & 5 deletions imconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
// Using Dear ImGui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility.
// DLL users: heaps and globals are not shared across DLL boundaries! You will need to call SetCurrentContext() + SetAllocatorFunctions()
// for each static/DLL boundary you are calling from. Read "Context and Memory Allocators" section of imgui.cpp for more details.
#ifdef WIN32_
#define IMGUI_API __declspec( dllexport )
#endif
//#define IMGUI_API __declspec( dllexport )
//#define IMGUI_API __declspec( dllimport )

//---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to clean your code of obsolete function/names.
Expand Down Expand Up @@ -102,13 +100,13 @@
operator MyVec4() const { return MyVec4(x,y,z,w); }
*/
//---- ...Or use Dear ImGui's own very basic math operators.
#define IMGUI_DEFINE_MATH_OPERATORS
//#define IMGUI_DEFINE_MATH_OPERATORS

//---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices.
// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices).
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
#define ImDrawIdx unsigned int
//#define ImDrawIdx unsigned int

//---- Override ImDrawCallback signature (will need to modify renderer backends accordingly)
//struct ImDrawList;
Expand Down
29 changes: 0 additions & 29 deletions imgui-config.cmake.in

This file was deleted.

Loading

0 comments on commit 13d8753

Please sign in to comment.