summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r--src/widgets/kernel/qtooltip.cpp9
-rw-r--r--src/widgets/kernel/qwidget.cpp21
-rw-r--r--src/widgets/kernel/qwidget_p.h2
3 files changed, 32 insertions, 0 deletions
diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp
index 2e6575c163..9d8b0062f5 100644
--- a/src/widgets/kernel/qtooltip.cpp
+++ b/src/widgets/kernel/qtooltip.cpp
@@ -41,6 +41,7 @@
#endif
#include <QtWidgets/private/qtwidgetsglobal_p.h>
+#include <QtWidgets/private/qlabel_p.h>
#include <qapplication.h>
#include <qdesktopwidget.h>
@@ -127,6 +128,7 @@ public:
~QTipLabel();
static QTipLabel *instance;
+ void adjustTooltipScreen(const QPoint &pos);
void updateSize(const QPoint &pos);
bool eventFilter(QObject *, QEvent *) override;
@@ -222,6 +224,12 @@ void QTipLabel::reuseTip(const QString &text, int msecDisplayTime, const QPoint
void QTipLabel::updateSize(const QPoint &pos)
{
+#ifndef Q_OS_WINRT
+ // ### The code below does not always work well on WinRT
+ // (e.g COIN fails an auto test - tst_QToolTip::qtbug64550_stylesheet - QTBUG-72652)
+ d_func()->setScreenForPoint(pos);
+#endif
+ // Ensure that we get correct sizeHints by placing this window on the right screen.
QFontMetrics fm(font());
QSize extra(1, 0);
// Make it look good with the default ToolTip font on Mac, which has a small descent.
@@ -229,6 +237,7 @@ void QTipLabel::updateSize(const QPoint &pos)
++extra.rheight();
QSize sh = sizeHint();
if (wordWrap()) {
+ // ### When the above WinRT code is fixed, windowhandle should be used to find the screen.
QScreen *screen = QGuiApplication::screenAt(pos);
if (!screen)
screen = QGuiApplication::primaryScreen();
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index bcfae46155..2a94b25ec9 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -2571,6 +2571,27 @@ void QWidgetPrivate::createWinId()
}
}
+/*!
+\internal
+Ensures that the widget is set on the screen point is on. This is handy getting a correct
+size hint before a resize in e.g QMenu and QToolTip
+*/
+
+void QWidgetPrivate::setScreenForPoint(const QPoint &pos)
+{
+ Q_Q(QWidget);
+ if (!q->isWindow())
+ return;
+ // Find the screen for pos and make the widget undertand it is on that screen.
+ const QScreen *currentScreen = windowHandle() ? windowHandle()->screen() : nullptr;
+ QScreen *actualScreen = QGuiApplication::screenAt(pos);
+ if (actualScreen && currentScreen != actualScreen) {
+ if (!windowHandle()) // Try to create a window handle if not created.
+ createWinId();
+ if (windowHandle())
+ windowHandle()->setScreen(actualScreen);
+ }
+}
/*!
\internal
diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h
index be45c4c868..6f1ce67c4c 100644
--- a/src/widgets/kernel/qwidget_p.h
+++ b/src/widgets/kernel/qwidget_p.h
@@ -355,6 +355,8 @@ public:
void createRecursively();
void createWinId();
+ void setScreenForPoint(const QPoint &pos);
+
void createTLExtra();
void createExtra();
void deleteExtra();