Don't involve screen geometry for tooltip on Wayland
This commit is contained in:
parent
87c95b8fa7
commit
af680714ff
1 changed files with 18 additions and 14 deletions
|
|
@ -10,6 +10,7 @@
|
||||||
#include "ui/platform/ui_platform_utility.h"
|
#include "ui/platform/ui_platform_utility.h"
|
||||||
#include "base/invoke_queued.h"
|
#include "base/invoke_queued.h"
|
||||||
#include "styles/style_widgets.h"
|
#include "styles/style_widgets.h"
|
||||||
|
#include "base/platform/base_platform_info.h"
|
||||||
|
|
||||||
#include <QtGui/QScreen>
|
#include <QtGui/QScreen>
|
||||||
#include <QtWidgets/QApplication>
|
#include <QtWidgets/QApplication>
|
||||||
|
|
@ -72,8 +73,9 @@ Tooltip::~Tooltip() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tooltip::popup(const QPoint &m, const QString &text, const style::Tooltip *st) {
|
void Tooltip::popup(const QPoint &m, const QString &text, const style::Tooltip *st) {
|
||||||
const auto screen = QGuiApplication::screenAt(m);
|
const auto usingScreenGeometry = !::Platform::IsWayland();
|
||||||
if (!screen) {
|
const auto screen = usingScreenGeometry ? QGuiApplication::screenAt(m) : nullptr;
|
||||||
|
if (usingScreenGeometry && !screen) {
|
||||||
Hide();
|
Hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -114,6 +116,7 @@ void Tooltip::popup(const QPoint &m, const QString &text, const style::Tooltip *
|
||||||
}
|
}
|
||||||
|
|
||||||
// adjust tooltip position
|
// adjust tooltip position
|
||||||
|
if (screen) {
|
||||||
const auto r = screen->availableGeometry();
|
const auto r = screen->availableGeometry();
|
||||||
if (r.x() + r.width() - _st->skip < p.x() + s.width() && p.x() + s.width() > m.x()) {
|
if (r.x() + r.width() - _st->skip < p.x() + s.width() && p.x() + s.width() > m.x()) {
|
||||||
p.setX(qMax(r.x() + r.width() - int32(_st->skip) - s.width(), m.x() - s.width()));
|
p.setX(qMax(r.x() + r.width() - int32(_st->skip) - s.width(), m.x() - s.width()));
|
||||||
|
|
@ -127,6 +130,7 @@ void Tooltip::popup(const QPoint &m, const QString &text, const style::Tooltip *
|
||||||
if (r.y() > p.x()) {
|
if (r.y() > p.x()) {
|
||||||
p.setY(qMin(m.y() + _st->shift.y(), r.y() + r.height() - s.height()));
|
p.setY(qMin(m.y() + _st->shift.y(), r.y() + r.height() - s.height()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setGeometry(QRect(p, s));
|
setGeometry(QRect(p, s));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue