OSDPretty: Consolidate current_screen code in OSDPretty
This commit is contained in:
parent
a22af31e6e
commit
8706a39559
@ -423,13 +423,7 @@ void OSDPretty::mouseMoveEvent(QMouseEvent* e) {
|
|||||||
QPoint new_pos = original_window_pos_ + delta;
|
QPoint new_pos = original_window_pos_ + delta;
|
||||||
|
|
||||||
// Keep it to the bounds of the desktop
|
// Keep it to the bounds of the desktop
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
QScreen* screen = current_screen(e->globalPos());
|
||||||
QScreen* screen = QGuiApplication::screenAt(e->globalPos());
|
|
||||||
#else
|
|
||||||
QScreen* screen = (window() && window()->windowHandle()
|
|
||||||
? window()->windowHandle()->screen()
|
|
||||||
: QGuiApplication::primaryScreen());
|
|
||||||
#endif
|
|
||||||
if (!screen) return;
|
if (!screen) return;
|
||||||
QRect geometry = screen->availableGeometry();
|
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))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0))
|
||||||
return QGuiApplication::screenAt(pos());
|
return QGuiApplication::screenAt(pos);
|
||||||
#else
|
#else
|
||||||
return (window() && window()->windowHandle()
|
return (window() && window()->windowHandle()
|
||||||
? window()->windowHandle()->screen()
|
? window()->windowHandle()->screen()
|
||||||
@ -462,6 +456,8 @@ QScreen* OSDPretty::current_screen() const {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QScreen* OSDPretty::current_screen() const { return current_screen(pos()); }
|
||||||
|
|
||||||
QPoint OSDPretty::current_pos() const {
|
QPoint OSDPretty::current_pos() const {
|
||||||
if (current_screen()) {
|
if (current_screen()) {
|
||||||
QRect geometry = current_screen()->availableGeometry();
|
QRect geometry = current_screen()->availableGeometry();
|
||||||
|
@ -77,6 +77,7 @@ class OSDPretty : public QWidget {
|
|||||||
// position and screen. Note that these return invalid values if the popup
|
// position and screen. Note that these return invalid values if the popup
|
||||||
// is hidden.
|
// is hidden.
|
||||||
QScreen* current_screen() const;
|
QScreen* current_screen() const;
|
||||||
|
QScreen* current_screen(const QPoint& pos) const;
|
||||||
QPoint current_pos() const;
|
QPoint current_pos() const;
|
||||||
|
|
||||||
// QWidget
|
// QWidget
|
||||||
|
Loading…
x
Reference in New Issue
Block a user