UI: Improved Default GetWindowUnderCursor Behavior #111489

Harley Acheson merged 3 commits from Harley/blender:DefaultGetWindowUnderCursor into main 2024-01-15 20:27:56 +01:00
1 changed files with 16 additions and 5 deletions

View File

@ -204,16 +204,27 @@ bool GHOST_System::getFullScreen()
GHOST_IWindow *GHOST_System::getWindowUnderCursor(int32_t x, int32_t y)
/* TODO: This solution should follow the order of the activated windows (Z-order).
* It is imperfect but usable in most cases. */
for (GHOST_IWindow *iwindow : m_windowManager->getWindows()) {
if (iwindow->getState() == GHOST_kWindowStateMinimized) {
* It is imperfect but usable in most cases. Ideally each platform should provide
* a custom version of this function that properly considers z-order. */
std::vector<GHOST_IWindow *> windows = m_windowManager->getWindows();
std::vector<GHOST_IWindow *>::reverse_iterator iwindow_iter;
/* 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_iter = windows.rbegin(); iwindow_iter != windows.rend(); ++iwindow_iter) {
GHOST_IWindow *win = *iwindow_iter;
if (win->getState() == GHOST_kWindowStateMinimized) {
Harley marked this conversation as resolved Outdated

*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.
GHOST_Rect bounds;
if (bounds.isInside(x, y)) {
return iwindow;
return win;