summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-12-14 14:10:11 +0000
committerCaolán McNamara <caolanm@redhat.com>2015-12-14 14:36:09 +0000
commitc96eeb5bf2ef428e7d147258d69825ff97acb226 (patch)
tree4471b99be4b5adedc2e8901eb35159397ce65b25
parent01ef12d173fb2c54a49186c8eb4fa40288b82945 (diff)
Resolves: rhbz#1289394 gtk3: implement tooltips natively
side step the whole pile of misery by using native gtk tooltips also gets transparency and native themeing too by default Change-Id: I59552661cd9dc18a563341885bc40fcdadc5264f
-rw-r--r--vcl/inc/salframe.hxx7
-rw-r--r--vcl/inc/unx/gtk/gtkframe.hxx6
-rw-r--r--vcl/source/app/help.cxx7
-rw-r--r--vcl/unx/gtk3/gtk3gtkframe.cxx28
-rw-r--r--vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx3
5 files changed, 48 insertions, 3 deletions
diff --git a/vcl/inc/salframe.hxx b/vcl/inc/salframe.hxx
index 7638fd91ade2..f9f2d482fd5d 100644
--- a/vcl/inc/salframe.hxx
+++ b/vcl/inc/salframe.hxx
@@ -243,6 +243,13 @@ public:
{
}
+ // return true to indicate tooltips are shown natively, false otherwise
+ virtual bool ShowTooltip(const OUString& /*rHelpText*/, const Rectangle& /*rHelpArea*/ )
+ {
+ return false;
+ }
+
+
// Callbacks (indepent part in vcl/source/window/winproc.cxx)
// for default message handling return 0
void SetCallback( vcl::Window* pWindow, SALFRAMEPROC pProc );
diff --git a/vcl/inc/unx/gtk/gtkframe.hxx b/vcl/inc/unx/gtk/gtkframe.hxx
index dc5cd191d5e0..ba6ededd36bd 100644
--- a/vcl/inc/unx/gtk/gtkframe.hxx
+++ b/vcl/inc/unx/gtk/gtkframe.hxx
@@ -199,6 +199,8 @@ class GtkSalFrame : public SalFrame, public X11WindowProvider
Rectangle m_aRestorePosSize;
#if GTK_CHECK_VERSION(3,0,0)
+ OUString m_aTooltip;
+ Rectangle m_aHelpArea;
guint32 m_nLastScrollEventTime;
long m_nWidthRequest;
long m_nHeightRequest;
@@ -231,6 +233,9 @@ class GtkSalFrame : public SalFrame, public X11WindowProvider
#if GTK_CHECK_VERSION(3,0,0)
static gboolean signalDraw( GtkWidget*, cairo_t *cr, gpointer );
static void sizeAllocated(GtkWidget*, GdkRectangle *pAllocation, gpointer frame);
+ static gboolean signalTooltipQuery(GtkWidget*, gint x, gint y,
+ gboolean keyboard_mode, GtkTooltip *tooltip,
+ gpointer frame);
#if GTK_CHECK_VERSION(3,14,0)
static void gestureSwipe(GtkGestureSwipe* gesture, gdouble velocity_x, gdouble velocity_y, gpointer frame);
static void gestureLongPress(GtkGestureLongPress* gesture, gpointer frame);
@@ -449,6 +454,7 @@ public:
#if GTK_CHECK_VERSION(3,0,0)
virtual void SetModal(bool bModal) override;
+ virtual bool ShowTooltip(const OUString& rHelpText, const Rectangle& rHelpArea) override;
#endif
static GtkSalFrame *getFromWindow( GtkWindow *pWindow );
diff --git a/vcl/source/app/help.cxx b/vcl/source/app/help.cxx
index 51a9e31ff2f3..19570ceb5967 100644
--- a/vcl/source/app/help.cxx
+++ b/vcl/source/app/help.cxx
@@ -31,6 +31,7 @@
#include "vcl/settings.hxx"
#include "helpwin.hxx"
+#include "salframe.hxx"
#include "svdata.hxx"
#define HELPWINSTYLE_QUICK 0
@@ -462,6 +463,12 @@ void ImplShowHelpWindow( vcl::Window* pParent, sal_uInt16 nHelpWinStyle, QuickHe
const OUString& rHelpText, const OUString& rStatusText,
const Point& rScreenPos, const Rectangle& rHelpArea )
{
+ if (pParent->ImplGetFrame()->ShowTooltip(rHelpText, rHelpArea))
+ {
+ //tooltips are handled natively, return early
+ return;
+ }
+
ImplSVData* pSVData = ImplGetSVData();
if (rHelpText.isEmpty() && !pSVData->maHelpData.mbRequestingHelp)
diff --git a/vcl/unx/gtk3/gtk3gtkframe.cxx b/vcl/unx/gtk3/gtk3gtkframe.cxx
index 6b00f7bdbbc8..981fccffc063 100644
--- a/vcl/unx/gtk3/gtk3gtkframe.cxx
+++ b/vcl/unx/gtk3/gtk3gtkframe.cxx
@@ -972,6 +972,8 @@ void GtkSalFrame::InitCommon()
// connect signals
g_signal_connect( G_OBJECT(m_pWindow), "style-set", G_CALLBACK(signalStyleSet), this );
+ gtk_widget_set_has_tooltip(pEventWidget, true);
+ m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "query-tooltip", G_CALLBACK(signalTooltipQuery), this ));
m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "button-press-event", G_CALLBACK(signalButton), this ));
m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "motion-notify-event", G_CALLBACK(signalMotion), this ));
m_aMouseSignalIds.push_back(g_signal_connect( G_OBJECT(pEventWidget), "button-release-event", G_CALLBACK(signalButton), this ));
@@ -2351,6 +2353,32 @@ void GtkSalFrame::SetModal(bool bModal)
gtk_window_set_modal(GTK_WINDOW(m_pWindow), bModal);
}
+gboolean GtkSalFrame::signalTooltipQuery(GtkWidget*, gint /*x*/, gint /*y*/,
+ gboolean /*keyboard_mode*/, GtkTooltip *tooltip,
+ gpointer frame)
+{
+ GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
+ if (pThis->m_aTooltip.isEmpty())
+ return false;
+ gtk_tooltip_set_text(tooltip,
+ OUStringToOString(pThis->m_aTooltip, RTL_TEXTENCODING_UTF8).getStr());
+ GdkRectangle aHelpArea;
+ aHelpArea.x = pThis->m_aHelpArea.Left();
+ aHelpArea.y = pThis->m_aHelpArea.Top();
+ aHelpArea.width = pThis->m_aHelpArea.GetWidth();
+ aHelpArea.height = pThis->m_aHelpArea.GetHeight();
+ gtk_tooltip_set_tip_area(tooltip, &aHelpArea);
+ return true;
+}
+
+bool GtkSalFrame::ShowTooltip(const OUString& rHelpText, const Rectangle& rHelpArea)
+{
+ m_aTooltip = rHelpText;
+ m_aHelpArea = rHelpArea;
+ gtk_widget_trigger_tooltip_query(getMouseEventWidget());
+ return true;
+}
+
gboolean GtkSalFrame::signalButton( GtkWidget*, GdkEventButton* pEvent, gpointer frame )
{
GtkSalFrame* pThis = static_cast<GtkSalFrame*>(frame);
diff --git a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
index 9d5266fec8d1..b8740b5366a6 100644
--- a/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gtk3salnativewidgets-gtk.cxx
@@ -1812,9 +1812,6 @@ bool GtkSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nP
{
switch(nType)
{
- case CTRL_TOOLTIP:
- return false; //shaped, punt that problem for now
-
case CTRL_PUSHBUTTON:
case CTRL_RADIOBUTTON:
case CTRL_CHECKBOX: