summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Gräßlin <[email protected]>2016-10-19 15:15:28 +0200
committerMartin Gräßlin <[email protected]>2016-10-19 15:22:28 +0200
commit25ffff6b4a1da1e4f32876c7d5c63b0693a3aada (patch)
treee901934cb2a547eef95992b6de7e3ee3819c37ad
parentf78ef2c89ff87742c84a05f62e5c3e9df5489377 (diff)
Pass transient parent window to KToolTipWindow
Summary: This fixes tooltips on Wayland. We need the relationship to the transient parent window - tooltips are positioned relative to their parent window. Also on X11 this is an important information which was completely lacking. Before the change the tooltips got randomly positioned by the Wayland compositor as it thought that it is a new toplevel window. With the change the tooltip gets shown where it is supposed to be shown. Test Plan: Run systemsettings with --platform wayland and xcb Reviewers: #plasma Subscribers: plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D3112
-rw-r--r--app/ToolTips/ktooltip.cpp15
-rw-r--r--app/ToolTips/ktooltip.h5
-rw-r--r--app/ToolTips/tooltipmanager.cpp2
3 files changed, 13 insertions, 9 deletions
diff --git a/app/ToolTips/ktooltip.cpp b/app/ToolTips/ktooltip.cpp
index 9911410..34561f1 100644
--- a/app/ToolTips/ktooltip.cpp
+++ b/app/ToolTips/ktooltip.cpp
@@ -21,6 +21,7 @@
#include "ktooltipwindow_p.h"
#include <QLabel>
#include <QPoint>
+#include <QWindow>
#include <QWidget>
class KToolTipManager
@@ -30,7 +31,7 @@ public:
static KToolTipManager* instance();
- void showTip(const QPoint& pos, QWidget* content);
+ void showTip(const QPoint& pos, QWidget* content, QWindow *transientParent);
void hideTip();
private:
@@ -62,12 +63,14 @@ KToolTipManager* KToolTipManager::instance()
return s_instance;
}
-void KToolTipManager::showTip(const QPoint& pos, QWidget* content)
+void KToolTipManager::showTip(const QPoint& pos, QWidget* content, QWindow *transientParent)
{
hideTip();
Q_ASSERT(m_window == 0);
m_window = new KToolTipWindow(content);
m_window->move(pos);
+ m_window->createWinId();
+ m_window->windowHandle()->setTransientParent(transientParent);
m_window->show();
}
@@ -82,16 +85,16 @@ void KToolTipManager::hideTip()
namespace KToolTip
{
- void showText(const QPoint& pos, const QString& text)
+ void showText(const QPoint& pos, const QString& text, QWindow *transientParent)
{
QLabel* label = new QLabel(text);
label->setForegroundRole(QPalette::ToolTipText);
- showTip(pos, label);
+ showTip(pos, label, transientParent);
}
- void showTip(const QPoint& pos, QWidget* content)
+ void showTip(const QPoint& pos, QWidget* content, QWindow *transientParent)
{
- KToolTipManager::instance()->showTip(pos, content);
+ KToolTipManager::instance()->showTip(pos, content, transientParent);
}
void hideTip()
diff --git a/app/ToolTips/ktooltip.h b/app/ToolTips/ktooltip.h
index bd539b8..82ed45e 100644
--- a/app/ToolTips/ktooltip.h
+++ b/app/ToolTips/ktooltip.h
@@ -23,13 +23,14 @@
class QPoint;
class QString;
class QWidget;
+class QWindow;
/**
* Allows to show tooltips having a widget as content.
*/
namespace KToolTip
{
- void showText(const QPoint& pos, const QString& text);
+ void showText(const QPoint& pos, const QString& text, QWindow *transientParent);
/**
* Shows the tip @p content at the global position indicated by @p pos.
@@ -39,7 +40,7 @@ namespace KToolTip
*
* The tip is shown immediately when this function is called.
*/
- void showTip(const QPoint& pos, QWidget* content);
+ void showTip(const QPoint& pos, QWidget* content, QWindow *transientParent);
void hideTip();
}
diff --git a/app/ToolTips/tooltipmanager.cpp b/app/ToolTips/tooltipmanager.cpp
index 1f7e555..f2f9943 100644
--- a/app/ToolTips/tooltipmanager.cpp
+++ b/app/ToolTips/tooltipmanager.cpp
@@ -170,7 +170,7 @@ void ToolTipManager::showToolTip( QModelIndex menuItem )
}
// the ownership of tip is transferred to KToolTip
- KToolTip::showTip(QPoint(x, y), tip);
+ KToolTip::showTip(QPoint(x, y), tip, d->view->nativeParentWidget()->windowHandle());
}
QWidget * ToolTipManager::createTipContent( QModelIndex item )