Use glfwGetMonitorWorkarea for accurate screen size#7469
Use glfwGetMonitorWorkarea for accurate screen size#7469dannyboy0103 wants to merge 3 commits intoisl-org:mainfrom
Conversation
|
Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes. |
Replace glfwGetVideoMode with glfwGetMonitorWorkarea in GLFWWindowSystem::GetScreenSize(). Since Open3D already bundles GLFW 3.4, we can now use glfwGetMonitorWorkarea() which returns the usable work area (excluding taskbar, dock, and menu bar) instead of the full monitor resolution. This also removes the unusable_height estimation hack in Window::OnResize() that guessed the menu bar and dock height as 4 * font_size. The work area returned by glfwGetMonitorWorkarea() already excludes these regions, making the estimation unnecessary and the auto-sizing more accurate across all platforms.
a14ad9c to
fae8898
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates screen sizing to use the monitor work area (excluding OS UI like taskbars/docks) instead of full monitor resolution, improving window auto-sizing/centering and removing a heuristic height adjustment.
Changes:
- Switch
GLFWWindowSystem::GetScreenSize()fromglfwGetVideoMode()toglfwGetMonitorWorkarea(). - Remove the
unusable_heightestimation hack inWindow::OnResize(). - Document the behavioral change in
CHANGELOG.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| cpp/open3d/visualization/gui/Window.cpp | Removes manual unusable-height subtraction when clamping window size to screen size. |
| cpp/open3d/visualization/gui/GLFWWindowSystem.cpp | Uses GLFW work area API to return usable screen size rather than full mode resolution. |
| CHANGELOG.md | Adds an entry describing the screen sizing change. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| w = std::min(screen_size.width, | ||
| int(std::round(pref.width / impl_->imgui_.scaling))); | ||
| // screen_height is the screen height, not the usable screen height. | ||
| // If we cannot call glfwGetMonitorWorkarea(), then we need to guess | ||
| // at the size. The window titlebar is about 2 * em, and then there | ||
| // is often a global menubar (Linux/GNOME, macOS) or a toolbar | ||
| // (Windows). A toolbar is somewhere around 2 - 3 ems. | ||
| int unusable_height = 4 * impl_->theme_.font_size; | ||
| h = std::min(screen_size.height - unusable_height, | ||
| h = std::min(screen_size.height, | ||
| int(std::round(pref.height / impl_->imgui_.scaling))); |
| // &screen_width, &screen_height); | ||
| int xpos, ypos; | ||
| glfwGetMonitorWorkarea(monitor, &xpos, &ypos, | ||
| &screen_width, &screen_height); |
ssheorey
left a comment
There was a problem hiding this comment.
Hi @dannyboy0103 thanks for looking into this! Please check one comment below.
| w = std::min(screen_size.width, | ||
| int(std::round(pref.width / impl_->imgui_.scaling))); | ||
| // screen_height is the screen height, not the usable screen height. | ||
| // If we cannot call glfwGetMonitorWorkarea(), then we need to guess | ||
| // at the size. The window titlebar is about 2 * em, and then there | ||
| // is often a global menubar (Linux/GNOME, macOS) or a toolbar | ||
| // (Windows). A toolbar is somewhere around 2 - 3 ems. | ||
| int unusable_height = 4 * impl_->theme_.font_size; | ||
| h = std::min(screen_size.height - unusable_height, | ||
| h = std::min(screen_size.height, | ||
| int(std::round(pref.height / impl_->imgui_.scaling))); |
Replace
glfwGetVideoMode()withglfwGetMonitorWorkarea()inGLFWWindowSystem::GetScreenSize()as noted in the existing TODO comment. This also removes theunusable_heightestimation hack (4 * font_size) inWindow::OnResize()since the work area already excludes menu bar, dock, and taskbar.glfwGetVideoMode()returns the full monitor resolution including non-usable areas, which forced a rough estimate for unusable height. Since Open3D already bundles GLFW 3.4,glfwGetMonitorWorkarea()can now provide the exact usable area directly from the OS, making window auto-sizing and centering more accurate across all platforms.