eolian: rename is_ref API to is_ptr to match syntax
[platform/upstream/efl.git] / src / lib / ecore_x / xlib / ecore_x_gesture.c
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  *
38  * @return @c EINA_TRUE, if extension is available, @c EINA_FALSE otherwise.
39  */
40 EAPI Eina_Bool
41 ecore_x_gesture_supported(void)
42 {
43    return _gesture_available;
44 }
45
46 EAPI Eina_Bool
47 ecore_x_gesture_events_select(Ecore_X_Window win,
48                               Ecore_X_Gesture_Event_Mask mask)
49 {
50 #ifdef ECORE_XGESTURE
51    if (!_gesture_available)
52      return EINA_FALSE;
53
54    LOGFN(__FILE__, __LINE__, __FUNCTION__);
55    XGestureSelectEvents(_ecore_x_disp, win, mask);
56    if (_ecore_xlib_sync) ecore_x_sync();
57
58    return EINA_TRUE;
59 #else /* ifdef ECORE_XGESTURE */
60    (void) win;
61    (void) mask;
62    return EINA_FALSE;
63 #endif /* ifdef ECORE_XGESTURE */
64 }
65
66 EAPI Ecore_X_Gesture_Event_Mask
67 ecore_x_gesture_events_selected_get(Ecore_X_Window win)
68 {
69 #ifdef ECORE_XGESTURE
70    Ecore_X_Gesture_Event_Mask mask;
71
72    if (!_gesture_available)
73      return ECORE_X_GESTURE_EVENT_MASK_NONE;
74
75    LOGFN(__FILE__, __LINE__, __FUNCTION__);
76    if (GestureSuccess != XGestureGetSelectedEvents(_ecore_x_disp, win, (Mask *)&mask))
77      mask = ECORE_X_GESTURE_EVENT_MASK_NONE;
78    if (_ecore_xlib_sync) ecore_x_sync();
79
80    return mask;
81 #else /* ifdef ECORE_XGESTURE */
82    (void) win;
83    return ECORE_X_GESTURE_EVENT_MASK_NONE;
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    Eina_Bool ret;
94    if (!_gesture_available)
95      return EINA_FALSE;
96
97    LOGFN(__FILE__, __LINE__, __FUNCTION__);
98    ret = (GestureGrabSuccess == XGestureGrabEvent(_ecore_x_disp, win, type, num_fingers, CurrentTime));
99    if (_ecore_xlib_sync) ecore_x_sync();
100    return ret;
101 #else /* ifdef ECORE_XGESTURE */
102    (void) win;
103    (void) type;
104    (void) num_fingers;
105    return EINA_FALSE;
106 #endif /* ifdef ECORE_XGESTURE */
107 }
108
109 EAPI Eina_Bool
110 ecore_x_gesture_event_ungrab(Ecore_X_Window win,
111                              Ecore_X_Gesture_Event_Type type,
112                              int num_fingers)
113 {
114 #ifdef ECORE_XGESTURE
115    Eina_Bool ret;
116
117    if (!_gesture_available)
118      return EINA_FALSE;
119
120    LOGFN(__FILE__, __LINE__, __FUNCTION__);
121    ret = (GestureUngrabSuccess == XGestureUngrabEvent(_ecore_x_disp, win, type, num_fingers, CurrentTime));
122    if (_ecore_xlib_sync) ecore_x_sync();
123    return ret;
124 #else /* ifdef ECORE_XGESTURE */
125    (void) win;
126    (void) type;
127    (void) num_fingers;
128    return EINA_FALSE;
129 #endif /* ifdef ECORE_XGESTURE */
130 }
131