aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ecore/src/lib/ecore_x/xlib
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ecore/src/lib/ecore_x/xlib')
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/Makefile.am94
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/Makefile.in874
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x.c2098
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_atoms.c352
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_composite.c176
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_cursor.c246
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_damage.c71
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_dnd.c706
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_dpms.c247
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_drawable.c118
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_e.c1060
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_error.c111
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_events.c2486
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_fixes.c364
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_gc.c171
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_gesture.c136
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_icccm.c1214
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_image.c598
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_mwm.c106
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_netwm.c2003
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_pixmap.c121
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_private.h385
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr.c102
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr.h7
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_11.c332
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c2199
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12_edid.c457
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_13.c63
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_region.c158
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_screensaver.c173
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_selection.c1001
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_sync.c159
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_test.c155
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_vsync.c351
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_window.c1723
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_window_prop.c750
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_window_shape.c658
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_xi2.c283
-rw-r--r--libraries/ecore/src/lib/ecore_x/xlib/ecore_x_xinerama.c91
39 files changed, 22399 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/Makefile.am b/libraries/ecore/src/lib/ecore_x/xlib/Makefile.am
new file mode 100644
index 0000000..3c7364c
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/Makefile.am
@@ -0,0 +1,94 @@
1
2MAINTAINERCLEANFILES = Makefile.in
3
4if BUILD_ECORE_X_XLIB
5
6AM_CPPFLAGS = \
7@Xcursor_cflags@ \
8@XKB_CFLAGS@ \
9@XDAMAGE_CFLAGS@ \
10@XCOMPOSITE_CFLAGS@ \
11@XGESTURE_CFLAGS@ \
12@XDPMS_CFLAGS@ \
13@XFIXES_CFLAGS@ \
14@XI2_CFLAGS@ \
15@XINERAMA_CFLAGS@ \
16@XPRINT_CFLAGS@ \
17@XRANDR_CFLAGS@ \
18@XRENDER_CFLAGS@ \
19@XSS_CFLAGS@ \
20@XTEST_CFLAGS@ \
21@x_cflags@ \
22-I$(top_srcdir)/src/lib/ecore \
23-I$(top_srcdir)/src/lib/ecore_x \
24-I$(top_srcdir)/src/lib/ecore_input \
25-I$(top_builddir)/src/lib/ecore \
26-I$(top_builddir)/src/lib/ecore_x \
27-I$(top_builddir)/src/lib/ecore_input \
28@EVAS_CFLAGS@ \
29@EINA_CFLAGS@
30
31noinst_LTLIBRARIES = libecore_x_xlib.la
32
33libecore_x_xlib_la_SOURCES = \
34ecore_x.c \
35ecore_x_dnd.c \
36ecore_x_sync.c \
37ecore_x_randr.c \
38ecore_x_randr_11.c \
39ecore_x_randr_12.c \
40ecore_x_randr_12_edid.c \
41ecore_x_randr_13.c \
42ecore_x_fixes.c \
43ecore_x_damage.c \
44ecore_x_composite.c \
45ecore_x_error.c \
46ecore_x_events.c \
47ecore_x_icccm.c \
48ecore_x_netwm.c \
49ecore_x_mwm.c \
50ecore_x_e.c \
51ecore_x_selection.c \
52ecore_x_window.c \
53ecore_x_window_prop.c \
54ecore_x_window_shape.c \
55ecore_x_pixmap.c \
56ecore_x_gc.c \
57ecore_x_xinerama.c \
58ecore_x_screensaver.c \
59ecore_x_dpms.c \
60ecore_x_drawable.c \
61ecore_x_cursor.c \
62ecore_x_test.c \
63ecore_x_atoms.c \
64ecore_x_region.c \
65ecore_x_image.c \
66ecore_x_xi2.c \
67ecore_x_vsync.c \
68ecore_x_randr.h \
69ecore_x_gesture.c
70
71libecore_x_xlib_la_LIBADD = \
72@Xcursor_libs@ \
73@XKB_LIBS@ \
74@XDAMAGE_LIBS@ \
75@XCOMPOSITE_LIBS@ \
76@XGESTURE_LIBS@ \
77@XDPMS_LIBS@ \
78@XFIXES_LIBS@ \
79@XI2_LIBS@ \
80@XINERAMA_LIBS@ \
81@XPRINT_LIBS@ \
82@XRANDR_LIBS@ \
83@XRENDER_LIBS@ \
84@XSS_LIBS@ \
85@XTEST_LIBS@ \
86@x_libs@ \
87$(top_builddir)/src/lib/ecore/libecore.la \
88$(top_builddir)/src/lib/ecore_input/libecore_input.la \
89@EINA_LIBS@ \
90@dlopen_libs@
91
92endif
93
94EXTRA_DIST = ecore_x_private.h
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/Makefile.in b/libraries/ecore/src/lib/ecore_x/xlib/Makefile.in
new file mode 100644
index 0000000..e1026e5
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/Makefile.in
@@ -0,0 +1,874 @@
1# Makefile.in generated by automake 1.11.1 from Makefile.am.
2# @configure_input@
3
4# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
5# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
6# Inc.
7# This Makefile.in is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it,
9# with or without modifications, as long as this notice is preserved.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
13# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
14# PARTICULAR PURPOSE.
15
16@SET_MAKE@
17
18VPATH = @srcdir@
19pkgdatadir = $(datadir)/@PACKAGE@
20pkgincludedir = $(includedir)/@PACKAGE@
21pkglibdir = $(libdir)/@PACKAGE@
22pkglibexecdir = $(libexecdir)/@PACKAGE@
23am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
24install_sh_DATA = $(install_sh) -c -m 644
25install_sh_PROGRAM = $(install_sh) -c
26install_sh_SCRIPT = $(install_sh) -c
27INSTALL_HEADER = $(INSTALL_DATA)
28transform = $(program_transform_name)
29NORMAL_INSTALL = :
30PRE_INSTALL = :
31POST_INSTALL = :
32NORMAL_UNINSTALL = :
33PRE_UNINSTALL = :
34POST_UNINSTALL = :
35build_triplet = @build@
36host_triplet = @host@
37subdir = src/lib/ecore_x/xlib
38DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
39ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
40am__aclocal_m4_deps = $(top_srcdir)/m4/ac_attribute.m4 \
41 $(top_srcdir)/m4/ac_path_generic.m4 \
42 $(top_srcdir)/m4/check_x_extension.m4 \
43 $(top_srcdir)/m4/ecore_check_module.m4 \
44 $(top_srcdir)/m4/ecore_check_options.m4 \
45 $(top_srcdir)/m4/efl_compiler_flag.m4 \
46 $(top_srcdir)/m4/efl_doxygen.m4 \
47 $(top_srcdir)/m4/efl_examples.m4 \
48 $(top_srcdir)/m4/efl_path_max.m4 $(top_srcdir)/m4/efl_tests.m4 \
49 $(top_srcdir)/m4/efl_threads.m4 $(top_srcdir)/m4/gettext.m4 \
50 $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/intlmacosx.m4 \
51 $(top_srcdir)/m4/isc-posix.m4 $(top_srcdir)/m4/lib-ld.m4 \
52 $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \
53 $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
54 $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
55 $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \
56 $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \
57 $(top_srcdir)/configure.ac
58am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
59 $(ACLOCAL_M4)
60mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
61CONFIG_HEADER = $(top_builddir)/config.h
62CONFIG_CLEAN_FILES =
63CONFIG_CLEAN_VPATH_FILES =
64LTLIBRARIES = $(noinst_LTLIBRARIES)
65@BUILD_ECORE_X_XLIB_TRUE@libecore_x_xlib_la_DEPENDENCIES = $(top_builddir)/src/lib/ecore/libecore.la \
66@BUILD_ECORE_X_XLIB_TRUE@ $(top_builddir)/src/lib/ecore_input/libecore_input.la
67am__libecore_x_xlib_la_SOURCES_DIST = ecore_x.c ecore_x_dnd.c \
68 ecore_x_sync.c ecore_x_randr.c ecore_x_randr_11.c \
69 ecore_x_randr_12.c ecore_x_randr_12_edid.c ecore_x_randr_13.c \
70 ecore_x_fixes.c ecore_x_damage.c ecore_x_composite.c \
71 ecore_x_error.c ecore_x_events.c ecore_x_icccm.c \
72 ecore_x_netwm.c ecore_x_mwm.c ecore_x_e.c ecore_x_selection.c \
73 ecore_x_window.c ecore_x_window_prop.c ecore_x_window_shape.c \
74 ecore_x_pixmap.c ecore_x_gc.c ecore_x_xinerama.c \
75 ecore_x_screensaver.c ecore_x_dpms.c ecore_x_drawable.c \
76 ecore_x_cursor.c ecore_x_test.c ecore_x_atoms.c \
77 ecore_x_region.c ecore_x_image.c ecore_x_xi2.c ecore_x_vsync.c \
78 ecore_x_randr.h ecore_x_gesture.c
79@BUILD_ECORE_X_XLIB_TRUE@am_libecore_x_xlib_la_OBJECTS = ecore_x.lo \
80@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_dnd.lo ecore_x_sync.lo \
81@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_randr.lo ecore_x_randr_11.lo \
82@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_randr_12.lo \
83@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_randr_12_edid.lo \
84@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_randr_13.lo ecore_x_fixes.lo \
85@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_damage.lo \
86@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_composite.lo ecore_x_error.lo \
87@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_events.lo ecore_x_icccm.lo \
88@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_netwm.lo ecore_x_mwm.lo \
89@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_e.lo ecore_x_selection.lo \
90@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_window.lo \
91@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_window_prop.lo \
92@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_window_shape.lo \
93@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_pixmap.lo ecore_x_gc.lo \
94@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_xinerama.lo \
95@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_screensaver.lo \
96@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_dpms.lo ecore_x_drawable.lo \
97@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_cursor.lo ecore_x_test.lo \
98@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_atoms.lo ecore_x_region.lo \
99@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_image.lo ecore_x_xi2.lo \
100@BUILD_ECORE_X_XLIB_TRUE@ ecore_x_vsync.lo ecore_x_gesture.lo
101libecore_x_xlib_la_OBJECTS = $(am_libecore_x_xlib_la_OBJECTS)
102AM_V_lt = $(am__v_lt_$(V))
103am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
104am__v_lt_0 = --silent
105@BUILD_ECORE_X_XLIB_TRUE@am_libecore_x_xlib_la_rpath =
106DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
107depcomp = $(SHELL) $(top_srcdir)/depcomp
108am__depfiles_maybe = depfiles
109am__mv = mv -f
110COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
111 $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
112LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
113 $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
114 $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
115 $(AM_CFLAGS) $(CFLAGS)
116AM_V_CC = $(am__v_CC_$(V))
117am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
118am__v_CC_0 = @echo " CC " $@;
119AM_V_at = $(am__v_at_$(V))
120am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
121am__v_at_0 = @
122CCLD = $(CC)
123LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
124 $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
125 $(AM_LDFLAGS) $(LDFLAGS) -o $@
126AM_V_CCLD = $(am__v_CCLD_$(V))
127am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
128am__v_CCLD_0 = @echo " CCLD " $@;
129AM_V_GEN = $(am__v_GEN_$(V))
130am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
131am__v_GEN_0 = @echo " GEN " $@;
132SOURCES = $(libecore_x_xlib_la_SOURCES)
133DIST_SOURCES = $(am__libecore_x_xlib_la_SOURCES_DIST)
134ETAGS = etags
135CTAGS = ctags
136DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
137ACLOCAL = @ACLOCAL@
138ALLOCA = @ALLOCA@
139AMTAR = @AMTAR@
140AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
141AR = @AR@
142AS = @AS@
143AUTOCONF = @AUTOCONF@
144AUTOHEADER = @AUTOHEADER@
145AUTOMAKE = @AUTOMAKE@
146AWK = @AWK@
147CARES_CFLAGS = @CARES_CFLAGS@
148CARES_LIBS = @CARES_LIBS@
149CC = @CC@
150CCDEPMODE = @CCDEPMODE@
151CFLAGS = @CFLAGS@
152CHECK_CFLAGS = @CHECK_CFLAGS@
153CHECK_LIBS = @CHECK_LIBS@
154CPP = @CPP@
155CPPFLAGS = @CPPFLAGS@
156CURL_CFLAGS = @CURL_CFLAGS@
157CURL_LIBS = @CURL_LIBS@
158CXX = @CXX@
159CXXCPP = @CXXCPP@
160CXXDEPMODE = @CXXDEPMODE@
161CXXFLAGS = @CXXFLAGS@
162CYGPATH_W = @CYGPATH_W@
163DEFS = @DEFS@
164DEPDIR = @DEPDIR@
165DIRECTFB_CFLAGS = @DIRECTFB_CFLAGS@
166DIRECTFB_LIBS = @DIRECTFB_LIBS@
167DLLTOOL = @DLLTOOL@
168DSYMUTIL = @DSYMUTIL@
169DUMPBIN = @DUMPBIN@
170ECHO_C = @ECHO_C@
171ECHO_N = @ECHO_N@
172ECHO_T = @ECHO_T@
173ECORE_XCB_CFLAGS = @ECORE_XCB_CFLAGS@
174ECORE_XCB_LIBS = @ECORE_XCB_LIBS@
175EFL_ECORE_BUILD = @EFL_ECORE_BUILD@
176EFL_ECORE_CON_BUILD = @EFL_ECORE_CON_BUILD@
177EFL_ECORE_EVAS_BUILD = @EFL_ECORE_EVAS_BUILD@
178EFL_ECORE_FILE_BUILD = @EFL_ECORE_FILE_BUILD@
179EFL_ECORE_IMF_BUILD = @EFL_ECORE_IMF_BUILD@
180EFL_ECORE_IMF_EVAS_BUILD = @EFL_ECORE_IMF_EVAS_BUILD@
181EFL_ECORE_INPUT_BUILD = @EFL_ECORE_INPUT_BUILD@
182EFL_ECORE_INPUT_EVAS_BUILD = @EFL_ECORE_INPUT_EVAS_BUILD@
183EFL_ECORE_IPC_BUILD = @EFL_ECORE_IPC_BUILD@
184EFL_ECORE_PSL1GHT_BUILD = @EFL_ECORE_PSL1GHT_BUILD@
185EFL_ECORE_SDL_BUILD = @EFL_ECORE_SDL_BUILD@
186EFL_ECORE_WIN32_BUILD = @EFL_ECORE_WIN32_BUILD@
187EFL_ECORE_WINCE_BUILD = @EFL_ECORE_WINCE_BUILD@
188EFL_PTHREAD_CFLAGS = @EFL_PTHREAD_CFLAGS@
189EFL_PTHREAD_LIBS = @EFL_PTHREAD_LIBS@
190EGREP = @EGREP@
191EINA_CFLAGS = @EINA_CFLAGS@
192EINA_LIBS = @EINA_LIBS@
193ESCAPE_CFLAGS = @ESCAPE_CFLAGS@
194ESCAPE_LIBS = @ESCAPE_LIBS@
195EVAS_CFLAGS = @EVAS_CFLAGS@
196EVAS_LIBS = @EVAS_LIBS@
197EVIL_CFLAGS = @EVIL_CFLAGS@
198EVIL_LIBS = @EVIL_LIBS@
199EXEEXT = @EXEEXT@
200FGREP = @FGREP@
201GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
202GLIB_CFLAGS = @GLIB_CFLAGS@
203GLIB_LIBS = @GLIB_LIBS@
204GMSGFMT = @GMSGFMT@
205GMSGFMT_015 = @GMSGFMT_015@
206GREP = @GREP@
207INSTALL = @INSTALL@
208INSTALL_DATA = @INSTALL_DATA@
209INSTALL_PROGRAM = @INSTALL_PROGRAM@
210INSTALL_SCRIPT = @INSTALL_SCRIPT@
211INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
212INTLLIBS = @INTLLIBS@
213INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@
214KEYSYMDEFS = @KEYSYMDEFS@
215LD = @LD@
216LDFLAGS = @LDFLAGS@
217LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@
218LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@
219LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@
220LIBICONV = @LIBICONV@
221LIBINTL = @LIBINTL@
222LIBOBJS = @LIBOBJS@
223LIBS = @LIBS@
224LIBTOOL = @LIBTOOL@
225LIPO = @LIPO@
226LN_S = @LN_S@
227LTLIBICONV = @LTLIBICONV@
228LTLIBINTL = @LTLIBINTL@
229LTLIBOBJS = @LTLIBOBJS@
230MAKEINFO = @MAKEINFO@
231MKDIR_P = @MKDIR_P@
232MSGFMT = @MSGFMT@
233MSGFMT_015 = @MSGFMT_015@
234MSGMERGE = @MSGMERGE@
235NM = @NM@
236NMEDIT = @NMEDIT@
237OBJC = @OBJC@
238OBJCDEPMODE = @OBJCDEPMODE@
239OBJCFLAGS = @OBJCFLAGS@
240OBJDUMP = @OBJDUMP@
241OBJEXT = @OBJEXT@
242OTOOL = @OTOOL@
243OTOOL64 = @OTOOL64@
244PACKAGE = @PACKAGE@
245PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
246PACKAGE_NAME = @PACKAGE_NAME@
247PACKAGE_STRING = @PACKAGE_STRING@
248PACKAGE_TARNAME = @PACKAGE_TARNAME@
249PACKAGE_URL = @PACKAGE_URL@
250PACKAGE_VERSION = @PACKAGE_VERSION@
251PATH_SEPARATOR = @PATH_SEPARATOR@
252PIXMAN_CFLAGS = @PIXMAN_CFLAGS@
253PIXMAN_LIBS = @PIXMAN_LIBS@
254PKG_CONFIG = @PKG_CONFIG@
255PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
256PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
257POSUB = @POSUB@
258RANLIB = @RANLIB@
259SDL_CFLAGS = @SDL_CFLAGS@
260SDL_CONFIG = @SDL_CONFIG@
261SDL_LIBS = @SDL_LIBS@
262SED = @SED@
263SET_MAKE = @SET_MAKE@
264SHELL = @SHELL@
265SSL_CFLAGS = @SSL_CFLAGS@
266SSL_LIBS = @SSL_LIBS@
267STRIP = @STRIP@
268TLS2_CFLAGS = @TLS2_CFLAGS@
269TLS2_LIBS = @TLS2_LIBS@
270TLS_CFLAGS = @TLS_CFLAGS@
271TLS_LIBS = @TLS_LIBS@
272TSLIB_CFLAGS = @TSLIB_CFLAGS@
273TSLIB_LIBS = @TSLIB_LIBS@
274USE_NLS = @USE_NLS@
275VERSION = @VERSION@
276VMAJ = @VMAJ@
277WIN32_CFLAGS = @WIN32_CFLAGS@
278WIN32_CPPFLAGS = @WIN32_CPPFLAGS@
279WIN32_LIBS = @WIN32_LIBS@
280XCB_COMPOSITE_CFLAGS = @XCB_COMPOSITE_CFLAGS@
281XCB_COMPOSITE_LIBS = @XCB_COMPOSITE_LIBS@
282XCB_CURSOR_CFLAGS = @XCB_CURSOR_CFLAGS@
283XCB_CURSOR_LIBS = @XCB_CURSOR_LIBS@
284XCB_DAMAGE_CFLAGS = @XCB_DAMAGE_CFLAGS@
285XCB_DAMAGE_LIBS = @XCB_DAMAGE_LIBS@
286XCB_DPMS_CFLAGS = @XCB_DPMS_CFLAGS@
287XCB_DPMS_LIBS = @XCB_DPMS_LIBS@
288XCB_RANDR_CFLAGS = @XCB_RANDR_CFLAGS@
289XCB_RANDR_LIBS = @XCB_RANDR_LIBS@
290XCB_RENDER_CFLAGS = @XCB_RENDER_CFLAGS@
291XCB_RENDER_LIBS = @XCB_RENDER_LIBS@
292XCB_SCREENSAVER_CFLAGS = @XCB_SCREENSAVER_CFLAGS@
293XCB_SCREENSAVER_LIBS = @XCB_SCREENSAVER_LIBS@
294XCB_SHAPE_CFLAGS = @XCB_SHAPE_CFLAGS@
295XCB_SHAPE_LIBS = @XCB_SHAPE_LIBS@
296XCB_SYNC_CFLAGS = @XCB_SYNC_CFLAGS@
297XCB_SYNC_LIBS = @XCB_SYNC_LIBS@
298XCB_X11_CFLAGS = @XCB_X11_CFLAGS@
299XCB_X11_LIBS = @XCB_X11_LIBS@
300XCB_XFIXES_CFLAGS = @XCB_XFIXES_CFLAGS@
301XCB_XFIXES_LIBS = @XCB_XFIXES_LIBS@
302XCB_XGESTURE_CFLAGS = @XCB_XGESTURE_CFLAGS@
303XCB_XGESTURE_LIBS = @XCB_XGESTURE_LIBS@
304XCB_XINERAMA_CFLAGS = @XCB_XINERAMA_CFLAGS@
305XCB_XINERAMA_LIBS = @XCB_XINERAMA_LIBS@
306XCB_XINPUT_CFLAGS = @XCB_XINPUT_CFLAGS@
307XCB_XINPUT_LIBS = @XCB_XINPUT_LIBS@
308XCB_XPRINT_CFLAGS = @XCB_XPRINT_CFLAGS@
309XCB_XPRINT_LIBS = @XCB_XPRINT_LIBS@
310XCB_XTEST_CFLAGS = @XCB_XTEST_CFLAGS@
311XCB_XTEST_LIBS = @XCB_XTEST_LIBS@
312XCOMPOSITE_CFLAGS = @XCOMPOSITE_CFLAGS@
313XCOMPOSITE_LIBS = @XCOMPOSITE_LIBS@
314XDAMAGE_CFLAGS = @XDAMAGE_CFLAGS@
315XDAMAGE_LIBS = @XDAMAGE_LIBS@
316XDPMS_CFLAGS = @XDPMS_CFLAGS@
317XDPMS_LIBS = @XDPMS_LIBS@
318XFIXES_CFLAGS = @XFIXES_CFLAGS@
319XFIXES_LIBS = @XFIXES_LIBS@
320XGESTURE_CFLAGS = @XGESTURE_CFLAGS@
321XGESTURE_LIBS = @XGESTURE_LIBS@
322XGETTEXT = @XGETTEXT@
323XGETTEXT_015 = @XGETTEXT_015@
324XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@
325XI2_CFLAGS = @XI2_CFLAGS@
326XI2_LIBS = @XI2_LIBS@
327XINERAMA_CFLAGS = @XINERAMA_CFLAGS@
328XINERAMA_LIBS = @XINERAMA_LIBS@
329XKB_CFLAGS = @XKB_CFLAGS@
330XKB_LIBS = @XKB_LIBS@
331XMKMF = @XMKMF@
332XPRINT_CFLAGS = @XPRINT_CFLAGS@
333XPRINT_LIBS = @XPRINT_LIBS@
334XRANDR_CFLAGS = @XRANDR_CFLAGS@
335XRANDR_LIBS = @XRANDR_LIBS@
336XRENDER_CFLAGS = @XRENDER_CFLAGS@
337XRENDER_LIBS = @XRENDER_LIBS@
338XSS_CFLAGS = @XSS_CFLAGS@
339XSS_LIBS = @XSS_LIBS@
340XTEST_CFLAGS = @XTEST_CFLAGS@
341XTEST_LIBS = @XTEST_LIBS@
342X_CFLAGS = @X_CFLAGS@
343X_EXTRA_LIBS = @X_EXTRA_LIBS@
344X_LIBS = @X_LIBS@
345X_PRE_LIBS = @X_PRE_LIBS@
346Xcursor_cflags = @Xcursor_cflags@
347Xcursor_libs = @Xcursor_libs@
348abs_builddir = @abs_builddir@
349abs_srcdir = @abs_srcdir@
350abs_top_builddir = @abs_top_builddir@
351abs_top_srcdir = @abs_top_srcdir@
352ac_ct_CC = @ac_ct_CC@
353ac_ct_CXX = @ac_ct_CXX@
354ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
355ac_ct_OBJC = @ac_ct_OBJC@
356am__include = @am__include@
357am__leading_dot = @am__leading_dot@
358am__quote = @am__quote@
359am__tar = @am__tar@
360am__untar = @am__untar@
361bindir = @bindir@
362build = @build@
363build_alias = @build_alias@
364build_cpu = @build_cpu@
365build_os = @build_os@
366build_vendor = @build_vendor@
367builddir = @builddir@
368cocoa_ldflags = @cocoa_ldflags@
369datadir = @datadir@
370datarootdir = @datarootdir@
371dlopen_libs = @dlopen_libs@
372docdir = @docdir@
373dvidir = @dvidir@
374ecore_cocoa_cflags = @ecore_cocoa_cflags@
375ecore_cocoa_libs = @ecore_cocoa_libs@
376ecore_con_cflags = @ecore_con_cflags@
377ecore_con_libs = @ecore_con_libs@
378ecore_directfb_cflags = @ecore_directfb_cflags@
379ecore_directfb_libs = @ecore_directfb_libs@
380ecore_evas_cflags = @ecore_evas_cflags@
381ecore_evas_libs = @ecore_evas_libs@
382ecore_fb_cflags = @ecore_fb_cflags@
383ecore_fb_libs = @ecore_fb_libs@
384ecore_file_cflags = @ecore_file_cflags@
385ecore_file_libs = @ecore_file_libs@
386ecore_imf_cflags = @ecore_imf_cflags@
387ecore_imf_evas_cflags = @ecore_imf_evas_cflags@
388ecore_imf_evas_libs = @ecore_imf_evas_libs@
389ecore_imf_libs = @ecore_imf_libs@
390ecore_imf_xim_cflags = @ecore_imf_xim_cflags@
391ecore_imf_xim_libs = @ecore_imf_xim_libs@
392ecore_input_cflags = @ecore_input_cflags@
393ecore_input_evas_cflags = @ecore_input_evas_cflags@
394ecore_input_evas_libs = @ecore_input_evas_libs@
395ecore_input_libs = @ecore_input_libs@
396ecore_ipc_cflags = @ecore_ipc_cflags@
397ecore_ipc_libs = @ecore_ipc_libs@
398ecore_psl1ght_cflags = @ecore_psl1ght_cflags@
399ecore_psl1ght_libs = @ecore_psl1ght_libs@
400ecore_sdl_cflags = @ecore_sdl_cflags@
401ecore_sdl_libs = @ecore_sdl_libs@
402ecore_win32_cflags = @ecore_win32_cflags@
403ecore_win32_libs = @ecore_win32_libs@
404ecore_wince_cflags = @ecore_wince_cflags@
405ecore_wince_libs = @ecore_wince_libs@
406ecore_x_cflags = @ecore_x_cflags@
407ecore_x_libs = @ecore_x_libs@
408ecore_x_libs_private = @ecore_x_libs_private@
409efl_doxygen = @efl_doxygen@
410efl_have_doxygen = @efl_have_doxygen@
411exec_prefix = @exec_prefix@
412have_ecore_x_xcb_define = @have_ecore_x_xcb_define@
413host = @host@
414host_alias = @host_alias@
415host_cpu = @host_cpu@
416host_os = @host_os@
417host_vendor = @host_vendor@
418htmldir = @htmldir@
419includedir = @includedir@
420infodir = @infodir@
421install_sh = @install_sh@
422libdir = @libdir@
423libexecdir = @libexecdir@
424localedir = @localedir@
425localstatedir = @localstatedir@
426lt_ECHO = @lt_ECHO@
427lt_enable_auto_import = @lt_enable_auto_import@
428mandir = @mandir@
429mkdir_p = @mkdir_p@
430oldincludedir = @oldincludedir@
431pdfdir = @pdfdir@
432pkgconfig_requires_private = @pkgconfig_requires_private@
433prefix = @prefix@
434program_transform_name = @program_transform_name@
435psdir = @psdir@
436release_info = @release_info@
437requirements_ecore = @requirements_ecore@
438requirements_ecore_cocoa = @requirements_ecore_cocoa@
439requirements_ecore_con = @requirements_ecore_con@
440requirements_ecore_directfb = @requirements_ecore_directfb@
441requirements_ecore_evas = @requirements_ecore_evas@
442requirements_ecore_fb = @requirements_ecore_fb@
443requirements_ecore_file = @requirements_ecore_file@
444requirements_ecore_imf = @requirements_ecore_imf@
445requirements_ecore_imf_evas = @requirements_ecore_imf_evas@
446requirements_ecore_imf_xim = @requirements_ecore_imf_xim@
447requirements_ecore_input = @requirements_ecore_input@
448requirements_ecore_input_evas = @requirements_ecore_input_evas@
449requirements_ecore_ipc = @requirements_ecore_ipc@
450requirements_ecore_psl1ght = @requirements_ecore_psl1ght@
451requirements_ecore_sdl = @requirements_ecore_sdl@
452requirements_ecore_win32 = @requirements_ecore_win32@
453requirements_ecore_wince = @requirements_ecore_wince@
454requirements_ecore_x = @requirements_ecore_x@
455rt_libs = @rt_libs@
456sbindir = @sbindir@
457sharedstatedir = @sharedstatedir@
458srcdir = @srcdir@
459sysconfdir = @sysconfdir@
460target_alias = @target_alias@
461top_build_prefix = @top_build_prefix@
462top_builddir = @top_builddir@
463top_srcdir = @top_srcdir@
464version_info = @version_info@
465x_cflags = @x_cflags@
466x_includes = @x_includes@
467x_libs = @x_libs@
468MAINTAINERCLEANFILES = Makefile.in
469@BUILD_ECORE_X_XLIB_TRUE@AM_CPPFLAGS = \
470@BUILD_ECORE_X_XLIB_TRUE@@Xcursor_cflags@ \
471@BUILD_ECORE_X_XLIB_TRUE@@XKB_CFLAGS@ \
472@BUILD_ECORE_X_XLIB_TRUE@@XDAMAGE_CFLAGS@ \
473@BUILD_ECORE_X_XLIB_TRUE@@XCOMPOSITE_CFLAGS@ \
474@BUILD_ECORE_X_XLIB_TRUE@@XGESTURE_CFLAGS@ \
475@BUILD_ECORE_X_XLIB_TRUE@@XDPMS_CFLAGS@ \
476@BUILD_ECORE_X_XLIB_TRUE@@XFIXES_CFLAGS@ \
477@BUILD_ECORE_X_XLIB_TRUE@@XI2_CFLAGS@ \
478@BUILD_ECORE_X_XLIB_TRUE@@XINERAMA_CFLAGS@ \
479@BUILD_ECORE_X_XLIB_TRUE@@XPRINT_CFLAGS@ \
480@BUILD_ECORE_X_XLIB_TRUE@@XRANDR_CFLAGS@ \
481@BUILD_ECORE_X_XLIB_TRUE@@XRENDER_CFLAGS@ \
482@BUILD_ECORE_X_XLIB_TRUE@@XSS_CFLAGS@ \
483@BUILD_ECORE_X_XLIB_TRUE@@XTEST_CFLAGS@ \
484@BUILD_ECORE_X_XLIB_TRUE@@x_cflags@ \
485@BUILD_ECORE_X_XLIB_TRUE@-I$(top_srcdir)/src/lib/ecore \
486@BUILD_ECORE_X_XLIB_TRUE@-I$(top_srcdir)/src/lib/ecore_x \
487@BUILD_ECORE_X_XLIB_TRUE@-I$(top_srcdir)/src/lib/ecore_input \
488@BUILD_ECORE_X_XLIB_TRUE@-I$(top_builddir)/src/lib/ecore \
489@BUILD_ECORE_X_XLIB_TRUE@-I$(top_builddir)/src/lib/ecore_x \
490@BUILD_ECORE_X_XLIB_TRUE@-I$(top_builddir)/src/lib/ecore_input \
491@BUILD_ECORE_X_XLIB_TRUE@@EVAS_CFLAGS@ \
492@BUILD_ECORE_X_XLIB_TRUE@@EINA_CFLAGS@
493
494@BUILD_ECORE_X_XLIB_TRUE@noinst_LTLIBRARIES = libecore_x_xlib.la
495@BUILD_ECORE_X_XLIB_TRUE@libecore_x_xlib_la_SOURCES = \
496@BUILD_ECORE_X_XLIB_TRUE@ecore_x.c \
497@BUILD_ECORE_X_XLIB_TRUE@ecore_x_dnd.c \
498@BUILD_ECORE_X_XLIB_TRUE@ecore_x_sync.c \
499@BUILD_ECORE_X_XLIB_TRUE@ecore_x_randr.c \
500@BUILD_ECORE_X_XLIB_TRUE@ecore_x_randr_11.c \
501@BUILD_ECORE_X_XLIB_TRUE@ecore_x_randr_12.c \
502@BUILD_ECORE_X_XLIB_TRUE@ecore_x_randr_12_edid.c \
503@BUILD_ECORE_X_XLIB_TRUE@ecore_x_randr_13.c \
504@BUILD_ECORE_X_XLIB_TRUE@ecore_x_fixes.c \
505@BUILD_ECORE_X_XLIB_TRUE@ecore_x_damage.c \
506@BUILD_ECORE_X_XLIB_TRUE@ecore_x_composite.c \
507@BUILD_ECORE_X_XLIB_TRUE@ecore_x_error.c \
508@BUILD_ECORE_X_XLIB_TRUE@ecore_x_events.c \
509@BUILD_ECORE_X_XLIB_TRUE@ecore_x_icccm.c \
510@BUILD_ECORE_X_XLIB_TRUE@ecore_x_netwm.c \
511@BUILD_ECORE_X_XLIB_TRUE@ecore_x_mwm.c \
512@BUILD_ECORE_X_XLIB_TRUE@ecore_x_e.c \
513@BUILD_ECORE_X_XLIB_TRUE@ecore_x_selection.c \
514@BUILD_ECORE_X_XLIB_TRUE@ecore_x_window.c \
515@BUILD_ECORE_X_XLIB_TRUE@ecore_x_window_prop.c \
516@BUILD_ECORE_X_XLIB_TRUE@ecore_x_window_shape.c \
517@BUILD_ECORE_X_XLIB_TRUE@ecore_x_pixmap.c \
518@BUILD_ECORE_X_XLIB_TRUE@ecore_x_gc.c \
519@BUILD_ECORE_X_XLIB_TRUE@ecore_x_xinerama.c \
520@BUILD_ECORE_X_XLIB_TRUE@ecore_x_screensaver.c \
521@BUILD_ECORE_X_XLIB_TRUE@ecore_x_dpms.c \
522@BUILD_ECORE_X_XLIB_TRUE@ecore_x_drawable.c \
523@BUILD_ECORE_X_XLIB_TRUE@ecore_x_cursor.c \
524@BUILD_ECORE_X_XLIB_TRUE@ecore_x_test.c \
525@BUILD_ECORE_X_XLIB_TRUE@ecore_x_atoms.c \
526@BUILD_ECORE_X_XLIB_TRUE@ecore_x_region.c \
527@BUILD_ECORE_X_XLIB_TRUE@ecore_x_image.c \
528@BUILD_ECORE_X_XLIB_TRUE@ecore_x_xi2.c \
529@BUILD_ECORE_X_XLIB_TRUE@ecore_x_vsync.c \
530@BUILD_ECORE_X_XLIB_TRUE@ecore_x_randr.h \
531@BUILD_ECORE_X_XLIB_TRUE@ecore_x_gesture.c
532
533@BUILD_ECORE_X_XLIB_TRUE@libecore_x_xlib_la_LIBADD = \
534@BUILD_ECORE_X_XLIB_TRUE@@Xcursor_libs@ \
535@BUILD_ECORE_X_XLIB_TRUE@@XKB_LIBS@ \
536@BUILD_ECORE_X_XLIB_TRUE@@XDAMAGE_LIBS@ \
537@BUILD_ECORE_X_XLIB_TRUE@@XCOMPOSITE_LIBS@ \
538@BUILD_ECORE_X_XLIB_TRUE@@XGESTURE_LIBS@ \
539@BUILD_ECORE_X_XLIB_TRUE@@XDPMS_LIBS@ \
540@BUILD_ECORE_X_XLIB_TRUE@@XFIXES_LIBS@ \
541@BUILD_ECORE_X_XLIB_TRUE@@XI2_LIBS@ \
542@BUILD_ECORE_X_XLIB_TRUE@@XINERAMA_LIBS@ \
543@BUILD_ECORE_X_XLIB_TRUE@@XPRINT_LIBS@ \
544@BUILD_ECORE_X_XLIB_TRUE@@XRANDR_LIBS@ \
545@BUILD_ECORE_X_XLIB_TRUE@@XRENDER_LIBS@ \
546@BUILD_ECORE_X_XLIB_TRUE@@XSS_LIBS@ \
547@BUILD_ECORE_X_XLIB_TRUE@@XTEST_LIBS@ \
548@BUILD_ECORE_X_XLIB_TRUE@@x_libs@ \
549@BUILD_ECORE_X_XLIB_TRUE@$(top_builddir)/src/lib/ecore/libecore.la \
550@BUILD_ECORE_X_XLIB_TRUE@$(top_builddir)/src/lib/ecore_input/libecore_input.la \
551@BUILD_ECORE_X_XLIB_TRUE@@EINA_LIBS@ \
552@BUILD_ECORE_X_XLIB_TRUE@@dlopen_libs@
553
554EXTRA_DIST = ecore_x_private.h
555all: all-am
556
557.SUFFIXES:
558.SUFFIXES: .c .lo .o .obj
559$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
560 @for dep in $?; do \
561 case '$(am__configure_deps)' in \
562 *$$dep*) \
563 ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
564 && { if test -f $@; then exit 0; else break; fi; }; \
565 exit 1;; \
566 esac; \
567 done; \
568 echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/lib/ecore_x/xlib/Makefile'; \
569 $(am__cd) $(top_srcdir) && \
570 $(AUTOMAKE) --gnu src/lib/ecore_x/xlib/Makefile
571.PRECIOUS: Makefile
572Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
573 @case '$?' in \
574 *config.status*) \
575 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
576 *) \
577 echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
578 cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
579 esac;
580
581$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
582 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
583
584$(top_srcdir)/configure: $(am__configure_deps)
585 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
586$(ACLOCAL_M4): $(am__aclocal_m4_deps)
587 cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
588$(am__aclocal_m4_deps):
589
590clean-noinstLTLIBRARIES:
591 -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
592 @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
593 dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
594 test "$$dir" != "$$p" || dir=.; \
595 echo "rm -f \"$${dir}/so_locations\""; \
596 rm -f "$${dir}/so_locations"; \
597 done
598libecore_x_xlib.la: $(libecore_x_xlib_la_OBJECTS) $(libecore_x_xlib_la_DEPENDENCIES)
599 $(AM_V_CCLD)$(LINK) $(am_libecore_x_xlib_la_rpath) $(libecore_x_xlib_la_OBJECTS) $(libecore_x_xlib_la_LIBADD) $(LIBS)
600
601mostlyclean-compile:
602 -rm -f *.$(OBJEXT)
603
604distclean-compile:
605 -rm -f *.tab.c
606
607@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x.Plo@am__quote@
608@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_atoms.Plo@am__quote@
609@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_composite.Plo@am__quote@
610@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_cursor.Plo@am__quote@
611@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_damage.Plo@am__quote@
612@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_dnd.Plo@am__quote@
613@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_dpms.Plo@am__quote@
614@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_drawable.Plo@am__quote@
615@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_e.Plo@am__quote@
616@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_error.Plo@am__quote@
617@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_events.Plo@am__quote@
618@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_fixes.Plo@am__quote@
619@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_gc.Plo@am__quote@
620@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_gesture.Plo@am__quote@
621@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_icccm.Plo@am__quote@
622@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_image.Plo@am__quote@
623@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_mwm.Plo@am__quote@
624@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_netwm.Plo@am__quote@
625@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_pixmap.Plo@am__quote@
626@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_randr.Plo@am__quote@
627@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_randr_11.Plo@am__quote@
628@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_randr_12.Plo@am__quote@
629@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_randr_12_edid.Plo@am__quote@
630@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_randr_13.Plo@am__quote@
631@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_region.Plo@am__quote@
632@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_screensaver.Plo@am__quote@
633@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_selection.Plo@am__quote@
634@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_sync.Plo@am__quote@
635@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_test.Plo@am__quote@
636@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_vsync.Plo@am__quote@
637@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_window.Plo@am__quote@
638@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_window_prop.Plo@am__quote@
639@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_window_shape.Plo@am__quote@
640@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_xi2.Plo@am__quote@
641@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_x_xinerama.Plo@am__quote@
642
643.c.o:
644@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
645@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
646@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
647@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
648@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
649@am__fastdepCC_FALSE@ $(COMPILE) -c $<
650
651.c.obj:
652@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
653@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
654@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
655@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
656@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
657@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
658
659.c.lo:
660@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
661@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
662@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
663@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
664@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
665@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
666
667mostlyclean-libtool:
668 -rm -f *.lo
669
670clean-libtool:
671 -rm -rf .libs _libs
672
673ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
674 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
675 unique=`for i in $$list; do \
676 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
677 done | \
678 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
679 END { if (nonempty) { for (i in files) print i; }; }'`; \
680 mkid -fID $$unique
681tags: TAGS
682
683TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
684 $(TAGS_FILES) $(LISP)
685 set x; \
686 here=`pwd`; \
687 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
688 unique=`for i in $$list; do \
689 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
690 done | \
691 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
692 END { if (nonempty) { for (i in files) print i; }; }'`; \
693 shift; \
694 if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
695 test -n "$$unique" || unique=$$empty_fix; \
696 if test $$# -gt 0; then \
697 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
698 "$$@" $$unique; \
699 else \
700 $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
701 $$unique; \
702 fi; \
703 fi
704ctags: CTAGS
705CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
706 $(TAGS_FILES) $(LISP)
707 list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
708 unique=`for i in $$list; do \
709 if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
710 done | \
711 $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
712 END { if (nonempty) { for (i in files) print i; }; }'`; \
713 test -z "$(CTAGS_ARGS)$$unique" \
714 || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
715 $$unique
716
717GTAGS:
718 here=`$(am__cd) $(top_builddir) && pwd` \
719 && $(am__cd) $(top_srcdir) \
720 && gtags -i $(GTAGS_ARGS) "$$here"
721
722distclean-tags:
723 -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
724
725distdir: $(DISTFILES)
726 @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
727 topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
728 list='$(DISTFILES)'; \
729 dist_files=`for file in $$list; do echo $$file; done | \
730 sed -e "s|^$$srcdirstrip/||;t" \
731 -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
732 case $$dist_files in \
733 */*) $(MKDIR_P) `echo "$$dist_files" | \
734 sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
735 sort -u` ;; \
736 esac; \
737 for file in $$dist_files; do \
738 if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
739 if test -d $$d/$$file; then \
740 dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
741 if test -d "$(distdir)/$$file"; then \
742 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
743 fi; \
744 if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
745 cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
746 find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
747 fi; \
748 cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
749 else \
750 test -f "$(distdir)/$$file" \
751 || cp -p $$d/$$file "$(distdir)/$$file" \
752 || exit 1; \
753 fi; \
754 done
755check-am: all-am
756check: check-am
757all-am: Makefile $(LTLIBRARIES)
758installdirs:
759install: install-am
760install-exec: install-exec-am
761install-data: install-data-am
762uninstall: uninstall-am
763
764install-am: all-am
765 @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
766
767installcheck: installcheck-am
768install-strip:
769 $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
770 install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
771 `test -z '$(STRIP)' || \
772 echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
773mostlyclean-generic:
774
775clean-generic:
776
777distclean-generic:
778 -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
779 -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
780
781maintainer-clean-generic:
782 @echo "This command is intended for maintainers to use"
783 @echo "it deletes files that may require special tools to rebuild."
784 -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
785clean: clean-am
786
787clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
788 mostlyclean-am
789
790distclean: distclean-am
791 -rm -rf ./$(DEPDIR)
792 -rm -f Makefile
793distclean-am: clean-am distclean-compile distclean-generic \
794 distclean-tags
795
796dvi: dvi-am
797
798dvi-am:
799
800html: html-am
801
802html-am:
803
804info: info-am
805
806info-am:
807
808install-data-am:
809
810install-dvi: install-dvi-am
811
812install-dvi-am:
813
814install-exec-am:
815
816install-html: install-html-am
817
818install-html-am:
819
820install-info: install-info-am
821
822install-info-am:
823
824install-man:
825
826install-pdf: install-pdf-am
827
828install-pdf-am:
829
830install-ps: install-ps-am
831
832install-ps-am:
833
834installcheck-am:
835
836maintainer-clean: maintainer-clean-am
837 -rm -rf ./$(DEPDIR)
838 -rm -f Makefile
839maintainer-clean-am: distclean-am maintainer-clean-generic
840
841mostlyclean: mostlyclean-am
842
843mostlyclean-am: mostlyclean-compile mostlyclean-generic \
844 mostlyclean-libtool
845
846pdf: pdf-am
847
848pdf-am:
849
850ps: ps-am
851
852ps-am:
853
854uninstall-am:
855
856.MAKE: install-am install-strip
857
858.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
859 clean-libtool clean-noinstLTLIBRARIES ctags distclean \
860 distclean-compile distclean-generic distclean-libtool \
861 distclean-tags distdir dvi dvi-am html html-am info info-am \
862 install install-am install-data install-data-am install-dvi \
863 install-dvi-am install-exec install-exec-am install-html \
864 install-html-am install-info install-info-am install-man \
865 install-pdf install-pdf-am install-ps install-ps-am \
866 install-strip installcheck installcheck-am installdirs \
867 maintainer-clean maintainer-clean-generic mostlyclean \
868 mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
869 pdf pdf-am ps ps-am tags uninstall uninstall-am
870
871
872# Tell versions [3.59,3.63) of GNU make to not export all variables.
873# Otherwise a system limit (for SysV at least) may be exceeded.
874.NOEXPORT:
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x.c
new file mode 100644
index 0000000..844ab04
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x.c
@@ -0,0 +1,2098 @@
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#include <unistd.h>
8
9//#define LOGRT 1
10
11#ifdef LOGRT
12#include <dlfcn.h>
13#endif /* ifdef LOGRT */
14
15#include "Ecore.h"
16#include "ecore_private.h"
17#include "ecore_x_private.h"
18#include "Ecore_X.h"
19#include "Ecore_X_Atoms.h"
20#include "Ecore_Input.h"
21
22static Eina_Bool _ecore_x_fd_handler(void *data,
23 Ecore_Fd_Handler *fd_handler);
24static Eina_Bool _ecore_x_fd_handler_buf(void *data,
25 Ecore_Fd_Handler *fd_handler);
26static int _ecore_x_key_mask_get(KeySym sym);
27static int _ecore_x_event_modifier(unsigned int state);
28
29static Ecore_Fd_Handler *_ecore_x_fd_handler_handle = NULL;
30
31static const int AnyXEvent = 0; /* 0 can be used as there are no event types
32 * with index 0 and 1 as they are used for
33 * errors
34 */
35
36static int _ecore_x_event_shape_id = 0;
37static int _ecore_x_event_screensaver_id = 0;
38static int _ecore_x_event_sync_id = 0;
39int _ecore_xlib_log_dom = -1;
40
41#ifdef ECORE_XRANDR
42static int _ecore_x_event_randr_id = 0;
43#endif /* ifdef ECORE_XRANDR */
44#ifdef ECORE_XFIXES
45static int _ecore_x_event_fixes_selection_id = 0;
46#endif /* ifdef ECORE_XFIXES */
47#ifdef ECORE_XDAMAGE
48static int _ecore_x_event_damage_id = 0;
49#endif /* ifdef ECORE_XDAMAGE */
50#ifdef ECORE_XGESTURE
51static int _ecore_x_event_gesture_id = 0;
52#endif /* ifdef ECORE_XGESTURE */
53static int _ecore_x_event_handlers_num = 0;
54static void (**_ecore_x_event_handlers) (XEvent * event) = NULL;
55
56static int _ecore_x_init_count = 0;
57static int _ecore_x_grab_count = 0;
58
59Display *_ecore_x_disp = NULL;
60double _ecore_x_double_click_time = 0.25;
61Time _ecore_x_event_last_time = 0;
62Window _ecore_x_event_last_win = 0;
63int _ecore_x_event_last_root_x = 0;
64int _ecore_x_event_last_root_y = 0;
65Eina_Bool _ecore_x_xcursor = EINA_FALSE;
66
67Ecore_X_Window _ecore_x_private_win = 0;
68
69Ecore_X_Atom _ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_NUM];
70
71EAPI int ECORE_X_EVENT_ANY = 0;
72EAPI int ECORE_X_EVENT_MOUSE_IN = 0;
73EAPI int ECORE_X_EVENT_MOUSE_OUT = 0;
74EAPI int ECORE_X_EVENT_WINDOW_FOCUS_IN = 0;
75EAPI int ECORE_X_EVENT_WINDOW_FOCUS_OUT = 0;
76EAPI int ECORE_X_EVENT_WINDOW_KEYMAP = 0;
77EAPI int ECORE_X_EVENT_WINDOW_DAMAGE = 0;
78EAPI int ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE = 0;
79EAPI int ECORE_X_EVENT_WINDOW_CREATE = 0;
80EAPI int ECORE_X_EVENT_WINDOW_DESTROY = 0;
81EAPI int ECORE_X_EVENT_WINDOW_HIDE = 0;
82EAPI int ECORE_X_EVENT_WINDOW_SHOW = 0;
83EAPI int ECORE_X_EVENT_WINDOW_SHOW_REQUEST = 0;
84EAPI int ECORE_X_EVENT_WINDOW_REPARENT = 0;
85EAPI int ECORE_X_EVENT_WINDOW_CONFIGURE = 0;
86EAPI int ECORE_X_EVENT_WINDOW_CONFIGURE_REQUEST = 0;
87EAPI int ECORE_X_EVENT_WINDOW_GRAVITY = 0;
88EAPI int ECORE_X_EVENT_WINDOW_RESIZE_REQUEST = 0;
89EAPI int ECORE_X_EVENT_WINDOW_STACK = 0;
90EAPI int ECORE_X_EVENT_WINDOW_STACK_REQUEST = 0;
91EAPI int ECORE_X_EVENT_WINDOW_PROPERTY = 0;
92EAPI int ECORE_X_EVENT_WINDOW_COLORMAP = 0;
93EAPI int ECORE_X_EVENT_WINDOW_MAPPING = 0;
94EAPI int ECORE_X_EVENT_MAPPING_CHANGE = 0;
95EAPI int ECORE_X_EVENT_SELECTION_CLEAR = 0;
96EAPI int ECORE_X_EVENT_SELECTION_REQUEST = 0;
97EAPI int ECORE_X_EVENT_SELECTION_NOTIFY = 0;
98EAPI int ECORE_X_EVENT_FIXES_SELECTION_NOTIFY = 0;
99EAPI int ECORE_X_EVENT_CLIENT_MESSAGE = 0;
100EAPI int ECORE_X_EVENT_WINDOW_SHAPE = 0;
101EAPI int ECORE_X_EVENT_SCREENSAVER_NOTIFY = 0;
102EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_FLICK;
103EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_PAN;
104EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION;
105EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_TAP;
106EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD;
107EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_HOLD;
108EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_GROUP;
109EAPI int ECORE_X_EVENT_SYNC_COUNTER = 0;
110EAPI int ECORE_X_EVENT_SYNC_ALARM = 0;
111EAPI int ECORE_X_EVENT_SCREEN_CHANGE = 0;
112EAPI int ECORE_X_EVENT_DAMAGE_NOTIFY = 0;
113EAPI int ECORE_X_EVENT_RANDR_CRTC_CHANGE = 0;
114EAPI int ECORE_X_EVENT_RANDR_OUTPUT_CHANGE = 0;
115EAPI int ECORE_X_EVENT_RANDR_OUTPUT_PROPERTY_NOTIFY = 0;
116EAPI int ECORE_X_EVENT_WINDOW_DELETE_REQUEST = 0;
117EAPI int ECORE_X_EVENT_WINDOW_MOVE_RESIZE_REQUEST = 0;
118EAPI int ECORE_X_EVENT_WINDOW_STATE_REQUEST = 0;
119EAPI int ECORE_X_EVENT_FRAME_EXTENTS_REQUEST = 0;
120EAPI int ECORE_X_EVENT_PING = 0;
121EAPI int ECORE_X_EVENT_DESKTOP_CHANGE = 0;
122
123EAPI int ECORE_X_EVENT_STARTUP_SEQUENCE_NEW = 0;
124EAPI int ECORE_X_EVENT_STARTUP_SEQUENCE_CHANGE = 0;
125EAPI int ECORE_X_EVENT_STARTUP_SEQUENCE_REMOVE = 0;
126
127EAPI int ECORE_X_EVENT_GENERIC = 0;
128
129int ECORE_X_MODIFIER_SHIFT = 0;
130int ECORE_X_MODIFIER_CTRL = 0;
131int ECORE_X_MODIFIER_ALT = 0;
132int ECORE_X_MODIFIER_WIN = 0;
133
134EAPI int ECORE_X_LOCK_SCROLL = 0;
135EAPI int ECORE_X_LOCK_NUM = 0;
136EAPI int ECORE_X_LOCK_CAPS = 0;
137EAPI int ECORE_X_LOCK_SHIFT = 0;
138
139#ifdef LOGRT
140static double t0 = 0.0;
141static Status (*_logrt_real_reply)(Display *disp,
142 void *rep,
143 int extra,
144 Bool discard) = NULL;
145static void
146_logrt_init(void)
147{
148 void *lib;
149
150 lib = dlopen("libX11.so", RTLD_GLOBAL | RTLD_LAZY);
151 if (!lib)
152 lib = dlopen("libX11.so.6", RTLD_GLOBAL | RTLD_LAZY);
153
154 if (!lib)
155 lib = dlopen("libX11.so.6.3", RTLD_GLOBAL | RTLD_LAZY);
156
157 if (!lib)
158 lib = dlopen("libX11.so.6.3.0", RTLD_GLOBAL | RTLD_LAZY);
159
160 _logrt_real_reply = dlsym(lib, "_XReply");
161 t0 = ecore_time_get();
162} /* _logrt_init */
163
164Status
165_XReply(Display *disp,
166 void *rep,
167 int extra,
168 Bool discard)
169{
170 void *bt[128];
171 int i, n;
172 char **sym;
173
174 n = backtrace(bt, 128);
175 if (n > 0)
176 {
177 sym = backtrace_symbols(bt, n);
178 printf("ROUNDTRIP: %4.4f :", ecore_time_get() - t0);
179 if (sym)
180 {
181 for (i = n - 1; i > 0; i--)
182 {
183 char *fname = strchr(sym[i], '(');
184 if (fname)
185 {
186 char *tsym = alloca(strlen(fname) + 1);
187 char *end;
188 strcpy(tsym, fname + 1);
189 end = strchr(tsym, '+');
190 if (end)
191 {
192 *end = 0;
193 printf("%s", tsym);
194 }
195 else
196 printf("???");
197 }
198 else
199 printf("???");
200
201 if (i > 1)
202 printf(" > ");
203 }
204 printf("\n");
205 }
206 }
207
208 // fixme: logme
209 return _logrt_real_reply(disp, rep, extra, discard);
210} /* _XReply */
211
212#endif /* ifdef LOGRT */
213
214void
215_ecore_x_modifiers_get(void)
216{
217 /* everything has these... unless its like a pda... :) */
218 ECORE_X_MODIFIER_SHIFT = _ecore_x_key_mask_get(XK_Shift_L);
219 ECORE_X_MODIFIER_CTRL = _ecore_x_key_mask_get(XK_Control_L);
220
221 /* apple's xdarwin has no alt!!!! */
222 ECORE_X_MODIFIER_ALT = _ecore_x_key_mask_get(XK_Alt_L);
223 if (!ECORE_X_MODIFIER_ALT)
224 ECORE_X_MODIFIER_ALT = _ecore_x_key_mask_get(XK_Meta_L);
225
226 if (!ECORE_X_MODIFIER_ALT)
227 ECORE_X_MODIFIER_ALT = _ecore_x_key_mask_get(XK_Super_L);
228
229 /* the windows key... a valid modifier :) */
230 ECORE_X_MODIFIER_WIN = _ecore_x_key_mask_get(XK_Super_L);
231 if (!ECORE_X_MODIFIER_WIN)
232 ECORE_X_MODIFIER_WIN = _ecore_x_key_mask_get(XK_Mode_switch);
233
234 if (!ECORE_X_MODIFIER_WIN)
235 ECORE_X_MODIFIER_WIN = _ecore_x_key_mask_get(XK_Meta_L);
236
237 if (ECORE_X_MODIFIER_WIN == ECORE_X_MODIFIER_ALT)
238 ECORE_X_MODIFIER_WIN = 0;
239
240 if (ECORE_X_MODIFIER_ALT == ECORE_X_MODIFIER_CTRL)
241 ECORE_X_MODIFIER_ALT = 0;
242
243 ECORE_X_LOCK_SCROLL = _ecore_x_key_mask_get(XK_Scroll_Lock);
244 ECORE_X_LOCK_NUM = _ecore_x_key_mask_get(XK_Num_Lock);
245 ECORE_X_LOCK_CAPS = _ecore_x_key_mask_get(XK_Caps_Lock);
246 ECORE_X_LOCK_SHIFT = _ecore_x_key_mask_get(XK_Shift_Lock);
247}
248
249/**
250 * @defgroup Ecore_X_Init_Group X Library Init and Shutdown Functions
251 *
252 * Functions that start and shut down the Ecore X Library.
253 */
254
255/**
256 * Initialize the X display connection to the given display.
257 *
258 * @param name Display target name. If @c NULL, the default display is
259 * assumed.
260 * @return The number of times the library has been initialized without
261 * being shut down. 0 is returned if an error occurs.
262 * @ingroup Ecore_X_Init_Group
263 */
264EAPI int
265ecore_x_init(const char *name)
266{
267 int shape_base = 0;
268 int shape_err_base = 0;
269#ifdef ECORE_XSS
270 int screensaver_base = 0;
271 int screensaver_err_base = 0;
272#endif /* ifdef ECORE_XSS */
273 int sync_base = 0;
274 int sync_err_base = 0;
275#ifdef ECORE_XRANDR
276 int randr_base = 0;
277 int randr_err_base = 0;
278#endif /* ifdef ECORE_XRANDR */
279#ifdef ECORE_XFIXES
280 int fixes_base = 0;
281 int fixes_err_base = 0;
282#endif /* ifdef ECORE_XFIXES */
283#ifdef ECORE_XDAMAGE
284 int damage_base = 0;
285 int damage_err_base = 0;
286#endif /* ifdef ECORE_XDAMAGE */
287#ifdef ECORE_XGESTURE
288 int gesture_base = 0;
289 int gesture_err_base = 0;
290#endif /* ifdef ECORE_XGESTURE */
291
292 if (++_ecore_x_init_count != 1)
293 return _ecore_x_init_count;
294
295 LOGFN(__FILE__, __LINE__, __FUNCTION__);
296#ifdef LOGRT
297 _logrt_init();
298#endif /* ifdef LOGRT */
299
300 eina_init();
301 _ecore_xlib_log_dom = eina_log_domain_register
302 ("ecore_x", ECORE_XLIB_DEFAULT_LOG_COLOR);
303 if(_ecore_xlib_log_dom < 0)
304 {
305 EINA_LOG_ERR(
306 "Impossible to create a log domain for the Ecore Xlib module.");
307 return --_ecore_x_init_count;
308 }
309
310 if (!ecore_init())
311 goto shutdown_eina;
312 if (!ecore_event_init())
313 goto shutdown_ecore;
314
315#ifdef EVAS_FRAME_QUEUING
316 XInitThreads();
317#endif /* ifdef EVAS_FRAME_QUEUING */
318 _ecore_x_disp = XOpenDisplay((char *)name);
319 if (!_ecore_x_disp)
320 goto shutdown_ecore_event;
321
322 _ecore_x_error_handler_init();
323 _ecore_x_event_handlers_num = LASTEvent;
324
325#define ECORE_X_EVENT_HANDLERS_GROW(ext_base, ext_num_events) \
326 do { \
327 if (_ecore_x_event_handlers_num < (ext_base + ext_num_events)) { \
328 _ecore_x_event_handlers_num = (ext_base + ext_num_events); } \
329 } while (0)
330
331 if (XShapeQueryExtension(_ecore_x_disp, &shape_base, &shape_err_base))
332 _ecore_x_event_shape_id = shape_base;
333
334 ECORE_X_EVENT_HANDLERS_GROW(shape_base, ShapeNumberEvents);
335
336#ifdef ECORE_XSS
337 if (XScreenSaverQueryExtension(_ecore_x_disp, &screensaver_base,
338 &screensaver_err_base))
339 _ecore_x_event_screensaver_id = screensaver_base;
340
341 ECORE_X_EVENT_HANDLERS_GROW(screensaver_base, ScreenSaverNumberEvents);
342#endif /* ifdef ECORE_XSS */
343
344 if (XSyncQueryExtension(_ecore_x_disp, &sync_base, &sync_err_base))
345 {
346 int major, minor;
347
348 _ecore_x_event_sync_id = sync_base;
349 if (!XSyncInitialize(_ecore_x_disp, &major, &minor))
350 _ecore_x_event_sync_id = 0;
351 }
352
353 ECORE_X_EVENT_HANDLERS_GROW(sync_base, XSyncNumberEvents);
354
355#ifdef ECORE_XRANDR
356 if (XRRQueryExtension(_ecore_x_disp, &randr_base, &randr_err_base))
357 _ecore_x_event_randr_id = randr_base;
358
359 ECORE_X_EVENT_HANDLERS_GROW(randr_base, RRNumberEvents);
360#endif /* ifdef ECORE_XRANDR */
361
362#ifdef ECORE_XFIXES
363 if (XFixesQueryExtension(_ecore_x_disp, &fixes_base, &fixes_err_base))
364 _ecore_x_event_fixes_selection_id = fixes_base;
365
366 ECORE_X_EVENT_HANDLERS_GROW(fixes_base, XFixesNumberEvents);
367#endif /* ifdef ECORE_XFIXES */
368
369#ifdef ECORE_XDAMAGE
370 if (XDamageQueryExtension(_ecore_x_disp, &damage_base, &damage_err_base))
371 _ecore_x_event_damage_id = damage_base;
372
373 ECORE_X_EVENT_HANDLERS_GROW(damage_base, XDamageNumberEvents);
374#endif /* ifdef ECORE_XDAMAGE */
375
376#ifdef ECORE_XGESTURE
377 if (XGestureQueryExtension(_ecore_x_disp, &gesture_base, &gesture_err_base))
378 _ecore_x_event_gesture_id = gesture_base;
379
380 ECORE_X_EVENT_HANDLERS_GROW(gesture_base, GestureNumberEvents);
381#endif /* ifdef ECORE_XGESTURE */
382
383 _ecore_x_event_handlers = calloc(_ecore_x_event_handlers_num, sizeof(void *));
384 if (!_ecore_x_event_handlers)
385 goto close_display;
386
387#ifdef ECORE_XCURSOR
388 _ecore_x_xcursor = XcursorSupportsARGB(_ecore_x_disp) ? EINA_TRUE : EINA_FALSE;
389#endif /* ifdef ECORE_XCURSOR */
390 _ecore_x_event_handlers[AnyXEvent] = _ecore_x_event_handle_any_event;
391 _ecore_x_event_handlers[KeyPress] = _ecore_x_event_handle_key_press;
392 _ecore_x_event_handlers[KeyRelease] = _ecore_x_event_handle_key_release;
393 _ecore_x_event_handlers[ButtonPress] = _ecore_x_event_handle_button_press;
394 _ecore_x_event_handlers[ButtonRelease] =
395 _ecore_x_event_handle_button_release;
396 _ecore_x_event_handlers[MotionNotify] = _ecore_x_event_handle_motion_notify;
397 _ecore_x_event_handlers[EnterNotify] = _ecore_x_event_handle_enter_notify;
398 _ecore_x_event_handlers[LeaveNotify] = _ecore_x_event_handle_leave_notify;
399 _ecore_x_event_handlers[FocusIn] = _ecore_x_event_handle_focus_in;
400 _ecore_x_event_handlers[FocusOut] = _ecore_x_event_handle_focus_out;
401 _ecore_x_event_handlers[KeymapNotify] = _ecore_x_event_handle_keymap_notify;
402 _ecore_x_event_handlers[Expose] = _ecore_x_event_handle_expose;
403 _ecore_x_event_handlers[GraphicsExpose] =
404 _ecore_x_event_handle_graphics_expose;
405 _ecore_x_event_handlers[VisibilityNotify] =
406 _ecore_x_event_handle_visibility_notify;
407 _ecore_x_event_handlers[CreateNotify] = _ecore_x_event_handle_create_notify;
408 _ecore_x_event_handlers[DestroyNotify] =
409 _ecore_x_event_handle_destroy_notify;
410 _ecore_x_event_handlers[UnmapNotify] = _ecore_x_event_handle_unmap_notify;
411 _ecore_x_event_handlers[MapNotify] = _ecore_x_event_handle_map_notify;
412 _ecore_x_event_handlers[MapRequest] = _ecore_x_event_handle_map_request;
413 _ecore_x_event_handlers[ReparentNotify] =
414 _ecore_x_event_handle_reparent_notify;
415 _ecore_x_event_handlers[ConfigureNotify] =
416 _ecore_x_event_handle_configure_notify;
417 _ecore_x_event_handlers[ConfigureRequest] =
418 _ecore_x_event_handle_configure_request;
419 _ecore_x_event_handlers[GravityNotify] =
420 _ecore_x_event_handle_gravity_notify;
421 _ecore_x_event_handlers[ResizeRequest] =
422 _ecore_x_event_handle_resize_request;
423 _ecore_x_event_handlers[CirculateNotify] =
424 _ecore_x_event_handle_circulate_notify;
425 _ecore_x_event_handlers[CirculateRequest] =
426 _ecore_x_event_handle_circulate_request;
427 _ecore_x_event_handlers[PropertyNotify] =
428 _ecore_x_event_handle_property_notify;
429 _ecore_x_event_handlers[SelectionClear] =
430 _ecore_x_event_handle_selection_clear;
431 _ecore_x_event_handlers[SelectionRequest] =
432 _ecore_x_event_handle_selection_request;
433 _ecore_x_event_handlers[SelectionNotify] =
434 _ecore_x_event_handle_selection_notify;
435 _ecore_x_event_handlers[ColormapNotify] =
436 _ecore_x_event_handle_colormap_notify;
437 _ecore_x_event_handlers[ClientMessage] =
438 _ecore_x_event_handle_client_message;
439 _ecore_x_event_handlers[MappingNotify] =
440 _ecore_x_event_handle_mapping_notify;
441#ifdef GenericEvent
442 _ecore_x_event_handlers[GenericEvent] = _ecore_x_event_handle_generic_event;
443#endif /* ifdef GenericEvent */
444
445 if (_ecore_x_event_shape_id)
446 _ecore_x_event_handlers[_ecore_x_event_shape_id] =
447 _ecore_x_event_handle_shape_change;
448
449 if (_ecore_x_event_screensaver_id)
450 _ecore_x_event_handlers[_ecore_x_event_screensaver_id] =
451 _ecore_x_event_handle_screensaver_notify;
452
453 if (_ecore_x_event_sync_id)
454 {
455 _ecore_x_event_handlers[_ecore_x_event_sync_id + XSyncCounterNotify] =
456 _ecore_x_event_handle_sync_counter;
457 _ecore_x_event_handlers[_ecore_x_event_sync_id + XSyncAlarmNotify] =
458 _ecore_x_event_handle_sync_alarm;
459 }
460
461#ifdef ECORE_XRANDR
462 if (_ecore_x_event_randr_id)
463 {
464 _ecore_x_event_handlers[_ecore_x_event_randr_id +
465 RRScreenChangeNotify] =
466 _ecore_x_event_handle_randr_change;
467 _ecore_x_event_handlers[_ecore_x_event_randr_id +
468 RRNotify] = _ecore_x_event_handle_randr_notify;
469 }
470
471#endif /* ifdef ECORE_XRANDR */
472#ifdef ECORE_XFIXES
473 if (_ecore_x_event_fixes_selection_id)
474 _ecore_x_event_handlers[_ecore_x_event_fixes_selection_id] =
475 _ecore_x_event_handle_fixes_selection_notify;
476
477#endif /* ifdef ECORE_XFIXES */
478#ifdef ECORE_XDAMAGE
479 if (_ecore_x_event_damage_id)
480 _ecore_x_event_handlers[_ecore_x_event_damage_id] =
481 _ecore_x_event_handle_damage_notify;
482
483#endif /* ifdef ECORE_XDAMAGE */
484#ifdef ECORE_XKB
485 // set x autorepeat detection to on. that means instead of
486 // press-release-press-release-press-release
487 // you get
488 // press-press-press-press-press-release
489 do
490 {
491 Bool works = 0;
492 XkbSetDetectableAutoRepeat(_ecore_x_disp, 1, &works);
493 }
494 while (0);
495#endif /* ifdef ECORE_XKB */
496
497#ifdef ECORE_XGESTURE
498 if (_ecore_x_event_gesture_id)
499 {
500 _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyFlick] =
501 _ecore_x_event_handle_gesture_notify_flick;
502 _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyPan] =
503 _ecore_x_event_handle_gesture_notify_pan;
504 _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyPinchRotation] =
505 _ecore_x_event_handle_gesture_notify_pinchrotation;
506 _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyTap] =
507 _ecore_x_event_handle_gesture_notify_tap;
508 _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyTapNHold] =
509 _ecore_x_event_handle_gesture_notify_tapnhold;
510 _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyHold] =
511 _ecore_x_event_handle_gesture_notify_hold;
512 _ecore_x_event_handlers[_ecore_x_event_gesture_id + GestureNotifyGroup] =
513 _ecore_x_event_handle_gesture_notify_group;
514 }
515
516#endif /* ifdef ECORE_XGESTURE */
517
518 if (!ECORE_X_EVENT_ANY)
519 {
520 ECORE_X_EVENT_ANY = ecore_event_type_new();
521 ECORE_X_EVENT_MOUSE_IN = ecore_event_type_new();
522 ECORE_X_EVENT_MOUSE_OUT = ecore_event_type_new();
523 ECORE_X_EVENT_WINDOW_FOCUS_IN = ecore_event_type_new();
524 ECORE_X_EVENT_WINDOW_FOCUS_OUT = ecore_event_type_new();
525 ECORE_X_EVENT_WINDOW_KEYMAP = ecore_event_type_new();
526 ECORE_X_EVENT_WINDOW_DAMAGE = ecore_event_type_new();
527 ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE = ecore_event_type_new();
528 ECORE_X_EVENT_WINDOW_CREATE = ecore_event_type_new();
529 ECORE_X_EVENT_WINDOW_DESTROY = ecore_event_type_new();
530 ECORE_X_EVENT_WINDOW_HIDE = ecore_event_type_new();
531 ECORE_X_EVENT_WINDOW_SHOW = ecore_event_type_new();
532 ECORE_X_EVENT_WINDOW_SHOW_REQUEST = ecore_event_type_new();
533 ECORE_X_EVENT_WINDOW_REPARENT = ecore_event_type_new();
534 ECORE_X_EVENT_WINDOW_CONFIGURE = ecore_event_type_new();
535 ECORE_X_EVENT_WINDOW_CONFIGURE_REQUEST = ecore_event_type_new();
536 ECORE_X_EVENT_WINDOW_GRAVITY = ecore_event_type_new();
537 ECORE_X_EVENT_WINDOW_RESIZE_REQUEST = ecore_event_type_new();
538 ECORE_X_EVENT_WINDOW_STACK = ecore_event_type_new();
539 ECORE_X_EVENT_WINDOW_STACK_REQUEST = ecore_event_type_new();
540 ECORE_X_EVENT_WINDOW_PROPERTY = ecore_event_type_new();
541 ECORE_X_EVENT_WINDOW_COLORMAP = ecore_event_type_new();
542 ECORE_X_EVENT_WINDOW_MAPPING = ecore_event_type_new();
543 ECORE_X_EVENT_MAPPING_CHANGE = ecore_event_type_new();
544 ECORE_X_EVENT_SELECTION_CLEAR = ecore_event_type_new();
545 ECORE_X_EVENT_SELECTION_REQUEST = ecore_event_type_new();
546 ECORE_X_EVENT_SELECTION_NOTIFY = ecore_event_type_new();
547 ECORE_X_EVENT_CLIENT_MESSAGE = ecore_event_type_new();
548 ECORE_X_EVENT_WINDOW_SHAPE = ecore_event_type_new();
549 ECORE_X_EVENT_SCREENSAVER_NOTIFY = ecore_event_type_new();
550 ECORE_X_EVENT_GESTURE_NOTIFY_FLICK = ecore_event_type_new();
551 ECORE_X_EVENT_GESTURE_NOTIFY_PAN = ecore_event_type_new();
552 ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION = ecore_event_type_new();
553 ECORE_X_EVENT_GESTURE_NOTIFY_TAP = ecore_event_type_new();
554 ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD = ecore_event_type_new();
555 ECORE_X_EVENT_GESTURE_NOTIFY_HOLD = ecore_event_type_new();
556 ECORE_X_EVENT_GESTURE_NOTIFY_GROUP = ecore_event_type_new();
557 ECORE_X_EVENT_SYNC_COUNTER = ecore_event_type_new();
558 ECORE_X_EVENT_SYNC_ALARM = ecore_event_type_new();
559 ECORE_X_EVENT_SCREEN_CHANGE = ecore_event_type_new();
560 ECORE_X_EVENT_RANDR_CRTC_CHANGE = ecore_event_type_new();
561 ECORE_X_EVENT_RANDR_OUTPUT_CHANGE = ecore_event_type_new();
562 ECORE_X_EVENT_RANDR_OUTPUT_PROPERTY_NOTIFY = ecore_event_type_new();
563 ECORE_X_EVENT_DAMAGE_NOTIFY = ecore_event_type_new();
564
565 ECORE_X_EVENT_WINDOW_DELETE_REQUEST = ecore_event_type_new();
566
567 ECORE_X_EVENT_DESKTOP_CHANGE = ecore_event_type_new();
568 ECORE_X_EVENT_WINDOW_MOVE_RESIZE_REQUEST = ecore_event_type_new();
569 ECORE_X_EVENT_WINDOW_STATE_REQUEST = ecore_event_type_new();
570 ECORE_X_EVENT_FRAME_EXTENTS_REQUEST = ecore_event_type_new();
571 ECORE_X_EVENT_PING = ecore_event_type_new();
572
573 ECORE_X_EVENT_STARTUP_SEQUENCE_NEW = ecore_event_type_new();
574 ECORE_X_EVENT_STARTUP_SEQUENCE_CHANGE = ecore_event_type_new();
575 ECORE_X_EVENT_STARTUP_SEQUENCE_REMOVE = ecore_event_type_new();
576
577 ECORE_X_EVENT_GENERIC = ecore_event_type_new();
578 }
579
580 _ecore_x_modifiers_get();
581
582 _ecore_x_fd_handler_handle =
583 ecore_main_fd_handler_add(ConnectionNumber(_ecore_x_disp),
584 ECORE_FD_READ,
585 _ecore_x_fd_handler, _ecore_x_disp,
586 _ecore_x_fd_handler_buf, _ecore_x_disp);
587 if (!_ecore_x_fd_handler_handle)
588 goto free_event_handlers;
589
590 _ecore_x_atoms_init();
591
592 /* Set up the ICCCM hints */
593 ecore_x_icccm_init();
594
595 /* Set up the _NET_... hints */
596 ecore_x_netwm_init();
597
598 /* old e hints init */
599 ecore_x_e_init();
600
601 /* This is just to be anal about naming conventions */
602
603 _ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_DELETE_REQUEST] =
604 ECORE_X_ATOM_WM_DELETE_WINDOW;
605 _ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_TAKE_FOCUS] =
606 ECORE_X_ATOM_WM_TAKE_FOCUS;
607 _ecore_x_atoms_wm_protocols[ECORE_X_NET_WM_PROTOCOL_PING] =
608 ECORE_X_ATOM_NET_WM_PING;
609 _ecore_x_atoms_wm_protocols[ECORE_X_NET_WM_PROTOCOL_SYNC_REQUEST] =
610 ECORE_X_ATOM_NET_WM_SYNC_REQUEST;
611
612 _ecore_x_selection_data_init();
613 _ecore_x_dnd_init();
614 _ecore_x_fixes_init();
615 _ecore_x_damage_init();
616 _ecore_x_composite_init();
617 _ecore_x_dpms_init();
618 _ecore_x_randr_init();
619 _ecore_x_gesture_init();
620 _ecore_x_input_init();
621 _ecore_x_events_init();
622
623 _ecore_x_private_win = ecore_x_window_override_new(0, -77, -777, 123, 456);
624
625 return _ecore_x_init_count;
626
627free_event_handlers:
628 free(_ecore_x_event_handlers);
629 _ecore_x_event_handlers = NULL;
630close_display:
631 XCloseDisplay(_ecore_x_disp);
632 _ecore_x_fd_handler_handle = NULL;
633 _ecore_x_disp = NULL;
634shutdown_ecore_event:
635 ecore_event_shutdown();
636shutdown_ecore:
637 ecore_shutdown();
638shutdown_eina:
639 eina_log_domain_unregister(_ecore_xlib_log_dom);
640 _ecore_xlib_log_dom = -1;
641 eina_shutdown();
642
643 return --_ecore_x_init_count;
644} /* ecore_x_init */
645
646static int
647_ecore_x_shutdown(int close_display)
648{
649 if (--_ecore_x_init_count != 0)
650 return _ecore_x_init_count;
651
652 if (!_ecore_x_disp)
653 return _ecore_x_init_count;
654
655 LOGFN(__FILE__, __LINE__, __FUNCTION__);
656
657 ecore_main_fd_handler_del(_ecore_x_fd_handler_handle);
658 if (close_display)
659 XCloseDisplay(_ecore_x_disp);
660 else
661 {
662 close(ConnectionNumber(_ecore_x_disp));
663 // FIXME: may have to clean up x display internal here
664// getting segv here? hmmm. odd. disable
665// XFree(_ecore_x_disp);
666 }
667
668 free(_ecore_x_event_handlers);
669 _ecore_x_fd_handler_handle = NULL;
670 _ecore_x_disp = NULL;
671 _ecore_x_event_handlers = NULL;
672 _ecore_x_events_shutdown();
673 _ecore_x_input_shutdown();
674 _ecore_x_selection_shutdown();
675 _ecore_x_dnd_shutdown();
676 ecore_x_netwm_shutdown();
677
678 ecore_event_shutdown();
679 ecore_shutdown();
680
681 eina_log_domain_unregister(_ecore_xlib_log_dom);
682 _ecore_xlib_log_dom = -1;
683 eina_shutdown();
684
685 return _ecore_x_init_count;
686} /* _ecore_x_shutdown */
687
688/**
689 * Shuts down the Ecore X library.
690 *
691 * In shutting down the library, the X display connection is terminated
692 * and any event handlers for it are removed.
693 *
694 * @return The number of times the library has been initialized without
695 * being shut down.
696 * @ingroup Ecore_X_Init_Group
697 */
698EAPI int
699ecore_x_shutdown(void)
700{
701 return _ecore_x_shutdown(1);
702} /* ecore_x_shutdown */
703
704/**
705 * Shuts down the Ecore X library.
706 *
707 * As ecore_x_shutdown, except do not close Display, only connection.
708 *
709 * @ingroup Ecore_X_Init_Group
710 */
711EAPI int
712ecore_x_disconnect(void)
713{
714 return _ecore_x_shutdown(0);
715} /* ecore_x_disconnect */
716
717/**
718 * @defgroup Ecore_X_Display_Attr_Group X Display Attributes
719 *
720 * Functions that set and retrieve X display attributes.
721 */
722
723/**
724 * Retrieves the Ecore_X_Display handle used for the current X connection.
725 * @return The current X display.
726 * @ingroup Ecore_X_Display_Attr_Group
727 */
728EAPI Ecore_X_Display *
729ecore_x_display_get(void)
730{
731 return (Ecore_X_Display *)_ecore_x_disp;
732} /* ecore_x_display_get */
733
734/**
735 * Retrieves the X display file descriptor.
736 * @return The current X display file descriptor.
737 * @ingroup Ecore_X_Display_Attr_Group
738 */
739EAPI int
740ecore_x_fd_get(void)
741{
742 LOGFN(__FILE__, __LINE__, __FUNCTION__);
743 return ConnectionNumber(_ecore_x_disp);
744} /* ecore_x_fd_get */
745
746/**
747 * Retrieves the Ecore_X_Screen handle used for the current X connection.
748 * @return The current default screen.
749 * @ingroup Ecore_X_Display_Attr_Group
750 */
751EAPI Ecore_X_Screen *
752ecore_x_default_screen_get(void)
753{
754 LOGFN(__FILE__, __LINE__, __FUNCTION__);
755 return (Ecore_X_Screen *)DefaultScreenOfDisplay(_ecore_x_disp);
756} /* ecore_x_default_screen_get */
757
758/**
759 * Retrieves the size of an Ecore_X_Screen.
760 * @param screen the handle to the screen to query.
761 * @param w where to return the width. May be NULL. Returns 0 on errors.
762 * @param h where to return the height. May be NULL. Returns 0 on errors.
763 * @ingroup Ecore_X_Display_Attr_Group
764 * @see ecore_x_default_screen_get()
765 *
766 * @since 1.1
767 */
768EAPI void
769ecore_x_screen_size_get(const Ecore_X_Screen *screen,
770 int *w,
771 int *h)
772{
773 Screen *s = (Screen *)screen;
774 LOGFN(__FILE__, __LINE__, __FUNCTION__);
775 if (w) *w = 0;
776 if (h) *h = 0;
777 if (!s) return;
778 if (w) *w = s->width;
779 if (h) *h = s->height;
780}
781
782/**
783 * Retrieves the number of screens.
784 *
785 * @return The count of the number of screens.
786 * @ingroup Ecore_X_Display_Attr_Group
787 *
788 * @since 1.1
789 */
790EAPI int
791ecore_x_screen_count_get(void)
792{
793 LOGFN(__FILE__, __LINE__, __FUNCTION__);
794
795 return ScreenCount(_ecore_x_disp);
796}
797
798/**
799 * Retrieves the index number of the given screen.
800 *
801 * @return The index number of the screen.
802 * @ingroup Ecore_X_Display_Attr_Group
803 *
804 * @since 1.1
805 */
806EAPI int
807ecore_x_screen_index_get(const Ecore_X_Screen *screen)
808{
809 return XScreenNumberOfScreen((Screen *)screen);
810}
811
812/**
813 * Retrieves the screen based on index number.
814 *
815 * @return The Ecore_X_Screen at this index.
816 * @ingroup Ecore_X_Display_Attr_Group
817 *
818 * @since 1.1
819 */
820EAPI Ecore_X_Screen *
821ecore_x_screen_get(int idx)
822{
823 return XScreenOfDisplay(_ecore_x_disp, idx);
824}
825
826/**
827 * Sets the timeout for a double and triple clicks to be flagged.
828 *
829 * This sets the time between clicks before the double_click flag is
830 * set in a button down event. If 3 clicks occur within double this
831 * time, the triple_click flag is also set.
832 *
833 * @param t The time in seconds
834 * @ingroup Ecore_X_Display_Attr_Group
835 */
836EAPI void
837ecore_x_double_click_time_set(double t)
838{
839 if (t < 0.0)
840 t = 0.0;
841
842 _ecore_x_double_click_time = t;
843} /* ecore_x_double_click_time_set */
844
845/**
846 * Retrieves the double and triple click flag timeout.
847 *
848 * See @ref ecore_x_double_click_time_set for more information.
849 *
850 * @return The timeout for double clicks in seconds.
851 * @ingroup Ecore_X_Display_Attr_Group
852 */
853EAPI double
854ecore_x_double_click_time_get(void)
855{
856 return _ecore_x_double_click_time;
857} /* ecore_x_double_click_time_get */
858
859/**
860 * @defgroup Ecore_X_Flush_Group X Synchronization Functions
861 *
862 * Functions that ensure that all commands that have been issued by the
863 * Ecore X library have been sent to the server.
864 */
865
866/**
867 * Sends all X commands in the X Display buffer.
868 * @ingroup Ecore_X_Flush_Group
869 */
870EAPI void
871ecore_x_flush(void)
872{
873 LOGFN(__FILE__, __LINE__, __FUNCTION__);
874 XFlush(_ecore_x_disp);
875} /* ecore_x_flush */
876
877/**
878 * Flushes the command buffer and waits until all requests have been
879 * processed by the server.
880 * @ingroup Ecore_X_Flush_Group
881 */
882EAPI void
883ecore_x_sync(void)
884{
885 LOGFN(__FILE__, __LINE__, __FUNCTION__);
886 XSync(_ecore_x_disp, False);
887} /* ecore_x_sync */
888
889/**
890 * Kill all clients with subwindows under a given window.
891 *
892 * You can kill all clients connected to the X server by using
893 * @ref ecore_x_window_root_list to get a list of root windows, and
894 * then passing each root window to this function.
895 *
896 * @param root The window whose children will be killed.
897 */
898EAPI void
899ecore_x_killall(Ecore_X_Window root)
900{
901 unsigned int j;
902 Window root_r;
903 Window parent_r;
904 Window *children_r = NULL;
905 unsigned int num_children = 0;
906
907 LOGFN(__FILE__, __LINE__, __FUNCTION__);
908 XGrabServer(_ecore_x_disp);
909 /* Tranverse window tree starting from root, and drag each
910 * before the firing squad */
911 while (XQueryTree(_ecore_x_disp, root, &root_r, &parent_r,
912 &children_r, &num_children) && (num_children > 0))
913 {
914 for (j = 0; j < num_children; ++j)
915 {
916 XKillClient(_ecore_x_disp, children_r[j]);
917 }
918
919 XFree(children_r);
920 }
921 XUngrabServer(_ecore_x_disp);
922 XSync(_ecore_x_disp, False);
923} /* ecore_x_killall */
924
925/**
926 * Kill a specific client
927 *
928 * You can kill a specific client owning window @p win
929 *
930 * @param win Window of the client to be killed
931 */
932EAPI void
933ecore_x_kill(Ecore_X_Window win)
934{
935 LOGFN(__FILE__, __LINE__, __FUNCTION__);
936 XKillClient(_ecore_x_disp, win);
937} /* ecore_x_kill */
938
939/**
940 * Return the last event time
941 */
942EAPI Ecore_X_Time
943ecore_x_current_time_get(void)
944{
945 return _ecore_x_event_last_time;
946} /* ecore_x_current_time_get */
947
948/**
949 * Return the screen DPI
950 *
951 * This is a simplistic call to get DPI. It does not account for differing
952 * DPI in the x amd y axes nor does it accoutn for multihead or xinerama and
953 * xrander where different parts of the screen may have differen DPI etc.
954 *
955 * @return the general screen DPI (dots/pixels per inch).
956 */
957EAPI int
958ecore_x_dpi_get(void)
959{
960 Screen *s;
961
962 LOGFN(__FILE__, __LINE__, __FUNCTION__);
963 s = DefaultScreenOfDisplay(_ecore_x_disp);
964 if (s->mwidth <= 0)
965 return 75;
966
967 return (((s->width * 254) / s->mwidth) + 5) / 10;
968} /* ecore_x_dpi_get */
969
970/**
971 * Invoke the standard system beep to alert users
972 *
973 * @param percent The volume at which the bell rings. Must be in the range
974 * [-100,+100]. If percent >= 0, the final volume will be:
975 * base - [(base * percent) / 100] + percent
976 * Otherwise, it's calculated as:
977 * base + [(base * percent) / 100]
978 * where @c base is the bell's base volume as set by XChangeKeyboardControl(3).
979 *
980 * @returns EINA_TRUE on success, EINA_FALSE otherwise.
981 */
982EAPI Eina_Bool
983ecore_x_bell(int percent)
984{
985 int ret;
986
987 ret = XBell(_ecore_x_disp, percent);
988 if (ret == BadValue)
989 return EINA_FALSE;
990
991 return EINA_TRUE;
992} /* ecore_x_bell */
993
994static Eina_Bool
995_ecore_x_fd_handler(void *data,
996 Ecore_Fd_Handler *fd_handler __UNUSED__)
997{
998 Display *d;
999
1000 d = data;
1001 while (XPending(d))
1002 {
1003 XEvent ev;
1004
1005 XNextEvent(d, &ev);
1006
1007#ifdef ENABLE_XIM
1008 /* Filter event for XIM */
1009 if (XFilterEvent(&ev, ev.xkey.window))
1010 continue;
1011
1012#endif /* ifdef ENABLE_XIM */
1013
1014 if ((ev.type >= 0) && (ev.type < _ecore_x_event_handlers_num))
1015 {
1016 if (_ecore_x_event_handlers[AnyXEvent])
1017 _ecore_x_event_handlers[AnyXEvent] (&ev);
1018
1019 if (_ecore_x_event_handlers[ev.type])
1020 _ecore_x_event_handlers[ev.type] (&ev);
1021 }
1022 }
1023 return ECORE_CALLBACK_RENEW;
1024} /* _ecore_x_fd_handler */
1025
1026static Eina_Bool
1027_ecore_x_fd_handler_buf(void *data,
1028 Ecore_Fd_Handler *fd_handler __UNUSED__)
1029{
1030 Display *d;
1031
1032 d = data;
1033 if (XPending(d))
1034 return ECORE_CALLBACK_RENEW;
1035
1036 return ECORE_CALLBACK_CANCEL;
1037} /* _ecore_x_fd_handler_buf */
1038
1039static int
1040_ecore_x_key_mask_get(KeySym sym)
1041{
1042 XModifierKeymap *mod;
1043 KeySym sym2;
1044 int i, j;
1045 const int masks[8] =
1046 {
1047 ShiftMask, LockMask, ControlMask,
1048 Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask
1049 };
1050
1051 mod = XGetModifierMapping(_ecore_x_disp);
1052 if ((mod) && (mod->max_keypermod > 0))
1053 for (i = 0; i < (8 * mod->max_keypermod); i++)
1054 {
1055 for (j = 0; j < 8; j++)
1056 {
1057 sym2 = XKeycodeToKeysym(_ecore_x_disp, mod->modifiermap[i], j);
1058 if (sym2 != 0)
1059 break;
1060 }
1061 if (sym2 == sym)
1062 {
1063 int mask;
1064
1065 mask = masks[i / mod->max_keypermod];
1066 if (mod->modifiermap)
1067 XFree(mod->modifiermap);
1068
1069 XFree(mod);
1070 return mask;
1071 }
1072 }
1073
1074 if (mod)
1075 {
1076 if (mod->modifiermap)
1077 XFree(mod->modifiermap);
1078
1079 XFree(mod);
1080 }
1081
1082 return 0;
1083} /* _ecore_x_key_mask_get */
1084
1085/*****************************************************************************/
1086/*****************************************************************************/
1087/*****************************************************************************/
1088/* FIXME: these funcs need categorising */
1089/*****************************************************************************/
1090
1091/**
1092 * Get a list of all the root windows on the server.
1093 *
1094 * @note The returned array will need to be freed after use.
1095 * @param num_ret Pointer to integer to put number of windows returned in.
1096 * @return An array of all the root windows. @c NULL is returned if memory
1097 * could not be allocated for the list, or if @p num_ret is @c NULL.
1098 */
1099EAPI Ecore_X_Window *
1100ecore_x_window_root_list(int *num_ret)
1101{
1102 int num, i;
1103 Ecore_X_Window *roots;
1104#ifdef ECORE_XPRINT
1105 int xp_base, xp_err_base;
1106#endif /* ifdef ECORE_XPRINT */
1107
1108 if (!num_ret)
1109 return NULL;
1110
1111 *num_ret = 0;
1112
1113 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1114#ifdef ECORE_XPRINT
1115 num = ScreenCount(_ecore_x_disp);
1116 if (XpQueryExtension(_ecore_x_disp, &xp_base, &xp_err_base))
1117 {
1118 Screen **ps = NULL;
1119 int psnum = 0;
1120
1121 ps = XpQueryScreens(_ecore_x_disp, &psnum);
1122 if (ps)
1123 {
1124 int overlap, j;
1125
1126 overlap = 0;
1127 for (i = 0; i < num; i++)
1128 {
1129 for (j = 0; j < psnum; j++)
1130 {
1131 if (ScreenOfDisplay(_ecore_x_disp, i) == ps[j])
1132 overlap++;
1133 }
1134 }
1135 roots = malloc((num - overlap) * sizeof(Window));
1136 if (roots)
1137 {
1138 int k;
1139
1140 k = 0;
1141 for (i = 0; i < num; i++)
1142 {
1143 int is_print;
1144
1145 is_print = 0;
1146 for (j = 0; j < psnum; j++)
1147 {
1148 if (ScreenOfDisplay(_ecore_x_disp, i) == ps[j])
1149 {
1150 is_print = 1;
1151 break;
1152 }
1153 }
1154 if (!is_print)
1155 {
1156 roots[k] = RootWindow(_ecore_x_disp, i);
1157 k++;
1158 }
1159 }
1160 *num_ret = k;
1161 }
1162
1163 XFree(ps);
1164 }
1165 else
1166 {
1167 roots = malloc(num * sizeof(Window));
1168 if (!roots)
1169 return NULL;
1170
1171 *num_ret = num;
1172 for (i = 0; i < num; i++)
1173 roots[i] = RootWindow(_ecore_x_disp, i);
1174 }
1175 }
1176 else
1177 {
1178 roots = malloc(num * sizeof(Window));
1179 if (!roots)
1180 return NULL;
1181
1182 *num_ret = num;
1183 for (i = 0; i < num; i++)
1184 roots[i] = RootWindow(_ecore_x_disp, i);
1185 }
1186
1187#else /* ifdef ECORE_XPRINT */
1188 num = ScreenCount(_ecore_x_disp);
1189 roots = malloc(num * sizeof(Window));
1190 if (!roots)
1191 return NULL;
1192
1193 *num_ret = num;
1194 for (i = 0; i < num; i++)
1195 roots[i] = RootWindow(_ecore_x_disp, i);
1196#endif /* ifdef ECORE_XPRINT */
1197 return roots;
1198} /* ecore_x_window_root_list */
1199
1200EAPI Ecore_X_Window
1201ecore_x_window_root_first_get(void)
1202{
1203 return RootWindow(_ecore_x_disp, 0);
1204/*
1205 int num;
1206 Ecore_X_Window root, *roots = NULL;
1207
1208 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1209 roots = ecore_x_window_root_list(&num);
1210 if (!(roots)) return 0;
1211
1212 if (num > 0)
1213 root = roots[0];
1214 else
1215 root = 0;
1216
1217 free(roots);
1218 return root;
1219 */
1220} /* ecore_x_window_root_first_get */
1221
1222static void _ecore_x_window_manage_error(void *data);
1223
1224static int _ecore_x_window_manage_failed = 0;
1225static void
1226_ecore_x_window_manage_error(void *data __UNUSED__)
1227{
1228 if ((ecore_x_error_request_get() == X_ChangeWindowAttributes) &&
1229 (ecore_x_error_code_get() == BadAccess))
1230 _ecore_x_window_manage_failed = 1;
1231} /* _ecore_x_window_manage_error */
1232
1233EAPI Eina_Bool
1234ecore_x_window_manage(Ecore_X_Window win)
1235{
1236 XWindowAttributes att;
1237
1238 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1239 if (XGetWindowAttributes(_ecore_x_disp, win, &att) != True)
1240 return EINA_FALSE;
1241
1242 ecore_x_sync();
1243 _ecore_x_window_manage_failed = 0;
1244 ecore_x_error_handler_set(_ecore_x_window_manage_error, NULL);
1245 XSelectInput(_ecore_x_disp, win,
1246 EnterWindowMask |
1247 LeaveWindowMask |
1248 PropertyChangeMask |
1249 ResizeRedirectMask |
1250 SubstructureRedirectMask |
1251 SubstructureNotifyMask |
1252 StructureNotifyMask |
1253 KeyPressMask |
1254 KeyReleaseMask |
1255 att.your_event_mask);
1256 ecore_x_sync();
1257 ecore_x_error_handler_set(NULL, NULL);
1258 if (_ecore_x_window_manage_failed)
1259 {
1260 _ecore_x_window_manage_failed = 0;
1261 return EINA_FALSE;
1262 }
1263
1264 return EINA_TRUE;
1265} /* ecore_x_window_manage */
1266
1267EAPI void
1268ecore_x_window_container_manage(Ecore_X_Window win)
1269{
1270 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1271 XSelectInput(_ecore_x_disp, win,
1272 SubstructureRedirectMask |
1273 SubstructureNotifyMask);
1274} /* ecore_x_window_container_manage */
1275
1276EAPI void
1277ecore_x_window_client_manage(Ecore_X_Window win)
1278{
1279 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1280 XSelectInput(_ecore_x_disp, win,
1281 PropertyChangeMask |
1282// ResizeRedirectMask |
1283 FocusChangeMask |
1284 ColormapChangeMask |
1285 VisibilityChangeMask |
1286 StructureNotifyMask |
1287 SubstructureNotifyMask
1288 );
1289 XShapeSelectInput(_ecore_x_disp, win, ShapeNotifyMask);
1290} /* ecore_x_window_client_manage */
1291
1292EAPI void
1293ecore_x_window_sniff(Ecore_X_Window win)
1294{
1295 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1296 XSelectInput(_ecore_x_disp, win,
1297 PropertyChangeMask |
1298 SubstructureNotifyMask);
1299} /* ecore_x_window_sniff */
1300
1301EAPI void
1302ecore_x_window_client_sniff(Ecore_X_Window win)
1303{
1304 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1305 XSelectInput(_ecore_x_disp, win,
1306 PropertyChangeMask |
1307 FocusChangeMask |
1308 ColormapChangeMask |
1309 VisibilityChangeMask |
1310 StructureNotifyMask |
1311 SubstructureNotifyMask);
1312 XShapeSelectInput(_ecore_x_disp, win, ShapeNotifyMask);
1313} /* ecore_x_window_client_sniff */
1314
1315EAPI Eina_Bool
1316ecore_x_window_attributes_get(Ecore_X_Window win,
1317 Ecore_X_Window_Attributes *att_ret)
1318{
1319 XWindowAttributes att;
1320
1321 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1322 if (!XGetWindowAttributes(_ecore_x_disp, win, &att))
1323 return EINA_FALSE;
1324
1325 memset(att_ret, 0, sizeof(Ecore_X_Window_Attributes));
1326 att_ret->root = att.root;
1327 att_ret->x = att.x;
1328 att_ret->y = att.y;
1329 att_ret->w = att.width;
1330 att_ret->h = att.height;
1331 att_ret->border = att.border_width;
1332 att_ret->depth = att.depth;
1333 if (att.map_state != IsUnmapped)
1334 att_ret->visible = 1;
1335
1336 if (att.map_state == IsViewable)
1337 att_ret->viewable = 1;
1338
1339 if (att.override_redirect)
1340 att_ret->override = 1;
1341
1342 if (att.class == InputOnly)
1343 att_ret->input_only = 1;
1344
1345 if (att.save_under)
1346 att_ret->save_under = 1;
1347
1348 att_ret->event_mask.mine = att.your_event_mask;
1349 att_ret->event_mask.all = att.all_event_masks;
1350 att_ret->event_mask.no_propagate = att.do_not_propagate_mask;
1351 att_ret->window_gravity = att.win_gravity;
1352 att_ret->pixel_gravity = att.bit_gravity;
1353 att_ret->colormap = att.colormap;
1354 att_ret->visual = att.visual;
1355 return EINA_TRUE;
1356} /* ecore_x_window_attributes_get */
1357
1358EAPI void
1359ecore_x_window_save_set_add(Ecore_X_Window win)
1360{
1361 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1362 XAddToSaveSet(_ecore_x_disp, win);
1363} /* ecore_x_window_save_set_add */
1364
1365EAPI void
1366ecore_x_window_save_set_del(Ecore_X_Window win)
1367{
1368 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1369 XRemoveFromSaveSet(_ecore_x_disp, win);
1370} /* ecore_x_window_save_set_del */
1371
1372EAPI Ecore_X_Window *
1373ecore_x_window_children_get(Ecore_X_Window win,
1374 int *num)
1375{
1376 Ecore_X_Window *windows = NULL;
1377 Window root_ret = 0, parent_ret = 0, *children_ret = NULL;
1378 unsigned int children_ret_num = 0;
1379
1380 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1381 if (!XQueryTree(_ecore_x_disp, win, &root_ret, &parent_ret, &children_ret,
1382 &children_ret_num))
1383 return NULL;
1384
1385 if (children_ret)
1386 {
1387 windows = malloc(children_ret_num * sizeof(Ecore_X_Window));
1388 if (windows)
1389 {
1390 unsigned int i;
1391
1392 for (i = 0; i < children_ret_num; i++)
1393 windows[i] = children_ret[i];
1394 *num = children_ret_num;
1395 }
1396
1397 XFree(children_ret);
1398 }
1399
1400 return windows;
1401} /* ecore_x_window_children_get */
1402
1403EAPI Eina_Bool
1404ecore_x_pointer_control_set(int accel_num,
1405 int accel_denom,
1406 int threshold)
1407{
1408 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1409 return XChangePointerControl(_ecore_x_disp, 1, 1,
1410 accel_num, accel_denom, threshold) ? EINA_TRUE : EINA_FALSE;
1411} /* ecore_x_pointer_control_set */
1412
1413EAPI Eina_Bool
1414ecore_x_pointer_control_get(int *accel_num,
1415 int *accel_denom,
1416 int *threshold)
1417{
1418 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1419 return XGetPointerControl(_ecore_x_disp,
1420 accel_num, accel_denom, threshold) ? EINA_TRUE : EINA_FALSE;
1421} /* ecore_x_pointer_control_get */
1422
1423EAPI Eina_Bool
1424ecore_x_pointer_mapping_set(unsigned char *map,
1425 int nmap)
1426{
1427 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1428 return XSetPointerMapping(_ecore_x_disp, map, nmap) ? EINA_TRUE : EINA_FALSE;
1429} /* ecore_x_pointer_mapping_set */
1430
1431EAPI Eina_Bool
1432ecore_x_pointer_mapping_get(unsigned char *map,
1433 int nmap)
1434{
1435 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1436 return XGetPointerMapping(_ecore_x_disp, map, nmap) ? EINA_TRUE : EINA_FALSE;
1437} /* ecore_x_pointer_mapping_get */
1438
1439EAPI Eina_Bool
1440ecore_x_pointer_grab(Ecore_X_Window win)
1441{
1442 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1443 if (XGrabPointer(_ecore_x_disp, win, False,
1444 ButtonPressMask | ButtonReleaseMask |
1445 EnterWindowMask | LeaveWindowMask | PointerMotionMask,
1446 GrabModeAsync, GrabModeAsync,
1447 None, None, CurrentTime) == GrabSuccess)
1448 return EINA_TRUE;
1449
1450 return EINA_FALSE;
1451} /* ecore_x_pointer_grab */
1452
1453EAPI Eina_Bool
1454ecore_x_pointer_confine_grab(Ecore_X_Window win)
1455{
1456 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1457 if (XGrabPointer(_ecore_x_disp, win, False,
1458 ButtonPressMask | ButtonReleaseMask |
1459 EnterWindowMask | LeaveWindowMask | PointerMotionMask,
1460 GrabModeAsync, GrabModeAsync,
1461 win, None, CurrentTime) == GrabSuccess)
1462 return EINA_TRUE;
1463
1464 return EINA_FALSE;
1465} /* ecore_x_pointer_confine_grab */
1466
1467EAPI void
1468ecore_x_pointer_ungrab(void)
1469{
1470 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1471 XUngrabPointer(_ecore_x_disp, CurrentTime);
1472} /* ecore_x_pointer_ungrab */
1473
1474EAPI Eina_Bool
1475ecore_x_pointer_warp(Ecore_X_Window win,
1476 int x,
1477 int y)
1478{
1479 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1480 return XWarpPointer(_ecore_x_disp, None, win, 0, 0, 0, 0, x, y) ? EINA_TRUE : EINA_FALSE;
1481} /* ecore_x_pointer_warp */
1482
1483EAPI Eina_Bool
1484ecore_x_keyboard_grab(Ecore_X_Window win)
1485{
1486 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1487 if (XGrabKeyboard(_ecore_x_disp, win, False,
1488 GrabModeAsync, GrabModeAsync,
1489 CurrentTime) == GrabSuccess)
1490 return EINA_TRUE;
1491
1492 return EINA_FALSE;
1493} /* ecore_x_keyboard_grab */
1494
1495EAPI void
1496ecore_x_keyboard_ungrab(void)
1497{
1498 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1499 XUngrabKeyboard(_ecore_x_disp, CurrentTime);
1500} /* ecore_x_keyboard_ungrab */
1501
1502EAPI void
1503ecore_x_grab(void)
1504{
1505 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1506 _ecore_x_grab_count++;
1507 if (_ecore_x_grab_count == 1)
1508 XGrabServer(_ecore_x_disp);
1509} /* ecore_x_grab */
1510
1511EAPI void
1512ecore_x_ungrab(void)
1513{
1514 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1515 _ecore_x_grab_count--;
1516 if (_ecore_x_grab_count < 0)
1517 _ecore_x_grab_count = 0;
1518
1519 if (_ecore_x_grab_count == 0)
1520 XUngrabServer(_ecore_x_disp);
1521} /* ecore_x_ungrab */
1522
1523int _ecore_window_grabs_num = 0;
1524Window *_ecore_window_grabs = NULL;
1525Eina_Bool (*_ecore_window_grab_replay_func)(void *data,
1526 int event_type,
1527 void *event);
1528void *_ecore_window_grab_replay_data;
1529
1530EAPI void
1531ecore_x_passive_grab_replay_func_set(Eina_Bool (*func)(void *data,
1532 int event_type,
1533 void *event),
1534 void *data)
1535{
1536 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1537 _ecore_window_grab_replay_func = func;
1538 _ecore_window_grab_replay_data = data;
1539} /* ecore_x_passive_grab_replay_func_set */
1540
1541EAPI void
1542ecore_x_window_button_grab(Ecore_X_Window win,
1543 int button,
1544 Ecore_X_Event_Mask event_mask,
1545 int mod,
1546 int any_mod)
1547{
1548 unsigned int b;
1549 unsigned int m;
1550 unsigned int locks[8];
1551 int i, ev;
1552 Window *t;
1553
1554 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1555 b = button;
1556 if (b == 0)
1557 b = AnyButton;
1558
1559 m = _ecore_x_event_modifier(mod);
1560 if (any_mod)
1561 m = AnyModifier;
1562
1563 locks[0] = 0;
1564 locks[1] = ECORE_X_LOCK_CAPS;
1565 locks[2] = ECORE_X_LOCK_NUM;
1566 locks[3] = ECORE_X_LOCK_SCROLL;
1567 locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
1568 locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
1569 locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1570 locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1571 ev = event_mask;
1572 for (i = 0; i < 8; i++)
1573 XGrabButton(_ecore_x_disp, b, m | locks[i],
1574 win, False, ev, GrabModeSync, GrabModeAsync, None, None);
1575 _ecore_window_grabs_num++;
1576 t = realloc(_ecore_window_grabs,
1577 _ecore_window_grabs_num * sizeof(Window));
1578 if (!t) return;
1579 _ecore_window_grabs = t;
1580 _ecore_window_grabs[_ecore_window_grabs_num - 1] = win;
1581} /* ecore_x_window_button_grab */
1582
1583void
1584_ecore_x_sync_magic_send(int val,
1585 Ecore_X_Window swin)
1586{
1587 XEvent xev;
1588
1589 xev.xclient.type = ClientMessage;
1590 xev.xclient.serial = 0;
1591 xev.xclient.send_event = True;
1592 xev.xclient.display = _ecore_x_disp;
1593 xev.xclient.window = _ecore_x_private_win;
1594 xev.xclient.format = 32;
1595 xev.xclient.message_type = 27777;
1596 xev.xclient.data.l[0] = 0x7162534;
1597 xev.xclient.data.l[1] = 0x10000000 + val;
1598 xev.xclient.data.l[2] = swin;
1599 XSendEvent(_ecore_x_disp, _ecore_x_private_win, False, NoEventMask, &xev);
1600} /* _ecore_x_sync_magic_send */
1601
1602void
1603_ecore_x_window_grab_remove(Ecore_X_Window win)
1604{
1605 int i, shuffle = 0;
1606 Window *t;
1607
1608 if (_ecore_window_grabs_num > 0)
1609 {
1610 for (i = 0; i < _ecore_window_grabs_num; i++)
1611 {
1612 if (shuffle)
1613 _ecore_window_grabs[i - 1] = _ecore_window_grabs[i];
1614
1615 if ((!shuffle) && (_ecore_window_grabs[i] == win))
1616 shuffle = 1;
1617 }
1618 if (shuffle)
1619 {
1620 _ecore_window_grabs_num--;
1621 if (_ecore_window_grabs_num <= 0)
1622 {
1623 free(_ecore_window_grabs);
1624 _ecore_window_grabs = NULL;
1625 return;
1626 }
1627 t = realloc(_ecore_window_grabs,
1628 _ecore_window_grabs_num *
1629 sizeof(Window));
1630 if (!t) return;
1631 _ecore_window_grabs = t;
1632 }
1633 }
1634} /* _ecore_x_window_grab_remove */
1635
1636EAPI void
1637ecore_x_window_button_ungrab(Ecore_X_Window win,
1638 int button,
1639 int mod,
1640 int any_mod)
1641{
1642 unsigned int b;
1643 unsigned int m;
1644 unsigned int locks[8];
1645 int i;
1646
1647 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1648 b = button;
1649 if (b == 0)
1650 b = AnyButton;
1651
1652 m = _ecore_x_event_modifier(mod);
1653 if (any_mod)
1654 m = AnyModifier;
1655
1656 locks[0] = 0;
1657 locks[1] = ECORE_X_LOCK_CAPS;
1658 locks[2] = ECORE_X_LOCK_NUM;
1659 locks[3] = ECORE_X_LOCK_SCROLL;
1660 locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
1661 locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
1662 locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1663 locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1664 for (i = 0; i < 8; i++)
1665 XUngrabButton(_ecore_x_disp, b, m | locks[i], win);
1666 _ecore_x_sync_magic_send(1, win);
1667} /* ecore_x_window_button_ungrab */
1668
1669int _ecore_key_grabs_num = 0;
1670Window *_ecore_key_grabs = NULL;
1671
1672EAPI void
1673ecore_x_window_key_grab(Ecore_X_Window win,
1674 const char *key,
1675 int mod,
1676 int any_mod)
1677{
1678 KeyCode keycode = 0;
1679 KeySym keysym;
1680 unsigned int m;
1681 unsigned int locks[8];
1682 int i;
1683 Window *t;
1684
1685 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1686 if (!strncmp(key, "Keycode-", 8))
1687 keycode = atoi(key + 8);
1688 else
1689 {
1690 keysym = XStringToKeysym(key);
1691 if (keysym == NoSymbol)
1692 return;
1693
1694 keycode = XKeysymToKeycode(_ecore_x_disp, XStringToKeysym(key));
1695 }
1696
1697 if (keycode == 0)
1698 return;
1699
1700 m = _ecore_x_event_modifier(mod);
1701 if (any_mod)
1702 m = AnyModifier;
1703
1704 locks[0] = 0;
1705 locks[1] = ECORE_X_LOCK_CAPS;
1706 locks[2] = ECORE_X_LOCK_NUM;
1707 locks[3] = ECORE_X_LOCK_SCROLL;
1708 locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
1709 locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
1710 locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1711 locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1712 for (i = 0; i < 8; i++)
1713 XGrabKey(_ecore_x_disp, keycode, m | locks[i],
1714 win, False, GrabModeSync, GrabModeAsync);
1715 _ecore_key_grabs_num++;
1716 t = realloc(_ecore_key_grabs,
1717 _ecore_key_grabs_num * sizeof(Window));
1718 if (!t) return;
1719 _ecore_key_grabs = t;
1720 _ecore_key_grabs[_ecore_key_grabs_num - 1] = win;
1721} /* ecore_x_window_key_grab */
1722
1723void
1724_ecore_x_key_grab_remove(Ecore_X_Window win)
1725{
1726 int i, shuffle = 0;
1727 Window *t;
1728
1729 if (_ecore_key_grabs_num > 0)
1730 {
1731 for (i = 0; i < _ecore_key_grabs_num; i++)
1732 {
1733 if (shuffle)
1734 _ecore_key_grabs[i - 1] = _ecore_key_grabs[i];
1735
1736 if ((!shuffle) && (_ecore_key_grabs[i] == win))
1737 shuffle = 1;
1738 }
1739 if (shuffle)
1740 {
1741 _ecore_key_grabs_num--;
1742 if (_ecore_key_grabs_num <= 0)
1743 {
1744 free(_ecore_key_grabs);
1745 _ecore_key_grabs = NULL;
1746 return;
1747 }
1748 t = realloc(_ecore_key_grabs,
1749 _ecore_key_grabs_num * sizeof(Window));
1750 if (!t) return;
1751 _ecore_key_grabs = t;
1752 }
1753 }
1754} /* _ecore_x_key_grab_remove */
1755
1756EAPI void
1757ecore_x_window_key_ungrab(Ecore_X_Window win,
1758 const char *key,
1759 int mod,
1760 int any_mod)
1761{
1762 KeyCode keycode = 0;
1763 KeySym keysym;
1764 unsigned int m;
1765 unsigned int locks[8];
1766 int i;
1767
1768 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1769 if (!strncmp(key, "Keycode-", 8))
1770 keycode = atoi(key + 8);
1771 else
1772 {
1773 keysym = XStringToKeysym(key);
1774 if (keysym == NoSymbol)
1775 return;
1776
1777 keycode = XKeysymToKeycode(_ecore_x_disp, XStringToKeysym(key));
1778 }
1779
1780 if (keycode == 0)
1781 return;
1782
1783 m = _ecore_x_event_modifier(mod);
1784 if (any_mod)
1785 m = AnyModifier;
1786
1787 locks[0] = 0;
1788 locks[1] = ECORE_X_LOCK_CAPS;
1789 locks[2] = ECORE_X_LOCK_NUM;
1790 locks[3] = ECORE_X_LOCK_SCROLL;
1791 locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM;
1792 locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL;
1793 locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1794 locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL;
1795 for (i = 0; i < 8; i++)
1796 XUngrabKey(_ecore_x_disp, keycode, m | locks[i], win);
1797 _ecore_x_sync_magic_send(2, win);
1798} /* ecore_x_window_key_ungrab */
1799
1800/**
1801 * Send client message with given type and format 32.
1802 *
1803 * @param win The window the message is sent to.
1804 * @param type The client message type.
1805 * @param d0 The client message data item 1
1806 * @param d1 The client message data item 2
1807 * @param d2 The client message data item 3
1808 * @param d3 The client message data item 4
1809 * @param d4 The client message data item 5
1810 *
1811 * @return EINA_TRUE on success EINA_FALSE otherwise.
1812 */
1813EAPI Eina_Bool
1814ecore_x_client_message32_send(Ecore_X_Window win,
1815 Ecore_X_Atom type,
1816 Ecore_X_Event_Mask mask,
1817 long d0,
1818 long d1,
1819 long d2,
1820 long d3,
1821 long d4)
1822{
1823 XEvent xev;
1824
1825 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1826 xev.xclient.window = win;
1827 xev.xclient.type = ClientMessage;
1828 xev.xclient.message_type = type;
1829 xev.xclient.format = 32;
1830 xev.xclient.data.l[0] = d0;
1831 xev.xclient.data.l[1] = d1;
1832 xev.xclient.data.l[2] = d2;
1833 xev.xclient.data.l[3] = d3;
1834 xev.xclient.data.l[4] = d4;
1835
1836 return XSendEvent(_ecore_x_disp, win, False, mask, &xev) ? EINA_TRUE : EINA_FALSE;
1837} /* ecore_x_client_message32_send */
1838
1839/**
1840 * Send client message with given type and format 8.
1841 *
1842 * @param win The window the message is sent to.
1843 * @param type The client message type.
1844 * @param data Data to be sent.
1845 * @param len Number of data bytes, max 20.
1846 *
1847 * @return EINA_TRUE on success EINA_FALSE otherwise.
1848 */
1849EAPI Eina_Bool
1850ecore_x_client_message8_send(Ecore_X_Window win,
1851 Ecore_X_Atom type,
1852 const void *data,
1853 int len)
1854{
1855 XEvent xev;
1856
1857 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1858 xev.xclient.window = win;
1859 xev.xclient.type = ClientMessage;
1860 xev.xclient.message_type = type;
1861 xev.xclient.format = 8;
1862 if (len > 20)
1863 len = 20;
1864
1865 memcpy(xev.xclient.data.b, data, len);
1866 memset(xev.xclient.data.b + len, 0, 20 - len);
1867
1868 return XSendEvent(_ecore_x_disp, win, False, NoEventMask, &xev) ? EINA_TRUE : EINA_FALSE;
1869} /* ecore_x_client_message8_send */
1870
1871EAPI Eina_Bool
1872ecore_x_mouse_move_send(Ecore_X_Window win,
1873 int x,
1874 int y)
1875{
1876 XEvent xev;
1877 XWindowAttributes att;
1878 Window tw;
1879 int rx, ry;
1880
1881 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1882 XGetWindowAttributes(_ecore_x_disp, win, &att);
1883 XTranslateCoordinates(_ecore_x_disp, win, att.root, x, y, &rx, &ry, &tw);
1884 xev.xmotion.type = MotionNotify;
1885 xev.xmotion.window = win;
1886 xev.xmotion.root = att.root;
1887 xev.xmotion.subwindow = win;
1888 xev.xmotion.time = _ecore_x_event_last_time;
1889 xev.xmotion.x = x;
1890 xev.xmotion.y = y;
1891 xev.xmotion.x_root = rx;
1892 xev.xmotion.y_root = ry;
1893 xev.xmotion.state = 0;
1894 xev.xmotion.is_hint = 0;
1895 xev.xmotion.same_screen = 1;
1896 return XSendEvent(_ecore_x_disp, win, True, PointerMotionMask, &xev) ? EINA_TRUE : EINA_FALSE;
1897} /* ecore_x_mouse_move_send */
1898
1899EAPI Eina_Bool
1900ecore_x_mouse_down_send(Ecore_X_Window win,
1901 int x,
1902 int y,
1903 int b)
1904{
1905 XEvent xev;
1906 XWindowAttributes att;
1907 Window tw;
1908 int rx, ry;
1909
1910 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1911 XGetWindowAttributes(_ecore_x_disp, win, &att);
1912 XTranslateCoordinates(_ecore_x_disp, win, att.root, x, y, &rx, &ry, &tw);
1913 xev.xbutton.type = ButtonPress;
1914 xev.xbutton.window = win;
1915 xev.xbutton.root = att.root;
1916 xev.xbutton.subwindow = win;
1917 xev.xbutton.time = _ecore_x_event_last_time;
1918 xev.xbutton.x = x;
1919 xev.xbutton.y = y;
1920 xev.xbutton.x_root = rx;
1921 xev.xbutton.y_root = ry;
1922 xev.xbutton.state = 1 << b;
1923 xev.xbutton.button = b;
1924 xev.xbutton.same_screen = 1;
1925 return XSendEvent(_ecore_x_disp, win, True, ButtonPressMask, &xev) ? EINA_TRUE : EINA_FALSE;
1926} /* ecore_x_mouse_down_send */
1927
1928EAPI Eina_Bool
1929ecore_x_mouse_up_send(Ecore_X_Window win,
1930 int x,
1931 int y,
1932 int b)
1933{
1934 XEvent xev;
1935 XWindowAttributes att;
1936 Window tw;
1937 int rx, ry;
1938
1939 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1940 XGetWindowAttributes(_ecore_x_disp, win, &att);
1941 XTranslateCoordinates(_ecore_x_disp, win, att.root, x, y, &rx, &ry, &tw);
1942 xev.xbutton.type = ButtonRelease;
1943 xev.xbutton.window = win;
1944 xev.xbutton.root = att.root;
1945 xev.xbutton.subwindow = win;
1946 xev.xbutton.time = _ecore_x_event_last_time;
1947 xev.xbutton.x = x;
1948 xev.xbutton.y = y;
1949 xev.xbutton.x_root = rx;
1950 xev.xbutton.y_root = ry;
1951 xev.xbutton.state = 0;
1952 xev.xbutton.button = b;
1953 xev.xbutton.same_screen = 1;
1954 return XSendEvent(_ecore_x_disp, win, True, ButtonReleaseMask, &xev) ? EINA_TRUE : EINA_FALSE;
1955} /* ecore_x_mouse_up_send */
1956
1957EAPI void
1958ecore_x_focus_reset(void)
1959{
1960 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1961 XSetInputFocus(_ecore_x_disp, PointerRoot, RevertToPointerRoot, CurrentTime);
1962} /* ecore_x_focus_reset */
1963
1964EAPI void
1965ecore_x_events_allow_all(void)
1966{
1967 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1968 XAllowEvents(_ecore_x_disp, AsyncBoth, CurrentTime);
1969} /* ecore_x_events_allow_all */
1970
1971EAPI void
1972ecore_x_pointer_last_xy_get(int *x,
1973 int *y)
1974{
1975 if (x)
1976 *x = _ecore_x_event_last_root_x;
1977
1978 if (y)
1979 *y = _ecore_x_event_last_root_y;
1980} /* ecore_x_pointer_last_xy_get */
1981
1982EAPI void
1983ecore_x_pointer_xy_get(Ecore_X_Window win,
1984 int *x,
1985 int *y)
1986{
1987 Window rwin, cwin;
1988 int rx, ry, wx, wy, ret;
1989 unsigned int mask;
1990
1991 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1992 ret = XQueryPointer(_ecore_x_disp, win, &rwin, &cwin,
1993 &rx, &ry, &wx, &wy, &mask);
1994 if (!ret)
1995 wx = wy = -1;
1996
1997 if (x) *x = wx;
1998 if (y) *y = wy;
1999} /* ecore_x_pointer_xy_get */
2000
2001/**
2002 * Retrieve the Visual ID from a given Visual.
2003 *
2004 * @param visual The Visual to get the ID for.
2005 *
2006 * @return The visual id.
2007 * @since 1.1.0
2008 */
2009EAPI unsigned int
2010ecore_x_visual_id_get(Ecore_X_Visual visual)
2011{
2012 return XVisualIDFromVisual(visual);
2013}
2014
2015/**
2016 * Retrieve the default Visual.
2017 *
2018 * @param disp The Display to get the Default Visual from
2019 * @param screen The Screen.
2020 *
2021 * @return The default visual.
2022 * @since 1.1.0
2023 */
2024EAPI Ecore_X_Visual
2025ecore_x_default_visual_get(Ecore_X_Display *disp,
2026 Ecore_X_Screen *screen)
2027{
2028 return DefaultVisual(disp, ecore_x_screen_index_get(screen));
2029}
2030
2031/**
2032 * Retrieve the default Colormap.
2033 *
2034 * @param disp The Display to get the Default Colormap from
2035 * @param screen The Screen.
2036 *
2037 * @return The default colormap.
2038 * @since 1.1.0
2039 */
2040EAPI Ecore_X_Colormap
2041ecore_x_default_colormap_get(Ecore_X_Display *disp,
2042 Ecore_X_Screen *screen)
2043{
2044 return DefaultColormap(disp, ecore_x_screen_index_get(screen));
2045}
2046
2047/**
2048 * Retrieve the default depth.
2049 *
2050 * @param disp The Display to get the Default Depth from
2051 * @param screen The Screen.
2052 *
2053 * @return The default depth.
2054 * @since 1.1.0
2055 */
2056EAPI int
2057ecore_x_default_depth_get(Ecore_X_Display *disp,
2058 Ecore_X_Screen *screen)
2059{
2060 return DefaultDepth(disp, ecore_x_screen_index_get(screen));
2061}
2062
2063/*****************************************************************************/
2064/*****************************************************************************/
2065/*****************************************************************************/
2066
2067static int
2068_ecore_x_event_modifier(unsigned int state)
2069{
2070 int xmodifiers = 0;
2071
2072 if (state & ECORE_EVENT_MODIFIER_SHIFT)
2073 xmodifiers |= ECORE_X_MODIFIER_SHIFT;
2074
2075 if (state & ECORE_EVENT_MODIFIER_CTRL)
2076 xmodifiers |= ECORE_X_MODIFIER_CTRL;
2077
2078 if (state & ECORE_EVENT_MODIFIER_ALT)
2079 xmodifiers |= ECORE_X_MODIFIER_ALT;
2080
2081 if (state & ECORE_EVENT_MODIFIER_WIN)
2082 xmodifiers |= ECORE_X_MODIFIER_WIN;
2083
2084 if (state & ECORE_EVENT_LOCK_SCROLL)
2085 xmodifiers |= ECORE_X_LOCK_SCROLL;
2086
2087 if (state & ECORE_EVENT_LOCK_NUM)
2088 xmodifiers |= ECORE_X_LOCK_NUM;
2089
2090 if (state & ECORE_EVENT_LOCK_CAPS)
2091 xmodifiers |= ECORE_X_LOCK_CAPS;
2092
2093 if (state & ECORE_EVENT_LOCK_SHIFT)
2094 xmodifiers |= ECORE_X_LOCK_SHIFT;
2095
2096 return xmodifiers;
2097} /* _ecore_x_event_modifier */
2098
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_atoms.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_atoms.c
new file mode 100644
index 0000000..fd96d5c
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_atoms.c
@@ -0,0 +1,352 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#ifdef HAVE_ALLOCA_H
6# include <alloca.h>
7#elif defined __GNUC__
8# define alloca __builtin_alloca
9#elif defined _AIX
10# define alloca __alloca
11#elif defined _MSC_VER
12# include <malloc.h>
13# define alloca _alloca
14#else /* ifdef HAVE_ALLOCA_H */
15# include <stddef.h>
16# ifdef __cplusplus
17extern "C"
18# endif /* ifdef __cplusplus */
19void *alloca(size_t);
20#endif /* ifdef HAVE_ALLOCA_H */
21
22#include <string.h>
23
24#include "Ecore.h"
25#include "ecore_x_private.h"
26#include "Ecore_X.h"
27#include "Ecore_X_Atoms.h"
28
29#include "ecore_x_atoms_decl.h"
30
31typedef struct
32{
33 const char *name;
34 Ecore_X_Atom *atom;
35} Atom_Item;
36
37void
38_ecore_x_atoms_init(void)
39{
40 const Atom_Item items[] =
41 {
42 { "ATOM", &ECORE_X_ATOM_ATOM },
43 { "CARDINAL", &ECORE_X_ATOM_CARDINAL },
44 { "COMPOUND_TEXT", &ECORE_X_ATOM_COMPOUND_TEXT },
45 { "FILE_NAME", &ECORE_X_ATOM_FILE_NAME },
46 { "STRING", &ECORE_X_ATOM_STRING },
47 { "TEXT", &ECORE_X_ATOM_TEXT },
48 { "UTF8_STRING", &ECORE_X_ATOM_UTF8_STRING },
49 { "WINDOW", &ECORE_X_ATOM_WINDOW },
50 { "PIXMAP", &ECORE_X_ATOM_PIXMAP },
51
52 { "JXSelectionWindowProperty", &ECORE_X_ATOM_SELECTION_PROP_XDND },
53 { "XdndSelection", &ECORE_X_ATOM_SELECTION_XDND },
54 { "XdndAware", &ECORE_X_ATOM_XDND_AWARE },
55 { "XdndEnter", &ECORE_X_ATOM_XDND_ENTER },
56 { "XdndTypeList", &ECORE_X_ATOM_XDND_TYPE_LIST },
57 { "XdndPosition", &ECORE_X_ATOM_XDND_POSITION },
58 { "XdndActionCopy", &ECORE_X_ATOM_XDND_ACTION_COPY },
59 { "XdndActionMove", &ECORE_X_ATOM_XDND_ACTION_MOVE },
60 { "XdndActionPrivate", &ECORE_X_ATOM_XDND_ACTION_PRIVATE },
61 { "XdndActionAsk", &ECORE_X_ATOM_XDND_ACTION_ASK },
62 { "XdndActionList", &ECORE_X_ATOM_XDND_ACTION_LIST },
63 { "XdndActionLink", &ECORE_X_ATOM_XDND_ACTION_LINK },
64 { "XdndActionDescription", &ECORE_X_ATOM_XDND_ACTION_DESCRIPTION },
65 { "XdndProxy", &ECORE_X_ATOM_XDND_PROXY },
66 { "XdndStatus", &ECORE_X_ATOM_XDND_STATUS },
67 { "XdndLeave", &ECORE_X_ATOM_XDND_LEAVE },
68 { "XdndDrop", &ECORE_X_ATOM_XDND_DROP },
69 { "XdndFinished", &ECORE_X_ATOM_XDND_FINISHED },
70
71 { "XdndActionCopy", &ECORE_X_DND_ACTION_COPY },
72 { "XdndActionMove", &ECORE_X_DND_ACTION_MOVE },
73 { "XdndActionLink", &ECORE_X_DND_ACTION_LINK },
74 { "XdndActionAsk", &ECORE_X_DND_ACTION_ASK },
75 { "XdndActionPrivate", &ECORE_X_DND_ACTION_PRIVATE },
76
77 { "_E_FRAME_SIZE", &ECORE_X_ATOM_E_FRAME_SIZE },
78
79 { "_WIN_LAYER", &ECORE_X_ATOM_WIN_LAYER },
80
81 { "WM_NAME", &ECORE_X_ATOM_WM_NAME },
82 { "WM_ICON_NAME", &ECORE_X_ATOM_WM_ICON_NAME },
83 { "WM_NORMAL_HINTS", &ECORE_X_ATOM_WM_NORMAL_HINTS },
84 { "WM_SIZE_HINTS", &ECORE_X_ATOM_WM_SIZE_HINTS },
85 { "WM_HINTS", &ECORE_X_ATOM_WM_HINTS },
86 { "WM_CLASS", &ECORE_X_ATOM_WM_CLASS },
87 { "WM_TRANSIENT_FOR", &ECORE_X_ATOM_WM_TRANSIENT_FOR },
88 { "WM_PROTOCOLS", &ECORE_X_ATOM_WM_PROTOCOLS },
89 { "WM_COLORMAP_WINDOWS", &ECORE_X_ATOM_WM_COLORMAP_WINDOWS },
90 { "WM_COMMAND", &ECORE_X_ATOM_WM_COMMAND },
91 { "WM_CLIENT_MACHINE", &ECORE_X_ATOM_WM_CLIENT_MACHINE },
92
93 { "WM_STATE", &ECORE_X_ATOM_WM_STATE },
94 { "WM_ICON_SIZE", &ECORE_X_ATOM_WM_ICON_SIZE },
95
96 { "WM_CHANGE_STATE", &ECORE_X_ATOM_WM_CHANGE_STATE },
97
98 { "WM_TAKE_FOCUS", &ECORE_X_ATOM_WM_TAKE_FOCUS },
99 { "WM_SAVE_YOURSELF", &ECORE_X_ATOM_WM_SAVE_YOURSELF },
100 { "WM_DELETE_WINDOW", &ECORE_X_ATOM_WM_DELETE_WINDOW },
101
102 { "WM_COLORMAP_NOTIFY", &ECORE_X_ATOM_WM_COLORMAP_NOTIFY },
103
104 { "SM_CLIENT_ID", &ECORE_X_ATOM_SM_CLIENT_ID },
105 { "WM_CLIENT_LEADER", &ECORE_X_ATOM_WM_CLIENT_LEADER },
106 { "WM_WINDOW_ROLE", &ECORE_X_ATOM_WM_WINDOW_ROLE },
107
108 { "_MOTIF_WM_HINTS", &ECORE_X_ATOM_MOTIF_WM_HINTS },
109
110 { "_NET_SUPPORTED", &ECORE_X_ATOM_NET_SUPPORTED },
111 { "_NET_CLIENT_LIST", &ECORE_X_ATOM_NET_CLIENT_LIST },
112 { "_NET_CLIENT_LIST_STACKING", &ECORE_X_ATOM_NET_CLIENT_LIST_STACKING },
113 { "_NET_NUMBER_OF_DESKTOPS", &ECORE_X_ATOM_NET_NUMBER_OF_DESKTOPS },
114 { "_NET_DESKTOP_GEOMETRY", &ECORE_X_ATOM_NET_DESKTOP_GEOMETRY },
115 { "_NET_DESKTOP_VIEWPORT", &ECORE_X_ATOM_NET_DESKTOP_VIEWPORT },
116 { "_NET_CURRENT_DESKTOP", &ECORE_X_ATOM_NET_CURRENT_DESKTOP },
117 { "_NET_DESKTOP_NAMES", &ECORE_X_ATOM_NET_DESKTOP_NAMES },
118 { "_NET_ACTIVE_WINDOW", &ECORE_X_ATOM_NET_ACTIVE_WINDOW },
119 { "_NET_WORKAREA", &ECORE_X_ATOM_NET_WORKAREA },
120 { "_NET_SUPPORTING_WM_CHECK", &ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK },
121 { "_NET_VIRTUAL_ROOTS", &ECORE_X_ATOM_NET_VIRTUAL_ROOTS },
122 { "_NET_DESKTOP_LAYOUT", &ECORE_X_ATOM_NET_DESKTOP_LAYOUT },
123 { "_NET_SHOWING_DESKTOP", &ECORE_X_ATOM_NET_SHOWING_DESKTOP },
124
125 { "_NET_CLOSE_WINDOW", &ECORE_X_ATOM_NET_CLOSE_WINDOW },
126 { "_NET_MOVERESIZE_WINDOW", &ECORE_X_ATOM_NET_MOVERESIZE_WINDOW },
127 { "_NET_WM_MOVERESIZE", &ECORE_X_ATOM_NET_WM_MOVERESIZE },
128 { "_NET_RESTACK_WINDOW", &ECORE_X_ATOM_NET_RESTACK_WINDOW },
129
130 { "_NET_REQUEST_FRAME_EXTENTS", &ECORE_X_ATOM_NET_REQUEST_FRAME_EXTENTS },
131
132 { "_NET_WM_NAME", &ECORE_X_ATOM_NET_WM_NAME },
133 { "_NET_WM_VISIBLE_NAME", &ECORE_X_ATOM_NET_WM_VISIBLE_NAME },
134 { "_NET_WM_ICON_NAME", &ECORE_X_ATOM_NET_WM_ICON_NAME },
135 { "_NET_WM_VISIBLE_ICON_NAME", &ECORE_X_ATOM_NET_WM_VISIBLE_ICON_NAME },
136 { "_NET_WM_DESKTOP", &ECORE_X_ATOM_NET_WM_DESKTOP },
137
138 { "_NET_WM_WINDOW_TYPE", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE },
139 { "_NET_WM_WINDOW_TYPE_DESKTOP", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DESKTOP },
140 { "_NET_WM_WINDOW_TYPE_DOCK", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DOCK },
141 { "_NET_WM_WINDOW_TYPE_TOOLBAR", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLBAR },
142 { "_NET_WM_WINDOW_TYPE_MENU", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_MENU },
143 { "_NET_WM_WINDOW_TYPE_UTILITY", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_UTILITY },
144 { "_NET_WM_WINDOW_TYPE_SPLASH", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_SPLASH },
145 { "_NET_WM_WINDOW_TYPE_DIALOG", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DIALOG },
146 { "_NET_WM_WINDOW_TYPE_NORMAL", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NORMAL },
147 { "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU",
148 &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DROPDOWN_MENU },
149 { "_NET_WM_WINDOW_TYPE_POPUP_MENU",
150 &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_POPUP_MENU },
151 { "_NET_WM_WINDOW_TYPE_TOOLTIP", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLTIP },
152 { "_NET_WM_WINDOW_TYPE_NOTIFICATION",
153 &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NOTIFICATION },
154 { "_NET_WM_WINDOW_TYPE_COMBO", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_COMBO },
155 { "_NET_WM_WINDOW_TYPE_DND", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DND },
156
157 { "_NET_WM_STATE", &ECORE_X_ATOM_NET_WM_STATE },
158 { "_NET_WM_STATE_MODAL", &ECORE_X_ATOM_NET_WM_STATE_MODAL },
159 { "_NET_WM_STATE_STICKY", &ECORE_X_ATOM_NET_WM_STATE_STICKY },
160 { "_NET_WM_STATE_MAXIMIZED_VERT",
161 &ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_VERT },
162 { "_NET_WM_STATE_MAXIMIZED_HORZ",
163 &ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_HORZ },
164 { "_NET_WM_STATE_SHADED", &ECORE_X_ATOM_NET_WM_STATE_SHADED },
165 { "_NET_WM_STATE_SKIP_TASKBAR", &ECORE_X_ATOM_NET_WM_STATE_SKIP_TASKBAR },
166 { "_NET_WM_STATE_SKIP_PAGER", &ECORE_X_ATOM_NET_WM_STATE_SKIP_PAGER },
167 { "_NET_WM_STATE_HIDDEN", &ECORE_X_ATOM_NET_WM_STATE_HIDDEN },
168 { "_NET_WM_STATE_FULLSCREEN", &ECORE_X_ATOM_NET_WM_STATE_FULLSCREEN },
169 { "_NET_WM_STATE_ABOVE", &ECORE_X_ATOM_NET_WM_STATE_ABOVE },
170 { "_NET_WM_STATE_BELOW", &ECORE_X_ATOM_NET_WM_STATE_BELOW },
171 { "_NET_WM_STATE_DEMANDS_ATTENTION",
172 &ECORE_X_ATOM_NET_WM_STATE_DEMANDS_ATTENTION },
173
174 { "_NET_WM_ALLOWED_ACTIONS", &ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS },
175 { "_NET_WM_ACTION_MOVE", &ECORE_X_ATOM_NET_WM_ACTION_MOVE },
176 { "_NET_WM_ACTION_RESIZE", &ECORE_X_ATOM_NET_WM_ACTION_RESIZE },
177 { "_NET_WM_ACTION_MINIMIZE", &ECORE_X_ATOM_NET_WM_ACTION_MINIMIZE },
178 { "_NET_WM_ACTION_SHADE", &ECORE_X_ATOM_NET_WM_ACTION_SHADE },
179 { "_NET_WM_ACTION_STICK", &ECORE_X_ATOM_NET_WM_ACTION_STICK },
180 { "_NET_WM_ACTION_MAXIMIZE_HORZ",
181 &ECORE_X_ATOM_NET_WM_ACTION_MAXIMIZE_HORZ },
182 { "_NET_WM_ACTION_MAXIMIZE_VERT",
183 &ECORE_X_ATOM_NET_WM_ACTION_MAXIMIZE_VERT },
184 { "_NET_WM_ACTION_FULLSCREEN", &ECORE_X_ATOM_NET_WM_ACTION_FULLSCREEN },
185 { "_NET_WM_ACTION_CHANGE_DESKTOP",
186 &ECORE_X_ATOM_NET_WM_ACTION_CHANGE_DESKTOP },
187 { "_NET_WM_ACTION_CLOSE", &ECORE_X_ATOM_NET_WM_ACTION_CLOSE },
188 { "_NET_WM_ACTION_ABOVE", &ECORE_X_ATOM_NET_WM_ACTION_ABOVE },
189 { "_NET_WM_ACTION_BELOW", &ECORE_X_ATOM_NET_WM_ACTION_BELOW },
190
191 { "_NET_WM_STRUT", &ECORE_X_ATOM_NET_WM_STRUT },
192 { "_NET_WM_STRUT_PARTIAL", &ECORE_X_ATOM_NET_WM_STRUT_PARTIAL },
193 { "_NET_WM_ICON_GEOMETRY", &ECORE_X_ATOM_NET_WM_ICON_GEOMETRY },
194 { "_NET_WM_ICON", &ECORE_X_ATOM_NET_WM_ICON },
195 { "_NET_WM_PID", &ECORE_X_ATOM_NET_WM_PID },
196 { "_NET_WM_HANDLED_ICONS", &ECORE_X_ATOM_NET_WM_HANDLED_ICONS },
197 { "_NET_WM_USER_TIME", &ECORE_X_ATOM_NET_WM_USER_TIME },
198 { "_NET_STARTUP_ID", &ECORE_X_ATOM_NET_STARTUP_ID },
199 { "_NET_FRAME_EXTENTS", &ECORE_X_ATOM_NET_FRAME_EXTENTS },
200
201 { "_NET_WM_PING", &ECORE_X_ATOM_NET_WM_PING },
202 { "_NET_WM_SYNC_REQUEST", &ECORE_X_ATOM_NET_WM_SYNC_REQUEST },
203 { "_NET_WM_SYNC_REQUEST_COUNTER",
204 &ECORE_X_ATOM_NET_WM_SYNC_REQUEST_COUNTER },
205
206 { "_NET_WM_WINDOW_OPACITY", &ECORE_X_ATOM_NET_WM_WINDOW_OPACITY },
207 { "_NET_WM_WINDOW_SHADOW", &ECORE_X_ATOM_NET_WM_WINDOW_SHADOW },
208 { "_NET_WM_WINDOW_SHADE", &ECORE_X_ATOM_NET_WM_WINDOW_SHADE },
209
210 { "TARGETS", &ECORE_X_ATOM_SELECTION_TARGETS },
211 { "CLIPBOARD", &ECORE_X_ATOM_SELECTION_CLIPBOARD },
212 { "PRIMARY", &ECORE_X_ATOM_SELECTION_PRIMARY },
213 { "SECONDARY", &ECORE_X_ATOM_SELECTION_SECONDARY },
214 { "_ECORE_SELECTION_PRIMARY", &ECORE_X_ATOM_SELECTION_PROP_PRIMARY },
215 { "_ECORE_SELECTION_SECONDARY", &ECORE_X_ATOM_SELECTION_PROP_SECONDARY },
216 { "_ECORE_SELECTION_CLIPBOARD", &ECORE_X_ATOM_SELECTION_PROP_CLIPBOARD },
217
218 { "_E_VIRTUAL_KEYBOARD", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD },
219 { "_E_VIRTUAL_KEYBOARD_STATE", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE },
220 { "_E_VIRTUAL_KEYBOARD_ON", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_ON },
221 { "_E_VIRTUAL_KEYBOARD_OFF", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_OFF },
222 { "_E_VIRTUAL_KEYBOARD_ALPHA", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_ALPHA },
223 { "_E_VIRTUAL_KEYBOARD_NUMERIC", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_NUMERIC },
224 { "_E_VIRTUAL_KEYBOARD_PIN", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PIN },
225 { "_E_VIRTUAL_KEYBOARD_PHONE_NUMBER",
226 &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PHONE_NUMBER },
227 { "_E_VIRTUAL_KEYBOARD_HEX", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_HEX },
228 { "_E_VIRTUAL_KEYBOARD_TERMINAL",
229 &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_TERMINAL },
230 { "_E_VIRTUAL_KEYBOARD_PASSWORD",
231 &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PASSWORD },
232 { "_E_VIRTUAL_KEYBOARD_IP", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_IP },
233 { "_E_VIRTUAL_KEYBOARD_HOST", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_HOST },
234 { "_E_VIRTUAL_KEYBOARD_FILE", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_FILE },
235 { "_E_VIRTUAL_KEYBOARD_URL", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_URL },
236 { "_E_VIRTUAL_KEYBOARD_KEYPAD", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_KEYPAD },
237 { "_E_VIRTUAL_KEYBOARD_J2ME", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_J2ME },
238
239 { "_E_ILLUME_ZONE", &ECORE_X_ATOM_E_ILLUME_ZONE },
240 { "_E_ILLUME_ZONE_LIST", &ECORE_X_ATOM_E_ILLUME_ZONE_LIST },
241 { "_E_ILLUME_CONFORMANT", &ECORE_X_ATOM_E_ILLUME_CONFORMANT },
242 { "_E_ILLUME_MODE", &ECORE_X_ATOM_E_ILLUME_MODE },
243 { "_E_ILLUME_MODE_SINGLE", &ECORE_X_ATOM_E_ILLUME_MODE_SINGLE },
244 { "_E_ILLUME_MODE_DUAL_TOP", &ECORE_X_ATOM_E_ILLUME_MODE_DUAL_TOP },
245 { "_E_ILLUME_MODE_DUAL_LEFT", &ECORE_X_ATOM_E_ILLUME_MODE_DUAL_LEFT },
246 { "_E_ILLUME_FOCUS_BACK", &ECORE_X_ATOM_E_ILLUME_FOCUS_BACK },
247 { "_E_ILLUME_FOCUS_FORWARD", &ECORE_X_ATOM_E_ILLUME_FOCUS_FORWARD },
248 { "_E_ILLUME_FOCUS_HOME", &ECORE_X_ATOM_E_ILLUME_FOCUS_HOME },
249 { "_E_ILLUME_CLOSE", &ECORE_X_ATOM_E_ILLUME_CLOSE },
250 { "_E_ILLUME_HOME_NEW", &ECORE_X_ATOM_E_ILLUME_HOME_NEW },
251 { "_E_ILLUME_HOME_DEL", &ECORE_X_ATOM_E_ILLUME_HOME_DEL },
252 { "_E_ILLUME_DRAG", &ECORE_X_ATOM_E_ILLUME_DRAG },
253 { "_E_ILLUME_DRAG_LOCKED", &ECORE_X_ATOM_E_ILLUME_DRAG_LOCKED },
254 { "_E_ILLUME_DRAG_START", &ECORE_X_ATOM_E_ILLUME_DRAG_START },
255 { "_E_ILLUME_DRAG_END", &ECORE_X_ATOM_E_ILLUME_DRAG_END },
256 { "_E_ILLUME_INDICATOR_GEOMETRY",
257 &ECORE_X_ATOM_E_ILLUME_INDICATOR_GEOMETRY },
258 { "_E_ILLUME_SOFTKEY_GEOMETRY", &ECORE_X_ATOM_E_ILLUME_SOFTKEY_GEOMETRY },
259 { "_E_ILLUME_KEYBOARD_GEOMETRY", &ECORE_X_ATOM_E_ILLUME_KEYBOARD_GEOMETRY },
260 { "_E_ILLUME_QUICKPANEL", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL },
261 { "_E_ILLUME_QUICKPANEL_STATE", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE },
262 { "_E_ILLUME_QUICKPANEL_STATE_TOGGLE",
263 &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE_TOGGLE },
264 { "_E_ILLUME_QUICKPANEL_ON", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON },
265 { "_E_ILLUME_QUICKPANEL_OFF", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF },
266 { "_E_ILLUME_QUICKPANEL_PRIORITY_MAJOR",
267 &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MAJOR },
268 { "_E_ILLUME_QUICKPANEL_PRIORITY_MINOR",
269 &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MINOR },
270 { "_E_ILLUME_QUICKPANEL_ZONE", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ZONE },
271 { "_E_ILLUME_QUICKPANEL_POSITION_UPDATE",
272 &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_POSITION_UPDATE },
273
274 { "_E_COMP_SYNC_COUNTER", &ECORE_X_ATOM_E_COMP_SYNC_COUNTER },
275 { "_E_COMP_SYNC_DRAW_DONE", &ECORE_X_ATOM_E_COMP_SYNC_DRAW_DONE },
276 { "_E_COMP_SYNC_SUPPORTED", &ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED },
277 { "_E_COMP_SYNC_BEGIN", &ECORE_X_ATOM_E_COMP_SYNC_BEGIN },
278 { "_E_COMP_SYNC_END", &ECORE_X_ATOM_E_COMP_SYNC_END },
279 { "_E_COMP_SYNC_CANCEL", &ECORE_X_ATOM_E_COMP_SYNC_CANCEL },
280
281 { "_E_COMP_FLUSH", &ECORE_X_ATOM_E_COMP_FLUSH },
282 { "_E_COMP_DUMP", &ECORE_X_ATOM_E_COMP_DUMP },
283 { "_E_COMP_PIXMAP", &ECORE_X_ATOM_E_COMP_PIXMAP },
284 { "_E_VIDEO_PARENT", &ECORE_X_ATOM_E_VIDEO_PARENT },
285 { "_E_VIDEO_POSITION", &ECORE_X_ATOM_E_VIDEO_POSITION }
286 };
287 Atom *atoms;
288 char **names;
289 int i, num;
290
291 num = sizeof(items) / sizeof(Atom_Item);
292 atoms = alloca(num * sizeof(Atom));
293 names = alloca(num * sizeof(char *));
294 for (i = 0; i < num; i++) names[i] = (char *)items[i].name;
295 XInternAtoms(_ecore_x_disp, names, num, False, atoms);
296 for (i = 0; i < num; i++) *(items[i].atom) = atoms[i];
297} /* _ecore_x_atoms_init */
298
299/**
300 * Retrieves the atom value associated with the given name.
301 * @param name The given name.
302 * @return Associated atom value.
303 */
304EAPI Ecore_X_Atom
305ecore_x_atom_get(const char *name)
306{
307 if (!_ecore_x_disp)
308 return 0;
309
310 LOGFN(__FILE__, __LINE__, __FUNCTION__);
311 return XInternAtom(_ecore_x_disp, name, False);
312} /* ecore_x_atom_get */
313
314EAPI void
315ecore_x_atoms_get(const char **names,
316 int num,
317 Ecore_X_Atom *atoms)
318{
319 Atom *atoms_int;
320 int i;
321
322 if (!_ecore_x_disp)
323 return;
324
325 LOGFN(__FILE__, __LINE__, __FUNCTION__);
326 atoms_int = alloca(num * sizeof(Atom));
327 XInternAtoms(_ecore_x_disp, (char **)names, num, False, atoms_int);
328 for (i = 0; i < num; i++)
329 atoms[i] = atoms_int[i];
330} /* ecore_x_atoms_get */
331
332EAPI char *
333ecore_x_atom_name_get(Ecore_X_Atom atom)
334{
335 char *name;
336 char *xname;
337
338 if (!_ecore_x_disp)
339 return NULL;
340
341 LOGFN(__FILE__, __LINE__, __FUNCTION__);
342
343 xname = XGetAtomName(_ecore_x_disp, atom);
344 if (!xname)
345 return NULL;
346
347 name = strdup(xname);
348 XFree(xname);
349
350 return name;
351} /* ecore_x_atom_name_get */
352
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_composite.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_composite.c
new file mode 100644
index 0000000..43153ff
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_composite.c
@@ -0,0 +1,176 @@
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} /* _ecore_x_composite_init */
34
35EAPI Eina_Bool
36ecore_x_composite_query(void)
37{
38 LOGFN(__FILE__, __LINE__, __FUNCTION__);
39 return _composite_available;
40} /* ecore_x_composite_query */
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 } /* switch */
60 XCompositeRedirectWindow(_ecore_x_disp, win, update);
61#endif /* ifdef ECORE_XCOMPOSITE */
62} /* ecore_x_composite_redirect_window */
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 } /* switch */
82 XCompositeRedirectSubwindows(_ecore_x_disp, win, update);
83#endif /* ifdef ECORE_XCOMPOSITE */
84} /* ecore_x_composite_redirect_subwindows */
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 } /* switch */
104 XCompositeUnredirectWindow(_ecore_x_disp, win, update);
105#endif /* ifdef ECORE_XCOMPOSITE */
106} /* ecore_x_composite_unredirect_window */
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 } /* switch */
126 XCompositeUnredirectSubwindows(_ecore_x_disp, win, update);
127#endif /* ifdef ECORE_XCOMPOSITE */
128} /* ecore_x_composite_unredirect_subwindows */
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} /* ecore_x_composite_name_window_pixmap_get */
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} /* ecore_x_composite_render_window_enable */
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} /* ecore_x_composite_render_window_disable */
176
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_cursor.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_cursor.c
new file mode 100644
index 0000000..434505c
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_cursor.c
@@ -0,0 +1,246 @@
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} /* ecore_x_cursor_color_supported_get */
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} /* ecore_x_cursor_new */
204
205EAPI void
206ecore_x_cursor_free(Ecore_X_Cursor c)
207{
208 LOGFN(__FILE__, __LINE__, __FUNCTION__);
209 XFreeCursor(_ecore_x_disp, c);
210} /* ecore_x_cursor_free */
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} /* ecore_x_cursor_shape_get */
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} /* ecore_x_cursor_size_set */
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} /* ecore_x_cursor_size_get */
246
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_damage.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_damage.c
new file mode 100644
index 0000000..5e44d07
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_damage.c
@@ -0,0 +1,71 @@
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} /* _ecore_x_damage_init */
30
31EAPI Eina_Bool
32ecore_x_damage_query(void)
33{
34 return _damage_available;
35} /* ecore_x_damage_query */
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} /* ecore_x_damage_new */
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} /* ecore_x_damage_free */
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} /* ecore_x_damage_subtract */
71
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_dnd.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_dnd.c
new file mode 100644
index 0000000..7908584
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_dnd.c
@@ -0,0 +1,706 @@
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} /* _ecore_x_dnd_init */
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} /* _ecore_x_dnd_shutdown */
89
90static Eina_Bool
91_ecore_x_dnd_converter_copy(char *target __UNUSED__,
92 void *data,
93 int size,
94 void **data_ret,
95 int *size_ret,
96 Ecore_X_Atom *tprop __UNUSED__,
97 int *count __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} /* _ecore_x_dnd_converter_copy */
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} /* ecore_x_dnd_aware_set */
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} /* ecore_x_dnd_version_get */
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} /* ecore_x_dnd_type_isset */
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} /* ecore_x_dnd_type_set */
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} /* ecore_x_dnd_types_set */
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} /* ecore_x_dnd_actions_set */
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} /* _ecore_x_dnd_source_get */
394
395Ecore_X_DND_Target *
396_ecore_x_dnd_target_get(void)
397{
398 return _target;
399} /* _ecore_x_dnd_target_get */
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} /* ecore_x_dnd_begin */
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} /* ecore_x_dnd_drop */
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} /* ecore_x_dnd_send_status */
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} /* ecore_x_dnd_send_finished */
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} /* ecore_x_dnd_source_action_set */
573
574EAPI Ecore_X_Atom
575ecore_x_dnd_source_action_get(void)
576{
577 return _source->action;
578} /* ecore_x_dnd_source_action_get */
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} /* _ecore_x_dnd_drag */
705
706/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_dpms.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_dpms.c
new file mode 100644
index 0000000..74d5344
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_dpms.c
@@ -0,0 +1,247 @@
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} /* _ecore_x_dpms_init */
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} /* ecore_x_dpms_query */
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.
48 * @ingroup Ecore_X_DPMS_Group
49 */
50EAPI Eina_Bool
51ecore_x_dpms_capable_get(void)
52{
53#ifdef ECORE_XDPMS
54 LOGFN(__FILE__, __LINE__, __FUNCTION__);
55 return DPMSCapable(_ecore_x_disp) ? EINA_TRUE : EINA_FALSE;
56#else /* ifdef ECORE_XDPMS */
57 return EINA_FALSE;
58#endif /* ifdef ECORE_XDPMS */
59} /* ecore_x_dpms_capable_get */
60
61/**
62 * Checks the DPMS state of the display.
63 * @return @c 1 if DPMS is enabled, @c 0 otherwise.
64 * @ingroup Ecore_X_DPMS_Group
65 */
66EAPI Eina_Bool
67ecore_x_dpms_enabled_get(void)
68{
69#ifdef ECORE_XDPMS
70 unsigned char state;
71 unsigned short power_lvl;
72
73 LOGFN(__FILE__, __LINE__, __FUNCTION__);
74 DPMSInfo(_ecore_x_disp, &power_lvl, &state);
75 return state ? EINA_TRUE : EINA_FALSE;
76#else /* ifdef ECORE_XDPMS */
77 return EINA_FALSE;
78#endif /* ifdef ECORE_XDPMS */
79} /* ecore_x_dpms_enabled_get */
80
81/**
82 * Sets the DPMS state of the display.
83 * @param enabled @c 0 to disable DPMS characteristics of the server, enable it otherwise.
84 * @ingroup Ecore_X_DPMS_Group
85 */
86EAPI void
87ecore_x_dpms_enabled_set(int enabled)
88{
89#ifdef ECORE_XDPMS
90 LOGFN(__FILE__, __LINE__, __FUNCTION__);
91 if (enabled)
92 DPMSEnable(_ecore_x_disp);
93 else
94 DPMSDisable(_ecore_x_disp);
95
96#endif /* ifdef ECORE_XDPMS */
97} /* ecore_x_dpms_enabled_set */
98
99/**
100 * Gets the timeouts. The values are in unit of seconds.
101 * @param standby Amount of time of inactivity before standby mode will be invoked.
102 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
103 * @param off Amount of time of inactivity before the monitor is shut off.
104 * @ingroup Ecore_X_DPMS_Group
105 */
106EAPI void
107ecore_x_dpms_timeouts_get(unsigned int *standby,
108 unsigned int *suspend,
109 unsigned int *off)
110{
111#ifdef ECORE_XDPMS
112 LOGFN(__FILE__, __LINE__, __FUNCTION__);
113 DPMSGetTimeouts(_ecore_x_disp, (unsigned short *)standby,
114 (unsigned short *)suspend, (unsigned short *)off);
115#endif /* ifdef ECORE_XDPMS */
116} /* ecore_x_dpms_timeouts_get */
117
118/**
119 * Sets the timeouts. The values are in unit of seconds.
120 * @param standby Amount of time of inactivity before standby mode will be invoked.
121 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
122 * @param off Amount of time of inactivity before the monitor is shut off.
123 * @ingroup Ecore_X_DPMS_Group
124 */
125EAPI Eina_Bool
126ecore_x_dpms_timeouts_set(unsigned int standby,
127 unsigned int suspend,
128 unsigned int off)
129{
130#ifdef ECORE_XDPMS
131 LOGFN(__FILE__, __LINE__, __FUNCTION__);
132 return DPMSSetTimeouts(_ecore_x_disp, standby, suspend, off) ? EINA_TRUE : EINA_FALSE;
133#else /* ifdef ECORE_XDPMS */
134 return EINA_FALSE;
135#endif /* ifdef ECORE_XDPMS */
136} /* ecore_x_dpms_timeouts_set */
137
138/**
139 * Returns the amount of time of inactivity before standby mode is invoked.
140 * @return The standby timeout value.
141 * @ingroup Ecore_X_DPMS_Group
142 */
143EAPI unsigned int
144ecore_x_dpms_timeout_standby_get(void)
145{
146#ifdef ECORE_XDPMS
147 unsigned short standby, suspend, off;
148
149 LOGFN(__FILE__, __LINE__, __FUNCTION__);
150 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
151 return standby;
152#else /* ifdef ECORE_XDPMS */
153 return 0;
154#endif /* ifdef ECORE_XDPMS */
155} /* ecore_x_dpms_timeout_standby_get */
156
157/**
158 * Returns the amount of time of inactivity before the second level of
159 * power saving is invoked.
160 * @return The suspend timeout value.
161 * @ingroup Ecore_X_DPMS_Group
162 */
163EAPI unsigned int
164ecore_x_dpms_timeout_suspend_get(void)
165{
166#ifdef ECORE_XDPMS
167 unsigned short standby, suspend, off;
168
169 LOGFN(__FILE__, __LINE__, __FUNCTION__);
170 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
171 return suspend;
172#else /* ifdef ECORE_XDPMS */
173 return 0;
174#endif /* ifdef ECORE_XDPMS */
175} /* ecore_x_dpms_timeout_suspend_get */
176
177/**
178 * Returns the amount of time of inactivity before the third and final
179 * level of power saving is invoked.
180 * @return The off timeout value.
181 * @ingroup Ecore_X_DPMS_Group
182 */
183EAPI unsigned int
184ecore_x_dpms_timeout_off_get(void)
185{
186#ifdef ECORE_XDPMS
187 unsigned short standby, suspend, off;
188
189 LOGFN(__FILE__, __LINE__, __FUNCTION__);
190 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
191 return off;
192#else /* ifdef ECORE_XDPMS */
193 return 0;
194#endif /* ifdef ECORE_XDPMS */
195} /* ecore_x_dpms_timeout_off_get */
196
197/**
198 * Sets the standby timeout (in unit of seconds).
199 * @param new_standby Amount of time of inactivity before standby mode will be invoked.
200 * @ingroup Ecore_X_DPMS_Group
201 */
202EAPI void
203ecore_x_dpms_timeout_standby_set(unsigned int new_timeout)
204{
205#ifdef ECORE_XDPMS
206 unsigned short standby, suspend, off;
207
208 LOGFN(__FILE__, __LINE__, __FUNCTION__);
209 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
210 DPMSSetTimeouts(_ecore_x_disp, new_timeout, suspend, off);
211#endif /* ifdef ECORE_XDPMS */
212} /* ecore_x_dpms_timeout_standby_set */
213
214/**
215 * Sets the suspend timeout (in unit of seconds).
216 * @param suspend Amount of time of inactivity before the screen is placed into suspend mode.
217 * @ingroup Ecore_X_DPMS_Group
218 */
219EAPI void
220ecore_x_dpms_timeout_suspend_set(unsigned int new_timeout)
221{
222#ifdef ECORE_XDPMS
223 unsigned short standby, suspend, off;
224
225 LOGFN(__FILE__, __LINE__, __FUNCTION__);
226 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
227 DPMSSetTimeouts(_ecore_x_disp, standby, new_timeout, off);
228#endif /* ifdef ECORE_XDPMS */
229} /* ecore_x_dpms_timeout_suspend_set */
230
231/**
232 * Sets the off timeout (in unit of seconds).
233 * @param off Amount of time of inactivity before the monitor is shut off.
234 * @ingroup Ecore_X_DPMS_Group
235 */
236EAPI void
237ecore_x_dpms_timeout_off_set(unsigned int new_timeout)
238{
239#ifdef ECORE_XDPMS
240 unsigned short standby, suspend, off;
241
242 LOGFN(__FILE__, __LINE__, __FUNCTION__);
243 DPMSGetTimeouts(_ecore_x_disp, &standby, &suspend, &off);
244 DPMSSetTimeouts(_ecore_x_disp, standby, suspend, new_timeout);
245#endif /* ifdef ECORE_XDPMS */
246} /* ecore_x_dpms_timeout_off_set */
247
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_drawable.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_drawable.c
new file mode 100644
index 0000000..a64060b
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_drawable.c
@@ -0,0 +1,118 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include "ecore_x_private.h"
6
7/**
8 * @defgroup Ecore_X_Drawable_Group X Drawable Functions
9 *
10 * Functions that operate on drawables.
11 */
12
13/**
14 * Retrieves the geometry of the given drawable.
15 * @param d The given drawable.
16 * @param x Pointer to an integer into which the X position is to be stored.
17 * @param y Pointer to an integer into which the Y position is to be stored.
18 * @param w Pointer to an integer into which the width is to be stored.
19 * @param h Pointer to an integer into which the height is to be stored.
20 * @ingroup Ecore_X_Drawable_Group
21 */
22EAPI void
23ecore_x_drawable_geometry_get(Ecore_X_Drawable d,
24 int *x,
25 int *y,
26 int *w,
27 int *h)
28{
29 Window dummy_win;
30 int ret_x, ret_y;
31 unsigned int ret_w, ret_h, dummy_border, dummy_depth;
32
33 LOGFN(__FILE__, __LINE__, __FUNCTION__);
34 if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &ret_x, &ret_y,
35 &ret_w, &ret_h, &dummy_border, &dummy_depth))
36 {
37 ret_x = 0;
38 ret_y = 0;
39 ret_w = 0;
40 ret_h = 0;
41 }
42
43 if (x)
44 *x = ret_x;
45
46 if (y)
47 *y = ret_y;
48
49 if (w)
50 *w = (int)ret_w;
51
52 if (h)
53 *h = (int)ret_h;
54} /* ecore_x_drawable_geometry_get */
55
56/**
57 * Retrieves the width of the border of the given drawable.
58 * @param d The given drawable.
59 * @return The border width of the given drawable.
60 * @ingroup Ecore_X_Drawable_Group
61 */
62EAPI int
63ecore_x_drawable_border_width_get(Ecore_X_Drawable d)
64{
65 Window dummy_win;
66 int dummy_x, dummy_y;
67 unsigned int dummy_w, dummy_h, border_ret, dummy_depth;
68
69 LOGFN(__FILE__, __LINE__, __FUNCTION__);
70 if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &dummy_x, &dummy_y,
71 &dummy_w, &dummy_h, &border_ret, &dummy_depth))
72 border_ret = 0;
73
74 return (int)border_ret;
75} /* ecore_x_drawable_border_width_get */
76
77/**
78 * Retrieves the depth of the given drawable.
79 * @param d The given drawable.
80 * @return The depth of the given drawable.
81 * @ingroup Ecore_X_Drawable_Group
82 */
83EAPI int
84ecore_x_drawable_depth_get(Ecore_X_Drawable d)
85{
86 Window dummy_win;
87 int dummy_x, dummy_y;
88 unsigned int dummy_w, dummy_h, dummy_border, depth_ret;
89
90 LOGFN(__FILE__, __LINE__, __FUNCTION__);
91 if (!XGetGeometry(_ecore_x_disp, d, &dummy_win, &dummy_x, &dummy_y,
92 &dummy_w, &dummy_h, &dummy_border, &depth_ret))
93 depth_ret = 0;
94
95 return (int)depth_ret;
96} /* ecore_x_drawable_depth_get */
97
98/**
99 * Fill the specified rectangle on a drawable.
100 * @param d The given drawable.
101 * @param gc The graphic context that controls the fill rules.
102 * @param x The X coordinate of the top-left corner of the rectangle.
103 * @param y The Y coordinate of the top-left corner of the rectangle.
104 * @param width The width of the rectangle.
105 * @param height The height of the rectangle.
106 */
107EAPI void
108ecore_x_drawable_rectangle_fill(Ecore_X_Drawable d,
109 Ecore_X_GC gc,
110 int x,
111 int y,
112 int width,
113 int height)
114{
115 LOGFN(__FILE__, __LINE__, __FUNCTION__);
116 XFillRectangle(_ecore_x_disp, d, gc, x, y, width, height);
117} /* ecore_x_drawable_rectangle_fill */
118
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_e.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_e.c
new file mode 100644
index 0000000..d357c9b
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_e.c
@@ -0,0 +1,1060 @@
1/*
2 * OLD E hints
3 */
4
5#ifdef HAVE_CONFIG_H
6# include <config.h>
7#endif /* ifdef HAVE_CONFIG_H */
8
9#include "Ecore.h"
10#include "ecore_x_private.h"
11#include "Ecore_X.h"
12#include "Ecore_X_Atoms.h"
13
14EAPI void
15ecore_x_e_init(void)
16{
17} /* ecore_x_e_init */
18
19EAPI void
20ecore_x_e_frame_size_set(Ecore_X_Window win,
21 int fl,
22 int fr,
23 int ft,
24 int fb)
25{
26 unsigned int frames[4];
27
28 LOGFN(__FILE__, __LINE__, __FUNCTION__);
29 frames[0] = fl;
30 frames[1] = fr;
31 frames[2] = ft;
32 frames[3] = fb;
33 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_FRAME_SIZE, frames, 4);
34} /* ecore_x_e_frame_size_set */
35
36EAPI void
37ecore_x_e_virtual_keyboard_set(Ecore_X_Window win,
38 unsigned int is_keyboard)
39{
40 LOGFN(__FILE__, __LINE__, __FUNCTION__);
41 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_VIRTUAL_KEYBOARD,
42 &is_keyboard, 1);
43} /* ecore_x_e_virtual_keyboard_set */
44
45EAPI Eina_Bool
46ecore_x_e_virtual_keyboard_get(Ecore_X_Window win)
47{
48 unsigned int val;
49
50 LOGFN(__FILE__, __LINE__, __FUNCTION__);
51 if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_E_VIRTUAL_KEYBOARD,
52 &val, 1))
53 return EINA_FALSE;
54
55 return val ? EINA_TRUE : EINA_FALSE;
56} /* ecore_x_e_virtual_keyboard_get */
57
58static Ecore_X_Virtual_Keyboard_State
59_ecore_x_e_vkbd_state_get(Ecore_X_Atom atom)
60{
61 if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_ON)
62 return ECORE_X_VIRTUAL_KEYBOARD_STATE_ON;
63
64 if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_OFF)
65 return ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF;
66
67 if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_ALPHA)
68 return ECORE_X_VIRTUAL_KEYBOARD_STATE_ALPHA;
69
70 if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_NUMERIC)
71 return ECORE_X_VIRTUAL_KEYBOARD_STATE_NUMERIC;
72
73 if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PIN)
74 return ECORE_X_VIRTUAL_KEYBOARD_STATE_PIN;
75
76 if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PHONE_NUMBER)
77 return ECORE_X_VIRTUAL_KEYBOARD_STATE_PHONE_NUMBER;
78
79 if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_HEX)
80 return ECORE_X_VIRTUAL_KEYBOARD_STATE_HEX;
81
82 if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_TERMINAL)
83 return ECORE_X_VIRTUAL_KEYBOARD_STATE_TERMINAL;
84
85 if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PASSWORD)
86 return ECORE_X_VIRTUAL_KEYBOARD_STATE_PASSWORD;
87
88 if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_IP)
89 return ECORE_X_VIRTUAL_KEYBOARD_STATE_IP;
90
91 if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_HOST)
92 return ECORE_X_VIRTUAL_KEYBOARD_STATE_HOST;
93
94 if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_FILE)
95 return ECORE_X_VIRTUAL_KEYBOARD_STATE_FILE;
96
97 if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_URL)
98 return ECORE_X_VIRTUAL_KEYBOARD_STATE_URL;
99
100 if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_KEYPAD)
101 return ECORE_X_VIRTUAL_KEYBOARD_STATE_KEYPAD;
102
103 if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_J2ME)
104 return ECORE_X_VIRTUAL_KEYBOARD_STATE_J2ME;
105
106 return ECORE_X_VIRTUAL_KEYBOARD_STATE_UNKNOWN;
107} /* _ecore_x_e_vkbd_state_get */
108
109static Ecore_X_Atom
110_ecore_x_e_vkbd_atom_get(Ecore_X_Virtual_Keyboard_State state)
111{
112 switch (state)
113 {
114 case ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF:
115 return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_OFF;
116
117 case ECORE_X_VIRTUAL_KEYBOARD_STATE_ON:
118 return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_ON;
119
120 case ECORE_X_VIRTUAL_KEYBOARD_STATE_ALPHA:
121 return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_ALPHA;
122
123 case ECORE_X_VIRTUAL_KEYBOARD_STATE_NUMERIC:
124 return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_NUMERIC;
125
126 case ECORE_X_VIRTUAL_KEYBOARD_STATE_PIN:
127 return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PIN;
128
129 case ECORE_X_VIRTUAL_KEYBOARD_STATE_PHONE_NUMBER:
130 return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PHONE_NUMBER;
131
132 case ECORE_X_VIRTUAL_KEYBOARD_STATE_HEX:
133 return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_HEX;
134
135 case ECORE_X_VIRTUAL_KEYBOARD_STATE_TERMINAL:
136 return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_TERMINAL;
137
138 case ECORE_X_VIRTUAL_KEYBOARD_STATE_PASSWORD:
139 return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PASSWORD;
140
141 case ECORE_X_VIRTUAL_KEYBOARD_STATE_IP:
142 return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_IP;
143
144 case ECORE_X_VIRTUAL_KEYBOARD_STATE_HOST:
145 return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_HOST;
146
147 case ECORE_X_VIRTUAL_KEYBOARD_STATE_FILE:
148 return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_FILE;
149
150 case ECORE_X_VIRTUAL_KEYBOARD_STATE_URL:
151 return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_URL;
152
153 case ECORE_X_VIRTUAL_KEYBOARD_STATE_KEYPAD:
154 return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_KEYPAD;
155
156 case ECORE_X_VIRTUAL_KEYBOARD_STATE_J2ME:
157 return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_J2ME;
158
159 default: break;
160 } /* switch */
161 return 0;
162} /* _ecore_x_e_vkbd_atom_get */
163
164EAPI void
165ecore_x_e_virtual_keyboard_state_set(Ecore_X_Window win,
166 Ecore_X_Virtual_Keyboard_State state)
167{
168 Ecore_X_Atom atom = 0;
169
170 LOGFN(__FILE__, __LINE__, __FUNCTION__);
171 atom = _ecore_x_e_vkbd_atom_get(state);
172 ecore_x_window_prop_atom_set(win, ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE,
173 &atom, 1);
174} /* ecore_x_e_virtual_keyboard_state_set */
175
176EAPI Ecore_X_Virtual_Keyboard_State
177ecore_x_e_virtual_keyboard_state_get(Ecore_X_Window win)
178{
179 Ecore_X_Atom atom;
180
181 LOGFN(__FILE__, __LINE__, __FUNCTION__);
182 if (!ecore_x_window_prop_atom_get(win, ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE,
183 &atom, 1))
184 return ECORE_X_VIRTUAL_KEYBOARD_STATE_UNKNOWN;
185
186 return _ecore_x_e_vkbd_state_get(atom);
187} /* ecore_x_e_virtual_keyboard_state_get */
188
189EAPI void
190ecore_x_e_virtual_keyboard_state_send(Ecore_X_Window win,
191 Ecore_X_Virtual_Keyboard_State state)
192{
193 LOGFN(__FILE__, __LINE__, __FUNCTION__);
194 ecore_x_client_message32_send(win, ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE,
195 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
196 _ecore_x_e_vkbd_atom_get(state),
197 0, 0, 0, 0);
198} /* ecore_x_e_virtual_keyboard_state_send */
199
200static Ecore_X_Atom
201_ecore_x_e_illume_atom_get(Ecore_X_Illume_Mode mode)
202{
203 switch (mode)
204 {
205 case ECORE_X_ILLUME_MODE_SINGLE:
206 return ECORE_X_ATOM_E_ILLUME_MODE_SINGLE;
207
208 case ECORE_X_ILLUME_MODE_DUAL_TOP:
209 return ECORE_X_ATOM_E_ILLUME_MODE_DUAL_TOP;
210
211 case ECORE_X_ILLUME_MODE_DUAL_LEFT:
212 return ECORE_X_ATOM_E_ILLUME_MODE_DUAL_LEFT;
213
214 default:
215 break;
216 } /* switch */
217 return ECORE_X_ILLUME_MODE_UNKNOWN;
218} /* _ecore_x_e_illume_atom_get */
219
220static Ecore_X_Illume_Mode
221_ecore_x_e_illume_mode_get(Ecore_X_Atom atom)
222{
223 if (atom == ECORE_X_ATOM_E_ILLUME_MODE_SINGLE)
224 return ECORE_X_ILLUME_MODE_SINGLE;
225
226 if (atom == ECORE_X_ATOM_E_ILLUME_MODE_DUAL_TOP)
227 return ECORE_X_ILLUME_MODE_DUAL_TOP;
228
229 if (atom == ECORE_X_ATOM_E_ILLUME_MODE_DUAL_LEFT)
230 return ECORE_X_ILLUME_MODE_DUAL_LEFT;
231
232 return ECORE_X_ILLUME_MODE_UNKNOWN;
233} /* _ecore_x_e_illume_mode_get */
234
235EAPI void
236ecore_x_e_illume_zone_set(Ecore_X_Window win,
237 Ecore_X_Window zone)
238{
239 LOGFN(__FILE__, __LINE__, __FUNCTION__);
240 ecore_x_window_prop_window_set(win, ECORE_X_ATOM_E_ILLUME_ZONE,
241 &zone, 1);
242} /* ecore_x_e_illume_zone_set */
243
244EAPI Ecore_X_Window
245ecore_x_e_illume_zone_get(Ecore_X_Window win)
246{
247 Ecore_X_Window zone;
248
249 LOGFN(__FILE__, __LINE__, __FUNCTION__);
250 if (!ecore_x_window_prop_window_get(win, ECORE_X_ATOM_E_ILLUME_ZONE,
251 &zone, 1))
252 return 0;
253
254 return zone;
255} /* ecore_x_e_illume_zone_get */
256
257EAPI void
258ecore_x_e_illume_zone_list_set(Ecore_X_Window win,
259 Ecore_X_Window *zones,
260 unsigned int n_zones)
261{
262 LOGFN(__FILE__, __LINE__, __FUNCTION__);
263 ecore_x_window_prop_window_set(win, ECORE_X_ATOM_E_ILLUME_ZONE_LIST,
264 zones, n_zones);
265} /* ecore_x_e_illume_zone_list_set */
266
267EAPI void
268ecore_x_e_illume_conformant_set(Ecore_X_Window win,
269 unsigned int is_conformant)
270{
271 LOGFN(__FILE__, __LINE__, __FUNCTION__);
272 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_ILLUME_CONFORMANT,
273 &is_conformant, 1);
274} /* ecore_x_e_illume_conformant_set */
275
276EAPI Eina_Bool
277ecore_x_e_illume_conformant_get(Ecore_X_Window win)
278{
279 unsigned int val = 0;
280
281 LOGFN(__FILE__, __LINE__, __FUNCTION__);
282 if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_E_ILLUME_CONFORMANT,
283 &val, 1))
284 return EINA_FALSE;
285
286 return val ? EINA_TRUE : EINA_FALSE;
287} /* ecore_x_e_illume_conformant_get */
288
289EAPI void
290ecore_x_e_illume_mode_set(Ecore_X_Window win,
291 Ecore_X_Illume_Mode mode)
292{
293 Ecore_X_Atom atom = 0;
294
295 LOGFN(__FILE__, __LINE__, __FUNCTION__);
296 atom = _ecore_x_e_illume_atom_get(mode);
297 ecore_x_window_prop_atom_set(win, ECORE_X_ATOM_E_ILLUME_MODE,
298 &atom, 1);
299} /* ecore_x_e_illume_mode_set */
300
301EAPI Ecore_X_Illume_Mode
302ecore_x_e_illume_mode_get(Ecore_X_Window win)
303{
304 Ecore_X_Atom atom = 0;
305
306 LOGFN(__FILE__, __LINE__, __FUNCTION__);
307 if (!ecore_x_window_prop_atom_get(win, ECORE_X_ATOM_E_ILLUME_MODE, &atom, 1))
308 return ECORE_X_ILLUME_MODE_UNKNOWN;
309
310 return _ecore_x_e_illume_mode_get(atom);
311} /* ecore_x_e_illume_mode_get */
312
313EAPI void
314ecore_x_e_illume_mode_send(Ecore_X_Window win,
315 Ecore_X_Illume_Mode mode)
316{
317 LOGFN(__FILE__, __LINE__, __FUNCTION__);
318 ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_MODE,
319 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
320 _ecore_x_e_illume_atom_get(mode),
321 0, 0, 0, 0);
322} /* ecore_x_e_illume_mode_send */
323
324EAPI void
325ecore_x_e_illume_focus_back_send(Ecore_X_Window win)
326{
327 LOGFN(__FILE__, __LINE__, __FUNCTION__);
328 ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_FOCUS_BACK,
329 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
330 1, 0, 0, 0, 0);
331} /* ecore_x_e_illume_focus_back_send */
332
333EAPI void
334ecore_x_e_illume_focus_forward_send(Ecore_X_Window win)
335{
336 LOGFN(__FILE__, __LINE__, __FUNCTION__);
337 ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_FOCUS_FORWARD,
338 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
339 1, 0, 0, 0, 0);
340} /* ecore_x_e_illume_focus_forward_send */
341
342EAPI void
343ecore_x_e_illume_focus_home_send(Ecore_X_Window win)
344{
345 LOGFN(__FILE__, __LINE__, __FUNCTION__);
346 ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_FOCUS_HOME,
347 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
348 1, 0, 0, 0, 0);
349} /* ecore_x_e_illume_focus_home_send */
350
351EAPI void
352ecore_x_e_illume_close_send(Ecore_X_Window win)
353{
354 LOGFN(__FILE__, __LINE__, __FUNCTION__);
355 ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_CLOSE,
356 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
357 1, 0, 0, 0, 0);
358} /* ecore_x_e_illume_close_send */
359
360EAPI void
361ecore_x_e_illume_home_new_send(Ecore_X_Window win)
362{
363 LOGFN(__FILE__, __LINE__, __FUNCTION__);
364 ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_HOME_NEW,
365 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
366 1, 0, 0, 0, 0);
367} /* ecore_x_e_illume_home_new_send */
368
369EAPI void
370ecore_x_e_illume_home_del_send(Ecore_X_Window win)
371{
372 LOGFN(__FILE__, __LINE__, __FUNCTION__);
373 ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_HOME_DEL,
374 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
375 1, 0, 0, 0, 0);
376} /* ecore_x_e_illume_home_del_send */
377
378EAPI void
379ecore_x_e_illume_drag_set(Ecore_X_Window win,
380 unsigned int drag)
381{
382 LOGFN(__FILE__, __LINE__, __FUNCTION__);
383 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_ILLUME_DRAG, &drag, 1);
384} /* ecore_x_e_illume_drag_set */
385
386EAPI Eina_Bool
387ecore_x_e_illume_drag_get(Ecore_X_Window win)
388{
389 unsigned int val = 0;
390
391 LOGFN(__FILE__, __LINE__, __FUNCTION__);
392 if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_E_ILLUME_DRAG, &val, 1))
393 return EINA_FALSE;
394
395 return val ? EINA_TRUE : EINA_FALSE;
396} /* ecore_x_e_illume_drag_get */
397
398EAPI void
399ecore_x_e_illume_drag_locked_set(Ecore_X_Window win,
400 unsigned int is_locked)
401{
402 LOGFN(__FILE__, __LINE__, __FUNCTION__);
403 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_ILLUME_DRAG_LOCKED,
404 &is_locked, 1);
405} /* ecore_x_e_illume_drag_locked_set */
406
407EAPI Eina_Bool
408ecore_x_e_illume_drag_locked_get(Ecore_X_Window win)
409{
410 unsigned int val = 0;
411
412 LOGFN(__FILE__, __LINE__, __FUNCTION__);
413 if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_E_ILLUME_DRAG_LOCKED,
414 &val, 1))
415 return EINA_FALSE;
416
417 return val ? EINA_TRUE : EINA_FALSE;
418} /* ecore_x_e_illume_drag_locked_get */
419
420EAPI void
421ecore_x_e_illume_drag_start_send(Ecore_X_Window win)
422{
423 LOGFN(__FILE__, __LINE__, __FUNCTION__);
424 ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_DRAG_START,
425 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
426 1, 0, 0, 0, 0);
427} /* ecore_x_e_illume_drag_start_send */
428
429EAPI void
430ecore_x_e_illume_drag_end_send(Ecore_X_Window win)
431{
432 LOGFN(__FILE__, __LINE__, __FUNCTION__);
433 ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_DRAG_END,
434 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
435 1, 0, 0, 0, 0);
436} /* ecore_x_e_illume_drag_end_send */
437
438EAPI void
439ecore_x_e_illume_indicator_geometry_set(Ecore_X_Window win,
440 int x,
441 int y,
442 int w,
443 int h)
444{
445 unsigned int geom[4];
446
447 LOGFN(__FILE__, __LINE__, __FUNCTION__);
448 geom[0] = x;
449 geom[1] = y;
450 geom[2] = w;
451 geom[3] = h;
452 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_ILLUME_INDICATOR_GEOMETRY,
453 geom, 4);
454} /* ecore_x_e_illume_indicator_geometry_set */
455
456EAPI Eina_Bool
457ecore_x_e_illume_indicator_geometry_get(Ecore_X_Window win,
458 int *x,
459 int *y,
460 int *w,
461 int *h)
462{
463 int ret = 0;
464 unsigned int geom[4];
465
466 LOGFN(__FILE__, __LINE__, __FUNCTION__);
467 ret =
468 ecore_x_window_prop_card32_get(win,
469 ECORE_X_ATOM_E_ILLUME_INDICATOR_GEOMETRY,
470 geom, 4);
471 if (ret != 4)
472 return EINA_FALSE;
473
474 if (x)
475 *x = geom[0];
476
477 if (y)
478 *y = geom[1];
479
480 if (w)
481 *w = geom[2];
482
483 if (h)
484 *h = geom[3];
485
486 return EINA_TRUE;
487} /* ecore_x_e_illume_indicator_geometry_get */
488
489EAPI void
490ecore_x_e_illume_softkey_geometry_set(Ecore_X_Window win,
491 int x,
492 int y,
493 int w,
494 int h)
495{
496 unsigned int geom[4];
497
498 LOGFN(__FILE__, __LINE__, __FUNCTION__);
499 geom[0] = x;
500 geom[1] = y;
501 geom[2] = w;
502 geom[3] = h;
503 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_ILLUME_SOFTKEY_GEOMETRY,
504 geom, 4);
505} /* ecore_x_e_illume_softkey_geometry_set */
506
507EAPI Eina_Bool
508ecore_x_e_illume_softkey_geometry_get(Ecore_X_Window win,
509 int *x,
510 int *y,
511 int *w,
512 int *h)
513{
514 int ret = 0;
515 unsigned int geom[4];
516
517 LOGFN(__FILE__, __LINE__, __FUNCTION__);
518 ret =
519 ecore_x_window_prop_card32_get(win,
520 ECORE_X_ATOM_E_ILLUME_SOFTKEY_GEOMETRY,
521 geom, 4);
522 if (ret != 4)
523 return EINA_FALSE;
524
525 if (x)
526 *x = geom[0];
527
528 if (y)
529 *y = geom[1];
530
531 if (w)
532 *w = geom[2];
533
534 if (h)
535 *h = geom[3];
536
537 return EINA_TRUE;
538} /* ecore_x_e_illume_softkey_geometry_get */
539
540EAPI void
541ecore_x_e_illume_keyboard_geometry_set(Ecore_X_Window win,
542 int x,
543 int y,
544 int w,
545 int h)
546{
547 unsigned int geom[4];
548
549 LOGFN(__FILE__, __LINE__, __FUNCTION__);
550 geom[0] = x;
551 geom[1] = y;
552 geom[2] = w;
553 geom[3] = h;
554 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_ILLUME_KEYBOARD_GEOMETRY,
555 geom, 4);
556} /* ecore_x_e_illume_keyboard_geometry_set */
557
558EAPI Eina_Bool
559ecore_x_e_illume_keyboard_geometry_get(Ecore_X_Window win,
560 int *x,
561 int *y,
562 int *w,
563 int *h)
564{
565 int ret = 0;
566 unsigned int geom[4];
567
568 LOGFN(__FILE__, __LINE__, __FUNCTION__);
569 ret =
570 ecore_x_window_prop_card32_get(win,
571 ECORE_X_ATOM_E_ILLUME_KEYBOARD_GEOMETRY,
572 geom, 4);
573 if (ret != 4)
574 return EINA_FALSE;
575
576 if (x)
577 *x = geom[0];
578
579 if (y)
580 *y = geom[1];
581
582 if (w)
583 *w = geom[2];
584
585 if (h)
586 *h = geom[3];
587
588 return EINA_TRUE;
589} /* ecore_x_e_illume_keyboard_geometry_get */
590
591static Ecore_X_Atom
592_ecore_x_e_quickpanel_atom_get(Ecore_X_Illume_Quickpanel_State state)
593{
594 switch (state)
595 {
596 case ECORE_X_ILLUME_QUICKPANEL_STATE_ON:
597 return ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON;
598
599 case ECORE_X_ILLUME_QUICKPANEL_STATE_OFF:
600 return ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF;
601
602 default:
603 break;
604 } /* switch */
605 return 0;
606} /* _ecore_x_e_quickpanel_atom_get */
607
608static Ecore_X_Illume_Quickpanel_State
609_ecore_x_e_quickpanel_state_get(Ecore_X_Atom atom)
610{
611 if (atom == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON)
612 return ECORE_X_ILLUME_QUICKPANEL_STATE_ON;
613
614 if (atom == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF)
615 return ECORE_X_ILLUME_QUICKPANEL_STATE_OFF;
616
617 return ECORE_X_ILLUME_QUICKPANEL_STATE_UNKNOWN;
618} /* _ecore_x_e_quickpanel_state_get */
619
620EAPI void
621ecore_x_e_illume_quickpanel_set(Ecore_X_Window win,
622 unsigned int is_quickpanel)
623{
624 LOGFN(__FILE__, __LINE__, __FUNCTION__);
625 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_ILLUME_QUICKPANEL,
626 &is_quickpanel, 1);
627} /* ecore_x_e_illume_quickpanel_set */
628
629EAPI Eina_Bool
630ecore_x_e_illume_quickpanel_get(Ecore_X_Window win)
631{
632 unsigned int val = 0;
633
634 LOGFN(__FILE__, __LINE__, __FUNCTION__);
635 if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_E_ILLUME_QUICKPANEL,
636 &val, 1))
637 return EINA_FALSE;
638
639 return val ? EINA_TRUE : EINA_FALSE;
640} /* ecore_x_e_illume_quickpanel_get */
641
642EAPI void
643ecore_x_e_illume_quickpanel_state_set(Ecore_X_Window win,
644 Ecore_X_Illume_Quickpanel_State state)
645{
646 Ecore_X_Atom atom = 0;
647
648 LOGFN(__FILE__, __LINE__, __FUNCTION__);
649 atom = _ecore_x_e_quickpanel_atom_get(state);
650 ecore_x_window_prop_atom_set(win, ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE,
651 &atom, 1);
652} /* ecore_x_e_illume_quickpanel_state_set */
653
654EAPI Ecore_X_Illume_Quickpanel_State
655ecore_x_e_illume_quickpanel_state_get(Ecore_X_Window win)
656{
657 Ecore_X_Atom atom;
658
659 LOGFN(__FILE__, __LINE__, __FUNCTION__);
660 if (!ecore_x_window_prop_atom_get(win,
661 ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE,
662 &atom, 1))
663 return ECORE_X_ILLUME_QUICKPANEL_STATE_UNKNOWN;
664
665 return _ecore_x_e_quickpanel_state_get(atom);
666} /* ecore_x_e_illume_quickpanel_state_get */
667
668EAPI void
669ecore_x_e_illume_quickpanel_state_send(Ecore_X_Window win,
670 Ecore_X_Illume_Quickpanel_State state)
671{
672 LOGFN(__FILE__, __LINE__, __FUNCTION__);
673 ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE,
674 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
675 _ecore_x_e_quickpanel_atom_get(state),
676 0, 0, 0, 0);
677} /* ecore_x_e_illume_quickpanel_state_send */
678
679EAPI void
680ecore_x_e_illume_quickpanel_state_toggle(Ecore_X_Window win)
681{
682 LOGFN(__FILE__, __LINE__, __FUNCTION__);
683 ecore_x_client_message32_send(win,
684 ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE_TOGGLE,
685 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
686 0, 0, 0, 0, 0);
687} /* ecore_x_e_illume_quickpanel_state_toggle */
688
689EAPI void
690ecore_x_e_illume_quickpanel_priority_major_set(Ecore_X_Window win,
691 unsigned int priority)
692{
693 LOGFN(__FILE__, __LINE__, __FUNCTION__);
694 ecore_x_window_prop_card32_set(win,
695 ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MAJOR,
696 &priority, 1);
697} /* ecore_x_e_illume_quickpanel_priority_major_set */
698
699EAPI int
700ecore_x_e_illume_quickpanel_priority_major_get(Ecore_X_Window win)
701{
702 unsigned int val = 0;
703
704 LOGFN(__FILE__, __LINE__, __FUNCTION__);
705 if (!ecore_x_window_prop_card32_get(win,
706 ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MAJOR,
707 &val, 1))
708 return 0;
709
710 return val;
711} /* ecore_x_e_illume_quickpanel_priority_major_get */
712
713EAPI void
714ecore_x_e_illume_quickpanel_priority_minor_set(Ecore_X_Window win,
715 unsigned int priority)
716{
717 LOGFN(__FILE__, __LINE__, __FUNCTION__);
718 ecore_x_window_prop_card32_set(win,
719 ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MINOR,
720 &priority, 1);
721} /* ecore_x_e_illume_quickpanel_priority_minor_set */
722
723EAPI int
724ecore_x_e_illume_quickpanel_priority_minor_get(Ecore_X_Window win)
725{
726 unsigned int val = 0;
727
728 LOGFN(__FILE__, __LINE__, __FUNCTION__);
729 if (!ecore_x_window_prop_card32_get(win,
730 ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MINOR,
731 &val, 1))
732 return 0;
733
734 return val;
735} /* ecore_x_e_illume_quickpanel_priority_minor_get */
736
737EAPI void
738ecore_x_e_illume_quickpanel_zone_set(Ecore_X_Window win,
739 unsigned int zone)
740{
741 LOGFN(__FILE__, __LINE__, __FUNCTION__);
742 ecore_x_window_prop_card32_set(win,
743 ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ZONE,
744 &zone, 1);
745} /* ecore_x_e_illume_quickpanel_zone_set */
746
747EAPI int
748ecore_x_e_illume_quickpanel_zone_get(Ecore_X_Window win)
749{
750 unsigned int val = 0;
751
752 LOGFN(__FILE__, __LINE__, __FUNCTION__);
753 if (!ecore_x_window_prop_card32_get(win,
754 ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ZONE,
755 &val, 1))
756 return 0;
757
758 return val;
759} /* ecore_x_e_illume_quickpanel_zone_get */
760
761EAPI void
762ecore_x_e_illume_quickpanel_position_update_send(Ecore_X_Window win)
763{
764 LOGFN(__FILE__, __LINE__, __FUNCTION__);
765 ecore_x_client_message32_send(win,
766 ECORE_X_ATOM_E_ILLUME_QUICKPANEL_POSITION_UPDATE,
767 ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
768 1, 0, 0, 0, 0);
769} /* ecore_x_e_illume_quickpanel_position_update_send */
770
771EAPI void
772ecore_x_e_comp_sync_counter_set(Ecore_X_Window win,
773 Ecore_X_Sync_Counter counter)
774{
775 LOGFN(__FILE__, __LINE__, __FUNCTION__);
776 if (counter)
777 ecore_x_window_prop_xid_set(win, ECORE_X_ATOM_E_COMP_SYNC_COUNTER,
778 ECORE_X_ATOM_CARDINAL, &counter, 1);
779 else
780 ecore_x_window_prop_property_del(win, ECORE_X_ATOM_E_COMP_SYNC_COUNTER);
781} /* ecore_x_e_comp_sync_counter_set */
782
783EAPI Ecore_X_Sync_Counter
784ecore_x_e_comp_sync_counter_get(Ecore_X_Window win)
785{
786 int ret = 0;
787 Ecore_X_Sync_Counter counter = 0;
788
789 LOGFN(__FILE__, __LINE__, __FUNCTION__);
790 ret =
791 ecore_x_window_prop_xid_get(win,
792 ECORE_X_ATOM_E_COMP_SYNC_COUNTER,
793 ECORE_X_ATOM_CARDINAL,
794 &counter, 1);
795 if (ret != 1)
796 return 0;
797
798 return counter;
799} /* ecore_x_e_comp_sync_counter_get */
800
801EAPI void
802ecore_x_e_comp_sync_draw_done_send(Ecore_X_Window root,
803 Ecore_X_Window win)
804{
805 XEvent xev;
806
807 LOGFN(__FILE__, __LINE__, __FUNCTION__);
808 if (!root)
809 root = DefaultRootWindow(_ecore_x_disp);
810
811 xev.xclient.type = ClientMessage;
812 xev.xclient.display = _ecore_x_disp;
813 xev.xclient.window = win;
814 xev.xclient.message_type = ECORE_X_ATOM_E_COMP_SYNC_DRAW_DONE;
815 xev.xclient.format = 32;
816 xev.xclient.data.l[0] = win;
817 xev.xclient.data.l[1] = 0; // version
818 xev.xclient.data.l[2] = 0; // later
819 xev.xclient.data.l[3] = 0; // later
820 xev.xclient.data.l[4] = 0; // later
821
822 XSendEvent(_ecore_x_disp, root, False,
823 SubstructureRedirectMask | SubstructureNotifyMask,
824 &xev);
825} /* ecore_x_e_comp_sync_draw_done_send */
826
827EAPI void
828ecore_x_e_comp_sync_draw_size_done_send(Ecore_X_Window root,
829 Ecore_X_Window win,
830 int w,
831 int h)
832{
833 XEvent xev;
834
835 LOGFN(__FILE__, __LINE__, __FUNCTION__);
836 if (!root)
837 root = DefaultRootWindow(_ecore_x_disp);
838
839 xev.xclient.type = ClientMessage;
840 xev.xclient.display = _ecore_x_disp;
841 xev.xclient.window = win;
842 xev.xclient.message_type = ECORE_X_ATOM_E_COMP_SYNC_DRAW_DONE;
843 xev.xclient.format = 32;
844 xev.xclient.data.l[0] = win;
845 xev.xclient.data.l[1] = 1; // version
846 xev.xclient.data.l[2] = w; // win width at draw time
847 xev.xclient.data.l[3] = h; // win height at draw time
848 xev.xclient.data.l[4] = 0; // later
849
850 XSendEvent(_ecore_x_disp, root, False,
851 SubstructureRedirectMask | SubstructureNotifyMask,
852 &xev);
853} /* ecore_x_e_comp_sync_draw_done_send */
854
855EAPI void
856ecore_x_e_comp_sync_supported_set(Ecore_X_Window root,
857 Eina_Bool enabled)
858{
859 Ecore_X_Window win;
860
861 if (!root)
862 root = DefaultRootWindow(_ecore_x_disp);
863
864 LOGFN(__FILE__, __LINE__, __FUNCTION__);
865 if (enabled)
866 {
867 win = ecore_x_window_new(root, 1, 2, 3, 4);
868 ecore_x_window_prop_xid_set(win, ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED,
869 ECORE_X_ATOM_WINDOW, &win, 1);
870 ecore_x_window_prop_xid_set(root, ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED,
871 ECORE_X_ATOM_WINDOW, &win, 1);
872 }
873 else
874 {
875 int ret;
876
877 ret =
878 ecore_x_window_prop_xid_get(root,
879 ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED,
880 ECORE_X_ATOM_WINDOW,
881 &win, 1);
882 if ((ret == 1) && (win))
883 {
884 ecore_x_window_prop_property_del(
885 root,
886 ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED);
887 ecore_x_window_free(win);
888 }
889 }
890} /* ecore_x_e_comp_sync_supported_set */
891
892EAPI Eina_Bool
893ecore_x_e_comp_sync_supported_get(Ecore_X_Window root)
894{
895 Ecore_X_Window win, win2;
896 int ret;
897
898 LOGFN(__FILE__, __LINE__, __FUNCTION__);
899 if (!root)
900 root = DefaultRootWindow(_ecore_x_disp);
901
902 ret =
903 ecore_x_window_prop_xid_get(root,
904 ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED,
905 ECORE_X_ATOM_WINDOW,
906 &win, 1);
907 if ((ret == 1) && (win))
908 {
909 ret =
910 ecore_x_window_prop_xid_get(win,
911 ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED,
912 ECORE_X_ATOM_WINDOW,
913 &win2, 1);
914 if ((ret == 1) && (win2 == win))
915 return EINA_TRUE;
916 }
917
918 return EINA_FALSE;
919} /* ecore_x_e_comp_sync_supported_get */
920
921EAPI void
922ecore_x_e_comp_sync_begin_send(Ecore_X_Window win)
923{
924 XEvent xev;
925
926 LOGFN(__FILE__, __LINE__, __FUNCTION__);
927 xev.xclient.type = ClientMessage;
928 xev.xclient.display = _ecore_x_disp;
929 xev.xclient.window = win;
930 xev.xclient.message_type = ECORE_X_ATOM_E_COMP_SYNC_BEGIN;
931 xev.xclient.format = 32;
932 xev.xclient.data.l[0] = win;
933 xev.xclient.data.l[1] = 0; // later
934 xev.xclient.data.l[2] = 0; // later
935 xev.xclient.data.l[3] = 0; // later
936 xev.xclient.data.l[4] = 0; // later
937
938 XSendEvent(_ecore_x_disp, win, False,
939 NoEventMask, //SubstructureRedirectMask | SubstructureNotifyMask,
940 &xev);
941} /* ecore_x_e_comp_sync_begin_send */
942
943EAPI void
944ecore_x_e_comp_sync_end_send(Ecore_X_Window win)
945{
946 XEvent xev;
947
948 LOGFN(__FILE__, __LINE__, __FUNCTION__);
949 xev.xclient.type = ClientMessage;
950 xev.xclient.display = _ecore_x_disp;
951 xev.xclient.window = win;
952 xev.xclient.message_type = ECORE_X_ATOM_E_COMP_SYNC_END;
953 xev.xclient.format = 32;
954 xev.xclient.data.l[0] = win;
955 xev.xclient.data.l[1] = 0; // later
956 xev.xclient.data.l[2] = 0; // later
957 xev.xclient.data.l[3] = 0; // later
958 xev.xclient.data.l[4] = 0; // later
959
960 XSendEvent(_ecore_x_disp, win, False,
961 NoEventMask, //SubstructureRedirectMask | SubstructureNotifyMask,
962 &xev);
963} /* ecore_x_e_comp_sync_end_send */
964
965EAPI void
966ecore_x_e_comp_sync_cancel_send(Ecore_X_Window win)
967{
968 XEvent xev;
969
970 LOGFN(__FILE__, __LINE__, __FUNCTION__);
971 xev.xclient.type = ClientMessage;
972 xev.xclient.display = _ecore_x_disp;
973 xev.xclient.window = win;
974 xev.xclient.message_type = ECORE_X_ATOM_E_COMP_SYNC_CANCEL;
975 xev.xclient.format = 32;
976 xev.xclient.data.l[0] = win;
977 xev.xclient.data.l[1] = 0; // later
978 xev.xclient.data.l[2] = 0; // later
979 xev.xclient.data.l[3] = 0; // later
980 xev.xclient.data.l[4] = 0; // later
981
982 XSendEvent(_ecore_x_disp, win, False,
983 NoEventMask, //SubstructureRedirectMask | SubstructureNotifyMask,
984 &xev);
985} /* ecore_x_e_comp_sync_cancel_send */
986
987EAPI void
988ecore_x_e_comp_flush_send(Ecore_X_Window win)
989{
990 XEvent xev;
991
992 LOGFN(__FILE__, __LINE__, __FUNCTION__);
993 xev.xclient.type = ClientMessage;
994 xev.xclient.display = _ecore_x_disp;
995 xev.xclient.window = win;
996 xev.xclient.message_type = ECORE_X_ATOM_E_COMP_FLUSH;
997 xev.xclient.format = 32;
998 xev.xclient.data.l[0] = win;
999 xev.xclient.data.l[1] = 0; // later
1000 xev.xclient.data.l[2] = 0; // later
1001 xev.xclient.data.l[3] = 0; // later
1002 xev.xclient.data.l[4] = 0; // later
1003
1004 XSendEvent(_ecore_x_disp, win, False,
1005 NoEventMask, //SubstructureRedirectMask | SubstructureNotifyMask,
1006 &xev);
1007} /* ecore_x_e_comp_flush_send */
1008
1009EAPI void
1010ecore_x_e_comp_dump_send(Ecore_X_Window win)
1011{
1012 XEvent xev;
1013
1014 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1015 xev.xclient.type = ClientMessage;
1016 xev.xclient.display = _ecore_x_disp;
1017 xev.xclient.window = win;
1018 xev.xclient.message_type = ECORE_X_ATOM_E_COMP_DUMP;
1019 xev.xclient.format = 32;
1020 xev.xclient.data.l[0] = win;
1021 xev.xclient.data.l[1] = 0; // later
1022 xev.xclient.data.l[2] = 0; // later
1023 xev.xclient.data.l[3] = 0; // later
1024 xev.xclient.data.l[4] = 0; // later
1025
1026 XSendEvent(_ecore_x_disp, win, False,
1027 NoEventMask, //SubstructureRedirectMask | SubstructureNotifyMask,
1028 &xev);
1029} /* ecore_x_e_comp_dump_send */
1030
1031EAPI void
1032ecore_x_e_comp_pixmap_set(Ecore_X_Window win,
1033 Ecore_X_Pixmap pixmap)
1034{
1035 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1036 if (pixmap)
1037 ecore_x_window_prop_xid_set(win, ECORE_X_ATOM_E_COMP_PIXMAP,
1038 ECORE_X_ATOM_PIXMAP, &pixmap, 1);
1039 else
1040 ecore_x_window_prop_property_del(win, pixmap);
1041} /* ecore_x_e_comp_pixmap_set */
1042
1043EAPI Ecore_X_Pixmap
1044ecore_x_e_comp_pixmap_get(Ecore_X_Window win)
1045{
1046 int ret = 0;
1047 Ecore_X_Pixmap pixmap = 0;
1048
1049 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1050 ret =
1051 ecore_x_window_prop_xid_get(win,
1052 ECORE_X_ATOM_E_COMP_PIXMAP,
1053 ECORE_X_ATOM_PIXMAP,
1054 &pixmap, 1);
1055 if (ret != 1)
1056 return 0;
1057
1058 return pixmap;
1059} /* ecore_x_e_comp_pixmap_get */
1060
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_error.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_error.c
new file mode 100644
index 0000000..837ff53
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_error.c
@@ -0,0 +1,111 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdlib.h>
6
7#include "Ecore.h"
8#include "ecore_private.h"
9#include "ecore_x_private.h"
10#include "Ecore_X.h"
11
12static int _ecore_x_error_handle(Display *d,
13 XErrorEvent *ev);
14static int _ecore_x_io_error_handle(Display *d);
15
16static void (*_error_func)(void *data) = NULL;
17static void *_error_data = NULL;
18static void (*_io_error_func)(void *data) = NULL;
19static void *_io_error_data = NULL;
20static int _error_request_code = 0;
21static int _error_code = 0;
22
23/**
24 * Set the error handler.
25 * @param func The error handler function
26 * @param data The data to be passed to the handler function
27 *
28 * Set the X error handler function
29 */
30EAPI void
31ecore_x_error_handler_set(void (*func)(void *data),
32 const void *data)
33{
34 _error_func = func;
35 _error_data = (void *)data;
36} /* ecore_x_error_handler_set */
37
38/**
39 * Set the I/O error handler.
40 * @param func The I/O error handler function
41 * @param data The data to be passed to the handler function
42 *
43 * Set the X I/O error handler function
44 */
45EAPI void
46ecore_x_io_error_handler_set(void (*func)(void *data),
47 const void *data)
48{
49 _io_error_func = func;
50 _io_error_data = (void *)data;
51} /* ecore_x_io_error_handler_set */
52
53/**
54 * Get the request code that caused the error.
55 * @return The request code causing the X error
56 *
57 * Return the X request code that caused the last X error
58 */
59EAPI int
60ecore_x_error_request_get(void)
61{
62 return _error_request_code;
63} /* ecore_x_error_request_get */
64
65/**
66 * Get the error code from the error.
67 * @return The error code from the X error
68 *
69 * Return the error code from the last X error
70 */
71EAPI int
72ecore_x_error_code_get(void)
73{
74 return _error_code;
75} /* ecore_x_error_code_get */
76
77void
78_ecore_x_error_handler_init(void)
79{
80 XSetErrorHandler((XErrorHandler)_ecore_x_error_handle);
81 XSetIOErrorHandler((XIOErrorHandler)_ecore_x_io_error_handle);
82} /* _ecore_x_error_handler_init */
83
84static int
85_ecore_x_error_handle(Display *d,
86 XErrorEvent *ev)
87{
88 if (d == _ecore_x_disp)
89 {
90 _error_request_code = ev->request_code;
91 _error_code = ev->error_code;
92 if (_error_func)
93 _error_func(_error_data);
94 }
95 return 0;
96} /* _ecore_x_error_handle */
97
98static int
99_ecore_x_io_error_handle(Display *d)
100{
101 if (d == _ecore_x_disp)
102 {
103 if (_io_error_func)
104 _io_error_func(_io_error_data);
105 else
106 exit(-1);
107 }
108
109 return 0;
110} /* _ecore_x_io_error_handle */
111
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_events.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_events.c
new file mode 100644
index 0000000..136cd63
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_events.c
@@ -0,0 +1,2486 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdlib.h>
6#include <stdio.h>
7#include <string.h>
8
9#include <langinfo.h>
10
11#include "Ecore.h"
12#include "ecore_private.h"
13#include "ecore_x_private.h"
14#include "Ecore_X.h"
15#include "Ecore_X_Atoms.h"
16
17/** OpenBSD does not define CODESET
18 * FIXME ??
19 */
20
21#ifndef CODESET
22#define CODESET "INVALID"
23#endif /* ifndef CODESET */
24
25typedef struct _Ecore_X_Mouse_Down_Info
26{
27 EINA_INLIST;
28 int dev;
29 Window last_win;
30 Window last_last_win;
31 Window last_event_win;
32 Window last_last_event_win;
33 Time last_time;
34 Time last_last_time;
35 Eina_Bool did_double : 1;
36 Eina_Bool did_triple : 1;
37} Ecore_X_Mouse_Down_Info;
38
39static int _ecore_x_last_event_mouse_move = 0;
40static Ecore_Event *_ecore_x_last_event_mouse_move_event = NULL;
41static Eina_Inlist *_ecore_x_mouse_down_info_list = NULL;
42
43static void
44_ecore_x_mouse_down_info_clear(void)
45{
46 Eina_Inlist *l = _ecore_x_mouse_down_info_list;
47 Ecore_X_Mouse_Down_Info *info = NULL;
48 while (l)
49 {
50 info = EINA_INLIST_CONTAINER_GET(l, Ecore_X_Mouse_Down_Info);
51 l = eina_inlist_remove(l, l);
52 free(info);
53 }
54 _ecore_x_mouse_down_info_list = NULL;
55}
56
57void
58_ecore_x_events_init(void)
59{
60 //Actually, Nothing to do.
61}
62
63void
64_ecore_x_events_shutdown(void)
65{
66 _ecore_x_mouse_down_info_clear();
67}
68
69static Ecore_X_Mouse_Down_Info *
70_ecore_x_mouse_down_info_get(int dev)
71{
72 Eina_Inlist *l = _ecore_x_mouse_down_info_list;
73 Ecore_X_Mouse_Down_Info *info = NULL;
74
75 //Return the exist info
76 EINA_INLIST_FOREACH(l, info)
77 if (info->dev == dev) return info;
78
79 //New Device. Add it.
80 info = calloc(1, sizeof(Ecore_X_Mouse_Down_Info));
81 if (!info) return NULL;
82
83 info->dev = dev;
84 l = eina_inlist_append(l, (Eina_Inlist *)info);
85 _ecore_x_mouse_down_info_list = l;
86 return info;
87}
88
89static void
90_ecore_x_event_free_mouse_move(void *data __UNUSED__,
91 void *ev)
92{
93 Ecore_Event_Mouse_Move *e;
94
95 e = ev;
96 if (_ecore_x_last_event_mouse_move)
97 {
98 _ecore_x_last_event_mouse_move_event = NULL;
99 _ecore_x_last_event_mouse_move = 0;
100 }
101
102 free(e);
103} /* _ecore_x_event_free_mouse_move */
104
105EAPI void
106ecore_x_event_mask_set(Ecore_X_Window w,
107 Ecore_X_Event_Mask mask)
108{
109 XWindowAttributes attr;
110 XSetWindowAttributes s_attr;
111
112 LOGFN(__FILE__, __LINE__, __FUNCTION__);
113 if (!w)
114 w = DefaultRootWindow(_ecore_x_disp);
115
116 memset(&attr, 0, sizeof(XWindowAttributes));
117 XGetWindowAttributes(_ecore_x_disp, w, &attr);
118 s_attr.event_mask = mask | attr.your_event_mask;
119 XChangeWindowAttributes(_ecore_x_disp, w, CWEventMask, &s_attr);
120} /* ecore_x_event_mask_set */
121
122EAPI void
123ecore_x_event_mask_unset(Ecore_X_Window w,
124 Ecore_X_Event_Mask mask)
125{
126 XWindowAttributes attr;
127 XSetWindowAttributes s_attr;
128
129 LOGFN(__FILE__, __LINE__, __FUNCTION__);
130 if (!w)
131 w = DefaultRootWindow(_ecore_x_disp);
132
133 memset(&attr, 0, sizeof(XWindowAttributes));
134 XGetWindowAttributes(_ecore_x_disp, w, &attr);
135 s_attr.event_mask = attr.your_event_mask & ~mask;
136 XChangeWindowAttributes(_ecore_x_disp, w, CWEventMask, &s_attr);
137} /* ecore_x_event_mask_unset */
138
139static void
140_ecore_x_event_free_xdnd_enter(void *data __UNUSED__,
141 void *ev)
142{
143 Ecore_X_Event_Xdnd_Enter *e;
144 int i;
145
146 e = ev;
147 for (i = 0; i < e->num_types; i++)
148 XFree(e->types[i]);
149 free(e->types);
150 free(e);
151} /* _ecore_x_event_free_xdnd_enter */
152
153static void
154_ecore_x_event_free_selection_notify(void *data __UNUSED__,
155 void *ev)
156{
157 Ecore_X_Event_Selection_Notify *e;
158 Ecore_X_Selection_Data *sel;
159
160 e = ev;
161 sel = e->data;
162 if (sel->free)
163 sel->free(sel);
164
165 free(e->target);
166 free(e);
167} /* _ecore_x_event_free_selection_notify */
168
169static unsigned int
170_ecore_x_event_modifiers(unsigned int state)
171{
172 unsigned int modifiers = 0;
173
174 if (state & ECORE_X_MODIFIER_SHIFT)
175 modifiers |= ECORE_EVENT_MODIFIER_SHIFT;
176
177 if (state & ECORE_X_MODIFIER_CTRL)
178 modifiers |= ECORE_EVENT_MODIFIER_CTRL;
179
180 if (state & ECORE_X_MODIFIER_ALT)
181 modifiers |= ECORE_EVENT_MODIFIER_ALT;
182
183 if (state & ECORE_X_MODIFIER_WIN)
184 modifiers |= ECORE_EVENT_MODIFIER_WIN;
185
186 if (state & ECORE_X_LOCK_SCROLL)
187 modifiers |= ECORE_EVENT_LOCK_SCROLL;
188
189 if (state & ECORE_X_LOCK_NUM)
190 modifiers |= ECORE_EVENT_LOCK_NUM;
191
192 if (state & ECORE_X_LOCK_CAPS)
193 modifiers |= ECORE_EVENT_LOCK_CAPS;
194
195 if (state & ECORE_X_LOCK_SHIFT)
196 modifiers |= ECORE_EVENT_LOCK_SHIFT;
197
198 return modifiers;
199} /* _ecore_x_event_modifiers */
200
201void
202_ecore_mouse_move(unsigned int timestamp,
203 unsigned int xmodifiers,
204 int x,
205 int y,
206 int x_root,
207 int y_root,
208 unsigned int event_window,
209 unsigned int window,
210 unsigned int root_win,
211 int same_screen,
212 int dev,
213 double radx,
214 double rady,
215 double pressure,
216 double angle,
217 double mx,
218 double my,
219 double mrx,
220 double mry)
221{
222 Ecore_Event_Mouse_Move *e;
223 Ecore_Event *event;
224
225 e = malloc(sizeof(Ecore_Event_Mouse_Move));
226 if (!e)
227 return;
228
229 e->window = window;
230 e->root_window = root_win;
231 e->timestamp = timestamp;
232 e->same_screen = same_screen;
233 e->event_window = event_window;
234
235 e->modifiers = _ecore_x_event_modifiers(xmodifiers);
236 e->x = x;
237 e->y = y;
238 e->root.x = x_root;
239 e->root.y = y_root;
240
241 e->multi.device = dev;
242 e->multi.radius = (radx + rady) / 2;
243 e->multi.radius_x = radx;
244 e->multi.radius_y = rady;
245 e->multi.pressure = pressure;
246 e->multi.angle = angle;
247 e->multi.x = mx;
248 e->multi.y = my;
249 e->multi.root.x = mrx;
250 e->multi.root.y = mry;
251
252 event = ecore_event_add(ECORE_EVENT_MOUSE_MOVE,
253 e,
254 _ecore_x_event_free_mouse_move,
255 NULL);
256
257 _ecore_x_event_last_time = timestamp;
258 _ecore_x_event_last_win = window;
259 _ecore_x_event_last_root_x = x_root;
260 _ecore_x_event_last_root_y = y_root;
261
262 _ecore_x_last_event_mouse_move_event = event;
263} /* _ecore_mouse_move */
264
265static void
266_ecore_key_press(int event,
267 XKeyEvent *xevent)
268{
269 Ecore_Event_Key *e;
270 char *compose = NULL;
271 char *tmp = NULL;
272 char *keyname;
273 char *key;
274 char keyname_buffer[256];
275 char compose_buffer[256];
276 KeySym sym;
277 XComposeStatus status;
278 int val;
279
280 _ecore_x_last_event_mouse_move = 0;
281 keyname = XKeysymToString(XKeycodeToKeysym(xevent->display,
282 xevent->keycode, 0));
283 if (!keyname)
284 {
285 snprintf(keyname_buffer,
286 sizeof(keyname_buffer),
287 "Keycode-%i",
288 xevent->keycode);
289 keyname = keyname_buffer;
290 }
291
292 sym = 0;
293 key = NULL;
294 compose = NULL;
295 val = XLookupString(xevent,
296 compose_buffer,
297 sizeof(compose_buffer),
298 &sym,
299 &status);
300 if (val > 0)
301 {
302 compose_buffer[val] = 0;
303 compose = eina_str_convert(nl_langinfo(CODESET), "UTF-8",
304 compose_buffer);
305 if (!compose)
306 ERR("Ecore_X cannot convert input key string '%s' to UTF-8. "
307 "Is Eina built with iconv support?", compose_buffer);
308 tmp = compose;
309 }
310
311 key = XKeysymToString(sym);
312 if (!key)
313 key = keyname;
314
315 e =
316 malloc(sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
317 (compose ? strlen(compose) : 0) + 3);
318 if (!e)
319 goto on_error;
320
321 e->keyname = (char *)(e + 1);
322 e->key = e->keyname + strlen(keyname) + 1;
323 e->compose = (compose) ? e->key + strlen(key) + 1 : NULL;
324 e->string = e->compose;
325
326 strcpy((char *)e->keyname, keyname);
327 strcpy((char *)e->key, key);
328 if (compose)
329 strcpy((char *)e->compose, compose);
330
331 e->modifiers = _ecore_x_event_modifiers(xevent->state);
332
333 e->timestamp = xevent->time;
334 e->window = xevent->subwindow ? xevent->subwindow : xevent->window;
335 e->event_window = xevent->window;
336 e->same_screen = xevent->same_screen;
337 e->root_window = xevent->root;
338
339 ecore_event_add(event, e, NULL, NULL);
340
341 _ecore_x_event_last_time = e->timestamp;
342
343on_error:
344 if (tmp)
345 free(tmp);
346} /* _ecore_key_press */
347
348Ecore_Event_Mouse_Button *
349_ecore_mouse_button(int event,
350 unsigned int timestamp,
351 unsigned int xmodifiers,
352 unsigned int buttons,
353 int x,
354 int y,
355 int x_root,
356 int y_root,
357 unsigned int event_window,
358 unsigned int window,
359 unsigned int root_win,
360 int same_screen,
361 int dev,
362 double radx,
363 double rady,
364 double pressure,
365 double angle,
366 double mx,
367 double my,
368 double mrx,
369 double mry)
370{
371 Ecore_Event_Mouse_Button *e;
372
373 e = malloc(sizeof(Ecore_Event_Mouse_Button));
374 if (!e)
375 return NULL;
376
377 e->window = window;
378 e->root_window = root_win;
379 e->timestamp = timestamp;
380 e->same_screen = same_screen;
381 e->event_window = event_window;
382
383 e->buttons = buttons;
384 e->modifiers = _ecore_x_event_modifiers(xmodifiers);
385 e->double_click = 0;
386 e->triple_click = 0;
387 e->x = x;
388 e->y = y;
389 e->root.x = x_root;
390 e->root.y = y_root;
391
392 Ecore_X_Mouse_Down_Info *down_info = _ecore_x_mouse_down_info_get(dev);
393
394 if (down_info)
395 {
396 if ((event == ECORE_EVENT_MOUSE_BUTTON_DOWN) &&
397 down_info->did_triple)
398 {
399 down_info->last_win = 0;
400 down_info->last_last_win = 0;
401 down_info->last_event_win = 0;
402 down_info->last_last_event_win = 0;
403 down_info->last_time = 0;
404 down_info->last_last_time = 0;
405 }
406 if (event_window == window)
407 {
408 if (event == ECORE_EVENT_MOUSE_BUTTON_DOWN)
409 {
410 //Check Double Clicked
411 if (((int)(timestamp - down_info->last_time) <=
412 (int)(1000 * _ecore_x_double_click_time)) &&
413 (window == down_info->last_win) &&
414 (event_window == down_info->last_event_win))
415 {
416 e->double_click = 1;
417 down_info->did_double = EINA_TRUE;
418 }
419 else
420 {
421 down_info->did_double = EINA_FALSE;
422 down_info->did_triple = EINA_FALSE;
423 }
424
425 //Check Triple Clicked
426 if (((int)(timestamp - down_info->last_last_time) <=
427 (int)(2 * 1000 * _ecore_x_double_click_time)) &&
428 (window == down_info->last_win) &&
429 (window == down_info->last_last_win) &&
430 (event_window == down_info->last_event_win) &&
431 (event_window == down_info->last_last_event_win)
432 )
433 {
434 e->triple_click = 1;
435 down_info->did_triple = EINA_TRUE;
436 }
437 else
438 {
439 down_info->did_triple = EINA_FALSE;
440 }
441 }
442 else
443 {
444 if (down_info->did_double)
445 e->double_click = 1;
446 if (down_info->did_triple)
447 e->triple_click = 1;
448 }
449 }
450 }
451
452 /* NB: Block commented out as _ecore_x_mouse_up_count appears to have
453 * no use. The variable is also commented out above. This code block is
454 * the only place that this variable is used, and appears to serve no
455 * purpose. - dh
456 if (event == ECORE_EVENT_MOUSE_BUTTON_DOWN
457 && !e->double_click
458 && !e->triple_click)
459 _ecore_x_mouse_up_count = 0;
460 */
461
462 e->multi.device = dev;
463 e->multi.radius = (radx + rady) / 2;
464 e->multi.radius_x = radx;
465 e->multi.radius_y = rady;
466 e->multi.pressure = pressure;
467 e->multi.angle = angle;
468 e->multi.x = mx;
469 e->multi.y = my;
470 e->multi.root.x = mrx;
471 e->multi.root.y = mry;
472
473 _ecore_x_event_last_time = e->timestamp;
474 _ecore_x_event_last_win = e->window;
475 _ecore_x_event_last_root_x = x_root;
476 _ecore_x_event_last_root_y = y_root;
477
478 ecore_event_add(event, e, NULL, NULL);
479
480 if ((down_info) &&
481 (event == ECORE_EVENT_MOUSE_BUTTON_DOWN) &&
482 (window == event_window) &&
483 (!down_info->did_triple))
484 {
485 down_info->last_last_win = down_info->last_win;
486 down_info->last_win = window;
487 down_info->last_last_event_win = down_info->last_event_win;
488 down_info->last_event_win = event_window;
489 down_info->last_last_time = down_info->last_time;
490 down_info->last_time = timestamp;
491 }
492
493 return e;
494} /* _ecore_mouse_button */
495
496void
497_ecore_x_event_handle_any_event(XEvent *xevent)
498{
499 XEvent *ev = malloc(sizeof(XEvent));
500 if (!ev) return;
501 memcpy(ev, xevent, sizeof(XEvent));
502 ecore_event_add(ECORE_X_EVENT_ANY, ev, NULL, NULL);
503} /* _ecore_x_event_handle_any_event */
504
505void
506_ecore_x_event_handle_key_press(XEvent *xevent)
507{
508 _ecore_key_press(ECORE_EVENT_KEY_DOWN, (XKeyEvent *)xevent);
509} /* _ecore_x_event_handle_key_press */
510
511void
512_ecore_x_event_handle_key_release(XEvent *xevent)
513{
514 _ecore_key_press(ECORE_EVENT_KEY_UP, (XKeyEvent *)xevent);
515} /* _ecore_x_event_handle_key_release */
516
517void
518_ecore_x_event_handle_button_press(XEvent *xevent)
519{
520 int i;
521
522 _ecore_x_last_event_mouse_move = 0;
523 if ((xevent->xbutton.button > 3) && (xevent->xbutton.button < 8))
524 {
525 Ecore_Event_Mouse_Wheel *e;
526
527 e = malloc(sizeof(Ecore_Event_Mouse_Wheel));
528 if (!e)
529 return;
530
531 e->timestamp = xevent->xbutton.time;
532 e->modifiers = _ecore_x_event_modifiers(xevent->xbutton.state);
533 switch (xevent->xbutton.button)
534 {
535 case 4: e->direction = 0; e->z = -1; break;
536
537 case 5: e->direction = 0; e->z = 1; break;
538
539 case 6: e->direction = 1; e->z = -1; break;
540
541 case 7: e->direction = 1; e->z = 1; break;
542
543 default: e->direction = 0; e->z = 0; break;
544 } /* switch */
545
546 e->x = xevent->xbutton.x;
547 e->y = xevent->xbutton.y;
548 e->root.x = xevent->xbutton.x_root;
549 e->root.y = xevent->xbutton.y_root;
550
551 if (xevent->xbutton.subwindow)
552 e->window = xevent->xbutton.subwindow;
553 else
554 e->window = xevent->xbutton.window;
555
556 e->event_window = xevent->xbutton.window;
557 e->same_screen = xevent->xbutton.same_screen;
558 e->root_window = xevent->xbutton.root;
559
560 _ecore_x_event_last_time = e->timestamp;
561 _ecore_x_event_last_win = e->window;
562 _ecore_x_event_last_root_x = xevent->xbutton.x_root;
563 _ecore_x_event_last_root_y = xevent->xbutton.y_root;
564 ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, e, NULL, NULL);
565
566 for (i = 0; i < _ecore_window_grabs_num; i++)
567 {
568 if ((_ecore_window_grabs[i] == xevent->xbutton.window) ||
569 (_ecore_window_grabs[i] == xevent->xbutton.subwindow))
570 {
571 Eina_Bool replay = EINA_FALSE;
572
573 if (_ecore_window_grab_replay_func)
574 replay = _ecore_window_grab_replay_func(
575 _ecore_window_grab_replay_data,
576 ECORE_EVENT_MOUSE_WHEEL,
577 e);
578
579 if (replay)
580 XAllowEvents(xevent->xbutton.display,
581 ReplayPointer, xevent->xbutton.time);
582 else
583 XAllowEvents(xevent->xbutton.display,
584 AsyncPointer, xevent->xbutton.time);
585
586 break;
587 }
588 }
589 }
590 else
591 {
592 {
593 _ecore_mouse_move(xevent->xbutton.time, xevent->xbutton.state,
594 xevent->xbutton.x, xevent->xbutton.y,
595 xevent->xbutton.x_root, xevent->xbutton.y_root,
596 xevent->xbutton.window,
597 (xevent->xbutton.subwindow ? xevent->xbutton.
598 subwindow : xevent->xbutton.window),
599 xevent->xbutton.root,
600 xevent->xbutton.same_screen,
601 0, 1, 1,
602 1.0, // pressure
603 0.0, // angle
604 xevent->xbutton.x, xevent->xbutton.y,
605 xevent->xbutton.x_root, xevent->xbutton.y_root);
606 }
607 {
608 Ecore_Event_Mouse_Button *e;
609 int event_window;
610 int window;
611
612 window =
613 (xevent->xbutton.subwindow ? xevent->xbutton.subwindow : xevent->
614 xbutton.window);
615 event_window = xevent->xbutton.window;
616
617 e = _ecore_mouse_button(ECORE_EVENT_MOUSE_BUTTON_DOWN,
618 xevent->xbutton.time,
619 xevent->xbutton.state,
620 xevent->xbutton.button,
621 xevent->xbutton.x,
622 xevent->xbutton.y,
623 xevent->xbutton.x_root,
624 xevent->xbutton.y_root,
625 event_window,
626 window,
627 xevent->xbutton.root,
628 xevent->xbutton.same_screen,
629 0,
630 1,
631 1,
632 1.0,
633// pressure
634 0.0,
635// angle
636 xevent->xbutton.x,
637 xevent->xbutton.y,
638 xevent->xbutton.x_root,
639 xevent->xbutton.y_root);
640 if (e)
641 for (i = 0; i < _ecore_window_grabs_num; i++)
642 {
643 if ((_ecore_window_grabs[i] == xevent->xbutton.window) ||
644 (_ecore_window_grabs[i] == xevent->xbutton.subwindow))
645 {
646 Eina_Bool replay = EINA_FALSE;
647
648 if (_ecore_window_grab_replay_func)
649 replay = _ecore_window_grab_replay_func(
650 _ecore_window_grab_replay_data,
651 ECORE_EVENT_MOUSE_BUTTON_DOWN,
652 e);
653
654 if (replay)
655 XAllowEvents(xevent->xbutton.display,
656 ReplayPointer, xevent->xbutton.time);
657 else
658 XAllowEvents(xevent->xbutton.display,
659 AsyncPointer, xevent->xbutton.time);
660
661 break;
662 }
663 }
664 }
665 }
666} /* _ecore_x_event_handle_button_press */
667
668void
669_ecore_x_event_handle_button_release(XEvent *xevent)
670{
671 _ecore_x_last_event_mouse_move = 0;
672 /* filter out wheel buttons */
673 if ((xevent->xbutton.button <= 3) || (xevent->xbutton.button > 7))
674 {
675 _ecore_mouse_move(xevent->xbutton.time, xevent->xbutton.state,
676 xevent->xbutton.x, xevent->xbutton.y,
677 xevent->xbutton.x_root, xevent->xbutton.y_root,
678 xevent->xbutton.window,
679 (xevent->xbutton.subwindow ? xevent->xbutton.
680 subwindow : xevent->xbutton.window),
681 xevent->xbutton.root,
682 xevent->xbutton.same_screen,
683 0, 1, 1,
684 1.0, // pressure
685 0.0, // angle
686 xevent->xbutton.x, xevent->xbutton.y,
687 xevent->xbutton.x_root, xevent->xbutton.y_root);
688
689 _ecore_mouse_button(ECORE_EVENT_MOUSE_BUTTON_UP,
690 xevent->xbutton.time, xevent->xbutton.state,
691 xevent->xbutton.button,
692 xevent->xbutton.x, xevent->xbutton.y,
693 xevent->xbutton.x_root, xevent->xbutton.y_root,
694 xevent->xbutton.window,
695 (xevent->xbutton.subwindow ? xevent->xbutton.
696 subwindow : xevent->xbutton.window),
697 xevent->xbutton.root,
698 xevent->xbutton.same_screen,
699 0, 1, 1,
700 1.0, // pressure
701 0.0, // angle
702 xevent->xbutton.x, xevent->xbutton.y,
703 xevent->xbutton.x_root, xevent->xbutton.y_root);
704 }
705} /* _ecore_x_event_handle_button_release */
706
707void
708_ecore_x_event_handle_motion_notify(XEvent *xevent)
709{
710/*
711 if (_ecore_x_last_event_mouse_move)
712 {
713 ecore_event_del(_ecore_x_last_event_mouse_move_event);
714 _ecore_x_last_event_mouse_move = 0;
715 _ecore_x_last_event_mouse_move_event = NULL;
716 }
717 */
718 _ecore_mouse_move(xevent->xmotion.time, xevent->xmotion.state,
719 xevent->xmotion.x, xevent->xmotion.y,
720 xevent->xmotion.x_root, xevent->xmotion.y_root,
721 xevent->xmotion.window,
722 (xevent->xmotion.subwindow ? xevent->xmotion.subwindow :
723 xevent->xmotion.window),
724 xevent->xmotion.root,
725 xevent->xmotion.same_screen,
726 0, 1, 1,
727 1.0, // pressure
728 0.0, // angle
729 xevent->xmotion.x, xevent->xmotion.y,
730 xevent->xmotion.x_root, xevent->xmotion.y_root);
731
732 _ecore_x_last_event_mouse_move = 1;
733
734 /* Xdnd handling */
735 _ecore_x_dnd_drag(xevent->xmotion.root,
736 xevent->xmotion.x_root,
737 xevent->xmotion.y_root);
738} /* _ecore_x_event_handle_motion_notify */
739
740void
741_ecore_x_event_handle_enter_notify(XEvent *xevent)
742{
743 _ecore_x_last_event_mouse_move = 0;
744 {
745 _ecore_mouse_move(xevent->xcrossing.time, xevent->xcrossing.state,
746 xevent->xcrossing.x, xevent->xcrossing.y,
747 xevent->xcrossing.x_root, xevent->xcrossing.y_root,
748 xevent->xcrossing.window,
749 (xevent->xcrossing.subwindow ? xevent->xcrossing.
750 subwindow : xevent->xcrossing.window),
751 xevent->xcrossing.root,
752 xevent->xcrossing.same_screen,
753 0, 1, 1,
754 1.0, // pressure
755 0.0, // angle
756 xevent->xcrossing.x, xevent->xcrossing.y,
757 xevent->xcrossing.x_root, xevent->xcrossing.y_root);
758 }
759 {
760 Ecore_X_Event_Mouse_In *e;
761
762 e = calloc(1, sizeof(Ecore_X_Event_Mouse_In));
763 if (!e)
764 return;
765
766 e->modifiers = _ecore_x_event_modifiers(xevent->xcrossing.state);
767 e->x = xevent->xcrossing.x;
768 e->y = xevent->xcrossing.y;
769 e->root.x = xevent->xcrossing.x_root;
770 e->root.y = xevent->xcrossing.y_root;
771 if (xevent->xcrossing.subwindow)
772 e->win = xevent->xcrossing.subwindow;
773 else
774 e->win = xevent->xcrossing.window;
775
776 e->same_screen = xevent->xcrossing.same_screen;
777 e->root_win = xevent->xcrossing.root;
778 e->event_win = xevent->xcrossing.window;
779
780 if (xevent->xcrossing.mode == NotifyNormal)
781 e->mode = ECORE_X_EVENT_MODE_NORMAL;
782 else if (xevent->xcrossing.mode == NotifyGrab)
783 e->mode = ECORE_X_EVENT_MODE_GRAB;
784 else if (xevent->xcrossing.mode == NotifyUngrab)
785 e->mode = ECORE_X_EVENT_MODE_UNGRAB;
786
787 if (xevent->xcrossing.detail == NotifyAncestor)
788 e->detail = ECORE_X_EVENT_DETAIL_ANCESTOR;
789 else if (xevent->xcrossing.detail == NotifyVirtual)
790 e->detail = ECORE_X_EVENT_DETAIL_VIRTUAL;
791 else if (xevent->xcrossing.detail == NotifyInferior)
792 e->detail = ECORE_X_EVENT_DETAIL_INFERIOR;
793 else if (xevent->xcrossing.detail == NotifyNonlinear)
794 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR;
795 else if (xevent->xcrossing.detail == NotifyNonlinearVirtual)
796 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR_VIRTUAL;
797
798 e->time = xevent->xcrossing.time;
799 _ecore_x_event_last_time = e->time;
800 ecore_event_add(ECORE_X_EVENT_MOUSE_IN, e, NULL, NULL);
801 }
802} /* _ecore_x_event_handle_enter_notify */
803
804void
805_ecore_x_event_handle_leave_notify(XEvent *xevent)
806{
807 _ecore_x_last_event_mouse_move = 0;
808 {
809 _ecore_mouse_move(xevent->xcrossing.time, xevent->xcrossing.state,
810 xevent->xcrossing.x, xevent->xcrossing.y,
811 xevent->xcrossing.x_root, xevent->xcrossing.y_root,
812 xevent->xcrossing.window,
813 (xevent->xcrossing.subwindow ? xevent->xcrossing.
814 subwindow : xevent->xcrossing.window),
815 xevent->xcrossing.root,
816 xevent->xcrossing.same_screen,
817 0, 1, 1,
818 1.0, // pressure
819 0.0, // angle
820 xevent->xcrossing.x, xevent->xcrossing.y,
821 xevent->xcrossing.x_root, xevent->xcrossing.y_root);
822 }
823 {
824 Ecore_X_Event_Mouse_Out *e;
825
826 e = calloc(1, sizeof(Ecore_X_Event_Mouse_Out));
827 if (!e)
828 return;
829
830 e->modifiers = _ecore_x_event_modifiers(xevent->xcrossing.state);
831 e->x = xevent->xcrossing.x;
832 e->y = xevent->xcrossing.y;
833 e->root.x = xevent->xcrossing.x_root;
834 e->root.y = xevent->xcrossing.y_root;
835 if (xevent->xcrossing.subwindow)
836 e->win = xevent->xcrossing.subwindow;
837 else
838 e->win = xevent->xcrossing.window;
839
840 e->same_screen = xevent->xcrossing.same_screen;
841 e->root_win = xevent->xcrossing.root;
842 e->event_win = xevent->xcrossing.window;
843
844 if (xevent->xcrossing.mode == NotifyNormal)
845 e->mode = ECORE_X_EVENT_MODE_NORMAL;
846 else if (xevent->xcrossing.mode == NotifyGrab)
847 e->mode = ECORE_X_EVENT_MODE_GRAB;
848 else if (xevent->xcrossing.mode == NotifyUngrab)
849 e->mode = ECORE_X_EVENT_MODE_UNGRAB;
850
851 if (xevent->xcrossing.detail == NotifyAncestor)
852 e->detail = ECORE_X_EVENT_DETAIL_ANCESTOR;
853 else if (xevent->xcrossing.detail == NotifyVirtual)
854 e->detail = ECORE_X_EVENT_DETAIL_VIRTUAL;
855 else if (xevent->xcrossing.detail == NotifyInferior)
856 e->detail = ECORE_X_EVENT_DETAIL_INFERIOR;
857 else if (xevent->xcrossing.detail == NotifyNonlinear)
858 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR;
859 else if (xevent->xcrossing.detail == NotifyNonlinearVirtual)
860 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR_VIRTUAL;
861
862 e->time = xevent->xcrossing.time;
863 _ecore_x_event_last_time = e->time;
864 _ecore_x_event_last_win = e->win;
865 _ecore_x_event_last_root_x = e->root.x;
866 _ecore_x_event_last_root_y = e->root.y;
867 ecore_event_add(ECORE_X_EVENT_MOUSE_OUT, e, NULL, NULL);
868 }
869} /* _ecore_x_event_handle_leave_notify */
870
871void
872_ecore_x_event_handle_focus_in(XEvent *xevent)
873{
874 Ecore_X_Event_Window_Focus_In *e;
875
876 _ecore_x_last_event_mouse_move = 0;
877
878 e = calloc(1, sizeof(Ecore_X_Event_Window_Focus_In));
879 if (!e)
880 return;
881
882 e->win = xevent->xfocus.window;
883
884 if (xevent->xfocus.mode == NotifyNormal)
885 e->mode = ECORE_X_EVENT_MODE_NORMAL;
886 else if (xevent->xfocus.mode == NotifyWhileGrabbed)
887 e->mode = ECORE_X_EVENT_MODE_WHILE_GRABBED;
888 else if (xevent->xfocus.mode == NotifyGrab)
889 e->mode = ECORE_X_EVENT_MODE_GRAB;
890 else if (xevent->xfocus.mode == NotifyUngrab)
891 e->mode = ECORE_X_EVENT_MODE_UNGRAB;
892
893 if (xevent->xfocus.detail == NotifyAncestor)
894 e->detail = ECORE_X_EVENT_DETAIL_ANCESTOR;
895 else if (xevent->xfocus.detail == NotifyVirtual)
896 e->detail = ECORE_X_EVENT_DETAIL_VIRTUAL;
897 else if (xevent->xfocus.detail == NotifyInferior)
898 e->detail = ECORE_X_EVENT_DETAIL_INFERIOR;
899 else if (xevent->xfocus.detail == NotifyNonlinear)
900 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR;
901 else if (xevent->xfocus.detail == NotifyNonlinearVirtual)
902 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR_VIRTUAL;
903 else if (xevent->xfocus.detail == NotifyPointer)
904 e->detail = ECORE_X_EVENT_DETAIL_POINTER;
905 else if (xevent->xfocus.detail == NotifyPointerRoot)
906 e->detail = ECORE_X_EVENT_DETAIL_POINTER_ROOT;
907 else if (xevent->xfocus.detail == NotifyDetailNone)
908 e->detail = ECORE_X_EVENT_DETAIL_DETAIL_NONE;
909
910 e->time = _ecore_x_event_last_time;
911 _ecore_x_event_last_time = e->time;
912 ecore_event_add(ECORE_X_EVENT_WINDOW_FOCUS_IN, e, NULL, NULL);
913} /* _ecore_x_event_handle_focus_in */
914
915void
916_ecore_x_event_handle_focus_out(XEvent *xevent)
917{
918 Ecore_X_Event_Window_Focus_Out *e;
919
920 _ecore_x_last_event_mouse_move = 0;
921
922 e = calloc(1, sizeof(Ecore_X_Event_Window_Focus_Out));
923 if (!e)
924 return;
925
926 e->win = xevent->xfocus.window;
927
928 if (xevent->xfocus.mode == NotifyNormal)
929 e->mode = ECORE_X_EVENT_MODE_NORMAL;
930 else if (xevent->xfocus.mode == NotifyWhileGrabbed)
931 e->mode = ECORE_X_EVENT_MODE_WHILE_GRABBED;
932 else if (xevent->xfocus.mode == NotifyGrab)
933 e->mode = ECORE_X_EVENT_MODE_GRAB;
934 else if (xevent->xfocus.mode == NotifyUngrab)
935 e->mode = ECORE_X_EVENT_MODE_UNGRAB;
936
937 if (xevent->xfocus.detail == NotifyAncestor)
938 e->detail = ECORE_X_EVENT_DETAIL_ANCESTOR;
939 else if (xevent->xfocus.detail == NotifyVirtual)
940 e->detail = ECORE_X_EVENT_DETAIL_VIRTUAL;
941 else if (xevent->xfocus.detail == NotifyInferior)
942 e->detail = ECORE_X_EVENT_DETAIL_INFERIOR;
943 else if (xevent->xfocus.detail == NotifyNonlinear)
944 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR;
945 else if (xevent->xfocus.detail == NotifyNonlinearVirtual)
946 e->detail = ECORE_X_EVENT_DETAIL_NON_LINEAR_VIRTUAL;
947 else if (xevent->xfocus.detail == NotifyPointer)
948 e->detail = ECORE_X_EVENT_DETAIL_POINTER;
949 else if (xevent->xfocus.detail == NotifyPointerRoot)
950 e->detail = ECORE_X_EVENT_DETAIL_POINTER_ROOT;
951 else if (xevent->xfocus.detail == NotifyDetailNone)
952 e->detail = ECORE_X_EVENT_DETAIL_DETAIL_NONE;
953
954 e->time = _ecore_x_event_last_time;
955 _ecore_x_event_last_time = e->time;
956 ecore_event_add(ECORE_X_EVENT_WINDOW_FOCUS_OUT, e, NULL, NULL);
957} /* _ecore_x_event_handle_focus_out */
958
959void
960_ecore_x_event_handle_keymap_notify(XEvent *xevent __UNUSED__)
961{
962 _ecore_x_last_event_mouse_move = 0;
963 /* FIXME: handle this event type */
964} /* _ecore_x_event_handle_keymap_notify */
965
966void
967_ecore_x_event_handle_expose(XEvent *xevent)
968{
969 Ecore_X_Event_Window_Damage *e;
970
971 _ecore_x_last_event_mouse_move = 0;
972 e = calloc(1, sizeof(Ecore_X_Event_Window_Damage));
973 if (!e)
974 return;
975
976 e->win = xevent->xexpose.window;
977 e->time = _ecore_x_event_last_time;
978 e->x = xevent->xexpose.x;
979 e->y = xevent->xexpose.y;
980 e->w = xevent->xexpose.width;
981 e->h = xevent->xexpose.height;
982 e->count = xevent->xexpose.count;
983 ecore_event_add(ECORE_X_EVENT_WINDOW_DAMAGE, e, NULL, NULL);
984} /* _ecore_x_event_handle_expose */
985
986void
987_ecore_x_event_handle_graphics_expose(XEvent *xevent)
988{
989 Ecore_X_Event_Window_Damage *e;
990
991 _ecore_x_last_event_mouse_move = 0;
992 e = calloc(1, sizeof(Ecore_X_Event_Window_Damage));
993 if (!e)
994 return;
995
996 e->win = xevent->xgraphicsexpose.drawable;
997 e->time = _ecore_x_event_last_time;
998 e->x = xevent->xgraphicsexpose.x;
999 e->y = xevent->xgraphicsexpose.y;
1000 e->w = xevent->xgraphicsexpose.width;
1001 e->h = xevent->xgraphicsexpose.height;
1002 e->count = xevent->xgraphicsexpose.count;
1003 ecore_event_add(ECORE_X_EVENT_WINDOW_DAMAGE, e, NULL, NULL);
1004} /* _ecore_x_event_handle_graphics_expose */
1005
1006void
1007_ecore_x_event_handle_visibility_notify(XEvent *xevent)
1008{
1009 _ecore_x_last_event_mouse_move = 0;
1010// if (xevent->xvisibility.state != VisibilityPartiallyObscured)
1011 {
1012 Ecore_X_Event_Window_Visibility_Change *e;
1013
1014 e = calloc(1, sizeof(Ecore_X_Event_Window_Visibility_Change));
1015 if (!e)
1016 return;
1017
1018 e->win = xevent->xvisibility.window;
1019 e->time = _ecore_x_event_last_time;
1020 if (xevent->xvisibility.state == VisibilityFullyObscured)
1021 e->fully_obscured = 1;
1022 else
1023 e->fully_obscured = 0;
1024
1025 ecore_event_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE, e, NULL, NULL);
1026 }
1027} /* _ecore_x_event_handle_visibility_notify */
1028
1029void
1030_ecore_x_event_handle_create_notify(XEvent *xevent)
1031{
1032 Ecore_X_Event_Window_Create *e;
1033
1034 _ecore_x_last_event_mouse_move = 0;
1035 e = calloc(1, sizeof(Ecore_X_Event_Window_Create));
1036 if (!e)
1037 return;
1038
1039 e->win = xevent->xcreatewindow.window;
1040 e->parent = xevent->xcreatewindow.parent;
1041 if (xevent->xcreatewindow.override_redirect)
1042 e->override = 1;
1043 else
1044 e->override = 0;
1045
1046 e->x = xevent->xcreatewindow.x;
1047 e->y = xevent->xcreatewindow.y;
1048 e->w = xevent->xcreatewindow.width;
1049 e->h = xevent->xcreatewindow.height;
1050 e->border = xevent->xcreatewindow.border_width;
1051 e->time = _ecore_x_event_last_time;
1052 ecore_event_add(ECORE_X_EVENT_WINDOW_CREATE, e, NULL, NULL);
1053} /* _ecore_x_event_handle_create_notify */
1054
1055void
1056_ecore_x_event_handle_destroy_notify(XEvent *xevent)
1057{
1058 Ecore_X_Event_Window_Destroy *e;
1059
1060 _ecore_x_last_event_mouse_move = 0;
1061 e = calloc(1, sizeof(Ecore_X_Event_Window_Destroy));
1062 if (!e)
1063 return;
1064
1065 e->win = xevent->xdestroywindow.window;
1066 e->event_win = xevent->xdestroywindow.event;
1067 e->time = _ecore_x_event_last_time;
1068 if (e->win == _ecore_x_event_last_win)
1069 _ecore_x_event_last_win = 0;
1070
1071 ecore_event_add(ECORE_X_EVENT_WINDOW_DESTROY, e, NULL, NULL);
1072} /* _ecore_x_event_handle_destroy_notify */
1073
1074void
1075_ecore_x_event_handle_unmap_notify(XEvent *xevent)
1076{
1077 Ecore_X_Event_Window_Hide *e;
1078
1079 _ecore_x_last_event_mouse_move = 0;
1080 e = calloc(1, sizeof(Ecore_X_Event_Window_Hide));
1081 if (!e)
1082 return;
1083
1084 e->win = xevent->xunmap.window;
1085 e->event_win = xevent->xunmap.event;
1086 e->time = _ecore_x_event_last_time;
1087 ecore_event_add(ECORE_X_EVENT_WINDOW_HIDE, e, NULL, NULL);
1088} /* _ecore_x_event_handle_unmap_notify */
1089
1090void
1091_ecore_x_event_handle_map_notify(XEvent *xevent)
1092{
1093 Ecore_X_Event_Window_Show *e;
1094
1095 _ecore_x_last_event_mouse_move = 0;
1096 e = calloc(1, sizeof(Ecore_X_Event_Window_Show));
1097 if (!e)
1098 return;
1099
1100 e->win = xevent->xmap.window;
1101 e->event_win = xevent->xmap.event;
1102 e->time = _ecore_x_event_last_time;
1103 ecore_event_add(ECORE_X_EVENT_WINDOW_SHOW, e, NULL, NULL);
1104} /* _ecore_x_event_handle_map_notify */
1105
1106void
1107_ecore_x_event_handle_map_request(XEvent *xevent)
1108{
1109 Ecore_X_Event_Window_Show_Request *e;
1110
1111 _ecore_x_last_event_mouse_move = 0;
1112 e = calloc(1, sizeof(Ecore_X_Event_Window_Show_Request));
1113 if (!e)
1114 return;
1115
1116 e->win = xevent->xmaprequest.window;
1117 e->time = _ecore_x_event_last_time;
1118 e->parent = xevent->xmaprequest.parent;
1119 ecore_event_add(ECORE_X_EVENT_WINDOW_SHOW_REQUEST, e, NULL, NULL);
1120} /* _ecore_x_event_handle_map_request */
1121
1122void
1123_ecore_x_event_handle_reparent_notify(XEvent *xevent)
1124{
1125 Ecore_X_Event_Window_Reparent *e;
1126
1127 _ecore_x_last_event_mouse_move = 0;
1128 e = calloc(1, sizeof(Ecore_X_Event_Window_Reparent));
1129 if (!e)
1130 return;
1131
1132 e->win = xevent->xreparent.window;
1133 e->event_win = xevent->xreparent.event;
1134 e->parent = xevent->xreparent.parent;
1135 e->time = _ecore_x_event_last_time;
1136 ecore_event_add(ECORE_X_EVENT_WINDOW_REPARENT, e, NULL, NULL);
1137} /* _ecore_x_event_handle_reparent_notify */
1138
1139void
1140_ecore_x_event_handle_configure_notify(XEvent *xevent)
1141{
1142 Ecore_X_Event_Window_Configure *e;
1143
1144 _ecore_x_last_event_mouse_move = 0;
1145 e = calloc(1, sizeof(Ecore_X_Event_Window_Configure));
1146 if (!e)
1147 return;
1148
1149 e->win = xevent->xconfigure.window;
1150 e->event_win = xevent->xconfigure.event;
1151 e->abovewin = xevent->xconfigure.above;
1152 e->x = xevent->xconfigure.x;
1153 e->y = xevent->xconfigure.y;
1154 e->w = xevent->xconfigure.width;
1155 e->h = xevent->xconfigure.height;
1156 e->border = xevent->xconfigure.border_width;
1157 e->override = xevent->xconfigure.override_redirect;
1158 e->from_wm = xevent->xconfigure.send_event;
1159 e->time = _ecore_x_event_last_time;
1160 ecore_event_add(ECORE_X_EVENT_WINDOW_CONFIGURE, e, NULL, NULL);
1161} /* _ecore_x_event_handle_configure_notify */
1162
1163void
1164_ecore_x_event_handle_configure_request(XEvent *xevent)
1165{
1166 Ecore_X_Event_Window_Configure_Request *e;
1167
1168 _ecore_x_last_event_mouse_move = 0;
1169 e = calloc(1, sizeof(Ecore_X_Event_Window_Configure_Request));
1170 if (!e)
1171 return;
1172
1173 e->win = xevent->xconfigurerequest.window;
1174 e->parent_win = xevent->xconfigurerequest.parent;
1175 e->abovewin = xevent->xconfigurerequest.above;
1176 e->x = xevent->xconfigurerequest.x;
1177 e->y = xevent->xconfigurerequest.y;
1178 e->w = xevent->xconfigurerequest.width;
1179 e->h = xevent->xconfigurerequest.height;
1180 e->border = xevent->xconfigurerequest.border_width;
1181 e->value_mask = xevent->xconfigurerequest.value_mask;
1182 e->time = _ecore_x_event_last_time;
1183
1184 if (xevent->xconfigurerequest.detail == Above)
1185 e->detail = ECORE_X_WINDOW_STACK_ABOVE;
1186 else if (xevent->xconfigurerequest.detail == Below)
1187 e->detail = ECORE_X_WINDOW_STACK_BELOW;
1188 else if (xevent->xconfigurerequest.detail == TopIf)
1189 e->detail = ECORE_X_WINDOW_STACK_TOP_IF;
1190 else if (xevent->xconfigurerequest.detail == BottomIf)
1191 e->detail = ECORE_X_WINDOW_STACK_BOTTOM_IF;
1192 else if (xevent->xconfigurerequest.detail == Opposite)
1193 e->detail = ECORE_X_WINDOW_STACK_OPPOSITE;
1194
1195 ecore_event_add(ECORE_X_EVENT_WINDOW_CONFIGURE_REQUEST, e, NULL, NULL);
1196} /* _ecore_x_event_handle_configure_request */
1197
1198void
1199_ecore_x_event_handle_gravity_notify(XEvent *xevent __UNUSED__)
1200{
1201 _ecore_x_last_event_mouse_move = 0;
1202 /* FIXME: handle this event type */
1203} /* _ecore_x_event_handle_gravity_notify */
1204
1205void
1206_ecore_x_event_handle_resize_request(XEvent *xevent)
1207{
1208 Ecore_X_Event_Window_Resize_Request *e;
1209
1210 _ecore_x_last_event_mouse_move = 0;
1211 e = calloc(1, sizeof(Ecore_X_Event_Window_Resize_Request));
1212 if (!e)
1213 return;
1214
1215 e->win = xevent->xresizerequest.window;
1216 e->w = xevent->xresizerequest.width;
1217 e->h = xevent->xresizerequest.height;
1218 e->time = _ecore_x_event_last_time;
1219 ecore_event_add(ECORE_X_EVENT_WINDOW_RESIZE_REQUEST, e, NULL, NULL);
1220} /* _ecore_x_event_handle_resize_request */
1221
1222void
1223_ecore_x_event_handle_circulate_notify(XEvent *xevent)
1224{
1225 Ecore_X_Event_Window_Stack *e;
1226
1227 _ecore_x_last_event_mouse_move = 0;
1228 e = calloc(1, sizeof(Ecore_X_Event_Window_Stack));
1229 if (!e)
1230 return;
1231
1232 e->win = xevent->xcirculate.window;
1233 e->event_win = xevent->xcirculate.event;
1234 if (xevent->xcirculate.place == PlaceOnTop)
1235 e->detail = ECORE_X_WINDOW_STACK_ABOVE;
1236 else
1237 e->detail = ECORE_X_WINDOW_STACK_BELOW;
1238
1239 e->time = _ecore_x_event_last_time;
1240 ecore_event_add(ECORE_X_EVENT_WINDOW_STACK, e, NULL, NULL);
1241} /* _ecore_x_event_handle_circulate_notify */
1242
1243void
1244_ecore_x_event_handle_circulate_request(XEvent *xevent)
1245{
1246 Ecore_X_Event_Window_Stack_Request *e;
1247
1248 _ecore_x_last_event_mouse_move = 0;
1249 e = calloc(1, sizeof(Ecore_X_Event_Window_Stack_Request));
1250 if (!e)
1251 return;
1252
1253 e->win = xevent->xcirculaterequest.window;
1254 e->parent = xevent->xcirculaterequest.parent;
1255 if (xevent->xcirculaterequest.place == PlaceOnTop)
1256 e->detail = ECORE_X_WINDOW_STACK_ABOVE;
1257 else
1258 e->detail = ECORE_X_WINDOW_STACK_BELOW;
1259
1260 e->time = _ecore_x_event_last_time;
1261 ecore_event_add(ECORE_X_EVENT_WINDOW_STACK_REQUEST, e, NULL, NULL);
1262} /* _ecore_x_event_handle_circulate_request */
1263
1264void
1265_ecore_x_event_handle_property_notify(XEvent *xevent)
1266{
1267 _ecore_x_last_event_mouse_move = 0;
1268 {
1269 Ecore_X_Event_Window_Property *e;
1270
1271 e = calloc(1, sizeof(Ecore_X_Event_Window_Property));
1272 if (!e)
1273 return;
1274
1275 e->win = xevent->xproperty.window;
1276 e->atom = xevent->xproperty.atom;
1277 e->time = xevent->xproperty.time;
1278 _ecore_x_event_last_time = e->time;
1279 ecore_event_add(ECORE_X_EVENT_WINDOW_PROPERTY, e, NULL, NULL);
1280 }
1281} /* _ecore_x_event_handle_property_notify */
1282
1283void
1284_ecore_x_event_handle_selection_clear(XEvent *xevent)
1285{
1286// Ecore_X_Selection_Intern *d;
1287 Ecore_X_Event_Selection_Clear *e;
1288 Ecore_X_Atom sel;
1289
1290 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1291 _ecore_x_last_event_mouse_move = 0;
1292/* errr..... why? paranoia.
1293 d = _ecore_x_selection_get(xevent->xselectionclear.selection);
1294 if (d && (xevent->xselectionclear.time > d->time))
1295 {
1296 _ecore_x_selection_set(None, NULL, 0,
1297 xevent->xselectionclear.selection);
1298 }
1299 */
1300/* Generate event for app cleanup */
1301 e = malloc(sizeof(Ecore_X_Event_Selection_Clear));
1302 e->win = xevent->xselectionclear.window;
1303 e->time = xevent->xselectionclear.time;
1304 e->atom = sel = xevent->xselectionclear.selection;
1305 if (sel == ECORE_X_ATOM_SELECTION_PRIMARY)
1306 e->selection = ECORE_X_SELECTION_PRIMARY;
1307 else if (sel == ECORE_X_ATOM_SELECTION_SECONDARY)
1308 e->selection = ECORE_X_SELECTION_SECONDARY;
1309 else if (sel == ECORE_X_ATOM_SELECTION_CLIPBOARD)
1310 e->selection = ECORE_X_SELECTION_CLIPBOARD;
1311 else
1312 e->selection = ECORE_X_SELECTION_OTHER;
1313
1314 ecore_event_add(ECORE_X_EVENT_SELECTION_CLEAR, e, NULL, NULL);
1315} /* _ecore_x_event_handle_selection_clear */
1316
1317void
1318_ecore_x_event_handle_selection_request(XEvent *xevent)
1319{
1320 Ecore_X_Event_Selection_Request *e;
1321 Ecore_X_Selection_Intern *sd;
1322 void *data = NULL;
1323 int len;
1324 int typesize;
1325
1326 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1327 _ecore_x_last_event_mouse_move = 0;
1328 /*
1329 * Generate a selection request event.
1330 */
1331 e = malloc(sizeof(Ecore_X_Event_Selection_Request));
1332 e->owner = xevent->xselectionrequest.owner;
1333 e->requestor = xevent->xselectionrequest.requestor;
1334 e->time = xevent->xselectionrequest.time;
1335 e->selection = xevent->xselectionrequest.selection;
1336 e->target = xevent->xselectionrequest.target;
1337 e->property = xevent->xselectionrequest.property;
1338 ecore_event_add(ECORE_X_EVENT_SELECTION_REQUEST, e, NULL, NULL);
1339
1340 if ((sd = _ecore_x_selection_get(xevent->xselectionrequest.selection)) &&
1341 (sd->win == xevent->xselectionrequest.owner))
1342 {
1343 Ecore_X_Selection_Intern *si;
1344
1345 si = _ecore_x_selection_get(xevent->xselectionrequest.selection);
1346 if (si->data)
1347 {
1348 Ecore_X_Atom property = None;
1349 Ecore_X_Atom type;
1350
1351 /* Set up defaults for strings first */
1352 type = xevent->xselectionrequest.target;
1353 typesize = 8;
1354 len = sd->length;
1355
1356 if (!ecore_x_selection_convert(xevent->xselectionrequest.selection,
1357 xevent->xselectionrequest.target,
1358 &data, &len, &type, &typesize))
1359 /* Refuse selection, conversion to requested target failed */
1360 property = None;
1361 else if (data)
1362 {
1363 /* FIXME: This does not properly handle large data transfers */
1364 ecore_x_window_prop_property_set(
1365 xevent->xselectionrequest.requestor,
1366 xevent->xselectionrequest.
1367 property,
1368 type,
1369 typesize,
1370 data,
1371 len);
1372 property = xevent->xselectionrequest.property;
1373 free(data);
1374 }
1375
1376 ecore_x_selection_notify_send(xevent->xselectionrequest.requestor,
1377 xevent->xselectionrequest.selection,
1378 xevent->xselectionrequest.target,
1379 property,
1380 xevent->xselectionrequest.time);
1381 }
1382 }
1383} /* _ecore_x_event_handle_selection_request */
1384
1385void
1386_ecore_x_event_handle_selection_notify(XEvent *xevent)
1387{
1388 Ecore_X_Event_Selection_Notify *e;
1389 unsigned char *data = NULL;
1390 Ecore_X_Atom selection;
1391 int num_ret, format;
1392
1393 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1394 _ecore_x_last_event_mouse_move = 0;
1395 selection = xevent->xselection.selection;
1396
1397 if (xevent->xselection.target == ECORE_X_ATOM_SELECTION_TARGETS)
1398 {
1399 format = ecore_x_window_prop_property_get(xevent->xselection.requestor,
1400 xevent->xselection.property,
1401 XA_ATOM, 32, &data, &num_ret);
1402 if (!format)
1403 return;
1404 }
1405 else
1406 {
1407 format = ecore_x_window_prop_property_get(xevent->xselection.requestor,
1408 xevent->xselection.property,
1409 AnyPropertyType, 8, &data,
1410 &num_ret);
1411 if (!format)
1412 return;
1413 }
1414
1415 e = calloc(1, sizeof(Ecore_X_Event_Selection_Notify));
1416 if (!e)
1417 return;
1418
1419 e->win = xevent->xselection.requestor;
1420 e->time = xevent->xselection.time;
1421 e->atom = selection;
1422 e->target = _ecore_x_selection_target_get(xevent->xselection.target);
1423
1424 if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
1425 e->selection = ECORE_X_SELECTION_PRIMARY;
1426 else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY)
1427 e->selection = ECORE_X_SELECTION_SECONDARY;
1428 else if (selection == ECORE_X_ATOM_SELECTION_XDND)
1429 e->selection = ECORE_X_SELECTION_XDND;
1430 else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
1431 e->selection = ECORE_X_SELECTION_CLIPBOARD;
1432 else
1433 e->selection = ECORE_X_SELECTION_OTHER;
1434
1435 e->data = _ecore_x_selection_parse(e->target, data, num_ret, format);
1436
1437 ecore_event_add(ECORE_X_EVENT_SELECTION_NOTIFY, e,
1438 _ecore_x_event_free_selection_notify, NULL);
1439} /* _ecore_x_event_handle_selection_notify */
1440
1441void
1442_ecore_x_event_handle_colormap_notify(XEvent *xevent)
1443{
1444 Ecore_X_Event_Window_Colormap *e;
1445
1446 _ecore_x_last_event_mouse_move = 0;
1447 e = calloc(1, sizeof(Ecore_X_Event_Window_Colormap));
1448 if (!e)
1449 return;
1450
1451 e->win = xevent->xcolormap.window;
1452 e->cmap = xevent->xcolormap.colormap;
1453 e->time = _ecore_x_event_last_time;
1454 if (xevent->xcolormap.state == ColormapInstalled)
1455 e->installed = EINA_TRUE;
1456 else
1457 e->installed = EINA_FALSE;
1458
1459 ecore_event_add(ECORE_X_EVENT_WINDOW_COLORMAP, e, NULL, NULL);
1460} /* _ecore_x_event_handle_colormap_notify */
1461
1462void
1463_ecore_x_event_handle_client_message(XEvent *xevent)
1464{
1465 _ecore_x_last_event_mouse_move = 0;
1466 /* Special client message event handling here. need to put LOTS of if */
1467 /* checks here and generate synthetic events per special message known */
1468 /* otherwise generate generic client message event. this would handle*/
1469 /* netwm, ICCCM, gnomewm, old kde and mwm hint client message protocols */
1470 if ((xevent->xclient.message_type == ECORE_X_ATOM_WM_PROTOCOLS) &&
1471 (xevent->xclient.format == 32) &&
1472 (xevent->xclient.data.l[0] == (long)ECORE_X_ATOM_WM_DELETE_WINDOW))
1473 {
1474 Ecore_X_Event_Window_Delete_Request *e;
1475
1476 e = calloc(1, sizeof(Ecore_X_Event_Window_Delete_Request));
1477 if (!e)
1478 return;
1479
1480 e->win = xevent->xclient.window;
1481 e->time = _ecore_x_event_last_time;
1482 ecore_event_add(ECORE_X_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL);
1483 }
1484 else if ((xevent->xclient.message_type == ECORE_X_ATOM_NET_WM_MOVERESIZE) &&
1485 (xevent->xclient.format == 32) &&
1486/* Ignore move and resize with keyboard */
1487 (xevent->xclient.data.l[2] < 9))
1488 {
1489 Ecore_X_Event_Window_Move_Resize_Request *e;
1490
1491 e = calloc(1, sizeof(Ecore_X_Event_Window_Move_Resize_Request));
1492 if (!e)
1493 return;
1494
1495 e->win = xevent->xclient.window;
1496 e->x = xevent->xclient.data.l[0];
1497 e->y = xevent->xclient.data.l[1];
1498 e->direction = xevent->xclient.data.l[2];
1499 e->button = xevent->xclient.data.l[3];
1500 e->source = xevent->xclient.data.l[4];
1501 ecore_event_add(ECORE_X_EVENT_WINDOW_MOVE_RESIZE_REQUEST, e, NULL, NULL);
1502 }
1503 /* Xdnd Client Message Handling Begin */
1504 /* Message Type: XdndEnter target */
1505 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_ENTER)
1506 {
1507 Ecore_X_Event_Xdnd_Enter *e;
1508 Ecore_X_DND_Target *target;
1509
1510 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Enter));
1511 if (!e) return;
1512
1513 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1514
1515 target = _ecore_x_dnd_target_get();
1516 target->state = ECORE_X_DND_TARGET_ENTERED;
1517 target->source = xevent->xclient.data.l[0];
1518 target->win = xevent->xclient.window;
1519 target->version = (int)(xevent->xclient.data.l[1] >> 24);
1520 if (target->version > ECORE_X_DND_VERSION)
1521 {
1522 WRN("DND: Requested version %d, we only support up to %d",
1523 target->version, ECORE_X_DND_VERSION);
1524 free(e);
1525 return;
1526 }
1527
1528 if (xevent->xclient.data.l[1] & 0x1UL)
1529 {
1530 /* source supports more than 3 types, fetch property */
1531 unsigned char *data;
1532 Ecore_X_Atom *types;
1533 int i, num_ret;
1534
1535 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1536 if (!(ecore_x_window_prop_property_get(target->source,
1537 ECORE_X_ATOM_XDND_TYPE_LIST,
1538 XA_ATOM,
1539 32, &data, &num_ret)))
1540 {
1541 WRN(
1542 "DND: Could not fetch data type list from source window, aborting.");
1543 free(e);
1544 return;
1545 }
1546
1547 types = (Ecore_X_Atom *)data;
1548 e->types = calloc(num_ret, sizeof(char *));
1549 if (e->types)
1550 {
1551 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1552 for (i = 0; i < num_ret; i++)
1553 e->types[i] = XGetAtomName(_ecore_x_disp, types[i]);
1554 }
1555
1556 e->num_types = num_ret;
1557 }
1558 else
1559 {
1560 int i = 0;
1561
1562 e->types = calloc(3, sizeof(char *));
1563 if (e->types)
1564 {
1565 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1566 while ((i < 3) && (xevent->xclient.data.l[i + 2]))
1567 {
1568 e->types[i] = XGetAtomName(_ecore_x_disp,
1569 xevent->xclient.data.l[i + 2]);
1570 i++;
1571 }
1572 }
1573
1574 e->num_types = i;
1575 }
1576
1577 e->win = target->win;
1578 e->source = target->source;
1579 ecore_event_add(ECORE_X_EVENT_XDND_ENTER, e,
1580 _ecore_x_event_free_xdnd_enter, NULL);
1581 }
1582 /* Message Type: XdndPosition target */
1583 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_POSITION)
1584 {
1585 Ecore_X_Event_Xdnd_Position *e;
1586 Ecore_X_DND_Target *target;
1587
1588 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1589
1590 target = _ecore_x_dnd_target_get();
1591 if ((target->source != (Ecore_X_Window)xevent->xclient.data.l[0]) ||
1592 (target->win != xevent->xclient.window))
1593 return;
1594
1595 target->pos.x = xevent->xclient.data.l[2] >> 16;
1596 target->pos.y = xevent->xclient.data.l[2] & 0xFFFFUL;
1597 target->action = xevent->xclient.data.l[4]; /* Version 2 */
1598
1599 target->time = (target->version >= 1) ?
1600 (Time)xevent->xclient.data.l[3] : CurrentTime;
1601
1602 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Position));
1603 if (!e) return;
1604
1605 e->win = target->win;
1606 e->source = target->source;
1607 e->position.x = target->pos.x;
1608 e->position.y = target->pos.y;
1609 e->action = target->action;
1610 ecore_event_add(ECORE_X_EVENT_XDND_POSITION, e, NULL, NULL);
1611 }
1612 /* Message Type: XdndStatus source */
1613 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_STATUS)
1614 {
1615 Ecore_X_Event_Xdnd_Status *e;
1616 Ecore_X_DND_Source *source;
1617
1618 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1619
1620 source = _ecore_x_dnd_source_get();
1621 /* Make sure source/target match */
1622 if ((source->win != xevent->xclient.window) ||
1623 (source->dest != (Window)xevent->xclient.data.l[0]))
1624 return;
1625
1626 source->await_status = 0;
1627
1628 source->will_accept = xevent->xclient.data.l[1] & 0x1UL;
1629 source->suppress = (xevent->xclient.data.l[1] & 0x2UL) ? 0 : 1;
1630
1631 source->rectangle.x = xevent->xclient.data.l[2] >> 16;
1632 source->rectangle.y = xevent->xclient.data.l[2] & 0xFFFFUL;
1633 source->rectangle.width = xevent->xclient.data.l[3] >> 16;
1634 source->rectangle.height = xevent->xclient.data.l[3] & 0xFFFFUL;
1635
1636 source->accepted_action = xevent->xclient.data.l[4];
1637
1638 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Status));
1639 if (!e) return;
1640
1641 e->win = source->win;
1642 e->target = source->dest;
1643 e->will_accept = source->will_accept;
1644 e->rectangle.x = source->rectangle.x;
1645 e->rectangle.y = source->rectangle.y;
1646 e->rectangle.width = source->rectangle.width;
1647 e->rectangle.height = source->rectangle.height;
1648 e->action = source->accepted_action;
1649
1650 ecore_event_add(ECORE_X_EVENT_XDND_STATUS, e, NULL, NULL);
1651 }
1652 /* Message Type: XdndLeave target */
1653 /* Pretend the whole thing never happened, sort of */
1654 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_LEAVE)
1655 {
1656 Ecore_X_Event_Xdnd_Leave *e;
1657 Ecore_X_DND_Target *target;
1658
1659 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1660
1661 target = _ecore_x_dnd_target_get();
1662 if ((target->source != (Ecore_X_Window)xevent->xclient.data.l[0]) ||
1663 (target->win != xevent->xclient.window))
1664 return;
1665
1666 target->state = ECORE_X_DND_TARGET_IDLE;
1667
1668 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Leave));
1669 if (!e) return;
1670
1671 e->win = xevent->xclient.window;
1672 e->source = (Window)xevent->xclient.data.l[0];
1673 ecore_event_add(ECORE_X_EVENT_XDND_LEAVE, e, NULL, NULL);
1674 }
1675 /* Message Type: XdndDrop target */
1676 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_DROP)
1677 {
1678 Ecore_X_Event_Xdnd_Drop *e;
1679 Ecore_X_DND_Target *target;
1680
1681 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1682
1683 target = _ecore_x_dnd_target_get();
1684 /* Match source/target */
1685 if ((target->source != (Window)xevent->xclient.data.l[0]) ||
1686 (target->win != xevent->xclient.window))
1687 return;
1688
1689 target->time = (target->version >= 1) ?
1690 (Time)xevent->xclient.data.l[2] : _ecore_x_event_last_time;
1691
1692 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Drop));
1693 if (!e) return;
1694
1695 e->win = target->win;
1696 e->source = target->source;
1697 e->action = target->action;
1698 e->position.x = target->pos.x;
1699 e->position.y = target->pos.y;
1700 ecore_event_add(ECORE_X_EVENT_XDND_DROP, e, NULL, NULL);
1701 }
1702 /* Message Type: XdndFinished source */
1703 else if (xevent->xclient.message_type == ECORE_X_ATOM_XDND_FINISHED)
1704 {
1705 Ecore_X_Event_Xdnd_Finished *e;
1706 Ecore_X_DND_Source *source;
1707 Eina_Bool completed = EINA_TRUE;
1708
1709 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1710
1711 source = _ecore_x_dnd_source_get();
1712 /* Match source/target */
1713 if ((source->win != xevent->xclient.window) ||
1714 (source->dest != (Window)xevent->xclient.data.l[0]))
1715 return;
1716
1717 if ((source->version < 5) || (xevent->xclient.data.l[1] & 0x1UL))
1718 {
1719 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1720 /* Target successfully performed drop action */
1721 ecore_x_selection_xdnd_clear();
1722 source->state = ECORE_X_DND_SOURCE_IDLE;
1723 }
1724 else if (source->version >= 5)
1725 {
1726 completed = EINA_FALSE;
1727 source->state = ECORE_X_DND_SOURCE_CONVERTING;
1728
1729 /* FIXME: Probably need to add a timer to switch back to idle
1730 * and discard the selection data */
1731 }
1732
1733 e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Finished));
1734 if (!e) return;
1735
1736 e->win = source->win;
1737 e->target = source->dest;
1738 e->completed = completed;
1739 if (source->version >= 5)
1740 {
1741 source->accepted_action = xevent->xclient.data.l[2];
1742 e->action = source->accepted_action;
1743 }
1744 else
1745 {
1746 source->accepted_action = 0;
1747 e->action = source->action;
1748 }
1749
1750 ecore_event_add(ECORE_X_EVENT_XDND_FINISHED, e, NULL, NULL);
1751 }
1752 else if (xevent->xclient.message_type == ECORE_X_ATOM_NET_WM_STATE)
1753 {
1754 Ecore_X_Event_Window_State_Request *e;
1755
1756 e = calloc(1, sizeof(Ecore_X_Event_Window_State_Request));
1757 if (!e) return;
1758
1759 e->win = xevent->xclient.window;
1760 if (xevent->xclient.data.l[0] == 0)
1761 e->action = ECORE_X_WINDOW_STATE_ACTION_REMOVE;
1762 else if (xevent->xclient.data.l[0] == 1)
1763 e->action = ECORE_X_WINDOW_STATE_ACTION_ADD;
1764 else if (xevent->xclient.data.l[0] == 2)
1765 e->action = ECORE_X_WINDOW_STATE_ACTION_TOGGLE;
1766 else
1767 {
1768 free(e);
1769 return;
1770 }
1771
1772 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1773 e->state[0] = _ecore_x_netwm_state_get(xevent->xclient.data.l[1]);
1774 if (e->state[0] == ECORE_X_WINDOW_STATE_UNKNOWN)
1775 {
1776// char *name;
1777 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1778
1779// name = XGetAtomName(_ecore_x_disp, xevent->xclient.data.l[1]);
1780// if (name) ERR("Unknown state: %s", name);
1781// XFree(name);
1782 }
1783 e->state[1] = _ecore_x_netwm_state_get(xevent->xclient.data.l[2]);
1784 if (e->state[1] == ECORE_X_WINDOW_STATE_UNKNOWN)
1785 {
1786// char *name;
1787 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1788
1789// name = XGetAtomName(_ecore_x_disp, xevent->xclient.data.l[2]);
1790// if (name) ERR("Unknown state: %s", name);
1791// XFree(name);
1792 }
1793
1794 e->source = xevent->xclient.data.l[3];
1795
1796 ecore_event_add(ECORE_X_EVENT_WINDOW_STATE_REQUEST, e, NULL, NULL);
1797 }
1798 else if ((xevent->xclient.message_type == ECORE_X_ATOM_WM_CHANGE_STATE)
1799 && (xevent->xclient.format == 32)
1800 && (xevent->xclient.data.l[0] == IconicState))
1801 {
1802 Ecore_X_Event_Window_State_Request *e;
1803
1804 e = calloc(1, sizeof(Ecore_X_Event_Window_State_Request));
1805 if (!e)
1806 return;
1807
1808 e->win = xevent->xclient.window;
1809 e->action = ECORE_X_WINDOW_STATE_ACTION_ADD;
1810 e->state[0] = ECORE_X_WINDOW_STATE_ICONIFIED;
1811
1812 ecore_event_add(ECORE_X_EVENT_WINDOW_STATE_REQUEST, e, NULL, NULL);
1813 }
1814 else if ((xevent->xclient.message_type == ECORE_X_ATOM_NET_WM_DESKTOP)
1815 && (xevent->xclient.format == 32))
1816 {
1817 Ecore_X_Event_Desktop_Change *e;
1818
1819 e = calloc(1, sizeof(Ecore_X_Event_Desktop_Change));
1820 if (!e)
1821 return;
1822
1823 e->win = xevent->xclient.window;
1824 e->desk = xevent->xclient.data.l[0];
1825 e->source = xevent->xclient.data.l[1];
1826
1827 ecore_event_add(ECORE_X_EVENT_DESKTOP_CHANGE, e, NULL, NULL);
1828 }
1829 else if ((xevent->xclient.message_type ==
1830 ECORE_X_ATOM_NET_REQUEST_FRAME_EXTENTS))
1831 {
1832 Ecore_X_Event_Frame_Extents_Request *e;
1833
1834 e = calloc(1, sizeof(Ecore_X_Event_Frame_Extents_Request));
1835 if (!e)
1836 return;
1837
1838 e->win = xevent->xclient.window;
1839
1840 ecore_event_add(ECORE_X_EVENT_FRAME_EXTENTS_REQUEST, e, NULL, NULL);
1841 }
1842 else if ((xevent->xclient.message_type == ECORE_X_ATOM_WM_PROTOCOLS)
1843 && ((Ecore_X_Atom)xevent->xclient.data.l[0] ==
1844 ECORE_X_ATOM_NET_WM_PING)
1845 && (xevent->xclient.format == 32))
1846 {
1847 Ecore_X_Event_Ping *e;
1848 Ecore_X_Window root = 0;
1849
1850 e = calloc(1, sizeof(Ecore_X_Event_Ping));
1851 if (!e)
1852 return;
1853
1854 e->win = xevent->xclient.window;
1855 e->time = xevent->xclient.data.l[1];
1856 e->event_win = xevent->xclient.data.l[2];
1857
1858 /* send a reply anyway - we are alive... eventloop at least */
1859 ecore_event_add(ECORE_X_EVENT_PING, e, NULL, NULL);
1860 if (ScreenCount(_ecore_x_disp) > 1)
1861 {
1862 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1863 root = ecore_x_window_root_get(e->win);
1864 }
1865 else
1866 root = DefaultRootWindow(_ecore_x_disp);
1867
1868 if (xevent->xclient.window != root)
1869 {
1870 xevent->xclient.window = root;
1871 XSendEvent(_ecore_x_disp, root, False,
1872 SubstructureRedirectMask | SubstructureNotifyMask,
1873 xevent);
1874 }
1875 }
1876 else if ((xevent->xclient.message_type ==
1877 ECORE_X_ATOM_NET_STARTUP_INFO_BEGIN) &&
1878 (xevent->xclient.format == 8))
1879 _ecore_x_netwm_startup_info_begin(xevent->xclient.window,
1880 xevent->xclient.data.b);
1881 else if ((xevent->xclient.message_type == ECORE_X_ATOM_NET_STARTUP_INFO) &&
1882 (xevent->xclient.format == 8))
1883 _ecore_x_netwm_startup_info(xevent->xclient.window,
1884 xevent->xclient.data.b);
1885 else if ((xevent->xclient.message_type == 27777)
1886 && (xevent->xclient.data.l[0] == 0x7162534)
1887 && (xevent->xclient.format == 32)
1888 && (xevent->xclient.window == _ecore_x_private_win))
1889 {
1890 /* a grab sync marker */
1891 if (xevent->xclient.data.l[1] == 0x10000001)
1892 _ecore_x_window_grab_remove(xevent->xclient.data.l[2]);
1893 else if (xevent->xclient.data.l[1] == 0x10000002)
1894 _ecore_x_key_grab_remove(xevent->xclient.data.l[2]);
1895 }
1896 else
1897 {
1898 Ecore_X_Event_Client_Message *e;
1899 int i;
1900
1901 e = calloc(1, sizeof(Ecore_X_Event_Client_Message));
1902 if (!e)
1903 return;
1904
1905 e->win = xevent->xclient.window;
1906 e->message_type = xevent->xclient.message_type;
1907 e->format = xevent->xclient.format;
1908 for (i = 0; i < 5; i++)
1909 e->data.l[i] = xevent->xclient.data.l[i];
1910
1911 ecore_event_add(ECORE_X_EVENT_CLIENT_MESSAGE, e, NULL, NULL);
1912 }
1913} /* _ecore_x_event_handle_client_message */
1914
1915void
1916_ecore_x_event_handle_mapping_notify(XEvent *xevent)
1917{
1918 Ecore_X_Event_Mapping_Change *e;
1919
1920 _ecore_x_last_event_mouse_move = 0;
1921 XRefreshKeyboardMapping((XMappingEvent *)xevent);
1922 _ecore_x_modifiers_get();
1923 e = calloc(1, sizeof(Ecore_X_Event_Mapping_Change));
1924 if (!e) return;
1925 switch (xevent->xmapping.request)
1926 {
1927 case MappingModifier:
1928 e->type = ECORE_X_MAPPING_MODIFIER;
1929 break;
1930
1931 case MappingKeyboard:
1932 e->type = ECORE_X_MAPPING_KEYBOARD;
1933 break;
1934
1935 case MappingPointer:
1936 default:
1937 e->type = ECORE_X_MAPPING_MOUSE;
1938 break;
1939 }
1940 e->keycode = xevent->xmapping.first_keycode;
1941 e->num = xevent->xmapping.count;
1942 ecore_event_add(ECORE_X_EVENT_MAPPING_CHANGE, e, NULL, NULL);
1943} /* _ecore_x_event_handle_mapping_notify */
1944
1945void
1946_ecore_x_event_handle_shape_change(XEvent *xevent)
1947{
1948 XShapeEvent *shape_event;
1949 Ecore_X_Event_Window_Shape *e;
1950
1951 _ecore_x_last_event_mouse_move = 0;
1952 shape_event = (XShapeEvent *)xevent;
1953 e = calloc(1, sizeof(Ecore_X_Event_Window_Shape));
1954 if (!e)
1955 return;
1956
1957 e->win = shape_event->window;
1958 e->time = shape_event->time;
1959 switch (shape_event->kind)
1960 {
1961 case ShapeBounding:
1962 e->type = ECORE_X_SHAPE_BOUNDING;
1963 break;
1964
1965 case ShapeClip:
1966 e->type = ECORE_X_SHAPE_CLIP;
1967 break;
1968
1969 case ShapeInput:
1970 e->type = ECORE_X_SHAPE_INPUT;
1971 break;
1972
1973 default:
1974 break;
1975 }
1976 e->x = shape_event->x;
1977 e->y = shape_event->y;
1978 e->w = shape_event->width;
1979 e->h = shape_event->height;
1980 e->shaped = shape_event->shaped;
1981 ecore_event_add(ECORE_X_EVENT_WINDOW_SHAPE, e, NULL, NULL);
1982} /* _ecore_x_event_handle_shape_change */
1983
1984void
1985_ecore_x_event_handle_screensaver_notify(XEvent *xevent)
1986{
1987#ifdef ECORE_XSS
1988 XScreenSaverNotifyEvent *screensaver_event;
1989 Ecore_X_Event_Screensaver_Notify *e;
1990
1991 _ecore_x_last_event_mouse_move = 0;
1992 screensaver_event = (XScreenSaverNotifyEvent *)xevent;
1993 e = calloc(1, sizeof(Ecore_X_Event_Screensaver_Notify));
1994 if (!e)
1995 return;
1996
1997 e->win = screensaver_event->window;
1998 if (screensaver_event->state == ScreenSaverOn)
1999 e->on = EINA_TRUE;
2000 else
2001 e->on = EINA_FALSE;
2002
2003 e->time = screensaver_event->time;
2004 ecore_event_add(ECORE_X_EVENT_SCREENSAVER_NOTIFY, e, NULL, NULL);
2005#else /* ifdef ECORE_XSS */
2006 xevent = NULL;
2007#endif /* ifdef ECORE_XSS */
2008} /* _ecore_x_event_handle_screensaver_notify */
2009
2010void
2011_ecore_x_event_handle_sync_counter(XEvent *xevent)
2012{
2013 XSyncCounterNotifyEvent *sync_counter_event;
2014 Ecore_X_Event_Sync_Counter *e;
2015
2016 _ecore_x_last_event_mouse_move = 0;
2017 sync_counter_event = (XSyncCounterNotifyEvent *)xevent;
2018 e = calloc(1, sizeof(Ecore_X_Event_Sync_Counter));
2019 if (!e)
2020 return;
2021
2022 e->time = sync_counter_event->time;
2023 ecore_event_add(ECORE_X_EVENT_SYNC_COUNTER, e, NULL, NULL);
2024} /* _ecore_x_event_handle_sync_counter */
2025
2026void
2027_ecore_x_event_handle_sync_alarm(XEvent *xevent)
2028{
2029 XSyncAlarmNotifyEvent *sync_alarm_event;
2030 Ecore_X_Event_Sync_Alarm *e;
2031
2032 _ecore_x_last_event_mouse_move = 0;
2033 sync_alarm_event = (XSyncAlarmNotifyEvent *)xevent;
2034
2035 e = calloc(1, sizeof(Ecore_X_Event_Sync_Alarm));
2036 if (!e)
2037 return;
2038
2039 e->time = sync_alarm_event->time;
2040 e->alarm = sync_alarm_event->alarm;
2041 ecore_event_add(ECORE_X_EVENT_SYNC_ALARM, e, NULL, NULL);
2042} /* _ecore_x_event_handle_sync_alarm */
2043
2044#ifdef ECORE_XRANDR
2045void
2046_ecore_x_event_handle_randr_change(XEvent *xevent)
2047{
2048 XRRScreenChangeNotifyEvent *randr_event;
2049 Ecore_X_Event_Screen_Change *e;
2050
2051 _ecore_x_last_event_mouse_move = 0;
2052 randr_event = (XRRScreenChangeNotifyEvent *)xevent;
2053 if (!XRRUpdateConfiguration(xevent))
2054 ERR("Can't update RR config!");
2055
2056 e = calloc(1, sizeof(Ecore_X_Event_Screen_Change));
2057 if (!e)
2058 return;
2059
2060 e->win = randr_event->window;
2061 e->root = randr_event->root;
2062 e->size.width = randr_event->width;
2063 e->size.height = randr_event->height;
2064 e->time = randr_event->timestamp;
2065 e->config_time = randr_event->config_timestamp;
2066 e->size.width_mm = randr_event->mwidth;
2067 e->size.height_mm = randr_event->mheight;
2068 e->orientation = randr_event->rotation;
2069 e->subpixel_order = randr_event->subpixel_order;
2070 ecore_event_add(ECORE_X_EVENT_SCREEN_CHANGE, e, NULL, NULL);
2071} /* _ecore_x_event_handle_randr_change */
2072
2073static void
2074_ecore_x_event_handle_randr_notify_crtc_change(const XRRNotifyEvent *xevent)
2075{
2076 const XRRCrtcChangeNotifyEvent *randr_event;
2077 Ecore_X_Event_Randr_Crtc_Change *e;
2078
2079 randr_event = (const XRRCrtcChangeNotifyEvent *)xevent;
2080
2081 e = calloc(1, sizeof(Ecore_X_Event_Randr_Crtc_Change));
2082 if (!e)
2083 return;
2084
2085 e->win = randr_event->window;
2086 e->crtc = randr_event->crtc;
2087 e->mode = randr_event->mode;
2088 e->orientation = randr_event->rotation;
2089 e->geo.x = randr_event->x;
2090 e->geo.y = randr_event->y;
2091 e->geo.w = randr_event->width;
2092 e->geo.h = randr_event->height;
2093 ecore_event_add(ECORE_X_EVENT_RANDR_CRTC_CHANGE, e, NULL, NULL);
2094} /* _ecore_x_event_handle_randr_notify_crtc_change */
2095
2096static void
2097_ecore_x_event_handle_randr_notify_output_change(const XRRNotifyEvent *xevent)
2098{
2099 const XRROutputChangeNotifyEvent *randr_event;
2100 Ecore_X_Event_Randr_Output_Change *e;
2101
2102 randr_event = (const XRROutputChangeNotifyEvent *)xevent;
2103
2104 e = calloc(1, sizeof(Ecore_X_Event_Randr_Output_Change));
2105 if (!e)
2106 return;
2107
2108 e->win = randr_event->window;
2109 e->output = randr_event->output;
2110 e->crtc = randr_event->crtc;
2111 e->mode = randr_event->mode;
2112 e->orientation = randr_event->rotation;
2113 e->connection = randr_event->connection;
2114 e->subpixel_order = randr_event->subpixel_order;
2115 ecore_event_add(ECORE_X_EVENT_RANDR_OUTPUT_CHANGE, e, NULL, NULL);
2116} /* _ecore_x_event_handle_randr_notify_output_change */
2117
2118static void
2119_ecore_x_event_handle_randr_notify_output_property(const XRRNotifyEvent *xevent)
2120{
2121 const XRROutputPropertyNotifyEvent *randr_event;
2122 Ecore_X_Event_Randr_Output_Property_Notify *e;
2123
2124 randr_event = (const XRROutputPropertyNotifyEvent *)xevent;
2125
2126 e = calloc(1, sizeof(Ecore_X_Event_Randr_Output_Property_Notify));
2127 if (!e)
2128 return;
2129
2130 e->win = randr_event->window;
2131 e->output = randr_event->output;
2132 e->property = randr_event->property;
2133 e->time = randr_event->timestamp;
2134 if (randr_event->state == PropertyNewValue)
2135 e->state = ECORE_X_RANDR_PROPERTY_CHANGE_ADD;
2136 else
2137 e->state = ECORE_X_RANDR_PROPERTY_CHANGE_DEL;
2138 ecore_event_add(ECORE_X_EVENT_RANDR_OUTPUT_PROPERTY_NOTIFY, e, NULL, NULL);
2139} /* _ecore_x_event_handle_randr_notify_output_property */
2140
2141void
2142_ecore_x_event_handle_randr_notify(XEvent *xevent)
2143{
2144 const XRRNotifyEvent *randr_event;
2145
2146 _ecore_x_last_event_mouse_move = 0;
2147 randr_event = (const XRRNotifyEvent *)xevent;
2148 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2149 switch (randr_event->subtype)
2150 {
2151 case RRNotify_CrtcChange:
2152 _ecore_x_event_handle_randr_notify_crtc_change(randr_event);
2153 break;
2154
2155 case RRNotify_OutputChange:
2156 _ecore_x_event_handle_randr_notify_output_change(randr_event);
2157 break;
2158
2159 case RRNotify_OutputProperty:
2160 _ecore_x_event_handle_randr_notify_output_property(randr_event);
2161 break;
2162
2163 default:
2164 ERR("Unknown XRandR RRNotify subtype: %d.",
2165 randr_event->subtype);
2166 break;
2167 } /* switch */
2168} /* _ecore_x_event_handle_randr_notify */
2169
2170#endif /* ifdef ECORE_XRANDR */
2171
2172#ifdef ECORE_XFIXES
2173void
2174_ecore_x_event_handle_fixes_selection_notify(XEvent *event)
2175{
2176 XFixesSelectionNotifyEvent *notify_event =
2177 (XFixesSelectionNotifyEvent *)event;
2178 Ecore_X_Event_Fixes_Selection_Notify *e;
2179 Ecore_X_Atom sel;
2180
2181 _ecore_x_last_event_mouse_move = 0;
2182 /* Nothing here yet */
2183
2184 e = calloc(1, sizeof(*e));
2185 if (!e)
2186 return;
2187
2188 e->win = notify_event->window;
2189 e->owner = notify_event->owner;
2190 e->time = notify_event->timestamp;
2191 e->selection_time = notify_event->selection_timestamp;
2192 e->atom = sel = notify_event->selection;
2193 if (sel == ECORE_X_ATOM_SELECTION_PRIMARY)
2194 e->selection = ECORE_X_SELECTION_PRIMARY;
2195 else if (sel == ECORE_X_ATOM_SELECTION_SECONDARY)
2196 e->selection = ECORE_X_SELECTION_SECONDARY;
2197 else if (sel == ECORE_X_ATOM_SELECTION_CLIPBOARD)
2198 e->selection = ECORE_X_SELECTION_CLIPBOARD;
2199 else
2200 e->selection = ECORE_X_SELECTION_OTHER;
2201 e->reason = notify_event->subtype;
2202
2203 ecore_event_add(ECORE_X_EVENT_FIXES_SELECTION_NOTIFY, e, NULL, NULL);
2204} /* _ecore_x_event_handle_fixes_selection_notify */
2205
2206#endif /* ifdef ECORE_XFIXES */
2207
2208#ifdef ECORE_XDAMAGE
2209void
2210_ecore_x_event_handle_damage_notify(XEvent *event)
2211{
2212 XDamageNotifyEvent *damage_event;
2213 Ecore_X_Event_Damage *e;
2214
2215 _ecore_x_last_event_mouse_move = 0;
2216 damage_event = (XDamageNotifyEvent *)event;
2217
2218 e = calloc(1, sizeof(Ecore_X_Event_Damage));
2219 if (!e)
2220 return;
2221
2222 e->level = damage_event->level;
2223 e->drawable = damage_event->drawable;
2224 e->damage = damage_event->damage;
2225 e->more = damage_event->more;
2226 e->time = damage_event->timestamp;
2227 e->area.x = damage_event->area.x;
2228 e->area.y = damage_event->area.y;
2229 e->area.width = damage_event->area.width;
2230 e->area.height = damage_event->area.height;
2231 e->geometry.x = damage_event->geometry.x;
2232 e->geometry.y = damage_event->geometry.y;
2233 e->geometry.width = damage_event->geometry.width;
2234 e->geometry.height = damage_event->geometry.height;
2235
2236 ecore_event_add(ECORE_X_EVENT_DAMAGE_NOTIFY, e, NULL, NULL);
2237} /* _ecore_x_event_handle_damage_notify */
2238
2239#endif /* ifdef ECORE_XDAMAGE */
2240
2241static void
2242_ecore_x_event_free_generic_event(void *data,
2243 void *ev)
2244{
2245#ifdef ECORE_XI2
2246 Ecore_X_Event_Generic *e = (Ecore_X_Event_Generic *)ev;
2247
2248 if (data)
2249 {
2250 if (e->data)
2251 XFreeEventData(_ecore_x_disp, (XGenericEventCookie *)data);
2252 free(data);
2253 }
2254 free(e);
2255#else
2256 return;
2257 data = NULL; ev = NULL;
2258#endif /* ifdef ECORE_XI2 */
2259} /* _ecore_x_event_free_generic_event */
2260
2261void
2262_ecore_x_event_handle_generic_event(XEvent *event)
2263{
2264#ifdef ECORE_XI2
2265 XGenericEvent *generic_event;
2266 Ecore_X_Event_Generic *e;
2267 XGenericEventCookie *data;
2268
2269 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2270 generic_event = (XGenericEvent *)event;
2271
2272 e = calloc(1, sizeof(Ecore_X_Event_Generic));
2273 if (!e)
2274 return;
2275
2276 if (XGetEventData(_ecore_x_disp, &(event->xcookie)))
2277 {
2278 e->cookie = event->xcookie.cookie;
2279 e->data = event->xcookie.data;
2280 }
2281 else
2282 {
2283 e->cookie = 0;
2284 e->data = NULL;
2285 }
2286
2287 e->extension = generic_event->extension;
2288 e->evtype = generic_event->evtype;
2289
2290 if (e->extension == _ecore_x_xi2_opcode)
2291 _ecore_x_input_handler(event);
2292
2293 data = malloc(sizeof(XGenericEventCookie));
2294 if (data) memcpy(data, &(event->xcookie), sizeof(XGenericEventCookie));
2295 ecore_event_add(ECORE_X_EVENT_GENERIC,
2296 e,
2297 _ecore_x_event_free_generic_event,
2298 data);
2299#else
2300 return;
2301 event = NULL;
2302#endif /* ifdef ECORE_XI2 */
2303} /* _ecore_x_event_handle_generic_event */
2304
2305#ifdef ECORE_XGESTURE
2306void
2307_ecore_x_event_handle_gesture_notify_flick(XEvent *xevent)
2308{
2309 XGestureNotifyFlickEvent *xfe;
2310 Ecore_X_Event_Gesture_Notify_Flick *e;
2311
2312 _ecore_x_last_event_mouse_move = 0;
2313 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2314
2315 xfe = (XGestureNotifyFlickEvent *)xevent;
2316 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Flick));
2317 if (!e)
2318 return;
2319
2320 e->win = xfe->window;
2321 e->time = xfe->time;
2322 e->subtype = xfe->kind;
2323 e->num_fingers = xfe->num_finger;
2324 e->distance = xfe->distance;
2325 e->duration = xfe->duration;
2326 e->direction = xfe->direction;
2327 e->angle = XFixedToDouble(xfe->angle);
2328
2329 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_FLICK, e, NULL, NULL);
2330}
2331
2332void
2333_ecore_x_event_handle_gesture_notify_pan(XEvent *xevent)
2334{
2335 XGestureNotifyPanEvent *xpe;
2336 Ecore_X_Event_Gesture_Notify_Pan *e;
2337
2338 _ecore_x_last_event_mouse_move = 0;
2339 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2340
2341 xpe = (XGestureNotifyPanEvent *)xevent;
2342 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Pan));
2343 if (!e)
2344 return;
2345
2346 e->win = xpe->window;
2347 e->time = xpe->time;
2348 e->subtype = xpe->kind;
2349 e->num_fingers = xpe->num_finger;
2350 e->dx = xpe->dx;
2351 e->dy = xpe->dy;
2352 e->distance = xpe->distance;
2353 e->duration = xpe->duration;
2354 e->direction = xpe->direction;
2355
2356 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_PAN, e, NULL, NULL);
2357}
2358
2359void
2360_ecore_x_event_handle_gesture_notify_pinchrotation(XEvent *xevent)
2361{
2362 XGestureNotifyPinchRotationEvent *xpre;
2363 Ecore_X_Event_Gesture_Notify_PinchRotation *e;
2364
2365 _ecore_x_last_event_mouse_move = 0;
2366 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2367
2368 xpre = (XGestureNotifyPinchRotationEvent *)xevent;
2369 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_PinchRotation));
2370 if (!e)
2371 return;
2372
2373 e->win = xpre->window;
2374 e->time = xpre->time;
2375 e->subtype = xpre->kind;
2376 e->num_fingers = xpre->num_finger;
2377 e->distance = xpre->distance;
2378 e->cx = xpre->cx;
2379 e->cy = xpre->cy;
2380 e->zoom = XFixedToDouble(xpre->zoom);
2381 e->angle = XFixedToDouble(xpre->angle);
2382
2383 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION, e, NULL, NULL);
2384}
2385
2386void
2387_ecore_x_event_handle_gesture_notify_tap(XEvent *xevent)
2388{
2389 XGestureNotifyTapEvent *xte;
2390 Ecore_X_Event_Gesture_Notify_Tap *e;
2391
2392 _ecore_x_last_event_mouse_move = 0;
2393 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2394
2395 xte = (XGestureNotifyTapEvent *)xevent;
2396 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Tap));
2397 if (!e)
2398 return;
2399
2400 e->win = xte->window;
2401 e->time = xte->time;
2402 e->subtype = xte->kind;
2403 e->num_fingers = xte->num_finger;
2404 e->cx = xte->cx;
2405 e->cy = xte->cy;
2406 e->tap_repeat = xte->tap_repeat;
2407 e->interval = xte->interval;
2408
2409 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_TAP, e, NULL, NULL);
2410}
2411
2412void
2413_ecore_x_event_handle_gesture_notify_tapnhold(XEvent *xevent)
2414{
2415 XGestureNotifyTapNHoldEvent *xthe;
2416 Ecore_X_Event_Gesture_Notify_TapNHold *e;
2417
2418 _ecore_x_last_event_mouse_move = 0;
2419 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2420
2421 xthe = (XGestureNotifyTapNHoldEvent *)xevent;
2422 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_TapNHold));
2423 if (!e)
2424 return;
2425
2426 e->win = xthe->window;
2427 e->time = xthe->time;
2428 e->subtype = xthe->kind;
2429 e->num_fingers = xthe->num_finger;
2430 e->cx = xthe->cx;
2431 e->cy = xthe->cy;
2432 e->interval = xthe->interval;
2433 e->hold_time = xthe->holdtime;
2434
2435 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD, e, NULL, NULL);
2436}
2437
2438void
2439 _ecore_x_event_handle_gesture_notify_hold(XEvent *xevent)
2440{
2441 XGestureNotifyHoldEvent *xhe;
2442 Ecore_X_Event_Gesture_Notify_Hold *e;
2443
2444 _ecore_x_last_event_mouse_move = 0;
2445 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2446
2447 xhe = (XGestureNotifyHoldEvent *)xevent;
2448 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Hold));
2449 if (!e)
2450 return;
2451
2452 e->win = xhe->window;
2453 e->time = xhe->time;
2454 e->subtype = xhe->kind;
2455 e->num_fingers = xhe->num_finger;
2456 e->cx = xhe->cx;
2457 e->cy = xhe->cy;
2458 e->hold_time = xhe->holdtime;
2459
2460 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_HOLD, e, NULL, NULL);
2461}
2462
2463void
2464 _ecore_x_event_handle_gesture_notify_group(XEvent *xevent)
2465{
2466 XGestureNotifyGroupEvent *xge;
2467 Ecore_X_Event_Gesture_Notify_Group *e;
2468
2469 _ecore_x_last_event_mouse_move = 0;
2470 LOGFN(__FILE__, __LINE__, __FUNCTION__);
2471
2472 xge = (XGestureNotifyGroupEvent *)xevent;
2473 e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Group));
2474 if (!e)
2475 return;
2476
2477 e->win = xge->window;
2478 e->time = xge->time;
2479 e->subtype = xge->kind;
2480 e->num_groups = xge->num_group;
2481 e->group_id = xge->groupid;
2482
2483 ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_GROUP, e, NULL, NULL);
2484}
2485#endif /* ifdef ECORE_XGESTURE */
2486
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_fixes.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_fixes.c
new file mode 100644
index 0000000..e81af13
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_fixes.c
@@ -0,0 +1,364 @@
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#include "Ecore_X.h"
9
10static int _fixes_available;
11#ifdef ECORE_XFIXES
12static int _fixes_major, _fixes_minor;
13#endif /* ifdef ECORE_XFIXES */
14
15void
16_ecore_x_fixes_init(void)
17{
18#ifdef ECORE_XFIXES
19 _fixes_major = 3;
20 _fixes_minor = 0;
21
22 LOGFN(__FILE__, __LINE__, __FUNCTION__);
23 if (XFixesQueryVersion(_ecore_x_disp, &_fixes_major, &_fixes_minor))
24 {
25 _fixes_available = 1;
26
27 ECORE_X_EVENT_FIXES_SELECTION_NOTIFY = ecore_event_type_new();
28 }
29 else
30 _fixes_available = 0;
31
32#else /* ifdef ECORE_XFIXES */
33 _fixes_available = 0;
34#endif /* ifdef ECORE_XFIXES */
35} /* _ecore_x_fixes_init */
36
37#ifdef ECORE_XFIXES
38/* I don't know what to call this function. */
39static XRectangle *
40_ecore_x_rectangle_ecore_to_x(Ecore_X_Rectangle *rects,
41 int num)
42{
43 XRectangle *xrect;
44 int i;
45
46 if (num == 0)
47 return NULL;
48
49 xrect = malloc(sizeof(XRectangle) * num);
50 if (!xrect)
51 return NULL;
52
53 for (i = 0; i < num; i++)
54 {
55 xrect[i].x = rects[i].x;
56 xrect[i].y = rects[i].y;
57 xrect[i].width = rects[i].width;
58 xrect[i].height = rects[i].height;
59 }
60 return xrect;
61} /* _ecore_x_rectangle_ecore_to_x */
62
63static Ecore_X_Rectangle *
64_ecore_x_rectangle_x_to_ecore(XRectangle *xrect,
65 int num)
66{
67 Ecore_X_Rectangle *rects;
68 int i;
69
70 if (num == 0)
71 return NULL;
72
73 rects = malloc(sizeof(Ecore_X_Rectangle) * num);
74 if (!rects)
75 return NULL;
76
77 for (i = 0; i < num; i++)
78 {
79 rects[i].x = xrect[i].x;
80 rects[i].y = xrect[i].y;
81 rects[i].width = xrect[i].width;
82 rects[i].height = xrect[i].height;
83 }
84 return rects;
85} /* _ecore_x_rectangle_x_to_ecore */
86
87#endif /* ifdef ECORE_XFIXES */
88
89EAPI Eina_Bool
90ecore_x_fixes_selection_notification_request(Ecore_X_Atom selection)
91{
92#ifdef ECORE_XFIXES
93 if (_fixes_available)
94 {
95 XFixesSelectSelectionInput (_ecore_x_disp,
96 DefaultRootWindow(_ecore_x_disp),
97 selection,
98 XFixesSetSelectionOwnerNotifyMask |
99 XFixesSelectionWindowDestroyNotifyMask |
100 XFixesSelectionClientCloseNotifyMask);
101 return EINA_TRUE;
102 }
103#endif
104 return EINA_FALSE;
105}
106
107EAPI Ecore_X_Region
108ecore_x_region_new(Ecore_X_Rectangle *rects,
109 int num)
110{
111#ifdef ECORE_XFIXES
112 Ecore_X_Region region;
113 XRectangle *xrect;
114
115 LOGFN(__FILE__, __LINE__, __FUNCTION__);
116 xrect = _ecore_x_rectangle_ecore_to_x(rects, num);
117 region = XFixesCreateRegion(_ecore_x_disp, xrect, num);
118 free(xrect);
119 return region;
120#else /* ifdef ECORE_XFIXES */
121 return 0;
122#endif /* ifdef ECORE_XFIXES */
123} /* ecore_x_region_new */
124
125EAPI Ecore_X_Region
126ecore_x_region_new_from_bitmap(Ecore_X_Pixmap bitmap)
127{
128#ifdef ECORE_XFIXES
129 Ecore_X_Region region;
130
131 LOGFN(__FILE__, __LINE__, __FUNCTION__);
132 region = XFixesCreateRegionFromBitmap(_ecore_x_disp, bitmap);
133 return region;
134#else /* ifdef ECORE_XFIXES */
135 return 0;
136#endif /* ifdef ECORE_XFIXES */
137} /* ecore_x_region_new_from_bitmap */
138
139EAPI Ecore_X_Region
140ecore_x_region_new_from_window(Ecore_X_Window win,
141 Ecore_X_Region_Type type)
142{
143#ifdef ECORE_XFIXES
144 Ecore_X_Region region;
145
146 LOGFN(__FILE__, __LINE__, __FUNCTION__);
147 region = XFixesCreateRegionFromWindow(_ecore_x_disp, win, type);
148 return region;
149#else /* ifdef ECORE_XFIXES */
150 return 0;
151#endif /* ifdef ECORE_XFIXES */
152} /* ecore_x_region_new_from_window */
153
154EAPI Ecore_X_Region
155ecore_x_region_new_from_gc(Ecore_X_GC gc)
156{
157#ifdef ECORE_XFIXES
158 Ecore_X_Region region;
159
160 LOGFN(__FILE__, __LINE__, __FUNCTION__);
161 region = XFixesCreateRegionFromGC(_ecore_x_disp, gc);
162 return region;
163#else /* ifdef ECORE_XFIXES */
164 return 0;
165#endif /* ifdef ECORE_XFIXES */
166} /* ecore_x_region_new_from_gc */
167
168EAPI Ecore_X_Region
169ecore_x_region_new_from_picture(Ecore_X_Picture picture)
170{
171#ifdef ECORE_XFIXES
172 Ecore_X_Region region;
173
174 LOGFN(__FILE__, __LINE__, __FUNCTION__);
175 region = XFixesCreateRegionFromPicture(_ecore_x_disp, picture);
176 return region;
177#else /* ifdef ECORE_XFIXES */
178 return 0;
179#endif /* ifdef ECORE_XFIXES */
180} /* ecore_x_region_new_from_picture */
181
182EAPI void
183ecore_x_region_free(Ecore_X_Region region)
184{
185#ifdef ECORE_XFIXES
186 LOGFN(__FILE__, __LINE__, __FUNCTION__);
187 XFixesDestroyRegion(_ecore_x_disp, region);
188#endif /* ifdef ECORE_XFIXES */
189} /* ecore_x_region_free */
190
191EAPI void
192ecore_x_region_set(Ecore_X_Region region,
193 Ecore_X_Rectangle *rects,
194 int num)
195{
196#ifdef ECORE_XFIXES
197 XRectangle *xrect = _ecore_x_rectangle_ecore_to_x(rects, num);
198 LOGFN(__FILE__, __LINE__, __FUNCTION__);
199 XFixesSetRegion(_ecore_x_disp, region, xrect, num);
200#endif /* ifdef ECORE_XFIXES */
201} /* ecore_x_region_set */
202
203EAPI void
204ecore_x_region_copy(Ecore_X_Region dest,
205 Ecore_X_Region source)
206{
207#ifdef ECORE_XFIXES
208 LOGFN(__FILE__, __LINE__, __FUNCTION__);
209 XFixesCopyRegion(_ecore_x_disp, dest, source);
210#endif /* ifdef ECORE_XFIXES */
211} /* ecore_x_region_copy */
212
213EAPI void
214ecore_x_region_combine(Ecore_X_Region dest,
215 Ecore_X_Region source1,
216 Ecore_X_Region source2)
217{
218#ifdef ECORE_XFIXES
219 LOGFN(__FILE__, __LINE__, __FUNCTION__);
220 XFixesUnionRegion(_ecore_x_disp, dest, source1, source2);
221#endif /* ifdef ECORE_XFIXES */
222} /* ecore_x_region_combine */
223
224EAPI void
225ecore_x_region_intersect(Ecore_X_Region dest,
226 Ecore_X_Region source1,
227 Ecore_X_Region source2)
228{
229#ifdef ECORE_XFIXES
230 LOGFN(__FILE__, __LINE__, __FUNCTION__);
231 XFixesIntersectRegion(_ecore_x_disp, dest, source1, source2);
232#endif /* ifdef ECORE_XFIXES */
233} /* ecore_x_region_intersect */
234
235EAPI void
236ecore_x_region_subtract(Ecore_X_Region dest,
237 Ecore_X_Region source1,
238 Ecore_X_Region source2)
239{
240#ifdef ECORE_XFIXES
241 LOGFN(__FILE__, __LINE__, __FUNCTION__);
242 XFixesSubtractRegion(_ecore_x_disp, dest, source1, source2);
243#endif /* ifdef ECORE_XFIXES */
244} /* ecore_x_region_subtract */
245
246EAPI void
247ecore_x_region_invert(Ecore_X_Region dest,
248 Ecore_X_Rectangle *bounds,
249 Ecore_X_Region source)
250{
251#ifdef ECORE_XFIXES
252 XRectangle *xbound;
253 int num = 0;
254
255 LOGFN(__FILE__, __LINE__, __FUNCTION__);
256 while (bounds + num) num++;
257 xbound = _ecore_x_rectangle_ecore_to_x(bounds, num);
258
259 XFixesInvertRegion(_ecore_x_disp, dest, xbound, source);
260#endif /* ifdef ECORE_XFIXES */
261} /* ecore_x_region_invert */
262
263EAPI void
264ecore_x_region_translate(Ecore_X_Region region,
265 int dx,
266 int dy)
267{
268#ifdef ECORE_XFIXES
269 LOGFN(__FILE__, __LINE__, __FUNCTION__);
270 XFixesTranslateRegion(_ecore_x_disp, region, dx, dy);
271#endif /* ifdef ECORE_XFIXES */
272} /* ecore_x_region_translate */
273
274EAPI void
275ecore_x_region_extents(Ecore_X_Region dest,
276 Ecore_X_Region source)
277{
278#ifdef ECORE_XFIXES
279 LOGFN(__FILE__, __LINE__, __FUNCTION__);
280 XFixesRegionExtents(_ecore_x_disp, dest, source);
281#endif /* ifdef ECORE_XFIXES */
282} /* ecore_x_region_extents */
283
284EAPI Ecore_X_Rectangle *
285ecore_x_region_fetch(Ecore_X_Region region,
286 int *num,
287 Ecore_X_Rectangle *bounds){
288#ifdef ECORE_XFIXES
289 Ecore_X_Rectangle *rects;
290 XRectangle *xrect, xbound;
291
292 LOGFN(__FILE__, __LINE__, __FUNCTION__);
293 xrect = XFixesFetchRegionAndBounds(_ecore_x_disp, region, num, &xbound);
294 rects = _ecore_x_rectangle_x_to_ecore(xrect, *num);
295 (*bounds).x = xbound.x;
296 (*bounds).y = xbound.y;
297 (*bounds).width = xbound.width;
298 (*bounds).height = xbound.height;
299 return rects;
300#else /* ifdef ECORE_XFIXES */
301 return NULL;
302#endif /* ifdef ECORE_XFIXES */
303} /* ecore_x_region_fetch */
304
305EAPI void
306ecore_x_region_expand(Ecore_X_Region dest,
307 Ecore_X_Region source,
308 unsigned int left,
309 unsigned int right,
310 unsigned int top,
311 unsigned int bottom)
312{
313#ifdef ECORE_XFIXES
314 LOGFN(__FILE__, __LINE__, __FUNCTION__);
315 XFixesExpandRegion(_ecore_x_disp, dest, source, left, right, top, bottom);
316#endif /* ifdef ECORE_XFIXES */
317} /* ecore_x_region_expand */
318
319EAPI void
320ecore_x_region_gc_clip_set(Ecore_X_Region region,
321 Ecore_X_GC gc,
322 int x_origin,
323 int y_origin)
324{
325#ifdef ECORE_XFIXES
326 LOGFN(__FILE__, __LINE__, __FUNCTION__);
327 XFixesSetGCClipRegion(_ecore_x_disp, gc, x_origin, y_origin, region);
328#endif /* ifdef ECORE_XFIXES */
329} /* ecore_x_region_gc_clip_set */
330
331EAPI void
332ecore_x_region_window_shape_set(Ecore_X_Region region,
333 Ecore_X_Window win,
334 Ecore_X_Shape_Type type,
335 int x_offset,
336 int y_offset)
337{
338#ifdef ECORE_XFIXES
339 LOGFN(__FILE__, __LINE__, __FUNCTION__);
340 XFixesSetWindowShapeRegion(_ecore_x_disp,
341 win,
342 type,
343 x_offset,
344 y_offset,
345 region);
346#endif /* ifdef ECORE_XFIXES */
347} /* ecore_x_region_window_shape_set */
348
349EAPI void
350ecore_x_region_picture_clip_set(Ecore_X_Region region,
351 Ecore_X_Picture picture,
352 int x_origin,
353 int y_origin)
354{
355#ifdef ECORE_XFIXES
356 LOGFN(__FILE__, __LINE__, __FUNCTION__);
357 XFixesSetPictureClipRegion(_ecore_x_disp,
358 picture,
359 x_origin,
360 y_origin,
361 region);
362#endif /* ifdef ECORE_XFIXES */
363} /* ecore_x_region_picture_clip_set */
364
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_gc.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_gc.c
new file mode 100644
index 0000000..10b807b
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_gc.c
@@ -0,0 +1,171 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <string.h>
6
7#include "Ecore.h"
8#include "ecore_x_private.h"
9#include "Ecore_X.h"
10
11/**
12 * Creates a new default graphics context associated with the given
13 * drawable.
14 * @param draw Drawable to create graphics context with. If @c 0 is
15 * given instead, the default root window is used.
16 * @param value_mask Bitmask values.
17 * @param value_list List of values. The order of values must be the
18 * same than the corresponding bitmaks.
19 * @return The new default graphics context.
20 */
21EAPI Ecore_X_GC
22ecore_x_gc_new(Ecore_X_Drawable draw,
23 Ecore_X_GC_Value_Mask value_mask,
24 const unsigned int *value_list)
25{
26 XGCValues gcv;
27 int mask;
28 int idx;
29 int i;
30
31 LOGFN(__FILE__, __LINE__, __FUNCTION__);
32 if (!draw)
33 draw = DefaultRootWindow(_ecore_x_disp);
34
35 memset(&gcv, 0, sizeof (gcv));
36
37 for (i = 0, idx = 0, mask = 1; i <= 22; i++, mask <<= 1)
38 {
39 switch (mask & value_mask)
40 {
41 case ECORE_X_GC_VALUE_MASK_FUNCTION:
42 gcv.function = value_list[idx];
43 idx++;
44 break;
45
46 case ECORE_X_GC_VALUE_MASK_PLANE_MASK:
47 gcv.plane_mask = value_list[idx];
48 idx++;
49 break;
50
51 case ECORE_X_GC_VALUE_MASK_FOREGROUND:
52 gcv.foreground = value_list[idx];
53 idx++;
54 break;
55
56 case ECORE_X_GC_VALUE_MASK_BACKGROUND:
57 gcv.background = value_list[idx];
58 idx++;
59 break;
60
61 case ECORE_X_GC_VALUE_MASK_LINE_WIDTH:
62 gcv.line_width = value_list[idx];
63 idx++;
64 break;
65
66 case ECORE_X_GC_VALUE_MASK_LINE_STYLE:
67 gcv.line_style = value_list[idx];
68 idx++;
69 break;
70
71 case ECORE_X_GC_VALUE_MASK_CAP_STYLE:
72 gcv.cap_style = value_list[idx];
73 idx++;
74 break;
75
76 case ECORE_X_GC_VALUE_MASK_JOIN_STYLE:
77 gcv.join_style = value_list[idx];
78 idx++;
79 break;
80
81 case ECORE_X_GC_VALUE_MASK_FILL_STYLE:
82 gcv.fill_style = value_list[idx];
83 idx++;
84 break;
85
86 case ECORE_X_GC_VALUE_MASK_FILL_RULE:
87 gcv.fill_rule = value_list[idx];
88 idx++;
89 break;
90
91 case ECORE_X_GC_VALUE_MASK_TILE:
92 gcv.tile = value_list[idx];
93 idx++;
94 break;
95
96 case ECORE_X_GC_VALUE_MASK_STIPPLE:
97 gcv.stipple = value_list[idx];
98 idx++;
99 break;
100
101 case ECORE_X_GC_VALUE_MASK_TILE_STIPPLE_ORIGIN_X:
102 gcv.ts_x_origin = value_list[idx];
103 idx++;
104 break;
105
106 case ECORE_X_GC_VALUE_MASK_TILE_STIPPLE_ORIGIN_Y:
107 gcv.ts_y_origin = value_list[idx];
108 idx++;
109 break;
110
111 case ECORE_X_GC_VALUE_MASK_FONT:
112 gcv.font = value_list[idx];
113 idx++;
114 break;
115
116 case ECORE_X_GC_VALUE_MASK_SUBWINDOW_MODE:
117 gcv.subwindow_mode = value_list[idx];
118 idx++;
119 break;
120
121 case ECORE_X_GC_VALUE_MASK_GRAPHICS_EXPOSURES:
122 gcv.graphics_exposures = value_list[idx];
123 idx++;
124 break;
125
126 case ECORE_X_GC_VALUE_MASK_CLIP_ORIGIN_X:
127 gcv.clip_x_origin = value_list[idx];
128 idx++;
129 break;
130
131 case ECORE_X_GC_VALUE_MASK_CLIP_ORIGIN_Y:
132 gcv.clip_y_origin = value_list[idx];
133 idx++;
134 break;
135
136 case ECORE_X_GC_VALUE_MASK_CLIP_MASK:
137 gcv.clip_mask = value_list[idx];
138 idx++;
139 break;
140
141 case ECORE_X_GC_VALUE_MASK_DASH_OFFSET:
142 gcv.dash_offset = value_list[idx];
143 idx++;
144 break;
145
146 case ECORE_X_GC_VALUE_MASK_DASH_LIST:
147 gcv.dashes = value_list[idx];
148 idx++;
149 break;
150
151 case ECORE_X_GC_VALUE_MASK_ARC_MODE:
152 gcv.arc_mode = value_list[idx];
153 idx++;
154 break;
155 } /* switch */
156 }
157
158 return XCreateGC(_ecore_x_disp, draw, value_mask, &gcv);
159} /* ecore_x_gc_new */
160
161/**
162 * Deletes and frees the given graphics context.
163 * @param gc The given graphics context.
164 */
165EAPI void
166ecore_x_gc_free(Ecore_X_GC gc)
167{
168 LOGFN(__FILE__, __LINE__, __FUNCTION__);
169 XFreeGC(_ecore_x_disp, gc);
170} /* ecore_x_gc_free */
171
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_gesture.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_gesture.c
new file mode 100644
index 0000000..e1dc75c
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_gesture.c
@@ -0,0 +1,136 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include "ecore_x_private.h"
6
7static Eina_Bool _gesture_available = EINA_FALSE;
8
9#ifdef ECORE_XGESTURE
10static int _gesture_major, _gesture_minor, _gesture_patch;
11int _gesture_version;
12#endif /* ifdef ECORE_XGESTURE */
13
14void
15_ecore_x_gesture_init(void)
16{
17#ifdef ECORE_XGESTURE
18 _gesture_major = 0;
19 _gesture_minor = 0;
20 _gesture_patch = 0;
21 _gesture_version = 0;
22
23 if (XGestureQueryVersion(_ecore_x_disp, &_gesture_major, &_gesture_minor, &_gesture_patch))
24 {
25 _gesture_version = (_gesture_major << 16) | _gesture_minor;
26 _gesture_available = EINA_TRUE;
27 }
28 else
29 _gesture_available = EINA_FALSE;
30#else /* ifdef ECORE_XGESTURE */
31 _gesture_available = EINA_FALSE;
32#endif /* ifdef ECORE_XGESTURE */
33}
34
35/*
36 * @brief query whether gesture is available or not
37 * @return EINA_TRUE, if extension is available, else EINA_FALSE
38 */
39EAPI Eina_Bool
40ecore_x_gesture_supported(void)
41{
42 return _gesture_available;
43}
44
45EAPI Eina_Bool
46ecore_x_gesture_events_select(Ecore_X_Window win,
47 Ecore_X_Gesture_Event_Mask mask)
48{
49#ifdef ECORE_XGESTURE
50 if (!_gesture_available)
51 return EINA_FALSE;
52
53 LOGFN(__FILE__, __LINE__, __FUNCTION__);
54 XGestureSelectEvents(_ecore_x_disp, win, mask);
55
56 return EINA_TRUE;
57#else /* ifdef ECORE_XGESTURE */
58 return EINA_FALSE;
59 win = 0;
60 mask = 0;
61#endif /* ifdef ECORE_XGESTURE */
62}
63
64EAPI Ecore_X_Gesture_Event_Mask
65ecore_x_gesture_events_selected_get(Ecore_X_Window win)
66{
67#ifdef ECORE_XGESTURE
68 Ecore_X_Gesture_Event_Mask mask;
69
70 if (!_gesture_available)
71 return ECORE_X_GESTURE_EVENT_MASK_NONE;
72
73 LOGFN(__FILE__, __LINE__, __FUNCTION__);
74 if (GestureSuccess != XGestureGetSelectedEvents(_ecore_x_disp, win, &mask))
75 {
76 mask = ECORE_X_GESTURE_EVENT_MASK_NONE;
77 return mask;
78 }
79
80 return mask;
81#else /* ifdef ECORE_XGESTURE */
82 return ECORE_X_GESTURE_EVENT_MASK_NONE;
83 win = 0;
84#endif /* ifdef ECORE_XGESTURE */
85}
86
87EAPI Eina_Bool
88ecore_x_gesture_event_grab(Ecore_X_Window win,
89 Ecore_X_Gesture_Event_Type type,
90 int num_fingers)
91{
92#ifdef ECORE_XGESTURE
93 if (!_gesture_available)
94 return EINA_FALSE;
95
96 LOGFN(__FILE__, __LINE__, __FUNCTION__);
97 if (GestureGrabSuccess != XGestureGrabEvent(_ecore_x_disp, win, type, num_fingers, CurrentTime))
98 {
99 return EINA_FALSE;
100 }
101
102 return EINA_TRUE;
103#else /* ifdef ECORE_XGESTURE */
104 return EINA_FALSE;
105 win = 0;
106 type = 0;
107 num_fingers = 0;
108#endif /* ifdef ECORE_XGESTURE */
109}
110
111EAPI Eina_Bool
112ecore_x_gesture_event_ungrab(Ecore_X_Window win,
113 Ecore_X_Gesture_Event_Type type,
114 int num_fingers)
115{
116#ifdef ECORE_XGESTURE
117 Ecore_X_Gesture_Event_Mask mask;
118
119 if (!_gesture_available)
120 return EINA_FALSE;
121
122 LOGFN(__FILE__, __LINE__, __FUNCTION__);
123 if (GestureUngrabSuccess != XGestureUngrabEvent(_ecore_x_disp, win, type, num_fingers, CurrentTime))
124 {
125 return EINA_FALSE;
126 }
127
128 return EINA_TRUE;
129#else /* ifdef ECORE_XGESTURE */
130 return EINA_FALSE;
131 win = 0;
132 type = 0;
133 num_fingers = 0;
134#endif /* ifdef ECORE_XGESTURE */
135}
136
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_icccm.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_icccm.c
new file mode 100644
index 0000000..3899651
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_icccm.c
@@ -0,0 +1,1214 @@
1/*
2 * Various ICCCM related functions.
3 *
4 * This is ALL the code involving anything ICCCM related. for both WM and
5 * client.
6 */
7
8#ifdef HAVE_CONFIG_H
9# include <config.h>
10#endif /* ifdef HAVE_CONFIG_H */
11
12#include <stdlib.h>
13#include <string.h>
14
15#include "Ecore.h"
16#include "ecore_x_private.h"
17#include "Ecore_X.h"
18#include "Ecore_X_Atoms.h"
19
20EAPI void
21ecore_x_icccm_init(void)
22{
23 LOGFN(__FILE__, __LINE__, __FUNCTION__);
24} /* ecore_x_icccm_init */
25
26EAPI void
27ecore_x_icccm_state_set(Ecore_X_Window win,
28 Ecore_X_Window_State_Hint state)
29{
30 unsigned long c[2];
31
32 LOGFN(__FILE__, __LINE__, __FUNCTION__);
33 if (state == ECORE_X_WINDOW_STATE_HINT_WITHDRAWN)
34 c[0] = WithdrawnState;
35 else if (state == ECORE_X_WINDOW_STATE_HINT_NORMAL)
36 c[0] = NormalState;
37 else if (state == ECORE_X_WINDOW_STATE_HINT_ICONIC)
38 c[0] = IconicState;
39
40 c[1] = None;
41 XChangeProperty(_ecore_x_disp, win, ECORE_X_ATOM_WM_STATE,
42 ECORE_X_ATOM_WM_STATE, 32, PropModeReplace,
43 (unsigned char *)c, 2);
44} /* ecore_x_icccm_state_set */
45
46EAPI Ecore_X_Window_State_Hint
47ecore_x_icccm_state_get(Ecore_X_Window win)
48{
49 unsigned char *prop_ret = NULL;
50 Atom type_ret;
51 unsigned long bytes_after, num_ret;
52 int format_ret;
53 Ecore_X_Window_State_Hint hint;
54
55 LOGFN(__FILE__, __LINE__, __FUNCTION__);
56 hint = ECORE_X_WINDOW_STATE_HINT_NONE;
57 XGetWindowProperty(_ecore_x_disp, win, ECORE_X_ATOM_WM_STATE,
58 0, 0x7fffffff, False, ECORE_X_ATOM_WM_STATE,
59 &type_ret, &format_ret, &num_ret, &bytes_after,
60 &prop_ret);
61 if ((prop_ret) && (num_ret == 2))
62 {
63 if (prop_ret[0] == WithdrawnState)
64 hint = ECORE_X_WINDOW_STATE_HINT_WITHDRAWN;
65 else if (prop_ret[0] == NormalState)
66 hint = ECORE_X_WINDOW_STATE_HINT_NORMAL;
67 else if (prop_ret[0] == IconicState)
68 hint = ECORE_X_WINDOW_STATE_HINT_ICONIC;
69 }
70
71 if (prop_ret)
72 XFree(prop_ret);
73
74 return hint;
75} /* ecore_x_icccm_state_get */
76
77EAPI void
78ecore_x_icccm_delete_window_send(Ecore_X_Window win,
79 Ecore_X_Time t)
80{
81 LOGFN(__FILE__, __LINE__, __FUNCTION__);
82 ecore_x_client_message32_send(win, ECORE_X_ATOM_WM_PROTOCOLS,
83 ECORE_X_EVENT_MASK_NONE,
84 ECORE_X_ATOM_WM_DELETE_WINDOW,
85 t, 0, 0, 0);
86} /* ecore_x_icccm_delete_window_send */
87
88EAPI void
89ecore_x_icccm_take_focus_send(Ecore_X_Window win,
90 Ecore_X_Time t)
91{
92 LOGFN(__FILE__, __LINE__, __FUNCTION__);
93 ecore_x_client_message32_send(win, ECORE_X_ATOM_WM_PROTOCOLS,
94 ECORE_X_EVENT_MASK_NONE,
95 ECORE_X_ATOM_WM_TAKE_FOCUS,
96 t, 0, 0, 0);
97} /* ecore_x_icccm_take_focus_send */
98
99EAPI void
100ecore_x_icccm_save_yourself_send(Ecore_X_Window win,
101 Ecore_X_Time t)
102{
103 LOGFN(__FILE__, __LINE__, __FUNCTION__);
104 ecore_x_client_message32_send(win, ECORE_X_ATOM_WM_PROTOCOLS,
105 ECORE_X_EVENT_MASK_NONE,
106 ECORE_X_ATOM_WM_SAVE_YOURSELF,
107 t, 0, 0, 0);
108} /* ecore_x_icccm_save_yourself_send */
109
110EAPI void
111ecore_x_icccm_move_resize_send(Ecore_X_Window win,
112 int x,
113 int y,
114 int w,
115 int h)
116{
117 XEvent ev;
118
119 LOGFN(__FILE__, __LINE__, __FUNCTION__);
120 ev.type = ConfigureNotify;
121 ev.xconfigure.display = _ecore_x_disp;
122 ev.xconfigure.event = win;
123 ev.xconfigure.window = win;
124 ev.xconfigure.x = x;
125 ev.xconfigure.y = y;
126 ev.xconfigure.width = w;
127 ev.xconfigure.height = h;
128 ev.xconfigure.border_width = 0;
129 ev.xconfigure.above = None;
130 ev.xconfigure.override_redirect = False;
131 XSendEvent(_ecore_x_disp, win, False, StructureNotifyMask, &ev);
132} /* ecore_x_icccm_move_resize_send */
133
134EAPI void
135ecore_x_icccm_hints_set(Ecore_X_Window win,
136 Eina_Bool accepts_focus,
137 Ecore_X_Window_State_Hint initial_state,
138 Ecore_X_Pixmap icon_pixmap,
139 Ecore_X_Pixmap icon_mask,
140 Ecore_X_Window icon_window,
141 Ecore_X_Window window_group,
142 Eina_Bool is_urgent)
143{
144 XWMHints *hints;
145
146 hints = XAllocWMHints();
147 if (!hints)
148 return;
149
150 LOGFN(__FILE__, __LINE__, __FUNCTION__);
151 hints->flags = InputHint | StateHint;
152 hints->input = accepts_focus;
153 if (initial_state == ECORE_X_WINDOW_STATE_HINT_WITHDRAWN)
154 hints->initial_state = WithdrawnState;
155 else if (initial_state == ECORE_X_WINDOW_STATE_HINT_NORMAL)
156 hints->initial_state = NormalState;
157 else if (initial_state == ECORE_X_WINDOW_STATE_HINT_ICONIC)
158 hints->initial_state = IconicState;
159
160 if (icon_pixmap != 0)
161 {
162 hints->icon_pixmap = icon_pixmap;
163 hints->flags |= IconPixmapHint;
164 }
165
166 if (icon_mask != 0)
167 {
168 hints->icon_mask = icon_mask;
169 hints->flags |= IconMaskHint;
170 }
171
172 if (icon_window != 0)
173 {
174 hints->icon_window = icon_window;
175 hints->flags |= IconWindowHint;
176 }
177
178 if (window_group != 0)
179 {
180 hints->window_group = window_group;
181 hints->flags |= WindowGroupHint;
182 }
183
184 if (is_urgent)
185 hints->flags |= XUrgencyHint;
186
187 XSetWMHints(_ecore_x_disp, win, hints);
188 XFree(hints);
189} /* ecore_x_icccm_hints_set */
190
191EAPI Eina_Bool
192ecore_x_icccm_hints_get(Ecore_X_Window win,
193 Eina_Bool *accepts_focus,
194 Ecore_X_Window_State_Hint *initial_state,
195 Ecore_X_Pixmap *icon_pixmap,
196 Ecore_X_Pixmap *icon_mask,
197 Ecore_X_Window *icon_window,
198 Ecore_X_Window *window_group,
199 Eina_Bool *is_urgent)
200{
201 XWMHints *hints;
202
203 LOGFN(__FILE__, __LINE__, __FUNCTION__);
204 if (accepts_focus)
205 *accepts_focus = EINA_TRUE;
206
207 if (initial_state)
208 *initial_state = ECORE_X_WINDOW_STATE_HINT_NORMAL;
209
210 if (icon_pixmap)
211 *icon_pixmap = 0;
212
213 if (icon_mask)
214 *icon_mask = 0;
215
216 if (icon_window)
217 *icon_window = 0;
218
219 if (window_group)
220 *window_group = 0;
221
222 if (is_urgent)
223 *is_urgent = EINA_FALSE;
224
225 hints = XGetWMHints(_ecore_x_disp, win);
226 if (hints)
227 {
228 if ((hints->flags & InputHint) && (accepts_focus))
229 {
230 if (hints->input)
231 *accepts_focus = EINA_TRUE;
232 else
233 *accepts_focus = EINA_FALSE;
234 }
235
236 if ((hints->flags & StateHint) && (initial_state))
237 {
238 if (hints->initial_state == WithdrawnState)
239 *initial_state = ECORE_X_WINDOW_STATE_HINT_WITHDRAWN;
240 else if (hints->initial_state == NormalState)
241 *initial_state = ECORE_X_WINDOW_STATE_HINT_NORMAL;
242 else if (hints->initial_state == IconicState)
243 *initial_state = ECORE_X_WINDOW_STATE_HINT_ICONIC;
244 }
245
246 if ((hints->flags & IconPixmapHint) && (icon_pixmap))
247 *icon_pixmap = hints->icon_pixmap;
248
249 if ((hints->flags & IconMaskHint) && (icon_mask))
250 *icon_mask = hints->icon_mask;
251
252 if ((hints->flags & IconWindowHint) && (icon_window))
253 *icon_window = hints->icon_window;
254
255 if ((hints->flags & WindowGroupHint) && (window_group))
256 *window_group = hints->window_group;
257
258 if ((hints->flags & XUrgencyHint) && (is_urgent))
259 *is_urgent = EINA_TRUE;
260
261 XFree(hints);
262 return EINA_TRUE;
263 }
264
265 return EINA_FALSE;
266} /* ecore_x_icccm_hints_get */
267
268EAPI void
269ecore_x_icccm_size_pos_hints_set(Ecore_X_Window win,
270 Eina_Bool request_pos,
271 Ecore_X_Gravity gravity,
272 int min_w,
273 int min_h,
274 int max_w,
275 int max_h,
276 int base_w,
277 int base_h,
278 int step_x,
279 int step_y,
280 double min_aspect,
281 double max_aspect)
282{
283 XSizeHints hint;
284 long mask;
285
286 LOGFN(__FILE__, __LINE__, __FUNCTION__);
287 if (!XGetWMNormalHints(_ecore_x_disp, win, &hint, &mask))
288 memset(&hint, 0, sizeof(XSizeHints));
289
290 hint.flags = 0;
291 if (request_pos)
292 hint.flags |= USPosition;
293
294 if (gravity != ECORE_X_GRAVITY_NW)
295 {
296 hint.flags |= PWinGravity;
297 hint.win_gravity = gravity;
298 }
299
300 if ((min_w > 0) || (min_h > 0))
301 {
302 hint.flags |= PMinSize;
303 hint.min_width = min_w;
304 hint.min_height = min_h;
305 }
306
307 if ((max_w > 0) || (max_h > 0))
308 {
309 hint.flags |= PMaxSize;
310 hint.max_width = max_w;
311 hint.max_height = max_h;
312 }
313
314 if ((base_w > 0) || (base_h > 0))
315 {
316 hint.flags |= PBaseSize;
317 hint.base_width = base_w;
318 hint.base_height = base_h;
319 }
320
321 if ((step_x > 1) || (step_y > 1))
322 {
323 hint.flags |= PResizeInc;
324 hint.width_inc = step_x;
325 hint.height_inc = step_y;
326 }
327
328 if ((min_aspect > 0.0) || (max_aspect > 0.0))
329 {
330 hint.flags |= PAspect;
331 hint.min_aspect.x = min_aspect * 10000;
332 hint.min_aspect.y = 10000;
333 hint.max_aspect.x = max_aspect * 10000;
334 hint.max_aspect.y = 10000;
335 }
336
337 XSetWMNormalHints(_ecore_x_disp, win, &hint);
338} /* ecore_x_icccm_size_pos_hints_set */
339
340EAPI Eina_Bool
341ecore_x_icccm_size_pos_hints_get(Ecore_X_Window win,
342 Eina_Bool *request_pos,
343 Ecore_X_Gravity *gravity,
344 int *min_w,
345 int *min_h,
346 int *max_w,
347 int *max_h,
348 int *base_w,
349 int *base_h,
350 int *step_x,
351 int *step_y,
352 double *min_aspect,
353 double *max_aspect)
354{
355 XSizeHints hint;
356 long mask;
357
358 int minw = 0, minh = 0;
359 int maxw = 32767, maxh = 32767;
360 int basew = -1, baseh = -1;
361 int stepx = -1, stepy = -1;
362 double mina = 0.0, maxa = 0.0;
363
364 LOGFN(__FILE__, __LINE__, __FUNCTION__);
365 if (!XGetWMNormalHints(_ecore_x_disp, win, &hint, &mask))
366 return EINA_FALSE;
367
368 if ((hint.flags & USPosition) || ((hint.flags & PPosition)))
369 {
370 if (request_pos)
371 *request_pos = EINA_TRUE;
372 }
373 else if (request_pos)
374 *request_pos = EINA_FALSE;
375
376 if (hint.flags & PWinGravity)
377 {
378 if (gravity)
379 *gravity = hint.win_gravity;
380 }
381 else if (gravity)
382 *gravity = ECORE_X_GRAVITY_NW;
383
384 if (hint.flags & PMinSize)
385 {
386 minw = hint.min_width;
387 minh = hint.min_height;
388 }
389
390 if (hint.flags & PMaxSize)
391 {
392 maxw = hint.max_width;
393 maxh = hint.max_height;
394 if (maxw < minw)
395 maxw = minw;
396
397 if (maxh < minh)
398 maxh = minh;
399 }
400
401 if (hint.flags & PBaseSize)
402 {
403 basew = hint.base_width;
404 baseh = hint.base_height;
405 if (basew > minw)
406 minw = basew;
407
408 if (baseh > minh)
409 minh = baseh;
410 }
411
412 if (hint.flags & PResizeInc)
413 {
414 stepx = hint.width_inc;
415 stepy = hint.height_inc;
416 if (stepx < 1)
417 stepx = 1;
418
419 if (stepy < 1)
420 stepy = 1;
421 }
422
423 if (hint.flags & PAspect)
424 {
425 if (hint.min_aspect.y > 0)
426 mina = ((double)hint.min_aspect.x) / ((double)hint.min_aspect.y);
427
428 if (hint.max_aspect.y > 0)
429 maxa = ((double)hint.max_aspect.x) / ((double)hint.max_aspect.y);
430 }
431
432 if (min_w)
433 *min_w = minw;
434
435 if (min_h)
436 *min_h = minh;
437
438 if (max_w)
439 *max_w = maxw;
440
441 if (max_h)
442 *max_h = maxh;
443
444 if (base_w)
445 *base_w = basew;
446
447 if (base_h)
448 *base_h = baseh;
449
450 if (step_x)
451 *step_x = stepx;
452
453 if (step_y)
454 *step_y = stepy;
455
456 if (min_aspect)
457 *min_aspect = mina;
458
459 if (max_aspect)
460 *max_aspect = maxa;
461
462 return EINA_TRUE;
463} /* ecore_x_icccm_size_pos_hints_get */
464
465EAPI void
466ecore_x_icccm_title_set(Ecore_X_Window win,
467 const char *t)
468{
469 char *list[1];
470 XTextProperty xprop;
471 int ret;
472
473 if (!t)
474 return;
475
476 LOGFN(__FILE__, __LINE__, __FUNCTION__);
477 xprop.value = NULL;
478#ifdef X_HAVE_UTF8_STRING
479 list[0] = strdup(t);
480 ret =
481 Xutf8TextListToTextProperty(_ecore_x_disp, list, 1, XUTF8StringStyle,
482 &xprop);
483#else /* ifdef X_HAVE_UTF8_STRING */
484 list[0] = strdup(t);
485 ret =
486 XmbTextListToTextProperty(_ecore_x_disp, list, 1, XStdICCTextStyle,
487 &xprop);
488#endif /* ifdef X_HAVE_UTF8_STRING */
489 if (ret >= Success)
490 {
491 XSetWMName(_ecore_x_disp, win, &xprop);
492 if (xprop.value)
493 XFree(xprop.value);
494 }
495 else if (XStringListToTextProperty(list, 1, &xprop) >= Success)
496 {
497 XSetWMName(_ecore_x_disp, win, &xprop);
498 if (xprop.value)
499 XFree(xprop.value);
500 }
501
502 free(list[0]);
503} /* ecore_x_icccm_title_set */
504
505EAPI char *
506ecore_x_icccm_title_get(Ecore_X_Window win)
507{
508 XTextProperty xprop;
509
510 LOGFN(__FILE__, __LINE__, __FUNCTION__);
511 xprop.value = NULL;
512 if (XGetWMName(_ecore_x_disp, win, &xprop) >= Success)
513 {
514 if (xprop.value)
515 {
516 char **list = NULL;
517 char *t = NULL;
518 int num = 0;
519 int ret;
520
521 if (xprop.encoding == ECORE_X_ATOM_UTF8_STRING)
522 t = strdup((char *)xprop.value);
523 else
524 {
525 /* convert to utf8 */
526#ifdef X_HAVE_UTF8_STRING
527 ret = Xutf8TextPropertyToTextList(_ecore_x_disp, &xprop,
528 &list, &num);
529#else /* ifdef X_HAVE_UTF8_STRING */
530 ret = XmbTextPropertyToTextList(_ecore_x_disp, &xprop,
531 &list, &num);
532#endif /* ifdef X_HAVE_UTF8_STRING */
533
534 if ((ret == XLocaleNotSupported) ||
535 (ret == XNoMemory) || (ret == XConverterNotFound))
536 t = strdup((char *)xprop.value);
537 else if ((ret >= Success) && (num > 0))
538 t = strdup(list[0]);
539
540 if (list)
541 XFreeStringList(list);
542 }
543
544 if (xprop.value)
545 XFree(xprop.value);
546
547 return t;
548 }
549 }
550
551 return NULL;
552} /* ecore_x_icccm_title_get */
553
554/**
555 * Set protocol atoms explicitly
556 * @param win The Window
557 * @param protos An array of protocol atoms
558 * @param num the number of members of the array
559 */
560EAPI void
561ecore_x_icccm_protocol_atoms_set(Ecore_X_Window win,
562 Ecore_X_Atom *protos,
563 int num)
564{
565 LOGFN(__FILE__, __LINE__, __FUNCTION__);
566 if (num > 0)
567 XSetWMProtocols(_ecore_x_disp, win, (Atom *)(protos), num);
568 else
569 XDeleteProperty(_ecore_x_disp, win, ECORE_X_ATOM_WM_PROTOCOLS);
570} /* ecore_x_icccm_protocol_atoms_set */
571
572/**
573 * Set or unset a wm protocol property.
574 * @param win The Window
575 * @param protocol The protocol to enable/disable
576 * @param on On/Off
577 */
578EAPI void
579ecore_x_icccm_protocol_set(Ecore_X_Window win,
580 Ecore_X_WM_Protocol protocol,
581 Eina_Bool on)
582{
583 Atom *protos = NULL;
584 Atom proto;
585 int protos_count = 0;
586 int already_set = 0;
587 int i;
588
589 /* Check for invalid values */
590 if (protocol >= ECORE_X_WM_PROTOCOL_NUM)
591 return;
592
593 LOGFN(__FILE__, __LINE__, __FUNCTION__);
594 proto = _ecore_x_atoms_wm_protocols[protocol];
595
596 if (!XGetWMProtocols(_ecore_x_disp, win, &protos, &protos_count))
597 {
598 protos = NULL;
599 protos_count = 0;
600 }
601
602 for (i = 0; i < protos_count; i++)
603 {
604 if (protos[i] == proto)
605 {
606 already_set = 1;
607 break;
608 }
609 }
610
611 if (on)
612 {
613 Atom *new_protos = NULL;
614
615 if (already_set)
616 goto leave;
617
618 new_protos = malloc((protos_count + 1) * sizeof(Atom));
619 if (!new_protos)
620 goto leave;
621
622 for (i = 0; i < protos_count; i++)
623 new_protos[i] = protos[i];
624 new_protos[protos_count] = proto;
625 XSetWMProtocols(_ecore_x_disp, win, new_protos, protos_count + 1);
626 free(new_protos);
627 }
628 else
629 {
630 if (!already_set)
631 goto leave;
632
633 for (i = 0; i < protos_count; i++)
634 {
635 if (protos[i] == proto)
636 {
637 int j;
638
639 for (j = i + 1; j < protos_count; j++)
640 protos[j - 1] = protos[j];
641 if (protos_count > 1)
642 XSetWMProtocols(_ecore_x_disp, win, protos,
643 protos_count - 1);
644 else
645 XDeleteProperty(_ecore_x_disp, win,
646 ECORE_X_ATOM_WM_PROTOCOLS);
647
648 goto leave;
649 }
650 }
651 }
652
653leave:
654 if (protos)
655 XFree(protos);
656} /* ecore_x_icccm_protocol_set */
657
658/**
659 * Determines whether a protocol is set for a window.
660 * @param win The Window
661 * @param protocol The protocol to query
662 * @return 1 if the protocol is set, else 0.
663 */
664EAPI Eina_Bool
665ecore_x_icccm_protocol_isset(Ecore_X_Window win,
666 Ecore_X_WM_Protocol protocol)
667{
668 Atom proto, *protos = NULL;
669 int i, protos_count = 0;
670 Eina_Bool ret = EINA_FALSE;
671
672 /* check for invalid values */
673 if (protocol >= ECORE_X_WM_PROTOCOL_NUM)
674 return EINA_FALSE;
675
676 LOGFN(__FILE__, __LINE__, __FUNCTION__);
677 proto = _ecore_x_atoms_wm_protocols[protocol];
678
679 if (!XGetWMProtocols(_ecore_x_disp, win, &protos, &protos_count))
680 return EINA_FALSE;
681
682 for (i = 0; i < protos_count; i++)
683 if (protos[i] == proto)
684 {
685 ret = EINA_TRUE;
686 break;
687 }
688
689 if (protos)
690 XFree(protos);
691
692 return ret;
693} /* ecore_x_icccm_protocol_isset */
694
695/**
696 * Set a window name & class.
697 * @param win The window
698 * @param n The name string
699 * @param c The class string
700 *
701 * Set a window name * class
702 */
703EAPI void
704ecore_x_icccm_name_class_set(Ecore_X_Window win,
705 const char *n,
706 const char *c)
707{
708 XClassHint *xch;
709
710 xch = XAllocClassHint();
711 if (!xch)
712 return;
713
714 LOGFN(__FILE__, __LINE__, __FUNCTION__);
715 xch->res_name = (char *)n;
716 xch->res_class = (char *)c;
717 XSetClassHint(_ecore_x_disp, win, xch);
718 XFree(xch);
719} /* ecore_x_icccm_name_class_set */
720
721/**
722 * Get a window name & class.
723 * @param win The window
724 * @param n The name string
725 * @param c The class string
726 *
727 * Get a window name * class
728 */
729EAPI void
730ecore_x_icccm_name_class_get(Ecore_X_Window win,
731 char **n,
732 char **c)
733{
734 XClassHint xch;
735
736 LOGFN(__FILE__, __LINE__, __FUNCTION__);
737 if (n)
738 *n = NULL;
739
740 if (c)
741 *c = NULL;
742
743 xch.res_name = NULL;
744 xch.res_class = NULL;
745 if (XGetClassHint(_ecore_x_disp, win, &xch))
746 {
747 if (n)
748 if (xch.res_name)
749 *n = strdup(xch.res_name);
750
751 if (c)
752 if (xch.res_class)
753 *c = strdup(xch.res_class);
754
755 XFree(xch.res_name);
756 XFree(xch.res_class);
757 }
758} /* ecore_x_icccm_name_class_get */
759
760/**
761 * Get a window client machine string.
762 * @param win The window
763 * @return The windows client machine string
764 *
765 * Return the client machine of a window. String must be free'd when done with.
766 */
767EAPI char *
768ecore_x_icccm_client_machine_get(Ecore_X_Window win)
769{
770 char *name;
771
772 LOGFN(__FILE__, __LINE__, __FUNCTION__);
773 name = ecore_x_window_prop_string_get(win, ECORE_X_ATOM_WM_CLIENT_MACHINE);
774 return name;
775} /* ecore_x_icccm_client_machine_get */
776
777/**
778 * Sets the WM_COMMAND property for @a win.
779 *
780 * @param win The window.
781 * @param argc Number of arguments.
782 * @param argv Arguments.
783 */
784EAPI void
785ecore_x_icccm_command_set(Ecore_X_Window win,
786 int argc,
787 char **argv)
788{
789 LOGFN(__FILE__, __LINE__, __FUNCTION__);
790 XSetCommand(_ecore_x_disp, win, argv, argc);
791} /* ecore_x_icccm_command_set */
792
793/**
794 * Get the WM_COMMAND property for @a win.
795 *
796 * Return the command of a window. String must be free'd when done with.
797 *
798 * @param win The window.
799 * @param argc Number of arguments.
800 * @param argv Arguments.
801 */
802EAPI void
803ecore_x_icccm_command_get(Ecore_X_Window win,
804 int *argc,
805 char ***argv)
806{
807 int i, c;
808 char **v;
809
810 if (argc)
811 *argc = 0;
812
813 if (argv)
814 *argv = NULL;
815
816 LOGFN(__FILE__, __LINE__, __FUNCTION__);
817 if (!XGetCommand(_ecore_x_disp, win, &v, &c))
818 return;
819
820 if (c < 1)
821 {
822 if (v)
823 XFreeStringList(v);
824
825 return;
826 }
827
828 if (argc)
829 *argc = c;
830
831 if (argv)
832 {
833 (*argv) = malloc(c * sizeof(char *));
834 if (!*argv)
835 {
836 XFreeStringList(v);
837 if (argc)
838 *argc = 0;
839
840 return;
841 }
842
843 for (i = 0; i < c; i++)
844 {
845 if (v[i])
846 (*argv)[i] = strdup(v[i]);
847 else
848 (*argv)[i] = strdup("");
849 }
850 }
851
852 XFreeStringList(v);
853} /* ecore_x_icccm_command_get */
854
855/**
856 * Set a window icon name.
857 * @param win The window
858 * @param t The icon name string
859 *
860 * Set a window icon name
861 */
862EAPI void
863ecore_x_icccm_icon_name_set(Ecore_X_Window win,
864 const char *t)
865{
866 char *list[1];
867 XTextProperty xprop;
868 int ret;
869
870 LOGFN(__FILE__, __LINE__, __FUNCTION__);
871 xprop.value = NULL;
872#ifdef X_HAVE_UTF8_STRING
873 list[0] = strdup(t);
874 ret = Xutf8TextListToTextProperty(_ecore_x_disp, list, 1,
875 XUTF8StringStyle, &xprop);
876#else /* ifdef X_HAVE_UTF8_STRING */
877 list[0] = strdup(t);
878 ret = XmbTextListToTextProperty(_ecore_x_disp, list, 1,
879 XStdICCTextStyle, &xprop);
880#endif /* ifdef X_HAVE_UTF8_STRING */
881 if (ret >= Success)
882 {
883 XSetWMIconName(_ecore_x_disp, win, &xprop);
884 if (xprop.value)
885 XFree(xprop.value);
886 }
887 else if (XStringListToTextProperty(list, 1, &xprop) >= Success)
888 {
889 XSetWMIconName(_ecore_x_disp, win, &xprop);
890 if (xprop.value)
891 XFree(xprop.value);
892 }
893
894 free(list[0]);
895} /* ecore_x_icccm_icon_name_set */
896
897/**
898 * Get a window icon name.
899 * @param win The window
900 * @return The windows icon name string
901 *
902 * Return the icon name of a window. String must be free'd when done with.
903 */
904EAPI char *
905ecore_x_icccm_icon_name_get(Ecore_X_Window win)
906{
907 XTextProperty xprop;
908
909 LOGFN(__FILE__, __LINE__, __FUNCTION__);
910 xprop.value = NULL;
911 if (XGetWMIconName(_ecore_x_disp, win, &xprop) >= Success)
912 {
913 if (xprop.value)
914 {
915 char **list = NULL;
916 char *t = NULL;
917 int num = 0;
918 int ret;
919
920 if (xprop.encoding == ECORE_X_ATOM_UTF8_STRING)
921 t = strdup((char *)xprop.value);
922 else
923 {
924 /* convert to utf8 */
925#ifdef X_HAVE_UTF8_STRING
926 ret = Xutf8TextPropertyToTextList(_ecore_x_disp, &xprop,
927 &list, &num);
928#else /* ifdef X_HAVE_UTF8_STRING */
929 ret = XmbTextPropertyToTextList(_ecore_x_disp, &xprop,
930 &list, &num);
931#endif /* ifdef X_HAVE_UTF8_STRING */
932
933 if ((ret == XLocaleNotSupported) ||
934 (ret == XNoMemory) || (ret == XConverterNotFound))
935 t = strdup((char *)xprop.value);
936 else if (ret >= Success)
937 {
938 if ((num >= 1) && (list))
939 t = strdup(list[0]);
940
941 if (list)
942 XFreeStringList(list);
943 }
944 }
945
946 if (xprop.value)
947 XFree(xprop.value);
948
949 return t;
950 }
951 }
952
953 return NULL;
954} /* ecore_x_icccm_icon_name_get */
955
956/**
957 * Add a subwindow to the list of windows that need a different colormap installed.
958 * @param win The toplevel window
959 * @param subwin The subwindow to be added to the colormap windows list
960 */
961EAPI void
962ecore_x_icccm_colormap_window_set(Ecore_X_Window win,
963 Ecore_X_Window subwin)
964{
965 int num = 0, i;
966 unsigned char *old_data = NULL;
967 unsigned char *data = NULL;
968 Window *oldset = NULL;
969 Window *newset = NULL;
970
971 LOGFN(__FILE__, __LINE__, __FUNCTION__);
972 if (!ecore_x_window_prop_property_get(win,
973 ECORE_X_ATOM_WM_COLORMAP_WINDOWS,
974 XA_WINDOW, 32, &old_data, &num))
975 {
976 newset = calloc(1, sizeof(Window));
977 if (!newset)
978 return;
979
980 newset[0] = subwin;
981 num = 1;
982 data = (unsigned char *)newset;
983 }
984 else
985 {
986 newset = calloc(num + 1, sizeof(Window));
987 oldset = (Window *)old_data;
988 if (!newset)
989 return;
990
991 for (i = 0; i < num; ++i)
992 {
993 if (oldset[i] == subwin)
994 {
995 if (old_data)
996 XFree(old_data);
997
998 old_data = NULL;
999 free(newset);
1000 return;
1001 }
1002
1003 newset[i] = oldset[i];
1004 }
1005
1006 newset[num++] = subwin;
1007 if (old_data)
1008 XFree(old_data);
1009
1010 data = (unsigned char *)newset;
1011 }
1012
1013 ecore_x_window_prop_property_set(win,
1014 ECORE_X_ATOM_WM_COLORMAP_WINDOWS,
1015 XA_WINDOW, 32, data, num);
1016 free(newset);
1017} /* ecore_x_icccm_colormap_window_set */
1018
1019/**
1020 * Remove a window from the list of colormap windows.
1021 * @param win The toplevel window
1022 * @param subwin The window to be removed from the colormap window list.
1023 */
1024EAPI void
1025ecore_x_icccm_colormap_window_unset(Ecore_X_Window win,
1026 Ecore_X_Window subwin)
1027{
1028 int num = 0, i, j, k = 0;
1029 unsigned char *old_data = NULL;
1030 unsigned char *data = NULL;
1031 Window *oldset = NULL;
1032 Window *newset = NULL;
1033
1034 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1035 if (!ecore_x_window_prop_property_get(win,
1036 ECORE_X_ATOM_WM_COLORMAP_WINDOWS,
1037 XA_WINDOW, 32, &old_data, &num))
1038 return;
1039
1040 oldset = (Window *)old_data;
1041 for (i = 0; i < num; i++)
1042 {
1043 if (oldset[i] == subwin)
1044 {
1045 if (num == 1)
1046 {
1047 XDeleteProperty(_ecore_x_disp,
1048 win, ECORE_X_ATOM_WM_COLORMAP_WINDOWS);
1049 if (old_data)
1050 XFree(old_data);
1051
1052 old_data = NULL;
1053 return;
1054 }
1055 else
1056 {
1057 newset = calloc(num - 1, sizeof(Window));
1058 data = (unsigned char *)newset;
1059 for (j = 0; j < num; ++j)
1060 if (oldset[j] != subwin)
1061 newset[k++] = oldset[j];
1062
1063 ecore_x_window_prop_property_set(
1064 win,
1065 ECORE_X_ATOM_WM_COLORMAP_WINDOWS,
1066 XA_WINDOW,
1067 32,
1068 data,
1069 k);
1070 if (old_data)
1071 XFree(old_data);
1072
1073 old_data = NULL;
1074 free(newset);
1075 return;
1076 }
1077 }
1078 }
1079
1080 if (old_data)
1081 XFree(old_data);
1082} /* ecore_x_icccm_colormap_window_unset */
1083
1084/**
1085 * Specify that a window is transient for another top-level window and should be handled accordingly.
1086 * @param win the transient window
1087 * @param forwin the toplevel window
1088 */
1089EAPI void
1090ecore_x_icccm_transient_for_set(Ecore_X_Window win,
1091 Ecore_X_Window forwin)
1092{
1093 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1094 XSetTransientForHint(_ecore_x_disp, win, forwin);
1095} /* ecore_x_icccm_transient_for_set */
1096
1097/**
1098 * Remove the transient_for setting from a window.
1099 * @param The window
1100 */
1101EAPI void
1102ecore_x_icccm_transient_for_unset(Ecore_X_Window win)
1103{
1104 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1105 XDeleteProperty(_ecore_x_disp, win, ECORE_X_ATOM_WM_TRANSIENT_FOR);
1106} /* ecore_x_icccm_transient_for_unset */
1107
1108/**
1109 * Get the window this window is transient for, if any.
1110 * @param win The window to check
1111 * @return The window ID of the top-level window, or 0 if the property does not exist.
1112 */
1113EAPI Ecore_X_Window
1114ecore_x_icccm_transient_for_get(Ecore_X_Window win)
1115{
1116 Window forwin;
1117
1118 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1119 if (XGetTransientForHint(_ecore_x_disp, win, &forwin))
1120 return (Ecore_X_Window)forwin;
1121 else
1122 return 0;
1123} /* ecore_x_icccm_transient_for_get */
1124
1125/**
1126 * Set the window role hint.
1127 * @param win The window
1128 * @param role The role string
1129 */
1130EAPI void
1131ecore_x_icccm_window_role_set(Ecore_X_Window win,
1132 const char *role)
1133{
1134 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1135 ecore_x_window_prop_string_set(win, ECORE_X_ATOM_WM_WINDOW_ROLE,
1136 (char *)role);
1137} /* ecore_x_icccm_window_role_set */
1138
1139/**
1140 * Get the window role.
1141 * @param win The window
1142 * @return The window's role string.
1143 */
1144EAPI char *
1145ecore_x_icccm_window_role_get(Ecore_X_Window win)
1146{
1147 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1148 return ecore_x_window_prop_string_get(win, ECORE_X_ATOM_WM_WINDOW_ROLE);
1149} /* ecore_x_icccm_window_role_get */
1150
1151/**
1152 * Set the window's client leader.
1153 * @param win The window
1154 * @param l The client leader window
1155 *
1156 * All non-transient top-level windows created by an app other than
1157 * the main window must have this property set to the app's main window.
1158 */
1159EAPI void
1160ecore_x_icccm_client_leader_set(Ecore_X_Window win,
1161 Ecore_X_Window l)
1162{
1163 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1164 ecore_x_window_prop_window_set(win, ECORE_X_ATOM_WM_CLIENT_LEADER,
1165 &l, 1);
1166} /* ecore_x_icccm_client_leader_set */
1167
1168/**
1169 * Get the window's client leader.
1170 * @param win The window
1171 * @return The window's client leader window, or 0 if unset */
1172EAPI Ecore_X_Window
1173ecore_x_icccm_client_leader_get(Ecore_X_Window win)
1174{
1175 Ecore_X_Window l;
1176
1177 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1178 if (ecore_x_window_prop_window_get(win, ECORE_X_ATOM_WM_CLIENT_LEADER,
1179 &l, 1) > 0)
1180 return l;
1181
1182 return 0;
1183} /* ecore_x_icccm_client_leader_get */
1184
1185EAPI void
1186ecore_x_icccm_iconic_request_send(Ecore_X_Window win,
1187 Ecore_X_Window root)
1188{
1189 XEvent xev;
1190
1191 if (!win)
1192 return;
1193
1194 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1195 if (!root)
1196 root = DefaultRootWindow(_ecore_x_disp);
1197
1198 xev.xclient.type = ClientMessage;
1199 xev.xclient.serial = 0;
1200 xev.xclient.send_event = True;
1201 xev.xclient.display = _ecore_x_disp;
1202 xev.xclient.window = win;
1203 xev.xclient.format = 32;
1204 xev.xclient.message_type = ECORE_X_ATOM_WM_CHANGE_STATE;
1205 xev.xclient.data.l[0] = IconicState;
1206
1207 XSendEvent(_ecore_x_disp, root, False,
1208 SubstructureNotifyMask | SubstructureRedirectMask, &xev);
1209} /* ecore_x_icccm_iconic_request_send */
1210
1211/* FIXME: there are older E hints, gnome hints and mwm hints and new netwm */
1212/* hints. each should go in their own file/section so we know which */
1213/* is which. also older kde hints too. we should try support as much */
1214/* as makese sense to support */
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_image.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_image.c
new file mode 100644
index 0000000..2de5319
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_image.c
@@ -0,0 +1,598 @@
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
8#include <X11/extensions/XShm.h>
9#include <X11/Xutil.h>
10#include <sys/ipc.h>
11#include <sys/shm.h>
12#include <string.h>
13
14static int _ecore_x_image_shm_can = -1;
15static int _ecore_x_image_err = 0;
16
17static int
18_ecore_x_image_error_handler(Display *d __UNUSED__,
19 XErrorEvent *ev __UNUSED__)
20{
21 _ecore_x_image_err = 1;
22 return 0;
23} /* _ecore_x_image_error_handler */
24
25static void
26_ecore_x_image_shm_check(void)
27{
28 XErrorHandler ph;
29 XShmSegmentInfo shminfo;
30 XImage *xim;
31
32 if (_ecore_x_image_shm_can != -1)
33 return;
34
35 XSync(_ecore_x_disp, False);
36 _ecore_x_image_err = 0;
37
38 xim = XShmCreateImage(_ecore_x_disp,
39 DefaultVisual(_ecore_x_disp,
40 DefaultScreen(_ecore_x_disp)),
41 DefaultDepth(_ecore_x_disp,
42 DefaultScreen(_ecore_x_disp)),
43 ZPixmap, NULL,
44 &shminfo, 1, 1);
45 if (!xim)
46 {
47 _ecore_x_image_shm_can = 0;
48 return;
49 }
50
51 shminfo.shmid = shmget(IPC_PRIVATE, xim->bytes_per_line * xim->height,
52 IPC_CREAT | 0666);
53 if (shminfo.shmid == -1)
54 {
55 XDestroyImage(xim);
56 _ecore_x_image_shm_can = 0;
57 return;
58 }
59
60 shminfo.readOnly = False;
61 shminfo.shmaddr = shmat(shminfo.shmid, 0, 0);
62 xim->data = shminfo.shmaddr;
63
64 if (xim->data == (char *)-1)
65 {
66 XDestroyImage(xim);
67 _ecore_x_image_shm_can = 0;
68 return;
69 }
70
71 ph = XSetErrorHandler((XErrorHandler)_ecore_x_image_error_handler);
72 XShmAttach(_ecore_x_disp, &shminfo);
73 XShmGetImage(_ecore_x_disp, DefaultRootWindow(_ecore_x_disp),
74 xim, 0, 0, 0xffffffff);
75 XSync(_ecore_x_disp, False);
76 XSetErrorHandler((XErrorHandler)ph);
77 if (_ecore_x_image_err)
78 {
79 XShmDetach(_ecore_x_disp, &shminfo);
80 XDestroyImage(xim);
81 shmdt(shminfo.shmaddr);
82 shmctl(shminfo.shmid, IPC_RMID, 0);
83 _ecore_x_image_shm_can = 0;
84 return;
85 }
86
87 XShmDetach(_ecore_x_disp, &shminfo);
88 XDestroyImage(xim);
89 shmdt(shminfo.shmaddr);
90 shmctl(shminfo.shmid, IPC_RMID, 0);
91
92 _ecore_x_image_shm_can = 1;
93} /* _ecore_x_image_shm_check */
94
95struct _Ecore_X_Image
96{
97 XShmSegmentInfo shminfo;
98 Ecore_X_Visual vis;
99 XImage *xim;
100 int depth;
101 int w, h;
102 int bpl, bpp, rows;
103 unsigned char *data;
104 Eina_Bool shm : 1;
105};
106
107EAPI Ecore_X_Image *
108ecore_x_image_new(int w,
109 int h,
110 Ecore_X_Visual vis,
111 int depth)
112{
113 Ecore_X_Image *im;
114
115 im = calloc(1, sizeof(Ecore_X_Image));
116 if (!im)
117 return NULL;
118
119 LOGFN(__FILE__, __LINE__, __FUNCTION__);
120 im->w = w;
121 im->h = h;
122 im->vis = vis;
123 im->depth = depth;
124 _ecore_x_image_shm_check();
125 im->shm = _ecore_x_image_shm_can;
126 return im;
127} /* ecore_x_image_new */
128
129EAPI void
130ecore_x_image_free(Ecore_X_Image *im)
131{
132 LOGFN(__FILE__, __LINE__, __FUNCTION__);
133 if (im->shm)
134 {
135 if (im->xim)
136 {
137 XShmDetach(_ecore_x_disp, &(im->shminfo));
138 XDestroyImage(im->xim);
139 shmdt(im->shminfo.shmaddr);
140 shmctl(im->shminfo.shmid, IPC_RMID, 0);
141 }
142 }
143 else if (im->xim)
144 {
145 free(im->xim->data);
146 im->xim->data = NULL;
147 XDestroyImage(im->xim);
148 }
149
150 free(im);
151} /* ecore_x_image_free */
152
153static void
154_ecore_x_image_shm_create(Ecore_X_Image *im)
155{
156 im->xim = XShmCreateImage(_ecore_x_disp, im->vis, im->depth,
157 ZPixmap, NULL, &(im->shminfo),
158 im->w, im->h);
159 if (!im->xim)
160 return;
161
162 im->shminfo.shmid = shmget(IPC_PRIVATE,
163 im->xim->bytes_per_line * im->xim->height,
164 IPC_CREAT | 0666);
165 if (im->shminfo.shmid == -1)
166 {
167 XDestroyImage(im->xim);
168 return;
169 }
170
171 im->shminfo.readOnly = False;
172 im->shminfo.shmaddr = shmat(im->shminfo.shmid, 0, 0);
173 im->xim->data = im->shminfo.shmaddr;
174 if ((im->xim->data == (char *)-1) ||
175 (!im->xim->data))
176 {
177 shmdt(im->shminfo.shmaddr);
178 shmctl(im->shminfo.shmid, IPC_RMID, 0);
179 XDestroyImage(im->xim);
180 return;
181 }
182
183 XShmAttach(_ecore_x_disp, &im->shminfo);
184
185 im->data = (unsigned char *)im->xim->data;
186
187 im->bpl = im->xim->bytes_per_line;
188 im->rows = im->xim->height;
189 if (im->xim->bits_per_pixel <= 8)
190 im->bpp = 1;
191 else if (im->xim->bits_per_pixel <= 16)
192 im->bpp = 2;
193 else
194 im->bpp = 4;
195} /* _ecore_x_image_shm_create */
196
197EAPI Eina_Bool
198ecore_x_image_get(Ecore_X_Image *im,
199 Ecore_X_Drawable draw,
200 int x,
201 int y,
202 int sx,
203 int sy,
204 int w,
205 int h)
206{
207 Eina_Bool ret = EINA_TRUE;
208 XErrorHandler ph;
209
210 LOGFN(__FILE__, __LINE__, __FUNCTION__);
211 if (im->shm)
212 {
213 if (!im->xim)
214 _ecore_x_image_shm_create(im);
215
216 if (!im->xim)
217 return 0;
218
219 _ecore_x_image_err = 0;
220 // optimised path
221 ph = XSetErrorHandler((XErrorHandler)_ecore_x_image_error_handler);
222 if ((sx == 0) && (w == im->w))
223 {
224 im->xim->data = (char *)
225 im->data + (im->xim->bytes_per_line * sy) + (sx * im->bpp);
226 im->xim->width = w;
227 im->xim->height = h;
228 XGrabServer(_ecore_x_disp);
229 if (!XShmGetImage(_ecore_x_disp, draw, im->xim, x, y, 0xffffffff))
230 ret = EINA_FALSE;
231 XUngrabServer(_ecore_x_disp);
232 ecore_x_sync();
233 }
234 // unavoidable thanks to mit-shm get api - tmp shm buf + copy into it
235 else
236 {
237 Ecore_X_Image *tim;
238 unsigned char *spixels, *sp, *pixels, *p;
239 int bpp, bpl, rows, sbpp, sbpl, srows;
240 int r;
241
242 tim = ecore_x_image_new(w, h, im->vis, im->depth);
243 if (tim)
244 {
245 ret = ecore_x_image_get(tim, draw, x, y, 0, 0, w, h);
246 if (ret)
247 {
248 spixels = ecore_x_image_data_get(tim,
249 &sbpl,
250 &srows,
251 &sbpp);
252 pixels = ecore_x_image_data_get(im, &bpl, &rows, &bpp);
253 if ((pixels) && (spixels))
254 {
255 p = pixels + (sy * bpl) + (sx * bpp);
256 sp = spixels;
257 for (r = srows; r > 0; r--)
258 {
259 memcpy(p, sp, sbpl);
260 p += bpl;
261 sp += sbpl;
262 }
263 }
264 }
265
266 ecore_x_image_free(tim);
267 }
268 }
269
270 XSetErrorHandler((XErrorHandler)ph);
271 if (_ecore_x_image_err)
272 ret = EINA_FALSE;
273 }
274 else
275 {
276 printf("currently unimplemented ecore_x_image_get without shm\n");
277 ret = EINA_FALSE;
278 }
279
280 return ret;
281} /* ecore_x_image_get */
282
283EAPI void
284ecore_x_image_put(Ecore_X_Image *im,
285 Ecore_X_Drawable draw,
286 Ecore_X_GC gc,
287 int x,
288 int y,
289 int sx,
290 int sy,
291 int w,
292 int h)
293{
294 Ecore_X_GC tgc = 0;
295
296 LOGFN(__FILE__, __LINE__, __FUNCTION__);
297 if (!gc)
298 {
299 XGCValues gcv;
300 memset(&gcv, 0, sizeof(gcv));
301 gcv.subwindow_mode = IncludeInferiors;
302 tgc = XCreateGC(_ecore_x_disp, draw, GCSubwindowMode, &gcv);
303 gc = tgc;
304 }
305 if (!im->xim) _ecore_x_image_shm_create(im);
306 if (im->xim)
307 XShmPutImage(_ecore_x_disp, draw, gc, im->xim, sx, sy, x, y, w, h, False);
308 if (tgc) ecore_x_gc_free(tgc);
309} /* ecore_x_image_put */
310
311EAPI void *
312ecore_x_image_data_get(Ecore_X_Image *im,
313 int *bpl,
314 int *rows,
315 int *bpp)
316{
317 LOGFN(__FILE__, __LINE__, __FUNCTION__);
318 if (!im->xim) _ecore_x_image_shm_create(im);
319 if (!im->xim) return NULL;
320 if (bpl) *bpl = im->bpl;
321 if (rows) *rows = im->rows;
322 if (bpp) *bpp = im->bpp;
323 return im->data;
324} /* ecore_x_image_data_get */
325
326EAPI Eina_Bool
327ecore_x_image_is_argb32_get(Ecore_X_Image *im)
328{
329 Visual *vis = im->vis;
330 if (!im->xim) _ecore_x_image_shm_create(im);
331 if (((vis->class == TrueColor) ||
332 (vis->class == DirectColor)) &&
333 (im->depth >= 24) &&
334 (vis->red_mask == 0xff0000) &&
335 (vis->green_mask == 0x00ff00) &&
336 (vis->blue_mask == 0x0000ff))
337 {
338#ifdef WORDS_BIGENDIAN
339 if (im->xim->bitmap_bit_order == LSBFirst) return EINA_TRUE;
340#else
341 if (im->xim->bitmap_bit_order == MSBFirst) return EINA_TRUE;
342#endif
343 }
344 return EINA_FALSE;
345}
346
347EAPI Eina_Bool
348ecore_x_image_to_argb_convert(void *src,
349 int sbpp,
350 int sbpl,
351 Ecore_X_Colormap c,
352 Ecore_X_Visual v,
353 int x,
354 int y,
355 int w,
356 int h,
357 unsigned int *dst,
358 int dbpl,
359 int dx,
360 int dy)
361{
362 Visual *vis = v;
363 XColor *cols = NULL;
364 int n = 0, nret = 0, i, row;
365 unsigned int pal[256], r, g, b;
366 enum
367 {
368 rgbnone = 0,
369 rgb565,
370 bgr565,
371 rgbx555,
372 argbx888,
373 abgrx888,
374 rgba888x,
375 bgra888x,
376 argbx666
377 };
378 int mode = 0;
379
380 sbpp *= 8;
381
382 n = vis->map_entries;
383 if ((n <= 256) &&
384 ((vis->class == PseudoColor) ||
385 (vis->class == StaticColor) ||
386 (vis->class == GrayScale) ||
387 (vis->class == StaticGray)))
388 {
389 if (!c)
390 c = DefaultColormap(_ecore_x_disp,
391 DefaultScreen(_ecore_x_disp));
392 cols = alloca(n * sizeof(XColor));
393 for (i = 0; i < n; i++)
394 {
395 cols[i].pixel = i;
396 cols[i].flags = DoRed | DoGreen | DoBlue;
397 cols[i].red = 0;
398 cols[i].green = 0;
399 cols[i].blue = 0;
400 }
401 XQueryColors(_ecore_x_disp, c, cols, n);
402 for (i = 0; i < n; i++)
403 {
404 pal[i] = 0xff000000 |
405 ((cols[i].red >> 8) << 16) |
406 ((cols[i].green >> 8) << 8) |
407 ((cols[i].blue >> 8));
408 }
409 nret = n;
410 }
411 else if ((vis->class == TrueColor) ||
412 (vis->class == DirectColor))
413 {
414 if ((vis->red_mask == 0x00ff0000) &&
415 (vis->green_mask == 0x0000ff00) &&
416 (vis->blue_mask == 0x000000ff))
417 mode = argbx888;
418 else if ((vis->red_mask == 0x000000ff) &&
419 (vis->green_mask == 0x0000ff00) &&
420 (vis->blue_mask == 0x00ff0000))
421 mode = abgrx888;
422 else if ((vis->red_mask == 0xff000000) &&
423 (vis->green_mask == 0x00ff0000) &&
424 (vis->blue_mask == 0x0000ff00))
425 mode = rgba888x;
426 else if ((vis->red_mask == 0x0000ff00) &&
427 (vis->green_mask == 0x00ff0000) &&
428 (vis->blue_mask == 0xff000000))
429 mode = bgra888x;
430 else if ((vis->red_mask == 0x0003f000) &&
431 (vis->green_mask == 0x00000fc0) &&
432 (vis->blue_mask == 0x0000003f))
433 mode = argbx666;
434 else if ((vis->red_mask == 0x0000f800) &&
435 (vis->green_mask == 0x000007e0) &&
436 (vis->blue_mask == 0x0000001f))
437 mode = rgb565;
438 else if ((vis->red_mask == 0x0000001f) &&
439 (vis->green_mask == 0x000007e0) &&
440 (vis->blue_mask == 0x0000f800))
441 mode = bgr565;
442 else if ((vis->red_mask == 0x00007c00) &&
443 (vis->green_mask == 0x000003e0) &&
444 (vis->blue_mask == 0x0000001f))
445 mode = rgbx555;
446 else
447 return EINA_FALSE;
448 }
449 for (row = 0; row < h; row++)
450 {
451 unsigned char *s8;
452 unsigned short *s16;
453 unsigned int *s32;
454 unsigned int *dp, *de;
455
456 dp = ((unsigned int *)(((unsigned char *)dst) +
457 ((dy + row) * dbpl))) + dx;
458 de = dp + w;
459 switch (sbpp)
460 {
461 case 8:
462 s8 = ((unsigned char *)(((unsigned char *)src) + ((y + row) * sbpl))) + x;
463 if (nret > 0)
464 {
465 while (dp < de)
466 {
467 *dp = pal[*s8];
468 s8++; dp++;
469 }
470 }
471 else
472 return EINA_FALSE;
473 break;
474
475 case 16:
476 s16 = ((unsigned short *)(((unsigned char *)src) + ((y + row) * sbpl))) + x;
477 switch (mode)
478 {
479 case rgb565:
480 while (dp < de)
481 {
482 r = (*s16 & 0xf800) << 8;
483 g = (*s16 & 0x07e0) << 5;
484 b = (*s16 & 0x001f) << 3;
485 r |= (r >> 5) & 0xff0000;
486 g |= (g >> 6) & 0x00ff00;
487 b |= (b >> 5);
488 *dp = 0xff000000 | r | g | b;
489 s16++; dp++;
490 }
491 break;
492
493 case bgr565:
494 while (dp < de)
495 {
496 r = (*s16 & 0x001f) << 19;
497 g = (*s16 & 0x07e0) << 5;
498 b = (*s16 & 0xf800) >> 8;
499 r |= (r >> 5) & 0xff0000;
500 g |= (g >> 6) & 0x00ff00;
501 b |= (b >> 5);
502 *dp = 0xff000000 | r | g | b;
503 s16++; dp++;
504 }
505 break;
506
507 case rgbx555:
508 while (dp < de)
509 {
510 r = (*s16 & 0x7c00) << 9;
511 g = (*s16 & 0x03e0) << 6;
512 b = (*s16 & 0x001f) << 3;
513 r |= (r >> 5) & 0xff0000;
514 g |= (g >> 5) & 0x00ff00;
515 b |= (b >> 5);
516 *dp = 0xff000000 | r | g | b;
517 s16++; dp++;
518 }
519 break;
520
521 default:
522 return EINA_FALSE;
523 break;
524 }
525 break;
526
527 case 24:
528 case 32:
529 s32 = ((unsigned int *)(((unsigned char *)src) + ((y + row) * sbpl))) + x;
530 switch (mode)
531 {
532 case argbx888:
533 while (dp < de)
534 {
535 *dp = 0xff000000 | *s32;
536 s32++; dp++;
537 }
538 break;
539
540 case abgrx888:
541 while (dp < de)
542 {
543 r = *s32 & 0x000000ff;
544 g = *s32 & 0x0000ff00;
545 b = *s32 & 0x00ff0000;
546 *dp = 0xff000000 | (r << 16) | (g) | (b >> 16);
547 s32++; dp++;
548 }
549 break;
550
551 case rgba888x:
552 while (dp < de)
553 {
554 *dp = 0xff000000 | (*s32 >> 8);
555 s32++; dp++;
556 }
557 break;
558
559 case bgra888x:
560 while (dp < de)
561 {
562 r = *s32 & 0x0000ff00;
563 g = *s32 & 0x00ff0000;
564 b = *s32 & 0xff000000;
565 *dp = 0xff000000 | (r << 8) | (g >> 8) | (b >> 24);
566 s32++; dp++;
567 }
568 break;
569
570 case argbx666:
571 while (dp < de)
572 {
573 r = (*s32 & 0x3f000) << 6;
574 g = (*s32 & 0x00fc0) << 4;
575 b = (*s32 & 0x0003f) << 2;
576 r |= (r >> 6) & 0xff0000;
577 g |= (g >> 6) & 0x00ff00;
578 b |= (b >> 6);
579 *dp = 0xff000000 | r | g | b;
580 s32++; dp++;
581 }
582 break;
583
584 default:
585 return EINA_FALSE;
586 break;
587 }
588 break;
589 break;
590
591 default:
592 return EINA_FALSE;
593 break;
594 }
595 }
596 return EINA_TRUE;
597}
598
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_mwm.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_mwm.c
new file mode 100644
index 0000000..7459a8b
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_mwm.c
@@ -0,0 +1,106 @@
1/*
2 * Various MWM related functions.
3 *
4 * This is ALL the code involving anything MWM related. for both WM and
5 * client.
6 */
7
8#ifdef HAVE_CONFIG_H
9# include <config.h>
10#endif /* ifdef HAVE_CONFIG_H */
11
12#include <stdlib.h>
13
14#include "Ecore.h"
15#include "ecore_x_private.h"
16#include "Ecore_X.h"
17#include "Ecore_X_Atoms.h"
18
19#define ECORE_X_MWM_HINTS_FUNCTIONS (1 << 0)
20#define ECORE_X_MWM_HINTS_DECORATIONS (1 << 1)
21#define ECORE_X_MWM_HINTS_INPUT_MODE (1 << 2)
22#define ECORE_X_MWM_HINTS_STATUS (1 << 3)
23
24typedef struct _mwmhints
25{
26 CARD32 flags;
27 CARD32 functions;
28 CARD32 decorations;
29 INT32 inputmode;
30 CARD32 status;
31}
32MWMHints;
33
34EAPI Eina_Bool
35ecore_x_mwm_hints_get(Ecore_X_Window win,
36 Ecore_X_MWM_Hint_Func *fhint,
37 Ecore_X_MWM_Hint_Decor *dhint,
38 Ecore_X_MWM_Hint_Input *ihint)
39{
40 unsigned char *p = NULL;
41 MWMHints *mwmhints = NULL;
42 int num;
43 Eina_Bool ret;
44
45 LOGFN(__FILE__, __LINE__, __FUNCTION__);
46 ret = EINA_FALSE;
47 if (!ecore_x_window_prop_property_get(win,
48 ECORE_X_ATOM_MOTIF_WM_HINTS,
49 ECORE_X_ATOM_MOTIF_WM_HINTS,
50 32, &p, &num))
51 return EINA_FALSE;
52
53 mwmhints = (MWMHints *)p;
54 if (mwmhints)
55 {
56 if (num >= 4)
57 {
58 if (dhint)
59 {
60 if (mwmhints->flags & ECORE_X_MWM_HINTS_DECORATIONS)
61 *dhint = mwmhints->decorations;
62 else
63 *dhint = ECORE_X_MWM_HINT_DECOR_ALL;
64 }
65
66 if (fhint)
67 {
68 if (mwmhints->flags & ECORE_X_MWM_HINTS_FUNCTIONS)
69 *fhint = mwmhints->functions;
70 else
71 *fhint = ECORE_X_MWM_HINT_FUNC_ALL;
72 }
73
74 if (ihint)
75 {
76 if (mwmhints->flags & ECORE_X_MWM_HINTS_INPUT_MODE)
77 *ihint = mwmhints->inputmode;
78 else
79 *ihint = ECORE_X_MWM_HINT_INPUT_MODELESS;
80 }
81
82 ret = EINA_TRUE;
83 }
84
85 free(mwmhints);
86 }
87
88 return ret;
89} /* ecore_x_mwm_hints_get */
90
91EAPI void
92ecore_x_mwm_borderless_set(Ecore_X_Window win,
93 Eina_Bool borderless)
94{
95 unsigned int data[5] = {0, 0, 0, 0, 0};
96
97 data[0] = 2; /* just set the decorations hint! */
98 data[2] = !borderless;
99
100 LOGFN(__FILE__, __LINE__, __FUNCTION__);
101 ecore_x_window_prop_property_set(win,
102 ECORE_X_ATOM_MOTIF_WM_HINTS,
103 ECORE_X_ATOM_MOTIF_WM_HINTS,
104 32, (void *)data, 5);
105} /* ecore_x_mwm_borderless_set */
106
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_netwm.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_netwm.c
new file mode 100644
index 0000000..1a6fc9a
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_netwm.c
@@ -0,0 +1,2003 @@
1/*
2 * _NET_WM... aka Extended Window Manager Hint (EWMH) functions.
3 */
4
5#ifdef HAVE_CONFIG_H
6# include <config.h>
7#endif /* ifdef HAVE_CONFIG_H */
8
9#include <stdio.h>
10#include <string.h>
11
12#include "Ecore.h"
13#include "ecore_x_private.h"
14#include "Ecore_X.h"
15
16typedef struct _Ecore_X_Startup_Info Ecore_X_Startup_Info;
17
18struct _Ecore_X_Startup_Info
19{
20 Ecore_X_Window win;
21
22 int init;
23
24 int buffer_size;
25 char *buffer;
26
27 int length;
28
29 /* These are the sequence info fields */
30 char *id;
31 char *name;
32 int screen;
33 char *bin;
34 char *icon;
35 int desktop;
36 int timestamp;
37 char *description;
38 char *wmclass;
39 int silent;
40};
41
42static void _ecore_x_window_prop_string_utf8_set(Ecore_X_Window win,
43 Ecore_X_Atom atom,
44 const char *str);
45static char *_ecore_x_window_prop_string_utf8_get(Ecore_X_Window win,
46 Ecore_X_Atom atom);
47#if 0 /* Unused */
48static int _ecore_x_netwm_startup_info_process(Ecore_X_Startup_Info *info);
49static int _ecore_x_netwm_startup_info_parse(Ecore_X_Startup_Info *info,
50 char *data);
51#endif /* if 0 */
52static void _ecore_x_netwm_startup_info_free(void *data);
53
54/*
55 * Convenience macros
56 */
57#define _ATOM_SET_UTF8_STRING_LIST(win, atom, string, cnt) \
58 XChangeProperty(_ecore_x_disp, \
59 win, \
60 atom, \
61 ECORE_X_ATOM_UTF8_STRING, \
62 8, \
63 PropModeReplace, \
64 (unsigned char *)string, \
65 cnt)
66
67/*
68 * Local variables
69 */
70
71static Eina_Hash *startup_info = NULL;
72
73EAPI void
74ecore_x_netwm_init(void)
75{
76 LOGFN(__FILE__, __LINE__, __FUNCTION__);
77 startup_info = eina_hash_string_superfast_new(
78 _ecore_x_netwm_startup_info_free);
79} /* ecore_x_netwm_init */
80
81EAPI void
82ecore_x_netwm_shutdown(void)
83{
84 LOGFN(__FILE__, __LINE__, __FUNCTION__);
85 if (startup_info)
86 eina_hash_free(startup_info);
87
88 startup_info = NULL;
89} /* ecore_x_netwm_shutdown */
90
91/*
92 * WM identification
93 */
94EAPI void
95ecore_x_netwm_wm_identify(Ecore_X_Window root,
96 Ecore_X_Window check,
97 const char *wm_name)
98{
99 LOGFN(__FILE__, __LINE__, __FUNCTION__);
100 ecore_x_window_prop_window_set(root,
101 ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK,
102 &check,
103 1);
104 ecore_x_window_prop_window_set(check,
105 ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK,
106 &check,
107 1);
108 _ecore_x_window_prop_string_utf8_set(check,
109 ECORE_X_ATOM_NET_WM_NAME,
110 wm_name);
111 /* This one isn't mandatory */
112 _ecore_x_window_prop_string_utf8_set(root,
113 ECORE_X_ATOM_NET_WM_NAME,
114 wm_name);
115} /* ecore_x_netwm_wm_identify */
116
117/*
118 * Set supported atoms
119 */
120EAPI void
121ecore_x_netwm_supported_set(Ecore_X_Window root,
122 Ecore_X_Atom *supported,
123 int num)
124{
125 LOGFN(__FILE__, __LINE__, __FUNCTION__);
126 ecore_x_window_prop_atom_set(root,
127 ECORE_X_ATOM_NET_SUPPORTED,
128 supported,
129 num);
130} /* ecore_x_netwm_supported_set */
131
132EAPI Eina_Bool
133ecore_x_netwm_supported_get(Ecore_X_Window root,
134 Ecore_X_Atom **supported,
135 int *num)
136{
137 int num_ret;
138
139 if (num)
140 *num = 0;
141
142 if (supported)
143 *supported = NULL;
144
145 LOGFN(__FILE__, __LINE__, __FUNCTION__);
146 num_ret = ecore_x_window_prop_atom_list_get(root, ECORE_X_ATOM_NET_SUPPORTED,
147 supported);
148 if (num_ret <= 0)
149 return EINA_FALSE;
150
151 if (num)
152 *num = num_ret;
153
154 return EINA_TRUE;
155} /* ecore_x_netwm_supported_get */
156
157/*
158 * Desktop configuration and status
159 */
160EAPI void
161ecore_x_netwm_desk_count_set(Ecore_X_Window root,
162 unsigned int n_desks)
163{
164 LOGFN(__FILE__, __LINE__, __FUNCTION__);
165 ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_NUMBER_OF_DESKTOPS,
166 &n_desks, 1);
167} /* ecore_x_netwm_desk_count_set */
168
169EAPI void
170ecore_x_netwm_desk_roots_set(Ecore_X_Window root,
171 Ecore_X_Window *vroots,
172 unsigned int n_desks)
173{
174 LOGFN(__FILE__, __LINE__, __FUNCTION__);
175 ecore_x_window_prop_window_set(root,
176 ECORE_X_ATOM_NET_VIRTUAL_ROOTS,
177 vroots,
178 n_desks);
179} /* ecore_x_netwm_desk_roots_set */
180
181EAPI void
182ecore_x_netwm_desk_names_set(Ecore_X_Window root,
183 const char **names,
184 unsigned int n_desks)
185{
186 char ss[32], *buf, *t;
187 const char *s;
188 unsigned int i;
189 int l, len;
190
191 LOGFN(__FILE__, __LINE__, __FUNCTION__);
192 buf = NULL;
193 len = 0;
194
195 for (i = 0; i < n_desks; i++)
196 {
197 s = (names) ? names[i] : NULL;
198 if (!s)
199 {
200 /* Default to "Desk-<number>" */
201 sprintf(ss, "Desk-%d", i);
202 s = ss;
203 }
204
205 l = strlen(s) + 1;
206 t = realloc(buf, len + l);
207 if (t)
208 {
209 buf = t;
210 memcpy(buf + len, s, l);
211 }
212 len += l;
213 }
214
215 _ATOM_SET_UTF8_STRING_LIST(root, ECORE_X_ATOM_NET_DESKTOP_NAMES, buf, len);
216
217 free(buf);
218} /* ecore_x_netwm_desk_names_set */
219
220EAPI void
221ecore_x_netwm_desk_size_set(Ecore_X_Window root,
222 unsigned int width,
223 unsigned int height)
224{
225 unsigned int size[2];
226
227 LOGFN(__FILE__, __LINE__, __FUNCTION__);
228 size[0] = width;
229 size[1] = height;
230 ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_DESKTOP_GEOMETRY, size,
231 2);
232} /* ecore_x_netwm_desk_size_set */
233
234EAPI void
235ecore_x_netwm_desk_viewports_set(Ecore_X_Window root,
236 unsigned int *origins,
237 unsigned int n_desks)
238{
239 LOGFN(__FILE__, __LINE__, __FUNCTION__);
240 ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_DESKTOP_VIEWPORT,
241 origins, 2 * n_desks);
242} /* ecore_x_netwm_desk_viewports_set */
243
244EAPI void
245ecore_x_netwm_desk_layout_set(Ecore_X_Window root,
246 int orientation,
247 int columns,
248 int rows,
249 int starting_corner)
250{
251 unsigned int layout[4];
252
253 LOGFN(__FILE__, __LINE__, __FUNCTION__);
254 layout[0] = orientation;
255 layout[1] = columns;
256 layout[2] = rows;
257 layout[3] = starting_corner;
258 ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_DESKTOP_LAYOUT,
259 layout, 4);
260} /* ecore_x_netwm_desk_layout_set */
261
262EAPI void
263ecore_x_netwm_desk_workareas_set(Ecore_X_Window root,
264 unsigned int *areas,
265 unsigned int n_desks)
266{
267 LOGFN(__FILE__, __LINE__, __FUNCTION__);
268 ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_WORKAREA, areas,
269 4 * n_desks);
270} /* ecore_x_netwm_desk_workareas_set */
271
272EAPI unsigned int *
273ecore_x_netwm_desk_workareas_get(Ecore_X_Window root, unsigned int *n_desks)
274{
275 int ret;
276 unsigned int *areas = NULL;
277
278 if (!root) root = DefaultRootWindow(_ecore_x_disp);
279
280 ret = ecore_x_window_prop_card32_list_get(root, ECORE_X_ATOM_NET_WORKAREA,
281 &areas);
282 if (!areas)
283 {
284 if (n_desks) *n_desks = 0;
285 return 0;
286 }
287 if (n_desks) *n_desks = ret / 4;
288 return areas;
289}
290
291EAPI void
292ecore_x_netwm_desk_current_set(Ecore_X_Window root,
293 unsigned int desk)
294{
295 LOGFN(__FILE__, __LINE__, __FUNCTION__);
296 ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_CURRENT_DESKTOP, &desk,
297 1);
298} /* ecore_x_netwm_desk_current_set */
299
300EAPI void
301ecore_x_netwm_showing_desktop_set(Ecore_X_Window root,
302 Eina_Bool on)
303{
304 unsigned int val;
305
306 LOGFN(__FILE__, __LINE__, __FUNCTION__);
307 val = (on) ? 1 : 0;
308 ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_SHOWING_DESKTOP, &val,
309 1);
310} /* ecore_x_netwm_showing_desktop_set */
311
312/*
313 * Client status
314 */
315
316/* Mapping order */
317EAPI void
318ecore_x_netwm_client_list_set(Ecore_X_Window root,
319 Ecore_X_Window *p_clients,
320 unsigned int n_clients)
321{
322 LOGFN(__FILE__, __LINE__, __FUNCTION__);
323 ecore_x_window_prop_window_set(root, ECORE_X_ATOM_NET_CLIENT_LIST,
324 p_clients, n_clients);
325} /* ecore_x_netwm_client_list_set */
326
327/* Stacking order */
328EAPI void
329ecore_x_netwm_client_list_stacking_set(Ecore_X_Window root,
330 Ecore_X_Window *p_clients,
331 unsigned int n_clients)
332{
333 LOGFN(__FILE__, __LINE__, __FUNCTION__);
334 ecore_x_window_prop_window_set(root, ECORE_X_ATOM_NET_CLIENT_LIST_STACKING,
335 p_clients, n_clients);
336} /* ecore_x_netwm_client_list_stacking_set */
337
338EAPI void
339ecore_x_netwm_client_active_set(Ecore_X_Window root,
340 Ecore_X_Window win)
341{
342 LOGFN(__FILE__, __LINE__, __FUNCTION__);
343 ecore_x_window_prop_window_set(root, ECORE_X_ATOM_NET_ACTIVE_WINDOW,
344 &win, 1);
345} /* ecore_x_netwm_client_active_set */
346
347EAPI void
348ecore_x_netwm_client_active_request(Ecore_X_Window root,
349 Ecore_X_Window win,
350 int type,
351 Ecore_X_Window current_win)
352{
353 XEvent xev;
354
355 LOGFN(__FILE__, __LINE__, __FUNCTION__);
356 if (!root)
357 root = DefaultRootWindow(_ecore_x_disp);
358
359 xev.xclient.type = ClientMessage;
360 xev.xclient.display = _ecore_x_disp;
361 xev.xclient.window = win;
362 xev.xclient.message_type = ECORE_X_ATOM_NET_ACTIVE_WINDOW;
363 xev.xclient.format = 32;
364 xev.xclient.data.l[0] = type;
365 xev.xclient.data.l[1] = CurrentTime;
366 xev.xclient.data.l[2] = current_win;
367 xev.xclient.data.l[3] = 0;
368 xev.xclient.data.l[4] = 0;
369
370 XSendEvent(_ecore_x_disp, root, False,
371 SubstructureRedirectMask | SubstructureNotifyMask, &xev);
372} /* ecore_x_netwm_client_active_request */
373
374EAPI void
375ecore_x_netwm_name_set(Ecore_X_Window win,
376 const char *name)
377{
378 LOGFN(__FILE__, __LINE__, __FUNCTION__);
379 _ecore_x_window_prop_string_utf8_set(win, ECORE_X_ATOM_NET_WM_NAME, name);
380} /* ecore_x_netwm_name_set */
381
382EAPI int
383ecore_x_netwm_name_get(Ecore_X_Window win,
384 char **name)
385{
386 LOGFN(__FILE__, __LINE__, __FUNCTION__);
387 if (name)
388 *name = _ecore_x_window_prop_string_utf8_get(win,
389 ECORE_X_ATOM_NET_WM_NAME);
390
391 return 1;
392} /* ecore_x_netwm_name_get */
393
394EAPI void
395ecore_x_netwm_startup_id_set(Ecore_X_Window win,
396 const char *id)
397{
398 LOGFN(__FILE__, __LINE__, __FUNCTION__);
399 _ecore_x_window_prop_string_utf8_set(win, ECORE_X_ATOM_NET_STARTUP_ID, id);
400} /* ecore_x_netwm_startup_id_set */
401
402EAPI int
403ecore_x_netwm_startup_id_get(Ecore_X_Window win,
404 char **id)
405{
406 LOGFN(__FILE__, __LINE__, __FUNCTION__);
407 if (id)
408 *id = _ecore_x_window_prop_string_utf8_get(win,
409 ECORE_X_ATOM_NET_STARTUP_ID);
410
411 return 1;
412} /* ecore_x_netwm_startup_id_get */
413
414EAPI void
415ecore_x_netwm_visible_name_set(Ecore_X_Window win,
416 const char *name)
417{
418 LOGFN(__FILE__, __LINE__, __FUNCTION__);
419 _ecore_x_window_prop_string_utf8_set(win, ECORE_X_ATOM_NET_WM_VISIBLE_NAME,
420 name);
421} /* ecore_x_netwm_visible_name_set */
422
423EAPI int
424ecore_x_netwm_visible_name_get(Ecore_X_Window win,
425 char **name)
426{
427 LOGFN(__FILE__, __LINE__, __FUNCTION__);
428 if (name)
429 *name = _ecore_x_window_prop_string_utf8_get(
430 win,
431 ECORE_X_ATOM_NET_WM_VISIBLE_NAME);
432
433 return 1;
434} /* ecore_x_netwm_visible_name_get */
435
436EAPI void
437ecore_x_netwm_icon_name_set(Ecore_X_Window win,
438 const char *name)
439{
440 LOGFN(__FILE__, __LINE__, __FUNCTION__);
441 _ecore_x_window_prop_string_utf8_set(win, ECORE_X_ATOM_NET_WM_ICON_NAME,
442 name);
443} /* ecore_x_netwm_icon_name_set */
444
445EAPI int
446ecore_x_netwm_icon_name_get(Ecore_X_Window win,
447 char **name)
448{
449 LOGFN(__FILE__, __LINE__, __FUNCTION__);
450 if (name)
451 *name = _ecore_x_window_prop_string_utf8_get(
452 win,
453 ECORE_X_ATOM_NET_WM_ICON_NAME);
454
455 return 1;
456} /* ecore_x_netwm_icon_name_get */
457
458EAPI void
459ecore_x_netwm_visible_icon_name_set(Ecore_X_Window win,
460 const char *name)
461{
462 LOGFN(__FILE__, __LINE__, __FUNCTION__);
463 _ecore_x_window_prop_string_utf8_set(win,
464 ECORE_X_ATOM_NET_WM_VISIBLE_ICON_NAME,
465 name);
466} /* ecore_x_netwm_visible_icon_name_set */
467
468EAPI int
469ecore_x_netwm_visible_icon_name_get(Ecore_X_Window win,
470 char **name)
471{
472 LOGFN(__FILE__, __LINE__, __FUNCTION__);
473 if (name)
474 *name = _ecore_x_window_prop_string_utf8_get(
475 win,
476 ECORE_X_ATOM_NET_WM_VISIBLE_ICON_NAME);
477
478 return 1;
479} /* ecore_x_netwm_visible_icon_name_get */
480
481EAPI void
482ecore_x_netwm_desktop_set(Ecore_X_Window win,
483 unsigned int desk)
484{
485 LOGFN(__FILE__, __LINE__, __FUNCTION__);
486 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_DESKTOP, &desk, 1);
487} /* ecore_x_netwm_desktop_set */
488
489EAPI Eina_Bool
490ecore_x_netwm_desktop_get(Ecore_X_Window win,
491 unsigned int *desk)
492{
493 int ret;
494 unsigned int tmp;
495
496 LOGFN(__FILE__, __LINE__, __FUNCTION__);
497 ret = ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_DESKTOP,
498 &tmp, 1);
499
500 if (desk)
501 *desk = tmp;
502
503 return ret == 1 ? EINA_TRUE : EINA_FALSE;
504} /* ecore_x_netwm_desktop_get */
505
506/*
507 * _NET_WM_STRUT is deprecated
508 */
509EAPI void
510ecore_x_netwm_strut_set(Ecore_X_Window win,
511 int left,
512 int right,
513 int top,
514 int bottom)
515{
516 unsigned int strut[4];
517
518 LOGFN(__FILE__, __LINE__, __FUNCTION__);
519 strut[0] = left;
520 strut[1] = right;
521 strut[2] = top;
522 strut[3] = bottom;
523 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_STRUT, strut, 4);
524} /* ecore_x_netwm_strut_set */
525
526/*
527 * _NET_WM_STRUT is deprecated
528 */
529EAPI Eina_Bool
530ecore_x_netwm_strut_get(Ecore_X_Window win,
531 int *left,
532 int *right,
533 int *top,
534 int *bottom)
535{
536 int ret = 0;
537 unsigned int strut[4];
538
539 LOGFN(__FILE__, __LINE__, __FUNCTION__);
540 ret = ecore_x_window_prop_card32_get(win,
541 ECORE_X_ATOM_NET_WM_STRUT,
542 strut,
543 4);
544 if (ret != 4)
545 return EINA_FALSE;
546
547 if (left)
548 *left = strut[0];
549
550 if (right)
551 *right = strut[1];
552
553 if (top)
554 *top = strut[2];
555
556 if (bottom)
557 *bottom = strut[3];
558
559 return EINA_TRUE;
560} /* ecore_x_netwm_strut_get */
561
562EAPI void
563ecore_x_netwm_strut_partial_set(Ecore_X_Window win,
564 int left,
565 int right,
566 int top,
567 int bottom,
568 int left_start_y,
569 int left_end_y,
570 int right_start_y,
571 int right_end_y,
572 int top_start_x,
573 int top_end_x,
574 int bottom_start_x,
575 int bottom_end_x)
576{
577 unsigned int strut[12];
578
579 LOGFN(__FILE__, __LINE__, __FUNCTION__);
580 strut[0] = left;
581 strut[1] = right;
582 strut[2] = top;
583 strut[3] = bottom;
584 strut[4] = left_start_y;
585 strut[5] = left_end_y;
586 strut[6] = right_start_y;
587 strut[7] = right_end_y;
588 strut[8] = top_start_x;
589 strut[9] = top_end_x;
590 strut[10] = bottom_start_x;
591 strut[11] = bottom_end_x;
592 ecore_x_window_prop_card32_set(win,
593 ECORE_X_ATOM_NET_WM_STRUT_PARTIAL,
594 strut,
595 12);
596} /* ecore_x_netwm_strut_partial_set */
597
598EAPI Eina_Bool
599ecore_x_netwm_strut_partial_get(Ecore_X_Window win,
600 int *left,
601 int *right,
602 int *top,
603 int *bottom,
604 int *left_start_y,
605 int *left_end_y,
606 int *right_start_y,
607 int *right_end_y,
608 int *top_start_x,
609 int *top_end_x,
610 int *bottom_start_x,
611 int *bottom_end_x)
612{
613 int ret = 0;
614 unsigned int strut[12];
615
616 LOGFN(__FILE__, __LINE__, __FUNCTION__);
617 ret = ecore_x_window_prop_card32_get(win,
618 ECORE_X_ATOM_NET_WM_STRUT_PARTIAL,
619 strut,
620 12);
621 if (ret != 12)
622 return EINA_FALSE;
623
624 if (left)
625 *left = strut[0];
626
627 if (right)
628 *right = strut[1];
629
630 if (top)
631 *top = strut[2];
632
633 if (bottom)
634 *bottom = strut[3];
635
636 if (left_start_y)
637 *left_start_y = strut[4];
638
639 if (left_end_y)
640 *left_end_y = strut[5];
641
642 if (right_start_y)
643 *right_start_y = strut[6];
644
645 if (right_end_y)
646 *right_end_y = strut[7];
647
648 if (top_start_x)
649 *top_start_x = strut[8];
650
651 if (top_end_x)
652 *top_end_x = strut[9];
653
654 if (bottom_start_x)
655 *bottom_start_x = strut[10];
656
657 if (bottom_end_x)
658 *bottom_end_x = strut[11];
659
660 return EINA_TRUE;
661} /* ecore_x_netwm_strut_partial_get */
662
663EAPI Eina_Bool
664ecore_x_netwm_icons_get(Ecore_X_Window win,
665 Ecore_X_Icon **icon,
666 int *num)
667{
668 unsigned int *data, *p;
669 unsigned int *src;
670 unsigned int len, icons, i;
671 int num_ret;
672
673 LOGFN(__FILE__, __LINE__, __FUNCTION__);
674 if (num)
675 *num = 0;
676
677 if (icon)
678 *icon = NULL;
679
680 num_ret = ecore_x_window_prop_card32_list_get(win, ECORE_X_ATOM_NET_WM_ICON,
681 &data);
682 if (num_ret <= 0)
683 return EINA_FALSE;
684
685 if (!data)
686 return EINA_FALSE;
687
688 if (num_ret < 2)
689 {
690 free(data);
691 return EINA_FALSE;
692 }
693
694 /* Check how many icons there are */
695 icons = 0;
696 p = data;
697 while (p)
698 {
699 len = p[0] * p[1];
700 p += (len + 2);
701 if ((p - data) > num_ret)
702 {
703 free(data);
704 return EINA_FALSE;
705 }
706
707 icons++;
708
709 if ((p - data) == num_ret)
710 p = NULL;
711 }
712 if (num)
713 *num = icons;
714
715 /* If the user doesn't want the icons, return */
716 if (!icon)
717 {
718 free(data);
719 return EINA_TRUE;
720 }
721
722 /* Allocate memory */
723 *icon = malloc(icons * sizeof(Ecore_X_Icon));
724 if (!(*icon))
725 {
726 free(data);
727 return EINA_FALSE;
728 }
729
730 /* Fetch the icons */
731 p = data;
732 for (i = 0; i < icons; i++)
733 {
734 unsigned int *ps, *pd, *pe;
735
736 len = p[0] * p[1];
737 ((*icon)[i]).width = p[0];
738 ((*icon)[i]).height = p[1];
739 src = &(p[2]);
740 ((*icon)[i]).data = malloc(len * sizeof(unsigned int));
741 if (!((*icon)[i]).data)
742 {
743 while (i)
744 free(((*icon)[--i]).data);
745 free(*icon);
746 free(data);
747 return EINA_FALSE;
748 }
749
750 pd = ((*icon)[i]).data;
751 ps = src;
752 pe = ps + len;
753 for (; ps < pe; ps++)
754 {
755 unsigned int r, g, b, a;
756
757 a = (*ps >> 24) & 0xff;
758 r = (((*ps >> 16) & 0xff) * a) / 255;
759 g = (((*ps >> 8) & 0xff) * a) / 255;
760 b = (((*ps) & 0xff) * a) / 255;
761 *pd = (a << 24) | (r << 16) | (g << 8) | (b);
762 pd++;
763 }
764 p += (len + 2);
765 }
766
767 free(data);
768
769 return EINA_TRUE;
770} /* ecore_x_netwm_icons_get */
771
772EAPI void
773ecore_x_netwm_icon_geometry_set(Ecore_X_Window win,
774 int x,
775 int y,
776 int width,
777 int height)
778{
779 unsigned int geometry[4];
780
781 LOGFN(__FILE__, __LINE__, __FUNCTION__);
782 geometry[0] = x;
783 geometry[1] = y;
784 geometry[2] = width;
785 geometry[3] = height;
786 ecore_x_window_prop_card32_set(win,
787 ECORE_X_ATOM_NET_WM_ICON_GEOMETRY,
788 geometry,
789 4);
790} /* ecore_x_netwm_icon_geometry_set */
791
792EAPI Eina_Bool
793ecore_x_netwm_icon_geometry_get(Ecore_X_Window win,
794 int *x,
795 int *y,
796 int *width,
797 int *height)
798{
799 int ret;
800 unsigned int geometry[4];
801
802 LOGFN(__FILE__, __LINE__, __FUNCTION__);
803 ret = ecore_x_window_prop_card32_get(win,
804 ECORE_X_ATOM_NET_WM_ICON_GEOMETRY,
805 geometry,
806 4);
807 if (ret != 4)
808 return EINA_FALSE;
809
810 if (x)
811 *x = geometry[0];
812
813 if (y)
814 *y = geometry[1];
815
816 if (width)
817 *width = geometry[2];
818
819 if (height)
820 *height = geometry[3];
821
822 return EINA_TRUE;
823} /* ecore_x_netwm_icon_geometry_get */
824
825EAPI void
826ecore_x_netwm_pid_set(Ecore_X_Window win,
827 int pid)
828{
829 unsigned int tmp;
830
831 LOGFN(__FILE__, __LINE__, __FUNCTION__);
832 tmp = pid;
833 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_PID,
834 &tmp, 1);
835} /* ecore_x_netwm_pid_set */
836
837EAPI Eina_Bool
838ecore_x_netwm_pid_get(Ecore_X_Window win,
839 int *pid)
840{
841 int ret;
842 unsigned int tmp;
843
844 LOGFN(__FILE__, __LINE__, __FUNCTION__);
845 ret = ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_PID,
846 &tmp, 1);
847 if (pid)
848 *pid = tmp;
849
850 return ret == 1 ? EINA_TRUE : EINA_FALSE;
851} /* ecore_x_netwm_pid_get */
852
853EAPI void
854ecore_x_netwm_handled_icons_set(Ecore_X_Window win)
855{
856 LOGFN(__FILE__, __LINE__, __FUNCTION__);
857 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_HANDLED_ICONS,
858 NULL, 0);
859} /* ecore_x_netwm_handled_icons_set */
860
861EAPI Eina_Bool
862ecore_x_netwm_handled_icons_get(Ecore_X_Window win)
863{
864 int ret = 0;
865 LOGFN(__FILE__, __LINE__, __FUNCTION__);
866 ret = ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_HANDLED_ICONS,
867 NULL, 0);
868 return ret == 0 ? EINA_TRUE : EINA_FALSE;
869} /* ecore_x_netwm_handled_icons_get */
870
871EAPI void
872ecore_x_netwm_user_time_set(Ecore_X_Window win,
873 unsigned int tim)
874{
875 LOGFN(__FILE__, __LINE__, __FUNCTION__);
876 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_USER_TIME,
877 &tim, 1);
878} /* ecore_x_netwm_user_time_set */
879
880EAPI Eina_Bool
881ecore_x_netwm_user_time_get(Ecore_X_Window win,
882 unsigned int *tim)
883{
884 int ret;
885 unsigned int tmp;
886
887 LOGFN(__FILE__, __LINE__, __FUNCTION__);
888 ret = ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_USER_TIME,
889 &tmp, 1);
890 if (tim)
891 *tim = tmp;
892
893 return ret == 1 ? EINA_TRUE : EINA_FALSE;
894} /* ecore_x_netwm_user_time_get */
895
896Ecore_X_Window_State
897_ecore_x_netwm_state_get(Ecore_X_Atom a)
898{
899 if (a == ECORE_X_ATOM_NET_WM_STATE_MODAL)
900 return ECORE_X_WINDOW_STATE_MODAL;
901 else if (a == ECORE_X_ATOM_NET_WM_STATE_STICKY)
902 return ECORE_X_WINDOW_STATE_STICKY;
903 else if (a == ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_VERT)
904 return ECORE_X_WINDOW_STATE_MAXIMIZED_VERT;
905 else if (a == ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_HORZ)
906 return ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ;
907 else if (a == ECORE_X_ATOM_NET_WM_STATE_SHADED)
908 return ECORE_X_WINDOW_STATE_SHADED;
909 else if (a == ECORE_X_ATOM_NET_WM_STATE_SKIP_TASKBAR)
910 return ECORE_X_WINDOW_STATE_SKIP_TASKBAR;
911 else if (a == ECORE_X_ATOM_NET_WM_STATE_SKIP_PAGER)
912 return ECORE_X_WINDOW_STATE_SKIP_PAGER;
913 else if (a == ECORE_X_ATOM_NET_WM_STATE_HIDDEN)
914 return ECORE_X_WINDOW_STATE_HIDDEN;
915 else if (a == ECORE_X_ATOM_NET_WM_STATE_FULLSCREEN)
916 return ECORE_X_WINDOW_STATE_FULLSCREEN;
917 else if (a == ECORE_X_ATOM_NET_WM_STATE_ABOVE)
918 return ECORE_X_WINDOW_STATE_ABOVE;
919 else if (a == ECORE_X_ATOM_NET_WM_STATE_BELOW)
920 return ECORE_X_WINDOW_STATE_BELOW;
921 else if (a == ECORE_X_ATOM_NET_WM_STATE_DEMANDS_ATTENTION)
922 return ECORE_X_WINDOW_STATE_DEMANDS_ATTENTION;
923 else
924 return ECORE_X_WINDOW_STATE_UNKNOWN;
925} /* _ecore_x_netwm_state_get */
926
927static Ecore_X_Atom
928_ecore_x_netwm_state_atom_get(Ecore_X_Window_State s)
929{
930 switch(s)
931 {
932 case ECORE_X_WINDOW_STATE_MODAL:
933 return ECORE_X_ATOM_NET_WM_STATE_MODAL;
934
935 case ECORE_X_WINDOW_STATE_STICKY:
936 return ECORE_X_ATOM_NET_WM_STATE_STICKY;
937
938 case ECORE_X_WINDOW_STATE_MAXIMIZED_VERT:
939 return ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_VERT;
940
941 case ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ:
942 return ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_HORZ;
943
944 case ECORE_X_WINDOW_STATE_SHADED:
945 return ECORE_X_ATOM_NET_WM_STATE_SHADED;
946
947 case ECORE_X_WINDOW_STATE_SKIP_TASKBAR:
948 return ECORE_X_ATOM_NET_WM_STATE_SKIP_TASKBAR;
949
950 case ECORE_X_WINDOW_STATE_SKIP_PAGER:
951 return ECORE_X_ATOM_NET_WM_STATE_SKIP_PAGER;
952
953 case ECORE_X_WINDOW_STATE_HIDDEN:
954 return ECORE_X_ATOM_NET_WM_STATE_HIDDEN;
955
956 case ECORE_X_WINDOW_STATE_FULLSCREEN:
957 return ECORE_X_ATOM_NET_WM_STATE_FULLSCREEN;
958
959 case ECORE_X_WINDOW_STATE_ABOVE:
960 return ECORE_X_ATOM_NET_WM_STATE_ABOVE;
961
962 case ECORE_X_WINDOW_STATE_BELOW:
963 return ECORE_X_ATOM_NET_WM_STATE_BELOW;
964
965 case ECORE_X_WINDOW_STATE_DEMANDS_ATTENTION:
966 return ECORE_X_ATOM_NET_WM_STATE_DEMANDS_ATTENTION;
967
968 default:
969 return 0;
970 } /* switch */
971} /* _ecore_x_netwm_state_atom_get */
972
973EAPI void
974ecore_x_netwm_window_state_set(Ecore_X_Window win,
975 Ecore_X_Window_State *state,
976 unsigned int num)
977{
978 Ecore_X_Atom *set;
979 unsigned int i;
980
981 LOGFN(__FILE__, __LINE__, __FUNCTION__);
982 if (!num)
983 {
984 ecore_x_window_prop_property_del(win, ECORE_X_ATOM_NET_WM_STATE);
985 return;
986 }
987
988 set = malloc(num * sizeof(Ecore_X_Atom));
989 if (!set)
990 return;
991
992 for (i = 0; i < num; i++)
993 set[i] = _ecore_x_netwm_state_atom_get(state[i]);
994
995 ecore_x_window_prop_atom_set(win, ECORE_X_ATOM_NET_WM_STATE, set, num);
996
997 free(set);
998} /* ecore_x_netwm_window_state_set */
999
1000EAPI Eina_Bool
1001ecore_x_netwm_window_state_get(Ecore_X_Window win,
1002 Ecore_X_Window_State **state,
1003 unsigned int *num)
1004{
1005 int num_ret, i;
1006 Ecore_X_Atom *atoms;
1007
1008 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1009 if (num)
1010 *num = 0;
1011
1012 if (state)
1013 *state = NULL;
1014
1015 num_ret = ecore_x_window_prop_atom_list_get(win, ECORE_X_ATOM_NET_WM_STATE,
1016 &atoms);
1017 if (num_ret <= 0)
1018 return EINA_FALSE;
1019
1020 if (state)
1021 {
1022 *state = malloc(num_ret * sizeof(Ecore_X_Window_State));
1023 if (*state)
1024 for (i = 0; i < num_ret; ++i)
1025 (*state)[i] = _ecore_x_netwm_state_get(atoms[i]);
1026
1027 if (num)
1028 *num = num_ret;
1029 }
1030
1031 free(atoms);
1032 return EINA_TRUE;
1033} /* ecore_x_netwm_window_state_get */
1034
1035static Ecore_X_Window_Type
1036_ecore_x_netwm_window_type_type_get(Ecore_X_Atom atom)
1037{
1038 if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DESKTOP)
1039 return ECORE_X_WINDOW_TYPE_DESKTOP;
1040 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DOCK)
1041 return ECORE_X_WINDOW_TYPE_DOCK;
1042 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLBAR)
1043 return ECORE_X_WINDOW_TYPE_TOOLBAR;
1044 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_MENU)
1045 return ECORE_X_WINDOW_TYPE_MENU;
1046 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_UTILITY)
1047 return ECORE_X_WINDOW_TYPE_UTILITY;
1048 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_SPLASH)
1049 return ECORE_X_WINDOW_TYPE_SPLASH;
1050 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DIALOG)
1051 return ECORE_X_WINDOW_TYPE_DIALOG;
1052 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NORMAL)
1053 return ECORE_X_WINDOW_TYPE_NORMAL;
1054 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DROPDOWN_MENU)
1055 return ECORE_X_WINDOW_TYPE_DROPDOWN_MENU;
1056 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_POPUP_MENU)
1057 return ECORE_X_WINDOW_TYPE_POPUP_MENU;
1058 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLTIP)
1059 return ECORE_X_WINDOW_TYPE_TOOLTIP;
1060 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NOTIFICATION)
1061 return ECORE_X_WINDOW_TYPE_NOTIFICATION;
1062 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_COMBO)
1063 return ECORE_X_WINDOW_TYPE_COMBO;
1064 else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DND)
1065 return ECORE_X_WINDOW_TYPE_DND;
1066 else
1067 return ECORE_X_WINDOW_TYPE_UNKNOWN;
1068} /* _ecore_x_netwm_window_type_type_get */
1069
1070static Ecore_X_Atom
1071_ecore_x_netwm_window_type_atom_get(Ecore_X_Window_Type type)
1072{
1073 switch (type)
1074 {
1075 case ECORE_X_WINDOW_TYPE_DESKTOP:
1076 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DESKTOP;
1077
1078 case ECORE_X_WINDOW_TYPE_DOCK:
1079 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DOCK;
1080
1081 case ECORE_X_WINDOW_TYPE_TOOLBAR:
1082 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLBAR;
1083
1084 case ECORE_X_WINDOW_TYPE_MENU:
1085 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_MENU;
1086
1087 case ECORE_X_WINDOW_TYPE_UTILITY:
1088 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_UTILITY;
1089
1090 case ECORE_X_WINDOW_TYPE_SPLASH:
1091 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_SPLASH;
1092
1093 case ECORE_X_WINDOW_TYPE_DIALOG:
1094 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DIALOG;
1095
1096 case ECORE_X_WINDOW_TYPE_NORMAL:
1097 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NORMAL;
1098
1099 case ECORE_X_WINDOW_TYPE_DROPDOWN_MENU:
1100 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DROPDOWN_MENU;
1101
1102 case ECORE_X_WINDOW_TYPE_POPUP_MENU:
1103 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_POPUP_MENU;
1104
1105 case ECORE_X_WINDOW_TYPE_TOOLTIP:
1106 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLTIP;
1107
1108 case ECORE_X_WINDOW_TYPE_NOTIFICATION:
1109 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NOTIFICATION;
1110
1111 case ECORE_X_WINDOW_TYPE_COMBO:
1112 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_COMBO;
1113
1114 case ECORE_X_WINDOW_TYPE_DND:
1115 return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DND;
1116
1117 default:
1118 return 0;
1119 } /* switch */
1120} /* _ecore_x_netwm_window_type_atom_get */
1121
1122/*
1123 * FIXME: We should set WM_TRANSIENT_FOR if type is ECORE_X_WINDOW_TYPE_TOOLBAR
1124 * , ECORE_X_WINDOW_TYPE_MENU or ECORE_X_WINDOW_TYPE_DIALOG
1125 */
1126EAPI void
1127ecore_x_netwm_window_type_set(Ecore_X_Window win,
1128 Ecore_X_Window_Type type)
1129{
1130 Ecore_X_Atom atom;
1131
1132 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1133 atom = _ecore_x_netwm_window_type_atom_get(type);
1134 ecore_x_window_prop_atom_set(win, ECORE_X_ATOM_NET_WM_WINDOW_TYPE,
1135 &atom, 1);
1136} /* ecore_x_netwm_window_type_set */
1137
1138/* FIXME: Maybe return 0 on some conditions? */
1139EAPI Eina_Bool
1140ecore_x_netwm_window_type_get(Ecore_X_Window win,
1141 Ecore_X_Window_Type *type)
1142{
1143 int num;
1144 Ecore_X_Atom *atoms = NULL;
1145
1146 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1147 if (type)
1148 *type = ECORE_X_WINDOW_TYPE_NORMAL;
1149
1150 num = ecore_x_window_prop_atom_list_get(win,
1151 ECORE_X_ATOM_NET_WM_WINDOW_TYPE,
1152 &atoms);
1153 if ((type) && (num >= 1) && (atoms))
1154 *type = _ecore_x_netwm_window_type_type_get(atoms[0]);
1155
1156 free(atoms);
1157 if (num >= 1)
1158 return EINA_TRUE;
1159
1160 return EINA_FALSE;
1161} /* ecore_x_netwm_window_type_get */
1162
1163EAPI int
1164ecore_x_netwm_window_types_get(Ecore_X_Window win,
1165 Ecore_X_Window_Type **types)
1166{
1167 int num, i;
1168 Ecore_X_Atom *atoms = NULL;
1169 Ecore_X_Window_Type *atoms2 = NULL;
1170
1171 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1172 if (types)
1173 *types = NULL;
1174
1175 num = ecore_x_window_prop_atom_list_get(win,
1176 ECORE_X_ATOM_NET_WM_WINDOW_TYPE,
1177 &atoms);
1178 if ((num <= 0) || (!atoms))
1179 {
1180 if (atoms)
1181 free(atoms);
1182
1183 return 0;
1184 }
1185
1186 atoms2 = malloc(num * sizeof(Ecore_X_Window_Type));
1187 if (!atoms2)
1188 return 0;
1189
1190 for (i = 0; i < num; i++)
1191 atoms2[i] = _ecore_x_netwm_window_type_type_get(atoms[i]);
1192 free(atoms);
1193 if (types)
1194 *types = atoms2;
1195 else
1196 free(atoms2);
1197
1198 return num;
1199} /* ecore_x_netwm_window_types_get */
1200
1201static Ecore_X_Atom
1202_ecore_x_netwm_action_atom_get(Ecore_X_Action action)
1203{
1204 switch (action)
1205 {
1206 case ECORE_X_ACTION_MOVE:
1207 return ECORE_X_ATOM_NET_WM_ACTION_MOVE;
1208
1209 case ECORE_X_ACTION_RESIZE:
1210 return ECORE_X_ATOM_NET_WM_ACTION_RESIZE;
1211
1212 case ECORE_X_ACTION_MINIMIZE:
1213 return ECORE_X_ATOM_NET_WM_ACTION_MINIMIZE;
1214
1215 case ECORE_X_ACTION_SHADE:
1216 return ECORE_X_ATOM_NET_WM_ACTION_SHADE;
1217
1218 case ECORE_X_ACTION_STICK:
1219 return ECORE_X_ATOM_NET_WM_ACTION_STICK;
1220
1221 case ECORE_X_ACTION_MAXIMIZE_HORZ:
1222 return ECORE_X_ATOM_NET_WM_ACTION_MAXIMIZE_HORZ;
1223
1224 case ECORE_X_ACTION_MAXIMIZE_VERT:
1225 return ECORE_X_ATOM_NET_WM_ACTION_MAXIMIZE_VERT;
1226
1227 case ECORE_X_ACTION_FULLSCREEN:
1228 return ECORE_X_ATOM_NET_WM_ACTION_FULLSCREEN;
1229
1230 case ECORE_X_ACTION_CHANGE_DESKTOP:
1231 return ECORE_X_ATOM_NET_WM_ACTION_CHANGE_DESKTOP;
1232
1233 case ECORE_X_ACTION_CLOSE:
1234 return ECORE_X_ATOM_NET_WM_ACTION_CLOSE;
1235
1236 case ECORE_X_ACTION_ABOVE:
1237 return ECORE_X_ATOM_NET_WM_ACTION_ABOVE;
1238
1239 case ECORE_X_ACTION_BELOW:
1240 return ECORE_X_ATOM_NET_WM_ACTION_BELOW;
1241
1242 default:
1243 return 0;
1244 } /* switch */
1245} /* _ecore_x_netwm_action_atom_get */
1246
1247/* FIXME: Get complete list */
1248EAPI Eina_Bool
1249ecore_x_netwm_allowed_action_isset(Ecore_X_Window win,
1250 Ecore_X_Action action)
1251{
1252 int num, i;
1253 Ecore_X_Atom *atoms, atom;
1254 Eina_Bool ret = EINA_FALSE;
1255
1256 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1257 num = ecore_x_window_prop_atom_list_get(win, ECORE_X_ATOM_NET_WM_WINDOW_TYPE,
1258 &atoms);
1259 if (num <= 0)
1260 return ret;
1261
1262 atom = _ecore_x_netwm_action_atom_get(action);
1263
1264 for (i = 0; i < num; ++i)
1265 {
1266 if (atom == atoms[i])
1267 {
1268 ret = 1;
1269 break;
1270 }
1271 }
1272
1273 free(atoms);
1274 return ret;
1275} /* ecore_x_netwm_allowed_action_isset */
1276
1277/* FIXME: Set complete list */
1278EAPI void
1279ecore_x_netwm_allowed_action_set(Ecore_X_Window win,
1280 Ecore_X_Action *action,
1281 unsigned int num)
1282{
1283 Ecore_X_Atom *set;
1284 unsigned int i;
1285
1286 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1287 if (!num)
1288 {
1289 ecore_x_window_prop_property_del(win,
1290 ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS);
1291 return;
1292 }
1293
1294 set = malloc(num * sizeof(Ecore_X_Atom));
1295 if (!set)
1296 return;
1297
1298 for (i = 0; i < num; i++)
1299 set[i] = _ecore_x_netwm_action_atom_get(action[i]);
1300
1301 ecore_x_window_prop_atom_set(win,
1302 ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS,
1303 set,
1304 num);
1305
1306 free(set);
1307} /* ecore_x_netwm_allowed_action_set */
1308
1309EAPI Eina_Bool
1310ecore_x_netwm_allowed_action_get(Ecore_X_Window win,
1311 Ecore_X_Action **action,
1312 unsigned int *num)
1313{
1314 int num_ret, i;
1315 Ecore_X_Atom *atoms;
1316
1317 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1318 if (num)
1319 *num = 0;
1320
1321 if (action)
1322 *action = NULL;
1323
1324 num_ret = ecore_x_window_prop_atom_list_get(
1325 win,
1326 ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS,
1327 &atoms);
1328 if (num_ret <= 0)
1329 return EINA_FALSE;
1330
1331 if (action)
1332 {
1333 *action = malloc(num_ret * sizeof(Ecore_X_Action));
1334 if (*action)
1335 for (i = 0; i < num_ret; ++i)
1336 (*action)[i] = _ecore_x_netwm_action_atom_get(atoms[i]);
1337
1338 if (num)
1339 *num = num_ret;
1340 }
1341
1342 free(atoms);
1343 return EINA_TRUE;
1344} /* ecore_x_netwm_allowed_action_get */
1345
1346EAPI void
1347ecore_x_netwm_opacity_set(Ecore_X_Window win,
1348 unsigned int opacity)
1349{
1350 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1351 ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_WINDOW_OPACITY,
1352 &opacity, 1);
1353} /* ecore_x_netwm_opacity_set */
1354
1355EAPI Eina_Bool
1356ecore_x_netwm_opacity_get(Ecore_X_Window win,
1357 unsigned int *opacity)
1358{
1359 int ret;
1360 unsigned int tmp;
1361
1362 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1363 ret = ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_WINDOW_OPACITY,
1364 &tmp, 1);
1365 if (opacity)
1366 *opacity = tmp;
1367
1368 return ret == 1 ? EINA_TRUE : EINA_FALSE;
1369} /* ecore_x_netwm_opacity_get */
1370
1371EAPI void
1372ecore_x_netwm_frame_size_set(Ecore_X_Window win,
1373 int fl,
1374 int fr,
1375 int ft,
1376 int fb)
1377{
1378 unsigned int frames[4];
1379
1380 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1381 frames[0] = fl;
1382 frames[1] = fr;
1383 frames[2] = ft;
1384 frames[3] = fb;
1385 ecore_x_window_prop_card32_set(win,
1386 ECORE_X_ATOM_NET_FRAME_EXTENTS,
1387 frames,
1388 4);
1389} /* ecore_x_netwm_frame_size_set */
1390
1391EAPI Eina_Bool
1392ecore_x_netwm_frame_size_get(Ecore_X_Window win,
1393 int *fl,
1394 int *fr,
1395 int *ft,
1396 int *fb)
1397{
1398 int ret = 0;
1399 unsigned int frames[4];
1400
1401 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1402 ret = ecore_x_window_prop_card32_get(win,
1403 ECORE_X_ATOM_NET_FRAME_EXTENTS,
1404 frames,
1405 4);
1406 if (ret != 4)
1407 return EINA_FALSE;
1408
1409 if (fl)
1410 *fl = frames[0];
1411
1412 if (fr)
1413 *fr = frames[1];
1414
1415 if (ft)
1416 *ft = frames[2];
1417
1418 if (fb)
1419 *fb = frames[3];
1420
1421 return EINA_TRUE;
1422} /* ecore_x_netwm_frame_size_get */
1423
1424EAPI Eina_Bool
1425ecore_x_netwm_sync_counter_get(Ecore_X_Window win,
1426 Ecore_X_Sync_Counter *counter)
1427{
1428 int ret;
1429 unsigned int tmp;
1430
1431 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1432 ret = ecore_x_window_prop_card32_get(
1433 win,
1434 ECORE_X_ATOM_NET_WM_SYNC_REQUEST_COUNTER,
1435 &tmp,
1436 1);
1437
1438 if (counter)
1439 *counter = tmp;
1440
1441 return ret == 1 ? EINA_TRUE : EINA_FALSE;
1442} /* ecore_x_netwm_sync_counter_get */
1443
1444EAPI void
1445ecore_x_netwm_ping_send(Ecore_X_Window win)
1446{
1447 XEvent xev;
1448
1449 if (!win)
1450 return;
1451
1452 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1453 xev.xclient.type = ClientMessage;
1454 xev.xclient.display = _ecore_x_disp;
1455 xev.xclient.window = win;
1456 xev.xclient.message_type = ECORE_X_ATOM_WM_PROTOCOLS;
1457 xev.xclient.format = 32;
1458 xev.xclient.data.l[0] = ECORE_X_ATOM_NET_WM_PING;
1459 xev.xclient.data.l[1] = _ecore_x_event_last_time;
1460 xev.xclient.data.l[2] = win;
1461 xev.xclient.data.l[3] = 0;
1462 xev.xclient.data.l[4] = 0;
1463
1464 XSendEvent(_ecore_x_disp, win, False, NoEventMask, &xev);
1465} /* ecore_x_netwm_ping_send */
1466
1467EAPI void
1468ecore_x_netwm_sync_request_send(Ecore_X_Window win,
1469 unsigned int serial)
1470{
1471 XSyncValue value;
1472 XEvent xev;
1473
1474 if (!win)
1475 return;
1476
1477 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1478 XSyncIntToValue(&value, (int)serial);
1479
1480 xev.xclient.type = ClientMessage;
1481 xev.xclient.display = _ecore_x_disp;
1482 xev.xclient.window = win;
1483 xev.xclient.message_type = ECORE_X_ATOM_WM_PROTOCOLS;
1484 xev.xclient.format = 32;
1485 xev.xclient.data.l[0] = ECORE_X_ATOM_NET_WM_SYNC_REQUEST;
1486 xev.xclient.data.l[1] = _ecore_x_event_last_time;
1487 xev.xclient.data.l[2] = XSyncValueLow32(value);
1488 xev.xclient.data.l[3] = XSyncValueHigh32(value);
1489 xev.xclient.data.l[4] = 0;
1490
1491 XSendEvent(_ecore_x_disp, win, False, NoEventMask, &xev);
1492} /* ecore_x_netwm_sync_request_send */
1493
1494EAPI void
1495ecore_x_netwm_state_request_send(Ecore_X_Window win,
1496 Ecore_X_Window root,
1497 Ecore_X_Window_State s1,
1498 Ecore_X_Window_State s2,
1499 Eina_Bool set)
1500{
1501 XEvent xev;
1502
1503 if (!win)
1504 return;
1505
1506 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1507 if (!root)
1508 root = DefaultRootWindow(_ecore_x_disp);
1509
1510 xev.xclient.type = ClientMessage;
1511 xev.xclient.serial = 0;
1512 xev.xclient.send_event = True;
1513 xev.xclient.display = _ecore_x_disp;
1514 xev.xclient.window = win;
1515 xev.xclient.format = 32;
1516 xev.xclient.message_type = ECORE_X_ATOM_NET_WM_STATE;
1517 xev.xclient.data.l[0] = !!set;
1518 xev.xclient.data.l[1] = _ecore_x_netwm_state_atom_get(s1);
1519 xev.xclient.data.l[2] = _ecore_x_netwm_state_atom_get(s2);
1520 /* 1 == normal client, if someone wants to use this
1521 * function in a pager, this should be 2 */
1522 xev.xclient.data.l[3] = 1;
1523 xev.xclient.data.l[4] = 0;
1524
1525 XSendEvent(_ecore_x_disp, root, False,
1526 SubstructureNotifyMask | SubstructureRedirectMask, &xev);
1527} /* ecore_x_netwm_state_request_send */
1528
1529EAPI void
1530ecore_x_netwm_desktop_request_send(Ecore_X_Window win,
1531 Ecore_X_Window root,
1532 unsigned int desktop)
1533{
1534 XEvent xev;
1535
1536 if (!win)
1537 return;
1538
1539 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1540 if (!root)
1541 root = DefaultRootWindow(_ecore_x_disp);
1542
1543 xev.xclient.type = ClientMessage;
1544 xev.xclient.serial = 0;
1545 xev.xclient.send_event = True;
1546 xev.xclient.display = _ecore_x_disp;
1547 xev.xclient.window = win;
1548 xev.xclient.format = 32;
1549 xev.xclient.message_type = ECORE_X_ATOM_NET_WM_DESKTOP;
1550 xev.xclient.data.l[0] = desktop;
1551
1552 XSendEvent(_ecore_x_disp, root, False,
1553 SubstructureNotifyMask | SubstructureRedirectMask, &xev);
1554} /* ecore_x_netwm_desktop_request_send */
1555
1556int
1557_ecore_x_netwm_startup_info_begin(Ecore_X_Window win __UNUSED__,
1558 char *data __UNUSED__)
1559{
1560#if 0
1561 Ecore_X_Startup_Info *info;
1562 unsigned char *exists = 0;
1563
1564 if (!startup_info)
1565 return 0;
1566
1567 info = eina_hash_find(startup_info, (void *)win);
1568 if (info)
1569 {
1570 exists = 1;
1571 WRN("Already got info for win: 0x%x", win);
1572 _ecore_x_netwm_startup_info_free(info);
1573 }
1574
1575 info = calloc(1, sizeof(Ecore_X_Startup_Info));
1576 if (!info)
1577 return 0;
1578
1579 info->win = win;
1580 info->length = 0;
1581 info->buffer_size = 161;
1582 info->buffer = calloc(info->buffer_size, sizeof(char));
1583 if (!info->buffer)
1584 {
1585 _ecore_x_netwm_startup_info_free(info);
1586 return 0;
1587 }
1588
1589 memcpy(info->buffer, data, 20);
1590 info->length += 20;
1591 info->buffer[info->length] = 0;
1592 if (exists)
1593 eina_hash_modify(startup_info, (void *)info->win, info);
1594 else
1595 eina_hash_add(startup_info, (void *)info->win, info);
1596
1597 if (strlen(info->buffer) != 20)
1598 /* We have a '\0' in there, the message is done */
1599 _ecore_x_netwm_startup_info_process(info);
1600
1601#endif /* if 0 */
1602 return 1;
1603} /* _ecore_x_netwm_startup_info_begin */
1604
1605int
1606_ecore_x_netwm_startup_info(Ecore_X_Window win __UNUSED__,
1607 char *data __UNUSED__)
1608{
1609#if 0
1610 Ecore_X_Startup_Info *info;
1611 char *p;
1612
1613 if (!startup_info)
1614 return 0;
1615
1616 info = eina_hash_find(startup_info, (void *)win);
1617 if (!info)
1618 return 0;
1619
1620 if ((info->length + 20) > info->buffer_size)
1621 {
1622 info->buffer_size += 160;
1623 info->buffer = realloc(info->buffer, info->buffer_size * sizeof(char));
1624 if (!info->buffer)
1625 {
1626 eina_hash_del(startup_info, (void *)info->win);
1627 _ecore_x_netwm_startup_info_free(info);
1628 return 0;
1629 }
1630 }
1631
1632 memcpy(info->buffer + info->length, data, 20);
1633 p = info->buffer + info->length;
1634 info->length += 20;
1635 info->buffer[info->length] = 0;
1636 if (strlen(p) != 20)
1637 /* We have a '\0' in there, the message is done */
1638 _ecore_x_netwm_startup_info_process(info);
1639
1640#endif /* if 0 */
1641 return 1;
1642} /* _ecore_x_netwm_startup_info */
1643
1644/*
1645 * Set UTF-8 string property
1646 */
1647static void
1648_ecore_x_window_prop_string_utf8_set(Ecore_X_Window win,
1649 Ecore_X_Atom atom,
1650 const char *str)
1651{
1652 XChangeProperty(_ecore_x_disp, win, atom, ECORE_X_ATOM_UTF8_STRING, 8,
1653 PropModeReplace, (unsigned char *)str, strlen(str));
1654} /* _ecore_x_window_prop_string_utf8_set */
1655
1656/*
1657 * Get UTF-8 string property
1658 */
1659static char *
1660_ecore_x_window_prop_string_utf8_get(Ecore_X_Window win,
1661 Ecore_X_Atom atom)
1662{
1663 char *str;
1664 unsigned char *prop_ret;
1665 Atom type_ret;
1666 unsigned long bytes_after, num_ret;
1667 int format_ret;
1668
1669 str = NULL;
1670 prop_ret = NULL;
1671 XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False,
1672 ECORE_X_ATOM_UTF8_STRING, &type_ret,
1673 &format_ret, &num_ret, &bytes_after, &prop_ret);
1674 if (prop_ret && num_ret > 0 && format_ret == 8)
1675 {
1676 str = malloc(num_ret + 1);
1677 if (str)
1678 {
1679 memcpy(str, prop_ret, num_ret);
1680 str[num_ret] = '\0';
1681 }
1682 }
1683
1684 if (prop_ret)
1685 XFree(prop_ret);
1686
1687 return str;
1688} /* _ecore_x_window_prop_string_utf8_get */
1689
1690#if 0 /* Unused */
1691/*
1692 * Process startup info
1693 */
1694static int
1695_ecore_x_netwm_startup_info_process(Ecore_X_Startup_Info *info)
1696{
1697 Ecore_X_Event_Startup_Sequence *e;
1698 int event;
1699 char *p;
1700
1701 p = strchr(info->buffer, ':');
1702 if (!p)
1703 {
1704 eina_hash_del(startup_info, (void *)info->win);
1705 _ecore_x_netwm_startup_info_free(info);
1706 return 0;
1707 }
1708
1709 *p = 0;
1710 if (!strcmp(info->buffer, "new"))
1711 {
1712 if (info->init)
1713 event = ECORE_X_EVENT_STARTUP_SEQUENCE_CHANGE;
1714 else
1715 event = ECORE_X_EVENT_STARTUP_SEQUENCE_NEW;
1716
1717 info->init = 1;
1718 }
1719 else if (!strcmp(info->buffer, "change"))
1720 event = ECORE_X_EVENT_STARTUP_SEQUENCE_CHANGE;
1721 else if (!strcmp(info->buffer, "remove"))
1722 event = ECORE_X_EVENT_STARTUP_SEQUENCE_REMOVE;
1723 else
1724 {
1725 eina_hash_del(startup_info, (void *)info->win);
1726 _ecore_x_netwm_startup_info_free(info);
1727 return 0;
1728 }
1729
1730 p++;
1731
1732 if (!_ecore_x_netwm_startup_info_parse(info, p))
1733 {
1734 eina_hash_del(startup_info, (void *)info->win);
1735 _ecore_x_netwm_startup_info_free(info);
1736 return 0;
1737 }
1738
1739 if (info->init)
1740 {
1741 e = calloc(1, sizeof(Ecore_X_Event_Startup_Sequence));
1742 if (!e)
1743 {
1744 eina_hash_del(startup_info, (void *)info->win);
1745 _ecore_x_netwm_startup_info_free(info);
1746 return 0;
1747 }
1748
1749 e->win = info->win;
1750 ecore_event_add(event, e, NULL, NULL);
1751 }
1752
1753 if (event == ECORE_X_EVENT_STARTUP_SEQUENCE_REMOVE)
1754 {
1755 eina_hash_del(startup_info, (void *)info->win);
1756 _ecore_x_netwm_startup_info_free(info);
1757 }
1758 else
1759 {
1760 /* Discard buffer */
1761 info->length = 0;
1762 info->buffer[0] = 0;
1763 }
1764
1765 return 1;
1766} /* _ecore_x_netwm_startup_info_process */
1767
1768/*
1769 * Parse startup info
1770 */
1771static int
1772_ecore_x_netwm_startup_info_parse(Ecore_X_Startup_Info *info,
1773 char *data)
1774{
1775 while (*data)
1776 {
1777 int in_quot_sing, in_quot_dbl, escaped;
1778 char *p, *pp;
1779 char *key;
1780 char value[1024];
1781
1782 /* Skip space */
1783 while (*data == ' ') data++;
1784 /* Get key */
1785 key = data;
1786 data = strchr(key, '=');
1787 if (!data)
1788 return 0;
1789
1790 *data = 0;
1791 data++;
1792
1793 /* Get value */
1794 p = data;
1795 pp = value;
1796 in_quot_dbl = 0;
1797 in_quot_sing = 0;
1798 escaped = 0;
1799 while (*p)
1800 {
1801 if ((pp - value) >= 1024)
1802 return 0;
1803
1804 if (escaped)
1805 {
1806 *pp = *p;
1807 pp++;
1808 escaped = 0;
1809 }
1810 else if (in_quot_sing)
1811 {
1812 if (*p == '\\')
1813 escaped = 1;
1814 else if (*p == '\'')
1815 in_quot_sing = 0;
1816 else
1817 {
1818 *pp = *p;
1819 pp++;
1820 }
1821 }
1822 else if (in_quot_dbl)
1823 {
1824 if (*p == '\\')
1825 escaped = 1;
1826 else if (*p == '\"')
1827 in_quot_dbl = 0;
1828 else
1829 {
1830 *pp = *p;
1831 pp++;
1832 }
1833 }
1834 else
1835 {
1836 if (*p == '\\')
1837 escaped = 1;
1838 else if (*p == '\'')
1839 in_quot_sing = 1;
1840 else if (*p == '\"')
1841 in_quot_dbl = 1;
1842 else if (*p == ' ')
1843 break;
1844 else
1845 {
1846 *pp = *p;
1847 pp++;
1848 }
1849 }
1850
1851 p++;
1852 }
1853 if ((in_quot_dbl) || (in_quot_sing))
1854 return 0;
1855
1856 data = p;
1857 *pp = 0;
1858
1859 /* Parse info */
1860 if (!strcmp(key, "ID"))
1861 {
1862 if ((info->id) && (strcmp(info->id, value)))
1863 return 0;
1864
1865 info->id = strdup(value);
1866 p = strstr(value, "_TIME");
1867 if (p)
1868 info->timestamp = atoi(p + 5);
1869 }
1870 else if (!strcmp(key, "NAME"))
1871 {
1872 if (info->name)
1873 free(info->name);
1874
1875 info->name = strdup(value);
1876 }
1877 else if (!strcmp(key, "SCREEN"))
1878 info->screen = atoi(value);
1879 else if (!strcmp(key, "BIN"))
1880 {
1881 if (info->bin)
1882 free(info->bin);
1883
1884 info->bin = strdup(value);
1885 }
1886 else if (!strcmp(key, "ICON"))
1887 {
1888 if (info->icon)
1889 free(info->icon);
1890
1891 info->icon = strdup(value);
1892 }
1893 else if (!strcmp(key, "DESKTOP"))
1894 info->desktop = atoi(value);
1895 else if (!strcmp(key, "TIMESTAMP"))
1896 {
1897 if (!info->timestamp)
1898 info->timestamp = atoi(value);
1899 }
1900 else if (!strcmp(key, "DESCRIPTION"))
1901 {
1902 if (info->description)
1903 free(info->description);
1904
1905 info->description = strdup(value);
1906 }
1907 else if (!strcmp(key, "WMCLASS"))
1908 {
1909 if (info->wmclass)
1910 free(info->wmclass);
1911
1912 info->wmclass = strdup(value);
1913 }
1914 else if (!strcmp(key, "SILENT"))
1915 info->silent = atoi(value);
1916 else
1917 ERR("Ecore X Sequence, Unknown: %s=%s", key, value);
1918 }
1919 if (!info->id)
1920 return 0;
1921
1922 return 1;
1923} /* _ecore_x_netwm_startup_info_parse */
1924
1925#endif /* if 0 */
1926
1927/*
1928 * Free startup info struct
1929 */
1930static void
1931_ecore_x_netwm_startup_info_free(void *data)
1932{
1933 Ecore_X_Startup_Info *info;
1934
1935 info = data;
1936 if (!info)
1937 return;
1938
1939 if (info->buffer)
1940 free(info->buffer);
1941
1942 if (info->id)
1943 free(info->id);
1944
1945 if (info->name)
1946 free(info->name);
1947
1948 if (info->bin)
1949 free(info->bin);
1950
1951 if (info->icon)
1952 free(info->icon);
1953
1954 if (info->description)
1955 free(info->description);
1956
1957 if (info->wmclass)
1958 free(info->wmclass);
1959
1960 free(info);
1961} /* _ecore_x_netwm_startup_info_free */
1962
1963/*
1964 * Is screen composited?
1965 */
1966EAPI Eina_Bool
1967ecore_x_screen_is_composited(int screen)
1968{
1969 Ecore_X_Window win;
1970 static Ecore_X_Atom atom = None;
1971 char buf[32];
1972
1973 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1974 snprintf(buf, sizeof(buf), "_NET_WM_CM_S%i", screen);
1975 if (atom == None)
1976 atom = XInternAtom(_ecore_x_disp, buf, False);
1977
1978 if (atom == None)
1979 return EINA_FALSE;
1980
1981 win = XGetSelectionOwner(_ecore_x_disp, atom);
1982
1983 return (win != None) ? EINA_TRUE : EINA_FALSE;
1984} /* ecore_x_screen_is_composited */
1985
1986EAPI void
1987ecore_x_screen_is_composited_set(int screen,
1988 Ecore_X_Window win)
1989{
1990 static Ecore_X_Atom atom = None;
1991 char buf[32];
1992
1993 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1994 snprintf(buf, sizeof(buf), "_NET_WM_CM_S%i", screen);
1995 if (atom == None)
1996 atom = XInternAtom(_ecore_x_disp, buf, False);
1997
1998 if (atom == None)
1999 return;
2000
2001 XSetSelectionOwner(_ecore_x_disp, atom, win, _ecore_x_event_last_time);
2002} /* ecore_x_screen_is_composited_set */
2003
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_pixmap.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_pixmap.c
new file mode 100644
index 0000000..b81d06c
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_pixmap.c
@@ -0,0 +1,121 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include "Ecore.h"
6#include "ecore_x_private.h"
7#include "Ecore_X.h"
8
9/**
10 * @defgroup Ecore_X_Pixmap_Group X Pixmap Functions
11 *
12 * Functions that operate on pixmaps.
13 */
14
15/**
16 * Creates a new pixmap.
17 * @param win Window used to determine which screen of the display the
18 * pixmap should be created on. If 0, the default root window
19 * is used.
20 * @param w Width of the new pixmap.
21 * @param h Height of the new pixmap.
22 * @param dep Depth of the pixmap. If 0, the default depth of the default
23 * screen is used.
24 * @return New pixmap.
25 * @ingroup Ecore_X_Pixmap_Group
26 */
27EAPI Ecore_X_Pixmap
28ecore_x_pixmap_new(Ecore_X_Window win,
29 int w,
30 int h,
31 int dep)
32{
33 LOGFN(__FILE__, __LINE__, __FUNCTION__);
34 if (win == 0)
35 win = DefaultRootWindow(_ecore_x_disp);
36
37 if (dep == 0)
38 dep = DefaultDepth(_ecore_x_disp, DefaultScreen(_ecore_x_disp));
39
40 return XCreatePixmap(_ecore_x_disp, win, w, h, dep);
41} /* ecore_x_pixmap_new */
42
43/**
44 * Deletes the reference to the given pixmap.
45 *
46 * If no other clients have a reference to the given pixmap, the server
47 * will destroy it.
48 *
49 * @param pmap The given pixmap.
50 * @ingroup Ecore_X_Pixmap_Group
51 */
52EAPI void
53ecore_x_pixmap_free(Ecore_X_Pixmap pmap)
54{
55 LOGFN(__FILE__, __LINE__, __FUNCTION__);
56 XFreePixmap(_ecore_x_disp, pmap);
57} /* ecore_x_pixmap_free */
58
59/**
60 * Pastes a rectangular area of the given pixmap onto the given drawable.
61 * @param pmap The given pixmap.
62 * @param dest The given drawable.
63 * @param gc The graphics context which governs which operation will
64 * be used to paste the area onto the drawable.
65 * @param sx The X position of the area on the pixmap.
66 * @param sy The Y position of the area on the pixmap.
67 * @param w The width of the area.
68 * @param h The height of the area.
69 * @param dx The X position at which to paste the area on @p dest.
70 * @param dy The Y position at which to paste the area on @p dest.
71 * @ingroup Ecore_X_Pixmap_Group
72 */
73EAPI void
74ecore_x_pixmap_paste(Ecore_X_Pixmap pmap,
75 Ecore_X_Drawable dest,
76 Ecore_X_GC gc,
77 int sx,
78 int sy,
79 int w,
80 int h,
81 int dx,
82 int dy)
83{
84 LOGFN(__FILE__, __LINE__, __FUNCTION__);
85 XCopyArea(_ecore_x_disp, pmap, dest, gc, sx, sy, w, h, dx, dy);
86} /* ecore_x_pixmap_paste */
87
88/**
89 * Retrieves the size of the given pixmap.
90 * @param pmap The given pixmap.
91 * @param x Pointer to an integer in which to store the X position.
92 * @param y Pointer to an integer in which to store the Y position.
93 * @param w Pointer to an integer in which to store the width.
94 * @param h Pointer to an integer in which to store the height.
95 * @ingroup Ecore_X_Pixmap_Group
96 */
97EAPI void
98ecore_x_pixmap_geometry_get(Ecore_X_Pixmap pmap,
99 int *x,
100 int *y,
101 int *w,
102 int *h)
103{
104 LOGFN(__FILE__, __LINE__, __FUNCTION__);
105 if (pmap)
106 ecore_x_drawable_geometry_get(pmap, x, y, w, h);
107} /* ecore_x_pixmap_geometry_get */
108
109/**
110 * Retrieves the depth of the given pixmap.
111 * @param pmap The given pixmap.
112 * @return The depth of the pixmap.
113 * @ingroup Ecore_X_Pixmap_Group
114 */
115EAPI int
116ecore_x_pixmap_depth_get(Ecore_X_Pixmap pmap)
117{
118 LOGFN(__FILE__, __LINE__, __FUNCTION__);
119 return ecore_x_drawable_depth_get(pmap);
120} /* ecore_x_pixmap_depth_get */
121
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_private.h b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_private.h
new file mode 100644
index 0000000..02a01f7
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_private.h
@@ -0,0 +1,385 @@
1#ifndef _ECORE_X_PRIVATE_H
2#define _ECORE_X_PRIVATE_H
3
4#include <sys/param.h>
5#ifndef MAXHOSTNAMELEN
6#define MAXHOSTNAMELEN 256
7#endif /* ifndef MAXHOSTNAMELEN */
8
9#include <X11/Xlib.h>
10#include <X11/Xproto.h>
11#include <X11/Xutil.h>
12#include <X11/Xatom.h>
13#include <X11/Xresource.h>
14#include <X11/keysymdef.h>
15#include <X11/extensions/XShm.h>
16#include <X11/extensions/shape.h>
17#include <X11/extensions/sync.h>
18#include <X11/extensions/dpms.h>
19#ifdef ECORE_XCURSOR
20#include <X11/Xcursor/Xcursor.h>
21#endif /* ifdef ECORE_XCURSOR */
22#ifdef ECORE_XPRINT
23#include <X11/extensions/Print.h>
24#endif /* ifdef ECORE_XPRINT */
25#ifdef ECORE_XINERAMA
26#include <X11/extensions/Xinerama.h>
27#endif /* ifdef ECORE_XINERAMA */
28#ifdef ECORE_XRANDR
29#include <X11/extensions/Xrandr.h>
30#endif /* ifdef ECORE_XRANDR */
31#ifdef ECORE_XSS
32#include <X11/extensions/scrnsaver.h>
33#endif /* ifdef ECORE_XSS */
34#ifdef ECORE_XRENDER
35#include <X11/extensions/Xrender.h>
36#endif /* ifdef ECORE_XRENDER */
37#ifdef ECORE_XFIXES
38#include <X11/extensions/Xfixes.h>
39#endif /* ifdef ECORE_XFIXES */
40#ifdef ECORE_XCOMPOSITE
41#include <X11/extensions/Xcomposite.h>
42#endif /* ifdef ECORE_XCOMPOSITE */
43#ifdef ECORE_XDAMAGE
44#include <X11/extensions/Xdamage.h>
45#endif /* ifdef ECORE_XDAMAGE */
46#ifdef ECORE_XGESTURE
47#include <X11/extensions/gesture.h>
48#include <X11/extensions/gestureproto.h>
49#endif /* ifdef ECORE_XGESTURE */
50#ifdef ECORE_XDPMS
51#include <X11/extensions/dpms.h>
52#endif /* ifdef ECORE_XDPMS */
53#ifdef ECORE_XKB
54#include <X11/XKBlib.h>
55#endif /* ifdef ECORE_XKB */
56#ifdef ECORE_XI2
57#include <X11/extensions/XInput2.h>
58#endif /* ifdef ECORE_XI2 */
59
60#ifndef XK_MISCELLANY
61# define XK_MISCELLANY 1
62#endif
63
64#include "Ecore.h"
65#include "ecore_private.h"
66#include "Ecore_X.h"
67#include "Ecore_Input.h"
68
69extern int _ecore_xlib_log_dom;
70#ifdef ECORE_XLIB_DEFAULT_LOG_COLOR
71# undef ECORE_XLIB_DEFAULT_LOG_COLOR
72#endif /* ifdef ECORE_XLIB_DEFAULT_LOG_COLOR */
73#define ECORE_XLIB_DEFAULT_LOG_COLOR EINA_COLOR_BLUE
74
75#ifdef ERR
76# undef ERR
77#endif /* ifdef ERR */
78#define ERR(...) EINA_LOG_DOM_ERR(_ecore_xlib_log_dom, __VA_ARGS__)
79
80#ifdef DBG
81# undef DBG
82#endif /* ifdef DBG */
83#define DBG(...) EINA_LOG_DOM_DBG(_ecore_xlib_log_dom, __VA_ARGS__)
84
85#ifdef INF
86# undef INF
87#endif /* ifdef INF */
88#define INF(...) EINA_LOG_DOM_INFO(_ecore_xlib_log_dom, __VA_ARGS__)
89
90#ifdef WRN
91# undef WRN
92#endif /* ifdef WRN */
93#define WRN(...) EINA_LOG_DOM_WARN(_ecore_xlib_log_dom, __VA_ARGS__)
94
95#ifdef CRIT
96# undef CRIT
97#endif /* ifdef CRIT */
98#define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_xlib_log_dom, __VA_ARGS__)
99
100typedef struct _Ecore_X_Selection_Intern Ecore_X_Selection_Intern;
101
102struct _Ecore_X_Selection_Intern
103{
104 Ecore_X_Window win;
105 Ecore_X_Atom selection;
106 unsigned char *data;
107 int length;
108 Time time;
109};
110
111typedef struct _Ecore_X_Selection_Converter Ecore_X_Selection_Converter;
112
113struct _Ecore_X_Selection_Converter
114{
115 Ecore_X_Atom target;
116 Eina_Bool (*convert)(char *target, void *data, int size, void **data_ret, int *size_ret, Ecore_X_Atom *type, int *typeseize);
117 Ecore_X_Selection_Converter *next;
118};
119
120typedef struct _Ecore_X_Selection_Parser Ecore_X_Selection_Parser;
121
122struct _Ecore_X_Selection_Parser
123{
124 char *target;
125 void *(*parse)(const char *target, void *data, int size, int format);
126 Ecore_X_Selection_Parser *next;
127};
128
129typedef struct _Ecore_X_DND_Source
130{
131 int version;
132 Ecore_X_Window win, dest;
133
134 enum {
135 ECORE_X_DND_SOURCE_IDLE,
136 ECORE_X_DND_SOURCE_DRAGGING,
137 ECORE_X_DND_SOURCE_DROPPED,
138 ECORE_X_DND_SOURCE_CONVERTING
139 } state;
140
141 struct
142 {
143 short x, y;
144 unsigned short width, height;
145 } rectangle;
146
147 struct
148 {
149 Ecore_X_Window window;
150 int x, y;
151 } prev;
152
153 Time time;
154
155 Ecore_X_Atom action, accepted_action;
156
157 int will_accept;
158 int suppress;
159
160 int await_status;
161} Ecore_X_DND_Source;
162
163typedef struct _Ecore_X_DND_Target
164{
165 int version;
166 Ecore_X_Window win, source;
167
168 enum {
169 ECORE_X_DND_TARGET_IDLE,
170 ECORE_X_DND_TARGET_ENTERED
171 } state;
172
173 struct
174 {
175 int x, y;
176 } pos;
177
178 Time time;
179
180 Ecore_X_Atom action, accepted_action;
181
182 int will_accept;
183} Ecore_X_DND_Target;
184
185extern int ECORE_X_MODIFIER_SHIFT;
186extern int ECORE_X_MODIFIER_CTRL;
187extern int ECORE_X_MODIFIER_ALT;
188extern int ECORE_X_MODIFIER_WIN;
189
190extern int ECORE_X_LOCK_SCROLL;
191extern int ECORE_X_LOCK_NUM;
192extern int ECORE_X_LOCK_CAPS;
193extern int ECORE_X_LOCK_SHIFT;
194
195extern Display *_ecore_x_disp;
196extern double _ecore_x_double_click_time;
197extern Time _ecore_x_event_last_time;
198extern Window _ecore_x_event_last_win;
199extern int _ecore_x_event_last_root_x;
200extern int _ecore_x_event_last_root_y;
201extern Eina_Bool _ecore_x_xcursor;
202
203extern Ecore_X_Atom _ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_NUM];
204
205extern int _ecore_window_grabs_num;
206extern Window *_ecore_window_grabs;
207extern Eina_Bool (*_ecore_window_grab_replay_func)(void *data,
208 int event_type,
209 void *event);
210extern void *_ecore_window_grab_replay_data;
211
212extern Ecore_X_Window _ecore_x_private_win;
213
214void _ecore_x_error_handler_init(void);
215void _ecore_x_event_handle_any_event(XEvent *xevent);
216void _ecore_x_event_handle_key_press(XEvent *xevent);
217void _ecore_x_event_handle_key_release(XEvent *xevent);
218void _ecore_x_event_handle_button_press(XEvent *xevent);
219void _ecore_x_event_handle_button_release(XEvent *xevent);
220void _ecore_x_event_handle_motion_notify(XEvent *xevent);
221void _ecore_x_event_handle_enter_notify(XEvent *xevent);
222void _ecore_x_event_handle_leave_notify(XEvent *xevent);
223void _ecore_x_event_handle_focus_in(XEvent *xevent);
224void _ecore_x_event_handle_focus_out(XEvent *xevent);
225void _ecore_x_event_handle_keymap_notify(XEvent *xevent);
226void _ecore_x_event_handle_expose(XEvent *xevent);
227void _ecore_x_event_handle_graphics_expose(XEvent *xevent);
228void _ecore_x_event_handle_visibility_notify(XEvent *xevent);
229void _ecore_x_event_handle_create_notify(XEvent *xevent);
230void _ecore_x_event_handle_destroy_notify(XEvent *xevent);
231void _ecore_x_event_handle_unmap_notify(XEvent *xevent);
232void _ecore_x_event_handle_map_notify(XEvent *xevent);
233void _ecore_x_event_handle_map_request(XEvent *xevent);
234void _ecore_x_event_handle_reparent_notify(XEvent *xevent);
235void _ecore_x_event_handle_configure_notify(XEvent *xevent);
236void _ecore_x_event_handle_configure_request(XEvent *xevent);
237void _ecore_x_event_handle_gravity_notify(XEvent *xevent);
238void _ecore_x_event_handle_resize_request(XEvent *xevent);
239void _ecore_x_event_handle_circulate_notify(XEvent *xevent);
240void _ecore_x_event_handle_circulate_request(XEvent *xevent);
241void _ecore_x_event_handle_property_notify(XEvent *xevent);
242void _ecore_x_event_handle_selection_clear(XEvent *xevent);
243void _ecore_x_event_handle_selection_request(XEvent *xevent);
244void _ecore_x_event_handle_selection_notify(XEvent *xevent);
245void _ecore_x_event_handle_colormap_notify(XEvent *xevent);
246void _ecore_x_event_handle_client_message(XEvent *xevent);
247void _ecore_x_event_handle_mapping_notify(XEvent *xevent);
248void _ecore_x_event_handle_shape_change(XEvent *xevent);
249void _ecore_x_event_handle_screensaver_notify(XEvent *xevent);
250#ifdef ECORE_XGESTURE
251void _ecore_x_event_handle_gesture_notify_flick(XEvent *xevent);
252void _ecore_x_event_handle_gesture_notify_pan(XEvent *xevent);
253void _ecore_x_event_handle_gesture_notify_pinchrotation(XEvent *xevent);
254void _ecore_x_event_handle_gesture_notify_tap(XEvent *xevent);
255void _ecore_x_event_handle_gesture_notify_tapnhold(XEvent *xevent);
256void _ecore_x_event_handle_gesture_notify_hold(XEvent *xevent);
257void _ecore_x_event_handle_gesture_notify_group(XEvent *xevent);
258#endif /* ifdef ECORE_XGESTURE */
259void _ecore_x_event_handle_sync_counter(XEvent *xevent);
260void _ecore_x_event_handle_sync_alarm(XEvent *xevent);
261#ifdef ECORE_XRANDR
262void _ecore_x_event_handle_randr_change(XEvent *xevent);
263void _ecore_x_event_handle_randr_notify(XEvent *xevent);
264#endif /* ifdef ECORE_XRANDR */
265#ifdef ECORE_XFIXES
266void _ecore_x_event_handle_fixes_selection_notify(XEvent *xevent);
267#endif /* ifdef ECORE_XFIXES */
268#ifdef ECORE_XDAMAGE
269void _ecore_x_event_handle_damage_notify(XEvent *xevent);
270#endif /* ifdef ECORE_XDAMAGE */
271void _ecore_x_event_handle_generic_event(XEvent *xevent);
272
273void _ecore_x_selection_data_init(void);
274void _ecore_x_selection_shutdown(void);
275Ecore_X_Atom _ecore_x_selection_target_atom_get(const char *target);
276char *_ecore_x_selection_target_get(Ecore_X_Atom target);
277Ecore_X_Selection_Intern *_ecore_x_selection_get(Ecore_X_Atom selection);
278Eina_Bool _ecore_x_selection_set(Window w,
279 const void *data,
280 int len,
281 Ecore_X_Atom selection);
282int _ecore_x_selection_convert(Ecore_X_Atom selection,
283 Ecore_X_Atom target,
284 void **data_ret,
285 Ecore_X_Atom *targettype,
286 int *targetsize);
287void *_ecore_x_selection_parse(const char *target,
288 void *data,
289 int size,
290 int format);
291
292void _ecore_x_sync_magic_send(int val,
293 Ecore_X_Window swin);
294void _ecore_x_window_grab_remove(Ecore_X_Window win);
295void _ecore_x_key_grab_remove(Ecore_X_Window win);
296
297/* from dnd */
298void _ecore_x_dnd_init(void);
299Ecore_X_DND_Source *_ecore_x_dnd_source_get(void);
300Ecore_X_DND_Target *_ecore_x_dnd_target_get(void);
301void _ecore_x_dnd_drag(Ecore_X_Window root,
302 int x,
303 int y);
304void _ecore_x_dnd_shutdown(void);
305
306/* from netwm */
307Ecore_X_Window_State _ecore_x_netwm_state_get(Ecore_X_Atom a);
308int _ecore_x_netwm_startup_info_begin(Ecore_X_Window win,
309 char *data);
310int _ecore_x_netwm_startup_info(Ecore_X_Window win,
311 char *data);
312
313/* Fixes * Damage * Composite * DPMS */
314void _ecore_x_fixes_init(void);
315void _ecore_x_damage_init(void);
316void _ecore_x_composite_init(void);
317void _ecore_x_dpms_init(void);
318void _ecore_x_randr_init(void);
319void _ecore_x_gesture_init(void);
320
321void _ecore_x_atoms_init(void);
322
323extern int _ecore_x_xi2_opcode;
324
325void _ecore_x_events_init(void);
326void _ecore_x_events_shutdown(void);
327
328void _ecore_x_input_init(void);
329void _ecore_x_input_shutdown(void);
330void _ecore_x_input_handler(XEvent *xevent);
331/* from sync */
332
333void _ecore_mouse_move(unsigned int timestamp,
334 unsigned int xmodifiers,
335 int x,
336 int y,
337 int x_root,
338 int y_root,
339 unsigned int event_window,
340 unsigned int window,
341 unsigned int root_win,
342 int same_screen,
343 int dev,
344 double radx,
345 double rady,
346 double pressure,
347 double angle,
348 double mx,
349 double my,
350 double mrx,
351 double mry);
352Ecore_Event_Mouse_Button *_ecore_mouse_button(int event,
353 unsigned int timestamp,
354 unsigned int xmodifiers,
355 unsigned int buttons,
356 int x,
357 int y,
358 int x_root,
359 int y_root,
360 unsigned int event_window,
361 unsigned int window,
362 unsigned int root_win,
363 int same_screen,
364 int dev,
365 double radx,
366 double rady,
367 double pressure,
368 double angle,
369 double mx,
370 double my,
371 double mrx,
372 double mry);
373
374void _ecore_x_modifiers_get(void);
375
376//#define LOGFNS 1
377
378#ifdef LOGFNS
379#include <stdio.h>
380#define LOGFN(fl, ln, fn) printf("-ECORE-X: %25s: %5i - %s\n", fl, ln, fn);
381#else /* ifdef LOGFNS */
382#define LOGFN(fl, ln, fn)
383#endif /* ifdef LOGFNS */
384
385#endif /* ifndef _ECORE_X_PRIVATE_H */
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr.c
new file mode 100644
index 0000000..d4d834f
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr.c
@@ -0,0 +1,102 @@
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_randr.h"
7
8static Eina_Bool _randr_available = EINA_FALSE;
9#ifdef ECORE_XRANDR
10static int _randr_major, _randr_minor;
11int _randr_version;
12#define RANDR_1_1 ((1 << 16) | 1)
13#define RANDR_1_2 ((1 << 16) | 2)
14#define RANDR_1_3 ((1 << 16) | 3)
15
16#define RANDR_VALIDATE_ROOT(screen, \
17 root) ((screen = \
18 XRRRootToScreen(_ecore_x_disp, \
19 root)) != -1)
20
21#define Ecore_X_Randr_Unset -1
22
23XRRScreenResources *(*_ecore_x_randr_get_screen_resources)(Display * dpy,
24 Window window);
25
26#endif /* ifdef ECORE_XRANDR */
27
28void
29_ecore_x_randr_init(void)
30{
31#ifdef ECORE_XRANDR
32 _randr_major = 1;
33 _randr_minor = 3;
34 _randr_version = 0;
35
36 _ecore_x_randr_get_screen_resources = NULL;
37 if (XRRQueryVersion(_ecore_x_disp, &_randr_major, &_randr_minor))
38 {
39 _randr_version = (_randr_major << 16) | _randr_minor;
40 if (_randr_version >= RANDR_1_3)
41 _ecore_x_randr_get_screen_resources = XRRGetScreenResourcesCurrent;
42 else if (_randr_version == RANDR_1_2)
43 _ecore_x_randr_get_screen_resources = XRRGetScreenResources;
44
45 _randr_available = EINA_TRUE;
46 }
47 else
48 _randr_available = EINA_FALSE;
49
50#else
51 _randr_available = EINA_FALSE;
52#endif
53}
54
55/*
56 * @brief query whether randr is available or not
57 * @return EINA_TRUE, if extension is available, else EINA_FALSE
58 */
59EAPI Eina_Bool
60ecore_x_randr_query(void)
61{
62 return _randr_available;
63}
64
65/*
66 * @return version of the RandRR extension supported by the server or,
67 * in case RandRR extension is not available, Ecore_X_Randr_Unset (=-1).
68 * bit version information: 31 MAJOR 16 | 15 MINOR 0
69 */
70EAPI int
71ecore_x_randr_version_get(void)
72{
73#ifdef ECORE_XRANDR
74 LOGFN(__FILE__, __LINE__, __FUNCTION__);
75 if (_randr_available)
76 {
77 return _randr_version;
78 }
79 else
80 {
81 return Ecore_X_Randr_Unset;
82 }
83#else
84 return -1;
85#endif
86}
87
88Eina_Bool
89_ecore_x_randr_root_validate(Ecore_X_Window root)
90{
91#ifdef ECORE_XRANDR
92 Ecore_X_Randr_Screen scr = -1;
93 if (root && RANDR_VALIDATE_ROOT(scr, root))
94 return EINA_TRUE;
95 else
96 return EINA_FALSE;
97
98#else
99 return EINA_FALSE;
100#endif
101}
102
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr.h b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr.h
new file mode 100644
index 0000000..eca3c0c
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr.h
@@ -0,0 +1,7 @@
1#ifndef ECORE_X_INLINE_X
2#define ECORE_X_INLINE_X
3Eina_Bool _ecore_x_randr_root_validate(Ecore_X_Window root);
4Eina_Bool _ecore_x_randr_output_validate(Ecore_X_Window root,
5 Ecore_X_Randr_Output
6 output);
7#endif
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_11.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_11.c
new file mode 100644
index 0000000..a6bafb6
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_11.c
@@ -0,0 +1,332 @@
1/*
2 * vim:ts=8:sw=3:sts=8:expandtab:cino=>5n-3f0^-2{2
3 */
4
5#ifdef HAVE_CONFIG_H
6# include <config.h>
7#endif /* ifdef HAVE_CONFIG_H */
8
9#include "ecore_x_private.h"
10#include "ecore_x_randr.h"
11
12#define Ecore_X_Randr_None 0
13#ifdef ECORE_XRANDR
14
15#define RANDR_1_1 ((1 << 16) | 1)
16
17#define RANDR_VALIDATE_ROOT(screen, \
18 root) ((screen = \
19 XRRRootToScreen(_ecore_x_disp, \
20 root)) != -1)
21#define RANDR_CHECK_1_1_RET(ret) if(_randr_version < RANDR_1_1) return ret
22
23extern XRRScreenResources *(*_ecore_x_randr_get_screen_resources)(Display *
24 dpy,
25 Window
26 window);
27extern int _randr_version;
28#endif /* ifdef ECORE_XRANDR */
29
30/*
31 * @param root window which's primary output will be queried
32 */
33EAPI Ecore_X_Randr_Orientation
34ecore_x_randr_screen_primary_output_orientations_get(Ecore_X_Window root)
35{
36#ifdef ECORE_XRANDR
37 Rotation rot = Ecore_X_Randr_None, crot;
38
39 LOGFN(__FILE__, __LINE__, __FUNCTION__);
40 rot =
41 XRRRotations(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
42 root), &crot);
43 return rot;
44#else /* ifdef ECORE_XRANDR */
45 return Ecore_X_Randr_None;
46#endif /* ifdef ECORE_XRANDR */
47} /* ecore_x_randr_screen_primary_output_orientations_get */
48
49/*
50 * @param root window which's primary output will be queried
51 * @return the current orientation of the root window's screen primary output
52 */
53EAPI Ecore_X_Randr_Orientation
54ecore_x_randr_screen_primary_output_orientation_get(Ecore_X_Window root)
55{
56#ifdef ECORE_XRANDR
57 Rotation crot = Ecore_X_Randr_None;
58 XRRRotations(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
59 root), &crot);
60 return crot;
61#else /* ifdef ECORE_XRANDR */
62 return Ecore_X_Randr_None;
63#endif /* ifdef ECORE_XRANDR */
64} /* ecore_x_randr_screen_primary_output_orientation_get */
65
66/*
67 * @brief sets a given screen's primary output's orientation
68 * @param root window which's screen's primary output will be queried
69 * @param orientation orientation which should be set for the root window's screen primary output
70 * @return EINA_TRUE if the primary output's orientation could be successfully altered
71 */
72EAPI Eina_Bool
73ecore_x_randr_screen_primary_output_orientation_set(
74 Ecore_X_Window root,
75 Ecore_X_Randr_Orientation
76 orientation)
77{
78#ifdef ECORE_XRANDR
79 XRRScreenConfiguration *xrr_screen_cfg = NULL;
80 int sizeid;
81 Rotation crot;
82 Eina_Bool ret = EINA_FALSE;
83 if (!(xrr_screen_cfg = XRRGetScreenInfo(_ecore_x_disp, root)))
84 return EINA_FALSE;
85
86 sizeid = XRRConfigCurrentConfiguration(xrr_screen_cfg, &crot);
87 if (!XRRSetScreenConfig(_ecore_x_disp, xrr_screen_cfg, root, sizeid,
88 orientation, CurrentTime))
89 ret = EINA_TRUE;
90
91 if (xrr_screen_cfg)
92 XRRFreeScreenConfigInfo(xrr_screen_cfg);
93
94 return ret;
95#else /* ifdef ECORE_XRANDR */
96 return EINA_FALSE;
97#endif /* ifdef ECORE_XRANDR */
98} /* ecore_x_randr_screen_primary_output_orientation_set */
99
100/*
101 * @brief gets a screen's primary output's possible sizes
102 * @param root window which's primary output will be queried
103 * @param num number of sizes reported as supported by the screen's primary output
104 * @return an array of sizes reported as supported by the screen's primary output or - if query failed - NULL
105 */
106EAPI Ecore_X_Randr_Screen_Size_MM *
107ecore_x_randr_screen_primary_output_sizes_get(Ecore_X_Window root,
108 int *num)
109{
110#ifdef ECORE_XRANDR
111 Ecore_X_Randr_Screen_Size_MM *ret = NULL;
112 XRRScreenSize *sizes;
113 int i, n;
114
115 /* we don't have to free sizes, because they're hold in a cache inside X*/
116 sizes =
117 XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
118 root), &n);
119 if ((!sizes) || (n <= 0)) return NULL;
120 ret = calloc(n, sizeof(Ecore_X_Randr_Screen_Size_MM));
121 if (!ret)
122 return NULL;
123
124 if (num)
125 *num = n;
126
127 for (i = 0; i < n; i++)
128 {
129 ret[i].width = sizes[i].width;
130 ret[i].height = sizes[i].height;
131 ret[i].width_mm = sizes[i].mwidth;
132 ret[i].height_mm = sizes[i].mheight;
133 }
134 return ret;
135#else /* ifdef ECORE_XRANDR */
136 return NULL;
137#endif /* ifdef ECORE_XRANDR */
138} /* ecore_x_randr_screen_primary_output_sizes_get */
139
140/*
141 * @brief get the current set size of a given screen's primary output
142 * @param root window which's primary output will be queried
143 * @param w the current size's width
144 * @param h the current size's height
145 * @param w_mm the current size's width in mm
146 * @param h_mm the current size's height in mm
147 * @param size_index of current set size to be used with ecore_x_randr_primary_output_size_set()
148 */
149EAPI void
150ecore_x_randr_screen_primary_output_current_size_get(Ecore_X_Window root,
151 int *w,
152 int *h,
153 int *w_mm,
154 int *h_mm,
155 int *size_index)
156{
157#ifdef ECORE_XRANDR
158 XRRScreenSize *sizes;
159 XRRScreenConfiguration *sc = NULL;
160 int idx;
161 Rotation orientation;
162 int n;
163
164 if (!(sc = XRRGetScreenInfo(_ecore_x_disp, root)))
165 {
166 ERR("Couldn't get screen information for %d", root);
167 return;
168 }
169
170 idx = XRRConfigCurrentConfiguration(sc, &orientation);
171
172 sizes =
173 XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
174 root), &n);
175 if ((idx < n) && (idx >= 0))
176 {
177 if (w)
178 *w = sizes[idx].width;
179
180 if (h)
181 *h = sizes[idx].height;
182
183 if (w_mm)
184 *w_mm = sizes[idx].mwidth;
185
186 if (h_mm)
187 *h_mm = sizes[idx].mheight;
188
189 if (size_index)
190 *size_index = idx;
191 }
192
193 XRRFreeScreenConfigInfo(sc);
194#endif /* ifdef ECORE_XRANDR */
195} /* ecore_x_randr_screen_primary_output_current_size_get */
196
197/*
198 * @brief sets a given screen's primary output size, but disables all other outputs at the same time
199 * @param root window which's primary output will be queried
200 * @param size_index within the list of sizes reported as supported by the root window's screen primary output
201 * @return EINA_TRUE on success, EINA_FALSE on failure due to e.g. invalid times
202 */
203EAPI Eina_Bool
204ecore_x_randr_screen_primary_output_size_set(Ecore_X_Window root,
205 int size_index)
206{
207#ifdef ECORE_XRANDR
208 XRRScreenConfiguration *sc = NULL;
209 XRRScreenSize *sizes;
210 Eina_Bool ret = EINA_FALSE;
211 int nsizes = 0;
212
213 if (size_index >= 0 && _ecore_x_randr_root_validate(root))
214 {
215 sizes =
216 XRRSizes(_ecore_x_disp, XRRRootToScreen(_ecore_x_disp,
217 root), &nsizes);
218
219 if (size_index < nsizes)
220 {
221 sc = XRRGetScreenInfo(_ecore_x_disp, root);
222 if (!XRRSetScreenConfig(_ecore_x_disp, sc,
223 root, size_index,
224 ECORE_X_RANDR_ORIENTATION_ROT_0, CurrentTime))
225 {
226 ret = EINA_TRUE;
227 }
228
229 if (sc)
230 XRRFreeScreenConfigInfo(sc);
231 }
232 }
233
234 return ret;
235#else /* ifdef ECORE_XRANDR */
236 return EINA_FALSE;
237#endif /* ifdef ECORE_XRANDR */
238} /* ecore_x_randr_screen_primary_output_size_set */
239
240/*
241 * @param root window which's primary output will be queried
242 * @return currently used refresh rate or - if request failed or RandRR is not available - 0.0
243 */
244EAPI Ecore_X_Randr_Refresh_Rate
245ecore_x_randr_screen_primary_output_current_refresh_rate_get(
246 Ecore_X_Window root)
247{
248#ifdef ECORE_XRANDR
249 Ecore_X_Randr_Refresh_Rate ret = 0.0;
250 XRRScreenConfiguration *sc = NULL;
251
252 if (!_ecore_x_randr_root_validate(root) ||
253 !(sc = XRRGetScreenInfo(_ecore_x_disp, root)))
254 return ret;
255
256 ret = XRRConfigCurrentRate(sc);
257 if (sc)
258 XRRFreeScreenConfigInfo(sc);
259
260 return ret;
261#else /* ifdef ECORE_XRANDR */
262 return 0.0;
263#endif /* ifdef ECORE_XRANDR */
264} /* ecore_x_randr_screen_primary_output_current_refresh_rate_get */
265
266/*
267 * @param root window which's primary output will be queried
268 * @param size_index referencing the size to query valid refresh rates for
269 * @return currently used refresh rate or - if request failed or RandRR is not available - NULL
270 */
271EAPI Ecore_X_Randr_Refresh_Rate *
272ecore_x_randr_screen_primary_output_refresh_rates_get(Ecore_X_Window root,
273 int size_index,
274 int *num)
275{
276#ifdef ECORE_XRANDR
277 Ecore_X_Randr_Refresh_Rate *ret = NULL, *rates = NULL;
278 Ecore_X_Randr_Screen scr;
279 int n;
280
281 if (num
282 && RANDR_VALIDATE_ROOT(scr, root)
283 && (rates = XRRRates(_ecore_x_disp, scr, size_index, &n)))
284 {
285 if (rates && (ret = malloc(sizeof(Ecore_X_Randr_Refresh_Rate) * n)))
286 {
287 memcpy(ret, rates, (sizeof(Ecore_X_Randr_Refresh_Rate) * n));
288 *num = n;
289 }
290 }
291
292 return ret;
293#else /* ifdef ECORE_XRANDR */
294 return NULL;
295#endif /* ifdef ECORE_XRANDR */
296} /* ecore_x_randr_screen_primary_output_refresh_rates_get */
297
298//>= 1.1
299/*
300 * @brief sets the current primary output's refresh rate
301 * @param root window which's primary output will be queried
302 * @param size_index referencing the size to be set
303 * @param rate the refresh rate to be set
304 * @return EINA_TRUE on success else EINA_FALSE
305 */
306EAPI Eina_Bool
307ecore_x_randr_screen_primary_output_refresh_rate_set(
308 Ecore_X_Window root,
309 int size_index,
310 Ecore_X_Randr_Refresh_Rate
311 rate)
312{
313#ifdef ECORE_XRANDR
314 RANDR_CHECK_1_1_RET(EINA_FALSE);
315 Eina_Bool ret = EINA_FALSE;
316 XRRScreenConfiguration *sc = NULL;
317
318 if (!(sc = XRRGetScreenInfo(_ecore_x_disp, root)))
319 return ret;
320
321 if (!XRRSetScreenConfigAndRate(_ecore_x_disp, sc,
322 root, size_index,
323 RR_Rotate_0, rate, CurrentTime))
324 ret = EINA_TRUE;
325
326 XRRFreeScreenConfigInfo(sc);
327 return ret;
328#else /* ifdef ECORE_XRANDR */
329 return EINA_FALSE;
330#endif /* ifdef ECORE_XRANDR */
331} /* ecore_x_randr_screen_primary_output_refresh_rate_set */
332
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c
new file mode 100644
index 0000000..fb607d1
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12.c
@@ -0,0 +1,2199 @@
1/*
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */
4
5#ifdef HAVE_CONFIG_H
6# include <config.h>
7#endif
8
9#include "ecore_x_private.h"
10#include "ecore_x_randr.h"
11
12#define Ecore_X_Randr_None (Ecore_X_Randr_Crtc)0
13#define Ecore_X_Randr_Unset (Ecore_X_Randr_Crtc) - 1
14
15#ifdef ECORE_XRANDR
16
17#define RANDR_1_2 ((1 << 16) | 2)
18
19#define RANDR_VALIDATE_ROOT(screen, root) \
20 ((screen = XRRRootToScreen(_ecore_x_disp, root)) != -1)
21
22#define RANDR_CHECK_1_2_RET(ret) if(_randr_version < RANDR_1_2) return ret
23
24#define RANDR_PROPERTY_EDID "EDID"
25#define RANDR_PROPERTY_BACKLIGHT "Backlight"
26#define RANDR_PROPERTY_SIGNAL_FORMAT "SignalFormat"
27#define RANDR_PROPERTY_SIGNAL_PROPERTIES "SignalProperties"
28#define RANDR_PROPERTY_CONNECTOR_TYPE "ConnectorType"
29#define RANDR_PROPERTY_CONNECTOR_NUMBER "ConnectorNumber"
30#define RANDR_PROPERTY_COMPATIBILITY_LIST "CompatibilityList"
31#define RANDR_PROPERTY_CLONE_LIST "CloneList"
32
33extern XRRScreenResources *(*_ecore_x_randr_get_screen_resources)(Display *
34 dpy,
35 Window
36 window);
37extern int _randr_version;
38#endif
39
40/**
41 * @brief enable event selection. This enables basic interaction with
42 * output/crtc events and requires RRandR >= 1.2.
43 * @param win select this window's properties for RandRR events
44 * @param on enable/disable selecting
45 */
46EAPI void
47ecore_x_randr_events_select(Ecore_X_Window win,
48 Eina_Bool on)
49{
50#ifdef ECORE_XRANDR
51 int mask;
52
53 LOGFN(__FILE__, __LINE__, __FUNCTION__);
54 if (!on)
55 mask = 0;
56 else
57 {
58 mask = RRScreenChangeNotifyMask;
59 if (_randr_version >= RANDR_1_2)
60 mask |= (RRCrtcChangeNotifyMask |
61 RROutputChangeNotifyMask |
62 RROutputPropertyNotifyMask);
63 }
64
65 XRRSelectInput(_ecore_x_disp, win, mask);
66#endif
67}
68
69/**
70 * @brief validates a CRTC for a given root window's screen.
71 * @param root the window which's default display will be queried
72 * @param crtc the CRTC to be validated.
73 * @return in case it is found EINA_TRUE will be returned. Else EINA_FALSE is returned.
74 */
75static inline Eina_Bool
76_ecore_x_randr_crtc_validate(Ecore_X_Window root,
77 Ecore_X_Randr_Crtc crtc)
78{
79#ifdef ECORE_XRANDR
80 RANDR_CHECK_1_2_RET(EINA_FALSE);
81
82 XRRScreenResources *res = NULL;
83 int i;
84 Eina_Bool ret = EINA_FALSE;
85
86 if ((crtc == Ecore_X_Randr_None) ||
87 (crtc == Ecore_X_Randr_Unset))
88 return ret;
89
90 if (_ecore_x_randr_root_validate(root) && crtc &&
91 (res = _ecore_x_randr_get_screen_resources (_ecore_x_disp, root)))
92 {
93 for (i = 0; i < res->ncrtc; i++)
94 {
95 if (res->crtcs[i] == crtc)
96 {
97 ret = EINA_TRUE;
98 break;
99 }
100 }
101 XRRFreeScreenResources(res);
102 }
103
104 return ret;
105#else
106 return EINA_FALSE;
107#endif
108}
109
110Eina_Bool
111_ecore_x_randr_output_validate(Ecore_X_Window root,
112 Ecore_X_Randr_Output output)
113{
114#ifdef ECORE_XRANDR
115 RANDR_CHECK_1_2_RET(EINA_FALSE);
116
117 Eina_Bool ret = EINA_FALSE;
118 XRRScreenResources *res = NULL;
119 int i;
120
121 if (_ecore_x_randr_root_validate(root) && output &&
122 (res = _ecore_x_randr_get_screen_resources (_ecore_x_disp, root)))
123 {
124 for (i = 0; i < res->noutput; i++)
125 {
126 if (res->outputs[i] == output)
127 {
128 ret = EINA_TRUE;
129 break;
130 }
131 }
132 XRRFreeScreenResources(res);
133 }
134
135 return ret;
136#else
137 return EINA_FALSE;
138#endif
139}
140
141static inline Eina_Bool
142_ecore_x_randr_mode_validate(Ecore_X_Window root,
143 Ecore_X_Randr_Mode mode)
144{
145#ifdef ECORE_XRANDR
146 RANDR_CHECK_1_2_RET(EINA_FALSE);
147
148 Eina_Bool ret = EINA_FALSE;
149 XRRScreenResources *res = NULL;
150 int i;
151
152 if (_ecore_x_randr_root_validate(root) && mode &&
153 (res = _ecore_x_randr_get_screen_resources (_ecore_x_disp, root)))
154 {
155 for (i = 0; i < res->nmode; i++)
156 {
157 if (res->modes[i].id == mode)
158 {
159 ret = EINA_TRUE;
160 break;
161 }
162 }
163 XRRFreeScreenResources(res);
164 }
165
166 return ret;
167#else
168 return EINA_FALSE;
169#endif
170}
171
172/*
173 * @param w width of screen in px
174 * @param h height of screen in px
175 */
176EAPI void
177ecore_x_randr_screen_current_size_get(Ecore_X_Window root,
178 int *w,
179 int *h,
180 int *w_mm,
181 int *h_mm)
182{
183#ifdef ECORE_XRANDR
184 RANDR_CHECK_1_2_RET();
185 Ecore_X_Randr_Screen scr;
186
187 if (!RANDR_VALIDATE_ROOT(scr, root))
188 return;
189
190 if (w)
191 *w = DisplayWidth(_ecore_x_disp, scr);
192
193 if (h)
194 *h = DisplayHeight(_ecore_x_disp, scr);
195
196 if (w_mm)
197 *w_mm = DisplayWidthMM(_ecore_x_disp, scr);
198
199 if (h_mm)
200 *h_mm = DisplayHeightMM(_ecore_x_disp, scr);
201
202#endif
203}
204
205/*
206 * @param root window which's screen will be queried
207 * @param wmin minimum width the screen can be set to
208 * @param hmin minimum height the screen can be set to
209 * @param wmax maximum width the screen can be set to
210 * @param hmax maximum height the screen can be set to
211 */
212EAPI void
213ecore_x_randr_screen_size_range_get(Ecore_X_Window root,
214 int *wmin,
215 int *hmin,
216 int *wmax,
217 int *hmax)
218{
219#ifdef ECORE_XRANDR
220 RANDR_CHECK_1_2_RET();
221 int twmin, thmin, twmax, thmax;
222 if (XRRGetScreenSizeRange (_ecore_x_disp, root, &twmin, &thmin, &twmax,
223 &thmax))
224 {
225 if (wmin)
226 *wmin = twmin;
227
228 if (hmin)
229 *hmin = thmin;
230
231 if (wmax)
232 *wmax = twmax;
233
234 if (hmax)
235 *hmax = thmax;
236 }
237
238#endif
239}
240
241/*
242 * @param root window which's screen's size should be set. If invalid (e.g. NULL) no action is taken.
243 * @param w width in px the screen should be set to. If out of valid boundaries, current value is assumed.
244 * @param h height in px the screen should be set to. If out of valid boundaries, current value is assumed.
245 * @param w_mm width in mm the screen should be set to. If 0, current aspect is assumed.
246 * @param h_mm height in mm the screen should be set to. If 0, current aspect is assumed.
247 * @return EINA_TRUE if request was successfully sent or screen is already in
248 * requested size, EINA_FALSE if parameters are invalid
249 */
250EAPI Eina_Bool
251ecore_x_randr_screen_current_size_set(Ecore_X_Window root,
252 int w,
253 int h,
254 int w_mm,
255 int h_mm)
256{
257#ifdef ECORE_XRANDR
258 RANDR_CHECK_1_2_RET(EINA_FALSE);
259
260 Ecore_X_Randr_Screen scr;
261 int w_c, h_c, w_mm_c, h_mm_c, twmin, thmin, twmax, thmax;
262
263 if (!RANDR_VALIDATE_ROOT(scr, root))
264 return EINA_FALSE;
265
266 ecore_x_randr_screen_current_size_get(root, &w_c, &h_c, &w_mm_c, &h_mm_c);
267 if ((w == w_c) && (h == h_c) && (w_mm_c == w_mm) && (h_mm_c == h_mm))
268 return EINA_TRUE;
269
270 ecore_x_randr_screen_size_range_get(root, &twmin, &thmin, &twmax, &thmax);
271
272 if (((w != Ecore_X_Randr_None) &&
273 ((w < twmin) ||
274 (w > twmax))) ||
275 ((h != Ecore_X_Randr_None) && ((h < thmin) || (h > thmax))))
276 return EINA_FALSE;
277
278 if (w <= 0)
279 w = DisplayWidth(_ecore_x_disp, scr);
280
281 if (h <= 0)
282 h = DisplayHeight(_ecore_x_disp, scr);
283
284 if(w_mm <= 0)
285 w_mm =
286 (int)(((double)(DisplayWidthMM(_ecore_x_disp,
287 scr) /
288 (double)DisplayWidth(_ecore_x_disp,
289 scr))) * (double)w);
290
291 if(h_mm <= 0)
292 h_mm =
293 (int)(((double)(DisplayHeightMM(_ecore_x_disp,
294 scr) /
295 (double)DisplayHeight(_ecore_x_disp,
296 scr))) * (double)h);
297
298 XRRSetScreenSize (_ecore_x_disp, root, w, h, w_mm, h_mm);
299 return EINA_TRUE;
300#else
301 return EINA_FALSE;
302#endif
303}
304
305/*
306 * @brief get detailed information for all modes related to a root window's screen
307 * @param root window which's screen's ressources are queried
308 * @param num number of modes returned
309 * @return modes' information
310 */
311EAPI Ecore_X_Randr_Mode_Info **
312ecore_x_randr_modes_info_get(Ecore_X_Window root,
313 int *num)
314{
315#ifdef ECORE_XRANDR
316 RANDR_CHECK_1_2_RET(NULL);
317 XRRScreenResources *res = NULL;
318 Ecore_X_Randr_Mode_Info **ret = NULL;
319 int i;
320
321 if (_ecore_x_randr_root_validate(root) &&
322 (res = _ecore_x_randr_get_screen_resources (_ecore_x_disp, root)))
323 {
324 if ((ret =
325 (Ecore_X_Randr_Mode_Info **)malloc(sizeof(
326 Ecore_X_Randr_Mode_Info *)
327 *
328 res->nmode)))
329 {
330 for (i = 0; i < res->nmode; i++)
331 {
332 if ((ret[i] = malloc(sizeof(Ecore_X_Randr_Mode_Info))))
333 {
334 ret[i]->xid = res->modes[i].id;
335 ret[i]->width = res->modes[i].width;
336 ret[i]->height = res->modes[i].height;
337 ret[i]->dotClock = res->modes[i].dotClock;
338 ret[i]->hSyncStart = res->modes[i].hSyncStart;
339 ret[i]->hSyncEnd = res->modes[i].hSyncEnd;
340 ret[i]->hTotal = res->modes[i].hTotal;
341 ret[i]->hSkew = res->modes[i].hSkew;
342 ret[i]->vSyncStart = res->modes[i].vSyncStart;
343 ret[i]->vSyncEnd = res->modes[i].vSyncEnd;
344 ret[i]->vTotal = res->modes[i].vTotal;
345 if ((ret[i]->name = (malloc(res->modes[i].nameLength))))
346 strncpy(ret[i]->name, res->modes[i].name,
347 res->modes[i].nameLength);
348 else
349 ret[i]->name = NULL;
350
351 ret[i]->nameLength = res->modes[i].nameLength;
352 ret[i]->modeFlags = res->modes[i].modeFlags;
353 }
354 else
355 {
356 while(i > 0)
357 free(ret[--i]);
358 free(ret);
359 ret = NULL;
360 break;
361 }
362 }
363 }
364
365 if (ret && num)
366 *num = res->nmode;
367
368 XRRFreeScreenResources(res);
369 }
370
371 return ret;
372#else
373 return NULL;
374#endif
375}
376
377/*
378 * @brief get detailed information for a given mode id
379 * @param root window which's screen's ressources are queried
380 * @param mode the XID which identifies the mode of interest
381 * @return mode's detailed information
382 */
383EAPI Ecore_X_Randr_Mode_Info *
384ecore_x_randr_mode_info_get(Ecore_X_Window root,
385 Ecore_X_Randr_Mode mode)
386{
387#ifdef ECORE_XRANDR
388 RANDR_CHECK_1_2_RET(NULL);
389 XRRScreenResources *res = NULL;
390 Ecore_X_Randr_Mode_Info *ret = NULL;
391 int i;
392
393 if (_ecore_x_randr_root_validate(root) &&
394 (res = _ecore_x_randr_get_screen_resources(_ecore_x_disp, root)))
395 {
396 for (i = 0; i < res->nmode; i++)
397 {
398 if ((res->modes[i].id == mode) &&
399 (ret = malloc(sizeof(Ecore_X_Randr_Mode_Info))))
400 {
401 ret->xid = res->modes[i].id;
402 ret->width = res->modes[i].width;
403 ret->height = res->modes[i].height;
404 ret->dotClock = res->modes[i].dotClock;
405 ret->hSyncStart = res->modes[i].hSyncStart;
406 ret->hSyncEnd = res->modes[i].hSyncEnd;
407 ret->hTotal = res->modes[i].hTotal;
408 ret->hSkew = res->modes[i].hSkew;
409 ret->vSyncStart = res->modes[i].vSyncStart;
410 ret->vSyncEnd = res->modes[i].vSyncEnd;
411 ret->vTotal = res->modes[i].vTotal;
412 ret->name = NULL;
413 ret->nameLength = 0;
414 if (res->modes[i].nameLength > 0)
415 {
416 ret->nameLength = res->modes[i].nameLength;
417 ret->name = malloc(res->modes[i].nameLength + 1);
418 if (ret->name)
419 memcpy(ret->name, res->modes[i].name,
420 res->modes[i].nameLength + 1);
421 }
422 ret->modeFlags = res->modes[i].modeFlags;
423 break;
424 }
425 }
426 XRRFreeScreenResources(res);
427 }
428
429 return ret;
430#else
431 return NULL;
432#endif
433}
434
435/*
436 * @brief free detailed mode information. The pointer handed in will be set to
437 * NULL after freeing the memory.
438 * @param mode_info the mode information that should be freed
439 */
440EAPI void
441ecore_x_randr_mode_info_free(Ecore_X_Randr_Mode_Info *mode_info)
442{
443#ifdef ECORE_XRANDR
444 RANDR_CHECK_1_2_RET();
445 if (!mode_info)
446 return;
447
448 if (mode_info->name)
449 free(mode_info->name);
450
451 free(mode_info);
452 mode_info = NULL;
453#endif
454}
455
456/*
457 * @brief get all known CRTCs related to a root window's screen
458 * @param root window which's screen's ressources are queried
459 * @param num number of CRTCs returned
460 * @return CRTC IDs
461 */
462EAPI Ecore_X_Randr_Crtc *
463ecore_x_randr_crtcs_get(Ecore_X_Window root,
464 int *num)
465{
466#ifdef ECORE_XRANDR
467 RANDR_CHECK_1_2_RET(NULL);
468 XRRScreenResources *res = NULL;
469 Ecore_X_Randr_Crtc *ret = NULL;
470
471 if (num && root &&
472 (res = _ecore_x_randr_get_screen_resources (_ecore_x_disp, root)))
473 {
474 if ((ret = malloc(sizeof(Ecore_X_Randr_Crtc) * res->ncrtc)))
475 {
476 memcpy(ret, res->crtcs, (sizeof(Ecore_X_Randr_Crtc) * res->ncrtc));
477 *num = res->ncrtc;
478 }
479
480 XRRFreeScreenResources(res);
481 }
482
483 return ret;
484#else
485 return NULL;
486#endif
487}
488
489EAPI Ecore_X_Randr_Output *
490ecore_x_randr_outputs_get(Ecore_X_Window root,
491 int *num)
492{
493#ifdef ECORE_XRANDR
494 RANDR_CHECK_1_2_RET(NULL);
495 XRRScreenResources *res = NULL;
496 Ecore_X_Randr_Output *ret = NULL;
497
498 if (num && root &&
499 (res = _ecore_x_randr_get_screen_resources (_ecore_x_disp, root)))
500 {
501 if ((ret = malloc(sizeof(Ecore_X_Randr_Output) * res->noutput)))
502 {
503 memcpy(ret, res->outputs,
504 (sizeof(Ecore_X_Randr_Output) * res->noutput));
505 if (num)
506 *num = res->noutput;
507 }
508
509 if (res)
510 XRRFreeScreenResources(res);
511 }
512
513 return ret;
514#else
515 return NULL;
516#endif
517}
518
519//Per Crtc
520/*
521 * @brief get a CRTC's outputs.
522 * @param root the root window which's screen will be queried
523 * @param num number of outputs referenced by given CRTC
524 */
525EAPI Ecore_X_Randr_Output *
526ecore_x_randr_crtc_outputs_get(Ecore_X_Window root,
527 Ecore_X_Randr_Crtc crtc,
528 int *num)
529{
530#ifdef ECORE_XRANDR
531 RANDR_CHECK_1_2_RET(NULL);
532 XRRScreenResources *res = NULL;
533 Ecore_X_Randr_Output *ret = NULL;
534 XRRCrtcInfo *crtc_info = NULL;
535
536 if (_ecore_x_randr_crtc_validate(root,
537 crtc) &&
538 (res =
539 _ecore_x_randr_get_screen_resources (_ecore_x_disp,
540 root)) &&
541 (crtc_info = XRRGetCrtcInfo(_ecore_x_disp, res, crtc)))
542 {
543 if ((ret = malloc(sizeof(Ecore_X_Randr_Output) * crtc_info->noutput)))
544 {
545 memcpy(ret, crtc_info->outputs,
546 (sizeof(Ecore_X_Randr_Output) * crtc_info->noutput));
547 if (num)
548 *num = crtc_info->noutput;
549 }
550
551 if (crtc_info)
552 XRRFreeCrtcInfo(crtc_info);
553
554 if (res)
555 XRRFreeScreenResources(res);
556 }
557
558 return ret;
559#else
560 return NULL;
561#endif
562}
563
564/*
565 * @brief get a CRTC's possible outputs.
566 * @param root the root window which's screen will be queried
567 * @param num number of possible outputs referenced by given CRTC
568 */
569EAPI Ecore_X_Randr_Output *
570ecore_x_randr_crtc_possible_outputs_get(Ecore_X_Window root,
571 Ecore_X_Randr_Crtc crtc,
572 int *num)
573{
574#ifdef ECORE_XRANDR
575 RANDR_CHECK_1_2_RET(NULL);
576 XRRScreenResources *res = NULL;
577 Ecore_X_Randr_Output *ret = NULL;
578 XRRCrtcInfo *crtc_info = NULL;
579
580 if (_ecore_x_randr_crtc_validate(root,
581 crtc) &&
582 (res = _ecore_x_randr_get_screen_resources (_ecore_x_disp, root)))
583 {
584 if((crtc_info = XRRGetCrtcInfo(_ecore_x_disp, res, crtc)))
585 {
586 if ((ret =
587 malloc(sizeof(Ecore_X_Randr_Output) * crtc_info->npossible)))
588 {
589 memcpy(ret, crtc_info->possible,
590 (sizeof(Ecore_X_Randr_Output) * crtc_info->npossible));
591 if (num)
592 *num = res->ncrtc;
593 }
594
595 XRRFreeCrtcInfo(crtc_info);
596 }
597
598 XRRFreeScreenResources(res);
599 }
600
601 return ret;
602#else
603 return NULL;
604#endif
605}
606
607EAPI void
608ecore_x_randr_crtc_geometry_get(Ecore_X_Window root,
609 Ecore_X_Randr_Crtc crtc,
610 int *x,
611 int *y,
612 int *w,
613 int *h)
614{
615#ifdef ECORE_XRANDR
616 RANDR_CHECK_1_2_RET();
617 XRRScreenResources *res = NULL;
618 XRRCrtcInfo *crtc_info = NULL;
619
620 if (_ecore_x_randr_crtc_validate(root,
621 crtc) &&
622 (res =
623 _ecore_x_randr_get_screen_resources (_ecore_x_disp,
624 root)) &&
625 (crtc_info = XRRGetCrtcInfo(_ecore_x_disp, res, crtc)))
626 {
627 if (x)
628 *x = crtc_info->x;
629
630 if (y)
631 *y = crtc_info->y;
632
633 if (w)
634 *w = crtc_info->width;
635
636 if (h)
637 *h = crtc_info->height;
638
639 XRRFreeCrtcInfo(crtc_info);
640 XRRFreeScreenResources(res);
641 }
642
643#endif
644}
645
646/*
647 * @brief sets the position of given CRTC within root window's screen
648 * @param root the window's screen to be queried
649 * @param crtc the CRTC which's position within the mentioned screen is to be altered
650 * @param x position on the x-axis (0 == left) of the screen. if x < 0 current value will be kept.
651 * @param y position on the y-ayis (0 == top) of the screen. if y < 0, current value will be kept.
652 * @return EINA_TRUE if position could be successfully be altered.
653 */
654EAPI Eina_Bool
655ecore_x_randr_crtc_pos_set(Ecore_X_Window root,
656 Ecore_X_Randr_Crtc crtc,
657 int x,
658 int y)
659{
660#ifdef ECORE_XRANDR
661 RANDR_CHECK_1_2_RET(EINA_FALSE);
662 int w_c, h_c, w_new = 0, h_new = 0;
663 Eina_Rectangle crtc_geo;
664
665 ecore_x_randr_crtc_geometry_get(root,
666 crtc,
667 &crtc_geo.x,
668 &crtc_geo.y,
669 &crtc_geo.w,
670 &crtc_geo.h);
671 ecore_x_randr_screen_current_size_get(root, &w_c, &h_c, NULL, NULL);
672 if (x < 0)
673 x = crtc_geo.x;
674
675 if (y < 0)
676 y = crtc_geo.y;
677
678 if ((x + crtc_geo.w) > w_c)
679 w_new = x + crtc_geo.w;
680
681 if ((y + crtc_geo.h) > h_c)
682 h_new = y + crtc_geo.h;
683
684 if ((w_new != 0) || (h_new != 0))
685 if (!ecore_x_randr_screen_current_size_set(root, w_new, h_new, 0, 0))
686 return EINA_FALSE;
687
688 return ecore_x_randr_crtc_settings_set(root,
689 crtc,
690 NULL,
691 Ecore_X_Randr_Unset,
692 x,
693 y,
694 Ecore_X_Randr_Unset,
695 Ecore_X_Randr_Unset);
696#else
697 return EINA_FALSE;
698#endif
699}
700
701/**
702 * @brief Get the current set mode of a given CRTC
703 * @param root the window's screen to be queried
704 * @param crtc the CRTC which's should be queried
705 * @return currently set mode or - in case parameters are invalid -
706 * Ecore_X_Randr_Unset
707 */
708EAPI Ecore_X_Randr_Mode
709ecore_x_randr_crtc_mode_get(Ecore_X_Window root,
710 Ecore_X_Randr_Crtc crtc)
711{
712#ifdef ECORE_XRANDR
713 RANDR_CHECK_1_2_RET(Ecore_X_Randr_Unset);
714 XRRScreenResources *res = NULL;
715 XRRCrtcInfo *crtc_info = NULL;
716 Ecore_X_Randr_Mode ret = Ecore_X_Randr_Unset;
717 if (_ecore_x_randr_root_validate(root) &&
718 _ecore_x_randr_crtc_validate(root,
719 crtc) &&
720 (res =
721 _ecore_x_randr_get_screen_resources(_ecore_x_disp,
722 root)) &&
723 (crtc_info = XRRGetCrtcInfo(_ecore_x_disp, res, crtc)))
724 {
725 ret = crtc_info->mode;
726 XRRFreeCrtcInfo(crtc_info);
727 XRRFreeScreenResources(res);
728 }
729
730 return ret;
731#else
732 return Ecore_X_Randr_Unset;
733#endif
734}
735
736/**
737 * @brief sets a mode for a CRTC and the outputs attached to it
738 * @param root the window's screen to be queried
739 * @param crtc the CRTC which shall be set
740 * @param outputs array of outputs which have to be compatible with the mode. If
741 * NULL CRTC will be disabled.
742 * @param noutputs number of outputs in array to be used. Use
743 * Ecore_X_Randr_Unset (or -1) to use currently used outputs.
744 * @param mode XID of the mode to be set. If set to 0 the CRTC will be disabled.
745 * If set to -1 the call will fail.
746 * @return EINA_TRUE if mode setting was successful. Else EINA_FALSE
747 */
748EAPI Eina_Bool
749ecore_x_randr_crtc_mode_set(Ecore_X_Window root,
750 Ecore_X_Randr_Crtc crtc,
751 Ecore_X_Randr_Output *outputs,
752 int noutputs,
753 Ecore_X_Randr_Mode mode)
754{
755#ifdef ECORE_XRANDR
756 RANDR_CHECK_1_2_RET(EINA_FALSE);
757
758 if (mode == Ecore_X_Randr_Unset)
759 return EINA_FALSE;
760
761 return ecore_x_randr_crtc_settings_set(root,
762 crtc,
763 outputs,
764 noutputs,
765 Ecore_X_Randr_Unset,
766 Ecore_X_Randr_Unset,
767 mode,
768 Ecore_X_Randr_Unset);
769#else
770 return EINA_FALSE;
771#endif
772}
773
774EAPI void
775ecore_x_randr_crtc_size_get(Ecore_X_Window root,
776 Ecore_X_Randr_Crtc crtc,
777 int *w,
778 int *h)
779{
780#ifdef ECORE_XRANDR
781 RANDR_CHECK_1_2_RET();
782 ecore_x_randr_crtc_geometry_get(root, crtc, NULL, NULL, w, h);
783#endif
784}
785
786EAPI Ecore_X_Randr_Refresh_Rate
787ecore_x_randr_crtc_refresh_rate_get(Ecore_X_Window root,
788 Ecore_X_Randr_Crtc crtc,
789 Ecore_X_Randr_Mode mode)
790{
791#ifdef ECORE_XRANDR
792 RANDR_CHECK_1_2_RET(0.0);
793 XRRScreenResources *res = NULL;
794 XRRCrtcInfo *crtc_info = NULL;
795 Ecore_X_Randr_Refresh_Rate ret = 0.0;
796 int i;
797
798 if (_ecore_x_randr_crtc_validate(root,
799 crtc) &&
800 (res = _ecore_x_randr_get_screen_resources (_ecore_x_disp, root)))
801 {
802 for (i = 0; i < res->nmode; i++)
803 if (res->modes[i].id == mode)
804 {
805 if (res->modes[i].hTotal && res->modes[i].vTotal)
806 ret = ((double)res->modes[i].dotClock /
807 ((double)res->modes[i].hTotal *
808 (double)res->modes[i].vTotal));
809
810 break;
811 }
812 }
813
814 if (crtc_info)
815 XRRFreeCrtcInfo(crtc_info);
816
817 if (res)
818 XRRFreeScreenResources(res);
819
820 return ret;
821#else
822 return 0.0;
823#endif
824}
825
826EAPI Ecore_X_Randr_Orientation
827ecore_x_randr_crtc_orientations_get(Ecore_X_Window root,
828 Ecore_X_Randr_Crtc crtc)
829{
830#ifdef ECORE_XRANDR
831 RANDR_CHECK_1_2_RET(Ecore_X_Randr_None);
832 XRRCrtcInfo *crtc_info = NULL;
833 XRRScreenResources *res = NULL;
834 Ecore_X_Randr_Orientation ret = Ecore_X_Randr_None;
835
836 if (_ecore_x_randr_crtc_validate(root,
837 crtc) &&
838 (res =
839 _ecore_x_randr_get_screen_resources (_ecore_x_disp,
840 root)) &&
841 (crtc_info = XRRGetCrtcInfo(_ecore_x_disp, res, crtc)))
842 {
843 ret = crtc_info->rotations;
844 }
845 if (crtc_info)
846 XRRFreeCrtcInfo(crtc_info);
847
848 if (res)
849 XRRFreeScreenResources(res);
850
851 return ret;
852#else
853 return Ecore_X_Randr_None;
854#endif
855}
856
857EAPI Ecore_X_Randr_Orientation
858ecore_x_randr_crtc_orientation_get(Ecore_X_Window root,
859 Ecore_X_Randr_Crtc crtc)
860{
861#ifdef ECORE_XRANDR
862 RANDR_CHECK_1_2_RET(Ecore_X_Randr_None);
863 XRRCrtcInfo *crtc_info = NULL;
864 XRRScreenResources *res = NULL;
865 Ecore_X_Randr_Orientation ret = Ecore_X_Randr_None;
866
867 if (_ecore_x_randr_crtc_validate(root,
868 crtc) &&
869 (res =
870 _ecore_x_randr_get_screen_resources (_ecore_x_disp,
871 root)) &&
872 (crtc_info = XRRGetCrtcInfo(_ecore_x_disp, res, crtc)))
873 {
874 ret = crtc_info->rotation;
875 }
876 if (crtc_info)
877 XRRFreeCrtcInfo(crtc_info);
878
879 if (res)
880 XRRFreeScreenResources(res);
881
882 return ret;
883#else
884 return Ecore_X_Randr_None;
885#endif
886}
887
888EAPI Eina_Bool
889ecore_x_randr_crtc_orientation_set(Ecore_X_Window root,
890 Ecore_X_Randr_Crtc crtc,
891 Ecore_X_Randr_Orientation orientation)
892{
893#ifdef ECORE_XRANDR
894 RANDR_CHECK_1_2_RET(EINA_FALSE);
895 Eina_Bool ret = EINA_FALSE;
896
897 if (orientation != Ecore_X_Randr_None)
898 {
899 ret = ecore_x_randr_crtc_settings_set(root,
900 crtc,
901 NULL,
902 Ecore_X_Randr_Unset,
903 Ecore_X_Randr_Unset,
904 Ecore_X_Randr_Unset,
905 Ecore_X_Randr_Unset,
906 orientation);
907 }
908
909 return ret;
910#else
911 return EINA_FALSE;
912#endif
913}
914
915EAPI void
916ecore_x_randr_crtc_pos_get(Ecore_X_Window root,
917 Ecore_X_Randr_Crtc crtc,
918 int *x,
919 int *y)
920{
921#ifdef ECORE_XRANDR
922 RANDR_CHECK_1_2_RET();
923
924 ecore_x_randr_crtc_geometry_get(root, crtc, x, y, NULL, NULL);
925#endif
926}
927
928EAPI Eina_Bool
929ecore_x_randr_crtc_clone_set(Ecore_X_Window root,
930 Ecore_X_Randr_Crtc original,
931 Ecore_X_Randr_Crtc clon)
932{
933#ifdef ECORE_XRANDR
934 RANDR_CHECK_1_2_RET(EINA_FALSE);
935
936 XRRScreenResources *res = NULL;
937 XRRCrtcInfo *clone_crtc_info = NULL;
938 Ecore_X_Randr_Mode original_mode = Ecore_X_Randr_None;
939 Ecore_X_Randr_Orientation original_orientation = Ecore_X_Randr_None;
940 Eina_Bool ret = EINA_FALSE;
941 int x, y;
942
943 if (_ecore_x_randr_root_validate(root) &&
944 _ecore_x_randr_crtc_validate(root,
945 original) &&
946 _ecore_x_randr_crtc_validate(root,
947 clon) &&
948 (res =
949 _ecore_x_randr_get_screen_resources (_ecore_x_disp,
950 root)) &&
951 (clone_crtc_info = XRRGetCrtcInfo(_ecore_x_disp, res, clon)))
952 {
953 ecore_x_randr_crtc_geometry_get(root, original, &x, &y, NULL, NULL);
954 original_mode = ecore_x_randr_crtc_mode_get(root, original);
955 original_orientation = ecore_x_randr_crtc_orientation_get(root,
956 original);
957 ret = ecore_x_randr_crtc_settings_set(root,
958 clon,
959 NULL,
960 Ecore_X_Randr_Unset,
961 x,
962 y,
963 original_mode,
964 original_orientation);
965 XRRFreeCrtcInfo(clone_crtc_info);
966 XRRFreeScreenResources(res);
967 }
968
969 return ret;
970#else
971 return EINA_FALSE;
972#endif
973}
974
975/**
976 * @brief sets the demanded parameters for a given CRTC. Note that the CRTC is
977 * auto enabled in it's preferred mode, when it was disabled before.
978 * @param root the root window which's default display will be queried
979 * @param crtc the CRTC which's configuration should be altered
980 * @param outputs an array of outputs, that should display this CRTC's content.
981 * @param noutputs number of outputs in the array of outputs.
982 * If set to Ecore_X_Randr_Unset, current outputs and number of outputs will be used.
983 * If set to Ecore_X_Randr_None, CRTC will be disabled
984 * @param x new x coordinate. If <0 (e.g. Ecore_X_Randr_Unset) the current x
985 * corrdinate will be assumed.
986 * @param y new y coordinate. If <0 (e.g. Ecore_X_Randr_Unset) the current y
987 * corrdinate will be assumed.
988 * @param mode the new mode to be set. If Ecore_X_Randr_None is passed, the
989 * CRTC will be disabled. If Ecore_X_Randr_Unset is passed, the current mode is assumed.
990 * @param orientation the new orientation to be set. If Ecore_X_Randr_Unset is used,
991 * the current mode is assumed.
992 * @return EINA_TRUE if the configuration alteration was successful, else
993 * EINA_FALSE
994 */
995EAPI Eina_Bool
996ecore_x_randr_crtc_settings_set(Ecore_X_Window root,
997 Ecore_X_Randr_Crtc crtc,
998 Ecore_X_Randr_Output *outputs,
999 int noutputs,
1000 int x,
1001 int y,
1002 Ecore_X_Randr_Mode mode,
1003 Ecore_X_Randr_Orientation orientation)
1004{
1005#ifdef ECORE_XRANDR
1006 RANDR_CHECK_1_2_RET(EINA_FALSE);
1007 XRRScreenResources *res = NULL;
1008 XRRCrtcInfo *crtc_info = NULL;
1009 Eina_Bool ret = EINA_FALSE;
1010
1011 if (_ecore_x_randr_crtc_validate(root,
1012 crtc) &&
1013 (res = _ecore_x_randr_get_screen_resources(_ecore_x_disp, root)))
1014 {
1015 if ((crtc_info = XRRGetCrtcInfo(_ecore_x_disp, res, crtc)))
1016 {
1017 if ((mode == Ecore_X_Randr_None) ||
1018 (noutputs == Ecore_X_Randr_None))
1019 {
1020 outputs = NULL;
1021 noutputs = 0;
1022 }
1023 else if (noutputs == (int)Ecore_X_Randr_Unset)
1024 {
1025 outputs = (Ecore_X_Randr_Output *)crtc_info->outputs;
1026 noutputs = crtc_info->noutput;
1027 }
1028
1029 if (mode == Ecore_X_Randr_Unset)
1030 mode = crtc_info->mode;
1031
1032 if (x < 0)
1033 x = crtc_info->x;
1034
1035 if (y < 0)
1036 y = crtc_info->y;
1037
1038 if (orientation == Ecore_X_Randr_Unset)
1039 orientation = crtc_info->rotation;
1040
1041 if (!XRRSetCrtcConfig(_ecore_x_disp, res, crtc, CurrentTime,
1042 x, y, mode, orientation, (RROutput *)outputs,
1043 noutputs))
1044 ret = EINA_TRUE;
1045
1046 XRRFreeCrtcInfo(crtc_info);
1047 }
1048
1049 XRRFreeScreenResources(res);
1050 }
1051
1052 return ret;
1053#else
1054 return EINA_FALSE;
1055#endif
1056}
1057
1058/**
1059 * @brief sets a CRTC relative to another one.
1060 * @param crtc_r1 the CRTC to be positioned.
1061 * @param crtc_r2 the CRTC the position should be relative to
1062 * @param position the relation between the crtcs
1063 * @param alignment in case CRTCs size differ, aligns CRTC1 accordingly at CRTC2's
1064 * borders
1065 * @return EINA_TRUE if crtc could be successfully positioned. EINA_FALSE if
1066 * repositioning failed or if position of new crtc would be out of given screen's min/max bounds.
1067 */
1068EAPI Eina_Bool
1069ecore_x_randr_crtc_pos_relative_set(Ecore_X_Window root,
1070 Ecore_X_Randr_Crtc crtc_r1,
1071 Ecore_X_Randr_Crtc crtc_r2,
1072 Ecore_X_Randr_Output_Policy policy,
1073 Ecore_X_Randr_Relative_Alignment alignment)
1074{
1075#ifdef ECORE_XRANDR
1076 RANDR_CHECK_1_2_RET(EINA_FALSE);
1077
1078 Eina_Rectangle r1_geo, r2_geo;
1079 int w_max, h_max, cw, ch, x_n = Ecore_X_Randr_Unset, y_n =
1080 Ecore_X_Randr_Unset;
1081 /*
1082 int r1_noutputs, r2_noutputs, r1_nmodes, i, j, outputs_mode_found, mode_w, mode_h;
1083 Ecore_X_Randr_Output *r1_outputs, *r2_outputs, *r2_r1_outputs;
1084 Ecore_X_Randr_Mode *r1_modes, r2_mode, r1_mode;
1085 Eina_Bool ret;
1086 */
1087
1088 if ((ecore_x_randr_crtc_mode_get(root, crtc_r1) == Ecore_X_Randr_None)
1089 || (ecore_x_randr_crtc_mode_get(root, crtc_r2) == Ecore_X_Randr_None))
1090 return EINA_FALSE;
1091
1092 if (!_ecore_x_randr_crtc_validate(root, crtc_r1) ||
1093 (!(crtc_r1 != crtc_r2) &&
1094 !_ecore_x_randr_crtc_validate(root, crtc_r2)))
1095 return EINA_FALSE;
1096
1097 ecore_x_randr_crtc_geometry_get(root,
1098 crtc_r1,
1099 &r1_geo.x,
1100 &r1_geo.y,
1101 &r1_geo.w,
1102 &r1_geo.h);
1103 ecore_x_randr_crtc_geometry_get(root,
1104 crtc_r2,
1105 &r2_geo.x,
1106 &r2_geo.y,
1107 &r2_geo.w,
1108 &r2_geo.h);
1109 ecore_x_randr_screen_size_range_get(root, NULL, NULL, &w_max, &h_max);
1110 ecore_x_randr_screen_current_size_get(root, &cw, &ch, NULL, NULL);
1111
1112 switch (policy)
1113 {
1114 case ECORE_X_RANDR_OUTPUT_POLICY_RIGHT:
1115 //set r1 right of r2
1116 x_n = r2_geo.x + r2_geo.w;
1117
1118 switch (alignment)
1119 {
1120 case ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE:
1121 y_n = Ecore_X_Randr_Unset;
1122 break;
1123
1124 case ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL:
1125 y_n =
1126 ((int)(((double)r2_geo.h /
1127 2.0) + (double)r2_geo.y - ((double)r1_geo.h / 2.0)));
1128 break;
1129
1130 case ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR:
1131 y_n = ((int)((double)ch / 2.0) - ((double)r1_geo.h / 2.0));
1132 break;
1133 }
1134 break;
1135
1136 case ECORE_X_RANDR_OUTPUT_POLICY_LEFT:
1137 //set r1 left of r2
1138 x_n = r2_geo.x - r1_geo.w;
1139
1140 switch (alignment)
1141 {
1142 case ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE:
1143 y_n = Ecore_X_Randr_Unset;
1144 break;
1145
1146 case ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL:
1147 y_n =
1148 ((int)(((double)r2_geo.h /
1149 2.0) + r2_geo.y - ((double)r1_geo.h / 2.0)));
1150 break;
1151
1152 case ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR:
1153 y_n = ((int)(((double)ch / 2.0) - ((double)r1_geo.h / 2.0)));
1154 break;
1155 }
1156 break;
1157
1158 case ECORE_X_RANDR_OUTPUT_POLICY_BELOW:
1159 //set r1 below r2
1160 y_n = r2_geo.y + r2_geo.h;
1161
1162 switch (alignment)
1163 {
1164 case ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE:
1165 x_n = Ecore_X_Randr_Unset;
1166 break;
1167
1168 case ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL:
1169 x_n =
1170 ((int)((((double)r2_geo.x +
1171 (double)r2_geo.w) / 2.0) - ((double)r1_geo.w / 2.0)));
1172 break;
1173
1174 case ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR:
1175 x_n = ((int)((double)cw / 2.0));
1176 break;
1177 }
1178 break;
1179
1180 case ECORE_X_RANDR_OUTPUT_POLICY_ABOVE:
1181 y_n = r2_geo.y - r1_geo.h;
1182
1183 //set r1 above r2
1184 switch (alignment)
1185 {
1186 case ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE:
1187 x_n = Ecore_X_Randr_Unset;
1188 break;
1189
1190 case ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL:
1191 x_n =
1192 ((int)((((double)r2_geo.x +
1193 (double)r2_geo.w) / 2.0) - ((double)r1_geo.w / 2.0)));
1194 break;
1195
1196 case ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR:
1197 x_n = ((int)((double)cw / 2.0));
1198 break;
1199 }
1200 break;
1201
1202 case ECORE_X_RANDR_OUTPUT_POLICY_CLONE:
1203 return ecore_x_randr_crtc_pos_set(root, crtc_r1, r2_geo.x, r2_geo.y);
1204
1205 /* entire cloning (including modesetting)
1206 //all outputs of crtc1 capable of crtc2's current mode?
1207 r2_mode = ecore_x_randr_crtc_mode_get(root, crtc_r2);
1208 if (!(r1_outputs =
1209 ecore_x_randr_crtc_outputs_get(root, crtc_r1,
1210 &r1_noutputs)) ||
1211 (r1_noutputs == 0))
1212 return EINA_FALSE;
1213
1214 for (i = 0, outputs_mode_found = 0; i < r1_noutputs; i++)
1215 {
1216 if (!(r1_modes =
1217 ecore_x_randr_output_modes_get(root, r1_outputs[i],
1218 &r1_nmodes, NULL)))
1219 {
1220 free(r1_outputs);
1221 return EINA_FALSE;
1222 }
1223
1224 for (j = 0; j < r1_nmodes; j++)
1225 {
1226 ecore_x_randr_mode_size_get(root,
1227 r1_modes[j],
1228 &mode_w,
1229 &mode_h);
1230 if ((mode_w == r2_geo.w) && (mode_h == r2_geo.h))
1231 {
1232 r1_mode = r1_modes[j];
1233 ++outputs_mode_found;
1234 free(r1_modes);
1235 r1_modes = NULL;
1236 break;
1237 }
1238 }
1239 if (r1_modes)
1240 free(r1_modes);
1241
1242 if (outputs_mode_found <= i)
1243 {
1244 //an output doesn't support the set mode, cancel!
1245 free(r1_outputs);
1246 return EINA_FALSE;
1247 }
1248 }
1249 free (r1_outputs);
1250 //CRTC 1's outputs support a mode of same geometry as CRTC 2.
1251 ret =
1252 (ecore_x_randr_crtc_mode_set(root, crtc_r1, Ecore_X_Randr_None,
1253 Ecore_X_Randr_None,
1254 r1_mode) &&
1255 ecore_x_randr_crtc_pos_set(root, crtc_r1, r2_geo.x, r2_geo.y));
1256 return ret;
1257 */
1258
1259 /* entire cloning on same CRTC
1260 //all outputs of crtc1 capable of crtc2's current mode?
1261 r2_mode = ecore_x_randr_crtc_mode_get(root, crtc_r2);
1262 if (!(r1_outputs =
1263 ecore_x_randr_crtc_outputs_get(root, crtc_r1,
1264 &r1_noutputs)) ||
1265 (r1_noutputs == 0))
1266 return EINA_FALSE;
1267
1268 for (i = 0, outputs_mode_found = 0; i < r1_noutputs; i++)
1269 {
1270 if (!(r1_modes =
1271 ecore_x_randr_output_modes_get(root, r1_outputs[i],
1272 &r1_nmodes, NULL)))
1273 {
1274 free(r1_outputs);
1275 return EINA_FALSE;
1276 }
1277
1278 for (j = 0; j < r1_nmodes; j++)
1279 {
1280 if (r1_modes[j] == r2_mode)
1281 {
1282 ++outputs_mode_found;
1283 free(r1_modes);
1284 r1_modes = NULL;
1285 break;
1286 }
1287 }
1288 if (r1_modes)
1289 free(r1_modes);
1290
1291 if (outputs_mode_found <= i)
1292 {
1293 //an output doesn't support the set mode, cancel!
1294 free(r1_outputs);
1295 return EINA_FALSE;
1296 }
1297 }
1298 //check whether crtc r2 can use all outputs of r1.
1299 if (!(r2_outputs =
1300 ecore_x_randr_crtc_possible_outputs_get(root, crtc_r2,
1301 &r2_noutputs)) ||
1302 (r2_noutputs == 0))
1303 {
1304 free(r1_outputs);
1305 return EINA_FALSE;
1306 }
1307
1308 for (i = 0; i < r1_noutputs; i++)
1309 {
1310 for (j = 0; j < r2_noutputs; )
1311 {
1312 if (r1_outputs[i] == r2_outputs[j])
1313 break;
1314
1315 j++;
1316 }
1317 if (j == r2_noutputs)
1318 {
1319 //didn't find the output!
1320 free (r1_outputs);
1321 free (r2_outputs);
1322 return EINA_FALSE;
1323 }
1324 }
1325
1326 //apparently crtc2 supports all outputs of r1
1327 //TODO: check with the compatible list of outputs (property in RR1.3)
1328 r2_r1_outputs =
1329 malloc(sizeof(Ecore_X_Randr_Output) * (r1_noutputs + r2_noutputs));
1330 for (i = 0; i < r1_noutputs; i++)
1331 {
1332 r2_r1_outputs[i] = r1_outputs[i];
1333 }
1334 free(r1_outputs);
1335 for (; i < r2_noutputs; i++)
1336 {
1337 r2_r1_outputs[i] = r2_outputs[i];
1338 }
1339 free(r2_outputs);
1340 ret =
1341 ecore_x_randr_crtc_mode_set(root, crtc_r2, r2_r1_outputs,
1342 (r1_noutputs + r1_noutputs), r2_mode);
1343 free (r2_r1_outputs);
1344 return ret;
1345 */
1346 case ECORE_X_RANDR_OUTPUT_POLICY_NONE:
1347 break;
1348 }
1349 if ((x_n == r1_geo.x) && (y_n == r1_geo.x))
1350 return EINA_TRUE;
1351
1352 //out of possible bounds?
1353 if (((y_n + r1_geo.h) > h_max) || ((x_n + r1_geo.w) > w_max))
1354 return EINA_FALSE;
1355
1356 return ecore_x_randr_crtc_pos_set(root, crtc_r1, x_n, y_n);
1357#else
1358 return EINA_FALSE;
1359#endif
1360}
1361
1362EAPI Ecore_X_Randr_Mode *
1363ecore_x_randr_output_modes_get(Ecore_X_Window root,
1364 Ecore_X_Randr_Output output,
1365 int *num,
1366 int *npreferred)
1367{
1368#ifdef ECORE_XRANDR
1369 RANDR_CHECK_1_2_RET(NULL);
1370 XRRScreenResources *res = NULL;
1371 XRROutputInfo *output_info = NULL;
1372 Ecore_X_Randr_Mode *modes = NULL;
1373
1374 if ((output != Ecore_X_Randr_None)
1375 && (res = _ecore_x_randr_get_screen_resources(_ecore_x_disp, root))
1376 && (output_info =
1377 XRRGetOutputInfo(_ecore_x_disp, res, (RROutput)output)))
1378 {
1379 if ((modes = malloc(sizeof(Ecore_X_Randr_Mode) * output_info->nmode)))
1380 {
1381 memcpy(modes, output_info->modes,
1382 (sizeof(Ecore_X_Randr_Mode) * output_info->nmode));
1383 if (num)
1384 *num = output_info->nmode;
1385
1386 if (npreferred)
1387 *npreferred = output_info->npreferred;
1388 }
1389 }
1390
1391 if (output_info)
1392 XRRFreeOutputInfo(output_info);
1393
1394 if (res)
1395 XRRFreeScreenResources(res);
1396
1397 return modes;
1398#else
1399 return NULL;
1400#endif
1401}
1402
1403EAPI Ecore_X_Randr_Crtc *
1404ecore_x_randr_output_possible_crtcs_get(Ecore_X_Window root,
1405 Ecore_X_Randr_Output output,
1406 int *num)
1407{
1408#ifdef ECORE_XRANDR
1409 RANDR_CHECK_1_2_RET(NULL);
1410 XRRScreenResources *res = NULL;
1411 XRROutputInfo *output_info = NULL;
1412 Ecore_X_Randr_Crtc *crtcs = NULL;
1413
1414 if ((output != Ecore_X_Randr_None))
1415 {
1416 if ((res = _ecore_x_randr_get_screen_resources(_ecore_x_disp, root)))
1417 {
1418 if ((output_info = XRRGetOutputInfo(_ecore_x_disp, res, output)))
1419 {
1420 if ((crtcs = malloc(sizeof(Ecore_X_Randr_Crtc) * output_info->ncrtc)))
1421 {
1422 memcpy(crtcs, output_info->crtcs, (sizeof(Ecore_X_Randr_Crtc) * output_info->ncrtc));
1423 if (num) *num = output_info->ncrtc;
1424 }
1425 XRRFreeOutputInfo(output_info);
1426 }
1427 XRRFreeScreenResources(res);
1428 }
1429 }
1430 return crtcs;
1431#else
1432 return Ecore_X_Randr_None;
1433#endif
1434}
1435
1436/**
1437 * @brief gets the the outputs which might be used simultenously on the same
1438 * CRTC.
1439 * @param root window that this information should be queried for.
1440 * @param output the output which's clones we concern
1441 * @param num number of possible clones
1442 */
1443EAPI Ecore_X_Randr_Output *
1444ecore_x_randr_output_clones_get(Ecore_X_Window root,
1445 Ecore_X_Randr_Output output,
1446 int *num)
1447{
1448#ifdef ECORE_XRANDR
1449 RANDR_CHECK_1_2_RET(NULL);
1450 XRRScreenResources *res = NULL;
1451 XRROutputInfo *output_info = NULL;
1452 Ecore_X_Randr_Output *outputs = NULL;
1453
1454 if ((output != Ecore_X_Randr_None))
1455 {
1456 if ((res = _ecore_x_randr_get_screen_resources(_ecore_x_disp, root)))
1457 {
1458 if ((output_info = XRRGetOutputInfo(_ecore_x_disp, res, output)))
1459 {
1460 if ((outputs = malloc(sizeof(Ecore_X_Randr_Output) * output_info->nclone)))
1461 {
1462 memcpy(outputs, output_info->clones, (sizeof(Ecore_X_Randr_Output) * output_info->nclone));
1463 if (num) *num = output_info->nclone;
1464 }
1465 XRRFreeOutputInfo(output_info);
1466 }
1467 XRRFreeScreenResources(res);
1468 }
1469 }
1470 return outputs;
1471#else
1472 return Ecore_X_Randr_None;
1473#endif
1474}
1475
1476EAPI Ecore_X_Randr_Crtc
1477ecore_x_randr_output_crtc_get(Ecore_X_Window root,
1478 Ecore_X_Randr_Output output)
1479{
1480#ifdef ECORE_XRANDR
1481 RANDR_CHECK_1_2_RET(Ecore_X_Randr_None);
1482 XRRScreenResources *res = NULL;
1483 XRROutputInfo *output_info = NULL;
1484 Ecore_X_Randr_Crtc ret = Ecore_X_Randr_None;
1485
1486 if ((output != Ecore_X_Randr_None))
1487 {
1488 if ((res = _ecore_x_randr_get_screen_resources(_ecore_x_disp, root)))
1489 {
1490 if ((output_info = XRRGetOutputInfo(_ecore_x_disp, res, output)))
1491 {
1492 ret = output_info->crtc;
1493 XRRFreeOutputInfo(output_info);
1494 }
1495 XRRFreeScreenResources(res);
1496 }
1497 }
1498
1499 return ret;
1500#else
1501 return Ecore_X_Randr_None;
1502#endif
1503}
1504
1505/**
1506 * @brief gets the given output's name as reported by X
1507 * @param root the window which's screen will be queried
1508 * @param len length of returned c-string.
1509 * @return name of the output as reported by X
1510 */
1511EAPI char *
1512ecore_x_randr_output_name_get(Ecore_X_Window root,
1513 Ecore_X_Randr_Output output,
1514 int *len)
1515{
1516#ifdef ECORE_XRANDR
1517 RANDR_CHECK_1_2_RET(NULL);
1518 XRRScreenResources *res = NULL;
1519 XRROutputInfo *output_info = NULL;
1520 char *ret = NULL;
1521
1522 if ((output != Ecore_X_Randr_None)
1523 && (res = _ecore_x_randr_get_screen_resources(_ecore_x_disp, root))
1524 && (output_info = XRRGetOutputInfo(_ecore_x_disp, res, output)))
1525 {
1526 /*
1527 * Actually the below command is correct, but due to a bug in libXrandr
1528 * it doesn't work. Therefore we stick with strlen().
1529 * Replace the line below with the following once this bug is
1530 * fixed within libXrandr.
1531 *
1532 * *len = output_info->nameLen;
1533 *
1534 */
1535 if ((ret = strdup(output_info->name)) && len)
1536 *len = strlen(ret);
1537
1538 XRRFreeOutputInfo(output_info);
1539 }
1540
1541 if (res)
1542 XRRFreeScreenResources(res);
1543
1544 return ret;
1545#else
1546 return NULL;
1547#endif
1548}
1549
1550/**
1551 * @brief gets the width and hight of a given mode
1552 * @param mode the mode which's size is to be looked up
1553 * @param w width of given mode in px
1554 * @param h height of given mode in px
1555 */
1556EAPI void
1557ecore_x_randr_mode_size_get(Ecore_X_Window root,
1558 Ecore_X_Randr_Mode mode,
1559 int *w,
1560 int *h)
1561{
1562#ifdef ECORE_XRANDR
1563 RANDR_CHECK_1_2_RET();
1564 XRRScreenResources *res = NULL;
1565 int i;
1566
1567 if ((mode != Ecore_X_Randr_None)
1568 && (w || h)
1569 && (res = _ecore_x_randr_get_screen_resources(_ecore_x_disp, root)))
1570 {
1571 for (i = 0; i < res->nmode; i++)
1572 {
1573 if (res->modes[i].id == mode)
1574 {
1575 if (w)
1576 *w = res->modes[i].width;
1577
1578 if (h)
1579 *h = res->modes[i].height;
1580
1581 break;
1582 }
1583 }
1584 }
1585
1586 if (res)
1587 XRRFreeScreenResources(res);
1588
1589#endif
1590}
1591
1592/**
1593 * @brief gets the EDID information of an attached output if available.
1594 * Note that this information is not to be compared using ordinary string
1595 * comparison functions, since it includes 0-bytes.
1596 * @param root window this information should be queried from
1597 * @param output the XID of the output
1598 * @param length length of the byte-array. If NULL, request will fail.
1599 */
1600EAPI unsigned char *
1601ecore_x_randr_output_edid_get(Ecore_X_Window root,
1602 Ecore_X_Randr_Output output,
1603 unsigned long *length)
1604{
1605#ifdef ECORE_XRANDR
1606 RANDR_CHECK_1_2_RET(NULL);
1607 Atom name = XInternAtom (_ecore_x_disp, RANDR_PROPERTY_EDID, False);
1608 unsigned char *prop_data, *ret = NULL;
1609 int actual_format;
1610 unsigned long nitems, bytes_after;
1611 Atom actual_type;
1612
1613 if (!length || !_ecore_x_randr_output_validate(root, output))
1614 return NULL;
1615
1616 if(XRRGetOutputProperty (_ecore_x_disp, output, name,
1617 0, 100, False, False,
1618 AnyPropertyType,
1619 &actual_type, &actual_format,
1620 &nitems, &bytes_after, &prop_data) == Success)
1621 {
1622 if (actual_type == XA_INTEGER && actual_format == 8)
1623 {
1624 if ((ret = malloc(nitems * sizeof(unsigned char))))
1625 {
1626 if(length &&
1627 (memcpy(ret, prop_data, (nitems * sizeof(unsigned char)))))
1628 *length = nitems;
1629
1630 return ret;
1631 }
1632 }
1633 }
1634
1635 return NULL;
1636#else
1637 return NULL;
1638#endif
1639}
1640
1641EAPI Ecore_X_Randr_Connection_Status
1642ecore_x_randr_output_connection_status_get(Ecore_X_Window root,
1643 Ecore_X_Randr_Output output)
1644{
1645#ifdef ECORE_XRANDR
1646 RANDR_CHECK_1_2_RET(ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN);
1647 XRRScreenResources *res = NULL;
1648 XRROutputInfo *output_info = NULL;
1649 Ecore_X_Randr_Connection_Status ret =
1650 ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN;
1651
1652 if ((output != Ecore_X_Randr_None)
1653 && (res = _ecore_x_randr_get_screen_resources(_ecore_x_disp, root))
1654 && (output_info = XRRGetOutputInfo(_ecore_x_disp, res, output)))
1655 {
1656 ret = output_info->connection;
1657 }
1658
1659 if (output_info)
1660 XRRFreeOutputInfo(output_info);
1661
1662 if (res)
1663 XRRFreeScreenResources(res);
1664
1665 return ret;
1666#else
1667 return ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN;
1668#endif
1669}
1670
1671EAPI void
1672ecore_x_randr_output_size_mm_get(Ecore_X_Window root,
1673 Ecore_X_Randr_Output output,
1674 int *w_mm,
1675 int *h_mm)
1676{
1677#ifdef ECORE_XRANDR
1678 RANDR_CHECK_1_2_RET();
1679 XRRScreenResources *res = NULL;
1680 XRROutputInfo *output_info = NULL;
1681
1682 if ((output != Ecore_X_Randr_None)
1683 && (res = _ecore_x_randr_get_screen_resources(_ecore_x_disp, root)))
1684 {
1685 if ((output_info =
1686 XRRGetOutputInfo(_ecore_x_disp, res, (RROutput)output)))
1687 {
1688 if (w_mm)
1689 *w_mm = output_info->mm_width;
1690
1691 if (h_mm)
1692 *h_mm = output_info->mm_height;
1693
1694 XRRFreeOutputInfo(output_info);
1695 }
1696
1697 XRRFreeScreenResources(res);
1698 }
1699
1700#endif
1701}
1702
1703EAPI Eina_Bool
1704ecore_x_randr_move_all_crtcs_but(Ecore_X_Window root,
1705 const Ecore_X_Randr_Crtc *not_moved,
1706 int nnot_moved,
1707 int dx,
1708 int dy)
1709{
1710#ifdef ECORE_XRANDR
1711 Ecore_X_Randr_Crtc *crtcs_to_be_moved = NULL;
1712 XRRScreenResources *res = NULL;
1713 int i, j, k, n;
1714 Eina_Bool ret;
1715
1716 if ((nnot_moved <= 0) || (!not_moved)
1717 || !_ecore_x_randr_root_validate(root)
1718 || !(res =
1719 _ecore_x_randr_get_screen_resources (_ecore_x_disp, root)))
1720 return EINA_FALSE;
1721
1722 n = (res->ncrtc - nnot_moved);
1723 if ((crtcs_to_be_moved = malloc(sizeof(Ecore_X_Randr_Crtc) * n)))
1724 {
1725 for (i = 0, k = 0; (i < res->ncrtc) && (k < n); i++)
1726 {
1727 for (j = 0; j < nnot_moved; j++)
1728 {
1729 if (res->crtcs[i] == not_moved[j])
1730 break;
1731 }
1732 if (j == nnot_moved)
1733 //crtcs[i] is not in the 'not to move'-list
1734 crtcs_to_be_moved[k++] = res->crtcs[i];
1735 }
1736 }
1737
1738 XRRFreeScreenResources(res);
1739 ret = ecore_x_randr_move_crtcs(root, crtcs_to_be_moved, n, dx, dy);
1740 free(crtcs_to_be_moved);
1741 return ret;
1742#else
1743 return EINA_FALSE;
1744#endif
1745}
1746
1747/*
1748 * @brief move given CRTCs belonging to the given root window's screen dx/dy pixels relative to their current position. The screen size will be automatically adjusted if necessary and possible.
1749 * @param root window which's screen's resources are used
1750 * @param crtcs list of CRTCs to be moved
1751 * @param ncrtc number of CRTCs in array
1752 * @param dx amount of pixels the CRTCs should be moved in x direction
1753 * @param dy amount of pixels the CRTCs should be moved in y direction
1754 * @return EINA_TRUE if all crtcs could be moved successfully.
1755 */
1756EAPI Eina_Bool
1757ecore_x_randr_move_crtcs(Ecore_X_Window root,
1758 const Ecore_X_Randr_Crtc *crtcs,
1759 int ncrtc,
1760 int dx,
1761 int dy)
1762{
1763#ifdef ECORE_XRANDR
1764 RANDR_CHECK_1_2_RET(EINA_FALSE);
1765 XRRScreenResources *res = NULL;
1766 XRRCrtcInfo **crtc_info = NULL;
1767 Eina_Bool ret = EINA_TRUE;
1768 int i, cw, ch, w_max, h_max, nw, nh;
1769
1770 crtc_info = alloca(sizeof(XRRCrtcInfo *) * ncrtc);
1771 memset(crtc_info, 0, sizeof(XRRCrtcInfo *) * ncrtc);
1772 if (_ecore_x_randr_root_validate(root)
1773 && (res = _ecore_x_randr_get_screen_resources (_ecore_x_disp, root)))
1774 {
1775 ecore_x_randr_screen_size_range_get(root, NULL, NULL, &w_max, &h_max);
1776 ecore_x_randr_screen_current_size_get(root, &cw, &ch, NULL, NULL);
1777 nw = cw;
1778 nh = ch;
1779
1780 for (i = 0;
1781 (i < ncrtc) &&
1782 (crtc_info[i] = XRRGetCrtcInfo(_ecore_x_disp, res, crtcs[i]));
1783 i++)
1784 {
1785 if (((crtc_info[i]->x + dx) < 0) ||
1786 ((int)(crtc_info[i]->x + crtc_info[i]->width + dx) > w_max)
1787 || ((crtc_info[i]->y + dy) < 0) ||
1788 ((int)(crtc_info[i]->y + crtc_info[i]->height + dy) > h_max)
1789 )
1790 goto _ecore_x_randr_move_crtcs_fail_free_crtc_info;
1791
1792 nw = MAX((int)(crtc_info[i]->x + crtc_info[i]->width + dx), nw);
1793 nh = MAX((int)(crtc_info[i]->y + crtc_info[i]->height + dy), nh);
1794 }
1795 //not out of bounds
1796
1797 //resize if necessary
1798 if (!(((nw > cw) ||
1799 (nh > ch)) ||
1800 ecore_x_randr_screen_current_size_set(root, nw, nh,
1801 Ecore_X_Randr_Unset,
1802 Ecore_X_Randr_Unset)))
1803 goto _ecore_x_randr_move_crtcs_fail_free_crtc_info;
1804
1805 //actually move all the crtcs, keep their rotation and mode.
1806 for (i = 0; (i < ncrtc) && crtc_info[i]; i++)
1807 {
1808 if ((crtc_info[i]) &&
1809 (!ecore_x_randr_crtc_settings_set(root, crtcs[i], NULL,
1810 Ecore_X_Randr_Unset,
1811 (crtc_info[i]->x + dx),
1812 (crtc_info[i]->y + dy),
1813 crtc_info[i]->mode,
1814 crtc_info[i]->rotation)))
1815 {
1816 ret = EINA_FALSE;
1817 break;
1818 }
1819 }
1820 if (i < ncrtc)
1821 {
1822 //something went wrong, let's try to move the already moved crtcs
1823 //back.
1824 while ((i--) >= 0)
1825 {
1826 if (crtc_info[i])
1827 ecore_x_randr_crtc_settings_set(root,
1828 crtcs[i],
1829 NULL,
1830 Ecore_X_Randr_Unset,
1831 (crtc_info[i]->x - dx),
1832 (crtc_info[i]->y - dy),
1833 crtc_info[i]->mode,
1834 crtc_info[i]->rotation);
1835 }
1836 }
1837
1838 for (i = 0; i < ncrtc; i++)
1839 {
1840 if (crtc_info[i]) XRRFreeCrtcInfo(crtc_info[i]);
1841 }
1842 }
1843
1844 XRRFreeScreenResources(res);
1845
1846 return ret;
1847_ecore_x_randr_move_crtcs_fail_free_crtc_info:
1848 while (i-- > 0)
1849 XRRFreeCrtcInfo(crtc_info[i]);
1850 XRRFreeScreenResources(res);
1851 return EINA_FALSE;
1852#else
1853 return EINA_FALSE;
1854#endif
1855}
1856
1857/**
1858 * @brief removes unused screen space. The most upper left CRTC is set to 0x0
1859 * and all other CRTCs dx,dy respectively.
1860 * @param root the window's screen which will be reset.
1861 */
1862EAPI void
1863ecore_x_randr_screen_reset(Ecore_X_Window root)
1864{
1865#ifdef ECORE_XRANDR
1866 XRRCrtcInfo *crtc_info = NULL;
1867 XRRScreenResources *res = NULL;
1868 //the 100000 are just a random huge number.
1869 int i, dx_min = 100000, dy_min = 100000, w_n = 0, h_n = 0, nenabled_crtcs = 0;
1870
1871 if (!_ecore_x_randr_root_validate(root) ||
1872 !(res = _ecore_x_randr_get_screen_resources(_ecore_x_disp, root)))
1873 return;
1874
1875 Ecore_X_Randr_Crtc enabled_crtcs[res->ncrtc];
1876
1877 for (i = 0; i < res->ncrtc; i++)
1878 {
1879 if (!(crtc_info =
1880 XRRGetCrtcInfo(_ecore_x_disp, res,
1881 res->crtcs[i])) ||
1882 (crtc_info->mode == Ecore_X_Randr_None) ||
1883 (crtc_info->mode == Ecore_X_Randr_Unset)
1884 || ((crtc_info->noutput == 0)))
1885 continue;
1886
1887 enabled_crtcs[nenabled_crtcs++] = res->crtcs[i];
1888
1889 if ((int)(crtc_info->x + crtc_info->width) > w_n)
1890 w_n = (crtc_info->x + crtc_info->width);
1891
1892 if ((int)(crtc_info->y + crtc_info->height) > h_n)
1893 h_n = (crtc_info->y + crtc_info->height);
1894
1895 if (crtc_info->x < dx_min)
1896 dx_min = crtc_info->x;
1897 if (crtc_info->y < dy_min)
1898 dy_min = crtc_info->y;
1899
1900 XRRFreeCrtcInfo(crtc_info);
1901 }
1902 if ((dx_min > 0) || (dy_min > 0))
1903 {
1904 if (ecore_x_randr_move_crtcs(root, enabled_crtcs, nenabled_crtcs, -dx_min, -dy_min))
1905 {
1906 w_n -= dx_min;
1907 h_n -= dy_min;
1908 }
1909 }
1910 ecore_x_randr_screen_current_size_set(root,
1911 w_n,
1912 h_n,
1913 Ecore_X_Randr_Unset,
1914 Ecore_X_Randr_Unset);
1915#endif
1916}
1917
1918/**
1919 * @brief set up the backlight level to the given level.
1920 * @param root the window's screen which will be set.
1921 * @param level of the backlight between 0 and 1
1922 */
1923
1924EAPI void
1925ecore_x_randr_screen_backlight_level_set(Ecore_X_Window root,
1926 double level)
1927{
1928#ifdef ECORE_XRANDR
1929 RANDR_CHECK_1_2_RET();
1930 Atom _backlight;
1931 XRRScreenResources *resources = NULL;
1932 Ecore_X_Randr_Output output;
1933 int o;
1934
1935 if ((level < 0) || (level > 1))
1936 {
1937 ERR("Wrong value for the backlight level. It should be between 0 and 1.");
1938 return;
1939 }
1940
1941 /*
1942 * To make sure that the _backlight atomic property still exists.
1943 */
1944 _backlight = XInternAtom(_ecore_x_disp, RANDR_PROPERTY_BACKLIGHT, True);
1945 if (_backlight == None)
1946 {
1947 WRN("Backlight setting is not supported on this server or driver");
1948 return;
1949 }
1950
1951 /* get the ressources */
1952 resources = _ecore_x_randr_get_screen_resources(_ecore_x_disp, root);
1953 if (!resources) return;
1954
1955 for (o = 0; o < resources->noutput; o++)
1956 {
1957 output = resources->outputs[o];
1958 if (ecore_x_randr_output_backlight_level_get(root, output) >= 0)
1959 {
1960 ecore_x_randr_output_backlight_level_set(root, output, level);
1961 }
1962 }
1963 XRRFreeScreenResources(resources);
1964#endif
1965}
1966
1967/*
1968 * @brief get the backlight level of the given output
1969 * @param root window which's screen should be queried
1970 * @param output from which the backlight level should be retrieved
1971 * @return the backlight level
1972 */
1973
1974EAPI double
1975ecore_x_randr_output_backlight_level_get(Ecore_X_Window root,
1976 Ecore_X_Randr_Output output)
1977{
1978#ifdef ECORE_XRANDR
1979 RANDR_CHECK_1_2_RET(-1);
1980 Atom actual_type;
1981 Atom _backlight;
1982 XRRPropertyInfo *info = NULL;
1983 double dvalue;
1984 int actual_format;
1985 long value, max, min;
1986 unsigned long nitems;
1987 unsigned long bytes_after;
1988 unsigned char *prop = NULL;
1989
1990 /* set backlight variable if not already done */
1991
1992 _backlight = XInternAtom(_ecore_x_disp, RANDR_PROPERTY_BACKLIGHT, True);
1993 if (_backlight == None)
1994 {
1995 ERR("Backlight property is not suppported on this server or driver");
1996 return -1;
1997 }
1998
1999 if (!_ecore_x_randr_output_validate(root, output))
2000 {
2001 ERR("Invalid output");
2002 return -1;
2003 }
2004
2005 if (XRRGetOutputProperty(_ecore_x_disp, output, _backlight,
2006 0, 4, False, False, None,
2007 &actual_type, &actual_format,
2008 &nitems, &bytes_after, &prop) != Success)
2009 {
2010 WRN("Backlight not supported on this output");
2011 return -1;
2012 }
2013
2014 if ((actual_type != XA_INTEGER) || (nitems != 1) || (actual_format != 32)) return -1;
2015
2016 value = *((long *)prop);
2017 free (prop);
2018
2019 /* I have the current value of the backlight */
2020 /* Now retrieve the min and max intensities of the output */
2021 info = XRRQueryOutputProperty(_ecore_x_disp, output, _backlight);
2022 if (info)
2023 {
2024 dvalue = -1;
2025 if ((info->range) && (info->num_values == 2))
2026 {
2027 /* finally convert the current value in the interval [0..1] */
2028 min = info->values[0];
2029 max = info->values[1];
2030 dvalue = ((double)(value - min)) / ((double)(max - min));
2031 }
2032 free(info);
2033 return dvalue;
2034 }
2035#endif
2036 return -1;
2037}
2038
2039/*
2040 * @brief set the backlight level of a given output
2041 * @param root window which's screen should be queried
2042 * @param output that should be set
2043 * @param level for which the backlight should be set
2044 * @return EINA_TRUE in case of success
2045 */
2046
2047EAPI Eina_Bool
2048ecore_x_randr_output_backlight_level_set(Ecore_X_Window root,
2049 Ecore_X_Randr_Output output,
2050 double level)
2051{
2052#ifdef ECORE_XRANDR
2053 RANDR_CHECK_1_2_RET(EINA_FALSE);
2054 Atom _backlight;
2055 XRRPropertyInfo *info = NULL;
2056 double min, max, tmp;
2057 long new;
2058
2059 if ((level < 0) || (level > 1))
2060 {
2061 ERR("Backlight level should be between 0 and 1");
2062 return EINA_FALSE;
2063 }
2064
2065 if (!_ecore_x_randr_output_validate(root, output))
2066 {
2067 ERR("Wrong output value");
2068 return EINA_FALSE;
2069 }
2070
2071 _backlight = XInternAtom(_ecore_x_disp, RANDR_PROPERTY_BACKLIGHT, True);
2072 if (_backlight == None)
2073 {
2074 WRN("Backlight property is not suppported on this server or driver");
2075 return EINA_FALSE;
2076 }
2077
2078 info = XRRQueryOutputProperty(_ecore_x_disp, output, _backlight);
2079 if (info)
2080 {
2081 if ((info->range) && (info->num_values == 2))
2082 {
2083 min = info->values[0];
2084 max = info->values[1];
2085 tmp = (level * (max - min)) + min;
2086 new = tmp;
2087 if (new > max) new = max;
2088 if (new < min) new = min;
2089 XRRChangeOutputProperty(_ecore_x_disp, output, _backlight, XA_INTEGER, 32,
2090 PropModeReplace, (unsigned char *)&new, 1);
2091 XFlush(_ecore_x_disp);
2092 }
2093 free(info);
2094 return EINA_TRUE;
2095 }
2096#endif
2097 return EINA_FALSE;
2098}
2099
2100/*
2101 * @brief get the outputs, which display a certain window
2102 * @param window window the displaying outputs shall be found for
2103 * @param num the number of outputs displaying the window
2104 * @return array of outputs that display a certain window. NULL if no outputs
2105 * was found that displays the specified window.
2106 */
2107
2108EAPI Ecore_X_Randr_Output *
2109ecore_x_randr_window_outputs_get(Ecore_X_Window window,
2110 int *num)
2111{
2112#ifdef ECORE_XRANDR
2113 Ecore_X_Window root;
2114 Eina_Rectangle w_geo, c_geo;
2115 Ecore_X_Randr_Crtc *crtcs;
2116 Ecore_X_Randr_Mode mode;
2117 Ecore_X_Randr_Output *outputs, *ret = NULL, *tret;
2118 Window tw;
2119 int ncrtcs, noutputs, i, nret = 0, rx = 0, ry = 0;
2120
2121 if (_randr_version < RANDR_1_2) goto _ecore_x_randr_current_output_get_fail;
2122
2123 ecore_x_window_geometry_get(window,
2124 &w_geo.x, &w_geo.y,
2125 &w_geo.w, &w_geo.h);
2126
2127 root = ecore_x_window_root_get(window);
2128 crtcs = ecore_x_randr_crtcs_get(root, &ncrtcs);
2129 if (!crtcs) goto _ecore_x_randr_current_output_get_fail;
2130
2131 /* now get window RELATIVE to root window - thats what matters. */
2132 XTranslateCoordinates(_ecore_x_disp, window, root, 0, 0, &rx, &ry, &tw);
2133 w_geo.x = rx;
2134 w_geo.y = ry;
2135
2136 for (i = 0; i < ncrtcs; i++)
2137 {
2138 /* if crtc is not enabled, don't bother about it any further */
2139 mode = ecore_x_randr_crtc_mode_get(root, crtcs[i]);
2140 if (mode == Ecore_X_Randr_None) continue;
2141
2142 ecore_x_randr_crtc_geometry_get(root, crtcs[i],
2143 &c_geo.x, &c_geo.y,
2144 &c_geo.w, &c_geo.h);
2145 if (eina_rectangles_intersect(&w_geo, &c_geo))
2146 {
2147 outputs = ecore_x_randr_crtc_outputs_get(root, crtcs[i],
2148 &noutputs);
2149 /* The case below should be impossible, but for safety reasons
2150 * remains */
2151 if (!outputs)
2152 {
2153 if (num) *num = 0;
2154 free(ret);
2155 free(crtcs);
2156 return NULL;
2157 }
2158 tret = realloc(ret, ((nret + noutputs) * sizeof(Ecore_X_Randr_Output)));
2159 if (!tret)
2160 {
2161 if (num) *num = 0;
2162 free(outputs);
2163 free(ret);
2164 free(crtcs);
2165 return NULL;
2166 }
2167 ret = tret;
2168 memcpy(&ret[nret], outputs, (noutputs * sizeof(Ecore_X_Randr_Output)));
2169 nret += noutputs;
2170 free(outputs);
2171 }
2172 }
2173 free(crtcs);
2174
2175 if (num) *num = nret;
2176 return ret;
2177
2178_ecore_x_randr_current_output_get_fail:
2179#endif
2180 if (num) *num = 0;
2181 return NULL;
2182}
2183
2184/*
2185 * @depricated bad naming. Use ecore_x_randr_window_outputs_get instead.
2186 * @brief get the outputs, which display a certain window
2187 * @param window window the displaying outputs shall be found for
2188 * @param num the number of outputs displaying the window
2189 * @return array of outputs that display a certain window. NULL if no outputs
2190 * was found that displays the specified window.
2191 */
2192
2193EINA_DEPRECATED EAPI Ecore_X_Randr_Output *
2194ecore_x_randr_current_output_get(Ecore_X_Window window,
2195 int *num)
2196{
2197 return ecore_x_randr_window_outputs_get(window, num);
2198}
2199
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12_edid.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12_edid.c
new file mode 100644
index 0000000..d434f2f
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_12_edid.c
@@ -0,0 +1,457 @@
1/*
2 * Copyright 2006-2009 Red Hat, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 */
22/* Original Author: Adam Jackson <ajax@nwnk.net> */
23/* Heavily modified by: Leif Middelschulte <leif.middelschulte@gmail.com> */
24
25#include "Ecore_X.h"
26
27/* TODO:
28 * - see other TODO's within this file.
29 */
30
31#define ECORE_X_RANDR_EDID_VERSION_10 ((1 << 8) | 0)
32#define ECORE_X_RANDR_EDID_VERSION_11 ((1 << 8) | 1)
33#define ECORE_X_RANDR_EDID_VERSION_12 ((1 << 8) | 2)
34#define ECORE_X_RANDR_EDID_VERSION_13 ((1 << 8) | 3)
35#define ECORE_X_RANDR_EDID_VERSION_14 ((1 << 8) | 4)
36
37#define _ECORE_X_RANDR_EDID_OFFSET_MANUFACTURER 0x08
38#define _ECORE_X_RANDR_EDID_OFFSET_TYPE 0x14
39#define _ECORE_X_RANDR_EDID_OFFSET_VERSION_MAJOR 0x12
40#define _ECORE_X_RANDR_EDID_OFFSET_VERSION_MINOR 0x13
41#define _ECORE_X_RANDR_EDID_OFFSET_DPMS 0x18
42#define _ECORE_X_RANDR_EDID_OFFSET_COLORSPACE 0x18
43#define _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK 0x36
44#define _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_TYPE 3
45#define _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_CONTENT 5
46#define _ECORE_X_RANDR_EDID_OFFSET_ASPECT_RATIO_PREFERRED 15
47#define _ECORE_X_RANDR_EDID_OFFSET_ASPECT_RATIO 14
48
49#define _ECORE_X_RANDR_EDID_MASK_DIGITAL 0x80
50#define _ECORE_X_RANDR_EDID_MASK_DIGITAL_INTERFACE 0x0f
51#define _ECORE_X_RANDR_EDID_MASK_DIGITAL_TMDS_DFP_10 0x01
52#define _ECORE_X_RANDR_EDID_MASK_COLORSCHEME_ANALOGOUS 0x18
53#define _ECORE_X_RANDR_EDID_MASK_COLORSCHEME_DIGITAL_YCRCB_444 0x10
54#define _ECORE_X_RANDR_EDID_MASK_COLORSCHEME_DIGITAL_YCRCB_422 0x08
55#define _ECORE_X_RANDR_EDID_MASK_ASPECT_RATIO_PREFERRED 0xe0
56#define _ECORE_X_RANDR_EDID_MASK_DPMS 0xE0
57#define _ECORE_X_RANDR_EDID_MASK_DPMS_STANDBY 0x80
58#define _ECORE_X_RANDR_EDID_MASK_DPMS_SUSPEND 0x40
59#define _ECORE_X_RANDR_EDID_MASK_DPMS_OFF 0x20
60#define _ECORE_X_RANDR_EDID_MASK_INTERFACE_TYPE 0x0f
61#define _ECORE_X_RANDR_EDID_MASK_ASPECT_RATIO_4_3 0x80
62#define _ECORE_X_RANDR_EDID_MASK_ASPECT_RATIO_16_9 0x40
63#define _ECORE_X_RANDR_EDID_MASK_ASPECT_RATIO_16_10 0x20
64#define _ECORE_X_RANDR_EDID_MASK_ASPECT_RATIO_5_4 0x10
65#define _ECORE_X_RANDR_EDID_MASK_ASPECT_RATIO_15_9 0x08
66
67#define _ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX 13
68
69typedef enum _Ecore_X_Randr_Edid_Aspect_Ratio_Preferred {
70 ECORE_X_RANDR_EDID_ASPECT_RATIO_PREFERRED_4_3 = 0x00,
71 ECORE_X_RANDR_EDID_ASPECT_RATIO_PREFERRED_16_9 = 0x01,
72 ECORE_X_RANDR_EDID_ASPECT_RATIO_PREFERRED_16_10 = 0x02,
73 ECORE_X_RANDR_EDID_ASPECT_RATIO_PREFERRED_5_4 = 0x03,
74 ECORE_X_RANDR_EDID_ASPECT_RATIO_PREFERRED_15_9 = 0x04
75} Ecore_X_Randr_Edid_Aspect_Ratio_Preferred;
76
77/* Some convenience loops */
78#define _ECORE_X_RANDR_EDID_FOR_EACH_EXTENSION_BLOCK(edid, edid_length, extension_block_iter) \
79 for (extension_block_iter = edid; extension_block_iter < (edid + edid_length); extension_block_iter += 128)
80
81#define _ECORE_X_RANDR_EDID_FOR_EACH_CEA_BLOCK(edid, edid_length, cea_block_iter) \
82 _ECORE_X_RANDR_EDID_FOR_EACH_EXTENSION_BLOCK(edid, edid_length, cea_block_iter) \
83 if (cea_block_iter[0] == 0x02)
84
85/* The following macro is to be used with caution as it inherits another loop.
86 * Therefore using a 'break;' statement will lead to continuation in the
87 * inherent 'Extension block'-loop.
88 */
89#define _ECORE_X_RANDR_EDID_FOR_EACH_CEA_DETAILED_BLOCK(edid, edid_length, cea_block_iter, detailed_block_iter) \
90 _ECORE_X_RANDR_EDID_FOR_EACH_CEA_BLOCK(edid, edid_length, cea_block_iter) \
91 for (detailed_block_iter = cea_block_iter + cea_block_iter[2]; detailed_block_iter + 18 < cea_block_iter + 127; detailed_block_iter += 18) \
92 if (detailed_block_iter[0])
93
94#define _ECORE_X_RANDR_EDID_FOR_EACH_DESCRIPTOR_BLOCK(edid, block) \
95 for (block = edid + _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK; block <= (edid + _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK + (3 * 18)); block += 18)
96
97#define _ECORE_X_RANDR_EDID_FOR_EACH_NON_PIXEL_DESCRIPTOR_BLOCK(edid, block) \
98 _ECORE_X_RANDR_EDID_FOR_EACH_DESCRIPTOR_BLOCK(edid, block) \
99 if ((block[0] == 0) && (block[1] == 0))
100
101EAPI Eina_Bool
102ecore_x_randr_edid_has_valid_header(unsigned char *edid,
103 unsigned long edid_length)
104{
105 const unsigned char header[] =
106 { 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 };
107 if (!edid) return EINA_FALSE;
108 if (edid_length < 8) return EINA_FALSE;
109 if (!memcmp(edid, header, 8)) return EINA_TRUE;
110 return EINA_FALSE;
111}
112
113EAPI int
114ecore_x_randr_edid_version_get(unsigned char *edid,
115 unsigned long edid_length)
116{
117 if ((edid_length > _ECORE_X_RANDR_EDID_OFFSET_VERSION_MINOR) &&
118 (ecore_x_randr_edid_has_valid_header(edid, edid_length)))
119 return (edid[_ECORE_X_RANDR_EDID_OFFSET_VERSION_MAJOR] << 8) |
120 edid[_ECORE_X_RANDR_EDID_OFFSET_VERSION_MINOR];
121 return ECORE_X_RANDR_EDID_UNKNOWN_VALUE;
122}
123
124EAPI int
125ecore_x_randr_edid_manufacturer_model_get(unsigned char *edid,
126 unsigned long edid_length)
127{
128 if ((edid_length > 0x0b) &&
129 (ecore_x_randr_edid_has_valid_header(edid, edid_length)))
130 return (int)(edid[0x0a] + (edid[0x0b] << 8));
131 return ECORE_X_RANDR_EDID_UNKNOWN_VALUE;
132}
133
134EAPI int
135ecore_x_randr_edid_manufacturer_serial_number_get(unsigned char *edid,
136 unsigned long edid_length)
137{
138 if ((edid_length > 0x0f) &&
139 (ecore_x_randr_edid_has_valid_header(edid, edid_length)))
140 return (int)(edid[0x0c] + (edid[0x0d] << 8) +
141 (edid[0x0e] << 16) + (edid[0x0f] << 24));
142 return ECORE_X_RANDR_EDID_UNKNOWN_VALUE;
143}
144
145EAPI char *
146ecore_x_randr_edid_manufacturer_name_get(unsigned char *edid,
147 unsigned long edid_length)
148{
149 if ((edid_length > (_ECORE_X_RANDR_EDID_OFFSET_MANUFACTURER + 1)) &&
150 (ecore_x_randr_edid_has_valid_header(edid, edid_length)))
151 {
152 unsigned char *x;
153 char *name;
154
155 x = (edid + _ECORE_X_RANDR_EDID_OFFSET_MANUFACTURER);
156 name = malloc(sizeof(char) * 4);
157 if (!name) return NULL;
158 name[0] = ((x[0] & 0x7c) >> 2) + '@';
159 name[1] = ((x[0] & 0x03) << 3) + ((x[1] & 0xe0) >> 5) + '@';
160 name[2] = (x[1] & 0x1f) + '@';
161 name[_ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_TYPE] = 0;
162 return name;
163 }
164 return NULL;
165}
166
167EAPI char *
168ecore_x_randr_edid_display_name_get(unsigned char *edid,
169 unsigned long edid_length)
170{
171 unsigned char *block = NULL;
172 int version = ecore_x_randr_edid_version_get(edid, edid_length);
173
174 if (version < ECORE_X_RANDR_EDID_VERSION_13) return NULL;
175 _ECORE_X_RANDR_EDID_FOR_EACH_NON_PIXEL_DESCRIPTOR_BLOCK(edid, block)
176 {
177 if (block[_ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_TYPE] == 0xfc)
178 {
179 char *name, *p;
180 const char *edid_name;
181
182 edid_name = (const char *)block + _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_CONTENT;
183 name = malloc(sizeof(char) * _ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX);
184 if (!name) return NULL;
185 strncpy(name, edid_name, (_ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX - 1));
186 name[_ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX] = 0;
187 for (p = name; *p; p++)
188 {
189 if ((*p < ' ') || (*p > '~')) *p = 0;
190 }
191 return name;
192 }
193 }
194 return NULL;
195}
196
197EAPI Ecore_X_Randr_Edid_Aspect_Ratio
198ecore_x_randr_edid_display_aspect_ratio_preferred_get(unsigned char *edid,
199 unsigned long edid_length)
200{
201 unsigned char *block = NULL;
202 int version = ecore_x_randr_edid_version_get(edid, edid_length);
203
204 if (version < ECORE_X_RANDR_EDID_VERSION_13) return ECORE_X_RANDR_EDID_UNKNOWN_VALUE;
205 _ECORE_X_RANDR_EDID_FOR_EACH_NON_PIXEL_DESCRIPTOR_BLOCK(edid, block)
206 {
207 if ((block[_ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_TYPE] == 0xfd) &&
208 (block[10] == 0x04))
209 {
210 Ecore_X_Randr_Edid_Aspect_Ratio_Preferred preferred_ratio =
211 (Ecore_X_Randr_Edid_Aspect_Ratio_Preferred)
212 ((block[_ECORE_X_RANDR_EDID_OFFSET_ASPECT_RATIO_PREFERRED] &
213 _ECORE_X_RANDR_EDID_MASK_ASPECT_RATIO_PREFERRED) >> 5);
214 switch (preferred_ratio)
215 {
216 case ECORE_X_RANDR_EDID_ASPECT_RATIO_PREFERRED_4_3:
217 return ECORE_X_RANDR_EDID_ASPECT_RATIO_4_3;
218
219 case ECORE_X_RANDR_EDID_ASPECT_RATIO_PREFERRED_16_9:
220 return ECORE_X_RANDR_EDID_ASPECT_RATIO_16_9;
221
222 case ECORE_X_RANDR_EDID_ASPECT_RATIO_PREFERRED_16_10:
223 return ECORE_X_RANDR_EDID_ASPECT_RATIO_16_10;
224
225 case ECORE_X_RANDR_EDID_ASPECT_RATIO_PREFERRED_5_4:
226 return ECORE_X_RANDR_EDID_ASPECT_RATIO_5_4;
227
228 case ECORE_X_RANDR_EDID_ASPECT_RATIO_PREFERRED_15_9:
229 return ECORE_X_RANDR_EDID_ASPECT_RATIO_15_9;
230
231 default:
232 return ECORE_X_RANDR_EDID_UNKNOWN_VALUE;
233 }
234 }
235 }
236 return ECORE_X_RANDR_EDID_UNKNOWN_VALUE;
237}
238
239EAPI Ecore_X_Randr_Edid_Aspect_Ratio
240ecore_x_randr_edid_display_aspect_ratios_get(unsigned char *edid,
241 unsigned long edid_length)
242{
243 Ecore_X_Randr_Edid_Aspect_Ratio ret = ECORE_X_RANDR_EDID_UNKNOWN_VALUE;
244 unsigned char *block = NULL;
245 int version = ecore_x_randr_edid_version_get(edid, edid_length);
246
247 if (version < ECORE_X_RANDR_EDID_VERSION_13) return ECORE_X_RANDR_EDID_UNKNOWN_VALUE;
248 _ECORE_X_RANDR_EDID_FOR_EACH_NON_PIXEL_DESCRIPTOR_BLOCK(edid, block)
249 {
250 if ((block[_ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_TYPE] == 0xfd) &&
251 (block[10] == 0x04))
252 {
253 if (block[_ECORE_X_RANDR_EDID_OFFSET_ASPECT_RATIO] & _ECORE_X_RANDR_EDID_MASK_ASPECT_RATIO_4_3)
254 ret |= ECORE_X_RANDR_EDID_ASPECT_RATIO_4_3;
255 if (block[_ECORE_X_RANDR_EDID_OFFSET_ASPECT_RATIO] & _ECORE_X_RANDR_EDID_MASK_ASPECT_RATIO_16_9)
256 ret |= ECORE_X_RANDR_EDID_ASPECT_RATIO_16_9;
257 if (block[_ECORE_X_RANDR_EDID_OFFSET_ASPECT_RATIO] & _ECORE_X_RANDR_EDID_MASK_ASPECT_RATIO_16_10)
258 ret |= ECORE_X_RANDR_EDID_ASPECT_RATIO_16_10;
259 if (block[_ECORE_X_RANDR_EDID_OFFSET_ASPECT_RATIO] & _ECORE_X_RANDR_EDID_MASK_ASPECT_RATIO_5_4)
260 ret |= ECORE_X_RANDR_EDID_ASPECT_RATIO_5_4;
261 if (block[_ECORE_X_RANDR_EDID_OFFSET_ASPECT_RATIO] & _ECORE_X_RANDR_EDID_MASK_ASPECT_RATIO_15_9)
262 ret |= ECORE_X_RANDR_EDID_ASPECT_RATIO_15_9;
263 }
264 }
265 return ret;
266}
267
268EAPI char *
269ecore_x_randr_edid_display_ascii_get(unsigned char *edid,
270 unsigned long edid_length)
271{
272 unsigned char *block = NULL;
273 int version = ecore_x_randr_edid_version_get(edid, edid_length);
274
275 if (version < ECORE_X_RANDR_EDID_VERSION_13) return NULL;
276 _ECORE_X_RANDR_EDID_FOR_EACH_NON_PIXEL_DESCRIPTOR_BLOCK(edid, block)
277 {
278 if (block[_ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_TYPE] == 0xfe)
279 {
280 char *ascii, *p;
281 const char *edid_ascii = (const char *)block +
282 _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_CONTENT;
283 /*
284 * TODO: Two of these in a row, in the third and fourth slots,
285 * seems to be specified by SPWG: http://www.spwg.org/
286 */
287 ascii = malloc(sizeof(char) * _ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX);
288 if (!ascii) return NULL;
289 strncpy(ascii, edid_ascii, (_ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX - 1));
290 ascii[_ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX] = 0;
291 for (p = ascii; *p; p++)
292 {
293 if ((*p < ' ') || (*p > '~')) *p = 0;
294 }
295 return ascii;
296 }
297 }
298 return NULL;
299}
300
301EAPI char *
302ecore_x_randr_edid_display_serial_get(unsigned char *edid,
303 unsigned long edid_length)
304{
305 unsigned char *block = NULL;
306 int version = ecore_x_randr_edid_version_get(edid, edid_length);
307
308 if (version < ECORE_X_RANDR_EDID_VERSION_13) return NULL;
309 _ECORE_X_RANDR_EDID_FOR_EACH_NON_PIXEL_DESCRIPTOR_BLOCK(edid, block)
310 {
311 if (block[_ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_TYPE] == 0xff)
312 {
313 char *serial, *p;
314 const char *edid_serial = (const char *)block +
315 _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_CONTENT;
316 /*
317 * TODO: Two of these in a row, in the third and fourth slots,
318 * seems to be specified by SPWG: http://www.spwg.org/
319 */
320 serial = malloc(sizeof(char) * _ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX);
321 if (!serial) return NULL;
322 strncpy(serial, edid_serial, (_ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX - 1));
323 serial[_ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX] = 0;
324 for (p = serial; *p; p++)
325 {
326 if ((*p < ' ') || (*p > '~')) *p = 0;
327 }
328 return serial;
329 }
330 }
331 return NULL;
332}
333
334EAPI Eina_Bool
335ecore_x_randr_edid_info_has_valid_checksum(unsigned char *edid,
336 unsigned long edid_length)
337{
338 unsigned char *cea_block_iter = NULL;
339 char sum = 0;
340 int i;
341 int version = ecore_x_randr_edid_version_get(edid, edid_length);
342
343 if (version < ECORE_X_RANDR_EDID_VERSION_13) return EINA_FALSE;
344 if (edid_length < 128) return EINA_FALSE;
345
346 /* Check the EDID block itself */
347 for (i = 0; i < 128; i++) sum += edid[i];
348 if (sum) return EINA_FALSE;
349
350 /* Check the cea extension blocks */
351 _ECORE_X_RANDR_EDID_FOR_EACH_CEA_BLOCK(edid, edid_length, cea_block_iter)
352 {
353 for (i = 0, sum = 0; i < 128; i++) sum += cea_block_iter[i];
354 }
355 if (sum) return EINA_FALSE;
356 return EINA_TRUE;
357}
358
359EAPI Eina_Bool
360ecore_x_randr_edid_dpms_available_get(unsigned char *edid,
361 unsigned long edid_length)
362{
363 int version = ecore_x_randr_edid_version_get(edid, edid_length);
364
365 if (version < ECORE_X_RANDR_EDID_VERSION_13) return EINA_FALSE;
366 return !!(edid[_ECORE_X_RANDR_EDID_OFFSET_DPMS] &
367 _ECORE_X_RANDR_EDID_MASK_DPMS);
368}
369
370EAPI Eina_Bool
371ecore_x_randr_edid_dpms_standby_available_get(unsigned char *edid,
372 unsigned long edid_length)
373{
374 int version = ecore_x_randr_edid_version_get(edid, edid_length);
375
376 if (version < ECORE_X_RANDR_EDID_VERSION_13) return EINA_FALSE;
377 if (edid[_ECORE_X_RANDR_EDID_OFFSET_DPMS] & _ECORE_X_RANDR_EDID_MASK_DPMS)
378 return !!(edid[_ECORE_X_RANDR_EDID_OFFSET_DPMS] &
379 _ECORE_X_RANDR_EDID_MASK_DPMS_STANDBY);
380 return EINA_FALSE;
381}
382
383EAPI Eina_Bool
384ecore_x_randr_edid_dpms_suspend_available_get(unsigned char *edid,
385 unsigned long edid_length)
386{
387 int version = ecore_x_randr_edid_version_get(edid, edid_length);
388
389 if (version < ECORE_X_RANDR_EDID_VERSION_13) return EINA_FALSE;
390 if (edid[_ECORE_X_RANDR_EDID_OFFSET_DPMS] & _ECORE_X_RANDR_EDID_MASK_DPMS)
391 return !!(edid[_ECORE_X_RANDR_EDID_OFFSET_DPMS] &
392 _ECORE_X_RANDR_EDID_MASK_DPMS_SUSPEND);
393 return EINA_FALSE;
394}
395
396EAPI Eina_Bool
397ecore_x_randr_edid_dpms_off_available_get(unsigned char *edid,
398 unsigned long edid_length)
399{
400 int version = ecore_x_randr_edid_version_get(edid, edid_length);
401
402 if (version < ECORE_X_RANDR_EDID_VERSION_13) return EINA_FALSE;
403 if (edid[_ECORE_X_RANDR_EDID_OFFSET_DPMS] & _ECORE_X_RANDR_EDID_MASK_DPMS)
404 return !!(edid[_ECORE_X_RANDR_EDID_OFFSET_DPMS] &
405 _ECORE_X_RANDR_EDID_MASK_DPMS_OFF);
406 return EINA_FALSE;
407}
408
409EAPI Eina_Bool
410ecore_x_randr_edid_display_type_digital_get(unsigned char *edid,
411 unsigned long edid_length)
412{
413 int version = ecore_x_randr_edid_version_get(edid, edid_length);
414
415 if (version < ECORE_X_RANDR_EDID_VERSION_13) return EINA_FALSE;
416 return !!(edid[_ECORE_X_RANDR_EDID_OFFSET_TYPE] &
417 _ECORE_X_RANDR_EDID_MASK_DIGITAL);
418}
419
420EAPI Ecore_X_Randr_Edid_Display_Colorscheme
421ecore_x_randr_edid_display_colorscheme_get(unsigned char *edid,
422 unsigned long edid_length)
423{
424 Ecore_X_Randr_Edid_Display_Colorscheme colorscheme = ECORE_X_RANDR_EDID_UNKNOWN_VALUE;
425 int version = ecore_x_randr_edid_version_get(edid, edid_length);
426
427 if (version < ECORE_X_RANDR_EDID_VERSION_13) return colorscheme;
428 if (ecore_x_randr_edid_display_type_digital_get(edid, edid_length))
429 {
430 colorscheme = ECORE_X_RANDR_EDID_DISPLAY_COLORSCHEME_COLOR_RGB_4_4_4;
431 if (edid[_ECORE_X_RANDR_EDID_OFFSET_COLORSPACE] &
432 _ECORE_X_RANDR_EDID_MASK_COLORSCHEME_DIGITAL_YCRCB_444)
433 colorscheme |= ECORE_X_RANDR_EDID_DISPLAY_COLORSCHEME_COLOR_RGB_YCRCB_4_4_4;
434 if (edid[_ECORE_X_RANDR_EDID_OFFSET_COLORSPACE] &
435 _ECORE_X_RANDR_EDID_MASK_COLORSCHEME_DIGITAL_YCRCB_422)
436 colorscheme |= ECORE_X_RANDR_EDID_DISPLAY_COLORSCHEME_COLOR_RGB_YCRCB_4_2_2;
437 }
438 else
439 colorscheme = edid[_ECORE_X_RANDR_EDID_OFFSET_COLORSPACE] & _ECORE_X_RANDR_EDID_MASK_COLORSCHEME_ANALOGOUS;
440 return colorscheme;
441}
442
443EAPI Ecore_X_Randr_Edid_Display_Interface_Type
444ecore_x_randr_edid_display_interface_type_get(unsigned char *edid,
445 unsigned long edid_length)
446{
447 Ecore_X_Randr_Edid_Display_Interface_Type type = ECORE_X_RANDR_EDID_UNKNOWN_VALUE;
448 int version = ecore_x_randr_edid_version_get(edid, edid_length);
449
450 if (version < ECORE_X_RANDR_EDID_VERSION_13) return type;
451 type = edid[_ECORE_X_RANDR_EDID_OFFSET_TYPE] &
452 _ECORE_X_RANDR_EDID_MASK_INTERFACE_TYPE;
453 if (type > ECORE_X_RANDR_EDID_DISPLAY_INTERFACE_DISPLAY_PORT)
454 type = ECORE_X_RANDR_EDID_UNKNOWN_VALUE;
455 return type;
456}
457
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_13.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_13.c
new file mode 100644
index 0000000..ab242f7
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_randr_13.c
@@ -0,0 +1,63 @@
1/*
2 * vim:ts=8:sw=3:sts=8:expandtab:cino=>5n-3f0^-2{2
3 */
4
5#ifdef HAVE_CONFIG_H
6# include <config.h>
7#endif
8
9#include "ecore_x_private.h"
10#include "ecore_x_randr.h"
11
12#define Ecore_X_Randr_None 0
13#define Ecore_X_Randr_Unset -1
14
15#ifdef ECORE_XRANDR
16
17#define RANDR_1_3 ((1 << 16) | 3)
18#define RANDR_CHECK_1_3_RET(ret) if(_randr_version < RANDR_1_3) return ret
19
20extern XRRScreenResources *(*_ecore_x_randr_get_screen_resources)(Display *
21 dpy,
22 Window
23 window);
24extern int _randr_version;
25#endif
26
27/*
28 * @param root window which's screen should be queried
29 * @return Ecore_X_Randr_Ouptut_Id or - if query failed or none is set - Ecore_X_Randr_None
30 */
31EAPI Ecore_X_Randr_Output
32ecore_x_randr_primary_output_get(Ecore_X_Window root)
33{
34#ifdef ECORE_XRANDR
35 RANDR_CHECK_1_3_RET(Ecore_X_Randr_None);
36 if (!_ecore_x_randr_root_validate(root))
37 return Ecore_X_Randr_None;
38
39 return XRRGetOutputPrimary(_ecore_x_disp, root);
40#else
41 return Ecore_X_Randr_None;
42#endif
43}
44
45/*
46 * @param root window which's screen should be queried
47 * @param output that should be set as given root window's screen primary output
48 */
49EAPI void
50ecore_x_randr_primary_output_set(Ecore_X_Window root,
51 Ecore_X_Randr_Output output)
52{
53#ifdef ECORE_XRANDR
54 RANDR_CHECK_1_3_RET();
55
56 if (_ecore_x_randr_output_validate(root, output))
57 {
58 XRRSetOutputPrimary(_ecore_x_disp, root, output);
59 }
60
61#endif
62}
63
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_region.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_region.c
new file mode 100644
index 0000000..7cc66e3
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_region.c
@@ -0,0 +1,158 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include "ecore_x_private.h"
6
7/*
8 * [x] XCreateRegion
9 * [ ] XPolygonRegion
10 * [x] XSetRegion
11 * [x] XDestroyRegion
12 *
13 * [x] XOffsetRegion
14 * [ ] XShrinkRegion
15 *
16 * [ ] XClipBox
17 * [x] XIntersectRegion
18 * [x] XUnionRegion
19 * [x] XUnionRectWithRegion
20 * [x] XSubtractRegion
21 * [ ] XXorRegion
22 *
23 * [x] XEmptyRegion
24 * [x] XEqualRegion
25 *
26 * [x] XPointInRegion
27 * [x] XRectInRegion
28 */
29
30EAPI Ecore_X_XRegion *
31ecore_x_xregion_new()
32{
33 LOGFN(__FILE__, __LINE__, __FUNCTION__);
34 return (Ecore_X_XRegion *)XCreateRegion();
35} /* ecore_x_xregion_new */
36
37EAPI void
38ecore_x_xregion_free(Ecore_X_XRegion *region)
39{
40 LOGFN(__FILE__, __LINE__, __FUNCTION__);
41 if (!region)
42 return;
43
44 XDestroyRegion((Region)region);
45} /* ecore_x_xregion_free */
46
47EAPI Eina_Bool
48ecore_x_xregion_set(Ecore_X_XRegion *region,
49 Ecore_X_GC gc)
50{
51 LOGFN(__FILE__, __LINE__, __FUNCTION__);
52 return XSetRegion(_ecore_x_disp, gc, (Region)region) ? EINA_TRUE : EINA_FALSE;
53} /* ecore_x_xregion_set */
54
55EAPI void
56ecore_x_xregion_translate(Ecore_X_XRegion *region,
57 int x,
58 int y)
59{
60 LOGFN(__FILE__, __LINE__, __FUNCTION__);
61 if (!region)
62 return;
63
64 /* return value not used */
65 XOffsetRegion((Region)region, x, y);
66} /* ecore_x_xregion_translate */
67
68EAPI Eina_Bool
69ecore_x_xregion_intersect(Ecore_X_XRegion *dst,
70 Ecore_X_XRegion *r1,
71 Ecore_X_XRegion *r2)
72{
73 LOGFN(__FILE__, __LINE__, __FUNCTION__);
74 return XIntersectRegion((Region)r1, (Region)r2, (Region)dst) ? EINA_TRUE : EINA_FALSE;
75} /* ecore_x_xregion_intersect */
76
77EAPI Eina_Bool
78ecore_x_xregion_union(Ecore_X_XRegion *dst,
79 Ecore_X_XRegion *r1,
80 Ecore_X_XRegion *r2)
81{
82 LOGFN(__FILE__, __LINE__, __FUNCTION__);
83 return XUnionRegion((Region)r1, (Region)r2, (Region)dst) ? EINA_TRUE : EINA_FALSE;
84} /* ecore_x_xregion_union */
85
86EAPI Eina_Bool
87ecore_x_xregion_union_rect(Ecore_X_XRegion *dst,
88 Ecore_X_XRegion *src,
89 Ecore_X_Rectangle *rect)
90{
91 XRectangle xr;
92
93 LOGFN(__FILE__, __LINE__, __FUNCTION__);
94 xr.x = rect->x;
95 xr.y = rect->y;
96 xr.width = rect->width;
97 xr.height = rect->height;
98
99 return XUnionRectWithRegion(&xr, (Region)src, (Region)dst) ? EINA_TRUE : EINA_FALSE;
100} /* ecore_x_xregion_union_rect */
101
102EAPI Eina_Bool
103ecore_x_xregion_subtract(Ecore_X_XRegion *dst,
104 Ecore_X_XRegion *rm,
105 Ecore_X_XRegion *rs)
106{
107 LOGFN(__FILE__, __LINE__, __FUNCTION__);
108 return XSubtractRegion((Region)rm, (Region)rs, (Region)dst) ? EINA_TRUE : EINA_FALSE;
109} /* ecore_x_xregion_subtract */
110
111EAPI Eina_Bool
112ecore_x_xregion_is_empty(Ecore_X_XRegion *region)
113{
114 if (!region)
115 return EINA_TRUE;
116
117 LOGFN(__FILE__, __LINE__, __FUNCTION__);
118 return XEmptyRegion((Region)region) ? EINA_TRUE : EINA_FALSE;
119} /* ecore_x_xregion_is_empty */
120
121EAPI Eina_Bool
122ecore_x_xregion_is_equal(Ecore_X_XRegion *r1,
123 Ecore_X_XRegion *r2)
124{
125 if (!r1 || !r2)
126 return EINA_FALSE;
127
128 LOGFN(__FILE__, __LINE__, __FUNCTION__);
129 return XEqualRegion((Region)r1, (Region)r1) ? EINA_TRUE : EINA_FALSE;
130} /* ecore_x_xregion_is_equal */
131
132EAPI Eina_Bool
133ecore_x_xregion_point_contain(Ecore_X_XRegion *region,
134 int x,
135 int y)
136{
137 if (!region)
138 return EINA_FALSE;
139
140 LOGFN(__FILE__, __LINE__, __FUNCTION__);
141 return XPointInRegion((Region)region, x, y) ? EINA_TRUE : EINA_FALSE;
142} /* ecore_x_xregion_point_contain */
143
144EAPI Eina_Bool
145ecore_x_xregion_rect_contain(Ecore_X_XRegion *region,
146 Ecore_X_Rectangle *rect)
147{
148 if (!region || !rect)
149 return EINA_FALSE;
150
151 LOGFN(__FILE__, __LINE__, __FUNCTION__);
152 return XRectInRegion((Region)region,
153 rect->x,
154 rect->y,
155 rect->width,
156 rect->height) ? EINA_TRUE : EINA_FALSE;
157} /* ecore_x_xregion_rect_contain */
158
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_screensaver.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_screensaver.c
new file mode 100644
index 0000000..a3bca67
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_screensaver.c
@@ -0,0 +1,173 @@
1/*
2 * Screensaver code
3 */
4
5#ifdef HAVE_CONFIG_H
6# include <config.h>
7#endif /* ifdef HAVE_CONFIG_H */
8
9#include "Ecore.h"
10#include "ecore_x_private.h"
11#include "Ecore_X.h"
12#include "Ecore_X_Atoms.h"
13
14static int _screensaver_available = -1;
15
16EAPI Eina_Bool
17ecore_x_screensaver_event_available_get(void)
18{
19 if (_screensaver_available >= 0)
20 return _screensaver_available;
21
22#ifdef ECORE_XSS
23 int _screensaver_major, _screensaver_minor;
24
25 LOGFN(__FILE__, __LINE__, __FUNCTION__);
26 _screensaver_major = 1;
27 _screensaver_minor = 0;
28
29 if (XScreenSaverQueryVersion(_ecore_x_disp, &_screensaver_major,
30 &_screensaver_minor))
31 _screensaver_available = 1;
32 else
33 _screensaver_available = 0;
34
35#else /* ifdef ECORE_XSS */
36 _screensaver_available = 0;
37#endif /* ifdef ECORE_XSS */
38 return _screensaver_available;
39} /* ecore_x_screensaver_event_available_get */
40
41EAPI int
42ecore_x_screensaver_idle_time_get(void)
43{
44#ifdef ECORE_XSS
45 XScreenSaverInfo *xss;
46 int idle;
47
48 LOGFN(__FILE__, __LINE__, __FUNCTION__);
49 xss = XScreenSaverAllocInfo();
50 XScreenSaverQueryInfo(_ecore_x_disp,
51 RootWindow(_ecore_x_disp, DefaultScreen(
52 _ecore_x_disp)), xss);
53 idle = xss->idle / 1000;
54 XFree(xss);
55
56 return idle;
57#else
58 return 0;
59#endif /* ifdef ECORE_XSS */
60} /* ecore_x_screensaver_idle_time_get */
61
62EAPI void
63ecore_x_screensaver_set(int timeout,
64 int interval,
65 int prefer_blanking,
66 int allow_exposures)
67{
68 LOGFN(__FILE__, __LINE__, __FUNCTION__);
69 XSetScreenSaver(_ecore_x_disp,
70 timeout,
71 interval,
72 prefer_blanking,
73 allow_exposures);
74} /* ecore_x_screensaver_set */
75
76EAPI void
77ecore_x_screensaver_timeout_set(int timeout)
78{
79 int pto, pint, pblank, pexpo;
80
81 LOGFN(__FILE__, __LINE__, __FUNCTION__);
82 XGetScreenSaver(_ecore_x_disp, &pto, &pint, &pblank, &pexpo);
83 XSetScreenSaver(_ecore_x_disp, timeout, pint, pblank, pexpo);
84} /* ecore_x_screensaver_timeout_set */
85
86EAPI int
87ecore_x_screensaver_timeout_get(void)
88{
89 int pto, pint, pblank, pexpo;
90
91 LOGFN(__FILE__, __LINE__, __FUNCTION__);
92 XGetScreenSaver(_ecore_x_disp, &pto, &pint, &pblank, &pexpo);
93 return pto;
94} /* ecore_x_screensaver_timeout_get */
95
96EAPI void
97ecore_x_screensaver_blank_set(int blank)
98{
99 int pto, pint, pblank, pexpo;
100
101 LOGFN(__FILE__, __LINE__, __FUNCTION__);
102 XGetScreenSaver(_ecore_x_disp, &pto, &pint, &pblank, &pexpo);
103 XSetScreenSaver(_ecore_x_disp, pto, pint, blank, pexpo);
104} /* ecore_x_screensaver_blank_set */
105
106EAPI int
107ecore_x_screensaver_blank_get(void)
108{
109 int pto, pint, pblank, pexpo;
110
111 LOGFN(__FILE__, __LINE__, __FUNCTION__);
112 XGetScreenSaver(_ecore_x_disp, &pto, &pint, &pblank, &pexpo);
113 return pblank;
114} /* ecore_x_screensaver_blank_get */
115
116EAPI void
117ecore_x_screensaver_expose_set(int expose)
118{
119 int pto, pint, pblank, pexpo;
120
121 LOGFN(__FILE__, __LINE__, __FUNCTION__);
122 XGetScreenSaver(_ecore_x_disp, &pto, &pint, &pblank, &pexpo);
123 XSetScreenSaver(_ecore_x_disp, pto, pint, pblank, expose);
124} /* ecore_x_screensaver_expose_set */
125
126EAPI int
127ecore_x_screensaver_expose_get(void)
128{
129 int pto, pint, pblank, pexpo;
130
131 LOGFN(__FILE__, __LINE__, __FUNCTION__);
132 XGetScreenSaver(_ecore_x_disp, &pto, &pint, &pblank, &pexpo);
133 return pexpo;
134} /* ecore_x_screensaver_expose_get */
135
136EAPI void
137ecore_x_screensaver_interval_set(int interval)
138{
139 int pto, pint, pblank, pexpo;
140
141 LOGFN(__FILE__, __LINE__, __FUNCTION__);
142 XGetScreenSaver(_ecore_x_disp, &pto, &pint, &pblank, &pexpo);
143 XSetScreenSaver(_ecore_x_disp, pto, interval, pblank, pexpo);
144} /* ecore_x_screensaver_interval_set */
145
146EAPI int
147ecore_x_screensaver_interval_get(void)
148{
149 int pto, pint, pblank, pexpo;
150
151 LOGFN(__FILE__, __LINE__, __FUNCTION__);
152 XGetScreenSaver(_ecore_x_disp, &pto, &pint, &pblank, &pexpo);
153 return pint;
154} /* ecore_x_screensaver_interval_get */
155
156EAPI void
157ecore_x_screensaver_event_listen_set(Eina_Bool on)
158{
159#ifdef ECORE_XSS
160 Ecore_X_Window root;
161
162 LOGFN(__FILE__, __LINE__, __FUNCTION__);
163 root = DefaultRootWindow(_ecore_x_disp);
164 if (on)
165 XScreenSaverSelectInput(_ecore_x_disp, root, ScreenSaverNotifyMask);
166 else
167 XScreenSaverSelectInput(_ecore_x_disp, root, 0);
168#else
169 return;
170 on = EINA_FALSE;
171#endif /* ifdef ECORE_XSS */
172} /* ecore_x_screensaver_event_listen_set */
173
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_selection.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_selection.c
new file mode 100644
index 0000000..b1aa611
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_selection.c
@@ -0,0 +1,1001 @@
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_private.h"
10#include "ecore_x_private.h"
11#include "Ecore_X.h"
12#include "Ecore_X_Atoms.h"
13
14static Ecore_X_Selection_Intern selections[4];
15static Ecore_X_Selection_Converter *converters = NULL;
16static Ecore_X_Selection_Parser *parsers = NULL;
17
18static Eina_Bool _ecore_x_selection_converter_text(char *target,
19 void *data,
20 int size,
21 void **data_ret,
22 int *size_ret,
23 Ecore_X_Atom *tprop,
24 int *);
25static int _ecore_x_selection_data_default_free(void *data);
26static void *_ecore_x_selection_parser_files(const char *target,
27 void *data,
28 int size,
29 int format);
30static int _ecore_x_selection_data_files_free(void *data);
31static void *_ecore_x_selection_parser_text(const char *target,
32 void *data,
33 int size,
34 int format);
35static int _ecore_x_selection_data_text_free(void *data);
36static void *_ecore_x_selection_parser_targets(const char *target,
37 void *data,
38 int size,
39 int format);
40static int _ecore_x_selection_data_targets_free(void *data);
41
42#define ECORE_X_SELECTION_DATA(x) ((Ecore_X_Selection_Data *)(x))
43
44void
45_ecore_x_selection_data_init(void)
46{
47 /* Initialize global data */
48 memset(selections, 0, sizeof(selections));
49
50 /* Initialize converters */
51 ecore_x_selection_converter_atom_add(ECORE_X_ATOM_TEXT,
52 _ecore_x_selection_converter_text);
53#ifdef X_HAVE_UTF8_STRING
54 ecore_x_selection_converter_atom_add(ECORE_X_ATOM_UTF8_STRING,
55 _ecore_x_selection_converter_text);
56#endif /* ifdef X_HAVE_UTF8_STRING */
57 ecore_x_selection_converter_atom_add(ECORE_X_ATOM_COMPOUND_TEXT,
58 _ecore_x_selection_converter_text);
59 ecore_x_selection_converter_atom_add(ECORE_X_ATOM_STRING,
60 _ecore_x_selection_converter_text);
61
62 /* Initialize parsers */
63 ecore_x_selection_parser_add("text/plain",
64 _ecore_x_selection_parser_text);
65 ecore_x_selection_parser_add(ECORE_X_SELECTION_TARGET_UTF8_STRING,
66 _ecore_x_selection_parser_text);
67 ecore_x_selection_parser_add("text/uri-list",
68 _ecore_x_selection_parser_files);
69 ecore_x_selection_parser_add("_NETSCAPE_URL",
70 _ecore_x_selection_parser_files);
71 ecore_x_selection_parser_add(ECORE_X_SELECTION_TARGET_TARGETS,
72 _ecore_x_selection_parser_targets);
73} /* _ecore_x_selection_data_init */
74
75void
76_ecore_x_selection_shutdown(void)
77{
78 Ecore_X_Selection_Converter *cnv;
79 Ecore_X_Selection_Parser *prs;
80
81 /* free the selection converters */
82 cnv = converters;
83 while (cnv)
84 {
85 Ecore_X_Selection_Converter *tmp;
86
87 tmp = cnv->next;
88 free(cnv);
89 cnv = tmp;
90 }
91 converters = NULL;
92
93 /* free the selection parsers */
94 prs = parsers;
95 while (prs)
96 {
97 Ecore_X_Selection_Parser *tmp;
98
99 tmp = prs;
100 prs = prs->next;
101 free(tmp->target);
102 free(tmp);
103 }
104 parsers = NULL;
105} /* _ecore_x_selection_shutdown */
106
107Ecore_X_Selection_Intern *
108_ecore_x_selection_get(Ecore_X_Atom selection)
109{
110 if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
111 return &selections[0];
112 else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY)
113 return &selections[1];
114 else if (selection == ECORE_X_ATOM_SELECTION_XDND)
115 return &selections[2];
116 else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
117 return &selections[3];
118 else
119 return NULL;
120} /* _ecore_x_selection_get */
121
122Eina_Bool
123_ecore_x_selection_set(Window w,
124 const void *data,
125 int size,
126 Ecore_X_Atom selection)
127{
128 int in;
129 unsigned char *buf = NULL;
130
131 XSetSelectionOwner(_ecore_x_disp, selection, w, _ecore_x_event_last_time);
132 if (XGetSelectionOwner(_ecore_x_disp, selection) != w)
133 return EINA_FALSE;
134
135 if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
136 in = 0;
137 else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY)
138 in = 1;
139 else if (selection == ECORE_X_ATOM_SELECTION_XDND)
140 in = 2;
141 else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
142 in = 3;
143 else
144 return EINA_FALSE;
145
146 if (data)
147 {
148 selections[in].win = w;
149 selections[in].selection = selection;
150 selections[in].length = size;
151 selections[in].time = _ecore_x_event_last_time;
152
153 buf = malloc(size);
154 if (!buf) return EINA_FALSE;
155 memcpy(buf, data, size);
156 selections[in].data = buf;
157 }
158 else if (selections[in].data)
159 {
160 free(selections[in].data);
161 memset(&selections[in], 0, sizeof(Ecore_X_Selection_Data));
162 }
163
164 return EINA_TRUE;
165} /* _ecore_x_selection_set */
166
167/**
168 * Claim ownership of the PRIMARY selection and set its data.
169 * @param w The window to which this selection belongs
170 * @param data The data associated with the selection
171 * @param size The size of the data buffer in bytes
172 * @return Returns 1 if the ownership of the selection was successfully
173 * claimed, or 0 if unsuccessful.
174 */
175EAPI Eina_Bool
176ecore_x_selection_primary_set(Ecore_X_Window w,
177 const void *data,
178 int size)
179{
180 LOGFN(__FILE__, __LINE__, __FUNCTION__);
181 return _ecore_x_selection_set(w, data, size, ECORE_X_ATOM_SELECTION_PRIMARY);
182} /* ecore_x_selection_primary_set */
183
184/**
185 * Release ownership of the primary selection
186 * @return Returns 1 if the selection was successfully cleared,
187 * or 0 if unsuccessful.
188 *
189 */
190EAPI Eina_Bool
191ecore_x_selection_primary_clear(void)
192{
193 LOGFN(__FILE__, __LINE__, __FUNCTION__);
194 return _ecore_x_selection_set(None, NULL, 0, ECORE_X_ATOM_SELECTION_PRIMARY);
195} /* ecore_x_selection_primary_clear */
196
197/**
198 * Claim ownership of the SECONDARY selection and set its data.
199 * @param w The window to which this selection belongs
200 * @param data The data associated with the selection
201 * @param size The size of the data buffer in bytes
202 * @return Returns 1 if the ownership of the selection was successfully
203 * claimed, or 0 if unsuccessful.
204 */
205EAPI Eina_Bool
206ecore_x_selection_secondary_set(Ecore_X_Window w,
207 const void *data,
208 int size)
209{
210 LOGFN(__FILE__, __LINE__, __FUNCTION__);
211 return _ecore_x_selection_set(w,
212 data,
213 size,
214 ECORE_X_ATOM_SELECTION_SECONDARY);
215} /* ecore_x_selection_secondary_set */
216
217/**
218 * Release ownership of the secondary selection
219 * @return Returns 1 if the selection was successfully cleared,
220 * or 0 if unsuccessful.
221 *
222 */
223EAPI Eina_Bool
224ecore_x_selection_secondary_clear(void)
225{
226 LOGFN(__FILE__, __LINE__, __FUNCTION__);
227 return _ecore_x_selection_set(None,
228 NULL,
229 0,
230 ECORE_X_ATOM_SELECTION_SECONDARY);
231} /* ecore_x_selection_secondary_clear */
232
233/**
234 * Claim ownership of the XDND selection and set its data.
235 * @param w The window to which this selection belongs
236 * @param data The data associated with the selection
237 * @param size The size of the data buffer in bytes
238 * @return Returns 1 if the ownership of the selection was successfully
239 * claimed, or 0 if unsuccessful.
240 */
241EAPI Eina_Bool
242ecore_x_selection_xdnd_set(Ecore_X_Window w,
243 const void *data,
244 int size)
245{
246 LOGFN(__FILE__, __LINE__, __FUNCTION__);
247 return _ecore_x_selection_set(w, data, size, ECORE_X_ATOM_SELECTION_XDND);
248} /* ecore_x_selection_xdnd_set */
249
250/**
251 * Release ownership of the XDND selection
252 * @return Returns 1 if the selection was successfully cleared,
253 * or 0 if unsuccessful.
254 *
255 */
256EAPI Eina_Bool
257ecore_x_selection_xdnd_clear(void)
258{
259 LOGFN(__FILE__, __LINE__, __FUNCTION__);
260 return _ecore_x_selection_set(None, NULL, 0, ECORE_X_ATOM_SELECTION_XDND);
261} /* ecore_x_selection_xdnd_clear */
262
263/**
264 * Claim ownership of the CLIPBOARD selection and set its data.
265 * @param w The window to which this selection belongs
266 * @param data The data associated with the selection
267 * @param size The size of the data buffer in bytes
268 * @return Returns 1 if the ownership of the selection was successfully
269 * claimed, or 0 if unsuccessful.
270 *
271 * Get the converted data from a previous CLIPBOARD selection
272 * request. The buffer must be freed when done with.
273 */
274EAPI Eina_Bool
275ecore_x_selection_clipboard_set(Ecore_X_Window w,
276 const void *data,
277 int size)
278{
279 LOGFN(__FILE__, __LINE__, __FUNCTION__);
280 return _ecore_x_selection_set(w,
281 data,
282 size,
283 ECORE_X_ATOM_SELECTION_CLIPBOARD);
284} /* ecore_x_selection_clipboard_set */
285
286/**
287 * Release ownership of the clipboard selection
288 * @return Returns 1 if the selection was successfully cleared,
289 * or 0 if unsuccessful.
290 *
291 */
292EAPI Eina_Bool
293ecore_x_selection_clipboard_clear(void)
294{
295 LOGFN(__FILE__, __LINE__, __FUNCTION__);
296 return _ecore_x_selection_set(None,
297 NULL,
298 0,
299 ECORE_X_ATOM_SELECTION_CLIPBOARD);
300} /* ecore_x_selection_clipboard_clear */
301
302Ecore_X_Atom
303_ecore_x_selection_target_atom_get(const char *target)
304{
305 Ecore_X_Atom x_target;
306
307 if (!strcmp(target, ECORE_X_SELECTION_TARGET_TEXT))
308 x_target = ECORE_X_ATOM_TEXT;
309 else if (!strcmp(target, ECORE_X_SELECTION_TARGET_COMPOUND_TEXT))
310 x_target = ECORE_X_ATOM_COMPOUND_TEXT;
311 else if (!strcmp(target, ECORE_X_SELECTION_TARGET_STRING))
312 x_target = ECORE_X_ATOM_STRING;
313 else if (!strcmp(target, ECORE_X_SELECTION_TARGET_UTF8_STRING))
314 x_target = ECORE_X_ATOM_UTF8_STRING;
315 else if (!strcmp(target, ECORE_X_SELECTION_TARGET_FILENAME))
316 x_target = ECORE_X_ATOM_FILE_NAME;
317 else
318 x_target = ecore_x_atom_get(target);
319
320 return x_target;
321} /* _ecore_x_selection_target_atom_get */
322
323char *
324_ecore_x_selection_target_get(Ecore_X_Atom target)
325{
326 /* FIXME: Should not return mem allocated with strdup or X mixed,
327 * one should use free to free, the other XFree */
328 if (target == ECORE_X_ATOM_FILE_NAME)
329 return strdup(ECORE_X_SELECTION_TARGET_FILENAME);
330 else if (target == ECORE_X_ATOM_STRING)
331 return strdup(ECORE_X_SELECTION_TARGET_STRING);
332 else if (target == ECORE_X_ATOM_UTF8_STRING)
333 return strdup(ECORE_X_SELECTION_TARGET_UTF8_STRING);
334 else if (target == ECORE_X_ATOM_TEXT)
335 return strdup(ECORE_X_SELECTION_TARGET_TEXT);
336 else
337 return XGetAtomName(_ecore_x_disp, target);
338} /* _ecore_x_selection_target_get */
339
340static void
341_ecore_x_selection_request(Ecore_X_Window w,
342 Ecore_X_Atom selection,
343 const char *target_str)
344{
345 Ecore_X_Atom target, prop;
346
347 target = _ecore_x_selection_target_atom_get(target_str);
348
349 if (selection == ECORE_X_ATOM_SELECTION_PRIMARY)
350 prop = ECORE_X_ATOM_SELECTION_PROP_PRIMARY;
351 else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY)
352 prop = ECORE_X_ATOM_SELECTION_PROP_SECONDARY;
353 else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD)
354 prop = ECORE_X_ATOM_SELECTION_PROP_CLIPBOARD;
355 else
356 return;
357
358 XConvertSelection(_ecore_x_disp, selection, target, prop,
359 w, CurrentTime);
360} /* _ecore_x_selection_request */
361
362EAPI void
363ecore_x_selection_primary_request(Ecore_X_Window w,
364 const char *target)
365{
366 LOGFN(__FILE__, __LINE__, __FUNCTION__);
367 _ecore_x_selection_request(w, ECORE_X_ATOM_SELECTION_PRIMARY, target);
368} /* ecore_x_selection_primary_request */
369
370EAPI void
371ecore_x_selection_secondary_request(Ecore_X_Window w,
372 const char *target)
373{
374 LOGFN(__FILE__, __LINE__, __FUNCTION__);
375 _ecore_x_selection_request(w, ECORE_X_ATOM_SELECTION_SECONDARY, target);
376} /* ecore_x_selection_secondary_request */
377
378EAPI void
379ecore_x_selection_xdnd_request(Ecore_X_Window w,
380 const char *target)
381{
382 Ecore_X_Atom atom;
383 Ecore_X_DND_Target *_target;
384
385 LOGFN(__FILE__, __LINE__, __FUNCTION__);
386 _target = _ecore_x_dnd_target_get();
387 atom = _ecore_x_selection_target_atom_get(target);
388 XConvertSelection(_ecore_x_disp, ECORE_X_ATOM_SELECTION_XDND, atom,
389 ECORE_X_ATOM_SELECTION_PROP_XDND, w,
390 _target->time);
391} /* ecore_x_selection_xdnd_request */
392
393EAPI void
394ecore_x_selection_clipboard_request(Ecore_X_Window w,
395 const char *target)
396{
397 LOGFN(__FILE__, __LINE__, __FUNCTION__);
398 _ecore_x_selection_request(w, ECORE_X_ATOM_SELECTION_CLIPBOARD, target);
399} /* ecore_x_selection_clipboard_request */
400
401EAPI void
402ecore_x_selection_converter_atom_add(Ecore_X_Atom target,
403 Eina_Bool (*func)(char *target,
404 void *data,
405 int size,
406 void **data_ret,
407 int *size_ret,
408 Ecore_X_Atom *ttype,
409 int *tsize))
410{
411 Ecore_X_Selection_Converter *cnv;
412
413 LOGFN(__FILE__, __LINE__, __FUNCTION__);
414 cnv = converters;
415 if (converters)
416 {
417 while (1)
418 {
419 if (cnv->target == target)
420 {
421 cnv->convert = func;
422 return;
423 }
424
425 if (cnv->next)
426 cnv = cnv->next;
427 else
428 break;
429 }
430
431 cnv->next = calloc(1, sizeof(Ecore_X_Selection_Converter));
432 if (!cnv->next) return;
433 cnv = cnv->next;
434 }
435 else
436 {
437 converters = calloc(1, sizeof(Ecore_X_Selection_Converter));
438 if (!converters) return;
439 cnv = converters;
440 }
441
442 cnv->target = target;
443 cnv->convert = func;
444} /* ecore_x_selection_converter_atom_add */
445
446EAPI void
447ecore_x_selection_converter_add(char *target,
448 Eina_Bool (*func)(char *target,
449 void *data,
450 int size,
451 void **data_ret,
452 int *size_ret,
453 Ecore_X_Atom *,
454 int *))
455{
456 Ecore_X_Atom x_target;
457
458 if (!func || !target)
459 return;
460
461 LOGFN(__FILE__, __LINE__, __FUNCTION__);
462 x_target = _ecore_x_selection_target_atom_get(target);
463
464 ecore_x_selection_converter_atom_add(x_target, func);
465} /* ecore_x_selection_converter_add */
466
467EAPI void
468ecore_x_selection_converter_atom_del(Ecore_X_Atom target)
469{
470 Ecore_X_Selection_Converter *cnv, *prev_cnv;
471
472 LOGFN(__FILE__, __LINE__, __FUNCTION__);
473 prev_cnv = NULL;
474 cnv = converters;
475
476 while (cnv)
477 {
478 if (cnv->target == target)
479 {
480 if (prev_cnv)
481 prev_cnv->next = cnv->next;
482 else
483 {
484 converters = cnv->next; /* This was the first converter */
485 }
486
487 free(cnv);
488
489 return;
490 }
491
492 prev_cnv = cnv;
493 cnv = cnv->next;
494 }
495} /* ecore_x_selection_converter_atom_del */
496
497EAPI void
498ecore_x_selection_converter_del(char *target)
499{
500 Ecore_X_Atom x_target;
501
502 if (!target)
503 return;
504
505 LOGFN(__FILE__, __LINE__, __FUNCTION__);
506 x_target = _ecore_x_selection_target_atom_get(target);
507 ecore_x_selection_converter_atom_del(x_target);
508} /* ecore_x_selection_converter_del */
509
510EAPI Eina_Bool
511ecore_x_selection_notify_send(Ecore_X_Window requestor,
512 Ecore_X_Atom selection,
513 Ecore_X_Atom target,
514 Ecore_X_Atom property,
515 Ecore_X_Time tim)
516{
517 XEvent xev;
518 XSelectionEvent xnotify;
519
520 LOGFN(__FILE__, __LINE__, __FUNCTION__);
521 xnotify.type = SelectionNotify;
522 xnotify.display = _ecore_x_disp;
523 xnotify.requestor = requestor;
524 xnotify.selection = selection;
525 xnotify.target = target;
526 xnotify.property = property;
527 xnotify.time = tim;
528 xnotify.send_event = True;
529 xnotify.serial = 0;
530
531 xev.xselection = xnotify;
532 return (XSendEvent(_ecore_x_disp, requestor, False, 0, &xev) > 0) ? EINA_TRUE : EINA_FALSE;
533} /* ecore_x_selection_notify_send */
534
535/* Locate and run conversion callback for specified selection target */
536EAPI Eina_Bool
537ecore_x_selection_convert(Ecore_X_Atom selection,
538 Ecore_X_Atom target,
539 void **data_ret,
540 int *size,
541 Ecore_X_Atom *targtype,
542 int *typesize)
543{
544 Ecore_X_Selection_Intern *sel;
545 Ecore_X_Selection_Converter *cnv;
546 void *data;
547 char *tgt_str;
548
549 LOGFN(__FILE__, __LINE__, __FUNCTION__);
550 sel = _ecore_x_selection_get(selection);
551 tgt_str = _ecore_x_selection_target_get(target);
552
553 for (cnv = converters; cnv; cnv = cnv->next)
554 {
555 if (cnv->target == target)
556 {
557 int r;
558 r = cnv->convert(tgt_str, sel->data, sel->length, &data, size,
559 targtype, typesize);
560 free(tgt_str);
561 if (r)
562 {
563 *data_ret = data;
564 return r;
565 }
566 else
567 return EINA_FALSE;
568 }
569 }
570
571 /* ICCCM says "If the selection cannot be converted into a form based on the target (and parameters, if any), the owner should refuse the SelectionRequest as previously described." */
572 return EINA_FALSE;
573
574 /* Default, just return the data
575 *data_ret = malloc(sel->length);
576 memcpy(*data_ret, sel->data, sel->length);
577 free(tgt_str);
578 return 1;
579 */
580} /* ecore_x_selection_convert */
581
582/* TODO: We need to work out a mechanism for automatic conversion to any requested
583 * locale using Ecore_Txt functions */
584/* Converter for standard non-utf8 text targets */
585static Eina_Bool
586_ecore_x_selection_converter_text(char *target,
587 void *data,
588 int size,
589 void **data_ret,
590 int *size_ret,
591 Ecore_X_Atom *targprop __UNUSED__,
592 int *s __UNUSED__)
593{
594 XTextProperty text_prop;
595 char *mystr;
596 XICCEncodingStyle style;
597
598 if (!data || !size)
599 return EINA_FALSE;
600
601 LOGFN(__FILE__, __LINE__, __FUNCTION__);
602 if (!strcmp(target, ECORE_X_SELECTION_TARGET_TEXT))
603 style = XTextStyle;
604 else if (!strcmp(target, ECORE_X_SELECTION_TARGET_COMPOUND_TEXT))
605 style = XCompoundTextStyle;
606 else if (!strcmp(target, ECORE_X_SELECTION_TARGET_STRING))
607 style = XStringStyle;
608
609#ifdef X_HAVE_UTF8_STRING
610 else if (!strcmp(target, ECORE_X_SELECTION_TARGET_UTF8_STRING))
611 style = XUTF8StringStyle;
612#endif /* ifdef X_HAVE_UTF8_STRING */
613 else
614 return EINA_FALSE;
615
616 mystr = alloca(size + 1);
617 memcpy(mystr, data, size);
618 mystr[size] = '\0';
619
620#ifdef X_HAVE_UTF8_STRING
621 if (Xutf8TextListToTextProperty(_ecore_x_disp, &mystr, 1, style,
622 &text_prop) == Success)
623 {
624 int bufsize = strlen((char *)text_prop.value) + 1;
625 *data_ret = malloc(bufsize);
626 if (!*data_ret)
627 {
628 return EINA_FALSE;
629 }
630 memcpy(*data_ret, text_prop.value, bufsize);
631 *size_ret = bufsize;
632 XFree(text_prop.value);
633 return EINA_TRUE;
634 }
635
636#else /* ifdef X_HAVE_UTF8_STRING */
637 if (XmbTextListToTextProperty(_ecore_x_disp, &mystr, 1, style,
638 &text_prop) == Success)
639 {
640 int bufsize = strlen(text_prop.value) + 1;
641 *data_ret = malloc(bufsize);
642 if (!*data_ret) return EINA_FALSE;
643 memcpy(*data_ret, text_prop.value, bufsize);
644 *size_ret = bufsize;
645 XFree(text_prop.value);
646 return EINA_TRUE;
647 }
648
649#endif /* ifdef X_HAVE_UTF8_STRING */
650 else
651 {
652 return EINA_TRUE;
653 }
654} /* _ecore_x_selection_converter_text */
655
656EAPI void
657ecore_x_selection_parser_add(const char *target,
658 void *(*func)(const char *target, void *data,
659 int size,
660 int format))
661{
662 Ecore_X_Selection_Parser *prs;
663
664 if (!target)
665 return;
666
667 LOGFN(__FILE__, __LINE__, __FUNCTION__);
668 prs = parsers;
669 if (parsers)
670 {
671 while (prs->next)
672 {
673 if (!strcmp(prs->target, target))
674 {
675 prs->parse = func;
676 return;
677 }
678
679 prs = prs->next;
680 }
681
682 prs->next = calloc(1, sizeof(Ecore_X_Selection_Parser));
683 if (!prs->next) return;
684 prs = prs->next;
685 }
686 else
687 {
688 parsers = calloc(1, sizeof(Ecore_X_Selection_Parser));
689 if (!parsers) return;
690 prs = parsers;
691 }
692
693 prs->target = strdup(target);
694 prs->parse = func;
695} /* ecore_x_selection_parser_add */
696
697EAPI void
698ecore_x_selection_parser_del(const char *target)
699{
700 Ecore_X_Selection_Parser *prs, *prev_prs;
701
702 if (!target)
703 return;
704
705 LOGFN(__FILE__, __LINE__, __FUNCTION__);
706 prev_prs = NULL;
707 prs = parsers;
708
709 while (prs)
710 {
711 if (!strcmp(prs->target, target))
712 {
713 if (prev_prs)
714 prev_prs->next = prs->next;
715 else
716 {
717 parsers = prs->next; /* This was the first parser */
718 }
719
720 free(prs->target);
721 free(prs);
722
723 return;
724 }
725
726 prev_prs = prs;
727 prs = prs->next;
728 }
729} /* ecore_x_selection_parser_del */
730
731/**
732 * Change the owner and last-change time for the specified selection.
733 * @param win The owner of the specified atom.
734 * @param atom The selection atom
735 * @param time Specifies the time
736 * @since 1.1.0
737 */
738EAPI void
739ecore_x_selection_owner_set(Ecore_X_Window win,
740 Ecore_X_Atom atom,
741 Ecore_X_Time tim)
742{
743 XSetSelectionOwner(_ecore_x_disp, atom, win, tim);
744}
745
746/**
747 * Return the window that currently owns the specified selection.
748 *
749 * @param atom The specified selection atom.
750 *
751 * @return The window that currently owns the specified selection.
752 * @since 1.1.0
753 */
754EAPI Ecore_X_Window
755ecore_x_selection_owner_get(Ecore_X_Atom atom)
756{
757 return XGetSelectionOwner(_ecore_x_disp, atom);
758}
759
760/* Locate and run conversion callback for specified selection target */
761void *
762_ecore_x_selection_parse(const char *target,
763 void *data,
764 int size,
765 int format)
766{
767 Ecore_X_Selection_Parser *prs;
768 Ecore_X_Selection_Data *sel;
769
770 for (prs = parsers; prs; prs = prs->next)
771 {
772 if (!strcmp(prs->target, target))
773 {
774 sel = prs->parse(target, data, size, format);
775 if (sel) return sel;
776 }
777 }
778
779 /* Default, just return the data */
780 sel = calloc(1, sizeof(Ecore_X_Selection_Data));
781 if (!sel) return NULL;
782 sel->free = _ecore_x_selection_data_default_free;
783 sel->length = size;
784 sel->format = format;
785 sel->data = data;
786 return sel;
787} /* _ecore_x_selection_parse */
788
789static int
790_ecore_x_selection_data_default_free(void *data)
791{
792 Ecore_X_Selection_Data *sel;
793
794 sel = data;
795 free(sel->data);
796 free(sel);
797 return 1;
798} /* _ecore_x_selection_data_default_free */
799
800static void *
801_ecore_x_selection_parser_files(const char *target,
802 void *_data,
803 int size,
804 int format __UNUSED__)
805{
806 Ecore_X_Selection_Data_Files *sel;
807 char *t, *data = _data;
808 int i, is;
809 char *tmp;
810 char **t2;
811
812 if (strcmp(target, "text/uri-list") &&
813 strcmp(target, "_NETSCAPE_URL"))
814 return NULL;
815
816 sel = calloc(1, sizeof(Ecore_X_Selection_Data_Files));
817 if (!sel) return NULL;
818 ECORE_X_SELECTION_DATA(sel)->free = _ecore_x_selection_data_files_free;
819
820 if (data[size - 1])
821 {
822 /* Isn't nul terminated */
823 size++;
824 t = realloc(data, size);
825 if (!t)
826 {
827 free(sel);
828 return NULL;
829 }
830 data = t;
831 data[size - 1] = 0;
832 }
833
834 tmp = malloc(size);
835 if (!tmp)
836 {
837 free(sel);
838 return NULL;
839 }
840 i = 0;
841 is = 0;
842 while ((is < size) && (data[is]))
843 {
844 if ((i == 0) && (data[is] == '#'))
845 for (; ((data[is]) && (data[is] != '\n')); is++) ;
846 else
847 {
848 if ((data[is] != '\r') &&
849 (data[is] != '\n'))
850 tmp[i++] = data[is++];
851 else
852 {
853 while ((data[is] == '\r') || (data[is] == '\n')) is++;
854 tmp[i] = 0;
855 sel->num_files++;
856 t2 = realloc(sel->files, sel->num_files * sizeof(char *));
857 if (t2)
858 {
859 sel->files = t2;
860 sel->files[sel->num_files - 1] = strdup(tmp);
861 }
862 tmp[0] = 0;
863 i = 0;
864 }
865 }
866 }
867 if (i > 0)
868 {
869 tmp[i] = 0;
870 sel->num_files++;
871 t2 = realloc(sel->files, sel->num_files * sizeof(char *));
872 if (t2)
873 {
874 sel->files = t2;
875 sel->files[sel->num_files - 1] = strdup(tmp);
876 }
877 }
878
879 free(tmp);
880 free(data);
881
882 ECORE_X_SELECTION_DATA(sel)->content = ECORE_X_SELECTION_CONTENT_FILES;
883 ECORE_X_SELECTION_DATA(sel)->length = sel->num_files;
884
885 return ECORE_X_SELECTION_DATA(sel);
886} /* _ecore_x_selection_parser_files */
887
888static int
889_ecore_x_selection_data_files_free(void *data)
890{
891 Ecore_X_Selection_Data_Files *sel;
892 int i;
893
894 sel = data;
895 if (sel->files)
896 {
897 for (i = 0; i < sel->num_files; i++)
898 free(sel->files[i]);
899 free(sel->files);
900 }
901
902 free(sel);
903 return 0;
904} /* _ecore_x_selection_data_files_free */
905
906static void *
907_ecore_x_selection_parser_text(const char *target __UNUSED__,
908 void *_data,
909 int size,
910 int format __UNUSED__)
911{
912 Ecore_X_Selection_Data_Text *sel;
913 unsigned char *data = _data;
914 void *t;
915
916 sel = calloc(1, sizeof(Ecore_X_Selection_Data_Text));
917 if (!sel) return NULL;
918 if (data[size - 1])
919 {
920 /* Isn't nul terminated */
921 size++;
922 t = realloc(data, size);
923 if (!t)
924 {
925 free(sel);
926 return NULL;
927 }
928 data = t;
929 data[size - 1] = 0;
930 }
931
932 sel->text = (char *)data;
933 ECORE_X_SELECTION_DATA(sel)->length = size;
934 ECORE_X_SELECTION_DATA(sel)->content = ECORE_X_SELECTION_CONTENT_TEXT;
935 ECORE_X_SELECTION_DATA(sel)->data = data;
936 ECORE_X_SELECTION_DATA(sel)->free = _ecore_x_selection_data_text_free;
937 return sel;
938} /* _ecore_x_selection_parser_text */
939
940static int
941_ecore_x_selection_data_text_free(void *data)
942{
943 Ecore_X_Selection_Data_Text *sel;
944
945 sel = data;
946 free(sel->text);
947 free(sel);
948 return 1;
949} /* _ecore_x_selection_data_text_free */
950
951static void *
952_ecore_x_selection_parser_targets(const char *target __UNUSED__,
953 void *data,
954 int size,
955 int format __UNUSED__)
956{
957 Ecore_X_Selection_Data_Targets *sel;
958 unsigned long *targets;
959 int i;
960
961 sel = calloc(1, sizeof(Ecore_X_Selection_Data_Targets));
962 if (!sel) return NULL;
963 targets = (unsigned long *)data;
964
965 sel->num_targets = size - 2;
966 sel->targets = malloc((size - 2) * sizeof(char *));
967 if (!sel->targets)
968 {
969 free(sel);
970 return NULL;
971 }
972 for (i = 2; i < size; i++)
973 sel->targets[i - 2] = XGetAtomName(_ecore_x_disp, targets[i]);
974
975 ECORE_X_SELECTION_DATA(sel)->free = _ecore_x_selection_data_targets_free;
976 ECORE_X_SELECTION_DATA(sel)->content = ECORE_X_SELECTION_CONTENT_TARGETS;
977 ECORE_X_SELECTION_DATA(sel)->length = size;
978 ECORE_X_SELECTION_DATA(sel)->data = data;
979 return sel;
980} /* _ecore_x_selection_parser_targets */
981
982static int
983_ecore_x_selection_data_targets_free(void *data)
984{
985 Ecore_X_Selection_Data_Targets *sel;
986 int i;
987
988 sel = data;
989
990 if (sel->targets)
991 {
992 for (i = 0; i < sel->num_targets; i++)
993 XFree(sel->targets[i]);
994 free(sel->targets);
995 }
996
997 free(ECORE_X_SELECTION_DATA(sel)->data);
998 free(sel);
999 return 1;
1000} /* _ecore_x_selection_data_targets_free */
1001
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_sync.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_sync.c
new file mode 100644
index 0000000..e49fede
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_sync.c
@@ -0,0 +1,159 @@
1/*
2 * XSync code
3 */
4
5#ifdef HAVE_CONFIG_H
6# include <config.h>
7#endif /* ifdef HAVE_CONFIG_H */
8
9#include "Ecore.h"
10#include "ecore_x_private.h"
11#include "Ecore_X.h"
12#include "Ecore_X_Atoms.h"
13
14EAPI Ecore_X_Sync_Alarm
15ecore_x_sync_alarm_new(Ecore_X_Sync_Counter counter)
16{
17 Ecore_X_Sync_Alarm alarm;
18 XSyncAlarmAttributes values;
19 XSyncValue init;
20
21 LOGFN(__FILE__, __LINE__, __FUNCTION__);
22 XSyncIntToValue(&init, 0);
23 XSyncSetCounter(_ecore_x_disp, counter, init);
24
25 values.trigger.counter = counter;
26 values.trigger.value_type = XSyncAbsolute;
27 XSyncIntToValue(&values.trigger.wait_value, 1);
28 values.trigger.test_type = XSyncPositiveComparison;
29
30 XSyncIntToValue(&values.delta, 1);
31
32 values.events = True;
33
34 alarm = XSyncCreateAlarm(_ecore_x_disp,
35 XSyncCACounter |
36 XSyncCAValueType |
37 XSyncCAValue |
38 XSyncCATestType |
39 XSyncCADelta |
40 XSyncCAEvents,
41 &values);
42
43 ecore_x_sync();
44 return alarm;
45} /* ecore_x_sync_alarm_new */
46
47EAPI Eina_Bool
48ecore_x_sync_alarm_free(Ecore_X_Sync_Alarm alarm)
49{
50 LOGFN(__FILE__, __LINE__, __FUNCTION__);
51 return XSyncDestroyAlarm(_ecore_x_disp, alarm);
52} /* ecore_x_sync_alarm_free */
53
54EAPI Eina_Bool
55ecore_x_sync_counter_query(Ecore_X_Sync_Counter counter,
56 unsigned int *val)
57{
58 XSyncValue value;
59
60 LOGFN(__FILE__, __LINE__, __FUNCTION__);
61 if (XSyncQueryCounter(_ecore_x_disp, counter, &value))
62 {
63 *val = (unsigned int)XSyncValueLow32(value);
64 return EINA_TRUE;
65 }
66
67 return EINA_FALSE;
68} /* ecore_x_sync_counter_query */
69
70EAPI Ecore_X_Sync_Counter
71ecore_x_sync_counter_new(int val)
72{
73 XSyncCounter counter;
74 XSyncValue v;
75
76 LOGFN(__FILE__, __LINE__, __FUNCTION__);
77 XSyncIntToValue(&v, val);
78 counter = XSyncCreateCounter(_ecore_x_disp, v);
79 return counter;
80} /* ecore_x_sync_counter_new */
81
82EAPI void
83ecore_x_sync_counter_free(Ecore_X_Sync_Counter counter)
84{
85 LOGFN(__FILE__, __LINE__, __FUNCTION__);
86 XSyncDestroyCounter(_ecore_x_disp, counter);
87} /* ecore_x_sync_counter_free */
88
89EAPI void
90ecore_x_sync_counter_inc(Ecore_X_Sync_Counter counter,
91 int by)
92{
93 XSyncValue v;
94
95 LOGFN(__FILE__, __LINE__, __FUNCTION__);
96 XSyncIntToValue(&v, by);
97 XSyncChangeCounter(_ecore_x_disp, counter, v);
98} /* ecore_x_sync_counter_inc */
99
100EAPI void
101ecore_x_sync_counter_val_wait(Ecore_X_Sync_Counter counter,
102 int val)
103{
104 XSyncWaitCondition cond;
105 XSyncValue v, v2;
106
107 LOGFN(__FILE__, __LINE__, __FUNCTION__);
108 XSyncQueryCounter(_ecore_x_disp, counter, &v);
109 XSyncIntToValue(&v, val);
110 XSyncIntToValue(&v2, val + 1);
111 cond.trigger.counter = counter;
112 cond.trigger.value_type = XSyncAbsolute;
113 cond.trigger.wait_value = v;
114 cond.trigger.test_type = XSyncPositiveComparison;
115 cond.event_threshold = v2;
116 XSyncAwait(_ecore_x_disp, &cond, 1);
117// XSync(_ecore_x_disp, False); // dont need this
118} /* ecore_x_sync_counter_val_wait */
119
120EAPI void
121ecore_x_sync_counter_set(Ecore_X_Sync_Counter counter,
122 int val)
123{
124 XSyncValue v;
125
126 LOGFN(__FILE__, __LINE__, __FUNCTION__);
127 XSyncIntToValue(&v, val);
128 XSyncSetCounter(_ecore_x_disp, counter, v);
129}
130
131EAPI void
132ecore_x_sync_counter_2_set(Ecore_X_Sync_Counter counter,
133 int val_hi,
134 unsigned int val_lo)
135{
136 XSyncValue v;
137
138 LOGFN(__FILE__, __LINE__, __FUNCTION__);
139 XSyncIntsToValue(&v, val_lo, val_hi);
140 XSyncSetCounter(_ecore_x_disp, counter, v);
141}
142
143EAPI Eina_Bool
144ecore_x_sync_counter_2_query(Ecore_X_Sync_Counter counter,
145 int *val_hi,
146 unsigned int *val_lo)
147{
148 XSyncValue value;
149
150 LOGFN(__FILE__, __LINE__, __FUNCTION__);
151 if (XSyncQueryCounter(_ecore_x_disp, counter, &value))
152 {
153 *val_lo = (unsigned int)XSyncValueLow32(value);
154 *val_hi = (int)XSyncValueHigh32(value);
155 return EINA_TRUE;
156 }
157 return EINA_FALSE;
158}
159
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_test.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_test.c
new file mode 100644
index 0000000..c4576f9
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_test.c
@@ -0,0 +1,155 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdlib.h>
6
7#ifdef ECORE_XTEST
8# include <X11/extensions/XTest.h>
9#endif /* ifdef ECORE_XTEST */
10
11#include "ecore_x_private.h"
12#include "Ecore_X.h"
13#include <string.h>
14
15EAPI Eina_Bool
16#ifdef ECORE_XTEST
17ecore_x_test_fake_key_down(const char *key)
18#else
19ecore_x_test_fake_key_down(const char *key __UNUSED__)
20#endif
21{
22#ifdef ECORE_XTEST
23 KeyCode keycode = 0;
24 KeySym keysym;
25
26 LOGFN(__FILE__, __LINE__, __FUNCTION__);
27 if (!strncmp(key, "Keycode-", 8))
28 keycode = atoi(key + 8);
29 else
30 {
31 keysym = XStringToKeysym(key);
32 if (keysym == NoSymbol)
33 return EINA_FALSE;
34
35 keycode = XKeysymToKeycode(_ecore_x_disp, keysym);
36 }
37
38 if (keycode == 0)
39 return EINA_FALSE;
40
41 return XTestFakeKeyEvent(_ecore_x_disp, keycode, 1, 0) ? EINA_TRUE : EINA_FALSE;
42#else /* ifdef ECORE_XTEST */
43 return EINA_FALSE;
44#endif /* ifdef ECORE_XTEST */
45} /* ecore_x_test_fake_key_down */
46
47EAPI Eina_Bool
48#ifdef ECORE_XTEST
49ecore_x_test_fake_key_up(const char *key)
50#else
51ecore_x_test_fake_key_up(const char *key __UNUSED__)
52#endif
53{
54#ifdef ECORE_XTEST
55 KeyCode keycode = 0;
56 KeySym keysym;
57
58 LOGFN(__FILE__, __LINE__, __FUNCTION__);
59 if (!strncmp(key, "Keycode-", 8))
60 keycode = atoi(key + 8);
61 else
62 {
63 keysym = XStringToKeysym(key);
64 if (keysym == NoSymbol)
65 return EINA_FALSE;
66
67 keycode = XKeysymToKeycode(_ecore_x_disp, keysym);
68 }
69
70 if (keycode == 0)
71 return EINA_FALSE;
72
73 return XTestFakeKeyEvent(_ecore_x_disp, keycode, 0, 0) ? EINA_TRUE : EINA_FALSE;
74#else /* ifdef ECORE_XTEST */
75 return EINA_FALSE;
76#endif /* ifdef ECORE_XTEST */
77} /* ecore_x_test_fake_key_up */
78
79EAPI Eina_Bool
80#ifdef ECORE_XTEST
81ecore_x_test_fake_key_press(const char *key)
82#else
83ecore_x_test_fake_key_press(const char *key __UNUSED__)
84#endif
85{
86#ifdef ECORE_XTEST
87 KeyCode keycode = 0;
88 KeySym keysym = 0;
89 int shift = 0;
90
91 LOGFN(__FILE__, __LINE__, __FUNCTION__);
92 if (!strncmp(key, "Keycode-", 8))
93 keycode = atoi(key + 8);
94 else
95 {
96 keysym = XStringToKeysym(key);
97 if (keysym == NoSymbol)
98 return EINA_FALSE;
99
100 keycode = XKeysymToKeycode(_ecore_x_disp, keysym);
101 if (XKeycodeToKeysym(_ecore_x_disp, keycode, 0) != keysym)
102 {
103 if (XKeycodeToKeysym(_ecore_x_disp, keycode, 1) == keysym)
104 shift = 1;
105 else
106 keycode = 0;
107 }
108 else
109 shift = 0;
110 }
111
112 if (keycode == 0)
113 {
114 static int mod = 0;
115 KeySym *keysyms;
116 int keycode_min, keycode_max, keycode_num;
117 int i;
118
119 XDisplayKeycodes(_ecore_x_disp, &keycode_min, &keycode_max);
120 keysyms = XGetKeyboardMapping(_ecore_x_disp, keycode_min,
121 keycode_max - keycode_min + 1,
122 &keycode_num);
123 mod = (mod + 1) & 0x7;
124 i = (keycode_max - keycode_min - mod - 1) * keycode_num;
125
126 keysyms[i] = keysym;
127 XChangeKeyboardMapping(_ecore_x_disp, keycode_min, keycode_num,
128 keysyms, (keycode_max - keycode_min));
129 XFree(keysyms);
130 XSync(_ecore_x_disp, False);
131 keycode = keycode_max - mod - 1;
132 }
133
134 if (shift)
135 XTestFakeKeyEvent(_ecore_x_disp,
136 XKeysymToKeycode(_ecore_x_disp, XK_Shift_L), 1, 0);
137
138 XTestFakeKeyEvent(_ecore_x_disp, keycode, 1, 0);
139 XTestFakeKeyEvent(_ecore_x_disp, keycode, 0, 0);
140 if (shift)
141 XTestFakeKeyEvent(_ecore_x_disp,
142 XKeysymToKeycode(_ecore_x_disp, XK_Shift_L), 0, 0);
143
144 return EINA_TRUE;
145#else /* ifdef ECORE_XTEST */
146 return EINA_FALSE;
147#endif /* ifdef ECORE_XTEST */
148} /* ecore_x_test_fake_key_press */
149
150EAPI const char *
151ecore_x_keysym_string_get(int keysym)
152{
153 return XKeysymToString(keysym);
154} /* ecore_x_keysym_string_get */
155
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_vsync.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_vsync.c
new file mode 100644
index 0000000..f054298
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_vsync.c
@@ -0,0 +1,351 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include "Ecore.h"
6#include "ecore_x_private.h"
7#include "Ecore_X.h"
8
9#include <string.h>
10#include <stdlib.h>
11#include <string.h>
12#include <unistd.h>
13#include <dlfcn.h>
14#include <sys/types.h>
15#include <sys/stat.h>
16#include <fcntl.h>
17
18#define ECORE_X_VSYNC_DRI2 1
19
20#ifdef ECORE_X_VSYNC_DRI2
21// relevant header bits of dri/drm inlined here to avoid needing external
22// headers to build
23/// drm
24typedef unsigned int drm_magic_t;
25
26typedef enum
27{
28 DRM_VBLANK_ABSOLUTE = 0x00000000,
29 DRM_VBLANK_RELATIVE = 0x00000001,
30 DRM_VBLANK_EVENT = 0x04000000,
31 DRM_VBLANK_FLIP = 0x08000000,
32 DRM_VBLANK_NEXTONMISS = 0x10000000,
33 DRM_VBLANK_SECONDARY = 0x20000000,
34 DRM_VBLANK_SIGNAL = 0x40000000
35}
36drmVBlankSeqType;
37
38typedef struct _drmVBlankReq
39{
40 drmVBlankSeqType type;
41 unsigned int sequence;
42 unsigned long signal;
43} drmVBlankReq;
44
45typedef struct _drmVBlankReply
46{
47 drmVBlankSeqType type;
48 unsigned int sequence;
49 long tval_sec;
50 long tval_usec;
51} drmVBlankReply;
52
53typedef union _drmVBlank
54{
55 drmVBlankReq request;
56 drmVBlankReply reply;
57} drmVBlank;
58
59#define DRM_EVENT_CONTEXT_VERSION 2
60
61typedef struct _drmEventContext
62{
63 int version;
64 void (*vblank_handler)(int fd,
65 unsigned int sequence,
66 unsigned int tv_sec,
67 unsigned int tv_usec,
68 void *user_data);
69 void (*page_flip_handler)(int fd,
70 unsigned int sequence,
71 unsigned int tv_sec,
72 unsigned int tv_usec,
73 void *user_data);
74} drmEventContext;
75
76static int (*sym_drmClose)(int fd) = NULL;
77static int (*sym_drmGetMagic)(int fd,
78 drm_magic_t *magic) = NULL;
79static int (*sym_drmWaitVBlank)(int fd,
80 drmVBlank *vbl) = NULL;
81static int (*sym_drmHandleEvent)(int fd,
82 drmEventContext *evctx) = NULL;
83
84//// dri
85
86static Bool (*sym_DRI2QueryExtension)(Display *display,
87 int *eventBase,
88 int *errorBase) = NULL;
89static Bool (*sym_DRI2QueryVersion)(Display *display,
90 int *major,
91 int *minor) = NULL;
92static Bool (*sym_DRI2Connect)(Display *display,
93 XID window,
94 char **driverName,
95 char **deviceName) = NULL;
96static Bool (*sym_DRI2Authenticate)(Display *display,
97 XID window,
98 drm_magic_t magic) = NULL;
99
100//// dri/drm data needed
101static int dri2_event = 0;
102static int dri2_error = 0;
103static int dri2_major = 0;
104static int dri2_minor = 0;
105static char *device_name = 0;
106static char *driver_name = 0;
107static drm_magic_t drm_magic;
108
109static int drm_fd = -1;
110static int drm_event_is_busy = 0;
111static int drm_animators_interval = 1;
112static drmEventContext drm_evctx;
113static Ecore_Fd_Handler *dri_drm_fdh = NULL;
114
115static void *dri_lib = NULL;
116static void *drm_lib = NULL;
117
118static Window dri_drm_vsync_root = 0;
119
120static void
121_dri_drm_tick_schedule(void)
122{
123 drmVBlank vbl;
124
125 vbl.request.type = DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT;
126 vbl.request.sequence = drm_animators_interval;
127 vbl.request.signal = 0;
128 sym_drmWaitVBlank(drm_fd, &vbl);
129}
130
131static void
132_dri_drm_tick_begin(void *data __UNUSED__)
133{
134 drm_event_is_busy = 1;
135 _dri_drm_tick_schedule();
136}
137
138static void
139_dri_drm_tick_end(void *data __UNUSED__)
140{
141 drm_event_is_busy = 0;
142}
143
144static void
145_dri_drm_vblank_handler(int fd __UNUSED__,
146 unsigned int frame __UNUSED__,
147 unsigned int sec __UNUSED__,
148 unsigned int usec __UNUSED__,
149 void *data __UNUSED__)
150{
151 ecore_animator_custom_tick();
152 if (drm_event_is_busy) _dri_drm_tick_schedule();
153}
154
155static Eina_Bool
156_dri_drm_cb(void *data __UNUSED__,
157 Ecore_Fd_Handler *fd_handler __UNUSED__)
158{
159 sym_drmHandleEvent(drm_fd, &drm_evctx);
160 return ECORE_CALLBACK_RENEW;
161}
162
163// yes. most evil. we dlopen libdrm and libGL etc. to manually find smbols
164// so we can be as compatible as possible given the whole mess of the
165// gl/dri/drm etc. world. and handle graceful failure at runtime not
166// compile time
167static int
168_dri_drm_link(void)
169{
170 const char *drm_libs[] =
171 {
172 "libdrm.so.2",
173 "libdrm.so.1",
174 "libdrm.so.0",
175 "libdrm.so",
176 NULL,
177 };
178 const char *dri_libs[] =
179 {
180 "libdri2.so.2",
181 "libdri2.so.1",
182 "libdri2.so.0",
183 "libdri2.so",
184 "libGL.so.4",
185 "libGL.so.3",
186 "libGL.so.2",
187 "libGL.so.1",
188 "libGL.so.0",
189 "libGL.so",
190 NULL,
191 };
192 int i, fail;
193#define SYM(lib, xx) \
194 do { \
195 sym_ ## xx = dlsym(lib, #xx); \
196 if (!(sym_ ## xx)) { \
197 fprintf(stderr, "%s\n", dlerror()); \
198 fail = 1; \
199 } \
200 } while (0)
201
202 if (dri_lib) return 1;
203 for (i = 0; drm_libs[i]; i++)
204 {
205 drm_lib = dlopen(drm_libs[i], RTLD_LOCAL | RTLD_LAZY);
206 if (drm_lib)
207 {
208 fail = 0;
209 SYM(drm_lib, drmClose);
210 SYM(drm_lib, drmWaitVBlank);
211 SYM(drm_lib, drmHandleEvent);
212 if (fail)
213 {
214 dlclose(drm_lib);
215 drm_lib = NULL;
216 }
217 else break;
218 }
219 }
220 if (!drm_lib) return 0;
221 for (i = 0; dri_libs[i]; i++)
222 {
223 dri_lib = dlopen(dri_libs[i], RTLD_LOCAL | RTLD_LAZY);
224 if (dri_lib)
225 {
226 fail = 0;
227 SYM(dri_lib, DRI2QueryExtension);
228 SYM(dri_lib, DRI2QueryVersion);
229 SYM(dri_lib, DRI2Connect);
230 SYM(dri_lib, DRI2Authenticate);
231 if (fail)
232 {
233 dlclose(dri_lib);
234 dri_lib = NULL;
235 }
236 else break;
237 }
238 }
239 if (!dri_lib)
240 {
241 dlclose(drm_lib);
242 drm_lib = NULL;
243 return 0;
244 }
245 return 1;
246}
247
248static int
249_dri_drm_init(void)
250{
251 if (!sym_DRI2QueryExtension(_ecore_x_disp, &dri2_event, &dri2_error))
252 return 0;
253 if (!sym_DRI2QueryVersion(_ecore_x_disp, &dri2_major, &dri2_minor))
254 return 0;
255 if (dri2_major < 2)
256 return 0;
257 if (!sym_DRI2Connect(_ecore_x_disp, dri_drm_vsync_root, &driver_name, &device_name))
258 return 0;
259 drm_fd = open(device_name, O_RDWR);
260 if (drm_fd < 0)
261 return 0;
262 sym_drmGetMagic(drm_fd, &drm_magic);
263 if (!sym_DRI2Authenticate(_ecore_x_disp, dri_drm_vsync_root, drm_magic))
264 {
265 close(drm_fd);
266 drm_fd = -1;
267 return 0;
268 }
269 memset(&drm_evctx, 0, sizeof(drm_evctx));
270 drm_evctx.version = DRM_EVENT_CONTEXT_VERSION;
271 drm_evctx.vblank_handler = _dri_drm_vblank_handler;
272 drm_evctx.page_flip_handler = NULL;
273
274 dri_drm_fdh = ecore_main_fd_handler_add(drm_fd, ECORE_FD_READ,
275 _dri_drm_cb, NULL, NULL, NULL);
276 if (!dri_drm_fdh)
277 {
278 close(drm_fd);
279 drm_fd = -1;
280 return 0;
281 }
282 return 1;
283}
284
285static void
286_dri_drm_shutdown(void)
287{
288 if (drm_fd >= 0)
289 {
290 close(drm_fd);
291 drm_fd = -1;
292 }
293 if (dri_drm_fdh)
294 {
295 ecore_main_fd_handler_del(dri_drm_fdh);
296 dri_drm_fdh = NULL;
297 }
298}
299
300#endif
301
302EAPI Eina_Bool
303ecore_x_vsync_animator_tick_source_set(Ecore_X_Window win)
304{
305#ifdef ECORE_X_VSYNC_DRI2
306 Ecore_X_Window root;
307
308 root = ecore_x_window_root_get(win);
309 if (root != dri_drm_vsync_root)
310 {
311 dri_drm_vsync_root = root;
312 if (dri_drm_vsync_root)
313 {
314 if (!_dri_drm_link())
315 {
316 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
317 return EINA_FALSE;
318 }
319 _dri_drm_shutdown();
320 if (!_dri_drm_init())
321 {
322 dri_drm_vsync_root = 0;
323 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
324 return EINA_FALSE;
325 }
326 ecore_animator_custom_source_tick_begin_callback_set
327 (_dri_drm_tick_begin, NULL);
328 ecore_animator_custom_source_tick_end_callback_set
329 (_dri_drm_tick_end, NULL);
330 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM);
331 }
332 else
333 {
334 if (drm_fd >= 0)
335 {
336 _dri_drm_shutdown();
337 ecore_animator_custom_source_tick_begin_callback_set
338 (NULL, NULL);
339 ecore_animator_custom_source_tick_end_callback_set
340 (NULL, NULL);
341 ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER);
342 }
343 }
344 }
345 return EINA_TRUE;
346#else
347 return EINA_FALSE;
348 win = 0;
349#endif
350}
351
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_window.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_window.c
new file mode 100644
index 0000000..76670d3
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_window.c
@@ -0,0 +1,1723 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdlib.h>
6#include <sys/types.h>
7#include <unistd.h>
8
9#include "Ecore.h"
10#include "ecore_x_private.h"
11#include "Ecore_X.h"
12#include "Ecore_X_Atoms.h"
13
14static int ignore_num = 0;
15static Ecore_X_Window *ignore_list = NULL;
16
17/**
18 * @defgroup Ecore_X_Window_Create_Group X Window Creation Functions
19 *
20 * Functions that can be used to create an X window.
21 */
22
23/**
24 * Creates a new window.
25 * @param parent The parent window to use. If @p parent is @c 0, the root
26 * window of the default display is used.
27 * @param x X position.
28 * @param y Y position.
29 * @param w Width.
30 * @param h Height.
31 * @return The new window handle.
32 * @ingroup Ecore_X_Window_Create_Group
33 */
34EAPI Ecore_X_Window
35ecore_x_window_new(Ecore_X_Window parent,
36 int x,
37 int y,
38 int w,
39 int h)
40{
41 Window win;
42 XSetWindowAttributes attr;
43
44 LOGFN(__FILE__, __LINE__, __FUNCTION__);
45 if (parent == 0)
46 parent = DefaultRootWindow(_ecore_x_disp);
47
48 attr.backing_store = NotUseful;
49 attr.override_redirect = False;
50 attr.border_pixel = 0;
51 attr.background_pixmap = None;
52 attr.bit_gravity = NorthWestGravity;
53 attr.win_gravity = NorthWestGravity;
54 attr.save_under = False;
55 attr.do_not_propagate_mask = NoEventMask;
56 attr.event_mask = KeyPressMask |
57 KeyReleaseMask |
58 ButtonPressMask |
59 ButtonReleaseMask |
60 EnterWindowMask |
61 LeaveWindowMask |
62 PointerMotionMask |
63 ExposureMask |
64 VisibilityChangeMask |
65 StructureNotifyMask |
66 FocusChangeMask |
67 PropertyChangeMask |
68 ColormapChangeMask;
69 win = XCreateWindow(_ecore_x_disp, parent,
70 x, y, w, h, 0,
71 CopyFromParent, /*DefaultDepth(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
72 InputOutput,
73 CopyFromParent, /*DefaultVisual(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
74 CWBackingStore |
75 CWOverrideRedirect |
76/* CWColormap | */
77 CWBorderPixel |
78 CWBackPixmap |
79 CWSaveUnder |
80 CWDontPropagate |
81 CWEventMask |
82 CWBitGravity |
83 CWWinGravity,
84 &attr);
85
86 if (parent == DefaultRootWindow(_ecore_x_disp))
87 ecore_x_window_defaults_set(win);
88
89 return win;
90} /* ecore_x_window_new */
91
92/**
93 * Creates a window with the override redirect attribute set to @c True.
94 * @param parent The parent window to use. If @p parent is @c 0, the root
95 * window of the default display is used.
96 * @param x X position.
97 * @param y Y position.
98 * @param w Width.
99 * @param h Height.
100 * @return The new window handle.
101 * @ingroup Ecore_X_Window_Create_Group
102 */
103EAPI Ecore_X_Window
104ecore_x_window_override_new(Ecore_X_Window parent,
105 int x,
106 int y,
107 int w,
108 int h)
109{
110 Window win;
111 XSetWindowAttributes attr;
112
113 LOGFN(__FILE__, __LINE__, __FUNCTION__);
114 if (parent == 0)
115 parent = DefaultRootWindow(_ecore_x_disp);
116
117 attr.backing_store = NotUseful;
118 attr.override_redirect = True;
119 attr.border_pixel = 0;
120 attr.background_pixmap = None;
121 attr.bit_gravity = NorthWestGravity;
122 attr.win_gravity = NorthWestGravity;
123 attr.save_under = False;
124 attr.do_not_propagate_mask = NoEventMask;
125 attr.event_mask = KeyPressMask |
126 KeyReleaseMask |
127 ButtonPressMask |
128 ButtonReleaseMask |
129 EnterWindowMask |
130 LeaveWindowMask |
131 PointerMotionMask |
132 ExposureMask |
133 VisibilityChangeMask |
134 StructureNotifyMask |
135 FocusChangeMask |
136 PropertyChangeMask |
137 ColormapChangeMask;
138 win = XCreateWindow(_ecore_x_disp, parent,
139 x, y, w, h, 0,
140 CopyFromParent, /*DefaultDepth(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
141 InputOutput,
142 CopyFromParent, /*DefaultVisual(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
143 CWBackingStore |
144 CWOverrideRedirect |
145/* CWColormap | */
146 CWBorderPixel |
147 CWBackPixmap |
148 CWSaveUnder |
149 CWDontPropagate |
150 CWEventMask |
151 CWBitGravity |
152 CWWinGravity,
153 &attr);
154 return win;
155} /* ecore_x_window_override_new */
156
157/**
158 * Creates a new input window.
159 * @param parent The parent window to use. If @p parent is @c 0, the root
160 * window of the default display is used.
161 * @param x X position.
162 * @param y Y position.
163 * @param w Width.
164 * @param h Height.
165 * @return The new window.
166 * @ingroup Ecore_X_Window_Create_Group
167 */
168EAPI Ecore_X_Window
169ecore_x_window_input_new(Ecore_X_Window parent,
170 int x,
171 int y,
172 int w,
173 int h)
174{
175 Window win;
176 XSetWindowAttributes attr;
177
178 LOGFN(__FILE__, __LINE__, __FUNCTION__);
179 if (parent == 0)
180 parent = DefaultRootWindow(_ecore_x_disp);
181
182 attr.override_redirect = True;
183 attr.do_not_propagate_mask = NoEventMask;
184 attr.event_mask = KeyPressMask |
185 KeyReleaseMask |
186 ButtonPressMask |
187 ButtonReleaseMask |
188 EnterWindowMask |
189 LeaveWindowMask |
190 PointerMotionMask |
191 ExposureMask |
192 VisibilityChangeMask |
193 StructureNotifyMask |
194 FocusChangeMask |
195 PropertyChangeMask |
196 ColormapChangeMask;
197 win = XCreateWindow(_ecore_x_disp, parent,
198 x, y, w, h, 0,
199 CopyFromParent,
200 InputOnly,
201 CopyFromParent, /*DefaultVisual(_ecore_x_disp, DefaultScreen(_ecore_x_disp)),*/
202 CWOverrideRedirect |
203 CWDontPropagate |
204 CWEventMask,
205 &attr);
206
207 if (parent == DefaultRootWindow(_ecore_x_disp))
208 {
209 }
210
211 return win;
212} /* ecore_x_window_input_new */
213
214/**
215 * @defgroup Ecore_X_Window_Properties_Group X Window Property Functions
216 *
217 * Functions that set window properties.
218 */
219
220/**
221 * Sets the default properties for the given window.
222 *
223 * The default properties set for the window are @c WM_CLIENT_MACHINE and
224 * @c _NET_WM_PID.
225 *
226 * @param win The given window.
227 * @ingroup Ecore_X_Window_Properties_Groups
228 */
229EAPI void
230ecore_x_window_defaults_set(Ecore_X_Window win)
231{
232 long pid;
233 char buf[MAXHOSTNAMELEN];
234 char *hostname[1];
235 int argc;
236 char **argv;
237 XTextProperty xprop;
238
239 LOGFN(__FILE__, __LINE__, __FUNCTION__);
240 /*
241 * Set WM_CLIENT_MACHINE.
242 */
243 gethostname(buf, MAXHOSTNAMELEN);
244 buf[MAXHOSTNAMELEN - 1] = '\0';
245 hostname[0] = buf;
246 /* The ecore function uses UTF8 which Xlib may not like (especially
247 * with older clients) */
248 /* ecore_x_window_prop_string_set(win, ECORE_X_ATOM_WM_CLIENT_MACHINE,
249 (char *)buf); */
250 if (XStringListToTextProperty(hostname, 1, &xprop))
251 {
252 XSetWMClientMachine(_ecore_x_disp, win, &xprop);
253 XFree(xprop.value);
254 }
255
256 /*
257 * Set _NET_WM_PID
258 */
259 pid = getpid();
260 ecore_x_netwm_pid_set(win, pid);
261
262 ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NORMAL);
263
264 ecore_app_args_get(&argc, &argv);
265 ecore_x_icccm_command_set(win, argc, argv);
266} /* ecore_x_window_defaults_set */
267
268EAPI void
269ecore_x_window_configure(Ecore_X_Window win,
270 Ecore_X_Window_Configure_Mask mask,
271 int x,
272 int y,
273 int w,
274 int h,
275 int border_width,
276 Ecore_X_Window sibling,
277 int stack_mode)
278{
279 XWindowChanges xwc;
280
281 if (!win)
282 return;
283
284 LOGFN(__FILE__, __LINE__, __FUNCTION__);
285
286 xwc.x = x;
287 xwc.y = y;
288 xwc.width = w;
289 xwc.height = h;
290 xwc.border_width = border_width;
291 xwc.sibling = sibling;
292 xwc.stack_mode = stack_mode;
293
294 XConfigureWindow(_ecore_x_disp, win, mask, &xwc);
295} /* ecore_x_window_configure */
296
297/**
298 * @defgroup Ecore_X_Window_Destroy_Group X Window Destroy Functions
299 *
300 * Functions to destroy X windows.
301 */
302
303/**
304 * Deletes the given window.
305 * @param win The given window.
306 * @ingroup Ecore_X_Window_Destroy_Group
307 */
308EAPI void
309ecore_x_window_free(Ecore_X_Window win)
310{
311 /* sorry sir, deleting the root window doesn't sound like
312 * a smart idea.
313 */
314 LOGFN(__FILE__, __LINE__, __FUNCTION__);
315 if (win)
316 XDestroyWindow(_ecore_x_disp, win);
317} /* ecore_x_window_free */
318
319/**
320 * Set if a window should be ignored.
321 * @param win The given window.
322 * @param ignore if to ignore
323 */
324EAPI void
325ecore_x_window_ignore_set(Ecore_X_Window win,
326 int ignore)
327{
328 int i, j, cnt;
329 Ecore_X_Window *t;
330
331 LOGFN(__FILE__, __LINE__, __FUNCTION__);
332 if (ignore)
333 {
334 if (ignore_list)
335 {
336 for (i = 0; i < ignore_num; i++)
337 {
338 if (win == ignore_list[i])
339 return;
340 }
341 t = realloc(ignore_list, (ignore_num + 1) * sizeof(Ecore_X_Window));
342 if (!t) return;
343 ignore_list = t;
344 ignore_list[ignore_num++] = win;
345 }
346 else
347 {
348 ignore_num = 0;
349 ignore_list = malloc(sizeof(Ecore_X_Window));
350 if (ignore_list)
351 ignore_list[ignore_num++] = win;
352 }
353 }
354 else
355 {
356 if (!ignore_list)
357 return;
358
359 for (cnt = ignore_num, i = 0, j = 0; i < cnt; i++)
360 {
361 if (win != ignore_list[i])
362 ignore_list[j++] = ignore_list[i];
363 else
364 ignore_num--;
365 }
366
367 if (ignore_num <= 0)
368 {
369 free(ignore_list);
370 ignore_list = NULL;
371 return;
372 }
373 t = realloc(ignore_list, ignore_num * sizeof(Ecore_X_Window));
374 if (t) ignore_list = t;
375 }
376} /* ecore_x_window_ignore_set */
377
378/**
379 * Get the ignore list
380 * @param num number of windows in the list
381 * @return list of windows to ignore
382 */
383EAPI Ecore_X_Window *
384ecore_x_window_ignore_list(int *num)
385{
386 if (num)
387 *num = ignore_num;
388
389 return ignore_list;
390} /* ecore_x_window_ignore_list */
391
392/**
393 * Sends a delete request to the given window.
394 * @param win The given window.
395 * @ingroup Ecore_X_Window_Destroy_Group
396 */
397EAPI void
398ecore_x_window_delete_request_send(Ecore_X_Window win)
399{
400 XEvent xev;
401
402 /* sorry sir, deleting the root window doesn't sound like
403 * a smart idea.
404 */
405 if (!win)
406 return;
407
408 LOGFN(__FILE__, __LINE__, __FUNCTION__);
409 xev.xclient.type = ClientMessage;
410 xev.xclient.display = _ecore_x_disp;
411 xev.xclient.window = win;
412 xev.xclient.message_type = ECORE_X_ATOM_WM_PROTOCOLS;
413 xev.xclient.format = 32;
414 xev.xclient.data.l[0] = ECORE_X_ATOM_WM_DELETE_WINDOW;
415 xev.xclient.data.l[1] = CurrentTime;
416
417 XSendEvent(_ecore_x_disp, win, False, NoEventMask, &xev);
418} /* ecore_x_window_delete_request_send */
419
420/**
421 * @defgroup Ecore_X_Window_Visibility_Group X Window Visibility Functions
422 *
423 * Functions to access and change the visibility of X windows.
424 */
425
426/**
427 * Shows a window.
428 *
429 * Synonymous to "mapping" a window in X Window System terminology.
430 *
431 * @param win The window to show.
432 * @ingroup Ecore_X_Window_Visibility
433 */
434EAPI void
435ecore_x_window_show(Ecore_X_Window win)
436{
437 LOGFN(__FILE__, __LINE__, __FUNCTION__);
438 XMapWindow(_ecore_x_disp, win);
439} /* ecore_x_window_show */
440
441/**
442 * Hides a window.
443 *
444 * Synonymous to "unmapping" a window in X Window System terminology.
445 *
446 * @param win The window to hide.
447 * @ingroup Ecore_X_Window_Visibility
448 */
449EAPI void
450ecore_x_window_hide(Ecore_X_Window win)
451{
452 XEvent xev;
453 Window root;
454 int idum;
455 unsigned int uidum;
456
457 /* ICCCM: SEND unmap event... */
458 LOGFN(__FILE__, __LINE__, __FUNCTION__);
459 root = win;
460 if (ScreenCount(_ecore_x_disp) == 1)
461 root = DefaultRootWindow(_ecore_x_disp);
462 else
463 XGetGeometry(_ecore_x_disp,
464 win,
465 &root,
466 &idum,
467 &idum,
468 &uidum,
469 &uidum,
470 &uidum,
471 &uidum);
472
473 xev.xunmap.type = UnmapNotify;
474 xev.xunmap.serial = 0;
475 xev.xunmap.send_event = True;
476 xev.xunmap.display = _ecore_x_disp;
477 xev.xunmap.event = root;
478 xev.xunmap.window = win;
479 xev.xunmap.from_configure = False;
480 XSendEvent(_ecore_x_disp, xev.xunmap.event, False,
481 SubstructureRedirectMask | SubstructureNotifyMask, &xev);
482 XUnmapWindow(_ecore_x_disp, win);
483} /* ecore_x_window_hide */
484
485/**
486 * @defgroup Ecore_X_Window_Geometry_Group X Window Geometry Functions
487 *
488 * Functions that change or retrieve the geometry of X windows.
489 */
490
491/**
492 * Moves a window to the position @p x, @p y.
493 *
494 * The position is relative to the upper left hand corner of the
495 * parent window.
496 *
497 * @param win The window to move.
498 * @param x X position.
499 * @param y Y position.
500 * @ingroup Ecore_X_Window_Geometry_Group
501 */
502EAPI void
503ecore_x_window_move(Ecore_X_Window win,
504 int x,
505 int y)
506{
507 LOGFN(__FILE__, __LINE__, __FUNCTION__);
508 XMoveWindow(_ecore_x_disp, win, x, y);
509} /* ecore_x_window_move */
510
511/**
512 * Resizes a window.
513 * @param win The window to resize.
514 * @param w New width of the window.
515 * @param h New height of the window.
516 * @ingroup Ecore_X_Window_Geometry_Group
517 */
518EAPI void
519ecore_x_window_resize(Ecore_X_Window win,
520 int w,
521 int h)
522{
523 LOGFN(__FILE__, __LINE__, __FUNCTION__);
524 if (w < 1)
525 w = 1;
526
527 if (h < 1)
528 h = 1;
529
530 XResizeWindow(_ecore_x_disp, win, w, h);
531} /* ecore_x_window_resize */
532
533/**
534 * Moves and resizes a window.
535 * @param win The window to move and resize.
536 * @param x New X position of the window.
537 * @param y New Y position of the window.
538 * @param w New width of the window.
539 * @param h New height of the window.
540 * @ingroup Ecore_X_Window_Geometry_Group
541 */
542EAPI void
543ecore_x_window_move_resize(Ecore_X_Window win,
544 int x,
545 int y,
546 int w,
547 int h)
548{
549 LOGFN(__FILE__, __LINE__, __FUNCTION__);
550 if (w < 1)
551 w = 1;
552
553 if (h < 1)
554 h = 1;
555
556 XMoveResizeWindow(_ecore_x_disp, win, x, y, w, h);
557} /* ecore_x_window_move_resize */
558
559/**
560 * @defgroup Ecore_X_Window_Focus_Functions X Window Focus Functions
561 *
562 * Functions that give the focus to an X Window.
563 */
564
565/**
566 * Sets the focus to the window @p win.
567 * @param win The window to focus.
568 * @ingroup Ecore_X_Window_Focus_Functions
569 */
570EAPI void
571ecore_x_window_focus(Ecore_X_Window win)
572{
573 LOGFN(__FILE__, __LINE__, __FUNCTION__);
574 if (win == 0)
575 win = DefaultRootWindow(_ecore_x_disp); // XSetInputFocus(_ecore_x_disp, win, RevertToNone, CurrentTime);
576
577// XSetInputFocus(_ecore_x_disp, win, RevertToPointerRoot, CurrentTime);
578 XSetInputFocus(_ecore_x_disp, win, RevertToParent, CurrentTime);
579} /* ecore_x_window_focus */
580
581/**
582 * Sets the focus to the given window at a specific time.
583 * @param win The window to focus.
584 * @param t When to set the focus to the window.
585 * @ingroup Ecore_X_Window_Focus_Functions
586 */
587EAPI void
588ecore_x_window_focus_at_time(Ecore_X_Window win,
589 Ecore_X_Time t)
590{
591 LOGFN(__FILE__, __LINE__, __FUNCTION__);
592 if (win == 0)
593 win = DefaultRootWindow(_ecore_x_disp); // XSetInputFocus(_ecore_x_disp, win, RevertToNone, t);
594
595// XSetInputFocus(_ecore_x_disp, win, PointerRoot, t);
596 XSetInputFocus(_ecore_x_disp, win, RevertToParent, t);
597} /* ecore_x_window_focus_at_time */
598
599/**
600 * gets the focus to the window @p win.
601 * @return The window that has focus.
602 * @ingroup Ecore_X_Window_Focus_Functions
603 */
604EAPI Ecore_X_Window
605ecore_x_window_focus_get(void)
606{
607 Window win;
608 int revert_mode;
609
610 LOGFN(__FILE__, __LINE__, __FUNCTION__);
611 win = 0;
612 XGetInputFocus(_ecore_x_disp, &win, &revert_mode);
613 return win;
614} /* ecore_x_window_focus_get */
615
616/**
617 * @defgroup Ecore_X_Window_Z_Order_Group X Window Z Order Functions
618 *
619 * Functions that change the Z order of X windows.
620 */
621
622/**
623 * Raises the given window.
624 * @param win The window to raise.
625 * @ingroup Ecore_X_Window_Z_Order_Group
626 */
627EAPI void
628ecore_x_window_raise(Ecore_X_Window win)
629{
630 LOGFN(__FILE__, __LINE__, __FUNCTION__);
631 XRaiseWindow(_ecore_x_disp, win);
632} /* ecore_x_window_raise */
633
634/**
635 * Lowers the given window.
636 * @param win The window to lower.
637 * @ingroup Ecore_X_Window_Z_Order_Group
638 */
639EAPI void
640ecore_x_window_lower(Ecore_X_Window win)
641{
642 LOGFN(__FILE__, __LINE__, __FUNCTION__);
643 XLowerWindow(_ecore_x_disp, win);
644} /* ecore_x_window_lower */
645
646/**
647 * @defgroup Ecore_X_Window_Parent_Group X Window Parent Functions
648 *
649 * Functions that retrieve or changes the parent window of a window.
650 */
651
652/**
653 * Moves a window to within another window at a given position.
654 * @param win The window to reparent.
655 * @param new_parent The new parent window.
656 * @param x X position within new parent window.
657 * @param y Y position within new parent window.
658 * @ingroup Ecore_X_Window_Parent_Group
659 */
660EAPI void
661ecore_x_window_reparent(Ecore_X_Window win,
662 Ecore_X_Window new_parent,
663 int x,
664 int y)
665{
666 LOGFN(__FILE__, __LINE__, __FUNCTION__);
667 if (new_parent == 0)
668 new_parent = DefaultRootWindow(_ecore_x_disp);
669
670 XReparentWindow(_ecore_x_disp, win, new_parent, x, y);
671} /* ecore_x_window_reparent */
672
673/**
674 * Retrieves the size of the given window.
675 * @param win The given window.
676 * @param w Pointer to an integer into which the width is to be stored.
677 * @param h Pointer to an integer into which the height is to be stored.
678 * @ingroup Ecore_X_Window_Geometry_Group
679 */
680EAPI void
681ecore_x_window_size_get(Ecore_X_Window win,
682 int *w,
683 int *h)
684{
685 int dummy_x, dummy_y;
686
687 LOGFN(__FILE__, __LINE__, __FUNCTION__);
688 if (win == 0)
689 win = DefaultRootWindow(_ecore_x_disp);
690
691 ecore_x_drawable_geometry_get(win, &dummy_x, &dummy_y, w, h);
692} /* ecore_x_window_size_get */
693
694/**
695 * Retrieves the geometry of the given window.
696 *
697 * Note that the x & y coordingates are relative to your parent. In
698 * particular for reparenting window managers - relative to you window border.
699 * If you want screen coordinates either walk the window tree to the root,
700 * else for ecore_evas applications see ecore_evas_geometry_get(). Elementary
701 * applications can use elm_win_screen_position_get().
702 *
703 * @param win The given window.
704 * @param x Pointer to an integer in which the X position is to be stored.
705 * @param y Pointer to an integer in which the Y position is to be stored.
706 * @param w Pointer to an integer in which the width is to be stored.
707 * @param h Pointer to an integer in which the height is to be stored.
708 * @ingroup Ecore_X_Window_Geometry_Group
709 */
710EAPI void
711ecore_x_window_geometry_get(Ecore_X_Window win,
712 int *x,
713 int *y,
714 int *w,
715 int *h)
716{
717 LOGFN(__FILE__, __LINE__, __FUNCTION__);
718 if (!win)
719 win = DefaultRootWindow(_ecore_x_disp);
720
721 ecore_x_drawable_geometry_get(win, x, y, w, h);
722} /* ecore_x_window_geometry_get */
723
724/**
725 * Retrieves the width of the border of the given window.
726 * @param win The given window.
727 * @return Width of the border of @p win.
728 * @ingroup Ecore_X_Window_Geometry_Group
729 */
730EAPI int
731ecore_x_window_border_width_get(Ecore_X_Window win)
732{
733 LOGFN(__FILE__, __LINE__, __FUNCTION__);
734 /* doesn't make sense to call this on a root window */
735 if (!win)
736 return 0;
737
738 return ecore_x_drawable_border_width_get(win);
739} /* ecore_x_window_border_width_get */
740
741/**
742 * Sets the width of the border of the given window.
743 * @param win The given window.
744 * @param width The new border width.
745 * @ingroup Ecore_X_Window_Geometry_Group
746 */
747EAPI void
748ecore_x_window_border_width_set(Ecore_X_Window win,
749 int width)
750{
751 LOGFN(__FILE__, __LINE__, __FUNCTION__);
752 /* doesn't make sense to call this on a root window */
753 if (!win)
754 return;
755
756 XSetWindowBorderWidth (_ecore_x_disp, win, width);
757} /* ecore_x_window_border_width_set */
758
759/**
760 * Retrieves the depth of the given window.
761 * @param win The given window.
762 * @return Depth of the window.
763 */
764EAPI int
765ecore_x_window_depth_get(Ecore_X_Window win)
766{
767 LOGFN(__FILE__, __LINE__, __FUNCTION__);
768 return ecore_x_drawable_depth_get(win);
769} /* ecore_x_window_depth_get */
770
771/**
772 * To be documented.
773 *
774 * FIXME: To be fixed.
775 */
776EAPI void
777ecore_x_window_cursor_show(Ecore_X_Window win,
778 Eina_Bool show)
779{
780 LOGFN(__FILE__, __LINE__, __FUNCTION__);
781 if (win == 0)
782 win = DefaultRootWindow(_ecore_x_disp);
783
784 if (!show)
785 {
786 Cursor c;
787 XColor cl;
788 Pixmap p, m;
789 GC gc;
790 XGCValues gcv;
791
792 p = XCreatePixmap(_ecore_x_disp, win, 1, 1, 1);
793 m = XCreatePixmap(_ecore_x_disp, win, 1, 1, 1);
794 gc = XCreateGC(_ecore_x_disp, m, 0, &gcv);
795 XSetForeground(_ecore_x_disp, gc, 0);
796 XDrawPoint(_ecore_x_disp, m, gc, 0, 0);
797 XFreeGC(_ecore_x_disp, gc);
798 c = XCreatePixmapCursor(_ecore_x_disp, p, m, &cl, &cl, 0, 0);
799 XDefineCursor(_ecore_x_disp, win, c);
800 XFreeCursor(_ecore_x_disp, c);
801 XFreePixmap(_ecore_x_disp, p);
802 XFreePixmap(_ecore_x_disp, m);
803 }
804 else
805 XDefineCursor(_ecore_x_disp, win, 0);
806} /* ecore_x_window_cursor_show */
807
808EAPI void
809ecore_x_window_cursor_set(Ecore_X_Window win,
810 Ecore_X_Cursor c)
811{
812 LOGFN(__FILE__, __LINE__, __FUNCTION__);
813 if (c == 0)
814 XUndefineCursor(_ecore_x_disp, win);
815 else
816 XDefineCursor(_ecore_x_disp, win, c);
817} /* ecore_x_window_cursor_set */
818
819/**
820 * Finds out whether the given window is currently visible.
821 * @param win The given window.
822 * @return 1 if the window is visible, otherwise 0.
823 * @ingroup Ecore_X_Window_Visibility_Group
824 */
825EAPI int
826ecore_x_window_visible_get(Ecore_X_Window win)
827{
828 XWindowAttributes attr;
829
830 LOGFN(__FILE__, __LINE__, __FUNCTION__);
831 return XGetWindowAttributes(_ecore_x_disp, win, &attr) &&
832 (attr.map_state == IsViewable);
833} /* ecore_x_window_visible_get */
834
835typedef struct _Shadow Shadow;
836struct _Shadow
837{
838 Shadow *parent;
839 Shadow **children;
840 Window win;
841 int children_num;
842 short x, y;
843 unsigned short w, h;
844};
845
846static Shadow **shadow_base = NULL;
847static int shadow_num = 0;
848
849static Shadow *
850_ecore_x_window_tree_walk(Window win)
851{
852 Window *list = NULL;
853 Window parent_win = 0, root_win = 0;
854 unsigned int num;
855 Shadow *s, **sl;
856 XWindowAttributes att;
857
858 if (!XGetWindowAttributes(_ecore_x_disp, win, &att))
859 return NULL; // if (att.class == InputOnly) return NULL;
860
861 if (att.map_state != IsViewable)
862 return NULL;
863
864 s = calloc(1, sizeof(Shadow));
865 if (!s)
866 return NULL;
867
868 s->win = win;
869 s->x = att.x;
870 s->y = att.y;
871 s->w = att.width;
872 s->h = att.height;
873 if (XQueryTree(_ecore_x_disp, s->win, &root_win, &parent_win,
874 &list, &num))
875 {
876 s->children = calloc(1, sizeof(Shadow *) * num);
877 if (s->children)
878 {
879 size_t i, j;
880 s->children_num = num;
881 for (i = 0; i < num; i++)
882 {
883 s->children[i] = _ecore_x_window_tree_walk(list[i]);
884 if (s->children[i])
885 s->children[i]->parent = s;
886 }
887 /* compress list down */
888 j = 0;
889 for (i = 0; i < num; i++)
890 {
891 if (s->children[i])
892 {
893 s->children[j] = s->children[i];
894 j++;
895 }
896 }
897 if (j == 0)
898 {
899 free(s->children);
900 s->children = NULL;
901 s->children_num = 0;
902 }
903 else
904 {
905 s->children_num = j;
906 sl = realloc(s->children, sizeof(Shadow *) * j);
907 if (sl)
908 s->children = sl;
909 }
910 }
911 }
912
913 if (list)
914 XFree(list);
915
916 return s;
917} /* _ecore_x_window_tree_walk */
918
919static void
920_ecore_x_window_tree_shadow_free1(Shadow *s)
921{
922 int i;
923
924 if (!s)
925 return;
926
927 if (s->children)
928 {
929 for (i = 0; i < s->children_num; i++)
930 {
931 if (s->children[i])
932 _ecore_x_window_tree_shadow_free1(s->children[i]);
933 }
934 free(s->children);
935 }
936
937 free(s);
938} /* _ecore_x_window_tree_shadow_free1 */
939
940static void
941_ecore_x_window_tree_shadow_free(void)
942{
943 int i;
944
945 if (!shadow_base)
946 return;
947
948 for (i = 0; i < shadow_num; i++)
949 {
950 if (!shadow_base[i])
951 continue;
952
953 _ecore_x_window_tree_shadow_free1(shadow_base[i]);
954 }
955 free(shadow_base);
956 shadow_base = NULL;
957 shadow_num = 0;
958} /* _ecore_x_window_tree_shadow_free */
959
960static void
961_ecore_x_window_tree_shadow_populate(void)
962{
963 Ecore_X_Window *roots;
964 int i, num;
965
966 roots = ecore_x_window_root_list(&num);
967 if (roots)
968 {
969 shadow_base = calloc(1, sizeof(Shadow *) * num);
970 if (shadow_base)
971 {
972 shadow_num = num;
973 for (i = 0; i < num; i++)
974 shadow_base[i] = _ecore_x_window_tree_walk(roots[i]);
975 }
976
977 free(roots);
978 }
979} /* _ecore_x_window_tree_shadow_populate */
980
981/*
982 static int shadow_count = 0;
983
984 static void
985 _ecore_x_window_tree_shadow_start(void)
986 {
987 shadow_count++;
988 if (shadow_count > 1) return;
989 _ecore_x_window_tree_shadow_populate();
990 }
991
992 static void
993 _ecore_x_window_tree_shadow_stop(void)
994 {
995 shadow_count--;
996 if (shadow_count != 0) return;
997 _ecore_x_window_tree_shadow_free();
998 }
999 */
1000
1001static Shadow *
1002_ecore_x_window_shadow_tree_find_shadow(Shadow *s,
1003 Window win)
1004{
1005 Shadow *ss;
1006 int i;
1007
1008 if (s->win == win)
1009 return s;
1010
1011 if (s->children)
1012 for (i = 0; i < s->children_num; i++)
1013 {
1014 if (!s->children[i])
1015 continue;
1016
1017 if ((ss =
1018 _ecore_x_window_shadow_tree_find_shadow(s->children[i], win)))
1019 return ss;
1020 }
1021
1022 return NULL;
1023} /* _ecore_x_window_shadow_tree_find_shadow */
1024
1025static Shadow *
1026_ecore_x_window_shadow_tree_find(Window base)
1027{
1028 Shadow *s;
1029 int i;
1030
1031 for (i = 0; i < shadow_num; i++)
1032 {
1033 if (!shadow_base[i])
1034 continue;
1035
1036 if ((s = _ecore_x_window_shadow_tree_find_shadow(shadow_base[i], base)))
1037 return s;
1038 }
1039 return NULL;
1040} /* _ecore_x_window_shadow_tree_find */
1041
1042static int
1043_inside_rects(Shadow *s,
1044 int x,
1045 int y,
1046 int bx,
1047 int by,
1048 Ecore_X_Rectangle *rects,
1049 int num)
1050{
1051 int i, inside;
1052
1053 if (!rects) return 0;
1054 inside = 0;
1055 for (i = 0; i < num; i++)
1056 {
1057 if ((x >= s->x + bx + rects[i].x) &&
1058 (y >= s->y + by + rects[i].y) &&
1059 (x < (int)(s->x + bx + rects[i].x + rects[i].width)) &&
1060 (y < (int)(s->y + by + rects[i].y + rects[i].height)))
1061 {
1062 inside = 1;
1063 break;
1064 }
1065 }
1066 free(rects);
1067 return inside;
1068}
1069
1070static Window
1071_ecore_x_window_shadow_tree_at_xy_get_shadow(Shadow *s,
1072 int bx,
1073 int by,
1074 int x,
1075 int y,
1076 Ecore_X_Window *skip,
1077 int skip_num)
1078{
1079 Window child;
1080 int i, j;
1081 int wx, wy;
1082
1083 wx = s->x + bx;
1084 wy = s->y + by;
1085 if (!((x >= wx) && (y >= wy) && (x < (wx + s->w)) && (y < (wy + s->h))))
1086 return 0;
1087
1088 /* FIXME: get shape */
1089 {
1090 int num;
1091 Ecore_X_Rectangle *rects;
1092
1093 num = 0;
1094 rects = ecore_x_window_shape_rectangles_get(s->win, &num);
1095 if (!_inside_rects(s, x, y, bx, by, rects, num)) return 0;
1096 num = 0;
1097 rects = ecore_x_window_shape_input_rectangles_get(s->win, &num);
1098 if (!_inside_rects(s, x, y, bx, by, rects, num)) return 0;
1099 }
1100
1101 if (s->children)
1102 {
1103 int skipit = 0;
1104
1105 for (i = s->children_num - 1; i >= 0; --i)
1106 {
1107 if (!s->children[i])
1108 continue;
1109
1110 skipit = 0;
1111 if (skip)
1112 for (j = 0; j < skip_num; j++)
1113 {
1114 if (s->children[i]->win == skip[j])
1115 {
1116 skipit = 1;
1117 goto onward;
1118 }
1119 }
1120
1121onward:
1122 if (!skipit)
1123 if ((child =
1124 _ecore_x_window_shadow_tree_at_xy_get_shadow(s->
1125 children[i
1126 ], wx, wy,
1127 x, y, skip,
1128 skip_num)))
1129 return child;
1130 }
1131 }
1132
1133 return s->win;
1134} /* _ecore_x_window_shadow_tree_at_xy_get_shadow */
1135
1136static Window
1137_ecore_x_window_shadow_tree_at_xy_get(Window base,
1138 int bx,
1139 int by,
1140 int x,
1141 int y,
1142 Ecore_X_Window *skip,
1143 int skip_num)
1144{
1145 Shadow *s;
1146
1147 if (!shadow_base)
1148 {
1149 _ecore_x_window_tree_shadow_populate();
1150 if (!shadow_base)
1151 return 0;
1152 }
1153
1154 s = _ecore_x_window_shadow_tree_find(base);
1155 if (!s)
1156 return 0;
1157
1158 return _ecore_x_window_shadow_tree_at_xy_get_shadow(s,
1159 bx,
1160 by,
1161 x,
1162 y,
1163 skip,
1164 skip_num);
1165} /* _ecore_x_window_shadow_tree_at_xy_get */
1166
1167/**
1168 * Retrieves the top, visible window at the given location,
1169 * but skips the windows in the list. This uses a shadow tree built from the
1170 * window tree that is only updated the first time
1171 * ecore_x_window_shadow_tree_at_xy_with_skip_get() is called, or the next time
1172 * it is called after a ecore_x_window_shadow_tree_flush()
1173 * @param base The base window to start searching from (normally root).
1174 * @param x The given X position.
1175 * @param y The given Y position.
1176 * @return The window at that position.
1177 * @ingroup Ecore_X_Window_Geometry_Group
1178 */
1179EAPI Ecore_X_Window
1180ecore_x_window_shadow_tree_at_xy_with_skip_get(Ecore_X_Window base,
1181 int x,
1182 int y,
1183 Ecore_X_Window *skip,
1184 int skip_num)
1185{
1186 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1187 return _ecore_x_window_shadow_tree_at_xy_get(base,
1188 0,
1189 0,
1190 x,
1191 y,
1192 skip,
1193 skip_num);
1194} /* ecore_x_window_shadow_tree_at_xy_with_skip_get */
1195
1196/**
1197 * Retrieves the parent window a given window has. This uses the shadow window
1198 * tree.
1199 * @param root The root window of @p win - if 0, this will be automatically determined with extra processing overhead
1200 * @param win The window to get the parent window of
1201 * @return The parent window of @p win
1202 * @ingroup Ecore_X_Window_Geometry_Group
1203 */
1204EAPI Ecore_X_Window
1205ecore_x_window_shadow_parent_get(Ecore_X_Window root __UNUSED__,
1206 Ecore_X_Window win)
1207{
1208 Shadow *s;
1209 int i;
1210
1211 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1212 if (!shadow_base)
1213 {
1214 _ecore_x_window_tree_shadow_populate();
1215 if (!shadow_base)
1216 return 0;
1217 }
1218
1219 for (i = 0; i < shadow_num; i++)
1220 {
1221 if (!shadow_base[i])
1222 continue;
1223
1224 s = _ecore_x_window_shadow_tree_find_shadow(shadow_base[i], win);
1225 if (s)
1226 {
1227 if (!s->parent)
1228 return 0;
1229
1230 return s->parent->win;
1231 }
1232 }
1233 return 0;
1234} /* ecore_x_window_shadow_parent_get */
1235
1236/**
1237 * Flushes the window shadow tree so nothing is stored.
1238 * @ingroup Ecore_X_Window_Geometry_Group
1239 */
1240EAPI void
1241ecore_x_window_shadow_tree_flush(void)
1242{
1243 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1244 _ecore_x_window_tree_shadow_free();
1245} /* ecore_x_window_shadow_tree_flush */
1246
1247/**
1248 * Retrieves the root window a given window is on.
1249 * @param win The window to get the root window of
1250 * @return The root window of @p win
1251 * @ingroup Ecore_X_Window_Geometry_Group
1252 */
1253EAPI Ecore_X_Window
1254ecore_x_window_root_get(Ecore_X_Window win)
1255{
1256 XWindowAttributes att;
1257
1258 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1259 if (!XGetWindowAttributes(_ecore_x_disp, win, &att))
1260 return 0;
1261
1262 return att.root;
1263} /* ecore_x_window_root_get */
1264
1265static Window
1266_ecore_x_window_at_xy_get(Window base,
1267 int bx,
1268 int by,
1269 int x,
1270 int y,
1271 Ecore_X_Window *skip,
1272 int skip_num)
1273{
1274 Window *list = NULL;
1275 Window parent_win = 0, child = 0, root_win = 0;
1276 int i, j, wx, wy, ww, wh;
1277 unsigned int num;
1278
1279 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1280 if (!ecore_x_window_visible_get(base))
1281 return 0;
1282
1283 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1284 ecore_x_window_geometry_get(base, &wx, &wy, &ww, &wh);
1285 wx += bx;
1286 wy += by;
1287
1288 if (!((x >= wx) && (y >= wy) && (x < (wx + ww)) && (y < (wy + wh))))
1289 return 0;
1290
1291 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1292 if (!XQueryTree(_ecore_x_disp, base, &root_win, &parent_win, &list, &num))
1293 return base;
1294
1295 if (list)
1296 {
1297 int skipit = 0;
1298
1299 for (i = num - 1; i >= 0; --i)
1300 {
1301 skipit = 0;
1302
1303 if (skip)
1304 for (j = 0; j < skip_num; j++)
1305 {
1306 if (list[i] == skip[j])
1307 {
1308 skipit = 1;
1309 goto onward;
1310 }
1311 }
1312
1313onward:
1314 if (!skipit)
1315 if ((child =
1316 _ecore_x_window_at_xy_get(list[i], wx, wy, x, y, skip,
1317 skip_num)))
1318 {
1319 XFree(list);
1320 return child;
1321 }
1322 }
1323 XFree(list);
1324 }
1325
1326 return base;
1327} /* _ecore_x_window_at_xy_get */
1328
1329/**
1330 * Retrieves the top, visible window at the given location.
1331 * @param x The given X position.
1332 * @param y The given Y position.
1333 * @return The window at that position.
1334 * @ingroup Ecore_X_Window_Geometry_Group
1335 */
1336EAPI Ecore_X_Window
1337ecore_x_window_at_xy_get(int x,
1338 int y)
1339{
1340 Ecore_X_Window win, root;
1341
1342 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1343 /* FIXME: Proper function to determine current root/virtual root
1344 * window missing here */
1345 root = DefaultRootWindow(_ecore_x_disp);
1346
1347 ecore_x_grab();
1348 win = _ecore_x_window_at_xy_get(root, 0, 0, x, y, NULL, 0);
1349 ecore_x_ungrab();
1350
1351 return win ? win : root;
1352} /* ecore_x_window_at_xy_get */
1353
1354/**
1355 * Retrieves the top, visible window at the given location,
1356 * but skips the windows in the list.
1357 * @param x The given X position.
1358 * @param y The given Y position.
1359 * @return The window at that position.
1360 * @ingroup Ecore_X_Window_Geometry_Group
1361 */
1362EAPI Ecore_X_Window
1363ecore_x_window_at_xy_with_skip_get(int x,
1364 int y,
1365 Ecore_X_Window *skip,
1366 int skip_num)
1367{
1368 Ecore_X_Window win, root;
1369
1370 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1371 /* FIXME: Proper function to determine current root/virtual root
1372 * window missing here */
1373 root = DefaultRootWindow(_ecore_x_disp);
1374
1375 ecore_x_grab();
1376 win = _ecore_x_window_at_xy_get(root, 0, 0, x, y, skip, skip_num);
1377 ecore_x_ungrab();
1378
1379 return win ? win : root;
1380} /* ecore_x_window_at_xy_with_skip_get */
1381
1382EAPI Ecore_X_Window
1383ecore_x_window_at_xy_begin_get(Ecore_X_Window begin,
1384 int x,
1385 int y)
1386{
1387 Ecore_X_Window win;
1388
1389 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1390 ecore_x_grab();
1391 win = _ecore_x_window_at_xy_get(begin, 0, 0, x, y, NULL, 0);
1392 ecore_x_ungrab();
1393
1394 return win ? win : begin;
1395} /* ecore_x_window_at_xy_begin_get */
1396
1397/**
1398 * Retrieves the parent window of the given window.
1399 * @param win The given window.
1400 * @return The parent window of @p win.
1401 * @ingroup Ecore_X_Window_Parent_Group
1402 */
1403EAPI Ecore_X_Window
1404ecore_x_window_parent_get(Ecore_X_Window win)
1405{
1406 Window root, parent, *children = NULL;
1407 unsigned int num;
1408
1409 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1410 if (!XQueryTree(_ecore_x_disp, win, &root, &parent, &children, &num))
1411 return 0;
1412
1413 if (children)
1414 XFree(children);
1415
1416 return parent;
1417} /* ecore_x_window_parent_get */
1418
1419/**
1420 * Sets the background color of the given window.
1421 * @param win The given window
1422 * @param r red value (0...65536, 16 bits)
1423 * @param g green value (0...65536, 16 bits)
1424 * @param b blue value (0...65536, 16 bits)
1425 */
1426EAPI void
1427ecore_x_window_background_color_set(Ecore_X_Window win,
1428 unsigned short r,
1429 unsigned short g,
1430 unsigned short b)
1431{
1432 XSetWindowAttributes attr;
1433 Colormap map;
1434 XColor col;
1435
1436 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1437 col.red = r;
1438 col.green = g;
1439 col.blue = b;
1440
1441 map = DefaultColormap(_ecore_x_disp, DefaultScreen(_ecore_x_disp));
1442 XAllocColor(_ecore_x_disp, map, &col);
1443
1444 attr.background_pixel = col.pixel;
1445 XChangeWindowAttributes(_ecore_x_disp, win, CWBackPixel, &attr);
1446} /* ecore_x_window_background_color_set */
1447
1448EAPI void
1449ecore_x_window_gravity_set(Ecore_X_Window win,
1450 Ecore_X_Gravity grav)
1451{
1452 XSetWindowAttributes att;
1453
1454 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1455 att.win_gravity = grav;
1456 XChangeWindowAttributes(_ecore_x_disp, win, CWWinGravity, &att);
1457} /* ecore_x_window_gravity_set */
1458
1459EAPI void
1460ecore_x_window_pixel_gravity_set(Ecore_X_Window win,
1461 Ecore_X_Gravity grav)
1462{
1463 XSetWindowAttributes att;
1464
1465 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1466 att.bit_gravity = grav;
1467 XChangeWindowAttributes(_ecore_x_disp, win, CWBitGravity, &att);
1468} /* ecore_x_window_pixel_gravity_set */
1469
1470EAPI void
1471ecore_x_window_pixmap_set(Ecore_X_Window win,
1472 Ecore_X_Pixmap pmap)
1473{
1474 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1475 XSetWindowBackgroundPixmap(_ecore_x_disp, win, pmap);
1476} /* ecore_x_window_pixmap_set */
1477
1478EAPI void
1479ecore_x_window_area_clear(Ecore_X_Window win,
1480 int x,
1481 int y,
1482 int w,
1483 int h)
1484{
1485 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1486 XClearArea(_ecore_x_disp, win, x, y, w, h, False);
1487} /* ecore_x_window_area_clear */
1488
1489EAPI void
1490ecore_x_window_area_expose(Ecore_X_Window win,
1491 int x,
1492 int y,
1493 int w,
1494 int h)
1495{
1496 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1497 XClearArea(_ecore_x_disp, win, x, y, w, h, True);
1498} /* ecore_x_window_area_expose */
1499
1500EAPI void
1501ecore_x_window_override_set(Ecore_X_Window win,
1502 Eina_Bool override)
1503{
1504 XSetWindowAttributes att;
1505
1506 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1507 att.override_redirect = override;
1508 XChangeWindowAttributes(_ecore_x_disp, win, CWOverrideRedirect, &att);
1509} /* ecore_x_window_override_set */
1510
1511#ifdef ECORE_XRENDER
1512static Ecore_X_Window
1513_ecore_x_window_argb_internal_new(Ecore_X_Window parent,
1514 int x,
1515 int y,
1516 int w,
1517 int h,
1518 Eina_Bool override,
1519 Eina_Bool saveunder)
1520{
1521 Window win;
1522 XSetWindowAttributes attr;
1523 XWindowAttributes att;
1524 XVisualInfo *xvi;
1525 XVisualInfo vi_in;
1526 int nvi, i, scr = 0;
1527 XRenderPictFormat *fmt;
1528 Visual *vis;
1529
1530 if (parent == 0)
1531 {
1532 parent = DefaultRootWindow(_ecore_x_disp);
1533 scr = DefaultScreen(_ecore_x_disp);
1534 }
1535 else
1536 {
1537 /* ewww - round trip */
1538 XGetWindowAttributes(_ecore_x_disp, parent, &att);
1539 for (i = 0; i < ScreenCount(_ecore_x_disp); i++)
1540 {
1541 if (att.screen == ScreenOfDisplay(_ecore_x_disp, i))
1542 {
1543 scr = i;
1544 break;
1545 }
1546 }
1547 }
1548
1549 vi_in.screen = scr;
1550 vi_in.depth = 32;
1551 vi_in.class = TrueColor;
1552 xvi = XGetVisualInfo(_ecore_x_disp,
1553 VisualScreenMask |
1554 VisualDepthMask |
1555 VisualClassMask,
1556 &vi_in,
1557 &nvi);
1558 if (!xvi)
1559 return 0;
1560
1561 vis = NULL;
1562 for (i = 0; i < nvi; i++)
1563 {
1564 fmt = XRenderFindVisualFormat(_ecore_x_disp, xvi[i].visual);
1565 if ((fmt->type == PictTypeDirect) && (fmt->direct.alphaMask))
1566 {
1567 vis = xvi[i].visual;
1568 break;
1569 }
1570 }
1571 XFree (xvi);
1572
1573 attr.backing_store = NotUseful;
1574 attr.override_redirect = override;
1575 attr.colormap = XCreateColormap(_ecore_x_disp, parent,
1576 vis, AllocNone);
1577 attr.border_pixel = 0;
1578 attr.background_pixmap = None;
1579 attr.bit_gravity = NorthWestGravity;
1580 attr.win_gravity = NorthWestGravity;
1581 attr.save_under = saveunder;
1582 attr.do_not_propagate_mask = NoEventMask;
1583 attr.event_mask = KeyPressMask |
1584 KeyReleaseMask |
1585 ButtonPressMask |
1586 ButtonReleaseMask |
1587 EnterWindowMask |
1588 LeaveWindowMask |
1589 PointerMotionMask |
1590 ExposureMask |
1591 VisibilityChangeMask |
1592 StructureNotifyMask |
1593 FocusChangeMask |
1594 PropertyChangeMask |
1595 ColormapChangeMask;
1596 win = XCreateWindow(_ecore_x_disp, parent,
1597 x, y, w, h, 0,
1598 32,
1599 InputOutput,
1600 vis,
1601 CWBackingStore |
1602 CWOverrideRedirect |
1603 CWColormap |
1604 CWBorderPixel |
1605 CWBackPixmap |
1606 CWSaveUnder |
1607 CWDontPropagate |
1608 CWEventMask |
1609 CWBitGravity |
1610 CWWinGravity,
1611 &attr);
1612 XFreeColormap(_ecore_x_disp, attr.colormap);
1613
1614 if (parent == DefaultRootWindow(_ecore_x_disp))
1615 ecore_x_window_defaults_set(win);
1616
1617 return win;
1618} /* _ecore_x_window_argb_internal_new */
1619
1620#endif /* ifdef ECORE_XRENDER */
1621
1622EAPI int
1623ecore_x_window_argb_get(Ecore_X_Window win)
1624{
1625#ifdef ECORE_XRENDER
1626 XWindowAttributes att;
1627 XRenderPictFormat *fmt;
1628
1629 att.visual = 0;
1630 if (!XGetWindowAttributes(_ecore_x_disp, win, &att))
1631 return 0;
1632
1633 fmt = XRenderFindVisualFormat(_ecore_x_disp, att.visual);
1634 if (!fmt)
1635 return 0;
1636
1637 if ((fmt->type == PictTypeDirect) && (fmt->direct.alphaMask))
1638 return 1;
1639
1640 return 0;
1641#else /* ifdef ECORE_XRENDER */
1642 return 0;
1643#endif /* ifdef ECORE_XRENDER */
1644} /* ecore_x_window_argb_get */
1645
1646/**
1647 * Creates a new window.
1648 * @param parent The parent window to use. If @p parent is @c 0, the root
1649 * window of the default display is used.
1650 * @param x X position.
1651 * @param y Y position.
1652 * @param w Width.
1653 * @param h Height.
1654 * @return The new window handle.
1655 * @ingroup Ecore_X_Window_Create_Group
1656 */
1657EAPI Ecore_X_Window
1658ecore_x_window_manager_argb_new(Ecore_X_Window parent,
1659 int x,
1660 int y,
1661 int w,
1662 int h)
1663{
1664#ifdef ECORE_XRENDER
1665 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1666 return _ecore_x_window_argb_internal_new(parent, x, y, w, h, 1, 0);
1667#else /* ifdef ECORE_XRENDER */
1668 return 0;
1669#endif /* ifdef ECORE_XRENDER */
1670} /* ecore_x_window_manager_argb_new */
1671
1672/**
1673 * Creates a new window.
1674 * @param parent The parent window to use. If @p parent is @c 0, the root
1675 * window of the default display is used.
1676 * @param x X position.
1677 * @param y Y position.
1678 * @param w Width.
1679 * @param h Height.
1680 * @return The new window handle.
1681 * @ingroup Ecore_X_Window_Create_Group
1682 */
1683EAPI Ecore_X_Window
1684ecore_x_window_argb_new(Ecore_X_Window parent,
1685 int x,
1686 int y,
1687 int w,
1688 int h)
1689{
1690#ifdef ECORE_XRENDER
1691 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1692 return _ecore_x_window_argb_internal_new(parent, x, y, w, h, 0, 0);
1693#else /* ifdef ECORE_XRENDER */
1694 return 0;
1695#endif /* ifdef ECORE_XRENDER */
1696} /* ecore_x_window_argb_new */
1697
1698/**
1699 * Creates a window with the override redirect attribute set to @c True.
1700 * @param parent The parent window to use. If @p parent is @c 0, the root
1701 * window of the default display is used.
1702 * @param x X position.
1703 * @param y Y position.
1704 * @param w Width.
1705 * @param h Height.
1706 * @return The new window handle.
1707 * @ingroup Ecore_X_Window_Create_Group
1708 */
1709EAPI Ecore_X_Window
1710ecore_x_window_override_argb_new(Ecore_X_Window parent,
1711 int x,
1712 int y,
1713 int w,
1714 int h)
1715{
1716#ifdef ECORE_XRENDER
1717 LOGFN(__FILE__, __LINE__, __FUNCTION__);
1718 return _ecore_x_window_argb_internal_new(parent, x, y, w, h, 1, 0);
1719#else /* ifdef ECORE_XRENDER */
1720 return 0;
1721#endif /* ifdef ECORE_XRENDER */
1722} /* ecore_x_window_override_argb_new */
1723
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_window_prop.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_window_prop.c
new file mode 100644
index 0000000..8d5c757
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_window_prop.c
@@ -0,0 +1,750 @@
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#include <inttypes.h>
13#include <limits.h>
14
15#define _ATOM_SET_CARD32(win, atom, p_val, cnt) \
16 XChangeProperty(_ecore_x_disp, win, atom, XA_CARDINAL, 32, PropModeReplace, \
17 (unsigned char *)p_val, cnt)
18
19/*
20 * Set CARD32 (array) property
21 */
22EAPI void
23ecore_x_window_prop_card32_set(Ecore_X_Window win,
24 Ecore_X_Atom atom,
25 unsigned int *val,
26 unsigned int num)
27{
28#if SIZEOF_INT == SIZEOF_LONG
29 _ATOM_SET_CARD32(win, atom, val, num);
30#else /* if SIZEOF_INT == SIZEOF_LONG */
31 long *v2;
32 unsigned int i;
33
34 LOGFN(__FILE__, __LINE__, __FUNCTION__);
35 v2 = malloc(num * sizeof(long));
36 if (!v2)
37 return;
38
39 for (i = 0; i < num; i++)
40 v2[i] = val[i];
41 _ATOM_SET_CARD32(win, atom, v2, num);
42 free(v2);
43#endif /* if SIZEOF_INT == SIZEOF_LONG */
44} /* ecore_x_window_prop_card32_set */
45
46/*
47 * Get CARD32 (array) property
48 *
49 * At most len items are returned in val.
50 * If the property was successfully fetched the number of items stored in
51 * val is returned, otherwise -1 is returned.
52 * Note: Return value 0 means that the property exists but has no elements.
53 */
54EAPI int
55ecore_x_window_prop_card32_get(Ecore_X_Window win,
56 Ecore_X_Atom atom,
57 unsigned int *val,
58 unsigned int len)
59{
60 unsigned char *prop_ret;
61 Atom type_ret;
62 unsigned long bytes_after, num_ret;
63 int format_ret;
64 unsigned int i;
65 int num;
66
67 LOGFN(__FILE__, __LINE__, __FUNCTION__);
68 prop_ret = NULL;
69 if (XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False,
70 XA_CARDINAL, &type_ret, &format_ret, &num_ret,
71 &bytes_after, &prop_ret) != Success)
72 return -1;
73
74 if (type_ret != XA_CARDINAL || format_ret != 32)
75 num = -1;
76 else if (num_ret == 0 || !prop_ret)
77 num = 0;
78 else
79 {
80 if (num_ret < len)
81 len = num_ret;
82
83 for (i = 0; i < len; i++)
84 val[i] = ((unsigned long *)prop_ret)[i];
85 num = len;
86 }
87
88 if (prop_ret)
89 XFree(prop_ret);
90
91 return num;
92} /* ecore_x_window_prop_card32_get */
93
94/*
95 * Get CARD32 (array) property of any length
96 *
97 * If the property was successfully fetched the number of items stored in
98 * val is returned, otherwise -1 is returned.
99 * Note: Return value 0 means that the property exists but has no elements.
100 */
101EAPI int
102ecore_x_window_prop_card32_list_get(Ecore_X_Window win,
103 Ecore_X_Atom atom,
104 unsigned int **plst)
105{
106 unsigned char *prop_ret;
107 Atom type_ret;
108 unsigned long bytes_after, num_ret;
109 int format_ret;
110 unsigned int i, *val;
111 int num;
112
113 LOGFN(__FILE__, __LINE__, __FUNCTION__);
114 *plst = NULL;
115 prop_ret = NULL;
116 if (XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False,
117 XA_CARDINAL, &type_ret, &format_ret, &num_ret,
118 &bytes_after, &prop_ret) != Success)
119 return -1;
120
121 if ((type_ret != XA_CARDINAL) || (format_ret != 32))
122 num = -1;
123 else if ((num_ret == 0) || (!prop_ret))
124 num = 0;
125 else
126 {
127 val = malloc(num_ret * sizeof(unsigned int));
128 if (!val)
129 {
130 if (prop_ret) XFree(prop_ret);
131 return -1;
132 }
133 for (i = 0; i < num_ret; i++)
134 val[i] = ((unsigned long *)prop_ret)[i];
135 num = num_ret;
136 *plst = val;
137 }
138
139 if (prop_ret)
140 XFree(prop_ret);
141
142 return num;
143} /* ecore_x_window_prop_card32_list_get */
144
145/*
146 * Set X ID (array) property
147 */
148EAPI void
149ecore_x_window_prop_xid_set(Ecore_X_Window win,
150 Ecore_X_Atom atom,
151 Ecore_X_Atom type,
152 Ecore_X_ID *lst,
153 unsigned int num)
154{
155#if SIZEOF_INT == SIZEOF_LONG
156 XChangeProperty(_ecore_x_disp, win, atom, type, 32, PropModeReplace,
157 (unsigned char *)lst, num);
158#else /* if SIZEOF_INT == SIZEOF_LONG */
159 unsigned long *pl;
160 unsigned int i;
161
162 LOGFN(__FILE__, __LINE__, __FUNCTION__);
163 pl = malloc(num * sizeof(long));
164 if (!pl)
165 return;
166
167 for (i = 0; i < num; i++)
168 pl[i] = lst[i];
169 XChangeProperty(_ecore_x_disp, win, atom, type, 32, PropModeReplace,
170 (unsigned char *)pl, num);
171 free(pl);
172#endif /* if SIZEOF_INT == SIZEOF_LONG */
173} /* ecore_x_window_prop_xid_set */
174
175/*
176 * Get X ID (array) property
177 *
178 * At most len items are returned in val.
179 * If the property was successfully fetched the number of items stored in
180 * val is returned, otherwise -1 is returned.
181 * Note: Return value 0 means that the property exists but has no elements.
182 */
183EAPI int
184ecore_x_window_prop_xid_get(Ecore_X_Window win,
185 Ecore_X_Atom atom,
186 Ecore_X_Atom type,
187 Ecore_X_ID *lst,
188 unsigned int len)
189{
190 unsigned char *prop_ret;
191 Atom type_ret;
192 unsigned long bytes_after, num_ret;
193 int format_ret;
194 int num;
195 unsigned i;
196
197 LOGFN(__FILE__, __LINE__, __FUNCTION__);
198 prop_ret = NULL;
199 if (XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False,
200 type, &type_ret, &format_ret, &num_ret,
201 &bytes_after, &prop_ret) != Success)
202 return -1;
203
204 if (type_ret != type || format_ret != 32)
205 num = -1;
206 else if (num_ret == 0 || !prop_ret)
207 num = 0;
208 else
209 {
210 if (num_ret < len)
211 len = num_ret;
212
213 for (i = 0; i < len; i++)
214 lst[i] = ((unsigned long *)prop_ret)[i];
215 num = len;
216 }
217
218 if (prop_ret)
219 XFree(prop_ret);
220
221 return num;
222} /* ecore_x_window_prop_xid_get */
223
224/*
225 * Get X ID (array) property
226 *
227 * If the property was successfully fetched the number of items stored in
228 * val is returned, otherwise -1 is returned.
229 * The returned array must be freed with free().
230 * Note: Return value 0 means that the property exists but has no elements.
231 */
232EAPI int
233ecore_x_window_prop_xid_list_get(Ecore_X_Window win,
234 Ecore_X_Atom atom,
235 Ecore_X_Atom type,
236 Ecore_X_ID **val)
237{
238 unsigned char *prop_ret;
239 Atom type_ret;
240 unsigned long bytes_after, num_ret;
241 int format_ret;
242 Ecore_X_Atom *alst;
243 int num;
244 unsigned i;
245
246 LOGFN(__FILE__, __LINE__, __FUNCTION__);
247 *val = NULL;
248 prop_ret = NULL;
249 if (XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False,
250 type, &type_ret, &format_ret, &num_ret,
251 &bytes_after, &prop_ret) != Success)
252 return -1;
253
254 if (type_ret != type || format_ret != 32)
255 num = -1;
256 else if (num_ret == 0 || !prop_ret)
257 num = 0;
258 else
259 {
260 alst = malloc(num_ret * sizeof(Ecore_X_ID));
261 for (i = 0; i < num_ret; i++)
262 alst[i] = ((unsigned long *)prop_ret)[i];
263 num = num_ret;
264 *val = alst;
265 }
266
267 if (prop_ret)
268 XFree(prop_ret);
269
270 return num;
271} /* ecore_x_window_prop_xid_list_get */
272
273/*
274 * Remove/add/toggle X ID list item.
275 */
276EAPI void
277ecore_x_window_prop_xid_list_change(Ecore_X_Window win,
278 Ecore_X_Atom atom,
279 Ecore_X_Atom type,
280 Ecore_X_ID item,
281 int op)
282{
283 Ecore_X_ID *lst;
284 int i, num;
285
286 LOGFN(__FILE__, __LINE__, __FUNCTION__);
287 num = ecore_x_window_prop_xid_list_get(win, atom, type, &lst);
288 if (num < 0)
289 {
290 return; /* Error - assuming invalid window */
291 }
292
293 /* Is it there? */
294 for (i = 0; i < num; i++)
295 {
296 if (lst[i] == item)
297 break;
298 }
299
300 if (i < num)
301 {
302 /* Was in list */
303 if (op == ECORE_X_PROP_LIST_ADD)
304 goto done; /* Remove it */
305
306 num--;
307 for (; i < num; i++)
308 lst[i] = lst[i + 1];
309 }
310 else
311 {
312 /* Was not in list */
313 if (op == ECORE_X_PROP_LIST_REMOVE)
314 goto done; /* Add it */
315
316 num++;
317 lst = realloc(lst, num * sizeof(Ecore_X_ID));
318 lst[i] = item;
319 }
320
321 ecore_x_window_prop_xid_set(win, atom, type, lst, num);
322
323done:
324 if (lst)
325 free(lst);
326} /* ecore_x_window_prop_xid_list_change */
327
328/*
329 * Set Atom (array) property
330 */
331EAPI void
332ecore_x_window_prop_atom_set(Ecore_X_Window win,
333 Ecore_X_Atom atom,
334 Ecore_X_Atom *lst,
335 unsigned int num)
336{
337 LOGFN(__FILE__, __LINE__, __FUNCTION__);
338 ecore_x_window_prop_xid_set(win, atom, XA_ATOM, lst, num);
339} /* ecore_x_window_prop_atom_set */
340
341/*
342 * Get Atom (array) property
343 *
344 * At most len items are returned in val.
345 * If the property was successfully fetched the number of items stored in
346 * val is returned, otherwise -1 is returned.
347 * Note: Return value 0 means that the property exists but has no elements.
348 */
349EAPI int
350ecore_x_window_prop_atom_get(Ecore_X_Window win,
351 Ecore_X_Atom atom,
352 Ecore_X_Atom *lst,
353 unsigned int len)
354{
355 LOGFN(__FILE__, __LINE__, __FUNCTION__);
356 return ecore_x_window_prop_xid_get(win, atom, XA_ATOM, lst, len);
357} /* ecore_x_window_prop_atom_get */
358
359/*
360 * Get Atom (array) property
361 *
362 * If the property was successfully fetched the number of items stored in
363 * val is returned, otherwise -1 is returned.
364 * The returned array must be freed with free().
365 * Note: Return value 0 means that the property exists but has no elements.
366 */
367EAPI int
368ecore_x_window_prop_atom_list_get(Ecore_X_Window win,
369 Ecore_X_Atom atom,
370 Ecore_X_Atom **plst)
371{
372 LOGFN(__FILE__, __LINE__, __FUNCTION__);
373 return ecore_x_window_prop_xid_list_get(win, atom, XA_ATOM, plst);
374} /* ecore_x_window_prop_atom_list_get */
375
376/*
377 * Remove/add/toggle atom list item.
378 */
379EAPI void
380ecore_x_window_prop_atom_list_change(Ecore_X_Window win,
381 Ecore_X_Atom atom,
382 Ecore_X_Atom item,
383 int op)
384{
385 LOGFN(__FILE__, __LINE__, __FUNCTION__);
386 ecore_x_window_prop_xid_list_change(win, atom, XA_ATOM, item, op);
387} /* ecore_x_window_prop_atom_list_change */
388
389/*
390 * Set Window (array) property
391 */
392EAPI void
393ecore_x_window_prop_window_set(Ecore_X_Window win,
394 Ecore_X_Atom atom,
395 Ecore_X_Window *lst,
396 unsigned int num)
397{
398 LOGFN(__FILE__, __LINE__, __FUNCTION__);
399 ecore_x_window_prop_xid_set(win, atom, XA_WINDOW, lst, num);
400} /* ecore_x_window_prop_window_set */
401
402/*
403 * Get Window (array) property
404 *
405 * At most len items are returned in val.
406 * If the property was successfully fetched the number of items stored in
407 * val is returned, otherwise -1 is returned.
408 * Note: Return value 0 means that the property exists but has no elements.
409 */
410EAPI int
411ecore_x_window_prop_window_get(Ecore_X_Window win,
412 Ecore_X_Atom atom,
413 Ecore_X_Window *lst,
414 unsigned int len)
415{
416 LOGFN(__FILE__, __LINE__, __FUNCTION__);
417 return ecore_x_window_prop_xid_get(win, atom, XA_WINDOW, lst, len);
418} /* ecore_x_window_prop_window_get */
419
420/*
421 * Get Window (array) property
422 *
423 * If the property was successfully fetched the number of items stored in
424 * val is returned, otherwise -1 is returned.
425 * The returned array must be freed with free().
426 * Note: Return value 0 means that the property exists but has no elements.
427 */
428EAPI int
429ecore_x_window_prop_window_list_get(Ecore_X_Window win,
430 Ecore_X_Atom atom,
431 Ecore_X_Window **plst)
432{
433 LOGFN(__FILE__, __LINE__, __FUNCTION__);
434 return ecore_x_window_prop_xid_list_get(win, atom, XA_WINDOW, plst);
435} /* ecore_x_window_prop_window_list_get */
436
437/**
438 * To be documented.
439 *
440 * FIXME: To be fixed.
441 */
442EAPI Ecore_X_Atom
443ecore_x_window_prop_any_type(void)
444{
445 return AnyPropertyType;
446} /* ecore_x_window_prop_any_type */
447
448/**
449 * To be documented.
450 *
451 * FIXME: To be fixed.
452 */
453EAPI void
454ecore_x_window_prop_property_set(Ecore_X_Window win,
455 Ecore_X_Atom property,
456 Ecore_X_Atom type,
457 int size,
458 void *data,
459 int number)
460{
461 LOGFN(__FILE__, __LINE__, __FUNCTION__);
462 if (win == 0)
463 win = DefaultRootWindow(_ecore_x_disp);
464
465 if (size != 32)
466 XChangeProperty(_ecore_x_disp,
467 win,
468 property,
469 type,
470 size,
471 PropModeReplace,
472 (unsigned char *)data,
473 number);
474 else
475 {
476 unsigned long *dat;
477 int i, *ptr;
478
479 dat = malloc(sizeof(unsigned long) * number);
480 if (dat)
481 {
482 for (ptr = (int *)data, i = 0; i < number; i++) dat[i] = ptr[i];
483 XChangeProperty(_ecore_x_disp, win, property, type, size,
484 PropModeReplace, (unsigned char *)dat, number);
485 free(dat);
486 }
487 }
488} /* ecore_x_window_prop_property_set */
489
490/**
491 * To be documented.
492 *
493 * FIXME: To be fixed.
494 */
495EAPI int
496ecore_x_window_prop_property_get(Ecore_X_Window win,
497 Ecore_X_Atom property,
498 Ecore_X_Atom type,
499 int size __UNUSED__,
500 unsigned char **data,
501 int *num)
502{
503 Atom type_ret = 0;
504 int ret, size_ret = 0;
505 unsigned long num_ret = 0, bytes = 0, i;
506 unsigned char *prop_ret = NULL;
507
508 /* make sure these are initialized */
509 if (num)
510 *num = 0;
511
512 if (data)
513 *data = NULL;
514 else /* we can't store the retrieved data, so just return */
515 return 0;
516
517 LOGFN(__FILE__, __LINE__, __FUNCTION__);
518 if (!win)
519 win = DefaultRootWindow(_ecore_x_disp);
520
521 ret = XGetWindowProperty(_ecore_x_disp, win, property, 0, LONG_MAX,
522 False, type, &type_ret, &size_ret,
523 &num_ret, &bytes, &prop_ret);
524
525 if (ret != Success)
526 return 0;
527
528 if (!num_ret)
529 {
530 XFree(prop_ret);
531 return 0;
532 }
533
534 if (!(*data = malloc(num_ret * size_ret / 8)))
535 {
536 XFree(prop_ret);
537 return 0;
538 }
539
540 switch (size_ret) {
541 case 8:
542 for (i = 0; i < num_ret; i++)
543 (*data)[i] = prop_ret[i];
544 break;
545
546 case 16:
547 for (i = 0; i < num_ret; i++)
548 ((unsigned short *)*data)[i] = ((unsigned short *)prop_ret)[i];
549 break;
550
551 case 32:
552 for (i = 0; i < num_ret; i++)
553 ((unsigned int *)*data)[i] = ((unsigned long *)prop_ret)[i];
554 break;
555 } /* switch */
556
557 XFree(prop_ret);
558
559 if (num)
560 *num = num_ret;
561
562 return size_ret;
563} /* ecore_x_window_prop_property_get */
564
565EAPI void
566ecore_x_window_prop_property_del(Ecore_X_Window win,
567 Ecore_X_Atom property)
568{
569 LOGFN(__FILE__, __LINE__, __FUNCTION__);
570 XDeleteProperty(_ecore_x_disp, win, property);
571} /* ecore_x_window_prop_property_del */
572
573EAPI Ecore_X_Atom *
574ecore_x_window_prop_list(Ecore_X_Window win,
575 int *num_ret)
576{
577 Ecore_X_Atom *atoms;
578 Atom *atom_ret;
579 int num = 0, i;
580
581 LOGFN(__FILE__, __LINE__, __FUNCTION__);
582 if (num_ret)
583 *num_ret = 0;
584
585 atom_ret = XListProperties(_ecore_x_disp, win, &num);
586 if (!atom_ret)
587 return NULL;
588
589 atoms = malloc(num * sizeof(Ecore_X_Atom));
590 if (atoms)
591 {
592 for (i = 0; i < num; i++) atoms[i] = atom_ret[i];
593 if (num_ret)
594 *num_ret = num;
595 }
596
597 XFree(atom_ret);
598 return atoms;
599} /* ecore_x_window_prop_list */
600
601/**
602 * Set a window string property.
603 * @param win The window
604 * @param type The property
605 * @param str The string
606 *
607 * Set a window string property
608 */
609EAPI void
610ecore_x_window_prop_string_set(Ecore_X_Window win,
611 Ecore_X_Atom type,
612 const char *str)
613{
614 XTextProperty xtp;
615
616 LOGFN(__FILE__, __LINE__, __FUNCTION__);
617 if (win == 0)
618 win = DefaultRootWindow(_ecore_x_disp);
619
620 xtp.value = (unsigned char *)str;
621 xtp.format = 8;
622 xtp.encoding = ECORE_X_ATOM_UTF8_STRING;
623 xtp.nitems = strlen(str);
624 XSetTextProperty(_ecore_x_disp, win, &xtp, type);
625} /* ecore_x_window_prop_string_set */
626
627/**
628 * Get a window string property.
629 * @param win The window
630 * @param type The property
631 *
632 * Return window string property of a window. String must be free'd when done.
633 */
634EAPI char *
635ecore_x_window_prop_string_get(Ecore_X_Window win,
636 Ecore_X_Atom type)
637{
638 XTextProperty xtp;
639 char *str = NULL;
640
641 LOGFN(__FILE__, __LINE__, __FUNCTION__);
642 if (win == 0)
643 win = DefaultRootWindow(_ecore_x_disp);
644
645 if (XGetTextProperty(_ecore_x_disp, win, &xtp, type))
646 {
647 int items;
648 char **list = NULL;
649 Status s;
650
651 if (xtp.encoding == ECORE_X_ATOM_UTF8_STRING)
652 str = strdup((char *)xtp.value);
653 else
654 {
655#ifdef X_HAVE_UTF8_STRING
656 s = Xutf8TextPropertyToTextList(_ecore_x_disp, &xtp,
657 &list, &items);
658#else /* ifdef X_HAVE_UTF8_STRING */
659 s = XmbTextPropertyToTextList(_ecore_x_disp, &xtp,
660 &list, &items);
661#endif /* ifdef X_HAVE_UTF8_STRING */
662 if ((s == XLocaleNotSupported) ||
663 (s == XNoMemory) || (s == XConverterNotFound))
664 str = strdup((char *)xtp.value);
665 else if ((s >= Success) && (items > 0))
666 str = strdup(list[0]);
667
668 if (list)
669 XFreeStringList(list);
670 }
671
672 XFree(xtp.value);
673 }
674
675 return str;
676} /* ecore_x_window_prop_string_get */
677
678EAPI Eina_Bool
679ecore_x_window_prop_protocol_isset(Ecore_X_Window win,
680 Ecore_X_WM_Protocol protocol)
681{
682 Atom proto, *protos = NULL;
683 int i, protos_count = 0;
684 Eina_Bool ret = EINA_FALSE;
685
686 /* check for invalid values */
687 if (protocol >= ECORE_X_WM_PROTOCOL_NUM)
688 return EINA_FALSE;
689
690 LOGFN(__FILE__, __LINE__, __FUNCTION__);
691 proto = _ecore_x_atoms_wm_protocols[protocol];
692
693 if (!XGetWMProtocols(_ecore_x_disp, win, &protos, &protos_count))
694 return ret;
695
696 for (i = 0; i < protos_count; i++)
697 if (protos[i] == proto)
698 {
699 ret = EINA_TRUE;
700 break;
701 }
702
703 XFree(protos);
704
705 return ret;
706} /* ecore_x_window_prop_protocol_isset */
707
708/**
709 * To be documented.
710 *
711 * FIXME: To be fixed.
712 */
713EAPI Ecore_X_WM_Protocol *
714ecore_x_window_prop_protocol_list_get(Ecore_X_Window win,
715 int *num_ret)
716{
717 Atom *protos = NULL;
718 int i, protos_count = 0;
719 Ecore_X_WM_Protocol *prot_ret = NULL;
720
721 LOGFN(__FILE__, __LINE__, __FUNCTION__);
722 if (!XGetWMProtocols(_ecore_x_disp, win, &protos, &protos_count))
723 return NULL;
724
725 if ((!protos) || (protos_count <= 0))
726 return NULL;
727
728 prot_ret = calloc(1, protos_count * sizeof(Ecore_X_WM_Protocol));
729 if (!prot_ret)
730 {
731 XFree(protos);
732 return NULL;
733 }
734
735 for (i = 0; i < protos_count; i++)
736 {
737 Ecore_X_WM_Protocol j;
738
739 prot_ret[i] = -1;
740 for (j = 0; j < ECORE_X_WM_PROTOCOL_NUM; j++)
741 {
742 if (_ecore_x_atoms_wm_protocols[j] == protos[i])
743 prot_ret[i] = j;
744 }
745 }
746 XFree(protos);
747 *num_ret = protos_count;
748 return prot_ret;
749} /* ecore_x_window_prop_protocol_list_get */
750
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_window_shape.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_window_shape.c
new file mode 100644
index 0000000..2e8f8ce
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_window_shape.c
@@ -0,0 +1,658 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <stdlib.h>
6
7#include "Ecore.h"
8#include "ecore_x_private.h"
9#include "Ecore_X.h"
10
11/**
12 * @defgroup Ecore_X_Window_Shape X Window Shape Functions
13 *
14 * These functions use the shape extension of the X server to change
15 * shape of given windows.
16 */
17
18/**
19 * Sets the shape of the given window to that given by the pixmap @p mask.
20 * @param win The given window.
21 * @param mask A 2-bit depth pixmap that provides the new shape of the
22 * window.
23 * @ingroup Ecore_X_Window_Shape
24 */
25EAPI void
26ecore_x_window_shape_mask_set(Ecore_X_Window win,
27 Ecore_X_Pixmap mask)
28{
29 LOGFN(__FILE__, __LINE__, __FUNCTION__);
30 XShapeCombineMask(_ecore_x_disp, win, ShapeBounding, 0, 0, mask, ShapeSet);
31} /* ecore_x_window_shape_mask_set */
32
33/**
34 * Sets the input shape of the given window to that given by the pixmap @p mask.
35 * @param win The given window.
36 * @param mask A 1-bit depth pixmap that provides the new input shape of the
37 * window.
38 * @ingroup Ecore_X_Window_Shape
39 */
40EAPI void
41ecore_x_window_shape_input_mask_set(Ecore_X_Window win,
42 Ecore_X_Pixmap mask)
43{
44 LOGFN(__FILE__, __LINE__, __FUNCTION__);
45#ifdef ShapeInput
46 XShapeCombineMask(_ecore_x_disp, win, ShapeInput, 0, 0, mask, ShapeSet);
47#else /* ifdef ShapeInput */
48 return;
49 win = mask = 0;
50#endif /* ifdef ShapeInput */
51} /* ecore_x_window_shape_input_mask_set */
52
53EAPI void
54ecore_x_window_shape_window_set(Ecore_X_Window win,
55 Ecore_X_Window shape_win)
56{
57 LOGFN(__FILE__, __LINE__, __FUNCTION__);
58 XShapeCombineShape(_ecore_x_disp,
59 win,
60 ShapeBounding,
61 0,
62 0,
63 shape_win,
64 ShapeBounding,
65 ShapeSet);
66} /* ecore_x_window_shape_window_set */
67
68EAPI void
69ecore_x_window_shape_input_window_set(Ecore_X_Window win,
70 Ecore_X_Window shape_win)
71{
72#ifdef ShapeInput
73 LOGFN(__FILE__, __LINE__, __FUNCTION__);
74 XShapeCombineShape(_ecore_x_disp,
75 win,
76 ShapeInput,
77 0,
78 0,
79 shape_win,
80 ShapeInput,
81 ShapeSet);
82#else
83 return;
84 win = shape_win = 0;
85#endif
86} /* ecore_x_window_shape_input_window_set */
87
88EAPI void
89ecore_x_window_shape_window_set_xy(Ecore_X_Window win,
90 Ecore_X_Window shape_win,
91 int x,
92 int y)
93{
94 LOGFN(__FILE__, __LINE__, __FUNCTION__);
95 XShapeCombineShape(_ecore_x_disp,
96 win,
97 ShapeBounding,
98 x,
99 y,
100 shape_win,
101 ShapeBounding,
102 ShapeSet);
103} /* ecore_x_window_shape_window_set_xy */
104
105EAPI void
106ecore_x_window_shape_input_window_set_xy(Ecore_X_Window win,
107 Ecore_X_Window shape_win,
108 int x,
109 int y)
110{
111#ifdef ShapeInput
112 LOGFN(__FILE__, __LINE__, __FUNCTION__);
113 XShapeCombineShape(_ecore_x_disp,
114 win,
115 ShapeInput,
116 x,
117 y,
118 shape_win,
119 ShapeInput,
120 ShapeSet);
121#else
122 return;
123 win = shape_win = x = y = 0;
124#endif
125} /* ecore_x_window_shape_input_window_set_xy */
126
127EAPI void
128ecore_x_window_shape_rectangle_set(Ecore_X_Window win,
129 int x,
130 int y,
131 int w,
132 int h)
133{
134 XRectangle rect;
135
136 LOGFN(__FILE__, __LINE__, __FUNCTION__);
137 rect.x = x;
138 rect.y = y;
139 rect.width = w;
140 rect.height = h;
141 XShapeCombineRectangles(_ecore_x_disp,
142 win,
143 ShapeBounding,
144 0,
145 0,
146 &rect,
147 1,
148 ShapeSet,
149 Unsorted);
150} /* ecore_x_window_shape_rectangle_set */
151
152EAPI void
153ecore_x_window_shape_input_rectangle_set(Ecore_X_Window win,
154 int x,
155 int y,
156 int w,
157 int h)
158{
159#ifdef ShapeInput
160 XRectangle rect;
161
162 LOGFN(__FILE__, __LINE__, __FUNCTION__);
163 rect.x = x;
164 rect.y = y;
165 rect.width = w;
166 rect.height = h;
167 XShapeCombineRectangles(_ecore_x_disp,
168 win,
169 ShapeInput,
170 0,
171 0,
172 &rect,
173 1,
174 ShapeSet,
175 Unsorted);
176#else
177 return;
178 win = x = y = w = h = 0;
179#endif
180} /* ecore_x_window_shape_input_rectangle_set */
181
182EAPI void
183ecore_x_window_shape_rectangles_set(Ecore_X_Window win,
184 Ecore_X_Rectangle *rects,
185 int num)
186{
187#ifdef ShapeInput
188 XRectangle *rect = NULL;
189 int i;
190
191 LOGFN(__FILE__, __LINE__, __FUNCTION__);
192 if (!rects) return;
193 if (num > 0)
194 {
195 rect = malloc(sizeof(XRectangle) * num);
196 if (!rect) return;
197 for (i = 0; i < num; i++)
198 {
199 rect[i].x = rects[i].x;
200 rect[i].y = rects[i].y;
201 rect[i].width = rects[i].width;
202 rect[i].height = rects[i].height;
203 }
204 }
205 XShapeCombineRectangles(_ecore_x_disp,
206 win,
207 ShapeBounding,
208 0,
209 0,
210 rect,
211 num,
212 ShapeSet,
213 Unsorted);
214 if (rect) free(rect);
215#else
216 return;
217 win = rects = num = 0;
218#endif
219} /* ecore_x_window_shape_rectangles_set */
220
221EAPI void
222ecore_x_window_shape_input_rectangles_set(Ecore_X_Window win,
223 Ecore_X_Rectangle *rects,
224 int num)
225{
226#ifdef ShapeInput
227 XRectangle *rect = NULL;
228 int i;
229
230 LOGFN(__FILE__, __LINE__, __FUNCTION__);
231 if (!rects) return;
232 if (num > 0)
233 {
234 rect = malloc(sizeof(XRectangle) * num);
235 if (!rect) return;
236 for (i = 0; i < num; i++)
237 {
238 rect[i].x = rects[i].x;
239 rect[i].y = rects[i].y;
240 rect[i].width = rects[i].width;
241 rect[i].height = rects[i].height;
242 }
243 }
244 XShapeCombineRectangles(_ecore_x_disp,
245 win,
246 ShapeInput,
247 0,
248 0,
249 rect,
250 num,
251 ShapeSet,
252 Unsorted);
253 if (rect) free(rect);
254#else
255 return;
256 win = rects = num = 0;
257#endif
258} /* ecore_x_window_shape_input_rectangles_set */
259
260EAPI void
261ecore_x_window_shape_rectangle_subtract(Ecore_X_Window win,
262 int x,
263 int y,
264 int w,
265 int h)
266{
267 XRectangle rect;
268
269 LOGFN(__FILE__, __LINE__, __FUNCTION__);
270 rect.x = x;
271 rect.y = y;
272 rect.width = w;
273 rect.height = h;
274 XShapeCombineRectangles(_ecore_x_disp,
275 win,
276 ShapeBounding,
277 0,
278 0,
279 &rect,
280 1,
281 ShapeSubtract,
282 Unsorted);
283} /* ecore_x_window_shape_rectangle_subtract */
284
285EAPI void
286ecore_x_window_shape_input_rectangle_subtract(Ecore_X_Window win,
287 int x,
288 int y,
289 int w,
290 int h)
291{
292#ifdef ShapeInput
293 XRectangle rect;
294
295 LOGFN(__FILE__, __LINE__, __FUNCTION__);
296 rect.x = x;
297 rect.y = y;
298 rect.width = w;
299 rect.height = h;
300 XShapeCombineRectangles(_ecore_x_disp,
301 win,
302 ShapeInput,
303 0,
304 0,
305 &rect,
306 1,
307 ShapeSubtract,
308 Unsorted);
309#else
310 return;
311 win = x = y = w = h = 0;
312#endif
313} /* ecore_x_window_shape_input_rectangle_subtract */
314
315EAPI void
316ecore_x_window_shape_window_add(Ecore_X_Window win,
317 Ecore_X_Window shape_win)
318{
319 LOGFN(__FILE__, __LINE__, __FUNCTION__);
320 XShapeCombineShape(_ecore_x_disp,
321 win,
322 ShapeBounding,
323 0,
324 0,
325 shape_win,
326 ShapeBounding,
327 ShapeUnion);
328} /* ecore_x_window_shape_window_add */
329
330EAPI void
331ecore_x_window_shape_window_add_xy(Ecore_X_Window win,
332 Ecore_X_Window shape_win,
333 int x,
334 int y)
335{
336 LOGFN(__FILE__, __LINE__, __FUNCTION__);
337 XShapeCombineShape(_ecore_x_disp,
338 win,
339 ShapeBounding,
340 x,
341 y,
342 shape_win,
343 ShapeBounding,
344 ShapeUnion);
345} /* ecore_x_window_shape_window_add_xy */
346
347EAPI void
348ecore_x_window_shape_input_window_add_xy(Ecore_X_Window win,
349 Ecore_X_Window shape_win,
350 int x,
351 int y)
352{
353#ifdef ShapeInput
354 LOGFN(__FILE__, __LINE__, __FUNCTION__);
355 XShapeCombineShape(_ecore_x_disp,
356 win,
357 ShapeInput,
358 x,
359 y,
360 shape_win,
361 ShapeInput,
362 ShapeUnion);
363#else
364 return;
365 win = shape_win = x = y = 0;
366#endif
367} /* ecore_x_window_shape_input_window_add_xy */
368
369EAPI void
370ecore_x_window_shape_rectangle_add(Ecore_X_Window win,
371 int x,
372 int y,
373 int w,
374 int h)
375{
376 XRectangle rect;
377
378 LOGFN(__FILE__, __LINE__, __FUNCTION__);
379 rect.x = x;
380 rect.y = y;
381 rect.width = w;
382 rect.height = h;
383 XShapeCombineRectangles(_ecore_x_disp,
384 win,
385 ShapeBounding,
386 0,
387 0,
388 &rect,
389 1,
390 ShapeUnion,
391 Unsorted);
392} /* ecore_x_window_shape_rectangle_add */
393
394EAPI void
395ecore_x_window_shape_input_rectangle_add(Ecore_X_Window win,
396 int x,
397 int y,
398 int w,
399 int h)
400{
401#ifdef ShapeInput
402 XRectangle rect;
403
404 LOGFN(__FILE__, __LINE__, __FUNCTION__);
405 rect.x = x;
406 rect.y = y;
407 rect.width = w;
408 rect.height = h;
409 XShapeCombineRectangles(_ecore_x_disp,
410 win,
411 ShapeInput,
412 0,
413 0,
414 &rect,
415 1,
416 ShapeUnion,
417 Unsorted);
418#else
419 return;
420 win = x = y = w = h = 0;
421#endif
422} /* ecore_x_window_shape_input_rectangle_add */
423
424EAPI void
425ecore_x_window_shape_rectangle_clip(Ecore_X_Window win,
426 int x,
427 int y,
428 int w,
429 int h)
430{
431 XRectangle rect;
432
433 LOGFN(__FILE__, __LINE__, __FUNCTION__);
434 rect.x = x;
435 rect.y = y;
436 rect.width = w;
437 rect.height = h;
438 XShapeCombineRectangles(_ecore_x_disp,
439 win,
440 ShapeBounding,
441 0,
442 0,
443 &rect,
444 1,
445 ShapeIntersect,
446 Unsorted);
447} /* ecore_x_window_shape_rectangle_clip */
448
449EAPI void
450ecore_x_window_shape_input_rectangle_clip(Ecore_X_Window win,
451 int x,
452 int y,
453 int w,
454 int h)
455{
456#ifdef ShapeInput
457 XRectangle rect;
458
459 LOGFN(__FILE__, __LINE__, __FUNCTION__);
460 rect.x = x;
461 rect.y = y;
462 rect.width = w;
463 rect.height = h;
464 XShapeCombineRectangles(_ecore_x_disp,
465 win,
466 ShapeInput,
467 0,
468 0,
469 &rect,
470 1,
471 ShapeIntersect,
472 Unsorted);
473#else
474 return;
475 win = x = y = w = h = 0;
476#endif
477} /* ecore_x_window_shape_input_rectangle_clip */
478
479EAPI void
480ecore_x_window_shape_rectangles_add(Ecore_X_Window win,
481 Ecore_X_Rectangle *rects,
482 int num)
483{
484 XRectangle *rect = NULL;
485 int i;
486
487 LOGFN(__FILE__, __LINE__, __FUNCTION__);
488 if (num > 0)
489 {
490 rect = malloc(sizeof(XRectangle) * num);
491 if (!rect) return;
492 for (i = 0; i < num; i++)
493 {
494 rect[i].x = rects[i].x;
495 rect[i].y = rects[i].y;
496 rect[i].width = rects[i].width;
497 rect[i].height = rects[i].height;
498 }
499 }
500
501 XShapeCombineRectangles(_ecore_x_disp,
502 win,
503 ShapeBounding,
504 0,
505 0,
506 rect,
507 num,
508 ShapeUnion,
509 Unsorted);
510 if (rect) free(rect);
511} /* ecore_x_window_shape_rectangles_add */
512
513EAPI void
514ecore_x_window_shape_input_rectangles_add(Ecore_X_Window win,
515 Ecore_X_Rectangle *rects,
516 int num)
517{
518#ifdef ShapeInput
519 XRectangle *rect = NULL;
520 int i;
521
522 LOGFN(__FILE__, __LINE__, __FUNCTION__);
523 if (num > 0)
524 {
525 rect = malloc(sizeof(XRectangle) * num);
526 if (!rect) return;
527 for (i = 0; i < num; i++)
528 {
529 rect[i].x = rects[i].x;
530 rect[i].y = rects[i].y;
531 rect[i].width = rects[i].width;
532 rect[i].height = rects[i].height;
533 }
534 }
535
536 XShapeCombineRectangles(_ecore_x_disp,
537 win,
538 ShapeInput,
539 0,
540 0,
541 rect,
542 num,
543 ShapeUnion,
544 Unsorted);
545 if (rect) free(rect);
546#else
547 return;
548 win = rects = num = 0;
549#endif
550} /* ecore_x_window_shape_input_rectangles_add */
551
552EAPI Ecore_X_Rectangle *
553ecore_x_window_shape_rectangles_get(Ecore_X_Window win,
554 int *num_ret)
555{
556 XRectangle *rect;
557 Ecore_X_Rectangle *rects = NULL;
558 int i, num = 0, ord;
559
560 LOGFN(__FILE__, __LINE__, __FUNCTION__);
561 rect = XShapeGetRectangles(_ecore_x_disp, win, ShapeBounding, &num, &ord);
562 if (rect)
563 {
564 if (num < 1)
565 {
566 XFree(rect);
567 if (num_ret) *num_ret = 0;
568 return NULL;
569 }
570 rects = malloc(sizeof(Ecore_X_Rectangle) * num);
571 if (!rects)
572 {
573 XFree(rect);
574 if (num_ret) *num_ret = 0;
575 return NULL;
576 }
577 for (i = 0; i < num; i++)
578 {
579 rects[i].x = rect[i].x;
580 rects[i].y = rect[i].y;
581 rects[i].width = rect[i].width;
582 rects[i].height = rect[i].height;
583 }
584 XFree(rect);
585 }
586 if (num_ret) *num_ret = num;
587 return rects;
588} /* ecore_x_window_shape_rectangles_get */
589
590EAPI Ecore_X_Rectangle *
591ecore_x_window_shape_input_rectangles_get(Ecore_X_Window win,
592 int *num_ret)
593{
594 Ecore_X_Rectangle *rects = NULL;
595#ifdef ShapeInput
596 XRectangle *rect;
597 int i, num = 0, ord;
598
599 LOGFN(__FILE__, __LINE__, __FUNCTION__);
600 rect = XShapeGetRectangles(_ecore_x_disp, win, ShapeInput, &num, &ord);
601 if (rect)
602 {
603 if (num < 1)
604 {
605 XFree(rect);
606 if (num_ret) *num_ret = 0;
607 return NULL;
608 }
609 rects = malloc(sizeof(Ecore_X_Rectangle) * num);
610 if (!rects)
611 {
612 XFree(rect);
613 if (num_ret) *num_ret = 0;
614 return NULL;
615 }
616 for (i = 0; i < num; i++)
617 {
618 rects[i].x = rect[i].x;
619 rects[i].y = rect[i].y;
620 rects[i].width = rect[i].width;
621 rects[i].height = rect[i].height;
622 }
623 XFree(rect);
624 }
625 if (num_ret) *num_ret = num;
626 return rects;
627#else
628 // have to return fake shape input rect of size of window
629 Window dw;
630 unsigned int di;
631
632 if (num_ret) *num_ret = 0;
633 rects = malloc(sizeof(Ecore_X_Rectangle));
634 if (!rects) return NULL;
635 if (!XGetGeometry(_ecore_x_disp, win, &dw,
636 &(rects[0].x), &(rects[0].y),
637 &(rects[0].width), &(rects[0].height),
638 &di, &di))
639 {
640 free(rects);
641 return NULL;
642 }
643 if (num_ret) *num_ret = 1;
644 return rects;
645#endif
646} /* ecore_x_window_shape_input_rectangles_get */
647
648EAPI void
649ecore_x_window_shape_events_select(Ecore_X_Window win,
650 Eina_Bool on)
651{
652 LOGFN(__FILE__, __LINE__, __FUNCTION__);
653 if (on)
654 XShapeSelectInput(_ecore_x_disp, win, ShapeNotifyMask);
655 else
656 XShapeSelectInput(_ecore_x_disp, win, 0);
657} /* ecore_x_window_shape_events_select */
658
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_xi2.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_xi2.c
new file mode 100644
index 0000000..38a81dd
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_xi2.c
@@ -0,0 +1,283 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif /* ifdef HAVE_CONFIG_H */
4
5#include <string.h>
6
7#include "Ecore.h"
8#include "ecore_x_private.h"
9#include "Ecore_X.h"
10
11#ifdef ECORE_XI2
12#include "Ecore_Input.h"
13#endif /* ifdef ECORE_XI2 */
14
15int _ecore_x_xi2_opcode = -1;
16
17#ifndef XIPointerEmulated
18#define XIPointerEmulated (1 << 16)
19#endif
20
21#ifdef ECORE_XI2
22static XIDeviceInfo *_ecore_x_xi2_devs = NULL;
23static int _ecore_x_xi2_num = 0;
24#endif /* ifdef ECORE_XI2 */
25
26void
27_ecore_x_input_init(void)
28{
29#ifdef ECORE_XI2
30 int event, error;
31 int major = 2, minor = 0;
32
33 if (!XQueryExtension(_ecore_x_disp, "XInputExtension",
34 &_ecore_x_xi2_opcode, &event, &error))
35 {
36 _ecore_x_xi2_opcode = -1;
37 return;
38 }
39
40 if (XIQueryVersion(_ecore_x_disp, &major, &minor) == BadRequest)
41 {
42 _ecore_x_xi2_opcode = -1;
43 return;
44 }
45
46 _ecore_x_xi2_devs = XIQueryDevice(_ecore_x_disp, XIAllDevices,
47 &_ecore_x_xi2_num);
48#endif /* ifdef ECORE_XI2 */
49} /* _ecore_x_input_init */
50
51void
52_ecore_x_input_shutdown(void)
53{
54#ifdef ECORE_XI2
55 if (_ecore_x_xi2_devs)
56 {
57 XIFreeDeviceInfo(_ecore_x_xi2_devs);
58 _ecore_x_xi2_devs = NULL;
59 }
60
61 _ecore_x_xi2_num = 0;
62 _ecore_x_xi2_opcode = -1;
63#endif /* ifdef ECORE_XI2 */
64} /* _ecore_x_input_shutdown */
65
66void
67_ecore_x_input_handler(XEvent *xevent)
68{
69#ifdef ECORE_XI2
70 XIDeviceEvent *evd = (XIDeviceEvent *)(xevent->xcookie.data);
71 int devid = evd->deviceid;
72 int i;
73
74 if (_ecore_x_xi2_devs)
75 {
76 for (i = 0; i < _ecore_x_xi2_num; i++)
77 {
78 XIDeviceInfo *dev = &(_ecore_x_xi2_devs[i]);
79
80 if (devid == dev->deviceid)
81 {
82 if (dev->use == XIMasterPointer) return;
83 if ((dev->use == XISlavePointer) &&
84 (evd->flags & XIPointerEmulated)) return;
85 }
86 }
87 }
88 switch (xevent->xcookie.evtype)
89 {
90 case XI_Motion:
91 _ecore_mouse_move
92 (evd->time,
93 0, // state
94 evd->event_x, evd->event_y,
95 evd->root_x, evd->root_y,
96 evd->event,
97 (evd->child ? evd->child : evd->event),
98 evd->root,
99 1, // same_screen
100 devid, 1, 1,
101 1.0, // pressure
102 0.0, // angle
103 evd->event_x, evd->event_y,
104 evd->root_x, evd->root_y);
105 break;
106
107 case XI_ButtonPress:
108 _ecore_mouse_button
109 (ECORE_EVENT_MOUSE_BUTTON_DOWN,
110 evd->time,
111 0, // state
112 0, // button
113 evd->event_x, evd->event_y,
114 evd->root_x, evd->root_y,
115 evd->event,
116 (evd->child ? evd->child : evd->event),
117 evd->root,
118 1, // same_screen
119 devid, 1, 1,
120 1.0, // pressure
121 0.0, // angle
122 evd->event_x, evd->event_y,
123 evd->root_x, evd->root_y);
124 break;
125
126 case XI_ButtonRelease:
127 _ecore_mouse_button
128 (ECORE_EVENT_MOUSE_BUTTON_UP,
129 evd->time,
130 0, // state
131 0, // button
132 evd->event_x, evd->event_y,
133 evd->root_x, evd->root_y,
134 evd->event,
135 (evd->child ? evd->child : evd->event),
136 evd->root,
137 1, // same_screen
138 devid, 1, 1,
139 1.0, // pressure
140 0.0, // angle
141 evd->event_x, evd->event_y,
142 evd->root_x, evd->root_y);
143 break;
144
145#ifdef XI_TouchUpdate
146 case XI_TouchUpdate:
147 _ecore_mouse_move
148 (evd->time,
149 0, // state
150 evd->event_x, evd->event_y,
151 evd->root_x, evd->root_y,
152 evd->event,
153 (evd->child ? evd->child : evd->event),
154 evd->root,
155 1, // same_screen
156 devid, 1, 1,
157 1.0, // pressure
158 0.0, // angle
159 evd->event_x, evd->event_y,
160 evd->root_x, evd->root_y);
161 break;
162
163#endif
164#ifdef XI_TouchBegin
165 case XI_TouchBegin:
166 _ecore_mouse_button
167 (ECORE_EVENT_MOUSE_BUTTON_DOWN,
168 evd->time,
169 0, // state
170 0, // button
171 evd->event_x, evd->event_y,
172 evd->root_x, evd->root_y,
173 evd->event,
174 (evd->child ? evd->child : evd->event),
175 evd->root,
176 1, // same_screen
177 devid, 1, 1,
178 1.0, // pressure
179 0.0, // angle
180 evd->event_x, evd->event_y,
181 evd->root_x, evd->root_y);
182 break;
183
184#endif
185#ifdef XI_TouchEnd
186 case XI_TouchEnd:
187 _ecore_mouse_button
188 (ECORE_EVENT_MOUSE_BUTTON_UP,
189 evd->time,
190 0, // state
191 0, // button
192 evd->event_x, evd->event_y,
193 evd->root_x, evd->root_y,
194 evd->event,
195 (evd->child ? evd->child : evd->event),
196 evd->root,
197 1, // same_screen
198 devid, 1, 1,
199 1.0, // pressure
200 0.0, // angle
201 evd->event_x, evd->event_y,
202 evd->root_x, evd->root_y);
203 break;
204
205#endif
206 default:
207 break;
208 } /* switch */
209#endif /* ifdef ECORE_XI2 */
210} /* _ecore_x_input_handler */
211
212EAPI Eina_Bool
213ecore_x_input_multi_select(Ecore_X_Window win)
214{
215#ifdef ECORE_XI2
216 int i;
217 Eina_Bool find = EINA_FALSE;
218
219 if (!_ecore_x_xi2_devs)
220 return 0;
221
222 LOGFN(__FILE__, __LINE__, __FUNCTION__);
223 for (i = 0; i < _ecore_x_xi2_num; i++)
224 {
225 XIDeviceInfo *dev = &(_ecore_x_xi2_devs[i]);
226
227 if (dev->use == XIFloatingSlave)
228 {
229 XIEventMask eventmask;
230 unsigned char mask[4] = { 0 };
231
232 eventmask.deviceid = dev->deviceid;
233 eventmask.mask_len = sizeof(mask);
234 eventmask.mask = mask;
235 XISetMask(mask, XI_ButtonPress);
236 XISetMask(mask, XI_ButtonRelease);
237 XISetMask(mask, XI_Motion);
238 XISelectEvents(_ecore_x_disp, win, &eventmask, 1);
239 find = EINA_TRUE;
240 }
241 else if (dev->use == XISlavePointer)
242 {
243 XIDeviceInfo *atdev = NULL;
244 int j;
245
246 for (j = 0; j < _ecore_x_xi2_num; j++)
247 {
248 if (_ecore_x_xi2_devs[j].deviceid == dev->attachment)
249 atdev = &(_ecore_x_xi2_devs[j]);
250 }
251 if (((atdev) && (atdev->use != XIMasterPointer)) ||
252 (!atdev))
253 {
254 XIEventMask eventmask;
255 unsigned char mask[4] = { 0 };
256
257 eventmask.deviceid = dev->deviceid;
258 eventmask.mask_len = sizeof(mask);
259 eventmask.mask = mask;
260 XISetMask(mask, XI_ButtonPress);
261 XISetMask(mask, XI_ButtonRelease);
262 XISetMask(mask, XI_Motion);
263# ifdef XI_TouchUpdate
264 XISetMask(mask, XI_TouchUpdate);
265# endif
266# ifdef XI_TouchBegin
267 XISetMask(mask, XI_TouchBegin);
268# endif
269# ifdef XI_TouchEnd
270 XISetMask(mask, XI_TouchEnd);
271# endif
272 XISelectEvents(_ecore_x_disp, win, &eventmask, 1);
273 find = EINA_TRUE;
274 }
275 }
276 }
277
278 return find;
279#else /* ifdef ECORE_XI2 */
280 return EINA_FALSE;
281#endif /* ifdef ECORE_XI2 */
282} /* ecore_x_input_multi_select */
283
diff --git a/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_xinerama.c b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_xinerama.c
new file mode 100644
index 0000000..1d956b7
--- /dev/null
+++ b/libraries/ecore/src/lib/ecore_x/xlib/ecore_x_xinerama.c
@@ -0,0 +1,91 @@
1/*
2 * Xinerama code
3 */
4
5#ifdef HAVE_CONFIG_H
6# include <config.h>
7#endif /* ifdef HAVE_CONFIG_H */
8
9#include "Ecore.h"
10#include "ecore_x_private.h"
11#include "Ecore_X.h"
12#include "Ecore_X_Atoms.h"
13
14#ifdef ECORE_XINERAMA
15static XineramaScreenInfo *_xin_info = NULL;
16static int _xin_scr_num = 0;
17#endif /* ifdef ECORE_XINERAMA */
18
19EAPI int
20ecore_x_xinerama_screen_count_get(void)
21{
22#ifdef ECORE_XINERAMA
23 int event_base, error_base;
24
25 LOGFN(__FILE__, __LINE__, __FUNCTION__);
26 if (_xin_info)
27 XFree(_xin_info);
28
29 _xin_info = NULL;
30 if (XineramaQueryExtension(_ecore_x_disp, &event_base, &error_base))
31 {
32 _xin_info = XineramaQueryScreens(_ecore_x_disp, &_xin_scr_num);
33 if (_xin_info)
34 return _xin_scr_num;
35 }
36
37#endif /* ifdef ECORE_XINERAMA */
38 return 0;
39} /* ecore_x_xinerama_screen_count_get */
40
41EAPI Eina_Bool
42ecore_x_xinerama_screen_geometry_get(int screen,
43 int *x,
44 int *y,
45 int *w,
46 int *h)
47{
48 LOGFN(__FILE__, __LINE__, __FUNCTION__);
49#ifdef ECORE_XINERAMA
50 if (_xin_info)
51 {
52 int i;
53
54 for (i = 0; i < _xin_scr_num; i++)
55 {
56 if (_xin_info[i].screen_number == screen)
57 {
58 if (x)
59 *x = _xin_info[i].x_org;
60
61 if (y)
62 *y = _xin_info[i].y_org;
63
64 if (w)
65 *w = _xin_info[i].width;
66
67 if (h)
68 *h = _xin_info[i].height;
69
70 return EINA_TRUE;
71 }
72 }
73 }
74
75#endif /* ifdef ECORE_XINERAMA */
76 if (x)
77 *x = 0;
78
79 if (y)
80 *y = 0;
81
82 if (w)
83 *w = DisplayWidth(_ecore_x_disp, 0);
84
85 if (h)
86 *h = DisplayHeight(_ecore_x_disp, 0);
87
88 return EINA_FALSE;
89 screen = 0;
90} /* ecore_x_xinerama_screen_geometry_get */
91