diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/lib/ecore_x/xlib/ecore_x_gesture.c | 136 |
1 files changed, 136 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_gesture.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_gesture.c new file mode 100644 index 0000000..e1dc75c --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_gesture.c | |||
@@ -0,0 +1,136 @@ | |||
1 | #ifdef HAVE_CONFIG_H | ||
2 | # include <config.h> | ||
3 | #endif /* ifdef HAVE_CONFIG_H */ | ||
4 | |||
5 | #include "ecore_x_private.h" | ||
6 | |||
7 | static Eina_Bool _gesture_available = EINA_FALSE; | ||
8 | |||
9 | #ifdef ECORE_XGESTURE | ||
10 | static int _gesture_major, _gesture_minor, _gesture_patch; | ||
11 | int _gesture_version; | ||
12 | #endif /* ifdef ECORE_XGESTURE */ | ||
13 | |||
14 | void | ||
15 | _ecore_x_gesture_init(void) | ||
16 | { | ||
17 | #ifdef ECORE_XGESTURE | ||
18 | _gesture_major = 0; | ||
19 | _gesture_minor = 0; | ||
20 | _gesture_patch = 0; | ||
21 | _gesture_version = 0; | ||
22 | |||
23 | if (XGestureQueryVersion(_ecore_x_disp, &_gesture_major, &_gesture_minor, &_gesture_patch)) | ||
24 | { | ||
25 | _gesture_version = (_gesture_major << 16) | _gesture_minor; | ||
26 | _gesture_available = EINA_TRUE; | ||
27 | } | ||
28 | else | ||
29 | _gesture_available = EINA_FALSE; | ||
30 | #else /* ifdef ECORE_XGESTURE */ | ||
31 | _gesture_available = EINA_FALSE; | ||
32 | #endif /* ifdef ECORE_XGESTURE */ | ||
33 | } | ||
34 | |||
35 | /* | ||
36 | * @brief query whether gesture is available or not | ||
37 | * @return EINA_TRUE, if extension is available, else EINA_FALSE | ||
38 | */ | ||
39 | EAPI Eina_Bool | ||
40 | ecore_x_gesture_supported(void) | ||
41 | { | ||
42 | return _gesture_available; | ||
43 | } | ||
44 | |||
45 | EAPI Eina_Bool | ||
46 | ecore_x_gesture_events_select(Ecore_X_Window win, | ||
47 | Ecore_X_Gesture_Event_Mask mask) | ||
48 | { | ||
49 | #ifdef ECORE_XGESTURE | ||
50 | if (!_gesture_available) | ||
51 | return EINA_FALSE; | ||
52 | |||
53 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
54 | XGestureSelectEvents(_ecore_x_disp, win, mask); | ||
55 | |||
56 | return EINA_TRUE; | ||
57 | #else /* ifdef ECORE_XGESTURE */ | ||
58 | return EINA_FALSE; | ||
59 | win = 0; | ||
60 | mask = 0; | ||
61 | #endif /* ifdef ECORE_XGESTURE */ | ||
62 | } | ||
63 | |||
64 | EAPI Ecore_X_Gesture_Event_Mask | ||
65 | ecore_x_gesture_events_selected_get(Ecore_X_Window win) | ||
66 | { | ||
67 | #ifdef ECORE_XGESTURE | ||
68 | Ecore_X_Gesture_Event_Mask mask; | ||
69 | |||
70 | if (!_gesture_available) | ||
71 | return ECORE_X_GESTURE_EVENT_MASK_NONE; | ||
72 | |||
73 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
74 | if (GestureSuccess != XGestureGetSelectedEvents(_ecore_x_disp, win, &mask)) | ||
75 | { | ||
76 | mask = ECORE_X_GESTURE_EVENT_MASK_NONE; | ||
77 | return mask; | ||
78 | } | ||
79 | |||
80 | return mask; | ||
81 | #else /* ifdef ECORE_XGESTURE */ | ||
82 | return ECORE_X_GESTURE_EVENT_MASK_NONE; | ||
83 | win = 0; | ||
84 | #endif /* ifdef ECORE_XGESTURE */ | ||
85 | } | ||
86 | |||
87 | EAPI Eina_Bool | ||
88 | ecore_x_gesture_event_grab(Ecore_X_Window win, | ||
89 | Ecore_X_Gesture_Event_Type type, | ||
90 | int num_fingers) | ||
91 | { | ||
92 | #ifdef ECORE_XGESTURE | ||
93 | if (!_gesture_available) | ||
94 | return EINA_FALSE; | ||
95 | |||
96 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
97 | if (GestureGrabSuccess != XGestureGrabEvent(_ecore_x_disp, win, type, num_fingers, CurrentTime)) | ||
98 | { | ||
99 | return EINA_FALSE; | ||
100 | } | ||
101 | |||
102 | return EINA_TRUE; | ||
103 | #else /* ifdef ECORE_XGESTURE */ | ||
104 | return EINA_FALSE; | ||
105 | win = 0; | ||
106 | type = 0; | ||
107 | num_fingers = 0; | ||
108 | #endif /* ifdef ECORE_XGESTURE */ | ||
109 | } | ||
110 | |||
111 | EAPI Eina_Bool | ||
112 | ecore_x_gesture_event_ungrab(Ecore_X_Window win, | ||
113 | Ecore_X_Gesture_Event_Type type, | ||
114 | int num_fingers) | ||
115 | { | ||
116 | #ifdef ECORE_XGESTURE | ||
117 | Ecore_X_Gesture_Event_Mask mask; | ||
118 | |||
119 | if (!_gesture_available) | ||
120 | return EINA_FALSE; | ||
121 | |||
122 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
123 | if (GestureUngrabSuccess != XGestureUngrabEvent(_ecore_x_disp, win, type, num_fingers, CurrentTime)) | ||
124 | { | ||
125 | return EINA_FALSE; | ||
126 | } | ||
127 | |||
128 | return EINA_TRUE; | ||
129 | #else /* ifdef ECORE_XGESTURE */ | ||
130 | return EINA_FALSE; | ||
131 | win = 0; | ||
132 | type = 0; | ||
133 | num_fingers = 0; | ||
134 | #endif /* ifdef ECORE_XGESTURE */ | ||
135 | } | ||
136 | |||