-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
Win32 DX11 monitor Work Size desync issue #8415
Comments
Oops, I think I knew about this oversight but forgot to report it :( Thanks for the reminder!
My private backend looks for case WM_SETTINGCHANGE:
if (wParam != SPI_SETWORKAREA)
break;
case WM_DISPLAYCHANGE:
bd->WantUpdateMonitors = true;
return 0; Can you confirm that fixes things for you? |
Thanks, this seems to work (with a small change) Initially I did not see any reference to
I notice that:
But I think a more backward compatible version would be to use
This fixes the workarea issues, and may or may not fix the other offset issues users have reported (although I have been unable to reproduce their issues to test). This is a good addition then nonetheless. |
Reopening as this should be in our backend. |
|
Yes, WM_SETTINGCHANGE should be good then. 👍 |
Thank you both for investigating! I have pushed change ea59440 (attributed to David). TL;DR: work area change may trigger a WM_SETTINGCHANGE's SPI_SETWORKAREA message. case WM_DISPLAYCHANGE:
bd->WantUpdateMonitors = true;
return 0;
++ case WM_SETTINGCHANGE:
++ if (wParam == SPI_SETWORKAREA)
++ bd->WantUpdateMonitors = true;
++ return 0;
} I was curious and noticed neither GLFW neither SDL3 used case WM_DISPLAYCHANGE:
_glfwPollMonitorsWin32();
break; For SDL3 it's harder for me to tell. From my point of view which is the same one of an app using SDL, I'm waiting for the following messages to refresh my list of display and work area: case SDL_EVENT_DISPLAY_ORIENTATION:
case SDL_EVENT_DISPLAY_ADDED:
case SDL_EVENT_DISPLAY_REMOVED:
case SDL_EVENT_DISPLAY_MOVED:
case SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED:
{
bd->WantUpdateMonitors = true;
return true;
} And it doesn't look like WM_SETTINGCHANGE's SPI_SETWORKAREA has any particular effect: case WM_DISPLAYCHANGE:
{
// Reacquire displays if any were added or removed
WIN_RefreshDisplays(SDL_GetVideoDevice());
} break; So even if Sorry for pinging cc @slouken you might find this useful. |
…gers a refresh of monitor list. (#8415)
GLFW doesn't have a work area callback, only a work area query. Maximized windows automatically get resized by the OS with WM_SIZE, and mouse coordinates do not depend on monitor work area. As far as I can see changing the work area doesn't cause issues for ImGui on GLFW, though I've only tested by auto-hiding the Taskbar so far. So at the moment there's no reason to add |
To clarify, the patch we applied was specifically for this sub-issue:
And I brain-farted that there was a wider issue in this topic (which, to clarify, has nothing to do with GLFW or SDL) so it was hasty to me to close, reopening.
Indeed. But as |
I agree it's a property of a monitor, but the GLFW monitor callback is for connect/disconnect events rather than property changes. At the moment we have a number of monitor properties which can be polled, but we don't have events for them changing. Adding callbacks for these property changing is a good idea, but it's a pretty large endeavour given the number of properties and OSs to cover. I've added an issue to track this: |
Just to clarify i can totally do without. We could rework backends to update work area once a frame and call it a day. I merely wanted to tag you for your thoughts. But you are right it may not be glfw nor sdl job to notify of those changes. |
I just did a text and noticed that our Linux SDL backend did not adjust workarea on Gnome launcher resizing either. |
I've kind of given up on the fidelity of SDL work-area metrics, need to double-check and fall back in my app to compensate for invalid data. This ticket case-in-point: |
I think it’s an issue on our end that we can fix in the backend, as no one gave a specific suggestion that those values changing was tied to monitor/display changing. |
…every frame, as the later may change regardless of monitor changes. (#8415)
Pushed 1a7b594 to update monitors and work area every frames with GLFW, SDL2, SDL3 backends. |
Version/Branch of Dear ImGui:
Version 1.91.9, Branch: docking
Back-ends:
imgui_impl_dx11 + imgui_impl_win32
Compiler, OS:
MSVC
Full config/build information:
Details:
I've been seeing some desync issues happening on occasion, and they may or may not all be related to each other.
One of the cases is when working with ImGui over RDP, when switching back one user reported that the mouse showed the hover over controls that were about 20px below where the mouse was (once the window was moved it was correct again).
And another user commented that our hovering app bar was not above the windows taskbar as it usually is, but right over it (and no amount of dragging fixed that).
I believe (perhaps both) these are related to the fact that the monitor layout is different and changes (in several ways). ImGui already handled the
WM_DISPLAYCHANGE
message, so this confused me. However, something else I saw when switching from and to RDP is that after connecting, Windows goes wild reordering windows (and the task bar) for a few more seconds, thus even though ImGui received theWM_DISPLAYCHANGE
shortly after connecting, there may still be additional messages needed.Indeed, I also saw that resizing the windows task bar did not update ImGui's internal metrics of monitor work sizes real-time as it should, so I added some debugging to see the messages being dispatched.
I'm not sure if it is the correct message, but I also added
WM_GETMINMAXINFO
to:And this at least solved how ImGui responds to taskbar changes.
I'm not an experienced windows programmer, and if anyone else can see an issue with this, perhaps there is a better message, but I believe this will address that shortfall.
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
No response
The text was updated successfully, but these errors were encountered: