refactor(new_editor/app): isolate cross-window drop support
This commit is contained in:
@@ -54,4 +54,45 @@ const EditorWindow* EditorWindowManager::FindPrimaryWindow() const {
|
||||
return const_cast<EditorWindowManager*>(this)->FindPrimaryWindow();
|
||||
}
|
||||
|
||||
EditorWindow* EditorWindowManager::FindTopmostWindowAtScreenPoint(
|
||||
const POINT& screenPoint,
|
||||
std::string_view excludedWindowId) {
|
||||
if (const HWND hitWindow = WindowFromPoint(screenPoint); hitWindow != nullptr) {
|
||||
const HWND rootWindow = GetAncestor(hitWindow, GA_ROOT);
|
||||
if (EditorWindow* window = FindWindow(rootWindow);
|
||||
window != nullptr &&
|
||||
window->GetWindowId() != excludedWindowId) {
|
||||
return window;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto it = m_windows.rbegin(); it != m_windows.rend(); ++it) {
|
||||
EditorWindow* const window = it->get();
|
||||
if (window == nullptr ||
|
||||
window->GetHwnd() == nullptr ||
|
||||
window->GetWindowId() == excludedWindowId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
RECT windowRect = {};
|
||||
if (GetWindowRect(window->GetHwnd(), &windowRect) &&
|
||||
screenPoint.x >= windowRect.left &&
|
||||
screenPoint.x < windowRect.right &&
|
||||
screenPoint.y >= windowRect.top &&
|
||||
screenPoint.y < windowRect.bottom) {
|
||||
return window;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const EditorWindow* EditorWindowManager::FindTopmostWindowAtScreenPoint(
|
||||
const POINT& screenPoint,
|
||||
std::string_view excludedWindowId) const {
|
||||
return const_cast<EditorWindowManager*>(this)->FindTopmostWindowAtScreenPoint(
|
||||
screenPoint,
|
||||
excludedWindowId);
|
||||
}
|
||||
|
||||
} // namespace XCEngine::UI::Editor::App
|
||||
|
||||
Reference in New Issue
Block a user