Let Wayland to use QGuiApplication::screenAt

Looks like it works correctly nowadays
This commit is contained in:
Ilya Fedin 2024-03-28 04:11:43 +04:00 committed by John Preston
parent fa8de8b199
commit 476d751251
2 changed files with 7 additions and 6 deletions

View file

@ -958,9 +958,7 @@ bool PopupMenu::prepareGeometryFor(const QPoint &p) {
bool PopupMenu::prepareGeometryFor(const QPoint &p, PopupMenu *parent) { bool PopupMenu::prepareGeometryFor(const QPoint &p, PopupMenu *parent) {
const auto usingScreenGeometry = !::Platform::IsWayland(); const auto usingScreenGeometry = !::Platform::IsWayland();
const auto screen = usingScreenGeometry const auto screen = QGuiApplication::screenAt(p);
? QGuiApplication::screenAt(p)
: nullptr;
if ((usingScreenGeometry && !screen) if ((usingScreenGeometry && !screen)
|| (!parent || (!parent
&& ::Platform::IsMac() && ::Platform::IsMac()
@ -1002,7 +1000,7 @@ bool PopupMenu::prepareGeometryFor(const QPoint &p, PopupMenu *parent) {
_additionalMenuPadding.left() - _st.shadow.extend.left(), _additionalMenuPadding.left() - _st.shadow.extend.left(),
0), 0),
_padding.top() - _topShift); _padding.top() - _topShift);
auto r = screen ? screen->availableGeometry() : QRect(); auto r = usingScreenGeometry ? screen->availableGeometry() : QRect();
const auto parentWidth = _parent ? _parent->inner().width() : 0; const auto parentWidth = _parent ? _parent->inner().width() : 0;
if (style::RightToLeft()) { if (style::RightToLeft()) {
const auto badLeft = !r.isNull() && w.x() - width() < r.x() - _margins.left(); const auto badLeft = !r.isNull() && w.x() - width() < r.x() - _margins.left();

View file

@ -77,7 +77,7 @@ 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 usingScreenGeometry = !::Platform::IsWayland(); const auto usingScreenGeometry = !::Platform::IsWayland();
const auto screen = usingScreenGeometry ? QGuiApplication::screenAt(m) : nullptr; const auto screen = QGuiApplication::screenAt(m);
if (usingScreenGeometry && !screen) { if (usingScreenGeometry && !screen) {
Hide(); Hide();
return; return;
@ -118,10 +118,13 @@ void Tooltip::popup(const QPoint &m, const QString &text, const style::Tooltip *
p.setX(m.x() - (s.width() / 2)); p.setX(m.x() - (s.width() / 2));
} }
// adjust tooltip position
if (screen) { if (screen) {
createWinId(); createWinId();
windowHandle()->setScreen(screen); windowHandle()->setScreen(screen);
}
// adjust tooltip position
if (usingScreenGeometry) {
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()));