Fix tooltips in multi-displays mode when the Preview window is open

This commit is contained in:
David Capello 2021-03-31 17:10:31 -03:00
parent ff3b14978a
commit 4f4f5fee7f
3 changed files with 21 additions and 5 deletions

View File

@ -760,19 +760,16 @@ void Manager::updateMouseWidgets(const gfx::Point& mousePos,
Widget* widget = nullptr;
for (auto mouseWidget : mouse_widgets_list) {
if (get_multiple_displays()) {
gfx::Point displayPos;
if (display) {
if (display != mouseWidget->display()) {
displayPos = mouseWidget->display()->nativeWindow()->pointFromScreen(screenPos);
widget = mouseWidget->display()->containedWidget()->pick(displayPos);
widget = mouseWidget->display()->containedWidget()->pickFromScreenPos(screenPos);
}
else {
widget = mouseWidget->pick(mousePos);
}
}
else {
displayPos = mouseWidget->display()->nativeWindow()->pointFromScreen(screenPos);
widget = mouseWidget->display()->containedWidget()->pick(displayPos);
widget = mouseWidget->display()->containedWidget()->pickFromScreenPos(screenPos);
}
}
else {
@ -853,6 +850,16 @@ Window* Manager::getTopWindow()
return static_cast<Window*>(UI_FIRST_WIDGET(children()));
}
Window* Manager::getDesktopWindow()
{
for (auto child : children()) {
Window* window = static_cast<Window*>(child);
if (window->isDesktop())
return window;
}
return nullptr;
}
Window* Manager::getForegroundWindow()
{
for (auto child : children()) {

View File

@ -61,6 +61,7 @@ namespace ui {
void collectGarbage();
Window* getTopWindow();
Window* getDesktopWindow();
Window* getForegroundWindow();
Display* getForegroundDisplay();

View File

@ -1102,6 +1102,14 @@ bool Widget::paintEvent(Graphics* graphics,
Widget* parentWidget;
if (type() == kWindowWidget) {
parentWidget = display()->containedWidget();
// Draw the desktop window as the background, not the manager
// (as the manager contains all windows as children and will try
// to draw other foreground windows here).
if (get_multiple_displays() &&
parentWidget->type() == kManagerWidget) {
parentWidget = static_cast<Manager*>(parentWidget)->getDesktopWindow();
}
}
else {
parentWidget = parent();