[Xfce4-commits] [apps/xfdashboard] 01/02: Differ between "clicked" which is usually associated to a left-click and a "click" with any other button at XfdashboardClickAction.
noreply at xfce.org
noreply at xfce.org
Tue Jun 21 09:58:56 CEST 2016
This is an automated email from the git hooks/post-receive script.
nomad pushed a commit to branch master
in repository apps/xfdashboard.
commit db21a8ddc3a449ff968d3743029f94ec912e3720
Author: Stephan Haller <nomad at froevel.de>
Date: Tue Jun 21 09:46:39 2016 +0200
Differ between "clicked" which is usually associated to a left-click and a "click" with any other button at XfdashboardClickAction.
Therefore the signals "clicked" and "long-press" at XfdashboardClickAction are only emitted if the click was done with the left button. To get clicks with any other the new signals "button-clicked" and "long-button-press" are emitted (also for left-clicks) which tranfer also the button which was clicked.
This changes the default behaviour of XfdashboardClickAction but should interfer with the current behaviour as left-clicks were assumed so far.
---
libxfdashboard/click-action.c | 74 +++++++++++++++++++++++++++++++++++++------
libxfdashboard/click-action.h | 2 ++
libxfdashboard/marshal.list | 2 ++
3 files changed, 69 insertions(+), 9 deletions(-)
diff --git a/libxfdashboard/click-action.c b/libxfdashboard/click-action.c
index 1b813e5..3804d24 100644
--- a/libxfdashboard/click-action.c
+++ b/libxfdashboard/click-action.c
@@ -99,7 +99,9 @@ GParamSpec* XfdashboardClickActionProperties[PROP_LAST]={ 0, };
enum
{
SIGNAL_CLICKED,
+ SIGNAL_BUTTON_CLICKED,
SIGNAL_LONG_PRESS,
+ SIGNAL_LONG_BUTTON_PRESS,
SIGNAL_LAST
};
@@ -177,9 +179,17 @@ static gboolean _xfdashboard_click_action_emit_long_press(gpointer inUserData)
/* Reset variables */
priv->longPressID=0;
- /* Emit signal */
+ /* Get target actor of long-press used in emitting signal */
actor=clutter_actor_meta_get_actor(CLUTTER_ACTOR_META(inUserData));
- g_signal_emit(self, XfdashboardClickActionSignals[SIGNAL_LONG_PRESS], 0, actor, CLUTTER_LONG_PRESS_ACTIVATE, &result);
+
+ /* Emit 'long-press' signal only when left-button was pressed for perform click */
+ if(priv->pressButton==1)
+ {
+ g_signal_emit(self, XfdashboardClickActionSignals[SIGNAL_LONG_PRESS], 0, actor, CLUTTER_LONG_PRESS_ACTIVATE, &result);
+ }
+
+ /* Always emit 'long-button-press' signal */
+ g_signal_emit(self, XfdashboardClickActionSignals[SIGNAL_LONG_BUTTON_PRESS], 0, actor, CLUTTER_LONG_PRESS_ACTIVATE, priv->pressButton, &result);
/* Disconnect signal handlers */
if(priv->captureID!=0)
@@ -218,15 +228,20 @@ static void _xfdashboard_click_action_query_long_press(XfdashboardClickAction *s
}
else timeout=priv->longPressDuration;
- /* Emit signal to determine if long-press should be supported */
+ /* Emit signal to determine if long-press should be supported.
+ * First we try to normal use-case of long press of left button. If this is
+ * not supported (returning FALSE) then re-try with the specific button pressed.
+ */
actor=clutter_actor_meta_get_actor(CLUTTER_ACTOR_META(self));
g_signal_emit(self, XfdashboardClickActionSignals[SIGNAL_LONG_PRESS], 0, actor, CLUTTER_LONG_PRESS_QUERY, &result);
+ if(!result) g_signal_emit(self, XfdashboardClickActionSignals[SIGNAL_LONG_BUTTON_PRESS], 0, actor, CLUTTER_LONG_PRESS_QUERY, priv->pressButton, &result);
if(result)
{
- priv->longPressID=clutter_threads_add_timeout(timeout,
- _xfdashboard_click_action_emit_long_press,
- self);
+ priv->longPressID=
+ clutter_threads_add_timeout(timeout,
+ _xfdashboard_click_action_emit_long_press,
+ self);
}
}
@@ -249,9 +264,17 @@ static void _xfdashboard_click_action_cancel_long_press(XfdashboardClickAction *
g_source_remove(priv->longPressID);
priv->longPressID=0;
- /* Emit signal */
+ /* Get target actor of long-press used in emitting signal */
actor=clutter_actor_meta_get_actor(CLUTTER_ACTOR_META(self));
- g_signal_emit(self, XfdashboardClickActionSignals[SIGNAL_LONG_PRESS], 0, actor, CLUTTER_LONG_PRESS_CANCEL, &result);
+
+ /* Emit 'long-press' signal only when left-button was pressed for perform click */
+ if(priv->pressButton==1)
+ {
+ g_signal_emit(self, XfdashboardClickActionSignals[SIGNAL_LONG_PRESS], 0, actor, CLUTTER_LONG_PRESS_CANCEL, &result);
+ }
+
+ /* Always emit 'long-button-press' signal */
+ g_signal_emit(self, XfdashboardClickActionSignals[SIGNAL_LONG_BUTTON_PRESS], 0, actor, CLUTTER_LONG_PRESS_CANCEL, priv->pressButton, &result);
}
}
@@ -329,7 +352,15 @@ static gboolean _xfdashboard_click_action_on_captured_event(XfdashboardClickActi
if(modifierState!=priv->modifierState) priv->modifierState=0;
_xfdashboard_click_action_set_pressed(self, FALSE);
- g_signal_emit(self, XfdashboardClickActionSignals[SIGNAL_CLICKED], 0, actor);
+
+ /* Emit 'clicked' signal only when left-button was pressed for perform click */
+ if(priv->pressButton==1)
+ {
+ g_signal_emit(self, XfdashboardClickActionSignals[SIGNAL_CLICKED], 0, actor);
+ }
+
+ /* Always emit 'button-clicked' signal */
+ g_signal_emit(self, XfdashboardClickActionSignals[SIGNAL_BUTTON_CLICKED], 0, actor, priv->pressButton);
break;
case CLUTTER_MOTION:
@@ -628,6 +659,18 @@ static void xfdashboard_click_action_class_init(XfdashboardClickActionClass *kla
1,
CLUTTER_TYPE_ACTOR);
+ XfdashboardClickActionSignals[SIGNAL_BUTTON_CLICKED]=
+ g_signal_new("button-clicked",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(XfdashboardClickActionClass, button_clicked),
+ NULL, NULL,
+ _xfdashboard_marshal_VOID__OBJECT_UINT,
+ G_TYPE_NONE,
+ 2,
+ CLUTTER_TYPE_ACTOR,
+ G_TYPE_UINT);
+
XfdashboardClickActionSignals[SIGNAL_LONG_PRESS]=
g_signal_new("long-press",
G_TYPE_FROM_CLASS(klass),
@@ -639,6 +682,19 @@ static void xfdashboard_click_action_class_init(XfdashboardClickActionClass *kla
2,
CLUTTER_TYPE_ACTOR,
CLUTTER_TYPE_LONG_PRESS_STATE);
+
+ XfdashboardClickActionSignals[SIGNAL_LONG_BUTTON_PRESS]=
+ g_signal_new("long-button-press",
+ G_TYPE_FROM_CLASS(klass),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET(XfdashboardClickActionClass, long_button_press),
+ NULL, NULL,
+ _xfdashboard_marshal_BOOLEAN__OBJECT_ENUM_UINT,
+ G_TYPE_BOOLEAN,
+ 3,
+ CLUTTER_TYPE_ACTOR,
+ CLUTTER_TYPE_LONG_PRESS_STATE,
+ G_TYPE_UINT);
}
/* Object initialization
diff --git a/libxfdashboard/click-action.h b/libxfdashboard/click-action.h
index 88f85de..08a3ccb 100644
--- a/libxfdashboard/click-action.h
+++ b/libxfdashboard/click-action.h
@@ -70,7 +70,9 @@ struct _XfdashboardClickActionClass
/*< public >*/
/* Virtual functions */
void (*clicked)(XfdashboardClickAction *self, ClutterActor *inActor);
+ void (*button_clicked)(XfdashboardClickAction *self, ClutterActor *inActor, guint inButton);
gboolean (*long_press)(XfdashboardClickAction *self, ClutterActor *inActor, ClutterLongPressState inState);
+ gboolean (*long_button_press)(XfdashboardClickAction *self, ClutterActor *inActor, ClutterLongPressState inState, guint inButton);
};
/* Public API */
diff --git a/libxfdashboard/marshal.list b/libxfdashboard/marshal.list
index 0120dfc..69ffce8 100644
--- a/libxfdashboard/marshal.list
+++ b/libxfdashboard/marshal.list
@@ -1,12 +1,14 @@
VOID:FLOAT,FLOAT
VOID:INT,INT
VOID:INT,INT,INT,INT
+VOID:OBJECT,UINT
VOID:OBJECT,OBJECT
VOID:OBJECT,FLOAT,FLOAT
VOID:OBJECT,OBJECT,OBJECT
VOID:STRING,BOOLEAN
BOOLEAN:OBJECT
BOOLEAN:OBJECT,ENUM
+BOOLEAN:OBJECT,ENUM,UINT
BOOLEAN:OBJECT,FLOAT,FLOAT
BOOLEAN:OBJECT,STRING,OBJECT
BOOLEAN:VOID
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list