OSDPretty: Consolidate current_screen code in OSDPretty

This commit is contained in:
Jim Broadus 2020-03-29 10:58:47 -07:00 committed by John Maguire
parent a22af31e6e
commit 8706a39559
2 changed files with 6 additions and 9 deletions

View File

@ -423,13 +423,7 @@ void OSDPretty::mouseMoveEvent(QMouseEvent* e) {
QPoint new_pos = original_window_pos_ + delta;
// Keep it to the bounds of the desktop
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
QScreen* screen = QGuiApplication::screenAt(e->globalPos());
#else
QScreen* screen = (window() && window()->windowHandle()
? window()->windowHandle()->screen()
: QGuiApplication::primaryScreen());
#endif
QScreen* screen = current_screen(e->globalPos());
if (!screen) return;
QRect geometry = screen->availableGeometry();
@ -452,9 +446,9 @@ void OSDPretty::mouseMoveEvent(QMouseEvent* e) {
}
}
QScreen* OSDPretty::current_screen() const {
QScreen* OSDPretty::current_screen(const QPoint& pos) const {
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
return QGuiApplication::screenAt(pos());
return QGuiApplication::screenAt(pos);
#else
return (window() && window()->windowHandle()
? window()->windowHandle()->screen()
@ -462,6 +456,8 @@ QScreen* OSDPretty::current_screen() const {
#endif
}
QScreen* OSDPretty::current_screen() const { return current_screen(pos()); }
QPoint OSDPretty::current_pos() const {
if (current_screen()) {
QRect geometry = current_screen()->availableGeometry();

View File

@ -77,6 +77,7 @@ class OSDPretty : public QWidget {
// position and screen. Note that these return invalid values if the popup
// is hidden.
QScreen* current_screen() const;
QScreen* current_screen(const QPoint& pos) const;
QPoint current_pos() const;
// QWidget