@ -10,6 +10,9 @@
// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE).
// [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE).
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'.
// Issues:
// [ ] Platform: Multi-viewport support: ParentViewportID not honored, and so io.ConfigViewportsNoDefaultParent has no effect (minor).
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
// You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this.
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
// If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp.
// https://github.com/ocornut/imgui
// https://github.com/ocornut/imgui
@ -63,6 +66,11 @@
# else
# else
# define GLFW_HAS_NEW_CURSORS (0)
# define GLFW_HAS_NEW_CURSORS (0)
# endif
# endif
# ifdef GLFW_MOUSE_PASSTHROUGH // Let's be nice to people who pulled GLFW between 2019-04-16 (3.4 define) and 2020-07-17 (passthrough)
# define GLFW_HAS_MOUSE_PASSTHROUGH (GLFW_VERSION_MAJOR * 1000 + GLFW_VERSION_MINOR * 100 >= 3400) // 3.4+ GLFW_MOUSE_PASSTHROUGH
# else
# define GLFW_HAS_MOUSE_PASSTHROUGH (0)
# endif
// Data
// Data
enum GlfwClientApi
enum GlfwClientApi
@ -166,7 +174,7 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
io . BackendFlags | = ImGuiBackendFlags_HasMouseCursors ; // We can honor GetMouseCursor() values (optional)
io . BackendFlags | = ImGuiBackendFlags_HasMouseCursors ; // We can honor GetMouseCursor() values (optional)
io . BackendFlags | = ImGuiBackendFlags_HasSetMousePos ; // We can honor io.WantSetMousePos requests (optional, rarely used)
io . BackendFlags | = ImGuiBackendFlags_HasSetMousePos ; // We can honor io.WantSetMousePos requests (optional, rarely used)
io . BackendFlags | = ImGuiBackendFlags_PlatformHasViewports ; // We can create multi-viewports on the Platform side (optional)
io . BackendFlags | = ImGuiBackendFlags_PlatformHasViewports ; // We can create multi-viewports on the Platform side (optional)
# if GLFW_HAS_ WINDOW_HOVERED && defined(_WIN32)
# if GLFW_HAS_ MOUSE_PASSTHROUGH || (GLFW_HAS_ WINDOW_HOVERED && defined(_WIN32) )
io . BackendFlags | = ImGuiBackendFlags_HasMouseHoveredViewport ; // We can set io.MouseHoveredViewport correctly (optional, not easy)
io . BackendFlags | = ImGuiBackendFlags_HasMouseHoveredViewport ; // We can set io.MouseHoveredViewport correctly (optional, not easy)
# endif
# endif
io . BackendPlatformName = " imgui_impl_glfw " ;
io . BackendPlatformName = " imgui_impl_glfw " ;
@ -348,8 +356,12 @@ static void ImGui_ImplGlfw_UpdateMousePosAndButtons()
// rectangles and last focused time of every viewports it knows about. It will be unaware of other windows that may be sitting between or over your windows.
// rectangles and last focused time of every viewports it knows about. It will be unaware of other windows that may be sitting between or over your windows.
// [GLFW] FIXME: This is currently only correct on Win32. See what we do below with the WM_NCHITTEST, missing an equivalent for other systems.
// [GLFW] FIXME: This is currently only correct on Win32. See what we do below with the WM_NCHITTEST, missing an equivalent for other systems.
// See https://github.com/glfw/glfw/issues/1236 if you want to help in making this a GLFW feature.
// See https://github.com/glfw/glfw/issues/1236 if you want to help in making this a GLFW feature.
# if GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
# if GLFW_HAS_MOUSE_PASSTHROUGH || (GLFW_HAS_WINDOW_HOVERED && defined(_WIN32))
if ( glfwGetWindowAttrib ( window , GLFW_HOVERED ) & & ! ( viewport - > Flags & ImGuiViewportFlags_NoInputs ) )
const bool window_no_input = ( viewport - > Flags & ImGuiViewportFlags_NoInputs ) ! = 0 ;
# if GLFW_HAS_MOUSE_PASSTHROUGH
glfwSetWindowAttrib ( window , GLFW_MOUSE_PASSTHROUGH , window_no_input ) ;
# endif
if ( glfwGetWindowAttrib ( window , GLFW_HOVERED ) & & ! window_no_input )
io . MouseHoveredViewport = viewport - > ID ;
io . MouseHoveredViewport = viewport - > ID ;
# endif
# endif
}
}
@ -586,7 +598,7 @@ static void ImGui_ImplGlfw_DestroyWindow(ImGuiViewport* viewport)
{
{
if ( data - > WindowOwned )
if ( data - > WindowOwned )
{
{
# if GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
# if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
HWND hwnd = ( HWND ) viewport - > PlatformHandleRaw ;
HWND hwnd = ( HWND ) viewport - > PlatformHandleRaw ;
: : RemovePropA ( hwnd , " IMGUI_VIEWPORT " ) ;
: : RemovePropA ( hwnd , " IMGUI_VIEWPORT " ) ;
# endif
# endif
@ -600,7 +612,7 @@ static void ImGui_ImplGlfw_DestroyWindow(ImGuiViewport* viewport)
// We have submitted https://github.com/glfw/glfw/pull/1568 to allow GLFW to support "transparent inputs".
// We have submitted https://github.com/glfw/glfw/pull/1568 to allow GLFW to support "transparent inputs".
// In the meanwhile we implement custom per-platform workarounds here (FIXME-VIEWPORT: Implement same work-around for Linux/OSX!)
// In the meanwhile we implement custom per-platform workarounds here (FIXME-VIEWPORT: Implement same work-around for Linux/OSX!)
# if GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
# if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
static WNDPROC g_GlfwWndProc = NULL ;
static WNDPROC g_GlfwWndProc = NULL ;
static LRESULT CALLBACK WndProcNoInputs ( HWND hWnd , UINT msg , WPARAM wParam , LPARAM lParam )
static LRESULT CALLBACK WndProcNoInputs ( HWND hWnd , UINT msg , WPARAM wParam , LPARAM lParam )
{
{
@ -634,7 +646,7 @@ static void ImGui_ImplGlfw_ShowWindow(ImGuiViewport* viewport)
}
}
// GLFW hack: install hook for WM_NCHITTEST message handler
// GLFW hack: install hook for WM_NCHITTEST message handler
# if GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
# if !GLFW_HAS_MOUSE_PASSTHROUGH && GLFW_HAS_WINDOW_HOVERED && defined(_WIN32)
: : SetPropA ( hwnd , " IMGUI_VIEWPORT " , viewport ) ;
: : SetPropA ( hwnd , " IMGUI_VIEWPORT " , viewport ) ;
if ( g_GlfwWndProc = = NULL )
if ( g_GlfwWndProc = = NULL )
g_GlfwWndProc = ( WNDPROC ) : : GetWindowLongPtr ( hwnd , GWLP_WNDPROC ) ;
g_GlfwWndProc = ( WNDPROC ) : : GetWindowLongPtr ( hwnd , GWLP_WNDPROC ) ;