mirror of
https://github.com/ocornut/imgui.git
synced 2026-10-20 19:08:56 +00:00
Win32 backend: can't hover over nonclient areas when window does not have focus #6045
Labels
No labels
accidentally closed
android
backends
bug
building
clipper
coloredit
color spaces
cplusplus
data types
demo
disabled
doc
docking
dpi
drag drop
drawing/drawlist
dropped
dx12
enhancement
focus
font/text
gallery
help wanted
idle/power saving
ime
in progress
inputs
inputtext
internals
label/id and id stack
language bindings
layout
linux/bsd
menus
multi-contexts
multi-threading
multi-viewports
nav
news/info
opengl
optimization
osx/ios
overlap
plot/graph
popups
question
scrolling
selection
settings
sliders/drags
style
tables/columns
tabs
test wanted
tools
tooltips
tree
tricks & tips
useful widgets
vulkan
web
window pos/depth
window sizing
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ocornut/imgui#6045
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Version: 1.88
Branch: master/viewport/docking
Back-ends: imgui_impl_win32.cpp
Compiler: vs2022
Operating System: Windows 11
imgui buttons that are part of the nonclient area of the window behave correctly only when the window has focus:
When creating a frameless window with owner draw captions you can use imgui buttons for min/max/close buttons, by appropriately processing WM_NCHITTEST on the button regions. This works fine when the window has focus (is foreground). In this case AddMousePosEvent is not called from ImGui_ImplWin32_WndProcHandler's WM_MOUSEMOVE handler since they are considered nonclient areas. Instead, AddMousePosEvent is called from
ImGui_ImplWin32_UpdateMouseData(). However, UpdateMouseData checks first that the window has focus, so that when the window does not have focus AddMousePosEvent is never called and hover tests fail.
ImGui_ImplWin32_WndProcHandler should probably handle WM_NCMOUSEMOVE as well as WM_MOUSEMOVE.
It doesn't seem trivial to handle seems how WM_MOUSELEAVE are occasionally triggered after WM_NCMOUSEMOVE.
I came up with this:
Add
bool MouseInClientArea;inImGui_ImplWin32_Data.I would however need to test it more thoroughly, and with multi-viewports.
Could you test on your side?
That stuff tends to be tricky and fragile so if it comes with other undesirable side-effects we might need to back-track.
In handling WM_NCMOUSEMOVE I think you want
TRACKMOUSEEVENT tme = { sizeof(tme), TME_LEAVE | TME_NONCLIENT, hwnd, 0 };Getting WM_MOUSELEAVE after the first WM_NCMOUSEMOVE is unfortunate but not the end of the world. Otherwise I believe this works. One idea is to cancel the outstanding track mouse event (
TME_CANCEL | TME_LEAVE) and issue a new one.@ocornut your code above works perfectly with the addition of
That didn't look right. When unfocused we don't always get leave events there.
I think I worked it our right always sending a cancel request when changing area.
Pushed
5d74891Merged in docking via
e25e452cc @BobbyAnguelov would be good if you can confirm it works with vanilla backend and without your custom msg handler.
Works in both the minimal example I created and in Esoterica.