-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hit-testing fails on Win32 with viewport sidebar + docking + borderless window #6162
Comments
Interesting, my suspicion is similar that there is perhaps some bad interaction between the wndProc handlers but I know the viewportSidebar is also a newish feature so there may have been some bug. I'll try to investigate what is causing the loss of mouse updating. I hate these sorts of bugs where everything looks to be working but isnt ;) Will follow up with more info, and perhaps we can turn this into a borderless starter Gist or something. |
Thanks for the lead about the mouse position. So what seems to be happening is that once I return the "HTCAPTION" result from the hit-test, we stop receiving the WM_MOUSEMOVE message and receive WM_NCMOUSEMOVE messages instead. This seems to be standard behavior and dearImgui doesnt handle those messages because they are generally irrelevant for it. Adding this code fixes the issue but what I don't understand is why it was working intermittently. case WM_NCMOUSEMOVE:
{
// We need to call TrackMouseEvent in order to receive WM_MOUSELEAVE events
bd->MouseHwnd = hwnd;
if (!bd->MouseTracked)
{
TRACKMOUSEEVENT tme = { sizeof(tme), TME_LEAVE, hwnd, 0 };
::TrackMouseEvent(&tme);
bd->MouseTracked = true;
}
POINT mouse_pos = { (LONG)GET_X_LPARAM(lParam), (LONG)GET_Y_LPARAM(lParam) };
io.AddMousePosEvent((float)mouse_pos.x, (float)mouse_pos.y);
break;
} I'm not a win32 expert so would be good for someone else to validate this but for now it fixes the problem. I can easily add that to my client code but the default imgui impl could also be updated with it as it probably doesnt hurt. |
Ah! It turns out we have a thread discussing just this: #6045 |
May be wrong and lose mouse pos when app is unfocused, I'll post solution/fix in win32 backend once I find it (right now I don't have it). |
Yeh, I don't know either, so far it seems to fix the issue, but I'll keep testing and see if I can trigger any further issues. At least now that I know what the core problem is, it's easy enough to debug and I will just patch the wndProc (and update this issues) if/as needed. |
…positions over non-client area (OS decorations) when app is not focused. (ocornut#6045, ocornut#6162)
…positions over non-client area (OS decorations) when app is not focused. (ocornut#6045, ocornut#6162)
Version: 1.89.3
Branch: docking
Back-end/Renderer/Compiler/OS
Back-ends: imgui_impl_dx11cpp + imgui_impl_win32.cpp
Operating System: Win11 and Win10
My Issue/Question:
So this is a really strange issue that I've tried debugging but once I ended up deep in the imgui internals, I figured it would be better to post the question.
So I'm trying to create a custom title bar for my window. I'm using the ViewportSidebar feature to create my window titlebar and it's mostly working great except that occasionally the hit testing fails. This seems to be related to some combination of docking of windows and (maybe?) moving the main win32 window. It's a 100% reproduceable in my home engine but a little harder to repro in the example app but it still happens.
I think enabling the dockspace example exacerbates the issue. I've provided a repro case, so all you need to do is replace the main.cpp in the dx11 example and run it. you'll notice the new title bar and the three buttons that you can hover over and they detect that. Now example the dockspace example and dock undock the windows and you'll notice how the hit-testing starts to fail. In some cases it fixes but sometimes it doesn't (and in my home engine it never fixes itself). I've also attached a video showing the issue.
Anyone have any idea what's going on?
Screenshots/Video
https://user-images.githubusercontent.com/10767490/218336676-ffa7d46c-6c4e-4f11-90e8-203b63fe21cc.mp4
Standalone, minimal, complete and verifiable example:
Replace the DX11 example main.cpp with the version supplied, all changes are within // BUG REPRO comment blocks.
main.zip
The text was updated successfully, but these errors were encountered: