[Xfce4-commits] [apps/xfdashboard] 01/01: Make tooltip to behave more like a tooltip in GTK+ that means hide tooltip when leaving the actor not when moving the pointer - that is too early.
noreply at xfce.org
noreply at xfce.org
Mon Jun 8 22:02:25 CEST 2015
This is an automated email from the git hooks/post-receive script.
nomad pushed a commit to branch master
in repository apps/xfdashboard.
commit 65d293b8b884c11a3a234b77d27e05695f64a96c
Author: Stephan Haller <nomad at froevel.de>
Date: Mon Jun 8 22:01:04 2015 +0200
Make tooltip to behave more like a tooltip in GTK+ that means hide tooltip when leaving the actor not when moving the pointer - that is too early.
---
xfdashboard/stage.c | 66 ++++++++++++++++++------------------------
xfdashboard/stage.h | 1 +
xfdashboard/tooltip-action.c | 15 ++++++++++
3 files changed, 44 insertions(+), 38 deletions(-)
diff --git a/xfdashboard/stage.c b/xfdashboard/stage.c
index 3c56c42..3bad33b 100644
--- a/xfdashboard/stage.c
+++ b/xfdashboard/stage.c
@@ -117,6 +117,7 @@ enum
SIGNAL_SEARCH_ENDED,
SIGNAL_SHOW_TOOLTIP,
+ SIGNAL_HIDE_TOOLTIP,
SIGNAL_LAST
};
@@ -245,28 +246,6 @@ static void _xfdashboard_stage_set_focus(XfdashboardStage *self)
}
}
-/* The pointer has been moved after a tooltip was shown */
-static gboolean _xfdashboard_stage_on_captured_event_after_tooltip(XfdashboardStage *self,
- ClutterEvent *inEvent,
- gpointer inUserData)
-{
- XfdashboardStagePrivate *priv;
-
- g_return_val_if_fail(XFDASHBOARD_IS_STAGE(self), CLUTTER_EVENT_PROPAGATE);
-
- priv=self->priv;
-
- /* Disconnect signal */
- g_signal_handlers_disconnect_by_func(self,
- G_CALLBACK(_xfdashboard_stage_on_captured_event_after_tooltip),
- NULL);
-
- /* Hide tooltip */
- clutter_actor_hide(priv->tooltip);
-
- return(CLUTTER_EVENT_PROPAGATE);
-}
-
/* Stage got signal to show a tooltip */
static void _xfdashboard_stage_show_tooltip(XfdashboardStage *self, ClutterAction *inAction)
{
@@ -286,13 +265,7 @@ static void _xfdashboard_stage_show_tooltip(XfdashboardStage *self, ClutterActio
priv=self->priv;
tooltipAction=XFDASHBOARD_TOOLTIP_ACTION(inAction);
- /* Disconnect any signal handler for hiding tooltip because
- * we are going to resetup tooltip. Hide tooltip while setup
- * to avoid flicker.
- */
- g_signal_handlers_disconnect_by_func(self,
- G_CALLBACK(_xfdashboard_stage_on_captured_event_after_tooltip),
- NULL);
+ /* Hide tooltip while setup to avoid flicker */
clutter_actor_hide(priv->tooltip);
/* Get tooltip text and update text in tooltip actor */
@@ -316,12 +289,19 @@ static void _xfdashboard_stage_show_tooltip(XfdashboardStage *self, ClutterActio
/* Show tooltip */
clutter_actor_show(priv->tooltip);
+}
+
+/* Stage got signal to hide tooltip */
+static void _xfdashboard_stage_hide_tooltip(XfdashboardStage *self, ClutterAction *inAction)
+{
+ XfdashboardStagePrivate *priv;
- /* Connect signal to hide tooltip on next movement of pointer */
- g_signal_connect(self,
- "captured-event",
- G_CALLBACK(_xfdashboard_stage_on_captured_event_after_tooltip),
- NULL);
+ g_return_if_fail(XFDASHBOARD_IS_STAGE(self));
+
+ priv=self->priv;
+
+ /* Hide tooltip */
+ clutter_actor_hide(priv->tooltip);
}
/* Notification timeout has been reached */
@@ -639,11 +619,8 @@ static void _xfdashboard_stage_on_application_suspend(XfdashboardStage *self, gp
xfdashboard_window_tracker_window_hide(priv->stageWindow);
}
- /* Hide tooltip and clean up */
+ /* Hide tooltip */
if(priv->tooltip) clutter_actor_hide(priv->tooltip);
- g_signal_handlers_disconnect_by_func(self,
- G_CALLBACK(_xfdashboard_stage_on_captured_event_after_tooltip),
- NULL);
}
/* The application will be resumed */
@@ -1495,6 +1472,7 @@ static void xfdashboard_stage_class_init(XfdashboardStageClass *klass)
/* Override functions */
klass->show_tooltip=_xfdashboard_stage_show_tooltip;
+ klass->hide_tooltip=_xfdashboard_stage_hide_tooltip;
actorClass->show=_xfdashboard_stage_show;
actorClass->event=_xfdashboard_stage_event;
@@ -1570,6 +1548,18 @@ static void xfdashboard_stage_class_init(XfdashboardStageClass *klass)
G_TYPE_NONE,
1,
CLUTTER_TYPE_ACTION);
+
+ XfdashboardStageSignals[SIGNAL_HIDE_TOOLTIP]=
+ g_signal_new("hide-tooltip",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET(XfdashboardStageClass, hide_tooltip),
+ NULL,
+ NULL,
+ g_cclosure_marshal_VOID__OBJECT,
+ G_TYPE_NONE,
+ 1,
+ CLUTTER_TYPE_ACTION);
}
/* Object initialization
diff --git a/xfdashboard/stage.h b/xfdashboard/stage.h
index fbdcf0a..4fdb1a1 100644
--- a/xfdashboard/stage.h
+++ b/xfdashboard/stage.h
@@ -63,6 +63,7 @@ struct _XfdashboardStageClass
void (*search_ended)(XfdashboardStage *self);
void (*show_tooltip)(XfdashboardStage *self, ClutterAction *inAction);
+ void (*hide_tooltip)(XfdashboardStage *self, ClutterAction *inAction);
};
/* Public API */
diff --git a/xfdashboard/tooltip-action.c b/xfdashboard/tooltip-action.c
index 5f683fa..310a3b3 100644
--- a/xfdashboard/tooltip-action.c
+++ b/xfdashboard/tooltip-action.c
@@ -54,6 +54,8 @@ struct _XfdashboardTooltipActionPrivate
guint motionID;
guint leaveID;
guint timeoutSourceID;
+
+ gboolean isVisible;
};
/* Properties */
@@ -114,6 +116,7 @@ static gboolean _xfdashboard_tooltip_action_on_timeout(gpointer inUserData)
/* Show tooltip */
g_signal_emit_by_name(stage, "show-tooltip", self, NULL);
+ priv->isVisible=TRUE;
}
/* Remove source */
@@ -136,6 +139,9 @@ static gboolean _xfdashboard_tooltip_action_on_motion_event(XfdashboardTooltipAc
actor=CLUTTER_ACTOR(inUserData);
tooltipTimeout=0;
+ /* Do nothing if tooltip is already visible */
+ if(priv->isVisible) return(CLUTTER_EVENT_PROPAGATE);
+
/* Remove any timeout source we have added for this actor */
if(priv->timeoutSourceID!=0)
{
@@ -166,6 +172,7 @@ static gboolean _xfdashboard_tooltip_action_on_leave_event(XfdashboardTooltipAct
{
XfdashboardTooltipActionPrivate *priv;
ClutterActor *actor;
+ ClutterActor *stage;
g_return_val_if_fail(XFDASHBOARD_IS_TOOLTIP_ACTION(self), CLUTTER_EVENT_PROPAGATE);
g_return_val_if_fail(CLUTTER_IS_ACTOR(inUserData), CLUTTER_EVENT_PROPAGATE);
@@ -186,6 +193,14 @@ static gboolean _xfdashboard_tooltip_action_on_leave_event(XfdashboardTooltipAct
_xfdashboard_tooltip_last_event_actor=NULL;
}
+ /* Hide tooltip now */
+ stage=clutter_actor_get_stage(actor);
+ if(stage && XFDASHBOARD_IS_STAGE(stage))
+ {
+ g_signal_emit_by_name(stage, "hide-tooltip", self, NULL);
+ priv->isVisible=FALSE;
+ }
+
return(CLUTTER_EVENT_PROPAGATE);
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list