Commit 491f5a20 authored by Victor Dodon's avatar Victor Dodon Committed by Maximilian Schiller
Browse files

Fix computing screen geometry on multiple HiDPI monitors

When using setups with multiple HiDPI displays, Yakuake did not show up
on all the other monitors except for the top-left one, due to the fact
that the screen geometry is not properly computed, so
getDesktopGeometry() returns QRect(0,0 0x0). The QScreen::geometry()
method appears to behave "weird" on HiDPI displays: the top left corner
is given in physical pixels, while the width,height are in device
independent pixels. For example, if using two 4K displays, one on top
and one on bottom, the QScreen::geometry() will return
QRect(0,2160 1920x1080) for the bottom one.
parent aecc1961
......@@ -1480,15 +1480,28 @@ void MainWindow::setFullScreen(bool state)
int MainWindow::getScreen()
{
if (!Settings::screen())
return QApplication::desktop()->screenNumber(QCursor::pos());
else
if (!Settings::screen() || Settings::screen() > QGuiApplication::screens().length()) {
// Right after unplugging an external monitor and the Yakuake window was on
// that monitor, QGuiApplication::screenAt() can return nullptr so we fallback on
// the first monitor.
QScreen *screen = QGuiApplication::screenAt(QCursor::pos());
return screen ? QGuiApplication::screens().indexOf(screen) : 0;
} else {
return Settings::screen() - 1;
}
}
QRect MainWindow::getScreenGeometry()
{
QScreen *screen = QGuiApplication::screens().at(getScreen());
QRect screenGeometry = screen->geometry();
screenGeometry.moveTo(screenGeometry.topLeft() / screen->devicePixelRatio());
return screenGeometry;
}
QRect MainWindow::getDesktopGeometry()
{
QRect screenGeometry = QApplication::desktop()->screenGeometry(getScreen());
QRect screenGeometry = getScreenGeometry();
QAction* action = actionCollection()->action(QStringLiteral("view-full-screen"));
......
......@@ -175,6 +175,7 @@ class MainWindow : public KMainWindow
void updateMask();
int getScreen();
QRect getScreenGeometry();
QRect getDesktopGeometry();
// get a better value from plasmashell through dbus in wayland case
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment