Fix #111295: Add Missing Win32 Platform-Specific Window functions #111359
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
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
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
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
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
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
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#111359
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "Harley/blender:Win32WinFunctions"
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?
Add platform-specific (Windows) versions of getOSWindow() and
getWindowUnderCursor().
This does not add any new ghost functions, just Windows-specific implementations of existing ones.
The base default behavior of
getOSWindow
always returns nullptr. This PR makes it return the Windows OS Handle as expected. This is needed forgetWindowAssociatedWithOSWindow
to work correctly because it uses this as a test while iterating through ghost windows. So it currently always returns nullptr.The base default behavior of
getWindowUnderCursor
does a forward search through the ghost windows checking bounds. This does not consider z-depth. And because the search is forward it will always return the main window if a child is overlapping in front. This specific implementation gets the cursor location from the OS and then the Window handle from that usingWindowFromPoint
. Converting from window handle to ghost window requiresgetWindowAssociatedWithOSWindow
, which needs a workinggetOSWindow
.This PR does not use the passed cursor location because that will often be wrong. The best example is when we have a blender window on one monitor but the mouse cursor is on a different monitor that uses a different scale. In this case the cursor location will not be a nice offset from our blender window. Best to just ask the OS where the cursor actually is.
For testing and how this relates to the referenced bug report. Opening the "Preferences" window and having it above the main window, using the color picker in the Themes area will select through to the main window. This is because the base getWindowUnderCursor behavior returns the first window with bounds that match the cursor position.
I gotta say, i'm not loving the x,y coordinates being ignored, then again i'm also not loving the initial design, where a function called
getWindowUnderCursor
needs x,y coordinates fed to it, feels like something it should be able to figure out on its own. Or perhaps the function should have been calledgetWindowForScreenCoordinates
in the first place if the location of the cursor has no influence on the results what so ever.from talking with you on chat, we seem a bit stuck with this mess, without time to fix it, as some UI theming work needs this to function, to move forward i see 3 options :
this function needs a better comment in both
GHOST_ISystem.hh
andGHOST_C-api.h
outlining that the x and y parameters are hints at best, and could be ignored on some backends.Change the signature not to take x,y coordinates. I'm unsure why they are needed, @mano-wii may have some historic knowledge here as he implemented this in the past.
Make it actually work with the x,y coordinates, I understand per monitor DPI scaling makes this difficult/impossible
1 is the bare minimum we need to land this since it's a blocker, 2 or 3 would be my preference though
To bring a little historical context.
Prior to
9bd586a01e
all OS's had the same solution for finding a window under the cursor.But the existing solution there didn't work for MacOS when the cursor was on another monitor (bringing bugs).
It was not possible to use the same generic solution for Mac. So it was necessary to create a specific solution for this OS.
Thus, the algorithm that was previously in
WM_window_find_under_cursor
was then moved toGHOST_IWindow *GHOST_SystemWin32::getWindowUnderCursor
;And on Mac another algorithm using OS API overwrote the existing one.
Not on Mac here, but to my eye I think it might also benefit from asking the OS where the mouse is, instead of using the coordinates we supply. Something like:
I remember having tested it on monitors with different pixel resolution on the Mac. I don't really understand this limitation.
If that's really the case, it looks like the function
wm_cursor_position_to_ghost(win, &x, &y);
is incorrect or limited.Since the cursor isn't used, calling
wm_cursor_position_to_ghost
seems to be redundant, (which doesn't look good on something that gets called so often).Also since this function is working incorrectly, the other associated function
wm_cursor_position_from_ghost(r_win, &x, &y);
must also be incorrect.So even if the window is the correct one, the relative coordinates returned by
WM_window_find_under_cursor
are incorrect.So it would be ideal to fix
wm_cursor_position_to_ghost
andwm_cursor_position_from_ghost
(or remove the need for them for all OS's).FYI I'm not sure this patch handles that, but #111295 is also reproducible on linux, so it's probably also broken on at least X11. (My wayland is broken can't test it)
Assuming you mean that when Properties is on top of the main blender window the picker will select from the main window. That is probably a strong argument for having the loop reversed in GHOST_System.cc, GHOST_System::getWindowUnderCursor. That way the default behavior would test children before their parents. That would be better in almost all cases.
The loop there now is a "foreach" style (range-based) for loop, which AFAIK does not offer some easy "reverse" option. So just needs to be rewritten in regular for style.
@blender-bot build