Ensure that floating windows are not positioned off-screen when they are shown

At points when a Rect is to be used to position a floating widget,
test to see if it overlaps any of the system's screens.

If it does not, adjust the Rect to within the closest screen edges.
This commit is contained in:
Alistair Baxter
2021-12-22 13:49:31 +00:00
committed by Sergio Martins
parent c0c8399bd7
commit f1e19ec59c
4 changed files with 56 additions and 2 deletions

View File

@@ -513,6 +513,7 @@ FloatingWindow *DockWidgetBase::Private::morphIntoFloatingWindow()
auto frame = Config::self().frameworkWidgetFactory()->createFrame();
frame->addWidget(q);
geo.setSize(geo.size().boundedTo(frame->maxSizeHint()));
FloatingWindow::ensureRectIsOnScreen(geo);
auto floatingWindow =
Config::self().frameworkWidgetFactory()->createFloatingWindow(frame, nullptr, geo);
floatingWindow->show();