summaryrefslogtreecommitdiff
path: root/legacy/ecore/src/lib/ecore_x/xlib
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2012-12-02 22:35:45 +0000
committerVincent Torri <vincent.torri@gmail.com>2012-12-02 22:35:45 +0000
commit7d6010b12c47a20e492da808e3192c3f87dab619 (patch)
tree26c6fd189e046a76560c0bc740b85f4d767ae399 /legacy/ecore/src/lib/ecore_x/xlib
parent53fc441d5475155965d92da89502fe4634a561b2 (diff)
merge: add escape ecore, fix several bugs
SVN revision: 79995
Diffstat (limited to 'legacy/ecore/src/lib/ecore_x/xlib')
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x.c2242
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_atoms.c109
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_composite.c176
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_cursor.c246
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_damage.c71
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_dnd.c706
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_dpms.c247
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_drawable.c118
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_e.c1670
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_error.c126
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_events.c2523
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_fixes.c365
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_gc.c171
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_gesture.c137
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_icccm.c1214
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_image.c626
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_mwm.c106
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_netwm.c2083
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_pixmap.c121
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_private.h379
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr.c103
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr.h7
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr_11.c334
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c2438
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12_edid.c463
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_randr_13.c68
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_region.c158
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_screensaver.c204
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_selection.c1021
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_sync.c159
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_test.c167
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_vsync.c351
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_window.c1727
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_window_prop.c760
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_window_shape.c658
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_xi2.c336
-rw-r--r--legacy/ecore/src/lib/ecore_x/xlib/ecore_x_xinerama.c91
37 files changed, 0 insertions, 22481 deletions
diff --git a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x.c b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x.c
deleted file mode 100644
index d9b81bc..0000000
--- a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x.c
+++ /dev/null
@@ -1,2242 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#ifdef STDC_HEADERS
6# include <stdlib.h>
7# include <stddef.h>
8#else
9# ifdef HAVE_STDLIB_H
10# include <stdlib.h>
11# endif
12#endif
13#ifdef HAVE_ALLOCA_H
14# include <alloca.h>
15#elif !defined alloca
16# ifdef __GNUC__
17# define alloca __builtin_alloca
18# elif defined _AIX
19# define alloca __alloca
20# elif defined _MSC_VER
21# include <malloc.h>
22# define alloca _alloca
23# elif !defined HAVE_ALLOCA
24# ifdef __cplusplus
25extern "C"
26# endif
27void *alloca (size_t);
28# endif
29#endif
30
31#include <stdlib.h>
32#include <string.h>
33#include <unistd.h>
34
35//#define LOGRT 1
36
37#ifdef LOGRT
38#include <dlfcn.h>
39#endif /* ifdef LOGRT */
40
41#include "Ecore.h"
42#include "ecore_private.h"
43#include "ecore_x_private.h"
44#include "Ecore_X.h"
45#include "Ecore_X_Atoms.h"
46#include "Ecore_Input.h"
47
48static Eina_Bool _ecore_x_fd_handler(void *data,
49 Ecore_Fd_Handler *fd_handler);
50static Eina_Bool _ecore_x_fd_handler_buf(void *data,
51 Ecore_Fd_Handler *fd_handler);
52static int _ecore_x_key_mask_get(KeySym sym);
53static int _ecore_x_event_modifier(unsigned int state);
54
55static Ecore_Fd_Handler *_ecore_x_fd_handler_handle = NULL;
56
57static const int AnyXEvent = 0; /* 0 can be used as there are no event types
58 * with index 0 and 1 as they are used for
59 * errors
60 */
61
62static int _ecore_x_event_shape_id = 0;
63static int _ecore_x_event_screensaver_id = 0;
64static int _ecore_x_event_sync_id = 0;
65int _ecore_xlib_log_dom = -1;
66
67#ifdef ECORE_XRANDR
68static int _ecore_x_event_randr_id = 0;
69#endif /* ifdef ECORE_XRANDR */
70#ifdef ECORE_XFIXES
71static int _ecore_x_event_fixes_selection_id = 0;
72#endif /* ifdef ECORE_XFIXES */
73#ifdef ECORE_XDAMAGE
74static int _ecore_x_event_damage_id = 0;
75#endif /* ifdef ECORE_XDAMAGE */
76#ifdef ECORE_XGESTURE
77static int _ecore_x_event_gesture_id = 0;
78#endif /* ifdef ECORE_XGESTURE */
79#ifdef ECORE_XKB
80static int _ecore_x_event_xkb_id = 0;
81#endif /* ifdef ECORE_XKB */
82static int _ecore_x_event_handlers_num = 0;
83static void (**_ecore_x_event_handlers) (XEvent * event) = NULL;
84
85static int _ecore_x_init_count = 0;
86static int _ecore_x_grab_count = 0;
87
88Display *_ecore_x_disp = NULL;
89double _ecore_x_double_click_time = 0.25;
90Time _ecore_x_event_last_time = 0;
91Window _ecore_x_event_last_win = 0;
92int _ecore_x_event_last_root_x = 0;
93int _ecore_x_event_last_root_y = 0;
94Eina_Bool _ecore_x_xcursor = EINA_FALSE;
95
96Ecore_X_Window _ecore_x_private_win = 0;
97
98Ecore_X_Atom _ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_NUM];
99
100EAPI int ECORE_X_EVENT_ANY = 0;
101EAPI int ECORE_X_EVENT_MOUSE_IN = 0;
102EAPI int ECORE_X_EVENT_MOUSE_OUT = 0;
103EAPI int ECORE_X_EVENT_WINDOW_FOCUS_IN = 0;
104EAPI int ECORE_X_EVENT_WINDOW_FOCUS_OUT = 0;
105EAPI int ECORE_X_EVENT_WINDOW_KEYMAP = 0;
106EAPI int ECORE_X_EVENT_WINDOW_DAMAGE = 0;
107EAPI int ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE = 0;
108EAPI int ECORE_X_EVENT_WINDOW_CREATE = 0;
109EAPI int ECORE_X_EVENT_WINDOW_DESTROY = 0;
110EAPI int ECORE_X_EVENT_WINDOW_HIDE = 0;
111EAPI int ECORE_X_EVENT_WINDOW_SHOW = 0;
112EAPI int ECORE_X_EVENT_WINDOW_SHOW_REQUEST = 0;
113EAPI int ECORE_X_EVENT_WINDOW_REPARENT = 0;
114EAPI int ECORE_X_EVENT_WINDOW_CONFIGURE = 0;
115EAPI int ECORE_X_EVENT_WINDOW_CONFIGURE_REQUEST = 0;
116EAPI int ECORE_X_EVENT_WINDOW_GRAVITY = 0;
117EAPI int ECORE_X_EVENT_WINDOW_RESIZE_REQUEST = 0;
118EAPI int ECORE_X_EVENT_WINDOW_STACK = 0;
119EAPI int ECORE_X_EVENT_WINDOW_STACK_REQUEST = 0;
120EAPI int ECORE_X_EVENT_WINDOW_PROPERTY = 0;
121EAPI int ECORE_X_EVENT_WINDOW_COLORMAP = 0;
122EAPI int ECORE_X_EVENT_WINDOW_MAPPING = 0;
123EAPI int ECORE_X_EVENT_MAPPING_CHANGE = 0;
124EAPI int ECORE_X_EVENT_SELECTION_CLEAR = 0;
125EAPI int ECORE_X_EVENT_SELECTION_REQUEST = 0;
126EAPI int ECORE_X_EVENT_SELECTION_NOTIFY = 0;
127EAPI int ECORE_X_EVENT_FIXES_SELECTION_NOTIFY = 0;
128EAPI int ECORE_X_EVENT_CLIENT_MESSAGE = 0;
129EAPI int ECORE_X_EVENT_WINDOW_SHAPE = 0;
130EAPI int ECORE_X_EVENT_SCREENSAVER_NOTIFY = 0;
131EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_FLICK;
132EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_PAN;
133EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION;
134EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_TAP;
135EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD;
136EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_HOLD;
137EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_GROUP;
138EAPI int ECORE_X_EVENT_SYNC_COUNTER = 0;
139EAPI int ECORE_X_EVENT_SYNC_ALARM = 0;
140EAPI int ECORE_X_EVENT_SCREEN_CHANGE = 0;
141EAPI int ECORE_X_EVENT_DAMAGE_NOTIFY = 0;
142EAPI int ECORE_X_EVENT_RANDR_CRTC_CHANGE = 0;
143EAPI int ECORE_X_EVENT_RANDR_OUTPUT_CHANGE = 0;
144EAPI int ECORE_X_EVENT_RANDR_OUTPUT_PROPERTY_NOTIFY = 0;
145EAPI int ECORE_X_EVENT_WINDOW_DELETE_REQUEST = 0;
146EAPI int ECORE_X_EVENT_WINDOW_MOVE_RESIZE_REQUEST = 0;
147EAPI int ECORE_X_EVENT_WINDOW_STATE_REQUEST = 0;
148EAPI int ECORE_X_EVENT_FRAME_EXTENTS_REQUEST = 0;
149EAPI int ECORE_X_EVENT_PING = 0;
150EAPI int ECORE_X_EVENT_DESKTOP_CHANGE = 0;
151
152EAPI int ECORE_X_EVENT_STARTUP_SEQUENCE_NEW = 0;
153EAPI int ECORE_X_EVENT_STARTUP_SEQUENCE_CHANGE = 0;
154EAPI int ECORE_X_EVENT_STARTUP_SEQUENCE_REMOVE = 0;
155
156EAPI int ECORE_X_EVENT_XKB_STATE_NOTIFY = 0;
157EAPI int ECORE_X_EVENT_XKB_NEWKBD_NOTIFY = 0;
158
159
160EAPI int ECORE_X_EVENT_GENERIC = 0;
161
162EAPI int ECORE_X_MODIFIER_SHIFT = 0;
163EAPI int ECORE_X_MODIFIER_CTRL = 0;
164EAPI int ECORE_X_MODIFIER_ALT = 0;
165EAPI int ECORE_X_MODIFIER_WIN = 0;
166EAPI int ECORE_X_MODIFIER_ALTGR = 0;
167
168EAPI int ECORE_X_LOCK_SCROLL = 0;
169EAPI int ECORE_X_LOCK_NUM = 0;
170EAPI int ECORE_X_LOCK_CAPS = 0;
171EAPI int ECORE_X_LOCK_SHIFT = 0;
172
173EAPI int ECORE_X_RAW_BUTTON_PRESS = 0;
174EAPI int ECORE_X_RAW_BUTTON_RELEASE = 0;
175EAPI int ECORE_X_RAW_MOTION = 0;
176
177#ifdef LOGRT
178static double t0 = 0.0;
179static Status (*_logrt_real_reply)(Display *disp,
180 void *rep,
181 int extra,
182 Bool discard) = NULL;
183static void
184_logrt_init(void)
185{
186 void *lib;
187
188 lib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
189 if (!lib)
190 lib = dlopen("libX11.so.6", RTLD_GLOBAL | RTLD_LAZY);
191
192 if (!lib)
193 lib = dlopen("libX11.so.6.3", RTLD_GLOBAL | RTLD_LAZY);
194
195 if (!lib)
196 lib = dlopen("libX11.so.6.3.0", RTLD_GLOBAL | RTLD_LAZY);
197
198 _logrt_real_reply = dlsym(lib, "_XReply");
199 t0 = ecore_time_get();
200}
201
202Status
203_XReply(Display *disp,
204 void *rep,
205 int extra,
206 Bool discard)
207{
208 void *bt[128];
209 int i, n;
210 char **sym;
211
212 n = backtrace(bt, 128);
213 if (n > 0)
214 {
215 sym = backtrace_symbols(bt, n);
216 printf("ROUNDTRIP: %4.4f :", ecore_time_get() - t0);
217 if (sym)
218 {
219 for (i = n - 1; i > 0; i--)
220 {
221 char *fname = strchr(sym[i], '(');
222 if (fname)
223 {
224 char *tsym = alloca(strlen(fname) + 1);
225 char *end;
226 strcpy(tsym, fname + 1);
227 end = strchr(tsym, '+');
228 if (end)
229 {
230 *end = 0;
231 printf("%s", tsym);
232 }
233 else
234 printf("???");
235 }
236 else
237 printf("???");
238
239 if (i > 1)
240 printf(" > ");
241 }
242 printf("\n");
243 }
244 }
245
246 // fixme: logme
247 return _logrt_real_reply(disp, rep, extra, discard);
248}
249
250#endif /* ifdef LOGRT */
251
252/* wrapper to use XkbKeycodeToKeysym when possible */
253KeySym
254_ecore_x_XKeycodeToKeysym(Display *display, KeyCode keycode, int idx)
255{
256#ifdef ECORE_XKB
257 return XkbKeycodeToKeysym(display, keycode, 0, idx);
258#else
259 return XKeycodeToKeysym(display, keycode, idx);
260#endif
261}
262
263void
264_ecore_x_modifiers_get(void)
265{
266 /* everything has these... unless its like a pda... :) */
267 ECORE_X_MODIFIER_SHIFT = _ecore_x_key_mask_get(XK_Shift_L);
268 ECORE_X_MODIFIER_CTRL = _ecore_x_key_mask_get(XK_Control_L);
269
270 /* apple's xdarwin has no alt!!!! */
271 ECORE_X_MODIFIER_ALT = _ecore_x_key_mask_get(XK_Alt_L);
272 if (!ECORE_X_MODIFIER_ALT)
273 ECORE_X_MODIFIER_ALT = _ecore_x_key_mask_get(XK_Meta_L);
274
275 if (!ECORE_X_MODIFIER_ALT)
276 ECORE_X_MODIFIER_ALT = _ecore_x_key_mask_get(XK_Super_L);
277
278 /* the windows key... a valid modifier :) */
279 ECORE_X_MODIFIER_WIN = _ecore_x_key_mask_get(XK_Super_L);
280 if (!ECORE_X_MODIFIER_WIN)
281 ECORE_X_MODIFIER_WIN = _ecore_x_key_mask_get(XK_Meta_L);
282
283 ECORE_X_MODIFIER_ALTGR = _ecore_x_key_mask_get(XK_Mode_switch);
284
285 if (ECORE_X_MODIFIER_WIN == ECORE_X_MODIFIER_ALT)
286 ECORE_X_MODIFIER_WIN = 0;
287
288 if (ECORE_X_MODIFIER_ALT == ECORE_X_MODIFIER_CTRL)
289 ECORE_X_MODIFIER_ALT = 0;
290
291 ECORE_X_LOCK_SCROLL = _ecore_x_key_mask_get(XK_Scroll_Lock);
292 ECORE_X_LOCK_NUM = _ecore_x_key_mask_get(XK_Num_Lock);
293 ECORE_X_LOCK_CAPS = _ecore_x_key_mask_get(XK_Caps_Lock);
294 ECORE_X_LOCK_SHIFT = _ecore_x_key_mask_get(XK_Shift_Lock);
295}
296
297/**
298 * @defgroup Ecore_X_Init_Group X Library Init and Shutdown Functions
299 *
300 * Functions that start and shut down the Ecore X Library.
301 */
302
303/**
304 * Initialize the X display connection to the given display.
305 *
306 * @param name Display target name. If @c NULL, the default display is
307 * assumed.
308 * @return The number of times the library has been initialized without
309 * being shut down. 0 is returned if an error occurs.
310 * @ingroup Ecore_X_Init_Group
311 */
312EAPI int
313ecore_x_init(const char *name)
314{
315 int shape_base = 0;
316 int shape_err_base = 0;
317#ifdef ECORE_XSS
318 int screensaver_base = 0;
319 int screensaver_err_base = 0;
320#endif /* ifdef ECORE_XSS */
321 int sync_base = 0;
322 int sync_err_base = 0;
323#ifdef ECORE_XRANDR
324 int randr_base = 0;
325 int randr_err_base = 0;
326#endif /* ifdef ECORE_XRANDR */
327#ifdef ECORE_XFIXES
328 int fixes_base = 0;
329 int fixes_err_base = 0;
330#endif /* ifdef ECORE_XFIXES */
331#ifdef ECORE_XDAMAGE
332 int damage_base = 0;
333 int damage_err_base = 0;
334#endif /* ifdef ECORE_XDAMAGE */
335#ifdef ECORE_XGESTURE
336 int gesture_base = 0;
337 int gesture_err_base = 0;
338#endif /* ifdef ECORE_XGESTURE */
339#ifdef ECORE_XKB
340 int xkb_base = 0;
341#endif /* ifdef ECORE_XKB */
342 if (++_ecore_x_init_count != 1)
343 return _ecore_x_init_count;
344
345 LOGFN(__FILE__, __LINE__, __FUNCTION__);
346#ifdef LOGRT
347 _logrt_init();
348#endif /* ifdef LOGRT */
349
350 eina_init();
351 _ecore_xlib_log_dom = eina_log_domain_register
352 ("ecore_x", ECORE_XLIB_DEFAULT_LOG_COLOR);
353 if (_ecore_xlib_log_dom < 0)
354 {
355 EINA_LOG_ERR(
356 "Impossible to create a log domain for the Ecore Xlib module.");
357 return --_ecore_x_init_count;
358 }
359
360 if (!ecore_init())
361 goto shutdown_eina;
362 if (!ecore_event_init())
363 goto shutdown_ecore;
364
365#ifdef EVAS_FRAME_QUEUING
366 XInitThreads();
367#endif /* ifdef EVAS_FRAME_QUEUING */
368 _ecore_x_disp = XOpenDisplay((char *)name);
369 if (!_ecore_x_disp)
370 goto shutdown_ecore_event;
371
372 _ecore_x_error_handler_init();
373 _ecore_x_event_handlers_num = LASTEvent;
374
375#define ECORE_X_EVENT_HANDLERS_GROW(ext_base, ext_num_events) \
376 do { \
377 if (_ecore_x_event_handlers_num < (ext_base + ext_num_events)) { \
378 _ecore_x_event_handlers_num = (ext_base + ext_num_events); } \
379 } while (0)
380
381 if (XShapeQueryExtension(_ecore_x_disp, &shape_base, &shape_err_base))
382 _ecore_x_event_shape_id = shape_base;
383
384 ECORE_X_EVENT_HANDLERS_GROW(shape_base, ShapeNumberEvents);
385
386#ifdef ECORE_XSS
387 if (XScreenSaverQueryExtension(_ecore_x_disp, &screensaver_base,
388 &screensaver_err_base))
389 _ecore_x_event_screensaver_id = screensaver_base;
390
391 ECORE_X_EVENT_HANDLERS_GROW(screensaver_base, ScreenSaverNumberEvents);
392#endif /* ifdef ECORE_XSS */
393
394 if (XSyncQueryExtension(_ecore_x_disp, &sync_base, &sync_err_base))
395 {
396 int major, minor;
397
398 _ecore_x_event_sync_id = sync_base;
399 if (!XSyncInitialize(_ecore_x_disp, &major, &minor))
400 _ecore_x_event_sync_id = 0;
401 }
402
403 ECORE_X_EVENT_HANDLERS_GROW(sync_base, XSyncNumberEvents);
404
405#ifdef ECORE_XRANDR
406 if (XRRQueryExtension(_ecore_x_disp, &randr_base, &randr_err_base))
407 _ecore_x_event_randr_id = randr_base;
408
409 ECORE_X_EVENT_HANDLERS_GROW(randr_base, RRNumberEvents);
410#endif /* ifdef ECORE_XRANDR */
411
412#ifdef ECORE_XFIXES
413 if (XFixesQueryExtension(_ecore_x_disp, &fixes_base, &fixes_err_base))
414 _ecore_x_event_fixes_selection_id = fixes_base;
415
416 ECORE_X_EVENT_HANDLERS_GROW(fixes_base, XFixesNumberEvents);
417#endif /* ifdef ECORE_XFIXES */
418
419#ifdef ECORE_XDAMAGE
420 if (XDamageQueryExtension(_ecore_x_disp, &damage_base, &damage_err_base))
421 _ecore_x_event_damage_id = damage_base;
422
423 ECORE_X_EVENT_HANDLERS_GROW(damage_base, XDamageNumberEvents);
424#endif /* ifdef ECORE_XDAMAGE */
425
426#ifdef ECORE_XGESTURE
427 if (XGestureQueryExtension(_ecore_x_disp, &gesture_base, &gesture_err_base))
428 _ecore_x_event_gesture_id = gesture_base;
429
430 ECORE_X_EVENT_HANDLERS_GROW(gesture_base, GestureNumberEvents);
431#endif /* ifdef ECORE_XGESTURE */
432#ifdef ECORE_XKB
433 {
434 int dummy;
435
436 if (XkbQueryExtension(_ecore_x_disp, &dummy, &xkb_base,
437 &dummy, &dummy, &dummy))
438 _ecore_x_event_xkb_id = xkb_base;
439 XkbSelectEventDetails(_ecore_x_disp, XkbUseCoreKbd, XkbStateNotify,
440 XkbAllStateComponentsMask, XkbGroupStateMask);
441 }
442 ECORE_X_EVENT_HANDLERS_GROW(xkb_base, XkbNumberEvents);
443#endif
444
445 _ecore_x_event_handlers = calloc(_ecore_x_event_handlers_num, sizeof(void *));
446 if (!_ecore_x_event_handlers)
447 goto close_display;
448
449#ifdef ECORE_XCURSOR
450 _ecore_x_xcursor = XcursorSupportsARGB(_ecore_x_disp) ? EINA_TRUE : EINA_FALSE;
451#endif /* ifdef ECORE_XCURSOR */
452 _ecore_x_event_handlers[AnyXEvent] = _ecore_x_event_handle_any_event;
453 _ecore_x_event_handlers[KeyPress] = _ecore_x_event_handle_key_press;
454 _ecore_x_event_handlers[KeyRelease] = _ecore_x_event_handle_key_release;
455 _ecore_x_event_handlers[ButtonPress] = _ecore_x_event_handle_button_press;
456 _ecore_x_event_handlers[ButtonRelease] =
457 _ecore_x_event_handle_button_release;
458 _ecore_x_event_handlers[MotionNotify] = _ecore_x_event_handle_motion_notify;
459 _ecore_x_event_handlers[EnterNotify] = _ecore_x_event_handle_enter_notify;
460 _ecore_x_event_handlers[LeaveNotify] = _ecore_x_event_handle_leave_notify;
461 _ecore_x_event_handlers[FocusIn] = _ecore_x_event_handle_focus_in;
462 _ecore_x_event_handlers[FocusOut] = _ecore_x_event_handle_focus_out;
463 _ecore_x_event_handlers[KeymapNotify] = _ecore_x_event_handle_keymap_notify;
464 _ecore_x_event_handlers[Expose] = _ecore_x_event_handle_expose;
465 _ecore_x_event_handlers[GraphicsExpose] =
466 _ecore_x_event_handle_graphics_expose;
467 _ecore_x_event_handlers[VisibilityNotify] =
468 _ecore_x_event_handle_visibility_notify;
469 _ecore_x_event_handlers[CreateNotify] = _ecore_x_event_handle_create_notify;
470 _ecore_x_event_handlers[DestroyNotify] =
471 _ecore_x_event_handle_destroy_notify;
472 _ecore_x_event_handlers[UnmapNotify] = _ecore_x_event_handle_unmap_notify;
473 _ecore_x_event_handlers[MapNotify] = _ecore_x_event_handle_map_notify;
474 _ecore_x_event_handlers[MapRequest] = _ecore_x_event_handle_map_request;
475 _ecore_x_event_handlers[ReparentNotify] =
476 _ecore_x_event_handle_reparent_notify;
477 _ecore_x_event_handlers[ConfigureNotify] =
478 _ecore_x_event_handle_configure_notify;
479 _ecore_x_event_handlers[ConfigureRequest] =
480 _ecore_x_event_handle_configure_request;
481 _ecore_x_event_handlers[GravityNotify] =
482 _ecore_x_event_handle_gravity_notify;
483 _ecore_x_event_handlers[ResizeRequest] =
484 _ecore_x_event_handle_resize_request;
485 _ecore_x_event_handlers[CirculateNotify] =
486 _ecore_x_event_handle_circulate_notify;
487 _ecore_x_event_handlers[CirculateRequest] =
488 _ecore_x_event_handle_circulate_request;
489 _ecore_x_event_handlers[PropertyNotify] =
490 _ecore_x_event_handle_property_notify;
491 _ecore_x_event_handlers[SelectionClear] =
492 _ecore_x_event_handle_selection_clear;
493 _ecore_x_event_handlers[SelectionRequest] =
494 _ecore_x_event_handle_selection_request;
495 _ecore_x_event_handlers[SelectionNotify] =
496 _ecore_x_event_handle_selection_notify;
497 _ecore_x_event_handlers[ColormapNotify] =
498 _ecore_x_event_handle_colormap_notify;
499 _ecore_x_event_handlers[ClientMessage] =
500 _ecore_x_event_handle_client_message;
501 _ecore_x_event_handlers[MappingNotify] =
502 _ecore_x_event_handle_mapping_notify;
503#ifdef GenericEvent
504 _ecore_x_event_handlers[GenericEvent] = _ecore_x_event_handle_generic_event;
505#endif /* ifdef GenericEvent */
506
507 if (_ecore_x_event_shape_id)
508 _ecore_x_event_handlers[_ecore_x_event_shape_id] =
509 _ecore_x_event_handle_shape_change;
510
511 if (_ecore_x_event_screensaver_id)
512 _ecore_x_event_handlers[_ecore_x_event_screensaver_id] =
513 _ecore_x_event_handle_screensaver_notify;
514
515 if (_ecore_x_event_sync_id)
516 {
517 _ecore_x_event_handlers[_ecore_x_event_sync_id + XSyncCounterNotify] =
518 _ecore_x_event_handle_sync_counter;
519 _ecore_x_event_handlers[_ecore_x_event_sync_id + XSyncAlarmNotify] =
520 _ecore_x_event_handle_sync_alarm;
521 }
522
523#ifdef ECORE_XRANDR
524 if (_ecore_x_event_randr_id)
525 {
526 _ecore_x_event_handlers[_ecore_x_event_randr_id +
527 RRScreenChangeNotify] =
528 _ecore_x_event_handle_randr_change;
529 _ecore_x_event_handlers[_ecore_x_event_randr_id +
530 RRNotify] = _ecore_x_event_handle_randr_notify;
531 }
532
533#endif /* ifdef ECORE_XRANDR */
534#ifdef ECORE_XFIXES
535 if (_ecore_x_event_fixes_selection_id)
536 _ecore_x_event_handlers[_ecore_x_event_fixes_selection_id] =
537 _ecore_x_event_handle_fixes_selection_notify;
538
539#endif /* ifdef ECORE_XFIXES */
540#ifdef ECORE_XDAMAGE
541 if (_ecore_x_event_damage_id)
542 _ecore_x_event_handlers[_ecore_x_event_damage_id] =
543 _ecore_x_event_handle_damage_notify;
544
545#endif /* ifdef ECORE_XDAMAGE */
546#ifdef ECORE_XKB
547 // set x autorepeat detection to on. that means instead of
548 // press-release-press-release-press-release
549 // you get
550 // press-press-press-press-press-release
551 do
552 {
553 Bool works = 0;
554 XkbSetDetectableAutoRepeat(_ecore_x_disp, 1, &works);
555 }
556 while (0);
557 if (_ecore_x_event_xkb_id)
558 _ecore_x_event_handlers[_ecore_x_event_xkb_id] = _ecore_x_event_handle_xkb;
559#endif /* ifdef ECORE_XKB */
560
561#ifdef ECORE_XGESTURE
562 if (_ecore_x_event_gesture_id)
563 {
564 _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyFlick] =
565 _ecore_x_event_handle_gesture_notify_flick;
566 _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyPan] =
567 _ecore_x_event_handle_gesture_notify_pan;
568 _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyPinchRotation] =
569 _ecore_x_event_handle_gesture_notify_pinchrotation;
570 _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyTap] =
571 _ecore_x_event_handle_gesture_notify_tap;
572 _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyTapNHold] =
573 _ecore_x_event_handle_gesture_notify_tapnhold;
574 _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyHold] =
575 _ecore_x_event_handle_gesture_notify_hold;
576 _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyGroup] =
577 _ecore_x_event_handle_gesture_notify_group;
578 }
579
580#endif /* ifdef ECORE_XGESTURE */
581
582 if (!ECORE_X_EVENT_ANY)
583 {
584 ECORE_X_EVENT_ANY = ecore_event_type_new();
585 ECORE_X_EVENT_MOUSE_IN = ecore_event_type_new();
586 ECORE_X_EVENT_MOUSE_OUT = ecore_event_type_new();
587 ECORE_X_EVENT_WINDOW_FOCUS_IN = ecore_event_type_new();
588 ECORE_X_EVENT_WINDOW_FOCUS_OUT = ecore_event_type_new();
589 ECORE_X_EVENT_WINDOW_KEYMAP = ecore_event_type_new();
590 ECORE_X_EVENT_WINDOW_DAMAGE = ecore_event_type_new();
591 ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE = ecore_event_type_new();
592 ECORE_X_EVENT_WINDOW_CREATE = ecore_event_type_new();
593 ECORE_X_EVENT_WINDOW_DESTROY = ecore_event_type_new();
594 ECORE_X_EVENT_WINDOW_HIDE = ecore_event_type_new();
595 ECORE_X_EVENT_WINDOW_SHOW = ecore_event_type_new();
596 ECORE_X_EVENT_WINDOW_SHOW_REQUEST = ecore_event_type_new();
597 ECORE_X_EVENT_WINDOW_REPARENT = ecore_event_type_new();
598 ECORE_X_EVENT_WINDOW_CONFIGURE = ecore_event_type_new();
599 ECORE_X_EVENT_WINDOW_CONFIGURE_REQUEST = ecore_event_type_new();
600 ECORE_X_EVENT_WINDOW_GRAVITY = ecore_event_type_new();
601 ECORE_X_EVENT_WINDOW_RESIZE_REQUEST = ecore_event_type_new();
602 ECORE_X_EVENT_WINDOW_STACK = ecore_event_type_new();
603 ECORE_X_EVENT_WINDOW_STACK_REQUEST = ecore_event_type_new();
604 ECORE_X_EVENT_WINDOW_PROPERTY = ecore_event_type_new();
605 ECORE_X_EVENT_WINDOW_COLORMAP = ecore_event_type_new();
606 ECORE_X_EVENT_WINDOW_MAPPING = ecore_event_type_new();
607 ECORE_X_EVENT_MAPPING_CHANGE = ecore_event_type_new();
608 ECORE_X_EVENT_SELECTION_CLEAR = ecore_event_type_new();
609 ECORE_X_EVENT_SELECTION_REQUEST = ecore_event_type_new();
610 ECORE_X_EVENT_SELECTION_NOTIFY = ecore_event_type_new();
611 ECORE_X_EVENT_CLIENT_MESSAGE = ecore_event_type_new();
612 ECORE_X_EVENT_WINDOW_SHAPE = ecore_event_type_new();
613 ECORE_X_EVENT_SCREENSAVER_NOTIFY = ecore_event_type_new();
614 ECORE_X_EVENT_GESTURE_NOTIFY_FLICK = ecore_event_type_new();
615 ECORE_X_EVENT_GESTURE_NOTIFY_PAN = ecore_event_type_new();
616 ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION = ecore_event_type_new();
617 ECORE_X_EVENT_GESTURE_NOTIFY_TAP = ecore_event_type_new();
618 ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD = ecore_event_type_new();
619 ECORE_X_EVENT_GESTURE_NOTIFY_HOLD = ecore_event_type_new();
620 ECORE_X_EVENT_GESTURE_NOTIFY_GROUP = ecore_event_type_new();
621 ECORE_X_EVENT_SYNC_COUNTER = ecore_event_type_new();
622 ECORE_X_EVENT_SYNC_ALARM = ecore_event_type_new();
623 ECORE_X_EVENT_SCREEN_CHANGE = ecore_event_type_new();
624 ECORE_X_EVENT_RANDR_CRTC_CHANGE = ecore_event_type_new();
625 ECORE_X_EVENT_RANDR_OUTPUT_CHANGE = ecore_event_type_new();
626 ECORE_X_EVENT_RANDR_OUTPUT_PROPERTY_NOTIFY = ecore_event_type_new();
627 ECORE_X_EVENT_DAMAGE_NOTIFY = ecore_event_type_new();
628
629 ECORE_X_EVENT_WINDOW_DELETE_REQUEST = ecore_event_type_new();
630
631 ECORE_X_EVENT_DESKTOP_CHANGE = ecore_event_type_new();
632 ECORE_X_EVENT_WINDOW_MOVE_RESIZE_REQUEST = ecore_event_type_new();
633 ECORE_X_EVENT_WINDOW_STATE_REQUEST = ecore_event_type_new();
634 ECORE_X_EVENT_FRAME_EXTENTS_REQUEST = ecore_event_type_new();
635 ECORE_X_EVENT_PING = ecore_event_type_new();
636
637 ECORE_X_EVENT_STARTUP_SEQUENCE_NEW = ecore_event_type_new();
638 ECORE_X_EVENT_STARTUP_SEQUENCE_CHANGE = ecore_event_type_new();
639 ECORE_X_EVENT_STARTUP_SEQUENCE_REMOVE = ecore_event_type_new();
640
641 ECORE_X_EVENT_XKB_STATE_NOTIFY = ecore_event_type_new();
642 ECORE_X_EVENT_XKB_NEWKBD_NOTIFY = ecore_event_type_new();
643
644 ECORE_X_EVENT_GENERIC = ecore_event_type_new();
645
646 ECORE_X_RAW_BUTTON_PRESS = ecore_event_type_new();
647 ECORE_X_RAW_BUTTON_RELEASE = ecore_event_type_new();
648 ECORE_X_RAW_MOTION = ecore_event_type_new();
649 }
650
651 _ecore_x_modifiers_get();
652
653 _ecore_x_fd_handler_handle =
654 ecore_main_fd_handler_add(ConnectionNumber(_ecore_x_disp),
655 ECORE_FD_READ,
656 _ecore_x_fd_handler, _ecore_x_disp,
657 _ecore_x_fd_handler_buf, _ecore_x_disp);
658 if (!_ecore_x_fd_handler_handle)
659 goto free_event_handlers;
660
661 _ecore_x_atoms_init();
662
663 /* Set up the ICCCM hints */
664 ecore_x_icccm_init();
665
666 /* Set up the _NET_... hints */
667 ecore_x_netwm_init();
668
669 /* old e hints init */
670 ecore_x_e_init();
671
672 /* This is just to be anal about naming conventions */
673
674 _ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_DELETE_REQUEST] =
675 ECORE_X_ATOM_WM_DELETE_WINDOW;
676 _ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_TAKE_FOCUS] =
677 ECORE_X_ATOM_WM_TAKE_FOCUS;
678 _ecore_x_atoms_wm_protocols[ECORE_X_NET_WM_PROTOCOL_PING] =
679 ECORE_X_ATOM_NET_WM_PING;
680 _ecore_x_atoms_wm_protocols[ECORE_X_NET_WM_PROTOCOL_SYNC_REQUEST] =
681 ECORE_X_ATOM_NET_WM_SYNC_REQUEST;
682
683 _ecore_x_selection_data_init();
684 _ecore_x_dnd_init();
685 _ecore_x_fixes_init();
686 _ecore_x_damage_init();
687 _ecore_x_composite_init();
688 _ecore_x_dpms_init();
689 _ecore_x_randr_init();
690 _ecore_x_gesture_init();
691 _ecore_x_input_init();
692 _ecore_x_events_init();
693
694 _ecore_x_private_win = ecore_x_window_override_new(0, -77, -777, 123, 456);
695
696 return _ecore_x_init_count;
697
698free_event_handlers:
699 free(_ecore_x_event_handlers);
700 _ecore_x_event_handlers = NULL;
701close_display:
702 XCloseDisplay(_ecore_x_disp);
703 _ecore_x_fd_handler_handle = NULL;
704 _ecore_x_disp = NULL;
705shutdown_ecore_event:
706 ecore_event_shutdown();
707shutdown_ecore:
708 ecore_shutdown();
709shutdown_eina:
710 eina_log_domain_unregister(_ecore_xlib_log_dom);
711 _ecore_xlib_log_dom = -1;
712 eina_shutdown();
713
714 return --_ecore_x_init_count;
715}
716
717static int
718_ecore_x_shutdown(int close_display)
719{
720 if (--_ecore_x_init_count != 0)
721 return _ecore_x_init_count;
722
723 if (!_ecore_x_disp)
724 return _ecore_x_init_count;
725
726 LOGFN(__FILE__, __LINE__, __FUNCTION__);
727
728 ecore_main_fd_handler_del(_ecore_x_fd_handler_handle);
729 if (close_display)
730 XCloseDisplay(_ecore_x_disp);
731 else
732 {
733 close(ConnectionNumber(_ecore_x_disp));
734 // FIXME: may have to clean up x display internal here
735// getting segv here? hmmm. odd. disable
736// XFree(_ecore_x_disp);
737 }
738
739 free(_ecore_x_event_handlers);
740 _ecore_x_fd_handler_handle = NULL;
741 _ecore_x_disp = NULL;
742 _ecore_x_event_handlers = NULL;
743 _ecore_x_events_shutdown();
744 _ecore_x_input_shutdown();
745 _ecore_x_selection_shutdown();
746 _ecore_x_dnd_shutdown();
747 ecore_x_netwm_shutdown();
748
749 ecore_event_shutdown();
750 ecore_shutdown();
751
752 eina_log_domain_unregister(_ecore_xlib_log_dom);
753 _ecore_xlib_log_dom = -1;
754 eina_shutdown();
755
756 return _ecore_x_init_count;
757}
758
759/**
760 * Shuts down the Ecore X library.
761 *
762 * In shutting down the library, the X display connection is terminated
763 * and any event handlers for it are removed.
764 *
765 * @return The number of times the library has been initialized without
766 * being shut down. 0 is returned if an error occurs.
767 * @ingroup Ecore_X_Init_Group
768 */
769EAPI int
770ecore_x_shutdown(void)
771{
772 return _ecore_x_shutdown(1);
773}
774
775/**
776 * Shuts down the Ecore X library.
777 *
778 * As ecore_x_shutdown, except do not close Display, only connection.
779 *
780 * @ingroup Ecore_X_Init_Group
781 */
782EAPI int
783ecore_x_disconnect(void)
784{
785 return _ecore_x_shutdown(0);
786}
787
788/**
789 * @defgroup Ecore_X_Display_Attr_Group X Display Attributes
790 *
791 * Functions that set and retrieve X display attributes.
792 */
793
794/**
795 * Retrieves the Ecore_X_Display handle used for the current X connection.
796 * @return The current X display.
797 * @ingroup Ecore_X_Display_Attr_Group
798 */
799EAPI Ecore_X_Display *
800ecore_x_display_get(void)
801{
802 return (Ecore_X_Display *)_ecore_x_disp;
803}
804
805/**
806 * Retrieves the X display file descriptor.
807 * @return The current X display file descriptor.
808 * @ingroup Ecore_X_Display_Attr_Group
809 */
810EAPI int
811ecore_x_fd_get(void)
812{
813 LOGFN(__FILE__, __LINE__, __FUNCTION__);
814 return ConnectionNumber(_ecore_x_disp);
815}
816
817/**
818 * Retrieves the Ecore_X_Screen handle used for the current X connection.
819 * @return The current default screen.
820 * @ingroup Ecore_X_Display_Attr_Group
821 */
822EAPI Ecore_X_Screen *
823ecore_x_default_screen_get(void)
824{
825 LOGFN(__FILE__, __LINE__, __FUNCTION__);
826 return (Ecore_X_Screen *)DefaultScreenOfDisplay(_ecore_x_disp);
827}
828
829/**
830 * Retrieves the size of an Ecore_X_Screen.
831 * @param screen the handle to the screen to query.
832 * @param w where to return the width. May be NULL. Returns 0 on errors.
833 * @param h where to return the height. May be NULL. Returns 0 on errors.
834 * @ingroup Ecore_X_Display_Attr_Group
835 * @see ecore_x_default_screen_get()
836 *
837 * @since 1.1
838 */
839EAPI void
840ecore_x_screen_size_get(const Ecore_X_Screen *screen,
841 int *w,
842 int *h)
843{
844 Screen *s = (Screen *)screen;
845 LOGFN(__FILE__, __LINE__, __FUNCTION__);
846 if (w) *w = 0;
847 if (h) *h = 0;
848 if (!s) return;
849 if (w) *w = s->width;
850 if (h) *h = s->height;
851}
852
853/**
854 * Retrieves the number of screens.
855 *
856 * @return The count of the number of screens.
857 * @ingroup Ecore_X_Display_Attr_Group
858 *
859 * @since 1.1
860 */
861EAPI int
862ecore_x_screen_count_get(void)
863{
864 LOGFN(__FILE__, __LINE__, __FUNCTION__);
865
866 return ScreenCount(_ecore_x_disp);
867}
868
869/**
870 * Retrieves the index number of the given screen.
871 *
872 * @param screen The screen for which the index will be retrieved.
873 * @return The index number of the screen.
874 * @ingroup Ecore_X_Display_Attr_Group
875 *
876 * @since 1.1
877 */
878EAPI int
879ecore_x_screen_index_get(const Ecore_X_Screen *screen)
880{
881 return XScreenNumberOfScreen((Screen *)screen);
882}
883
884/**
885 * Retrieves the screen based on index number.
886 *
887 * @param idx The index that will be used to retrieve the screen.
888 * @return The Ecore_X_Screen at this index.
889 * @ingroup Ecore_X_Display_Attr_Group
890 *
891 * @since 1.1
892 */
893EAPI Ecore_X_Screen *
894ecore_x_screen_get(int idx)
895{
896 return XScreenOfDisplay(_ecore_x_disp, idx);
897}
898
899/**
900 * Sets the timeout for a double and triple clicks to be flagged.
901 *
902 * This sets the time between clicks before the double_click flag is
903 * set in a button down event. If 3 clicks occur within double this
904 * time, the triple_click flag is also set.
905 *
906 * @param t The time in seconds
907 * @ingroup Ecore_X_Display_Attr_Group
908 */
909EAPI void
910ecore_x_double_click_time_set(double t)
911{
912 if (t < 0.0)
913 t = 0.0;
914
915 _ecore_x_double_click_time = t;
916}
917
918/**
919 * Retrieves the double and triple click flag timeout.
920 *
921 * See @ref ecore_x_double_click_time_set for more information.
922 *
923 * @return The timeout for double clicks in seconds.
924 * @ingroup Ecore_X_Display_Attr_Group
925 */
926EAPI double
927ecore_x_double_click_time_get(void)
928{
929 return _ecore_x_double_click_time;
930}
931
932/**
933 * @defgroup Ecore_X_Flush_Group X Synchronization Functions
934 *
935 * Functions that ensure that all commands that have been issued by the
936 * Ecore X library have been sent to the server.
937 */
938
939/**
940 * Sends all X commands in the X Display buffer.
941 * @ingroup Ecore_X_Flush_Group
942 */
943EAPI void
944ecore_x_flush(void)
945{
946 LOGFN(__FILE__, __LINE__, __FUNCTION__);
947 XFlush(_ecore_x_disp);
948}
949
950/**
951 * Flushes the command buffer and waits until all requests have been
952 * processed by the server.
953 * @ingroup Ecore_X_Flush_Group
954 */
955EAPI void
956ecore_x_sync(void)
957{
958 LOGFN(__FILE__, __LINE__, __FUNCTION__);
959 XSync(_ecore_x_disp, False);
960}
961
962/**
963 * Kill all clients with subwindows under a given window.
964 *
965 * You can kill all clients connected to the X server by using
966 * @ref ecore_x_window_root_list to get a list of root windows, and
967 * then passing each root window to this function.
968 *
969 * @param root The window whose children will be killed.
970 */
971EAPI void
972ecore_x_killall(Ecore_X_Window root)
973{
974 unsigned int j;
975 Window root_r;
976 Window parent_r;
977 Window *children_r = NULL;
978 unsigned int num_children = 0;
979
980 LOGFN(__FILE__, __LINE__, __FUNCTION__);
981 XGrabServer(_ecore_x_disp);
982 /* Tranverse window tree starting from root, and drag each
983 * before the firing squad */
984 while (XQueryTree(_ecore_x_disp, root, &root_r, &parent_r,
985 &children_r, &num_children) && (num_children > 0))
986 {
987 for (j = 0; j < num_children; ++j)
988 {
989 XKillClient(_ecore_x_disp, children_r[j]);
990 }
991
992 XFree(children_r);
993 }
994 XUngrabServer(_ecore_x_disp);
995 XSync(_ecore_x_disp, False);
996}
997
998/**
999 * Kill a specific client
1000 *
1001 * You can kill a specific client owning window @p win
1002 *
1003 * @param win Window of the client to be killed
1004 */
1005EAPI void
1006ecore_x_kill(Ecore_X_Window win)
1007{
1008 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1009 XKillClient(_ecore_x_disp, win);
1010}
1011
1012/**
1013 * Return the last event time
1014 */
1015EAPI Ecore_X_Time
1016ecore_x_current_time_get(void)
1017{
1018 return _ecore_x_event_last_time;
1019}
1020
1021/**
1022 * Return the screen DPI
1023 *
1024 * This is a simplistic call to get DPI. It does not account for differing
1025 * DPI in the x amd y axes nor does it account for multihead or xinerama and
1026 * xrander where different parts of the screen may have different DPI etc.
1027 *
1028 * @return the general screen DPI (dots/pixels per inch).
1029 */
1030EAPI int
1031ecore_x_dpi_get(void)
1032{
1033 Screen *s;
1034
1035 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1036 s = DefaultScreenOfDisplay(_ecore_x_disp);
1037 if (s->mwidth <= 0)
1038 return 75;
1039
1040 return (((s->width * 254) / s->mwidth) + 5) / 10;
1041}
1042
1043/**
1044 * Invoke the standard system beep to alert users
1045 *
1046 * @param percent The volume at which the bell rings. Must be in the range
1047 * [-100,+100]. If percent >= 0, the final volume will be:
1048 * base - [(base * percent) / 100] + percent
1049 * Otherwise, it's calculated as:
1050 * base + [(base * percent) / 100]
1051 * where @c base is the bell's base volume as set by XChangeKeyboardControl(3).
1052 *
1053 * @returns @c EINA_TRUE on success, @c EINA_FALSE otherwise.
1054 */
1055EAPI Eina_Bool
1056ecore_x_bell(int percent)
1057{
1058 int ret;
1059
1060 ret = XBell(_ecore_x_disp, percent);
1061 if (ret == BadValue)
1062 return EINA_FALSE;
1063
1064 return EINA_TRUE;
1065}
1066
1067static Eina_Bool
1068_ecore_x_fd_handler(void *data,
1069 Ecore_Fd_Handler *fd_handler EINA_UNUSED)
1070{
1071 Display *d;
1072
1073 d = data;
1074 while (XPending(d))
1075 {
1076 XEvent ev;
1077
1078 XNextEvent(d, &ev);
1079#ifdef ENABLE_XIM
1080 /* Filter event for XIM */
1081 if (XFilterEvent(&ev, ev.xkey.window))
1082 continue;
1083
1084#endif /* ifdef ENABLE_XIM */
1085 if ((ev.type >= 0) && (ev.type < _ecore_x_event_handlers_num))
1086 {
1087 if (_ecore_x_event_handlers[AnyXEvent])
1088 _ecore_x_event_handlers[AnyXEvent] (&ev);
1089
1090 if (_ecore_x_event_handlers[ev.type])
1091 _ecore_x_event_handlers[ev.type] (&ev);
1092 }
1093 }
1094 return ECORE_CALLBACK_RENEW;
1095}
1096
1097static Eina_Bool
1098_ecore_x_fd_handler_buf(void *data,
1099 Ecore_Fd_Handler *fd_handler EINA_UNUSED)
1100{
1101 Display *d;
1102
1103 d = data;
1104 if (XPending(d))
1105 return ECORE_CALLBACK_RENEW;
1106
1107 return ECORE_CALLBACK_CANCEL;
1108}
1109
1110static int
1111_ecore_x_key_mask_get(KeySym sym)
1112{
1113 XModifierKeymap *mod;
1114 KeySym sym2;
1115 int i, j;
1116 const int masks[8] =
1117 {
1118 ShiftMask, LockMask, ControlMask,
1119 Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
1120 };
1121
1122 mod = XGetModifierMapping(_ecore_x_disp);
1123 if ((mod) && (mod->max_keypermod > 0))
1124 for (i = 0; i < (8 * mod->max_keypermod); i++)
1125 {
1126 for (j = 0; j < 8; j++)
1127 {
1128 sym2 = _ecore_x_XKeycodeToKeysym(_ecore_x_disp,
1129 mod->modifiermap[i], j);
1130 if (sym2 != 0)
1131 break;
1132 }
1133 if (sym2 == sym)
1134 {
1135 int mask;
1136
1137 mask = masks[i / mod->max_keypermod];
1138 if (mod->modifiermap)
1139 XFree(mod->modifiermap);
1140
1141 XFree(mod);
1142 return mask;
1143 }
1144 }
1145
1146 if (mod)
1147 {
1148 if (mod->modifiermap)
1149 XFree(mod->modifiermap);
1150
1151 XFree(mod);
1152 }
1153
1154 return 0;
1155}
1156
1157/*****************************************************************************/
1158/*****************************************************************************/
1159/*****************************************************************************/
1160/* FIXME: these funcs need categorising */
1161/*****************************************************************************/
1162
1163/**
1164 * Get a list of all the root windows on the server.
1165 *
1166 * @note The returned array will need to be freed after use.
1167 * @param num_ret Pointer to integer to put number of windows returned in.
1168 * @return An array of all the root windows. @c NULL is returned if memory
1169 * could not be allocated for the list, or if @p num_ret is @c NULL.
1170 */
1171EAPI Ecore_X_Window *
1172ecore_x_window_root_list(int *num_ret)
1173{
1174 int num, i;
1175 Ecore_X_Window *roots;
1176#ifdef ECORE_XPRINT
1177 int xp_base, xp_err_base;
1178#endif /* ifdef ECORE_XPRINT */
1179
1180 if (!num_ret)
1181 return NULL;
1182
1183 *num_ret = 0;
1184
1185 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1186#ifdef ECORE_XPRINT
1187 num = ScreenCount(_ecore_x_disp);
1188 if (XpQueryExtension(_ecore_x_disp, &xp_base, &xp_err_base))
1189 {
1190 Screen **ps = NULL;
1191 int psnum = 0;
1192
1193 ps = XpQueryScreens(_ecore_x_disp, &psnum);
1194 if (ps)
1195 {
1196 int overlap, j;
1197
1198 overlap = 0;
1199 for (i = 0; i < num; i++)
1200 {
1201 for (j = 0; j < psnum; j++)
1202 {
1203 if (ScreenOfDisplay(_ecore_x_disp, i) == ps[j])
1204 overlap++;
1205 }
1206 }
1207 roots = malloc(MAX((num - overlap) * sizeof(Window), 1));
1208 if (roots)
1209 {
1210 int k;
1211
1212 k = 0;
1213 for (i = 0; i < num; i++)
1214 {
1215 int is_print;
1216
1217 is_print = 0;
1218 for (j = 0; j < psnum; j++)
1219 {
1220 if (ScreenOfDisplay(_ecore_x_disp, i) == ps[j])
1221 {
1222 is_print = 1;
1223 break;
1224 }
1225 }
1226 if (!is_print)
1227 {
1228 roots[k] = RootWindow(_ecore_x_disp, i);
1229 k++;
1230 }
1231 }
1232 *num_ret = k;
1233 }
1234
1235 XFree(ps);
1236 }
1237 else
1238 {
1239 roots = malloc(num * sizeof(Window));
1240 if (!roots)
1241 return NULL;
1242
1243 *num_ret = num;
1244 for (i = 0; i < num; i++)
1245 roots[i] = RootWindow(_ecore_x_disp, i);
1246 }
1247 }
1248 else
1249 {
1250 roots = malloc(num * sizeof(Window));
1251 if (!roots)
1252 return NULL;
1253
1254 *num_ret = num;
1255 for (i = 0; i < num; i++)
1256 roots[i] = RootWindow(_ecore_x_disp, i);
1257 }
1258
1259#else /* ifdef ECORE_XPRINT */
1260 num = ScreenCount(_ecore_x_disp);
1261 roots = malloc(num * sizeof(Window));
1262 if (!roots)
1263 return NULL;
1264
1265 *num_ret = num;
1266 for (i = 0; i < num; i++)
1267 roots[i] = RootWindow(_ecore_x_disp, i);
1268#endif /* ifdef ECORE_XPRINT */
1269 return roots;
1270}
1271
1272EAPI Ecore_X_Window
1273ecore_x_window_root_first_get(void)
1274{
1275 return RootWindow(_ecore_x_disp, 0);
1276/*
1277 int num;
1278 Ecore_X_Window root, *roots = NULL;
1279
1280 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1281 roots = ecore_x_window_root_list(&num);
1282 if (!(roots)) return 0;
1283
1284 if (num > 0)
1285 root = roots[0];
1286 else
1287 root = 0;
1288
1289 free(roots);
1290 return root;
1291 */
1292}
1293
1294static void _ecore_x_window_manage_error(void *data);
1295
1296static int _ecore_x_window_manage_failed = 0;
1297static void
1298_ecore_x_window_manage_error(void *data EINA_UNUSED)
1299{
1300 if ((ecore_x_error_request_get() == X_ChangeWindowAttributes) &&
1301 (ecore_x_error_code_get() == BadAccess))
1302 _ecore_x_window_manage_failed = 1;
1303}
1304
1305EAPI Eina_Bool
1306ecore_x_window_manage(Ecore_X_Window win)
1307{
1308 XWindowAttributes att;
1309
1310 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1311 if (XGetWindowAttributes(_ecore_x_disp, win, &att) != True)
1312 return EINA_FALSE;
1313
1314 ecore_x_sync();
1315 _ecore_x_window_manage_failed = 0;
1316 ecore_x_error_handler_set(_ecore_x_window_manage_error, NULL);
1317 XSelectInput(_ecore_x_disp, win,
1318 EnterWindowMask |
1319 LeaveWindowMask |
1320 PropertyChangeMask |
1321 ResizeRedirectMask |
1322 SubstructureRedirectMask |
1323 SubstructureNotifyMask |
1324 StructureNotifyMask |
1325 KeyPressMask |
1326 KeyReleaseMask |
1327 att.your_event_mask);
1328 ecore_x_sync();
1329 ecore_x_error_handler_set(NULL, NULL);
1330 if (_ecore_x_window_manage_failed)
1331 {
1332 _ecore_x_window_manage_failed = 0;
1333 return EINA_FALSE;
1334 }
1335
1336 return EINA_TRUE;
1337}
1338
1339EAPI void
1340ecore_x_window_container_manage(Ecore_X_Window win)
1341{
1342 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1343 XSelectInput(_ecore_x_disp, win,
1344 SubstructureRedirectMask |
1345 SubstructureNotifyMask);
1346}
1347
1348EAPI void
1349ecore_x_window_client_manage(Ecore_X_Window win)
1350{
1351 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1352 XSelectInput(_ecore_x_disp, win,
1353 PropertyChangeMask |
1354// ResizeRedirectMask |
1355 FocusChangeMask |
1356 ColormapChangeMask |
1357 VisibilityChangeMask |
1358 StructureNotifyMask |
1359 SubstructureNotifyMask
1360 );
1361 XShapeSelectInput(_ecore_x_disp, win, ShapeNotifyMask);
1362}
1363
1364EAPI void
1365ecore_x_window_sniff(Ecore_X_Window win)
1366{
1367 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1368 XSelectInput(_ecore_x_disp, win,
1369 PropertyChangeMask |
1370 SubstructureNotifyMask);
1371}
1372
1373EAPI void
1374ecore_x_window_client_sniff(Ecore_X_Window win)
1375{
1376 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1377 XSelectInput(_ecore_x_disp, win,
1378 PropertyChangeMask |
1379 FocusChangeMask |
1380 ColormapChangeMask |
1381 VisibilityChangeMask |
1382 StructureNotifyMask |
1383 SubstructureNotifyMask);
1384 XShapeSelectInput(_ecore_x_disp, win, ShapeNotifyMask);
1385}
1386
1387EAPI Eina_Bool
1388ecore_x_window_attributes_get(Ecore_X_Window win,
1389 Ecore_X_Window_Attributes *att_ret)
1390{
1391 XWindowAttributes att;
1392
1393 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1394 if (!XGetWindowAttributes(_ecore_x_disp, win, &att))
1395 return EINA_FALSE;
1396
1397 memset(att_ret, 0, sizeof(Ecore_X_Window_Attributes));
1398 att_ret->root = att.root;
1399 att_ret->x = att.x;
1400 att_ret->y = att.y;
1401 att_ret->w = att.width;
1402 att_ret->h = att.height;
1403 att_ret->border = att.border_width;
1404 att_ret->depth = att.depth;
1405 if (att.map_state != IsUnmapped)
1406 att_ret->visible = 1;
1407
1408 if (att.map_state == IsViewable)
1409 att_ret->viewable = 1;
1410
1411 if (att.override_redirect)
1412 att_ret->override = 1;
1413
1414 if (att.class == InputOnly)
1415 att_ret->input_only = 1;
1416
1417 if (att.save_under)
1418 att_ret->save_under = 1;
1419
1420 att_ret->event_mask.mine = att.your_event_mask;
1421 att_ret->event_mask.all = att.all_event_masks;
1422 att_ret->event_mask.no_propagate = att.do_not_propagate_mask;
1423 att_ret->window_gravity = att.win_gravity;
1424 att_ret->pixel_gravity = att.bit_gravity;
1425 att_ret->colormap = att.colormap;
1426 att_ret->visual = att.visual;
1427 return EINA_TRUE;
1428}
1429
1430EAPI void
1431ecore_x_window_save_set_add(Ecore_X_Window win)
1432{
1433 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1434 XAddToSaveSet(_ecore_x_disp, win);
1435}
1436
1437EAPI void
1438ecore_x_window_save_set_del(Ecore_X_Window win)
1439{
1440 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1441 XRemoveFromSaveSet(_ecore_x_disp, win);
1442}
1443
1444EAPI Ecore_X_Window *
1445ecore_x_window_children_get(Ecore_X_Window win,
1446 int *num)
1447{
1448 Ecore_X_Window *windows = NULL;
1449 Window root_ret = 0, parent_ret = 0, *children_ret = NULL;
1450 unsigned int children_ret_num = 0;
1451
1452 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1453 if (!XQueryTree(_ecore_x_disp, win, &root_ret, &parent_ret, &children_ret,
1454 &children_ret_num))
1455 return NULL;
1456
1457 if (children_ret)
1458 {
1459 windows = malloc(children_ret_num * sizeof(Ecore_X_Window));
1460 if (windows)
1461 {
1462 unsigned int i;
1463
1464 for (i = 0; i < children_ret_num; i++)
1465 windows[i] = children_ret[i];
1466 *num = children_ret_num;
1467 }
1468
1469 XFree(children_ret);
1470 }
1471
1472 return windows;
1473}
1474
1475EAPI Eina_Bool
1476ecore_x_pointer_control_set(int accel_num,
1477 int accel_denom,
1478 int threshold)
1479{
1480 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1481 return XChangePointerControl(_ecore_x_disp, 1, 1,
1482 accel_num, accel_denom, threshold) ? EINA_TRUE : EINA_FALSE;
1483}
1484
1485EAPI Eina_Bool
1486ecore_x_pointer_control_get(int *accel_num,
1487 int *accel_denom,
1488 int *threshold)
1489{
1490 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1491 return XGetPointerControl(_ecore_x_disp,
1492 accel_num, accel_denom, threshold) ? EINA_TRUE : EINA_FALSE;
1493}
1494
1495EAPI Eina_Bool
1496ecore_x_pointer_mapping_set(unsigned char *map,
1497 int nmap)
1498{
1499 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1500 return (XSetPointerMapping(_ecore_x_disp, map, nmap) == MappingSuccess) ? EINA_TRUE : EINA_FALSE;
1501}
1502
1503EAPI Eina_Bool
1504ecore_x_pointer_mapping_get(unsigned char *map,
1505 int nmap)
1506{
1507 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1508 return XGetPointerMapping(_ecore_x_disp, map, nmap) ? EINA_TRUE : EINA_FALSE;
1509}
1510
1511EAPI Eina_Bool
1512ecore_x_pointer_grab(Ecore_X_Window win)
1513{
1514 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1515 if (XGrabPointer(_ecore_x_disp, win, False,
1516 ButtonPressMask | ButtonReleaseMask |
1517 EnterWindowMask | LeaveWindowMask | PointerMotionMask,
1518 GrabModeAsync, GrabModeAsync,
1519 None, None, CurrentTime) == GrabSuccess)
1520 return EINA_TRUE;
1521
1522 return EINA_FALSE;
1523}
1524
1525EAPI Eina_Bool
1526ecore_x_pointer_confine_grab(Ecore_X_Window win)
1527{
1528 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1529 if (XGrabPointer(_ecore_x_disp, win, False,
1530 ButtonPressMask | ButtonReleaseMask |
1531 EnterWindowMask | LeaveWindowMask | PointerMotionMask,
1532 GrabModeAsync, GrabModeAsync,
1533 win, None, CurrentTime) == GrabSuccess)
1534 return EINA_TRUE;
1535
1536 return EINA_FALSE;
1537}
1538
1539EAPI void
1540ecore_x_pointer_ungrab(void)
1541{
1542 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1543 XUngrabPointer(_ecore_x_disp, CurrentTime);
1544}
1545
1546EAPI Eina_Bool
1547ecore_x_pointer_warp(Ecore_X_Window win,
1548 int x,
1549 int y)
1550{
1551 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1552 return XWarpPointer(_ecore_x_disp, None, win, 0, 0, 0, 0, x, y) ? EINA_TRUE : EINA_FALSE;
1553}
1554
1555EAPI Eina_Bool
1556ecore_x_keyboard_grab(Ecore_X_Window win)
1557{
1558 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1559 if (XGrabKeyboard(_ecore_x_disp, win, False,
1560 GrabModeAsync, GrabModeAsync,
1561 CurrentTime) == GrabSuccess)
1562 return EINA_TRUE;
1563
1564 return EINA_FALSE;
1565}
1566
1567EAPI void
1568ecore_x_keyboard_ungrab(void)
1569{
1570 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1571 XUngrabKeyboard(_ecore_x_disp, CurrentTime);
1572}
1573
1574EAPI void
1575ecore_x_grab(void)
1576{
1577 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1578 _ecore_x_grab_count++;
1579 if (_ecore_x_grab_count == 1)
1580 XGrabServer(_ecore_x_disp);
1581}
1582
1583EAPI void
1584ecore_x_ungrab(void)
1585{
1586 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1587 _ecore_x_grab_count--;
1588 if (_ecore_x_grab_count < 0)
1589 _ecore_x_grab_count = 0;
1590
1591 if (_ecore_x_grab_count == 0)
1592 XUngrabServer(_ecore_x_disp);
1593}
1594
1595int _ecore_window_grabs_num = 0;
1596Window *_ecore_window_grabs = NULL;
1597Eina_Bool (*_ecore_window_grab_replay_func)(void *data,
1598 int event_type,
1599 void *event);
1600void *_ecore_window_grab_replay_data;
1601
1602EAPI void
1603ecore_x_passive_grab_replay_func_set(Eina_Bool (*func)(void *data,
1604 int event_type,
1605 void *event),
1606 void *data)
1607{
1608 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1609 _ecore_window_grab_replay_func = func;
1610 _ecore_window_grab_replay_data = data;
1611}
1612
1613EAPI void
1614ecore_x_window_button_grab(Ecore_X_Window win,
1615 int button,
1616 Ecore_X_Event_Mask event_mask,
1617 int mod,
1618 int any_mod)
1619{
1620 unsigned int b;
1621 unsigned int m;
1622 unsigned int locks[8];
1623 int i, ev;
1624 Window *t;
1625
1626 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1627 b = button;
1628 if (b == 0)
1629 b = AnyButton;
1630
1631 m = _ecore_x_event_modifier(mod);
1632 if (any_mod)
1633 m = AnyModifier;
1634
1635 locks[0] = 0;
1636 locks[1] = ECORE_X_LOCK_CAPS;
1637 locks[2] = ECORE_X_LOCK_NUM;
1638 locks[3] = ECORE_X_LOCK_SCROLL;
1639 locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
1640 locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
1641 locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1642 locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1643 ev = event_mask;
1644 for (i = 0; i < 8; i++)
1645 XGrabButton(_ecore_x_disp, b, m | locks[i],
1646 win, False, ev, GrabModeSync, GrabModeAsync, None, None);
1647 _ecore_window_grabs_num++;
1648 t = realloc(_ecore_window_grabs,
1649 _ecore_window_grabs_num * sizeof(Window));
1650 if (!t) return;
1651 _ecore_window_grabs = t;
1652 _ecore_window_grabs[_ecore_window_grabs_num - 1] = win;
1653}
1654
1655void
1656_ecore_x_sync_magic_send(int val,
1657 Ecore_X_Window swin)
1658{
1659 XEvent xev;
1660
1661 xev.xclient.type = ClientMessage;
1662 xev.xclient.serial = 0;
1663 xev.xclient.send_event = True;
1664 xev.xclient.display = _ecore_x_disp;
1665 xev.xclient.window = _ecore_x_private_win;
1666 xev.xclient.format = 32;
1667 xev.xclient.message_type = 27777;
1668 xev.xclient.data.l[0] = 0x7162534;
1669 xev.xclient.data.l[1] = 0x10000000 + val;
1670 xev.xclient.data.l[2] = swin;
1671 XSendEvent(_ecore_x_disp, _ecore_x_private_win, False, NoEventMask, &xev);
1672}
1673
1674void
1675_ecore_x_window_grab_remove(Ecore_X_Window win)
1676{
1677 int i, shuffle = 0;
1678 Window *t;
1679
1680 if (_ecore_window_grabs_num > 0)
1681 {
1682 for (i = 0; i < _ecore_window_grabs_num; i++)
1683 {
1684 if (shuffle)
1685 _ecore_window_grabs[i - 1] = _ecore_window_grabs[i];
1686
1687 if ((!shuffle) && (_ecore_window_grabs[i] == win))
1688 shuffle = 1;
1689 }
1690 if (shuffle)
1691 {
1692 _ecore_window_grabs_num--;
1693 if (_ecore_window_grabs_num <= 0)
1694 {
1695 free(_ecore_window_grabs);
1696 _ecore_window_grabs = NULL;
1697 return;
1698 }
1699 t = realloc(_ecore_window_grabs,
1700 _ecore_window_grabs_num *
1701 sizeof(Window));
1702 if (!t) return;
1703 _ecore_window_grabs = t;
1704 }
1705 }
1706}
1707
1708EAPI void
1709ecore_x_window_button_ungrab(Ecore_X_Window win,
1710 int button,
1711 int mod,
1712 int any_mod)
1713{
1714 unsigned int b;
1715 unsigned int m;
1716 unsigned int locks[8];
1717 int i;
1718
1719 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1720 b = button;
1721 if (b == 0)
1722 b = AnyButton;
1723
1724 m = _ecore_x_event_modifier(mod);
1725 if (any_mod)
1726 m = AnyModifier;
1727
1728 locks[0] = 0;
1729 locks[1] = ECORE_X_LOCK_CAPS;
1730 locks[2] = ECORE_X_LOCK_NUM;
1731 locks[3] = ECORE_X_LOCK_SCROLL;
1732 locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
1733 locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
1734 locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1735 locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1736 for (i = 0; i < 8; i++)
1737 XUngrabButton(_ecore_x_disp, b, m | locks[i], win);
1738 _ecore_x_sync_magic_send(1, win);
1739}
1740
1741int _ecore_key_grabs_num = 0;
1742Window *_ecore_key_grabs = NULL;
1743
1744EAPI void
1745ecore_x_window_key_grab(Ecore_X_Window win,
1746 const char *key,
1747 int mod,
1748 int any_mod)
1749{
1750 KeyCode keycode = 0;
1751 KeySym keysym;
1752 unsigned int m;
1753 unsigned int locks[8];
1754 int i;
1755 Window *t;
1756
1757 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1758 if (!strncmp(key, "Keycode-", 8))
1759 keycode = atoi(key + 8);
1760 else
1761 {
1762 keysym = XStringToKeysym(key);
1763 if (keysym == NoSymbol)
1764 return;
1765
1766 keycode = XKeysymToKeycode(_ecore_x_disp, XStringToKeysym(key));
1767 }
1768
1769 if (keycode == 0)
1770 return;
1771
1772 m = _ecore_x_event_modifier(mod);
1773 if (any_mod)
1774 m = AnyModifier;
1775
1776 locks[0] = 0;
1777 locks[1] = ECORE_X_LOCK_CAPS;
1778 locks[2] = ECORE_X_LOCK_NUM;
1779 locks[3] = ECORE_X_LOCK_SCROLL;
1780 locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
1781 locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
1782 locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1783 locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1784 for (i = 0; i < 8; i++)
1785 XGrabKey(_ecore_x_disp, keycode, m | locks[i],
1786 win, False, GrabModeSync, GrabModeAsync);
1787 _ecore_key_grabs_num++;
1788 t = realloc(_ecore_key_grabs,
1789 _ecore_key_grabs_num * sizeof(Window));
1790 if (!t) return;
1791 _ecore_key_grabs = t;
1792 _ecore_key_grabs[_ecore_key_grabs_num - 1] = win;
1793}
1794
1795void
1796_ecore_x_key_grab_remove(Ecore_X_Window win)
1797{
1798 int i, shuffle = 0;
1799 Window *t;
1800
1801 if (_ecore_key_grabs_num > 0)
1802 {
1803 for (i = 0; i < _ecore_key_grabs_num; i++)
1804 {
1805 if (shuffle)
1806 _ecore_key_grabs[i - 1] = _ecore_key_grabs[i];
1807
1808 if ((!shuffle) && (_ecore_key_grabs[i] == win))
1809 shuffle = 1;
1810 }
1811 if (shuffle)
1812 {
1813 _ecore_key_grabs_num--;
1814 if (_ecore_key_grabs_num <= 0)
1815 {
1816 free(_ecore_key_grabs);
1817 _ecore_key_grabs = NULL;
1818 return;
1819 }
1820 t = realloc(_ecore_key_grabs,
1821 _ecore_key_grabs_num * sizeof(Window));
1822 if (!t) return;
1823 _ecore_key_grabs = t;
1824 }
1825 }
1826}
1827
1828EAPI void
1829ecore_x_window_key_ungrab(Ecore_X_Window win,
1830 const char *key,
1831 int mod,
1832 int any_mod)
1833{
1834 KeyCode keycode = 0;
1835 KeySym keysym;
1836 unsigned int m;
1837 unsigned int locks[8];
1838 int i;
1839
1840 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1841 if (!strncmp(key, "Keycode-", 8))
1842 keycode = atoi(key + 8);
1843 else
1844 {
1845 keysym = XStringToKeysym(key);
1846 if (keysym == NoSymbol)
1847 return;
1848
1849 keycode = XKeysymToKeycode(_ecore_x_disp, XStringToKeysym(key));
1850 }
1851
1852 if (keycode == 0)
1853 return;
1854
1855 m = _ecore_x_event_modifier(mod);
1856 if (any_mod)
1857 m = AnyModifier;
1858
1859 locks[0] = 0;
1860 locks[1] = ECORE_X_LOCK_CAPS;
1861 locks[2] = ECORE_X_LOCK_NUM;
1862 locks[3] = ECORE_X_LOCK_SCROLL;
1863 locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
1864 locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
1865 locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1866 locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1867 for (i = 0; i < 8; i++)
1868 XUngrabKey(_ecore_x_disp, keycode, m | locks[i], win);
1869 _ecore_x_sync_magic_send(2, win);
1870}
1871
1872/**
1873 * Send client message with given type and format 32.
1874 *
1875 * @param win The window the message is sent to.
1876 * @param type The client message type.
1877 * @param mask The mask of the message to be sent.
1878 * @param d0 The client message data item 1
1879 * @param d1 The client message data item 2
1880 * @param d2 The client message data item 3
1881 * @param d3 The client message data item 4
1882 * @param d4 The client message data item 5
1883 *
1884 * @return @c EINA_TRUE on success @c EINA_FALSE otherwise.
1885 */
1886EAPI Eina_Bool
1887ecore_x_client_message32_send(Ecore_X_Window win,
1888 Ecore_X_Atom type,
1889 Ecore_X_Event_Mask mask,
1890 long d0,
1891 long d1,
1892 long d2,
1893 long d3,
1894 long d4)
1895{
1896 XEvent xev;
1897
1898 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1899 xev.xclient.window = win;
1900 xev.xclient.type = ClientMessage;
1901 xev.xclient.message_type = type;
1902 xev.xclient.format = 32;
1903 xev.xclient.data.l[0] = d0;
1904 xev.xclient.data.l[1] = d1;
1905 xev.xclient.data.l[2] = d2;
1906 xev.xclient.data.l[3] = d3;
1907 xev.xclient.data.l[4] = d4;
1908
1909 return XSendEvent(_ecore_x_disp, win, False, mask, &xev) ? EINA_TRUE : EINA_FALSE;
1910}
1911
1912/**
1913 * Send client message with given type and format 8.
1914 *
1915 * @param win The window the message is sent to.
1916 * @param type The client message type.
1917 * @param data Data to be sent.
1918 * @param len Number of data bytes, max @c 20.
1919 *
1920 * @return @c EINA_TRUE on success, @c EINA_FALSE otherwise.
1921 */
1922EAPI Eina_Bool
1923ecore_x_client_message8_send(Ecore_X_Window win,
1924 Ecore_X_Atom type,
1925 const void *data,
1926 int len)
1927{
1928 XEvent xev;
1929
1930 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1931 xev.xclient.window = win;
1932 xev.xclient.type = ClientMessage;
1933 xev.xclient.message_type = type;
1934 xev.xclient.format = 8;
1935 if (len > 20)
1936 len = 20;
1937
1938 memcpy(xev.xclient.data.b, data, len);
1939 memset(xev.xclient.data.b + len, 0, 20 - len);
1940
1941 return XSendEvent(_ecore_x_disp, win, False, NoEventMask, &xev) ? EINA_TRUE : EINA_FALSE;
1942}
1943
1944EAPI Eina_Bool
1945ecore_x_mouse_move_send(Ecore_X_Window win,
1946 int x,
1947 int y)
1948{
1949 XEvent xev;
1950 XWindowAttributes att;
1951 Window tw;
1952 int rx, ry;
1953
1954 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1955 XGetWindowAttributes(_ecore_x_disp, win, &att);
1956 XTranslateCoordinates(_ecore_x_disp, win, att.root, x, y, &rx, &ry, &tw);
1957 xev.xmotion.type = MotionNotify;
1958 xev.xmotion.window = win;
1959 xev.xmotion.root = att.root;
1960 xev.xmotion.subwindow = win;
1961 xev.xmotion.time = _ecore_x_event_last_time;
1962 xev.xmotion.x = x;
1963 xev.xmotion.y = y;
1964 xev.xmotion.x_root = rx;
1965 xev.xmotion.y_root = ry;
1966 xev.xmotion.state = 0;
1967 xev.xmotion.is_hint = 0;
1968 xev.xmotion.same_screen = 1;
1969 return XSendEvent(_ecore_x_disp, win, True, PointerMotionMask, &xev) ? EINA_TRUE : EINA_FALSE;
1970}
1971
1972EAPI Eina_Bool
1973ecore_x_mouse_down_send(Ecore_X_Window win,
1974 int x,
1975 int y,
1976 int b)
1977{
1978 XEvent xev;
1979 XWindowAttributes att;
1980 Window tw;
1981 int rx, ry;
1982
1983 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1984 XGetWindowAttributes(_ecore_x_disp, win, &att);
1985 XTranslateCoordinates(_ecore_x_disp, win, att.root, x, y, &rx, &ry, &tw);
1986 xev.xbutton.type = ButtonPress;
1987 xev.xbutton.window = win;
1988 xev.xbutton.root = att.root;
1989 xev.xbutton.subwindow = win;
1990 xev.xbutton.time = _ecore_x_event_last_time;
1991 xev.xbutton.x = x;
1992 xev.xbutton.y = y;
1993 xev.xbutton.x_root = rx;
1994 xev.xbutton.y_root = ry;
1995 xev.xbutton.state = 1 << b;
1996 xev.xbutton.button = b;
1997 xev.xbutton.same_screen = 1;
1998 return XSendEvent(_ecore_x_disp, win, True, ButtonPressMask, &xev) ? EINA_TRUE : EINA_FALSE;
1999}
2000
2001EAPI Eina_Bool
2002ecore_x_mouse_up_send(Ecore_X_Window win,
2003 int x,
2004 int y,
2005 int b)
2006{
2007 XEvent xev;
2008 XWindowAttributes att;
2009 Window tw;
2010 int rx, ry;
2011
2012 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2013 XGetWindowAttributes(_ecore_x_disp, win, &att);
2014 XTranslateCoordinates(_ecore_x_disp, win, att.root, x, y, &rx, &ry, &tw);
2015 xev.xbutton.type = ButtonRelease;
2016 xev.xbutton.window = win;
2017 xev.xbutton.root = att.root;
2018 xev.xbutton.subwindow = win;
2019 xev.xbutton.time = _ecore_x_event_last_time;
2020 xev.xbutton.x = x;
2021 xev.xbutton.y = y;
2022 xev.xbutton.x_root = rx;
2023 xev.xbutton.y_root = ry;
2024 xev.xbutton.state = 0;
2025 xev.xbutton.button = b;
2026 xev.xbutton.same_screen = 1;
2027 return XSendEvent(_ecore_x_disp, win, True, ButtonReleaseMask, &xev) ? EINA_TRUE : EINA_FALSE;
2028}
2029
2030EAPI Eina_Bool
2031ecore_x_mouse_in_send(Ecore_X_Window win,
2032 int x,
2033 int y)
2034{
2035 XEvent xev;
2036 XWindowAttributes att;
2037 Window tw;
2038 int rx, ry;
2039
2040 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2041 XGetWindowAttributes(_ecore_x_disp, win, &att);
2042 XTranslateCoordinates(_ecore_x_disp, win, att.root, x, y, &rx, &ry, &tw);
2043 xev.xcrossing.type = EnterNotify;
2044 xev.xcrossing.window = win;
2045 xev.xcrossing.root = att.root;
2046 xev.xcrossing.subwindow = win;
2047 xev.xcrossing.time = _ecore_x_event_last_time;
2048 xev.xcrossing.x = x;
2049 xev.xcrossing.y = y;
2050 xev.xcrossing.x_root = rx;
2051 xev.xcrossing.y_root = ry;
2052 xev.xcrossing.mode = NotifyNormal;
2053 xev.xcrossing.detail = NotifyNonlinear;
2054 xev.xcrossing.same_screen = 1;
2055 xev.xcrossing.focus = 0;
2056 xev.xcrossing.state = 0;
2057 return XSendEvent(_ecore_x_disp, win, True, EnterWindowMask, &xev) ? EINA_TRUE : EINA_FALSE;
2058}
2059
2060EAPI Eina_Bool
2061ecore_x_mouse_out_send(Ecore_X_Window win,
2062 int x,
2063 int y)
2064{
2065 XEvent xev;
2066 XWindowAttributes att;
2067 Window tw;
2068 int rx, ry;
2069
2070 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2071 XGetWindowAttributes(_ecore_x_disp, win, &att);
2072 XTranslateCoordinates(_ecore_x_disp, win, att.root, x, y, &rx, &ry, &tw);
2073 xev.xcrossing.type = LeaveNotify;
2074 xev.xcrossing.window = win;
2075 xev.xcrossing.root = att.root;
2076 xev.xcrossing.subwindow = win;
2077 xev.xcrossing.time = _ecore_x_event_last_time;
2078 xev.xcrossing.x = x;
2079 xev.xcrossing.y = y;
2080 xev.xcrossing.x_root = rx;
2081 xev.xcrossing.y_root = ry;
2082 xev.xcrossing.mode = NotifyNormal;
2083 xev.xcrossing.detail = NotifyNonlinear;
2084 xev.xcrossing.same_screen = 1;
2085 xev.xcrossing.focus = 0;
2086 xev.xcrossing.state = 0;
2087 return XSendEvent(_ecore_x_disp, win, True, LeaveWindowMask, &xev) ? EINA_TRUE : EINA_FALSE;
2088}
2089
2090EAPI void
2091ecore_x_focus_reset(void)
2092{
2093 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2094 XSetInputFocus(_ecore_x_disp, PointerRoot, RevertToPointerRoot, CurrentTime);
2095}
2096
2097EAPI void
2098ecore_x_events_allow_all(void)
2099{
2100 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2101 XAllowEvents(_ecore_x_disp, AsyncBoth, CurrentTime);
2102}
2103
2104EAPI void
2105ecore_x_pointer_last_xy_get(int *x,
2106 int *y)
2107{
2108 if (x)
2109 *x = _ecore_x_event_last_root_x;
2110
2111 if (y)
2112 *y = _ecore_x_event_last_root_y;
2113}
2114
2115EAPI void
2116ecore_x_pointer_xy_get(Ecore_X_Window win,
2117 int *x,
2118 int *y)
2119{
2120 Window rwin, cwin;
2121 int rx, ry, wx, wy, ret;
2122 unsigned int mask;
2123
2124 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2125 ret = XQueryPointer(_ecore_x_disp, win, &rwin, &cwin,
2126 &rx, &ry, &wx, &wy, &mask);
2127 if (!ret)
2128 wx = wy = -1;
2129
2130 if (x) *x = wx;
2131 if (y) *y = wy;
2132}
2133
2134/**
2135 * Retrieve the Visual ID from a given Visual.
2136 *
2137 * @param visual The Visual to get the ID for.
2138 *
2139 * @return The visual id.
2140 * @since 1.1.0
2141 */
2142EAPI unsigned int
2143ecore_x_visual_id_get(Ecore_X_Visual visual)
2144{
2145 return XVisualIDFromVisual(visual);
2146}
2147
2148/**
2149 * Retrieve the default Visual.
2150 *
2151 * @param disp The Display to get the Default Visual from
2152 * @param screen The Screen.
2153 *
2154 * @return The default visual.
2155 * @since 1.1.0
2156 */
2157EAPI Ecore_X_Visual
2158ecore_x_default_visual_get(Ecore_X_Display *disp,
2159 Ecore_X_Screen *screen)
2160{
2161 return DefaultVisual(disp, ecore_x_screen_index_get(screen));
2162}
2163
2164/**
2165 * Retrieve the default Colormap.
2166 *
2167 * @param disp The Display to get the Default Colormap from
2168 * @param screen The Screen.
2169 *
2170 * @return The default colormap.
2171 * @since 1.1.0
2172 */
2173EAPI Ecore_X_Colormap
2174ecore_x_default_colormap_get(Ecore_X_Display *disp,
2175 Ecore_X_Screen *screen)
2176{
2177 return DefaultColormap(disp, ecore_x_screen_index_get(screen));
2178}
2179
2180/**
2181 * Retrieve the default depth.
2182 *
2183 * @param disp The Display to get the Default Depth from
2184 * @param screen The Screen.
2185 *
2186 * @return The default depth.
2187 * @since 1.1.0
2188 */
2189EAPI int
2190ecore_x_default_depth_get(Ecore_X_Display *disp,
2191 Ecore_X_Screen *screen)
2192{
2193 return DefaultDepth(disp, ecore_x_screen_index_get(screen));
2194}
2195
2196EAPI void
2197ecore_x_xkb_select_group(int group)
2198{
2199#ifdef ECORE_XKB
2200 XkbLockGroup(_ecore_x_disp, XkbUseCoreKbd, group);
2201#endif
2202}
2203
2204/*****************************************************************************/
2205/*****************************************************************************/
2206/*****************************************************************************/
2207
2208static int
2209_ecore_x_event_modifier(unsigned int state)
2210{
2211 int xmodifiers = 0;
2212
2213 if (state & ECORE_EVENT_MODIFIER_SHIFT)
2214 xmodifiers |= ECORE_X_MODIFIER_SHIFT;
2215
2216 if (state & ECORE_EVENT_MODIFIER_CTRL)
2217 xmodifiers |= ECORE_X_MODIFIER_CTRL;
2218
2219 if (state & ECORE_EVENT_MODIFIER_ALT)
2220 xmodifiers |= ECORE_X_MODIFIER_ALT;
2221
2222 if (state & ECORE_EVENT_MODIFIER_WIN)
2223 xmodifiers |= ECORE_X_MODIFIER_WIN;
2224
2225 if (state & ECORE_EVENT_MODIFIER_ALTGR)
2226 xmodifiers |= ECORE_X_MODIFIER_ALTGR;
2227
2228 if (state & ECORE_EVENT_LOCK_SCROLL)
2229 xmodifiers |= ECORE_X_LOCK_SCROLL;
2230
2231 if (state & ECORE_EVENT_LOCK_NUM)
2232 xmodifiers |= ECORE_X_LOCK_NUM;
2233
2234 if (state & ECORE_EVENT_LOCK_CAPS)
2235 xmodifiers |= ECORE_X_LOCK_CAPS;
2236
2237 if (state & ECORE_EVENT_LOCK_SHIFT)
2238 xmodifiers |= ECORE_X_LOCK_SHIFT;
2239
2240 return xmodifiers;
2241}
2242
diff --git a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_atoms.c b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_atoms.c
deleted file mode 100644
index 2aec7ce..0000000
--- a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_atoms.c
+++ /dev/null
@@ -1,109 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#ifdef STDC_HEADERS
6# include <stdlib.h>
7# include <stddef.h>
8#else
9# ifdef HAVE_STDLIB_H
10# include <stdlib.h>
11# endif
12#endif
13#ifdef HAVE_ALLOCA_H
14# include <alloca.h>
15#elif !defined alloca
16# ifdef __GNUC__
17# define alloca __builtin_alloca
18# elif defined _AIX
19# define alloca __alloca
20# elif defined _MSC_VER
21# include <malloc.h>
22# define alloca _alloca
23# elif !defined HAVE_ALLOCA
24# ifdef __cplusplus
25extern "C"
26# endif
27void *alloca (size_t);
28# endif
29#endif
30
31#include <string.h>
32
33#include "Ecore.h"
34#include "ecore_x_private.h"
35#include "Ecore_X.h"
36#include "Ecore_X_Atoms.h"
37#include "ecore_x_atoms_decl.h"
38
39void
40_ecore_x_atoms_init(void)
41{
42 Atom *atoms;
43 char **names;
44 int i, num;
45
46 num = sizeof(atom_items) / sizeof(Atom_Item);
47 atoms = alloca(num * sizeof(Atom));
48 names = alloca(num * sizeof(char *));
49 for (i = 0; i < num; i++)
50 names[i] = (char *) atom_items[i].name;
51 XInternAtoms(_ecore_x_disp, names, num, False, atoms);
52 for (i = 0; i < num; i++)
53 *(atom_items[i].atom) = atoms[i];
54}
55
56/**
57 * Retrieves the atom value associated with the given name.
58 * @param name The given name.
59 * @return Associated atom value.
60 */
61EAPI Ecore_X_Atom
62ecore_x_atom_get(const char *name)
63{
64 if (!_ecore_x_disp)
65 return 0;
66
67 LOGFN(__FILE__, __LINE__, __FUNCTION__);
68 return XInternAtom(_ecore_x_disp, name, False);
69}
70
71EAPI void
72ecore_x_atoms_get(const char **names,
73 int num,
74 Ecore_X_Atom *atoms)
75{
76 Atom *atoms_int;
77 int i;
78
79 if (!_ecore_x_disp)
80 return;
81
82 LOGFN(__FILE__, __LINE__, __FUNCTION__);
83 atoms_int = alloca(num * sizeof(Atom));
84 XInternAtoms(_ecore_x_disp, (char **)names, num, False, atoms_int);
85 for (i = 0; i < num; i++)
86 atoms[i] = atoms_int[i];
87}
88
89EAPI char *
90ecore_x_atom_name_get(Ecore_X_Atom atom)
91{
92 char *name;
93 char *xname;
94
95 if (!_ecore_x_disp)
96 return NULL;
97
98 LOGFN(__FILE__, __LINE__, __FUNCTION__);
99
100 xname = XGetAtomName(_ecore_x_disp, atom);
101 if (!xname)
102 return NULL;
103
104 name = strdup(xname);
105 XFree(xname);
106
107 return name;
108}
109
diff --git a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_composite.c b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_composite.c
deleted file mode 100644
index b919db9..0000000
--- a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_composite.c
+++ /dev/null
@@ -1,176 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include "ecore_x_private.h"
6#include "Ecore_X.h"
7
8static Eina_Bool _composite_available = EINA_FALSE;
9
10void
11_ecore_x_composite_init(void)
12{
13 _composite_available = EINA_FALSE;
14
15#ifdef ECORE_XCOMPOSITE
16 int major, minor;
17
18 if (XCompositeQueryVersion(_ecore_x_disp, &major, &minor))
19 {
20# ifdef ECORE_XRENDER
21 if (XRenderQueryExtension(_ecore_x_disp, &major, &minor))
22 {
23# ifdef ECORE_XFIXES
24 if (XFixesQueryVersion(_ecore_x_disp, &major, &minor))
25 {
26 _composite_available = EINA_TRUE;
27 }
28# endif
29 }
30# endif
31 }
32#endif
33}
34
35EAPI Eina_Bool
36ecore_x_composite_query(void)
37{
38 LOGFN(__FILE__, __LINE__, __FUNCTION__);
39 return _composite_available;
40}
41
42EAPI void
43ecore_x_composite_redirect_window(Ecore_X_Window win,
44 Ecore_X_Composite_Update_Type type)
45{
46#ifdef ECORE_XCOMPOSITE
47 int update = CompositeRedirectAutomatic;
48
49 LOGFN(__FILE__, __LINE__, __FUNCTION__);
50 switch (type)
51 {
52 case ECORE_X_COMPOSITE_UPDATE_AUTOMATIC:
53 update = CompositeRedirectAutomatic;
54 break;
55
56 case ECORE_X_COMPOSITE_UPDATE_MANUAL:
57 update = CompositeRedirectManual;
58 break;
59 }
60 XCompositeRedirectWindow(_ecore_x_disp, win, update);
61#endif /* ifdef ECORE_XCOMPOSITE */
62}
63
64EAPI void
65ecore_x_composite_redirect_subwindows(Ecore_X_Window win,
66 Ecore_X_Composite_Update_Type type)
67{
68#ifdef ECORE_XCOMPOSITE
69 int update = CompositeRedirectAutomatic;
70
71 LOGFN(__FILE__, __LINE__, __FUNCTION__);
72 switch (type)
73 {
74 case ECORE_X_COMPOSITE_UPDATE_AUTOMATIC:
75 update = CompositeRedirectAutomatic;
76 break;
77
78 case ECORE_X_COMPOSITE_UPDATE_MANUAL:
79 update = CompositeRedirectManual;
80 break;
81 }
82 XCompositeRedirectSubwindows(_ecore_x_disp, win, update);
83#endif /* ifdef ECORE_XCOMPOSITE */
84}
85
86EAPI void
87ecore_x_composite_unredirect_window(Ecore_X_Window win,
88 Ecore_X_Composite_Update_Type type)
89{
90#ifdef ECORE_XCOMPOSITE
91 int update = CompositeRedirectAutomatic;
92
93 LOGFN(__FILE__, __LINE__, __FUNCTION__);
94 switch (type)
95 {
96 case ECORE_X_COMPOSITE_UPDATE_AUTOMATIC:
97 update = CompositeRedirectAutomatic;
98 break;
99
100 case ECORE_X_COMPOSITE_UPDATE_MANUAL:
101 update = CompositeRedirectManual;
102 break;
103 }
104 XCompositeUnredirectWindow(_ecore_x_disp, win, update);
105#endif /* ifdef ECORE_XCOMPOSITE */
106}
107
108EAPI void
109ecore_x_composite_unredirect_subwindows(Ecore_X_Window win,
110 Ecore_X_Composite_Update_Type type)
111{
112#ifdef ECORE_XCOMPOSITE
113 int update = CompositeRedirectAutomatic;
114
115 LOGFN(__FILE__, __LINE__, __FUNCTION__);
116 switch (type)
117 {
118 case ECORE_X_COMPOSITE_UPDATE_AUTOMATIC:
119 update = CompositeRedirectAutomatic;
120 break;
121
122 case ECORE_X_COMPOSITE_UPDATE_MANUAL:
123 update = CompositeRedirectManual;
124 break;
125 }
126 XCompositeUnredirectSubwindows(_ecore_x_disp, win, update);
127#endif /* ifdef ECORE_XCOMPOSITE */
128}
129
130EAPI Ecore_X_Pixmap
131ecore_x_composite_name_window_pixmap_get(Ecore_X_Window win)
132{
133 Ecore_X_Pixmap pixmap = None;
134#ifdef ECORE_XCOMPOSITE
135 LOGFN(__FILE__, __LINE__, __FUNCTION__);
136 pixmap = XCompositeNameWindowPixmap(_ecore_x_disp, win);
137#endif /* ifdef ECORE_XCOMPOSITE */
138 return pixmap;
139}
140
141EAPI void
142ecore_x_composite_window_events_disable(Ecore_X_Window win)
143{
144#ifdef ECORE_XCOMPOSITE
145 ecore_x_window_shape_input_rectangle_set(win, -1, -1, 1, 1);
146#endif /* ifdef ECORE_XCOMPOSITE */
147}
148
149EAPI void
150ecore_x_composite_window_events_enable(Ecore_X_Window win)
151{
152#ifdef ECORE_XCOMPOSITE
153 ecore_x_window_shape_input_rectangle_set(win, 0, 0, 65535, 65535);
154#endif /* ifdef ECORE_XCOMPOSITE */
155}
156
157EAPI Ecore_X_Window
158ecore_x_composite_render_window_enable(Ecore_X_Window root)
159{
160 Ecore_X_Window win = 0;
161#ifdef ECORE_XCOMPOSITE
162 win = XCompositeGetOverlayWindow(_ecore_x_disp, root);
163 ecore_x_composite_window_events_disable(win);
164#endif /* ifdef ECORE_XCOMPOSITE */
165 return win;
166}
167
168EAPI void
169ecore_x_composite_render_window_disable(Ecore_X_Window root)
170{
171#ifdef ECORE_XCOMPOSITE
172 LOGFN(__FILE__, __LINE__, __FUNCTION__);
173 XCompositeReleaseOverlayWindow(_ecore_x_disp, root);
174#endif /* ifdef ECORE_XCOMPOSITE */
175}
176
diff --git a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_cursor.c b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_cursor.c
deleted file mode 100644
index a968c56..0000000
--- a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_cursor.c
+++ /dev/null
@@ -1,246 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdlib.h>
6
7#include "ecore_x_private.h"
8
9EAPI Eina_Bool
10ecore_x_cursor_color_supported_get(void)
11{
12 return _ecore_x_xcursor;
13}
14
15EAPI Ecore_X_Cursor
16ecore_x_cursor_new(Ecore_X_Window win,
17 int *pixels,
18 int w,
19 int h,
20 int hot_x,
21 int hot_y)
22{
23#ifdef ECORE_XCURSOR
24 LOGFN(__FILE__, __LINE__, __FUNCTION__);
25 if (_ecore_x_xcursor)
26 {
27 Cursor c;
28 XcursorImage *xci;
29
30 xci = XcursorImageCreate(w, h);
31 if (xci)
32 {
33 int i;
34
35 xci->xhot = hot_x;
36 xci->yhot = hot_y;
37 xci->delay = 0;
38 for (i = 0; i < (w * h); i++)
39 {
40// int r, g, b, a;
41//
42// a = (pixels[i] >> 24) & 0xff;
43// r = (((pixels[i] >> 16) & 0xff) * a) / 0xff;
44// g = (((pixels[i] >> 8 ) & 0xff) * a) / 0xff;
45// b = (((pixels[i] ) & 0xff) * a) / 0xff;
46 xci->pixels[i] = pixels[i];
47// (a << 24) | (r << 16) | (g << 8) | (b);
48 }
49 c = XcursorImageLoadCursor(_ecore_x_disp, xci);
50 XcursorImageDestroy(xci);
51 return c;
52 }
53 }
54 else
55#endif /* ifdef ECORE_XCURSOR */
56 {
57 XColor c1, c2;
58 Cursor c;
59 Pixmap pmap, mask;
60 GC gc;
61 XGCValues gcv;
62 XImage *xim;
63 unsigned int *pix;
64 int fr, fg, fb, br, bg, bb;
65 int brightest = 0;
66 int darkest = 255 * 3;
67 int x, y;
68 const int dither[2][2] =
69 {
70 {0, 2},
71 {3, 1}
72 };
73
74 pmap = XCreatePixmap(_ecore_x_disp, win, w, h, 1);
75 mask = XCreatePixmap(_ecore_x_disp, win, w, h, 1);
76 xim = XCreateImage(_ecore_x_disp,
77 DefaultVisual(_ecore_x_disp, 0),
78 1, ZPixmap, 0, NULL, w, h, 32, 0);
79 xim->data = malloc(xim->bytes_per_line * xim->height);
80
81 fr = 0x00; fg = 0x00; fb = 0x00;
82 br = 0xff; bg = 0xff; bb = 0xff;
83 pix = (unsigned int *)pixels;
84 for (y = 0; y < h; y++)
85 {
86 for (x = 0; x < w; x++)
87 {
88 int r, g, b, a;
89
90 a = (pix[0] >> 24) & 0xff;
91 r = (pix[0] >> 16) & 0xff;
92 g = (pix[0] >> 8) & 0xff;
93 b = (pix[0]) & 0xff;
94 if (a > 0)
95 {
96 if ((r + g + b) > brightest)
97 {
98 brightest = r + g + b;
99 br = r;
100 bg = g;
101 bb = b;
102 }
103
104 if ((r + g + b) < darkest)
105 {
106 darkest = r + g + b;
107 fr = r;
108 fg = g;
109 fb = b;
110 }
111 }
112
113 pix++;
114 }
115 }
116
117 pix = (unsigned int *)pixels;
118 for (y = 0; y < h; y++)
119 {
120 for (x = 0; x < w; x++)
121 {
122 int v;
123 int r, g, b;
124 int d1, d2;
125
126 r = (pix[0] >> 16) & 0xff;
127 g = (pix[0] >> 8) & 0xff;
128 b = (pix[0]) & 0xff;
129 d1 =
130 ((r - fr) * (r - fr)) +
131 ((g - fg) * (g - fg)) +
132 ((b - fb) * (b - fb));
133 d2 =
134 ((r - br) * (r - br)) +
135 ((g - bg) * (g - bg)) +
136 ((b - bb) * (b - bb));
137 if (d1 + d2)
138 {
139 v = (((d2 * 255) / (d1 + d2)) * 5) / 256;
140 if (v > dither[x & 0x1][y & 0x1])
141 v = 1;
142 else
143 v = 0;
144 }
145 else
146 v = 0;
147
148 XPutPixel(xim, x, y, v);
149 pix++;
150 }
151 }
152 gc = XCreateGC(_ecore_x_disp, pmap, 0, &gcv);
153 XPutImage(_ecore_x_disp, pmap, gc, xim, 0, 0, 0, 0, w, h);
154 XFreeGC(_ecore_x_disp, gc);
155
156 pix = (unsigned int *)pixels;
157 for (y = 0; y < h; y++)
158 {
159 for (x = 0; x < w; x++)
160 {
161 int v;
162
163 v = (((pix[0] >> 24) & 0xff) * 5) / 256;
164 if (v > dither[x & 0x1][y & 0x1])
165 v = 1;
166 else
167 v = 0;
168
169 XPutPixel(xim, x, y, v);
170 pix++;
171 }
172 }
173 gc = XCreateGC(_ecore_x_disp, mask, 0, &gcv);
174 XPutImage(_ecore_x_disp, mask, gc, xim, 0, 0, 0, 0, w, h);
175 XFreeGC(_ecore_x_disp, gc);
176
177 free(xim->data);
178 xim->data = NULL;
179 XDestroyImage(xim);
180
181 c1.pixel = 0;
182 c1.red = fr << 8 | fr;
183 c1.green = fg << 8 | fg;
184 c1.blue = fb << 8 | fb;
185 c1.flags = DoRed | DoGreen | DoBlue;
186
187 c2.pixel = 0;
188 c2.red = br << 8 | br;
189 c2.green = bg << 8 | bg;
190 c2.blue = bb << 8 | bb;
191 c2.flags = DoRed | DoGreen | DoBlue;
192
193 c = XCreatePixmapCursor(_ecore_x_disp,
194 pmap, mask,
195 &c1, &c2,
196 hot_x, hot_y);
197 XFreePixmap(_ecore_x_disp, pmap);
198 XFreePixmap(_ecore_x_disp, mask);
199 return c;
200 }
201
202 return 0;
203}
204
205EAPI void
206ecore_x_cursor_free(Ecore_X_Cursor c)
207{
208 LOGFN(__FILE__, __LINE__, __FUNCTION__);
209 XFreeCursor(_ecore_x_disp, c);
210}
211
212/*
213 * Returns the cursor for the given shape.
214 * Note that the return value must not be freed with
215 * ecore_x_cursor_free()!
216 */
217EAPI Ecore_X_Cursor
218ecore_x_cursor_shape_get(int shape)
219{
220 LOGFN(__FILE__, __LINE__, __FUNCTION__);
221 /* Shapes are defined in Ecore_X_Cursor.h */
222 return XCreateFontCursor(_ecore_x_disp, shape);
223}
224
225EAPI void
226ecore_x_cursor_size_set(int size)
227{
228#ifdef ECORE_XCURSOR
229 LOGFN(__FILE__, __LINE__, __FUNCTION__);
230 XcursorSetDefaultSize(_ecore_x_disp, size);
231#else /* ifdef ECORE_XCURSOR */
232 size = 0;
233#endif /* ifdef ECORE_XCURSOR */
234}
235
236EAPI int
237ecore_x_cursor_size_get(void)
238{
239#ifdef ECORE_XCURSOR
240 LOGFN(__FILE__, __LINE__, __FUNCTION__);
241 return XcursorGetDefaultSize(_ecore_x_disp);
242#else /* ifdef ECORE_XCURSOR */
243 return 0;
244#endif /* ifdef ECORE_XCURSOR */
245}
246
diff --git a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_damage.c b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_damage.c
deleted file mode 100644
index b094f85..0000000
--- a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_damage.c
+++ /dev/null
@@ -1,71 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include "ecore_x_private.h"
6#include "Ecore_X.h"
7
8static Eina_Bool _damage_available = EINA_FALSE;
9#ifdef ECORE_XDAMAGE
10static int _damage_major, _damage_minor;
11#endif /* ifdef ECORE_XDAMAGE */
12
13void
14_ecore_x_damage_init(void)
15{
16#ifdef ECORE_XDAMAGE
17 _damage_major = 1;
18 _damage_minor = 0;
19
20 LOGFN(__FILE__, __LINE__, __FUNCTION__);
21 if (XDamageQueryVersion(_ecore_x_disp, &_damage_major, &_damage_minor))
22 _damage_available = EINA_TRUE;
23 else
24 _damage_available = EINA_FALSE;
25
26#else /* ifdef ECORE_XDAMAGE */
27 _damage_available = EINA_FALSE;
28#endif /* ifdef ECORE_XDAMAGE */
29}
30
31EAPI Eina_Bool
32ecore_x_damage_query(void)
33{
34 return _damage_available;
35}
36
37EAPI Ecore_X_Damage
38ecore_x_damage_new(Ecore_X_Drawable d,
39 Ecore_X_Damage_Report_Level level)
40{
41#ifdef ECORE_XDAMAGE
42 Ecore_X_Damage damage;
43
44 LOGFN(__FILE__, __LINE__, __FUNCTION__);
45 damage = XDamageCreate(_ecore_x_disp, d, level);
46 return damage;
47#else /* ifdef ECORE_XDAMAGE */
48 return 0;
49#endif /* ifdef ECORE_XDAMAGE */
50}
51
52EAPI void
53ecore_x_damage_free(Ecore_X_Damage damage)
54{
55#ifdef ECORE_XDAMAGE
56 LOGFN(__FILE__, __LINE__, __FUNCTION__);
57 XDamageDestroy(_ecore_x_disp, damage);
58#endif /* ifdef ECORE_XDAMAGE */
59}
60
61EAPI void
62ecore_x_damage_subtract(Ecore_X_Damage damage,
63 Ecore_X_Region repair,
64 Ecore_X_Region parts)
65{
66#ifdef ECORE_XDAMAGE
67 LOGFN(__FILE__, __LINE__, __FUNCTION__);
68 XDamageSubtract(_ecore_x_disp, damage, repair, parts);
69#endif /* ifdef ECORE_XDAMAGE */
70}
71
diff --git a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_dnd.c b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_dnd.c
deleted file mode 100644
index e4f74a7..0000000
--- a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_dnd.c
+++ /dev/null
@@ -1,706 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdlib.h>
6#include <string.h>
7
8#include "Ecore.h"
9#include "ecore_x_private.h"
10#include "Ecore_X.h"
11#include "Ecore_X_Atoms.h"
12
13EAPI int ECORE_X_EVENT_XDND_ENTER = 0;
14EAPI int ECORE_X_EVENT_XDND_POSITION = 0;
15EAPI int ECORE_X_EVENT_XDND_STATUS = 0;
16EAPI int ECORE_X_EVENT_XDND_LEAVE = 0;
17EAPI int ECORE_X_EVENT_XDND_DROP = 0;
18EAPI int ECORE_X_EVENT_XDND_FINISHED = 0;
19
20static Ecore_X_DND_Source *_source = NULL;
21static Ecore_X_DND_Target *_target = NULL;
22static int _ecore_x_dnd_init_count = 0;
23
24typedef struct _Version_Cache_Item
25{
26 Ecore_X_Window win;
27 int ver;
28} Version_Cache_Item;
29static Version_Cache_Item *_version_cache = NULL;
30static int _version_cache_num = 0, _version_cache_alloc = 0;
31static void (*_posupdatecb)(void *,
32 Ecore_X_Xdnd_Position *);
33static void *_posupdatedata;
34
35void
36_ecore_x_dnd_init(void)
37{
38 if (!_ecore_x_dnd_init_count)
39 {
40 _source = calloc(1, sizeof(Ecore_X_DND_Source));
41 if (!_source) return;
42 _source->version = ECORE_X_DND_VERSION;
43 _source->win = None;
44 _source->dest = None;
45 _source->state = ECORE_X_DND_SOURCE_IDLE;
46 _source->prev.window = 0;
47
48 _target = calloc(1, sizeof(Ecore_X_DND_Target));
49 if (!_target)
50 {
51 free(_source);
52 _source = NULL;
53 return;
54 }
55 _target->win = None;
56 _target->source = None;
57 _target->state = ECORE_X_DND_TARGET_IDLE;
58
59 ECORE_X_EVENT_XDND_ENTER = ecore_event_type_new();
60 ECORE_X_EVENT_XDND_POSITION = ecore_event_type_new();
61 ECORE_X_EVENT_XDND_STATUS = ecore_event_type_new();
62 ECORE_X_EVENT_XDND_LEAVE = ecore_event_type_new();
63 ECORE_X_EVENT_XDND_DROP = ecore_event_type_new();
64 ECORE_X_EVENT_XDND_FINISHED = ecore_event_type_new();
65 }
66
67 _ecore_x_dnd_init_count++;
68}
69
70void
71_ecore_x_dnd_shutdown(void)
72{
73 _ecore_x_dnd_init_count--;
74 if (_ecore_x_dnd_init_count > 0)
75 return;
76
77 if (_source)
78 free(_source);
79
80 _source = NULL;
81
82 if (_target)
83 free(_target);
84
85 _target = NULL;
86
87 _ecore_x_dnd_init_count = 0;
88}
89
90static Eina_Bool
91_ecore_x_dnd_converter_copy(char *target EINA_UNUSED,
92 void *data,
93 int size,
94 void **data_ret,
95 int *size_ret,
96 Ecore_X_Atom *tprop EINA_UNUSED,
97 int *count EINA_UNUSED)
98{
99 XTextProperty text_prop;
100 char *mystr;
101 XICCEncodingStyle style = XTextStyle;
102
103 if (!data || !size)
104 return EINA_FALSE;
105
106 mystr = calloc(1, size + 1);
107 if (!mystr)
108 return EINA_FALSE;
109
110 memcpy(mystr, data, size);
111
112 if (XmbTextListToTextProperty(_ecore_x_disp, &mystr, 1, style,
113 &text_prop) == Success)
114 {
115 int bufsize = strlen((char *)text_prop.value) + 1;
116 *data_ret = malloc(bufsize);
117 if (!*data_ret)
118 {
119 free(mystr);
120 return EINA_FALSE;
121 }
122 memcpy(*data_ret, text_prop.value, bufsize);
123 *size_ret = bufsize;
124 XFree(text_prop.value);
125 free(mystr);
126 return EINA_TRUE;
127 }
128 else
129 {
130 free(mystr);
131 return EINA_FALSE;
132 }
133}
134
135EAPI void
136ecore_x_dnd_aware_set(Ecore_X_Window win,
137 Eina_Bool on)
138{
139 Ecore_X_Atom prop_data = ECORE_X_DND_VERSION;
140
141 LOGFN(__FILE__, __LINE__, __FUNCTION__);
142 if (on)
143 ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_AWARE,
144 XA_ATOM, 32, &prop_data, 1);
145 else
146 ecore_x_window_prop_property_del(win, ECORE_X_ATOM_XDND_AWARE);
147}
148
149EAPI int
150ecore_x_dnd_version_get(Ecore_X_Window win)
151{
152 unsigned char *prop_data;
153 int num;
154 Version_Cache_Item *t;
155
156 LOGFN(__FILE__, __LINE__, __FUNCTION__);
157 // this looks hacky - and it is, but we need a way of caching info about
158 // a window while dragging, because we literally query this every mouse
159 // move and going to and from x multiple times per move is EXPENSIVE
160 // and slows things down, puts lots of load on x etc.
161 if (_source->state == ECORE_X_DND_SOURCE_DRAGGING)
162 if (_version_cache)
163 {
164 int i;
165
166 for (i = 0; i < _version_cache_num; i++)
167 {
168 if (_version_cache[i].win == win)
169 return _version_cache[i].ver;
170 }
171 }
172
173 if (ecore_x_window_prop_property_get(win, ECORE_X_ATOM_XDND_AWARE,
174 XA_ATOM, 32, &prop_data, &num))
175 {
176 int version = (int)*prop_data;
177 free(prop_data);
178 if (_source->state == ECORE_X_DND_SOURCE_DRAGGING)
179 {
180 _version_cache_num++;
181 if (_version_cache_num > _version_cache_alloc)
182 _version_cache_alloc += 16;
183
184 t = realloc(_version_cache,
185 _version_cache_alloc *
186 sizeof(Version_Cache_Item));
187 if (!t) return 0;
188 _version_cache = t;
189 _version_cache[_version_cache_num - 1].win = win;
190 _version_cache[_version_cache_num - 1].ver = version;
191 }
192
193 return version;
194 }
195
196 if (_source->state == ECORE_X_DND_SOURCE_DRAGGING)
197 {
198 _version_cache_num++;
199 if (_version_cache_num > _version_cache_alloc)
200 _version_cache_alloc += 16;
201
202 t = realloc(_version_cache, _version_cache_alloc *
203 sizeof(Version_Cache_Item));
204 if (!t) return 0;
205 _version_cache = t;
206 _version_cache[_version_cache_num - 1].win = win;
207 _version_cache[_version_cache_num - 1].ver = 0;
208 }
209
210 return 0;
211}
212
213EAPI Eina_Bool
214ecore_x_dnd_type_isset(Ecore_X_Window win,
215 const char *type)
216{
217 int num, i, ret = EINA_FALSE;
218 unsigned char *data;
219 Ecore_X_Atom *atoms, atom;
220
221 LOGFN(__FILE__, __LINE__, __FUNCTION__);
222 if (!ecore_x_window_prop_property_get(win, ECORE_X_ATOM_XDND_TYPE_LIST,
223 XA_ATOM, 32, &data, &num))
224 return ret;
225
226 atom = ecore_x_atom_get(type);
227 atoms = (Ecore_X_Atom *)data;
228
229 for (i = 0; i < num; ++i)
230 {
231 if (atom == atoms[i])
232 {
233 ret = EINA_TRUE;
234 break;
235 }
236 }
237
238 XFree(data);
239 return ret;
240}
241
242EAPI void
243ecore_x_dnd_type_set(Ecore_X_Window win,
244 const char *type,
245 Eina_Bool on)
246{
247 Ecore_X_Atom atom;
248 Ecore_X_Atom *oldset = NULL, *newset = NULL;
249 int i, j = 0, num = 0;
250 unsigned char *data = NULL;
251 unsigned char *old_data = NULL;
252
253 LOGFN(__FILE__, __LINE__, __FUNCTION__);
254 atom = ecore_x_atom_get(type);
255 ecore_x_window_prop_property_get(win, ECORE_X_ATOM_XDND_TYPE_LIST,
256 XA_ATOM, 32, &old_data, &num);
257 oldset = (Ecore_X_Atom *)old_data;
258
259 LOGFN(__FILE__, __LINE__, __FUNCTION__);
260 if (on)
261 {
262 if (ecore_x_dnd_type_isset(win, type))
263 {
264 XFree(old_data);
265 return;
266 }
267
268 newset = calloc(num + 1, sizeof(Ecore_X_Atom));
269 if (!newset)
270 return;
271
272 data = (unsigned char *)newset;
273
274 for (i = 0; i < num; i++)
275 newset[i + 1] = oldset[i];
276 /* prepend the new type */
277 newset[0] = atom;
278
279 ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_TYPE_LIST,
280 XA_ATOM, 32, data, num + 1);
281 }
282 else
283 {
284 if (!ecore_x_dnd_type_isset(win, type))
285 {
286 XFree(old_data);
287 return;
288 }
289
290 newset = calloc(num - 1, sizeof(Ecore_X_Atom));
291 if (!newset)
292 {
293 XFree(old_data);
294 return;
295 }
296
297 data = (unsigned char *)newset;
298 for (i = 0; i < num; i++)
299 if (oldset[i] != atom)
300 newset[j++] = oldset[i];
301
302 ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_TYPE_LIST,
303 XA_ATOM, 32, data, num - 1);
304 }
305
306 XFree(oldset);
307 free(newset);
308}
309
310EAPI void
311ecore_x_dnd_types_set(Ecore_X_Window win,
312 const char **types,
313 unsigned int num_types)
314{
315 Ecore_X_Atom *newset = NULL;
316 unsigned int i;
317 unsigned char *data = NULL;
318
319 LOGFN(__FILE__, __LINE__, __FUNCTION__);
320 if (!num_types)
321 ecore_x_window_prop_property_del(win, ECORE_X_ATOM_XDND_TYPE_LIST);
322 else
323 {
324 newset = calloc(num_types, sizeof(Ecore_X_Atom));
325 if (!newset)
326 return;
327
328 data = (unsigned char *)newset;
329 for (i = 0; i < num_types; i++)
330 {
331 newset[i] = ecore_x_atom_get(types[i]);
332 ecore_x_selection_converter_atom_add(newset[i],
333 _ecore_x_dnd_converter_copy);
334 }
335 ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_TYPE_LIST,
336 XA_ATOM, 32, data, num_types);
337 free(newset);
338 }
339}
340
341EAPI void
342ecore_x_dnd_actions_set(Ecore_X_Window win,
343 Ecore_X_Atom *actions,
344 unsigned int num_actions)
345{
346 unsigned int i;
347 unsigned char *data = NULL;
348
349 LOGFN(__FILE__, __LINE__, __FUNCTION__);
350 if (!num_actions)
351 ecore_x_window_prop_property_del(win, ECORE_X_ATOM_XDND_ACTION_LIST);
352 else
353 {
354 data = (unsigned char *)actions;
355 for (i = 0; i < num_actions; i++)
356 {
357 ecore_x_selection_converter_atom_add(actions[i],
358 _ecore_x_dnd_converter_copy);
359 }
360 ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_ACTION_LIST,
361 XA_ATOM, 32, data, num_actions);
362 }
363}
364
365/**
366 * The DND position update cb is called Ecore_X sends a DND position to a
367 * client.
368 *
369 * It essentially mirrors some of the data sent in the position message.
370 * Generally this cb should be set just before position update is called.
371 * Please note well you need to look after your own data pointer if someone
372 * trashes you position update cb set.
373 *
374 * It is considered good form to clear this when the dnd event finishes.
375 *
376 * @param cb Callback to updated each time ecore_x sends a position update.
377 * @param data User data.
378 */
379EAPI void
380ecore_x_dnd_callback_pos_update_set(
381 void (*cb)(void *,
382 Ecore_X_Xdnd_Position *data),
383 const void *data)
384{
385 _posupdatecb = cb;
386 _posupdatedata = (void *)data; /* Discard the const early */
387}
388
389Ecore_X_DND_Source *
390_ecore_x_dnd_source_get(void)
391{
392 return _source;
393}
394
395Ecore_X_DND_Target *
396_ecore_x_dnd_target_get(void)
397{
398 return _target;
399}
400
401EAPI Eina_Bool
402ecore_x_dnd_begin(Ecore_X_Window source,
403 unsigned char *data,
404 int size)
405{
406 LOGFN(__FILE__, __LINE__, __FUNCTION__);
407 if (!ecore_x_dnd_version_get(source))
408 return EINA_FALSE;
409
410 /* Take ownership of XdndSelection */
411 if (!ecore_x_selection_xdnd_set(source, data, size))
412 return EINA_FALSE;
413
414 if (_version_cache)
415 {
416 free(_version_cache);
417 _version_cache = NULL;
418 _version_cache_num = 0;
419 _version_cache_alloc = 0;
420 }
421
422 ecore_x_window_shadow_tree_flush();
423
424 _source->win = source;
425 ecore_x_window_ignore_set(_source->win, 1);
426 _source->state = ECORE_X_DND_SOURCE_DRAGGING;
427 _source->time = _ecore_x_event_last_time;
428 _source->prev.window = 0;
429
430 /* Default Accepted Action: move */
431 _source->action = ECORE_X_ATOM_XDND_ACTION_MOVE;
432 _source->accepted_action = None;
433 _source->dest = None;
434
435 return EINA_TRUE;
436}
437
438EAPI Eina_Bool
439ecore_x_dnd_drop(void)
440{
441 XEvent xev;
442 int status = EINA_FALSE;
443
444 LOGFN(__FILE__, __LINE__, __FUNCTION__);
445 if (_source->dest)
446 {
447 xev.xany.type = ClientMessage;
448 xev.xany.display = _ecore_x_disp;
449 xev.xclient.format = 32;
450 xev.xclient.window = _source->dest;
451
452 if (_source->will_accept)
453 {
454 xev.xclient.message_type = ECORE_X_ATOM_XDND_DROP;
455 xev.xclient.data.l[0] = _source->win;
456 xev.xclient.data.l[1] = 0;
457 xev.xclient.data.l[2] = _source->time;
458 XSendEvent(_ecore_x_disp, _source->dest, False, 0, &xev);
459 _source->state = ECORE_X_DND_SOURCE_DROPPED;
460 status = EINA_TRUE;
461 }
462 else
463 {
464 xev.xclient.message_type = ECORE_X_ATOM_XDND_LEAVE;
465 xev.xclient.data.l[0] = _source->win;
466 xev.xclient.data.l[1] = 0;
467 XSendEvent(_ecore_x_disp, _source->dest, False, 0, &xev);
468 _source->state = ECORE_X_DND_SOURCE_IDLE;
469 }
470 }
471 else
472 {
473 /* Dropping on nothing */
474 ecore_x_selection_xdnd_clear();
475 _source->state = ECORE_X_DND_SOURCE_IDLE;
476 }
477
478 ecore_x_window_ignore_set(_source->win, 0);
479
480 _source->prev.window = 0;
481
482 return status;
483}
484
485EAPI void
486ecore_x_dnd_send_status(Eina_Bool will_accept,
487 Eina_Bool suppress,
488 Ecore_X_Rectangle rectangle,
489 Ecore_X_Atom action)
490{
491 XEvent xev;
492
493 if (_target->state == ECORE_X_DND_TARGET_IDLE)
494 return;
495
496 LOGFN(__FILE__, __LINE__, __FUNCTION__);
497 memset(&xev, 0, sizeof(XEvent));
498
499 _target->will_accept = will_accept;
500
501 xev.xclient.type = ClientMessage;
502 xev.xclient.display = _ecore_x_disp;
503 xev.xclient.message_type = ECORE_X_ATOM_XDND_STATUS;
504 xev.xclient.format = 32;
505 xev.xclient.window = _target->source;
506
507 xev.xclient.data.l[0] = _target->win;
508 xev.xclient.data.l[1] = 0;
509 if (will_accept)
510 xev.xclient.data.l[1] |= 0x1UL;
511
512 if (!suppress)
513 xev.xclient.data.l[1] |= 0x2UL;
514
515 /* Set rectangle information */
516 xev.xclient.data.l[2] = rectangle.x;
517 xev.xclient.data.l[2] <<= 16;
518 xev.xclient.data.l[2] |= rectangle.y;
519 xev.xclient.data.l[3] = rectangle.width;
520 xev.xclient.data.l[3] <<= 16;
521 xev.xclient.data.l[3] |= rectangle.height;
522
523 if (will_accept)
524 {
525 xev.xclient.data.l[4] = action;
526 _target->accepted_action = action;
527 }
528 else
529 {
530 xev.xclient.data.l[4] = None;
531 _target->accepted_action = action;
532 }
533
534 XSendEvent(_ecore_x_disp, _target->source, False, 0, &xev);
535}
536
537EAPI void
538ecore_x_dnd_send_finished(void)
539{
540 XEvent xev;
541
542 if (_target->state == ECORE_X_DND_TARGET_IDLE)
543 return;
544
545 LOGFN(__FILE__, __LINE__, __FUNCTION__);
546 xev.xany.type = ClientMessage;
547 xev.xany.display = _ecore_x_disp;
548 xev.xclient.message_type = ECORE_X_ATOM_XDND_FINISHED;
549 xev.xclient.format = 32;
550 xev.xclient.window = _target->source;
551
552 xev.xclient.data.l[0] = _target->win;
553 xev.xclient.data.l[1] = 0;
554 xev.xclient.data.l[2] = 0;
555 if (_target->will_accept)
556 {
557 xev.xclient.data.l[1] |= 0x1UL;
558 xev.xclient.data.l[2] = _target->accepted_action;
559 }
560
561 XSendEvent(_ecore_x_disp, _target->source, False, 0, &xev);
562
563 _target->state = ECORE_X_DND_TARGET_IDLE;
564}
565
566EAPI void
567ecore_x_dnd_source_action_set(Ecore_X_Atom action)
568{
569 _source->action = action;
570 if (_source->prev.window)
571 _ecore_x_dnd_drag(_source->prev.window, _source->prev.x, _source->prev.y);
572}
573
574EAPI Ecore_X_Atom
575ecore_x_dnd_source_action_get(void)
576{
577 return _source->action;
578}
579
580void
581_ecore_x_dnd_drag(Ecore_X_Window root,
582 int x,
583 int y)
584{
585 XEvent xev;
586 Ecore_X_Window win;
587 Ecore_X_Window *skip;
588 Ecore_X_Xdnd_Position pos;
589 int num;
590
591 if (_source->state != ECORE_X_DND_SOURCE_DRAGGING)
592 return;
593
594 /* Preinitialize XEvent struct */
595 memset(&xev, 0, sizeof(XEvent));
596 xev.xany.type = ClientMessage;
597 xev.xany.display = _ecore_x_disp;
598 xev.xclient.format = 32;
599
600 /* Attempt to find a DND-capable window under the cursor */
601 skip = ecore_x_window_ignore_list(&num);
602// WARNING - this function is HEAVY. it goes to and from x a LOT walking the
603// window tree - use the SHADOW version - makes a 1-off tree copy, then uses
604// that instead.
605// win = ecore_x_window_at_xy_with_skip_get(x, y, skip, num);
606 win = ecore_x_window_shadow_tree_at_xy_with_skip_get(root, x, y, skip, num);
607
608// NOTE: This now uses the shadow version to find parent windows
609// while ((win) && !(ecore_x_dnd_version_get(win)))
610// win = ecore_x_window_parent_get(win);
611 while ((win) && !(ecore_x_dnd_version_get(win)))
612 win = ecore_x_window_shadow_parent_get(root, win);
613
614 /* Send XdndLeave to current destination window if we have left it */
615 if ((_source->dest) && (win != _source->dest))
616 {
617 xev.xclient.window = _source->dest;
618 xev.xclient.message_type = ECORE_X_ATOM_XDND_LEAVE;
619 xev.xclient.data.l[0] = _source->win;
620 xev.xclient.data.l[1] = 0;
621
622 XSendEvent(_ecore_x_disp, _source->dest, False, 0, &xev);
623 _source->suppress = 0;
624 }
625
626 if (win)
627 {
628 int x1, x2, y1, y2;
629
630 _source->version = MIN(ECORE_X_DND_VERSION,
631 ecore_x_dnd_version_get(win));
632 if (win != _source->dest)
633 {
634 int i;
635 unsigned char *data;
636 Ecore_X_Atom *types;
637
638 ecore_x_window_prop_property_get(_source->win,
639 ECORE_X_ATOM_XDND_TYPE_LIST,
640 XA_ATOM,
641 32,
642 &data,
643 &num);
644 types = (Ecore_X_Atom *)data;
645
646 /* Entered new window, send XdndEnter */
647 xev.xclient.window = win;
648 xev.xclient.message_type = ECORE_X_ATOM_XDND_ENTER;
649 xev.xclient.data.l[0] = _source->win;
650 xev.xclient.data.l[1] = 0;
651 if (num > 3)
652 xev.xclient.data.l[1] |= 0x1UL;
653 else
654 xev.xclient.data.l[1] &= 0xfffffffeUL;
655
656 xev.xclient.data.l[1] |= ((unsigned long)_source->version) << 24;
657
658 for (i = 2; i < 5; i++)
659 xev.xclient.data.l[i] = 0;
660 for (i = 0; i < MIN(num, 3); ++i)
661 xev.xclient.data.l[i + 2] = types[i];
662 XFree(data);
663 XSendEvent(_ecore_x_disp, win, False, 0, &xev);
664 _source->await_status = 0;
665 _source->will_accept = 0;
666 }
667
668 /* Determine if we're still in the rectangle from the last status */
669 x1 = _source->rectangle.x;
670 x2 = _source->rectangle.x + _source->rectangle.width;
671 y1 = _source->rectangle.y;
672 y2 = _source->rectangle.y + _source->rectangle.height;
673
674 if ((!_source->await_status) ||
675 (!_source->suppress) ||
676 ((x < x1) || (x > x2) || (y < y1) || (y > y2)))
677 {
678 xev.xclient.window = win;
679 xev.xclient.message_type = ECORE_X_ATOM_XDND_POSITION;
680 xev.xclient.data.l[0] = _source->win;
681 xev.xclient.data.l[1] = 0; /* Reserved */
682 xev.xclient.data.l[2] = ((x << 16) & 0xffff0000) | (y & 0xffff);
683 xev.xclient.data.l[3] = _source->time; /* Version 1 */
684 xev.xclient.data.l[4] = _source->action; /* Version 2, Needs to be pre-set */
685 XSendEvent(_ecore_x_disp, win, False, 0, &xev);
686
687 _source->await_status = 1;
688 }
689 }
690
691 if (_posupdatecb)
692 {
693 pos.position.x = x;
694 pos.position.y = y;
695 pos.win = win;
696 pos.prev = _source->dest;
697 _posupdatecb(_posupdatedata, &pos);
698 }
699
700 _source->prev.x = x;
701 _source->prev.y = y;
702 _source->prev.window = root;
703 _source->dest = win;
704}
705
706/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
diff --git a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_dpms.c b/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_dpms.c
deleted file mode 100644
index 23349f4..0000000
--- a/legacy/ecore/src/lib/ecore_x/xlib/ecore_x_dpms.c
+++ /dev/null
@@ -1,247 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include "ecore_x_private.h"
6
7static Eina_Bool _dpms_available = EINA_FALSE;
8
9void
10_ecore_x_dpms_init(void)
11{
12#ifdef ECORE_XDPMS
13 int _dpms_major, _dpms_minor;
14
15 _dpms_major = 1;
16 _dpms_minor = 0;
17
18 if (DPMSGetVersion(_ecore_x_disp, &_dpms_major, &_dpms_minor))
19 _dpms_available = EINA_TRUE;
20 else
21 _dpms_available = EINA_FALSE;
22
23#else /* ifdef ECORE_XDPMS */
24 _dpms_available = EINA_FALSE;
25#endif /* ifdef ECORE_XDPMS */
26}
27
28/**
29 * @defgroup Ecore_X_DPMS_Group X DPMS Extension Functions
30 *
31 * Functions related to the X DPMS extension.
32 */
33
34/**
35 * Checks if the X DPMS extension is available on the server.
36 * @return @c 1 if the X DPMS extension is available, @c 0 otherwise.
37 * @ingroup Ecore_X_DPMS_Group
38 */
39EAPI Eina_Bool
40ecore_x_dpms_query(void)
41{
42 return _dpms_available;
43}
44
45/**
46 * Checks if the X server is capable of DPMS.
47 * @return @c 1 if the X server is capable of DPMS, @c 0 otherwise.