UI: Improved Default GetWindowUnderCursor Behavior #111489
|
@ -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) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Harley marked this conversation as resolved
Outdated
|
||||
GHOST_Rect bounds;
|
||||
iwindow->getClientBounds(bounds);
|
||||
win->getClientBounds(bounds);
|
||||
if (bounds.isInside(x, y)) {
|
||||
return iwindow;
|
||||
return win;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
*picky* prefer to call the iterator
iwindow_iter
and assign a variable toiwindow
since referencing(*iwindow)
is awkward.