From 0d7fea31119ee2d37986a8b7620bbb5182874383 Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 20 Apr 2021 17:55:49 -0300 Subject: [PATCH] Fix several problems w/multiple screens * Limit dialogs to the current screen workarea correctly * Fixed several issues on macOS --- laf | 2 +- src/app/ui/color_button.cpp | 4 ++-- src/ui/combobox.cpp | 2 +- src/ui/fit_bounds.cpp | 4 +++- src/ui/menu.cpp | 6 +++--- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/laf b/laf index 9a93eeb45..5325bc040 160000 --- a/laf +++ b/laf @@ -1 +1 @@ -Subproject commit 9a93eeb4557a37232e5f062dfc9effa797ea2e2b +Subproject commit 5325bc040d1a99dedfbe258f05a01064261c89ac diff --git a/src/app/ui/color_button.cpp b/src/app/ui/color_button.cpp index 6f9f78e9d..40579b318 100644 --- a/src/app/ui/color_button.cpp +++ b/src/app/ui/color_button.cpp @@ -355,9 +355,9 @@ void ColorButton::openPopup(const bool forcePinned) winBounds.x = base::clamp(bounds.x, workarea.x, workarea.x2()-winBounds.w); if (bounds.y2()+winBounds.h <= workarea.y2()) - winBounds.y = std::max(0, bounds.y2()); + winBounds.y = std::max(workarea.y, bounds.y2()); else - winBounds.y = std::max(0, bounds.y-winBounds.h); + winBounds.y = std::max(workarea.y, bounds.y-winBounds.h); } else if (forcePinned) { winBounds = convertBounds(m_hiddenPopupBounds); diff --git a/src/ui/combobox.cpp b/src/ui/combobox.cpp index b0d3af5b3..d1a556f52 100644 --- a/src/ui/combobox.cpp +++ b/src/ui/combobox.cpp @@ -716,7 +716,7 @@ void ComboBox::updateListBoxPos() [this](const gfx::Rect& workarea, gfx::Rect& bounds, std::function getWidgetBounds) { - if (bounds.y2() > workarea.h) + if (bounds.y2() > workarea.y2()) bounds.offset(0, -(bounds.h + getWidgetBounds(m_entry).h)); }); } diff --git a/src/ui/fit_bounds.cpp b/src/ui/fit_bounds.cpp index e4a6f9c9e..25262e063 100644 --- a/src/ui/fit_bounds.cpp +++ b/src/ui/fit_bounds.cpp @@ -111,7 +111,9 @@ void fit_bounds(Display* parentDisplay, if (get_multiple_displays() && window->shouldCreateNativeWindow()) { const os::Window* nativeWindow = parentDisplay->nativeWindow(); - const gfx::Rect workarea = get_workarea_region().bounds(); + // Limit to the current screen workarea (instead of using all the + // available workarea between all monitors, get_workarea_region()) + const gfx::Rect workarea = nativeWindow->screen()->workarea(); const int scale = nativeWindow->scale(); // Screen frame bounds diff --git a/src/ui/menu.cpp b/src/ui/menu.cpp index e13ff97eb..05f1d4c79 100644 --- a/src/ui/menu.cpp +++ b/src/ui/menu.cpp @@ -840,9 +840,9 @@ bool MenuItem::onProcessMessage(Message* msg) Rect r1(0, 0, pos.w, pos.h); Rect r2(0, 0, pos.w, pos.h); - r1.x = x_left = base::clamp(x_left, 0, workarea.w-pos.w); - r2.x = x_right = base::clamp(x_right, 0, workarea.w-pos.w); - r1.y = r2.y = y = base::clamp(y, 0, workarea.h-pos.h); + r1.x = x_left = base::clamp(x_left, workarea.x, workarea.w-pos.w); + r2.x = x_right = base::clamp(x_right, workarea.x, workarea.w-pos.w); + r1.y = r2.y = y = base::clamp(y, workarea.y, workarea.h-pos.h); // Calculate both intersections const gfx::Rect s1 = r1.createIntersection(parentPos);