[Xfce4-commits] [apps/xfdashboard] 06/10: Add utility function for checking if a click action was a touch or a left click
noreply at xfce.org
noreply at xfce.org
Wed Oct 4 10:28:20 CEST 2017
This is an automated email from the git hooks/post-receive script.
n o m a d p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfdashboard.
commit 4c4d42ff3e51a5478355f639cf1e43ee3d2e21f1
Author: TheZoq2 <frans.skarman at gmail.com>
Date: Tue Oct 3 16:42:19 2017 +0200
Add utility function for checking if a click action was a touch or a left click
---
libxfdashboard/button.c | 3 +--
libxfdashboard/click-action.c | 21 +++++++++++++++++++++
libxfdashboard/click-action.h | 2 ++
libxfdashboard/live-window.c | 3 +--
libxfdashboard/live-workspace.c | 3 +--
libxfdashboard/popup-menu-item-button.c | 3 +--
libxfdashboard/quicklaunch.c | 3 +--
libxfdashboard/search-result-container.c | 3 +--
8 files changed, 29 insertions(+), 12 deletions(-)
diff --git a/libxfdashboard/button.c b/libxfdashboard/button.c
index 0ce2285..e4c7d4f 100644
--- a/libxfdashboard/button.c
+++ b/libxfdashboard/button.c
@@ -85,8 +85,7 @@ static void _xfdashboard_button_clicked(XfdashboardClickAction *inAction,
/* Only emit any of these signals if click was perform with left button
* or is a short touchscreen touch event.
*/
- if(xfdashboard_click_action_get_button(inAction)!=XFDASHBOARD_CLICK_ACTION_LEFT_BUTTON &&
- xfdashboard_click_action_get_button(inAction)!=0) return;
+ if(xfdashboard_click_action_is_left_button_or_touch(inAction))
{
/* Emit 'clicked' signal */
g_signal_emit(self, XfdashboardButtonSignals[SIGNAL_CLICKED], 0);
diff --git a/libxfdashboard/click-action.c b/libxfdashboard/click-action.c
index 6d321a4..af121fa 100644
--- a/libxfdashboard/click-action.c
+++ b/libxfdashboard/click-action.c
@@ -887,3 +887,24 @@ void xfdashboard_click_action_release(XfdashboardClickAction *self)
_xfdashboard_click_action_set_held(self, FALSE);
_xfdashboard_click_action_set_pressed(self, FALSE);
}
+
+/**
+ * xfdashboard_click_action_is_left_button_or_touch
+ * @self: A #XfdashboardClickAction
+ *
+ * Checks if the specified click action is either a left button press or a single touch 'tap'
+ */
+gboolean xfdashboard_click_action_is_left_button_or_touch(XfdashboardClickAction *self)
+{
+ XfdashboardClickActionPrivate *priv;
+ g_return_val_if_fail(XFDASHBOARD_IS_CLICK_ACTION(self), FALSE);
+
+ priv=self->priv;
+
+ if(priv->pressButton==0 || priv->pressButton==XFDASHBOARD_CLICK_ACTION_LEFT_BUTTON)
+ {
+ return(TRUE);
+ }
+
+ return(FALSE);
+}
diff --git a/libxfdashboard/click-action.h b/libxfdashboard/click-action.h
index 44d0f09..a1f02b5 100644
--- a/libxfdashboard/click-action.h
+++ b/libxfdashboard/click-action.h
@@ -128,6 +128,8 @@ void xfdashboard_click_action_get_coords(XfdashboardClickAction *self, gfloat *o
void xfdashboard_click_action_release(XfdashboardClickAction *self);
+gboolean xfdashboard_click_action_is_left_button_or_touch(XfdashboardClickAction *self);
+
G_END_DECLS
#endif /* __LIBXFDASHBOARD_CLICK_ACTION__ */
diff --git a/libxfdashboard/live-window.c b/libxfdashboard/live-window.c
index 6bbddfe..a878c77 100644
--- a/libxfdashboard/live-window.c
+++ b/libxfdashboard/live-window.c
@@ -360,8 +360,7 @@ static void _xfdashboard_live_window_on_clicked(XfdashboardLiveWindow *self,
/* Only emit any of these signals if click was perform with left button
* or is a short touchscreen touch event.
*/
- if(xfdashboard_click_action_get_button(action)!=XFDASHBOARD_CLICK_ACTION_LEFT_BUTTON &&
- xfdashboard_click_action_get_button(action)!=0)
+ if(!xfdashboard_click_action_is_left_button_or_touch(action))
{
return;
}
diff --git a/libxfdashboard/live-workspace.c b/libxfdashboard/live-workspace.c
index f72af6b..a0932c6 100644
--- a/libxfdashboard/live-workspace.c
+++ b/libxfdashboard/live-workspace.c
@@ -348,8 +348,7 @@ static void _xfdashboard_live_workspace_on_clicked(XfdashboardLiveWorkspace *sel
/* Only emit any of these signals if click was perform with left button
* or is a short touchscreen touch event.
*/
- if(xfdashboard_click_action_get_button(action)!=XFDASHBOARD_CLICK_ACTION_LEFT_BUTTON &&
- xfdashboard_click_action_get_button(action)!=0)
+ if(xfdashboard_click_action_is_left_button_or_touch(action))
{
/* Emit "clicked" signal */
g_signal_emit(self, XfdashboardLiveWorkspaceSignals[SIGNAL_CLICKED], 0);
diff --git a/libxfdashboard/popup-menu-item-button.c b/libxfdashboard/popup-menu-item-button.c
index 6287297..82ce03a 100644
--- a/libxfdashboard/popup-menu-item-button.c
+++ b/libxfdashboard/popup-menu-item-button.c
@@ -66,8 +66,7 @@ static void _xfdashboard_popup_menu_item_button_clicked(XfdashboardClickAction *
/* Only emit any of these signals if click was perform with left button
* or is a short touchscreen touch event.
*/
- if(xfdashboard_click_action_get_button(inAction)!=XFDASHBOARD_CLICK_ACTION_LEFT_BUTTON &&
- xfdashboard_click_action_get_button(inAction)!=0) return;
+ if(xfdashboard_click_action_is_left_button_or_touch(inAction))
{
xfdashboard_popup_menu_item_activate(XFDASHBOARD_POPUP_MENU_ITEM(self));
}
diff --git a/libxfdashboard/quicklaunch.c b/libxfdashboard/quicklaunch.c
index f276d7b..c3a6250 100644
--- a/libxfdashboard/quicklaunch.c
+++ b/libxfdashboard/quicklaunch.c
@@ -674,8 +674,7 @@ static void _xfdashboard_quicklaunch_on_favourite_popup_menu(XfdashboardQuicklau
/* Only emit any of these signals if click was perform with left button
* or is a short touchscreen touch event.
*/
- if(xfdashboard_click_action_get_button(action)!=XFDASHBOARD_CLICK_ACTION_LEFT_BUTTON &&
- xfdashboard_click_action_get_button(action)!=0) return;
+ if(xfdashboard_click_action_is_left_button_or_touch(action))
{
ClutterActor *popup;
ClutterActor *menuItem;
diff --git a/libxfdashboard/search-result-container.c b/libxfdashboard/search-result-container.c
index f4379d2..02e9d21 100644
--- a/libxfdashboard/search-result-container.c
+++ b/libxfdashboard/search-result-container.c
@@ -396,8 +396,7 @@ static void _xfdashboard_search_result_container_on_result_item_actor_clicked(Xf
/* Only emit any of these signals if click was perform with left button
* or is a short touchscreen touch event.
*/
- if(xfdashboard_click_action_get_button(inAction)!=XFDASHBOARD_CLICK_ACTION_LEFT_BUTTON &&
- xfdashboard_click_action_get_button(inAction)!=0) return;
+ if(xfdashboard_click_action_is_left_button_or_touch(inAction))
{
/* Activate result item by actor clicked */
_xfdashboard_search_result_container_activate_result_item_by_actor(self, inActor);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list