Backends: GLFW: sync clamped viewport positions#9441
Open
KBentley57 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix a GLFW multi-viewport position sync issue on Linux/X11 when the window manager clamps a secondary viewport to a monitor edge.
Issue: #9442
Confirmed from at least Dear ImGui 1.90 through current docking HEAD, using GCC 13 and GCC 14, on Debian 13, Ubuntu 24.04, Ubuntu under WSL, Red Hat Enterprise Linux 8/9, and Rocky Linux 8/9.
The GLFW backend currently ignores window-position callbacks for one frame after calling
glfwSetWindowPos(), so ordinary echo events from the backend do not setPlatformRequestMove. On X11 window managers such as Mutter, the requested position may be refused or clamped near monitor edges. In that case GLFW reports a different actual position, but the callback is still ignored and Dear ImGui keeps using the requested position internally.This patch keeps the existing ignore behavior when GLFW reports the exact position Dear ImGui requested. If the callback reports a different position, it is treated as an actual platform move so the viewport can be synchronized back to the real platform window position.
Related Issues
Repro
Minimal repro repository:
https://github.com/KBentley57/imgui-viewport-edge-repro
Build the repro once against
v1.92.8-dockingand once against this branch. With the affected backend, the detached viewport can report a cached ImGui viewport position that differs fromglfwGetWindowPos()after requesting/dragging near a monitor edge. With this branch, the backend no longer discards the clamped position callback.Validation
backends/imgui_impl_glfw.cpp.