UI: Improved Default GetWindowUnderCursor Behavior #111489

Merged
Harley Acheson merged 3 commits from Harley/blender:DefaultGetWindowUnderCursor into main 2024-01-15 20:27:56 +01:00
Member

For default GetWindowUnderCursor (when there is not a platform-specific
version), search windows in reverse order. This is because in most
cases with overlapping windows the one that is on top was created after
those that are below it.


Note that this fixes #111295, although potentially imperfectly. A perfect fix on the Windows platform is #111359.

So what is this for? Ghost provides a base implementation of getWindowUnderCursor in GHOST_System::getWindowUnderCursor. This function tries to guess which blender window is at the supplied cursor location. Unfortunately we don't track the Z-order or activation order of our windows. This means that when two windows are overlapping we just return the first one that has bounds that include the location.

Unfortunately we iterate through our window list in forward order. This means that a window that is created first will be returned when windows overlap. But in the vast majority of cases a window that is on top of another is created after those below it. #111295 is an example of this function failing in simple cases. This PR just reverses this search to give better results in most cases.

Note that this is the base implementation. For better results that work correctly with z-depth and activation order it is best to ask the operating system, which requires having a platform-specific version of this function. The MacOS platform currently has such. And my #111359 does so for Windows. Once that is merged it will be just Linux that will use the version referenced in this PR.

For default GetWindowUnderCursor (when there is not a platform-specific version), search windows in reverse order. This is because in most cases with overlapping windows the one that is on top was created after those that are below it. --- Note that this fixes #111295, although potentially imperfectly. A perfect fix on the Windows platform is #111359. So what is this for? Ghost provides a **base** implementation of `getWindowUnderCursor` in `GHOST_System::getWindowUnderCursor`. This function tries to _guess_ which blender window is at the supplied cursor location. Unfortunately we don't track the Z-order or activation order of our windows. This means that when two windows are overlapping we just return the first one that has bounds that include the location. Unfortunately we iterate through our window list in forward order. This means that a window that is created first will be returned when windows overlap. But in the vast majority of cases a window that is on top of another is created after those below it. #111295 is an example of this function failing in simple cases. This PR just reverses this search to give better results in most cases. Note that this is the base implementation. For better results that work correctly with z-depth and activation order it is best to ask the operating system, which requires having a platform-specific version of this function. The MacOS platform currently has such. And my #111359 does so for Windows. Once that is merged it will be just Linux that will use the version referenced in this PR.
Harley Acheson added 1 commit 2023-08-24 21:34:42 +02:00
8fe899eb5f UI: Improved Default GetWindowUnderCursor Behavior
For default GetWindowUnderCursor (when there is not a platform-specific
version), search windows in reverse order. This is because in most
cases with overlapping windows the one that is on top was created after
those that are below it.
Harley Acheson added this to the User Interface project 2023-08-24 21:35:01 +02:00
Harley Acheson requested review from Campbell Barton 2023-08-24 21:35:12 +02:00
Author
Member

@ChengduLittleA - This should fix #111295 for you on LInux.

@ChengduLittleA - This should fix #111295 for you on LInux.
Campbell Barton approved these changes 2024-01-15 03:22:28 +01:00
@ -217,0 +220,4 @@
/* Search through the windows in reverse order because in most cases
* the window that is on top was created after those that are below it. */
for (iwindow = windows.rbegin(); iwindow != windows.rend(); ++iwindow) {

*picky* prefer to call the iterator iwindow_iter and assign a variable to iwindow since referencing (*iwindow) is awkward.

\*picky\* prefer to call the iterator `iwindow_iter` and assign a variable to `iwindow` since referencing `(*iwindow)` is awkward.
Harley marked this conversation as resolved
Harley Acheson added 2 commits 2024-01-15 20:10:46 +01:00
buildbot/vexp-code-patch-darwin-x86_64 Build done. Details
buildbot/vexp-code-patch-darwin-arm64 Build done. Details
buildbot/vexp-code-patch-windows-amd64 Build done. Details
buildbot/vexp-code-patch-lint Build done. Details
buildbot/vexp-code-patch-linux-x86_64 Build done. Details
buildbot/vexp-code-patch-coordinator Build done. Details
051e427ea4
Changes suggested by review
Author
Member

@blender-bot build linux

@blender-bot build linux
Harley Acheson merged commit 0f8c8e475a into main 2024-01-15 20:27:56 +01:00
Harley Acheson deleted branch DefaultGetWindowUnderCursor 2024-01-15 20:27:58 +01:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#111489
No description provided.