1 /*
2  * click-action: Bad workaround for click action which prevent drag actions
3  *               to work properly since clutter version 1.12 at least.
4  *               This object/file is a complete copy of the original
5  *               clutter-click-action.{c,h} files of clutter 1.12 except
6  *               for one line, the renamed function names and the applied
7  *               coding style. The clutter-click-action.{c,h} files of
8  *               later clutter versions do not differ much from this one
9  *               so this object should work also for this versions.
10  *
11  *               See bug: https://bugzilla.gnome.org/show_bug.cgi?id=714993
12  *
13  * Copyright 2012-2020 Stephan Haller <nomad@froevel.de>
14  *         original by Emmanuele Bassi <ebassi@linux.intel.com>
15  *
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 2 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * You should have received a copy of the GNU General Public License
27  * along with this program; if not, write to the Free Software
28  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
29  * MA 02110-1301, USA.
30  *
31  *
32  */
33 
34 #ifndef __LIBXFDASHBOARD_CLICK_ACTION__
35 #define __LIBXFDASHBOARD_CLICK_ACTION__
36 
37 #if !defined(__LIBXFDASHBOARD_H_INSIDE__) && !defined(LIBXFDASHBOARD_COMPILATION)
38 #error "Only <libxfdashboard/libxfdashboard.h> can be included directly."
39 #endif
40 
41 #include <clutter/clutter.h>
42 
43 G_BEGIN_DECLS
44 
45 /* Public definitions */
46 /**
47  * XFDASHBOARD_CLICK_ACTION_LEFT_BUTTON:
48  *
49  * A helper macro to determine left button clicks using
50  * the function xfdashboard_click_action_get_button().
51  * The value for this macro is an unsinged integer.
52  **/
53 #define XFDASHBOARD_CLICK_ACTION_LEFT_BUTTON 		((guint)1)
54 
55 /**
56  * XFDASHBOARD_CLICK_ACTION_MIDDLE_BUTTON:
57  *
58  * A helper macro to determine middle button clicks using
59  * the function xfdashboard_click_action_get_button().
60  * The value for this macro is an unsinged integer.
61  **/
62 #define XFDASHBOARD_CLICK_ACTION_MIDDLE_BUTTON 		((guint)2)
63 
64 /**
65  * XFDASHBOARD_CLICK_ACTION_RIGHT_BUTTON:
66  *
67  * A helper macro to determine right button clicks using
68  * the function xfdashboard_click_action_get_button().
69  * The value for this macro is an unsinged integer.
70  **/
71 #define XFDASHBOARD_CLICK_ACTION_RIGHT_BUTTON 		((guint)3)
72 
73 
74 /* Object declaration */
75 #define XFDASHBOARD_TYPE_CLICK_ACTION				(xfdashboard_click_action_get_type ())
76 #define XFDASHBOARD_CLICK_ACTION(obj)				(G_TYPE_CHECK_INSTANCE_CAST ((obj), XFDASHBOARD_TYPE_CLICK_ACTION, XfdashboardClickAction))
77 #define XFDASHBOARD_IS_CLICK_ACTION(obj)			(G_TYPE_CHECK_INSTANCE_TYPE ((obj), XFDASHBOARD_TYPE_CLICK_ACTION))
78 #define XFDASHBOARD_CLICK_ACTION_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), XFDASHBOARD_TYPE_CLICK_ACTION, XfdashboardClickActionClass))
79 #define XFDASHBOARD_IS_CLICK_ACTION_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), XFDASHBOARD_TYPE_CLICK_ACTION))
80 #define XFDASHBOARD_CLICK_ACTION_GET_CLASS(obj)		(G_TYPE_INSTANCE_GET_CLASS ((obj), XFDASHBOARD_TYPE_CLICK_ACTION, XfdashboardClickActionClass))
81 
82 typedef struct _XfdashboardClickAction				XfdashboardClickAction;
83 typedef struct _XfdashboardClickActionPrivate		XfdashboardClickActionPrivate;
84 typedef struct _XfdashboardClickActionClass			XfdashboardClickActionClass;
85 
86 /**
87  * XfdashboardClickAction:
88  *
89  * The #XfdashboardClickAction structure contains only private data and
90  * should be accessed using the provided API
91  */
92 struct _XfdashboardClickAction
93 {
94 	/*< private >*/
95 	/* Parent instance */
96 	ClutterAction					parent_instance;
97 
98 	XfdashboardClickActionPrivate	*priv;
99 };
100 
101 /**
102  * XfdashboardClickActionClass:
103  * @clicked: Class handler for the #XfdashboardClickActionClass::clicked signal
104  * @long_press: Class handler for the #XfdashboardClickActionClass::long-press signal
105  *
106  * The #XfdashboardClickActionClass structure contains only private data
107  */
108 struct _XfdashboardClickActionClass
109 {
110 	/*< private >*/
111 	/* Parent class */
112 	ClutterActionClass				parent_class;
113 
114 	/*< public >*/
115 	/* Virtual functions */
116 	void (*clicked)(XfdashboardClickAction *self, ClutterActor *inActor);
117 	gboolean (*long_press)(XfdashboardClickAction *self, ClutterActor *inActor, ClutterLongPressState inState);
118 };
119 
120 /* Public API */
121 GType xfdashboard_click_action_get_type(void) G_GNUC_CONST;
122 
123 ClutterAction* xfdashboard_click_action_new(void);
124 
125 guint xfdashboard_click_action_get_button(XfdashboardClickAction *self);
126 ClutterModifierType xfdashboard_click_action_get_state(XfdashboardClickAction *self);
127 void xfdashboard_click_action_get_coords(XfdashboardClickAction *self, gfloat *outPressX, gfloat *outPressY);
128 
129 void xfdashboard_click_action_release(XfdashboardClickAction *self);
130 
131 gboolean xfdashboard_click_action_is_left_button_or_tap(XfdashboardClickAction *self);
132 
133 G_END_DECLS
134 
135 #endif	/* __LIBXFDASHBOARD_CLICK_ACTION__ */
136