aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2020-07-08 19:18:47 +1000
committerNeil <nyamatongwe@gmail.com>2020-07-08 19:18:47 +1000
commit16c28786ecb1209d88f7d2ea22926190ee95d1d6 (patch)
tree5e54f6c85de3ec07c472d8475943defa23b3c247
parent629eae1e428756f16ce486df78a8cab939438bde (diff)
downloadscintilla-mirror-16c28786ecb1209d88f7d2ea22926190ee95d1d6.tar.gz
Backport: Fix deprecated QDesktopWidget::availableGeometry call to use currently supported
QScreen::availableGeometry call when available. Backport of changeset 8392:b52e56eefb78.
-rw-r--r--qt/ScintillaEditBase/PlatQt.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp
index b56ae85e0..272a11f91 100644
--- a/qt/ScintillaEditBase/PlatQt.cpp
+++ b/qt/ScintillaEditBase/PlatQt.cpp
@@ -17,6 +17,9 @@
#include "FontQuality.h"
#include <QApplication>
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+#include <QScreen>
+#endif
#include <QFont>
#include <QColor>
#include <QRect>
@@ -609,10 +612,23 @@ Surface *Surface::Allocate(int)
//----------------------------------------------------------------------
namespace {
+
QWidget *window(WindowID wid) noexcept
{
return static_cast<QWidget *>(wid);
}
+
+QRect ScreenRectangleForPoint(QPoint posGlobal)
+{
+#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
+ const QScreen *screen = QGuiApplication::screenAt(posGlobal);
+ return screen->availableGeometry();
+#else
+ const QDesktopWidget *desktop = QApplication::desktop();
+ return desktop->availableGeometry(posGlobal);
+#endif
+}
+
}
Window::~Window() {}
@@ -643,8 +659,7 @@ void Window::SetPositionRelative(PRectangle rc, const Window *relativeTo)
ox += rc.left;
oy += rc.top;
- QDesktopWidget *desktop = QApplication::desktop();
- QRect rectDesk = desktop->availableGeometry(QPoint(ox, oy));
+ const QRect rectDesk = ScreenRectangleForPoint(QPoint(ox, oy));
/* do some corrections to fit into screen */
int sizex = rc.right - rc.left;
int sizey = rc.bottom - rc.top;
@@ -722,13 +737,11 @@ void Window::SetCursor(Cursor curs)
window coordinates */
PRectangle Window::GetMonitorRect(Point pt)
{
- QPoint originGlobal = window(wid)->mapToGlobal(QPoint(0, 0));
- QPoint posGlobal = window(wid)->mapToGlobal(QPoint(pt.x, pt.y));
- QDesktopWidget *desktop = QApplication::desktop();
- QRect rectScreen = desktop->availableGeometry(posGlobal);
+ const QPoint posGlobal = window(wid)->mapToGlobal(QPoint(pt.x, pt.y));
+ const QPoint originGlobal = window(wid)->mapToGlobal(QPoint(0, 0));
+ QRect rectScreen = ScreenRectangleForPoint(posGlobal);
rectScreen.translate(-originGlobal.x(), -originGlobal.y());
- return PRectangle(rectScreen.left(), rectScreen.top(),
- rectScreen.right(), rectScreen.bottom());
+ return PRectFromQRect(rectScreen);
}
//----------------------------------------------------------------------