diff options
Diffstat (limited to '')
41 files changed, 26501 insertions, 0 deletions
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/Makefile.am b/libraries/ecore/src/lib/ecore_x/xcb/Makefile.am new file mode 100644 index 0000000..366ebfd --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/Makefile.am | |||
@@ -0,0 +1,99 @@ | |||
1 | |||
2 | MAINTAINERCLEANFILES = Makefile.in ecore_xcb_keysym_table.h | ||
3 | |||
4 | if BUILD_ECORE_X_XCB | ||
5 | |||
6 | AM_CPPFLAGS = \ | ||
7 | @XCB_DAMAGE_CFLAGS@ \ | ||
8 | @XCB_COMPOSITE_CFLAGS@ \ | ||
9 | @XCB_DPMS_CFLAGS@ \ | ||
10 | @XCB_RANDR_CFLAGS@ \ | ||
11 | @XCB_RENDER_CFLAGS@ \ | ||
12 | @XCB_SCREENSAVER_CFLAGS@ \ | ||
13 | @XCB_SHAPE_CFLAGS@ \ | ||
14 | @XCB_SYNC_CFLAGS@ \ | ||
15 | @XCB_XFIXES_CFLAGS@ \ | ||
16 | @XCB_XINERAMA_CFLAGS@ \ | ||
17 | @XCB_XPRINT_CFLAGS@ \ | ||
18 | @XCB_XTEST_CFLAGS@ \ | ||
19 | @XCB_XINPUT_CFLAGS@ \ | ||
20 | @XCB_XGESTURE_CFLAGS@ \ | ||
21 | @XCB_CURSOR_CFLAGS@ \ | ||
22 | @ECORE_XCB_CFLAGS@ \ | ||
23 | @PIXMAN_CFLAGS@ \ | ||
24 | -I$(top_srcdir)/src/lib/ecore \ | ||
25 | -I$(top_srcdir)/src/lib/ecore_x \ | ||
26 | -I$(top_srcdir)/src/lib/ecore_input \ | ||
27 | -I$(top_builddir)/src/lib/ecore \ | ||
28 | -I$(top_builddir)/src/lib/ecore_x \ | ||
29 | -I$(top_builddir)/src/lib/ecore_input \ | ||
30 | @EINA_CFLAGS@ | ||
31 | |||
32 | noinst_LTLIBRARIES = libecore_x_xcb.la | ||
33 | |||
34 | libecore_x_xcb_la_SOURCES = \ | ||
35 | ecore_xcb.c \ | ||
36 | ecore_xcb_atoms.c \ | ||
37 | ecore_xcb_extensions.c \ | ||
38 | ecore_xcb_shape.c \ | ||
39 | ecore_xcb_screensaver.c \ | ||
40 | ecore_xcb_sync.c \ | ||
41 | ecore_xcb_render.c \ | ||
42 | ecore_xcb_randr.c \ | ||
43 | ecore_xcb_xfixes.c \ | ||
44 | ecore_xcb_composite.c \ | ||
45 | ecore_xcb_cursor.c \ | ||
46 | ecore_xcb_damage.c \ | ||
47 | ecore_xcb_dnd.c \ | ||
48 | ecore_xcb_dpms.c \ | ||
49 | ecore_xcb_drawable.c \ | ||
50 | ecore_xcb_e.c \ | ||
51 | ecore_xcb_gc.c \ | ||
52 | ecore_xcb_image.c \ | ||
53 | ecore_xcb_input.c \ | ||
54 | ecore_xcb_gesture.c \ | ||
55 | ecore_xcb_mwm.c \ | ||
56 | ecore_xcb_pixmap.c \ | ||
57 | ecore_xcb_region.c \ | ||
58 | ecore_xcb_selection.c \ | ||
59 | ecore_xcb_textlist.c \ | ||
60 | ecore_xcb_events.c \ | ||
61 | ecore_xcb_keymap.c \ | ||
62 | ecore_xcb_netwm.c \ | ||
63 | ecore_xcb_icccm.c \ | ||
64 | ecore_xcb_window.c \ | ||
65 | ecore_xcb_window_prop.c \ | ||
66 | ecore_xcb_window_shape.c \ | ||
67 | ecore_xcb_window_shadow.c \ | ||
68 | ecore_xcb_xinerama.c \ | ||
69 | ecore_xcb_error.c \ | ||
70 | ecore_xcb_xtest.c \ | ||
71 | ecore_xcb_vsync.c \ | ||
72 | ecore_xcb_xdefaults.c | ||
73 | |||
74 | libecore_x_xcb_la_LIBADD = \ | ||
75 | @XCB_DAMAGE_LIBS@ \ | ||
76 | @XCB_COMPOSITE_LIBS@ \ | ||
77 | @XCB_DPMS_LIBS@ \ | ||
78 | @XCB_RANDR_LIBS@ \ | ||
79 | @XCB_RENDER_LIBS@ \ | ||
80 | @XCB_SCREENSAVER_LIBS@ \ | ||
81 | @XCB_SHAPE_LIBS@ \ | ||
82 | @XCB_SYNC_LIBS@ \ | ||
83 | @XCB_XFIXES_LIBS@ \ | ||
84 | @XCB_XINERAMA_LIBS@ \ | ||
85 | @XCB_XPRINT_LIBS@ \ | ||
86 | @XCB_XTEST_LIBS@ \ | ||
87 | @XCB_XINPUT_LIBS@ \ | ||
88 | @XCB_XGESTURE_LIBS@ \ | ||
89 | @XCB_CURSOR_LIBS@ \ | ||
90 | @ECORE_XCB_LIBS@ \ | ||
91 | @PIXMAN_LIBS@ \ | ||
92 | $(top_builddir)/src/lib/ecore/libecore.la \ | ||
93 | $(top_builddir)/src/lib/ecore_input/libecore_input.la \ | ||
94 | @EINA_LIBS@ \ | ||
95 | @dlopen_libs@ | ||
96 | |||
97 | endif | ||
98 | |||
99 | EXTRA_DIST = ecore_xcb_private.h | ||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/Makefile.in b/libraries/ecore/src/lib/ecore_x/xcb/Makefile.in new file mode 100644 index 0000000..0213aea --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/Makefile.in | |||
@@ -0,0 +1,891 @@ | |||
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 | |||
18 | VPATH = @srcdir@ | ||
19 | pkgdatadir = $(datadir)/@PACKAGE@ | ||
20 | pkgincludedir = $(includedir)/@PACKAGE@ | ||
21 | pkglibdir = $(libdir)/@PACKAGE@ | ||
22 | pkglibexecdir = $(libexecdir)/@PACKAGE@ | ||
23 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd | ||
24 | install_sh_DATA = $(install_sh) -c -m 644 | ||
25 | install_sh_PROGRAM = $(install_sh) -c | ||
26 | install_sh_SCRIPT = $(install_sh) -c | ||
27 | INSTALL_HEADER = $(INSTALL_DATA) | ||
28 | transform = $(program_transform_name) | ||
29 | NORMAL_INSTALL = : | ||
30 | PRE_INSTALL = : | ||
31 | POST_INSTALL = : | ||
32 | NORMAL_UNINSTALL = : | ||
33 | PRE_UNINSTALL = : | ||
34 | POST_UNINSTALL = : | ||
35 | build_triplet = @build@ | ||
36 | host_triplet = @host@ | ||
37 | subdir = src/lib/ecore_x/xcb | ||
38 | DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in | ||
39 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 | ||
40 | am__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 | ||
58 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ | ||
59 | $(ACLOCAL_M4) | ||
60 | mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs | ||
61 | CONFIG_HEADER = $(top_builddir)/config.h | ||
62 | CONFIG_CLEAN_FILES = | ||
63 | CONFIG_CLEAN_VPATH_FILES = | ||
64 | LTLIBRARIES = $(noinst_LTLIBRARIES) | ||
65 | @BUILD_ECORE_X_XCB_TRUE@libecore_x_xcb_la_DEPENDENCIES = $(top_builddir)/src/lib/ecore/libecore.la \ | ||
66 | @BUILD_ECORE_X_XCB_TRUE@ $(top_builddir)/src/lib/ecore_input/libecore_input.la | ||
67 | am__libecore_x_xcb_la_SOURCES_DIST = ecore_xcb.c ecore_xcb_atoms.c \ | ||
68 | ecore_xcb_extensions.c ecore_xcb_shape.c \ | ||
69 | ecore_xcb_screensaver.c ecore_xcb_sync.c ecore_xcb_render.c \ | ||
70 | ecore_xcb_randr.c ecore_xcb_xfixes.c ecore_xcb_composite.c \ | ||
71 | ecore_xcb_cursor.c ecore_xcb_damage.c ecore_xcb_dnd.c \ | ||
72 | ecore_xcb_dpms.c ecore_xcb_drawable.c ecore_xcb_e.c \ | ||
73 | ecore_xcb_gc.c ecore_xcb_image.c ecore_xcb_input.c \ | ||
74 | ecore_xcb_gesture.c ecore_xcb_mwm.c ecore_xcb_pixmap.c \ | ||
75 | ecore_xcb_region.c ecore_xcb_selection.c ecore_xcb_textlist.c \ | ||
76 | ecore_xcb_events.c ecore_xcb_keymap.c ecore_xcb_netwm.c \ | ||
77 | ecore_xcb_icccm.c ecore_xcb_window.c ecore_xcb_window_prop.c \ | ||
78 | ecore_xcb_window_shape.c ecore_xcb_window_shadow.c \ | ||
79 | ecore_xcb_xinerama.c ecore_xcb_error.c ecore_xcb_xtest.c \ | ||
80 | ecore_xcb_vsync.c ecore_xcb_xdefaults.c | ||
81 | @BUILD_ECORE_X_XCB_TRUE@am_libecore_x_xcb_la_OBJECTS = ecore_xcb.lo \ | ||
82 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_atoms.lo \ | ||
83 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_extensions.lo \ | ||
84 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_shape.lo \ | ||
85 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_screensaver.lo \ | ||
86 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_sync.lo ecore_xcb_render.lo \ | ||
87 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_randr.lo ecore_xcb_xfixes.lo \ | ||
88 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_composite.lo \ | ||
89 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_cursor.lo \ | ||
90 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_damage.lo ecore_xcb_dnd.lo \ | ||
91 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_dpms.lo \ | ||
92 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_drawable.lo ecore_xcb_e.lo \ | ||
93 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_gc.lo ecore_xcb_image.lo \ | ||
94 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_input.lo \ | ||
95 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_gesture.lo ecore_xcb_mwm.lo \ | ||
96 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_pixmap.lo \ | ||
97 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_region.lo \ | ||
98 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_selection.lo \ | ||
99 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_textlist.lo \ | ||
100 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_events.lo \ | ||
101 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_keymap.lo ecore_xcb_netwm.lo \ | ||
102 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_icccm.lo ecore_xcb_window.lo \ | ||
103 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_window_prop.lo \ | ||
104 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_window_shape.lo \ | ||
105 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_window_shadow.lo \ | ||
106 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_xinerama.lo \ | ||
107 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_error.lo ecore_xcb_xtest.lo \ | ||
108 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_vsync.lo \ | ||
109 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_xdefaults.lo | ||
110 | libecore_x_xcb_la_OBJECTS = $(am_libecore_x_xcb_la_OBJECTS) | ||
111 | AM_V_lt = $(am__v_lt_$(V)) | ||
112 | am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) | ||
113 | am__v_lt_0 = --silent | ||
114 | @BUILD_ECORE_X_XCB_TRUE@am_libecore_x_xcb_la_rpath = | ||
115 | DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) | ||
116 | depcomp = $(SHELL) $(top_srcdir)/depcomp | ||
117 | am__depfiles_maybe = depfiles | ||
118 | am__mv = mv -f | ||
119 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ | ||
120 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) | ||
121 | LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ | ||
122 | $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ | ||
123 | $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ | ||
124 | $(AM_CFLAGS) $(CFLAGS) | ||
125 | AM_V_CC = $(am__v_CC_$(V)) | ||
126 | am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY)) | ||
127 | am__v_CC_0 = @echo " CC " $@; | ||
128 | AM_V_at = $(am__v_at_$(V)) | ||
129 | am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY)) | ||
130 | am__v_at_0 = @ | ||
131 | CCLD = $(CC) | ||
132 | LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ | ||
133 | $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ | ||
134 | $(AM_LDFLAGS) $(LDFLAGS) -o $@ | ||
135 | AM_V_CCLD = $(am__v_CCLD_$(V)) | ||
136 | am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) | ||
137 | am__v_CCLD_0 = @echo " CCLD " $@; | ||
138 | AM_V_GEN = $(am__v_GEN_$(V)) | ||
139 | am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY)) | ||
140 | am__v_GEN_0 = @echo " GEN " $@; | ||
141 | SOURCES = $(libecore_x_xcb_la_SOURCES) | ||
142 | DIST_SOURCES = $(am__libecore_x_xcb_la_SOURCES_DIST) | ||
143 | ETAGS = etags | ||
144 | CTAGS = ctags | ||
145 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) | ||
146 | ACLOCAL = @ACLOCAL@ | ||
147 | ALLOCA = @ALLOCA@ | ||
148 | AMTAR = @AMTAR@ | ||
149 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ | ||
150 | AR = @AR@ | ||
151 | AS = @AS@ | ||
152 | AUTOCONF = @AUTOCONF@ | ||
153 | AUTOHEADER = @AUTOHEADER@ | ||
154 | AUTOMAKE = @AUTOMAKE@ | ||
155 | AWK = @AWK@ | ||
156 | CARES_CFLAGS = @CARES_CFLAGS@ | ||
157 | CARES_LIBS = @CARES_LIBS@ | ||
158 | CC = @CC@ | ||
159 | CCDEPMODE = @CCDEPMODE@ | ||
160 | CFLAGS = @CFLAGS@ | ||
161 | CHECK_CFLAGS = @CHECK_CFLAGS@ | ||
162 | CHECK_LIBS = @CHECK_LIBS@ | ||
163 | CPP = @CPP@ | ||
164 | CPPFLAGS = @CPPFLAGS@ | ||
165 | CURL_CFLAGS = @CURL_CFLAGS@ | ||
166 | CURL_LIBS = @CURL_LIBS@ | ||
167 | CXX = @CXX@ | ||
168 | CXXCPP = @CXXCPP@ | ||
169 | CXXDEPMODE = @CXXDEPMODE@ | ||
170 | CXXFLAGS = @CXXFLAGS@ | ||
171 | CYGPATH_W = @CYGPATH_W@ | ||
172 | DEFS = @DEFS@ | ||
173 | DEPDIR = @DEPDIR@ | ||
174 | DIRECTFB_CFLAGS = @DIRECTFB_CFLAGS@ | ||
175 | DIRECTFB_LIBS = @DIRECTFB_LIBS@ | ||
176 | DLLTOOL = @DLLTOOL@ | ||
177 | DSYMUTIL = @DSYMUTIL@ | ||
178 | DUMPBIN = @DUMPBIN@ | ||
179 | ECHO_C = @ECHO_C@ | ||
180 | ECHO_N = @ECHO_N@ | ||
181 | ECHO_T = @ECHO_T@ | ||
182 | ECORE_XCB_CFLAGS = @ECORE_XCB_CFLAGS@ | ||
183 | ECORE_XCB_LIBS = @ECORE_XCB_LIBS@ | ||
184 | EFL_ECORE_BUILD = @EFL_ECORE_BUILD@ | ||
185 | EFL_ECORE_CON_BUILD = @EFL_ECORE_CON_BUILD@ | ||
186 | EFL_ECORE_EVAS_BUILD = @EFL_ECORE_EVAS_BUILD@ | ||
187 | EFL_ECORE_FILE_BUILD = @EFL_ECORE_FILE_BUILD@ | ||
188 | EFL_ECORE_IMF_BUILD = @EFL_ECORE_IMF_BUILD@ | ||
189 | EFL_ECORE_IMF_EVAS_BUILD = @EFL_ECORE_IMF_EVAS_BUILD@ | ||
190 | EFL_ECORE_INPUT_BUILD = @EFL_ECORE_INPUT_BUILD@ | ||
191 | EFL_ECORE_INPUT_EVAS_BUILD = @EFL_ECORE_INPUT_EVAS_BUILD@ | ||
192 | EFL_ECORE_IPC_BUILD = @EFL_ECORE_IPC_BUILD@ | ||
193 | EFL_ECORE_PSL1GHT_BUILD = @EFL_ECORE_PSL1GHT_BUILD@ | ||
194 | EFL_ECORE_SDL_BUILD = @EFL_ECORE_SDL_BUILD@ | ||
195 | EFL_ECORE_WIN32_BUILD = @EFL_ECORE_WIN32_BUILD@ | ||
196 | EFL_ECORE_WINCE_BUILD = @EFL_ECORE_WINCE_BUILD@ | ||
197 | EFL_PTHREAD_CFLAGS = @EFL_PTHREAD_CFLAGS@ | ||
198 | EFL_PTHREAD_LIBS = @EFL_PTHREAD_LIBS@ | ||
199 | EGREP = @EGREP@ | ||
200 | EINA_CFLAGS = @EINA_CFLAGS@ | ||
201 | EINA_LIBS = @EINA_LIBS@ | ||
202 | ESCAPE_CFLAGS = @ESCAPE_CFLAGS@ | ||
203 | ESCAPE_LIBS = @ESCAPE_LIBS@ | ||
204 | EVAS_CFLAGS = @EVAS_CFLAGS@ | ||
205 | EVAS_LIBS = @EVAS_LIBS@ | ||
206 | EVIL_CFLAGS = @EVIL_CFLAGS@ | ||
207 | EVIL_LIBS = @EVIL_LIBS@ | ||
208 | EXEEXT = @EXEEXT@ | ||
209 | FGREP = @FGREP@ | ||
210 | GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ | ||
211 | GLIB_CFLAGS = @GLIB_CFLAGS@ | ||
212 | GLIB_LIBS = @GLIB_LIBS@ | ||
213 | GMSGFMT = @GMSGFMT@ | ||
214 | GMSGFMT_015 = @GMSGFMT_015@ | ||
215 | GREP = @GREP@ | ||
216 | INSTALL = @INSTALL@ | ||
217 | INSTALL_DATA = @INSTALL_DATA@ | ||
218 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ | ||
219 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ | ||
220 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ | ||
221 | INTLLIBS = @INTLLIBS@ | ||
222 | INTL_MACOSX_LIBS = @INTL_MACOSX_LIBS@ | ||
223 | KEYSYMDEFS = @KEYSYMDEFS@ | ||
224 | LD = @LD@ | ||
225 | LDFLAGS = @LDFLAGS@ | ||
226 | LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ | ||
227 | LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ | ||
228 | LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ | ||
229 | LIBICONV = @LIBICONV@ | ||
230 | LIBINTL = @LIBINTL@ | ||
231 | LIBOBJS = @LIBOBJS@ | ||
232 | LIBS = @LIBS@ | ||
233 | LIBTOOL = @LIBTOOL@ | ||
234 | LIPO = @LIPO@ | ||
235 | LN_S = @LN_S@ | ||
236 | LTLIBICONV = @LTLIBICONV@ | ||
237 | LTLIBINTL = @LTLIBINTL@ | ||
238 | LTLIBOBJS = @LTLIBOBJS@ | ||
239 | MAKEINFO = @MAKEINFO@ | ||
240 | MKDIR_P = @MKDIR_P@ | ||
241 | MSGFMT = @MSGFMT@ | ||
242 | MSGFMT_015 = @MSGFMT_015@ | ||
243 | MSGMERGE = @MSGMERGE@ | ||
244 | NM = @NM@ | ||
245 | NMEDIT = @NMEDIT@ | ||
246 | OBJC = @OBJC@ | ||
247 | OBJCDEPMODE = @OBJCDEPMODE@ | ||
248 | OBJCFLAGS = @OBJCFLAGS@ | ||
249 | OBJDUMP = @OBJDUMP@ | ||
250 | OBJEXT = @OBJEXT@ | ||
251 | OTOOL = @OTOOL@ | ||
252 | OTOOL64 = @OTOOL64@ | ||
253 | PACKAGE = @PACKAGE@ | ||
254 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ | ||
255 | PACKAGE_NAME = @PACKAGE_NAME@ | ||
256 | PACKAGE_STRING = @PACKAGE_STRING@ | ||
257 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ | ||
258 | PACKAGE_URL = @PACKAGE_URL@ | ||
259 | PACKAGE_VERSION = @PACKAGE_VERSION@ | ||
260 | PATH_SEPARATOR = @PATH_SEPARATOR@ | ||
261 | PIXMAN_CFLAGS = @PIXMAN_CFLAGS@ | ||
262 | PIXMAN_LIBS = @PIXMAN_LIBS@ | ||
263 | PKG_CONFIG = @PKG_CONFIG@ | ||
264 | PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ | ||
265 | PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ | ||
266 | POSUB = @POSUB@ | ||
267 | RANLIB = @RANLIB@ | ||
268 | SDL_CFLAGS = @SDL_CFLAGS@ | ||
269 | SDL_CONFIG = @SDL_CONFIG@ | ||
270 | SDL_LIBS = @SDL_LIBS@ | ||
271 | SED = @SED@ | ||
272 | SET_MAKE = @SET_MAKE@ | ||
273 | SHELL = @SHELL@ | ||
274 | SSL_CFLAGS = @SSL_CFLAGS@ | ||
275 | SSL_LIBS = @SSL_LIBS@ | ||
276 | STRIP = @STRIP@ | ||
277 | TLS2_CFLAGS = @TLS2_CFLAGS@ | ||
278 | TLS2_LIBS = @TLS2_LIBS@ | ||
279 | TLS_CFLAGS = @TLS_CFLAGS@ | ||
280 | TLS_LIBS = @TLS_LIBS@ | ||
281 | TSLIB_CFLAGS = @TSLIB_CFLAGS@ | ||
282 | TSLIB_LIBS = @TSLIB_LIBS@ | ||
283 | USE_NLS = @USE_NLS@ | ||
284 | VERSION = @VERSION@ | ||
285 | VMAJ = @VMAJ@ | ||
286 | WIN32_CFLAGS = @WIN32_CFLAGS@ | ||
287 | WIN32_CPPFLAGS = @WIN32_CPPFLAGS@ | ||
288 | WIN32_LIBS = @WIN32_LIBS@ | ||
289 | XCB_COMPOSITE_CFLAGS = @XCB_COMPOSITE_CFLAGS@ | ||
290 | XCB_COMPOSITE_LIBS = @XCB_COMPOSITE_LIBS@ | ||
291 | XCB_CURSOR_CFLAGS = @XCB_CURSOR_CFLAGS@ | ||
292 | XCB_CURSOR_LIBS = @XCB_CURSOR_LIBS@ | ||
293 | XCB_DAMAGE_CFLAGS = @XCB_DAMAGE_CFLAGS@ | ||
294 | XCB_DAMAGE_LIBS = @XCB_DAMAGE_LIBS@ | ||
295 | XCB_DPMS_CFLAGS = @XCB_DPMS_CFLAGS@ | ||
296 | XCB_DPMS_LIBS = @XCB_DPMS_LIBS@ | ||
297 | XCB_RANDR_CFLAGS = @XCB_RANDR_CFLAGS@ | ||
298 | XCB_RANDR_LIBS = @XCB_RANDR_LIBS@ | ||
299 | XCB_RENDER_CFLAGS = @XCB_RENDER_CFLAGS@ | ||
300 | XCB_RENDER_LIBS = @XCB_RENDER_LIBS@ | ||
301 | XCB_SCREENSAVER_CFLAGS = @XCB_SCREENSAVER_CFLAGS@ | ||
302 | XCB_SCREENSAVER_LIBS = @XCB_SCREENSAVER_LIBS@ | ||
303 | XCB_SHAPE_CFLAGS = @XCB_SHAPE_CFLAGS@ | ||
304 | XCB_SHAPE_LIBS = @XCB_SHAPE_LIBS@ | ||
305 | XCB_SYNC_CFLAGS = @XCB_SYNC_CFLAGS@ | ||
306 | XCB_SYNC_LIBS = @XCB_SYNC_LIBS@ | ||
307 | XCB_X11_CFLAGS = @XCB_X11_CFLAGS@ | ||
308 | XCB_X11_LIBS = @XCB_X11_LIBS@ | ||
309 | XCB_XFIXES_CFLAGS = @XCB_XFIXES_CFLAGS@ | ||
310 | XCB_XFIXES_LIBS = @XCB_XFIXES_LIBS@ | ||
311 | XCB_XGESTURE_CFLAGS = @XCB_XGESTURE_CFLAGS@ | ||
312 | XCB_XGESTURE_LIBS = @XCB_XGESTURE_LIBS@ | ||
313 | XCB_XINERAMA_CFLAGS = @XCB_XINERAMA_CFLAGS@ | ||
314 | XCB_XINERAMA_LIBS = @XCB_XINERAMA_LIBS@ | ||
315 | XCB_XINPUT_CFLAGS = @XCB_XINPUT_CFLAGS@ | ||
316 | XCB_XINPUT_LIBS = @XCB_XINPUT_LIBS@ | ||
317 | XCB_XPRINT_CFLAGS = @XCB_XPRINT_CFLAGS@ | ||
318 | XCB_XPRINT_LIBS = @XCB_XPRINT_LIBS@ | ||
319 | XCB_XTEST_CFLAGS = @XCB_XTEST_CFLAGS@ | ||
320 | XCB_XTEST_LIBS = @XCB_XTEST_LIBS@ | ||
321 | XCOMPOSITE_CFLAGS = @XCOMPOSITE_CFLAGS@ | ||
322 | XCOMPOSITE_LIBS = @XCOMPOSITE_LIBS@ | ||
323 | XDAMAGE_CFLAGS = @XDAMAGE_CFLAGS@ | ||
324 | XDAMAGE_LIBS = @XDAMAGE_LIBS@ | ||
325 | XDPMS_CFLAGS = @XDPMS_CFLAGS@ | ||
326 | XDPMS_LIBS = @XDPMS_LIBS@ | ||
327 | XFIXES_CFLAGS = @XFIXES_CFLAGS@ | ||
328 | XFIXES_LIBS = @XFIXES_LIBS@ | ||
329 | XGESTURE_CFLAGS = @XGESTURE_CFLAGS@ | ||
330 | XGESTURE_LIBS = @XGESTURE_LIBS@ | ||
331 | XGETTEXT = @XGETTEXT@ | ||
332 | XGETTEXT_015 = @XGETTEXT_015@ | ||
333 | XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ | ||
334 | XI2_CFLAGS = @XI2_CFLAGS@ | ||
335 | XI2_LIBS = @XI2_LIBS@ | ||
336 | XINERAMA_CFLAGS = @XINERAMA_CFLAGS@ | ||
337 | XINERAMA_LIBS = @XINERAMA_LIBS@ | ||
338 | XKB_CFLAGS = @XKB_CFLAGS@ | ||
339 | XKB_LIBS = @XKB_LIBS@ | ||
340 | XMKMF = @XMKMF@ | ||
341 | XPRINT_CFLAGS = @XPRINT_CFLAGS@ | ||
342 | XPRINT_LIBS = @XPRINT_LIBS@ | ||
343 | XRANDR_CFLAGS = @XRANDR_CFLAGS@ | ||
344 | XRANDR_LIBS = @XRANDR_LIBS@ | ||
345 | XRENDER_CFLAGS = @XRENDER_CFLAGS@ | ||
346 | XRENDER_LIBS = @XRENDER_LIBS@ | ||
347 | XSS_CFLAGS = @XSS_CFLAGS@ | ||
348 | XSS_LIBS = @XSS_LIBS@ | ||
349 | XTEST_CFLAGS = @XTEST_CFLAGS@ | ||
350 | XTEST_LIBS = @XTEST_LIBS@ | ||
351 | X_CFLAGS = @X_CFLAGS@ | ||
352 | X_EXTRA_LIBS = @X_EXTRA_LIBS@ | ||
353 | X_LIBS = @X_LIBS@ | ||
354 | X_PRE_LIBS = @X_PRE_LIBS@ | ||
355 | Xcursor_cflags = @Xcursor_cflags@ | ||
356 | Xcursor_libs = @Xcursor_libs@ | ||
357 | abs_builddir = @abs_builddir@ | ||
358 | abs_srcdir = @abs_srcdir@ | ||
359 | abs_top_builddir = @abs_top_builddir@ | ||
360 | abs_top_srcdir = @abs_top_srcdir@ | ||
361 | ac_ct_CC = @ac_ct_CC@ | ||
362 | ac_ct_CXX = @ac_ct_CXX@ | ||
363 | ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ | ||
364 | ac_ct_OBJC = @ac_ct_OBJC@ | ||
365 | am__include = @am__include@ | ||
366 | am__leading_dot = @am__leading_dot@ | ||
367 | am__quote = @am__quote@ | ||
368 | am__tar = @am__tar@ | ||
369 | am__untar = @am__untar@ | ||
370 | bindir = @bindir@ | ||
371 | build = @build@ | ||
372 | build_alias = @build_alias@ | ||
373 | build_cpu = @build_cpu@ | ||
374 | build_os = @build_os@ | ||
375 | build_vendor = @build_vendor@ | ||
376 | builddir = @builddir@ | ||
377 | cocoa_ldflags = @cocoa_ldflags@ | ||
378 | datadir = @datadir@ | ||
379 | datarootdir = @datarootdir@ | ||
380 | dlopen_libs = @dlopen_libs@ | ||
381 | docdir = @docdir@ | ||
382 | dvidir = @dvidir@ | ||
383 | ecore_cocoa_cflags = @ecore_cocoa_cflags@ | ||
384 | ecore_cocoa_libs = @ecore_cocoa_libs@ | ||
385 | ecore_con_cflags = @ecore_con_cflags@ | ||
386 | ecore_con_libs = @ecore_con_libs@ | ||
387 | ecore_directfb_cflags = @ecore_directfb_cflags@ | ||
388 | ecore_directfb_libs = @ecore_directfb_libs@ | ||
389 | ecore_evas_cflags = @ecore_evas_cflags@ | ||
390 | ecore_evas_libs = @ecore_evas_libs@ | ||
391 | ecore_fb_cflags = @ecore_fb_cflags@ | ||
392 | ecore_fb_libs = @ecore_fb_libs@ | ||
393 | ecore_file_cflags = @ecore_file_cflags@ | ||
394 | ecore_file_libs = @ecore_file_libs@ | ||
395 | ecore_imf_cflags = @ecore_imf_cflags@ | ||
396 | ecore_imf_evas_cflags = @ecore_imf_evas_cflags@ | ||
397 | ecore_imf_evas_libs = @ecore_imf_evas_libs@ | ||
398 | ecore_imf_libs = @ecore_imf_libs@ | ||
399 | ecore_imf_xim_cflags = @ecore_imf_xim_cflags@ | ||
400 | ecore_imf_xim_libs = @ecore_imf_xim_libs@ | ||
401 | ecore_input_cflags = @ecore_input_cflags@ | ||
402 | ecore_input_evas_cflags = @ecore_input_evas_cflags@ | ||
403 | ecore_input_evas_libs = @ecore_input_evas_libs@ | ||
404 | ecore_input_libs = @ecore_input_libs@ | ||
405 | ecore_ipc_cflags = @ecore_ipc_cflags@ | ||
406 | ecore_ipc_libs = @ecore_ipc_libs@ | ||
407 | ecore_psl1ght_cflags = @ecore_psl1ght_cflags@ | ||
408 | ecore_psl1ght_libs = @ecore_psl1ght_libs@ | ||
409 | ecore_sdl_cflags = @ecore_sdl_cflags@ | ||
410 | ecore_sdl_libs = @ecore_sdl_libs@ | ||
411 | ecore_win32_cflags = @ecore_win32_cflags@ | ||
412 | ecore_win32_libs = @ecore_win32_libs@ | ||
413 | ecore_wince_cflags = @ecore_wince_cflags@ | ||
414 | ecore_wince_libs = @ecore_wince_libs@ | ||
415 | ecore_x_cflags = @ecore_x_cflags@ | ||
416 | ecore_x_libs = @ecore_x_libs@ | ||
417 | ecore_x_libs_private = @ecore_x_libs_private@ | ||
418 | efl_doxygen = @efl_doxygen@ | ||
419 | efl_have_doxygen = @efl_have_doxygen@ | ||
420 | exec_prefix = @exec_prefix@ | ||
421 | have_ecore_x_xcb_define = @have_ecore_x_xcb_define@ | ||
422 | host = @host@ | ||
423 | host_alias = @host_alias@ | ||
424 | host_cpu = @host_cpu@ | ||
425 | host_os = @host_os@ | ||
426 | host_vendor = @host_vendor@ | ||
427 | htmldir = @htmldir@ | ||
428 | includedir = @includedir@ | ||
429 | infodir = @infodir@ | ||
430 | install_sh = @install_sh@ | ||
431 | libdir = @libdir@ | ||
432 | libexecdir = @libexecdir@ | ||
433 | localedir = @localedir@ | ||
434 | localstatedir = @localstatedir@ | ||
435 | lt_ECHO = @lt_ECHO@ | ||
436 | lt_enable_auto_import = @lt_enable_auto_import@ | ||
437 | mandir = @mandir@ | ||
438 | mkdir_p = @mkdir_p@ | ||
439 | oldincludedir = @oldincludedir@ | ||
440 | pdfdir = @pdfdir@ | ||
441 | pkgconfig_requires_private = @pkgconfig_requires_private@ | ||
442 | prefix = @prefix@ | ||
443 | program_transform_name = @program_transform_name@ | ||
444 | psdir = @psdir@ | ||
445 | release_info = @release_info@ | ||
446 | requirements_ecore = @requirements_ecore@ | ||
447 | requirements_ecore_cocoa = @requirements_ecore_cocoa@ | ||
448 | requirements_ecore_con = @requirements_ecore_con@ | ||
449 | requirements_ecore_directfb = @requirements_ecore_directfb@ | ||
450 | requirements_ecore_evas = @requirements_ecore_evas@ | ||
451 | requirements_ecore_fb = @requirements_ecore_fb@ | ||
452 | requirements_ecore_file = @requirements_ecore_file@ | ||
453 | requirements_ecore_imf = @requirements_ecore_imf@ | ||
454 | requirements_ecore_imf_evas = @requirements_ecore_imf_evas@ | ||
455 | requirements_ecore_imf_xim = @requirements_ecore_imf_xim@ | ||
456 | requirements_ecore_input = @requirements_ecore_input@ | ||
457 | requirements_ecore_input_evas = @requirements_ecore_input_evas@ | ||
458 | requirements_ecore_ipc = @requirements_ecore_ipc@ | ||
459 | requirements_ecore_psl1ght = @requirements_ecore_psl1ght@ | ||
460 | requirements_ecore_sdl = @requirements_ecore_sdl@ | ||
461 | requirements_ecore_win32 = @requirements_ecore_win32@ | ||
462 | requirements_ecore_wince = @requirements_ecore_wince@ | ||
463 | requirements_ecore_x = @requirements_ecore_x@ | ||
464 | rt_libs = @rt_libs@ | ||
465 | sbindir = @sbindir@ | ||
466 | sharedstatedir = @sharedstatedir@ | ||
467 | srcdir = @srcdir@ | ||
468 | sysconfdir = @sysconfdir@ | ||
469 | target_alias = @target_alias@ | ||
470 | top_build_prefix = @top_build_prefix@ | ||
471 | top_builddir = @top_builddir@ | ||
472 | top_srcdir = @top_srcdir@ | ||
473 | version_info = @version_info@ | ||
474 | x_cflags = @x_cflags@ | ||
475 | x_includes = @x_includes@ | ||
476 | x_libs = @x_libs@ | ||
477 | MAINTAINERCLEANFILES = Makefile.in ecore_xcb_keysym_table.h | ||
478 | @BUILD_ECORE_X_XCB_TRUE@AM_CPPFLAGS = \ | ||
479 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_DAMAGE_CFLAGS@ \ | ||
480 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_COMPOSITE_CFLAGS@ \ | ||
481 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_DPMS_CFLAGS@ \ | ||
482 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_RANDR_CFLAGS@ \ | ||
483 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_RENDER_CFLAGS@ \ | ||
484 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_SCREENSAVER_CFLAGS@ \ | ||
485 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_SHAPE_CFLAGS@ \ | ||
486 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_SYNC_CFLAGS@ \ | ||
487 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_XFIXES_CFLAGS@ \ | ||
488 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_XINERAMA_CFLAGS@ \ | ||
489 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_XPRINT_CFLAGS@ \ | ||
490 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_XTEST_CFLAGS@ \ | ||
491 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_XINPUT_CFLAGS@ \ | ||
492 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_XGESTURE_CFLAGS@ \ | ||
493 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_CURSOR_CFLAGS@ \ | ||
494 | @BUILD_ECORE_X_XCB_TRUE@ @ECORE_XCB_CFLAGS@ \ | ||
495 | @BUILD_ECORE_X_XCB_TRUE@ @PIXMAN_CFLAGS@ \ | ||
496 | @BUILD_ECORE_X_XCB_TRUE@ -I$(top_srcdir)/src/lib/ecore \ | ||
497 | @BUILD_ECORE_X_XCB_TRUE@ -I$(top_srcdir)/src/lib/ecore_x \ | ||
498 | @BUILD_ECORE_X_XCB_TRUE@ -I$(top_srcdir)/src/lib/ecore_input \ | ||
499 | @BUILD_ECORE_X_XCB_TRUE@ -I$(top_builddir)/src/lib/ecore \ | ||
500 | @BUILD_ECORE_X_XCB_TRUE@ -I$(top_builddir)/src/lib/ecore_x \ | ||
501 | @BUILD_ECORE_X_XCB_TRUE@ -I$(top_builddir)/src/lib/ecore_input \ | ||
502 | @BUILD_ECORE_X_XCB_TRUE@ @EINA_CFLAGS@ | ||
503 | |||
504 | @BUILD_ECORE_X_XCB_TRUE@noinst_LTLIBRARIES = libecore_x_xcb.la | ||
505 | @BUILD_ECORE_X_XCB_TRUE@libecore_x_xcb_la_SOURCES = \ | ||
506 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb.c \ | ||
507 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_atoms.c \ | ||
508 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_extensions.c \ | ||
509 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_shape.c \ | ||
510 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_screensaver.c \ | ||
511 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_sync.c \ | ||
512 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_render.c \ | ||
513 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_randr.c \ | ||
514 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_xfixes.c \ | ||
515 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_composite.c \ | ||
516 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_cursor.c \ | ||
517 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_damage.c \ | ||
518 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_dnd.c \ | ||
519 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_dpms.c \ | ||
520 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_drawable.c \ | ||
521 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_e.c \ | ||
522 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_gc.c \ | ||
523 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_image.c \ | ||
524 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_input.c \ | ||
525 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_gesture.c \ | ||
526 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_mwm.c \ | ||
527 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_pixmap.c \ | ||
528 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_region.c \ | ||
529 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_selection.c \ | ||
530 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_textlist.c \ | ||
531 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_events.c \ | ||
532 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_keymap.c \ | ||
533 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_netwm.c \ | ||
534 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_icccm.c \ | ||
535 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_window.c \ | ||
536 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_window_prop.c \ | ||
537 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_window_shape.c \ | ||
538 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_window_shadow.c \ | ||
539 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_xinerama.c \ | ||
540 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_error.c \ | ||
541 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_xtest.c \ | ||
542 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_vsync.c \ | ||
543 | @BUILD_ECORE_X_XCB_TRUE@ ecore_xcb_xdefaults.c | ||
544 | |||
545 | @BUILD_ECORE_X_XCB_TRUE@libecore_x_xcb_la_LIBADD = \ | ||
546 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_DAMAGE_LIBS@ \ | ||
547 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_COMPOSITE_LIBS@ \ | ||
548 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_DPMS_LIBS@ \ | ||
549 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_RANDR_LIBS@ \ | ||
550 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_RENDER_LIBS@ \ | ||
551 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_SCREENSAVER_LIBS@ \ | ||
552 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_SHAPE_LIBS@ \ | ||
553 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_SYNC_LIBS@ \ | ||
554 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_XFIXES_LIBS@ \ | ||
555 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_XINERAMA_LIBS@ \ | ||
556 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_XPRINT_LIBS@ \ | ||
557 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_XTEST_LIBS@ \ | ||
558 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_XINPUT_LIBS@ \ | ||
559 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_XGESTURE_LIBS@ \ | ||
560 | @BUILD_ECORE_X_XCB_TRUE@ @XCB_CURSOR_LIBS@ \ | ||
561 | @BUILD_ECORE_X_XCB_TRUE@ @ECORE_XCB_LIBS@ \ | ||
562 | @BUILD_ECORE_X_XCB_TRUE@ @PIXMAN_LIBS@ \ | ||
563 | @BUILD_ECORE_X_XCB_TRUE@ $(top_builddir)/src/lib/ecore/libecore.la \ | ||
564 | @BUILD_ECORE_X_XCB_TRUE@ $(top_builddir)/src/lib/ecore_input/libecore_input.la \ | ||
565 | @BUILD_ECORE_X_XCB_TRUE@ @EINA_LIBS@ \ | ||
566 | @BUILD_ECORE_X_XCB_TRUE@ @dlopen_libs@ | ||
567 | |||
568 | EXTRA_DIST = ecore_xcb_private.h | ||
569 | all: all-am | ||
570 | |||
571 | .SUFFIXES: | ||
572 | .SUFFIXES: .c .lo .o .obj | ||
573 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) | ||
574 | @for dep in $?; do \ | ||
575 | case '$(am__configure_deps)' in \ | ||
576 | *$$dep*) \ | ||
577 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ | ||
578 | && { if test -f $@; then exit 0; else break; fi; }; \ | ||
579 | exit 1;; \ | ||
580 | esac; \ | ||
581 | done; \ | ||
582 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/lib/ecore_x/xcb/Makefile'; \ | ||
583 | $(am__cd) $(top_srcdir) && \ | ||
584 | $(AUTOMAKE) --gnu src/lib/ecore_x/xcb/Makefile | ||
585 | .PRECIOUS: Makefile | ||
586 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status | ||
587 | @case '$?' in \ | ||
588 | *config.status*) \ | ||
589 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ | ||
590 | *) \ | ||
591 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ | ||
592 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ | ||
593 | esac; | ||
594 | |||
595 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) | ||
596 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh | ||
597 | |||
598 | $(top_srcdir)/configure: $(am__configure_deps) | ||
599 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh | ||
600 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) | ||
601 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh | ||
602 | $(am__aclocal_m4_deps): | ||
603 | |||
604 | clean-noinstLTLIBRARIES: | ||
605 | -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) | ||
606 | @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ | ||
607 | dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ | ||
608 | test "$$dir" != "$$p" || dir=.; \ | ||
609 | echo "rm -f \"$${dir}/so_locations\""; \ | ||
610 | rm -f "$${dir}/so_locations"; \ | ||
611 | done | ||
612 | libecore_x_xcb.la: $(libecore_x_xcb_la_OBJECTS) $(libecore_x_xcb_la_DEPENDENCIES) | ||
613 | $(AM_V_CCLD)$(LINK) $(am_libecore_x_xcb_la_rpath) $(libecore_x_xcb_la_OBJECTS) $(libecore_x_xcb_la_LIBADD) $(LIBS) | ||
614 | |||
615 | mostlyclean-compile: | ||
616 | -rm -f *.$(OBJEXT) | ||
617 | |||
618 | distclean-compile: | ||
619 | -rm -f *.tab.c | ||
620 | |||
621 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb.Plo@am__quote@ | ||
622 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_atoms.Plo@am__quote@ | ||
623 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_composite.Plo@am__quote@ | ||
624 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_cursor.Plo@am__quote@ | ||
625 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_damage.Plo@am__quote@ | ||
626 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_dnd.Plo@am__quote@ | ||
627 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_dpms.Plo@am__quote@ | ||
628 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_drawable.Plo@am__quote@ | ||
629 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_e.Plo@am__quote@ | ||
630 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_error.Plo@am__quote@ | ||
631 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_events.Plo@am__quote@ | ||
632 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_extensions.Plo@am__quote@ | ||
633 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_gc.Plo@am__quote@ | ||
634 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_gesture.Plo@am__quote@ | ||
635 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_icccm.Plo@am__quote@ | ||
636 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_image.Plo@am__quote@ | ||
637 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_input.Plo@am__quote@ | ||
638 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_keymap.Plo@am__quote@ | ||
639 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_mwm.Plo@am__quote@ | ||
640 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_netwm.Plo@am__quote@ | ||
641 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_pixmap.Plo@am__quote@ | ||
642 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_randr.Plo@am__quote@ | ||
643 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_region.Plo@am__quote@ | ||
644 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_render.Plo@am__quote@ | ||
645 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_screensaver.Plo@am__quote@ | ||
646 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_selection.Plo@am__quote@ | ||
647 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_shape.Plo@am__quote@ | ||
648 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_sync.Plo@am__quote@ | ||
649 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_textlist.Plo@am__quote@ | ||
650 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_vsync.Plo@am__quote@ | ||
651 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_window.Plo@am__quote@ | ||
652 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_window_prop.Plo@am__quote@ | ||
653 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_window_shadow.Plo@am__quote@ | ||
654 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_window_shape.Plo@am__quote@ | ||
655 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_xdefaults.Plo@am__quote@ | ||
656 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_xfixes.Plo@am__quote@ | ||
657 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_xinerama.Plo@am__quote@ | ||
658 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ecore_xcb_xtest.Plo@am__quote@ | ||
659 | |||
660 | .c.o: | ||
661 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< | ||
662 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po | ||
663 | @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ | ||
664 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ | ||
665 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
666 | @am__fastdepCC_FALSE@ $(COMPILE) -c $< | ||
667 | |||
668 | .c.obj: | ||
669 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` | ||
670 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po | ||
671 | @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ | ||
672 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ | ||
673 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
674 | @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` | ||
675 | |||
676 | .c.lo: | ||
677 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< | ||
678 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo | ||
679 | @am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@ | ||
680 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ | ||
681 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ | ||
682 | @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< | ||
683 | |||
684 | mostlyclean-libtool: | ||
685 | -rm -f *.lo | ||
686 | |||
687 | clean-libtool: | ||
688 | -rm -rf .libs _libs | ||
689 | |||
690 | ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) | ||
691 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ | ||
692 | unique=`for i in $$list; do \ | ||
693 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ | ||
694 | done | \ | ||
695 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ | ||
696 | END { if (nonempty) { for (i in files) print i; }; }'`; \ | ||
697 | mkid -fID $$unique | ||
698 | tags: TAGS | ||
699 | |||
700 | TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ | ||
701 | $(TAGS_FILES) $(LISP) | ||
702 | set x; \ | ||
703 | here=`pwd`; \ | ||
704 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ | ||
705 | unique=`for i in $$list; do \ | ||
706 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ | ||
707 | done | \ | ||
708 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ | ||
709 | END { if (nonempty) { for (i in files) print i; }; }'`; \ | ||
710 | shift; \ | ||
711 | if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ | ||
712 | test -n "$$unique" || unique=$$empty_fix; \ | ||
713 | if test $$# -gt 0; then \ | ||
714 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ | ||
715 | "$$@" $$unique; \ | ||
716 | else \ | ||
717 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ | ||
718 | $$unique; \ | ||
719 | fi; \ | ||
720 | fi | ||
721 | ctags: CTAGS | ||
722 | CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ | ||
723 | $(TAGS_FILES) $(LISP) | ||
724 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ | ||
725 | unique=`for i in $$list; do \ | ||
726 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ | ||
727 | done | \ | ||
728 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ | ||
729 | END { if (nonempty) { for (i in files) print i; }; }'`; \ | ||
730 | test -z "$(CTAGS_ARGS)$$unique" \ | ||
731 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ | ||
732 | $$unique | ||
733 | |||
734 | GTAGS: | ||
735 | here=`$(am__cd) $(top_builddir) && pwd` \ | ||
736 | && $(am__cd) $(top_srcdir) \ | ||
737 | && gtags -i $(GTAGS_ARGS) "$$here" | ||
738 | |||
739 | distclean-tags: | ||
740 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags | ||
741 | |||
742 | distdir: $(DISTFILES) | ||
743 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ | ||
744 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ | ||
745 | list='$(DISTFILES)'; \ | ||
746 | dist_files=`for file in $$list; do echo $$file; done | \ | ||
747 | sed -e "s|^$$srcdirstrip/||;t" \ | ||
748 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ | ||
749 | case $$dist_files in \ | ||
750 | */*) $(MKDIR_P) `echo "$$dist_files" | \ | ||
751 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ | ||
752 | sort -u` ;; \ | ||
753 | esac; \ | ||
754 | for file in $$dist_files; do \ | ||
755 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ | ||
756 | if test -d $$d/$$file; then \ | ||
757 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ | ||
758 | if test -d "$(distdir)/$$file"; then \ | ||
759 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ | ||
760 | fi; \ | ||
761 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ | ||
762 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ | ||
763 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ | ||
764 | fi; \ | ||
765 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ | ||
766 | else \ | ||
767 | test -f "$(distdir)/$$file" \ | ||
768 | || cp -p $$d/$$file "$(distdir)/$$file" \ | ||
769 | || exit 1; \ | ||
770 | fi; \ | ||
771 | done | ||
772 | check-am: all-am | ||
773 | check: check-am | ||
774 | all-am: Makefile $(LTLIBRARIES) | ||
775 | installdirs: | ||
776 | install: install-am | ||
777 | install-exec: install-exec-am | ||
778 | install-data: install-data-am | ||
779 | uninstall: uninstall-am | ||
780 | |||
781 | install-am: all-am | ||
782 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am | ||
783 | |||
784 | installcheck: installcheck-am | ||
785 | install-strip: | ||
786 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ | ||
787 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ | ||
788 | `test -z '$(STRIP)' || \ | ||
789 | echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install | ||
790 | mostlyclean-generic: | ||
791 | |||
792 | clean-generic: | ||
793 | |||
794 | distclean-generic: | ||
795 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) | ||
796 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) | ||
797 | |||
798 | maintainer-clean-generic: | ||
799 | @echo "This command is intended for maintainers to use" | ||
800 | @echo "it deletes files that may require special tools to rebuild." | ||
801 | -test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES) | ||
802 | clean: clean-am | ||
803 | |||
804 | clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ | ||
805 | mostlyclean-am | ||
806 | |||
807 | distclean: distclean-am | ||
808 | -rm -rf ./$(DEPDIR) | ||
809 | -rm -f Makefile | ||
810 | distclean-am: clean-am distclean-compile distclean-generic \ | ||
811 | distclean-tags | ||
812 | |||
813 | dvi: dvi-am | ||
814 | |||
815 | dvi-am: | ||
816 | |||
817 | html: html-am | ||
818 | |||
819 | html-am: | ||
820 | |||
821 | info: info-am | ||
822 | |||
823 | info-am: | ||
824 | |||
825 | install-data-am: | ||
826 | |||
827 | install-dvi: install-dvi-am | ||
828 | |||
829 | install-dvi-am: | ||
830 | |||
831 | install-exec-am: | ||
832 | |||
833 | install-html: install-html-am | ||
834 | |||
835 | install-html-am: | ||
836 | |||
837 | install-info: install-info-am | ||
838 | |||
839 | install-info-am: | ||
840 | |||
841 | install-man: | ||
842 | |||
843 | install-pdf: install-pdf-am | ||
844 | |||
845 | install-pdf-am: | ||
846 | |||
847 | install-ps: install-ps-am | ||
848 | |||
849 | install-ps-am: | ||
850 | |||
851 | installcheck-am: | ||
852 | |||
853 | maintainer-clean: maintainer-clean-am | ||
854 | -rm -rf ./$(DEPDIR) | ||
855 | -rm -f Makefile | ||
856 | maintainer-clean-am: distclean-am maintainer-clean-generic | ||
857 | |||
858 | mostlyclean: mostlyclean-am | ||
859 | |||
860 | mostlyclean-am: mostlyclean-compile mostlyclean-generic \ | ||
861 | mostlyclean-libtool | ||
862 | |||
863 | pdf: pdf-am | ||
864 | |||
865 | pdf-am: | ||
866 | |||
867 | ps: ps-am | ||
868 | |||
869 | ps-am: | ||
870 | |||
871 | uninstall-am: | ||
872 | |||
873 | .MAKE: install-am install-strip | ||
874 | |||
875 | .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ | ||
876 | clean-libtool clean-noinstLTLIBRARIES ctags distclean \ | ||
877 | distclean-compile distclean-generic distclean-libtool \ | ||
878 | distclean-tags distdir dvi dvi-am html html-am info info-am \ | ||
879 | install install-am install-data install-data-am install-dvi \ | ||
880 | install-dvi-am install-exec install-exec-am install-html \ | ||
881 | install-html-am install-info install-info-am install-man \ | ||
882 | install-pdf install-pdf-am install-ps install-ps-am \ | ||
883 | install-strip installcheck installcheck-am installdirs \ | ||
884 | maintainer-clean maintainer-clean-generic mostlyclean \ | ||
885 | mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ | ||
886 | pdf pdf-am ps ps-am tags uninstall uninstall-am | ||
887 | |||
888 | |||
889 | # Tell versions [3.59,3.63) of GNU make to not export all variables. | ||
890 | # Otherwise a system limit (for SysV at least) may be exceeded. | ||
891 | .NOEXPORT: | ||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb.c new file mode 100644 index 0000000..ca7e798 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb.c | |||
@@ -0,0 +1,1470 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #include <X11/Xlib-xcb.h> | ||
3 | #include <dlfcn.h> | ||
4 | |||
5 | /* local function prototypes */ | ||
6 | static int _ecore_xcb_shutdown(Eina_Bool close_display); | ||
7 | static Eina_Bool _ecore_xcb_fd_handle(void *data, Ecore_Fd_Handler *hdlr __UNUSED__); | ||
8 | static Eina_Bool _ecore_xcb_fd_handle_buff(void *data, Ecore_Fd_Handler *hdlr __UNUSED__); | ||
9 | static Eina_Bool _ecore_xcb_idle_enter(void *data __UNUSED__); | ||
10 | |||
11 | /* local variables */ | ||
12 | static int _ecore_xcb_init_count = 0; | ||
13 | static int _ecore_xcb_grab_count = 0; | ||
14 | static Ecore_Fd_Handler *_ecore_xcb_fd_handler = NULL; | ||
15 | static xcb_generic_event_t *_ecore_xcb_event_buffered = NULL; | ||
16 | static Ecore_Idle_Enterer *_ecore_xcb_idle_enterer = NULL; | ||
17 | |||
18 | /* external variables */ | ||
19 | int _ecore_xcb_log_dom = -1; | ||
20 | Ecore_X_Display *_ecore_xcb_display = NULL; | ||
21 | Ecore_X_Connection *_ecore_xcb_conn = NULL; | ||
22 | Ecore_X_Screen *_ecore_xcb_screen = NULL; | ||
23 | Ecore_X_Atom _ecore_xcb_atoms_wm_protocol[ECORE_X_WM_PROTOCOL_NUM]; | ||
24 | double _ecore_xcb_double_click_time = 0.25; | ||
25 | |||
26 | /** | ||
27 | * @defgroup Ecore_X_Init_Group X Library Init and Shutdown Functions | ||
28 | * | ||
29 | * Functions that start and shut down the Ecore X Library. | ||
30 | */ | ||
31 | |||
32 | /** | ||
33 | * Initialize the X display connection to the given display. | ||
34 | * | ||
35 | * @param name Display target name. If @c NULL, the default display is | ||
36 | * assumed. | ||
37 | * @return The number of times the library has been initialized without | ||
38 | * being shut down. 0 is returned if an error occurs. | ||
39 | * @ingroup Ecore_X_Init_Group | ||
40 | */ | ||
41 | EAPI int | ||
42 | ecore_x_init(const char *name) | ||
43 | { | ||
44 | char *gl = NULL; | ||
45 | uint32_t mask, list[1]; | ||
46 | |||
47 | /* check if we have initialized already */ | ||
48 | if (++_ecore_xcb_init_count != 1) | ||
49 | return _ecore_xcb_init_count; | ||
50 | |||
51 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
52 | |||
53 | /* try to initialize eina */ | ||
54 | if (!eina_init()) return --_ecore_xcb_init_count; | ||
55 | |||
56 | /* setup ecore_xcb log domain */ | ||
57 | _ecore_xcb_log_dom = | ||
58 | eina_log_domain_register("ecore_x", ECORE_XCB_DEFAULT_LOG_COLOR); | ||
59 | if (_ecore_xcb_log_dom < 0) | ||
60 | { | ||
61 | EINA_LOG_ERR("Cannot create Ecore Xcb log domain"); | ||
62 | eina_shutdown(); | ||
63 | return --_ecore_xcb_init_count; | ||
64 | } | ||
65 | |||
66 | /* try to initialize ecore */ | ||
67 | if (!ecore_init()) | ||
68 | { | ||
69 | /* unregister log domain */ | ||
70 | eina_log_domain_unregister(_ecore_xcb_log_dom); | ||
71 | _ecore_xcb_log_dom = -1; | ||
72 | eina_shutdown(); | ||
73 | return --_ecore_xcb_init_count; | ||
74 | } | ||
75 | |||
76 | /* try to initialize ecore_event */ | ||
77 | if (!ecore_event_init()) | ||
78 | { | ||
79 | /* unregister log domain */ | ||
80 | eina_log_domain_unregister(_ecore_xcb_log_dom); | ||
81 | _ecore_xcb_log_dom = -1; | ||
82 | ecore_shutdown(); | ||
83 | eina_shutdown(); | ||
84 | return --_ecore_xcb_init_count; | ||
85 | } | ||
86 | |||
87 | /* NB: XLib has XInitThreads */ | ||
88 | |||
89 | /* check for env var which says we are not going to use GL @ all | ||
90 | * | ||
91 | * NB: This is done because if someone wants a 'pure' xcb implementation | ||
92 | * of ecore_x, all they need do is export this variable in the environment | ||
93 | * and ecore_x will not use xlib stuff at all. | ||
94 | * | ||
95 | * The upside is you can get pure xcb-based ecore_x (w/ all the speed), but | ||
96 | * there is a down-side here in that you cannot get OpenGL without XLib :( | ||
97 | */ | ||
98 | if ((gl = getenv("ECORE_X_NO_XLIB"))) | ||
99 | { | ||
100 | /* we found the env var that says 'Yes, we are not ever gonna try | ||
101 | * OpenGL so it is safe to not use XLib at all' */ | ||
102 | |||
103 | /* try to connect to the display server */ | ||
104 | _ecore_xcb_conn = xcb_connect(name, NULL); | ||
105 | } | ||
106 | else | ||
107 | { | ||
108 | /* env var was not specified, so we will assume that the user | ||
109 | * may want opengl @ some point. connect this way for opengl to work */ | ||
110 | void *libxcb, *libxlib; | ||
111 | Display *(*_real_display)(const char *display); | ||
112 | xcb_connection_t *(*_real_connection)(Display * dpy); | ||
113 | void (*_real_queue)(Display *dpy, enum XEventQueueOwner owner); | ||
114 | int (*_real_close)(Display *dpy); | ||
115 | #ifdef EVAS_FRAME_QUEUING | ||
116 | Status (*_real_threads)(void); | ||
117 | #endif | ||
118 | |||
119 | /* want to dlopen here to avoid actual library linkage */ | ||
120 | libxlib = dlopen("libX11.so", (RTLD_LAZY | RTLD_GLOBAL)); | ||
121 | if (!libxlib) | ||
122 | libxlib = dlopen("libX11.so.6", (RTLD_LAZY | RTLD_GLOBAL)); | ||
123 | if (!libxlib) | ||
124 | libxlib = dlopen("libX11.so.6.3.0", (RTLD_LAZY | RTLD_GLOBAL)); | ||
125 | if (!libxlib) | ||
126 | { | ||
127 | ERR("Could not dlsym to libX11"); | ||
128 | /* unregister log domain */ | ||
129 | eina_log_domain_unregister(_ecore_xcb_log_dom); | ||
130 | _ecore_xcb_log_dom = -1; | ||
131 | ecore_event_shutdown(); | ||
132 | ecore_shutdown(); | ||
133 | eina_shutdown(); | ||
134 | return --_ecore_xcb_init_count; | ||
135 | } | ||
136 | |||
137 | libxcb = dlopen("libX11-xcb.so", (RTLD_LAZY | RTLD_GLOBAL)); | ||
138 | if (!libxcb) | ||
139 | libxcb = dlopen("libX11-xcb.so.1", (RTLD_LAZY | RTLD_GLOBAL)); | ||
140 | if (!libxcb) | ||
141 | libxcb = dlopen("libX11-xcb.so.1.0.0", (RTLD_LAZY | RTLD_GLOBAL)); | ||
142 | if (!libxcb) | ||
143 | { | ||
144 | ERR("Could not dlsym to libX11-xcb"); | ||
145 | /* unregister log domain */ | ||
146 | eina_log_domain_unregister(_ecore_xcb_log_dom); | ||
147 | _ecore_xcb_log_dom = -1; | ||
148 | ecore_event_shutdown(); | ||
149 | ecore_shutdown(); | ||
150 | eina_shutdown(); | ||
151 | return --_ecore_xcb_init_count; | ||
152 | } | ||
153 | |||
154 | _real_display = dlsym(libxlib, "XOpenDisplay"); | ||
155 | _real_close = dlsym(libxlib, "XCloseDisplay"); | ||
156 | _real_connection = dlsym(libxcb, "XGetXCBConnection"); | ||
157 | _real_queue = dlsym(libxcb, "XSetEventQueueOwner"); | ||
158 | #ifdef EVAS_FRAME_QUEUING | ||
159 | _real_threads = dlsym(libxlib, "XInitThreads"); | ||
160 | #endif | ||
161 | |||
162 | if (_real_display) | ||
163 | { | ||
164 | #ifdef EVAS_FRAME_QUEUING | ||
165 | if (_real_threads) _real_threads(); | ||
166 | #endif | ||
167 | _ecore_xcb_display = _real_display(name); | ||
168 | if (!_ecore_xcb_display) | ||
169 | { | ||
170 | ERR("Could not open Display via XLib"); | ||
171 | /* unregister log domain */ | ||
172 | eina_log_domain_unregister(_ecore_xcb_log_dom); | ||
173 | _ecore_xcb_log_dom = -1; | ||
174 | ecore_event_shutdown(); | ||
175 | ecore_shutdown(); | ||
176 | eina_shutdown(); | ||
177 | return --_ecore_xcb_init_count; | ||
178 | } | ||
179 | if (_real_connection) | ||
180 | _ecore_xcb_conn = _real_connection(_ecore_xcb_display); | ||
181 | if (!_ecore_xcb_conn) | ||
182 | { | ||
183 | ERR("Could not get XCB Connection from XLib"); | ||
184 | |||
185 | if (_real_close) _real_close(_ecore_xcb_display); | ||
186 | |||
187 | /* unregister log domain */ | ||
188 | eina_log_domain_unregister(_ecore_xcb_log_dom); | ||
189 | _ecore_xcb_log_dom = -1; | ||
190 | ecore_event_shutdown(); | ||
191 | ecore_shutdown(); | ||
192 | eina_shutdown(); | ||
193 | return --_ecore_xcb_init_count; | ||
194 | } | ||
195 | if (_real_queue) | ||
196 | _real_queue(_ecore_xcb_display, XCBOwnsEventQueue); | ||
197 | } | ||
198 | } | ||
199 | |||
200 | if (xcb_connection_has_error(_ecore_xcb_conn)) | ||
201 | { | ||
202 | CRIT("XCB Connection has error"); | ||
203 | eina_log_domain_unregister(_ecore_xcb_log_dom); | ||
204 | _ecore_xcb_log_dom = -1; | ||
205 | ecore_event_shutdown(); | ||
206 | ecore_shutdown(); | ||
207 | eina_shutdown(); | ||
208 | return --_ecore_xcb_init_count; | ||
209 | } | ||
210 | |||
211 | /* grab the default screen */ | ||
212 | _ecore_xcb_screen = | ||
213 | xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).data; | ||
214 | |||
215 | /* NB: This method of init/finalize extensions first, then atoms | ||
216 | * Does end up being 2 round trips to X, BUT if we do extensions init then | ||
217 | * atoms init first, and call the 'finalize' functions later, we end up | ||
218 | * being slower, so it's a trade-off. This current method clocks in | ||
219 | * around 0.003 for fetching atoms VS 0.010 for init both then finalize */ | ||
220 | |||
221 | /* prefetch extension data */ | ||
222 | _ecore_xcb_extensions_init(); | ||
223 | |||
224 | /* finalize extensions */ | ||
225 | _ecore_xcb_extensions_finalize(); | ||
226 | |||
227 | /* set keyboard autorepeat */ | ||
228 | mask = XCB_KB_AUTO_REPEAT_MODE; | ||
229 | list[0] = XCB_AUTO_REPEAT_MODE_ON; | ||
230 | xcb_change_keyboard_control(_ecore_xcb_conn, mask, list); | ||
231 | |||
232 | /* setup xcb events */ | ||
233 | _ecore_xcb_events_init(); | ||
234 | |||
235 | /* setup xcb keymasks */ | ||
236 | _ecore_xcb_keymap_init(); | ||
237 | |||
238 | /* finalize xcb keymasks */ | ||
239 | _ecore_xcb_keymap_finalize(); | ||
240 | |||
241 | /* setup ecore fd handler */ | ||
242 | _ecore_xcb_fd_handler = | ||
243 | ecore_main_fd_handler_add(xcb_get_file_descriptor(_ecore_xcb_conn), | ||
244 | ECORE_FD_READ, _ecore_xcb_fd_handle, | ||
245 | _ecore_xcb_conn, _ecore_xcb_fd_handle_buff, | ||
246 | _ecore_xcb_conn); | ||
247 | |||
248 | if (!_ecore_xcb_fd_handler) | ||
249 | return _ecore_xcb_shutdown(EINA_TRUE); | ||
250 | |||
251 | /* prefetch atoms */ | ||
252 | _ecore_xcb_atoms_init(); | ||
253 | |||
254 | /* finalize atoms */ | ||
255 | _ecore_xcb_atoms_finalize(); | ||
256 | |||
257 | /* icccm_init: dummy function */ | ||
258 | ecore_x_icccm_init(); | ||
259 | |||
260 | /* setup netwm */ | ||
261 | ecore_x_netwm_init(); | ||
262 | |||
263 | /* old e hints init: dummy function */ | ||
264 | ecore_x_e_init(); | ||
265 | |||
266 | _ecore_xcb_atoms_wm_protocol[ECORE_X_WM_PROTOCOL_DELETE_REQUEST] = | ||
267 | ECORE_X_ATOM_WM_DELETE_WINDOW; | ||
268 | _ecore_xcb_atoms_wm_protocol[ECORE_X_WM_PROTOCOL_TAKE_FOCUS] = | ||
269 | ECORE_X_ATOM_WM_TAKE_FOCUS; | ||
270 | _ecore_xcb_atoms_wm_protocol[ECORE_X_NET_WM_PROTOCOL_PING] = | ||
271 | ECORE_X_ATOM_NET_WM_PING; | ||
272 | _ecore_xcb_atoms_wm_protocol[ECORE_X_NET_WM_PROTOCOL_SYNC_REQUEST] = | ||
273 | ECORE_X_ATOM_NET_WM_SYNC_REQUEST; | ||
274 | |||
275 | /* setup selection */ | ||
276 | _ecore_xcb_selection_init(); | ||
277 | |||
278 | /* setup dnd */ | ||
279 | _ecore_xcb_dnd_init(); | ||
280 | |||
281 | _ecore_xcb_idle_enterer = | ||
282 | ecore_idle_enterer_add(_ecore_xcb_idle_enter, NULL); | ||
283 | |||
284 | return _ecore_xcb_init_count; | ||
285 | } | ||
286 | |||
287 | /** | ||
288 | * Shuts down the Ecore X library. | ||
289 | * | ||
290 | * In shutting down the library, the X display connection is terminated | ||
291 | * and any event handlers for it are removed. | ||
292 | * | ||
293 | * @return The number of times the library has been initialized without | ||
294 | * being shut down. | ||
295 | * @ingroup Ecore_X_Init_Group | ||
296 | */ | ||
297 | EAPI int | ||
298 | ecore_x_shutdown(void) | ||
299 | { | ||
300 | return _ecore_xcb_shutdown(EINA_TRUE); | ||
301 | } | ||
302 | |||
303 | /** | ||
304 | * Shuts down the Ecore X library. | ||
305 | * | ||
306 | * As ecore_x_shutdown, except do not close Display, only connection. | ||
307 | * | ||
308 | * @ingroup Ecore_X_Init_Group | ||
309 | */ | ||
310 | EAPI int | ||
311 | ecore_x_disconnect(void) | ||
312 | { | ||
313 | return _ecore_xcb_shutdown(EINA_FALSE); | ||
314 | } | ||
315 | |||
316 | /** | ||
317 | * @defgroup Ecore_X_Flush_Group X Synchronization Functions | ||
318 | * | ||
319 | * Functions that ensure that all commands that have been issued by the | ||
320 | * Ecore X library have been sent to the server. | ||
321 | */ | ||
322 | |||
323 | /** | ||
324 | * Sends all X commands in the X Display buffer. | ||
325 | * @ingroup Ecore_X_Flush_Group | ||
326 | */ | ||
327 | EAPI void | ||
328 | ecore_x_flush(void) | ||
329 | { | ||
330 | // LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
331 | |||
332 | CHECK_XCB_CONN; | ||
333 | xcb_flush(_ecore_xcb_conn); | ||
334 | } | ||
335 | |||
336 | /** | ||
337 | * Retrieves the Ecore_X_Screen handle used for the current X connection. | ||
338 | * @return The current default screen. | ||
339 | * @ingroup Ecore_X_Display_Attr_Group | ||
340 | */ | ||
341 | EAPI Ecore_X_Screen * | ||
342 | ecore_x_default_screen_get(void) | ||
343 | { | ||
344 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
345 | |||
346 | return (Ecore_X_Screen *)_ecore_xcb_screen; | ||
347 | } | ||
348 | |||
349 | EAPI Ecore_X_Connection * | ||
350 | ecore_x_connection_get(void) | ||
351 | { | ||
352 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
353 | |||
354 | CHECK_XCB_CONN; | ||
355 | return (Ecore_X_Connection *)_ecore_xcb_conn; | ||
356 | } | ||
357 | |||
358 | /** | ||
359 | * Return the last event time | ||
360 | */ | ||
361 | EAPI Ecore_X_Time | ||
362 | ecore_x_current_time_get(void) | ||
363 | { | ||
364 | return _ecore_xcb_events_last_time_get(); | ||
365 | } | ||
366 | |||
367 | /** | ||
368 | * Flushes the command buffer and waits until all requests have been | ||
369 | * processed by the server. | ||
370 | * @ingroup Ecore_X_Flush_Group | ||
371 | */ | ||
372 | EAPI void | ||
373 | ecore_x_sync(void) | ||
374 | { | ||
375 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
376 | |||
377 | CHECK_XCB_CONN; | ||
378 | free(xcb_get_input_focus_reply(_ecore_xcb_conn, | ||
379 | xcb_get_input_focus_unchecked(_ecore_xcb_conn), | ||
380 | NULL)); | ||
381 | } | ||
382 | |||
383 | EAPI void | ||
384 | ecore_x_grab(void) | ||
385 | { | ||
386 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
387 | |||
388 | CHECK_XCB_CONN; | ||
389 | _ecore_xcb_grab_count++; | ||
390 | if (_ecore_xcb_grab_count == 1) | ||
391 | xcb_grab_server(_ecore_xcb_conn); | ||
392 | } | ||
393 | |||
394 | EAPI void | ||
395 | ecore_x_ungrab(void) | ||
396 | { | ||
397 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
398 | |||
399 | CHECK_XCB_CONN; | ||
400 | _ecore_xcb_grab_count--; | ||
401 | if (_ecore_xcb_grab_count < 0) _ecore_xcb_grab_count = 0; | ||
402 | if (_ecore_xcb_grab_count == 0) | ||
403 | xcb_ungrab_server(_ecore_xcb_conn); | ||
404 | } | ||
405 | |||
406 | /** | ||
407 | * Send client message with given type and format 32. | ||
408 | * | ||
409 | * @param win The window the message is sent to. | ||
410 | * @param type The client message type. | ||
411 | * @param d0 The client message data item 1 | ||
412 | * @param d1 The client message data item 2 | ||
413 | * @param d2 The client message data item 3 | ||
414 | * @param d3 The client message data item 4 | ||
415 | * @param d4 The client message data item 5 | ||
416 | * | ||
417 | * @return EINA_TRUE on success EINA_FALSE otherwise. | ||
418 | */ | ||
419 | EAPI Eina_Bool | ||
420 | ecore_x_client_message32_send(Ecore_X_Window win, Ecore_X_Atom type, | ||
421 | Ecore_X_Event_Mask mask, | ||
422 | long d0, long d1, long d2, long d3, long d4) | ||
423 | { | ||
424 | xcb_client_message_event_t ev; | ||
425 | xcb_void_cookie_t cookie; | ||
426 | xcb_generic_error_t *err; | ||
427 | |||
428 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
429 | CHECK_XCB_CONN; | ||
430 | |||
431 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
432 | |||
433 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
434 | ev.format = 32; | ||
435 | ev.window = win; | ||
436 | ev.type = type; | ||
437 | ev.data.data32[0] = (uint32_t)d0; | ||
438 | ev.data.data32[1] = (uint32_t)d1; | ||
439 | ev.data.data32[2] = (uint32_t)d2; | ||
440 | ev.data.data32[3] = (uint32_t)d3; | ||
441 | ev.data.data32[4] = (uint32_t)d4; | ||
442 | |||
443 | cookie = xcb_send_event(_ecore_xcb_conn, 0, win, mask, (const char *)&ev); | ||
444 | |||
445 | err = xcb_request_check(_ecore_xcb_conn, cookie); | ||
446 | if (err) | ||
447 | { | ||
448 | DBG("Problem Sending Event"); | ||
449 | DBG("\tType: %d", type); | ||
450 | DBG("\tWin: %d", win); | ||
451 | _ecore_xcb_error_handle(err); | ||
452 | free(err); | ||
453 | return EINA_FALSE; | ||
454 | } | ||
455 | |||
456 | return EINA_TRUE; | ||
457 | } | ||
458 | |||
459 | /** | ||
460 | * Send client message with given type and format 8. | ||
461 | * | ||
462 | * @param win The window the message is sent to. | ||
463 | * @param type The client message type. | ||
464 | * @param data Data to be sent. | ||
465 | * @param len Number of data bytes, max 20. | ||
466 | * | ||
467 | * @return EINA_TRUE on success EINA_FALSE otherwise. | ||
468 | */ | ||
469 | EAPI Eina_Bool | ||
470 | ecore_x_client_message8_send(Ecore_X_Window win, Ecore_X_Atom type, | ||
471 | const void *data, int len) | ||
472 | { | ||
473 | xcb_client_message_event_t ev; | ||
474 | xcb_void_cookie_t cookie; | ||
475 | xcb_generic_error_t *err; | ||
476 | |||
477 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
478 | CHECK_XCB_CONN; | ||
479 | |||
480 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
481 | |||
482 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
483 | ev.format = 8; | ||
484 | ev.window = win; | ||
485 | ev.type = type; | ||
486 | if (len > 20) len = 20; | ||
487 | memcpy(ev.data.data8, data, len); | ||
488 | memset(ev.data.data8 + len, 0, 20 - len); | ||
489 | |||
490 | cookie = xcb_send_event(_ecore_xcb_conn, 0, win, | ||
491 | XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); | ||
492 | |||
493 | err = xcb_request_check(_ecore_xcb_conn, cookie); | ||
494 | if (err) | ||
495 | { | ||
496 | DBG("Problem Sending Event"); | ||
497 | DBG("\tType: %d", type); | ||
498 | DBG("\tWin: %d", win); | ||
499 | _ecore_xcb_error_handle(err); | ||
500 | free(err); | ||
501 | return EINA_FALSE; | ||
502 | } | ||
503 | |||
504 | return EINA_TRUE; | ||
505 | } | ||
506 | |||
507 | EAPI Eina_Bool | ||
508 | ecore_x_mouse_down_send(Ecore_X_Window win, int x, int y, int b) | ||
509 | { | ||
510 | xcb_translate_coordinates_cookie_t cookie; | ||
511 | xcb_translate_coordinates_reply_t *reply; | ||
512 | xcb_button_press_event_t ev; | ||
513 | xcb_void_cookie_t vcookie; | ||
514 | xcb_generic_error_t *err; | ||
515 | Ecore_X_Window root = 0; | ||
516 | |||
517 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
518 | CHECK_XCB_CONN; | ||
519 | |||
520 | root = ecore_x_window_root_get(win); | ||
521 | cookie = xcb_translate_coordinates(_ecore_xcb_conn, win, root, x, y); | ||
522 | reply = xcb_translate_coordinates_reply(_ecore_xcb_conn, cookie, NULL); | ||
523 | if (!reply) return EINA_FALSE; | ||
524 | |||
525 | memset(&ev, 0, sizeof(xcb_button_press_event_t)); | ||
526 | |||
527 | ev.response_type = XCB_BUTTON_PRESS; | ||
528 | ev.event = win; | ||
529 | ev.child = win; | ||
530 | ev.root = root; | ||
531 | ev.event_x = x; | ||
532 | ev.event_y = y; | ||
533 | ev.same_screen = 1; | ||
534 | ev.state = 1 << b; | ||
535 | ev.detail = b; // xcb uses detail for button | ||
536 | ev.root_x = reply->dst_x; | ||
537 | ev.root_y = reply->dst_y; | ||
538 | ev.time = ecore_x_current_time_get(); | ||
539 | free(reply); | ||
540 | |||
541 | vcookie = xcb_send_event(_ecore_xcb_conn, 1, win, | ||
542 | XCB_EVENT_MASK_BUTTON_PRESS, (const char *)&ev); | ||
543 | |||
544 | err = xcb_request_check(_ecore_xcb_conn, vcookie); | ||
545 | if (err) | ||
546 | { | ||
547 | _ecore_xcb_error_handle(err); | ||
548 | free(err); | ||
549 | return EINA_FALSE; | ||
550 | } | ||
551 | |||
552 | return EINA_TRUE; | ||
553 | } | ||
554 | |||
555 | EAPI Eina_Bool | ||
556 | ecore_x_mouse_up_send(Ecore_X_Window win, int x, int y, int b) | ||
557 | { | ||
558 | xcb_translate_coordinates_cookie_t cookie; | ||
559 | xcb_translate_coordinates_reply_t *reply; | ||
560 | xcb_button_release_event_t ev; | ||
561 | xcb_void_cookie_t vcookie; | ||
562 | xcb_generic_error_t *err; | ||
563 | Ecore_X_Window root = 0; | ||
564 | |||
565 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
566 | CHECK_XCB_CONN; | ||
567 | |||
568 | root = ecore_x_window_root_get(win); | ||
569 | cookie = xcb_translate_coordinates(_ecore_xcb_conn, win, root, x, y); | ||
570 | reply = xcb_translate_coordinates_reply(_ecore_xcb_conn, cookie, NULL); | ||
571 | if (!reply) return EINA_FALSE; | ||
572 | |||
573 | memset(&ev, 0, sizeof(xcb_button_release_event_t)); | ||
574 | |||
575 | ev.response_type = XCB_BUTTON_RELEASE; | ||
576 | ev.event = win; | ||
577 | ev.child = win; | ||
578 | ev.root = root; | ||
579 | ev.event_x = x; | ||
580 | ev.event_y = y; | ||
581 | ev.same_screen = 1; | ||
582 | ev.state = 0; | ||
583 | ev.root_x = reply->dst_x; | ||
584 | ev.root_y = reply->dst_y; | ||
585 | ev.detail = b; // xcb uses detail for button | ||
586 | ev.time = ecore_x_current_time_get(); | ||
587 | free(reply); | ||
588 | |||
589 | vcookie = xcb_send_event(_ecore_xcb_conn, 1, win, | ||
590 | XCB_EVENT_MASK_BUTTON_RELEASE, (const char *)&ev); | ||
591 | |||
592 | err = xcb_request_check(_ecore_xcb_conn, vcookie); | ||
593 | if (err) | ||
594 | { | ||
595 | _ecore_xcb_error_handle(err); | ||
596 | free(err); | ||
597 | return EINA_FALSE; | ||
598 | } | ||
599 | |||
600 | return EINA_TRUE; | ||
601 | } | ||
602 | |||
603 | EAPI Eina_Bool | ||
604 | ecore_x_mouse_move_send(Ecore_X_Window win, int x, int y) | ||
605 | { | ||
606 | xcb_translate_coordinates_cookie_t cookie; | ||
607 | xcb_translate_coordinates_reply_t *reply; | ||
608 | xcb_motion_notify_event_t ev; | ||
609 | xcb_void_cookie_t vcookie; | ||
610 | xcb_generic_error_t *err; | ||
611 | Ecore_X_Window root = 0; | ||
612 | |||
613 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
614 | CHECK_XCB_CONN; | ||
615 | |||
616 | root = ecore_x_window_root_get(win); | ||
617 | cookie = xcb_translate_coordinates(_ecore_xcb_conn, win, root, x, y); | ||
618 | reply = xcb_translate_coordinates_reply(_ecore_xcb_conn, cookie, NULL); | ||
619 | if (!reply) return EINA_FALSE; | ||
620 | |||
621 | memset(&ev, 0, sizeof(xcb_motion_notify_event_t)); | ||
622 | |||
623 | ev.response_type = XCB_MOTION_NOTIFY; | ||
624 | ev.event = win; | ||
625 | ev.child = win; | ||
626 | ev.root = root; | ||
627 | ev.event_x = x; | ||
628 | ev.event_y = y; | ||
629 | ev.same_screen = 1; | ||
630 | ev.state = 0; | ||
631 | ev.detail = 0; // xcb uses 'detail' for is_hint | ||
632 | ev.root_x = reply->dst_x; | ||
633 | ev.root_y = reply->dst_y; | ||
634 | ev.time = ecore_x_current_time_get(); | ||
635 | free(reply); | ||
636 | |||
637 | vcookie = xcb_send_event(_ecore_xcb_conn, 1, win, | ||
638 | XCB_EVENT_MASK_POINTER_MOTION, (const char *)&ev); | ||
639 | |||
640 | err = xcb_request_check(_ecore_xcb_conn, vcookie); | ||
641 | if (err) | ||
642 | { | ||
643 | _ecore_xcb_error_handle(err); | ||
644 | free(err); | ||
645 | return EINA_FALSE; | ||
646 | } | ||
647 | |||
648 | return EINA_TRUE; | ||
649 | } | ||
650 | |||
651 | EAPI Eina_Bool | ||
652 | ecore_x_keyboard_grab(Ecore_X_Window win) | ||
653 | { | ||
654 | xcb_grab_keyboard_cookie_t cookie; | ||
655 | xcb_grab_keyboard_reply_t *reply; | ||
656 | |||
657 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
658 | CHECK_XCB_CONN; | ||
659 | |||
660 | cookie = | ||
661 | xcb_grab_keyboard_unchecked(_ecore_xcb_conn, 0, win, XCB_CURRENT_TIME, | ||
662 | XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC); | ||
663 | reply = xcb_grab_keyboard_reply(_ecore_xcb_conn, cookie, NULL); | ||
664 | if (!reply) return EINA_FALSE; | ||
665 | free(reply); | ||
666 | return EINA_TRUE; | ||
667 | } | ||
668 | |||
669 | EAPI void | ||
670 | ecore_x_keyboard_ungrab(void) | ||
671 | { | ||
672 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
673 | CHECK_XCB_CONN; | ||
674 | |||
675 | xcb_ungrab_keyboard(_ecore_xcb_conn, XCB_CURRENT_TIME); | ||
676 | } | ||
677 | |||
678 | EAPI void | ||
679 | ecore_x_pointer_xy_get(Ecore_X_Window win, int *x, int *y) | ||
680 | { | ||
681 | xcb_query_pointer_cookie_t cookie; | ||
682 | xcb_query_pointer_reply_t *reply; | ||
683 | |||
684 | // LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
685 | CHECK_XCB_CONN; | ||
686 | |||
687 | // if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
688 | |||
689 | if (x) *x = -1; | ||
690 | if (y) *y = -1; | ||
691 | |||
692 | cookie = xcb_query_pointer_unchecked(_ecore_xcb_conn, win); | ||
693 | reply = xcb_query_pointer_reply(_ecore_xcb_conn, cookie, NULL); | ||
694 | if (!reply) return; | ||
695 | if (x) *x = reply->win_x; | ||
696 | if (y) *y = reply->win_y; | ||
697 | free(reply); | ||
698 | } | ||
699 | |||
700 | EAPI Eina_Bool | ||
701 | ecore_x_pointer_control_set(int accel_num, int accel_denom, int threshold) | ||
702 | { | ||
703 | xcb_void_cookie_t vcookie; | ||
704 | xcb_generic_error_t *err; | ||
705 | |||
706 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
707 | CHECK_XCB_CONN; | ||
708 | |||
709 | vcookie = | ||
710 | xcb_change_pointer_control(_ecore_xcb_conn, | ||
711 | accel_num, accel_denom, threshold, 1, 1); | ||
712 | err = xcb_request_check(_ecore_xcb_conn, vcookie); | ||
713 | if (err) | ||
714 | { | ||
715 | _ecore_xcb_error_handle(err); | ||
716 | free(err); | ||
717 | return EINA_FALSE; | ||
718 | } | ||
719 | |||
720 | return EINA_TRUE; | ||
721 | } | ||
722 | |||
723 | EAPI Eina_Bool | ||
724 | ecore_x_pointer_control_get(int *accel_num, int *accel_denom, int *threshold) | ||
725 | { | ||
726 | xcb_get_pointer_control_cookie_t cookie; | ||
727 | xcb_get_pointer_control_reply_t *reply; | ||
728 | |||
729 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
730 | CHECK_XCB_CONN; | ||
731 | |||
732 | if (accel_num) *accel_num = 0; | ||
733 | if (accel_denom) *accel_denom = 0; | ||
734 | if (threshold) *threshold = 0; | ||
735 | |||
736 | cookie = xcb_get_pointer_control_unchecked(_ecore_xcb_conn); | ||
737 | reply = xcb_get_pointer_control_reply(_ecore_xcb_conn, cookie, NULL); | ||
738 | if (!reply) return EINA_FALSE; | ||
739 | |||
740 | if (accel_num) *accel_num = reply->acceleration_numerator; | ||
741 | if (accel_denom) *accel_denom = reply->acceleration_denominator; | ||
742 | if (threshold) *threshold = reply->threshold; | ||
743 | free(reply); | ||
744 | |||
745 | return EINA_TRUE; | ||
746 | } | ||
747 | |||
748 | EAPI Eina_Bool | ||
749 | ecore_x_pointer_mapping_set(unsigned char *map, int nmap) | ||
750 | { | ||
751 | xcb_set_pointer_mapping_cookie_t cookie; | ||
752 | xcb_set_pointer_mapping_reply_t *reply; | ||
753 | Eina_Bool ret = EINA_FALSE; | ||
754 | |||
755 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
756 | CHECK_XCB_CONN; | ||
757 | |||
758 | cookie = xcb_set_pointer_mapping_unchecked(_ecore_xcb_conn, nmap, map); | ||
759 | reply = xcb_set_pointer_mapping_reply(_ecore_xcb_conn, cookie, NULL); | ||
760 | if (!reply) return EINA_FALSE; | ||
761 | ret = | ||
762 | (reply->status == XCB_MAPPING_STATUS_SUCCESS) ? EINA_TRUE : EINA_FALSE; | ||
763 | |||
764 | free(reply); | ||
765 | return ret; | ||
766 | } | ||
767 | |||
768 | EAPI Eina_Bool | ||
769 | ecore_x_pointer_mapping_get(unsigned char *map, int nmap) | ||
770 | { | ||
771 | xcb_get_pointer_mapping_cookie_t cookie; | ||
772 | xcb_get_pointer_mapping_reply_t *reply; | ||
773 | |||
774 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
775 | CHECK_XCB_CONN; | ||
776 | |||
777 | if (map) *map = 0; | ||
778 | nmap = 0; | ||
779 | |||
780 | cookie = xcb_get_pointer_mapping_unchecked(_ecore_xcb_conn); | ||
781 | reply = xcb_get_pointer_mapping_reply(_ecore_xcb_conn, cookie, NULL); | ||
782 | if (!reply) return EINA_FALSE; | ||
783 | |||
784 | nmap = xcb_get_pointer_mapping_map_length(reply); | ||
785 | if (nmap <= 0) | ||
786 | { | ||
787 | free(reply); | ||
788 | return EINA_FALSE; | ||
789 | } | ||
790 | |||
791 | if (map) | ||
792 | { | ||
793 | uint8_t *tmp; | ||
794 | int i = 0; | ||
795 | |||
796 | tmp = xcb_get_pointer_mapping_map(reply); | ||
797 | for (i = 0; i < nmap; i++) | ||
798 | map[i] = tmp[i]; | ||
799 | } | ||
800 | |||
801 | free(reply); | ||
802 | return EINA_TRUE; | ||
803 | } | ||
804 | |||
805 | EAPI Eina_Bool | ||
806 | ecore_x_pointer_grab(Ecore_X_Window win) | ||
807 | { | ||
808 | xcb_grab_pointer_cookie_t cookie; | ||
809 | xcb_grab_pointer_reply_t *reply; | ||
810 | uint16_t mask; | ||
811 | Eina_Bool ret = EINA_FALSE; | ||
812 | |||
813 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
814 | CHECK_XCB_CONN; | ||
815 | |||
816 | mask = (XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | | ||
817 | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | | ||
818 | XCB_EVENT_MASK_POINTER_MOTION); | ||
819 | |||
820 | cookie = xcb_grab_pointer_unchecked(_ecore_xcb_conn, 0, win, mask, | ||
821 | XCB_GRAB_MODE_ASYNC, | ||
822 | XCB_GRAB_MODE_ASYNC, | ||
823 | XCB_NONE, XCB_NONE, XCB_CURRENT_TIME); | ||
824 | reply = xcb_grab_pointer_reply(_ecore_xcb_conn, cookie, NULL); | ||
825 | if (!reply) return EINA_FALSE; | ||
826 | |||
827 | ret = (reply->status == XCB_GRAB_STATUS_SUCCESS) ? EINA_TRUE : EINA_FALSE; | ||
828 | |||
829 | free(reply); | ||
830 | return ret; | ||
831 | } | ||
832 | |||
833 | EAPI Eina_Bool | ||
834 | ecore_x_pointer_confine_grab(Ecore_X_Window win) | ||
835 | { | ||
836 | xcb_grab_pointer_cookie_t cookie; | ||
837 | xcb_grab_pointer_reply_t *reply; | ||
838 | uint16_t mask; | ||
839 | Eina_Bool ret = EINA_FALSE; | ||
840 | |||
841 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
842 | CHECK_XCB_CONN; | ||
843 | |||
844 | mask = (XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | | ||
845 | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | | ||
846 | XCB_EVENT_MASK_POINTER_MOTION); | ||
847 | |||
848 | cookie = xcb_grab_pointer_unchecked(_ecore_xcb_conn, 0, win, mask, | ||
849 | XCB_GRAB_MODE_ASYNC, | ||
850 | XCB_GRAB_MODE_ASYNC, | ||
851 | win, XCB_NONE, XCB_CURRENT_TIME); | ||
852 | reply = xcb_grab_pointer_reply(_ecore_xcb_conn, cookie, NULL); | ||
853 | if (!reply) return EINA_FALSE; | ||
854 | |||
855 | ret = (reply->status == XCB_GRAB_STATUS_SUCCESS) ? EINA_TRUE : EINA_FALSE; | ||
856 | |||
857 | free(reply); | ||
858 | return ret; | ||
859 | } | ||
860 | |||
861 | EAPI void | ||
862 | ecore_x_pointer_ungrab(void) | ||
863 | { | ||
864 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
865 | CHECK_XCB_CONN; | ||
866 | |||
867 | xcb_ungrab_pointer(_ecore_xcb_conn, XCB_CURRENT_TIME); | ||
868 | } | ||
869 | |||
870 | EAPI Eina_Bool | ||
871 | ecore_x_pointer_warp(Ecore_X_Window win, int x, int y) | ||
872 | { | ||
873 | xcb_void_cookie_t vcookie; | ||
874 | xcb_generic_error_t *err; | ||
875 | |||
876 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
877 | CHECK_XCB_CONN; | ||
878 | |||
879 | vcookie = | ||
880 | xcb_warp_pointer_checked(_ecore_xcb_conn, XCB_NONE, win, 0, 0, 0, 0, x, y); | ||
881 | err = xcb_request_check(_ecore_xcb_conn, vcookie); | ||
882 | if (err) | ||
883 | { | ||
884 | _ecore_xcb_error_handle(err); | ||
885 | free(err); | ||
886 | return EINA_FALSE; | ||
887 | } | ||
888 | |||
889 | return EINA_TRUE; | ||
890 | } | ||
891 | |||
892 | /** | ||
893 | * Invoke the standard system beep to alert users | ||
894 | * | ||
895 | * @param percent The volume at which the bell rings. Must be in the range | ||
896 | * [-100,+100]. If percent >= 0, the final volume will be: | ||
897 | * base - [(base * percent) / 100] + percent | ||
898 | * Otherwise, it's calculated as: | ||
899 | * base + [(base * percent) / 100] | ||
900 | * where @c base is the bell's base volume as set by XChangeKeyboardControl(3). | ||
901 | * | ||
902 | * @returns EINA_TRUE on success, EINA_FALSE otherwise. | ||
903 | */ | ||
904 | EAPI Eina_Bool | ||
905 | ecore_x_bell(int percent) | ||
906 | { | ||
907 | xcb_void_cookie_t cookie; | ||
908 | xcb_generic_error_t *err; | ||
909 | |||
910 | CHECK_XCB_CONN; | ||
911 | |||
912 | // FIXME: Use unchecked version after development is ironed out | ||
913 | cookie = xcb_bell_checked(_ecore_xcb_conn, percent); | ||
914 | err = xcb_request_check(_ecore_xcb_conn, cookie); | ||
915 | if (err) | ||
916 | { | ||
917 | _ecore_xcb_error_handle(err); | ||
918 | free(err); | ||
919 | return EINA_FALSE; | ||
920 | } | ||
921 | |||
922 | return EINA_TRUE; | ||
923 | } | ||
924 | |||
925 | EAPI void | ||
926 | ecore_x_display_size_get(Ecore_X_Display *dsp __UNUSED__, int *w, int *h) | ||
927 | { | ||
928 | xcb_screen_t *screen; | ||
929 | |||
930 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
931 | CHECK_XCB_CONN; | ||
932 | |||
933 | /* grab the default screen */ | ||
934 | screen = xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).data; | ||
935 | if (w) *w = screen->width_in_pixels; | ||
936 | if (h) *h = screen->height_in_pixels; | ||
937 | } | ||
938 | |||
939 | EAPI unsigned long | ||
940 | ecore_x_display_black_pixel_get(Ecore_X_Display *dsp __UNUSED__) | ||
941 | { | ||
942 | xcb_screen_t *screen; | ||
943 | |||
944 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
945 | CHECK_XCB_CONN; | ||
946 | |||
947 | /* grab the default screen */ | ||
948 | screen = xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).data; | ||
949 | return screen->black_pixel; | ||
950 | } | ||
951 | |||
952 | EAPI unsigned long | ||
953 | ecore_x_display_white_pixel_get(Ecore_X_Display *dsp __UNUSED__) | ||
954 | { | ||
955 | xcb_screen_t *screen; | ||
956 | |||
957 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
958 | CHECK_XCB_CONN; | ||
959 | |||
960 | /* grab the default screen */ | ||
961 | screen = xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).data; | ||
962 | return screen->white_pixel; | ||
963 | } | ||
964 | |||
965 | EAPI void | ||
966 | ecore_x_pointer_last_xy_get(int *x, int *y) | ||
967 | { | ||
968 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
969 | |||
970 | if (x) *x = _ecore_xcb_event_last_root_x; | ||
971 | if (y) *y = _ecore_xcb_event_last_root_y; | ||
972 | } | ||
973 | |||
974 | EAPI void | ||
975 | ecore_x_focus_reset(void) | ||
976 | { | ||
977 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
978 | CHECK_XCB_CONN; | ||
979 | |||
980 | xcb_set_input_focus(_ecore_xcb_conn, XCB_INPUT_FOCUS_POINTER_ROOT, | ||
981 | ((xcb_screen_t *)_ecore_xcb_screen)->root, | ||
982 | XCB_CURRENT_TIME); | ||
983 | // ecore_x_flush(); | ||
984 | } | ||
985 | |||
986 | EAPI void | ||
987 | ecore_x_events_allow_all(void) | ||
988 | { | ||
989 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
990 | CHECK_XCB_CONN; | ||
991 | |||
992 | xcb_allow_events(_ecore_xcb_conn, XCB_ALLOW_ASYNC_BOTH, XCB_CURRENT_TIME); | ||
993 | // ecore_x_flush(); | ||
994 | } | ||
995 | |||
996 | /** | ||
997 | * Kill a specific client | ||
998 | * | ||
999 | * You can kill a specific client owning window @p win | ||
1000 | * | ||
1001 | * @param win Window of the client to be killed | ||
1002 | */ | ||
1003 | EAPI void | ||
1004 | ecore_x_kill(Ecore_X_Window win) | ||
1005 | { | ||
1006 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1007 | CHECK_XCB_CONN; | ||
1008 | |||
1009 | xcb_kill_client(_ecore_xcb_conn, win); | ||
1010 | // ecore_x_flush(); | ||
1011 | } | ||
1012 | |||
1013 | /** | ||
1014 | * Kill all clients with subwindows under a given window. | ||
1015 | * | ||
1016 | * You can kill all clients connected to the X server by using | ||
1017 | * @ref ecore_x_window_root_list to get a list of root windows, and | ||
1018 | * then passing each root window to this function. | ||
1019 | * | ||
1020 | * @param root The window whose children will be killed. | ||
1021 | */ | ||
1022 | EAPI void | ||
1023 | ecore_x_killall(Ecore_X_Window root) | ||
1024 | { | ||
1025 | int screens = 0, i = 0; | ||
1026 | |||
1027 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1028 | CHECK_XCB_CONN; | ||
1029 | |||
1030 | ecore_x_grab(); | ||
1031 | |||
1032 | screens = xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).rem; | ||
1033 | |||
1034 | /* Traverse window tree starting from root, and drag each | ||
1035 | * before the firing squad */ | ||
1036 | for (i = 0; i < screens; ++i) | ||
1037 | { | ||
1038 | xcb_query_tree_cookie_t cookie; | ||
1039 | xcb_query_tree_reply_t *reply; | ||
1040 | |||
1041 | cookie = xcb_query_tree_unchecked(_ecore_xcb_conn, root); | ||
1042 | reply = xcb_query_tree_reply(_ecore_xcb_conn, cookie, NULL); | ||
1043 | if (reply) | ||
1044 | { | ||
1045 | xcb_window_t *wins = NULL; | ||
1046 | int tree_c_len, j = 0; | ||
1047 | |||
1048 | wins = xcb_query_tree_children(reply); | ||
1049 | tree_c_len = xcb_query_tree_children_length(reply); | ||
1050 | for (j = 0; j < tree_c_len; j++) | ||
1051 | xcb_kill_client(_ecore_xcb_conn, wins[j]); | ||
1052 | free(reply); | ||
1053 | } | ||
1054 | } | ||
1055 | |||
1056 | ecore_x_ungrab(); | ||
1057 | ecore_x_sync(); // needed | ||
1058 | } | ||
1059 | |||
1060 | /** | ||
1061 | * Return the screen DPI | ||
1062 | * | ||
1063 | * This is a simplistic call to get DPI. It does not account for differing | ||
1064 | * DPI in the x amd y axes nor does it account for multihead or xinerama and | ||
1065 | * xrander where different parts of the screen may have differen DPI etc. | ||
1066 | * | ||
1067 | * @return the general screen DPI (dots/pixels per inch). | ||
1068 | */ | ||
1069 | EAPI int | ||
1070 | ecore_x_dpi_get(void) | ||
1071 | { | ||
1072 | uint16_t mw = 0, w = 0; | ||
1073 | |||
1074 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1075 | |||
1076 | mw = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_millimeters; | ||
1077 | if (mw <= 0) return 75; | ||
1078 | w = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels; | ||
1079 | return (((w * 254) / mw) + 5) / 10; | ||
1080 | } | ||
1081 | |||
1082 | /** | ||
1083 | * @defgroup Ecore_X_Display_Attr_Group X Display Attributes | ||
1084 | * | ||
1085 | * Functions that set and retrieve X display attributes. | ||
1086 | */ | ||
1087 | |||
1088 | /** | ||
1089 | * Retrieves the Ecore_X_Display handle used for the current X connection. | ||
1090 | * @return The current X display. | ||
1091 | * @ingroup Ecore_X_Display_Attr_Group | ||
1092 | */ | ||
1093 | EAPI Ecore_X_Display * | ||
1094 | ecore_x_display_get(void) | ||
1095 | { | ||
1096 | char *gl = NULL; | ||
1097 | |||
1098 | CHECK_XCB_CONN; | ||
1099 | |||
1100 | /* if we have the 'dont use xlib' env var, then we are not using | ||
1101 | * XLib and thus cannot return a real XDisplay. | ||
1102 | * | ||
1103 | * NB: This may break EFL in some places and needs lots of testing !!! */ | ||
1104 | if ((gl = getenv("ECORE_X_NO_XLIB"))) | ||
1105 | return (Ecore_X_Display *)_ecore_xcb_conn; | ||
1106 | else /* we can safely return an XDisplay var */ | ||
1107 | return (Ecore_X_Display *)_ecore_xcb_display; | ||
1108 | } | ||
1109 | |||
1110 | /** | ||
1111 | * Retrieves the X display file descriptor. | ||
1112 | * @return The current X display file descriptor. | ||
1113 | * @ingroup Ecore_X_Display_Attr_Group | ||
1114 | */ | ||
1115 | EAPI int | ||
1116 | ecore_x_fd_get(void) | ||
1117 | { | ||
1118 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1119 | CHECK_XCB_CONN; | ||
1120 | return xcb_get_file_descriptor(_ecore_xcb_conn); | ||
1121 | } | ||
1122 | |||
1123 | EAPI void | ||
1124 | ecore_x_passive_grab_replay_func_set(Eina_Bool (*func)(void *data, int type, void *event), | ||
1125 | void *data) | ||
1126 | { | ||
1127 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1128 | |||
1129 | _ecore_xcb_window_grab_replay_func = func; | ||
1130 | _ecore_xcb_window_grab_replay_data = data; | ||
1131 | } | ||
1132 | |||
1133 | /** | ||
1134 | * Retrieves the size of an Ecore_X_Screen. | ||
1135 | * @param screen the handle to the screen to query. | ||
1136 | * @param w where to return the width. May be NULL. Returns 0 on errors. | ||
1137 | * @param h where to return the height. May be NULL. Returns 0 on errors. | ||
1138 | * @ingroup Ecore_X_Display_Attr_Group | ||
1139 | * @see ecore_x_default_screen_get() | ||
1140 | * | ||
1141 | * @since 1.1 | ||
1142 | */ | ||
1143 | EAPI void | ||
1144 | ecore_x_screen_size_get(const Ecore_X_Screen *screen, int *w, int *h) | ||
1145 | { | ||
1146 | xcb_screen_t *s; | ||
1147 | |||
1148 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1149 | |||
1150 | if (w) *w = 0; | ||
1151 | if (h) *h = 0; | ||
1152 | if (!(s = (xcb_screen_t *)screen)) return; | ||
1153 | if (w) *w = s->width_in_pixels; | ||
1154 | if (h) *h = s->height_in_pixels; | ||
1155 | } | ||
1156 | |||
1157 | /** | ||
1158 | * Retrieves the count of screens. | ||
1159 | * | ||
1160 | * @return The count of screens. | ||
1161 | * @ingroup Ecore_X_Display_Attr_Group | ||
1162 | * | ||
1163 | * @since 1.1 | ||
1164 | */ | ||
1165 | EAPI int | ||
1166 | ecore_x_screen_count_get(void) | ||
1167 | { | ||
1168 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1169 | CHECK_XCB_CONN; | ||
1170 | |||
1171 | return xcb_setup_roots_length(xcb_get_setup(_ecore_xcb_conn)); | ||
1172 | } | ||
1173 | |||
1174 | /** | ||
1175 | * Retrieves the index number of the given screen. | ||
1176 | * | ||
1177 | * @return The index number of the screen. | ||
1178 | * @ingroup Ecore_X_Display_Attr_Group | ||
1179 | * | ||
1180 | * @since 1.1 | ||
1181 | */ | ||
1182 | EAPI int | ||
1183 | ecore_x_screen_index_get(const Ecore_X_Screen *screen) | ||
1184 | { | ||
1185 | xcb_screen_iterator_t iter; | ||
1186 | int i = 0; | ||
1187 | |||
1188 | CHECK_XCB_CONN; | ||
1189 | |||
1190 | iter = | ||
1191 | xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)); | ||
1192 | for (; iter.rem; xcb_screen_next(&iter)) | ||
1193 | { | ||
1194 | if (iter.data == (xcb_screen_t *)screen) | ||
1195 | return i; | ||
1196 | i++; | ||
1197 | } | ||
1198 | |||
1199 | return 0; | ||
1200 | } | ||
1201 | |||
1202 | /** | ||
1203 | * Retrieves the screen based on index number. | ||
1204 | * | ||
1205 | * @return The Ecore_X_Screen at this index. | ||
1206 | * @ingroup Ecore_X_Display_Attr_Group | ||
1207 | * | ||
1208 | * @since 1.1 | ||
1209 | */ | ||
1210 | EAPI Ecore_X_Screen * | ||
1211 | ecore_x_screen_get(int index) | ||
1212 | { | ||
1213 | xcb_screen_iterator_t iter; | ||
1214 | int i = 0; | ||
1215 | |||
1216 | CHECK_XCB_CONN; | ||
1217 | |||
1218 | iter = | ||
1219 | xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)); | ||
1220 | for (i = 0; iter.rem; xcb_screen_next(&iter), i++) | ||
1221 | if (i == index) return iter.data; | ||
1222 | |||
1223 | return NULL; | ||
1224 | } | ||
1225 | |||
1226 | EAPI unsigned int | ||
1227 | ecore_x_visual_id_get(Ecore_X_Visual visual) | ||
1228 | { | ||
1229 | return ((xcb_visualtype_t *)visual)->visual_id; | ||
1230 | } | ||
1231 | |||
1232 | /** | ||
1233 | * Retrieve the default Visual. | ||
1234 | * | ||
1235 | * @param disp The Display to get the Default Visual from | ||
1236 | * @param screen The Screen. | ||
1237 | * | ||
1238 | * @return The default visual. | ||
1239 | * @since 1.1.0 | ||
1240 | */ | ||
1241 | EAPI Ecore_X_Visual | ||
1242 | ecore_x_default_visual_get(Ecore_X_Display *disp __UNUSED__, Ecore_X_Screen *screen) | ||
1243 | { | ||
1244 | xcb_screen_t *s; | ||
1245 | xcb_depth_iterator_t diter; | ||
1246 | xcb_visualtype_iterator_t viter; | ||
1247 | |||
1248 | CHECK_XCB_CONN; | ||
1249 | |||
1250 | s = (xcb_screen_t *)screen; | ||
1251 | diter = xcb_screen_allowed_depths_iterator(s); | ||
1252 | for (; diter.rem; xcb_depth_next(&diter)) | ||
1253 | { | ||
1254 | viter = xcb_depth_visuals_iterator(diter.data); | ||
1255 | for (; viter.rem; xcb_visualtype_next(&viter)) | ||
1256 | { | ||
1257 | if (viter.data->visual_id == s->root_visual) | ||
1258 | return viter.data; | ||
1259 | } | ||
1260 | } | ||
1261 | return 0; | ||
1262 | } | ||
1263 | |||
1264 | /** | ||
1265 | * Retrieve the default Colormap. | ||
1266 | * | ||
1267 | * @param disp The Display to get the Default Colormap from | ||
1268 | * @param screen The Screen. | ||
1269 | * | ||
1270 | * @return The default colormap. | ||
1271 | * @since 1.1.0 | ||
1272 | */ | ||
1273 | EAPI Ecore_X_Colormap | ||
1274 | ecore_x_default_colormap_get(Ecore_X_Display *disp __UNUSED__, Ecore_X_Screen *screen) | ||
1275 | { | ||
1276 | xcb_screen_t *s; | ||
1277 | |||
1278 | s = (xcb_screen_t *)screen; | ||
1279 | return s->default_colormap; | ||
1280 | } | ||
1281 | |||
1282 | /** | ||
1283 | * Retrieve the default depth. | ||
1284 | * | ||
1285 | * @param disp The Display to get the Default Depth from | ||
1286 | * @param screen The Screen. | ||
1287 | * | ||
1288 | * @return The default depth. | ||
1289 | * @since 1.1.0 | ||
1290 | */ | ||
1291 | EAPI int | ||
1292 | ecore_x_default_depth_get(Ecore_X_Display *disp __UNUSED__, Ecore_X_Screen *screen) | ||
1293 | { | ||
1294 | xcb_screen_t *s; | ||
1295 | |||
1296 | s = (xcb_screen_t *)screen; | ||
1297 | return s->root_depth; | ||
1298 | } | ||
1299 | |||
1300 | /** | ||
1301 | * Sets the timeout for a double and triple clicks to be flagged. | ||
1302 | * | ||
1303 | * This sets the time between clicks before the double_click flag is | ||
1304 | * set in a button down event. If 3 clicks occur within double this | ||
1305 | * time, the triple_click flag is also set. | ||
1306 | * | ||
1307 | * @param t The time in seconds | ||
1308 | * @ingroup Ecore_X_Display_Attr_Group | ||
1309 | */ | ||
1310 | EAPI void | ||
1311 | ecore_x_double_click_time_set(double t) | ||
1312 | { | ||
1313 | if (t < 0.0) t = 0.0; | ||
1314 | _ecore_xcb_double_click_time = t; | ||
1315 | } | ||
1316 | |||
1317 | /** | ||
1318 | * Retrieves the double and triple click flag timeout. | ||
1319 | * | ||
1320 | * See @ref ecore_x_double_click_time_set for more information. | ||
1321 | * | ||
1322 | * @return The timeout for double clicks in seconds. | ||
1323 | * @ingroup Ecore_X_Display_Attr_Group | ||
1324 | */ | ||
1325 | EAPI double | ||
1326 | ecore_x_double_click_time_get(void) | ||
1327 | { | ||
1328 | return _ecore_xcb_double_click_time; | ||
1329 | } | ||
1330 | |||
1331 | /* local function prototypes */ | ||
1332 | static int | ||
1333 | _ecore_xcb_shutdown(Eina_Bool close_display) | ||
1334 | { | ||
1335 | if (--_ecore_xcb_init_count != 0) | ||
1336 | return _ecore_xcb_init_count; | ||
1337 | |||
1338 | if (!_ecore_xcb_conn) | ||
1339 | return _ecore_xcb_init_count; | ||
1340 | |||
1341 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1342 | CHECK_XCB_CONN; | ||
1343 | |||
1344 | ecore_idle_enterer_del(_ecore_xcb_idle_enterer); | ||
1345 | _ecore_xcb_idle_enterer = NULL; | ||
1346 | |||
1347 | if (_ecore_xcb_fd_handler) | ||
1348 | ecore_main_fd_handler_del(_ecore_xcb_fd_handler); | ||
1349 | |||
1350 | /* disconnect from display server */ | ||
1351 | if (close_display) | ||
1352 | xcb_disconnect(_ecore_xcb_conn); | ||
1353 | else | ||
1354 | { | ||
1355 | close(xcb_get_file_descriptor(_ecore_xcb_conn)); | ||
1356 | _ecore_xcb_conn = NULL; | ||
1357 | } | ||
1358 | |||
1359 | /* shutdown events */ | ||
1360 | _ecore_xcb_events_shutdown(); | ||
1361 | |||
1362 | /* shutdown input extension */ | ||
1363 | _ecore_xcb_input_shutdown(); | ||
1364 | |||
1365 | /* shutdown gesture extension */ | ||
1366 | _ecore_xcb_gesture_shutdown(); | ||
1367 | |||
1368 | /* shutdown selection */ | ||
1369 | _ecore_xcb_selection_shutdown(); | ||
1370 | |||
1371 | /* shutdown dnd */ | ||
1372 | _ecore_xcb_dnd_shutdown(); | ||
1373 | |||
1374 | /* shutdown netwm */ | ||
1375 | ecore_x_netwm_shutdown(); | ||
1376 | |||
1377 | /* shutdown keymap */ | ||
1378 | _ecore_xcb_keymap_shutdown(); | ||
1379 | |||
1380 | /* shutdown ecore_event */ | ||
1381 | ecore_event_shutdown(); | ||
1382 | |||
1383 | /* shutdown ecore */ | ||
1384 | ecore_shutdown(); | ||
1385 | |||
1386 | /* unregister log domain */ | ||
1387 | eina_log_domain_unregister(_ecore_xcb_log_dom); | ||
1388 | _ecore_xcb_log_dom = -1; | ||
1389 | |||
1390 | /* shutdown eina */ | ||
1391 | eina_shutdown(); | ||
1392 | |||
1393 | return _ecore_xcb_init_count; | ||
1394 | } | ||
1395 | |||
1396 | static Eina_Bool | ||
1397 | _ecore_xcb_fd_handle(void *data, Ecore_Fd_Handler *hdlr __UNUSED__) | ||
1398 | { | ||
1399 | xcb_connection_t *conn; | ||
1400 | xcb_generic_event_t *ev = NULL; | ||
1401 | |||
1402 | conn = (xcb_connection_t *)data; | ||
1403 | |||
1404 | if (_ecore_xcb_event_buffered) | ||
1405 | { | ||
1406 | _ecore_xcb_events_handle(_ecore_xcb_event_buffered); | ||
1407 | free(_ecore_xcb_event_buffered); | ||
1408 | _ecore_xcb_event_buffered = NULL; | ||
1409 | } | ||
1410 | |||
1411 | // xcb_flush(conn); | ||
1412 | |||
1413 | while ((ev = xcb_poll_for_event(conn))) | ||
1414 | { | ||
1415 | /* NB: Ecore Xlib uses filterevent for xim, but xcb does not support | ||
1416 | * xim, so no need for it here */ | ||
1417 | |||
1418 | /* check for errors first */ | ||
1419 | if (xcb_connection_has_error(conn)) | ||
1420 | { | ||
1421 | xcb_generic_error_t *err; | ||
1422 | |||
1423 | err = (xcb_generic_error_t *)ev; | ||
1424 | _ecore_xcb_io_error_handle(err); | ||
1425 | } | ||
1426 | else | ||
1427 | { | ||
1428 | /* FIXME: Filter event for XIM */ | ||
1429 | _ecore_xcb_events_handle(ev); | ||
1430 | free(ev); | ||
1431 | } | ||
1432 | } | ||
1433 | |||
1434 | return ECORE_CALLBACK_RENEW; | ||
1435 | } | ||
1436 | |||
1437 | static Eina_Bool | ||
1438 | _ecore_xcb_fd_handle_buff(void *data, Ecore_Fd_Handler *hdlr __UNUSED__) | ||
1439 | { | ||
1440 | xcb_connection_t *conn; | ||
1441 | xcb_generic_event_t *ev = NULL; | ||
1442 | |||
1443 | conn = (xcb_connection_t *)data; | ||
1444 | ev = xcb_poll_for_event(conn); | ||
1445 | if (ev) | ||
1446 | { | ||
1447 | /* check for errors first */ | ||
1448 | if (xcb_connection_has_error(conn)) | ||
1449 | { | ||
1450 | xcb_generic_error_t *err; | ||
1451 | |||
1452 | err = (xcb_generic_error_t *)ev; | ||
1453 | _ecore_xcb_io_error_handle(err); | ||
1454 | return ECORE_CALLBACK_CANCEL; | ||
1455 | } | ||
1456 | _ecore_xcb_event_buffered = ev; | ||
1457 | return ECORE_CALLBACK_RENEW; | ||
1458 | } | ||
1459 | return ECORE_CALLBACK_CANCEL; | ||
1460 | } | ||
1461 | |||
1462 | static Eina_Bool | ||
1463 | _ecore_xcb_idle_enter(void *data __UNUSED__) | ||
1464 | { | ||
1465 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1466 | CHECK_XCB_CONN; | ||
1467 | |||
1468 | xcb_flush(_ecore_xcb_conn); | ||
1469 | return ECORE_CALLBACK_RENEW; | ||
1470 | } | ||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_atoms.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_atoms.c new file mode 100644 index 0000000..769ffac --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_atoms.c | |||
@@ -0,0 +1,408 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #include "ecore_x_atoms_decl.h" | ||
3 | |||
4 | /* NB: Increment if you add new atoms */ | ||
5 | #define ECORE_X_ATOMS_COUNT 199 | ||
6 | |||
7 | typedef struct _Xcb_Atom Xcb_Atom; | ||
8 | struct _Xcb_Atom | ||
9 | { | ||
10 | const char *name; | ||
11 | Ecore_X_Atom *atom; | ||
12 | }; | ||
13 | |||
14 | /* local function prototypes */ | ||
15 | |||
16 | /* local variables */ | ||
17 | static xcb_intern_atom_cookie_t cookies[ECORE_X_ATOMS_COUNT]; | ||
18 | static Xcb_Atom atoms[] = | ||
19 | { | ||
20 | { "ATOM", &ECORE_X_ATOM_ATOM }, | ||
21 | { "CARDINAL", &ECORE_X_ATOM_CARDINAL }, | ||
22 | { "COMPOUND_TEXT", &ECORE_X_ATOM_COMPOUND_TEXT }, | ||
23 | { "FILE_NAME", &ECORE_X_ATOM_FILE_NAME }, | ||
24 | { "STRING", &ECORE_X_ATOM_STRING }, | ||
25 | { "TEXT", &ECORE_X_ATOM_TEXT }, | ||
26 | { "UTF8_STRING", &ECORE_X_ATOM_UTF8_STRING }, | ||
27 | { "WINDOW", &ECORE_X_ATOM_WINDOW }, | ||
28 | { "PIXMAP", &ECORE_X_ATOM_PIXMAP }, | ||
29 | { "VISUALID", &ECORE_X_ATOM_VISUALID }, | ||
30 | |||
31 | { "JXSelectionWindowProperty", &ECORE_X_ATOM_SELECTION_PROP_XDND }, | ||
32 | { "XdndSelection", &ECORE_X_ATOM_SELECTION_XDND }, | ||
33 | { "XdndAware", &ECORE_X_ATOM_XDND_AWARE }, | ||
34 | { "XdndEnter", &ECORE_X_ATOM_XDND_ENTER }, | ||
35 | { "XdndTypeList", &ECORE_X_ATOM_XDND_TYPE_LIST }, | ||
36 | { "XdndPosition", &ECORE_X_ATOM_XDND_POSITION }, | ||
37 | { "XdndActionCopy", &ECORE_X_ATOM_XDND_ACTION_COPY }, | ||
38 | { "XdndActionMove", &ECORE_X_ATOM_XDND_ACTION_MOVE }, | ||
39 | { "XdndActionPrivate", &ECORE_X_ATOM_XDND_ACTION_PRIVATE }, | ||
40 | { "XdndActionAsk", &ECORE_X_ATOM_XDND_ACTION_ASK }, | ||
41 | { "XdndActionList", &ECORE_X_ATOM_XDND_ACTION_LIST }, | ||
42 | { "XdndActionLink", &ECORE_X_ATOM_XDND_ACTION_LINK }, | ||
43 | { "XdndActionDescription", &ECORE_X_ATOM_XDND_ACTION_DESCRIPTION }, | ||
44 | { "XdndProxy", &ECORE_X_ATOM_XDND_PROXY }, | ||
45 | { "XdndStatus", &ECORE_X_ATOM_XDND_STATUS }, | ||
46 | { "XdndLeave", &ECORE_X_ATOM_XDND_LEAVE }, | ||
47 | { "XdndDrop", &ECORE_X_ATOM_XDND_DROP }, | ||
48 | { "XdndFinished", &ECORE_X_ATOM_XDND_FINISHED }, | ||
49 | |||
50 | { "XdndActionCopy", &ECORE_X_DND_ACTION_COPY }, | ||
51 | { "XdndActionMove", &ECORE_X_DND_ACTION_MOVE }, | ||
52 | { "XdndActionLink", &ECORE_X_DND_ACTION_LINK }, | ||
53 | { "XdndActionAsk", &ECORE_X_DND_ACTION_ASK }, | ||
54 | { "XdndActionPrivate", &ECORE_X_DND_ACTION_PRIVATE }, | ||
55 | |||
56 | { "_E_FRAME_SIZE", &ECORE_X_ATOM_E_FRAME_SIZE }, | ||
57 | |||
58 | { "_WIN_LAYER", &ECORE_X_ATOM_WIN_LAYER }, | ||
59 | |||
60 | { "WM_NAME", &ECORE_X_ATOM_WM_NAME }, | ||
61 | { "WM_ICON_NAME", &ECORE_X_ATOM_WM_ICON_NAME }, | ||
62 | { "WM_NORMAL_HINTS", &ECORE_X_ATOM_WM_NORMAL_HINTS }, | ||
63 | { "WM_SIZE_HINTS", &ECORE_X_ATOM_WM_SIZE_HINTS }, | ||
64 | { "WM_HINTS", &ECORE_X_ATOM_WM_HINTS }, | ||
65 | { "WM_CLASS", &ECORE_X_ATOM_WM_CLASS }, | ||
66 | { "WM_TRANSIENT_FOR", &ECORE_X_ATOM_WM_TRANSIENT_FOR }, | ||
67 | { "WM_PROTOCOLS", &ECORE_X_ATOM_WM_PROTOCOLS }, | ||
68 | { "WM_COLORMAP_WINDOWS", &ECORE_X_ATOM_WM_COLORMAP_WINDOWS }, | ||
69 | { "WM_COMMAND", &ECORE_X_ATOM_WM_COMMAND }, | ||
70 | { "WM_CLIENT_MACHINE", &ECORE_X_ATOM_WM_CLIENT_MACHINE }, | ||
71 | |||
72 | { "WM_STATE", &ECORE_X_ATOM_WM_STATE }, | ||
73 | { "WM_ICON_SIZE", &ECORE_X_ATOM_WM_ICON_SIZE }, | ||
74 | |||
75 | { "WM_CHANGE_STATE", &ECORE_X_ATOM_WM_CHANGE_STATE }, | ||
76 | |||
77 | { "WM_TAKE_FOCUS", &ECORE_X_ATOM_WM_TAKE_FOCUS }, | ||
78 | { "WM_SAVE_YOURSELF", &ECORE_X_ATOM_WM_SAVE_YOURSELF }, | ||
79 | { "WM_DELETE_WINDOW", &ECORE_X_ATOM_WM_DELETE_WINDOW }, | ||
80 | |||
81 | { "WM_COLORMAP_NOTIFY", &ECORE_X_ATOM_WM_COLORMAP_NOTIFY }, | ||
82 | |||
83 | { "SM_CLIENT_ID", &ECORE_X_ATOM_SM_CLIENT_ID }, | ||
84 | { "WM_CLIENT_LEADER", &ECORE_X_ATOM_WM_CLIENT_LEADER }, | ||
85 | { "WM_WINDOW_ROLE", &ECORE_X_ATOM_WM_WINDOW_ROLE }, | ||
86 | |||
87 | { "_MOTIF_WM_HINTS", &ECORE_X_ATOM_MOTIF_WM_HINTS }, | ||
88 | |||
89 | { "_NET_SUPPORTED", &ECORE_X_ATOM_NET_SUPPORTED }, | ||
90 | { "_NET_CLIENT_LIST", &ECORE_X_ATOM_NET_CLIENT_LIST }, | ||
91 | { "_NET_CLIENT_LIST_STACKING", &ECORE_X_ATOM_NET_CLIENT_LIST_STACKING }, | ||
92 | { "_NET_NUMBER_OF_DESKTOPS", &ECORE_X_ATOM_NET_NUMBER_OF_DESKTOPS }, | ||
93 | { "_NET_DESKTOP_GEOMETRY", &ECORE_X_ATOM_NET_DESKTOP_GEOMETRY }, | ||
94 | { "_NET_DESKTOP_VIEWPORT", &ECORE_X_ATOM_NET_DESKTOP_VIEWPORT }, | ||
95 | { "_NET_CURRENT_DESKTOP", &ECORE_X_ATOM_NET_CURRENT_DESKTOP }, | ||
96 | { "_NET_DESKTOP_NAMES", &ECORE_X_ATOM_NET_DESKTOP_NAMES }, | ||
97 | { "_NET_ACTIVE_WINDOW", &ECORE_X_ATOM_NET_ACTIVE_WINDOW }, | ||
98 | { "_NET_WORKAREA", &ECORE_X_ATOM_NET_WORKAREA }, | ||
99 | { "_NET_SUPPORTING_WM_CHECK", &ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK }, | ||
100 | { "_NET_VIRTUAL_ROOTS", &ECORE_X_ATOM_NET_VIRTUAL_ROOTS }, | ||
101 | { "_NET_DESKTOP_LAYOUT", &ECORE_X_ATOM_NET_DESKTOP_LAYOUT }, | ||
102 | { "_NET_SHOWING_DESKTOP", &ECORE_X_ATOM_NET_SHOWING_DESKTOP }, | ||
103 | |||
104 | { "_NET_CLOSE_WINDOW", &ECORE_X_ATOM_NET_CLOSE_WINDOW }, | ||
105 | { "_NET_MOVERESIZE_WINDOW", &ECORE_X_ATOM_NET_MOVERESIZE_WINDOW }, | ||
106 | { "_NET_WM_MOVERESIZE", &ECORE_X_ATOM_NET_WM_MOVERESIZE }, | ||
107 | { "_NET_RESTACK_WINDOW", &ECORE_X_ATOM_NET_RESTACK_WINDOW }, | ||
108 | |||
109 | { "_NET_REQUEST_FRAME_EXTENTS", &ECORE_X_ATOM_NET_REQUEST_FRAME_EXTENTS }, | ||
110 | |||
111 | { "_NET_WM_NAME", &ECORE_X_ATOM_NET_WM_NAME }, | ||
112 | { "_NET_WM_VISIBLE_NAME", &ECORE_X_ATOM_NET_WM_VISIBLE_NAME }, | ||
113 | { "_NET_WM_ICON_NAME", &ECORE_X_ATOM_NET_WM_ICON_NAME }, | ||
114 | { "_NET_WM_VISIBLE_ICON_NAME", &ECORE_X_ATOM_NET_WM_VISIBLE_ICON_NAME }, | ||
115 | { "_NET_WM_DESKTOP", &ECORE_X_ATOM_NET_WM_DESKTOP }, | ||
116 | |||
117 | { "_NET_WM_WINDOW_TYPE", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE }, | ||
118 | { "_NET_WM_WINDOW_TYPE_DESKTOP", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DESKTOP }, | ||
119 | { "_NET_WM_WINDOW_TYPE_DOCK", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DOCK }, | ||
120 | { "_NET_WM_WINDOW_TYPE_TOOLBAR", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLBAR }, | ||
121 | { "_NET_WM_WINDOW_TYPE_MENU", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_MENU }, | ||
122 | { "_NET_WM_WINDOW_TYPE_UTILITY", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_UTILITY }, | ||
123 | { "_NET_WM_WINDOW_TYPE_SPLASH", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_SPLASH }, | ||
124 | { "_NET_WM_WINDOW_TYPE_DIALOG", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DIALOG }, | ||
125 | { "_NET_WM_WINDOW_TYPE_NORMAL", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NORMAL }, | ||
126 | { "_NET_WM_WINDOW_TYPE_DROPDOWN_MENU", | ||
127 | &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DROPDOWN_MENU }, | ||
128 | { "_NET_WM_WINDOW_TYPE_POPUP_MENU", | ||
129 | &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_POPUP_MENU }, | ||
130 | { "_NET_WM_WINDOW_TYPE_TOOLTIP", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLTIP }, | ||
131 | { "_NET_WM_WINDOW_TYPE_NOTIFICATION", | ||
132 | &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NOTIFICATION }, | ||
133 | { "_NET_WM_WINDOW_TYPE_COMBO", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_COMBO }, | ||
134 | { "_NET_WM_WINDOW_TYPE_DND", &ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DND }, | ||
135 | |||
136 | { "_NET_WM_STATE", &ECORE_X_ATOM_NET_WM_STATE }, | ||
137 | { "_NET_WM_STATE_MODAL", &ECORE_X_ATOM_NET_WM_STATE_MODAL }, | ||
138 | { "_NET_WM_STATE_STICKY", &ECORE_X_ATOM_NET_WM_STATE_STICKY }, | ||
139 | { "_NET_WM_STATE_MAXIMIZED_VERT", | ||
140 | &ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_VERT }, | ||
141 | { "_NET_WM_STATE_MAXIMIZED_HORZ", | ||
142 | &ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_HORZ }, | ||
143 | { "_NET_WM_STATE_SHADED", &ECORE_X_ATOM_NET_WM_STATE_SHADED }, | ||
144 | { "_NET_WM_STATE_SKIP_TASKBAR", &ECORE_X_ATOM_NET_WM_STATE_SKIP_TASKBAR }, | ||
145 | { "_NET_WM_STATE_SKIP_PAGER", &ECORE_X_ATOM_NET_WM_STATE_SKIP_PAGER }, | ||
146 | { "_NET_WM_STATE_HIDDEN", &ECORE_X_ATOM_NET_WM_STATE_HIDDEN }, | ||
147 | { "_NET_WM_STATE_FULLSCREEN", &ECORE_X_ATOM_NET_WM_STATE_FULLSCREEN }, | ||
148 | { "_NET_WM_STATE_ABOVE", &ECORE_X_ATOM_NET_WM_STATE_ABOVE }, | ||
149 | { "_NET_WM_STATE_BELOW", &ECORE_X_ATOM_NET_WM_STATE_BELOW }, | ||
150 | { "_NET_WM_STATE_DEMANDS_ATTENTION", | ||
151 | &ECORE_X_ATOM_NET_WM_STATE_DEMANDS_ATTENTION }, | ||
152 | |||
153 | { "_NET_WM_ALLOWED_ACTIONS", &ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS }, | ||
154 | { "_NET_WM_ACTION_MOVE", &ECORE_X_ATOM_NET_WM_ACTION_MOVE }, | ||
155 | { "_NET_WM_ACTION_RESIZE", &ECORE_X_ATOM_NET_WM_ACTION_RESIZE }, | ||
156 | { "_NET_WM_ACTION_MINIMIZE", &ECORE_X_ATOM_NET_WM_ACTION_MINIMIZE }, | ||
157 | { "_NET_WM_ACTION_SHADE", &ECORE_X_ATOM_NET_WM_ACTION_SHADE }, | ||
158 | { "_NET_WM_ACTION_STICK", &ECORE_X_ATOM_NET_WM_ACTION_STICK }, | ||
159 | { "_NET_WM_ACTION_MAXIMIZE_HORZ", | ||
160 | &ECORE_X_ATOM_NET_WM_ACTION_MAXIMIZE_HORZ }, | ||
161 | { "_NET_WM_ACTION_MAXIMIZE_VERT", | ||
162 | &ECORE_X_ATOM_NET_WM_ACTION_MAXIMIZE_VERT }, | ||
163 | { "_NET_WM_ACTION_FULLSCREEN", &ECORE_X_ATOM_NET_WM_ACTION_FULLSCREEN }, | ||
164 | { "_NET_WM_ACTION_CHANGE_DESKTOP", | ||
165 | &ECORE_X_ATOM_NET_WM_ACTION_CHANGE_DESKTOP }, | ||
166 | { "_NET_WM_ACTION_CLOSE", &ECORE_X_ATOM_NET_WM_ACTION_CLOSE }, | ||
167 | { "_NET_WM_ACTION_ABOVE", &ECORE_X_ATOM_NET_WM_ACTION_ABOVE }, | ||
168 | { "_NET_WM_ACTION_BELOW", &ECORE_X_ATOM_NET_WM_ACTION_BELOW }, | ||
169 | |||
170 | { "_NET_WM_STRUT", &ECORE_X_ATOM_NET_WM_STRUT }, | ||
171 | { "_NET_WM_STRUT_PARTIAL", &ECORE_X_ATOM_NET_WM_STRUT_PARTIAL }, | ||
172 | { "_NET_WM_ICON_GEOMETRY", &ECORE_X_ATOM_NET_WM_ICON_GEOMETRY }, | ||
173 | { "_NET_WM_ICON", &ECORE_X_ATOM_NET_WM_ICON }, | ||
174 | { "_NET_WM_PID", &ECORE_X_ATOM_NET_WM_PID }, | ||
175 | { "_NET_WM_HANDLED_ICONS", &ECORE_X_ATOM_NET_WM_HANDLED_ICONS }, | ||
176 | { "_NET_WM_USER_TIME", &ECORE_X_ATOM_NET_WM_USER_TIME }, | ||
177 | { "_NET_STARTUP_ID", &ECORE_X_ATOM_NET_STARTUP_ID }, | ||
178 | { "_NET_FRAME_EXTENTS", &ECORE_X_ATOM_NET_FRAME_EXTENTS }, | ||
179 | |||
180 | { "_NET_WM_PING", &ECORE_X_ATOM_NET_WM_PING }, | ||
181 | { "_NET_WM_SYNC_REQUEST", &ECORE_X_ATOM_NET_WM_SYNC_REQUEST }, | ||
182 | { "_NET_WM_SYNC_REQUEST_COUNTER", | ||
183 | &ECORE_X_ATOM_NET_WM_SYNC_REQUEST_COUNTER }, | ||
184 | |||
185 | { "_NET_WM_WINDOW_OPACITY", &ECORE_X_ATOM_NET_WM_WINDOW_OPACITY }, | ||
186 | { "_NET_WM_WINDOW_SHADOW", &ECORE_X_ATOM_NET_WM_WINDOW_SHADOW }, | ||
187 | { "_NET_WM_WINDOW_SHADE", &ECORE_X_ATOM_NET_WM_WINDOW_SHADE }, | ||
188 | |||
189 | { "TARGETS", &ECORE_X_ATOM_SELECTION_TARGETS }, | ||
190 | { "CLIPBOARD", &ECORE_X_ATOM_SELECTION_CLIPBOARD }, | ||
191 | { "PRIMARY", &ECORE_X_ATOM_SELECTION_PRIMARY }, | ||
192 | { "SECONDARY", &ECORE_X_ATOM_SELECTION_SECONDARY }, | ||
193 | { "_ECORE_SELECTION_PRIMARY", &ECORE_X_ATOM_SELECTION_PROP_PRIMARY }, | ||
194 | { "_ECORE_SELECTION_SECONDARY", &ECORE_X_ATOM_SELECTION_PROP_SECONDARY }, | ||
195 | { "_ECORE_SELECTION_CLIPBOARD", &ECORE_X_ATOM_SELECTION_PROP_CLIPBOARD }, | ||
196 | |||
197 | { "_E_VIRTUAL_KEYBOARD", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD }, | ||
198 | { "_E_VIRTUAL_KEYBOARD_STATE", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE }, | ||
199 | { "_E_VIRTUAL_KEYBOARD_ON", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_ON }, | ||
200 | { "_E_VIRTUAL_KEYBOARD_OFF", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_OFF }, | ||
201 | { "_E_VIRTUAL_KEYBOARD_ALPHA", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_ALPHA }, | ||
202 | { "_E_VIRTUAL_KEYBOARD_NUMERIC", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_NUMERIC }, | ||
203 | { "_E_VIRTUAL_KEYBOARD_PIN", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PIN }, | ||
204 | { "_E_VIRTUAL_KEYBOARD_PHONE_NUMBER", | ||
205 | &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PHONE_NUMBER }, | ||
206 | { "_E_VIRTUAL_KEYBOARD_HEX", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_HEX }, | ||
207 | { "_E_VIRTUAL_KEYBOARD_TERMINAL", | ||
208 | &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_TERMINAL }, | ||
209 | { "_E_VIRTUAL_KEYBOARD_PASSWORD", | ||
210 | &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PASSWORD }, | ||
211 | { "_E_VIRTUAL_KEYBOARD_IP", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_IP }, | ||
212 | { "_E_VIRTUAL_KEYBOARD_HOST", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_HOST }, | ||
213 | { "_E_VIRTUAL_KEYBOARD_FILE", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_FILE }, | ||
214 | { "_E_VIRTUAL_KEYBOARD_URL", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_URL }, | ||
215 | { "_E_VIRTUAL_KEYBOARD_KEYPAD", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_KEYPAD }, | ||
216 | { "_E_VIRTUAL_KEYBOARD_J2ME", &ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_J2ME }, | ||
217 | |||
218 | { "_E_ILLUME_ZONE", &ECORE_X_ATOM_E_ILLUME_ZONE }, | ||
219 | { "_E_ILLUME_ZONE_LIST", &ECORE_X_ATOM_E_ILLUME_ZONE_LIST }, | ||
220 | { "_E_ILLUME_CONFORMANT", &ECORE_X_ATOM_E_ILLUME_CONFORMANT }, | ||
221 | { "_E_ILLUME_MODE", &ECORE_X_ATOM_E_ILLUME_MODE }, | ||
222 | { "_E_ILLUME_MODE_SINGLE", &ECORE_X_ATOM_E_ILLUME_MODE_SINGLE }, | ||
223 | { "_E_ILLUME_MODE_DUAL_TOP", &ECORE_X_ATOM_E_ILLUME_MODE_DUAL_TOP }, | ||
224 | { "_E_ILLUME_MODE_DUAL_LEFT", &ECORE_X_ATOM_E_ILLUME_MODE_DUAL_LEFT }, | ||
225 | { "_E_ILLUME_FOCUS_BACK", &ECORE_X_ATOM_E_ILLUME_FOCUS_BACK }, | ||
226 | { "_E_ILLUME_FOCUS_FORWARD", &ECORE_X_ATOM_E_ILLUME_FOCUS_FORWARD }, | ||
227 | { "_E_ILLUME_FOCUS_HOME", &ECORE_X_ATOM_E_ILLUME_FOCUS_HOME }, | ||
228 | { "_E_ILLUME_CLOSE", &ECORE_X_ATOM_E_ILLUME_CLOSE }, | ||
229 | { "_E_ILLUME_HOME_NEW", &ECORE_X_ATOM_E_ILLUME_HOME_NEW }, | ||
230 | { "_E_ILLUME_HOME_DEL", &ECORE_X_ATOM_E_ILLUME_HOME_DEL }, | ||
231 | { "_E_ILLUME_DRAG", &ECORE_X_ATOM_E_ILLUME_DRAG }, | ||
232 | { "_E_ILLUME_DRAG_LOCKED", &ECORE_X_ATOM_E_ILLUME_DRAG_LOCKED }, | ||
233 | { "_E_ILLUME_DRAG_START", &ECORE_X_ATOM_E_ILLUME_DRAG_START }, | ||
234 | { "_E_ILLUME_DRAG_END", &ECORE_X_ATOM_E_ILLUME_DRAG_END }, | ||
235 | { "_E_ILLUME_INDICATOR_GEOMETRY", | ||
236 | &ECORE_X_ATOM_E_ILLUME_INDICATOR_GEOMETRY }, | ||
237 | { "_E_ILLUME_SOFTKEY_GEOMETRY", &ECORE_X_ATOM_E_ILLUME_SOFTKEY_GEOMETRY }, | ||
238 | { "_E_ILLUME_KEYBOARD_GEOMETRY", &ECORE_X_ATOM_E_ILLUME_KEYBOARD_GEOMETRY }, | ||
239 | { "_E_ILLUME_QUICKPANEL", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL }, | ||
240 | { "_E_ILLUME_QUICKPANEL_STATE", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE }, | ||
241 | { "_E_ILLUME_QUICKPANEL_STATE_TOGGLE", | ||
242 | &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE_TOGGLE }, | ||
243 | { "_E_ILLUME_QUICKPANEL_ON", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON }, | ||
244 | { "_E_ILLUME_QUICKPANEL_OFF", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF }, | ||
245 | { "_E_ILLUME_QUICKPANEL_PRIORITY_MAJOR", | ||
246 | &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MAJOR }, | ||
247 | { "_E_ILLUME_QUICKPANEL_PRIORITY_MINOR", | ||
248 | &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MINOR }, | ||
249 | { "_E_ILLUME_QUICKPANEL_ZONE", &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ZONE }, | ||
250 | { "_E_ILLUME_QUICKPANEL_POSITION_UPDATE", | ||
251 | &ECORE_X_ATOM_E_ILLUME_QUICKPANEL_POSITION_UPDATE }, | ||
252 | |||
253 | { "_E_COMP_SYNC_COUNTER", &ECORE_X_ATOM_E_COMP_SYNC_COUNTER }, | ||
254 | { "_E_COMP_SYNC_DRAW_DONE", &ECORE_X_ATOM_E_COMP_SYNC_DRAW_DONE }, | ||
255 | { "_E_COMP_SYNC_SUPPORTED", &ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED }, | ||
256 | { "_E_COMP_SYNC_BEGIN", &ECORE_X_ATOM_E_COMP_SYNC_BEGIN }, | ||
257 | { "_E_COMP_SYNC_END", &ECORE_X_ATOM_E_COMP_SYNC_END }, | ||
258 | { "_E_COMP_SYNC_CANCEL", &ECORE_X_ATOM_E_COMP_SYNC_CANCEL }, | ||
259 | |||
260 | { "_E_COMP_FLUSH", &ECORE_X_ATOM_E_COMP_FLUSH }, | ||
261 | { "_E_COMP_DUMP", &ECORE_X_ATOM_E_COMP_DUMP }, | ||
262 | { "_E_COMP_PIXMAP", &ECORE_X_ATOM_E_COMP_PIXMAP }, | ||
263 | { "_E_VIDEO_PARENT", &ECORE_X_ATOM_E_VIDEO_PARENT }, | ||
264 | { "_E_VIDEO_POSITION", &ECORE_X_ATOM_E_VIDEO_POSITION } | ||
265 | }; | ||
266 | |||
267 | void | ||
268 | _ecore_xcb_atoms_init(void) | ||
269 | { | ||
270 | int i = 0, num = 0; | ||
271 | |||
272 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
273 | CHECK_XCB_CONN; | ||
274 | |||
275 | num = (sizeof(atoms) / sizeof(Xcb_Atom)); | ||
276 | for (i = 0; i < num; i++) | ||
277 | { | ||
278 | cookies[i] = | ||
279 | xcb_intern_atom_unchecked(_ecore_xcb_conn, 0, | ||
280 | strlen(atoms[i].name), atoms[i].name); | ||
281 | } | ||
282 | } | ||
283 | |||
284 | void | ||
285 | _ecore_xcb_atoms_finalize(void) | ||
286 | { | ||
287 | int i = 0, num = 0; | ||
288 | |||
289 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
290 | CHECK_XCB_CONN; | ||
291 | |||
292 | num = (sizeof(atoms) / sizeof(Xcb_Atom)); | ||
293 | for (i = 0; i < num; i++) | ||
294 | { | ||
295 | xcb_intern_atom_reply_t *reply = NULL; | ||
296 | |||
297 | if (!(reply = xcb_intern_atom_reply(_ecore_xcb_conn, cookies[i], 0))) | ||
298 | continue; | ||
299 | *(atoms[i].atom) = reply->atom; | ||
300 | free(reply); | ||
301 | } | ||
302 | } | ||
303 | |||
304 | /** | ||
305 | * @defgroup Ecore_X_Atom_Group XCB Atom Functions | ||
306 | * | ||
307 | * Functions that operate on atoms | ||
308 | */ | ||
309 | |||
310 | /** | ||
311 | * Retrieves the atom value associated to a name. | ||
312 | * | ||
313 | * @param name Unused. | ||
314 | * @return Associated atom value. | ||
315 | * | ||
316 | * Retrieves the atom value associated to a name. The reply is the | ||
317 | * returned value of the function ecore_xcb_intern_atom_reply(). If | ||
318 | * @p reply is @c NULL, the NULL atom is returned. Otherwise, the atom | ||
319 | * associated to the name is returned. | ||
320 | * | ||
321 | * To use this function, you must call before, and in order, | ||
322 | * ecore_x_atom_get_prefetch(), which sends the InternAtom request, | ||
323 | * then ecore_x_atom_get_fetch(), which gets the reply. | ||
324 | * | ||
325 | * @ingroup Ecore_X_Atom_Group | ||
326 | */ | ||
327 | EAPI Ecore_X_Atom | ||
328 | ecore_x_atom_get(const char *name) | ||
329 | { | ||
330 | xcb_intern_atom_cookie_t cookie; | ||
331 | xcb_intern_atom_reply_t *reply; | ||
332 | Ecore_X_Atom a; | ||
333 | |||
334 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
335 | CHECK_XCB_CONN; | ||
336 | |||
337 | cookie = xcb_intern_atom_unchecked(_ecore_xcb_conn, 0, strlen(name), name); | ||
338 | reply = xcb_intern_atom_reply(_ecore_xcb_conn, cookie, NULL); | ||
339 | if (!reply) return XCB_ATOM_NONE; | ||
340 | a = reply->atom; | ||
341 | free(reply); | ||
342 | return a; | ||
343 | } | ||
344 | |||
345 | /** | ||
346 | * Retrieves the name of the given atom. | ||
347 | * | ||
348 | * @param atom | ||
349 | * @return The name of the atom. | ||
350 | * | ||
351 | * @ingroup Ecore_X_Atom_Group | ||
352 | */ | ||
353 | EAPI char * | ||
354 | ecore_x_atom_name_get(Ecore_X_Atom atom) | ||
355 | { | ||
356 | xcb_get_atom_name_cookie_t cookie; | ||
357 | xcb_get_atom_name_reply_t *reply; | ||
358 | char *name; | ||
359 | int len = 0; | ||
360 | |||
361 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
362 | CHECK_XCB_CONN; | ||
363 | |||
364 | cookie = xcb_get_atom_name_unchecked(_ecore_xcb_conn, atom); | ||
365 | reply = xcb_get_atom_name_reply(_ecore_xcb_conn, cookie, NULL); | ||
366 | if (!reply) return NULL; | ||
367 | len = xcb_get_atom_name_name_length(reply); | ||
368 | name = (char *)malloc(sizeof(char) * (len + 1)); | ||
369 | if (!name) | ||
370 | { | ||
371 | free(reply); | ||
372 | return NULL; | ||
373 | } | ||
374 | memcpy(name, xcb_get_atom_name_name(reply), len); | ||
375 | name[len] = '\0'; | ||
376 | |||
377 | free(reply); | ||
378 | return name; | ||
379 | } | ||
380 | |||
381 | EAPI void | ||
382 | ecore_x_atoms_get(const char **names, | ||
383 | int num, | ||
384 | Ecore_X_Atom *atoms) | ||
385 | { | ||
386 | xcb_intern_atom_cookie_t cookies[num]; | ||
387 | int i = 0; | ||
388 | |||
389 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
390 | CHECK_XCB_CONN; | ||
391 | |||
392 | for (i = 0; i < num; i++) | ||
393 | { | ||
394 | cookies[i] = | ||
395 | xcb_intern_atom_unchecked(_ecore_xcb_conn, 0, | ||
396 | strlen(names[i]), names[i]); | ||
397 | } | ||
398 | for (i = 0; i < num; i++) | ||
399 | { | ||
400 | xcb_intern_atom_reply_t *reply = NULL; | ||
401 | |||
402 | if (!(reply = xcb_intern_atom_reply(_ecore_xcb_conn, cookies[i], 0))) | ||
403 | continue; | ||
404 | atoms[i] = reply->atom; | ||
405 | free(reply); | ||
406 | } | ||
407 | } | ||
408 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_composite.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_composite.c new file mode 100644 index 0000000..f247b34 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_composite.c | |||
@@ -0,0 +1,289 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #ifdef ECORE_XCB_COMPOSITE | ||
3 | # include <xcb/composite.h> | ||
4 | #endif | ||
5 | |||
6 | /* local variables */ | ||
7 | static Eina_Bool _composite_avail = EINA_FALSE; | ||
8 | |||
9 | void | ||
10 | _ecore_xcb_composite_init(void) | ||
11 | { | ||
12 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
13 | |||
14 | #ifdef ECORE_XCB_COMPOSITE | ||
15 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_composite_id); | ||
16 | #endif | ||
17 | } | ||
18 | |||
19 | void | ||
20 | _ecore_xcb_composite_finalize(void) | ||
21 | { | ||
22 | #ifdef ECORE_XCB_COMPOSITE | ||
23 | const xcb_query_extension_reply_t *ext_reply; | ||
24 | #endif | ||
25 | |||
26 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
27 | |||
28 | #ifdef ECORE_XCB_COMPOSITE | ||
29 | ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_composite_id); | ||
30 | if ((ext_reply) && (ext_reply->present)) | ||
31 | { | ||
32 | xcb_composite_query_version_cookie_t cookie; | ||
33 | xcb_composite_query_version_reply_t *reply; | ||
34 | |||
35 | cookie = | ||
36 | xcb_composite_query_version_unchecked(_ecore_xcb_conn, | ||
37 | XCB_COMPOSITE_MAJOR_VERSION, | ||
38 | XCB_COMPOSITE_MINOR_VERSION); | ||
39 | reply = | ||
40 | xcb_composite_query_version_reply(_ecore_xcb_conn, cookie, NULL); | ||
41 | if (reply) | ||
42 | { | ||
43 | // if ((reply->major_version >= XCB_COMPOSITE_MAJOR_VERSION) && | ||
44 | if (reply->minor_version >= XCB_COMPOSITE_MINOR_VERSION) | ||
45 | { | ||
46 | # ifdef ECORE_XCB_RENDER | ||
47 | if (_ecore_xcb_render_avail_get()) | ||
48 | { | ||
49 | # ifdef ECORE_XCB_XFIXES | ||
50 | if (_ecore_xcb_xfixes_avail_get()) | ||
51 | _composite_avail = EINA_TRUE; | ||
52 | # endif | ||
53 | } | ||
54 | # endif | ||
55 | } | ||
56 | |||
57 | free(reply); | ||
58 | } | ||
59 | } | ||
60 | #endif | ||
61 | } | ||
62 | |||
63 | /** | ||
64 | * @defgroup Ecore_X_Composite_Group X Composite Extension Functions | ||
65 | * | ||
66 | * Functions related to the X Composite Extension | ||
67 | */ | ||
68 | |||
69 | /** | ||
70 | * Return whether the Composite Extension is available | ||
71 | * | ||
72 | * @return EINA_TRUE is the Composite Extension is available, EINA_FALSE if not | ||
73 | * | ||
74 | * @ingroup Ecore_X_Composite_Group | ||
75 | */ | ||
76 | EAPI Eina_Bool | ||
77 | ecore_x_composite_query(void) | ||
78 | { | ||
79 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
80 | return _composite_avail; | ||
81 | } | ||
82 | |||
83 | EAPI void | ||
84 | ecore_x_composite_redirect_window(Ecore_X_Window win, | ||
85 | Ecore_X_Composite_Update_Type type) | ||
86 | { | ||
87 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
88 | CHECK_XCB_CONN; | ||
89 | |||
90 | if (!_composite_avail) return; | ||
91 | |||
92 | #ifdef ECORE_XCB_COMPOSITE | ||
93 | uint8_t update = XCB_COMPOSITE_REDIRECT_AUTOMATIC; | ||
94 | |||
95 | switch (type) | ||
96 | { | ||
97 | case ECORE_X_COMPOSITE_UPDATE_AUTOMATIC: | ||
98 | update = XCB_COMPOSITE_REDIRECT_AUTOMATIC; | ||
99 | break; | ||
100 | |||
101 | case ECORE_X_COMPOSITE_UPDATE_MANUAL: | ||
102 | update = XCB_COMPOSITE_REDIRECT_MANUAL; | ||
103 | break; | ||
104 | } | ||
105 | xcb_composite_redirect_window(_ecore_xcb_conn, win, update); | ||
106 | // ecore_x_flush(); | ||
107 | #endif | ||
108 | } | ||
109 | |||
110 | EAPI void | ||
111 | ecore_x_composite_redirect_subwindows(Ecore_X_Window win, | ||
112 | Ecore_X_Composite_Update_Type type) | ||
113 | { | ||
114 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
115 | CHECK_XCB_CONN; | ||
116 | |||
117 | if (!_composite_avail) return; | ||
118 | |||
119 | #ifdef ECORE_XCB_COMPOSITE | ||
120 | uint8_t update = XCB_COMPOSITE_REDIRECT_AUTOMATIC; | ||
121 | |||
122 | switch (type) | ||
123 | { | ||
124 | case ECORE_X_COMPOSITE_UPDATE_AUTOMATIC: | ||
125 | update = XCB_COMPOSITE_REDIRECT_AUTOMATIC; | ||
126 | break; | ||
127 | |||
128 | case ECORE_X_COMPOSITE_UPDATE_MANUAL: | ||
129 | update = XCB_COMPOSITE_REDIRECT_MANUAL; | ||
130 | break; | ||
131 | } | ||
132 | xcb_composite_redirect_subwindows(_ecore_xcb_conn, win, update); | ||
133 | // ecore_x_flush(); | ||
134 | #endif | ||
135 | } | ||
136 | |||
137 | EAPI void | ||
138 | ecore_x_composite_unredirect_window(Ecore_X_Window win, | ||
139 | Ecore_X_Composite_Update_Type type) | ||
140 | { | ||
141 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
142 | CHECK_XCB_CONN; | ||
143 | |||
144 | if (!_composite_avail) return; | ||
145 | |||
146 | #ifdef ECORE_XCB_COMPOSITE | ||
147 | uint8_t update = XCB_COMPOSITE_REDIRECT_AUTOMATIC; | ||
148 | |||
149 | switch (type) | ||
150 | { | ||
151 | case ECORE_X_COMPOSITE_UPDATE_AUTOMATIC: | ||
152 | update = XCB_COMPOSITE_REDIRECT_AUTOMATIC; | ||
153 | break; | ||
154 | |||
155 | case ECORE_X_COMPOSITE_UPDATE_MANUAL: | ||
156 | update = XCB_COMPOSITE_REDIRECT_MANUAL; | ||
157 | break; | ||
158 | } | ||
159 | xcb_composite_unredirect_window(_ecore_xcb_conn, win, update); | ||
160 | // ecore_x_flush(); | ||
161 | #endif | ||
162 | } | ||
163 | |||
164 | EAPI void | ||
165 | ecore_x_composite_unredirect_subwindows(Ecore_X_Window win, | ||
166 | Ecore_X_Composite_Update_Type type) | ||
167 | { | ||
168 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
169 | CHECK_XCB_CONN; | ||
170 | |||
171 | if (!_composite_avail) return; | ||
172 | |||
173 | #ifdef ECORE_XCB_COMPOSITE | ||
174 | uint8_t update = XCB_COMPOSITE_REDIRECT_AUTOMATIC; | ||
175 | |||
176 | switch (type) | ||
177 | { | ||
178 | case ECORE_X_COMPOSITE_UPDATE_AUTOMATIC: | ||
179 | update = XCB_COMPOSITE_REDIRECT_AUTOMATIC; | ||
180 | break; | ||
181 | |||
182 | case ECORE_X_COMPOSITE_UPDATE_MANUAL: | ||
183 | update = XCB_COMPOSITE_REDIRECT_MANUAL; | ||
184 | break; | ||
185 | } | ||
186 | xcb_composite_unredirect_subwindows(_ecore_xcb_conn, win, update); | ||
187 | // ecore_x_flush(); | ||
188 | #endif | ||
189 | } | ||
190 | |||
191 | EAPI Ecore_X_Pixmap | ||
192 | ecore_x_composite_name_window_pixmap_get(Ecore_X_Window win) | ||
193 | { | ||
194 | #ifdef ECORE_XCB_COMPOSITE | ||
195 | Ecore_X_Pixmap pmap = XCB_NONE; | ||
196 | #endif | ||
197 | |||
198 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
199 | CHECK_XCB_CONN; | ||
200 | |||
201 | if (!_composite_avail) return XCB_NONE; | ||
202 | |||
203 | #ifdef ECORE_XCB_COMPOSITE | ||
204 | pmap = xcb_generate_id(_ecore_xcb_conn); | ||
205 | xcb_composite_name_window_pixmap(_ecore_xcb_conn, win, pmap); | ||
206 | // ecore_x_flush(); | ||
207 | #endif | ||
208 | |||
209 | return pmap; | ||
210 | } | ||
211 | |||
212 | EAPI void | ||
213 | ecore_x_composite_window_events_disable(Ecore_X_Window win) | ||
214 | { | ||
215 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
216 | CHECK_XCB_CONN; | ||
217 | |||
218 | if (!_composite_avail) return; | ||
219 | |||
220 | #ifdef ECORE_XCB_SHAPE | ||
221 | ecore_x_window_shape_input_rectangle_set(win, -1, -1, 1, 1); | ||
222 | // ecore_x_flush(); | ||
223 | #else | ||
224 | return; | ||
225 | win = 0; | ||
226 | #endif | ||
227 | } | ||
228 | |||
229 | EAPI void | ||
230 | ecore_x_composite_window_events_enable(Ecore_X_Window win) | ||
231 | { | ||
232 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
233 | CHECK_XCB_CONN; | ||
234 | |||
235 | if (!_composite_avail) return; | ||
236 | |||
237 | #ifdef ECORE_XCB_SHAPE | ||
238 | ecore_x_window_shape_input_rectangle_set(win, 0, 0, 65535, 65535); | ||
239 | // ecore_x_flush(); | ||
240 | #else | ||
241 | return; | ||
242 | win = 0; | ||
243 | #endif | ||
244 | } | ||
245 | |||
246 | EAPI Ecore_X_Window | ||
247 | ecore_x_composite_render_window_enable(Ecore_X_Window root) | ||
248 | { | ||
249 | Ecore_X_Window win = 0; | ||
250 | #ifdef ECORE_XCB_COMPOSITE | ||
251 | xcb_composite_get_overlay_window_cookie_t cookie; | ||
252 | xcb_composite_get_overlay_window_reply_t *reply; | ||
253 | #endif | ||
254 | |||
255 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
256 | CHECK_XCB_CONN; | ||
257 | |||
258 | if (!_composite_avail) return 0; | ||
259 | |||
260 | #ifdef ECORE_XCB_COMPOSITE | ||
261 | cookie = xcb_composite_get_overlay_window_unchecked(_ecore_xcb_conn, root); | ||
262 | reply = | ||
263 | xcb_composite_get_overlay_window_reply(_ecore_xcb_conn, cookie, NULL); | ||
264 | if (!reply) return win; | ||
265 | |||
266 | win = reply->overlay_win; | ||
267 | free(reply); | ||
268 | |||
269 | ecore_x_composite_window_events_disable(win); | ||
270 | // ecore_x_flush(); | ||
271 | #endif | ||
272 | |||
273 | return win; | ||
274 | } | ||
275 | |||
276 | EAPI void | ||
277 | ecore_x_composite_render_window_disable(Ecore_X_Window win) | ||
278 | { | ||
279 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
280 | CHECK_XCB_CONN; | ||
281 | |||
282 | if (!_composite_avail) return; | ||
283 | |||
284 | #ifdef ECORE_XCB_COMPOSITE | ||
285 | xcb_composite_release_overlay_window(_ecore_xcb_conn, win); | ||
286 | // ecore_x_flush(); | ||
287 | #endif | ||
288 | } | ||
289 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_cursor.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_cursor.c new file mode 100644 index 0000000..755df04 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_cursor.c | |||
@@ -0,0 +1,400 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #ifdef ECORE_XCB_CURSOR | ||
3 | # include <xcb/render.h> | ||
4 | # include <xcb/xcb_renderutil.h> | ||
5 | #endif | ||
6 | |||
7 | /* local function prototypes */ | ||
8 | #ifdef ECORE_XCB_CURSOR | ||
9 | static xcb_render_pictforminfo_t *_ecore_xcb_cursor_format_get(void); | ||
10 | #endif | ||
11 | static void _ecore_xcb_cursor_default_size_get(void); | ||
12 | static void _ecore_xcb_cursor_dpi_size_get(void); | ||
13 | static void _ecore_xcb_cursor_guess_size(void); | ||
14 | #ifdef ECORE_XCB_CURSOR | ||
15 | static Ecore_X_Cursor _ecore_xcb_cursor_image_load_cursor(xcb_image_t *img, | ||
16 | int hot_x, | ||
17 | int hot_y); | ||
18 | #endif | ||
19 | static void _ecore_xcb_cursor_image_destroy(xcb_image_t *img); | ||
20 | |||
21 | /* local variables */ | ||
22 | static int _ecore_xcb_cursor_size = 0; | ||
23 | static Eina_Bool _ecore_xcb_cursor = EINA_FALSE; | ||
24 | #ifdef ECORE_XCB_CURSOR | ||
25 | static uint32_t _ecore_xcb_cursor_format_id = 0; | ||
26 | // static xcb_render_pictforminfo_t *_ecore_xcb_cursor_format = NULL; | ||
27 | #endif | ||
28 | |||
29 | void | ||
30 | _ecore_xcb_cursor_init(void) | ||
31 | { | ||
32 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
33 | /* NB: No-op */ | ||
34 | } | ||
35 | |||
36 | void | ||
37 | _ecore_xcb_cursor_finalize(void) | ||
38 | { | ||
39 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
40 | |||
41 | #ifdef ECORE_XCB_CURSOR | ||
42 | _ecore_xcb_cursor = _ecore_xcb_render_argb_get(); | ||
43 | |||
44 | /* find render pict format */ | ||
45 | if (_ecore_xcb_cursor_format_id <= 0) | ||
46 | _ecore_xcb_cursor_format_id = _ecore_xcb_cursor_format_get()->id; | ||
47 | #endif | ||
48 | |||
49 | /* try to grab cursor size from XDefaults */ | ||
50 | _ecore_xcb_cursor_default_size_get(); | ||
51 | |||
52 | /* if that failed, try to get it from Xft Dpi setting */ | ||
53 | if (_ecore_xcb_cursor_size == 0) | ||
54 | _ecore_xcb_cursor_dpi_size_get(); | ||
55 | |||
56 | /* if that failed, try to guess from display size */ | ||
57 | if (_ecore_xcb_cursor_size == 0) | ||
58 | _ecore_xcb_cursor_guess_size(); | ||
59 | |||
60 | /* NB: Would normally add theme stuff here, but E cursor does not support | ||
61 | * xcursor themes. Delay parsing that stuff out until such time if/when the | ||
62 | * user selects to use X Cursor, rather than E cursor */ | ||
63 | } | ||
64 | |||
65 | EAPI Eina_Bool | ||
66 | ecore_x_cursor_color_supported_get(void) | ||
67 | { | ||
68 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
69 | |||
70 | return _ecore_xcb_cursor; | ||
71 | } | ||
72 | |||
73 | EAPI Ecore_X_Cursor | ||
74 | ecore_x_cursor_new(Ecore_X_Window win, | ||
75 | int *pixels, | ||
76 | int w, | ||
77 | int h, | ||
78 | int hot_x, | ||
79 | int hot_y) | ||
80 | { | ||
81 | Ecore_X_Cursor cursor = 0; | ||
82 | xcb_image_t *img; | ||
83 | |||
84 | // LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
85 | CHECK_XCB_CONN; | ||
86 | |||
87 | #ifdef ECORE_XCB_CURSOR | ||
88 | if (_ecore_xcb_cursor) | ||
89 | { | ||
90 | img = _ecore_xcb_image_create_native(w, h, XCB_IMAGE_FORMAT_Z_PIXMAP, | ||
91 | 32, NULL, (w * h * sizeof(int)), | ||
92 | (uint8_t *)pixels); | ||
93 | cursor = _ecore_xcb_cursor_image_load_cursor(img, hot_x, hot_y); | ||
94 | _ecore_xcb_cursor_image_destroy(img); | ||
95 | return cursor; | ||
96 | } | ||
97 | else | ||
98 | #endif | ||
99 | { | ||
100 | Ecore_X_GC gc; | ||
101 | xcb_pixmap_t pmap, mask; | ||
102 | uint32_t *pix; | ||
103 | uint8_t fr = 0x00, fg = 0x00, fb = 0x00; | ||
104 | uint8_t br = 0xff, bg = 0xff, bb = 0xff; | ||
105 | uint32_t brightest = 0, darkest = 255 * 3; | ||
106 | uint16_t x, y; | ||
107 | const uint32_t dither[2][2] = | ||
108 | { | ||
109 | {0, 2}, | ||
110 | {3, 1} | ||
111 | }; | ||
112 | |||
113 | img = _ecore_xcb_image_create_native(w, h, XCB_IMAGE_FORMAT_Z_PIXMAP, | ||
114 | 1, NULL, ~0, NULL); | ||
115 | if (img->data) free(img->data); | ||
116 | img->data = malloc(img->size); | ||
117 | |||
118 | pmap = xcb_generate_id(_ecore_xcb_conn); | ||
119 | xcb_create_pixmap(_ecore_xcb_conn, 1, pmap, win, w, h); | ||
120 | mask = xcb_generate_id(_ecore_xcb_conn); | ||
121 | xcb_create_pixmap(_ecore_xcb_conn, 1, mask, win, w, h); | ||
122 | |||
123 | pix = (uint32_t *)pixels; | ||
124 | for (y = 0; y < h; y++) | ||
125 | { | ||
126 | for (x = 0; x < w; x++) | ||
127 | { | ||
128 | uint8_t r, g, b, a; | ||
129 | |||
130 | a = (pix[0] >> 24) & 0xff; | ||
131 | r = (pix[0] >> 16) & 0xff; | ||
132 | g = (pix[0] >> 8) & 0xff; | ||
133 | b = (pix[0]) & 0xff; | ||
134 | if (a > 0) | ||
135 | { | ||
136 | if ((uint32_t)(r + g + b) > brightest) | ||
137 | { | ||
138 | brightest = r + g + b; | ||
139 | br = r; | ||
140 | bg = g; | ||
141 | bb = b; | ||
142 | } | ||
143 | |||
144 | if ((uint32_t)(r + g + b) < darkest) | ||
145 | { | ||
146 | darkest = r + g + b; | ||
147 | fr = r; | ||
148 | fg = g; | ||
149 | fb = b; | ||
150 | } | ||
151 | } | ||
152 | pix++; | ||
153 | } | ||
154 | } | ||
155 | |||
156 | pix = (uint32_t *)pixels; | ||
157 | for (y = 0; y < h; y++) | ||
158 | { | ||
159 | for (x = 0; x < w; x++) | ||
160 | { | ||
161 | uint32_t v; | ||
162 | uint8_t r, g, b; | ||
163 | int32_t d1, d2; | ||
164 | |||
165 | r = (pix[0] >> 16) & 0xff; | ||
166 | g = (pix[0] >> 8) & 0xff; | ||
167 | b = (pix[0]) & 0xff; | ||
168 | d1 = | ||
169 | ((r - fr) * (r - fr)) + | ||
170 | ((g - fg) * (g - fg)) + | ||
171 | ((b - fb) * (b - fb)); | ||
172 | d2 = | ||
173 | ((r - br) * (r - br)) + | ||
174 | ((g - bg) * (g - bg)) + | ||
175 | ((b - bb) * (b - bb)); | ||
176 | if (d1 + d2) | ||
177 | { | ||
178 | v = (((d2 * 255) / (d1 + d2)) * 5) / 256; | ||
179 | if (v > dither[x & 0x1][y & 0x1]) | ||
180 | v = 1; | ||
181 | else | ||
182 | v = 0; | ||
183 | } | ||
184 | else | ||
185 | v = 0; | ||
186 | |||
187 | xcb_image_put_pixel(img, x, y, v); | ||
188 | pix++; | ||
189 | } | ||
190 | } | ||
191 | |||
192 | gc = ecore_x_gc_new(pmap, 0, NULL); | ||
193 | xcb_put_image(_ecore_xcb_conn, img->format, pmap, gc, w, h, | ||
194 | 0, 0, 0, img->depth, img->size, img->data); | ||
195 | ecore_x_gc_free(gc); | ||
196 | |||
197 | pix = (uint32_t *)pixels; | ||
198 | for (y = 0; y < h; y++) | ||
199 | { | ||
200 | for (x = 0; x < w; x++) | ||
201 | { | ||
202 | uint32_t v; | ||
203 | |||
204 | v = (((pix[0] >> 24) & 0xff) * 5) / 256; | ||
205 | if (v > dither[x & 0x1][y & 0x1]) | ||
206 | v = 1; | ||
207 | else | ||
208 | v = 0; | ||
209 | |||
210 | xcb_image_put_pixel(img, x, y, v); | ||
211 | pix++; | ||
212 | } | ||
213 | } | ||
214 | |||
215 | gc = ecore_x_gc_new(mask, 0, NULL); | ||
216 | xcb_put_image(_ecore_xcb_conn, img->format, mask, gc, w, h, | ||
217 | 0, 0, 0, img->depth, img->size, img->data); | ||
218 | ecore_x_gc_free(gc); | ||
219 | |||
220 | if (img->data) free(img->data); | ||
221 | _ecore_xcb_cursor_image_destroy(img); | ||
222 | |||
223 | cursor = xcb_generate_id(_ecore_xcb_conn); | ||
224 | xcb_create_cursor(_ecore_xcb_conn, cursor, pmap, mask, | ||
225 | fr << 8 | fr, fg << 8 | fg, fb << 8 | fb, | ||
226 | br << 8 | br, bg << 8 | bg, bb << 8 | bb, | ||
227 | hot_x, hot_y); | ||
228 | |||
229 | xcb_free_pixmap(_ecore_xcb_conn, pmap); | ||
230 | xcb_free_pixmap(_ecore_xcb_conn, mask); | ||
231 | |||
232 | return cursor; | ||
233 | } | ||
234 | |||
235 | return 0; | ||
236 | } | ||
237 | |||
238 | EAPI void | ||
239 | ecore_x_cursor_free(Ecore_X_Cursor c) | ||
240 | { | ||
241 | // LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
242 | CHECK_XCB_CONN; | ||
243 | |||
244 | xcb_free_cursor(_ecore_xcb_conn, c); | ||
245 | } | ||
246 | |||
247 | /* | ||
248 | * Returns the cursor for the given shape. | ||
249 | * Note that the return value must not be freed with | ||
250 | * ecore_x_cursor_free()! | ||
251 | */ | ||
252 | EAPI Ecore_X_Cursor | ||
253 | ecore_x_cursor_shape_get(int shape) | ||
254 | { | ||
255 | Ecore_X_Cursor cursor = 0; | ||
256 | xcb_font_t font; | ||
257 | |||
258 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
259 | CHECK_XCB_CONN; | ||
260 | |||
261 | font = xcb_generate_id(_ecore_xcb_conn); | ||
262 | xcb_open_font(_ecore_xcb_conn, font, strlen("cursor"), "cursor"); | ||
263 | |||
264 | cursor = xcb_generate_id(_ecore_xcb_conn); | ||
265 | /* FIXME: Add request check ?? */ | ||
266 | xcb_create_glyph_cursor(_ecore_xcb_conn, cursor, font, font, | ||
267 | shape, shape + 1, 0, 0, 0, 65535, 65535, 65535); | ||
268 | |||
269 | xcb_close_font(_ecore_xcb_conn, font); | ||
270 | return cursor; | ||
271 | } | ||
272 | |||
273 | EAPI void | ||
274 | ecore_x_cursor_size_set(int size) | ||
275 | { | ||
276 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
277 | |||
278 | _ecore_xcb_cursor_size = size; | ||
279 | /* NB: May need to adjust size of current cursors here */ | ||
280 | } | ||
281 | |||
282 | EAPI int | ||
283 | ecore_x_cursor_size_get(void) | ||
284 | { | ||
285 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
286 | |||
287 | return _ecore_xcb_cursor_size; | ||
288 | } | ||
289 | |||
290 | /* local functions */ | ||
291 | #ifdef ECORE_XCB_CURSOR | ||
292 | static xcb_render_pictforminfo_t * | ||
293 | _ecore_xcb_cursor_format_get(void) | ||
294 | { | ||
295 | const xcb_render_query_pict_formats_reply_t *reply; | ||
296 | xcb_render_pictforminfo_t *ret = NULL; | ||
297 | |||
298 | CHECK_XCB_CONN; | ||
299 | |||
300 | reply = xcb_render_util_query_formats(_ecore_xcb_conn); | ||
301 | if (reply) | ||
302 | ret = xcb_render_util_find_standard_format(reply, | ||
303 | XCB_PICT_STANDARD_ARGB_32); | ||
304 | |||
305 | return ret; | ||
306 | } | ||
307 | |||
308 | #endif | ||
309 | |||
310 | static void | ||
311 | _ecore_xcb_cursor_default_size_get(void) | ||
312 | { | ||
313 | char *s = NULL; | ||
314 | int v = 0; | ||
315 | |||
316 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
317 | |||
318 | s = getenv("XCURSOR_SIZE"); | ||
319 | if (!s) | ||
320 | { | ||
321 | _ecore_xcb_xdefaults_init(); | ||
322 | v = _ecore_xcb_xdefaults_int_get("Xcursor", "size"); | ||
323 | _ecore_xcb_xdefaults_shutdown(); | ||
324 | } | ||
325 | else | ||
326 | v = atoi(s); | ||
327 | if (v) _ecore_xcb_cursor_size = ((v * 16) / 72); | ||
328 | } | ||
329 | |||
330 | static void | ||
331 | _ecore_xcb_cursor_dpi_size_get(void) | ||
332 | { | ||
333 | int v = 0; | ||
334 | |||
335 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
336 | |||
337 | _ecore_xcb_xdefaults_init(); | ||
338 | v = _ecore_xcb_xdefaults_int_get("Xft", "dpi"); | ||
339 | if (v) _ecore_xcb_cursor_size = ((v * 16) / 72); | ||
340 | _ecore_xcb_xdefaults_shutdown(); | ||
341 | } | ||
342 | |||
343 | static void | ||
344 | _ecore_xcb_cursor_guess_size(void) | ||
345 | { | ||
346 | int w = 0, h = 0, s = 0; | ||
347 | |||
348 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
349 | |||
350 | ecore_x_screen_size_get(_ecore_xcb_screen, &w, &h); | ||
351 | if (h < w) s = h; | ||
352 | else s = w; | ||
353 | _ecore_xcb_cursor_size = (s / 48); | ||
354 | } | ||
355 | |||
356 | #ifdef ECORE_XCB_CURSOR | ||
357 | static Ecore_X_Cursor | ||
358 | _ecore_xcb_cursor_image_load_cursor(xcb_image_t *img, | ||
359 | int hot_x, | ||
360 | int hot_y) | ||
361 | { | ||
362 | Ecore_X_Cursor cursor = 0; | ||
363 | Ecore_X_GC gc; | ||
364 | xcb_pixmap_t pmap; | ||
365 | xcb_render_picture_t pict; | ||
366 | |||
367 | CHECK_XCB_CONN; | ||
368 | |||
369 | pmap = xcb_generate_id(_ecore_xcb_conn); | ||
370 | xcb_create_pixmap(_ecore_xcb_conn, img->depth, pmap, | ||
371 | ((xcb_screen_t *)_ecore_xcb_screen)->root, | ||
372 | img->width, img->height); | ||
373 | |||
374 | gc = ecore_x_gc_new(pmap, 0, NULL); | ||
375 | xcb_put_image(_ecore_xcb_conn, img->format, pmap, gc, | ||
376 | img->width, img->height, 0, 0, 0, img->depth, | ||
377 | img->size, img->data); | ||
378 | ecore_x_gc_free(gc); | ||
379 | |||
380 | pict = xcb_generate_id(_ecore_xcb_conn); | ||
381 | xcb_render_create_picture(_ecore_xcb_conn, pict, pmap, | ||
382 | _ecore_xcb_cursor_format_id, 0, NULL); | ||
383 | xcb_free_pixmap(_ecore_xcb_conn, pmap); | ||
384 | |||
385 | cursor = xcb_generate_id(_ecore_xcb_conn); | ||
386 | xcb_render_create_cursor(_ecore_xcb_conn, cursor, pict, hot_x, hot_y); | ||
387 | xcb_render_free_picture(_ecore_xcb_conn, pict); | ||
388 | |||
389 | return cursor; | ||
390 | } | ||
391 | |||
392 | #endif | ||
393 | |||
394 | static void | ||
395 | _ecore_xcb_cursor_image_destroy(xcb_image_t *img) | ||
396 | { | ||
397 | CHECK_XCB_CONN; | ||
398 | if (img) xcb_image_destroy(img); | ||
399 | } | ||
400 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_damage.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_damage.c new file mode 100644 index 0000000..d0ffde1 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_damage.c | |||
@@ -0,0 +1,155 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | # ifdef ECORE_XCB_DAMAGE | ||
3 | # include <xcb/damage.h> | ||
4 | # endif | ||
5 | |||
6 | /* local variables */ | ||
7 | static Eina_Bool _damage_avail = EINA_FALSE; | ||
8 | |||
9 | /* external variables */ | ||
10 | int _ecore_xcb_event_damage = -1; | ||
11 | |||
12 | void | ||
13 | _ecore_xcb_damage_init(void) | ||
14 | { | ||
15 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
16 | |||
17 | #ifdef ECORE_XCB_DAMAGE | ||
18 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_damage_id); | ||
19 | #endif | ||
20 | } | ||
21 | |||
22 | void | ||
23 | _ecore_xcb_damage_finalize(void) | ||
24 | { | ||
25 | #ifdef ECORE_XCB_DAMAGE | ||
26 | const xcb_query_extension_reply_t *ext_reply; | ||
27 | #endif | ||
28 | |||
29 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
30 | |||
31 | #ifdef ECORE_XCB_DAMAGE | ||
32 | ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_damage_id); | ||
33 | if ((ext_reply) && (ext_reply->present)) | ||
34 | { | ||
35 | xcb_damage_query_version_cookie_t cookie; | ||
36 | xcb_damage_query_version_reply_t *reply; | ||
37 | |||
38 | cookie = | ||
39 | xcb_damage_query_version_unchecked(_ecore_xcb_conn, | ||
40 | XCB_DAMAGE_MAJOR_VERSION, | ||
41 | XCB_DAMAGE_MINOR_VERSION); | ||
42 | reply = xcb_damage_query_version_reply(_ecore_xcb_conn, cookie, NULL); | ||
43 | if (reply) | ||
44 | { | ||
45 | _damage_avail = EINA_TRUE; | ||
46 | free(reply); | ||
47 | } | ||
48 | |||
49 | if (_damage_avail) | ||
50 | _ecore_xcb_event_damage = ext_reply->first_event; | ||
51 | } | ||
52 | #endif | ||
53 | } | ||
54 | |||
55 | /** | ||
56 | * @defgroup Ecore_X_Damage_Group X Damage Extension Functions | ||
57 | * | ||
58 | * Functions related to the X Damage Extension. | ||
59 | */ | ||
60 | |||
61 | EAPI Eina_Bool | ||
62 | ecore_x_damage_query(void) | ||
63 | { | ||
64 | return _damage_avail; | ||
65 | } | ||
66 | |||
67 | /** | ||
68 | * Create a damage object | ||
69 | * | ||
70 | * @param drawable The drawable to monitor | ||
71 | * @param level The level of the damage report | ||
72 | * @return The damage object | ||
73 | * | ||
74 | * Creates a damage object to monitor changes to @p drawable, | ||
75 | * with the level @p level. | ||
76 | * | ||
77 | * @ingroup Ecore_X_Damage_Group | ||
78 | */ | ||
79 | EAPI Ecore_X_Damage | ||
80 | ecore_x_damage_new(Ecore_X_Drawable drawable, | ||
81 | Ecore_X_Damage_Report_Level level) | ||
82 | { | ||
83 | Ecore_X_Damage damage = 0; | ||
84 | |||
85 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
86 | CHECK_XCB_CONN; | ||
87 | |||
88 | if (!_damage_avail) return 0; | ||
89 | |||
90 | #ifdef ECORE_XCB_DAMAGE | ||
91 | damage = xcb_generate_id(_ecore_xcb_conn); | ||
92 | xcb_damage_create(_ecore_xcb_conn, damage, drawable, level); | ||
93 | // ecore_x_flush(); | ||
94 | #endif | ||
95 | |||
96 | return damage; | ||
97 | } | ||
98 | |||
99 | /** | ||
100 | * Destroy a damage object | ||
101 | * | ||
102 | * @param The damage object to destroy | ||
103 | * | ||
104 | * Destroys the damage object @p damage | ||
105 | * | ||
106 | * @ingroup Ecore_X_Damage_Group | ||
107 | */ | ||
108 | EAPI void | ||
109 | ecore_x_damage_free(Ecore_X_Damage damage) | ||
110 | { | ||
111 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
112 | CHECK_XCB_CONN; | ||
113 | |||
114 | if (!_damage_avail) return; | ||
115 | |||
116 | #ifdef ECORE_XCB_DAMAGE | ||
117 | xcb_damage_destroy(_ecore_xcb_conn, damage); | ||
118 | // ecore_x_flush(); | ||
119 | #endif | ||
120 | } | ||
121 | |||
122 | /** | ||
123 | * Synchronously modifies the region | ||
124 | * | ||
125 | * @param damage The damage object to destroy | ||
126 | * @param repair The repair region | ||
127 | * @param parts The parts region | ||
128 | * | ||
129 | * Synchronously modifies the regions in the following manner: | ||
130 | * If @p repair is @c XCB_NONE: | ||
131 | * 1) parts = damage | ||
132 | * 2) damage = <empty> | ||
133 | * Otherwise: | ||
134 | * 1) parts = damage INTERSECT repair | ||
135 | * 2) damage = damage - parts | ||
136 | * 3) Generate DamageNotify for remaining damage areas | ||
137 | * | ||
138 | * @ingroup Ecore_X_Damage_Group | ||
139 | */ | ||
140 | EAPI void | ||
141 | ecore_x_damage_subtract(Ecore_X_Damage damage, | ||
142 | Ecore_X_Region repair, | ||
143 | Ecore_X_Region parts) | ||
144 | { | ||
145 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
146 | CHECK_XCB_CONN; | ||
147 | |||
148 | if (!_damage_avail) return; | ||
149 | |||
150 | #ifdef ECORE_XCB_DAMAGE | ||
151 | xcb_damage_subtract(_ecore_xcb_conn, damage, repair, parts); | ||
152 | // ecore_x_flush(); | ||
153 | #endif | ||
154 | } | ||
155 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_dnd.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_dnd.c new file mode 100644 index 0000000..677de38 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_dnd.c | |||
@@ -0,0 +1,689 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | |||
3 | #ifndef MIN | ||
4 | # define MIN(a, b) (((a) < (b)) ? (a) : (b)) | ||
5 | #endif | ||
6 | |||
7 | /* local structures */ | ||
8 | typedef struct _Version_Cache_Item | ||
9 | { | ||
10 | Ecore_X_Window win; | ||
11 | int ver; | ||
12 | } Version_Cache_Item; | ||
13 | |||
14 | /* local function prototypes */ | ||
15 | static Eina_Bool _ecore_xcb_dnd_converter_copy(char *target __UNUSED__, | ||
16 | void *data, | ||
17 | int size, | ||
18 | void **data_ret, | ||
19 | int *size_ret, | ||
20 | Ecore_X_Atom *tprop __UNUSED__, | ||
21 | int *count __UNUSED__); | ||
22 | |||
23 | /* local variables */ | ||
24 | static int _ecore_xcb_dnd_init_count = 0; | ||
25 | static Ecore_X_DND_Source *_source = NULL; | ||
26 | static Ecore_X_DND_Target *_target = NULL; | ||
27 | static Version_Cache_Item *_version_cache = NULL; | ||
28 | static int _version_cache_num = 0, _version_cache_alloc = 0; | ||
29 | static void (*_posupdatecb)(void *, | ||
30 | Ecore_X_Xdnd_Position *); | ||
31 | static void *_posupdatedata; | ||
32 | |||
33 | /* external variables */ | ||
34 | EAPI int ECORE_X_EVENT_XDND_ENTER = 0; | ||
35 | EAPI int ECORE_X_EVENT_XDND_POSITION = 0; | ||
36 | EAPI int ECORE_X_EVENT_XDND_STATUS = 0; | ||
37 | EAPI int ECORE_X_EVENT_XDND_LEAVE = 0; | ||
38 | EAPI int ECORE_X_EVENT_XDND_DROP = 0; | ||
39 | EAPI int ECORE_X_EVENT_XDND_FINISHED = 0; | ||
40 | |||
41 | void | ||
42 | _ecore_xcb_dnd_init(void) | ||
43 | { | ||
44 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
45 | |||
46 | if (!_ecore_xcb_dnd_init_count) | ||
47 | { | ||
48 | _source = calloc(1, sizeof(Ecore_X_DND_Source)); | ||
49 | if (!_source) return; | ||
50 | _source->version = ECORE_X_DND_VERSION; | ||
51 | _source->win = XCB_NONE; | ||
52 | _source->dest = XCB_NONE; | ||
53 | _source->state = ECORE_X_DND_SOURCE_IDLE; | ||
54 | _source->prev.window = 0; | ||
55 | |||
56 | _target = calloc(1, sizeof(Ecore_X_DND_Target)); | ||
57 | if (!_target) | ||
58 | { | ||
59 | free(_source); | ||
60 | _source = NULL; | ||
61 | return; | ||
62 | } | ||
63 | _target->win = XCB_NONE; | ||
64 | _target->source = XCB_NONE; | ||
65 | _target->state = ECORE_X_DND_TARGET_IDLE; | ||
66 | |||
67 | ECORE_X_EVENT_XDND_ENTER = ecore_event_type_new(); | ||
68 | ECORE_X_EVENT_XDND_POSITION = ecore_event_type_new(); | ||
69 | ECORE_X_EVENT_XDND_STATUS = ecore_event_type_new(); | ||
70 | ECORE_X_EVENT_XDND_LEAVE = ecore_event_type_new(); | ||
71 | ECORE_X_EVENT_XDND_DROP = ecore_event_type_new(); | ||
72 | ECORE_X_EVENT_XDND_FINISHED = ecore_event_type_new(); | ||
73 | } | ||
74 | _ecore_xcb_dnd_init_count++; | ||
75 | } | ||
76 | |||
77 | void | ||
78 | _ecore_xcb_dnd_shutdown(void) | ||
79 | { | ||
80 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
81 | |||
82 | _ecore_xcb_dnd_init_count--; | ||
83 | if (_ecore_xcb_dnd_init_count > 0) return; | ||
84 | if (_source) free(_source); | ||
85 | _source = NULL; | ||
86 | if (_target) free(_target); | ||
87 | _target = NULL; | ||
88 | _ecore_xcb_dnd_init_count = 0; | ||
89 | } | ||
90 | |||
91 | EAPI void | ||
92 | ecore_x_dnd_send_status(Eina_Bool will_accept, | ||
93 | Eina_Bool suppress, | ||
94 | Ecore_X_Rectangle rect, | ||
95 | Ecore_X_Atom action) | ||
96 | { | ||
97 | xcb_client_message_event_t ev; | ||
98 | |||
99 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
100 | CHECK_XCB_CONN; | ||
101 | |||
102 | if (_target->state == ECORE_X_DND_TARGET_IDLE) return; | ||
103 | |||
104 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
105 | |||
106 | _target->will_accept = will_accept; | ||
107 | |||
108 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
109 | ev.type = ECORE_X_ATOM_XDND_STATUS; | ||
110 | ev.format = 32; | ||
111 | ev.window = _target->source; | ||
112 | ev.data.data32[0] = _target->win; | ||
113 | ev.data.data32[1] = 0; | ||
114 | if (will_accept) ev.data.data32[1] |= 0x1UL; | ||
115 | if (!suppress) ev.data.data32[1] |= 0x2UL; | ||
116 | |||
117 | ev.data.data32[2] = rect.x; | ||
118 | ev.data.data32[2] <<= 16; | ||
119 | ev.data.data32[2] |= rect.y; | ||
120 | ev.data.data32[3] = rect.width; | ||
121 | ev.data.data32[3] <<= 16; | ||
122 | ev.data.data32[3] |= rect.height; | ||
123 | |||
124 | if (will_accept) | ||
125 | ev.data.data32[4] = action; | ||
126 | else | ||
127 | ev.data.data32[4] = XCB_NONE; | ||
128 | _target->accepted_action = action; | ||
129 | |||
130 | xcb_send_event(_ecore_xcb_conn, 0, _target->source, | ||
131 | XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); | ||
132 | // ecore_x_flush(); | ||
133 | } | ||
134 | |||
135 | EAPI Eina_Bool | ||
136 | ecore_x_dnd_drop(void) | ||
137 | { | ||
138 | xcb_client_message_event_t ev; | ||
139 | Eina_Bool status = EINA_FALSE; | ||
140 | |||
141 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
142 | CHECK_XCB_CONN; | ||
143 | |||
144 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
145 | |||
146 | if (_source->dest) | ||
147 | { | ||
148 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
149 | ev.format = 32; | ||
150 | ev.window = _source->dest; | ||
151 | |||
152 | if (_source->will_accept) | ||
153 | { | ||
154 | ev.type = ECORE_X_ATOM_XDND_DROP; | ||
155 | ev.data.data32[0] = _source->win; | ||
156 | ev.data.data32[1] = 0; | ||
157 | ev.data.data32[2] = _source->time; | ||
158 | |||
159 | xcb_send_event(_ecore_xcb_conn, 0, _source->dest, | ||
160 | XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); | ||
161 | // ecore_x_flush(); | ||
162 | _source->state = ECORE_X_DND_SOURCE_DROPPED; | ||
163 | status = EINA_TRUE; | ||
164 | } | ||
165 | else | ||
166 | { | ||
167 | ev.type = ECORE_X_ATOM_XDND_LEAVE; | ||
168 | ev.data.data32[0] = _source->win; | ||
169 | ev.data.data32[1] = 0; | ||
170 | |||
171 | xcb_send_event(_ecore_xcb_conn, 0, _source->dest, | ||
172 | XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); | ||
173 | // ecore_x_flush(); | ||
174 | _source->state = ECORE_X_DND_SOURCE_IDLE; | ||
175 | } | ||
176 | } | ||
177 | else | ||
178 | { | ||
179 | ecore_x_selection_xdnd_clear(); | ||
180 | _source->state = ECORE_X_DND_SOURCE_IDLE; | ||
181 | } | ||
182 | |||
183 | ecore_x_window_ignore_set(_source->win, 0); | ||
184 | _source->prev.window = 0; | ||
185 | |||
186 | return status; | ||
187 | } | ||
188 | |||
189 | EAPI void | ||
190 | ecore_x_dnd_aware_set(Ecore_X_Window win, | ||
191 | Eina_Bool on) | ||
192 | { | ||
193 | Ecore_X_Atom prop_data = ECORE_X_DND_VERSION; | ||
194 | |||
195 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
196 | |||
197 | if (on) | ||
198 | ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_AWARE, | ||
199 | ECORE_X_ATOM_ATOM, 32, &prop_data, 1); | ||
200 | else | ||
201 | ecore_x_window_prop_property_del(win, ECORE_X_ATOM_XDND_AWARE); | ||
202 | } | ||
203 | |||
204 | EAPI int | ||
205 | ecore_x_dnd_version_get(Ecore_X_Window win) | ||
206 | { | ||
207 | unsigned char *data; | ||
208 | int num = 0; | ||
209 | Version_Cache_Item *t; | ||
210 | |||
211 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
212 | |||
213 | if (_source->state == ECORE_X_DND_SOURCE_DRAGGING) | ||
214 | { | ||
215 | if (_version_cache) | ||
216 | { | ||
217 | int i = 0; | ||
218 | |||
219 | for (i = 0; i < _version_cache_num; i++) | ||
220 | { | ||
221 | if (_version_cache[i].win == win) | ||
222 | return _version_cache[i].ver; | ||
223 | } | ||
224 | } | ||
225 | } | ||
226 | |||
227 | if (ecore_x_window_prop_property_get(win, ECORE_X_ATOM_XDND_AWARE, | ||
228 | ECORE_X_ATOM_ATOM, 32, &data, &num)) | ||
229 | { | ||
230 | int version = 0; | ||
231 | |||
232 | version = (int)*data; | ||
233 | free(data); | ||
234 | if (_source->state == ECORE_X_DND_SOURCE_DRAGGING) | ||
235 | { | ||
236 | _version_cache_num++; | ||
237 | if (_version_cache_num > _version_cache_alloc) | ||
238 | _version_cache_alloc += 16; | ||
239 | t = realloc(_version_cache, | ||
240 | _version_cache_alloc * sizeof(Version_Cache_Item)); | ||
241 | if (!t) return 0; | ||
242 | _version_cache = t; | ||
243 | _version_cache[_version_cache_num - 1].win = win; | ||
244 | _version_cache[_version_cache_num - 1].ver = version; | ||
245 | } | ||
246 | return version; | ||
247 | } | ||
248 | |||
249 | if (_source->state == ECORE_X_DND_SOURCE_DRAGGING) | ||
250 | { | ||
251 | _version_cache_num++; | ||
252 | if (_version_cache_num > _version_cache_alloc) | ||
253 | _version_cache_alloc += 16; | ||
254 | t = realloc(_version_cache, | ||
255 | _version_cache_alloc * sizeof(Version_Cache_Item)); | ||
256 | if (!t) return 0; | ||
257 | _version_cache = t; | ||
258 | _version_cache[_version_cache_num - 1].win = win; | ||
259 | _version_cache[_version_cache_num - 1].ver = 0; | ||
260 | } | ||
261 | |||
262 | return 0; | ||
263 | } | ||
264 | |||
265 | EAPI Eina_Bool | ||
266 | ecore_x_dnd_type_isset(Ecore_X_Window win, | ||
267 | const char *type) | ||
268 | { | ||
269 | int num = 0, i = 0; | ||
270 | Eina_Bool ret = EINA_FALSE; | ||
271 | unsigned char *data; | ||
272 | Ecore_X_Atom *atoms, atom; | ||
273 | |||
274 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
275 | CHECK_XCB_CONN; | ||
276 | |||
277 | if (!ecore_x_window_prop_property_get(win, ECORE_X_ATOM_XDND_TYPE_LIST, | ||
278 | ECORE_X_ATOM_ATOM, 32, &data, &num)) | ||
279 | return ret; | ||
280 | |||
281 | atom = ecore_x_atom_get(type); | ||
282 | atoms = (Ecore_X_Atom *)data; | ||
283 | for (i = 0; i < num; ++i) | ||
284 | { | ||
285 | if (atom == atoms[i]) | ||
286 | { | ||
287 | ret = EINA_TRUE; | ||
288 | break; | ||
289 | } | ||
290 | } | ||
291 | |||
292 | free(data); | ||
293 | return ret; | ||
294 | } | ||
295 | |||
296 | EAPI void | ||
297 | ecore_x_dnd_type_set(Ecore_X_Window win, | ||
298 | const char *type, | ||
299 | Eina_Bool on) | ||
300 | { | ||
301 | Ecore_X_Atom atom, *oldset = NULL, *newset = NULL; | ||
302 | int i = 0, j = 0, num = 0; | ||
303 | unsigned char *data = NULL, *old_data = NULL; | ||
304 | |||
305 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
306 | CHECK_XCB_CONN; | ||
307 | |||
308 | atom = ecore_x_atom_get(type); | ||
309 | ecore_x_window_prop_property_get(win, ECORE_X_ATOM_XDND_TYPE_LIST, | ||
310 | ECORE_X_ATOM_ATOM, 32, &old_data, &num); | ||
311 | oldset = (Ecore_X_Atom *)old_data; | ||
312 | if (on) | ||
313 | { | ||
314 | if (ecore_x_dnd_type_isset(win, type)) | ||
315 | { | ||
316 | free(old_data); | ||
317 | return; | ||
318 | } | ||
319 | newset = calloc(num + 1, sizeof(Ecore_X_Atom)); | ||
320 | if (!newset) return; | ||
321 | data = (unsigned char *)newset; | ||
322 | for (i = 0; i < num; i++) | ||
323 | newset[i + 1] = oldset[i]; | ||
324 | newset[0] = atom; | ||
325 | ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_TYPE_LIST, | ||
326 | ECORE_X_ATOM_ATOM, 32, data, num + 1); | ||
327 | } | ||
328 | else | ||
329 | { | ||
330 | if (!ecore_x_dnd_type_isset(win, type)) | ||
331 | { | ||
332 | free(old_data); | ||
333 | return; | ||
334 | } | ||
335 | newset = calloc(num - 1, sizeof(Ecore_X_Atom)); | ||
336 | if (!newset) | ||
337 | { | ||
338 | free(old_data); | ||
339 | return; | ||
340 | } | ||
341 | data = (unsigned char *)newset; | ||
342 | for (i = 0; i < num; i++) | ||
343 | if (oldset[i] != atom) | ||
344 | newset[j++] = oldset[i]; | ||
345 | ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_TYPE_LIST, | ||
346 | ECORE_X_ATOM_ATOM, 32, data, num - 1); | ||
347 | } | ||
348 | free(oldset); | ||
349 | free(newset); | ||
350 | } | ||
351 | |||
352 | EAPI void | ||
353 | ecore_x_dnd_types_set(Ecore_X_Window win, | ||
354 | const char **types, | ||
355 | unsigned int num_types) | ||
356 | { | ||
357 | Ecore_X_Atom *newset = NULL; | ||
358 | unsigned int i; | ||
359 | unsigned char *data = NULL; | ||
360 | |||
361 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
362 | CHECK_XCB_CONN; | ||
363 | |||
364 | if (!num_types) | ||
365 | ecore_x_window_prop_property_del(win, ECORE_X_ATOM_XDND_TYPE_LIST); | ||
366 | else | ||
367 | { | ||
368 | newset = calloc(num_types, sizeof(Ecore_X_Atom)); | ||
369 | if (!newset) return; | ||
370 | |||
371 | data = (unsigned char *)newset; | ||
372 | for (i = 0; i < num_types; i++) | ||
373 | { | ||
374 | newset[i] = ecore_x_atom_get(types[i]); | ||
375 | ecore_x_selection_converter_atom_add(newset[i], | ||
376 | _ecore_xcb_dnd_converter_copy); | ||
377 | } | ||
378 | ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_TYPE_LIST, | ||
379 | ECORE_X_ATOM_ATOM, 32, data, | ||
380 | num_types); | ||
381 | free(newset); | ||
382 | } | ||
383 | } | ||
384 | |||
385 | EAPI void | ||
386 | ecore_x_dnd_actions_set(Ecore_X_Window win, | ||
387 | Ecore_X_Atom *actions, | ||
388 | unsigned int num_actions) | ||
389 | { | ||
390 | unsigned int i; | ||
391 | unsigned char *data = NULL; | ||
392 | |||
393 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
394 | CHECK_XCB_CONN; | ||
395 | |||
396 | if (!num_actions) | ||
397 | ecore_x_window_prop_property_del(win, ECORE_X_ATOM_XDND_ACTION_LIST); | ||
398 | else | ||
399 | { | ||
400 | data = (unsigned char *)actions; | ||
401 | for (i = 0; i < num_actions; i++) | ||
402 | ecore_x_selection_converter_atom_add(actions[i], | ||
403 | _ecore_xcb_dnd_converter_copy); | ||
404 | ecore_x_window_prop_property_set(win, ECORE_X_ATOM_XDND_ACTION_LIST, | ||
405 | ECORE_X_ATOM_ATOM, 32, data, | ||
406 | num_actions); | ||
407 | } | ||
408 | } | ||
409 | |||
410 | /** | ||
411 | * The DND position update cb is called Ecore_X sends a DND position to a | ||
412 | * client. | ||
413 | * | ||
414 | * It essentially mirrors some of the data sent in the position message. | ||
415 | * Generally this cb should be set just before position update is called. | ||
416 | * Please note well you need to look after your own data pointer if someone | ||
417 | * trashes you position update cb set. | ||
418 | * | ||
419 | * It is considered good form to clear this when the dnd event finishes. | ||
420 | * | ||
421 | * @param cb Callback to updated each time ecore_x sends a position update. | ||
422 | * @param data User data. | ||
423 | */ | ||
424 | EAPI void | ||
425 | ecore_x_dnd_callback_pos_update_set(void (*cb)(void *, | ||
426 | Ecore_X_Xdnd_Position *data), | ||
427 | const void *data) | ||
428 | { | ||
429 | _posupdatecb = cb; | ||
430 | _posupdatedata = (void *)data; | ||
431 | } | ||
432 | |||
433 | EAPI Eina_Bool | ||
434 | ecore_x_dnd_begin(Ecore_X_Window source, | ||
435 | unsigned char *data, | ||
436 | int size) | ||
437 | { | ||
438 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
439 | |||
440 | if (!ecore_x_dnd_version_get(source)) return EINA_FALSE; | ||
441 | |||
442 | /* Take ownership of XdndSelection */ | ||
443 | if (!ecore_x_selection_xdnd_set(source, data, size)) return EINA_FALSE; | ||
444 | |||
445 | if (_version_cache) | ||
446 | { | ||
447 | free(_version_cache); | ||
448 | _version_cache = NULL; | ||
449 | _version_cache_num = 0; | ||
450 | _version_cache_alloc = 0; | ||
451 | } | ||
452 | |||
453 | ecore_x_window_shadow_tree_flush(); | ||
454 | |||
455 | _source->win = source; | ||
456 | ecore_x_window_ignore_set(_source->win, 1); | ||
457 | _source->state = ECORE_X_DND_SOURCE_DRAGGING; | ||
458 | _source->time = _ecore_xcb_events_last_time_get(); | ||
459 | _source->prev.window = 0; | ||
460 | |||
461 | /* Default Accepted Action: move */ | ||
462 | _source->action = ECORE_X_ATOM_XDND_ACTION_MOVE; | ||
463 | _source->accepted_action = XCB_NONE; | ||
464 | _source->dest = XCB_NONE; | ||
465 | |||
466 | return EINA_TRUE; | ||
467 | } | ||
468 | |||
469 | EAPI void | ||
470 | ecore_x_dnd_send_finished(void) | ||
471 | { | ||
472 | xcb_client_message_event_t ev; | ||
473 | |||
474 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
475 | CHECK_XCB_CONN; | ||
476 | |||
477 | if (_target->state == ECORE_X_DND_TARGET_IDLE) return; | ||
478 | |||
479 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
480 | |||
481 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
482 | ev.format = 32; | ||
483 | ev.type = ECORE_X_ATOM_XDND_FINISHED; | ||
484 | ev.window = _target->source; | ||
485 | ev.data.data32[0] = _target->win; | ||
486 | ev.data.data32[1] = 0; | ||
487 | ev.data.data32[2] = 0; | ||
488 | if (_target->will_accept) | ||
489 | { | ||
490 | ev.data.data32[1] |= 0x1UL; | ||
491 | ev.data.data32[2] = _target->accepted_action; | ||
492 | } | ||
493 | |||
494 | xcb_send_event(_ecore_xcb_conn, 0, _target->source, | ||
495 | XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); | ||
496 | // ecore_x_flush(); | ||
497 | _target->state = ECORE_X_DND_TARGET_IDLE; | ||
498 | } | ||
499 | |||
500 | EAPI void | ||
501 | ecore_x_dnd_source_action_set(Ecore_X_Atom action) | ||
502 | { | ||
503 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
504 | |||
505 | _source->action = action; | ||
506 | if (_source->prev.window) | ||
507 | _ecore_xcb_dnd_drag(_source->prev.window, | ||
508 | _source->prev.x, _source->prev.y); | ||
509 | } | ||
510 | |||
511 | Ecore_X_DND_Source * | ||
512 | _ecore_xcb_dnd_source_get(void) | ||
513 | { | ||
514 | return _source; | ||
515 | } | ||
516 | |||
517 | Ecore_X_DND_Target * | ||
518 | _ecore_xcb_dnd_target_get(void) | ||
519 | { | ||
520 | return _target; | ||
521 | } | ||
522 | |||
523 | void | ||
524 | _ecore_xcb_dnd_drag(Ecore_X_Window root, | ||
525 | int x, | ||
526 | int y) | ||
527 | { | ||
528 | xcb_client_message_event_t ev; | ||
529 | Ecore_X_Window win, *skip; | ||
530 | Ecore_X_Xdnd_Position pos; | ||
531 | int num = 0; | ||
532 | |||
533 | if (_source->state != ECORE_X_DND_SOURCE_DRAGGING) return; | ||
534 | |||
535 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
536 | CHECK_XCB_CONN; | ||
537 | |||
538 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
539 | |||
540 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
541 | ev.format = 32; | ||
542 | |||
543 | skip = ecore_x_window_ignore_list(&num); | ||
544 | win = ecore_x_window_shadow_tree_at_xy_with_skip_get(root, x, y, skip, num); | ||
545 | while ((win) && !(ecore_x_dnd_version_get(win))) | ||
546 | win = ecore_x_window_shadow_parent_get(root, win); | ||
547 | |||
548 | if ((_source->dest) && (win != _source->dest)) | ||
549 | { | ||
550 | ev.window = _source->dest; | ||
551 | ev.type = ECORE_X_ATOM_XDND_LEAVE; | ||
552 | ev.data.data32[0] = _source->win; | ||
553 | ev.data.data32[1] = 0; | ||
554 | |||
555 | xcb_send_event(_ecore_xcb_conn, 0, _source->dest, | ||
556 | XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); | ||
557 | // ecore_x_flush(); | ||
558 | _source->suppress = 0; | ||
559 | } | ||
560 | |||
561 | if (win) | ||
562 | { | ||
563 | int x1, x2, y1, y2; | ||
564 | |||
565 | _source->version = MIN(ECORE_X_DND_VERSION, | ||
566 | ecore_x_dnd_version_get(win)); | ||
567 | if (win != _source->dest) | ||
568 | { | ||
569 | int i = 0; | ||
570 | unsigned char *data; | ||
571 | Ecore_X_Atom *types; | ||
572 | |||
573 | ecore_x_window_prop_property_get(_source->win, | ||
574 | ECORE_X_ATOM_XDND_TYPE_LIST, | ||
575 | ECORE_X_ATOM_ATOM, 32, | ||
576 | &data, &num); | ||
577 | types = (Ecore_X_Atom *)data; | ||
578 | ev.window = win; | ||
579 | ev.type = ECORE_X_ATOM_XDND_ENTER; | ||
580 | ev.data.data32[0] = _source->win; | ||
581 | ev.data.data32[1] = 0; | ||
582 | if (num > 3) | ||
583 | ev.data.data32[1] |= 0x1UL; | ||
584 | else | ||
585 | ev.data.data32[1] &= 0xfffffffeUL; | ||
586 | ev.data.data32[1] |= ((unsigned long)_source->version) << 24; | ||
587 | |||
588 | for (i = 2; i < 5; i++) | ||
589 | ev.data.data32[i] = 0; | ||
590 | for (i = 0; i < MIN(num, 3); ++i) | ||
591 | ev.data.data32[i + 2] = types[i]; | ||
592 | free(data); | ||
593 | |||
594 | xcb_send_event(_ecore_xcb_conn, 0, win, | ||
595 | XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); | ||
596 | // ecore_x_flush(); | ||
597 | _source->await_status = 0; | ||
598 | _source->will_accept = 0; | ||
599 | } | ||
600 | |||
601 | x1 = _source->rectangle.x; | ||
602 | x2 = _source->rectangle.x + _source->rectangle.width; | ||
603 | y1 = _source->rectangle.y; | ||
604 | y2 = _source->rectangle.y + _source->rectangle.height; | ||
605 | |||
606 | if ((!_source->await_status) || (!_source->suppress) || | ||
607 | ((x < x1) || (x > x2) || (y < y1) || (y > y2))) | ||
608 | { | ||
609 | ev.window = win; | ||
610 | ev.type = ECORE_X_ATOM_XDND_POSITION; | ||
611 | ev.data.data32[0] = _source->win; | ||
612 | ev.data.data32[1] = 0; | ||
613 | ev.data.data32[2] = ((x << 16) & 0xffff0000) | (y & 0xffff); | ||
614 | ev.data.data32[3] = _source->time; | ||
615 | ev.data.data32[4] = _source->action; | ||
616 | |||
617 | xcb_send_event(_ecore_xcb_conn, 0, win, | ||
618 | XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); | ||
619 | // ecore_x_flush(); | ||
620 | _source->await_status = 1; | ||
621 | } | ||
622 | } | ||
623 | |||
624 | if (_posupdatecb) | ||
625 | { | ||
626 | pos.position.x = x; | ||
627 | pos.position.y = y; | ||
628 | pos.win = win; | ||
629 | pos.prev = _source->dest; | ||
630 | _posupdatecb(_posupdatedata, &pos); | ||
631 | } | ||
632 | |||
633 | _source->prev.x = x; | ||
634 | _source->prev.y = y; | ||
635 | _source->prev.window = root; | ||
636 | _source->dest = win; | ||
637 | } | ||
638 | |||
639 | EAPI Ecore_X_Atom | ||
640 | ecore_x_dnd_source_action_get(void) | ||
641 | { | ||
642 | return _source->action; | ||
643 | } | ||
644 | |||
645 | /* local functions */ | ||
646 | static Eina_Bool | ||
647 | _ecore_xcb_dnd_converter_copy(char *target __UNUSED__, | ||
648 | void *data, | ||
649 | int size, | ||
650 | void **data_ret, | ||
651 | int *size_ret, | ||
652 | Ecore_X_Atom *tprop __UNUSED__, | ||
653 | int *count __UNUSED__) | ||
654 | { | ||
655 | Ecore_Xcb_Textproperty text_prop; | ||
656 | Ecore_Xcb_Encoding_Style style = XcbTextStyle; | ||
657 | char *mystr; | ||
658 | |||
659 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
660 | |||
661 | if ((!data) || (!size)) return EINA_FALSE; | ||
662 | |||
663 | mystr = calloc(1, size + 1); | ||
664 | if (!mystr) return EINA_FALSE; | ||
665 | |||
666 | memcpy(mystr, data, size); | ||
667 | if (_ecore_xcb_mb_textlist_to_textproperty(&mystr, 1, style, &text_prop)) | ||
668 | { | ||
669 | int len; | ||
670 | |||
671 | len = strlen((char *)text_prop.value) + 1; | ||
672 | if (!(*data_ret = malloc(len))) | ||
673 | { | ||
674 | free(mystr); | ||
675 | return EINA_FALSE; | ||
676 | } | ||
677 | memcpy(*data_ret, text_prop.value, len); | ||
678 | *size_ret = len; | ||
679 | free(text_prop.value); | ||
680 | free(mystr); | ||
681 | return EINA_TRUE; | ||
682 | } | ||
683 | else | ||
684 | { | ||
685 | free(mystr); | ||
686 | return EINA_FALSE; | ||
687 | } | ||
688 | } | ||
689 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_dpms.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_dpms.c new file mode 100644 index 0000000..63b7f1e --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_dpms.c | |||
@@ -0,0 +1,318 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #ifdef ECORE_XCB_DAMAGE | ||
3 | # include <xcb/dpms.h> | ||
4 | #endif | ||
5 | |||
6 | /* local variables */ | ||
7 | static Eina_Bool _dpms_avail = EINA_FALSE; | ||
8 | |||
9 | void | ||
10 | _ecore_xcb_dpms_init(void) | ||
11 | { | ||
12 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
13 | |||
14 | #ifdef ECORE_XCB_DPMS | ||
15 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_dpms_id); | ||
16 | #endif | ||
17 | } | ||
18 | |||
19 | void | ||
20 | _ecore_xcb_dpms_finalize(void) | ||
21 | { | ||
22 | #ifdef ECORE_XCB_DPMS | ||
23 | const xcb_query_extension_reply_t *ext_reply; | ||
24 | #endif | ||
25 | |||
26 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
27 | |||
28 | #ifdef ECORE_XCB_DPMS | ||
29 | ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_dpms_id); | ||
30 | if ((ext_reply) && (ext_reply->present)) | ||
31 | { | ||
32 | xcb_dpms_get_version_cookie_t cookie; | ||
33 | xcb_dpms_get_version_reply_t *reply; | ||
34 | |||
35 | cookie = | ||
36 | xcb_dpms_get_version_unchecked(_ecore_xcb_conn, | ||
37 | XCB_DPMS_MAJOR_VERSION, | ||
38 | XCB_DPMS_MINOR_VERSION); | ||
39 | reply = xcb_dpms_get_version_reply(_ecore_xcb_conn, cookie, NULL); | ||
40 | if (reply) | ||
41 | { | ||
42 | if (reply->server_major_version >= 1) | ||
43 | _dpms_avail = EINA_TRUE; | ||
44 | free(reply); | ||
45 | } | ||
46 | } | ||
47 | #endif | ||
48 | } | ||
49 | |||
50 | /** | ||
51 | * @defgroup Ecore_X_DPMS_Group X DPMS Extension Functions | ||
52 | * | ||
53 | * Functions related to the X DPMS Extension | ||
54 | */ | ||
55 | |||
56 | /** | ||
57 | * Checks if the DPMS extension is available or not. | ||
58 | * | ||
59 | * @return @c EINA_TRUE if the DPMS extension is available, | ||
60 | * @c EINA_FALSE otherwise. | ||
61 | * | ||
62 | * Return EINA_TRUE if the X server supports the DPMS Extension version 1.0, | ||
63 | * EINA_FALSE otherwise. | ||
64 | * | ||
65 | * @ingroup Ecore_X_DPMS_Group | ||
66 | */ | ||
67 | EAPI Eina_Bool | ||
68 | ecore_x_dpms_query(void) | ||
69 | { | ||
70 | // LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
71 | |||
72 | return _dpms_avail; | ||
73 | } | ||
74 | |||
75 | /** | ||
76 | * Checks if the X server is capable of DPMS. | ||
77 | * @return @c 1 if the X server is capable of DPMS, @c 0 otherwise. | ||
78 | * @ingroup Ecore_X_DPMS_Group | ||
79 | */ | ||
80 | EAPI Eina_Bool | ||
81 | ecore_x_dpms_capable_get(void) | ||
82 | { | ||
83 | Eina_Bool ret = EINA_FALSE; | ||
84 | #ifdef ECORE_XCB_DPMS | ||
85 | xcb_dpms_capable_cookie_t cookie; | ||
86 | xcb_dpms_capable_reply_t *reply; | ||
87 | #endif | ||
88 | |||
89 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
90 | CHECK_XCB_CONN; | ||
91 | |||
92 | if (!_dpms_avail) return EINA_FALSE; | ||
93 | |||
94 | #ifdef ECORE_XCB_DPMS | ||
95 | cookie = xcb_dpms_capable_unchecked(_ecore_xcb_conn); | ||
96 | reply = xcb_dpms_capable_reply(_ecore_xcb_conn, cookie, NULL); | ||
97 | if (reply) | ||
98 | { | ||
99 | ret = reply->capable; | ||
100 | free(reply); | ||
101 | } | ||
102 | #endif | ||
103 | |||
104 | return ret; | ||
105 | } | ||
106 | |||
107 | /** | ||
108 | * Checks the DPMS state of the display. | ||
109 | * @return @c EINA_TRUE if DPMS is enabled, @c EINA_FALSE otherwise. | ||
110 | * @ingroup Ecore_X_DPMS_Group | ||
111 | */ | ||
112 | EAPI Eina_Bool | ||
113 | ecore_x_dpms_enabled_get(void) | ||
114 | { | ||
115 | Eina_Bool ret = EINA_FALSE; | ||
116 | #ifdef ECORE_XCB_DPMS | ||
117 | xcb_dpms_info_cookie_t cookie; | ||
118 | xcb_dpms_info_reply_t *reply; | ||
119 | #endif | ||
120 | |||
121 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
122 | CHECK_XCB_CONN; | ||
123 | |||
124 | if (!_dpms_avail) return EINA_FALSE; | ||
125 | |||
126 | #ifdef ECORE_XCB_DPMS | ||
127 | cookie = xcb_dpms_info_unchecked(_ecore_xcb_conn); | ||
128 | reply = xcb_dpms_info_reply(_ecore_xcb_conn, cookie, NULL); | ||
129 | if (!reply) return EINA_FALSE; | ||
130 | if (reply->state) ret = EINA_TRUE; | ||
131 | free(reply); | ||
132 | #endif | ||
133 | |||
134 | return ret; | ||
135 | } | ||
136 | |||
137 | /** | ||
138 | * Sets the DPMS state of the display. | ||
139 | * @param enabled @c 0 to disable DPMS characteristics of the server, enable it otherwise. | ||
140 | * @ingroup Ecore_X_DPMS_Group | ||
141 | */ | ||
142 | EAPI void | ||
143 | ecore_x_dpms_enabled_set(int enabled) | ||
144 | { | ||
145 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
146 | CHECK_XCB_CONN; | ||
147 | |||
148 | if (!_dpms_avail) return; | ||
149 | |||
150 | #ifdef ECORE_XCB_DPMS | ||
151 | if (enabled) | ||
152 | xcb_dpms_enable(_ecore_xcb_conn); | ||
153 | else | ||
154 | xcb_dpms_disable(_ecore_xcb_conn); | ||
155 | #endif | ||
156 | } | ||
157 | |||
158 | /** | ||
159 | * Gets the timeouts. The values are in unit of seconds. | ||
160 | * @param standby Amount of time of inactivity before standby mode will be invoked. | ||
161 | * @param suspend Amount of time of inactivity before the screen is placed into suspend mode. | ||
162 | * @param off Amount of time of inactivity before the monitor is shut off. | ||
163 | * @ingroup Ecore_X_DPMS_Group | ||
164 | */ | ||
165 | EAPI void | ||
166 | ecore_x_dpms_timeouts_get(unsigned int *standby, | ||
167 | unsigned int *suspend, | ||
168 | unsigned int *off) | ||
169 | { | ||
170 | #ifdef ECORE_XCB_DPMS | ||
171 | xcb_dpms_get_timeouts_cookie_t cookie; | ||
172 | xcb_dpms_get_timeouts_reply_t *reply; | ||
173 | #endif | ||
174 | |||
175 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
176 | CHECK_XCB_CONN; | ||
177 | |||
178 | if (standby) *standby = 0; | ||
179 | if (suspend) *suspend = 0; | ||
180 | if (off) *off = 0; | ||
181 | |||
182 | if (!_dpms_avail) return; | ||
183 | |||
184 | #ifdef ECORE_XCB_DPMS | ||
185 | cookie = xcb_dpms_get_timeouts_unchecked(_ecore_xcb_conn); | ||
186 | reply = xcb_dpms_get_timeouts_reply(_ecore_xcb_conn, cookie, NULL); | ||
187 | if (!reply) return; | ||
188 | if (standby) *standby = reply->standby_timeout; | ||
189 | if (suspend) *suspend = reply->suspend_timeout; | ||
190 | if (off) *off = reply->off_timeout; | ||
191 | free(reply); | ||
192 | #endif | ||
193 | } | ||
194 | |||
195 | /** | ||
196 | * Sets the timeouts. The values are in unit of seconds. | ||
197 | * @param standby Amount of time of inactivity before standby mode will be invoked. | ||
198 | * @param suspend Amount of time of inactivity before the screen is placed into suspend mode. | ||
199 | * @param off Amount of time of inactivity before the monitor is shut off. | ||
200 | * @ingroup Ecore_X_DPMS_Group | ||
201 | */ | ||
202 | EAPI Eina_Bool | ||
203 | ecore_x_dpms_timeouts_set(unsigned int standby, | ||
204 | unsigned int suspend, | ||
205 | unsigned int off) | ||
206 | { | ||
207 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
208 | CHECK_XCB_CONN; | ||
209 | |||
210 | if (!_dpms_avail) return EINA_FALSE; | ||
211 | |||
212 | #ifdef ECORE_XCB_DPMS | ||
213 | // FIXME: Add request check | ||
214 | xcb_dpms_set_timeouts(_ecore_xcb_conn, standby, suspend, off); | ||
215 | return EINA_TRUE; | ||
216 | #endif | ||
217 | |||
218 | return EINA_FALSE; | ||
219 | } | ||
220 | |||
221 | /** | ||
222 | * Returns the amount of time of inactivity before standby mode is invoked. | ||
223 | * @return The standby timeout value. | ||
224 | * @ingroup Ecore_X_DPMS_Group | ||
225 | */ | ||
226 | EAPI unsigned int | ||
227 | ecore_x_dpms_timeout_standby_get(void) | ||
228 | { | ||
229 | unsigned int standby = 0; | ||
230 | |||
231 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
232 | |||
233 | ecore_x_dpms_timeouts_get(&standby, NULL, NULL); | ||
234 | return standby; | ||
235 | } | ||
236 | |||
237 | /** | ||
238 | * Returns the amount of time of inactivity before the second level of | ||
239 | * power saving is invoked. | ||
240 | * @return The suspend timeout value. | ||
241 | * @ingroup Ecore_X_DPMS_Group | ||
242 | */ | ||
243 | EAPI unsigned int | ||
244 | ecore_x_dpms_timeout_suspend_get(void) | ||
245 | { | ||
246 | unsigned int suspend = 0; | ||
247 | |||
248 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
249 | |||
250 | ecore_x_dpms_timeouts_get(NULL, &suspend, NULL); | ||
251 | return suspend; | ||
252 | } | ||
253 | |||
254 | /** | ||
255 | * Returns the amount of time of inactivity before the third and final | ||
256 | * level of power saving is invoked. | ||
257 | * @return The off timeout value. | ||
258 | * @ingroup Ecore_X_DPMS_Group | ||
259 | */ | ||
260 | EAPI unsigned int | ||
261 | ecore_x_dpms_timeout_off_get(void) | ||
262 | { | ||
263 | unsigned int off = 0; | ||
264 | |||
265 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
266 | |||
267 | ecore_x_dpms_timeouts_get(NULL, NULL, &off); | ||
268 | return off; | ||
269 | } | ||
270 | |||
271 | /** | ||
272 | * Sets the standby timeout (in unit of seconds). | ||
273 | * @param new_standby Amount of time of inactivity before standby mode will be invoked. | ||
274 | * @ingroup Ecore_X_DPMS_Group | ||
275 | */ | ||
276 | EAPI void | ||
277 | ecore_x_dpms_timeout_standby_set(unsigned int new_timeout) | ||
278 | { | ||
279 | unsigned int standby = 0, suspend = 0, off = 0; | ||
280 | |||
281 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
282 | |||
283 | ecore_x_dpms_timeouts_get(&standby, &suspend, &off); | ||
284 | ecore_x_dpms_timeouts_set(new_timeout, suspend, off); | ||
285 | } | ||
286 | |||
287 | /** | ||
288 | * Sets the suspend timeout (in unit of seconds). | ||
289 | * @param suspend Amount of time of inactivity before the screen is placed into suspend mode. | ||
290 | * @ingroup Ecore_X_DPMS_Group | ||
291 | */ | ||
292 | EAPI void | ||
293 | ecore_x_dpms_timeout_suspend_set(unsigned int new_timeout) | ||
294 | { | ||
295 | unsigned int standby = 0, suspend = 0, off = 0; | ||
296 | |||
297 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
298 | |||
299 | ecore_x_dpms_timeouts_get(&standby, &suspend, &off); | ||
300 | ecore_x_dpms_timeouts_set(standby, new_timeout, off); | ||
301 | } | ||
302 | |||
303 | /** | ||
304 | * Sets the off timeout (in unit of seconds). | ||
305 | * @param off Amount of time of inactivity before the monitor is shut off. | ||
306 | * @ingroup Ecore_X_DPMS_Group | ||
307 | */ | ||
308 | EAPI void | ||
309 | ecore_x_dpms_timeout_off_set(unsigned int new_timeout) | ||
310 | { | ||
311 | unsigned int standby = 0, suspend = 0, off = 0; | ||
312 | |||
313 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
314 | |||
315 | ecore_x_dpms_timeouts_get(&standby, &suspend, &off); | ||
316 | ecore_x_dpms_timeouts_set(standby, suspend, new_timeout); | ||
317 | } | ||
318 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_drawable.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_drawable.c new file mode 100644 index 0000000..4e9a356 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_drawable.c | |||
@@ -0,0 +1,123 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | |||
3 | /** | ||
4 | * @defgroup Ecore_X_Drawable_Group X Drawable Functions | ||
5 | * | ||
6 | * Functions that operate on drawables. | ||
7 | */ | ||
8 | |||
9 | /** | ||
10 | * Fill the specified rectangle on a drawable. | ||
11 | * @param d The given drawable. | ||
12 | * @param gc The graphic context that controls the fill rules. | ||
13 | * @param x The X coordinate of the top-left corner of the rectangle. | ||
14 | * @param y The Y coordinate of the top-left corner of the rectangle. | ||
15 | * @param width The width of the rectangle. | ||
16 | * @param height The height of the rectangle. | ||
17 | */ | ||
18 | EAPI void | ||
19 | ecore_x_drawable_rectangle_fill(Ecore_X_Drawable draw, | ||
20 | Ecore_X_GC gc, | ||
21 | int x, | ||
22 | int y, | ||
23 | int w, | ||
24 | int h) | ||
25 | { | ||
26 | xcb_rectangle_t rect; | ||
27 | |||
28 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
29 | CHECK_XCB_CONN; | ||
30 | |||
31 | rect.x = x; | ||
32 | rect.y = y; | ||
33 | rect.width = w; | ||
34 | rect.height = h; | ||
35 | xcb_poly_fill_rectangle(_ecore_xcb_conn, draw, gc, 1, | ||
36 | (const xcb_rectangle_t *)&rect); | ||
37 | // ecore_x_flush(); | ||
38 | } | ||
39 | |||
40 | /** | ||
41 | * Retrieves the geometry of the given drawable. | ||
42 | * @param d The given drawable. | ||
43 | * @param x Pointer to an integer into which the X position is to be stored. | ||
44 | * @param y Pointer to an integer into which the Y position is to be stored. | ||
45 | * @param w Pointer to an integer into which the width is to be stored. | ||
46 | * @param h Pointer to an integer into which the height is to be stored. | ||
47 | * @ingroup Ecore_X_Drawable_Group | ||
48 | */ | ||
49 | EAPI void | ||
50 | ecore_x_drawable_geometry_get(Ecore_X_Drawable draw, | ||
51 | int *x, | ||
52 | int *y, | ||
53 | int *w, | ||
54 | int *h) | ||
55 | { | ||
56 | xcb_get_geometry_cookie_t cookie; | ||
57 | xcb_get_geometry_reply_t *reply; | ||
58 | |||
59 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
60 | CHECK_XCB_CONN; | ||
61 | |||
62 | if (x) *x = 0; | ||
63 | if (y) *y = 0; | ||
64 | if (w) *w = 0; | ||
65 | if (h) *h = 0; | ||
66 | cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, draw); | ||
67 | reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL); | ||
68 | if (!reply) return; | ||
69 | if (x) *x = reply->x; | ||
70 | if (y) *y = reply->y; | ||
71 | if (w) *w = (int)reply->width; | ||
72 | if (h) *h = (int)reply->height; | ||
73 | free(reply); | ||
74 | } | ||
75 | |||
76 | /** | ||
77 | * Retrieves the width of the border of the given drawable. | ||
78 | * @param d The given drawable. | ||
79 | * @return The border width of the given drawable. | ||
80 | * @ingroup Ecore_X_Drawable_Group | ||
81 | */ | ||
82 | EAPI int | ||
83 | ecore_x_drawable_border_width_get(Ecore_X_Drawable d) | ||
84 | { | ||
85 | xcb_get_geometry_cookie_t cookie; | ||
86 | xcb_get_geometry_reply_t *reply; | ||
87 | int ret = 0; | ||
88 | |||
89 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
90 | CHECK_XCB_CONN; | ||
91 | |||
92 | cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, d); | ||
93 | reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL); | ||
94 | if (!reply) return 0; | ||
95 | ret = (int)reply->border_width; | ||
96 | free(reply); | ||
97 | return ret; | ||
98 | } | ||
99 | |||
100 | /** | ||
101 | * Retrieves the depth of the given drawable. | ||
102 | * @param d The given drawable. | ||
103 | * @return The depth of the given drawable. | ||
104 | * @ingroup Ecore_X_Drawable_Group | ||
105 | */ | ||
106 | EAPI int | ||
107 | ecore_x_drawable_depth_get(Ecore_X_Drawable d) | ||
108 | { | ||
109 | xcb_get_geometry_cookie_t cookie; | ||
110 | xcb_get_geometry_reply_t *reply; | ||
111 | int ret = 0; | ||
112 | |||
113 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
114 | CHECK_XCB_CONN; | ||
115 | |||
116 | cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, d); | ||
117 | reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL); | ||
118 | if (!reply) return 0; | ||
119 | ret = (int)reply->depth; | ||
120 | free(reply); | ||
121 | return ret; | ||
122 | } | ||
123 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_e.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_e.c new file mode 100644 index 0000000..c868f5e --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_e.c | |||
@@ -0,0 +1,1071 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | |||
3 | /* local function prototypes */ | ||
4 | static Ecore_X_Atom _ecore_xcb_e_vkbd_atom_get(Ecore_X_Virtual_Keyboard_State state); | ||
5 | static Ecore_X_Virtual_Keyboard_State _ecore_xcb_e_vkbd_state_get(Ecore_X_Atom atom); | ||
6 | static Ecore_X_Atom _ecore_xcb_e_quickpanel_atom_get(Ecore_X_Illume_Quickpanel_State state); | ||
7 | static Ecore_X_Illume_Quickpanel_State _ecore_xcb_e_quickpanel_state_get(Ecore_X_Atom atom); | ||
8 | static Ecore_X_Atom _ecore_xcb_e_illume_atom_get(Ecore_X_Illume_Mode mode); | ||
9 | static Ecore_X_Illume_Mode _ecore_xcb_e_illume_mode_get(Ecore_X_Atom atom); | ||
10 | |||
11 | EAPI void | ||
12 | ecore_x_e_init(void) | ||
13 | { | ||
14 | } | ||
15 | |||
16 | EAPI void | ||
17 | ecore_x_e_comp_sync_draw_done_send(Ecore_X_Window root, | ||
18 | Ecore_X_Window win) | ||
19 | { | ||
20 | xcb_client_message_event_t ev; | ||
21 | |||
22 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
23 | CHECK_XCB_CONN; | ||
24 | |||
25 | if (!root) root = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
26 | |||
27 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
28 | |||
29 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
30 | ev.format = 32; | ||
31 | ev.window = win; | ||
32 | ev.type = ECORE_X_ATOM_E_COMP_SYNC_DRAW_DONE; | ||
33 | ev.data.data32[0] = win; | ||
34 | ev.data.data32[1] = 0; | ||
35 | ev.data.data32[2] = 0; | ||
36 | ev.data.data32[3] = 0; | ||
37 | ev.data.data32[4] = 0; | ||
38 | |||
39 | xcb_send_event(_ecore_xcb_conn, 0, root, | ||
40 | (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | | ||
41 | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY), (const char *)&ev); | ||
42 | // ecore_x_flush(); | ||
43 | } | ||
44 | |||
45 | EAPI void | ||
46 | ecore_x_e_comp_sync_draw_size_done_send(Ecore_X_Window root, | ||
47 | Ecore_X_Window win, | ||
48 | int w, | ||
49 | int h) | ||
50 | { | ||
51 | xcb_client_message_event_t ev; | ||
52 | |||
53 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
54 | CHECK_XCB_CONN; | ||
55 | |||
56 | if (!root) root = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
57 | |||
58 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
59 | |||
60 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
61 | ev.format = 32; | ||
62 | ev.window = win; | ||
63 | ev.type = ECORE_X_ATOM_E_COMP_SYNC_DRAW_DONE; | ||
64 | ev.data.data32[0] = win; | ||
65 | ev.data.data32[1] = 1; | ||
66 | ev.data.data32[2] = w; | ||
67 | ev.data.data32[3] = h; | ||
68 | ev.data.data32[4] = 0; | ||
69 | |||
70 | xcb_send_event(_ecore_xcb_conn, 0, root, | ||
71 | (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | | ||
72 | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY), (const char *)&ev); | ||
73 | // ecore_x_flush(); | ||
74 | } | ||
75 | |||
76 | EAPI void | ||
77 | ecore_x_e_comp_sync_counter_set(Ecore_X_Window win, | ||
78 | Ecore_X_Sync_Counter counter) | ||
79 | { | ||
80 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
81 | |||
82 | if (counter) | ||
83 | ecore_x_window_prop_xid_set(win, ECORE_X_ATOM_E_COMP_SYNC_COUNTER, | ||
84 | ECORE_X_ATOM_CARDINAL, &counter, 1); | ||
85 | else | ||
86 | ecore_x_window_prop_property_del(win, ECORE_X_ATOM_E_COMP_SYNC_COUNTER); | ||
87 | } | ||
88 | |||
89 | EAPI Ecore_X_Sync_Counter | ||
90 | ecore_x_e_comp_sync_counter_get(Ecore_X_Window win) | ||
91 | { | ||
92 | Ecore_X_Sync_Counter counter = 0; | ||
93 | int ret = 0; | ||
94 | |||
95 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
96 | |||
97 | ret = ecore_x_window_prop_xid_get(win, ECORE_X_ATOM_E_COMP_SYNC_COUNTER, | ||
98 | ECORE_X_ATOM_CARDINAL, &counter, 1); | ||
99 | if (ret != 1) return 0; | ||
100 | return counter; | ||
101 | } | ||
102 | |||
103 | EAPI Eina_Bool | ||
104 | ecore_x_e_comp_sync_supported_get(Ecore_X_Window root) | ||
105 | { | ||
106 | Ecore_X_Window win, win2; | ||
107 | int ret = 0; | ||
108 | |||
109 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
110 | |||
111 | if (!root) root = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
112 | ret = | ||
113 | ecore_x_window_prop_xid_get(root, ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED, | ||
114 | ECORE_X_ATOM_WINDOW, &win, 1); | ||
115 | if ((ret == 1) && (win)) | ||
116 | { | ||
117 | ret = | ||
118 | ecore_x_window_prop_xid_get(win, ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED, | ||
119 | ECORE_X_ATOM_WINDOW, &win2, 1); | ||
120 | if ((ret == 1) && (win2 == win)) | ||
121 | return EINA_TRUE; | ||
122 | } | ||
123 | return EINA_FALSE; | ||
124 | } | ||
125 | |||
126 | EAPI void | ||
127 | ecore_x_e_comp_sync_supported_set(Ecore_X_Window root, | ||
128 | Eina_Bool enabled) | ||
129 | { | ||
130 | Ecore_X_Window win; | ||
131 | |||
132 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
133 | |||
134 | if (!root) root = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
135 | if (enabled) | ||
136 | { | ||
137 | win = ecore_x_window_new(root, 1, 2, 3, 4); | ||
138 | ecore_x_window_prop_xid_set(win, ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED, | ||
139 | ECORE_X_ATOM_WINDOW, &win, 1); | ||
140 | ecore_x_window_prop_xid_set(root, ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED, | ||
141 | ECORE_X_ATOM_WINDOW, &win, 1); | ||
142 | } | ||
143 | else | ||
144 | { | ||
145 | int ret = 0; | ||
146 | |||
147 | ret = ecore_x_window_prop_xid_get(root, | ||
148 | ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED, | ||
149 | ECORE_X_ATOM_WINDOW, &win, 1); | ||
150 | if ((ret == 1) && (win)) | ||
151 | { | ||
152 | ecore_x_window_prop_property_del(root, | ||
153 | ECORE_X_ATOM_E_COMP_SYNC_SUPPORTED); | ||
154 | ecore_x_window_free(win); | ||
155 | } | ||
156 | } | ||
157 | } | ||
158 | |||
159 | EAPI void | ||
160 | ecore_x_e_comp_sync_begin_send(Ecore_X_Window win) | ||
161 | { | ||
162 | xcb_client_message_event_t ev; | ||
163 | |||
164 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
165 | CHECK_XCB_CONN; | ||
166 | |||
167 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
168 | |||
169 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
170 | ev.format = 32; | ||
171 | ev.window = win; | ||
172 | ev.type = ECORE_X_ATOM_E_COMP_SYNC_BEGIN; | ||
173 | ev.data.data32[0] = win; | ||
174 | ev.data.data32[1] = 0; | ||
175 | ev.data.data32[2] = 0; | ||
176 | ev.data.data32[3] = 0; | ||
177 | ev.data.data32[4] = 0; | ||
178 | |||
179 | xcb_send_event(_ecore_xcb_conn, 0, win, | ||
180 | XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); | ||
181 | // ecore_x_flush(); | ||
182 | } | ||
183 | |||
184 | EAPI void | ||
185 | ecore_x_e_comp_sync_end_send(Ecore_X_Window win) | ||
186 | { | ||
187 | xcb_client_message_event_t ev; | ||
188 | |||
189 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
190 | CHECK_XCB_CONN; | ||
191 | |||
192 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
193 | |||
194 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
195 | ev.format = 32; | ||
196 | ev.window = win; | ||
197 | ev.type = ECORE_X_ATOM_E_COMP_SYNC_END; | ||
198 | ev.data.data32[0] = win; | ||
199 | ev.data.data32[1] = 0; | ||
200 | ev.data.data32[2] = 0; | ||
201 | ev.data.data32[3] = 0; | ||
202 | ev.data.data32[4] = 0; | ||
203 | |||
204 | xcb_send_event(_ecore_xcb_conn, 0, win, | ||
205 | XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); | ||
206 | // ecore_x_flush(); | ||
207 | } | ||
208 | |||
209 | EAPI void | ||
210 | ecore_x_e_comp_sync_cancel_send(Ecore_X_Window win) | ||
211 | { | ||
212 | xcb_client_message_event_t ev; | ||
213 | |||
214 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
215 | CHECK_XCB_CONN; | ||
216 | |||
217 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
218 | |||
219 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
220 | ev.format = 32; | ||
221 | ev.window = win; | ||
222 | ev.type = ECORE_X_ATOM_E_COMP_SYNC_CANCEL; | ||
223 | ev.data.data32[0] = win; | ||
224 | ev.data.data32[1] = 0; | ||
225 | ev.data.data32[2] = 0; | ||
226 | ev.data.data32[3] = 0; | ||
227 | ev.data.data32[4] = 0; | ||
228 | |||
229 | xcb_send_event(_ecore_xcb_conn, 0, win, | ||
230 | XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); | ||
231 | // ecore_x_flush(); | ||
232 | } | ||
233 | |||
234 | EAPI void | ||
235 | ecore_x_e_comp_flush_send(Ecore_X_Window win) | ||
236 | { | ||
237 | xcb_client_message_event_t ev; | ||
238 | |||
239 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
240 | CHECK_XCB_CONN; | ||
241 | |||
242 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
243 | |||
244 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
245 | ev.format = 32; | ||
246 | ev.window = win; | ||
247 | ev.type = ECORE_X_ATOM_E_COMP_FLUSH; | ||
248 | ev.data.data32[0] = win; | ||
249 | ev.data.data32[1] = 0; | ||
250 | ev.data.data32[2] = 0; | ||
251 | ev.data.data32[3] = 0; | ||
252 | ev.data.data32[4] = 0; | ||
253 | |||
254 | xcb_send_event(_ecore_xcb_conn, 0, win, | ||
255 | XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); | ||
256 | // ecore_x_flush(); | ||
257 | } | ||
258 | |||
259 | EAPI void | ||
260 | ecore_x_e_comp_dump_send(Ecore_X_Window win) | ||
261 | { | ||
262 | xcb_client_message_event_t ev; | ||
263 | |||
264 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
265 | CHECK_XCB_CONN; | ||
266 | |||
267 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
268 | |||
269 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
270 | ev.format = 32; | ||
271 | ev.window = win; | ||
272 | ev.type = ECORE_X_ATOM_E_COMP_DUMP; | ||
273 | ev.data.data32[0] = win; | ||
274 | ev.data.data32[1] = 0; | ||
275 | ev.data.data32[2] = 0; | ||
276 | ev.data.data32[3] = 0; | ||
277 | ev.data.data32[4] = 0; | ||
278 | |||
279 | xcb_send_event(_ecore_xcb_conn, 0, win, | ||
280 | XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); | ||
281 | // ecore_x_flush(); | ||
282 | } | ||
283 | |||
284 | EAPI void | ||
285 | ecore_x_e_comp_pixmap_set(Ecore_X_Window win, | ||
286 | Ecore_X_Pixmap pixmap) | ||
287 | { | ||
288 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
289 | |||
290 | if (pixmap) | ||
291 | ecore_x_window_prop_xid_set(win, ECORE_X_ATOM_E_COMP_PIXMAP, | ||
292 | ECORE_X_ATOM_PIXMAP, &pixmap, 1); | ||
293 | else | ||
294 | ecore_x_window_prop_property_del(win, pixmap); | ||
295 | } | ||
296 | |||
297 | EAPI Ecore_X_Pixmap | ||
298 | ecore_x_e_comp_pixmap_get(Ecore_X_Window win) | ||
299 | { | ||
300 | Ecore_X_Pixmap pixmap = 0; | ||
301 | int ret = 0; | ||
302 | |||
303 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
304 | |||
305 | ret = ecore_x_window_prop_xid_get(win, ECORE_X_ATOM_E_COMP_PIXMAP, | ||
306 | ECORE_X_ATOM_PIXMAP, &pixmap, 1); | ||
307 | if (ret != 1) return 0; | ||
308 | return pixmap; | ||
309 | } | ||
310 | |||
311 | EAPI void | ||
312 | ecore_x_e_frame_size_set(Ecore_X_Window win, | ||
313 | int fl, | ||
314 | int fr, | ||
315 | int ft, | ||
316 | int fb) | ||
317 | { | ||
318 | uint32_t frames[4]; | ||
319 | |||
320 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
321 | |||
322 | frames[0] = fl; | ||
323 | frames[1] = fr; | ||
324 | frames[2] = ft; | ||
325 | frames[3] = fb; | ||
326 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_FRAME_SIZE, frames, 4); | ||
327 | } | ||
328 | |||
329 | EAPI Ecore_X_Virtual_Keyboard_State | ||
330 | ecore_x_e_virtual_keyboard_state_get(Ecore_X_Window win) | ||
331 | { | ||
332 | Ecore_X_Atom atom = 0; | ||
333 | |||
334 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
335 | |||
336 | if (!ecore_x_window_prop_atom_get(win, ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE, | ||
337 | &atom, 1)) | ||
338 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_UNKNOWN; | ||
339 | |||
340 | return _ecore_xcb_e_vkbd_state_get(atom); | ||
341 | } | ||
342 | |||
343 | EAPI void | ||
344 | ecore_x_e_virtual_keyboard_state_set(Ecore_X_Window win, | ||
345 | Ecore_X_Virtual_Keyboard_State state) | ||
346 | { | ||
347 | Ecore_X_Atom atom = 0; | ||
348 | |||
349 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
350 | |||
351 | atom = _ecore_xcb_e_vkbd_atom_get(state); | ||
352 | ecore_x_window_prop_atom_set(win, ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE, | ||
353 | &atom, 1); | ||
354 | } | ||
355 | |||
356 | EAPI void | ||
357 | ecore_x_e_virtual_keyboard_state_send(Ecore_X_Window win, | ||
358 | Ecore_X_Virtual_Keyboard_State state) | ||
359 | { | ||
360 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
361 | |||
362 | ecore_x_client_message32_send(win, ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_STATE, | ||
363 | ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, | ||
364 | _ecore_xcb_e_vkbd_atom_get(state), | ||
365 | 0, 0, 0, 0); | ||
366 | } | ||
367 | |||
368 | EAPI void | ||
369 | ecore_x_e_virtual_keyboard_set(Ecore_X_Window win, | ||
370 | unsigned int is_keyboard) | ||
371 | { | ||
372 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
373 | |||
374 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_VIRTUAL_KEYBOARD, | ||
375 | &is_keyboard, 1); | ||
376 | } | ||
377 | |||
378 | EAPI Eina_Bool | ||
379 | ecore_x_e_virtual_keyboard_get(Ecore_X_Window win) | ||
380 | { | ||
381 | unsigned int val = 0; | ||
382 | |||
383 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
384 | |||
385 | if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_E_VIRTUAL_KEYBOARD, | ||
386 | &val, 1)) | ||
387 | return EINA_FALSE; | ||
388 | |||
389 | return val ? EINA_TRUE : EINA_FALSE; | ||
390 | } | ||
391 | |||
392 | EAPI int | ||
393 | ecore_x_e_illume_quickpanel_priority_major_get(Ecore_X_Window win) | ||
394 | { | ||
395 | unsigned int val = 0; | ||
396 | |||
397 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
398 | |||
399 | if (!ecore_x_window_prop_card32_get(win, | ||
400 | ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MAJOR, | ||
401 | &val, 1)) | ||
402 | return 0; | ||
403 | |||
404 | return val; | ||
405 | } | ||
406 | |||
407 | EAPI void | ||
408 | ecore_x_e_illume_quickpanel_priority_major_set(Ecore_X_Window win, | ||
409 | unsigned int priority) | ||
410 | { | ||
411 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
412 | |||
413 | ecore_x_window_prop_card32_set(win, | ||
414 | ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MAJOR, | ||
415 | &priority, 1); | ||
416 | } | ||
417 | |||
418 | EAPI int | ||
419 | ecore_x_e_illume_quickpanel_priority_minor_get(Ecore_X_Window win) | ||
420 | { | ||
421 | unsigned int val = 0; | ||
422 | |||
423 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
424 | |||
425 | if (!ecore_x_window_prop_card32_get(win, | ||
426 | ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MINOR, | ||
427 | &val, 1)) | ||
428 | return 0; | ||
429 | |||
430 | return val; | ||
431 | } | ||
432 | |||
433 | EAPI void | ||
434 | ecore_x_e_illume_quickpanel_priority_minor_set(Ecore_X_Window win, | ||
435 | unsigned int priority) | ||
436 | { | ||
437 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
438 | |||
439 | ecore_x_window_prop_card32_set(win, | ||
440 | ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MINOR, | ||
441 | &priority, 1); | ||
442 | } | ||
443 | |||
444 | EAPI void | ||
445 | ecore_x_e_illume_quickpanel_zone_set(Ecore_X_Window win, | ||
446 | unsigned int zone) | ||
447 | { | ||
448 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
449 | |||
450 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ZONE, | ||
451 | &zone, 1); | ||
452 | } | ||
453 | |||
454 | EAPI int | ||
455 | ecore_x_e_illume_quickpanel_zone_get(Ecore_X_Window win) | ||
456 | { | ||
457 | unsigned int val = 0; | ||
458 | |||
459 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
460 | |||
461 | if (!ecore_x_window_prop_card32_get(win, | ||
462 | ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ZONE, | ||
463 | &val, 1)) | ||
464 | return 0; | ||
465 | |||
466 | return val; | ||
467 | } | ||
468 | |||
469 | EAPI void | ||
470 | ecore_x_e_illume_quickpanel_position_update_send(Ecore_X_Window win) | ||
471 | { | ||
472 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
473 | |||
474 | ecore_x_client_message32_send(win, | ||
475 | ECORE_X_ATOM_E_ILLUME_QUICKPANEL_POSITION_UPDATE, | ||
476 | ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, | ||
477 | 1, 0, 0, 0, 0); | ||
478 | } | ||
479 | |||
480 | EAPI Eina_Bool | ||
481 | ecore_x_e_illume_conformant_get(Ecore_X_Window win) | ||
482 | { | ||
483 | unsigned int val = 0; | ||
484 | |||
485 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
486 | |||
487 | if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_E_ILLUME_CONFORMANT, | ||
488 | &val, 1)) | ||
489 | return EINA_FALSE; | ||
490 | |||
491 | return val ? EINA_TRUE : EINA_FALSE; | ||
492 | } | ||
493 | |||
494 | EAPI void | ||
495 | ecore_x_e_illume_conformant_set(Ecore_X_Window win, | ||
496 | unsigned int is_conformant) | ||
497 | { | ||
498 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
499 | |||
500 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_ILLUME_CONFORMANT, | ||
501 | &is_conformant, 1); | ||
502 | } | ||
503 | |||
504 | EAPI void | ||
505 | ecore_x_e_illume_softkey_geometry_set(Ecore_X_Window win, | ||
506 | int x, | ||
507 | int y, | ||
508 | int w, | ||
509 | int h) | ||
510 | { | ||
511 | unsigned int geom[4]; | ||
512 | |||
513 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
514 | |||
515 | geom[0] = x; | ||
516 | geom[1] = y; | ||
517 | geom[2] = w; | ||
518 | geom[3] = h; | ||
519 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_ILLUME_SOFTKEY_GEOMETRY, | ||
520 | geom, 4); | ||
521 | } | ||
522 | |||
523 | EAPI Eina_Bool | ||
524 | ecore_x_e_illume_softkey_geometry_get(Ecore_X_Window win, | ||
525 | int *x, | ||
526 | int *y, | ||
527 | int *w, | ||
528 | int *h) | ||
529 | { | ||
530 | unsigned int geom[4]; | ||
531 | |||
532 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
533 | |||
534 | if (x) *x = 0; | ||
535 | if (y) *y = 0; | ||
536 | if (w) *w = 0; | ||
537 | if (h) *h = 0; | ||
538 | |||
539 | if (ecore_x_window_prop_card32_get(win, | ||
540 | ECORE_X_ATOM_E_ILLUME_SOFTKEY_GEOMETRY, | ||
541 | geom, 4) != 4) | ||
542 | return EINA_FALSE; | ||
543 | |||
544 | if (x) *x = geom[0]; | ||
545 | if (y) *y = geom[1]; | ||
546 | if (w) *w = geom[2]; | ||
547 | if (h) *h = geom[3]; | ||
548 | |||
549 | return EINA_TRUE; | ||
550 | } | ||
551 | |||
552 | EAPI void | ||
553 | ecore_x_e_illume_indicator_geometry_set(Ecore_X_Window win, | ||
554 | int x, | ||
555 | int y, | ||
556 | int w, | ||
557 | int h) | ||
558 | { | ||
559 | unsigned int geom[4]; | ||
560 | |||
561 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
562 | |||
563 | geom[0] = x; | ||
564 | geom[1] = y; | ||
565 | geom[2] = w; | ||
566 | geom[3] = h; | ||
567 | ecore_x_window_prop_card32_set(win, | ||
568 | ECORE_X_ATOM_E_ILLUME_INDICATOR_GEOMETRY, | ||
569 | geom, 4); | ||
570 | } | ||
571 | |||
572 | EAPI Eina_Bool | ||
573 | ecore_x_e_illume_indicator_geometry_get(Ecore_X_Window win, | ||
574 | int *x, | ||
575 | int *y, | ||
576 | int *w, | ||
577 | int *h) | ||
578 | { | ||
579 | unsigned int geom[4]; | ||
580 | |||
581 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
582 | |||
583 | if (x) *x = 0; | ||
584 | if (y) *y = 0; | ||
585 | if (w) *w = 0; | ||
586 | if (h) *h = 0; | ||
587 | |||
588 | if (ecore_x_window_prop_card32_get(win, | ||
589 | ECORE_X_ATOM_E_ILLUME_INDICATOR_GEOMETRY, | ||
590 | geom, 4) != 4) | ||
591 | return EINA_FALSE; | ||
592 | |||
593 | if (x) *x = geom[0]; | ||
594 | if (y) *y = geom[1]; | ||
595 | if (w) *w = geom[2]; | ||
596 | if (h) *h = geom[3]; | ||
597 | |||
598 | return EINA_TRUE; | ||
599 | } | ||
600 | |||
601 | EAPI void | ||
602 | ecore_x_e_illume_keyboard_geometry_set(Ecore_X_Window win, | ||
603 | int x, | ||
604 | int y, | ||
605 | int w, | ||
606 | int h) | ||
607 | { | ||
608 | unsigned int geom[4]; | ||
609 | |||
610 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
611 | |||
612 | geom[0] = x; | ||
613 | geom[1] = y; | ||
614 | geom[2] = w; | ||
615 | geom[3] = h; | ||
616 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_ILLUME_KEYBOARD_GEOMETRY, | ||
617 | geom, 4); | ||
618 | } | ||
619 | |||
620 | EAPI Eina_Bool | ||
621 | ecore_x_e_illume_keyboard_geometry_get(Ecore_X_Window win, | ||
622 | int *x, | ||
623 | int *y, | ||
624 | int *w, | ||
625 | int *h) | ||
626 | { | ||
627 | unsigned int geom[4]; | ||
628 | |||
629 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
630 | |||
631 | if (x) *x = 0; | ||
632 | if (y) *y = 0; | ||
633 | if (w) *w = 0; | ||
634 | if (h) *h = 0; | ||
635 | |||
636 | if (ecore_x_window_prop_card32_get(win, | ||
637 | ECORE_X_ATOM_E_ILLUME_KEYBOARD_GEOMETRY, | ||
638 | geom, 4) != 4) | ||
639 | return EINA_FALSE; | ||
640 | |||
641 | if (x) *x = geom[0]; | ||
642 | if (y) *y = geom[1]; | ||
643 | if (w) *w = geom[2]; | ||
644 | if (h) *h = geom[3]; | ||
645 | |||
646 | return EINA_TRUE; | ||
647 | } | ||
648 | |||
649 | EAPI void | ||
650 | ecore_x_e_illume_quickpanel_set(Ecore_X_Window win, | ||
651 | unsigned int is_quickpanel) | ||
652 | { | ||
653 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
654 | |||
655 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_ILLUME_QUICKPANEL, | ||
656 | &is_quickpanel, 1); | ||
657 | } | ||
658 | |||
659 | EAPI Eina_Bool | ||
660 | ecore_x_e_illume_quickpanel_get(Ecore_X_Window win) | ||
661 | { | ||
662 | unsigned int val = 0; | ||
663 | |||
664 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
665 | |||
666 | if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_E_ILLUME_QUICKPANEL, | ||
667 | &val, 1)) | ||
668 | return EINA_FALSE; | ||
669 | |||
670 | return val ? EINA_TRUE : EINA_FALSE; | ||
671 | } | ||
672 | |||
673 | EAPI void | ||
674 | ecore_x_e_illume_quickpanel_state_set(Ecore_X_Window win, | ||
675 | Ecore_X_Illume_Quickpanel_State state) | ||
676 | { | ||
677 | Ecore_X_Atom atom = 0; | ||
678 | |||
679 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
680 | |||
681 | atom = _ecore_xcb_e_quickpanel_atom_get(state); | ||
682 | ecore_x_window_prop_atom_set(win, ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE, | ||
683 | &atom, 1); | ||
684 | } | ||
685 | |||
686 | EAPI Ecore_X_Illume_Quickpanel_State | ||
687 | ecore_x_e_illume_quickpanel_state_get(Ecore_X_Window win) | ||
688 | { | ||
689 | Ecore_X_Atom atom = 0; | ||
690 | |||
691 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
692 | |||
693 | if (!ecore_x_window_prop_atom_get(win, | ||
694 | ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE, | ||
695 | &atom, 1)) | ||
696 | return ECORE_X_ILLUME_QUICKPANEL_STATE_UNKNOWN; | ||
697 | |||
698 | return _ecore_xcb_e_quickpanel_state_get(atom); | ||
699 | } | ||
700 | |||
701 | EAPI void | ||
702 | ecore_x_e_illume_quickpanel_state_send(Ecore_X_Window win, | ||
703 | Ecore_X_Illume_Quickpanel_State state) | ||
704 | { | ||
705 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
706 | ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE, | ||
707 | ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, | ||
708 | _ecore_xcb_e_quickpanel_atom_get(state), | ||
709 | 0, 0, 0, 0); | ||
710 | } | ||
711 | |||
712 | EAPI void | ||
713 | ecore_x_e_illume_quickpanel_state_toggle(Ecore_X_Window win) | ||
714 | { | ||
715 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
716 | ecore_x_client_message32_send(win, | ||
717 | ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE_TOGGLE, | ||
718 | ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, | ||
719 | 0, 0, 0, 0, 0); | ||
720 | } | ||
721 | |||
722 | EAPI void | ||
723 | ecore_x_e_illume_mode_set(Ecore_X_Window win, | ||
724 | Ecore_X_Illume_Mode mode) | ||
725 | { | ||
726 | Ecore_X_Atom atom = 0; | ||
727 | |||
728 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
729 | |||
730 | atom = _ecore_xcb_e_illume_atom_get(mode); | ||
731 | ecore_x_window_prop_atom_set(win, ECORE_X_ATOM_E_ILLUME_MODE, &atom, 1); | ||
732 | } | ||
733 | |||
734 | EAPI Ecore_X_Illume_Mode | ||
735 | ecore_x_e_illume_mode_get(Ecore_X_Window win) | ||
736 | { | ||
737 | Ecore_X_Atom atom = 0; | ||
738 | |||
739 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
740 | |||
741 | if (!ecore_x_window_prop_atom_get(win, ECORE_X_ATOM_E_ILLUME_MODE, &atom, 1)) | ||
742 | return ECORE_X_ILLUME_MODE_UNKNOWN; | ||
743 | |||
744 | return _ecore_xcb_e_illume_mode_get(atom); | ||
745 | } | ||
746 | |||
747 | EAPI void | ||
748 | ecore_x_e_illume_mode_send(Ecore_X_Window win, | ||
749 | Ecore_X_Illume_Mode mode) | ||
750 | { | ||
751 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
752 | |||
753 | ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_MODE, | ||
754 | ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, | ||
755 | _ecore_xcb_e_illume_atom_get(mode), | ||
756 | 0, 0, 0, 0); | ||
757 | } | ||
758 | |||
759 | EAPI void | ||
760 | ecore_x_e_illume_focus_back_send(Ecore_X_Window win) | ||
761 | { | ||
762 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
763 | |||
764 | ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_FOCUS_BACK, | ||
765 | ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, | ||
766 | 1, 0, 0, 0, 0); | ||
767 | } | ||
768 | |||
769 | EAPI void | ||
770 | ecore_x_e_illume_focus_forward_send(Ecore_X_Window win) | ||
771 | { | ||
772 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
773 | |||
774 | ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_FOCUS_FORWARD, | ||
775 | ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, | ||
776 | 1, 0, 0, 0, 0); | ||
777 | } | ||
778 | |||
779 | EAPI void | ||
780 | ecore_x_e_illume_focus_home_send(Ecore_X_Window win) | ||
781 | { | ||
782 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
783 | |||
784 | ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_FOCUS_HOME, | ||
785 | ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, | ||
786 | 1, 0, 0, 0, 0); | ||
787 | } | ||
788 | |||
789 | EAPI void | ||
790 | ecore_x_e_illume_close_send(Ecore_X_Window win) | ||
791 | { | ||
792 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
793 | |||
794 | ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_CLOSE, | ||
795 | ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, | ||
796 | 1, 0, 0, 0, 0); | ||
797 | } | ||
798 | |||
799 | EAPI void | ||
800 | ecore_x_e_illume_home_new_send(Ecore_X_Window win) | ||
801 | { | ||
802 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
803 | |||
804 | ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_HOME_NEW, | ||
805 | ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, | ||
806 | 1, 0, 0, 0, 0); | ||
807 | } | ||
808 | |||
809 | EAPI void | ||
810 | ecore_x_e_illume_home_del_send(Ecore_X_Window win) | ||
811 | { | ||
812 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
813 | |||
814 | ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_HOME_DEL, | ||
815 | ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, | ||
816 | 1, 0, 0, 0, 0); | ||
817 | } | ||
818 | |||
819 | EAPI void | ||
820 | ecore_x_e_illume_drag_set(Ecore_X_Window win, | ||
821 | unsigned int drag) | ||
822 | { | ||
823 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
824 | |||
825 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_ILLUME_DRAG, &drag, 1); | ||
826 | } | ||
827 | |||
828 | EAPI void | ||
829 | ecore_x_e_illume_drag_locked_set(Ecore_X_Window win, | ||
830 | unsigned int is_locked) | ||
831 | { | ||
832 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
833 | |||
834 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_ILLUME_DRAG_LOCKED, | ||
835 | &is_locked, 1); | ||
836 | } | ||
837 | |||
838 | EAPI Eina_Bool | ||
839 | ecore_x_e_illume_drag_locked_get(Ecore_X_Window win) | ||
840 | { | ||
841 | unsigned int val = 0; | ||
842 | |||
843 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
844 | |||
845 | if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_E_ILLUME_DRAG_LOCKED, | ||
846 | &val, 1)) | ||
847 | return EINA_FALSE; | ||
848 | |||
849 | return val ? EINA_TRUE : EINA_FALSE; | ||
850 | } | ||
851 | |||
852 | EAPI Eina_Bool | ||
853 | ecore_x_e_illume_drag_get(Ecore_X_Window win) | ||
854 | { | ||
855 | unsigned int val = 0; | ||
856 | |||
857 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
858 | |||
859 | if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_E_ILLUME_DRAG, &val, 1)) | ||
860 | return EINA_FALSE; | ||
861 | |||
862 | return val ? EINA_TRUE : EINA_FALSE; | ||
863 | } | ||
864 | |||
865 | EAPI void | ||
866 | ecore_x_e_illume_drag_start_send(Ecore_X_Window win) | ||
867 | { | ||
868 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
869 | ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_DRAG_START, | ||
870 | ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, | ||
871 | 1, 0, 0, 0, 0); | ||
872 | } | ||
873 | |||
874 | EAPI void | ||
875 | ecore_x_e_illume_drag_end_send(Ecore_X_Window win) | ||
876 | { | ||
877 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
878 | ecore_x_client_message32_send(win, ECORE_X_ATOM_E_ILLUME_DRAG_END, | ||
879 | ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, | ||
880 | 1, 0, 0, 0, 0); | ||
881 | } | ||
882 | |||
883 | EAPI void | ||
884 | ecore_x_e_illume_zone_set(Ecore_X_Window win, | ||
885 | Ecore_X_Window zone) | ||
886 | { | ||
887 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
888 | |||
889 | ecore_x_window_prop_window_set(win, ECORE_X_ATOM_E_ILLUME_ZONE, &zone, 1); | ||
890 | } | ||
891 | |||
892 | EAPI Ecore_X_Window | ||
893 | ecore_x_e_illume_zone_get(Ecore_X_Window win) | ||
894 | { | ||
895 | Ecore_X_Window zone; | ||
896 | |||
897 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
898 | |||
899 | if (!ecore_x_window_prop_window_get(win, ECORE_X_ATOM_E_ILLUME_ZONE, | ||
900 | &zone, 1)) | ||
901 | return 0; | ||
902 | |||
903 | return zone; | ||
904 | } | ||
905 | |||
906 | EAPI void | ||
907 | ecore_x_e_illume_zone_list_set(Ecore_X_Window win, | ||
908 | Ecore_X_Window *zones, | ||
909 | unsigned int num) | ||
910 | { | ||
911 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
912 | |||
913 | ecore_x_window_prop_window_set(win, ECORE_X_ATOM_E_ILLUME_ZONE_LIST, | ||
914 | zones, num); | ||
915 | } | ||
916 | |||
917 | /* local functions */ | ||
918 | static Ecore_X_Atom | ||
919 | _ecore_xcb_e_vkbd_atom_get(Ecore_X_Virtual_Keyboard_State state) | ||
920 | { | ||
921 | switch (state) | ||
922 | { | ||
923 | case ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF: | ||
924 | return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_OFF; | ||
925 | |||
926 | case ECORE_X_VIRTUAL_KEYBOARD_STATE_ON: | ||
927 | return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_ON; | ||
928 | |||
929 | case ECORE_X_VIRTUAL_KEYBOARD_STATE_ALPHA: | ||
930 | return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_ALPHA; | ||
931 | |||
932 | case ECORE_X_VIRTUAL_KEYBOARD_STATE_NUMERIC: | ||
933 | return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_NUMERIC; | ||
934 | |||
935 | case ECORE_X_VIRTUAL_KEYBOARD_STATE_PIN: | ||
936 | return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PIN; | ||
937 | |||
938 | case ECORE_X_VIRTUAL_KEYBOARD_STATE_PHONE_NUMBER: | ||
939 | return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PHONE_NUMBER; | ||
940 | |||
941 | case ECORE_X_VIRTUAL_KEYBOARD_STATE_HEX: | ||
942 | return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_HEX; | ||
943 | |||
944 | case ECORE_X_VIRTUAL_KEYBOARD_STATE_TERMINAL: | ||
945 | return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_TERMINAL; | ||
946 | |||
947 | case ECORE_X_VIRTUAL_KEYBOARD_STATE_PASSWORD: | ||
948 | return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PASSWORD; | ||
949 | |||
950 | case ECORE_X_VIRTUAL_KEYBOARD_STATE_IP: | ||
951 | return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_IP; | ||
952 | |||
953 | case ECORE_X_VIRTUAL_KEYBOARD_STATE_HOST: | ||
954 | return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_HOST; | ||
955 | |||
956 | case ECORE_X_VIRTUAL_KEYBOARD_STATE_FILE: | ||
957 | return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_FILE; | ||
958 | |||
959 | case ECORE_X_VIRTUAL_KEYBOARD_STATE_URL: | ||
960 | return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_URL; | ||
961 | |||
962 | case ECORE_X_VIRTUAL_KEYBOARD_STATE_KEYPAD: | ||
963 | return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_KEYPAD; | ||
964 | |||
965 | case ECORE_X_VIRTUAL_KEYBOARD_STATE_J2ME: | ||
966 | return ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_J2ME; | ||
967 | |||
968 | default: | ||
969 | break; | ||
970 | } | ||
971 | return 0; | ||
972 | } | ||
973 | |||
974 | static Ecore_X_Virtual_Keyboard_State | ||
975 | _ecore_xcb_e_vkbd_state_get(Ecore_X_Atom atom) | ||
976 | { | ||
977 | if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_ON) | ||
978 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_ON; | ||
979 | if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_OFF) | ||
980 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_OFF; | ||
981 | if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_ALPHA) | ||
982 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_ALPHA; | ||
983 | if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_NUMERIC) | ||
984 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_NUMERIC; | ||
985 | if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PIN) | ||
986 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_PIN; | ||
987 | if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PHONE_NUMBER) | ||
988 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_PHONE_NUMBER; | ||
989 | if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_HEX) | ||
990 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_HEX; | ||
991 | if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_TERMINAL) | ||
992 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_TERMINAL; | ||
993 | if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_PASSWORD) | ||
994 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_PASSWORD; | ||
995 | if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_IP) | ||
996 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_IP; | ||
997 | if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_HOST) | ||
998 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_HOST; | ||
999 | if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_FILE) | ||
1000 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_FILE; | ||
1001 | if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_URL) | ||
1002 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_URL; | ||
1003 | if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_KEYPAD) | ||
1004 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_KEYPAD; | ||
1005 | if (atom == ECORE_X_ATOM_E_VIRTUAL_KEYBOARD_J2ME) | ||
1006 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_J2ME; | ||
1007 | |||
1008 | return ECORE_X_VIRTUAL_KEYBOARD_STATE_UNKNOWN; | ||
1009 | } | ||
1010 | |||
1011 | static Ecore_X_Atom | ||
1012 | _ecore_xcb_e_quickpanel_atom_get(Ecore_X_Illume_Quickpanel_State state) | ||
1013 | { | ||
1014 | switch (state) | ||
1015 | { | ||
1016 | case ECORE_X_ILLUME_QUICKPANEL_STATE_ON: | ||
1017 | return ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON; | ||
1018 | |||
1019 | case ECORE_X_ILLUME_QUICKPANEL_STATE_OFF: | ||
1020 | return ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF; | ||
1021 | |||
1022 | default: | ||
1023 | break; | ||
1024 | } | ||
1025 | return 0; | ||
1026 | } | ||
1027 | |||
1028 | static Ecore_X_Illume_Quickpanel_State | ||
1029 | _ecore_xcb_e_quickpanel_state_get(Ecore_X_Atom atom) | ||
1030 | { | ||
1031 | if (atom == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON) | ||
1032 | return ECORE_X_ILLUME_QUICKPANEL_STATE_ON; | ||
1033 | if (atom == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF) | ||
1034 | return ECORE_X_ILLUME_QUICKPANEL_STATE_OFF; | ||
1035 | |||
1036 | return ECORE_X_ILLUME_QUICKPANEL_STATE_UNKNOWN; | ||
1037 | } | ||
1038 | |||
1039 | static Ecore_X_Atom | ||
1040 | _ecore_xcb_e_illume_atom_get(Ecore_X_Illume_Mode mode) | ||
1041 | { | ||
1042 | switch (mode) | ||
1043 | { | ||
1044 | case ECORE_X_ILLUME_MODE_SINGLE: | ||
1045 | return ECORE_X_ATOM_E_ILLUME_MODE_SINGLE; | ||
1046 | |||
1047 | case ECORE_X_ILLUME_MODE_DUAL_TOP: | ||
1048 | return ECORE_X_ATOM_E_ILLUME_MODE_DUAL_TOP; | ||
1049 | |||
1050 | case ECORE_X_ILLUME_MODE_DUAL_LEFT: | ||
1051 | return ECORE_X_ATOM_E_ILLUME_MODE_DUAL_LEFT; | ||
1052 | |||
1053 | default: | ||
1054 | break; | ||
1055 | } | ||
1056 | return ECORE_X_ILLUME_MODE_UNKNOWN; | ||
1057 | } | ||
1058 | |||
1059 | static Ecore_X_Illume_Mode | ||
1060 | _ecore_xcb_e_illume_mode_get(Ecore_X_Atom atom) | ||
1061 | { | ||
1062 | if (atom == ECORE_X_ATOM_E_ILLUME_MODE_SINGLE) | ||
1063 | return ECORE_X_ILLUME_MODE_SINGLE; | ||
1064 | if (atom == ECORE_X_ATOM_E_ILLUME_MODE_DUAL_TOP) | ||
1065 | return ECORE_X_ILLUME_MODE_DUAL_TOP; | ||
1066 | if (atom == ECORE_X_ATOM_E_ILLUME_MODE_DUAL_LEFT) | ||
1067 | return ECORE_X_ILLUME_MODE_DUAL_LEFT; | ||
1068 | |||
1069 | return ECORE_X_ILLUME_MODE_UNKNOWN; | ||
1070 | } | ||
1071 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_error.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_error.c new file mode 100644 index 0000000..bbd9c2a --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_error.c | |||
@@ -0,0 +1,109 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #include <xcb/xcb_event.h> | ||
3 | |||
4 | /* local variables */ | ||
5 | static void (*_error_func)(void *data) = NULL; | ||
6 | static void *_error_data = NULL; | ||
7 | static void (*_io_error_func)(void *data) = NULL; | ||
8 | static void *_io_error_data = NULL; | ||
9 | static int _error_request_code = 0; | ||
10 | static int _error_code = 0; | ||
11 | |||
12 | /** | ||
13 | * Set the error handler. | ||
14 | * @param func The error handler function | ||
15 | * @param data The data to be passed to the handler function | ||
16 | * | ||
17 | * Set the X error handler function | ||
18 | */ | ||
19 | EAPI void | ||
20 | ecore_x_error_handler_set(void (*func)(void *data), | ||
21 | const void *data) | ||
22 | { | ||
23 | _error_func = func; | ||
24 | _error_data = (void *)data; | ||
25 | } | ||
26 | |||
27 | /** | ||
28 | * Set the I/O error handler. | ||
29 | * @param func The I/O error handler function | ||
30 | * @param data The data to be passed to the handler function | ||
31 | * | ||
32 | * Set the X I/O error handler function | ||
33 | */ | ||
34 | EAPI void | ||
35 | ecore_x_io_error_handler_set(void (*func)(void *data), | ||
36 | const void *data) | ||
37 | { | ||
38 | _io_error_func = func; | ||
39 | _io_error_data = (void *)data; | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * Get the request code that caused the error. | ||
44 | * @return The request code causing the X error | ||
45 | * | ||
46 | * Return the X request code that caused the last X error | ||
47 | */ | ||
48 | EAPI int | ||
49 | ecore_x_error_request_get(void) | ||
50 | { | ||
51 | return _error_request_code; | ||
52 | } | ||
53 | |||
54 | /** | ||
55 | * Get the error code from the error. | ||
56 | * @return The error code from the X error | ||
57 | * | ||
58 | * Return the error code from the last X error | ||
59 | */ | ||
60 | EAPI int | ||
61 | ecore_x_error_code_get(void) | ||
62 | { | ||
63 | return _error_code; | ||
64 | } | ||
65 | |||
66 | int | ||
67 | _ecore_xcb_error_handle(xcb_generic_error_t *err) | ||
68 | { | ||
69 | WRN("Got Error:"); | ||
70 | WRN("\tEvent: %s", xcb_event_get_request_label(err->major_code)); | ||
71 | WRN("\tError: %s", xcb_event_get_error_label(err->error_code)); | ||
72 | |||
73 | #ifdef OLD_XCB_VERSION | ||
74 | if (err->error_code == XCB_EVENT_ERROR_BAD_VALUE) | ||
75 | WRN("\tBad Value: %d", ((xcb_value_error_t *)err)->bad_value); | ||
76 | else if (err->error_code == XCB_EVENT_ERROR_BAD_WINDOW) | ||
77 | WRN("\tBad Window: %d", ((xcb_window_error_t *)err)->bad_value); | ||
78 | #else | ||
79 | if (err->error_code == XCB_VALUE) | ||
80 | WRN("\tBad Value: %d", ((xcb_value_error_t *)err)->bad_value); | ||
81 | else if (err->error_code == XCB_WINDOW) | ||
82 | WRN("\tBad Window: %d", ((xcb_window_error_t *)err)->bad_value); | ||
83 | #endif | ||
84 | |||
85 | _error_request_code = err->sequence; | ||
86 | _error_code = err->error_code; | ||
87 | if (_error_func) | ||
88 | _error_func(_error_data); | ||
89 | |||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | int | ||
94 | _ecore_xcb_io_error_handle(xcb_generic_error_t *err) | ||
95 | { | ||
96 | CRIT("IO Error:"); | ||
97 | if (err) | ||
98 | { | ||
99 | CRIT("\tRequest: %d", err->sequence); | ||
100 | CRIT("\tCode: %d", err->error_code); | ||
101 | } | ||
102 | if (_io_error_func) | ||
103 | _io_error_func(_io_error_data); | ||
104 | else | ||
105 | exit(-1); | ||
106 | |||
107 | return 0; | ||
108 | } | ||
109 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_events.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_events.c new file mode 100644 index 0000000..8a18140 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_events.c | |||
@@ -0,0 +1,2805 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | //#include "Ecore_X_Atoms.h" | ||
3 | #include <langinfo.h> | ||
4 | #include <xcb/xcb_icccm.h> | ||
5 | #include <xcb/xcb_event.h> | ||
6 | # ifdef ECORE_XCB_DAMAGE | ||
7 | # include <xcb/damage.h> | ||
8 | # endif | ||
9 | # ifdef ECORE_XCB_RANDR | ||
10 | # include <xcb/randr.h> | ||
11 | # endif | ||
12 | # ifdef ECORE_XCB_SCREENSAVER | ||
13 | # include <xcb/screensaver.h> | ||
14 | # endif | ||
15 | # ifdef ECORE_XCB_SYNC | ||
16 | # include <xcb/sync.h> | ||
17 | # endif | ||
18 | # ifdef ECORE_XCB_XFIXES | ||
19 | # include <xcb/xfixes.h> | ||
20 | # endif | ||
21 | # ifdef ECORE_XCB_XGESTURE | ||
22 | # include <xcb/gesture.h> | ||
23 | # endif | ||
24 | |||
25 | #ifndef CODESET | ||
26 | # define CODESET "INVALID" | ||
27 | #endif | ||
28 | |||
29 | typedef struct _Ecore_X_Mouse_Down_Info | ||
30 | { | ||
31 | EINA_INLIST; | ||
32 | int dev; | ||
33 | Ecore_X_Time last_time; | ||
34 | Ecore_X_Time last_last_time; | ||
35 | Ecore_X_Window last_win; | ||
36 | Ecore_X_Window last_last_win; | ||
37 | Ecore_X_Window last_event_win; | ||
38 | Ecore_X_Window last_last_event_win; | ||
39 | Eina_Bool did_double : 1; | ||
40 | Eina_Bool did_triple : 1; | ||
41 | } Ecore_X_Mouse_Down_Info; | ||
42 | |||
43 | /* local function prototypes */ | ||
44 | static void _ecore_xcb_event_handle_any_event(xcb_generic_event_t *event); | ||
45 | static void _ecore_xcb_event_handle_key_press(xcb_generic_event_t *event); | ||
46 | static void _ecore_xcb_event_handle_key_release(xcb_generic_event_t *event); | ||
47 | static void _ecore_xcb_event_handle_button_press(xcb_generic_event_t *event); | ||
48 | static void _ecore_xcb_event_handle_button_release(xcb_generic_event_t *event); | ||
49 | static void _ecore_xcb_event_handle_motion_notify(xcb_generic_event_t *event); | ||
50 | static void _ecore_xcb_event_handle_enter_notify(xcb_generic_event_t *event); | ||
51 | static void _ecore_xcb_event_handle_leave_notify(xcb_generic_event_t *event); | ||
52 | static void _ecore_xcb_event_handle_keymap_notify(xcb_generic_event_t *event); | ||
53 | static void _ecore_xcb_event_handle_focus_in(xcb_generic_event_t *event); | ||
54 | static void _ecore_xcb_event_handle_focus_out(xcb_generic_event_t *event); | ||
55 | static void _ecore_xcb_event_handle_expose(xcb_generic_event_t *event); | ||
56 | static void _ecore_xcb_event_handle_graphics_exposure(xcb_generic_event_t *event); | ||
57 | static void _ecore_xcb_event_handle_visibility_notify(xcb_generic_event_t *event); | ||
58 | static void _ecore_xcb_event_handle_create_notify(xcb_generic_event_t *event); | ||
59 | static void _ecore_xcb_event_handle_destroy_notify(xcb_generic_event_t *event); | ||
60 | static void _ecore_xcb_event_handle_map_notify(xcb_generic_event_t *event); | ||
61 | static void _ecore_xcb_event_handle_unmap_notify(xcb_generic_event_t *event); | ||
62 | static void _ecore_xcb_event_handle_map_request(xcb_generic_event_t *event); | ||
63 | static void _ecore_xcb_event_handle_reparent_notify(xcb_generic_event_t *event); | ||
64 | static void _ecore_xcb_event_handle_configure_notify(xcb_generic_event_t *event); | ||
65 | static void _ecore_xcb_event_handle_configure_request(xcb_generic_event_t *event); | ||
66 | static void _ecore_xcb_event_handle_gravity_notify(xcb_generic_event_t *event); | ||
67 | static void _ecore_xcb_event_handle_resize_request(xcb_generic_event_t *event); | ||
68 | static void _ecore_xcb_event_handle_circulate_notify(xcb_generic_event_t *event); | ||
69 | static void _ecore_xcb_event_handle_circulate_request(xcb_generic_event_t *event); | ||
70 | static void _ecore_xcb_event_handle_property_notify(xcb_generic_event_t *event); | ||
71 | static void _ecore_xcb_event_handle_selection_clear(xcb_generic_event_t *event); | ||
72 | static void _ecore_xcb_event_handle_selection_request(xcb_generic_event_t *event); | ||
73 | static void _ecore_xcb_event_handle_selection_notify(xcb_generic_event_t *event); | ||
74 | static void _ecore_xcb_event_handle_colormap_notify(xcb_generic_event_t *event); | ||
75 | static void _ecore_xcb_event_handle_client_message(xcb_generic_event_t *event); | ||
76 | static void _ecore_xcb_event_handle_mapping_notify(xcb_generic_event_t *event); | ||
77 | static void _ecore_xcb_event_handle_damage_notify(xcb_generic_event_t *event); | ||
78 | static void _ecore_xcb_event_handle_randr_change(xcb_generic_event_t *event); | ||
79 | static void _ecore_xcb_event_handle_randr_notify(xcb_generic_event_t *event); | ||
80 | static void _ecore_xcb_event_handle_randr_crtc_change(xcb_generic_event_t *event); | ||
81 | static void _ecore_xcb_event_handle_randr_output_change(xcb_generic_event_t *event); | ||
82 | static void _ecore_xcb_event_handle_randr_output_property_change(xcb_generic_event_t *event); | ||
83 | static void _ecore_xcb_event_handle_screensaver_notify(xcb_generic_event_t *event); | ||
84 | #ifdef ECORE_XCB_XGESTURE | ||
85 | static void _ecore_xcb_event_handle_gesture_notify_flick(xcb_generic_event_t *event); | ||
86 | static void _ecore_xcb_event_handle_gesture_notify_pan(xcb_generic_event_t *event); | ||
87 | static void _ecore_xcb_event_handle_gesture_notify_pinchrotation(xcb_generic_event_t *event); | ||
88 | static void _ecore_xcb_event_handle_gesture_notify_tap(xcb_generic_event_t *event); | ||
89 | static void _ecore_xcb_event_handle_gesture_notify_tapnhold(xcb_generic_event_t *event); | ||
90 | static void _ecore_xcb_event_handle_gesture_notify_hold(xcb_generic_event_t *event); | ||
91 | static void _ecore_xcb_event_handle_gesture_notify_group(xcb_generic_event_t *event); | ||
92 | #endif | ||
93 | #ifdef ECORE_XCB_SHAPE | ||
94 | static void _ecore_xcb_event_handle_shape_change(xcb_generic_event_t *event); | ||
95 | #endif | ||
96 | static void _ecore_xcb_event_handle_sync_counter(xcb_generic_event_t *event); | ||
97 | static void _ecore_xcb_event_handle_sync_alarm(xcb_generic_event_t *event); | ||
98 | static void _ecore_xcb_event_handle_xfixes_selection_notify(xcb_generic_event_t *event __UNUSED__); | ||
99 | static void _ecore_xcb_event_handle_xfixes_cursor_notify(xcb_generic_event_t *event); | ||
100 | static void _ecore_xcb_event_handle_generic_event(xcb_generic_event_t *event); | ||
101 | static void _ecore_xcb_event_handle_input_event(xcb_generic_event_t *event); | ||
102 | |||
103 | static void _ecore_xcb_event_key_press(xcb_generic_event_t *event); | ||
104 | static void _ecore_xcb_event_key_release(xcb_generic_event_t *event); | ||
105 | static void _ecore_xcb_event_mouse_move_free(void *data __UNUSED__, | ||
106 | void *event); | ||
107 | static Ecore_X_Event_Mode _ecore_xcb_event_mode_get(uint8_t mode); | ||
108 | static Ecore_X_Event_Detail _ecore_xcb_event_detail_get(uint8_t detail); | ||
109 | static void _ecore_xcb_event_xdnd_enter_free(void *data __UNUSED__, | ||
110 | void *event); | ||
111 | static void _ecore_xcb_event_selection_notify_free(void *data __UNUSED__, | ||
112 | void *event); | ||
113 | static void _ecore_xcb_event_generic_event_free(void *data, | ||
114 | void *event); | ||
115 | static void _ecore_xcb_event_mouse_down_info_clear(void); | ||
116 | static Ecore_X_Mouse_Down_Info *_ecore_xcb_event_mouse_down_info_get(int dev); | ||
117 | |||
118 | /* local variables */ | ||
119 | static Eina_Bool _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
120 | //static Ecore_Event *_ecore_xcb_event_last_mouse_move_event = NULL; | ||
121 | static Eina_Inlist *_ecore_xcb_mouse_down_info_list = NULL; | ||
122 | static Ecore_X_Time _ecore_xcb_event_last_time; | ||
123 | static Ecore_X_Window _ecore_xcb_event_last_window = 0; | ||
124 | |||
125 | /* public variables */ | ||
126 | int16_t _ecore_xcb_event_last_root_x = 0; | ||
127 | int16_t _ecore_xcb_event_last_root_y = 0; | ||
128 | |||
129 | EAPI int ECORE_X_EVENT_ANY = 0; | ||
130 | EAPI int ECORE_X_EVENT_MOUSE_IN = 0; | ||
131 | EAPI int ECORE_X_EVENT_MOUSE_OUT = 0; | ||
132 | EAPI int ECORE_X_EVENT_WINDOW_FOCUS_IN = 0; | ||
133 | EAPI int ECORE_X_EVENT_WINDOW_FOCUS_OUT = 0; | ||
134 | EAPI int ECORE_X_EVENT_WINDOW_KEYMAP = 0; | ||
135 | EAPI int ECORE_X_EVENT_WINDOW_DAMAGE = 0; | ||
136 | EAPI int ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE = 0; | ||
137 | EAPI int ECORE_X_EVENT_WINDOW_CREATE = 0; | ||
138 | EAPI int ECORE_X_EVENT_WINDOW_DESTROY = 0; | ||
139 | EAPI int ECORE_X_EVENT_WINDOW_HIDE = 0; | ||
140 | EAPI int ECORE_X_EVENT_WINDOW_SHOW = 0; | ||
141 | EAPI int ECORE_X_EVENT_WINDOW_SHOW_REQUEST = 0; | ||
142 | EAPI int ECORE_X_EVENT_WINDOW_REPARENT = 0; | ||
143 | EAPI int ECORE_X_EVENT_WINDOW_CONFIGURE = 0; | ||
144 | EAPI int ECORE_X_EVENT_WINDOW_CONFIGURE_REQUEST = 0; | ||
145 | EAPI int ECORE_X_EVENT_WINDOW_GRAVITY = 0; | ||
146 | EAPI int ECORE_X_EVENT_WINDOW_RESIZE_REQUEST = 0; | ||
147 | EAPI int ECORE_X_EVENT_WINDOW_STACK = 0; | ||
148 | EAPI int ECORE_X_EVENT_WINDOW_STACK_REQUEST = 0; | ||
149 | EAPI int ECORE_X_EVENT_WINDOW_PROPERTY = 0; | ||
150 | EAPI int ECORE_X_EVENT_WINDOW_COLORMAP = 0; | ||
151 | EAPI int ECORE_X_EVENT_WINDOW_MAPPING = 0; | ||
152 | EAPI int ECORE_X_EVENT_MAPPING_CHANGE = 0; | ||
153 | EAPI int ECORE_X_EVENT_SELECTION_CLEAR = 0; | ||
154 | EAPI int ECORE_X_EVENT_SELECTION_REQUEST = 0; | ||
155 | EAPI int ECORE_X_EVENT_SELECTION_NOTIFY = 0; | ||
156 | EAPI int ECORE_X_EVENT_FIXES_SELECTION_NOTIFY = 0; | ||
157 | EAPI int ECORE_X_EVENT_CLIENT_MESSAGE = 0; | ||
158 | EAPI int ECORE_X_EVENT_WINDOW_SHAPE = 0; | ||
159 | EAPI int ECORE_X_EVENT_SCREENSAVER_NOTIFY = 0; | ||
160 | EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_FLICK = 0; | ||
161 | EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_PAN = 0; | ||
162 | EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION = 0; | ||
163 | EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_TAP = 0; | ||
164 | EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD = 0; | ||
165 | EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_HOLD = 0; | ||
166 | EAPI int ECORE_X_EVENT_GESTURE_NOTIFY_GROUP = 0; | ||
167 | EAPI int ECORE_X_EVENT_SYNC_COUNTER = 0; | ||
168 | EAPI int ECORE_X_EVENT_SYNC_ALARM = 0; | ||
169 | EAPI int ECORE_X_EVENT_SCREEN_CHANGE = 0; | ||
170 | EAPI int ECORE_X_EVENT_DAMAGE_NOTIFY = 0; | ||
171 | EAPI int ECORE_X_EVENT_RANDR_CRTC_CHANGE = 0; | ||
172 | EAPI int ECORE_X_EVENT_RANDR_OUTPUT_CHANGE = 0; | ||
173 | EAPI int ECORE_X_EVENT_RANDR_OUTPUT_PROPERTY_NOTIFY = 0; | ||
174 | EAPI int ECORE_X_EVENT_WINDOW_DELETE_REQUEST = 0; | ||
175 | EAPI int ECORE_X_EVENT_WINDOW_MOVE_RESIZE_REQUEST = 0; | ||
176 | EAPI int ECORE_X_EVENT_WINDOW_STATE_REQUEST = 0; | ||
177 | EAPI int ECORE_X_EVENT_FRAME_EXTENTS_REQUEST = 0; | ||
178 | EAPI int ECORE_X_EVENT_PING = 0; | ||
179 | EAPI int ECORE_X_EVENT_DESKTOP_CHANGE = 0; | ||
180 | EAPI int ECORE_X_EVENT_STARTUP_SEQUENCE_NEW = 0; | ||
181 | EAPI int ECORE_X_EVENT_STARTUP_SEQUENCE_CHANGE = 0; | ||
182 | EAPI int ECORE_X_EVENT_STARTUP_SEQUENCE_REMOVE = 0; | ||
183 | EAPI int ECORE_X_EVENT_GENERIC = 0; | ||
184 | |||
185 | void | ||
186 | _ecore_xcb_events_init(void) | ||
187 | { | ||
188 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
189 | |||
190 | if (!ECORE_X_EVENT_ANY) | ||
191 | { | ||
192 | ECORE_X_EVENT_ANY = ecore_event_type_new(); | ||
193 | ECORE_X_EVENT_MOUSE_IN = ecore_event_type_new(); | ||
194 | ECORE_X_EVENT_MOUSE_OUT = ecore_event_type_new(); | ||
195 | ECORE_X_EVENT_WINDOW_FOCUS_IN = ecore_event_type_new(); | ||
196 | ECORE_X_EVENT_WINDOW_FOCUS_OUT = ecore_event_type_new(); | ||
197 | ECORE_X_EVENT_WINDOW_KEYMAP = ecore_event_type_new(); | ||
198 | ECORE_X_EVENT_WINDOW_DAMAGE = ecore_event_type_new(); | ||
199 | ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE = ecore_event_type_new(); | ||
200 | ECORE_X_EVENT_WINDOW_CREATE = ecore_event_type_new(); | ||
201 | ECORE_X_EVENT_WINDOW_DESTROY = ecore_event_type_new(); | ||
202 | ECORE_X_EVENT_WINDOW_HIDE = ecore_event_type_new(); | ||
203 | ECORE_X_EVENT_WINDOW_SHOW = ecore_event_type_new(); | ||
204 | ECORE_X_EVENT_WINDOW_SHOW_REQUEST = ecore_event_type_new(); | ||
205 | ECORE_X_EVENT_WINDOW_REPARENT = ecore_event_type_new(); | ||
206 | ECORE_X_EVENT_WINDOW_CONFIGURE = ecore_event_type_new(); | ||
207 | ECORE_X_EVENT_WINDOW_CONFIGURE_REQUEST = ecore_event_type_new(); | ||
208 | ECORE_X_EVENT_WINDOW_GRAVITY = ecore_event_type_new(); | ||
209 | ECORE_X_EVENT_WINDOW_RESIZE_REQUEST = ecore_event_type_new(); | ||
210 | ECORE_X_EVENT_WINDOW_STACK = ecore_event_type_new(); | ||
211 | ECORE_X_EVENT_WINDOW_STACK_REQUEST = ecore_event_type_new(); | ||
212 | ECORE_X_EVENT_WINDOW_PROPERTY = ecore_event_type_new(); | ||
213 | ECORE_X_EVENT_WINDOW_COLORMAP = ecore_event_type_new(); | ||
214 | ECORE_X_EVENT_WINDOW_MAPPING = ecore_event_type_new(); | ||
215 | ECORE_X_EVENT_MAPPING_CHANGE = ecore_event_type_new(); | ||
216 | ECORE_X_EVENT_SELECTION_CLEAR = ecore_event_type_new(); | ||
217 | ECORE_X_EVENT_SELECTION_REQUEST = ecore_event_type_new(); | ||
218 | ECORE_X_EVENT_SELECTION_NOTIFY = ecore_event_type_new(); | ||
219 | ECORE_X_EVENT_FIXES_SELECTION_NOTIFY = ecore_event_type_new(); | ||
220 | ECORE_X_EVENT_CLIENT_MESSAGE = ecore_event_type_new(); | ||
221 | ECORE_X_EVENT_WINDOW_SHAPE = ecore_event_type_new(); | ||
222 | ECORE_X_EVENT_SCREENSAVER_NOTIFY = ecore_event_type_new(); | ||
223 | ECORE_X_EVENT_GESTURE_NOTIFY_FLICK = ecore_event_type_new(); | ||
224 | ECORE_X_EVENT_GESTURE_NOTIFY_PAN = ecore_event_type_new(); | ||
225 | ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION = ecore_event_type_new(); | ||
226 | ECORE_X_EVENT_GESTURE_NOTIFY_TAP = ecore_event_type_new(); | ||
227 | ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD = ecore_event_type_new(); | ||
228 | ECORE_X_EVENT_GESTURE_NOTIFY_HOLD = ecore_event_type_new(); | ||
229 | ECORE_X_EVENT_GESTURE_NOTIFY_GROUP = ecore_event_type_new(); | ||
230 | ECORE_X_EVENT_SYNC_COUNTER = ecore_event_type_new(); | ||
231 | ECORE_X_EVENT_SYNC_ALARM = ecore_event_type_new(); | ||
232 | ECORE_X_EVENT_SCREEN_CHANGE = ecore_event_type_new(); | ||
233 | ECORE_X_EVENT_RANDR_CRTC_CHANGE = ecore_event_type_new(); | ||
234 | ECORE_X_EVENT_RANDR_OUTPUT_CHANGE = ecore_event_type_new(); | ||
235 | ECORE_X_EVENT_RANDR_OUTPUT_PROPERTY_NOTIFY = ecore_event_type_new(); | ||
236 | ECORE_X_EVENT_DAMAGE_NOTIFY = ecore_event_type_new(); | ||
237 | ECORE_X_EVENT_WINDOW_DELETE_REQUEST = ecore_event_type_new(); | ||
238 | ECORE_X_EVENT_DESKTOP_CHANGE = ecore_event_type_new(); | ||
239 | ECORE_X_EVENT_WINDOW_MOVE_RESIZE_REQUEST = ecore_event_type_new(); | ||
240 | ECORE_X_EVENT_WINDOW_STATE_REQUEST = ecore_event_type_new(); | ||
241 | ECORE_X_EVENT_FRAME_EXTENTS_REQUEST = ecore_event_type_new(); | ||
242 | ECORE_X_EVENT_PING = ecore_event_type_new(); | ||
243 | ECORE_X_EVENT_STARTUP_SEQUENCE_NEW = ecore_event_type_new(); | ||
244 | ECORE_X_EVENT_STARTUP_SEQUENCE_CHANGE = ecore_event_type_new(); | ||
245 | ECORE_X_EVENT_STARTUP_SEQUENCE_REMOVE = ecore_event_type_new(); | ||
246 | ECORE_X_EVENT_GENERIC = ecore_event_type_new(); | ||
247 | } | ||
248 | } | ||
249 | |||
250 | void | ||
251 | _ecore_xcb_events_shutdown(void) | ||
252 | { | ||
253 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
254 | |||
255 | _ecore_xcb_event_mouse_down_info_clear(); | ||
256 | |||
257 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
258 | // if (_ecore_xcb_event_last_mouse_move_event) | ||
259 | // { | ||
260 | // ecore_event_del(_ecore_xcb_event_last_mouse_move_event); | ||
261 | // _ecore_xcb_event_last_mouse_move_event = NULL; | ||
262 | // } | ||
263 | } | ||
264 | |||
265 | void | ||
266 | _ecore_xcb_events_handle(xcb_generic_event_t *ev) | ||
267 | { | ||
268 | uint8_t response = 0; | ||
269 | |||
270 | // LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
271 | CHECK_XCB_CONN; | ||
272 | |||
273 | /* strip highest bit (set if event is generated) */ | ||
274 | response = (ev->response_type & ~0x80); | ||
275 | if (response == 0) | ||
276 | { | ||
277 | xcb_generic_error_t *err; | ||
278 | |||
279 | err = (xcb_generic_error_t *)ev; | ||
280 | |||
281 | /* NB: There is no way to check access of destroyed windows, | ||
282 | * so trap those cases and ignore. We also ignore BadValue from | ||
283 | * xcb_grab/ungrab_button (happens when we are using any_mod) | ||
284 | * and a few others */ | ||
285 | #ifdef OLD_XCB_VERSION | ||
286 | if (err->error_code == XCB_EVENT_ERROR_BAD_WINDOW) return; | ||
287 | else if (err->error_code == XCB_EVENT_ERROR_BAD_MATCH) | ||
288 | { | ||
289 | if ((err->major_code == XCB_SET_INPUT_FOCUS) || | ||
290 | (err->major_code == XCB_CONFIGURE_WINDOW)) | ||
291 | return; | ||
292 | } | ||
293 | else if (err->error_code == XCB_EVENT_ERROR_BAD_VALUE) | ||
294 | { | ||
295 | if ((err->major_code == XCB_KILL_CLIENT) || | ||
296 | (err->major_code == XCB_GRAB_BUTTON) || | ||
297 | (err->major_code == XCB_UNGRAB_BUTTON)) | ||
298 | return; | ||
299 | } | ||
300 | #else | ||
301 | if (err->error_code == XCB_WINDOW) return; | ||
302 | else if (err->error_code == XCB_MATCH) | ||
303 | { | ||
304 | if ((err->major_code == XCB_SET_INPUT_FOCUS) || | ||
305 | (err->major_code == XCB_CONFIGURE_WINDOW)) | ||
306 | return; | ||
307 | } | ||
308 | else if (err->error_code == XCB_VALUE) | ||
309 | { | ||
310 | if ((err->major_code == XCB_KILL_CLIENT) || | ||
311 | (err->major_code == XCB_GRAB_BUTTON) || | ||
312 | (err->major_code == XCB_UNGRAB_BUTTON)) | ||
313 | return; | ||
314 | } | ||
315 | #endif | ||
316 | WRN("Got Event Error:"); | ||
317 | WRN("\tMajor Code: %d", err->major_code); | ||
318 | WRN("\tMinor Code: %d", err->minor_code); | ||
319 | WRN("\tRequest: %s", xcb_event_get_request_label(err->major_code)); | ||
320 | WRN("\tError: %s", xcb_event_get_error_label(err->error_code)); | ||
321 | if (err->error_code == 2) // bad value | ||
322 | WRN("\tValue: %d", ((xcb_value_error_t *)err)->bad_value); | ||
323 | else if (err->error_code == 8) // bad match | ||
324 | WRN("\tMatch: %d", ((xcb_match_error_t *)err)->bad_value); | ||
325 | |||
326 | if (err->major_code == XCB_SEND_EVENT) | ||
327 | { | ||
328 | WRN("\tSend Event Error"); | ||
329 | WRN("\t\tSeq: %d", ev->sequence); | ||
330 | WRN("\t\tFull Seq: %d", ev->full_sequence); | ||
331 | WRN("\t\tType: %d", ev->response_type); | ||
332 | } | ||
333 | /* if (err->major_code == 148) */ | ||
334 | /* { */ | ||
335 | /* printf("GOT 148 Error\n"); */ | ||
336 | /* } */ | ||
337 | return; | ||
338 | } | ||
339 | |||
340 | /* FIXME: Filter event for xim when xcb supports xim */ | ||
341 | |||
342 | _ecore_xcb_event_handle_any_event(ev); | ||
343 | |||
344 | if (response == XCB_KEY_PRESS) | ||
345 | _ecore_xcb_event_handle_key_press(ev); | ||
346 | else if (response == XCB_KEY_RELEASE) | ||
347 | _ecore_xcb_event_handle_key_release(ev); | ||
348 | else if (response == XCB_BUTTON_PRESS) | ||
349 | _ecore_xcb_event_handle_button_press(ev); | ||
350 | else if (response == XCB_BUTTON_RELEASE) | ||
351 | _ecore_xcb_event_handle_button_release(ev); | ||
352 | else if (response == XCB_MOTION_NOTIFY) | ||
353 | _ecore_xcb_event_handle_motion_notify(ev); | ||
354 | else if (response == XCB_ENTER_NOTIFY) | ||
355 | _ecore_xcb_event_handle_enter_notify(ev); | ||
356 | else if (response == XCB_LEAVE_NOTIFY) | ||
357 | _ecore_xcb_event_handle_leave_notify(ev); | ||
358 | else if (response == XCB_KEYMAP_NOTIFY) | ||
359 | _ecore_xcb_event_handle_keymap_notify(ev); | ||
360 | else if (response == XCB_FOCUS_IN) | ||
361 | _ecore_xcb_event_handle_focus_in(ev); | ||
362 | else if (response == XCB_FOCUS_OUT) | ||
363 | _ecore_xcb_event_handle_focus_out(ev); | ||
364 | else if (response == XCB_EXPOSE) | ||
365 | _ecore_xcb_event_handle_expose(ev); | ||
366 | else if (response == XCB_GRAPHICS_EXPOSURE) | ||
367 | _ecore_xcb_event_handle_graphics_exposure(ev); | ||
368 | else if (response == XCB_VISIBILITY_NOTIFY) | ||
369 | _ecore_xcb_event_handle_visibility_notify(ev); | ||
370 | else if (response == XCB_CREATE_NOTIFY) | ||
371 | _ecore_xcb_event_handle_create_notify(ev); | ||
372 | else if (response == XCB_DESTROY_NOTIFY) | ||
373 | _ecore_xcb_event_handle_destroy_notify(ev); | ||
374 | else if (response == XCB_MAP_NOTIFY) | ||
375 | _ecore_xcb_event_handle_map_notify(ev); | ||
376 | else if (response == XCB_UNMAP_NOTIFY) | ||
377 | _ecore_xcb_event_handle_unmap_notify(ev); | ||
378 | else if (response == XCB_MAP_REQUEST) | ||
379 | _ecore_xcb_event_handle_map_request(ev); | ||
380 | else if (response == XCB_REPARENT_NOTIFY) | ||
381 | _ecore_xcb_event_handle_reparent_notify(ev); | ||
382 | else if (response == XCB_CONFIGURE_NOTIFY) | ||
383 | _ecore_xcb_event_handle_configure_notify(ev); | ||
384 | else if (response == XCB_CONFIGURE_REQUEST) | ||
385 | _ecore_xcb_event_handle_configure_request(ev); | ||
386 | else if (response == XCB_GRAVITY_NOTIFY) | ||
387 | _ecore_xcb_event_handle_gravity_notify(ev); | ||
388 | else if (response == XCB_RESIZE_REQUEST) | ||
389 | _ecore_xcb_event_handle_resize_request(ev); | ||
390 | else if (response == XCB_CIRCULATE_NOTIFY) | ||
391 | _ecore_xcb_event_handle_circulate_notify(ev); | ||
392 | else if (response == XCB_CIRCULATE_REQUEST) | ||
393 | _ecore_xcb_event_handle_circulate_request(ev); | ||
394 | else if (response == XCB_PROPERTY_NOTIFY) | ||
395 | _ecore_xcb_event_handle_property_notify(ev); | ||
396 | else if (response == XCB_SELECTION_CLEAR) | ||
397 | _ecore_xcb_event_handle_selection_clear(ev); | ||
398 | else if (response == XCB_SELECTION_REQUEST) | ||
399 | _ecore_xcb_event_handle_selection_request(ev); | ||
400 | else if (response == XCB_SELECTION_NOTIFY) | ||
401 | _ecore_xcb_event_handle_selection_notify(ev); | ||
402 | else if (response == XCB_COLORMAP_NOTIFY) | ||
403 | _ecore_xcb_event_handle_colormap_notify(ev); | ||
404 | else if (response == XCB_CLIENT_MESSAGE) | ||
405 | _ecore_xcb_event_handle_client_message(ev); | ||
406 | else if (response == XCB_MAPPING_NOTIFY) | ||
407 | _ecore_xcb_event_handle_mapping_notify(ev); | ||
408 | else if (response == 35) /* GenericEvent == 35 */ | ||
409 | _ecore_xcb_event_handle_generic_event(ev); | ||
410 | #ifdef ECORE_XCB_DAMAGE | ||
411 | else if ((_ecore_xcb_event_damage >= 0) && | ||
412 | (response == (_ecore_xcb_event_damage + XCB_DAMAGE_NOTIFY))) | ||
413 | _ecore_xcb_event_handle_damage_notify(ev); | ||
414 | #endif | ||
415 | #ifdef ECORE_XCB_RANDR | ||
416 | else if ((_ecore_xcb_event_randr >= 0) && | ||
417 | (response == | ||
418 | _ecore_xcb_event_randr + XCB_RANDR_SCREEN_CHANGE_NOTIFY)) | ||
419 | _ecore_xcb_event_handle_randr_change(ev); | ||
420 | else if ((_ecore_xcb_event_randr >= 0) && | ||
421 | (response == (_ecore_xcb_event_randr + XCB_RANDR_NOTIFY))) | ||
422 | _ecore_xcb_event_handle_randr_notify(ev); | ||
423 | #endif | ||
424 | #ifdef ECORE_XCB_SCREENSAVER | ||
425 | else if ((_ecore_xcb_event_screensaver >= 0) && | ||
426 | (response == | ||
427 | _ecore_xcb_event_screensaver + XCB_SCREENSAVER_NOTIFY)) | ||
428 | _ecore_xcb_event_handle_screensaver_notify(ev); | ||
429 | #endif | ||
430 | #ifdef ECORE_XCB_XGESTURE | ||
431 | else if ((_ecore_xcb_event_gesture >= 0) && | ||
432 | (response == | ||
433 | _ecore_xcb_event_gesture + XCB_GESTURE_NOTIFY_FLICK)) | ||
434 | _ecore_xcb_event_handle_gesture_notify_flick(ev); | ||
435 | else if ((_ecore_xcb_event_gesture >= 0) && | ||
436 | (response == | ||
437 | _ecore_xcb_event_gesture + XCB_GESTURE_NOTIFY_PAN)) | ||
438 | _ecore_xcb_event_handle_gesture_notify_pan(ev); | ||
439 | else if ((_ecore_xcb_event_gesture >= 0) && | ||
440 | (response == | ||
441 | _ecore_xcb_event_gesture + XCB_GESTURE_NOTIFY_PINCH_ROTATION)) | ||
442 | _ecore_xcb_event_handle_gesture_notify_pinchrotation(ev); | ||
443 | else if ((_ecore_xcb_event_gesture >= 0) && | ||
444 | (response == | ||
445 | _ecore_xcb_event_gesture + XCB_GESTURE_NOTIFY_TAP)) | ||
446 | _ecore_xcb_event_handle_gesture_notify_tap(ev); | ||
447 | else if ((_ecore_xcb_event_gesture >= 0) && | ||
448 | (response == | ||
449 | _ecore_xcb_event_gesture + XCB_GESTURE_NOTIFY_TAP_N_HOLD)) | ||
450 | _ecore_xcb_event_handle_gesture_notify_tapnhold(ev); | ||
451 | else if ((_ecore_xcb_event_gesture >= 0) && | ||
452 | (response == | ||
453 | _ecore_xcb_event_gesture + XCB_GESTURE_NOTIFY_HOLD)) | ||
454 | _ecore_xcb_event_handle_gesture_notify_hold(ev); | ||
455 | else if ((_ecore_xcb_event_gesture >= 0) && | ||
456 | (response == | ||
457 | _ecore_xcb_event_gesture + XCB_GESTURE_NOTIFY_GROUP)) | ||
458 | _ecore_xcb_event_handle_gesture_notify_group(ev); | ||
459 | #endif | ||
460 | #ifdef ECORE_XCB_SHAPE | ||
461 | else if ((_ecore_xcb_event_shape >= 0) && | ||
462 | (response == (_ecore_xcb_event_shape + XCB_SHAPE_NOTIFY))) | ||
463 | _ecore_xcb_event_handle_shape_change(ev); | ||
464 | #endif | ||
465 | #ifdef ECORE_XCB_SYNC | ||
466 | else if ((_ecore_xcb_event_sync >= 0) && | ||
467 | (response == (_ecore_xcb_event_sync + XCB_SYNC_COUNTER_NOTIFY))) | ||
468 | _ecore_xcb_event_handle_sync_counter(ev); | ||
469 | else if ((_ecore_xcb_event_sync >= 0) && | ||
470 | (response == (_ecore_xcb_event_sync + XCB_SYNC_ALARM_NOTIFY))) | ||
471 | _ecore_xcb_event_handle_sync_alarm(ev); | ||
472 | #endif | ||
473 | #ifdef ECORE_XCB_XFIXES | ||
474 | else if ((_ecore_xcb_event_xfixes >= 0) && | ||
475 | (response == | ||
476 | _ecore_xcb_event_xfixes + XCB_XFIXES_SELECTION_NOTIFY)) | ||
477 | _ecore_xcb_event_handle_xfixes_selection_notify(ev); | ||
478 | else if ((_ecore_xcb_event_xfixes >= 0) && | ||
479 | (response == (_ecore_xcb_event_xfixes + XCB_XFIXES_CURSOR_NOTIFY))) | ||
480 | _ecore_xcb_event_handle_xfixes_cursor_notify(ev); | ||
481 | #endif | ||
482 | } | ||
483 | |||
484 | Ecore_X_Time | ||
485 | _ecore_xcb_events_last_time_get(void) | ||
486 | { | ||
487 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
488 | |||
489 | return _ecore_xcb_event_last_time; | ||
490 | } | ||
491 | |||
492 | EAPI void | ||
493 | ecore_x_event_mask_set(Ecore_X_Window win, | ||
494 | Ecore_X_Event_Mask mask) | ||
495 | { | ||
496 | xcb_get_window_attributes_cookie_t cookie; | ||
497 | xcb_get_window_attributes_reply_t *reply; | ||
498 | uint32_t list; | ||
499 | |||
500 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
501 | CHECK_XCB_CONN; | ||
502 | |||
503 | if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
504 | cookie = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, win); | ||
505 | reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL); | ||
506 | if (!reply) return; | ||
507 | |||
508 | list = (mask | reply->your_event_mask); | ||
509 | free(reply); | ||
510 | xcb_change_window_attributes(_ecore_xcb_conn, win, | ||
511 | XCB_CW_EVENT_MASK, &list); | ||
512 | // ecore_x_flush(); | ||
513 | } | ||
514 | |||
515 | EAPI void | ||
516 | ecore_x_event_mask_unset(Ecore_X_Window win, | ||
517 | Ecore_X_Event_Mask mask) | ||
518 | { | ||
519 | xcb_get_window_attributes_cookie_t cookie; | ||
520 | xcb_get_window_attributes_reply_t *reply; | ||
521 | uint32_t list; | ||
522 | |||
523 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
524 | CHECK_XCB_CONN; | ||
525 | |||
526 | if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
527 | cookie = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, win); | ||
528 | reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL); | ||
529 | if (!reply) return; | ||
530 | |||
531 | list = (reply->your_event_mask & ~mask); | ||
532 | free(reply); | ||
533 | xcb_change_window_attributes(_ecore_xcb_conn, win, | ||
534 | XCB_CW_EVENT_MASK, &list); | ||
535 | // ecore_x_flush(); | ||
536 | } | ||
537 | |||
538 | unsigned int | ||
539 | _ecore_xcb_events_modifiers_get(unsigned int state) | ||
540 | { | ||
541 | unsigned int modifiers = 0; | ||
542 | |||
543 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
544 | |||
545 | if (state & ECORE_X_MODIFIER_SHIFT) | ||
546 | modifiers |= ECORE_EVENT_MODIFIER_SHIFT; | ||
547 | if (state & ECORE_X_MODIFIER_CTRL) | ||
548 | modifiers |= ECORE_EVENT_MODIFIER_CTRL; | ||
549 | if (state & ECORE_X_MODIFIER_ALT) | ||
550 | modifiers |= ECORE_EVENT_MODIFIER_ALT; | ||
551 | if (state & ECORE_X_MODIFIER_WIN) | ||
552 | modifiers |= ECORE_EVENT_MODIFIER_WIN; | ||
553 | if (state & ECORE_X_LOCK_SCROLL) | ||
554 | modifiers |= ECORE_EVENT_LOCK_SCROLL; | ||
555 | if (state & ECORE_X_LOCK_CAPS) | ||
556 | modifiers |= ECORE_EVENT_LOCK_CAPS; | ||
557 | if (state & ECORE_X_LOCK_NUM) | ||
558 | modifiers |= ECORE_EVENT_LOCK_NUM; | ||
559 | if (state & ECORE_X_LOCK_SHIFT) | ||
560 | modifiers |= ECORE_EVENT_LOCK_SHIFT; | ||
561 | |||
562 | return modifiers; | ||
563 | } | ||
564 | |||
565 | /* local functions */ | ||
566 | static void | ||
567 | _ecore_xcb_event_handle_any_event(xcb_generic_event_t *event) | ||
568 | { | ||
569 | xcb_generic_event_t *ev; | ||
570 | |||
571 | // LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
572 | |||
573 | ev = malloc(sizeof(xcb_generic_event_t)); | ||
574 | if (!ev) return; | ||
575 | |||
576 | memcpy(ev, event, sizeof(xcb_generic_event_t)); | ||
577 | ecore_event_add(ECORE_X_EVENT_ANY, ev, NULL, NULL); | ||
578 | } | ||
579 | |||
580 | static void | ||
581 | _ecore_xcb_event_handle_key_press(xcb_generic_event_t *event) | ||
582 | { | ||
583 | _ecore_xcb_event_key_press(event); | ||
584 | } | ||
585 | |||
586 | static void | ||
587 | _ecore_xcb_event_handle_key_release(xcb_generic_event_t *event) | ||
588 | { | ||
589 | _ecore_xcb_event_key_release(event); | ||
590 | } | ||
591 | |||
592 | static void | ||
593 | _ecore_xcb_event_handle_button_press(xcb_generic_event_t *event) | ||
594 | { | ||
595 | xcb_button_press_event_t *ev; | ||
596 | |||
597 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
598 | |||
599 | ev = (xcb_button_press_event_t *)event; | ||
600 | if ((ev->detail > 3) && (ev->detail < 8)) | ||
601 | { | ||
602 | Ecore_Event_Mouse_Wheel *e; | ||
603 | |||
604 | if (!(e = malloc(sizeof(Ecore_Event_Mouse_Wheel)))) return; | ||
605 | |||
606 | e->timestamp = ev->time; | ||
607 | e->modifiers = _ecore_xcb_events_modifiers_get(ev->state); | ||
608 | switch (ev->detail) | ||
609 | { | ||
610 | case 4: | ||
611 | e->direction = 0; | ||
612 | e->z = -1; | ||
613 | break; | ||
614 | |||
615 | case 5: | ||
616 | e->direction = 0; | ||
617 | e->z = 1; | ||
618 | break; | ||
619 | |||
620 | case 6: | ||
621 | e->direction = 1; | ||
622 | e->z = -1; | ||
623 | break; | ||
624 | |||
625 | case 7: | ||
626 | e->direction = 1; | ||
627 | e->z = 1; | ||
628 | break; | ||
629 | |||
630 | default: | ||
631 | e->direction = 0; | ||
632 | e->z = 0; | ||
633 | break; | ||
634 | } | ||
635 | e->x = ev->event_x; | ||
636 | e->y = ev->event_y; | ||
637 | e->root.x = ev->root_x; | ||
638 | e->root.y = ev->root_y; | ||
639 | if (ev->child) | ||
640 | e->window = ev->child; | ||
641 | else | ||
642 | e->window = ev->event; | ||
643 | |||
644 | e->event_window = ev->event; | ||
645 | e->same_screen = ev->same_screen; | ||
646 | e->root_window = ev->root; | ||
647 | |||
648 | _ecore_xcb_event_last_time = e->timestamp; | ||
649 | _ecore_xcb_event_last_window = e->window; | ||
650 | _ecore_xcb_event_last_root_x = e->root.x; | ||
651 | _ecore_xcb_event_last_root_y = e->root.y; | ||
652 | |||
653 | ecore_event_add(ECORE_EVENT_MOUSE_WHEEL, e, NULL, NULL); | ||
654 | |||
655 | _ecore_xcb_window_grab_allow_events(ev->event, ev->child, | ||
656 | ECORE_EVENT_MOUSE_WHEEL, | ||
657 | e, ev->time); | ||
658 | } | ||
659 | else | ||
660 | { | ||
661 | Ecore_Event_Mouse_Button *e; | ||
662 | unsigned int child_win = 0; | ||
663 | |||
664 | child_win = (ev->child ? ev->child : ev->event); | ||
665 | |||
666 | _ecore_xcb_event_mouse_move(ev->time, ev->state, | ||
667 | ev->event_x, ev->event_y, | ||
668 | ev->root_x, ev->root_y, | ||
669 | ev->event, child_win, | ||
670 | ev->root, ev->same_screen, | ||
671 | 0, 1, 1, 1.0, 0.0, | ||
672 | ev->event_x, ev->event_y, | ||
673 | ev->root_x, ev->root_y); | ||
674 | |||
675 | e = _ecore_xcb_event_mouse_button(ECORE_EVENT_MOUSE_BUTTON_DOWN, | ||
676 | ev->time, | ||
677 | ev->state, ev->detail, | ||
678 | ev->event_x, ev->event_y, | ||
679 | ev->root_x, ev->root_y, ev->event, | ||
680 | child_win, | ||
681 | ev->root, ev->same_screen, | ||
682 | 0, 1, 1, 1.0, 0.0, | ||
683 | ev->event_x, ev->event_y, | ||
684 | ev->root_x, ev->root_y); | ||
685 | if (e) | ||
686 | _ecore_xcb_window_grab_allow_events(ev->event, ev->child, | ||
687 | ECORE_EVENT_MOUSE_BUTTON_DOWN, | ||
688 | e, ev->time); | ||
689 | } | ||
690 | } | ||
691 | |||
692 | static void | ||
693 | _ecore_xcb_event_handle_button_release(xcb_generic_event_t *event) | ||
694 | { | ||
695 | xcb_button_release_event_t *ev; | ||
696 | |||
697 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
698 | ev = (xcb_button_release_event_t *)event; | ||
699 | if ((ev->detail <= 3) || (ev->detail > 7)) | ||
700 | { | ||
701 | _ecore_xcb_event_mouse_move(ev->time, ev->state, | ||
702 | ev->event_x, ev->event_y, | ||
703 | ev->root_x, ev->root_y, | ||
704 | ev->event, | ||
705 | (ev->child ? ev->child : ev->event), | ||
706 | ev->root, ev->same_screen, | ||
707 | 0, 1, 1, 1.0, 0.0, | ||
708 | ev->event_x, ev->event_y, | ||
709 | ev->root_x, ev->root_y); | ||
710 | |||
711 | _ecore_xcb_event_mouse_button(ECORE_EVENT_MOUSE_BUTTON_UP, ev->time, | ||
712 | ev->state, ev->detail, | ||
713 | ev->event_x, ev->event_y, ev->root_x, | ||
714 | ev->root_y, ev->event, | ||
715 | (ev->child ? ev->child : ev->event), | ||
716 | ev->root, ev->same_screen, | ||
717 | 0, 1, 1, 1.0, 0.0, | ||
718 | ev->event_x, ev->event_y, | ||
719 | ev->root_x, ev->root_y); | ||
720 | } | ||
721 | } | ||
722 | |||
723 | static void | ||
724 | _ecore_xcb_event_handle_motion_notify(xcb_generic_event_t *event) | ||
725 | { | ||
726 | xcb_motion_notify_event_t *ev; | ||
727 | |||
728 | ev = (xcb_motion_notify_event_t *)event; | ||
729 | |||
730 | /* if (_ecore_xcb_event_last_mouse_move_event) */ | ||
731 | /* { */ | ||
732 | /* ecore_event_del(_ecore_xcb_event_last_mouse_move_event); */ | ||
733 | /* _ecore_xcb_event_last_mouse_move = EINA_FALSE; */ | ||
734 | /* _ecore_xcb_event_last_mouse_move_event = NULL; */ | ||
735 | /* } */ | ||
736 | |||
737 | _ecore_xcb_event_mouse_move(ev->time, ev->state, | ||
738 | ev->event_x, ev->event_y, | ||
739 | ev->root_x, ev->root_y, | ||
740 | ev->event, | ||
741 | (ev->child ? ev->child : ev->event), | ||
742 | ev->root, ev->same_screen, | ||
743 | 0, 1, 1, 1.0, 0.0, | ||
744 | ev->event_x, ev->event_y, | ||
745 | ev->root_x, ev->root_y); | ||
746 | _ecore_xcb_event_last_mouse_move = EINA_TRUE; | ||
747 | |||
748 | _ecore_xcb_dnd_drag(ev->root, ev->root_x, ev->root_y); | ||
749 | } | ||
750 | |||
751 | static void | ||
752 | _ecore_xcb_event_handle_enter_notify(xcb_generic_event_t *event) | ||
753 | { | ||
754 | xcb_enter_notify_event_t *ev; | ||
755 | Ecore_X_Event_Mouse_In *e; | ||
756 | |||
757 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
758 | ev = (xcb_enter_notify_event_t *)event; | ||
759 | |||
760 | _ecore_xcb_event_mouse_move(ev->time, ev->state, | ||
761 | ev->event_x, ev->event_y, | ||
762 | ev->root_x, ev->root_y, | ||
763 | ev->event, | ||
764 | (ev->child ? ev->child : ev->event), | ||
765 | ev->root, ev->same_screen_focus, | ||
766 | 0, 1, 1, 1.0, 0.0, | ||
767 | ev->event_x, ev->event_y, | ||
768 | ev->root_x, ev->root_y); | ||
769 | |||
770 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Mouse_In)))) return; | ||
771 | |||
772 | e->modifiers = _ecore_xcb_events_modifiers_get(ev->state); | ||
773 | e->x = ev->event_x; | ||
774 | e->y = ev->event_y; | ||
775 | e->root.x = ev->root_x; | ||
776 | e->root.y = ev->root_y; | ||
777 | if (ev->child) | ||
778 | e->win = ev->child; | ||
779 | else | ||
780 | e->win = ev->event; | ||
781 | e->event_win = ev->event; | ||
782 | e->same_screen = ev->same_screen_focus; | ||
783 | e->root_win = ev->root; | ||
784 | e->mode = _ecore_xcb_event_mode_get(ev->mode); | ||
785 | e->detail = _ecore_xcb_event_detail_get(ev->detail); | ||
786 | e->time = ev->time; | ||
787 | _ecore_xcb_event_last_time = e->time; | ||
788 | |||
789 | ecore_event_add(ECORE_X_EVENT_MOUSE_IN, e, NULL, NULL); | ||
790 | } | ||
791 | |||
792 | static void | ||
793 | _ecore_xcb_event_handle_leave_notify(xcb_generic_event_t *event) | ||
794 | { | ||
795 | xcb_leave_notify_event_t *ev; | ||
796 | Ecore_X_Event_Mouse_Out *e; | ||
797 | |||
798 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
799 | ev = (xcb_enter_notify_event_t *)event; | ||
800 | |||
801 | _ecore_xcb_event_mouse_move(ev->time, ev->state, | ||
802 | ev->event_x, ev->event_y, | ||
803 | ev->root_x, ev->root_y, | ||
804 | ev->event, | ||
805 | (ev->child ? ev->child : ev->event), | ||
806 | ev->root, ev->same_screen_focus, | ||
807 | 0, 1, 1, 1.0, 0.0, | ||
808 | ev->event_x, ev->event_y, | ||
809 | ev->root_x, ev->root_y); | ||
810 | |||
811 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Mouse_Out)))) return; | ||
812 | |||
813 | e->modifiers = _ecore_xcb_events_modifiers_get(ev->state); | ||
814 | e->x = ev->event_x; | ||
815 | e->y = ev->event_y; | ||
816 | e->root.x = ev->root_x; | ||
817 | e->root.y = ev->root_y; | ||
818 | if (ev->child) | ||
819 | e->win = ev->child; | ||
820 | else | ||
821 | e->win = ev->event; | ||
822 | e->event_win = ev->event; | ||
823 | e->same_screen = ev->same_screen_focus; | ||
824 | e->root_win = ev->root; | ||
825 | e->mode = _ecore_xcb_event_mode_get(ev->mode); | ||
826 | e->detail = _ecore_xcb_event_detail_get(ev->detail); | ||
827 | |||
828 | e->time = ev->time; | ||
829 | _ecore_xcb_event_last_time = e->time; | ||
830 | _ecore_xcb_event_last_window = e->win; | ||
831 | _ecore_xcb_event_last_root_x = e->root.x; | ||
832 | _ecore_xcb_event_last_root_y = e->root.y; | ||
833 | |||
834 | ecore_event_add(ECORE_X_EVENT_MOUSE_OUT, e, NULL, NULL); | ||
835 | } | ||
836 | |||
837 | static void | ||
838 | _ecore_xcb_event_handle_keymap_notify(xcb_generic_event_t *event __UNUSED__) | ||
839 | { | ||
840 | // LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
841 | |||
842 | // FIXME: handle this event type | ||
843 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
844 | } | ||
845 | |||
846 | static void | ||
847 | _ecore_xcb_event_handle_focus_in(xcb_generic_event_t *event) | ||
848 | { | ||
849 | xcb_focus_in_event_t *ev; | ||
850 | Ecore_X_Event_Window_Focus_In *e; | ||
851 | |||
852 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
853 | ev = (xcb_focus_in_event_t *)event; | ||
854 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Focus_In)))) return; | ||
855 | |||
856 | e->win = ev->event; | ||
857 | e->mode = _ecore_xcb_event_mode_get(ev->mode); | ||
858 | e->detail = _ecore_xcb_event_detail_get(ev->detail); | ||
859 | |||
860 | e->time = _ecore_xcb_event_last_time; | ||
861 | _ecore_xcb_event_last_time = e->time; | ||
862 | |||
863 | ecore_event_add(ECORE_X_EVENT_WINDOW_FOCUS_IN, e, NULL, NULL); | ||
864 | } | ||
865 | |||
866 | static void | ||
867 | _ecore_xcb_event_handle_focus_out(xcb_generic_event_t *event) | ||
868 | { | ||
869 | xcb_focus_out_event_t *ev; | ||
870 | Ecore_X_Event_Window_Focus_Out *e; | ||
871 | |||
872 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
873 | ev = (xcb_focus_out_event_t *)event; | ||
874 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Focus_Out)))) return; | ||
875 | |||
876 | e->win = ev->event; | ||
877 | e->mode = _ecore_xcb_event_mode_get(ev->mode); | ||
878 | e->detail = _ecore_xcb_event_detail_get(ev->detail); | ||
879 | |||
880 | e->time = _ecore_xcb_event_last_time; | ||
881 | _ecore_xcb_event_last_time = e->time; | ||
882 | |||
883 | ecore_event_add(ECORE_X_EVENT_WINDOW_FOCUS_OUT, e, NULL, NULL); | ||
884 | } | ||
885 | |||
886 | static void | ||
887 | _ecore_xcb_event_handle_expose(xcb_generic_event_t *event) | ||
888 | { | ||
889 | xcb_expose_event_t *ev; | ||
890 | Ecore_X_Event_Window_Damage *e; | ||
891 | |||
892 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
893 | ev = (xcb_expose_event_t *)event; | ||
894 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Damage)))) return; | ||
895 | |||
896 | e->win = ev->window; | ||
897 | e->time = _ecore_xcb_event_last_time; | ||
898 | e->x = ev->x; | ||
899 | e->y = ev->y; | ||
900 | e->w = ev->width; | ||
901 | e->h = ev->height; | ||
902 | e->count = ev->count; | ||
903 | |||
904 | ecore_event_add(ECORE_X_EVENT_WINDOW_DAMAGE, e, NULL, NULL); | ||
905 | } | ||
906 | |||
907 | static void | ||
908 | _ecore_xcb_event_handle_graphics_exposure(xcb_generic_event_t *event) | ||
909 | { | ||
910 | xcb_graphics_exposure_event_t *ev; | ||
911 | Ecore_X_Event_Window_Damage *e; | ||
912 | |||
913 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
914 | ev = (xcb_graphics_exposure_event_t *)event; | ||
915 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Damage)))) return; | ||
916 | |||
917 | e->win = ev->drawable; | ||
918 | e->x = ev->x; | ||
919 | e->y = ev->y; | ||
920 | e->w = ev->width; | ||
921 | e->h = ev->height; | ||
922 | e->count = ev->count; | ||
923 | e->time = _ecore_xcb_event_last_time; | ||
924 | |||
925 | ecore_event_add(ECORE_X_EVENT_WINDOW_DAMAGE, e, NULL, NULL); | ||
926 | } | ||
927 | |||
928 | static void | ||
929 | _ecore_xcb_event_handle_visibility_notify(xcb_generic_event_t *event) | ||
930 | { | ||
931 | xcb_visibility_notify_event_t *ev; | ||
932 | Ecore_X_Event_Window_Visibility_Change *e; | ||
933 | |||
934 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
935 | ev = (xcb_visibility_notify_event_t *)event; | ||
936 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Visibility_Change)))) | ||
937 | return; | ||
938 | |||
939 | e->win = ev->window; | ||
940 | e->time = _ecore_xcb_event_last_time; | ||
941 | if (ev->state == XCB_VISIBILITY_FULLY_OBSCURED) | ||
942 | e->fully_obscured = 1; | ||
943 | else | ||
944 | e->fully_obscured = 0; | ||
945 | |||
946 | ecore_event_add(ECORE_X_EVENT_WINDOW_VISIBILITY_CHANGE, e, NULL, NULL); | ||
947 | } | ||
948 | |||
949 | static void | ||
950 | _ecore_xcb_event_handle_create_notify(xcb_generic_event_t *event) | ||
951 | { | ||
952 | xcb_create_notify_event_t *ev; | ||
953 | Ecore_X_Event_Window_Create *e; | ||
954 | |||
955 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
956 | ev = (xcb_create_notify_event_t *)event; | ||
957 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Create)))) return; | ||
958 | |||
959 | e->win = ev->window; | ||
960 | e->parent = ev->parent; | ||
961 | if (ev->override_redirect) | ||
962 | e->override = 1; | ||
963 | else | ||
964 | e->override = 0; | ||
965 | e->x = ev->x; | ||
966 | e->y = ev->y; | ||
967 | e->w = ev->width; | ||
968 | e->h = ev->height; | ||
969 | e->border = ev->border_width; | ||
970 | e->time = _ecore_xcb_event_last_time; | ||
971 | |||
972 | ecore_event_add(ECORE_X_EVENT_WINDOW_CREATE, e, NULL, NULL); | ||
973 | } | ||
974 | |||
975 | static void | ||
976 | _ecore_xcb_event_handle_destroy_notify(xcb_generic_event_t *event) | ||
977 | { | ||
978 | xcb_destroy_notify_event_t *ev; | ||
979 | Ecore_X_Event_Window_Destroy *e; | ||
980 | |||
981 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
982 | ev = (xcb_destroy_notify_event_t *)event; | ||
983 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Destroy)))) return; | ||
984 | |||
985 | e->win = ev->window; | ||
986 | e->event_win = ev->event; | ||
987 | if (e->win == _ecore_xcb_event_last_window) | ||
988 | _ecore_xcb_event_last_window = 0; | ||
989 | e->time = _ecore_xcb_event_last_time; | ||
990 | |||
991 | ecore_event_add(ECORE_X_EVENT_WINDOW_DESTROY, e, NULL, NULL); | ||
992 | } | ||
993 | |||
994 | static void | ||
995 | _ecore_xcb_event_handle_map_notify(xcb_generic_event_t *event) | ||
996 | { | ||
997 | xcb_map_notify_event_t *ev; | ||
998 | Ecore_X_Event_Window_Show *e; | ||
999 | |||
1000 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1001 | ev = (xcb_map_notify_event_t *)event; | ||
1002 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Show)))) return; | ||
1003 | |||
1004 | e->win = ev->window; | ||
1005 | e->event_win = ev->event; | ||
1006 | e->time = _ecore_xcb_event_last_time; | ||
1007 | |||
1008 | ecore_event_add(ECORE_X_EVENT_WINDOW_SHOW, e, NULL, NULL); | ||
1009 | } | ||
1010 | |||
1011 | static void | ||
1012 | _ecore_xcb_event_handle_unmap_notify(xcb_generic_event_t *event) | ||
1013 | { | ||
1014 | xcb_unmap_notify_event_t *ev; | ||
1015 | Ecore_X_Event_Window_Hide *e; | ||
1016 | |||
1017 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1018 | ev = (xcb_unmap_notify_event_t *)event; | ||
1019 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Hide)))) return; | ||
1020 | |||
1021 | e->win = ev->window; | ||
1022 | e->event_win = ev->event; | ||
1023 | e->time = _ecore_xcb_event_last_time; | ||
1024 | |||
1025 | ecore_event_add(ECORE_X_EVENT_WINDOW_HIDE, e, NULL, NULL); | ||
1026 | } | ||
1027 | |||
1028 | static void | ||
1029 | _ecore_xcb_event_handle_map_request(xcb_generic_event_t *event) | ||
1030 | { | ||
1031 | xcb_map_request_event_t *ev; | ||
1032 | Ecore_X_Event_Window_Show_Request *e; | ||
1033 | |||
1034 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1035 | ev = (xcb_map_request_event_t *)event; | ||
1036 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Show_Request)))) return; | ||
1037 | |||
1038 | e->win = ev->window; | ||
1039 | e->parent = ev->parent; | ||
1040 | e->time = _ecore_xcb_event_last_time; | ||
1041 | |||
1042 | ecore_event_add(ECORE_X_EVENT_WINDOW_SHOW_REQUEST, e, NULL, NULL); | ||
1043 | } | ||
1044 | |||
1045 | static void | ||
1046 | _ecore_xcb_event_handle_reparent_notify(xcb_generic_event_t *event) | ||
1047 | { | ||
1048 | xcb_reparent_notify_event_t *ev; | ||
1049 | Ecore_X_Event_Window_Reparent *e; | ||
1050 | |||
1051 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1052 | ev = (xcb_reparent_notify_event_t *)event; | ||
1053 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Reparent)))) return; | ||
1054 | |||
1055 | e->win = ev->window; | ||
1056 | e->event_win = ev->event; | ||
1057 | e->parent = ev->parent; | ||
1058 | e->time = _ecore_xcb_event_last_time; | ||
1059 | |||
1060 | ecore_event_add(ECORE_X_EVENT_WINDOW_REPARENT, e, NULL, NULL); | ||
1061 | } | ||
1062 | |||
1063 | static void | ||
1064 | _ecore_xcb_event_handle_configure_notify(xcb_generic_event_t *event) | ||
1065 | { | ||
1066 | xcb_configure_notify_event_t *ev; | ||
1067 | Ecore_X_Event_Window_Configure *e; | ||
1068 | |||
1069 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1070 | ev = (xcb_configure_notify_event_t *)event; | ||
1071 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Configure)))) return; | ||
1072 | |||
1073 | e->win = ev->window; | ||
1074 | e->event_win = ev->event; | ||
1075 | e->abovewin = ev->above_sibling; | ||
1076 | e->x = ev->x; | ||
1077 | e->y = ev->y; | ||
1078 | e->w = ev->width; | ||
1079 | e->h = ev->height; | ||
1080 | e->border = ev->border_width; | ||
1081 | e->override = ev->override_redirect; | ||
1082 | /* send_event is bit 7 (0x80) of response_type */ | ||
1083 | e->from_wm = ((ev->response_type & 0x80) ? 1 : 0); | ||
1084 | e->time = _ecore_xcb_event_last_time; | ||
1085 | |||
1086 | ecore_event_add(ECORE_X_EVENT_WINDOW_CONFIGURE, e, NULL, NULL); | ||
1087 | } | ||
1088 | |||
1089 | static void | ||
1090 | _ecore_xcb_event_handle_configure_request(xcb_generic_event_t *event) | ||
1091 | { | ||
1092 | xcb_configure_request_event_t *ev; | ||
1093 | Ecore_X_Event_Window_Configure_Request *e; | ||
1094 | |||
1095 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1096 | ev = (xcb_configure_request_event_t *)event; | ||
1097 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Configure_Request)))) | ||
1098 | return; | ||
1099 | |||
1100 | e->win = ev->window; | ||
1101 | e->parent_win = ev->parent; | ||
1102 | e->abovewin = ev->sibling; | ||
1103 | e->x = ev->x; | ||
1104 | e->y = ev->y; | ||
1105 | e->w = ev->width; | ||
1106 | e->h = ev->height; | ||
1107 | e->border = ev->border_width; | ||
1108 | e->value_mask = ev->value_mask; | ||
1109 | switch (ev->stack_mode) | ||
1110 | { | ||
1111 | case XCB_STACK_MODE_ABOVE: | ||
1112 | e->detail = ECORE_X_WINDOW_STACK_ABOVE; | ||
1113 | break; | ||
1114 | |||
1115 | case XCB_STACK_MODE_BELOW: | ||
1116 | e->detail = ECORE_X_WINDOW_STACK_BELOW; | ||
1117 | break; | ||
1118 | |||
1119 | case XCB_STACK_MODE_TOP_IF: | ||
1120 | e->detail = ECORE_X_WINDOW_STACK_TOP_IF; | ||
1121 | break; | ||
1122 | |||
1123 | case XCB_STACK_MODE_BOTTOM_IF: | ||
1124 | e->detail = ECORE_X_WINDOW_STACK_BOTTOM_IF; | ||
1125 | break; | ||
1126 | |||
1127 | case XCB_STACK_MODE_OPPOSITE: | ||
1128 | e->detail = ECORE_X_WINDOW_STACK_OPPOSITE; | ||
1129 | break; | ||
1130 | } | ||
1131 | e->time = _ecore_xcb_event_last_time; | ||
1132 | |||
1133 | ecore_event_add(ECORE_X_EVENT_WINDOW_CONFIGURE_REQUEST, e, NULL, NULL); | ||
1134 | } | ||
1135 | |||
1136 | static void | ||
1137 | _ecore_xcb_event_handle_gravity_notify(xcb_generic_event_t *event __UNUSED__) | ||
1138 | { | ||
1139 | /* | ||
1140 | xcb_gravity_notify_event_t *ev; | ||
1141 | Ecore_X_Event_Window_Gravity *e; | ||
1142 | |||
1143 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1144 | ev = (xcb_gravity_notify_event_t *)event; | ||
1145 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Gravity)))) return; | ||
1146 | |||
1147 | e->win = ev->window; | ||
1148 | e->event_win = ev->event; | ||
1149 | e->time = _ecore_xcb_event_last_time; | ||
1150 | |||
1151 | ecore_event_add(ECORE_X_EVENT_WINDOW_GRAVITY, e, NULL, NULL); | ||
1152 | */ | ||
1153 | } | ||
1154 | |||
1155 | static void | ||
1156 | _ecore_xcb_event_handle_resize_request(xcb_generic_event_t *event) | ||
1157 | { | ||
1158 | xcb_resize_request_event_t *ev; | ||
1159 | Ecore_X_Event_Window_Resize_Request *e; | ||
1160 | |||
1161 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1162 | ev = (xcb_resize_request_event_t *)event; | ||
1163 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Resize_Request)))) return; | ||
1164 | |||
1165 | e->win = ev->window; | ||
1166 | e->w = ev->width; | ||
1167 | e->h = ev->height; | ||
1168 | e->time = _ecore_xcb_event_last_time; | ||
1169 | |||
1170 | ecore_event_add(ECORE_X_EVENT_WINDOW_RESIZE_REQUEST, e, NULL, NULL); | ||
1171 | } | ||
1172 | |||
1173 | static void | ||
1174 | _ecore_xcb_event_handle_circulate_notify(xcb_generic_event_t *event) | ||
1175 | { | ||
1176 | xcb_circulate_notify_event_t *ev; | ||
1177 | Ecore_X_Event_Window_Stack *e; | ||
1178 | |||
1179 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1180 | ev = (xcb_circulate_notify_event_t *)event; | ||
1181 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Stack)))) return; | ||
1182 | |||
1183 | e->win = ev->window; | ||
1184 | e->event_win = ev->event; | ||
1185 | if (ev->place == XCB_PLACE_ON_TOP) | ||
1186 | e->detail = ECORE_X_WINDOW_STACK_ABOVE; | ||
1187 | else | ||
1188 | e->detail = ECORE_X_WINDOW_STACK_BELOW; | ||
1189 | e->time = _ecore_xcb_event_last_time; | ||
1190 | |||
1191 | ecore_event_add(ECORE_X_EVENT_WINDOW_STACK, e, NULL, NULL); | ||
1192 | } | ||
1193 | |||
1194 | static void | ||
1195 | _ecore_xcb_event_handle_circulate_request(xcb_generic_event_t *event) | ||
1196 | { | ||
1197 | xcb_circulate_request_event_t *ev; | ||
1198 | Ecore_X_Event_Window_Stack_Request *e; | ||
1199 | |||
1200 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1201 | ev = (xcb_circulate_request_event_t *)event; | ||
1202 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Stack_Request)))) return; | ||
1203 | |||
1204 | e->win = ev->window; | ||
1205 | e->parent = ev->event; | ||
1206 | if (ev->place == XCB_PLACE_ON_TOP) | ||
1207 | e->detail = ECORE_X_WINDOW_STACK_ABOVE; | ||
1208 | else | ||
1209 | e->detail = ECORE_X_WINDOW_STACK_BELOW; | ||
1210 | e->time = _ecore_xcb_event_last_time; | ||
1211 | |||
1212 | ecore_event_add(ECORE_X_EVENT_WINDOW_STACK_REQUEST, e, NULL, NULL); | ||
1213 | } | ||
1214 | |||
1215 | static void | ||
1216 | _ecore_xcb_event_handle_property_notify(xcb_generic_event_t *event) | ||
1217 | { | ||
1218 | xcb_property_notify_event_t *ev; | ||
1219 | Ecore_X_Event_Window_Property *e; | ||
1220 | |||
1221 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1222 | ev = (xcb_property_notify_event_t *)event; | ||
1223 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Property)))) return; | ||
1224 | |||
1225 | e->win = ev->window; | ||
1226 | e->atom = ev->atom; | ||
1227 | e->time = ev->time; | ||
1228 | _ecore_xcb_event_last_time = e->time; | ||
1229 | |||
1230 | ecore_event_add(ECORE_X_EVENT_WINDOW_PROPERTY, e, NULL, NULL); | ||
1231 | } | ||
1232 | |||
1233 | static void | ||
1234 | _ecore_xcb_event_handle_selection_clear(xcb_generic_event_t *event) | ||
1235 | { | ||
1236 | xcb_selection_clear_event_t *ev; | ||
1237 | Ecore_X_Event_Selection_Clear *e; | ||
1238 | Ecore_X_Atom sel; | ||
1239 | |||
1240 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1241 | |||
1242 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1243 | ev = (xcb_selection_clear_event_t *)event; | ||
1244 | if (!(e = malloc(sizeof(Ecore_X_Event_Selection_Clear)))) return; | ||
1245 | |||
1246 | e->win = ev->owner; | ||
1247 | e->atom = sel = ev->selection; | ||
1248 | if (sel == ECORE_X_ATOM_SELECTION_PRIMARY) | ||
1249 | e->selection = ECORE_X_SELECTION_PRIMARY; | ||
1250 | else if (sel == ECORE_X_ATOM_SELECTION_SECONDARY) | ||
1251 | e->selection = ECORE_X_SELECTION_SECONDARY; | ||
1252 | else if (sel == ECORE_X_ATOM_SELECTION_CLIPBOARD) | ||
1253 | e->selection = ECORE_X_SELECTION_CLIPBOARD; | ||
1254 | else | ||
1255 | e->selection = ECORE_X_SELECTION_OTHER; | ||
1256 | e->time = ev->time; | ||
1257 | |||
1258 | ecore_event_add(ECORE_X_EVENT_SELECTION_CLEAR, e, NULL, NULL); | ||
1259 | } | ||
1260 | |||
1261 | static void | ||
1262 | _ecore_xcb_event_handle_selection_request(xcb_generic_event_t *event) | ||
1263 | { | ||
1264 | xcb_selection_request_event_t *ev; | ||
1265 | Ecore_X_Event_Selection_Request *e; | ||
1266 | Ecore_X_Selection_Intern *sd; | ||
1267 | |||
1268 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1269 | |||
1270 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1271 | ev = (xcb_selection_request_event_t *)event; | ||
1272 | if (!(e = malloc(sizeof(Ecore_X_Event_Selection_Request)))) return; | ||
1273 | |||
1274 | e->owner = ev->owner; | ||
1275 | e->requestor = ev->requestor; | ||
1276 | e->selection = ev->selection; | ||
1277 | e->target = ev->target; | ||
1278 | e->property = ev->property; | ||
1279 | e->time = ev->time; | ||
1280 | |||
1281 | ecore_event_add(ECORE_X_EVENT_SELECTION_REQUEST, e, NULL, NULL); | ||
1282 | |||
1283 | if ((sd = _ecore_xcb_selection_get(ev->selection)) && | ||
1284 | (sd->win == ev->owner)) | ||
1285 | { | ||
1286 | Ecore_X_Selection_Intern *si; | ||
1287 | |||
1288 | si = _ecore_xcb_selection_get(ev->selection); | ||
1289 | if (si->data) | ||
1290 | { | ||
1291 | Ecore_X_Atom property = XCB_NONE, type; | ||
1292 | void *data = NULL; | ||
1293 | int len = 0, typesize = 0; | ||
1294 | |||
1295 | type = ev->target; | ||
1296 | typesize = 8; | ||
1297 | len = sd->length; | ||
1298 | |||
1299 | if (!ecore_x_selection_convert(ev->selection, ev->target, | ||
1300 | &data, &len, &type, &typesize)) | ||
1301 | property = XCB_NONE; | ||
1302 | else if (data) | ||
1303 | { | ||
1304 | ecore_x_window_prop_property_set(ev->requestor, ev->property, | ||
1305 | type, typesize, data, len); | ||
1306 | property = ev->property; | ||
1307 | free(data); | ||
1308 | } | ||
1309 | ecore_x_selection_notify_send(ev->requestor, ev->selection, | ||
1310 | ev->target, property, ev->time); | ||
1311 | } | ||
1312 | } | ||
1313 | } | ||
1314 | |||
1315 | static void | ||
1316 | _ecore_xcb_event_handle_selection_notify(xcb_generic_event_t *event) | ||
1317 | { | ||
1318 | xcb_selection_notify_event_t *ev; | ||
1319 | Ecore_X_Event_Selection_Notify *e; | ||
1320 | unsigned char *data = NULL; | ||
1321 | Ecore_X_Atom selection; | ||
1322 | int num = 0, format = 0; | ||
1323 | |||
1324 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1325 | |||
1326 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1327 | ev = (xcb_selection_notify_event_t *)event; | ||
1328 | selection = ev->selection; | ||
1329 | if (ev->target == ECORE_X_ATOM_SELECTION_TARGETS) | ||
1330 | { | ||
1331 | format = | ||
1332 | ecore_x_window_prop_property_get(ev->requestor, ev->property, | ||
1333 | XCB_ATOM_ATOM, 32, &data, &num); | ||
1334 | if (!format) return; | ||
1335 | } | ||
1336 | else | ||
1337 | { | ||
1338 | format = | ||
1339 | ecore_x_window_prop_property_get(ev->requestor, ev->property, | ||
1340 | XCB_GET_PROPERTY_TYPE_ANY, 8, | ||
1341 | &data, &num); | ||
1342 | if (!format) return; | ||
1343 | } | ||
1344 | |||
1345 | e = calloc(1, sizeof(Ecore_X_Event_Selection_Notify)); | ||
1346 | if (!e) return; | ||
1347 | e->win = ev->requestor; | ||
1348 | e->time = ev->time; | ||
1349 | e->atom = selection; | ||
1350 | e->target = _ecore_xcb_selection_target_get(ev->target); | ||
1351 | |||
1352 | if (selection == ECORE_X_ATOM_SELECTION_PRIMARY) | ||
1353 | e->selection = ECORE_X_SELECTION_PRIMARY; | ||
1354 | else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY) | ||
1355 | e->selection = ECORE_X_SELECTION_SECONDARY; | ||
1356 | else if (selection == ECORE_X_ATOM_SELECTION_XDND) | ||
1357 | e->selection = ECORE_X_SELECTION_XDND; | ||
1358 | else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD) | ||
1359 | e->selection = ECORE_X_SELECTION_CLIPBOARD; | ||
1360 | else | ||
1361 | e->selection = ECORE_X_SELECTION_OTHER; | ||
1362 | |||
1363 | e->data = _ecore_xcb_selection_parse(e->target, data, num, format); | ||
1364 | |||
1365 | ecore_event_add(ECORE_X_EVENT_SELECTION_NOTIFY, e, | ||
1366 | _ecore_xcb_event_selection_notify_free, NULL); | ||
1367 | } | ||
1368 | |||
1369 | static void | ||
1370 | _ecore_xcb_event_handle_colormap_notify(xcb_generic_event_t *event) | ||
1371 | { | ||
1372 | xcb_colormap_notify_event_t *ev; | ||
1373 | Ecore_X_Event_Window_Colormap *e; | ||
1374 | |||
1375 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1376 | ev = (xcb_colormap_notify_event_t *)event; | ||
1377 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Colormap)))) return; | ||
1378 | |||
1379 | e->win = ev->window; | ||
1380 | e->cmap = ev->colormap; | ||
1381 | if (ev->state == XCB_COLORMAP_STATE_INSTALLED) | ||
1382 | e->installed = 1; | ||
1383 | else | ||
1384 | e->installed = 0; | ||
1385 | e->time = _ecore_xcb_event_last_time; | ||
1386 | |||
1387 | ecore_event_add(ECORE_X_EVENT_WINDOW_COLORMAP, e, NULL, NULL); | ||
1388 | } | ||
1389 | |||
1390 | static void | ||
1391 | _ecore_xcb_event_handle_client_message(xcb_generic_event_t *event) | ||
1392 | { | ||
1393 | xcb_client_message_event_t *ev; | ||
1394 | |||
1395 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1396 | ev = (xcb_client_message_event_t *)event; | ||
1397 | |||
1398 | /* Special client message event handling here. need to put LOTS of if */ | ||
1399 | /* checks here and generate synthetic events per special message known */ | ||
1400 | /* otherwise generate generic client message event. this would handle*/ | ||
1401 | /* netwm, ICCCM, gnomewm, old kde and mwm hint client message protocols */ | ||
1402 | |||
1403 | if ((ev->type == ECORE_X_ATOM_WM_PROTOCOLS) && (ev->format == 32) && | ||
1404 | (ev->data.data32[0] == ECORE_X_ATOM_WM_DELETE_WINDOW)) | ||
1405 | { | ||
1406 | Ecore_X_Event_Window_Delete_Request *e; | ||
1407 | |||
1408 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Delete_Request)))) | ||
1409 | return; | ||
1410 | e->win = ev->window; | ||
1411 | e->time = _ecore_xcb_event_last_time; | ||
1412 | ecore_event_add(ECORE_X_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL); | ||
1413 | } | ||
1414 | else if ((ev->type == ECORE_X_ATOM_NET_WM_MOVERESIZE) && | ||
1415 | (ev->format == 32) && (ev->data.data32[2] < 9)) | ||
1416 | { | ||
1417 | Ecore_X_Event_Window_Move_Resize_Request *e; | ||
1418 | |||
1419 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Move_Resize_Request)))) | ||
1420 | return; | ||
1421 | e->win = ev->window; | ||
1422 | e->x = ev->data.data32[0]; | ||
1423 | e->y = ev->data.data32[1]; | ||
1424 | e->direction = ev->data.data32[2]; | ||
1425 | e->button = ev->data.data32[3]; | ||
1426 | e->source = ev->data.data32[4]; | ||
1427 | ecore_event_add(ECORE_X_EVENT_WINDOW_MOVE_RESIZE_REQUEST, e, NULL, NULL); | ||
1428 | } | ||
1429 | else if (ev->type == ECORE_X_ATOM_XDND_ENTER) | ||
1430 | { | ||
1431 | Ecore_X_Event_Xdnd_Enter *e; | ||
1432 | Ecore_X_DND_Target *target; | ||
1433 | |||
1434 | DBG("Got Xdnd Enter Event"); | ||
1435 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Enter)))) return; | ||
1436 | target = _ecore_xcb_dnd_target_get(); | ||
1437 | target->state = ECORE_X_DND_TARGET_ENTERED; | ||
1438 | target->source = ev->data.data32[0]; | ||
1439 | target->win = ev->window; | ||
1440 | target->version = (int)(ev->data.data32[1] >> 24); | ||
1441 | if (target->version > ECORE_X_DND_VERSION) | ||
1442 | { | ||
1443 | WRN("DND: Requested version %d but we only support up to %d", | ||
1444 | target->version, ECORE_X_DND_VERSION); | ||
1445 | free(e); | ||
1446 | return; | ||
1447 | } | ||
1448 | if (ev->data.data32[1] & 0x1UL) | ||
1449 | { | ||
1450 | unsigned char *data; | ||
1451 | Ecore_X_Atom *types; | ||
1452 | int num_ret = 0; | ||
1453 | |||
1454 | if (!ecore_x_window_prop_property_get(target->source, | ||
1455 | ECORE_X_ATOM_XDND_TYPE_LIST, | ||
1456 | ECORE_X_ATOM_ATOM, 32, | ||
1457 | &data, &num_ret)) | ||
1458 | { | ||
1459 | WRN("DND: Could not fetch data type list from source window"); | ||
1460 | free(e); | ||
1461 | return; | ||
1462 | } | ||
1463 | types = (Ecore_X_Atom *)data; | ||
1464 | e->types = calloc(num_ret, sizeof(char *)); | ||
1465 | if (e->types) | ||
1466 | { | ||
1467 | int i = 0; | ||
1468 | |||
1469 | for (i = 0; i < num_ret; i++) | ||
1470 | e->types[i] = ecore_x_atom_name_get(types[i]); | ||
1471 | } | ||
1472 | e->num_types = num_ret; | ||
1473 | } | ||
1474 | else | ||
1475 | { | ||
1476 | int i = 0; | ||
1477 | |||
1478 | e->types = calloc(3, sizeof(char *)); | ||
1479 | if (e->types) | ||
1480 | { | ||
1481 | while ((i < 3) && (ev->data.data32[i + 2])) | ||
1482 | { | ||
1483 | e->types[i] = | ||
1484 | ecore_x_atom_name_get(ev->data.data32[i + 2]); | ||
1485 | i++; | ||
1486 | } | ||
1487 | } | ||
1488 | e->num_types = i; | ||
1489 | } | ||
1490 | |||
1491 | e->win = target->win; | ||
1492 | e->source = target->source; | ||
1493 | ecore_event_add(ECORE_X_EVENT_XDND_ENTER, e, | ||
1494 | _ecore_xcb_event_xdnd_enter_free, NULL); | ||
1495 | } | ||
1496 | else if (ev->type == ECORE_X_ATOM_XDND_POSITION) | ||
1497 | { | ||
1498 | Ecore_X_Event_Xdnd_Position *e; | ||
1499 | Ecore_X_DND_Target *target; | ||
1500 | |||
1501 | DBG("Got Xdnd Position Event"); | ||
1502 | target = _ecore_xcb_dnd_target_get(); | ||
1503 | if ((target->source != (Ecore_X_Window)ev->data.data32[0]) || | ||
1504 | (target->win != ev->window)) return; | ||
1505 | target->pos.x = ev->data.data32[2] >> 16; | ||
1506 | target->pos.y = ev->data.data32[2] & 0xFFFFUL; | ||
1507 | target->action = ev->data.data32[4]; | ||
1508 | target->time = (target->version >= 1) ? | ||
1509 | (Ecore_X_Time)ev->data.data32[3] : XCB_CURRENT_TIME; | ||
1510 | |||
1511 | e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Position)); | ||
1512 | if (!e) return; | ||
1513 | e->win = target->win; | ||
1514 | e->source = target->source; | ||
1515 | e->position.x = target->pos.x; | ||
1516 | e->position.y = target->pos.y; | ||
1517 | e->action = target->action; | ||
1518 | ecore_event_add(ECORE_X_EVENT_XDND_POSITION, e, NULL, NULL); | ||
1519 | } | ||
1520 | else if (ev->type == ECORE_X_ATOM_XDND_STATUS) | ||
1521 | { | ||
1522 | Ecore_X_Event_Xdnd_Status *e; | ||
1523 | Ecore_X_DND_Source *source; | ||
1524 | |||
1525 | DBG("Got Xdnd Status Event"); | ||
1526 | source = _ecore_xcb_dnd_source_get(); | ||
1527 | if ((source->win != ev->window) || | ||
1528 | (source->dest != (Ecore_X_Window)ev->data.data32[0])) | ||
1529 | return; | ||
1530 | |||
1531 | source->await_status = 0; | ||
1532 | source->will_accept = ev->data.data32[1] & 0x1UL; | ||
1533 | source->suppress = (ev->data.data32[1] & 0x2UL) ? 0 : 1; | ||
1534 | source->rectangle.x = ev->data.data32[2] >> 16; | ||
1535 | source->rectangle.y = ev->data.data32[2] & 0xFFFFUL; | ||
1536 | source->rectangle.width = ev->data.data32[3] >> 16; | ||
1537 | source->rectangle.height = ev->data.data32[3] & 0xFFFFUL; | ||
1538 | source->accepted_action = ev->data.data32[4]; | ||
1539 | |||
1540 | e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Status)); | ||
1541 | if (!e) return; | ||
1542 | e->win = source->win; | ||
1543 | e->target = source->dest; | ||
1544 | e->will_accept = source->will_accept; | ||
1545 | e->rectangle.x = source->rectangle.x; | ||
1546 | e->rectangle.y = source->rectangle.y; | ||
1547 | e->rectangle.width = source->rectangle.width; | ||
1548 | e->rectangle.height = source->rectangle.height; | ||
1549 | e->action = source->accepted_action; | ||
1550 | |||
1551 | ecore_event_add(ECORE_X_EVENT_XDND_STATUS, e, NULL, NULL); | ||
1552 | } | ||
1553 | else if (ev->type == ECORE_X_ATOM_XDND_LEAVE) | ||
1554 | { | ||
1555 | Ecore_X_Event_Xdnd_Leave *e; | ||
1556 | Ecore_X_DND_Target *target; | ||
1557 | |||
1558 | DBG("Got Xdnd Leave Event"); | ||
1559 | target = _ecore_xcb_dnd_target_get(); | ||
1560 | if ((target->source != (Ecore_X_Window)ev->data.data32[0]) || | ||
1561 | (target->win != ev->window)) | ||
1562 | return; | ||
1563 | target->state = ECORE_X_DND_TARGET_IDLE; | ||
1564 | e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Leave)); | ||
1565 | if (!e) return; | ||
1566 | e->win = ev->window; | ||
1567 | e->source = (Ecore_X_Window)ev->data.data32[0]; | ||
1568 | ecore_event_add(ECORE_X_EVENT_XDND_LEAVE, e, NULL, NULL); | ||
1569 | } | ||
1570 | else if (ev->type == ECORE_X_ATOM_XDND_DROP) | ||
1571 | { | ||
1572 | Ecore_X_Event_Xdnd_Drop *e; | ||
1573 | Ecore_X_DND_Target *target; | ||
1574 | |||
1575 | DBG("Got Xdnd Drop Event"); | ||
1576 | target = _ecore_xcb_dnd_target_get(); | ||
1577 | if ((target->source != (Ecore_X_Window)ev->data.data32[0]) || | ||
1578 | (target->win != ev->window)) | ||
1579 | return; | ||
1580 | target->time = (target->version >= 1) ? | ||
1581 | (Ecore_X_Time)ev->data.data32[2] : _ecore_xcb_event_last_time; | ||
1582 | |||
1583 | e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Drop)); | ||
1584 | if (!e) return; | ||
1585 | e->win = target->win; | ||
1586 | e->source = target->source; | ||
1587 | e->action = target->action; | ||
1588 | e->position.x = target->pos.x; | ||
1589 | e->position.y = target->pos.y; | ||
1590 | ecore_event_add(ECORE_X_EVENT_XDND_DROP, e, NULL, NULL); | ||
1591 | } | ||
1592 | else if (ev->type == ECORE_X_ATOM_XDND_FINISHED) | ||
1593 | { | ||
1594 | Ecore_X_Event_Xdnd_Finished *e; | ||
1595 | Ecore_X_DND_Source *source; | ||
1596 | Eina_Bool completed = EINA_TRUE; | ||
1597 | |||
1598 | DBG("Got Xdnd Finished Event"); | ||
1599 | source = _ecore_xcb_dnd_source_get(); | ||
1600 | if ((source->win != ev->window) || | ||
1601 | (source->dest != (Ecore_X_Window)ev->data.data32[0])) | ||
1602 | return; | ||
1603 | if ((source->version < 5) || (ev->data.data32[1] & 0x1UL)) | ||
1604 | { | ||
1605 | ecore_x_selection_xdnd_clear(); | ||
1606 | source->state = ECORE_X_DND_SOURCE_IDLE; | ||
1607 | } | ||
1608 | else if (source->version >= 5) | ||
1609 | { | ||
1610 | completed = EINA_FALSE; | ||
1611 | source->state = ECORE_X_DND_SOURCE_CONVERTING; | ||
1612 | /* FIXME: Probably need to add a timer to switch back to idle | ||
1613 | * and discard the selection data */ | ||
1614 | } | ||
1615 | |||
1616 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Xdnd_Finished)))) | ||
1617 | return; | ||
1618 | e->win = source->win; | ||
1619 | e->target = source->dest; | ||
1620 | e->completed = completed; | ||
1621 | if (source->version >= 5) | ||
1622 | { | ||
1623 | source->accepted_action = ev->data.data32[2]; | ||
1624 | e->action = source->accepted_action; | ||
1625 | } | ||
1626 | else | ||
1627 | { | ||
1628 | source->accepted_action = 0; | ||
1629 | e->action = source->action; | ||
1630 | } | ||
1631 | ecore_event_add(ECORE_X_EVENT_XDND_FINISHED, e, NULL, NULL); | ||
1632 | } | ||
1633 | else if (ev->type == ECORE_X_ATOM_NET_WM_STATE) | ||
1634 | { | ||
1635 | Ecore_X_Event_Window_State_Request *e; | ||
1636 | |||
1637 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_State_Request)))) | ||
1638 | return; | ||
1639 | e->win = ev->window; | ||
1640 | if (ev->data.data32[0] == 0) | ||
1641 | e->action = ECORE_X_WINDOW_STATE_ACTION_REMOVE; | ||
1642 | else if (ev->data.data32[0] == 1) | ||
1643 | e->action = ECORE_X_WINDOW_STATE_ACTION_ADD; | ||
1644 | else if (ev->data.data32[0] == 2) | ||
1645 | e->action = ECORE_X_WINDOW_STATE_ACTION_TOGGLE; | ||
1646 | else | ||
1647 | { | ||
1648 | free(e); | ||
1649 | return; | ||
1650 | } | ||
1651 | e->state[0] = _ecore_xcb_netwm_window_state_get(ev->data.data32[1]); | ||
1652 | if (e->state[0] == ECORE_X_WINDOW_STATE_UNKNOWN) | ||
1653 | { | ||
1654 | /* FIXME */ | ||
1655 | } | ||
1656 | e->state[1] = _ecore_xcb_netwm_window_state_get(ev->data.data32[2]); | ||
1657 | if (e->state[1] == ECORE_X_WINDOW_STATE_UNKNOWN) | ||
1658 | { | ||
1659 | /* FIXME */ | ||
1660 | } | ||
1661 | e->source = ev->data.data32[3]; | ||
1662 | ecore_event_add(ECORE_X_EVENT_WINDOW_STATE_REQUEST, e, NULL, NULL); | ||
1663 | } | ||
1664 | #ifdef OLD_XCB_VERSION | ||
1665 | else if ((ev->type == ECORE_X_ATOM_WM_CHANGE_STATE) && | ||
1666 | (ev->format == 32) && (ev->data.data32[0] == XCB_WM_STATE_ICONIC)) | ||
1667 | #else | ||
1668 | else if ((ev->type == ECORE_X_ATOM_WM_CHANGE_STATE) && (ev->format == 32) && | ||
1669 | (ev->data.data32[0] == XCB_ICCCM_WM_STATE_ICONIC)) | ||
1670 | #endif | ||
1671 | { | ||
1672 | Ecore_X_Event_Window_State_Request *e; | ||
1673 | |||
1674 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_State_Request)))) | ||
1675 | return; | ||
1676 | e->win = ev->window; | ||
1677 | e->action = ECORE_X_WINDOW_STATE_ACTION_ADD; | ||
1678 | e->state[0] = ECORE_X_WINDOW_STATE_ICONIFIED; | ||
1679 | ecore_event_add(ECORE_X_EVENT_WINDOW_STATE_REQUEST, e, NULL, NULL); | ||
1680 | } | ||
1681 | else if ((ev->type == ECORE_X_ATOM_NET_WM_DESKTOP) && (ev->format == 32)) | ||
1682 | { | ||
1683 | Ecore_X_Event_Desktop_Change *e; | ||
1684 | |||
1685 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Desktop_Change)))) | ||
1686 | return; | ||
1687 | e->win = ev->window; | ||
1688 | e->desk = ev->data.data32[0]; | ||
1689 | e->source = ev->data.data32[1]; | ||
1690 | ecore_event_add(ECORE_X_EVENT_DESKTOP_CHANGE, e, NULL, NULL); | ||
1691 | } | ||
1692 | else if (ev->type == ECORE_X_ATOM_NET_REQUEST_FRAME_EXTENTS) | ||
1693 | { | ||
1694 | Ecore_X_Event_Frame_Extents_Request *e; | ||
1695 | |||
1696 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Frame_Extents_Request)))) | ||
1697 | return; | ||
1698 | e->win = ev->window; | ||
1699 | ecore_event_add(ECORE_X_EVENT_FRAME_EXTENTS_REQUEST, e, NULL, NULL); | ||
1700 | } | ||
1701 | else if ((ev->type == ECORE_X_ATOM_WM_PROTOCOLS) && | ||
1702 | ((Ecore_X_Atom)ev->data.data32[0] == ECORE_X_ATOM_NET_WM_PING) && | ||
1703 | (ev->format == 32)) | ||
1704 | { | ||
1705 | Ecore_X_Event_Ping *e; | ||
1706 | Ecore_X_Window root = 0; | ||
1707 | int count = 0; | ||
1708 | |||
1709 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Ping)))) return; | ||
1710 | e->win = ev->window; | ||
1711 | e->time = ev->data.data32[1]; | ||
1712 | e->event_win = ev->data.data32[2]; | ||
1713 | ecore_event_add(ECORE_X_EVENT_PING, e, NULL, NULL); | ||
1714 | |||
1715 | CHECK_XCB_CONN; | ||
1716 | |||
1717 | count = xcb_setup_roots_length(xcb_get_setup(_ecore_xcb_conn)); | ||
1718 | if (count > 1) | ||
1719 | root = ecore_x_window_root_get(e->win); | ||
1720 | else | ||
1721 | root = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
1722 | |||
1723 | if (ev->window != root) | ||
1724 | { | ||
1725 | ev->window = root; | ||
1726 | xcb_send_event(_ecore_xcb_conn, 0, root, | ||
1727 | (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | | ||
1728 | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY), | ||
1729 | (const char *)&ev); | ||
1730 | // ecore_x_flush(); | ||
1731 | } | ||
1732 | } | ||
1733 | else if ((ev->type == ECORE_X_ATOM_NET_STARTUP_INFO_BEGIN) && | ||
1734 | (ev->format == 8)) | ||
1735 | { | ||
1736 | _ecore_xcb_netwm_startup_info_begin(ev->window, ev->data.data8[0]); | ||
1737 | } | ||
1738 | else if ((ev->type == ECORE_X_ATOM_NET_STARTUP_INFO) && (ev->format == 8)) | ||
1739 | { | ||
1740 | _ecore_xcb_netwm_startup_info(ev->window, ev->data.data8[0]); | ||
1741 | } | ||
1742 | else if ((ev->type == 27777) && (ev->data.data32[0] == 0x7162534) && | ||
1743 | (ev->format == 32)) // && (ev->window = _private_window)) | ||
1744 | { | ||
1745 | if (ev->data.data32[1] == 0x10000001) | ||
1746 | _ecore_xcb_window_button_grab_remove(ev->data.data32[2]); | ||
1747 | else if (ev->data.data32[1] == 0x10000002) | ||
1748 | _ecore_xcb_window_key_grab_remove(ev->data.data32[2]); | ||
1749 | } | ||
1750 | else | ||
1751 | { | ||
1752 | Ecore_X_Event_Client_Message *e; | ||
1753 | int i = 0; | ||
1754 | |||
1755 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Client_Message)))) | ||
1756 | return; | ||
1757 | |||
1758 | e->win = ev->window; | ||
1759 | e->message_type = ev->type; | ||
1760 | e->format = ev->format; | ||
1761 | for (i = 0; i < 5; i++) | ||
1762 | e->data.l[i] = ev->data.data32[i]; | ||
1763 | ecore_event_add(ECORE_X_EVENT_CLIENT_MESSAGE, e, NULL, NULL); | ||
1764 | } | ||
1765 | } | ||
1766 | |||
1767 | static void | ||
1768 | _ecore_xcb_event_handle_mapping_notify(xcb_generic_event_t *event) | ||
1769 | { | ||
1770 | xcb_mapping_notify_event_t *ev; | ||
1771 | Ecore_X_Event_Mapping_Change *e; | ||
1772 | |||
1773 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1774 | |||
1775 | ev = (xcb_mapping_notify_event_t *)event; | ||
1776 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Mapping_Change)))) return; | ||
1777 | |||
1778 | _ecore_xcb_keymap_refresh(ev); | ||
1779 | _ecore_xcb_modifiers_get(); | ||
1780 | |||
1781 | switch (ev->request) | ||
1782 | { | ||
1783 | case XCB_MAPPING_MODIFIER: | ||
1784 | e->type = ECORE_X_MAPPING_MODIFIER; | ||
1785 | break; | ||
1786 | |||
1787 | case XCB_MAPPING_KEYBOARD: | ||
1788 | e->type = ECORE_X_MAPPING_KEYBOARD; | ||
1789 | break; | ||
1790 | |||
1791 | case XCB_MAPPING_POINTER: | ||
1792 | default: | ||
1793 | e->type = ECORE_X_MAPPING_MOUSE; | ||
1794 | break; | ||
1795 | } | ||
1796 | e->keycode = ev->first_keycode; | ||
1797 | e->num = ev->count; | ||
1798 | |||
1799 | ecore_event_add(ECORE_X_EVENT_MAPPING_CHANGE, e, NULL, NULL); | ||
1800 | } | ||
1801 | |||
1802 | static void | ||
1803 | _ecore_xcb_event_handle_damage_notify(xcb_generic_event_t *event) | ||
1804 | { | ||
1805 | #ifdef ECORE_XCB_DAMAGE | ||
1806 | xcb_damage_notify_event_t *ev; | ||
1807 | Ecore_X_Event_Damage *e; | ||
1808 | #endif | ||
1809 | |||
1810 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1811 | |||
1812 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1813 | #ifdef ECORE_XCB_DAMAGE | ||
1814 | ev = (xcb_damage_notify_event_t *)event; | ||
1815 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Damage)))) return; | ||
1816 | |||
1817 | e->level = ev->level; | ||
1818 | e->drawable = ev->drawable; | ||
1819 | e->damage = ev->damage; | ||
1820 | e->time = ev->timestamp; | ||
1821 | e->area.x = ev->area.x; | ||
1822 | e->area.y = ev->area.y; | ||
1823 | e->area.width = ev->area.width; | ||
1824 | e->area.height = ev->area.height; | ||
1825 | e->geometry.x = ev->geometry.x; | ||
1826 | e->geometry.y = ev->geometry.y; | ||
1827 | e->geometry.width = ev->geometry.width; | ||
1828 | e->geometry.height = ev->geometry.height; | ||
1829 | |||
1830 | ecore_event_add(ECORE_X_EVENT_DAMAGE_NOTIFY, e, NULL, NULL); | ||
1831 | #endif | ||
1832 | } | ||
1833 | |||
1834 | static void | ||
1835 | _ecore_xcb_event_handle_randr_change(xcb_generic_event_t *event) | ||
1836 | { | ||
1837 | #ifdef ECORE_XCB_RANDR | ||
1838 | xcb_randr_screen_change_notify_event_t *ev; | ||
1839 | Ecore_X_Event_Screen_Change *e; | ||
1840 | #endif | ||
1841 | |||
1842 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1843 | #ifdef ECORE_XCB_RANDR | ||
1844 | ev = (xcb_randr_screen_change_notify_event_t *)event; | ||
1845 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Screen_Change)))) return; | ||
1846 | |||
1847 | e->win = ev->request_window; | ||
1848 | e->root = ev->root; | ||
1849 | e->size.width = ev->width; | ||
1850 | e->size.height = ev->height; | ||
1851 | e->time = ev->timestamp; | ||
1852 | e->config_time = ev->config_timestamp; | ||
1853 | e->size.width_mm = ev->mwidth; | ||
1854 | e->size.height_mm = ev->mheight; | ||
1855 | e->orientation = ev->rotation; | ||
1856 | e->subpixel_order = ev->subpixel_order; | ||
1857 | |||
1858 | ecore_event_add(ECORE_X_EVENT_SCREEN_CHANGE, e, NULL, NULL); | ||
1859 | #endif | ||
1860 | } | ||
1861 | |||
1862 | static void | ||
1863 | _ecore_xcb_event_handle_randr_notify(xcb_generic_event_t *event) | ||
1864 | { | ||
1865 | #ifdef ECORE_XCB_RANDR | ||
1866 | xcb_randr_notify_event_t *ev; | ||
1867 | #endif | ||
1868 | |||
1869 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1870 | #ifdef ECORE_XCB_RANDR | ||
1871 | ev = (xcb_randr_notify_event_t *)event; | ||
1872 | switch (ev->subCode) | ||
1873 | { | ||
1874 | case XCB_RANDR_NOTIFY_CRTC_CHANGE: | ||
1875 | _ecore_xcb_event_handle_randr_crtc_change(event); | ||
1876 | break; | ||
1877 | |||
1878 | case XCB_RANDR_NOTIFY_OUTPUT_CHANGE: | ||
1879 | _ecore_xcb_event_handle_randr_output_change(event); | ||
1880 | break; | ||
1881 | |||
1882 | case XCB_RANDR_NOTIFY_OUTPUT_PROPERTY: | ||
1883 | _ecore_xcb_event_handle_randr_output_property_change(event); | ||
1884 | break; | ||
1885 | |||
1886 | default: | ||
1887 | break; | ||
1888 | } | ||
1889 | #endif | ||
1890 | } | ||
1891 | |||
1892 | static void | ||
1893 | _ecore_xcb_event_handle_randr_crtc_change(xcb_generic_event_t *event) | ||
1894 | { | ||
1895 | #ifdef ECORE_XCB_RANDR | ||
1896 | xcb_randr_notify_event_t *ev; | ||
1897 | Ecore_X_Event_Randr_Crtc_Change *e; | ||
1898 | #endif | ||
1899 | |||
1900 | #ifdef ECORE_XCB_RANDR | ||
1901 | ev = (xcb_randr_notify_event_t *)event; | ||
1902 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Randr_Crtc_Change)))) | ||
1903 | return; | ||
1904 | |||
1905 | e->win = ev->u.cc.window; | ||
1906 | e->crtc = ev->u.cc.crtc; | ||
1907 | e->mode = ev->u.cc.mode; | ||
1908 | e->orientation = ev->u.cc.rotation; | ||
1909 | e->geo.x = ev->u.cc.x; | ||
1910 | e->geo.y = ev->u.cc.y; | ||
1911 | e->geo.w = ev->u.cc.width; | ||
1912 | e->geo.h = ev->u.cc.height; | ||
1913 | |||
1914 | ecore_event_add(ECORE_X_EVENT_RANDR_CRTC_CHANGE, e, NULL, NULL); | ||
1915 | #endif | ||
1916 | } | ||
1917 | |||
1918 | static void | ||
1919 | _ecore_xcb_event_handle_randr_output_change(xcb_generic_event_t *event) | ||
1920 | { | ||
1921 | #ifdef ECORE_XCB_RANDR | ||
1922 | xcb_randr_notify_event_t *ev; | ||
1923 | Ecore_X_Event_Randr_Output_Change *e; | ||
1924 | #endif | ||
1925 | |||
1926 | #ifdef ECORE_XCB_RANDR | ||
1927 | ev = (xcb_randr_notify_event_t *)event; | ||
1928 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Randr_Crtc_Change)))) | ||
1929 | return; | ||
1930 | |||
1931 | e->win = ev->u.oc.window; | ||
1932 | e->output = ev->u.oc.output; | ||
1933 | e->crtc = ev->u.oc.crtc; | ||
1934 | e->mode = ev->u.oc.mode; | ||
1935 | e->orientation = ev->u.oc.rotation; | ||
1936 | e->connection = ev->u.oc.connection; | ||
1937 | e->subpixel_order = ev->u.oc.subpixel_order; | ||
1938 | |||
1939 | ecore_event_add(ECORE_X_EVENT_RANDR_OUTPUT_CHANGE, e, NULL, NULL); | ||
1940 | #endif | ||
1941 | } | ||
1942 | |||
1943 | static void | ||
1944 | _ecore_xcb_event_handle_randr_output_property_change(xcb_generic_event_t *event) | ||
1945 | { | ||
1946 | #ifdef ECORE_XCB_RANDR | ||
1947 | xcb_randr_notify_event_t *ev; | ||
1948 | Ecore_X_Event_Randr_Output_Property_Notify *e; | ||
1949 | #endif | ||
1950 | |||
1951 | #ifdef ECORE_XCB_RANDR | ||
1952 | ev = (xcb_randr_notify_event_t *)event; | ||
1953 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Randr_Output_Property_Notify)))) | ||
1954 | return; | ||
1955 | |||
1956 | e->win = ev->u.op.window; | ||
1957 | e->output = ev->u.op.output; | ||
1958 | e->property = ev->u.op.atom; | ||
1959 | e->time = ev->u.op.timestamp; | ||
1960 | if (ev->u.op.status == XCB_PROPERTY_NEW_VALUE) | ||
1961 | e->state = ECORE_X_RANDR_PROPERTY_CHANGE_ADD; | ||
1962 | else | ||
1963 | e->state = ECORE_X_RANDR_PROPERTY_CHANGE_DEL; | ||
1964 | |||
1965 | ecore_event_add(ECORE_X_EVENT_RANDR_OUTPUT_PROPERTY_NOTIFY, e, NULL, NULL); | ||
1966 | #endif | ||
1967 | } | ||
1968 | |||
1969 | static void | ||
1970 | _ecore_xcb_event_handle_screensaver_notify(xcb_generic_event_t *event) | ||
1971 | { | ||
1972 | #ifdef ECORE_XCB_SCREENSAVER | ||
1973 | xcb_screensaver_notify_event_t *ev; | ||
1974 | Ecore_X_Event_Screensaver_Notify *e; | ||
1975 | #endif | ||
1976 | |||
1977 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
1978 | #ifdef ECORE_XCB_SCREENSAVER | ||
1979 | ev = (xcb_screensaver_notify_event_t *)event; | ||
1980 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Screensaver_Notify)))) return; | ||
1981 | |||
1982 | e->win = ev->window; | ||
1983 | e->on = EINA_FALSE; | ||
1984 | if (ev->state == XCB_SCREENSAVER_STATE_ON) e->on = EINA_TRUE; | ||
1985 | e->time = ev->time; | ||
1986 | |||
1987 | ecore_event_add(ECORE_X_EVENT_SCREENSAVER_NOTIFY, e, NULL, NULL); | ||
1988 | #endif | ||
1989 | } | ||
1990 | |||
1991 | #ifdef ECORE_XCB_XGESTURE | ||
1992 | static void | ||
1993 | _ecore_xcb_event_handle_gesture_notify_flick(xcb_generic_event_t *event) | ||
1994 | { | ||
1995 | xcb_gesture_notify_flick_event_t *ev; | ||
1996 | Ecore_X_Event_Gesture_Notify_Flick *e; | ||
1997 | |||
1998 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1999 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
2000 | fprintf(stderr, "[ECORE_XCB][%s]...\n", __FUNCTION__); | ||
2001 | |||
2002 | ev = (xcb_gesture_notify_flick_event_t *)event; | ||
2003 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Flick)))) return; | ||
2004 | |||
2005 | e->win = ev->window; | ||
2006 | e->time = ev->time; | ||
2007 | e->subtype = ev->kind; | ||
2008 | e->num_fingers = ev->num_finger; | ||
2009 | e->distance = ev->distance; | ||
2010 | e->duration = ev->duration; | ||
2011 | e->direction = ev->direction; | ||
2012 | e->angle = XFixedToDouble(ev->angle); | ||
2013 | |||
2014 | ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_FLICK, e, NULL, NULL); | ||
2015 | } | ||
2016 | |||
2017 | static void | ||
2018 | _ecore_xcb_event_handle_gesture_notify_pan(xcb_generic_event_t *event) | ||
2019 | { | ||
2020 | xcb_gesture_notify_pan_event_t *ev; | ||
2021 | Ecore_X_Event_Gesture_Notify_Pan *e; | ||
2022 | |||
2023 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2024 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
2025 | fprintf(stderr, "[ECORE_XCB][%s]...\n", __FUNCTION__); | ||
2026 | |||
2027 | ev = (xcb_gesture_notify_pan_event_t *)event; | ||
2028 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Pan)))) return; | ||
2029 | |||
2030 | e->win = ev->window; | ||
2031 | e->time = ev->time; | ||
2032 | e->subtype = ev->kind; | ||
2033 | e->num_fingers = ev->num_finger; | ||
2034 | e->dx = ev->dx; | ||
2035 | e->dy = ev->dy; | ||
2036 | e->distance = ev->distance; | ||
2037 | e->duration = ev->duration; | ||
2038 | e->direction = ev->direction; | ||
2039 | |||
2040 | ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_PAN, e, NULL, NULL); | ||
2041 | } | ||
2042 | |||
2043 | static void | ||
2044 | _ecore_xcb_event_handle_gesture_notify_pinchrotation(xcb_generic_event_t *event) | ||
2045 | { | ||
2046 | xcb_gesture_notify_pinch_rotation_event_t *ev; | ||
2047 | Ecore_X_Event_Gesture_Notify_PinchRotation *e; | ||
2048 | |||
2049 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2050 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
2051 | fprintf(stderr, "[ECORE_XCB][%s]...\n", __FUNCTION__); | ||
2052 | |||
2053 | ev = (xcb_gesture_notify_pinch_rotation_event_t *)event; | ||
2054 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_PinchRotation)))) return; | ||
2055 | |||
2056 | e->win = ev->window; | ||
2057 | e->time = ev->time; | ||
2058 | e->subtype = ev->kind; | ||
2059 | e->num_fingers = ev->num_finger; | ||
2060 | e->distance = ev->distance; | ||
2061 | e->cx = ev->cx; | ||
2062 | e->cy = ev->cy; | ||
2063 | e->zoom = XFixedToDouble(ev->zoom); | ||
2064 | e->angle = XFixedToDouble(ev->angle); | ||
2065 | |||
2066 | ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_PINCHROTATION, e, NULL, NULL); | ||
2067 | } | ||
2068 | |||
2069 | static void | ||
2070 | _ecore_xcb_event_handle_gesture_notify_tap(xcb_generic_event_t *event) | ||
2071 | { | ||
2072 | xcb_gesture_notify_tap_event_t *ev; | ||
2073 | Ecore_X_Event_Gesture_Notify_Tap *e; | ||
2074 | |||
2075 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2076 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
2077 | fprintf(stderr, "[ECORE_XCB][%s]...\n", __FUNCTION__); | ||
2078 | |||
2079 | ev = (xcb_gesture_notify_tap_event_t *)event; | ||
2080 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Tap)))) return; | ||
2081 | |||
2082 | e->win = ev->window; | ||
2083 | e->time = ev->time; | ||
2084 | e->subtype = ev->kind; | ||
2085 | e->num_fingers = ev->num_finger; | ||
2086 | e->cx = ev->cx; | ||
2087 | e->cy = ev->cy; | ||
2088 | e->tap_repeat = ev->tap_repeat; | ||
2089 | e->interval = ev->interval; | ||
2090 | |||
2091 | ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_TAP, e, NULL, NULL); | ||
2092 | } | ||
2093 | |||
2094 | static void | ||
2095 | _ecore_xcb_event_handle_gesture_notify_tapnhold(xcb_generic_event_t *event) | ||
2096 | { | ||
2097 | xcb_gesture_notify_tap_n_hold_event_t *ev; | ||
2098 | Ecore_X_Event_Gesture_Notify_TapNHold *e; | ||
2099 | |||
2100 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2101 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
2102 | fprintf(stderr, "[ECORE_XCB][%s]...\n", __FUNCTION__); | ||
2103 | |||
2104 | ev = (xcb_gesture_notify_tap_n_hold_event_t *)event; | ||
2105 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_TapNHold)))) return; | ||
2106 | |||
2107 | e->win = ev->window; | ||
2108 | e->time = ev->time; | ||
2109 | e->subtype = ev->kind; | ||
2110 | e->num_fingers = ev->num_finger; | ||
2111 | e->cx = ev->cx; | ||
2112 | e->cy = ev->cy; | ||
2113 | e->interval = ev->interval; | ||
2114 | e->hold_time = ev->holdtime; | ||
2115 | |||
2116 | ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_TAPNHOLD, e, NULL, NULL); | ||
2117 | } | ||
2118 | |||
2119 | static void | ||
2120 | _ecore_xcb_event_handle_gesture_notify_hold(xcb_generic_event_t *event) | ||
2121 | { | ||
2122 | xcb_gesture_notify_hold_event_t *ev; | ||
2123 | Ecore_X_Event_Gesture_Notify_Hold *e; | ||
2124 | |||
2125 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2126 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
2127 | fprintf(stderr, "[ECORE_XCB][%s]...\n", __FUNCTION__); | ||
2128 | |||
2129 | ev = (xcb_gesture_notify_hold_event_t *)event; | ||
2130 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Hold)))) return; | ||
2131 | |||
2132 | e->win = ev->window; | ||
2133 | e->time = ev->time; | ||
2134 | e->subtype = ev->kind; | ||
2135 | e->num_fingers = ev->num_finger; | ||
2136 | e->cx = ev->cx; | ||
2137 | e->cy = ev->cy; | ||
2138 | e->hold_time = ev->holdtime; | ||
2139 | |||
2140 | ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_HOLD, e, NULL, NULL); | ||
2141 | } | ||
2142 | |||
2143 | static void | ||
2144 | _ecore_xcb_event_handle_gesture_notify_group(xcb_generic_event_t *event) | ||
2145 | { | ||
2146 | xcb_gesture_notify_group_event_t *ev; | ||
2147 | Ecore_X_Event_Gesture_Notify_Group *e; | ||
2148 | |||
2149 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2150 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
2151 | fprintf(stderr, "[ECORE_XCB][%s]...\n", __FUNCTION__); | ||
2152 | |||
2153 | ev = (xcb_gesture_notify_group_event_t *)event; | ||
2154 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Gesture_Notify_Group)))) return; | ||
2155 | |||
2156 | e->win = ev->window; | ||
2157 | e->time = ev->time; | ||
2158 | e->subtype = ev->kind; | ||
2159 | e->num_groups = ev->num_group; | ||
2160 | e->group_id = ev->groupid; | ||
2161 | |||
2162 | ecore_event_add(ECORE_X_EVENT_GESTURE_NOTIFY_GROUP, e, NULL, NULL); | ||
2163 | } | ||
2164 | #endif | ||
2165 | |||
2166 | #ifdef ECORE_XCB_SHAPE | ||
2167 | static void | ||
2168 | _ecore_xcb_event_handle_shape_change(xcb_generic_event_t *event) | ||
2169 | { | ||
2170 | xcb_shape_notify_event_t *ev; | ||
2171 | Ecore_X_Event_Window_Shape *e; | ||
2172 | |||
2173 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
2174 | ev = (xcb_shape_notify_event_t *)event; | ||
2175 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Window_Shape)))) return; | ||
2176 | |||
2177 | e->win = ev->affected_window; | ||
2178 | e->time = ev->server_time; | ||
2179 | switch (ev->shape_kind) | ||
2180 | { | ||
2181 | case XCB_SHAPE_SK_BOUNDING: | ||
2182 | e->type = ECORE_X_SHAPE_BOUNDING; | ||
2183 | break; | ||
2184 | |||
2185 | case XCB_SHAPE_SK_CLIP: | ||
2186 | e->type = ECORE_X_SHAPE_CLIP; | ||
2187 | break; | ||
2188 | |||
2189 | case XCB_SHAPE_SK_INPUT: | ||
2190 | e->type = ECORE_X_SHAPE_INPUT; | ||
2191 | break; | ||
2192 | |||
2193 | default: | ||
2194 | break; | ||
2195 | } | ||
2196 | e->x = ev->extents_x; | ||
2197 | e->y = ev->extents_y; | ||
2198 | e->w = ev->extents_width; | ||
2199 | e->h = ev->extents_height; | ||
2200 | e->shaped = ev->shaped; | ||
2201 | |||
2202 | ecore_event_add(ECORE_X_EVENT_WINDOW_SHAPE, e, NULL, NULL); | ||
2203 | } | ||
2204 | |||
2205 | #endif | ||
2206 | |||
2207 | static void | ||
2208 | _ecore_xcb_event_handle_sync_counter(xcb_generic_event_t *event) | ||
2209 | { | ||
2210 | #ifdef ECORE_XCB_SYNC | ||
2211 | xcb_sync_counter_notify_event_t *ev; | ||
2212 | Ecore_X_Event_Sync_Counter *e; | ||
2213 | #endif | ||
2214 | |||
2215 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
2216 | |||
2217 | #ifdef ECORE_XCB_SYNC | ||
2218 | ev = (xcb_sync_counter_notify_event_t *)event; | ||
2219 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Sync_Counter)))) return; | ||
2220 | |||
2221 | e->time = ev->timestamp; | ||
2222 | |||
2223 | ecore_event_add(ECORE_X_EVENT_SYNC_COUNTER, e, NULL, NULL); | ||
2224 | #endif | ||
2225 | } | ||
2226 | |||
2227 | static void | ||
2228 | _ecore_xcb_event_handle_sync_alarm(xcb_generic_event_t *event) | ||
2229 | { | ||
2230 | #ifdef ECORE_XCB_SYNC | ||
2231 | xcb_sync_alarm_notify_event_t *ev; | ||
2232 | Ecore_X_Event_Sync_Alarm *e; | ||
2233 | #endif | ||
2234 | |||
2235 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
2236 | #ifdef ECORE_XCB_SYNC | ||
2237 | ev = (xcb_sync_alarm_notify_event_t *)event; | ||
2238 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Sync_Alarm)))) return; | ||
2239 | |||
2240 | e->time = ev->timestamp; | ||
2241 | e->alarm = ev->alarm; | ||
2242 | |||
2243 | ecore_event_add(ECORE_X_EVENT_SYNC_ALARM, e, NULL, NULL); | ||
2244 | #endif | ||
2245 | } | ||
2246 | |||
2247 | static void | ||
2248 | _ecore_xcb_event_handle_xfixes_selection_notify(xcb_generic_event_t *event) | ||
2249 | { | ||
2250 | #ifdef ECORE_XCB_XFIXES | ||
2251 | Ecore_X_Event_Fixes_Selection_Notify *e; | ||
2252 | Ecore_X_Atom sel; | ||
2253 | xcb_xfixes_selection_notify_event_t *ev; | ||
2254 | #endif | ||
2255 | |||
2256 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
2257 | #ifdef ECORE_XCB_XFIXES | ||
2258 | ev = (xcb_xfixes_selection_notify_event_t *)event; | ||
2259 | |||
2260 | if (!(e = calloc(1, sizeof(*e)))) return; | ||
2261 | |||
2262 | e->win = ev->window; | ||
2263 | e->owner = ev->owner; | ||
2264 | e->time = ev->timestamp; | ||
2265 | e->selection_time = ev->selection_timestamp; | ||
2266 | e->atom = sel = ev->selection; | ||
2267 | if (sel == ECORE_X_ATOM_SELECTION_PRIMARY) | ||
2268 | e->selection = ECORE_X_SELECTION_PRIMARY; | ||
2269 | else if (sel == ECORE_X_ATOM_SELECTION_SECONDARY) | ||
2270 | e->selection = ECORE_X_SELECTION_SECONDARY; | ||
2271 | else if (sel == ECORE_X_ATOM_SELECTION_CLIPBOARD) | ||
2272 | e->selection = ECORE_X_SELECTION_CLIPBOARD; | ||
2273 | else | ||
2274 | e->selection = ECORE_X_SELECTION_OTHER; | ||
2275 | e->reason = ev->subtype; | ||
2276 | |||
2277 | ecore_event_add(ECORE_X_EVENT_FIXES_SELECTION_NOTIFY, e, NULL, NULL); | ||
2278 | #endif | ||
2279 | } | ||
2280 | |||
2281 | static void | ||
2282 | _ecore_xcb_event_handle_xfixes_cursor_notify(xcb_generic_event_t *event __UNUSED__) | ||
2283 | { | ||
2284 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2285 | // FIXME: TBD | ||
2286 | } | ||
2287 | |||
2288 | static void | ||
2289 | _ecore_xcb_event_handle_generic_event(xcb_generic_event_t *event) | ||
2290 | { | ||
2291 | xcb_ge_event_t *ev; | ||
2292 | Ecore_X_Event_Generic *e; | ||
2293 | |||
2294 | ev = (xcb_ge_event_t *)event; | ||
2295 | |||
2296 | /* pad0 *IS* extension - bug in xcb */ | ||
2297 | if (ev->pad0 == _ecore_xcb_event_input) | ||
2298 | { | ||
2299 | _ecore_xcb_event_handle_input_event(event); | ||
2300 | // FIXME: should we generate generic events as WELL as input events? | ||
2301 | // return; | ||
2302 | } | ||
2303 | |||
2304 | if (!(e = calloc(1, sizeof(Ecore_X_Event_Generic)))) | ||
2305 | return; | ||
2306 | |||
2307 | DBG("Handle Generic Event: %d", ev->event_type); | ||
2308 | |||
2309 | e->cookie = ev->sequence; | ||
2310 | /* NB: These are bugs in xcb ge_event structure. The struct should have a | ||
2311 | * field for extension & data, but does not. | ||
2312 | * | ||
2313 | * XCB people have been notified of this issue */ | ||
2314 | e->extension = ev->pad0; | ||
2315 | /* e->data = ev->pad1; */ | ||
2316 | if (ev->length > 0) | ||
2317 | { | ||
2318 | int len = ev->length * sizeof(int); | ||
2319 | e->data = malloc(len); | ||
2320 | if (e->data) memcpy(e->data, &(event[1]), len); | ||
2321 | } | ||
2322 | |||
2323 | e->evtype = ev->event_type; | ||
2324 | |||
2325 | ecore_event_add(ECORE_X_EVENT_GENERIC, e, | ||
2326 | _ecore_xcb_event_generic_event_free, e->data); | ||
2327 | } | ||
2328 | |||
2329 | static void | ||
2330 | _ecore_xcb_event_handle_input_event(xcb_generic_event_t *event) | ||
2331 | { | ||
2332 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2333 | |||
2334 | _ecore_xcb_input_handle_event(event); | ||
2335 | } | ||
2336 | |||
2337 | static void | ||
2338 | _ecore_xcb_event_key_press(xcb_generic_event_t *event) | ||
2339 | { | ||
2340 | Ecore_Event_Key *e; | ||
2341 | xcb_keysym_t sym = XCB_NO_SYMBOL; | ||
2342 | xcb_keycode_t keycode = 0; | ||
2343 | xcb_key_press_event_t *xevent; | ||
2344 | char *keyname = NULL, *key = NULL; | ||
2345 | char *compose = NULL; | ||
2346 | char compose_buffer[256]; | ||
2347 | int val = 0; | ||
2348 | |||
2349 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
2350 | |||
2351 | xevent = (xcb_key_press_event_t *)event; | ||
2352 | keycode = xevent->detail; | ||
2353 | |||
2354 | sym = _ecore_xcb_keymap_keycode_to_keysym(keycode, xevent->state); | ||
2355 | keyname = _ecore_xcb_keymap_keysym_to_string(sym); | ||
2356 | if (!keyname) | ||
2357 | { | ||
2358 | char buff[256]; | ||
2359 | |||
2360 | snprintf(buff, sizeof(buff), "Keycode-%i", keycode); | ||
2361 | keyname = buff; | ||
2362 | } | ||
2363 | |||
2364 | val = | ||
2365 | _ecore_xcb_keymap_lookup_string(keycode, xevent->state, compose_buffer, | ||
2366 | sizeof(compose_buffer), &sym); | ||
2367 | if (val > 0) | ||
2368 | { | ||
2369 | compose_buffer[val] = 0; | ||
2370 | compose = | ||
2371 | eina_str_convert(nl_langinfo(CODESET), "UTF-8", compose_buffer); | ||
2372 | if (!compose) | ||
2373 | ERR("Ecore_X cannot convert input key string '%s' to UTF-8. " | ||
2374 | "Is Eina built with iconv support?", compose_buffer); | ||
2375 | } | ||
2376 | |||
2377 | key = _ecore_xcb_keymap_keysym_to_string(sym); | ||
2378 | if (!key) key = keyname; | ||
2379 | |||
2380 | e = malloc(sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) + | ||
2381 | (compose ? strlen(compose) : 0) + 3); | ||
2382 | if (e) | ||
2383 | { | ||
2384 | e->keyname = (char *)(e + 1); | ||
2385 | e->key = e->keyname + strlen(keyname) + 1; | ||
2386 | |||
2387 | e->compose = NULL; | ||
2388 | if (compose) e->compose = (e->key + strlen(key) + 1); | ||
2389 | e->string = e->compose; | ||
2390 | |||
2391 | strcpy((char *)e->keyname, keyname); | ||
2392 | strcpy((char *)e->key, key); | ||
2393 | if (compose) strcpy((char *)e->compose, compose); | ||
2394 | |||
2395 | e->modifiers = _ecore_xcb_events_modifiers_get(xevent->state); | ||
2396 | e->timestamp = xevent->time; | ||
2397 | e->window = xevent->child ? xevent->child : xevent->event; | ||
2398 | e->event_window = xevent->event; | ||
2399 | e->same_screen = xevent->same_screen; | ||
2400 | e->root_window = xevent->root; | ||
2401 | |||
2402 | DBG("Sending Key Down Event: %s", e->keyname); | ||
2403 | ecore_event_add(ECORE_EVENT_KEY_DOWN, e, NULL, NULL); | ||
2404 | } | ||
2405 | _ecore_xcb_event_last_time = xevent->time; | ||
2406 | } | ||
2407 | |||
2408 | static void | ||
2409 | _ecore_xcb_event_key_release(xcb_generic_event_t *event) | ||
2410 | { | ||
2411 | Ecore_Event_Key *e; | ||
2412 | xcb_keysym_t sym = XCB_NO_SYMBOL; | ||
2413 | xcb_keycode_t keycode = 0; | ||
2414 | xcb_key_release_event_t *xevent; | ||
2415 | char *keyname = NULL, *key = NULL; | ||
2416 | char *compose = NULL; | ||
2417 | char compose_buffer[256]; | ||
2418 | int val = 0; | ||
2419 | |||
2420 | _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
2421 | |||
2422 | xevent = (xcb_key_release_event_t *)event; | ||
2423 | keycode = xevent->detail; | ||
2424 | |||
2425 | sym = _ecore_xcb_keymap_keycode_to_keysym(keycode, xevent->state); | ||
2426 | keyname = _ecore_xcb_keymap_keysym_to_string(sym); | ||
2427 | if (!keyname) | ||
2428 | { | ||
2429 | char buff[256]; | ||
2430 | |||
2431 | snprintf(buff, sizeof(buff), "Keycode-%i", keycode); | ||
2432 | keyname = buff; | ||
2433 | } | ||
2434 | |||
2435 | val = | ||
2436 | _ecore_xcb_keymap_lookup_string(keycode, xevent->state, compose_buffer, | ||
2437 | sizeof(compose_buffer), &sym); | ||
2438 | if (val > 0) | ||
2439 | { | ||
2440 | compose_buffer[val] = 0; | ||
2441 | compose = | ||
2442 | eina_str_convert(nl_langinfo(CODESET), "UTF-8", compose_buffer); | ||
2443 | // tmp = compose; | ||
2444 | } | ||
2445 | |||
2446 | key = _ecore_xcb_keymap_keysym_to_string(sym); | ||
2447 | if (!key) key = keyname; | ||
2448 | |||
2449 | e = malloc(sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) + | ||
2450 | (compose ? strlen(compose) : 0) + 3); | ||
2451 | if (e) | ||
2452 | { | ||
2453 | e->keyname = (char *)(e + 1); | ||
2454 | e->key = e->keyname + strlen(keyname) + 1; | ||
2455 | |||
2456 | e->compose = NULL; | ||
2457 | if (compose) e->compose = (e->key + strlen(key) + 1); | ||
2458 | e->string = e->compose; | ||
2459 | |||
2460 | strcpy((char *)e->keyname, keyname); | ||
2461 | strcpy((char *)e->key, key); | ||
2462 | if (compose) strcpy((char *)e->compose, compose); | ||
2463 | |||
2464 | e->modifiers = _ecore_xcb_events_modifiers_get(xevent->state); | ||
2465 | e->timestamp = xevent->time; | ||
2466 | e->window = xevent->child ? xevent->child : xevent->event; | ||
2467 | e->event_window = xevent->event; | ||
2468 | e->same_screen = xevent->same_screen; | ||
2469 | e->root_window = xevent->root; | ||
2470 | |||
2471 | ecore_event_add(ECORE_EVENT_KEY_UP, e, NULL, NULL); | ||
2472 | } | ||
2473 | _ecore_xcb_event_last_time = xevent->time; | ||
2474 | } | ||
2475 | |||
2476 | void | ||
2477 | _ecore_xcb_event_mouse_move(uint16_t timestamp, | ||
2478 | uint16_t modifiers, | ||
2479 | int16_t x, | ||
2480 | int16_t y, | ||
2481 | int16_t root_x, | ||
2482 | int16_t root_y, | ||
2483 | xcb_window_t event_win, | ||
2484 | xcb_window_t win, | ||
2485 | xcb_window_t root_win, | ||
2486 | uint8_t same_screen, | ||
2487 | int dev, | ||
2488 | double radx, | ||
2489 | double rady, | ||
2490 | double pressure, | ||
2491 | double angle, | ||
2492 | int16_t mx, | ||
2493 | int16_t my, | ||
2494 | int16_t mrx, | ||
2495 | int16_t mry) | ||
2496 | { | ||
2497 | Ecore_Event_Mouse_Move *e; | ||
2498 | Ecore_Event *event; | ||
2499 | |||
2500 | if (!(e = malloc(sizeof(Ecore_Event_Mouse_Move)))) return; | ||
2501 | |||
2502 | e->window = win; | ||
2503 | e->root_window = root_win; | ||
2504 | e->timestamp = timestamp; | ||
2505 | e->same_screen = same_screen; | ||
2506 | e->event_window = event_win; | ||
2507 | e->modifiers = _ecore_xcb_events_modifiers_get(modifiers); | ||
2508 | e->x = x; | ||
2509 | e->y = y; | ||
2510 | e->root.x = root_x; | ||
2511 | e->root.y = root_y; | ||
2512 | e->multi.device = dev; | ||
2513 | e->multi.radius = ((radx + rady) / 2); | ||
2514 | e->multi.radius_x = radx; | ||
2515 | e->multi.radius_y = rady; | ||
2516 | e->multi.pressure = pressure; | ||
2517 | e->multi.angle = angle; | ||
2518 | e->multi.x = mx; | ||
2519 | e->multi.y = my; | ||
2520 | e->multi.root.x = mrx; | ||
2521 | e->multi.root.y = mry; | ||
2522 | |||
2523 | event = ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, | ||
2524 | _ecore_xcb_event_mouse_move_free, NULL); | ||
2525 | |||
2526 | _ecore_xcb_event_last_time = e->timestamp; | ||
2527 | _ecore_xcb_event_last_window = e->window; | ||
2528 | _ecore_xcb_event_last_root_x = root_x; | ||
2529 | _ecore_xcb_event_last_root_y = root_y; | ||
2530 | // _ecore_xcb_event_last_mouse_move_event = event; | ||
2531 | } | ||
2532 | |||
2533 | static void | ||
2534 | _ecore_xcb_event_mouse_move_free(void *data __UNUSED__, | ||
2535 | void *event) | ||
2536 | { | ||
2537 | Ecore_Event_Mouse_Move *ev; | ||
2538 | |||
2539 | ev = event; | ||
2540 | // if (_ecore_xcb_event_last_mouse_move_event) | ||
2541 | // { | ||
2542 | // _ecore_xcb_event_last_mouse_move = EINA_FALSE; | ||
2543 | // _ecore_xcb_event_last_mouse_move_event = NULL; | ||
2544 | // } | ||
2545 | if (ev) free(ev); | ||
2546 | } | ||
2547 | |||
2548 | Ecore_Event_Mouse_Button * | ||
2549 | _ecore_xcb_event_mouse_button(int event, | ||
2550 | uint16_t timestamp, | ||
2551 | uint16_t modifiers, | ||
2552 | xcb_button_t buttons, | ||
2553 | int16_t x, | ||
2554 | int16_t y, | ||
2555 | int16_t root_x, | ||
2556 | int16_t root_y, | ||
2557 | xcb_window_t event_win, | ||
2558 | xcb_window_t win, | ||
2559 | xcb_window_t root_win, | ||
2560 | uint8_t same_screen, | ||
2561 | int dev, | ||
2562 | double radx, | ||
2563 | double rady, | ||
2564 | double pressure, | ||
2565 | double angle, | ||
2566 | int16_t mx, | ||
2567 | int16_t my, | ||
2568 | int16_t mrx, | ||
2569 | int16_t mry) | ||
2570 | { | ||
2571 | Ecore_Event_Mouse_Button *e; | ||
2572 | Ecore_X_Mouse_Down_Info *info = NULL; | ||
2573 | |||
2574 | if (!(e = malloc(sizeof(Ecore_Event_Mouse_Button)))) return NULL; | ||
2575 | |||
2576 | e->window = win; | ||
2577 | e->root_window = root_win; | ||
2578 | e->timestamp = timestamp; | ||
2579 | e->same_screen = same_screen; | ||
2580 | e->event_window = event_win; | ||
2581 | e->buttons = buttons; | ||
2582 | e->modifiers = _ecore_xcb_events_modifiers_get(modifiers); | ||
2583 | e->double_click = 0; | ||
2584 | e->triple_click = 0; | ||
2585 | e->x = x; | ||
2586 | e->y = y; | ||
2587 | e->root.x = root_x; | ||
2588 | e->root.y = root_y; | ||
2589 | |||
2590 | if ((info = _ecore_xcb_event_mouse_down_info_get(dev))) | ||
2591 | { | ||
2592 | if ((event == ECORE_EVENT_MOUSE_BUTTON_DOWN) && | ||
2593 | (info->did_triple)) | ||
2594 | { | ||
2595 | info->last_win = 0; | ||
2596 | info->last_last_win = 0; | ||
2597 | info->last_event_win = 0; | ||
2598 | info->last_time = 0; | ||
2599 | info->last_last_time = 0; | ||
2600 | } | ||
2601 | if (event_win == win) | ||
2602 | { | ||
2603 | if (event == ECORE_EVENT_MOUSE_BUTTON_DOWN) | ||
2604 | { | ||
2605 | if (((int)(timestamp - info->last_time) <= | ||
2606 | (int)(1000 * _ecore_xcb_double_click_time)) && | ||
2607 | (win == info->last_win) && | ||
2608 | (event_win == info->last_event_win)) | ||
2609 | { | ||
2610 | e->double_click = 1; | ||
2611 | info->did_double = EINA_TRUE; | ||
2612 | } | ||
2613 | else | ||
2614 | { | ||
2615 | info->did_double = EINA_FALSE; | ||
2616 | info->did_triple = EINA_FALSE; | ||
2617 | } | ||
2618 | if (((int)(timestamp - info->last_last_time) <= | ||
2619 | (int)(2 * 1000 * _ecore_xcb_double_click_time)) && | ||
2620 | (win == info->last_win) && | ||
2621 | (win == info->last_last_win) && | ||
2622 | (event_win == info->last_event_win) && | ||
2623 | (event_win == info->last_last_event_win)) | ||
2624 | { | ||
2625 | e->triple_click = 1; | ||
2626 | info->did_triple = EINA_TRUE; | ||
2627 | } | ||
2628 | else | ||
2629 | info->did_triple = EINA_FALSE; | ||
2630 | } | ||
2631 | else | ||
2632 | { | ||
2633 | if (info->did_double) e->double_click = 1; | ||
2634 | if (info->did_triple) e->triple_click = 1; | ||
2635 | } | ||
2636 | } | ||
2637 | } | ||
2638 | |||
2639 | /* NB: Comment out right now because _ecore_xcb_mouse_up_count is | ||
2640 | * only used here...nowhere else in the code */ | ||
2641 | |||
2642 | /* if ((event == ECORE_EVENT_MOUSE_BUTTON_DOWN) && */ | ||
2643 | /* (!e->double_click) && (!e->triple_click)) */ | ||
2644 | /* _ecore_xcb_mouse_up_count = 0; */ | ||
2645 | |||
2646 | e->multi.device = dev; | ||
2647 | e->multi.radius = ((radx + rady) / 2); | ||
2648 | e->multi.radius_x = radx; | ||
2649 | e->multi.radius_y = rady; | ||
2650 | e->multi.pressure = pressure; | ||
2651 | e->multi.angle = angle; | ||
2652 | e->multi.x = mx; | ||
2653 | e->multi.y = my; | ||
2654 | e->multi.root.x = mrx; | ||
2655 | e->multi.root.y = mry; | ||
2656 | |||
2657 | _ecore_xcb_event_last_time = e->timestamp; | ||
2658 | _ecore_xcb_event_last_window = e->window; | ||
2659 | _ecore_xcb_event_last_root_x = root_x; | ||
2660 | _ecore_xcb_event_last_root_y = root_y; | ||
2661 | |||
2662 | ecore_event_add(event, e, NULL, NULL); | ||
2663 | |||
2664 | if ((info) && (event == ECORE_EVENT_MOUSE_BUTTON_DOWN) && | ||
2665 | (win == event_win) && (!info->did_triple)) | ||
2666 | { | ||
2667 | info->last_last_win = info->last_win; | ||
2668 | info->last_win = win; | ||
2669 | info->last_last_event_win = info->last_event_win; | ||
2670 | info->last_event_win = event_win; | ||
2671 | info->last_last_time = info->last_time; | ||
2672 | info->last_time = timestamp; | ||
2673 | } | ||
2674 | |||
2675 | return e; | ||
2676 | } | ||
2677 | |||
2678 | static Ecore_X_Event_Mode | ||
2679 | _ecore_xcb_event_mode_get(uint8_t mode) | ||
2680 | { | ||
2681 | switch (mode) | ||
2682 | { | ||
2683 | case XCB_NOTIFY_MODE_NORMAL: | ||
2684 | return ECORE_X_EVENT_MODE_NORMAL; | ||
2685 | |||
2686 | case XCB_NOTIFY_MODE_WHILE_GRABBED: | ||
2687 | return ECORE_X_EVENT_MODE_WHILE_GRABBED; | ||
2688 | |||
2689 | case XCB_NOTIFY_MODE_GRAB: | ||
2690 | return ECORE_X_EVENT_MODE_GRAB; | ||
2691 | |||
2692 | case XCB_NOTIFY_MODE_UNGRAB: | ||
2693 | return ECORE_X_EVENT_MODE_UNGRAB; | ||
2694 | |||
2695 | default: | ||
2696 | return ECORE_X_EVENT_MODE_NORMAL; | ||
2697 | } | ||
2698 | } | ||
2699 | |||
2700 | static Ecore_X_Event_Detail | ||
2701 | _ecore_xcb_event_detail_get(uint8_t detail) | ||
2702 | { | ||
2703 | switch (detail) | ||
2704 | { | ||
2705 | case XCB_NOTIFY_DETAIL_ANCESTOR: | ||
2706 | return ECORE_X_EVENT_DETAIL_ANCESTOR; | ||
2707 | |||
2708 | case XCB_NOTIFY_DETAIL_VIRTUAL: | ||
2709 | return ECORE_X_EVENT_DETAIL_VIRTUAL; | ||
2710 | |||
2711 | case XCB_NOTIFY_DETAIL_INFERIOR: | ||
2712 | return ECORE_X_EVENT_DETAIL_INFERIOR; | ||
2713 | |||
2714 | case XCB_NOTIFY_DETAIL_NONLINEAR: | ||
2715 | return ECORE_X_EVENT_DETAIL_NON_LINEAR; | ||
2716 | |||
2717 | case XCB_NOTIFY_DETAIL_NONLINEAR_VIRTUAL: | ||
2718 | return ECORE_X_EVENT_DETAIL_NON_LINEAR_VIRTUAL; | ||
2719 | |||
2720 | case XCB_NOTIFY_DETAIL_POINTER: | ||
2721 | return ECORE_X_EVENT_DETAIL_POINTER; | ||
2722 | |||
2723 | case XCB_NOTIFY_DETAIL_POINTER_ROOT: | ||
2724 | return ECORE_X_EVENT_DETAIL_POINTER_ROOT; | ||
2725 | |||
2726 | case XCB_NOTIFY_DETAIL_NONE: | ||
2727 | default: | ||
2728 | return ECORE_X_EVENT_DETAIL_ANCESTOR; | ||
2729 | } | ||
2730 | } | ||
2731 | |||
2732 | static void | ||
2733 | _ecore_xcb_event_xdnd_enter_free(void *data __UNUSED__, | ||
2734 | void *event) | ||
2735 | { | ||
2736 | Ecore_X_Event_Xdnd_Enter *e; | ||
2737 | int i = 0; | ||
2738 | |||
2739 | e = event; | ||
2740 | for (i = 0; i < e->num_types; i++) | ||
2741 | free(e->types[i]); | ||
2742 | free(e->types); | ||
2743 | free(e); | ||
2744 | } | ||
2745 | |||
2746 | static void | ||
2747 | _ecore_xcb_event_selection_notify_free(void *data __UNUSED__, | ||
2748 | void *event) | ||
2749 | { | ||
2750 | Ecore_X_Event_Selection_Notify *e; | ||
2751 | Ecore_X_Selection_Data *sel; | ||
2752 | |||
2753 | e = event; | ||
2754 | if (!(sel = e->data)) return; | ||
2755 | if (sel->free) sel->free(sel); | ||
2756 | free(e->target); | ||
2757 | free(e); | ||
2758 | } | ||
2759 | |||
2760 | static void | ||
2761 | _ecore_xcb_event_generic_event_free(void *data, | ||
2762 | void *event) | ||
2763 | { | ||
2764 | Ecore_X_Event_Generic *e; | ||
2765 | |||
2766 | e = (Ecore_X_Event_Generic *)event; | ||
2767 | if (e->data) free(data); | ||
2768 | free(e); | ||
2769 | } | ||
2770 | |||
2771 | static void | ||
2772 | _ecore_xcb_event_mouse_down_info_clear(void) | ||
2773 | { | ||
2774 | Eina_Inlist *l; | ||
2775 | Ecore_X_Mouse_Down_Info *info = NULL; | ||
2776 | |||
2777 | l = _ecore_xcb_mouse_down_info_list; | ||
2778 | while (l) | ||
2779 | { | ||
2780 | info = EINA_INLIST_CONTAINER_GET(l, Ecore_X_Mouse_Down_Info); | ||
2781 | l = eina_inlist_remove(l, l); | ||
2782 | free(info); | ||
2783 | } | ||
2784 | _ecore_xcb_mouse_down_info_list = NULL; | ||
2785 | } | ||
2786 | |||
2787 | static Ecore_X_Mouse_Down_Info * | ||
2788 | _ecore_xcb_event_mouse_down_info_get(int dev) | ||
2789 | { | ||
2790 | Eina_Inlist *l; | ||
2791 | Ecore_X_Mouse_Down_Info *info = NULL; | ||
2792 | |||
2793 | l = _ecore_xcb_mouse_down_info_list; | ||
2794 | EINA_INLIST_FOREACH(l, info) | ||
2795 | if (info->dev == dev) return info; | ||
2796 | |||
2797 | if (!(info = calloc(1, sizeof(Ecore_X_Mouse_Down_Info)))) return NULL; | ||
2798 | |||
2799 | info->dev = dev; | ||
2800 | l = eina_inlist_append(l, (Eina_Inlist *)info); | ||
2801 | _ecore_xcb_mouse_down_info_list = l; | ||
2802 | |||
2803 | return info; | ||
2804 | } | ||
2805 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_extensions.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_extensions.c new file mode 100644 index 0000000..40c10ac --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_extensions.c | |||
@@ -0,0 +1,148 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | |||
3 | void | ||
4 | _ecore_xcb_extensions_init(void) | ||
5 | { | ||
6 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
7 | |||
8 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_big_requests_id); | ||
9 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_shm_id); | ||
10 | |||
11 | #ifdef ECORE_XCB_SHAPE | ||
12 | _ecore_xcb_shape_init(); | ||
13 | #endif | ||
14 | |||
15 | #ifdef ECORE_XCB_SCREENSAVER | ||
16 | _ecore_xcb_screensaver_init(); | ||
17 | #endif | ||
18 | |||
19 | #ifdef ECORE_XCB_SYNC | ||
20 | _ecore_xcb_sync_init(); | ||
21 | #endif | ||
22 | |||
23 | #ifdef ECORE_XCB_RANDR | ||
24 | _ecore_xcb_randr_init(); | ||
25 | #endif | ||
26 | |||
27 | #ifdef ECORE_XCB_XFIXES | ||
28 | _ecore_xcb_xfixes_init(); | ||
29 | #endif | ||
30 | |||
31 | #ifdef ECORE_XCB_DAMAGE | ||
32 | _ecore_xcb_damage_init(); | ||
33 | #endif | ||
34 | |||
35 | #ifdef ECORE_XCB_RENDER | ||
36 | _ecore_xcb_render_init(); | ||
37 | #endif | ||
38 | |||
39 | #ifdef ECORE_XCB_COMPOSITE | ||
40 | _ecore_xcb_composite_init(); | ||
41 | #endif | ||
42 | |||
43 | #ifdef ECORE_XCB_DPMS | ||
44 | _ecore_xcb_dpms_init(); | ||
45 | #endif | ||
46 | |||
47 | #ifdef ECORE_XCB_DPMS | ||
48 | _ecore_xcb_dpms_init(); | ||
49 | #endif | ||
50 | |||
51 | #ifdef ECORE_XCB_CURSOR | ||
52 | _ecore_xcb_cursor_init(); | ||
53 | #endif | ||
54 | |||
55 | #ifdef ECORE_XCB_XINERAMA | ||
56 | _ecore_xcb_xinerama_init(); | ||
57 | #endif | ||
58 | |||
59 | #ifdef ECORE_XCB_XINPUT | ||
60 | _ecore_xcb_input_init(); | ||
61 | #endif | ||
62 | |||
63 | #ifdef ECORE_XCB_GESTURE | ||
64 | _ecore_xcb_gesture_init(); | ||
65 | #endif | ||
66 | |||
67 | /* #ifdef ECORE_XCB_DRI */ | ||
68 | /* _ecore_xcb_dri_init(); */ | ||
69 | /* #endif */ | ||
70 | |||
71 | #ifdef ECORE_XCB_XTEST | ||
72 | _ecore_xcb_xtest_init(); | ||
73 | #endif | ||
74 | |||
75 | xcb_prefetch_maximum_request_length(_ecore_xcb_conn); | ||
76 | } | ||
77 | |||
78 | void | ||
79 | _ecore_xcb_extensions_finalize(void) | ||
80 | { | ||
81 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
82 | |||
83 | xcb_get_extension_data(_ecore_xcb_conn, &xcb_big_requests_id); | ||
84 | xcb_get_extension_data(_ecore_xcb_conn, &xcb_shm_id); | ||
85 | |||
86 | #ifdef ECORE_XCB_SHAPE | ||
87 | _ecore_xcb_shape_finalize(); | ||
88 | #endif | ||
89 | |||
90 | #ifdef ECORE_XCB_SCREENSAVER | ||
91 | _ecore_xcb_screensaver_finalize(); | ||
92 | #endif | ||
93 | |||
94 | #ifdef ECORE_XCB_SYNC | ||
95 | _ecore_xcb_sync_finalize(); | ||
96 | #endif | ||
97 | |||
98 | #ifdef ECORE_XCB_RANDR | ||
99 | _ecore_xcb_randr_finalize(); | ||
100 | #endif | ||
101 | |||
102 | #ifdef ECORE_XCB_XFIXES | ||
103 | _ecore_xcb_xfixes_finalize(); | ||
104 | #endif | ||
105 | |||
106 | #ifdef ECORE_XCB_DAMAGE | ||
107 | _ecore_xcb_damage_finalize(); | ||
108 | #endif | ||
109 | |||
110 | #ifdef ECORE_XCB_RENDER | ||
111 | _ecore_xcb_render_finalize(); | ||
112 | #endif | ||
113 | |||
114 | #ifdef ECORE_XCB_COMPOSITE | ||
115 | _ecore_xcb_composite_finalize(); | ||
116 | #endif | ||
117 | |||
118 | #ifdef ECORE_XCB_DPMS | ||
119 | _ecore_xcb_dpms_finalize(); | ||
120 | #endif | ||
121 | |||
122 | #ifdef ECORE_XCB_CURSOR | ||
123 | _ecore_xcb_cursor_finalize(); | ||
124 | #endif | ||
125 | |||
126 | #ifdef ECORE_XCB_XINERAMA | ||
127 | _ecore_xcb_xinerama_finalize(); | ||
128 | #endif | ||
129 | |||
130 | #ifdef ECORE_XCB_XINPUT | ||
131 | _ecore_xcb_input_finalize(); | ||
132 | #endif | ||
133 | |||
134 | #ifdef ECORE_XCB_GESTURE | ||
135 | _ecore_xcb_gesture_finalize(); | ||
136 | #endif | ||
137 | |||
138 | /* #ifdef ECORE_XCB_DRI */ | ||
139 | /* _ecore_xcb_dri_finalize(); */ | ||
140 | /* #endif */ | ||
141 | |||
142 | #ifdef ECORE_XCB_XTEST | ||
143 | _ecore_xcb_xtest_finalize(); | ||
144 | #endif | ||
145 | |||
146 | xcb_get_maximum_request_length(_ecore_xcb_conn); | ||
147 | } | ||
148 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_gc.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_gc.c new file mode 100644 index 0000000..d811b54 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_gc.c | |||
@@ -0,0 +1,173 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | |||
3 | /** | ||
4 | * Creates a new default graphics context associated with the given | ||
5 | * drawable. | ||
6 | * @param draw Drawable to create graphics context with. If @c 0 is | ||
7 | * given instead, the default root window is used. | ||
8 | * @param value_mask Bitmask values. | ||
9 | * @param value_list List of values. The order of values must be the | ||
10 | * same than the corresponding bitmaks. | ||
11 | * @return The new default graphics context. | ||
12 | */ | ||
13 | EAPI Ecore_X_GC | ||
14 | ecore_x_gc_new(Ecore_X_Drawable drawable, | ||
15 | Ecore_X_GC_Value_Mask value_mask, | ||
16 | const unsigned int *value_list) | ||
17 | { | ||
18 | xcb_gcontext_t gc; | ||
19 | uint32_t vmask = 0; | ||
20 | int i = 0, mask = 0; | ||
21 | |||
22 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
23 | CHECK_XCB_CONN; | ||
24 | |||
25 | if (!drawable) drawable = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
26 | |||
27 | for (i = 0, mask = 1; i <= 22; i++, mask <<= 1) | ||
28 | { | ||
29 | switch (mask & value_mask) | ||
30 | { | ||
31 | case ECORE_X_GC_VALUE_MASK_FUNCTION: | ||
32 | vmask |= XCB_GC_FUNCTION; | ||
33 | break; | ||
34 | |||
35 | case ECORE_X_GC_VALUE_MASK_PLANE_MASK: | ||
36 | vmask |= XCB_GC_PLANE_MASK; | ||
37 | break; | ||
38 | |||
39 | case ECORE_X_GC_VALUE_MASK_FOREGROUND: | ||
40 | vmask |= XCB_GC_FOREGROUND; | ||
41 | break; | ||
42 | |||
43 | case ECORE_X_GC_VALUE_MASK_BACKGROUND: | ||
44 | vmask |= XCB_GC_BACKGROUND; | ||
45 | break; | ||
46 | |||
47 | case ECORE_X_GC_VALUE_MASK_LINE_WIDTH: | ||
48 | vmask |= XCB_GC_LINE_WIDTH; | ||
49 | break; | ||
50 | |||
51 | case ECORE_X_GC_VALUE_MASK_LINE_STYLE: | ||
52 | vmask |= XCB_GC_LINE_STYLE; | ||
53 | break; | ||
54 | |||
55 | case ECORE_X_GC_VALUE_MASK_CAP_STYLE: | ||
56 | vmask |= XCB_GC_CAP_STYLE; | ||
57 | break; | ||
58 | |||
59 | case ECORE_X_GC_VALUE_MASK_JOIN_STYLE: | ||
60 | vmask |= XCB_GC_JOIN_STYLE; | ||
61 | break; | ||
62 | |||
63 | case ECORE_X_GC_VALUE_MASK_FILL_STYLE: | ||
64 | vmask |= XCB_GC_FILL_STYLE; | ||
65 | break; | ||
66 | |||
67 | case ECORE_X_GC_VALUE_MASK_FILL_RULE: | ||
68 | vmask |= XCB_GC_FILL_RULE; | ||
69 | break; | ||
70 | |||
71 | case ECORE_X_GC_VALUE_MASK_TILE: | ||
72 | vmask |= XCB_GC_TILE; | ||
73 | break; | ||
74 | |||
75 | case ECORE_X_GC_VALUE_MASK_STIPPLE: | ||
76 | vmask |= XCB_GC_STIPPLE; | ||
77 | break; | ||
78 | |||
79 | case ECORE_X_GC_VALUE_MASK_TILE_STIPPLE_ORIGIN_X: | ||
80 | vmask |= XCB_GC_TILE_STIPPLE_ORIGIN_X; | ||
81 | break; | ||
82 | |||
83 | case ECORE_X_GC_VALUE_MASK_TILE_STIPPLE_ORIGIN_Y: | ||
84 | vmask |= XCB_GC_TILE_STIPPLE_ORIGIN_Y; | ||
85 | break; | ||
86 | |||
87 | case ECORE_X_GC_VALUE_MASK_FONT: | ||
88 | vmask |= XCB_GC_FONT; | ||
89 | break; | ||
90 | |||
91 | case ECORE_X_GC_VALUE_MASK_SUBWINDOW_MODE: | ||
92 | vmask |= XCB_GC_SUBWINDOW_MODE; | ||
93 | break; | ||
94 | |||
95 | case ECORE_X_GC_VALUE_MASK_GRAPHICS_EXPOSURES: | ||
96 | vmask |= XCB_GC_GRAPHICS_EXPOSURES; | ||
97 | break; | ||
98 | |||
99 | case ECORE_X_GC_VALUE_MASK_CLIP_ORIGIN_X: | ||
100 | vmask |= XCB_GC_CLIP_ORIGIN_X; | ||
101 | break; | ||
102 | |||
103 | case ECORE_X_GC_VALUE_MASK_CLIP_ORIGIN_Y: | ||
104 | vmask |= XCB_GC_CLIP_ORIGIN_Y; | ||
105 | break; | ||
106 | |||
107 | case ECORE_X_GC_VALUE_MASK_CLIP_MASK: | ||
108 | vmask |= XCB_GC_CLIP_MASK; | ||
109 | break; | ||
110 | |||
111 | case ECORE_X_GC_VALUE_MASK_DASH_OFFSET: | ||
112 | vmask |= XCB_GC_DASH_OFFSET; | ||
113 | break; | ||
114 | |||
115 | case ECORE_X_GC_VALUE_MASK_DASH_LIST: | ||
116 | vmask |= XCB_GC_DASH_LIST; | ||
117 | break; | ||
118 | |||
119 | case ECORE_X_GC_VALUE_MASK_ARC_MODE: | ||
120 | vmask |= XCB_GC_ARC_MODE; | ||
121 | break; | ||
122 | } | ||
123 | } | ||
124 | |||
125 | gc = xcb_generate_id(_ecore_xcb_conn); | ||
126 | xcb_create_gc(_ecore_xcb_conn, gc, drawable, vmask, value_list); | ||
127 | |||
128 | // ecore_x_flush(); | ||
129 | return gc; | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * Deletes and frees the given graphics context. | ||
134 | * @param gc The given graphics context. | ||
135 | */ | ||
136 | EAPI void | ||
137 | ecore_x_gc_free(Ecore_X_GC gc) | ||
138 | { | ||
139 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
140 | CHECK_XCB_CONN; | ||
141 | |||
142 | xcb_free_gc(_ecore_xcb_conn, gc); | ||
143 | // ecore_x_flush(); | ||
144 | } | ||
145 | |||
146 | EAPI void | ||
147 | ecore_x_gc_foreground_set(Ecore_X_GC gc, | ||
148 | unsigned long foreground) | ||
149 | { | ||
150 | uint32_t list; | ||
151 | |||
152 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
153 | CHECK_XCB_CONN; | ||
154 | |||
155 | list = foreground; | ||
156 | xcb_change_gc(_ecore_xcb_conn, gc, XCB_GC_FOREGROUND, &list); | ||
157 | // ecore_x_flush(); | ||
158 | } | ||
159 | |||
160 | EAPI void | ||
161 | ecore_x_gc_background_set(Ecore_X_GC gc, | ||
162 | unsigned long background) | ||
163 | { | ||
164 | uint32_t list; | ||
165 | |||
166 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
167 | CHECK_XCB_CONN; | ||
168 | |||
169 | list = background; | ||
170 | xcb_change_gc(_ecore_xcb_conn, gc, XCB_GC_BACKGROUND, &list); | ||
171 | // ecore_x_flush(); | ||
172 | } | ||
173 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_gesture.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_gesture.c new file mode 100644 index 0000000..263dade --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_gesture.c | |||
@@ -0,0 +1,203 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #ifdef ECORE_XCB_XGESTURE | ||
3 | # include <xcb/gesture.h> | ||
4 | # include <xcb/xcb_event.h> | ||
5 | #endif | ||
6 | |||
7 | /* local variables */ | ||
8 | static Eina_Bool _gesture_available = EINA_FALSE; | ||
9 | |||
10 | /* external variables */ | ||
11 | int _ecore_xcb_event_gesture = -1; | ||
12 | |||
13 | void | ||
14 | _ecore_xcb_gesture_init(void) | ||
15 | { | ||
16 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
17 | |||
18 | #ifdef ECORE_XCB_XGESTURE | ||
19 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_gesture_id); | ||
20 | #endif | ||
21 | } | ||
22 | |||
23 | void | ||
24 | _ecore_xcb_gesture_finalize(void) | ||
25 | { | ||
26 | #ifdef ECORE_XCB_XGESTURE | ||
27 | xcb_gesture_query_version_cookie_t cookie; | ||
28 | xcb_gesture_query_version_reply_t *reply; | ||
29 | #endif | ||
30 | |||
31 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
32 | |||
33 | #ifdef ECORE_XCB_XGESTURE | ||
34 | cookie = | ||
35 | xcb_gesture_query_version_unchecked(_ecore_xcb_conn); | ||
36 | reply = | ||
37 | xcb_gesture_query_version_reply(_ecore_xcb_conn, cookie, NULL); | ||
38 | if (reply) | ||
39 | { | ||
40 | _gesture_available = EINA_TRUE; | ||
41 | free(reply); | ||
42 | } | ||
43 | |||
44 | if (_gesture_available) | ||
45 | { | ||
46 | const xcb_query_extension_reply_t *ext_reply; | ||
47 | |||
48 | ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_gesture_id); | ||
49 | if (ext_reply) | ||
50 | _ecore_xcb_event_gesture = ext_reply->first_event; | ||
51 | } | ||
52 | #endif | ||
53 | } | ||
54 | |||
55 | void | ||
56 | _ecore_xcb_gesture_shutdown(void) | ||
57 | { | ||
58 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
59 | } | ||
60 | |||
61 | EAPI Eina_Bool | ||
62 | ecore_x_gesture_supported(void) | ||
63 | { | ||
64 | return _gesture_available; | ||
65 | } | ||
66 | |||
67 | #ifdef ECORE_XCB_XGESTURE | ||
68 | EAPI Eina_Bool | ||
69 | ecore_x_gesture_events_select(Ecore_X_Window win, | ||
70 | Ecore_X_Gesture_Event_Mask mask) | ||
71 | #else | ||
72 | EAPI Eina_Bool | ||
73 | ecore_x_gesture_events_select(Ecore_X_Window win __UNUSED__, | ||
74 | Ecore_X_Gesture_Event_Mask mask __UNUSED__) | ||
75 | #endif | ||
76 | |||
77 | { | ||
78 | #ifdef ECORE_XCB_XGESTURE | ||
79 | if (!_gesture_available) return EINA_FALSE; | ||
80 | |||
81 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
82 | CHECK_XCB_CONN | ||
83 | |||
84 | xcb_gesture_select_events(_ecore_xcb_conn, win, mask); | ||
85 | |||
86 | return EINA_TRUE; | ||
87 | #else | ||
88 | return EINA_FALSE; | ||
89 | #endif | ||
90 | } | ||
91 | |||
92 | #ifdef ECORE_XCB_XGESTURE | ||
93 | EAPI Ecore_X_Gesture_Event_Mask | ||
94 | ecore_x_gesture_events_selected_get(Ecore_X_Window win) | ||
95 | #else | ||
96 | EAPI Ecore_X_Gesture_Event_Mask | ||
97 | ecore_x_gesture_events_selected_get(Ecore_X_Window win __UNUSED__) | ||
98 | #endif | ||
99 | { | ||
100 | #ifdef ECORE_XCB_XGESTURE | ||
101 | xcb_gesture_get_selected_events_cookie_t ecookie; | ||
102 | xcb_gesture_get_selected_events_reply_t *ereply; | ||
103 | Ecore_X_Gesture_Event_Mask mask = ECORE_X_GESTURE_EVENT_MASK_NONE; | ||
104 | |||
105 | if (!_gesture_available) return mask; | ||
106 | |||
107 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
108 | CHECK_XCB_CONN | ||
109 | |||
110 | ecookie = xcb_gesture_get_selected_events(_ecore_xcb_conn, win); | ||
111 | ereply = | ||
112 | xcb_gesture_get_selected_events_reply(_ecore_xcb_conn, ecookie, NULL); | ||
113 | if (ereply) | ||
114 | { | ||
115 | mask = ereply->mask; | ||
116 | free(ereply); | ||
117 | } | ||
118 | |||
119 | return mask; | ||
120 | #else | ||
121 | return ECORE_X_GESTURE_EVENT_MASK_NONE; | ||
122 | #endif | ||
123 | } | ||
124 | |||
125 | #ifdef ECORE_XCB_XGESTURE | ||
126 | EAPI Eina_Bool | ||
127 | ecore_x_gesture_event_grab(Ecore_X_Window win, | ||
128 | Ecore_X_Gesture_Event_Type type, | ||
129 | int num_fingers) | ||
130 | #else | ||
131 | EAPI Eina_Bool | ||
132 | ecore_x_gesture_event_grab(Ecore_X_Window win __UNUSED__, | ||
133 | Ecore_X_Gesture_Event_Type type __UNUSED__, | ||
134 | int num_fingers __UNUSED__) | ||
135 | #endif | ||
136 | { | ||
137 | #ifdef ECORE_XCB_XGESTURE | ||
138 | Eina_Bool status = EINA_TRUE; | ||
139 | xcb_gesture_grab_event_cookie_t ecookie; | ||
140 | xcb_gesture_grab_event_reply_t *ereply; | ||
141 | |||
142 | if (!_gesture_available) return EINA_FALSE; | ||
143 | |||
144 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
145 | CHECK_XCB_CONN | ||
146 | |||
147 | ecookie = | ||
148 | xcb_gesture_grab_event(_ecore_xcb_conn, win, type, num_fingers, 0L); | ||
149 | ereply = xcb_gesture_grab_event_reply(_ecore_xcb_conn, ecookie, NULL); | ||
150 | |||
151 | if (ereply) | ||
152 | { | ||
153 | if (ereply->status) status = EINA_FALSE; | ||
154 | free(ereply); | ||
155 | } | ||
156 | else | ||
157 | status = EINA_FALSE; | ||
158 | |||
159 | return status; | ||
160 | #else | ||
161 | return EINA_FALSE; | ||
162 | #endif | ||
163 | } | ||
164 | |||
165 | #ifdef ECORE_XCB_XGESTURE | ||
166 | EAPI Eina_Bool | ||
167 | ecore_x_gesture_event_ungrab(Ecore_X_Window win, | ||
168 | Ecore_X_Gesture_Event_Type type, | ||
169 | int num_fingers) | ||
170 | #else | ||
171 | EAPI Eina_Bool | ||
172 | ecore_x_gesture_event_ungrab(Ecore_X_Window win __UNUSED__, | ||
173 | Ecore_X_Gesture_Event_Type type __UNUSED__, | ||
174 | int num_fingers __UNUSED__) | ||
175 | #endif | ||
176 | { | ||
177 | #ifdef ECORE_XCB_XGESTURE | ||
178 | Eina_Bool status = EINA_TRUE; | ||
179 | xcb_gesture_ungrab_event_cookie_t ecookie; | ||
180 | xcb_gesture_ungrab_event_reply_t *ereply; | ||
181 | |||
182 | if (!_gesture_available) return EINA_FALSE; | ||
183 | |||
184 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
185 | CHECK_XCB_CONN | ||
186 | |||
187 | ecookie = | ||
188 | xcb_gesture_ungrab_event(_ecore_xcb_conn, win, type, num_fingers, 0L); | ||
189 | ereply = xcb_gesture_ungrab_event_reply(_ecore_xcb_conn, ecookie, NULL); | ||
190 | |||
191 | if (ereply) | ||
192 | { | ||
193 | if (ereply->status) status = EINA_FALSE; | ||
194 | free(ereply); | ||
195 | } | ||
196 | else | ||
197 | status = EINA_FALSE; | ||
198 | |||
199 | return status; | ||
200 | #else | ||
201 | return EINA_FALSE; | ||
202 | #endif | ||
203 | } | ||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_icccm.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_icccm.c new file mode 100644 index 0000000..6459db7 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_icccm.c | |||
@@ -0,0 +1,1568 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #include <xcb/xcb_icccm.h> | ||
3 | |||
4 | EAPI void | ||
5 | ecore_x_icccm_init(void) | ||
6 | { | ||
7 | } | ||
8 | |||
9 | /** | ||
10 | * Sets the WM_COMMAND property for @a win. | ||
11 | * | ||
12 | * @param win The window. | ||
13 | * @param argc Number of arguments. | ||
14 | * @param argv Arguments. | ||
15 | */ | ||
16 | EAPI void | ||
17 | ecore_x_icccm_command_set(Ecore_X_Window win, | ||
18 | int argc, | ||
19 | char **argv) | ||
20 | { | ||
21 | void *buf; | ||
22 | char *b; | ||
23 | int nbytes, i; | ||
24 | |||
25 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
26 | CHECK_XCB_CONN; | ||
27 | |||
28 | for (i = 0, nbytes = 0; i < argc; i++) | ||
29 | if (argv[i]) nbytes += strlen(argv[i]) + 1; | ||
30 | |||
31 | buf = malloc(sizeof(char) * nbytes); | ||
32 | if (!buf) return; | ||
33 | |||
34 | b = (char *)buf; | ||
35 | for (i = 0; i < argc; i++) | ||
36 | { | ||
37 | if (argv[i]) | ||
38 | { | ||
39 | strcpy(b, argv[i]); | ||
40 | b += strlen(argv[i]) + 1; | ||
41 | } | ||
42 | else | ||
43 | *b++ = '\0'; | ||
44 | } | ||
45 | xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, win, | ||
46 | ECORE_X_ATOM_WM_COMMAND, ECORE_X_ATOM_STRING, 8, | ||
47 | nbytes, buf); | ||
48 | free(buf); | ||
49 | } | ||
50 | |||
51 | /** | ||
52 | * Get the WM_COMMAND property for @a win. | ||
53 | * | ||
54 | * Return the command of a window. String must be free'd when done with. | ||
55 | * | ||
56 | * @param win The window. | ||
57 | * @param argc Number of arguments. | ||
58 | * @param argv Arguments. | ||
59 | */ | ||
60 | EAPI void | ||
61 | ecore_x_icccm_command_get(Ecore_X_Window win, | ||
62 | int *argc, | ||
63 | char ***argv) | ||
64 | { | ||
65 | xcb_get_property_cookie_t cookie; | ||
66 | xcb_get_property_reply_t *reply; | ||
67 | int len = 0; | ||
68 | char **v, *data, *cp, *start; | ||
69 | int c = 0, i = 0, j = 0; | ||
70 | |||
71 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
72 | CHECK_XCB_CONN; | ||
73 | |||
74 | if (argc) *argc = 0; | ||
75 | if (argv) *argv = NULL; | ||
76 | |||
77 | cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, win, | ||
78 | ECORE_X_ATOM_WM_COMMAND, | ||
79 | XCB_GET_PROPERTY_TYPE_ANY, | ||
80 | 0, 1000000L); | ||
81 | reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL); | ||
82 | if (!reply) return; | ||
83 | |||
84 | if ((reply->type != ECORE_X_ATOM_STRING) || (reply->format != 8)) | ||
85 | { | ||
86 | free(reply); | ||
87 | return; | ||
88 | } | ||
89 | |||
90 | len = reply->value_len; | ||
91 | if (len < 1) | ||
92 | { | ||
93 | free(reply); | ||
94 | return; | ||
95 | } | ||
96 | |||
97 | data = (char *)xcb_get_property_value(reply); | ||
98 | if (len && (data[len - 1] == '\0')) | ||
99 | len--; | ||
100 | |||
101 | c = 1; | ||
102 | for (cp = (char *)data, i = len; i > 0; cp++, i--) | ||
103 | if (*cp == '\0') c++; | ||
104 | |||
105 | v = (char **)malloc((c + 1) * sizeof(char *)); | ||
106 | if (!v) | ||
107 | { | ||
108 | free(reply); | ||
109 | return; | ||
110 | } | ||
111 | |||
112 | start = (char *)malloc((len + 1) * sizeof(char)); | ||
113 | if (!start) | ||
114 | { | ||
115 | free(reply); | ||
116 | free(v); | ||
117 | return; | ||
118 | } | ||
119 | |||
120 | memcpy(start, (char *)data, len); | ||
121 | start[len] = '\0'; | ||
122 | for (cp = start, i = len + 1, j = 0; i > 0; cp++, i--) | ||
123 | { | ||
124 | if (*cp == '\0') | ||
125 | { | ||
126 | v[j] = start; | ||
127 | start = (cp + 1); | ||
128 | j++; | ||
129 | } | ||
130 | } | ||
131 | |||
132 | if (c < 1) | ||
133 | { | ||
134 | free(reply); | ||
135 | free(v); | ||
136 | return; | ||
137 | } | ||
138 | |||
139 | if (argc) *argc = c; | ||
140 | |||
141 | if (argv) | ||
142 | { | ||
143 | (*argv) = malloc(c * sizeof(char *)); | ||
144 | if (!*argv) | ||
145 | { | ||
146 | free(reply); | ||
147 | free(v); | ||
148 | if (argc) *argc = 0; | ||
149 | return; | ||
150 | } | ||
151 | |||
152 | for (i = 0; i < c; i++) | ||
153 | { | ||
154 | if (v[i]) | ||
155 | (*argv)[i] = strdup(v[i]); | ||
156 | else | ||
157 | (*argv)[i] = strdup(""); | ||
158 | } | ||
159 | } | ||
160 | |||
161 | free(reply); | ||
162 | free(v); | ||
163 | } | ||
164 | |||
165 | EAPI char * | ||
166 | ecore_x_icccm_title_get(Ecore_X_Window win) | ||
167 | { | ||
168 | xcb_get_property_cookie_t cookie; | ||
169 | #ifdef OLD_XCB_VERSION | ||
170 | xcb_get_text_property_reply_t prop; | ||
171 | #else | ||
172 | xcb_icccm_get_text_property_reply_t prop; | ||
173 | #endif | ||
174 | uint8_t ret = 0; | ||
175 | char *title = NULL; | ||
176 | |||
177 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
178 | CHECK_XCB_CONN; | ||
179 | |||
180 | if (!win) return NULL; | ||
181 | #ifdef OLD_XCB_VERSION | ||
182 | cookie = xcb_get_wm_name_unchecked(_ecore_xcb_conn, win); | ||
183 | ret = xcb_get_wm_name_reply(_ecore_xcb_conn, cookie, &prop, NULL); | ||
184 | #else | ||
185 | cookie = xcb_icccm_get_wm_name_unchecked(_ecore_xcb_conn, win); | ||
186 | ret = xcb_icccm_get_wm_name_reply(_ecore_xcb_conn, cookie, &prop, NULL); | ||
187 | #endif | ||
188 | if (ret == 0) return NULL; | ||
189 | if (prop.name_len < 1) | ||
190 | { | ||
191 | #ifdef OLD_XCB_VERSION | ||
192 | xcb_get_text_property_reply_wipe(&prop); | ||
193 | #else | ||
194 | xcb_icccm_get_text_property_reply_wipe(&prop); | ||
195 | #endif | ||
196 | return NULL; | ||
197 | } | ||
198 | |||
199 | if (!(title = malloc((prop.name_len + 1) * sizeof(char *)))) | ||
200 | { | ||
201 | #ifdef OLD_XCB_VERSION | ||
202 | xcb_get_text_property_reply_wipe(&prop); | ||
203 | #else | ||
204 | xcb_icccm_get_text_property_reply_wipe(&prop); | ||
205 | #endif | ||
206 | return NULL; | ||
207 | } | ||
208 | memcpy(title, prop.name, sizeof(char *) * prop.name_len); | ||
209 | title[prop.name_len] = '\0'; | ||
210 | |||
211 | if (prop.encoding != ECORE_X_ATOM_UTF8_STRING) | ||
212 | { | ||
213 | Ecore_Xcb_Textproperty tp; | ||
214 | int count = 0; | ||
215 | char **list = NULL; | ||
216 | Eina_Bool ret = EINA_FALSE; | ||
217 | |||
218 | tp.value = strdup(title); | ||
219 | tp.nitems = prop.name_len; | ||
220 | tp.encoding = prop.encoding; | ||
221 | #ifdef HAVE_ICONV | ||
222 | ret = _ecore_xcb_utf8_textproperty_to_textlist(&tp, &list, &count); | ||
223 | #else | ||
224 | ret = _ecore_xcb_mb_textproperty_to_textlist(&tp, &list, &count); | ||
225 | #endif | ||
226 | if (ret) | ||
227 | { | ||
228 | if (count > 0) | ||
229 | title = strdup(list[0]); | ||
230 | |||
231 | if (list) free(list); | ||
232 | } | ||
233 | } | ||
234 | |||
235 | #ifdef OLD_XCB_VERSION | ||
236 | xcb_get_text_property_reply_wipe(&prop); | ||
237 | #else | ||
238 | xcb_icccm_get_text_property_reply_wipe(&prop); | ||
239 | #endif | ||
240 | return title; | ||
241 | } | ||
242 | |||
243 | EAPI void | ||
244 | ecore_x_icccm_title_set(Ecore_X_Window win, | ||
245 | const char *title) | ||
246 | { | ||
247 | Ecore_Xcb_Textproperty prop; | ||
248 | char *list[1]; | ||
249 | Eina_Bool ret = EINA_FALSE; | ||
250 | |||
251 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
252 | CHECK_XCB_CONN; | ||
253 | |||
254 | if (!title) return; | ||
255 | |||
256 | prop.value = NULL; | ||
257 | list[0] = strdup(title); | ||
258 | |||
259 | #ifdef HAVE_ICONV | ||
260 | ret = _ecore_xcb_utf8_textlist_to_textproperty(list, 1, XcbUTF8StringStyle, | ||
261 | &prop); | ||
262 | #else | ||
263 | ret = _ecore_xcb_mb_textlist_to_textproperty(list, 1, XcbStdICCTextStyle, | ||
264 | &prop); | ||
265 | #endif | ||
266 | |||
267 | if (ret) | ||
268 | { | ||
269 | #ifdef OLD_XCB_VERSION | ||
270 | xcb_set_wm_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, | ||
271 | strlen(prop.value), prop.value); | ||
272 | #else | ||
273 | xcb_icccm_set_wm_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, 8, | ||
274 | strlen(prop.value), prop.value); | ||
275 | #endif | ||
276 | if (prop.value) free(prop.value); | ||
277 | } | ||
278 | else | ||
279 | #ifdef OLD_XCB_VERSION | ||
280 | xcb_set_wm_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, | ||
281 | strlen(title), title); | ||
282 | #else | ||
283 | xcb_icccm_set_wm_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, 8, | ||
284 | strlen(title), title); | ||
285 | #endif | ||
286 | free(list[0]); | ||
287 | } | ||
288 | |||
289 | /** | ||
290 | * Get a window name & class. | ||
291 | * @param win The window | ||
292 | * @param n The name string | ||
293 | * @param c The class string | ||
294 | * | ||
295 | * Get a window name * class | ||
296 | */ | ||
297 | EAPI void | ||
298 | ecore_x_icccm_name_class_get(Ecore_X_Window win, | ||
299 | char **name, | ||
300 | char **class) | ||
301 | { | ||
302 | xcb_get_property_cookie_t cookie; | ||
303 | #ifdef OLD_XCB_VERSION | ||
304 | xcb_get_wm_class_reply_t prop; | ||
305 | #else | ||
306 | xcb_icccm_get_wm_class_reply_t prop; | ||
307 | #endif | ||
308 | uint8_t ret = 0; | ||
309 | |||
310 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
311 | CHECK_XCB_CONN; | ||
312 | |||
313 | if (name) *name = NULL; | ||
314 | if (class) *class = NULL; | ||
315 | |||
316 | #ifdef OLD_XCB_VERSION | ||
317 | cookie = xcb_get_wm_class_unchecked(_ecore_xcb_conn, win); | ||
318 | ret = xcb_get_wm_class_reply(_ecore_xcb_conn, cookie, &prop, NULL); | ||
319 | #else | ||
320 | cookie = xcb_icccm_get_wm_class_unchecked(_ecore_xcb_conn, win); | ||
321 | ret = xcb_icccm_get_wm_class_reply(_ecore_xcb_conn, cookie, &prop, NULL); | ||
322 | #endif | ||
323 | if (ret == 0) return; | ||
324 | |||
325 | if (name) *name = strdup(prop.instance_name); | ||
326 | if (class) *class = strdup(prop.class_name); | ||
327 | |||
328 | #ifdef OLD_XCB_VERSION | ||
329 | xcb_get_wm_class_reply_wipe(&prop); | ||
330 | #else | ||
331 | xcb_icccm_get_wm_class_reply_wipe(&prop); | ||
332 | #endif | ||
333 | } | ||
334 | |||
335 | /** | ||
336 | * Set a window name & class. | ||
337 | * @param win The window | ||
338 | * @param n The name string | ||
339 | * @param c The class string | ||
340 | * | ||
341 | * Set a window name * class | ||
342 | */ | ||
343 | EAPI void | ||
344 | ecore_x_icccm_name_class_set(Ecore_X_Window win, | ||
345 | const char *name, | ||
346 | const char *class) | ||
347 | { | ||
348 | char *class_string, *s; | ||
349 | int length_name, length_class; | ||
350 | |||
351 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
352 | CHECK_XCB_CONN; | ||
353 | |||
354 | length_name = strlen(name); | ||
355 | length_class = strlen(class); | ||
356 | class_string = | ||
357 | (char *)malloc(sizeof(char) * (length_name + length_class + 2)); | ||
358 | if (!class_string) return; | ||
359 | |||
360 | s = class_string; | ||
361 | if (length_name) | ||
362 | { | ||
363 | strcpy(s, name); | ||
364 | s += length_name + 1; | ||
365 | } | ||
366 | else | ||
367 | *s++ = '\0'; | ||
368 | |||
369 | if (length_class) | ||
370 | strcpy(s, class); | ||
371 | else | ||
372 | *s = '\0'; | ||
373 | |||
374 | xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, win, | ||
375 | ECORE_X_ATOM_WM_CLASS, ECORE_X_ATOM_STRING, 8, | ||
376 | length_name + length_class + 2, (void *)class_string); | ||
377 | free(class_string); | ||
378 | } | ||
379 | |||
380 | /** | ||
381 | * Specify that a window is transient for another top-level window and should be handled accordingly. | ||
382 | * @param win the transient window | ||
383 | * @param forwin the toplevel window | ||
384 | */ | ||
385 | EAPI void | ||
386 | ecore_x_icccm_transient_for_set(Ecore_X_Window win, | ||
387 | Ecore_X_Window forwindow) | ||
388 | { | ||
389 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
390 | CHECK_XCB_CONN; | ||
391 | |||
392 | xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, win, | ||
393 | ECORE_X_ATOM_WM_TRANSIENT_FOR, ECORE_X_ATOM_WINDOW, 32, | ||
394 | 1, (void *)&forwindow); | ||
395 | } | ||
396 | |||
397 | /** | ||
398 | * Remove the transient_for setting from a window. | ||
399 | * @param The window | ||
400 | */ | ||
401 | EAPI void | ||
402 | ecore_x_icccm_transient_for_unset(Ecore_X_Window win) | ||
403 | { | ||
404 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
405 | |||
406 | ecore_x_window_prop_property_del(win, ECORE_X_ATOM_WM_TRANSIENT_FOR); | ||
407 | } | ||
408 | |||
409 | /** | ||
410 | * Get the window this window is transient for, if any. | ||
411 | * @param win The window to check | ||
412 | * @return The window ID of the top-level window, or 0 if the property does not exist. | ||
413 | */ | ||
414 | EAPI Ecore_X_Window | ||
415 | ecore_x_icccm_transient_for_get(Ecore_X_Window win) | ||
416 | { | ||
417 | Ecore_X_Window forwin = 0; | ||
418 | xcb_get_property_cookie_t cookie; | ||
419 | |||
420 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
421 | CHECK_XCB_CONN; | ||
422 | |||
423 | #ifdef OLD_XCB_VERSION | ||
424 | cookie = xcb_get_wm_transient_for_unchecked(_ecore_xcb_conn, win); | ||
425 | xcb_get_wm_transient_for_reply(_ecore_xcb_conn, cookie, &forwin, NULL); | ||
426 | #else | ||
427 | cookie = xcb_icccm_get_wm_transient_for_unchecked(_ecore_xcb_conn, win); | ||
428 | xcb_icccm_get_wm_transient_for_reply(_ecore_xcb_conn, cookie, &forwin, NULL); | ||
429 | #endif | ||
430 | |||
431 | return forwin; | ||
432 | } | ||
433 | |||
434 | /** | ||
435 | * Get the window role. | ||
436 | * @param win The window | ||
437 | * @return The window's role string. | ||
438 | */ | ||
439 | EAPI char * | ||
440 | ecore_x_icccm_window_role_get(Ecore_X_Window win) | ||
441 | { | ||
442 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
443 | |||
444 | return ecore_x_window_prop_string_get(win, ECORE_X_ATOM_WM_WINDOW_ROLE); | ||
445 | } | ||
446 | |||
447 | /** | ||
448 | * Set the window role hint. | ||
449 | * @param win The window | ||
450 | * @param role The role string | ||
451 | */ | ||
452 | EAPI void | ||
453 | ecore_x_icccm_window_role_set(Ecore_X_Window win, | ||
454 | const char *role) | ||
455 | { | ||
456 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
457 | |||
458 | ecore_x_window_prop_string_set(win, ECORE_X_ATOM_WM_WINDOW_ROLE, role); | ||
459 | } | ||
460 | |||
461 | /** | ||
462 | * Get the window's client leader. | ||
463 | * @param win The window | ||
464 | * @return The window's client leader window, or 0 if unset | ||
465 | */ | ||
466 | EAPI Ecore_X_Window | ||
467 | ecore_x_icccm_client_leader_get(Ecore_X_Window win) | ||
468 | { | ||
469 | Ecore_X_Window leader; | ||
470 | |||
471 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
472 | |||
473 | if (ecore_x_window_prop_window_get(win, ECORE_X_ATOM_WM_CLIENT_LEADER, | ||
474 | &leader, 1) > 0) | ||
475 | return leader; | ||
476 | |||
477 | return 0; | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Set the window's client leader. | ||
482 | * @param win The window | ||
483 | * @param l The client leader window | ||
484 | * | ||
485 | * All non-transient top-level windows created by an app other than | ||
486 | * the main window must have this property set to the app's main window. | ||
487 | */ | ||
488 | EAPI void | ||
489 | ecore_x_icccm_client_leader_set(Ecore_X_Window win, | ||
490 | Ecore_X_Window leader) | ||
491 | { | ||
492 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
493 | |||
494 | ecore_x_window_prop_window_set(win, ECORE_X_ATOM_WM_CLIENT_LEADER, | ||
495 | &leader, 1); | ||
496 | } | ||
497 | |||
498 | EAPI Ecore_X_Window_State_Hint | ||
499 | ecore_x_icccm_state_get(Ecore_X_Window win) | ||
500 | { | ||
501 | xcb_get_property_cookie_t cookie; | ||
502 | xcb_get_property_reply_t *reply; | ||
503 | Ecore_X_Window_State_Hint hint = ECORE_X_WINDOW_STATE_HINT_NONE; | ||
504 | uint8_t *prop; | ||
505 | |||
506 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
507 | CHECK_XCB_CONN; | ||
508 | |||
509 | cookie = | ||
510 | xcb_get_property_unchecked(_ecore_xcb_conn, 0, win, | ||
511 | ECORE_X_ATOM_WM_STATE, ECORE_X_ATOM_WM_STATE, | ||
512 | 0L, 0x7fffffff); | ||
513 | reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL); | ||
514 | if (!reply) return hint; | ||
515 | if ((reply->type == 0) || (reply->format != 8) || (reply->value_len != 2)) | ||
516 | { | ||
517 | free(reply); | ||
518 | return hint; | ||
519 | } | ||
520 | |||
521 | prop = (uint8_t *)xcb_get_property_value(reply); | ||
522 | #ifdef OLD_XCB_VERSION | ||
523 | switch (prop[0]) | ||
524 | { | ||
525 | case XCB_WM_STATE_WITHDRAWN: | ||
526 | hint = ECORE_X_WINDOW_STATE_HINT_WITHDRAWN; | ||
527 | break; | ||
528 | |||
529 | case XCB_WM_STATE_NORMAL: | ||
530 | hint = ECORE_X_WINDOW_STATE_HINT_NORMAL; | ||
531 | break; | ||
532 | |||
533 | case XCB_WM_STATE_ICONIC: | ||
534 | hint = ECORE_X_WINDOW_STATE_HINT_ICONIC; | ||
535 | break; | ||
536 | |||
537 | default: | ||
538 | break; | ||
539 | } | ||
540 | #else | ||
541 | switch (prop[0]) | ||
542 | { | ||
543 | case XCB_ICCCM_WM_STATE_WITHDRAWN: | ||
544 | hint = ECORE_X_WINDOW_STATE_HINT_WITHDRAWN; | ||
545 | break; | ||
546 | |||
547 | case XCB_ICCCM_WM_STATE_NORMAL: | ||
548 | hint = ECORE_X_WINDOW_STATE_HINT_NORMAL; | ||
549 | break; | ||
550 | |||
551 | case XCB_ICCCM_WM_STATE_ICONIC: | ||
552 | hint = ECORE_X_WINDOW_STATE_HINT_ICONIC; | ||
553 | break; | ||
554 | |||
555 | default: | ||
556 | break; | ||
557 | } | ||
558 | #endif | ||
559 | |||
560 | free(reply); | ||
561 | return hint; | ||
562 | } | ||
563 | |||
564 | EAPI void | ||
565 | ecore_x_icccm_state_set(Ecore_X_Window win, | ||
566 | Ecore_X_Window_State_Hint state) | ||
567 | { | ||
568 | #ifdef OLD_XCB_VERSION | ||
569 | xcb_wm_hints_t hints; | ||
570 | #else | ||
571 | xcb_icccm_wm_hints_t hints; | ||
572 | #endif | ||
573 | |||
574 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
575 | CHECK_XCB_CONN; | ||
576 | |||
577 | #ifdef OLD_XCB_VERSION | ||
578 | xcb_wm_hints_set_none(&hints); | ||
579 | |||
580 | hints.flags = XCB_WM_HINT_STATE; | ||
581 | |||
582 | if (state == ECORE_X_WINDOW_STATE_HINT_WITHDRAWN) | ||
583 | xcb_wm_hints_set_withdrawn(&hints); | ||
584 | else if (state == ECORE_X_WINDOW_STATE_HINT_NORMAL) | ||
585 | xcb_wm_hints_set_normal(&hints); | ||
586 | else if (state == ECORE_X_WINDOW_STATE_HINT_ICONIC) | ||
587 | xcb_wm_hints_set_iconic(&hints); | ||
588 | |||
589 | xcb_set_wm_hints(_ecore_xcb_conn, win, &hints); | ||
590 | #else | ||
591 | xcb_icccm_wm_hints_set_none(&hints); | ||
592 | |||
593 | hints.flags = XCB_ICCCM_WM_HINT_STATE; | ||
594 | |||
595 | if (state == ECORE_X_WINDOW_STATE_HINT_WITHDRAWN) | ||
596 | xcb_icccm_wm_hints_set_withdrawn(&hints); | ||
597 | else if (state == ECORE_X_WINDOW_STATE_HINT_NORMAL) | ||
598 | xcb_icccm_wm_hints_set_normal(&hints); | ||
599 | else if (state == ECORE_X_WINDOW_STATE_HINT_ICONIC) | ||
600 | xcb_icccm_wm_hints_set_iconic(&hints); | ||
601 | |||
602 | xcb_icccm_set_wm_hints(_ecore_xcb_conn, win, &hints); | ||
603 | #endif | ||
604 | } | ||
605 | |||
606 | EAPI void | ||
607 | ecore_x_icccm_delete_window_send(Ecore_X_Window win, | ||
608 | Ecore_X_Time t) | ||
609 | { | ||
610 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
611 | ecore_x_client_message32_send(win, ECORE_X_ATOM_WM_PROTOCOLS, | ||
612 | ECORE_X_EVENT_MASK_NONE, | ||
613 | ECORE_X_ATOM_WM_DELETE_WINDOW, t, 0, 0, 0); | ||
614 | } | ||
615 | |||
616 | EAPI void | ||
617 | ecore_x_icccm_hints_set(Ecore_X_Window win, | ||
618 | Eina_Bool accepts_focus, | ||
619 | Ecore_X_Window_State_Hint initial_state, | ||
620 | Ecore_X_Pixmap icon_pixmap, | ||
621 | Ecore_X_Pixmap icon_mask, | ||
622 | Ecore_X_Window icon_window, | ||
623 | Ecore_X_Window window_group, | ||
624 | Eina_Bool is_urgent) | ||
625 | { | ||
626 | #ifdef OLD_XCB_VERSION | ||
627 | xcb_wm_hints_t hints; | ||
628 | #else | ||
629 | xcb_icccm_wm_hints_t hints; | ||
630 | #endif | ||
631 | |||
632 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
633 | CHECK_XCB_CONN; | ||
634 | |||
635 | #ifdef OLD_XCB_VERSION | ||
636 | xcb_wm_hints_set_none(&hints); | ||
637 | xcb_wm_hints_set_input(&hints, accepts_focus); | ||
638 | |||
639 | if (initial_state == ECORE_X_WINDOW_STATE_HINT_WITHDRAWN) | ||
640 | xcb_wm_hints_set_withdrawn(&hints); | ||
641 | else if (initial_state == ECORE_X_WINDOW_STATE_HINT_NORMAL) | ||
642 | xcb_wm_hints_set_normal(&hints); | ||
643 | else if (initial_state == ECORE_X_WINDOW_STATE_HINT_ICONIC) | ||
644 | xcb_wm_hints_set_iconic(&hints); | ||
645 | |||
646 | if (icon_pixmap != 0) xcb_wm_hints_set_icon_pixmap(&hints, icon_pixmap); | ||
647 | if (icon_mask != 0) xcb_wm_hints_set_icon_mask(&hints, icon_mask); | ||
648 | if (icon_window != 0) xcb_wm_hints_set_icon_window(&hints, icon_window); | ||
649 | if (window_group != 0) xcb_wm_hints_set_window_group(&hints, window_group); | ||
650 | if (is_urgent) xcb_wm_hints_set_urgency(&hints); | ||
651 | |||
652 | xcb_set_wm_hints(_ecore_xcb_conn, win, &hints); | ||
653 | #else | ||
654 | xcb_icccm_wm_hints_set_none(&hints); | ||
655 | xcb_icccm_wm_hints_set_input(&hints, accepts_focus); | ||
656 | |||
657 | if (initial_state == ECORE_X_WINDOW_STATE_HINT_WITHDRAWN) | ||
658 | xcb_icccm_wm_hints_set_withdrawn(&hints); | ||
659 | else if (initial_state == ECORE_X_WINDOW_STATE_HINT_NORMAL) | ||
660 | xcb_icccm_wm_hints_set_normal(&hints); | ||
661 | else if (initial_state == ECORE_X_WINDOW_STATE_HINT_ICONIC) | ||
662 | xcb_icccm_wm_hints_set_iconic(&hints); | ||
663 | |||
664 | if (icon_pixmap != 0) | ||
665 | xcb_icccm_wm_hints_set_icon_pixmap(&hints, icon_pixmap); | ||
666 | if (icon_mask != 0) | ||
667 | xcb_icccm_wm_hints_set_icon_mask(&hints, icon_mask); | ||
668 | if (icon_window != 0) | ||
669 | xcb_icccm_wm_hints_set_icon_window(&hints, icon_window); | ||
670 | if (window_group != 0) | ||
671 | xcb_icccm_wm_hints_set_window_group(&hints, window_group); | ||
672 | if (is_urgent) | ||
673 | xcb_icccm_wm_hints_set_urgency(&hints); | ||
674 | |||
675 | xcb_icccm_set_wm_hints(_ecore_xcb_conn, win, &hints); | ||
676 | #endif | ||
677 | } | ||
678 | |||
679 | EAPI Eina_Bool | ||
680 | ecore_x_icccm_hints_get(Ecore_X_Window win, | ||
681 | Eina_Bool *accepts_focus, | ||
682 | Ecore_X_Window_State_Hint *initial_state, | ||
683 | Ecore_X_Pixmap *icon_pixmap, | ||
684 | Ecore_X_Pixmap *icon_mask, | ||
685 | Ecore_X_Window *icon_window, | ||
686 | Ecore_X_Window *window_group, | ||
687 | Eina_Bool *is_urgent) | ||
688 | { | ||
689 | xcb_get_property_cookie_t cookie; | ||
690 | #ifdef OLD_XCB_VERSION | ||
691 | xcb_wm_hints_t hints; | ||
692 | #else | ||
693 | xcb_icccm_wm_hints_t hints; | ||
694 | #endif | ||
695 | uint8_t ret = 0; | ||
696 | |||
697 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
698 | CHECK_XCB_CONN; | ||
699 | |||
700 | if (accepts_focus) *accepts_focus = EINA_TRUE; | ||
701 | if (initial_state) *initial_state = ECORE_X_WINDOW_STATE_HINT_NORMAL; | ||
702 | if (icon_pixmap) *icon_pixmap = 0; | ||
703 | if (icon_mask) *icon_mask = 0; | ||
704 | if (icon_window) *icon_window = 0; | ||
705 | if (window_group) *window_group = 0; | ||
706 | if (is_urgent) *is_urgent = EINA_FALSE; | ||
707 | |||
708 | #ifdef OLD_XCB_VERSION | ||
709 | xcb_wm_hints_set_none(&hints); | ||
710 | cookie = xcb_get_wm_hints_unchecked(_ecore_xcb_conn, win); | ||
711 | ret = xcb_get_wm_hints_reply(_ecore_xcb_conn, cookie, &hints, NULL); | ||
712 | #else | ||
713 | xcb_icccm_wm_hints_set_none(&hints); | ||
714 | cookie = xcb_icccm_get_wm_hints_unchecked(_ecore_xcb_conn, win); | ||
715 | ret = xcb_icccm_get_wm_hints_reply(_ecore_xcb_conn, cookie, &hints, NULL); | ||
716 | #endif | ||
717 | if (!ret) return EINA_FALSE; | ||
718 | |||
719 | #ifdef OLD_XCB_VERSION | ||
720 | if ((hints.flags & XCB_WM_HINT_INPUT) && (accepts_focus)) | ||
721 | #else | ||
722 | if ((hints.flags & XCB_ICCCM_WM_HINT_INPUT) && (accepts_focus)) | ||
723 | #endif | ||
724 | { | ||
725 | if (hints.input) | ||
726 | *accepts_focus = EINA_TRUE; | ||
727 | else | ||
728 | *accepts_focus = EINA_FALSE; | ||
729 | } | ||
730 | |||
731 | #ifdef OLD_XCB_VERSION | ||
732 | if ((hints.flags & XCB_WM_HINT_STATE) && (initial_state)) | ||
733 | { | ||
734 | if (hints.initial_state == XCB_WM_STATE_WITHDRAWN) | ||
735 | *initial_state = ECORE_X_WINDOW_STATE_HINT_WITHDRAWN; | ||
736 | else if (hints.initial_state == XCB_WM_STATE_NORMAL) | ||
737 | *initial_state = ECORE_X_WINDOW_STATE_HINT_NORMAL; | ||
738 | else if (hints.initial_state == XCB_WM_STATE_ICONIC) | ||
739 | *initial_state = ECORE_X_WINDOW_STATE_HINT_ICONIC; | ||
740 | } | ||
741 | |||
742 | if ((hints.flags & XCB_WM_HINT_ICON_PIXMAP) && (icon_pixmap)) | ||
743 | *icon_pixmap = hints.icon_pixmap; | ||
744 | |||
745 | if ((hints.flags & XCB_WM_HINT_ICON_MASK) && (icon_mask)) | ||
746 | *icon_mask = hints.icon_mask; | ||
747 | |||
748 | if ((hints.flags & XCB_WM_HINT_ICON_WINDOW) && (icon_window)) | ||
749 | *icon_window = hints.icon_window; | ||
750 | |||
751 | if ((hints.flags & XCB_WM_HINT_WINDOW_GROUP) && (window_group)) | ||
752 | *window_group = hints.window_group; | ||
753 | |||
754 | if ((hints.flags & XCB_WM_HINT_X_URGENCY) && (is_urgent)) | ||
755 | *is_urgent = EINA_TRUE; | ||
756 | #else | ||
757 | if ((hints.flags & XCB_ICCCM_WM_HINT_STATE) && (initial_state)) | ||
758 | { | ||
759 | if (hints.initial_state == XCB_ICCCM_WM_STATE_WITHDRAWN) | ||
760 | *initial_state = ECORE_X_WINDOW_STATE_HINT_WITHDRAWN; | ||
761 | else if (hints.initial_state == XCB_ICCCM_WM_STATE_NORMAL) | ||
762 | *initial_state = ECORE_X_WINDOW_STATE_HINT_NORMAL; | ||
763 | else if (hints.initial_state == XCB_ICCCM_WM_STATE_ICONIC) | ||
764 | *initial_state = ECORE_X_WINDOW_STATE_HINT_ICONIC; | ||
765 | } | ||
766 | |||
767 | if ((hints.flags & XCB_ICCCM_WM_HINT_ICON_PIXMAP) && (icon_pixmap)) | ||
768 | *icon_pixmap = hints.icon_pixmap; | ||
769 | |||
770 | if ((hints.flags & XCB_ICCCM_WM_HINT_ICON_MASK) && (icon_mask)) | ||
771 | *icon_mask = hints.icon_mask; | ||
772 | |||
773 | if ((hints.flags & XCB_ICCCM_WM_HINT_ICON_WINDOW) && (icon_window)) | ||
774 | *icon_window = hints.icon_window; | ||
775 | |||
776 | if ((hints.flags & XCB_ICCCM_WM_HINT_WINDOW_GROUP) && (window_group)) | ||
777 | *window_group = hints.window_group; | ||
778 | |||
779 | if ((hints.flags & XCB_ICCCM_WM_HINT_X_URGENCY) && (is_urgent)) | ||
780 | *is_urgent = EINA_TRUE; | ||
781 | #endif | ||
782 | |||
783 | return EINA_TRUE; | ||
784 | } | ||
785 | |||
786 | /** | ||
787 | * Get a window icon name. | ||
788 | * @param win The window | ||
789 | * @return The windows icon name string | ||
790 | * | ||
791 | * Return the icon name of a window. String must be free'd when done with. | ||
792 | */ | ||
793 | EAPI char * | ||
794 | ecore_x_icccm_icon_name_get(Ecore_X_Window win) | ||
795 | { | ||
796 | xcb_get_property_cookie_t cookie; | ||
797 | #ifdef OLD_XCB_VERSION | ||
798 | xcb_get_text_property_reply_t prop; | ||
799 | #else | ||
800 | xcb_icccm_get_text_property_reply_t prop; | ||
801 | #endif | ||
802 | uint8_t ret = 0; | ||
803 | char *tmp = NULL; | ||
804 | |||
805 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
806 | CHECK_XCB_CONN; | ||
807 | |||
808 | if (!win) return NULL; | ||
809 | |||
810 | #ifdef OLD_XCB_VERSION | ||
811 | cookie = xcb_get_wm_icon_name_unchecked(_ecore_xcb_conn, win); | ||
812 | ret = xcb_get_wm_icon_name_reply(_ecore_xcb_conn, cookie, &prop, NULL); | ||
813 | #else | ||
814 | cookie = xcb_icccm_get_wm_icon_name_unchecked(_ecore_xcb_conn, win); | ||
815 | ret = xcb_icccm_get_wm_icon_name_reply(_ecore_xcb_conn, cookie, &prop, NULL); | ||
816 | #endif | ||
817 | if (ret == 0) return NULL; | ||
818 | |||
819 | if (prop.name_len < 1) | ||
820 | { | ||
821 | #ifdef OLD_XCB_VERSION | ||
822 | xcb_get_text_property_reply_wipe(&prop); | ||
823 | #else | ||
824 | xcb_icccm_get_text_property_reply_wipe(&prop); | ||
825 | #endif | ||
826 | return NULL; | ||
827 | } | ||
828 | |||
829 | if (!(tmp = malloc((prop.name_len + 1) * sizeof(char *)))) | ||
830 | { | ||
831 | #ifdef OLD_XCB_VERSION | ||
832 | xcb_get_text_property_reply_wipe(&prop); | ||
833 | #else | ||
834 | xcb_icccm_get_text_property_reply_wipe(&prop); | ||
835 | #endif | ||
836 | return NULL; | ||
837 | } | ||
838 | memcpy(tmp, prop.name, sizeof(char *) * prop.name_len); | ||
839 | tmp[prop.name_len] = '\0'; | ||
840 | |||
841 | if (prop.encoding != ECORE_X_ATOM_UTF8_STRING) | ||
842 | { | ||
843 | Ecore_Xcb_Textproperty tp; | ||
844 | int count = 0; | ||
845 | char **list = NULL; | ||
846 | Eina_Bool ret = EINA_FALSE; | ||
847 | |||
848 | tp.value = strdup(tmp); | ||
849 | tp.nitems = prop.name_len; | ||
850 | tp.encoding = prop.encoding; | ||
851 | #ifdef HAVE_ICONV | ||
852 | ret = _ecore_xcb_utf8_textproperty_to_textlist(&tp, &list, &count); | ||
853 | #else | ||
854 | ret = _ecore_xcb_mb_textproperty_to_textlist(&tp, &list, &count); | ||
855 | #endif | ||
856 | if (ret) | ||
857 | { | ||
858 | if (count > 0) | ||
859 | tmp = strdup(list[0]); | ||
860 | |||
861 | if (list) free(list); | ||
862 | } | ||
863 | } | ||
864 | |||
865 | #ifdef OLD_XCB_VERSION | ||
866 | xcb_get_text_property_reply_wipe(&prop); | ||
867 | #else | ||
868 | xcb_icccm_get_text_property_reply_wipe(&prop); | ||
869 | #endif | ||
870 | return tmp; | ||
871 | } | ||
872 | |||
873 | /** | ||
874 | * Set a window icon name. | ||
875 | * @param win The window | ||
876 | * @param t The icon name string | ||
877 | * | ||
878 | * Set a window icon name | ||
879 | */ | ||
880 | EAPI void | ||
881 | ecore_x_icccm_icon_name_set(Ecore_X_Window win, | ||
882 | const char *name) | ||
883 | { | ||
884 | Ecore_Xcb_Textproperty prop; | ||
885 | char *list[1]; | ||
886 | Eina_Bool ret = EINA_FALSE; | ||
887 | |||
888 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
889 | CHECK_XCB_CONN; | ||
890 | |||
891 | if ((!win) || (!name)) return; | ||
892 | |||
893 | prop.value = NULL; | ||
894 | list[0] = strdup(name); | ||
895 | |||
896 | #ifdef HAVE_ICONV | ||
897 | ret = _ecore_xcb_utf8_textlist_to_textproperty(list, 1, XcbUTF8StringStyle, | ||
898 | &prop); | ||
899 | #else | ||
900 | ret = _ecore_xcb_mb_textlist_to_textproperty(list, 1, XcbStdICCTextStyle, | ||
901 | &prop); | ||
902 | #endif | ||
903 | |||
904 | if (ret) | ||
905 | { | ||
906 | #ifdef OLD_XCB_VERSION | ||
907 | xcb_set_wm_icon_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, | ||
908 | strlen(prop.value), prop.value); | ||
909 | #else | ||
910 | xcb_icccm_set_wm_icon_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, | ||
911 | 8, strlen(prop.value), prop.value); | ||
912 | #endif | ||
913 | if (prop.value) free(prop.value); | ||
914 | } | ||
915 | else | ||
916 | #ifdef OLD_XCB_VERSION | ||
917 | xcb_set_wm_icon_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, | ||
918 | strlen(name), name); | ||
919 | #else | ||
920 | xcb_icccm_set_wm_icon_name(_ecore_xcb_conn, win, ECORE_X_ATOM_STRING, | ||
921 | 8, strlen(name), name); | ||
922 | #endif | ||
923 | |||
924 | free(list[0]); | ||
925 | } | ||
926 | |||
927 | EAPI void | ||
928 | ecore_x_icccm_iconic_request_send(Ecore_X_Window win, | ||
929 | Ecore_X_Window root) | ||
930 | { | ||
931 | xcb_client_message_event_t ev; | ||
932 | |||
933 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
934 | CHECK_XCB_CONN; | ||
935 | |||
936 | if (!win) return; | ||
937 | if (!root) root = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
938 | |||
939 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
940 | |||
941 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
942 | ev.format = 32; | ||
943 | ev.window = win; | ||
944 | ev.type = ECORE_X_ATOM_WM_CHANGE_STATE; | ||
945 | #ifdef OLD_XCB_VERSION | ||
946 | ev.data.data32[0] = XCB_WM_STATE_ICONIC; | ||
947 | #else | ||
948 | ev.data.data32[0] = XCB_ICCCM_WM_STATE_ICONIC; | ||
949 | #endif | ||
950 | |||
951 | xcb_send_event(_ecore_xcb_conn, 0, root, | ||
952 | (XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | | ||
953 | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT), | ||
954 | (const char *)&ev); | ||
955 | // ecore_x_flush(); | ||
956 | } | ||
957 | |||
958 | /** | ||
959 | * Set or unset a wm protocol property. | ||
960 | * @param win The Window | ||
961 | * @param protocol The protocol to enable/disable | ||
962 | * @param on On/Off | ||
963 | */ | ||
964 | EAPI void | ||
965 | ecore_x_icccm_protocol_set(Ecore_X_Window win, | ||
966 | Ecore_X_WM_Protocol protocol, | ||
967 | Eina_Bool on) | ||
968 | { | ||
969 | Ecore_X_Atom proto; | ||
970 | xcb_get_property_cookie_t cookie; | ||
971 | #ifdef OLD_XCB_VERSION | ||
972 | xcb_get_wm_protocols_reply_t protos; | ||
973 | #else | ||
974 | xcb_icccm_get_wm_protocols_reply_t protos; | ||
975 | #endif | ||
976 | int i = 0, count = 0, set = 0; | ||
977 | |||
978 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
979 | CHECK_XCB_CONN; | ||
980 | |||
981 | if (protocol >= ECORE_X_WM_PROTOCOL_NUM) return; | ||
982 | proto = _ecore_xcb_atoms_wm_protocol[protocol]; | ||
983 | #ifdef OLD_XCB_VERSION | ||
984 | cookie = xcb_get_wm_protocols_unchecked(_ecore_xcb_conn, win, proto); | ||
985 | if (!xcb_get_wm_protocols_reply(_ecore_xcb_conn, cookie, &protos, NULL)) | ||
986 | #else | ||
987 | cookie = xcb_icccm_get_wm_protocols_unchecked(_ecore_xcb_conn, win, proto); | ||
988 | if (!xcb_icccm_get_wm_protocols_reply(_ecore_xcb_conn, cookie, &protos, NULL)) | ||
989 | #endif | ||
990 | count = 0; | ||
991 | else | ||
992 | count = protos.atoms_len; | ||
993 | |||
994 | for (i = 0; i < count; i++) | ||
995 | { | ||
996 | if (protos.atoms[i] == proto) | ||
997 | { | ||
998 | set = 1; | ||
999 | break; | ||
1000 | } | ||
1001 | } | ||
1002 | |||
1003 | if (on) | ||
1004 | { | ||
1005 | if (!set) | ||
1006 | { | ||
1007 | Ecore_X_Atom *atoms = NULL; | ||
1008 | |||
1009 | atoms = malloc((count + 1) * sizeof(Ecore_X_Atom)); | ||
1010 | if (atoms) | ||
1011 | { | ||
1012 | for (i = 0; i < count; i++) | ||
1013 | atoms[i] = protos.atoms[i]; | ||
1014 | atoms[count] = proto; | ||
1015 | #ifdef OLD_XCB_VERSION | ||
1016 | xcb_set_wm_protocols(_ecore_xcb_conn, | ||
1017 | ECORE_X_ATOM_WM_PROTOCOLS, | ||
1018 | win, count, atoms); | ||
1019 | #else | ||
1020 | xcb_icccm_set_wm_protocols(_ecore_xcb_conn, win, | ||
1021 | ECORE_X_ATOM_WM_PROTOCOLS, | ||
1022 | count, atoms); | ||
1023 | #endif | ||
1024 | free(atoms); | ||
1025 | } | ||
1026 | } | ||
1027 | } | ||
1028 | else | ||
1029 | { | ||
1030 | if (set) | ||
1031 | { | ||
1032 | for (i = 0; i < count; i++) | ||
1033 | { | ||
1034 | if (protos.atoms[i] == proto) | ||
1035 | { | ||
1036 | int j = 0; | ||
1037 | |||
1038 | for (j = (i + 1); j < count; j++) | ||
1039 | protos.atoms[j - 1] = protos.atoms[j]; | ||
1040 | if (count > 1) | ||
1041 | #ifdef OLD_XCB_VERSION | ||
1042 | xcb_set_wm_protocols(_ecore_xcb_conn, | ||
1043 | ECORE_X_ATOM_WM_PROTOCOLS, | ||
1044 | win, count - 1, protos.atoms); | ||
1045 | #else | ||
1046 | xcb_icccm_set_wm_protocols(_ecore_xcb_conn, win, | ||
1047 | ECORE_X_ATOM_WM_PROTOCOLS, | ||
1048 | count - 1, protos.atoms); | ||
1049 | #endif | ||
1050 | else | ||
1051 | ecore_x_window_prop_property_del(win, | ||
1052 | ECORE_X_ATOM_WM_PROTOCOLS); | ||
1053 | break; | ||
1054 | } | ||
1055 | } | ||
1056 | } | ||
1057 | } | ||
1058 | |||
1059 | #ifdef OLD_XCB_VERSION | ||
1060 | xcb_get_wm_protocols_reply_wipe(&protos); | ||
1061 | #else | ||
1062 | xcb_icccm_get_wm_protocols_reply_wipe(&protos); | ||
1063 | #endif | ||
1064 | } | ||
1065 | |||
1066 | /** | ||
1067 | * Determines whether a protocol is set for a window. | ||
1068 | * @param win The Window | ||
1069 | * @param protocol The protocol to query | ||
1070 | * @return 1 if the protocol is set, else 0. | ||
1071 | */ | ||
1072 | EAPI Eina_Bool | ||
1073 | ecore_x_icccm_protocol_isset(Ecore_X_Window win, | ||
1074 | Ecore_X_WM_Protocol protocol) | ||
1075 | { | ||
1076 | Ecore_X_Atom proto; | ||
1077 | Eina_Bool ret = EINA_FALSE; | ||
1078 | xcb_get_property_cookie_t cookie; | ||
1079 | #ifdef OLD_XCB_VERSION | ||
1080 | xcb_get_wm_protocols_reply_t reply; | ||
1081 | #else | ||
1082 | xcb_icccm_get_wm_protocols_reply_t reply; | ||
1083 | #endif | ||
1084 | uint8_t val = 0; | ||
1085 | unsigned int i = 0; | ||
1086 | |||
1087 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1088 | CHECK_XCB_CONN; | ||
1089 | |||
1090 | if (protocol >= ECORE_X_WM_PROTOCOL_NUM) return EINA_FALSE; | ||
1091 | |||
1092 | proto = _ecore_xcb_atoms_wm_protocol[protocol]; | ||
1093 | #ifdef OLD_XCB_VERSION | ||
1094 | cookie = xcb_get_wm_protocols_unchecked(_ecore_xcb_conn, win, proto); | ||
1095 | val = xcb_get_wm_protocols_reply(_ecore_xcb_conn, cookie, &reply, NULL); | ||
1096 | #else | ||
1097 | cookie = xcb_icccm_get_wm_protocols_unchecked(_ecore_xcb_conn, win, proto); | ||
1098 | val = xcb_icccm_get_wm_protocols_reply(_ecore_xcb_conn, cookie, &reply, NULL); | ||
1099 | #endif | ||
1100 | if (!val) return EINA_FALSE; | ||
1101 | |||
1102 | for (i = 0; i < reply.atoms_len; i++) | ||
1103 | if (reply.atoms[i] == proto) | ||
1104 | { | ||
1105 | ret = EINA_TRUE; | ||
1106 | break; | ||
1107 | } | ||
1108 | |||
1109 | #ifdef OLD_XCB_VERSION | ||
1110 | xcb_get_wm_protocols_reply_wipe(&reply); | ||
1111 | #else | ||
1112 | xcb_icccm_get_wm_protocols_reply_wipe(&reply); | ||
1113 | #endif | ||
1114 | |||
1115 | return ret; | ||
1116 | } | ||
1117 | |||
1118 | /** | ||
1119 | * Set protocol atoms explicitly | ||
1120 | * @param win The Window | ||
1121 | * @param protos An array of protocol atoms | ||
1122 | * @param num the number of members of the array | ||
1123 | */ | ||
1124 | EAPI void | ||
1125 | ecore_x_icccm_protocol_atoms_set(Ecore_X_Window win, | ||
1126 | Ecore_X_Atom *protos, | ||
1127 | int num) | ||
1128 | { | ||
1129 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1130 | CHECK_XCB_CONN; | ||
1131 | |||
1132 | if (num > 0) | ||
1133 | #ifdef OLD_XCB_VERSION | ||
1134 | xcb_set_wm_protocols(_ecore_xcb_conn, ECORE_X_ATOM_WM_PROTOCOLS, | ||
1135 | win, num, protos); | ||
1136 | #else | ||
1137 | xcb_icccm_set_wm_protocols(_ecore_xcb_conn, win, | ||
1138 | ECORE_X_ATOM_WM_PROTOCOLS, num, protos); | ||
1139 | #endif | ||
1140 | else | ||
1141 | ecore_x_window_prop_property_del(win, ECORE_X_ATOM_WM_PROTOCOLS); | ||
1142 | } | ||
1143 | |||
1144 | EAPI Eina_Bool | ||
1145 | ecore_x_icccm_size_pos_hints_get(Ecore_X_Window win, | ||
1146 | Eina_Bool *request_pos, | ||
1147 | Ecore_X_Gravity *gravity, | ||
1148 | int *min_w, | ||
1149 | int *min_h, | ||
1150 | int *max_w, | ||
1151 | int *max_h, | ||
1152 | int *base_w, | ||
1153 | int *base_h, | ||
1154 | int *step_x, | ||
1155 | int *step_y, | ||
1156 | double *min_aspect, | ||
1157 | double *max_aspect) | ||
1158 | { | ||
1159 | xcb_size_hints_t hints; | ||
1160 | xcb_get_property_cookie_t cookie; | ||
1161 | uint8_t ret = 0; | ||
1162 | int32_t minw = 0, minh = 0; | ||
1163 | int32_t maxw = 32767, maxh = 32767; | ||
1164 | int32_t basew = -1, baseh = -1; | ||
1165 | int32_t stepx = -1, stepy = -1; | ||
1166 | double mina = 0.0, maxa = 0.0; | ||
1167 | |||
1168 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1169 | CHECK_XCB_CONN; | ||
1170 | |||
1171 | if (request_pos) *request_pos = EINA_FALSE; | ||
1172 | if (gravity) *gravity = ECORE_X_GRAVITY_NW; | ||
1173 | if (min_w) *min_w = minw; | ||
1174 | if (min_h) *min_h = minh; | ||
1175 | if (max_w) *max_w = maxw; | ||
1176 | if (max_h) *max_h = maxh; | ||
1177 | if (base_w) *base_w = basew; | ||
1178 | if (base_h) *base_h = baseh; | ||
1179 | if (step_x) *step_x = stepx; | ||
1180 | if (step_y) *step_y = stepy; | ||
1181 | if (min_aspect) *min_aspect = mina; | ||
1182 | if (max_aspect) *max_aspect = maxa; | ||
1183 | |||
1184 | #ifdef OLD_XCB_VERSION | ||
1185 | cookie = xcb_get_wm_normal_hints_unchecked(_ecore_xcb_conn, win); | ||
1186 | ret = xcb_get_wm_normal_hints_reply(_ecore_xcb_conn, cookie, &hints, NULL); | ||
1187 | #else | ||
1188 | cookie = xcb_icccm_get_wm_normal_hints_unchecked(_ecore_xcb_conn, win); | ||
1189 | ret = xcb_icccm_get_wm_normal_hints_reply(_ecore_xcb_conn, cookie, | ||
1190 | &hints, NULL); | ||
1191 | #endif | ||
1192 | if (!ret) return EINA_FALSE; | ||
1193 | |||
1194 | #ifdef OLD_XCB_VERSION | ||
1195 | if ((hints.flags & XCB_SIZE_HINT_US_POSITION) || | ||
1196 | (hints.flags & XCB_SIZE_HINT_P_POSITION)) | ||
1197 | #else | ||
1198 | if ((hints.flags & XCB_ICCCM_SIZE_HINT_US_POSITION) || | ||
1199 | (hints.flags & XCB_ICCCM_SIZE_HINT_P_POSITION)) | ||
1200 | #endif | ||
1201 | { | ||
1202 | if (request_pos) *request_pos = EINA_TRUE; | ||
1203 | } | ||
1204 | |||
1205 | #ifdef OLD_XCB_VERSION | ||
1206 | if (hints.flags & XCB_SIZE_HINT_P_WIN_GRAVITY) | ||
1207 | #else | ||
1208 | if (hints.flags & XCB_ICCCM_SIZE_HINT_P_WIN_GRAVITY) | ||
1209 | #endif | ||
1210 | { | ||
1211 | if (gravity) *gravity = hints.win_gravity; | ||
1212 | } | ||
1213 | |||
1214 | #ifdef OLD_XCB_VERSION | ||
1215 | if (hints.flags & XCB_SIZE_HINT_P_MIN_SIZE) | ||
1216 | #else | ||
1217 | if (hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE) | ||
1218 | #endif | ||
1219 | { | ||
1220 | minw = hints.min_width; | ||
1221 | minh = hints.min_height; | ||
1222 | } | ||
1223 | |||
1224 | #ifdef OLD_XCB_VERSION | ||
1225 | if (hints.flags & XCB_SIZE_HINT_P_MAX_SIZE) | ||
1226 | #else | ||
1227 | if (hints.flags & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE) | ||
1228 | #endif | ||
1229 | { | ||
1230 | maxw = hints.max_width; | ||
1231 | maxh = hints.max_height; | ||
1232 | if (maxw < minw) maxw = minw; | ||
1233 | if (maxh < minh) maxh = minh; | ||
1234 | } | ||
1235 | |||
1236 | #ifdef OLD_XCB_VERSION | ||
1237 | if (hints.flags & XCB_SIZE_HINT_BASE_SIZE) | ||
1238 | #else | ||
1239 | if (hints.flags & XCB_ICCCM_SIZE_HINT_BASE_SIZE) | ||
1240 | #endif | ||
1241 | { | ||
1242 | basew = hints.base_width; | ||
1243 | baseh = hints.base_height; | ||
1244 | if (basew > minw) minw = basew; | ||
1245 | if (baseh > minh) minh = baseh; | ||
1246 | } | ||
1247 | |||
1248 | #ifdef OLD_XCB_VERSION | ||
1249 | if (hints.flags & XCB_SIZE_HINT_P_RESIZE_INC) | ||
1250 | #else | ||
1251 | if (hints.flags & XCB_ICCCM_SIZE_HINT_P_RESIZE_INC) | ||
1252 | #endif | ||
1253 | { | ||
1254 | stepx = hints.width_inc; | ||
1255 | stepy = hints.height_inc; | ||
1256 | if (stepx < 1) stepx = 1; | ||
1257 | if (stepy < 1) stepy = 1; | ||
1258 | } | ||
1259 | |||
1260 | #ifdef OLD_XCB_VERSION | ||
1261 | if (hints.flags & XCB_SIZE_HINT_P_ASPECT) | ||
1262 | #else | ||
1263 | if (hints.flags & XCB_ICCCM_SIZE_HINT_P_ASPECT) | ||
1264 | #endif | ||
1265 | { | ||
1266 | if (hints.min_aspect_den > 0) | ||
1267 | mina = ((double)hints.min_aspect_num) / ((double)hints.min_aspect_den); | ||
1268 | |||
1269 | if (hints.max_aspect_den > 0) | ||
1270 | maxa = ((double)hints.max_aspect_num) / ((double)hints.max_aspect_den); | ||
1271 | } | ||
1272 | |||
1273 | if (min_w) *min_w = minw; | ||
1274 | if (min_h) *min_h = minh; | ||
1275 | if (max_w) *max_w = maxw; | ||
1276 | if (max_h) *max_h = maxh; | ||
1277 | if (base_w) *base_w = basew; | ||
1278 | if (base_h) *base_h = baseh; | ||
1279 | if (step_x) *step_x = stepx; | ||
1280 | if (step_y) *step_y = stepy; | ||
1281 | if (min_aspect) *min_aspect = mina; | ||
1282 | if (max_aspect) *max_aspect = maxa; | ||
1283 | |||
1284 | return EINA_TRUE; | ||
1285 | } | ||
1286 | |||
1287 | EAPI void | ||
1288 | ecore_x_icccm_size_pos_hints_set(Ecore_X_Window win, | ||
1289 | Eina_Bool request_pos, | ||
1290 | Ecore_X_Gravity gravity, | ||
1291 | int min_w, | ||
1292 | int min_h, | ||
1293 | int max_w, | ||
1294 | int max_h, | ||
1295 | int base_w, | ||
1296 | int base_h, | ||
1297 | int step_x, | ||
1298 | int step_y, | ||
1299 | double min_aspect, | ||
1300 | double max_aspect) | ||
1301 | { | ||
1302 | xcb_get_property_cookie_t cookie; | ||
1303 | xcb_size_hints_t hints; | ||
1304 | uint8_t ret = 0; | ||
1305 | |||
1306 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1307 | CHECK_XCB_CONN; | ||
1308 | |||
1309 | #ifdef OLD_XCB_VERSION | ||
1310 | cookie = xcb_get_wm_normal_hints_unchecked(_ecore_xcb_conn, win); | ||
1311 | ret = xcb_get_wm_normal_hints_reply(_ecore_xcb_conn, cookie, &hints, NULL); | ||
1312 | #else | ||
1313 | cookie = xcb_icccm_get_wm_normal_hints_unchecked(_ecore_xcb_conn, win); | ||
1314 | ret = xcb_icccm_get_wm_normal_hints_reply(_ecore_xcb_conn, cookie, | ||
1315 | &hints, NULL); | ||
1316 | #endif | ||
1317 | if (!ret) memset(&hints, 0, sizeof(xcb_size_hints_t)); | ||
1318 | |||
1319 | hints.flags = 0; | ||
1320 | |||
1321 | #ifdef OLD_XCB_VERSION | ||
1322 | if (request_pos) | ||
1323 | hints.flags |= XCB_SIZE_HINT_US_POSITION; | ||
1324 | |||
1325 | if (gravity != ECORE_X_GRAVITY_NW) | ||
1326 | xcb_size_hints_set_win_gravity(&hints, gravity); | ||
1327 | if ((min_w > 0) || (min_h > 0)) | ||
1328 | xcb_size_hints_set_min_size(&hints, min_w, min_h); | ||
1329 | if ((max_w > 0) || (max_h > 0)) | ||
1330 | xcb_size_hints_set_max_size(&hints, max_w, max_h); | ||
1331 | if ((base_w > 0) || (base_h > 0)) | ||
1332 | xcb_size_hints_set_base_size(&hints, base_w, base_h); | ||
1333 | if ((step_x > 1) || (step_y > 1)) | ||
1334 | xcb_size_hints_set_resize_inc(&hints, step_x, step_y); | ||
1335 | if ((min_aspect > 0.0) || (max_aspect > 0.0)) | ||
1336 | xcb_size_hints_set_aspect(&hints, | ||
1337 | (int32_t)(min_aspect * 10000), 10000, | ||
1338 | (int32_t)(max_aspect * 10000), 10000); | ||
1339 | |||
1340 | xcb_set_wm_normal_hints(_ecore_xcb_conn, win, &hints); | ||
1341 | #else | ||
1342 | if (request_pos) | ||
1343 | hints.flags |= XCB_ICCCM_SIZE_HINT_US_POSITION; | ||
1344 | |||
1345 | if (gravity != ECORE_X_GRAVITY_NW) | ||
1346 | xcb_icccm_size_hints_set_win_gravity(&hints, gravity); | ||
1347 | if ((min_w > 0) || (min_h > 0)) | ||
1348 | xcb_icccm_size_hints_set_min_size(&hints, min_w, min_h); | ||
1349 | if ((max_w > 0) || (max_h > 0)) | ||
1350 | xcb_icccm_size_hints_set_max_size(&hints, max_w, max_h); | ||
1351 | if ((base_w > 0) || (base_h > 0)) | ||
1352 | xcb_icccm_size_hints_set_base_size(&hints, base_w, base_h); | ||
1353 | if ((step_x > 1) || (step_y > 1)) | ||
1354 | xcb_icccm_size_hints_set_resize_inc(&hints, step_x, step_y); | ||
1355 | if ((min_aspect > 0.0) || (max_aspect > 0.0)) | ||
1356 | xcb_icccm_size_hints_set_aspect(&hints, | ||
1357 | (int32_t)(min_aspect * 10000), 10000, | ||
1358 | (int32_t)(max_aspect * 10000), 10000); | ||
1359 | |||
1360 | xcb_icccm_set_wm_normal_hints(_ecore_xcb_conn, win, &hints); | ||
1361 | #endif | ||
1362 | } | ||
1363 | |||
1364 | EAPI void | ||
1365 | ecore_x_icccm_move_resize_send(Ecore_X_Window win, | ||
1366 | int x, | ||
1367 | int y, | ||
1368 | int w, | ||
1369 | int h) | ||
1370 | { | ||
1371 | xcb_configure_notify_event_t ev; | ||
1372 | |||
1373 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1374 | CHECK_XCB_CONN; | ||
1375 | |||
1376 | if (!win) return; | ||
1377 | |||
1378 | memset(&ev, 0, sizeof(xcb_configure_notify_event_t)); | ||
1379 | |||
1380 | ev.response_type = XCB_CONFIGURE_NOTIFY; | ||
1381 | ev.event = win; | ||
1382 | ev.window = win; | ||
1383 | ev.above_sibling = XCB_NONE; | ||
1384 | ev.x = x; | ||
1385 | ev.y = y; | ||
1386 | ev.width = w; | ||
1387 | ev.height = h; | ||
1388 | ev.border_width = 0; | ||
1389 | ev.override_redirect = 0; | ||
1390 | |||
1391 | xcb_send_event(_ecore_xcb_conn, 0, win, | ||
1392 | XCB_EVENT_MASK_STRUCTURE_NOTIFY, (const char *)&ev); | ||
1393 | // ecore_x_flush(); | ||
1394 | } | ||
1395 | |||
1396 | /** | ||
1397 | * Get a window client machine string. | ||
1398 | * @param win The window | ||
1399 | * @return The windows client machine string | ||
1400 | * | ||
1401 | * Return the client machine of a window. String must be free'd when done with. | ||
1402 | */ | ||
1403 | EAPI char * | ||
1404 | ecore_x_icccm_client_machine_get(Ecore_X_Window win) | ||
1405 | { | ||
1406 | xcb_get_property_cookie_t cookie; | ||
1407 | #ifdef OLD_XCB_VERSION | ||
1408 | xcb_get_text_property_reply_t prop; | ||
1409 | #else | ||
1410 | xcb_icccm_get_text_property_reply_t prop; | ||
1411 | #endif | ||
1412 | uint8_t ret = 0; | ||
1413 | char *tmp = NULL; | ||
1414 | |||
1415 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1416 | CHECK_XCB_CONN; | ||
1417 | |||
1418 | #ifdef OLD_XCB_VERSION | ||
1419 | cookie = xcb_get_wm_client_machine_unchecked(_ecore_xcb_conn, win); | ||
1420 | ret = xcb_get_wm_client_machine_reply(_ecore_xcb_conn, cookie, &prop, NULL); | ||
1421 | #else | ||
1422 | cookie = xcb_icccm_get_wm_client_machine_unchecked(_ecore_xcb_conn, win); | ||
1423 | ret = xcb_icccm_get_wm_client_machine_reply(_ecore_xcb_conn, cookie, | ||
1424 | &prop, NULL); | ||
1425 | #endif | ||
1426 | if (ret == 0) return NULL; | ||
1427 | |||
1428 | tmp = malloc((prop.name_len + 1) * sizeof(char *)); | ||
1429 | if (!tmp) | ||
1430 | { | ||
1431 | #ifdef OLD_XCB_VERSION | ||
1432 | xcb_get_text_property_reply_wipe(&prop); | ||
1433 | #else | ||
1434 | xcb_icccm_get_text_property_reply_wipe(&prop); | ||
1435 | #endif | ||
1436 | return NULL; | ||
1437 | } | ||
1438 | memcpy(tmp, prop.name, sizeof(char *) * prop.name_len); | ||
1439 | tmp[prop.name_len] = '\0'; | ||
1440 | |||
1441 | #ifdef OLD_XCB_VERSION | ||
1442 | xcb_get_text_property_reply_wipe(&prop); | ||
1443 | #else | ||
1444 | xcb_icccm_get_text_property_reply_wipe(&prop); | ||
1445 | #endif | ||
1446 | |||
1447 | return tmp; | ||
1448 | } | ||
1449 | |||
1450 | EAPI void | ||
1451 | ecore_x_icccm_take_focus_send(Ecore_X_Window win, | ||
1452 | Ecore_X_Time t) | ||
1453 | { | ||
1454 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1455 | |||
1456 | ecore_x_client_message32_send(win, ECORE_X_ATOM_WM_PROTOCOLS, | ||
1457 | XCB_EVENT_MASK_NO_EVENT, | ||
1458 | ECORE_X_ATOM_WM_TAKE_FOCUS, t, 0, 0, 0); | ||
1459 | } | ||
1460 | |||
1461 | EAPI void | ||
1462 | ecore_x_icccm_save_yourself_send(Ecore_X_Window win, | ||
1463 | Ecore_X_Time t) | ||
1464 | { | ||
1465 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1466 | ecore_x_client_message32_send(win, ECORE_X_ATOM_WM_PROTOCOLS, | ||
1467 | XCB_EVENT_MASK_NO_EVENT, | ||
1468 | ECORE_X_ATOM_WM_SAVE_YOURSELF, t, 0, 0, 0); | ||
1469 | } | ||
1470 | |||
1471 | /** | ||
1472 | * Add a subwindow to the list of windows that need a different colormap installed. | ||
1473 | * @param win The toplevel window | ||
1474 | * @param subwin The subwindow to be added to the colormap windows list | ||
1475 | */ | ||
1476 | EAPI void | ||
1477 | ecore_x_icccm_colormap_window_set(Ecore_X_Window win, | ||
1478 | Ecore_X_Window subwin) | ||
1479 | { | ||
1480 | int num = 0, i = 0; | ||
1481 | unsigned char *odata = NULL, *data = NULL; | ||
1482 | Ecore_X_Window *newset = NULL, *oldset = NULL; | ||
1483 | |||
1484 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1485 | |||
1486 | if (!ecore_x_window_prop_property_get(win, ECORE_X_ATOM_WM_COLORMAP_WINDOWS, | ||
1487 | ECORE_X_ATOM_WINDOW, 32, &odata, &num)) | ||
1488 | { | ||
1489 | if (!(newset = calloc(1, sizeof(Ecore_X_Window)))) return; | ||
1490 | newset[0] = subwin; | ||
1491 | num = 1; | ||
1492 | data = (unsigned char *)newset; | ||
1493 | } | ||
1494 | else | ||
1495 | { | ||
1496 | if (!(newset = calloc(num + 1, sizeof(Ecore_X_Window)))) return; | ||
1497 | oldset = (Ecore_X_Window *)odata; | ||
1498 | for (i = 0; i < num; i++) | ||
1499 | { | ||
1500 | if (oldset[i] == subwin) | ||
1501 | { | ||
1502 | if (odata) free(odata); | ||
1503 | odata = NULL; | ||
1504 | free(newset); | ||
1505 | return; | ||
1506 | } | ||
1507 | newset[i] = oldset[i]; | ||
1508 | } | ||
1509 | newset[num++] = subwin; | ||
1510 | if (odata) free(odata); | ||
1511 | data = (unsigned char *)newset; | ||
1512 | } | ||
1513 | ecore_x_window_prop_property_set(win, ECORE_X_ATOM_WM_COLORMAP_WINDOWS, | ||
1514 | ECORE_X_ATOM_WINDOW, 32, data, num); | ||
1515 | free(newset); | ||
1516 | } | ||
1517 | |||
1518 | /** | ||
1519 | * Remove a window from the list of colormap windows. | ||
1520 | * @param win The toplevel window | ||
1521 | * @param subwin The window to be removed from the colormap window list. | ||
1522 | */ | ||
1523 | EAPI void | ||
1524 | ecore_x_icccm_colormap_window_unset(Ecore_X_Window win, | ||
1525 | Ecore_X_Window subwin) | ||
1526 | { | ||
1527 | int num = 0, i = 0, j = 0, k = 0; | ||
1528 | unsigned char *odata = NULL, *data = NULL; | ||
1529 | Ecore_X_Window *newset = NULL, *oldset = NULL; | ||
1530 | |||
1531 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1532 | |||
1533 | if (!ecore_x_window_prop_property_get(win, ECORE_X_ATOM_WM_COLORMAP_WINDOWS, | ||
1534 | ECORE_X_ATOM_WINDOW, 32, &odata, &num)) | ||
1535 | return; | ||
1536 | |||
1537 | oldset = (Ecore_X_Window *)odata; | ||
1538 | for (i = 0; i < num; i++) | ||
1539 | { | ||
1540 | if (oldset[i] == subwin) | ||
1541 | { | ||
1542 | if (num == 1) | ||
1543 | { | ||
1544 | ecore_x_window_prop_property_del(win, ECORE_X_ATOM_WM_COLORMAP_WINDOWS); | ||
1545 | if (odata) free(odata); | ||
1546 | odata = NULL; | ||
1547 | return; | ||
1548 | } | ||
1549 | else | ||
1550 | { | ||
1551 | newset = calloc(num - 1, sizeof(Ecore_X_Window)); | ||
1552 | data = (unsigned char *)newset; | ||
1553 | for (j = 0; j < num; ++j) | ||
1554 | if (oldset[j] != subwin) | ||
1555 | newset[k++] = oldset[j]; | ||
1556 | |||
1557 | ecore_x_window_prop_property_set(win, ECORE_X_ATOM_WM_COLORMAP_WINDOWS, | ||
1558 | ECORE_X_ATOM_WINDOW, 32, data, k); | ||
1559 | if (odata) free(odata); | ||
1560 | odata = NULL; | ||
1561 | free(newset); | ||
1562 | return; | ||
1563 | } | ||
1564 | } | ||
1565 | } | ||
1566 | if (odata) free(odata); | ||
1567 | } | ||
1568 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_image.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_image.c new file mode 100644 index 0000000..6789b94 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_image.c | |||
@@ -0,0 +1,740 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #include <sys/ipc.h> | ||
3 | #include <sys/shm.h> | ||
4 | #include <xcb/xcb_event.h> | ||
5 | #include <xcb/shm.h> | ||
6 | |||
7 | struct _Ecore_X_Image | ||
8 | { | ||
9 | xcb_shm_segment_info_t shminfo; | ||
10 | xcb_image_t *xim; | ||
11 | Ecore_X_Visual vis; | ||
12 | int depth, w, h; | ||
13 | int bpl, bpp, rows; | ||
14 | unsigned char *data; | ||
15 | Eina_Bool shm : 1; | ||
16 | }; | ||
17 | |||
18 | /* local function prototypes */ | ||
19 | static void _ecore_xcb_image_shm_check(void); | ||
20 | static void _ecore_xcb_image_shm_create(Ecore_X_Image *im); | ||
21 | static xcb_format_t *_ecore_xcb_image_find_format(const xcb_setup_t *setup, | ||
22 | uint8_t depth); | ||
23 | |||
24 | /* local variables */ | ||
25 | static int _ecore_xcb_image_shm_can = -1; | ||
26 | |||
27 | EAPI Ecore_X_Image * | ||
28 | ecore_x_image_new(int w, | ||
29 | int h, | ||
30 | Ecore_X_Visual vis, | ||
31 | int depth) | ||
32 | { | ||
33 | Ecore_X_Image *im; | ||
34 | |||
35 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
36 | |||
37 | if (!(im = calloc(1, sizeof(Ecore_X_Image)))) return NULL; | ||
38 | im->w = w; | ||
39 | im->h = h; | ||
40 | im->vis = vis; | ||
41 | im->depth = depth; | ||
42 | _ecore_xcb_image_shm_check(); | ||
43 | im->shm = _ecore_xcb_image_shm_can; | ||
44 | return im; | ||
45 | } | ||
46 | |||
47 | EAPI void | ||
48 | ecore_x_image_free(Ecore_X_Image *im) | ||
49 | { | ||
50 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
51 | CHECK_XCB_CONN; | ||
52 | |||
53 | if (!im) return; | ||
54 | if (im->shm) | ||
55 | { | ||
56 | if (im->xim) | ||
57 | { | ||
58 | xcb_shm_detach(_ecore_xcb_conn, im->shminfo.shmseg); | ||
59 | xcb_image_destroy(im->xim); | ||
60 | shmdt(im->shminfo.shmaddr); | ||
61 | shmctl(im->shminfo.shmid, IPC_RMID, 0); | ||
62 | } | ||
63 | } | ||
64 | else if (im->xim) | ||
65 | { | ||
66 | if (im->xim->data) free(im->xim->data); | ||
67 | im->xim->data = NULL; | ||
68 | xcb_image_destroy(im->xim); | ||
69 | } | ||
70 | |||
71 | free(im); | ||
72 | // ecore_x_flush(); | ||
73 | } | ||
74 | |||
75 | EAPI Eina_Bool | ||
76 | ecore_x_image_get(Ecore_X_Image *im, | ||
77 | Ecore_X_Drawable draw, | ||
78 | int x, | ||
79 | int y, | ||
80 | int sx, | ||
81 | int sy, | ||
82 | int w, | ||
83 | int h) | ||
84 | { | ||
85 | Eina_Bool ret = EINA_TRUE; | ||
86 | |||
87 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
88 | CHECK_XCB_CONN; | ||
89 | |||
90 | if (im->shm) | ||
91 | { | ||
92 | if (!im->xim) _ecore_xcb_image_shm_create(im); | ||
93 | if (!im->xim) return EINA_FALSE; | ||
94 | |||
95 | if ((sx == 0) && (w == im->w)) | ||
96 | { | ||
97 | im->xim->data = (uint8_t *)im->data + (im->xim->stride * sy) + | ||
98 | (sx * im->bpp); | ||
99 | im->xim->width = w; | ||
100 | im->xim->height = h; | ||
101 | |||
102 | ecore_x_grab(); | ||
103 | if (!xcb_image_shm_get(_ecore_xcb_conn, draw, im->xim, | ||
104 | im->shminfo, x, y, 0xffffffff)) | ||
105 | { | ||
106 | DBG("\tImage Shm Get Failed"); | ||
107 | ret = EINA_FALSE; | ||
108 | } | ||
109 | ecore_x_ungrab(); | ||
110 | ecore_x_sync(); // needed | ||
111 | } | ||
112 | else | ||
113 | { | ||
114 | Ecore_X_Image *tim; | ||
115 | |||
116 | tim = ecore_x_image_new(w, h, im->vis, im->depth); | ||
117 | if (tim) | ||
118 | { | ||
119 | ret = ecore_x_image_get(tim, draw, x, y, 0, 0, w, h); | ||
120 | if (ret) | ||
121 | { | ||
122 | unsigned char *spixels, *pixels; | ||
123 | int sbpp = 0, sbpl = 0, srows = 0; | ||
124 | int bpp = 0, bpl = 0, rows = 0; | ||
125 | |||
126 | spixels = | ||
127 | ecore_x_image_data_get(tim, &sbpl, &srows, &sbpp); | ||
128 | pixels = ecore_x_image_data_get(im, &bpl, &rows, &bpp); | ||
129 | if ((spixels) && (pixels)) | ||
130 | { | ||
131 | unsigned char *p, *sp; | ||
132 | int r = 0; | ||
133 | |||
134 | p = (pixels + (sy * bpl) + (sx * bpp)); | ||
135 | sp = spixels; | ||
136 | for (r = srows; r > 0; r--) | ||
137 | { | ||
138 | memcpy(p, sp, sbpl); | ||
139 | p += bpl; | ||
140 | sp += sbpl; | ||
141 | } | ||
142 | } | ||
143 | } | ||
144 | ecore_x_image_free(tim); | ||
145 | } | ||
146 | } | ||
147 | } | ||
148 | else | ||
149 | { | ||
150 | ret = EINA_FALSE; | ||
151 | ecore_x_grab(); | ||
152 | im->xim = | ||
153 | xcb_image_get(_ecore_xcb_conn, draw, x, y, w, h, | ||
154 | 0xffffffff, XCB_IMAGE_FORMAT_Z_PIXMAP); | ||
155 | if (!im->xim) ret = EINA_FALSE; | ||
156 | ecore_x_ungrab(); | ||
157 | ecore_x_sync(); // needed | ||
158 | |||
159 | if (im->xim) | ||
160 | { | ||
161 | im->data = (unsigned char *)im->xim->data; | ||
162 | im->bpl = im->xim->stride; | ||
163 | im->rows = im->xim->height; | ||
164 | if (im->xim->bpp <= 8) | ||
165 | im->bpp = 1; | ||
166 | else if (im->xim->bpp <= 16) | ||
167 | im->bpp = 2; | ||
168 | else | ||
169 | im->bpp = 4; | ||
170 | } | ||
171 | } | ||
172 | |||
173 | return ret; | ||
174 | } | ||
175 | |||
176 | EAPI void * | ||
177 | ecore_x_image_data_get(Ecore_X_Image *im, | ||
178 | int *bpl, | ||
179 | int *rows, | ||
180 | int *bpp) | ||
181 | { | ||
182 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
183 | |||
184 | if (!im) return NULL; | ||
185 | if (!im->xim) _ecore_xcb_image_shm_create(im); | ||
186 | if (!im->xim) return NULL; | ||
187 | |||
188 | if (bpl) *bpl = im->bpl; | ||
189 | if (rows) *rows = im->rows; | ||
190 | if (bpp) *bpp = im->bpp; | ||
191 | |||
192 | return im->data; | ||
193 | } | ||
194 | |||
195 | EAPI void | ||
196 | ecore_x_image_put(Ecore_X_Image *im, | ||
197 | Ecore_X_Drawable draw, | ||
198 | Ecore_X_GC gc, | ||
199 | int x, | ||
200 | int y, | ||
201 | int sx, | ||
202 | int sy, | ||
203 | int w, | ||
204 | int h) | ||
205 | { | ||
206 | Ecore_X_GC tgc = 0; | ||
207 | |||
208 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
209 | CHECK_XCB_CONN; | ||
210 | |||
211 | if (!gc) | ||
212 | { | ||
213 | uint32_t mask, values[1]; | ||
214 | |||
215 | tgc = xcb_generate_id(_ecore_xcb_conn); | ||
216 | mask = XCB_GC_SUBWINDOW_MODE; | ||
217 | values[0] = XCB_SUBWINDOW_MODE_INCLUDE_INFERIORS; | ||
218 | xcb_create_gc(_ecore_xcb_conn, tgc, draw, mask, values); | ||
219 | gc = tgc; | ||
220 | } | ||
221 | if (!im->xim) _ecore_xcb_image_shm_create(im); | ||
222 | if (im->xim) | ||
223 | { | ||
224 | if (im->shm) | ||
225 | xcb_shm_put_image(_ecore_xcb_conn, draw, gc, im->xim->width, | ||
226 | im->xim->height, sx, sy, w, h, x, y, | ||
227 | im->xim->depth, im->xim->format, 0, | ||
228 | im->shminfo.shmseg, | ||
229 | im->xim->data - im->shminfo.shmaddr); | ||
230 | // xcb_image_shm_put(_ecore_xcb_conn, draw, gc, im->xim, | ||
231 | // im->shminfo, sx, sy, x, y, w, h, 0); | ||
232 | else | ||
233 | xcb_image_put(_ecore_xcb_conn, draw, gc, im->xim, sx, sy, 0); | ||
234 | } | ||
235 | if (tgc) ecore_x_gc_free(tgc); | ||
236 | ecore_x_sync(); | ||
237 | } | ||
238 | |||
239 | EAPI Eina_Bool | ||
240 | ecore_x_image_is_argb32_get(Ecore_X_Image *im) | ||
241 | { | ||
242 | xcb_visualtype_t *vis; | ||
243 | |||
244 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
245 | CHECK_XCB_CONN; | ||
246 | |||
247 | vis = (xcb_visualtype_t *)im->vis; | ||
248 | if (!im->xim) _ecore_xcb_image_shm_create(im); | ||
249 | |||
250 | if (((vis->_class == XCB_VISUAL_CLASS_TRUE_COLOR) || | ||
251 | (vis->_class == XCB_VISUAL_CLASS_DIRECT_COLOR)) && | ||
252 | (im->depth >= 24) && (vis->red_mask == 0xff0000) && | ||
253 | (vis->green_mask == 0x00ff00) && (vis->blue_mask == 0x0000ff)) | ||
254 | { | ||
255 | #ifdef WORDS_BIGENDIAN | ||
256 | if (im->xim->byte_order == XCB_IMAGE_ORDER_LSB_FIRST) | ||
257 | return EINA_TRUE; | ||
258 | #else | ||
259 | if (im->xim->byte_order == XCB_IMAGE_ORDER_MSB_FIRST) | ||
260 | return EINA_TRUE; | ||
261 | #endif | ||
262 | } | ||
263 | |||
264 | return EINA_FALSE; | ||
265 | } | ||
266 | |||
267 | EAPI Eina_Bool | ||
268 | ecore_x_image_to_argb_convert(void *src, | ||
269 | int sbpp, | ||
270 | int sbpl, | ||
271 | Ecore_X_Colormap c, | ||
272 | Ecore_X_Visual v, | ||
273 | int x, | ||
274 | int y, | ||
275 | int w, | ||
276 | int h, | ||
277 | unsigned int *dst, | ||
278 | int dbpl, | ||
279 | int dx, | ||
280 | int dy) | ||
281 | { | ||
282 | xcb_visualtype_t *vis; | ||
283 | uint32_t *cols; | ||
284 | int n = 0, nret = 0, i, row, mode = 0; | ||
285 | unsigned int pal[256], r, g, b; | ||
286 | enum | ||
287 | { | ||
288 | rgbnone = 0, | ||
289 | rgb565, | ||
290 | bgr565, | ||
291 | rgbx555, | ||
292 | argbx888, | ||
293 | abgrx888, | ||
294 | rgba888x, | ||
295 | bgra888x, | ||
296 | argbx666 | ||
297 | }; | ||
298 | |||
299 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
300 | CHECK_XCB_CONN; | ||
301 | |||
302 | sbpp *= 8; | ||
303 | |||
304 | vis = (xcb_visualtype_t *)v; | ||
305 | n = vis->colormap_entries; | ||
306 | if ((n <= 256) && | ||
307 | ((vis->_class == XCB_VISUAL_CLASS_PSEUDO_COLOR) || | ||
308 | (vis->_class == XCB_VISUAL_CLASS_STATIC_COLOR) || | ||
309 | (vis->_class == XCB_VISUAL_CLASS_GRAY_SCALE) || | ||
310 | (vis->_class == XCB_VISUAL_CLASS_STATIC_GRAY))) | ||
311 | { | ||
312 | xcb_query_colors_cookie_t cookie; | ||
313 | xcb_query_colors_reply_t *reply; | ||
314 | |||
315 | if (!c) | ||
316 | { | ||
317 | c = (xcb_colormap_t)((xcb_screen_t *) | ||
318 | _ecore_xcb_screen)->default_colormap; | ||
319 | } | ||
320 | |||
321 | cols = alloca(n * sizeof(uint32_t)); | ||
322 | for (i = 0; i < n; i++) | ||
323 | cols[i] = i; | ||
324 | |||
325 | cookie = xcb_query_colors_unchecked(_ecore_xcb_conn, c, n, cols); | ||
326 | reply = xcb_query_colors_reply(_ecore_xcb_conn, cookie, NULL); | ||
327 | if (reply) | ||
328 | { | ||
329 | xcb_rgb_iterator_t iter; | ||
330 | xcb_rgb_t *ret; | ||
331 | |||
332 | iter = xcb_query_colors_colors_iterator(reply); | ||
333 | ret = xcb_query_colors_colors(reply); | ||
334 | if (ret) | ||
335 | { | ||
336 | for (i = 0; iter.rem; xcb_rgb_next(&iter), i++) | ||
337 | { | ||
338 | pal[i] = 0xff000000 | | ||
339 | ((iter.data->red >> 8) << 16) | | ||
340 | ((iter.data->green >> 8) << 8) | | ||
341 | ((iter.data->blue >> 8)); | ||
342 | } | ||
343 | nret = n; | ||
344 | } | ||
345 | free(reply); | ||
346 | } | ||
347 | } | ||
348 | else if ((vis->_class == XCB_VISUAL_CLASS_TRUE_COLOR) || | ||
349 | (vis->_class == XCB_VISUAL_CLASS_DIRECT_COLOR)) | ||
350 | { | ||
351 | if ((vis->red_mask == 0x00ff0000) && | ||
352 | (vis->green_mask == 0x0000ff00) && | ||
353 | (vis->blue_mask == 0x000000ff)) | ||
354 | mode = argbx888; | ||
355 | else if ((vis->red_mask == 0x000000ff) && | ||
356 | (vis->green_mask == 0x0000ff00) && | ||
357 | (vis->blue_mask == 0x00ff0000)) | ||
358 | mode = abgrx888; | ||
359 | else if ((vis->red_mask == 0xff000000) && | ||
360 | (vis->green_mask == 0x00ff0000) && | ||
361 | (vis->blue_mask == 0x0000ff00)) | ||
362 | mode = rgba888x; | ||
363 | else if ((vis->red_mask == 0x0000ff00) && | ||
364 | (vis->green_mask == 0x00ff0000) && | ||
365 | (vis->blue_mask == 0xff000000)) | ||
366 | mode = bgra888x; | ||
367 | else if ((vis->red_mask == 0x0003f000) && | ||
368 | (vis->green_mask == 0x00000fc0) && | ||
369 | (vis->blue_mask == 0x0000003f)) | ||
370 | mode = argbx666; | ||
371 | else if ((vis->red_mask == 0x0000f800) && | ||
372 | (vis->green_mask == 0x000007e0) && | ||
373 | (vis->blue_mask == 0x0000001f)) | ||
374 | mode = rgb565; | ||
375 | else if ((vis->red_mask == 0x0000001f) && | ||
376 | (vis->green_mask == 0x000007e0) && | ||
377 | (vis->blue_mask == 0x0000f800)) | ||
378 | mode = bgr565; | ||
379 | else if ((vis->red_mask == 0x00007c00) && | ||
380 | (vis->green_mask == 0x000003e0) && | ||
381 | (vis->blue_mask == 0x0000001f)) | ||
382 | mode = rgbx555; | ||
383 | else | ||
384 | return EINA_FALSE; | ||
385 | } | ||
386 | for (row = 0; row < h; row++) | ||
387 | { | ||
388 | unsigned char *s8; | ||
389 | unsigned short *s16; | ||
390 | unsigned int *s32, *dp, *de; | ||
391 | |||
392 | dp = ((unsigned int *)(((unsigned char *)dst) + | ||
393 | ((dy + row) * dbpl))) + dx; | ||
394 | de = dp + w; | ||
395 | switch (sbpp) | ||
396 | { | ||
397 | case 8: | ||
398 | s8 = ((unsigned char *)(((unsigned char *)src) + | ||
399 | ((y + row) * sbpl))) + x; | ||
400 | if (nret > 0) | ||
401 | { | ||
402 | while (dp < de) | ||
403 | { | ||
404 | *dp = pal[*s8]; | ||
405 | s8++; dp++; | ||
406 | } | ||
407 | } | ||
408 | else | ||
409 | return EINA_FALSE; | ||
410 | break; | ||
411 | |||
412 | case 16: | ||
413 | s16 = ((unsigned short *)(((unsigned char *)src) + | ||
414 | ((y + row) * sbpl))) + x; | ||
415 | switch (mode) | ||
416 | { | ||
417 | case rgb565: | ||
418 | while (dp < de) | ||
419 | { | ||
420 | r = (*s16 & 0xf800) << 8; | ||
421 | g = (*s16 & 0x07e0) << 5; | ||
422 | b = (*s16 & 0x001f) << 3; | ||
423 | r |= (r >> 5) & 0xff0000; | ||
424 | g |= (g >> 6) & 0x00ff00; | ||
425 | b |= (b >> 5); | ||
426 | *dp = 0xff000000 | r | g | b; | ||
427 | s16++; dp++; | ||
428 | } | ||
429 | break; | ||
430 | |||
431 | case bgr565: | ||
432 | while (dp < de) | ||
433 | { | ||
434 | r = (*s16 & 0x001f) << 19; | ||
435 | g = (*s16 & 0x07e0) << 5; | ||
436 | b = (*s16 & 0xf800) >> 8; | ||
437 | r |= (r >> 5) & 0xff0000; | ||
438 | g |= (g >> 6) & 0x00ff00; | ||
439 | b |= (b >> 5); | ||
440 | *dp = 0xff000000 | r | g | b; | ||
441 | s16++; dp++; | ||
442 | } | ||
443 | break; | ||
444 | |||
445 | case rgbx555: | ||
446 | while (dp < de) | ||
447 | { | ||
448 | r = (*s16 & 0x7c00) << 9; | ||
449 | g = (*s16 & 0x03e0) << 6; | ||
450 | b = (*s16 & 0x001f) << 3; | ||
451 | r |= (r >> 5) & 0xff0000; | ||
452 | g |= (g >> 5) & 0x00ff00; | ||
453 | b |= (b >> 5); | ||
454 | *dp = 0xff000000 | r | g | b; | ||
455 | s16++; dp++; | ||
456 | } | ||
457 | break; | ||
458 | |||
459 | default: | ||
460 | return EINA_FALSE; | ||
461 | break; | ||
462 | } | ||
463 | break; | ||
464 | |||
465 | case 24: | ||
466 | case 32: | ||
467 | s32 = ((unsigned int *)(((unsigned char *)src) + | ||
468 | ((y + row) * sbpl))) + x; | ||
469 | switch (mode) | ||
470 | { | ||
471 | case argbx888: | ||
472 | while (dp < de) | ||
473 | { | ||
474 | *dp = 0xff000000 | *s32; | ||
475 | s32++; dp++; | ||
476 | } | ||
477 | break; | ||
478 | |||
479 | case abgrx888: | ||
480 | while (dp < de) | ||
481 | { | ||
482 | r = *s32 & 0x000000ff; | ||
483 | g = *s32 & 0x0000ff00; | ||
484 | b = *s32 & 0x00ff0000; | ||
485 | *dp = 0xff000000 | (r << 16) | (g) | (b >> 16); | ||
486 | s32++; dp++; | ||
487 | } | ||
488 | break; | ||
489 | |||
490 | case rgba888x: | ||
491 | while (dp < de) | ||
492 | { | ||
493 | *dp = 0xff000000 | (*s32 >> 8); | ||
494 | s32++; dp++; | ||
495 | } | ||
496 | break; | ||
497 | |||
498 | case bgra888x: | ||
499 | while (dp < de) | ||
500 | { | ||
501 | r = *s32 & 0x0000ff00; | ||
502 | g = *s32 & 0x00ff0000; | ||
503 | b = *s32 & 0xff000000; | ||
504 | *dp = 0xff000000 | (r << 8) | (g >> 8) | (b >> 24); | ||
505 | s32++; dp++; | ||
506 | } | ||
507 | break; | ||
508 | |||
509 | case argbx666: | ||
510 | while (dp < de) | ||
511 | { | ||
512 | r = (*s32 & 0x3f000) << 6; | ||
513 | g = (*s32 & 0x00fc0) << 4; | ||
514 | b = (*s32 & 0x0003f) << 2; | ||
515 | r |= (r >> 6) & 0xff0000; | ||
516 | g |= (g >> 6) & 0x00ff00; | ||
517 | b |= (b >> 6); | ||
518 | *dp = 0xff000000 | r | g | b; | ||
519 | s32++; dp++; | ||
520 | } | ||
521 | break; | ||
522 | |||
523 | default: | ||
524 | return EINA_FALSE; | ||
525 | break; | ||
526 | } | ||
527 | break; | ||
528 | break; | ||
529 | |||
530 | default: | ||
531 | return EINA_FALSE; | ||
532 | break; | ||
533 | } | ||
534 | } | ||
535 | return EINA_TRUE; | ||
536 | } | ||
537 | |||
538 | /* local functions */ | ||
539 | static void | ||
540 | _ecore_xcb_image_shm_check(void) | ||
541 | { | ||
542 | // xcb_shm_query_version_reply_t *reply; | ||
543 | xcb_shm_segment_info_t shminfo; | ||
544 | xcb_shm_get_image_cookie_t cookie; | ||
545 | xcb_shm_get_image_reply_t *ireply; | ||
546 | xcb_image_t *img = 0; | ||
547 | uint8_t depth = 0; | ||
548 | |||
549 | if (_ecore_xcb_image_shm_can != -1) return; | ||
550 | CHECK_XCB_CONN; | ||
551 | |||
552 | /* reply = */ | ||
553 | /* xcb_shm_query_version_reply(_ecore_xcb_conn, */ | ||
554 | /* xcb_shm_query_version(_ecore_xcb_conn), NULL); */ | ||
555 | /* if (!reply) */ | ||
556 | /* { */ | ||
557 | /* _ecore_xcb_image_shm_can = 0; */ | ||
558 | /* return; */ | ||
559 | /* } */ | ||
560 | |||
561 | /* if ((reply->major_version < 1) || */ | ||
562 | /* ((reply->major_version == 1) && (reply->minor_version == 0))) */ | ||
563 | /* { */ | ||
564 | /* _ecore_xcb_image_shm_can = 0; */ | ||
565 | /* free(reply); */ | ||
566 | /* return; */ | ||
567 | /* } */ | ||
568 | |||
569 | /* free(reply); */ | ||
570 | |||
571 | depth = ((xcb_screen_t *)_ecore_xcb_screen)->root_depth; | ||
572 | |||
573 | ecore_x_sync(); // needed | ||
574 | |||
575 | img = _ecore_xcb_image_create_native(1, 1, XCB_IMAGE_FORMAT_Z_PIXMAP, | ||
576 | depth, NULL, ~0, NULL); | ||
577 | if (!img) | ||
578 | { | ||
579 | _ecore_xcb_image_shm_can = 0; | ||
580 | return; | ||
581 | } | ||
582 | |||
583 | shminfo.shmid = | ||
584 | shmget(IPC_PRIVATE, img->stride * img->height, (IPC_CREAT | 0666)); | ||
585 | if (shminfo.shmid == (uint32_t)-1) | ||
586 | { | ||
587 | xcb_image_destroy(img); | ||
588 | _ecore_xcb_image_shm_can = 0; | ||
589 | return; | ||
590 | } | ||
591 | |||
592 | shminfo.shmaddr = shmat(shminfo.shmid, 0, 0); | ||
593 | img->data = shminfo.shmaddr; | ||
594 | if (img->data == (uint8_t *)-1) | ||
595 | { | ||
596 | xcb_image_destroy(img); | ||
597 | _ecore_xcb_image_shm_can = 0; | ||
598 | return; | ||
599 | } | ||
600 | |||
601 | shminfo.shmseg = xcb_generate_id(_ecore_xcb_conn); | ||
602 | xcb_shm_attach(_ecore_xcb_conn, shminfo.shmseg, shminfo.shmid, 0); | ||
603 | |||
604 | cookie = | ||
605 | xcb_shm_get_image(_ecore_xcb_conn, | ||
606 | ((xcb_screen_t *)_ecore_xcb_screen)->root, | ||
607 | 0, 0, img->width, img->height, | ||
608 | 0xffffffff, img->format, | ||
609 | shminfo.shmseg, img->data - shminfo.shmaddr); | ||
610 | |||
611 | ecore_x_sync(); // needed | ||
612 | |||
613 | ireply = xcb_shm_get_image_reply(_ecore_xcb_conn, cookie, NULL); | ||
614 | if (ireply) | ||
615 | { | ||
616 | _ecore_xcb_image_shm_can = 1; | ||
617 | free(ireply); | ||
618 | } | ||
619 | else | ||
620 | _ecore_xcb_image_shm_can = 0; | ||
621 | |||
622 | xcb_shm_detach(_ecore_xcb_conn, shminfo.shmseg); | ||
623 | xcb_image_destroy(img); | ||
624 | shmdt(shminfo.shmaddr); | ||
625 | shmctl(shminfo.shmid, IPC_RMID, 0); | ||
626 | } | ||
627 | |||
628 | static void | ||
629 | _ecore_xcb_image_shm_create(Ecore_X_Image *im) | ||
630 | { | ||
631 | CHECK_XCB_CONN; | ||
632 | |||
633 | im->xim = | ||
634 | _ecore_xcb_image_create_native(im->w, im->h, XCB_IMAGE_FORMAT_Z_PIXMAP, | ||
635 | im->depth, NULL, ~0, NULL); | ||
636 | if (!im->xim) return; | ||
637 | |||
638 | im->shminfo.shmid = shmget(IPC_PRIVATE, im->xim->size, (IPC_CREAT | 0666)); | ||
639 | if (im->shminfo.shmid == (uint32_t)-1) | ||
640 | { | ||
641 | xcb_image_destroy(im->xim); | ||
642 | return; | ||
643 | } | ||
644 | |||
645 | im->shminfo.shmaddr = shmat(im->shminfo.shmid, 0, 0); | ||
646 | im->xim->data = im->shminfo.shmaddr; | ||
647 | if ((!im->xim->data) || (im->xim->data == (uint8_t *)-1)) | ||
648 | { | ||
649 | DBG("Shm Create No Image Data"); | ||
650 | xcb_image_destroy(im->xim); | ||
651 | shmdt(im->shminfo.shmaddr); | ||
652 | shmctl(im->shminfo.shmid, IPC_RMID, 0); | ||
653 | return; | ||
654 | } | ||
655 | |||
656 | im->shminfo.shmseg = xcb_generate_id(_ecore_xcb_conn); | ||
657 | xcb_shm_attach(_ecore_xcb_conn, im->shminfo.shmseg, im->shminfo.shmid, 0); | ||
658 | |||
659 | im->data = (unsigned char *)im->xim->data; | ||
660 | im->bpl = im->xim->stride; | ||
661 | im->rows = im->xim->height; | ||
662 | if (im->xim->bpp <= 8) | ||
663 | im->bpp = 1; | ||
664 | else if (im->xim->bpp <= 16) | ||
665 | im->bpp = 2; | ||
666 | else | ||
667 | im->bpp = 4; | ||
668 | } | ||
669 | |||
670 | xcb_image_t * | ||
671 | _ecore_xcb_image_create_native(int w, | ||
672 | int h, | ||
673 | xcb_image_format_t format, | ||
674 | uint8_t depth, | ||
675 | void *base, | ||
676 | uint32_t bytes, | ||
677 | uint8_t *data) | ||
678 | { | ||
679 | static uint8_t dpth = 0; | ||
680 | static xcb_format_t *fmt = NULL; | ||
681 | const xcb_setup_t *setup; | ||
682 | xcb_image_format_t xif; | ||
683 | |||
684 | CHECK_XCB_CONN; | ||
685 | |||
686 | /* NB: We cannot use xcb_image_create_native as it only creates images | ||
687 | * using MSB_FIRST, so this routine recreates that function and uses | ||
688 | * the endian-ness of the server setup */ | ||
689 | setup = xcb_get_setup(_ecore_xcb_conn); | ||
690 | xif = format; | ||
691 | |||
692 | if ((xif == XCB_IMAGE_FORMAT_Z_PIXMAP) && (depth == 1)) | ||
693 | xif = XCB_IMAGE_FORMAT_XY_PIXMAP; | ||
694 | |||
695 | if (dpth != depth) | ||
696 | { | ||
697 | dpth = depth; | ||
698 | fmt = _ecore_xcb_image_find_format(setup, depth); | ||
699 | if (!fmt) return 0; | ||
700 | } | ||
701 | |||
702 | switch (xif) | ||
703 | { | ||
704 | case XCB_IMAGE_FORMAT_XY_BITMAP: | ||
705 | if (depth != 1) return 0; | ||
706 | |||
707 | case XCB_IMAGE_FORMAT_XY_PIXMAP: | ||
708 | case XCB_IMAGE_FORMAT_Z_PIXMAP: | ||
709 | return xcb_image_create(w, h, xif, | ||
710 | fmt->scanline_pad, | ||
711 | fmt->depth, fmt->bits_per_pixel, | ||
712 | setup->bitmap_format_scanline_unit, | ||
713 | setup->image_byte_order, | ||
714 | setup->bitmap_format_bit_order, | ||
715 | base, bytes, data); | ||
716 | |||
717 | default: | ||
718 | break; | ||
719 | } | ||
720 | |||
721 | return 0; | ||
722 | } | ||
723 | |||
724 | static xcb_format_t * | ||
725 | _ecore_xcb_image_find_format(const xcb_setup_t *setup, | ||
726 | uint8_t depth) | ||
727 | { | ||
728 | xcb_format_t *fmt, *fmtend; | ||
729 | |||
730 | CHECK_XCB_CONN; | ||
731 | |||
732 | fmt = xcb_setup_pixmap_formats(setup); | ||
733 | fmtend = fmt + xcb_setup_pixmap_formats_length(setup); | ||
734 | for (; fmt != fmtend; ++fmt) | ||
735 | if (fmt->depth == depth) | ||
736 | return fmt; | ||
737 | |||
738 | return 0; | ||
739 | } | ||
740 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_input.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_input.c new file mode 100644 index 0000000..c0338c2 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_input.c | |||
@@ -0,0 +1,274 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #ifdef ECORE_XCB_XINPUT | ||
3 | # include <xcb/xinput.h> | ||
4 | # include <xcb/xcb_event.h> | ||
5 | #endif | ||
6 | |||
7 | /* FIXME: this is a guess. can't find defines for touch events in xcb libs | ||
8 | * online */ | ||
9 | /* these are not yet defined in xcb support for xi2 - so manually create */ | ||
10 | #ifndef XCB_INPUT_DEVICE_TOUCH_BEGIN | ||
11 | #define XCB_INPUT_DEVICE_TOUCH_BEGIN 18 | ||
12 | #endif | ||
13 | #ifndef XCB_INPUT_DEVICE_TOUCH_END | ||
14 | #define XCB_INPUT_DEVICE_TOUCH_END 19 | ||
15 | #endif | ||
16 | #ifndef XCB_INPUT_DEVICE_TOUCH_UPDATE | ||
17 | #define XCB_INPUT_DEVICE_TOUCH_UPDATE 21 | ||
18 | #endif | ||
19 | |||
20 | #ifndef XCB_INPUT_POINTER_EMULATED_MASK | ||
21 | #define XCB_INPUT_POINTER_EMULATED_MASK (1 << 16) | ||
22 | #endif | ||
23 | |||
24 | /* local variables */ | ||
25 | static Eina_Bool _input_avail = EINA_FALSE; | ||
26 | |||
27 | /* external variables */ | ||
28 | int _ecore_xcb_event_input = 0; | ||
29 | |||
30 | void | ||
31 | _ecore_xcb_input_init(void) | ||
32 | { | ||
33 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
34 | |||
35 | #ifdef ECORE_XCB_XINPUT | ||
36 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_input_id); | ||
37 | #endif | ||
38 | } | ||
39 | |||
40 | void | ||
41 | _ecore_xcb_input_finalize(void) | ||
42 | { | ||
43 | #ifdef ECORE_XCB_XINPUT | ||
44 | xcb_input_get_extension_version_cookie_t cookie; | ||
45 | xcb_input_get_extension_version_reply_t *reply; | ||
46 | char buff[128]; | ||
47 | #endif | ||
48 | |||
49 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
50 | |||
51 | #ifdef ECORE_XCB_XINPUT | ||
52 | cookie = | ||
53 | xcb_input_get_extension_version_unchecked(_ecore_xcb_conn, 127, buff); | ||
54 | reply = | ||
55 | xcb_input_get_extension_version_reply(_ecore_xcb_conn, cookie, NULL); | ||
56 | if (reply) | ||
57 | { | ||
58 | _input_avail = EINA_TRUE; | ||
59 | free(reply); | ||
60 | } | ||
61 | |||
62 | if (_input_avail) | ||
63 | { | ||
64 | const xcb_query_extension_reply_t *ext_reply; | ||
65 | |||
66 | ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_input_id); | ||
67 | if (ext_reply) | ||
68 | _ecore_xcb_event_input = ext_reply->first_event; | ||
69 | } | ||
70 | #endif | ||
71 | } | ||
72 | |||
73 | void | ||
74 | _ecore_xcb_input_shutdown(void) | ||
75 | { | ||
76 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
77 | } | ||
78 | |||
79 | void | ||
80 | #ifdef ECORE_XCB_XINPUT | ||
81 | _ecore_xcb_input_handle_event(xcb_generic_event_t *event) | ||
82 | #else | ||
83 | _ecore_xcb_input_handle_event(xcb_generic_event_t * event __UNUSED__) | ||
84 | #endif | ||
85 | { | ||
86 | #ifdef ECORE_XCB_XINPUT | ||
87 | xcb_ge_event_t *ev; | ||
88 | #endif | ||
89 | |||
90 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
91 | CHECK_XCB_CONN; | ||
92 | |||
93 | /* FIXME: look at xlib ecore_x_xi2.c to copy logic in when i can find an | ||
94 | * xcb-input lib to test with */ | ||
95 | #ifdef ECORE_XCB_XINPUT | ||
96 | ev = (xcb_ge_event_t *)event; | ||
97 | switch (ev->event_type) | ||
98 | { | ||
99 | case XCB_INPUT_DEVICE_MOTION_NOTIFY: | ||
100 | { | ||
101 | xcb_input_device_motion_notify_event_t *de; | ||
102 | unsigned int child_win = 0; | ||
103 | |||
104 | de = (xcb_input_device_motion_notify_event_t *)ev->pad1; | ||
105 | child_win = (de->child ? de->child : de->event); | ||
106 | _ecore_xcb_event_mouse_move(de->time, de->state, de->event_x, | ||
107 | de->event_y, de->root_x, de->root_y, | ||
108 | de->event, child_win, de->root, | ||
109 | de->same_screen, de->device_id, | ||
110 | 1, 1, 1.0, 0.0, | ||
111 | de->event_x, de->event_y, | ||
112 | de->root_x, de->root_y); | ||
113 | } | ||
114 | break; | ||
115 | |||
116 | case XCB_INPUT_DEVICE_BUTTON_PRESS: | ||
117 | { | ||
118 | xcb_input_device_button_press_event_t *de; | ||
119 | unsigned int child_win = 0; | ||
120 | |||
121 | de = (xcb_input_device_button_press_event_t *)ev->pad1; | ||
122 | child_win = (de->child ? de->child : de->event); | ||
123 | _ecore_xcb_event_mouse_button(ECORE_EVENT_MOUSE_BUTTON_DOWN, | ||
124 | de->time, de->state, de->detail, | ||
125 | de->event_x, de->event_y, | ||
126 | de->root_x, de->root_y, de->event, | ||
127 | child_win, de->root, | ||
128 | de->same_screen, de->device_id, | ||
129 | 1, 1, 1.0, 0.0, | ||
130 | de->event_x, de->event_y, | ||
131 | de->root_x, de->root_y); | ||
132 | } | ||
133 | break; | ||
134 | |||
135 | case XCB_INPUT_DEVICE_BUTTON_RELEASE: | ||
136 | { | ||
137 | xcb_input_device_button_release_event_t *de; | ||
138 | unsigned int child_win = 0; | ||
139 | |||
140 | de = (xcb_input_device_button_release_event_t *)ev->pad1; | ||
141 | child_win = (de->child ? de->child : de->event); | ||
142 | _ecore_xcb_event_mouse_button(ECORE_EVENT_MOUSE_BUTTON_UP, | ||
143 | de->time, de->state, de->detail, | ||
144 | de->event_x, de->event_y, | ||
145 | de->root_x, de->root_y, de->event, | ||
146 | child_win, de->root, | ||
147 | de->same_screen, de->device_id, | ||
148 | 1, 1, 1.0, 0.0, | ||
149 | de->event_x, de->event_y, | ||
150 | de->root_x, de->root_y); | ||
151 | } | ||
152 | break; | ||
153 | |||
154 | case XCB_INPUT_DEVICE_TOUCH_UPDATE: | ||
155 | { | ||
156 | xcb_input_device_motion_notify_event_t *de; | ||
157 | unsigned int child_win = 0; | ||
158 | |||
159 | de = (xcb_input_device_motion_notify_event_t *)ev->pad1; | ||
160 | child_win = (de->child ? de->child : de->event); | ||
161 | _ecore_xcb_event_mouse_move(de->time, de->state, de->event_x, | ||
162 | de->event_y, de->root_x, de->root_y, | ||
163 | de->event, child_win, de->root, | ||
164 | de->same_screen, de->device_id, | ||
165 | 1, 1, 1.0, 0.0, | ||
166 | de->event_x, de->event_y, | ||
167 | de->root_x, de->root_y); | ||
168 | } | ||
169 | break; | ||
170 | |||
171 | case XCB_INPUT_DEVICE_TOUCH_BEGIN: | ||
172 | { | ||
173 | xcb_input_device_button_press_event_t *de; | ||
174 | unsigned int child_win = 0; | ||
175 | |||
176 | de = (xcb_input_device_button_press_event_t *)ev->pad1; | ||
177 | child_win = (de->child ? de->child : de->event); | ||
178 | _ecore_xcb_event_mouse_button(ECORE_EVENT_MOUSE_BUTTON_DOWN, | ||
179 | de->time, de->state, de->detail, | ||
180 | de->event_x, de->event_y, | ||
181 | de->root_x, de->root_y, de->event, | ||
182 | child_win, de->root, | ||
183 | de->same_screen, de->device_id, | ||
184 | 1, 1, 1.0, 0.0, | ||
185 | de->event_x, de->event_y, | ||
186 | de->root_x, de->root_y); | ||
187 | } | ||
188 | break; | ||
189 | |||
190 | case XCB_INPUT_DEVICE_TOUCH_END: | ||
191 | { | ||
192 | xcb_input_device_button_release_event_t *de; | ||
193 | unsigned int child_win = 0; | ||
194 | |||
195 | de = (xcb_input_device_button_release_event_t *)ev->pad1; | ||
196 | child_win = (de->child ? de->child : de->event); | ||
197 | _ecore_xcb_event_mouse_button(ECORE_EVENT_MOUSE_BUTTON_UP, | ||
198 | de->time, de->state, de->detail, | ||
199 | de->event_x, de->event_y, | ||
200 | de->root_x, de->root_y, de->event, | ||
201 | child_win, de->root, | ||
202 | de->same_screen, de->device_id, | ||
203 | 1, 1, 1.0, 0.0, | ||
204 | de->event_x, de->event_y, | ||
205 | de->root_x, de->root_y); | ||
206 | } | ||
207 | break; | ||
208 | |||
209 | default: | ||
210 | break; | ||
211 | } | ||
212 | #endif | ||
213 | } | ||
214 | |||
215 | EAPI Eina_Bool | ||
216 | ecore_x_input_multi_select(Ecore_X_Window win) | ||
217 | { | ||
218 | Eina_Bool find = EINA_FALSE; | ||
219 | #ifdef ECORE_XCB_XINPUT | ||
220 | xcb_input_list_input_devices_cookie_t dcookie; | ||
221 | xcb_input_list_input_devices_reply_t *dreply; | ||
222 | xcb_input_device_info_iterator_t diter; | ||
223 | #endif | ||
224 | |||
225 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
226 | CHECK_XCB_CONN; | ||
227 | |||
228 | if (!_input_avail) return EINA_FALSE; | ||
229 | |||
230 | /* FIXME: i can't seemingly test this! no xcb input lib so can't look and | ||
231 | * test and look at types etc. - look at xlib code and copy logic over | ||
232 | * when we can */ | ||
233 | #ifdef ECORE_XCB_XINPUT | ||
234 | dcookie = xcb_input_list_input_devices_unchecked(_ecore_xcb_conn); | ||
235 | dreply = | ||
236 | xcb_input_list_input_devices_reply(_ecore_xcb_conn, dcookie, NULL); | ||
237 | if (!dreply) return EINA_FALSE; | ||
238 | |||
239 | diter = xcb_input_list_input_devices_devices_iterator(dreply); | ||
240 | while (diter.rem) | ||
241 | { | ||
242 | xcb_input_device_info_t *dev; | ||
243 | const xcb_input_event_class_t iclass[] = | ||
244 | { | ||
245 | XCB_INPUT_DEVICE_BUTTON_PRESS, | ||
246 | XCB_INPUT_DEVICE_BUTTON_RELEASE, | ||
247 | XCB_INPUT_DEVICE_MOTION_NOTIFY, | ||
248 | XCB_INPUT_DEVICE_TOUCH_BEGIN, | ||
249 | XCB_INPUT_DEVICE_TOUCH_END, | ||
250 | XCB_INPUT_DEVICE_TOUCH_UPDATE | ||
251 | }; | ||
252 | |||
253 | dev = diter.data; | ||
254 | if (dev->device_use == XCB_INPUT_DEVICE_USE_IS_X_EXTENSION_DEVICE) | ||
255 | { | ||
256 | DBG("Device %d", dev->device_id); | ||
257 | DBG("\tType: %d", dev->device_type); | ||
258 | DBG("\tNum Classes: %d", dev->num_class_info); | ||
259 | DBG("\tUse: %d", dev->device_use); | ||
260 | |||
261 | xcb_input_select_extension_event(_ecore_xcb_conn, win, | ||
262 | sizeof(iclass) / sizeof(xcb_input_event_class_t), | ||
263 | iclass); | ||
264 | find = EINA_TRUE; | ||
265 | } | ||
266 | xcb_input_device_info_next(&diter); | ||
267 | } | ||
268 | free(dreply); | ||
269 | #endif | ||
270 | |||
271 | return find; | ||
272 | win = 0; | ||
273 | } | ||
274 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_keymap.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_keymap.c new file mode 100644 index 0000000..40304df --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_keymap.c | |||
@@ -0,0 +1,482 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #define NEED_KEYSYM_TABLE | ||
3 | #define NEED_VTABLE | ||
4 | #include "ecore_xcb_keysym_table.h" | ||
5 | #include <xcb/xcb_keysyms.h> | ||
6 | #include <X11/keysym.h> | ||
7 | |||
8 | /* local function prototypes */ | ||
9 | static int _ecore_xcb_keymap_mask_get(void *reply, | ||
10 | xcb_keysym_t sym); | ||
11 | static xcb_keysym_t _ecore_xcb_keymap_string_to_keysym(const char *str); | ||
12 | static int _ecore_xcb_keymap_translate_key(xcb_keycode_t keycode, | ||
13 | unsigned int modifiers, | ||
14 | unsigned int *modifiers_return, | ||
15 | xcb_keysym_t *keysym_return); | ||
16 | static int _ecore_xcb_keymap_translate_keysym(xcb_keysym_t keysym, | ||
17 | unsigned int modifiers, | ||
18 | char *buffer, | ||
19 | int bytes); | ||
20 | |||
21 | /* local variables */ | ||
22 | static xcb_key_symbols_t *_ecore_xcb_keysyms; | ||
23 | static int _ecore_xcb_mode_switch = 0; | ||
24 | |||
25 | /* public variables */ | ||
26 | EAPI int ECORE_X_MODIFIER_SHIFT = 0; | ||
27 | EAPI int ECORE_X_MODIFIER_CTRL = 0; | ||
28 | EAPI int ECORE_X_MODIFIER_ALT = 0; | ||
29 | EAPI int ECORE_X_MODIFIER_WIN = 0; | ||
30 | EAPI int ECORE_X_LOCK_SCROLL = 0; | ||
31 | EAPI int ECORE_X_LOCK_NUM = 0; | ||
32 | EAPI int ECORE_X_LOCK_CAPS = 0; | ||
33 | EAPI int ECORE_X_LOCK_SHIFT = 0; | ||
34 | |||
35 | void | ||
36 | _ecore_xcb_keymap_init(void) | ||
37 | { | ||
38 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
39 | |||
40 | _ecore_xcb_keysyms = xcb_key_symbols_alloc(_ecore_xcb_conn); | ||
41 | } | ||
42 | |||
43 | void | ||
44 | _ecore_xcb_keymap_finalize(void) | ||
45 | { | ||
46 | xcb_get_modifier_mapping_cookie_t cookie; | ||
47 | xcb_get_modifier_mapping_reply_t *reply; | ||
48 | |||
49 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
50 | CHECK_XCB_CONN; | ||
51 | |||
52 | cookie = xcb_get_modifier_mapping_unchecked(_ecore_xcb_conn); | ||
53 | reply = xcb_get_modifier_mapping_reply(_ecore_xcb_conn, cookie, NULL); | ||
54 | if (!reply) | ||
55 | { | ||
56 | xcb_key_symbols_free(_ecore_xcb_keysyms); | ||
57 | return; | ||
58 | } | ||
59 | |||
60 | _ecore_xcb_mode_switch = _ecore_xcb_keymap_mask_get(reply, XK_Mode_switch); | ||
61 | |||
62 | ECORE_X_MODIFIER_SHIFT = _ecore_xcb_keymap_mask_get(reply, XK_Shift_L); | ||
63 | ECORE_X_MODIFIER_CTRL = _ecore_xcb_keymap_mask_get(reply, XK_Control_L); | ||
64 | |||
65 | ECORE_X_MODIFIER_ALT = _ecore_xcb_keymap_mask_get(reply, XK_Alt_L); | ||
66 | if (!ECORE_X_MODIFIER_ALT) | ||
67 | ECORE_X_MODIFIER_ALT = _ecore_xcb_keymap_mask_get(reply, XK_Meta_L); | ||
68 | if (!ECORE_X_MODIFIER_ALT) | ||
69 | ECORE_X_MODIFIER_ALT = _ecore_xcb_keymap_mask_get(reply, XK_Super_L); | ||
70 | |||
71 | ECORE_X_MODIFIER_WIN = _ecore_xcb_keymap_mask_get(reply, XK_Super_L); | ||
72 | if (!ECORE_X_MODIFIER_WIN) | ||
73 | ECORE_X_MODIFIER_WIN = _ecore_xcb_keymap_mask_get(reply, XK_Mode_switch); | ||
74 | if (!ECORE_X_MODIFIER_WIN) | ||
75 | ECORE_X_MODIFIER_WIN = _ecore_xcb_keymap_mask_get(reply, XK_Meta_L); | ||
76 | |||
77 | if (ECORE_X_MODIFIER_WIN == ECORE_X_MODIFIER_ALT) | ||
78 | ECORE_X_MODIFIER_WIN = 0; | ||
79 | if (ECORE_X_MODIFIER_ALT == ECORE_X_MODIFIER_CTRL) | ||
80 | ECORE_X_MODIFIER_ALT = 0; | ||
81 | |||
82 | ECORE_X_LOCK_SCROLL = _ecore_xcb_keymap_mask_get(reply, XK_Scroll_Lock); | ||
83 | ECORE_X_LOCK_NUM = _ecore_xcb_keymap_mask_get(reply, XK_Num_Lock); | ||
84 | ECORE_X_LOCK_CAPS = _ecore_xcb_keymap_mask_get(reply, XK_Caps_Lock); | ||
85 | ECORE_X_LOCK_SHIFT = _ecore_xcb_keymap_mask_get(reply, XK_Shift_Lock); | ||
86 | } | ||
87 | |||
88 | void | ||
89 | _ecore_xcb_modifiers_get(void) | ||
90 | { | ||
91 | _ecore_xcb_keymap_finalize(); | ||
92 | } | ||
93 | |||
94 | void | ||
95 | _ecore_xcb_keymap_shutdown(void) | ||
96 | { | ||
97 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
98 | |||
99 | if (_ecore_xcb_keysyms) xcb_key_symbols_free(_ecore_xcb_keysyms); | ||
100 | } | ||
101 | |||
102 | void | ||
103 | _ecore_xcb_keymap_refresh(xcb_mapping_notify_event_t *event) | ||
104 | { | ||
105 | CHECK_XCB_CONN; | ||
106 | xcb_refresh_keyboard_mapping(_ecore_xcb_keysyms, event); | ||
107 | } | ||
108 | |||
109 | xcb_keysym_t | ||
110 | _ecore_xcb_keymap_keycode_to_keysym(xcb_keycode_t keycode, | ||
111 | int col) | ||
112 | { | ||
113 | xcb_keysym_t key0, key1; | ||
114 | |||
115 | CHECK_XCB_CONN; | ||
116 | if (col & _ecore_xcb_mode_switch) | ||
117 | { | ||
118 | key0 = xcb_key_symbols_get_keysym(_ecore_xcb_keysyms, keycode, 4); | ||
119 | key1 = xcb_key_symbols_get_keysym(_ecore_xcb_keysyms, keycode, 5); | ||
120 | } | ||
121 | else | ||
122 | { | ||
123 | key0 = xcb_key_symbols_get_keysym(_ecore_xcb_keysyms, keycode, 0); | ||
124 | key1 = xcb_key_symbols_get_keysym(_ecore_xcb_keysyms, keycode, 1); | ||
125 | } | ||
126 | |||
127 | if (key1 == XCB_NO_SYMBOL) | ||
128 | key1 = key0; | ||
129 | |||
130 | if ((col & ECORE_X_LOCK_NUM) && | ||
131 | ((xcb_is_keypad_key(key1)) || (xcb_is_private_keypad_key(key1)))) | ||
132 | { | ||
133 | if ((col & XCB_MOD_MASK_SHIFT) || | ||
134 | ((col & XCB_MOD_MASK_LOCK) && (col & ECORE_X_LOCK_SHIFT))) | ||
135 | return key0; | ||
136 | else | ||
137 | return key1; | ||
138 | } | ||
139 | else if (!(col & XCB_MOD_MASK_SHIFT) && !(col & XCB_MOD_MASK_LOCK)) | ||
140 | return key0; | ||
141 | else if (!(col & XCB_MOD_MASK_SHIFT) && | ||
142 | (col & XCB_MOD_MASK_LOCK && (col & ECORE_X_LOCK_CAPS))) | ||
143 | return key1; | ||
144 | else if ((col & XCB_MOD_MASK_SHIFT) && | ||
145 | (col & XCB_MOD_MASK_LOCK) && (col & ECORE_X_LOCK_CAPS)) | ||
146 | return key0; | ||
147 | else if ((col & XCB_MOD_MASK_SHIFT) || | ||
148 | (col & XCB_MOD_MASK_LOCK && (col & ECORE_X_LOCK_SHIFT))) | ||
149 | return key1; | ||
150 | |||
151 | return XCB_NO_SYMBOL; | ||
152 | } | ||
153 | |||
154 | xcb_keycode_t * | ||
155 | _ecore_xcb_keymap_keysym_to_keycode(xcb_keysym_t keysym) | ||
156 | { | ||
157 | CHECK_XCB_CONN; | ||
158 | return xcb_key_symbols_get_keycode(_ecore_xcb_keysyms, keysym); | ||
159 | } | ||
160 | |||
161 | char * | ||
162 | _ecore_xcb_keymap_keysym_to_string(xcb_keysym_t keysym) | ||
163 | { | ||
164 | int i = 0, n = 0, h = 0, idx = 0; | ||
165 | const unsigned char *entry; | ||
166 | unsigned char val1, val2, val3, val4; | ||
167 | |||
168 | CHECK_XCB_CONN; | ||
169 | if (!keysym) return NULL; | ||
170 | if (keysym == XK_VoidSymbol) keysym = 0; | ||
171 | if (keysym <= 0x1fffffff) | ||
172 | { | ||
173 | val1 = (keysym >> 24); | ||
174 | val2 = ((keysym >> 16) & 0xff); | ||
175 | val3 = ((keysym >> 8) & 0xff); | ||
176 | val4 = (keysym & 0xff); | ||
177 | i = keysym % VTABLESIZE; | ||
178 | h = i + 1; | ||
179 | n = VMAXHASH; | ||
180 | while ((idx = hashKeysym[i])) | ||
181 | { | ||
182 | entry = &_ecore_xcb_keytable[idx]; | ||
183 | if ((entry[0] == val1) && (entry[1] == val2) && | ||
184 | (entry[2] == val3) && (entry[3] == val4)) | ||
185 | return (char *)entry + 4; | ||
186 | if (!--n) break; | ||
187 | i += h; | ||
188 | if (i >= VTABLESIZE) i -= VTABLESIZE; | ||
189 | } | ||
190 | } | ||
191 | |||
192 | if ((keysym >= 0x01000100) && (keysym <= 0x0110ffff)) | ||
193 | { | ||
194 | xcb_keysym_t val; | ||
195 | char *s = NULL; | ||
196 | int i = 0; | ||
197 | |||
198 | val = (keysym & 0xffffff); | ||
199 | if (val & 0xff0000) | ||
200 | i = 10; | ||
201 | else | ||
202 | i = 6; | ||
203 | |||
204 | if (!(s = malloc(i))) return NULL; | ||
205 | i--; | ||
206 | s[i--] = '\0'; | ||
207 | for (; i; i--) | ||
208 | { | ||
209 | val1 = (val & 0xf); | ||
210 | val >>= 4; | ||
211 | if (val1 < 10) | ||
212 | s[i] = '0' + val1; | ||
213 | else | ||
214 | s[i] = 'A' + val1 - 10; | ||
215 | } | ||
216 | s[i] = 'U'; | ||
217 | return s; | ||
218 | } | ||
219 | |||
220 | return NULL; | ||
221 | } | ||
222 | |||
223 | xcb_keycode_t | ||
224 | _ecore_xcb_keymap_string_to_keycode(const char *key) | ||
225 | { | ||
226 | if (!strncmp(key, "Keycode-", 8)) | ||
227 | return atoi(key + 8); | ||
228 | else | ||
229 | { | ||
230 | xcb_keysym_t keysym = XCB_NO_SYMBOL; | ||
231 | xcb_keycode_t *keycodes, keycode = 0; | ||
232 | int i = 0; | ||
233 | |||
234 | CHECK_XCB_CONN; | ||
235 | |||
236 | keysym = _ecore_xcb_keymap_string_to_keysym(key); | ||
237 | if (keysym == XCB_NO_SYMBOL) return XCB_NO_SYMBOL; | ||
238 | |||
239 | keycodes = _ecore_xcb_keymap_keysym_to_keycode(keysym); | ||
240 | if (!keycodes) return XCB_NO_SYMBOL; | ||
241 | |||
242 | while (keycodes[i] != XCB_NO_SYMBOL) | ||
243 | { | ||
244 | if (keycodes[i] != 0) | ||
245 | { | ||
246 | keycode = keycodes[i]; | ||
247 | break; | ||
248 | } | ||
249 | i++; | ||
250 | } | ||
251 | return keycode; | ||
252 | } | ||
253 | } | ||
254 | |||
255 | int | ||
256 | _ecore_xcb_keymap_lookup_string(xcb_keycode_t keycode, | ||
257 | int state, | ||
258 | char *buffer, | ||
259 | int bytes, | ||
260 | xcb_keysym_t *sym) | ||
261 | { | ||
262 | unsigned int modifiers = 0; | ||
263 | xcb_keysym_t keysym; | ||
264 | |||
265 | CHECK_XCB_CONN; | ||
266 | if (!_ecore_xcb_keymap_translate_key(keycode, state, &modifiers, &keysym)) | ||
267 | return 0; | ||
268 | |||
269 | if (sym) *sym = keysym; | ||
270 | |||
271 | return _ecore_xcb_keymap_translate_keysym(keysym, state, buffer, bytes); | ||
272 | } | ||
273 | |||
274 | EAPI const char * | ||
275 | ecore_x_keysym_string_get(int keysym) | ||
276 | { | ||
277 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
278 | |||
279 | return _ecore_xcb_keymap_keysym_to_string(keysym); | ||
280 | } | ||
281 | |||
282 | /* local functions */ | ||
283 | static int | ||
284 | _ecore_xcb_keymap_mask_get(void *reply, | ||
285 | xcb_keysym_t sym) | ||
286 | { | ||
287 | xcb_get_modifier_mapping_reply_t *rep; | ||
288 | xcb_keysym_t sym2; | ||
289 | int mask = 0; | ||
290 | const int masks[8] = | ||
291 | { | ||
292 | XCB_MOD_MASK_SHIFT, XCB_MOD_MASK_LOCK, XCB_MOD_MASK_CONTROL, | ||
293 | XCB_MOD_MASK_1, XCB_MOD_MASK_2, XCB_MOD_MASK_3, XCB_MOD_MASK_4, | ||
294 | XCB_MOD_MASK_5 | ||
295 | }; | ||
296 | |||
297 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
298 | CHECK_XCB_CONN; | ||
299 | |||
300 | rep = (xcb_get_modifier_mapping_reply_t *)reply; | ||
301 | if ((rep) && (rep->keycodes_per_modifier > 0)) | ||
302 | { | ||
303 | int i = 0; | ||
304 | xcb_keycode_t *modmap; | ||
305 | |||
306 | modmap = xcb_get_modifier_mapping_keycodes(rep); | ||
307 | for (i = 0; i < (8 * rep->keycodes_per_modifier); i++) | ||
308 | { | ||
309 | int j = 0; | ||
310 | |||
311 | for (j = 0; j < 8; j++) | ||
312 | { | ||
313 | sym2 = | ||
314 | xcb_key_symbols_get_keysym(_ecore_xcb_keysyms, | ||
315 | modmap[i], j); | ||
316 | if (sym2 != 0) break; | ||
317 | } | ||
318 | if (sym2 == sym) | ||
319 | { | ||
320 | mask = masks[i / rep->keycodes_per_modifier]; | ||
321 | break; | ||
322 | } | ||
323 | } | ||
324 | } | ||
325 | |||
326 | return mask; | ||
327 | } | ||
328 | |||
329 | static xcb_keysym_t | ||
330 | _ecore_xcb_keymap_string_to_keysym(const char *str) | ||
331 | { | ||
332 | int i = 0, n = 0, h = 0; | ||
333 | unsigned long sig = 0; | ||
334 | const char *p = NULL; | ||
335 | int c = 0, idx = 0; | ||
336 | const unsigned char *entry; | ||
337 | unsigned char sig1, sig2; | ||
338 | long unsigned int val; | ||
339 | |||
340 | p = str; | ||
341 | while ((c = *p++)) | ||
342 | sig = (sig << 1) + c; | ||
343 | |||
344 | i = (sig % KTABLESIZE); | ||
345 | h = i + 1; | ||
346 | sig1 = (sig >> 8) & 0xff; | ||
347 | sig2 = sig & 0xff; | ||
348 | n = KMAXHASH; | ||
349 | |||
350 | while ((idx = hashString[i])) | ||
351 | { | ||
352 | entry = &_ecore_xcb_keytable[idx]; | ||
353 | if ((entry[0] == sig1) && (entry[1] == sig2) && | ||
354 | !strcmp(str, (char *)entry + 6)) | ||
355 | { | ||
356 | val = ((entry[2] << 24) | (entry[3] << 16) | | ||
357 | (entry[4] << 8) | (entry[5])); | ||
358 | if (!val) val = 0xffffff; | ||
359 | return val; | ||
360 | } | ||
361 | if (!--n) break; | ||
362 | i += h; | ||
363 | if (i >= KTABLESIZE) i -= KTABLESIZE; | ||
364 | } | ||
365 | |||
366 | if (*str == 'U') | ||
367 | { | ||
368 | val = 0; | ||
369 | for (p = &str[1]; *p; p++) | ||
370 | { | ||
371 | c = *p; | ||
372 | if (('0' <= c) && (c <= '9')) | ||
373 | val = (val << 4) + c - '0'; | ||
374 | else if (('a' <= c) && (c <= 'f')) | ||
375 | val = (val << 4) + c - 'a' + 10; | ||
376 | else if (('A' <= c) && (c <= 'F')) | ||
377 | val = (val << 4) + c - 'A' + 10; | ||
378 | else | ||
379 | return XCB_NO_SYMBOL; | ||
380 | if (val > 0x10ffff) return XCB_NO_SYMBOL; | ||
381 | } | ||
382 | if ((val < 0x20) || ((val > 0x7e) && (val < 0xa0))) | ||
383 | return XCB_NO_SYMBOL; | ||
384 | if (val < 0x100) return val; | ||
385 | return val | 0x01000000; | ||
386 | } | ||
387 | |||
388 | if ((strlen(str) > 2) && (str[0] == '0') && (str[1] == 'x')) | ||
389 | { | ||
390 | char *tmp = NULL; | ||
391 | |||
392 | val = strtoul(str, &tmp, 16); | ||
393 | if ((val == ULONG_MAX) || ((tmp) && (*tmp != '\0'))) | ||
394 | return XCB_NO_SYMBOL; | ||
395 | else | ||
396 | return val; | ||
397 | } | ||
398 | |||
399 | if (!strncmp(str, "XF86_", 5)) | ||
400 | { | ||
401 | long unsigned int ret; | ||
402 | char *tmp; | ||
403 | |||
404 | tmp = strdup(str); | ||
405 | if (!tmp) return XCB_NO_SYMBOL; | ||
406 | memmove(&tmp[4], &tmp[5], strlen(str) - 5 + 1); | ||
407 | ret = _ecore_xcb_keymap_string_to_keysym(tmp); | ||
408 | free(tmp); | ||
409 | return ret; | ||
410 | } | ||
411 | |||
412 | return XCB_NO_SYMBOL; | ||
413 | } | ||
414 | |||
415 | static int | ||
416 | _ecore_xcb_keymap_translate_key(xcb_keycode_t keycode, | ||
417 | unsigned int modifiers, | ||
418 | unsigned int *modifiers_return, | ||
419 | xcb_keysym_t *keysym_return) | ||
420 | { | ||
421 | xcb_keysym_t sym; | ||
422 | |||
423 | if (!_ecore_xcb_keysyms) return 0; | ||
424 | |||
425 | sym = _ecore_xcb_keymap_keycode_to_keysym(keycode, modifiers); | ||
426 | |||
427 | if (modifiers_return) | ||
428 | *modifiers_return = ((XCB_MOD_MASK_SHIFT | XCB_MOD_MASK_LOCK) | | ||
429 | _ecore_xcb_mode_switch | ECORE_X_LOCK_NUM); | ||
430 | if (keysym_return) | ||
431 | *keysym_return = sym; | ||
432 | |||
433 | return 1; | ||
434 | } | ||
435 | |||
436 | static int | ||
437 | _ecore_xcb_keymap_translate_keysym(xcb_keysym_t keysym, | ||
438 | unsigned int modifiers, | ||
439 | char *buffer, | ||
440 | int bytes) | ||
441 | { | ||
442 | unsigned long hbytes = 0; | ||
443 | unsigned char c; | ||
444 | |||
445 | if (!keysym) return 0; | ||
446 | hbytes = (keysym >> 8); | ||
447 | |||
448 | if (!(bytes && | ||
449 | ((hbytes == 0) || | ||
450 | ((hbytes == 0xFF) && | ||
451 | (((keysym >= XK_BackSpace) && (keysym <= XK_Clear)) || | ||
452 | (keysym == XK_Return) || (keysym == XK_Escape) || | ||
453 | (keysym == XK_KP_Space) || (keysym == XK_KP_Tab) || | ||
454 | (keysym == XK_KP_Enter) || | ||
455 | ((keysym >= XK_KP_Multiply) && (keysym <= XK_KP_9)) || | ||
456 | (keysym == XK_KP_Equal) || (keysym == XK_Delete)))))) | ||
457 | return 0; | ||
458 | |||
459 | if (keysym == XK_KP_Space) | ||
460 | c = (XK_space & 0x7F); | ||
461 | else if (hbytes == 0xFF) | ||
462 | c = (keysym & 0x7F); | ||
463 | else | ||
464 | c = (keysym & 0xFF); | ||
465 | |||
466 | if (modifiers & ECORE_X_MODIFIER_CTRL) | ||
467 | { | ||
468 | if (((c >= '@') && (c < '\177')) || c == ' ') | ||
469 | c &= 0x1F; | ||
470 | else if (c == '2') | ||
471 | c = '\000'; | ||
472 | else if ((c >= '3') && (c <= '7')) | ||
473 | c -= ('3' - '\033'); | ||
474 | else if (c == '8') | ||
475 | c = '\177'; | ||
476 | else if (c == '/') | ||
477 | c = '_' & 0x1F; | ||
478 | } | ||
479 | buffer[0] = c; | ||
480 | return 1; | ||
481 | } | ||
482 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_mwm.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_mwm.c new file mode 100644 index 0000000..6c95331 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_mwm.c | |||
@@ -0,0 +1,104 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | //#include "Ecore_X_Atoms.h" | ||
3 | |||
4 | #define ECORE_X_MWM_HINTS_FUNCTIONS (1 << 0) | ||
5 | #define ECORE_X_MWM_HINTS_DECORATIONS (1 << 1) | ||
6 | #define ECORE_X_MWM_HINTS_INPUT_MODE (1 << 2) | ||
7 | #define ECORE_X_MWM_HINTS_STATUS (1 << 3) | ||
8 | |||
9 | typedef struct _mwmhints | ||
10 | { | ||
11 | uint32_t flags; | ||
12 | uint32_t functions; | ||
13 | uint32_t decorations; | ||
14 | int32_t inputmode; | ||
15 | uint32_t status; | ||
16 | } MWMHints; | ||
17 | |||
18 | /** | ||
19 | * @defgroup Ecore_X_MWM_Group MWM related functions. | ||
20 | * | ||
21 | * Functions related to MWM. | ||
22 | */ | ||
23 | |||
24 | /** | ||
25 | * Sets the borderless flag of a window using MWM. | ||
26 | * | ||
27 | * @param win The window. | ||
28 | * @param borderless The borderless flag. | ||
29 | * | ||
30 | * @ingroup Ecore_X_MWM_Group | ||
31 | */ | ||
32 | EAPI void | ||
33 | ecore_x_mwm_borderless_set(Ecore_X_Window win, | ||
34 | Eina_Bool borderless) | ||
35 | { | ||
36 | uint32_t data[5] = { 0, 0, 0, 0, 0 }; | ||
37 | |||
38 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
39 | |||
40 | data[0] = 2; | ||
41 | data[2] = !borderless; | ||
42 | |||
43 | ecore_x_window_prop_property_set(win, | ||
44 | ECORE_X_ATOM_MOTIF_WM_HINTS, | ||
45 | ECORE_X_ATOM_MOTIF_WM_HINTS, 32, | ||
46 | (void *)data, 5); | ||
47 | } | ||
48 | |||
49 | EAPI Eina_Bool | ||
50 | ecore_x_mwm_hints_get(Ecore_X_Window win, | ||
51 | Ecore_X_MWM_Hint_Func *fhint, | ||
52 | Ecore_X_MWM_Hint_Decor *dhint, | ||
53 | Ecore_X_MWM_Hint_Input *ihint) | ||
54 | { | ||
55 | xcb_get_property_cookie_t cookie; | ||
56 | xcb_get_property_reply_t *reply; | ||
57 | MWMHints *mwmhints = NULL; | ||
58 | int ret = EINA_FALSE; | ||
59 | |||
60 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
61 | CHECK_XCB_CONN; | ||
62 | |||
63 | cookie = | ||
64 | xcb_get_property_unchecked(_ecore_xcb_conn, 0, win, | ||
65 | ECORE_X_ATOM_MOTIF_WM_HINTS, | ||
66 | ECORE_X_ATOM_MOTIF_WM_HINTS, 0, UINT_MAX); | ||
67 | reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL); | ||
68 | if (!reply) return EINA_FALSE; | ||
69 | if ((reply->format != 32) || (reply->value_len == 0)) | ||
70 | { | ||
71 | free(reply); | ||
72 | return EINA_FALSE; | ||
73 | } | ||
74 | |||
75 | mwmhints = xcb_get_property_value(reply); | ||
76 | if (reply->value_len >= 4) | ||
77 | { | ||
78 | if (dhint) | ||
79 | { | ||
80 | if (mwmhints->flags & ECORE_X_MWM_HINTS_DECORATIONS) | ||
81 | *dhint = mwmhints->decorations; | ||
82 | else | ||
83 | *dhint = ECORE_X_MWM_HINT_DECOR_ALL; | ||
84 | } | ||
85 | if (fhint) | ||
86 | { | ||
87 | if (mwmhints->flags & ECORE_X_MWM_HINTS_FUNCTIONS) | ||
88 | *fhint = mwmhints->functions; | ||
89 | else | ||
90 | *fhint = ECORE_X_MWM_HINT_FUNC_ALL; | ||
91 | } | ||
92 | if (ihint) | ||
93 | { | ||
94 | if (mwmhints->flags & ECORE_X_MWM_HINTS_INPUT_MODE) | ||
95 | *ihint = mwmhints->inputmode; | ||
96 | else | ||
97 | *ihint = ECORE_X_MWM_HINT_INPUT_MODELESS; | ||
98 | } | ||
99 | ret = EINA_TRUE; | ||
100 | } | ||
101 | free(reply); | ||
102 | return ret; | ||
103 | } | ||
104 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_netwm.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_netwm.c new file mode 100644 index 0000000..0a523b9 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_netwm.c | |||
@@ -0,0 +1,1525 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | |||
3 | /* local function prototypes */ | ||
4 | /* static void _ecore_xcb_netwm_startup_info_free(void *data); */ | ||
5 | static Ecore_X_Atom _ecore_xcb_netwm_window_type_atom_get(Ecore_X_Window_Type type); | ||
6 | static Ecore_X_Window_Type _ecore_xcb_netwm_window_type_type_get(Ecore_X_Atom atom); | ||
7 | static Ecore_X_Atom _ecore_xcb_netwm_window_state_atom_get(Ecore_X_Window_State state); | ||
8 | static Ecore_X_Atom _ecore_xcb_netwm_action_atom_get(Ecore_X_Action action); | ||
9 | |||
10 | /* local variables */ | ||
11 | //static Eina_Hash *_startup_info = NULL; | ||
12 | |||
13 | /* local structures */ | ||
14 | typedef struct _Ecore_Xcb_Startup_Info Ecore_Xcb_Startup_Info; | ||
15 | struct _Ecore_Xcb_Startup_Info | ||
16 | { | ||
17 | Ecore_X_Window win; | ||
18 | int init, size; | ||
19 | char *buffer; | ||
20 | int length; | ||
21 | |||
22 | /* sequence info fields */ | ||
23 | char *id, *name; | ||
24 | int screen; | ||
25 | char *bin, *icon; | ||
26 | int desktop, timestamp; | ||
27 | char *description, *wmclass; | ||
28 | int silent; | ||
29 | }; | ||
30 | |||
31 | EAPI void | ||
32 | ecore_x_netwm_init(void) | ||
33 | { | ||
34 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
35 | |||
36 | // _startup_info = | ||
37 | // eina_hash_string_superfast_new(_ecore_xcb_netwm_startup_info_free); | ||
38 | } | ||
39 | |||
40 | EAPI void | ||
41 | ecore_x_netwm_shutdown(void) | ||
42 | { | ||
43 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
44 | |||
45 | // if (_startup_info) eina_hash_free(_startup_info); | ||
46 | // _startup_info = NULL; | ||
47 | } | ||
48 | |||
49 | EAPI Eina_Bool | ||
50 | ecore_x_netwm_pid_get(Ecore_X_Window win, | ||
51 | int *pid) | ||
52 | { | ||
53 | uint32_t tmp; | ||
54 | |||
55 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
56 | |||
57 | if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_PID, &tmp, 1)) | ||
58 | return EINA_FALSE; | ||
59 | |||
60 | if (pid) *pid = tmp; | ||
61 | |||
62 | return EINA_TRUE; | ||
63 | } | ||
64 | |||
65 | EAPI void | ||
66 | ecore_x_netwm_pid_set(Ecore_X_Window win, | ||
67 | int pid) | ||
68 | { | ||
69 | unsigned int tmp; | ||
70 | |||
71 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
72 | |||
73 | tmp = pid; | ||
74 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_PID, &tmp, 1); | ||
75 | } | ||
76 | |||
77 | EAPI Eina_Bool | ||
78 | ecore_x_netwm_window_type_get(Ecore_X_Window win, | ||
79 | Ecore_X_Window_Type *type) | ||
80 | { | ||
81 | Ecore_X_Atom *atoms; | ||
82 | int num = 0; | ||
83 | |||
84 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
85 | |||
86 | if (type) *type = ECORE_X_WINDOW_TYPE_NORMAL; | ||
87 | |||
88 | num = | ||
89 | ecore_x_window_prop_atom_list_get(win, | ||
90 | ECORE_X_ATOM_NET_WM_WINDOW_TYPE, &atoms); | ||
91 | if ((type) && (num >= 1) && (atoms)) | ||
92 | *type = _ecore_xcb_netwm_window_type_type_get(atoms[0]); | ||
93 | |||
94 | if (atoms) free(atoms); | ||
95 | |||
96 | if (num >= 1) return EINA_TRUE; | ||
97 | return EINA_FALSE; | ||
98 | } | ||
99 | |||
100 | EAPI void | ||
101 | ecore_x_netwm_window_type_set(Ecore_X_Window win, | ||
102 | Ecore_X_Window_Type type) | ||
103 | { | ||
104 | Ecore_X_Atom atom; | ||
105 | |||
106 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
107 | |||
108 | atom = _ecore_xcb_netwm_window_type_atom_get(type); | ||
109 | ecore_x_window_prop_atom_set(win, ECORE_X_ATOM_NET_WM_WINDOW_TYPE, &atom, 1); | ||
110 | } | ||
111 | |||
112 | EAPI int | ||
113 | ecore_x_netwm_window_types_get(Ecore_X_Window win, | ||
114 | Ecore_X_Window_Type **types) | ||
115 | { | ||
116 | int num = 0, i = 0; | ||
117 | Ecore_X_Atom *atoms = NULL; | ||
118 | Ecore_X_Window_Type *atoms2 = NULL; | ||
119 | |||
120 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
121 | |||
122 | if (types) *types = NULL; | ||
123 | num = | ||
124 | ecore_x_window_prop_atom_list_get(win, ECORE_X_ATOM_NET_WM_WINDOW_TYPE, | ||
125 | &atoms); | ||
126 | if ((num <= 0) || (!atoms)) | ||
127 | { | ||
128 | if (atoms) free(atoms); | ||
129 | return 0; | ||
130 | } | ||
131 | |||
132 | atoms2 = malloc(num * sizeof(Ecore_X_Window_Type)); | ||
133 | if (!atoms2) | ||
134 | { | ||
135 | if (atoms) free(atoms); | ||
136 | return 0; | ||
137 | } | ||
138 | |||
139 | for (i = 0; i < num; i++) | ||
140 | atoms2[i] = _ecore_xcb_netwm_window_type_type_get(atoms[i]); | ||
141 | if (atoms) free(atoms); | ||
142 | |||
143 | if (types) | ||
144 | *types = atoms2; | ||
145 | else | ||
146 | free(atoms2); | ||
147 | |||
148 | return num; | ||
149 | } | ||
150 | |||
151 | EAPI int | ||
152 | ecore_x_netwm_name_get(Ecore_X_Window win, | ||
153 | char **name) | ||
154 | { | ||
155 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
156 | |||
157 | if (name) | ||
158 | *name = ecore_x_window_prop_string_get(win, ECORE_X_ATOM_NET_WM_NAME); | ||
159 | return 1; | ||
160 | } | ||
161 | |||
162 | EAPI void | ||
163 | ecore_x_netwm_name_set(Ecore_X_Window win, | ||
164 | const char *name) | ||
165 | { | ||
166 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
167 | |||
168 | ecore_x_window_prop_string_set(win, ECORE_X_ATOM_NET_WM_NAME, name); | ||
169 | } | ||
170 | |||
171 | EAPI void | ||
172 | ecore_x_netwm_opacity_set(Ecore_X_Window win, | ||
173 | unsigned int opacity) | ||
174 | { | ||
175 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
176 | |||
177 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_WINDOW_OPACITY, | ||
178 | &opacity, 1); | ||
179 | } | ||
180 | |||
181 | EAPI Eina_Bool | ||
182 | ecore_x_netwm_opacity_get(Ecore_X_Window win, | ||
183 | unsigned int *opacity) | ||
184 | { | ||
185 | unsigned int tmp = 0; | ||
186 | |||
187 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
188 | |||
189 | if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_WINDOW_OPACITY, | ||
190 | &tmp, 1)) | ||
191 | return EINA_FALSE; | ||
192 | |||
193 | if (opacity) *opacity = tmp; | ||
194 | |||
195 | return EINA_TRUE; | ||
196 | } | ||
197 | |||
198 | EAPI void | ||
199 | ecore_x_netwm_wm_identify(Ecore_X_Window root, | ||
200 | Ecore_X_Window check, | ||
201 | const char *wm_name) | ||
202 | { | ||
203 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
204 | |||
205 | ecore_x_window_prop_window_set(root, ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK, | ||
206 | &check, 1); | ||
207 | ecore_x_window_prop_window_set(check, ECORE_X_ATOM_NET_SUPPORTING_WM_CHECK, | ||
208 | &check, 1); | ||
209 | ecore_x_window_prop_string_set(check, ECORE_X_ATOM_NET_WM_NAME, wm_name); | ||
210 | ecore_x_window_prop_string_set(root, ECORE_X_ATOM_NET_WM_NAME, wm_name); | ||
211 | } | ||
212 | |||
213 | EAPI void | ||
214 | ecore_x_netwm_supported_set(Ecore_X_Window root, | ||
215 | Ecore_X_Atom *supported, | ||
216 | int num) | ||
217 | { | ||
218 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
219 | |||
220 | ecore_x_window_prop_atom_set(root, ECORE_X_ATOM_NET_SUPPORTED, | ||
221 | supported, num); | ||
222 | } | ||
223 | |||
224 | EAPI Eina_Bool | ||
225 | ecore_x_netwm_supported_get(Ecore_X_Window root, | ||
226 | Ecore_X_Atom **supported, | ||
227 | int *num) | ||
228 | { | ||
229 | int num_ret = 0; | ||
230 | |||
231 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
232 | |||
233 | if (num) *num = 0; | ||
234 | if (supported) *supported = NULL; | ||
235 | |||
236 | num_ret = | ||
237 | ecore_x_window_prop_atom_list_get(root, ECORE_X_ATOM_NET_SUPPORTED, | ||
238 | supported); | ||
239 | if (num_ret <= 0) return EINA_FALSE; | ||
240 | if (num) *num = num_ret; | ||
241 | |||
242 | return EINA_TRUE; | ||
243 | } | ||
244 | |||
245 | EAPI void | ||
246 | ecore_x_netwm_desk_count_set(Ecore_X_Window root, | ||
247 | unsigned int n_desks) | ||
248 | { | ||
249 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
250 | |||
251 | ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_NUMBER_OF_DESKTOPS, | ||
252 | &n_desks, 1); | ||
253 | } | ||
254 | |||
255 | EAPI void | ||
256 | ecore_x_netwm_desk_roots_set(Ecore_X_Window root, | ||
257 | Ecore_X_Window *vroots, | ||
258 | unsigned int n_desks) | ||
259 | { | ||
260 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
261 | |||
262 | ecore_x_window_prop_window_set(root, ECORE_X_ATOM_NET_VIRTUAL_ROOTS, | ||
263 | vroots, n_desks); | ||
264 | } | ||
265 | |||
266 | EAPI void | ||
267 | ecore_x_netwm_desk_names_set(Ecore_X_Window root, | ||
268 | const char **names, | ||
269 | unsigned int n_desks) | ||
270 | { | ||
271 | char ss[32], *buf = NULL, *t = NULL; | ||
272 | const char *s; | ||
273 | uint32_t len = 0, i, l; | ||
274 | |||
275 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
276 | CHECK_XCB_CONN; | ||
277 | |||
278 | for (i = 0; i < n_desks; i++) | ||
279 | { | ||
280 | s = ((names) ? names[i] : NULL); | ||
281 | if (!s) | ||
282 | { | ||
283 | /* Default to "Desk-<number>" */ | ||
284 | sprintf(ss, "Desk-%d", i); | ||
285 | s = ss; | ||
286 | } | ||
287 | |||
288 | l = strlen(s) + 1; | ||
289 | t = realloc(buf, len + 1); | ||
290 | if (t) | ||
291 | { | ||
292 | buf = t; | ||
293 | memcpy(buf + len, s, l); | ||
294 | } | ||
295 | len += l; | ||
296 | } | ||
297 | |||
298 | xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, root, | ||
299 | ECORE_X_ATOM_NET_DESKTOP_NAMES, | ||
300 | ECORE_X_ATOM_UTF8_STRING, 8, len, (const void *)buf); | ||
301 | // ecore_x_flush(); | ||
302 | free(buf); | ||
303 | } | ||
304 | |||
305 | EAPI void | ||
306 | ecore_x_netwm_desk_size_set(Ecore_X_Window root, | ||
307 | unsigned int width, | ||
308 | unsigned int height) | ||
309 | { | ||
310 | uint32_t size[2]; | ||
311 | |||
312 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
313 | |||
314 | size[0] = width; | ||
315 | size[1] = height; | ||
316 | ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_DESKTOP_GEOMETRY, | ||
317 | size, 2); | ||
318 | } | ||
319 | |||
320 | EAPI void | ||
321 | ecore_x_netwm_desk_viewports_set(Ecore_X_Window root, | ||
322 | unsigned int *origins, | ||
323 | unsigned int n_desks) | ||
324 | { | ||
325 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
326 | |||
327 | ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_DESKTOP_VIEWPORT, | ||
328 | origins, (2 * n_desks)); | ||
329 | } | ||
330 | |||
331 | EAPI void | ||
332 | ecore_x_netwm_desk_layout_set(Ecore_X_Window root, | ||
333 | int orientation, | ||
334 | int columns, | ||
335 | int rows, | ||
336 | int starting_corner) | ||
337 | { | ||
338 | unsigned int layout[4]; | ||
339 | |||
340 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
341 | |||
342 | layout[0] = orientation; | ||
343 | layout[1] = columns; | ||
344 | layout[2] = rows; | ||
345 | layout[3] = starting_corner; | ||
346 | ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_DESKTOP_LAYOUT, | ||
347 | layout, 4); | ||
348 | } | ||
349 | |||
350 | EAPI void | ||
351 | ecore_x_netwm_desk_workareas_set(Ecore_X_Window root, | ||
352 | unsigned int *areas, | ||
353 | unsigned int n_desks) | ||
354 | { | ||
355 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
356 | |||
357 | ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_WORKAREA, areas, | ||
358 | 4 * n_desks); | ||
359 | } | ||
360 | |||
361 | EAPI unsigned int * | ||
362 | ecore_x_netwm_desk_workareas_get(Ecore_X_Window root, unsigned int *n_desks) | ||
363 | { | ||
364 | int ret; | ||
365 | unsigned int *areas = NULL; | ||
366 | |||
367 | if (!root) root = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
368 | |||
369 | ret = ecore_x_window_prop_card32_list_get(root, ECORE_X_ATOM_NET_WORKAREA, | ||
370 | &areas); | ||
371 | if (!areas) | ||
372 | { | ||
373 | if (n_desks) *n_desks = 0; | ||
374 | return 0; | ||
375 | } | ||
376 | if (n_desks) *n_desks = ret / 4; | ||
377 | return areas; | ||
378 | } | ||
379 | |||
380 | EAPI void | ||
381 | ecore_x_netwm_desk_current_set(Ecore_X_Window root, | ||
382 | unsigned int desk) | ||
383 | { | ||
384 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
385 | |||
386 | ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_CURRENT_DESKTOP, | ||
387 | &desk, 1); | ||
388 | } | ||
389 | |||
390 | EAPI void | ||
391 | ecore_x_netwm_showing_desktop_set(Ecore_X_Window root, | ||
392 | Eina_Bool on) | ||
393 | { | ||
394 | unsigned int val = 0; | ||
395 | |||
396 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
397 | |||
398 | val = ((on) ? 1 : 0); | ||
399 | ecore_x_window_prop_card32_set(root, ECORE_X_ATOM_NET_SHOWING_DESKTOP, | ||
400 | &val, 1); | ||
401 | } | ||
402 | |||
403 | EAPI int | ||
404 | ecore_x_netwm_startup_id_get(Ecore_X_Window win, | ||
405 | char **id) | ||
406 | { | ||
407 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
408 | |||
409 | if (id) | ||
410 | { | ||
411 | *id = | ||
412 | ecore_x_window_prop_string_get(win, ECORE_X_ATOM_NET_STARTUP_ID); | ||
413 | } | ||
414 | |||
415 | return 1; | ||
416 | } | ||
417 | |||
418 | EAPI void | ||
419 | ecore_x_netwm_startup_id_set(Ecore_X_Window win, | ||
420 | const char *id) | ||
421 | { | ||
422 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
423 | |||
424 | ecore_x_window_prop_string_set(win, ECORE_X_ATOM_NET_STARTUP_ID, id); | ||
425 | } | ||
426 | |||
427 | EAPI void | ||
428 | ecore_x_netwm_state_request_send(Ecore_X_Window win, | ||
429 | Ecore_X_Window root, | ||
430 | Ecore_X_Window_State s1, | ||
431 | Ecore_X_Window_State s2, | ||
432 | Eina_Bool set) | ||
433 | { | ||
434 | xcb_client_message_event_t ev; | ||
435 | |||
436 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
437 | CHECK_XCB_CONN; | ||
438 | |||
439 | if (!win) return; | ||
440 | if (!root) root = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
441 | |||
442 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
443 | ev.format = 32; | ||
444 | ev.window = win; | ||
445 | ev.type = ECORE_X_ATOM_NET_WM_STATE; | ||
446 | ev.data.data32[0] = !!set; | ||
447 | ev.data.data32[1] = _ecore_xcb_netwm_window_state_atom_get(s1); | ||
448 | ev.data.data32[2] = _ecore_xcb_netwm_window_state_atom_get(s2); | ||
449 | /* 1 == normal client, if used in a pager this should be 2 */ | ||
450 | ev.data.data32[3] = 1; | ||
451 | ev.data.data32[4] = 0; | ||
452 | |||
453 | xcb_send_event(_ecore_xcb_conn, 0, root, | ||
454 | (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | | ||
455 | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY), (const char *)&ev); | ||
456 | // ecore_x_flush(); | ||
457 | } | ||
458 | |||
459 | EAPI void | ||
460 | ecore_x_netwm_window_state_set(Ecore_X_Window win, | ||
461 | Ecore_X_Window_State *state, | ||
462 | unsigned int num) | ||
463 | { | ||
464 | Ecore_X_Atom *set; | ||
465 | unsigned int i = 0; | ||
466 | |||
467 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
468 | |||
469 | if (!num) | ||
470 | { | ||
471 | ecore_x_window_prop_property_del(win, ECORE_X_ATOM_NET_WM_STATE); | ||
472 | return; | ||
473 | } | ||
474 | |||
475 | set = malloc(num * sizeof(Ecore_X_Atom)); | ||
476 | if (!set) return; | ||
477 | |||
478 | for (i = 0; i < num; i++) | ||
479 | set[i] = _ecore_xcb_netwm_window_state_atom_get(state[i]); | ||
480 | |||
481 | ecore_x_window_prop_atom_set(win, ECORE_X_ATOM_NET_WM_STATE, set, num); | ||
482 | free(set); | ||
483 | } | ||
484 | |||
485 | EAPI Eina_Bool | ||
486 | ecore_x_netwm_window_state_get(Ecore_X_Window win, | ||
487 | Ecore_X_Window_State **state, | ||
488 | unsigned int *num) | ||
489 | { | ||
490 | Ecore_X_Atom *atoms; | ||
491 | int ret = 0; | ||
492 | |||
493 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
494 | |||
495 | if (num) *num = 0; | ||
496 | if (state) *state = NULL; | ||
497 | |||
498 | ret = | ||
499 | ecore_x_window_prop_atom_list_get(win, ECORE_X_ATOM_NET_WM_STATE, &atoms); | ||
500 | |||
501 | if (ret <= 0) return EINA_FALSE; | ||
502 | |||
503 | if (state) | ||
504 | { | ||
505 | *state = malloc(ret * sizeof(Ecore_X_Window_State)); | ||
506 | if (*state) | ||
507 | { | ||
508 | int i = 0; | ||
509 | |||
510 | for (i = 0; i < ret; i++) | ||
511 | (*state)[i] = _ecore_xcb_netwm_window_state_get(atoms[i]); | ||
512 | if (num) *num = ret; | ||
513 | } | ||
514 | } | ||
515 | |||
516 | free(atoms); | ||
517 | |||
518 | return EINA_TRUE; | ||
519 | } | ||
520 | |||
521 | EAPI void | ||
522 | ecore_x_netwm_client_active_set(Ecore_X_Window root, | ||
523 | Ecore_X_Window win) | ||
524 | { | ||
525 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
526 | |||
527 | ecore_x_window_prop_window_set(root, | ||
528 | ECORE_X_ATOM_NET_ACTIVE_WINDOW, &win, 1); | ||
529 | } | ||
530 | |||
531 | EAPI void | ||
532 | ecore_x_netwm_client_active_request(Ecore_X_Window root, | ||
533 | Ecore_X_Window win, | ||
534 | int type, | ||
535 | Ecore_X_Window current_win) | ||
536 | { | ||
537 | xcb_client_message_event_t ev; | ||
538 | |||
539 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
540 | CHECK_XCB_CONN; | ||
541 | |||
542 | if (!root) root = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
543 | |||
544 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
545 | ev.format = 32; | ||
546 | ev.window = win; | ||
547 | ev.type = ECORE_X_ATOM_NET_ACTIVE_WINDOW; | ||
548 | ev.data.data32[0] = type; | ||
549 | ev.data.data32[1] = XCB_CURRENT_TIME; | ||
550 | ev.data.data32[2] = current_win; | ||
551 | ev.data.data32[3] = 0; | ||
552 | ev.data.data32[4] = 0; | ||
553 | |||
554 | xcb_send_event(_ecore_xcb_conn, 0, root, | ||
555 | (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | | ||
556 | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY), (const char *)&ev); | ||
557 | // ecore_x_flush(); | ||
558 | } | ||
559 | |||
560 | EAPI void | ||
561 | ecore_x_netwm_client_list_set(Ecore_X_Window root, | ||
562 | Ecore_X_Window *p_clients, | ||
563 | unsigned int n_clients) | ||
564 | { | ||
565 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
566 | |||
567 | ecore_x_window_prop_window_set(root, ECORE_X_ATOM_NET_CLIENT_LIST, | ||
568 | p_clients, n_clients); | ||
569 | } | ||
570 | |||
571 | EAPI void | ||
572 | ecore_x_netwm_client_list_stacking_set(Ecore_X_Window root, | ||
573 | Ecore_X_Window *p_clients, | ||
574 | unsigned int n_clients) | ||
575 | { | ||
576 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
577 | |||
578 | ecore_x_window_prop_window_set(root, ECORE_X_ATOM_NET_CLIENT_LIST_STACKING, | ||
579 | p_clients, n_clients); | ||
580 | } | ||
581 | |||
582 | EAPI Eina_Bool | ||
583 | ecore_x_screen_is_composited(int screen) | ||
584 | { | ||
585 | char buff[32]; | ||
586 | xcb_get_selection_owner_cookie_t ocookie; | ||
587 | xcb_get_selection_owner_reply_t *oreply; | ||
588 | Ecore_X_Window win; | ||
589 | static Ecore_X_Atom atom = XCB_NONE; | ||
590 | |||
591 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
592 | CHECK_XCB_CONN; | ||
593 | |||
594 | snprintf(buff, sizeof(buff), "_NET_WM_CM_S%i", screen); | ||
595 | |||
596 | if (atom == XCB_NONE) | ||
597 | { | ||
598 | xcb_intern_atom_cookie_t acookie; | ||
599 | xcb_intern_atom_reply_t *areply; | ||
600 | |||
601 | acookie = | ||
602 | xcb_intern_atom_unchecked(_ecore_xcb_conn, 0, strlen(buff), buff); | ||
603 | areply = xcb_intern_atom_reply(_ecore_xcb_conn, acookie, NULL); | ||
604 | if (!areply) return EINA_FALSE; | ||
605 | atom = areply->atom; | ||
606 | free(areply); | ||
607 | } | ||
608 | if (atom == XCB_NONE) return EINA_FALSE; | ||
609 | |||
610 | ocookie = xcb_get_selection_owner_unchecked(_ecore_xcb_conn, atom); | ||
611 | oreply = xcb_get_selection_owner_reply(_ecore_xcb_conn, ocookie, NULL); | ||
612 | if (!oreply) return EINA_FALSE; | ||
613 | win = oreply->owner; | ||
614 | free(oreply); | ||
615 | |||
616 | return (win != XCB_NONE) ? EINA_TRUE : EINA_FALSE; | ||
617 | } | ||
618 | |||
619 | EAPI void | ||
620 | ecore_x_screen_is_composited_set(int screen, | ||
621 | Ecore_X_Window win) | ||
622 | { | ||
623 | static Ecore_X_Atom atom = XCB_NONE; | ||
624 | char buff[32]; | ||
625 | |||
626 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
627 | CHECK_XCB_CONN; | ||
628 | |||
629 | snprintf(buff, sizeof(buff), "_NET_WM_CM_S%i", screen); | ||
630 | if (atom == XCB_NONE) | ||
631 | { | ||
632 | xcb_intern_atom_cookie_t acookie; | ||
633 | xcb_intern_atom_reply_t *areply; | ||
634 | |||
635 | acookie = | ||
636 | xcb_intern_atom_unchecked(_ecore_xcb_conn, 0, strlen(buff), buff); | ||
637 | areply = xcb_intern_atom_reply(_ecore_xcb_conn, acookie, NULL); | ||
638 | if (!areply) return; | ||
639 | atom = areply->atom; | ||
640 | free(areply); | ||
641 | } | ||
642 | if (atom == XCB_NONE) return; | ||
643 | xcb_set_selection_owner(_ecore_xcb_conn, win, atom, | ||
644 | _ecore_xcb_events_last_time_get()); | ||
645 | } | ||
646 | |||
647 | EAPI void | ||
648 | ecore_x_netwm_ping_send(Ecore_X_Window win) | ||
649 | { | ||
650 | xcb_client_message_event_t ev; | ||
651 | |||
652 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
653 | CHECK_XCB_CONN; | ||
654 | |||
655 | if (!win) return; | ||
656 | |||
657 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
658 | ev.format = 32; | ||
659 | ev.window = win; | ||
660 | ev.type = ECORE_X_ATOM_WM_PROTOCOLS; | ||
661 | ev.data.data32[0] = ECORE_X_ATOM_NET_WM_PING; | ||
662 | ev.data.data32[1] = ecore_x_current_time_get(); | ||
663 | ev.data.data32[2] = win; | ||
664 | ev.data.data32[3] = 0; | ||
665 | ev.data.data32[4] = 0; | ||
666 | |||
667 | xcb_send_event(_ecore_xcb_conn, 0, win, | ||
668 | XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); | ||
669 | // ecore_x_flush(); | ||
670 | } | ||
671 | |||
672 | EAPI void | ||
673 | ecore_x_netwm_frame_size_set(Ecore_X_Window win, | ||
674 | int fl, | ||
675 | int fr, | ||
676 | int ft, | ||
677 | int fb) | ||
678 | { | ||
679 | uint32_t frames[4]; | ||
680 | |||
681 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
682 | |||
683 | frames[0] = fl; | ||
684 | frames[1] = fr; | ||
685 | frames[2] = ft; | ||
686 | frames[3] = fb; | ||
687 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_FRAME_EXTENTS, | ||
688 | frames, 4); | ||
689 | } | ||
690 | |||
691 | EAPI Eina_Bool | ||
692 | ecore_x_netwm_frame_size_get(Ecore_X_Window win, | ||
693 | int *fl, | ||
694 | int *fr, | ||
695 | int *ft, | ||
696 | int *fb) | ||
697 | { | ||
698 | int ret = 0; | ||
699 | unsigned int frames[4]; | ||
700 | |||
701 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
702 | |||
703 | ret = ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_FRAME_EXTENTS, | ||
704 | frames, 4); | ||
705 | if (ret != 4) return EINA_FALSE; | ||
706 | |||
707 | if (fl) *fl = frames[0]; | ||
708 | if (fr) *fr = frames[1]; | ||
709 | if (ft) *ft = frames[2]; | ||
710 | if (fb) *fb = frames[3]; | ||
711 | |||
712 | return EINA_TRUE; | ||
713 | } | ||
714 | |||
715 | EAPI void | ||
716 | ecore_x_netwm_sync_request_send(Ecore_X_Window win, | ||
717 | unsigned int serial) | ||
718 | { | ||
719 | xcb_client_message_event_t ev; | ||
720 | |||
721 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
722 | CHECK_XCB_CONN; | ||
723 | |||
724 | if (!win) return; | ||
725 | |||
726 | /* FIXME: Maybe need XSyncIntToValue ?? */ | ||
727 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
728 | |||
729 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
730 | ev.format = 32; | ||
731 | ev.window = win; | ||
732 | ev.type = ECORE_X_ATOM_WM_PROTOCOLS; | ||
733 | ev.data.data32[0] = ECORE_X_ATOM_NET_WM_SYNC_REQUEST; | ||
734 | ev.data.data32[1] = _ecore_xcb_events_last_time_get(); | ||
735 | ev.data.data32[2] = serial; | ||
736 | ev.data.data32[3] = 0; | ||
737 | ev.data.data32[4] = 0; | ||
738 | |||
739 | xcb_send_event(_ecore_xcb_conn, 0, win, | ||
740 | XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); | ||
741 | // ecore_x_flush(); | ||
742 | } | ||
743 | |||
744 | EAPI void | ||
745 | ecore_x_netwm_desktop_set(Ecore_X_Window win, | ||
746 | unsigned int desk) | ||
747 | { | ||
748 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
749 | |||
750 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_DESKTOP, &desk, 1); | ||
751 | } | ||
752 | |||
753 | EAPI Eina_Bool | ||
754 | ecore_x_netwm_desktop_get(Ecore_X_Window win, | ||
755 | unsigned int *desk) | ||
756 | { | ||
757 | unsigned int tmp = 0; | ||
758 | |||
759 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
760 | |||
761 | if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_DESKTOP, | ||
762 | &tmp, 1)) | ||
763 | return EINA_FALSE; | ||
764 | |||
765 | if (desk) *desk = tmp; | ||
766 | |||
767 | return EINA_TRUE; | ||
768 | } | ||
769 | |||
770 | EAPI void | ||
771 | ecore_x_netwm_desktop_request_send(Ecore_X_Window win, | ||
772 | Ecore_X_Window root, | ||
773 | unsigned int desktop) | ||
774 | { | ||
775 | xcb_client_message_event_t ev; | ||
776 | |||
777 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
778 | CHECK_XCB_CONN; | ||
779 | |||
780 | if (!root) root = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
781 | |||
782 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
783 | |||
784 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
785 | ev.format = 32; | ||
786 | ev.window = win; | ||
787 | ev.type = ECORE_X_ATOM_NET_WM_DESKTOP; | ||
788 | ev.data.data32[0] = desktop; | ||
789 | |||
790 | xcb_send_event(_ecore_xcb_conn, 0, root, | ||
791 | (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | | ||
792 | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY), (const char *)&ev); | ||
793 | // ecore_x_flush(); | ||
794 | } | ||
795 | |||
796 | EAPI void | ||
797 | ecore_x_netwm_handled_icons_set(Ecore_X_Window win) | ||
798 | { | ||
799 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
800 | |||
801 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_HANDLED_ICONS, | ||
802 | NULL, 0); | ||
803 | } | ||
804 | |||
805 | EAPI Eina_Bool | ||
806 | ecore_x_netwm_handled_icons_get(Ecore_X_Window win) | ||
807 | { | ||
808 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
809 | |||
810 | if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_HANDLED_ICONS, | ||
811 | NULL, 0)) | ||
812 | return EINA_FALSE; | ||
813 | |||
814 | return EINA_TRUE; | ||
815 | } | ||
816 | |||
817 | EAPI int | ||
818 | ecore_x_netwm_icon_name_get(Ecore_X_Window win, | ||
819 | char **name) | ||
820 | { | ||
821 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
822 | |||
823 | if (name) | ||
824 | { | ||
825 | *name = | ||
826 | ecore_x_window_prop_string_get(win, ECORE_X_ATOM_NET_WM_ICON_NAME); | ||
827 | } | ||
828 | |||
829 | return 1; | ||
830 | } | ||
831 | |||
832 | EAPI void | ||
833 | ecore_x_netwm_icon_name_set(Ecore_X_Window win, | ||
834 | const char *name) | ||
835 | { | ||
836 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
837 | |||
838 | ecore_x_window_prop_string_set(win, ECORE_X_ATOM_NET_WM_ICON_NAME, name); | ||
839 | } | ||
840 | |||
841 | EAPI Eina_Bool | ||
842 | ecore_x_netwm_icons_get(Ecore_X_Window win, | ||
843 | Ecore_X_Icon **icon, | ||
844 | int *num) | ||
845 | { | ||
846 | int num_ret = 0; | ||
847 | unsigned int i = 0, len = 0, icons = 0; | ||
848 | unsigned int *data, *p, *src; | ||
849 | |||
850 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
851 | |||
852 | if (num) *num = 0; | ||
853 | if (icon) *icon = NULL; | ||
854 | |||
855 | num_ret = | ||
856 | ecore_x_window_prop_card32_list_get(win, ECORE_X_ATOM_NET_WM_ICON, &data); | ||
857 | |||
858 | if ((num_ret <= 0) || (!data)) | ||
859 | { | ||
860 | if (data) free(data); | ||
861 | return EINA_FALSE; | ||
862 | } | ||
863 | if (num_ret < 2) | ||
864 | { | ||
865 | if (data) free(data); | ||
866 | return EINA_FALSE; | ||
867 | } | ||
868 | |||
869 | icons = 0; | ||
870 | p = data; | ||
871 | while (p) | ||
872 | { | ||
873 | len = (p[0] * p[1]); | ||
874 | p += (len + 2); | ||
875 | if ((p - data) > num_ret) | ||
876 | { | ||
877 | if (data) free(data); | ||
878 | return EINA_FALSE; | ||
879 | } | ||
880 | icons++; | ||
881 | if ((p - data) == num_ret) p = NULL; | ||
882 | } | ||
883 | if (num) *num = icons; | ||
884 | if (!icon) | ||
885 | { | ||
886 | if (data) free(data); | ||
887 | return EINA_TRUE; | ||
888 | } | ||
889 | |||
890 | *icon = malloc(icons * sizeof(Ecore_X_Icon)); | ||
891 | if (!(*icon)) | ||
892 | { | ||
893 | if (data) free(data); | ||
894 | return EINA_FALSE; | ||
895 | } | ||
896 | |||
897 | /* Fetch the icons */ | ||
898 | p = data; | ||
899 | for (i = 0; i < icons; i++) | ||
900 | { | ||
901 | unsigned int *ps, *pd, *pe; | ||
902 | |||
903 | len = p[0] * p[1]; | ||
904 | ((*icon)[i]).width = p[0]; | ||
905 | ((*icon)[i]).height = p[1]; | ||
906 | src = &(p[2]); | ||
907 | ((*icon)[i]).data = malloc(len * sizeof(unsigned int)); | ||
908 | if (!((*icon)[i]).data) | ||
909 | { | ||
910 | while (i) | ||
911 | free(((*icon)[--i]).data); | ||
912 | free(*icon); | ||
913 | free(data); | ||
914 | return EINA_FALSE; | ||
915 | } | ||
916 | |||
917 | pd = ((*icon)[i]).data; | ||
918 | ps = src; | ||
919 | pe = ps + len; | ||
920 | for (; ps < pe; ps++) | ||
921 | { | ||
922 | unsigned int r, g, b, a; | ||
923 | |||
924 | a = (*ps >> 24) & 0xff; | ||
925 | r = (((*ps >> 16) & 0xff) * a) / 255; | ||
926 | g = (((*ps >> 8) & 0xff) * a) / 255; | ||
927 | b = (((*ps) & 0xff) * a) / 255; | ||
928 | *pd = (a << 24) | (r << 16) | (g << 8) | (b); | ||
929 | pd++; | ||
930 | } | ||
931 | p += (len + 2); | ||
932 | } | ||
933 | |||
934 | if (data) free(data); | ||
935 | return EINA_TRUE; | ||
936 | } | ||
937 | |||
938 | EAPI void | ||
939 | ecore_x_netwm_icon_geometry_set(Ecore_X_Window win, | ||
940 | int x, | ||
941 | int y, | ||
942 | int w, | ||
943 | int h) | ||
944 | { | ||
945 | unsigned int geom[4]; | ||
946 | |||
947 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
948 | |||
949 | geom[0] = x; | ||
950 | geom[1] = y; | ||
951 | geom[2] = w; | ||
952 | geom[3] = h; | ||
953 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_ICON_GEOMETRY, | ||
954 | geom, 4); | ||
955 | } | ||
956 | |||
957 | EAPI Eina_Bool | ||
958 | ecore_x_netwm_icon_geometry_get(Ecore_X_Window win, | ||
959 | int *x, | ||
960 | int *y, | ||
961 | int *w, | ||
962 | int *h) | ||
963 | { | ||
964 | int ret = 0; | ||
965 | unsigned int geom[4]; | ||
966 | |||
967 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
968 | |||
969 | ret = | ||
970 | ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_ICON_GEOMETRY, | ||
971 | geom, 4); | ||
972 | if (ret != 4) return EINA_FALSE; | ||
973 | if (x) *x = geom[0]; | ||
974 | if (y) *y = geom[1]; | ||
975 | if (w) *w = geom[2]; | ||
976 | if (h) *h = geom[3]; | ||
977 | |||
978 | return EINA_TRUE; | ||
979 | } | ||
980 | |||
981 | EAPI void | ||
982 | ecore_x_netwm_strut_set(Ecore_X_Window win, | ||
983 | int l, | ||
984 | int r, | ||
985 | int t, | ||
986 | int b) | ||
987 | { | ||
988 | unsigned int strut[4]; | ||
989 | |||
990 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
991 | |||
992 | strut[0] = l; | ||
993 | strut[1] = r; | ||
994 | strut[2] = t; | ||
995 | strut[3] = b; | ||
996 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_STRUT, strut, 4); | ||
997 | } | ||
998 | |||
999 | EAPI Eina_Bool | ||
1000 | ecore_x_netwm_strut_get(Ecore_X_Window win, | ||
1001 | int *l, | ||
1002 | int *r, | ||
1003 | int *t, | ||
1004 | int *b) | ||
1005 | { | ||
1006 | unsigned int strut[4]; | ||
1007 | int ret = 0; | ||
1008 | |||
1009 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1010 | |||
1011 | ret = | ||
1012 | ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_STRUT, strut, 4); | ||
1013 | if (ret != 4) return EINA_FALSE; | ||
1014 | |||
1015 | if (l) *l = strut[0]; | ||
1016 | if (r) *r = strut[1]; | ||
1017 | if (t) *t = strut[2]; | ||
1018 | if (b) *b = strut[3]; | ||
1019 | |||
1020 | return EINA_TRUE; | ||
1021 | } | ||
1022 | |||
1023 | EAPI void | ||
1024 | ecore_x_netwm_strut_partial_set(Ecore_X_Window win, | ||
1025 | int left, | ||
1026 | int right, | ||
1027 | int top, | ||
1028 | int bottom, | ||
1029 | int left_start_y, | ||
1030 | int left_end_y, | ||
1031 | int right_start_y, | ||
1032 | int right_end_y, | ||
1033 | int top_start_x, | ||
1034 | int top_end_x, | ||
1035 | int bottom_start_x, | ||
1036 | int bottom_end_x) | ||
1037 | { | ||
1038 | unsigned int strut[12]; | ||
1039 | |||
1040 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1041 | |||
1042 | strut[0] = left; | ||
1043 | strut[1] = right; | ||
1044 | strut[2] = top; | ||
1045 | strut[3] = bottom; | ||
1046 | strut[4] = left_start_y; | ||
1047 | strut[5] = left_end_y; | ||
1048 | strut[6] = right_start_y; | ||
1049 | strut[7] = right_end_y; | ||
1050 | strut[8] = top_start_x; | ||
1051 | strut[9] = top_end_x; | ||
1052 | strut[10] = bottom_start_x; | ||
1053 | strut[11] = bottom_end_x; | ||
1054 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_STRUT_PARTIAL, | ||
1055 | strut, 12); | ||
1056 | } | ||
1057 | |||
1058 | EAPI Eina_Bool | ||
1059 | ecore_x_netwm_strut_partial_get(Ecore_X_Window win, | ||
1060 | int *left, | ||
1061 | int *right, | ||
1062 | int *top, | ||
1063 | int *bottom, | ||
1064 | int *left_start_y, | ||
1065 | int *left_end_y, | ||
1066 | int *right_start_y, | ||
1067 | int *right_end_y, | ||
1068 | int *top_start_x, | ||
1069 | int *top_end_x, | ||
1070 | int *bottom_start_x, | ||
1071 | int *bottom_end_x) | ||
1072 | { | ||
1073 | unsigned int strut[12]; | ||
1074 | int ret = 0; | ||
1075 | |||
1076 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1077 | |||
1078 | ret = | ||
1079 | ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_STRUT_PARTIAL, | ||
1080 | strut, 12); | ||
1081 | if (ret != 12) return EINA_FALSE; | ||
1082 | |||
1083 | if (left) *left = strut[0]; | ||
1084 | if (right) *right = strut[1]; | ||
1085 | if (top) *top = strut[2]; | ||
1086 | if (bottom) *bottom = strut[3]; | ||
1087 | if (left_start_y) *left_start_y = strut[4]; | ||
1088 | if (left_end_y) *left_end_y = strut[5]; | ||
1089 | if (right_start_y) *right_start_y = strut[6]; | ||
1090 | if (right_end_y) *right_end_y = strut[7]; | ||
1091 | if (top_start_x) *top_start_x = strut[8]; | ||
1092 | if (top_end_x) *top_end_x = strut[9]; | ||
1093 | if (bottom_start_x) *bottom_start_x = strut[10]; | ||
1094 | if (bottom_end_x) *bottom_end_x = strut[11]; | ||
1095 | |||
1096 | return EINA_TRUE; | ||
1097 | } | ||
1098 | |||
1099 | EAPI void | ||
1100 | ecore_x_netwm_user_time_set(Ecore_X_Window win, | ||
1101 | unsigned int t) | ||
1102 | { | ||
1103 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1104 | |||
1105 | ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_USER_TIME, &t, 1); | ||
1106 | } | ||
1107 | |||
1108 | EAPI Eina_Bool | ||
1109 | ecore_x_netwm_user_time_get(Ecore_X_Window win, | ||
1110 | unsigned int *t) | ||
1111 | { | ||
1112 | unsigned int tmp; | ||
1113 | |||
1114 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1115 | |||
1116 | if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_USER_TIME, | ||
1117 | &tmp, 1)) | ||
1118 | return EINA_FALSE; | ||
1119 | |||
1120 | if (t) *t = tmp; | ||
1121 | |||
1122 | return EINA_TRUE; | ||
1123 | } | ||
1124 | |||
1125 | EAPI void | ||
1126 | ecore_x_netwm_visible_name_set(Ecore_X_Window win, | ||
1127 | const char *name) | ||
1128 | { | ||
1129 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1130 | |||
1131 | ecore_x_window_prop_string_set(win, ECORE_X_ATOM_NET_WM_VISIBLE_NAME, | ||
1132 | name); | ||
1133 | } | ||
1134 | |||
1135 | EAPI int | ||
1136 | ecore_x_netwm_visible_name_get(Ecore_X_Window win, | ||
1137 | char **name) | ||
1138 | { | ||
1139 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1140 | |||
1141 | if (name) | ||
1142 | *name = ecore_x_window_prop_string_get(win, | ||
1143 | ECORE_X_ATOM_NET_WM_VISIBLE_NAME); | ||
1144 | return 1; | ||
1145 | } | ||
1146 | |||
1147 | EAPI void | ||
1148 | ecore_x_netwm_visible_icon_name_set(Ecore_X_Window win, | ||
1149 | const char *name) | ||
1150 | { | ||
1151 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1152 | |||
1153 | ecore_x_window_prop_string_set(win, ECORE_X_ATOM_NET_WM_VISIBLE_ICON_NAME, | ||
1154 | name); | ||
1155 | } | ||
1156 | |||
1157 | EAPI int | ||
1158 | ecore_x_netwm_visible_icon_name_get(Ecore_X_Window win, | ||
1159 | char **name) | ||
1160 | { | ||
1161 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1162 | |||
1163 | if (name) | ||
1164 | { | ||
1165 | *name = | ||
1166 | ecore_x_window_prop_string_get(win, | ||
1167 | ECORE_X_ATOM_NET_WM_VISIBLE_ICON_NAME); | ||
1168 | } | ||
1169 | |||
1170 | return 1; | ||
1171 | } | ||
1172 | |||
1173 | EAPI Eina_Bool | ||
1174 | ecore_x_netwm_sync_counter_get(Ecore_X_Window win, | ||
1175 | Ecore_X_Sync_Counter *counter) | ||
1176 | { | ||
1177 | unsigned int tmp; | ||
1178 | |||
1179 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1180 | |||
1181 | if (!ecore_x_window_prop_card32_get(win, | ||
1182 | ECORE_X_ATOM_NET_WM_SYNC_REQUEST_COUNTER, | ||
1183 | &tmp, 1)) | ||
1184 | return EINA_FALSE; | ||
1185 | |||
1186 | if (counter) *counter = tmp; | ||
1187 | |||
1188 | return EINA_TRUE; | ||
1189 | } | ||
1190 | |||
1191 | EAPI Eina_Bool | ||
1192 | ecore_x_netwm_allowed_action_isset(Ecore_X_Window win, | ||
1193 | Ecore_X_Action action) | ||
1194 | { | ||
1195 | int num = 0, i = 0; | ||
1196 | Ecore_X_Atom *atoms, atom; | ||
1197 | Eina_Bool ret = EINA_FALSE; | ||
1198 | |||
1199 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1200 | |||
1201 | num = | ||
1202 | ecore_x_window_prop_atom_list_get(win, ECORE_X_ATOM_NET_WM_WINDOW_TYPE, | ||
1203 | &atoms); | ||
1204 | if (num <= 0) return EINA_FALSE; | ||
1205 | |||
1206 | atom = _ecore_xcb_netwm_action_atom_get(action); | ||
1207 | for (i = 0; i < num; i++) | ||
1208 | { | ||
1209 | if (atoms[i] == atom) | ||
1210 | { | ||
1211 | ret = EINA_TRUE; | ||
1212 | break; | ||
1213 | } | ||
1214 | } | ||
1215 | |||
1216 | if (atoms) free(atoms); | ||
1217 | return ret; | ||
1218 | } | ||
1219 | |||
1220 | EAPI Eina_Bool | ||
1221 | ecore_x_netwm_allowed_action_get(Ecore_X_Window win, | ||
1222 | Ecore_X_Action **action, | ||
1223 | unsigned int *num) | ||
1224 | { | ||
1225 | Ecore_X_Atom *atoms; | ||
1226 | int num_ret = 0; | ||
1227 | |||
1228 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1229 | |||
1230 | if (num) *num = 0; | ||
1231 | if (action) *action = NULL; | ||
1232 | |||
1233 | num_ret = | ||
1234 | ecore_x_window_prop_atom_list_get(win, ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS, | ||
1235 | &atoms); | ||
1236 | if (num_ret <= 0) return EINA_FALSE; | ||
1237 | if (action) | ||
1238 | { | ||
1239 | *action = malloc(num_ret * sizeof(Ecore_X_Action)); | ||
1240 | if (*action) | ||
1241 | { | ||
1242 | int i = 0; | ||
1243 | |||
1244 | for (i = 0; i < num_ret; i++) | ||
1245 | (*action)[i] = _ecore_xcb_netwm_action_atom_get(atoms[i]); | ||
1246 | } | ||
1247 | if (num) *num = num_ret; | ||
1248 | } | ||
1249 | free(atoms); | ||
1250 | return EINA_TRUE; | ||
1251 | } | ||
1252 | |||
1253 | EAPI void | ||
1254 | ecore_x_netwm_allowed_action_set(Ecore_X_Window win, | ||
1255 | Ecore_X_Action *action, | ||
1256 | unsigned int num) | ||
1257 | { | ||
1258 | Ecore_X_Atom *set; | ||
1259 | unsigned int i = 0; | ||
1260 | |||
1261 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1262 | |||
1263 | if (!num) | ||
1264 | { | ||
1265 | ecore_x_window_prop_property_del(win, | ||
1266 | ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS); | ||
1267 | return; | ||
1268 | } | ||
1269 | |||
1270 | set = malloc(num * sizeof(Ecore_X_Atom)); | ||
1271 | if (!set) return; | ||
1272 | |||
1273 | for (i = 0; i < num; i++) | ||
1274 | set[i] = _ecore_xcb_netwm_action_atom_get(action[i]); | ||
1275 | |||
1276 | ecore_x_window_prop_atom_set(win, ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS, | ||
1277 | set, num); | ||
1278 | free(set); | ||
1279 | } | ||
1280 | |||
1281 | /* local functions */ | ||
1282 | int | ||
1283 | _ecore_xcb_netwm_startup_info_begin(Ecore_X_Window win __UNUSED__, | ||
1284 | uint8_t data __UNUSED__) | ||
1285 | { | ||
1286 | // TODO: TBD | ||
1287 | return 1; | ||
1288 | } | ||
1289 | |||
1290 | int | ||
1291 | _ecore_xcb_netwm_startup_info(Ecore_X_Window win __UNUSED__, | ||
1292 | uint8_t data __UNUSED__) | ||
1293 | { | ||
1294 | // TODO: TBD | ||
1295 | return 1; | ||
1296 | } | ||
1297 | |||
1298 | /* static void */ | ||
1299 | /* _ecore_xcb_netwm_startup_info_free(void *data) */ | ||
1300 | /* { */ | ||
1301 | /* Ecore_Xcb_Startup_Info *info; */ | ||
1302 | |||
1303 | /* LOGFN(__FILE__, __LINE__, __FUNCTION__); */ | ||
1304 | |||
1305 | /* if (!(info = data)) return; */ | ||
1306 | /* if (info->buffer) free(info->buffer); */ | ||
1307 | /* if (info->id) free(info->id); */ | ||
1308 | /* if (info->name) free(info->name); */ | ||
1309 | /* if (info->bin) free(info->bin); */ | ||
1310 | /* if (info->icon) free(info->icon); */ | ||
1311 | /* if (info->description) free(info->description); */ | ||
1312 | /* if (info->wmclass) free(info->wmclass); */ | ||
1313 | /* free(info); */ | ||
1314 | /* } */ | ||
1315 | |||
1316 | static Ecore_X_Atom | ||
1317 | _ecore_xcb_netwm_window_type_atom_get(Ecore_X_Window_Type type) | ||
1318 | { | ||
1319 | switch (type) | ||
1320 | { | ||
1321 | case ECORE_X_WINDOW_TYPE_DESKTOP: | ||
1322 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DESKTOP; | ||
1323 | |||
1324 | case ECORE_X_WINDOW_TYPE_DOCK: | ||
1325 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DOCK; | ||
1326 | |||
1327 | case ECORE_X_WINDOW_TYPE_TOOLBAR: | ||
1328 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLBAR; | ||
1329 | |||
1330 | case ECORE_X_WINDOW_TYPE_MENU: | ||
1331 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_MENU; | ||
1332 | |||
1333 | case ECORE_X_WINDOW_TYPE_UTILITY: | ||
1334 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_UTILITY; | ||
1335 | |||
1336 | case ECORE_X_WINDOW_TYPE_SPLASH: | ||
1337 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_SPLASH; | ||
1338 | |||
1339 | case ECORE_X_WINDOW_TYPE_DIALOG: | ||
1340 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DIALOG; | ||
1341 | |||
1342 | case ECORE_X_WINDOW_TYPE_NORMAL: | ||
1343 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NORMAL; | ||
1344 | |||
1345 | case ECORE_X_WINDOW_TYPE_DROPDOWN_MENU: | ||
1346 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DROPDOWN_MENU; | ||
1347 | |||
1348 | case ECORE_X_WINDOW_TYPE_POPUP_MENU: | ||
1349 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_POPUP_MENU; | ||
1350 | |||
1351 | case ECORE_X_WINDOW_TYPE_TOOLTIP: | ||
1352 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLTIP; | ||
1353 | |||
1354 | case ECORE_X_WINDOW_TYPE_NOTIFICATION: | ||
1355 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NOTIFICATION; | ||
1356 | |||
1357 | case ECORE_X_WINDOW_TYPE_COMBO: | ||
1358 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_COMBO; | ||
1359 | |||
1360 | case ECORE_X_WINDOW_TYPE_DND: | ||
1361 | return ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DND; | ||
1362 | |||
1363 | default: | ||
1364 | return 0; | ||
1365 | } | ||
1366 | } | ||
1367 | |||
1368 | static Ecore_X_Window_Type | ||
1369 | _ecore_xcb_netwm_window_type_type_get(Ecore_X_Atom atom) | ||
1370 | { | ||
1371 | if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DESKTOP) | ||
1372 | return ECORE_X_WINDOW_TYPE_DESKTOP; | ||
1373 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DOCK) | ||
1374 | return ECORE_X_WINDOW_TYPE_DOCK; | ||
1375 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLBAR) | ||
1376 | return ECORE_X_WINDOW_TYPE_TOOLBAR; | ||
1377 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_MENU) | ||
1378 | return ECORE_X_WINDOW_TYPE_MENU; | ||
1379 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_UTILITY) | ||
1380 | return ECORE_X_WINDOW_TYPE_UTILITY; | ||
1381 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_SPLASH) | ||
1382 | return ECORE_X_WINDOW_TYPE_SPLASH; | ||
1383 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DIALOG) | ||
1384 | return ECORE_X_WINDOW_TYPE_DIALOG; | ||
1385 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NORMAL) | ||
1386 | return ECORE_X_WINDOW_TYPE_NORMAL; | ||
1387 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DROPDOWN_MENU) | ||
1388 | return ECORE_X_WINDOW_TYPE_DROPDOWN_MENU; | ||
1389 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_POPUP_MENU) | ||
1390 | return ECORE_X_WINDOW_TYPE_POPUP_MENU; | ||
1391 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_TOOLTIP) | ||
1392 | return ECORE_X_WINDOW_TYPE_TOOLTIP; | ||
1393 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_NOTIFICATION) | ||
1394 | return ECORE_X_WINDOW_TYPE_NOTIFICATION; | ||
1395 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_COMBO) | ||
1396 | return ECORE_X_WINDOW_TYPE_COMBO; | ||
1397 | else if (atom == ECORE_X_ATOM_NET_WM_WINDOW_TYPE_DND) | ||
1398 | return ECORE_X_WINDOW_TYPE_DND; | ||
1399 | else | ||
1400 | return ECORE_X_WINDOW_TYPE_UNKNOWN; | ||
1401 | } | ||
1402 | |||
1403 | static Ecore_X_Atom | ||
1404 | _ecore_xcb_netwm_window_state_atom_get(Ecore_X_Window_State state) | ||
1405 | { | ||
1406 | switch (state) | ||
1407 | { | ||
1408 | case ECORE_X_WINDOW_STATE_MODAL: | ||
1409 | return ECORE_X_ATOM_NET_WM_STATE_MODAL; | ||
1410 | |||
1411 | case ECORE_X_WINDOW_STATE_STICKY: | ||
1412 | return ECORE_X_ATOM_NET_WM_STATE_STICKY; | ||
1413 | |||
1414 | case ECORE_X_WINDOW_STATE_MAXIMIZED_VERT: | ||
1415 | return ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_VERT; | ||
1416 | |||
1417 | case ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ: | ||
1418 | return ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_HORZ; | ||
1419 | |||
1420 | case ECORE_X_WINDOW_STATE_SHADED: | ||
1421 | return ECORE_X_ATOM_NET_WM_STATE_SHADED; | ||
1422 | |||
1423 | case ECORE_X_WINDOW_STATE_SKIP_TASKBAR: | ||
1424 | return ECORE_X_ATOM_NET_WM_STATE_SKIP_TASKBAR; | ||
1425 | |||
1426 | case ECORE_X_WINDOW_STATE_SKIP_PAGER: | ||
1427 | return ECORE_X_ATOM_NET_WM_STATE_SKIP_PAGER; | ||
1428 | |||
1429 | case ECORE_X_WINDOW_STATE_HIDDEN: | ||
1430 | return ECORE_X_ATOM_NET_WM_STATE_HIDDEN; | ||
1431 | |||
1432 | case ECORE_X_WINDOW_STATE_FULLSCREEN: | ||
1433 | return ECORE_X_ATOM_NET_WM_STATE_FULLSCREEN; | ||
1434 | |||
1435 | case ECORE_X_WINDOW_STATE_ABOVE: | ||
1436 | return ECORE_X_ATOM_NET_WM_STATE_ABOVE; | ||
1437 | |||
1438 | case ECORE_X_WINDOW_STATE_BELOW: | ||
1439 | return ECORE_X_ATOM_NET_WM_STATE_BELOW; | ||
1440 | |||
1441 | case ECORE_X_WINDOW_STATE_DEMANDS_ATTENTION: | ||
1442 | return ECORE_X_ATOM_NET_WM_STATE_DEMANDS_ATTENTION; | ||
1443 | |||
1444 | default: | ||
1445 | return 0; | ||
1446 | } | ||
1447 | } | ||
1448 | |||
1449 | Ecore_X_Window_State | ||
1450 | _ecore_xcb_netwm_window_state_get(Ecore_X_Atom atom) | ||
1451 | { | ||
1452 | if (atom == ECORE_X_ATOM_NET_WM_STATE_MODAL) | ||
1453 | return ECORE_X_WINDOW_STATE_MODAL; | ||
1454 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_STICKY) | ||
1455 | return ECORE_X_WINDOW_STATE_STICKY; | ||
1456 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_VERT) | ||
1457 | return ECORE_X_WINDOW_STATE_MAXIMIZED_VERT; | ||
1458 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_MAXIMIZED_HORZ) | ||
1459 | return ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ; | ||
1460 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_SHADED) | ||
1461 | return ECORE_X_WINDOW_STATE_SHADED; | ||
1462 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_SKIP_TASKBAR) | ||
1463 | return ECORE_X_WINDOW_STATE_SKIP_TASKBAR; | ||
1464 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_SKIP_PAGER) | ||
1465 | return ECORE_X_WINDOW_STATE_SKIP_PAGER; | ||
1466 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_HIDDEN) | ||
1467 | return ECORE_X_WINDOW_STATE_HIDDEN; | ||
1468 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_FULLSCREEN) | ||
1469 | return ECORE_X_WINDOW_STATE_FULLSCREEN; | ||
1470 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_ABOVE) | ||
1471 | return ECORE_X_WINDOW_STATE_ABOVE; | ||
1472 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_BELOW) | ||
1473 | return ECORE_X_WINDOW_STATE_BELOW; | ||
1474 | else if (atom == ECORE_X_ATOM_NET_WM_STATE_DEMANDS_ATTENTION) | ||
1475 | return ECORE_X_WINDOW_STATE_DEMANDS_ATTENTION; | ||
1476 | else | ||
1477 | return ECORE_X_WINDOW_STATE_UNKNOWN; | ||
1478 | } | ||
1479 | |||
1480 | static Ecore_X_Atom | ||
1481 | _ecore_xcb_netwm_action_atom_get(Ecore_X_Action action) | ||
1482 | { | ||
1483 | switch (action) | ||
1484 | { | ||
1485 | case ECORE_X_ACTION_MOVE: | ||
1486 | return ECORE_X_ATOM_NET_WM_ACTION_MOVE; | ||
1487 | |||
1488 | case ECORE_X_ACTION_RESIZE: | ||
1489 | return ECORE_X_ATOM_NET_WM_ACTION_RESIZE; | ||
1490 | |||
1491 | case ECORE_X_ACTION_MINIMIZE: | ||
1492 | return ECORE_X_ATOM_NET_WM_ACTION_MINIMIZE; | ||
1493 | |||
1494 | case ECORE_X_ACTION_SHADE: | ||
1495 | return ECORE_X_ATOM_NET_WM_ACTION_SHADE; | ||
1496 | |||
1497 | case ECORE_X_ACTION_STICK: | ||
1498 | return ECORE_X_ATOM_NET_WM_ACTION_STICK; | ||
1499 | |||
1500 | case ECORE_X_ACTION_MAXIMIZE_HORZ: | ||
1501 | return ECORE_X_ATOM_NET_WM_ACTION_MAXIMIZE_HORZ; | ||
1502 | |||
1503 | case ECORE_X_ACTION_MAXIMIZE_VERT: | ||
1504 | return ECORE_X_ATOM_NET_WM_ACTION_MAXIMIZE_VERT; | ||
1505 | |||
1506 | case ECORE_X_ACTION_FULLSCREEN: | ||
1507 | return ECORE_X_ATOM_NET_WM_ACTION_FULLSCREEN; | ||
1508 | |||
1509 | case ECORE_X_ACTION_CHANGE_DESKTOP: | ||
1510 | return ECORE_X_ATOM_NET_WM_ACTION_CHANGE_DESKTOP; | ||
1511 | |||
1512 | case ECORE_X_ACTION_CLOSE: | ||
1513 | return ECORE_X_ATOM_NET_WM_ACTION_CLOSE; | ||
1514 | |||
1515 | case ECORE_X_ACTION_ABOVE: | ||
1516 | return ECORE_X_ATOM_NET_WM_ACTION_ABOVE; | ||
1517 | |||
1518 | case ECORE_X_ACTION_BELOW: | ||
1519 | return ECORE_X_ATOM_NET_WM_ACTION_BELOW; | ||
1520 | |||
1521 | default: | ||
1522 | return 0; | ||
1523 | } | ||
1524 | } | ||
1525 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_pixmap.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_pixmap.c new file mode 100644 index 0000000..f9bf525 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_pixmap.c | |||
@@ -0,0 +1,128 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | |||
3 | /** | ||
4 | * @defgroup Ecore_X_Pixmap_Group X Pixmap Functions | ||
5 | * | ||
6 | * Functions that operate on pixmaps. | ||
7 | */ | ||
8 | |||
9 | /** | ||
10 | * Creates a new pixmap. | ||
11 | * @param win Window used to determine which screen of the display the | ||
12 | * pixmap should be created on. If 0, the default root window | ||
13 | * is used. | ||
14 | * @param w Width of the new pixmap. | ||
15 | * @param h Height of the new pixmap. | ||
16 | * @param dep Depth of the pixmap. If 0, the default depth of the default | ||
17 | * screen is used. | ||
18 | * @return New pixmap. | ||
19 | * @ingroup Ecore_X_Pixmap_Group | ||
20 | */ | ||
21 | EAPI Ecore_X_Pixmap | ||
22 | ecore_x_pixmap_new(Ecore_X_Window win, | ||
23 | int w, | ||
24 | int h, | ||
25 | int dep) | ||
26 | { | ||
27 | Ecore_X_Pixmap pmap; | ||
28 | |||
29 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
30 | CHECK_XCB_CONN; | ||
31 | |||
32 | if (win == 0) win = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
33 | if (dep == 0) dep = ((xcb_screen_t *)_ecore_xcb_screen)->root_depth; | ||
34 | |||
35 | pmap = xcb_generate_id(_ecore_xcb_conn); | ||
36 | xcb_create_pixmap(_ecore_xcb_conn, dep, pmap, win, w, h); | ||
37 | |||
38 | // ecore_x_flush(); | ||
39 | return pmap; | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * Deletes the reference to the given pixmap. | ||
44 | * | ||
45 | * If no other clients have a reference to the given pixmap, the server | ||
46 | * will destroy it. | ||
47 | * | ||
48 | * @param pmap The given pixmap. | ||
49 | * @ingroup Ecore_X_Pixmap_Group | ||
50 | */ | ||
51 | EAPI void | ||
52 | ecore_x_pixmap_free(Ecore_X_Pixmap pmap) | ||
53 | { | ||
54 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
55 | CHECK_XCB_CONN; | ||
56 | |||
57 | xcb_free_pixmap(_ecore_xcb_conn, pmap); | ||
58 | // ecore_x_flush(); | ||
59 | } | ||
60 | |||
61 | /** | ||
62 | * Pastes a rectangular area of the given pixmap onto the given drawable. | ||
63 | * @param pmap The given pixmap. | ||
64 | * @param dest The given drawable. | ||
65 | * @param gc The graphics context which governs which operation will | ||
66 | * be used to paste the area onto the drawable. | ||
67 | * @param sx The X position of the area on the pixmap. | ||
68 | * @param sy The Y position of the area on the pixmap. | ||
69 | * @param w The width of the area. | ||
70 | * @param h The height of the area. | ||
71 | * @param dx The X position at which to paste the area on @p dest. | ||
72 | * @param dy The Y position at which to paste the area on @p dest. | ||
73 | * @ingroup Ecore_X_Pixmap_Group | ||
74 | */ | ||
75 | EAPI void | ||
76 | ecore_x_pixmap_paste(Ecore_X_Pixmap pmap, | ||
77 | Ecore_X_Drawable dest, | ||
78 | Ecore_X_GC gc, | ||
79 | int sx, | ||
80 | int sy, | ||
81 | int w, | ||
82 | int h, | ||
83 | int dx, | ||
84 | int dy) | ||
85 | { | ||
86 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
87 | CHECK_XCB_CONN; | ||
88 | |||
89 | xcb_copy_area(_ecore_xcb_conn, pmap, dest, gc, sx, sy, dx, dy, w, h); | ||
90 | // ecore_x_flush(); | ||
91 | } | ||
92 | |||
93 | /** | ||
94 | * Retrieves the size of the given pixmap. | ||
95 | * @param pmap The given pixmap. | ||
96 | * @param x Pointer to an integer in which to store the X position. | ||
97 | * @param y Pointer to an integer in which to store the Y position. | ||
98 | * @param w Pointer to an integer in which to store the width. | ||
99 | * @param h Pointer to an integer in which to store the height. | ||
100 | * @ingroup Ecore_X_Pixmap_Group | ||
101 | */ | ||
102 | EAPI void | ||
103 | ecore_x_pixmap_geometry_get(Ecore_X_Pixmap pmap, | ||
104 | int *x, | ||
105 | int *y, | ||
106 | int *w, | ||
107 | int *h) | ||
108 | { | ||
109 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
110 | |||
111 | if (pmap) | ||
112 | ecore_x_drawable_geometry_get(pmap, x, y, w, h); | ||
113 | } | ||
114 | |||
115 | /** | ||
116 | * Retrieves the depth of the given pixmap. | ||
117 | * @param pmap The given pixmap. | ||
118 | * @return The depth of the pixmap. | ||
119 | * @ingroup Ecore_X_Pixmap_Group | ||
120 | */ | ||
121 | EAPI int | ||
122 | ecore_x_pixmap_depth_get(Ecore_X_Pixmap pmap) | ||
123 | { | ||
124 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
125 | |||
126 | return ecore_x_drawable_depth_get(pmap); | ||
127 | } | ||
128 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_private.h b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_private.h new file mode 100644 index 0000000..cf8f3e5 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_private.h | |||
@@ -0,0 +1,451 @@ | |||
1 | #ifndef __ECORE_XCB_PRIVATE_H__ | ||
2 | # define __ECORE_XCB_PRIVATE_H__ | ||
3 | |||
4 | //# define LOGFNS 1 | ||
5 | |||
6 | # ifdef HAVE_CONFIG_H | ||
7 | # include "config.h" | ||
8 | # endif | ||
9 | |||
10 | # include <unistd.h> // included for close & gethostname functions | ||
11 | |||
12 | /* generic xcb includes */ | ||
13 | # include <xcb/xcb.h> | ||
14 | # include <xcb/bigreq.h> | ||
15 | # include <xcb/shm.h> | ||
16 | # include <xcb/xcb_image.h> | ||
17 | |||
18 | /* EFL includes */ | ||
19 | # include "Ecore.h" | ||
20 | # include "Ecore_Input.h" | ||
21 | # include "Ecore_X.h" | ||
22 | |||
23 | /* logging */ | ||
24 | extern int _ecore_xcb_log_dom; | ||
25 | |||
26 | # ifdef ECORE_XCB_DEFAULT_LOG_COLOR | ||
27 | # undef ECORE_XCB_DEFAULT_LOG_COLOR | ||
28 | # endif | ||
29 | # define ECORE_XCB_DEFAULT_LOG_COLOR EINA_COLOR_BLUE | ||
30 | |||
31 | # ifdef ERR | ||
32 | # undef ERR | ||
33 | # endif | ||
34 | # define ERR(...) EINA_LOG_DOM_ERR(_ecore_xcb_log_dom, __VA_ARGS__) | ||
35 | |||
36 | # ifdef DBG | ||
37 | # undef DBG | ||
38 | # endif | ||
39 | # define DBG(...) EINA_LOG_DOM_DBG(_ecore_xcb_log_dom, __VA_ARGS__) | ||
40 | |||
41 | # ifdef INF | ||
42 | # undef INF | ||
43 | # endif | ||
44 | # define INF(...) EINA_LOG_DOM_INFO(_ecore_xcb_log_dom, __VA_ARGS__) | ||
45 | |||
46 | # ifdef WRN | ||
47 | # undef WRN | ||
48 | # endif | ||
49 | # define WRN(...) EINA_LOG_DOM_WARN(_ecore_xcb_log_dom, __VA_ARGS__) | ||
50 | |||
51 | # ifdef CRIT | ||
52 | # undef CRIT | ||
53 | # endif | ||
54 | # define CRIT(...) EINA_LOG_DOM_CRIT(_ecore_xcb_log_dom, __VA_ARGS__) | ||
55 | |||
56 | # ifdef LOGFNS | ||
57 | # include <stdio.h> | ||
58 | # define LOGFN(fl, ln, fn) printf("-ECORE-XCB: %25s: %5i - %s\n", fl, ln, fn); | ||
59 | # else | ||
60 | # define LOGFN(fl, ln, fn) | ||
61 | # endif | ||
62 | |||
63 | # ifndef MAXHOSTNAMELEN | ||
64 | # define MAXHOSTNAMELEN 256 | ||
65 | # endif | ||
66 | |||
67 | # ifndef MIN | ||
68 | # define MIN(x, y) (((x) > (y)) ? (y) : (x)) | ||
69 | # endif | ||
70 | |||
71 | # ifndef MAX | ||
72 | # define MAX(a, b) ((a < b) ? b : a) | ||
73 | # endif | ||
74 | |||
75 | #define CHECK_XCB_CONN \ | ||
76 | { \ | ||
77 | if (xcb_connection_has_error(_ecore_xcb_conn)) \ | ||
78 | { \ | ||
79 | DBG("XCB Connection Has Error !!"); \ | ||
80 | _ecore_xcb_io_error_handle(NULL); \ | ||
81 | } \ | ||
82 | } | ||
83 | |||
84 | /* enums */ | ||
85 | typedef enum _Ecore_Xcb_Encoding_Style Ecore_Xcb_Encoding_Style; | ||
86 | |||
87 | enum _Ecore_Xcb_Encoding_Style | ||
88 | { | ||
89 | XcbStringStyle, | ||
90 | XcbCompoundTextStyle, | ||
91 | XcbTextStyle, | ||
92 | XcbStdICCTextStyle, | ||
93 | XcbUTF8StringStyle | ||
94 | }; | ||
95 | |||
96 | /* structures */ | ||
97 | typedef struct _Ecore_X_DND_Source Ecore_X_DND_Source; | ||
98 | typedef struct _Ecore_X_DND_Target Ecore_X_DND_Target; | ||
99 | typedef struct _Ecore_X_Selection_Intern Ecore_X_Selection_Intern; | ||
100 | typedef struct _Ecore_X_Selection_Converter Ecore_X_Selection_Converter; | ||
101 | typedef struct _Ecore_X_Selection_Parser Ecore_X_Selection_Parser; | ||
102 | typedef struct _Ecore_Xcb_Textproperty Ecore_Xcb_Textproperty; | ||
103 | |||
104 | struct _Ecore_X_DND_Source | ||
105 | { | ||
106 | int version; | ||
107 | Ecore_X_Window win, dest; | ||
108 | |||
109 | enum | ||
110 | { | ||
111 | ECORE_X_DND_SOURCE_IDLE, | ||
112 | ECORE_X_DND_SOURCE_DRAGGING, | ||
113 | ECORE_X_DND_SOURCE_DROPPED, | ||
114 | ECORE_X_DND_SOURCE_CONVERTING | ||
115 | } state; | ||
116 | |||
117 | struct | ||
118 | { | ||
119 | short x, y; | ||
120 | unsigned short width, height; | ||
121 | } rectangle; | ||
122 | |||
123 | struct | ||
124 | { | ||
125 | Ecore_X_Window window; | ||
126 | int x, y; | ||
127 | } prev; | ||
128 | |||
129 | Ecore_X_Time time; | ||
130 | |||
131 | Ecore_X_Atom action, accepted_action; | ||
132 | |||
133 | int will_accept, suppress; | ||
134 | int await_status; | ||
135 | }; | ||
136 | |||
137 | struct _Ecore_X_DND_Target | ||
138 | { | ||
139 | int version; | ||
140 | Ecore_X_Window win, source; | ||
141 | |||
142 | enum | ||
143 | { | ||
144 | ECORE_X_DND_TARGET_IDLE, | ||
145 | ECORE_X_DND_TARGET_ENTERED | ||
146 | } state; | ||
147 | |||
148 | struct | ||
149 | { | ||
150 | int x, y; | ||
151 | } pos; | ||
152 | |||
153 | Ecore_X_Time time; | ||
154 | |||
155 | Ecore_X_Atom action, accepted_action; | ||
156 | int will_accept; | ||
157 | }; | ||
158 | |||
159 | struct _Ecore_X_Selection_Intern | ||
160 | { | ||
161 | Ecore_X_Window win; | ||
162 | Ecore_X_Atom selection; | ||
163 | unsigned char *data; | ||
164 | int length; | ||
165 | Ecore_X_Time time; | ||
166 | }; | ||
167 | |||
168 | struct _Ecore_X_Selection_Converter | ||
169 | { | ||
170 | Ecore_X_Atom target; | ||
171 | Eina_Bool (*convert)(char *target, | ||
172 | void *data, | ||
173 | int size, | ||
174 | void **data_ret, | ||
175 | int *size_ret, | ||
176 | Ecore_X_Atom *type, | ||
177 | int *size_type); | ||
178 | Ecore_X_Selection_Converter *next; | ||
179 | }; | ||
180 | |||
181 | struct _Ecore_X_Selection_Parser | ||
182 | { | ||
183 | char *target; | ||
184 | void *(*parse)(const char *target, void *data, int size, int format); | ||
185 | Ecore_X_Selection_Parser *next; | ||
186 | }; | ||
187 | |||
188 | struct _Ecore_Xcb_Textproperty | ||
189 | { | ||
190 | char *value; | ||
191 | Ecore_X_Atom encoding; | ||
192 | unsigned int format, nitems; | ||
193 | }; | ||
194 | |||
195 | /* external variables */ | ||
196 | extern Ecore_X_Connection *_ecore_xcb_conn; | ||
197 | extern Ecore_X_Screen *_ecore_xcb_screen; | ||
198 | extern double _ecore_xcb_double_click_time; | ||
199 | extern int16_t _ecore_xcb_event_last_root_x; | ||
200 | extern int16_t _ecore_xcb_event_last_root_y; | ||
201 | |||
202 | /* external variables for extension events */ | ||
203 | extern int _ecore_xcb_event_damage; | ||
204 | extern int _ecore_xcb_event_randr; | ||
205 | extern int _ecore_xcb_event_screensaver; | ||
206 | extern int _ecore_xcb_event_shape; | ||
207 | extern int _ecore_xcb_event_sync; | ||
208 | extern int _ecore_xcb_event_xfixes; | ||
209 | extern int _ecore_xcb_event_input; | ||
210 | extern int _ecore_xcb_event_gesture; | ||
211 | |||
212 | extern int ECORE_X_MODIFIER_SHIFT; | ||
213 | extern int ECORE_X_MODIFIER_CTRL; | ||
214 | extern int ECORE_X_MODIFIER_ALT; | ||
215 | extern int ECORE_X_MODIFIER_WIN; | ||
216 | extern int ECORE_X_LOCK_SCROLL; | ||
217 | extern int ECORE_X_LOCK_NUM; | ||
218 | extern int ECORE_X_LOCK_CAPS; | ||
219 | extern int ECORE_X_LOCK_SHIFT; | ||
220 | |||
221 | extern Ecore_X_Atom _ecore_xcb_atoms_wm_protocol[ECORE_X_WM_PROTOCOL_NUM]; | ||
222 | |||
223 | extern int _ecore_xcb_button_grabs_num; | ||
224 | extern int _ecore_xcb_key_grabs_num; | ||
225 | extern Ecore_X_Window *_ecore_xcb_button_grabs; | ||
226 | extern Ecore_X_Window *_ecore_xcb_key_grabs; | ||
227 | extern Eina_Bool (*_ecore_xcb_window_grab_replay_func)(void *data, | ||
228 | int type, | ||
229 | void *event); | ||
230 | extern void *_ecore_xcb_window_grab_replay_data; | ||
231 | |||
232 | /* private function prototypes */ | ||
233 | void _ecore_xcb_error_handler_init(void); | ||
234 | void _ecore_xcb_error_handler_shutdown(void); | ||
235 | |||
236 | void _ecore_xcb_atoms_init(void); | ||
237 | void _ecore_xcb_atoms_finalize(void); | ||
238 | |||
239 | void _ecore_xcb_extensions_init(void); | ||
240 | void _ecore_xcb_extensions_finalize(void); | ||
241 | |||
242 | void _ecore_xcb_shape_init(void); | ||
243 | void _ecore_xcb_shape_finalize(void); | ||
244 | |||
245 | void _ecore_xcb_screensaver_init(void); | ||
246 | void _ecore_xcb_screensaver_finalize(void); | ||
247 | |||
248 | void _ecore_xcb_sync_init(void); | ||
249 | void _ecore_xcb_sync_finalize(void); | ||
250 | void _ecore_xcb_sync_magic_send(int val, | ||
251 | Ecore_X_Window win); | ||
252 | |||
253 | void _ecore_xcb_render_init(void); | ||
254 | void _ecore_xcb_render_finalize(void); | ||
255 | Eina_Bool _ecore_xcb_render_argb_get(void); | ||
256 | Eina_Bool _ecore_xcb_render_anim_get(void); | ||
257 | Eina_Bool _ecore_xcb_render_avail_get(void); | ||
258 | |||
259 | Eina_Bool _ecore_xcb_render_visual_supports_alpha(Ecore_X_Visual visual); | ||
260 | uint32_t _ecore_xcb_render_find_visual_id(int type, | ||
261 | Eina_Bool check_alpha); | ||
262 | Ecore_X_Visual *_ecore_xcb_render_visual_get(int visual_id); | ||
263 | |||
264 | void _ecore_xcb_randr_init(void); | ||
265 | void _ecore_xcb_randr_finalize(void); | ||
266 | |||
267 | void _ecore_xcb_gesture_init(void); | ||
268 | void _ecore_xcb_gesture_finalize(void); | ||
269 | void _ecore_xcb_gesture_shutdown(void); | ||
270 | |||
271 | void _ecore_xcb_xfixes_init(void); | ||
272 | void _ecore_xcb_xfixes_finalize(void); | ||
273 | Eina_Bool _ecore_xcb_xfixes_avail_get(void); | ||
274 | |||
275 | void _ecore_xcb_damage_init(void); | ||
276 | void _ecore_xcb_damage_finalize(void); | ||
277 | |||
278 | void _ecore_xcb_composite_init(void); | ||
279 | void _ecore_xcb_composite_finalize(void); | ||
280 | |||
281 | void _ecore_xcb_dpms_init(void); | ||
282 | void _ecore_xcb_dpms_finalize(void); | ||
283 | |||
284 | void _ecore_xcb_cursor_init(void); | ||
285 | void _ecore_xcb_cursor_finalize(void); | ||
286 | |||
287 | void _ecore_xcb_xinerama_init(void); | ||
288 | void _ecore_xcb_xinerama_finalize(void); | ||
289 | |||
290 | void _ecore_xcb_dnd_init(void); | ||
291 | void _ecore_xcb_dnd_shutdown(void); | ||
292 | Ecore_X_DND_Source *_ecore_xcb_dnd_source_get(void); | ||
293 | Ecore_X_DND_Target *_ecore_xcb_dnd_target_get(void); | ||
294 | void _ecore_xcb_dnd_drag(Ecore_X_Window root, | ||
295 | int x, | ||
296 | int y); | ||
297 | |||
298 | void _ecore_xcb_selection_init(void); | ||
299 | void _ecore_xcb_selection_shutdown(void); | ||
300 | void *_ecore_xcb_selection_parse(const char *target, | ||
301 | void *data, | ||
302 | int size, | ||
303 | int format); | ||
304 | char *_ecore_xcb_selection_target_get(Ecore_X_Atom target); | ||
305 | Ecore_X_Selection_Intern *_ecore_xcb_selection_get(Ecore_X_Atom selection); | ||
306 | |||
307 | # ifdef HAVE_ICONV | ||
308 | Eina_Bool _ecore_xcb_utf8_textlist_to_textproperty(char **list, | ||
309 | int count, | ||
310 | Ecore_Xcb_Encoding_Style style, | ||
311 | Ecore_Xcb_Textproperty *ret); | ||
312 | # endif | ||
313 | Eina_Bool _ecore_xcb_mb_textlist_to_textproperty(char **list, | ||
314 | int count, | ||
315 | Ecore_Xcb_Encoding_Style style, | ||
316 | Ecore_Xcb_Textproperty *ret); | ||
317 | Eina_Bool _ecore_xcb_textlist_to_textproperty(const char *type, | ||
318 | char **list, | ||
319 | int count, | ||
320 | Ecore_Xcb_Encoding_Style style, | ||
321 | Ecore_Xcb_Textproperty *ret); | ||
322 | |||
323 | # ifdef HAVE_ICONV | ||
324 | Eina_Bool _ecore_xcb_utf8_textproperty_to_textlist(const Ecore_Xcb_Textproperty *text_prop, | ||
325 | char ***list_ret, | ||
326 | int *count_ret); | ||
327 | # endif | ||
328 | Eina_Bool _ecore_xcb_mb_textproperty_to_textlist(const Ecore_Xcb_Textproperty *text_prop, | ||
329 | char ***list_ret, | ||
330 | int *count_ret); | ||
331 | Eina_Bool _ecore_xcb_textproperty_to_textlist(const Ecore_Xcb_Textproperty *text_prop, | ||
332 | const char *type, | ||
333 | char ***list_ret, | ||
334 | int *count_ret); | ||
335 | |||
336 | void _ecore_xcb_events_init(void); | ||
337 | void _ecore_xcb_events_shutdown(void); | ||
338 | void _ecore_xcb_events_handle(xcb_generic_event_t *ev); | ||
339 | Ecore_X_Time _ecore_xcb_events_last_time_get(void); | ||
340 | unsigned int _ecore_xcb_events_modifiers_get(unsigned int state); | ||
341 | void _ecore_xcb_event_mouse_move(uint16_t timestamp, | ||
342 | uint16_t modifiers, | ||
343 | int16_t x, | ||
344 | int16_t y, | ||
345 | int16_t root_x, | ||
346 | int16_t root_y, | ||
347 | xcb_window_t event_win, | ||
348 | xcb_window_t win, | ||
349 | xcb_window_t root_win, | ||
350 | uint8_t same_screen, | ||
351 | int dev, | ||
352 | double radx, | ||
353 | double rady, | ||
354 | double pressure, | ||
355 | double angle, | ||
356 | int16_t mx, | ||
357 | int16_t my, | ||
358 | int16_t mrx, | ||
359 | int16_t mry); | ||
360 | Ecore_Event_Mouse_Button *_ecore_xcb_event_mouse_button(int event, | ||
361 | uint16_t timestamp, | ||
362 | uint16_t modifiers, | ||
363 | xcb_button_t buttons, | ||
364 | int16_t x, | ||
365 | int16_t y, | ||
366 | int16_t root_x, | ||
367 | int16_t root_y, | ||
368 | xcb_window_t event_win, | ||
369 | xcb_window_t win, | ||
370 | xcb_window_t root_win, | ||
371 | uint8_t same_screen, | ||
372 | int dev, | ||
373 | double radx, | ||
374 | double rady, | ||
375 | double pressure, | ||
376 | double angle, | ||
377 | int16_t mx, | ||
378 | int16_t my, | ||
379 | int16_t mrx, | ||
380 | int16_t mry); | ||
381 | |||
382 | void _ecore_xcb_keymap_init(void); | ||
383 | void _ecore_xcb_keymap_finalize(void); | ||
384 | void _ecore_xcb_keymap_shutdown(void); | ||
385 | void _ecore_xcb_keymap_refresh(xcb_mapping_notify_event_t *event); | ||
386 | xcb_keysym_t _ecore_xcb_keymap_keycode_to_keysym(xcb_keycode_t keycode, | ||
387 | int col); | ||
388 | xcb_keycode_t *_ecore_xcb_keymap_keysym_to_keycode(xcb_keysym_t keysym); | ||
389 | char *_ecore_xcb_keymap_keysym_to_string(xcb_keysym_t keysym); | ||
390 | xcb_keycode_t _ecore_xcb_keymap_string_to_keycode(const char *key); | ||
391 | int _ecore_xcb_keymap_lookup_string(xcb_keycode_t keycode, | ||
392 | int state, | ||
393 | char *buffer, | ||
394 | int bytes, | ||
395 | xcb_keysym_t *sym); | ||
396 | |||
397 | void _ecore_xcb_input_init(void); | ||
398 | void _ecore_xcb_input_finalize(void); | ||
399 | void _ecore_xcb_input_shutdown(void); | ||
400 | # ifdef ECORE_XCB_XINPUT | ||
401 | void _ecore_xcb_input_handle_event(xcb_generic_event_t *event); | ||
402 | # else | ||
403 | void _ecore_xcb_input_handle_event(xcb_generic_event_t *event __UNUSED__); | ||
404 | # endif | ||
405 | |||
406 | void _ecore_xcb_dri_init(void); | ||
407 | void _ecore_xcb_dri_finalize(void); | ||
408 | |||
409 | void _ecore_xcb_xtest_init(void); | ||
410 | void _ecore_xcb_xtest_finalize(void); | ||
411 | |||
412 | Ecore_X_Window _ecore_xcb_window_root_of_screen_get(int screen); | ||
413 | void _ecore_xcb_window_prop_string_utf8_set(Ecore_X_Window win, | ||
414 | Ecore_X_Atom atom, | ||
415 | const char *str); | ||
416 | Ecore_X_Visual _ecore_xcb_window_visual_get(Ecore_X_Window win); | ||
417 | void _ecore_xcb_window_button_grab_remove(Ecore_X_Window win); | ||
418 | void _ecore_xcb_window_key_grab_remove(Ecore_X_Window win); | ||
419 | void _ecore_xcb_window_grab_allow_events(Ecore_X_Window event_win, | ||
420 | Ecore_X_Window child_win, | ||
421 | int type, | ||
422 | void *event, | ||
423 | Ecore_X_Time timestamp); | ||
424 | |||
425 | int _ecore_xcb_netwm_startup_info_begin(Ecore_X_Window win __UNUSED__, | ||
426 | uint8_t data __UNUSED__); | ||
427 | int _ecore_xcb_netwm_startup_info(Ecore_X_Window win __UNUSED__, | ||
428 | uint8_t data __UNUSED__); | ||
429 | Ecore_X_Window_State _ecore_xcb_netwm_window_state_get(Ecore_X_Atom atom); | ||
430 | |||
431 | int _ecore_xcb_error_handle(xcb_generic_error_t *err); | ||
432 | int _ecore_xcb_io_error_handle(xcb_generic_error_t *err); | ||
433 | |||
434 | xcb_image_t *_ecore_xcb_image_create_native(int w, | ||
435 | int h, | ||
436 | xcb_image_format_t format, | ||
437 | uint8_t depth, | ||
438 | void *base, | ||
439 | uint32_t bytes, | ||
440 | uint8_t *data); | ||
441 | |||
442 | void _ecore_xcb_xdefaults_init(void); | ||
443 | void _ecore_xcb_xdefaults_shutdown(void); | ||
444 | char *_ecore_xcb_xdefaults_string_get(const char *prog, | ||
445 | const char *param); | ||
446 | int _ecore_xcb_xdefaults_int_get(const char *prog, | ||
447 | const char *param); | ||
448 | |||
449 | void _ecore_xcb_modifiers_get(void); | ||
450 | |||
451 | #endif | ||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_randr.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_randr.c new file mode 100644 index 0000000..510da49 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_randr.c | |||
@@ -0,0 +1,3474 @@ | |||
1 | /* TODO: List of missing functions | ||
2 | * | ||
3 | * ecore_x_randr_crtc_clone_set | ||
4 | * ecore_x_randr_output_size_mm_get | ||
5 | * ecore_x_randr_output_crtc_set | ||
6 | * ecore_x_randr_edid_version_get | ||
7 | * ecore_x_randr_edid_info_has_valid_checksum | ||
8 | * ecore_x_randr_edid_manufacturer_name_get | ||
9 | * ecore_x_randr_edid_display_ascii_get | ||
10 | * ecore_x_randr_edid_display_serial_get | ||
11 | * ecore_x_randr_edid_model_get | ||
12 | * ecore_x_randr_edid_manufacturer_serial_number_get | ||
13 | * ecore_x_randr_edid_manufacturer_model_get | ||
14 | * ecore_x_randr_edid_dpms_available_get | ||
15 | * ecore_x_randr_edid_dpms_standby_available_get | ||
16 | * ecore_x_randr_edid_dpms_suspend_available_get | ||
17 | * ecore_x_randr_edid_dpms_off_available_get | ||
18 | * ecore_x_randr_edid_display_aspect_ratio_preferred_get | ||
19 | * ecore_x_randr_edid_display_aspect_ratios_get | ||
20 | * ecore_x_randr_edid_display_colorscheme_get | ||
21 | * ecore_x_randr_edid_display_type_digital_get | ||
22 | * ecore_x_randr_edid_display_interface_type_get | ||
23 | * ecore_x_randr_screen_backlight_level_set | ||
24 | * ecore_x_randr_output_subpixel_order_get | ||
25 | * ecore_x_randr_output_wired_clones_get | ||
26 | * ecore_x_randr_output_compatibility_list_get | ||
27 | * ecore_x_randr_output_signal_formats_get | ||
28 | * ecore_x_randr_output_signal_format_set | ||
29 | * ecore_x_randr_output_signal_properties_get | ||
30 | * ecore_x_randr_output_connector_number_get | ||
31 | * ecore_x_randr_output_connector_type_get | ||
32 | * ecore_x_randr_crtc_panning_area_get | ||
33 | * ecore_x_randr_crtc_panning_area_set | ||
34 | * ecore_x_randr_crtc_tracking_area_get | ||
35 | * ecore_x_randr_crtc_tracking_area_set | ||
36 | * ecore_x_randr_crtc_border_area_get | ||
37 | * ecore_x_randr_crtc_border_area_set | ||
38 | */ | ||
39 | |||
40 | #include "ecore_xcb_private.h" | ||
41 | # ifdef ECORE_XCB_RANDR | ||
42 | # include <xcb/randr.h> | ||
43 | # endif | ||
44 | |||
45 | #define Ecore_X_Randr_None 0 | ||
46 | #define Ecore_X_Randr_Unset -1 | ||
47 | |||
48 | #define RANDR_1_1 ((1 << 16) | 1) | ||
49 | #define RANDR_1_2 ((1 << 16) | 2) | ||
50 | #define RANDR_1_3 ((1 << 16) | 3) | ||
51 | |||
52 | #define RANDR_CHECK_1_1_RET(ret) if (_randr_version < RANDR_1_1) return ret | ||
53 | #define RANDR_CHECK_1_2_RET(ret) if (_randr_version < RANDR_1_2) return ret | ||
54 | #define RANDR_CHECK_1_3_RET(ret) if (_randr_version < RANDR_1_3) return ret | ||
55 | |||
56 | #define ECORE_X_RANDR_EDID_VERSION_13 ((1 << 8) | 3) | ||
57 | #define _ECORE_X_RANDR_EDID_OFFSET_VERSION_MAJOR 0x12 | ||
58 | #define _ECORE_X_RANDR_EDID_OFFSET_VERSION_MINOR 0x13 | ||
59 | #define _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK 0x36 | ||
60 | #define _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_TYPE 3 | ||
61 | #define _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_CONTENT 5 | ||
62 | #define _ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX 13 | ||
63 | |||
64 | #define _ECORE_X_RANDR_EDID_FOR_EACH_DESCRIPTOR_BLOCK(edid, block) \ | ||
65 | for (block = edid + _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK; block <= (edid + _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK + (3 * 18)); block += 18) | ||
66 | |||
67 | #define _ECORE_X_RANDR_EDID_FOR_EACH_NON_PIXEL_DESCRIPTOR_BLOCK(edid, block) \ | ||
68 | _ECORE_X_RANDR_EDID_FOR_EACH_DESCRIPTOR_BLOCK(edid, block) \ | ||
69 | if ((block[0] == 0) && (block[1] == 0)) | ||
70 | |||
71 | /* local function prototypes */ | ||
72 | static Eina_Bool _ecore_xcb_randr_output_validate(Ecore_X_Window root, | ||
73 | Ecore_X_Randr_Output output); | ||
74 | static Eina_Bool _ecore_xcb_randr_crtc_validate(Ecore_X_Window root, | ||
75 | Ecore_X_Randr_Crtc crtc); | ||
76 | static Eina_Bool _ecore_xcb_randr_root_validate(Ecore_X_Window root); | ||
77 | static int _ecore_xcb_randr_root_to_screen(Ecore_X_Window root); | ||
78 | static xcb_randr_get_screen_resources_reply_t *_ecore_xcb_randr_12_get_resources(Ecore_X_Window win); | ||
79 | static xcb_randr_get_screen_resources_current_reply_t *_ecore_xcb_randr_13_get_resources(Ecore_X_Window win); | ||
80 | static xcb_timestamp_t _ecore_xcb_randr_12_get_resource_timestamp(Ecore_X_Window win); | ||
81 | static xcb_timestamp_t _ecore_xcb_randr_13_get_resource_timestamp(Ecore_X_Window win); | ||
82 | |||
83 | static Ecore_X_Randr_Mode *_ecore_xcb_randr_12_output_modes_get(Ecore_X_Window root, | ||
84 | Ecore_X_Randr_Output output, | ||
85 | int *num, | ||
86 | int *npreferred); | ||
87 | static Ecore_X_Randr_Mode *_ecore_xcb_randr_13_output_modes_get(Ecore_X_Window root, | ||
88 | Ecore_X_Randr_Output output, | ||
89 | int *num, | ||
90 | int *npreferred); | ||
91 | static Ecore_X_Randr_Mode_Info *_ecore_xcb_randr_12_mode_info_get(Ecore_X_Window root, | ||
92 | Ecore_X_Randr_Mode mode); | ||
93 | static Ecore_X_Randr_Mode_Info *_ecore_xcb_randr_13_mode_info_get(Ecore_X_Window root, | ||
94 | Ecore_X_Randr_Mode mode); | ||
95 | static Ecore_X_Randr_Mode_Info **_ecore_xcb_randr_12_modes_info_get(Ecore_X_Window root, | ||
96 | int *num); | ||
97 | static Ecore_X_Randr_Mode_Info **_ecore_xcb_randr_13_modes_info_get(Ecore_X_Window root, | ||
98 | int *num); | ||
99 | static void _ecore_xcb_randr_12_mode_size_get(Ecore_X_Window root, | ||
100 | Ecore_X_Randr_Mode mode, | ||
101 | int *w, | ||
102 | int *h); | ||
103 | static void _ecore_xcb_randr_13_mode_size_get(Ecore_X_Window root, | ||
104 | Ecore_X_Randr_Mode mode, | ||
105 | int *w, | ||
106 | int *h); | ||
107 | static Ecore_X_Randr_Output *_ecore_xcb_randr_12_output_clones_get(Ecore_X_Window root, | ||
108 | Ecore_X_Randr_Output output, | ||
109 | int *num); | ||
110 | static Ecore_X_Randr_Output *_ecore_xcb_randr_13_output_clones_get(Ecore_X_Window root, | ||
111 | Ecore_X_Randr_Output output, | ||
112 | int *num); | ||
113 | static Ecore_X_Randr_Crtc *_ecore_xcb_randr_12_output_possible_crtcs_get(Ecore_X_Window root, | ||
114 | Ecore_X_Randr_Output output, | ||
115 | int *num); | ||
116 | static Ecore_X_Randr_Crtc *_ecore_xcb_randr_13_output_possible_crtcs_get(Ecore_X_Window root, | ||
117 | Ecore_X_Randr_Output output, | ||
118 | int *num); | ||
119 | static char *_ecore_xcb_randr_12_output_name_get(Ecore_X_Window root, | ||
120 | Ecore_X_Randr_Output output, | ||
121 | int *len); | ||
122 | static char *_ecore_xcb_randr_13_output_name_get(Ecore_X_Window root, | ||
123 | Ecore_X_Randr_Output output, | ||
124 | int *len); | ||
125 | static Ecore_X_Randr_Connection_Status _ecore_xcb_randr_12_output_connection_status_get(Ecore_X_Window root, | ||
126 | Ecore_X_Randr_Output output); | ||
127 | static Ecore_X_Randr_Connection_Status _ecore_xcb_randr_13_output_connection_status_get(Ecore_X_Window root, | ||
128 | Ecore_X_Randr_Output output); | ||
129 | static Ecore_X_Randr_Output *_ecore_xcb_randr_12_outputs_get(Ecore_X_Window root, | ||
130 | int *num); | ||
131 | static Ecore_X_Randr_Output *_ecore_xcb_randr_13_outputs_get(Ecore_X_Window root, | ||
132 | int *num); | ||
133 | static Ecore_X_Randr_Crtc _ecore_xcb_randr_12_output_crtc_get(Ecore_X_Window root, | ||
134 | Ecore_X_Randr_Output output); | ||
135 | static Ecore_X_Randr_Crtc _ecore_xcb_randr_13_output_crtc_get(Ecore_X_Window root, | ||
136 | Ecore_X_Randr_Output output); | ||
137 | |||
138 | /* local variables */ | ||
139 | static Eina_Bool _randr_avail = EINA_FALSE; | ||
140 | static int _randr_version = -1; | ||
141 | |||
142 | /* external variables */ | ||
143 | int _ecore_xcb_event_randr = -1; | ||
144 | |||
145 | void | ||
146 | _ecore_xcb_randr_init(void) | ||
147 | { | ||
148 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
149 | |||
150 | #ifdef ECORE_XCB_RANDR | ||
151 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_randr_id); | ||
152 | #endif | ||
153 | } | ||
154 | |||
155 | void | ||
156 | _ecore_xcb_randr_finalize(void) | ||
157 | { | ||
158 | #ifdef ECORE_XCB_RANDR | ||
159 | const xcb_query_extension_reply_t *ext_reply; | ||
160 | #endif | ||
161 | |||
162 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
163 | |||
164 | #ifdef ECORE_XCB_RANDR | ||
165 | ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_randr_id); | ||
166 | if ((ext_reply) && (ext_reply->present)) | ||
167 | { | ||
168 | xcb_randr_query_version_cookie_t cookie; | ||
169 | xcb_randr_query_version_reply_t *reply; | ||
170 | |||
171 | cookie = | ||
172 | xcb_randr_query_version_unchecked(_ecore_xcb_conn, | ||
173 | XCB_RANDR_MAJOR_VERSION, | ||
174 | XCB_RANDR_MINOR_VERSION); | ||
175 | reply = xcb_randr_query_version_reply(_ecore_xcb_conn, cookie, NULL); | ||
176 | if (reply) | ||
177 | { | ||
178 | if ((reply->major_version >= XCB_RANDR_MAJOR_VERSION) && | ||
179 | (reply->minor_version >= XCB_RANDR_MINOR_VERSION)) | ||
180 | _randr_avail = EINA_TRUE; | ||
181 | |||
182 | _randr_version = | ||
183 | ((reply->major_version << 16) | reply->minor_version); | ||
184 | |||
185 | free(reply); | ||
186 | } | ||
187 | |||
188 | if (_randr_avail) | ||
189 | _ecore_xcb_event_randr = ext_reply->first_event; | ||
190 | } | ||
191 | #endif | ||
192 | } | ||
193 | |||
194 | static Eina_Bool | ||
195 | _ecore_xcb_randr_root_validate(Ecore_X_Window root) | ||
196 | { | ||
197 | #ifdef ECORE_XCB_RANDR | ||
198 | Ecore_X_Randr_Screen scr = -1; | ||
199 | # define RANDR_VALIDATE_ROOT(screen, root) \ | ||
200 | ((screen == _ecore_xcb_randr_root_to_screen(root)) != -1) | ||
201 | #endif | ||
202 | |||
203 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
204 | |||
205 | #ifdef ECORE_XCB_RANDR | ||
206 | if ((root) && RANDR_VALIDATE_ROOT(scr, root)) | ||
207 | return EINA_TRUE; | ||
208 | #endif | ||
209 | |||
210 | return EINA_FALSE; | ||
211 | } | ||
212 | |||
213 | static int | ||
214 | _ecore_xcb_randr_root_to_screen(Ecore_X_Window root) | ||
215 | { | ||
216 | int count = 0, num = 0; | ||
217 | |||
218 | CHECK_XCB_CONN; | ||
219 | |||
220 | count = xcb_setup_roots_length(xcb_get_setup(_ecore_xcb_conn)); | ||
221 | for (num = 0; num < count; num++) | ||
222 | if (_ecore_xcb_window_root_of_screen_get(num) == root) | ||
223 | return num; | ||
224 | |||
225 | return -1; | ||
226 | } | ||
227 | |||
228 | /* public functions */ | ||
229 | |||
230 | /* | ||
231 | * @brief query whether randr is available or not | ||
232 | * @return EINA_TRUE, if extension is available, else EINA_FALSE | ||
233 | */ | ||
234 | EAPI Eina_Bool | ||
235 | ecore_x_randr_query(void) | ||
236 | { | ||
237 | return _randr_avail; | ||
238 | } | ||
239 | |||
240 | /* | ||
241 | * @return version of the RandRR extension supported by the server or, | ||
242 | * in case RandRR extension is not available, Ecore_X_Randr_Unset (=-1). | ||
243 | * bit version information: 31 MAJOR 16 | 15 MINOR 0 | ||
244 | */ | ||
245 | EAPI int | ||
246 | ecore_x_randr_version_get(void) | ||
247 | { | ||
248 | return _randr_version; | ||
249 | } | ||
250 | |||
251 | /* | ||
252 | * @param root window which's primary output will be queried | ||
253 | */ | ||
254 | EAPI Ecore_X_Randr_Orientation | ||
255 | ecore_x_randr_screen_primary_output_orientations_get(Ecore_X_Window root) | ||
256 | { | ||
257 | int ret = Ecore_X_Randr_None; | ||
258 | #ifdef ECORE_XCB_RANDR | ||
259 | xcb_randr_get_screen_info_cookie_t cookie; | ||
260 | xcb_randr_get_screen_info_reply_t *reply; | ||
261 | #endif | ||
262 | |||
263 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
264 | CHECK_XCB_CONN; | ||
265 | |||
266 | #ifdef ECORE_XCB_RANDR | ||
267 | cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); | ||
268 | reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL); | ||
269 | if (reply) | ||
270 | { | ||
271 | ret = reply->rotations; | ||
272 | free(reply); | ||
273 | } | ||
274 | #endif | ||
275 | |||
276 | return ret; | ||
277 | } | ||
278 | |||
279 | /* | ||
280 | * @param root window which's primary output will be queried | ||
281 | * @return the current orientation of the root window's screen primary output | ||
282 | */ | ||
283 | EAPI Ecore_X_Randr_Orientation | ||
284 | ecore_x_randr_screen_primary_output_orientation_get(Ecore_X_Window root) | ||
285 | { | ||
286 | int ret = Ecore_X_Randr_None; | ||
287 | #ifdef ECORE_XCB_RANDR | ||
288 | xcb_randr_get_screen_info_cookie_t cookie; | ||
289 | xcb_randr_get_screen_info_reply_t *reply; | ||
290 | #endif | ||
291 | |||
292 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
293 | CHECK_XCB_CONN; | ||
294 | |||
295 | #ifdef ECORE_XCB_RANDR | ||
296 | cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); | ||
297 | reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL); | ||
298 | if (reply) | ||
299 | { | ||
300 | ret = reply->rotation; | ||
301 | free(reply); | ||
302 | } | ||
303 | #endif | ||
304 | |||
305 | return ret; | ||
306 | } | ||
307 | |||
308 | /* | ||
309 | * @brief sets a given screen's primary output's orientation | ||
310 | * @param root window which's screen's primary output will be queried | ||
311 | * @param orientation orientation which should be set for the root window's screen primary output | ||
312 | * @return EINA_TRUE if the primary output's orientation could be successfully altered | ||
313 | */ | ||
314 | EAPI Eina_Bool | ||
315 | ecore_x_randr_screen_primary_output_orientation_set(Ecore_X_Window root, | ||
316 | Ecore_X_Randr_Orientation orientation) | ||
317 | { | ||
318 | int ret = EINA_FALSE; | ||
319 | #ifdef ECORE_XCB_RANDR | ||
320 | xcb_randr_get_screen_info_cookie_t cookie; | ||
321 | xcb_randr_get_screen_info_reply_t *reply; | ||
322 | #endif | ||
323 | |||
324 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
325 | CHECK_XCB_CONN; | ||
326 | |||
327 | #ifdef ECORE_XCB_RANDR | ||
328 | cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); | ||
329 | reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL); | ||
330 | if (reply) | ||
331 | { | ||
332 | xcb_randr_set_screen_config_cookie_t scookie; | ||
333 | xcb_randr_set_screen_config_reply_t *sreply; | ||
334 | |||
335 | scookie = | ||
336 | xcb_randr_set_screen_config_unchecked(_ecore_xcb_conn, root, | ||
337 | XCB_CURRENT_TIME, | ||
338 | reply->config_timestamp, | ||
339 | reply->sizeID, orientation, | ||
340 | reply->rate); | ||
341 | sreply = | ||
342 | xcb_randr_set_screen_config_reply(_ecore_xcb_conn, scookie, NULL); | ||
343 | if (!sreply) | ||
344 | ret = EINA_FALSE; | ||
345 | else | ||
346 | { | ||
347 | ret = (sreply->status == XCB_RANDR_SET_CONFIG_SUCCESS) ? | ||
348 | EINA_TRUE : EINA_FALSE; | ||
349 | free(sreply); | ||
350 | } | ||
351 | free(reply); | ||
352 | } | ||
353 | #endif | ||
354 | |||
355 | return ret; | ||
356 | } | ||
357 | |||
358 | /* | ||
359 | * @brief gets a screen's primary output's possible sizes | ||
360 | * @param root window which's primary output will be queried | ||
361 | * @param num number of sizes reported as supported by the screen's primary output | ||
362 | * @return an array of sizes reported as supported by the screen's primary output or - if query failed - NULL | ||
363 | */ | ||
364 | EAPI Ecore_X_Randr_Screen_Size_MM * | ||
365 | ecore_x_randr_screen_primary_output_sizes_get(Ecore_X_Window root, | ||
366 | int *num) | ||
367 | { | ||
368 | #ifdef ECORE_XCB_RANDR | ||
369 | xcb_randr_get_screen_info_cookie_t cookie; | ||
370 | xcb_randr_get_screen_info_reply_t *reply; | ||
371 | Ecore_X_Randr_Screen_Size_MM *ret = NULL; | ||
372 | #endif | ||
373 | |||
374 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
375 | CHECK_XCB_CONN; | ||
376 | |||
377 | #ifdef ECORE_XCB_RANDR | ||
378 | cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); | ||
379 | reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL); | ||
380 | if (reply) | ||
381 | { | ||
382 | int len = 0, i = 0; | ||
383 | xcb_randr_screen_size_t *sizes; | ||
384 | |||
385 | len = xcb_randr_get_screen_info_sizes_length(reply); | ||
386 | sizes = xcb_randr_get_screen_info_sizes(reply); | ||
387 | if ((!sizes) || (len <= 0)) | ||
388 | { | ||
389 | free(reply); | ||
390 | return NULL; | ||
391 | } | ||
392 | if (num) *num = len; | ||
393 | ret = calloc(len, sizeof(Ecore_X_Randr_Screen_Size_MM)); | ||
394 | if (!ret) | ||
395 | { | ||
396 | free(reply); | ||
397 | return NULL; | ||
398 | } | ||
399 | for (i = 0; i < len; i++) | ||
400 | { | ||
401 | ret[i].width = sizes[i].width; | ||
402 | ret[i].height = sizes[i].height; | ||
403 | ret[i].width_mm = sizes[i].mwidth; | ||
404 | ret[i].height_mm = sizes[i].mheight; | ||
405 | } | ||
406 | |||
407 | free(reply); | ||
408 | } | ||
409 | |||
410 | return ret; | ||
411 | #else | ||
412 | return NULL; | ||
413 | #endif | ||
414 | } | ||
415 | |||
416 | /* | ||
417 | * @brief get the current set size of a given screen's primary output | ||
418 | * @param root window which's primary output will be queried | ||
419 | * @param w the current size's width | ||
420 | * @param h the current size's height | ||
421 | * @param w_mm the current size's width in mm | ||
422 | * @param h_mm the current size's height in mm | ||
423 | * @param size_index of current set size to be used with ecore_x_randr_primary_output_size_set() | ||
424 | */ | ||
425 | EAPI void | ||
426 | ecore_x_randr_screen_primary_output_current_size_get(Ecore_X_Window root, | ||
427 | int *w, | ||
428 | int *h, | ||
429 | int *w_mm, | ||
430 | int *h_mm, | ||
431 | int *size_index) | ||
432 | { | ||
433 | #ifdef ECORE_XCB_RANDR | ||
434 | xcb_randr_get_screen_info_cookie_t cookie; | ||
435 | xcb_randr_get_screen_info_reply_t *reply; | ||
436 | #endif | ||
437 | |||
438 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
439 | CHECK_XCB_CONN; | ||
440 | |||
441 | #ifdef ECORE_XCB_RANDR | ||
442 | cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); | ||
443 | reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL); | ||
444 | if (reply) | ||
445 | { | ||
446 | int len = 0, idx = 0; | ||
447 | xcb_randr_screen_size_t *sizes; | ||
448 | |||
449 | len = xcb_randr_get_screen_info_sizes_length(reply); | ||
450 | sizes = xcb_randr_get_screen_info_sizes(reply); | ||
451 | if ((!sizes) || (len <= 0)) | ||
452 | { | ||
453 | free(reply); | ||
454 | return; | ||
455 | } | ||
456 | idx = reply->sizeID; | ||
457 | if ((idx < len) && (idx >= 0)) | ||
458 | { | ||
459 | if (w) *w = sizes[idx].width; | ||
460 | if (h) *h = sizes[idx].height; | ||
461 | if (w_mm) *w_mm = sizes[idx].mwidth; | ||
462 | if (h_mm) *h_mm = sizes[idx].mheight; | ||
463 | if (size_index) *size_index = idx; | ||
464 | } | ||
465 | |||
466 | free(reply); | ||
467 | } | ||
468 | #endif | ||
469 | } | ||
470 | |||
471 | /* | ||
472 | * @brief sets a given screen's primary output size, but disables all other outputs at the same time | ||
473 | * @param root window which's primary output will be queried | ||
474 | * @param size_index within the list of sizes reported as supported by the root window's screen primary output | ||
475 | * @return EINA_TRUE on success, EINA_FALSE on failure due to e.g. invalid times | ||
476 | */ | ||
477 | EAPI Eina_Bool | ||
478 | ecore_x_randr_screen_primary_output_size_set(Ecore_X_Window root, | ||
479 | int size_index) | ||
480 | { | ||
481 | Eina_Bool ret = EINA_FALSE; | ||
482 | #ifdef ECORE_XCB_RANDR | ||
483 | xcb_randr_get_screen_info_cookie_t cookie; | ||
484 | xcb_randr_get_screen_info_reply_t *reply; | ||
485 | #endif | ||
486 | |||
487 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
488 | CHECK_XCB_CONN; | ||
489 | |||
490 | #ifdef ECORE_XCB_RANDR | ||
491 | if (!((size_index >= 0) && (_ecore_xcb_randr_root_validate(root)))) | ||
492 | return EINA_FALSE; | ||
493 | |||
494 | cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); | ||
495 | reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL); | ||
496 | if (reply) | ||
497 | { | ||
498 | int len = 0; | ||
499 | |||
500 | len = xcb_randr_get_screen_info_sizes_length(reply); | ||
501 | if (len <= 0) | ||
502 | { | ||
503 | free(reply); | ||
504 | return EINA_FALSE; | ||
505 | } | ||
506 | if ((size_index < len) && (size_index >= 0)) | ||
507 | { | ||
508 | xcb_randr_set_screen_config_cookie_t scookie; | ||
509 | xcb_randr_set_screen_config_reply_t *sreply; | ||
510 | |||
511 | scookie = | ||
512 | xcb_randr_set_screen_config_unchecked(_ecore_xcb_conn, root, | ||
513 | XCB_CURRENT_TIME, | ||
514 | reply->config_timestamp, | ||
515 | size_index, | ||
516 | reply->rotation, | ||
517 | reply->rate); | ||
518 | sreply = | ||
519 | xcb_randr_set_screen_config_reply(_ecore_xcb_conn, | ||
520 | scookie, NULL); | ||
521 | if (!sreply) | ||
522 | ret = EINA_FALSE; | ||
523 | else | ||
524 | { | ||
525 | ret = (sreply->status == XCB_RANDR_SET_CONFIG_SUCCESS) ? | ||
526 | EINA_TRUE : EINA_FALSE; | ||
527 | free(sreply); | ||
528 | } | ||
529 | } | ||
530 | |||
531 | free(reply); | ||
532 | } | ||
533 | #endif | ||
534 | return ret; | ||
535 | } | ||
536 | |||
537 | /* | ||
538 | * @param root window which's primary output will be queried | ||
539 | * @return currently used refresh rate or - if request failed or RandRR is not available - 0.0 | ||
540 | */ | ||
541 | EAPI Ecore_X_Randr_Refresh_Rate | ||
542 | ecore_x_randr_screen_primary_output_current_refresh_rate_get(Ecore_X_Window root) | ||
543 | { | ||
544 | #ifdef ECORE_XCB_RANDR | ||
545 | xcb_randr_get_screen_info_cookie_t cookie; | ||
546 | xcb_randr_get_screen_info_reply_t *reply; | ||
547 | Ecore_X_Randr_Refresh_Rate ret = 0.0; | ||
548 | #endif | ||
549 | |||
550 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
551 | CHECK_XCB_CONN; | ||
552 | |||
553 | #ifdef ECORE_XCB_RANDR | ||
554 | if (!_ecore_xcb_randr_root_validate(root)) return ret; | ||
555 | |||
556 | cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); | ||
557 | reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL); | ||
558 | if (reply) | ||
559 | { | ||
560 | ret = reply->rate; | ||
561 | free(reply); | ||
562 | } | ||
563 | |||
564 | return ret; | ||
565 | #else | ||
566 | return 0.0; | ||
567 | #endif | ||
568 | } | ||
569 | |||
570 | /* | ||
571 | * @param root window which's primary output will be queried | ||
572 | * @param size_index referencing the size to query valid refresh rates for | ||
573 | * @return currently used refresh rate or - if request failed or RandRR is not available - NULL | ||
574 | */ | ||
575 | EAPI Ecore_X_Randr_Refresh_Rate * | ||
576 | ecore_x_randr_screen_primary_output_refresh_rates_get(Ecore_X_Window root, | ||
577 | int size_index, | ||
578 | int *num) | ||
579 | { | ||
580 | #ifdef ECORE_XCB_RANDR | ||
581 | xcb_randr_get_screen_info_cookie_t cookie; | ||
582 | xcb_randr_get_screen_info_reply_t *reply; | ||
583 | Ecore_X_Randr_Refresh_Rate *ret = NULL; | ||
584 | #endif | ||
585 | |||
586 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
587 | CHECK_XCB_CONN; | ||
588 | |||
589 | #ifdef ECORE_XCB_RANDR | ||
590 | if (!_ecore_xcb_randr_root_validate(root)) return ret; | ||
591 | |||
592 | cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); | ||
593 | reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL); | ||
594 | if (reply) | ||
595 | { | ||
596 | int len = 0; | ||
597 | |||
598 | len = xcb_randr_get_screen_info_rates_length(reply); | ||
599 | if (num) *num = len; | ||
600 | |||
601 | ret = malloc(sizeof(Ecore_X_Randr_Refresh_Rate) * len); | ||
602 | if (ret) | ||
603 | { | ||
604 | xcb_randr_refresh_rates_iterator_t iter; | ||
605 | int i = 0; | ||
606 | |||
607 | iter = xcb_randr_get_screen_info_rates_iterator(reply); | ||
608 | while (i++ < size_index) | ||
609 | xcb_randr_refresh_rates_next(&iter); | ||
610 | |||
611 | memcpy(ret, xcb_randr_refresh_rates_rates(iter.data), | ||
612 | sizeof(Ecore_X_Randr_Refresh_Rate) * len); | ||
613 | } | ||
614 | free(reply); | ||
615 | } | ||
616 | |||
617 | return ret; | ||
618 | #else | ||
619 | return NULL; | ||
620 | #endif | ||
621 | } | ||
622 | |||
623 | /* | ||
624 | * @brief sets the current primary output's refresh rate | ||
625 | * @param root window which's primary output will be queried | ||
626 | * @param size_index referencing the size to be set | ||
627 | * @param rate the refresh rate to be set | ||
628 | * @return EINA_TRUE on success else EINA_FALSE | ||
629 | */ | ||
630 | EAPI Eina_Bool | ||
631 | ecore_x_randr_screen_primary_output_refresh_rate_set(Ecore_X_Window root, | ||
632 | int size_index, | ||
633 | Ecore_X_Randr_Refresh_Rate rate) | ||
634 | { | ||
635 | Eina_Bool ret = EINA_FALSE; | ||
636 | #ifdef ECORE_XCB_RANDR | ||
637 | xcb_randr_get_screen_info_cookie_t cookie; | ||
638 | xcb_randr_get_screen_info_reply_t *reply; | ||
639 | #endif | ||
640 | |||
641 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
642 | CHECK_XCB_CONN; | ||
643 | |||
644 | #ifdef ECORE_XCB_RANDR | ||
645 | if (_randr_version < RANDR_1_1) return EINA_FALSE; | ||
646 | |||
647 | cookie = xcb_randr_get_screen_info_unchecked(_ecore_xcb_conn, root); | ||
648 | reply = xcb_randr_get_screen_info_reply(_ecore_xcb_conn, cookie, NULL); | ||
649 | if (reply) | ||
650 | { | ||
651 | xcb_randr_set_screen_config_cookie_t scookie; | ||
652 | xcb_randr_set_screen_config_reply_t *sreply; | ||
653 | |||
654 | scookie = | ||
655 | xcb_randr_set_screen_config_unchecked(_ecore_xcb_conn, root, | ||
656 | XCB_CURRENT_TIME, | ||
657 | reply->config_timestamp, | ||
658 | size_index, | ||
659 | reply->rotation, rate); | ||
660 | sreply = | ||
661 | xcb_randr_set_screen_config_reply(_ecore_xcb_conn, | ||
662 | scookie, NULL); | ||
663 | if (!sreply) | ||
664 | ret = EINA_FALSE; | ||
665 | else | ||
666 | { | ||
667 | ret = (sreply->status == XCB_RANDR_SET_CONFIG_SUCCESS) ? | ||
668 | EINA_TRUE : EINA_FALSE; | ||
669 | free(sreply); | ||
670 | } | ||
671 | free(reply); | ||
672 | } | ||
673 | #endif | ||
674 | |||
675 | return ret; | ||
676 | } | ||
677 | |||
678 | /* | ||
679 | * @brief free detailed mode information. The pointer handed in will be set to | ||
680 | * NULL after freeing the memory. | ||
681 | * @param mode_info the mode information that should be freed | ||
682 | */ | ||
683 | EAPI void | ||
684 | ecore_x_randr_mode_info_free(Ecore_X_Randr_Mode_Info *mode_info) | ||
685 | { | ||
686 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
687 | CHECK_XCB_CONN; | ||
688 | |||
689 | RANDR_CHECK_1_2_RET(); | ||
690 | |||
691 | if (!mode_info) return; | ||
692 | |||
693 | if (mode_info->name) free(mode_info->name); | ||
694 | free(mode_info); | ||
695 | mode_info = NULL; | ||
696 | } | ||
697 | |||
698 | /* | ||
699 | * @param root window which's screen should be queried | ||
700 | * @return Ecore_X_Randr_Ouptut_Id or - if query failed or none is set - Ecore_X_Randr_None | ||
701 | */ | ||
702 | EAPI Ecore_X_Randr_Output | ||
703 | ecore_x_randr_primary_output_get(Ecore_X_Window root) | ||
704 | { | ||
705 | Ecore_X_Randr_Output ret = Ecore_X_Randr_None; | ||
706 | #ifdef ECORE_XCB_RANDR | ||
707 | xcb_randr_get_output_primary_cookie_t cookie; | ||
708 | xcb_randr_get_output_primary_reply_t *reply; | ||
709 | #endif | ||
710 | |||
711 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
712 | CHECK_XCB_CONN; | ||
713 | |||
714 | #ifdef ECORE_XCB_RANDR | ||
715 | RANDR_CHECK_1_3_RET(Ecore_X_Randr_None); | ||
716 | |||
717 | if (!_ecore_xcb_randr_root_validate(root)) | ||
718 | return Ecore_X_Randr_None; | ||
719 | |||
720 | cookie = xcb_randr_get_output_primary_unchecked(_ecore_xcb_conn, root); | ||
721 | reply = xcb_randr_get_output_primary_reply(_ecore_xcb_conn, cookie, NULL); | ||
722 | if (reply) | ||
723 | { | ||
724 | ret = reply->output; | ||
725 | free(reply); | ||
726 | } | ||
727 | #endif | ||
728 | return ret; | ||
729 | } | ||
730 | |||
731 | /* | ||
732 | * @param root window which's screen should be queried | ||
733 | * @param output that should be set as given root window's screen primary output | ||
734 | */ | ||
735 | EAPI void | ||
736 | ecore_x_randr_primary_output_set(Ecore_X_Window root, | ||
737 | Ecore_X_Randr_Output output) | ||
738 | { | ||
739 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
740 | CHECK_XCB_CONN; | ||
741 | |||
742 | #ifdef ECORE_XCB_RANDR | ||
743 | RANDR_CHECK_1_3_RET(); | ||
744 | |||
745 | if ((output) && (_ecore_xcb_randr_root_validate(root))) | ||
746 | xcb_randr_set_output_primary(_ecore_xcb_conn, root, output); | ||
747 | #endif | ||
748 | } | ||
749 | |||
750 | EAPI Ecore_X_Randr_Mode * | ||
751 | ecore_x_randr_output_modes_get(Ecore_X_Window root, | ||
752 | Ecore_X_Randr_Output output, | ||
753 | int *num, | ||
754 | int *npreferred) | ||
755 | { | ||
756 | Ecore_X_Randr_Mode *modes = NULL; | ||
757 | |||
758 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
759 | CHECK_XCB_CONN; | ||
760 | |||
761 | #ifdef ECORE_XCB_RANDR | ||
762 | RANDR_CHECK_1_2_RET(NULL); | ||
763 | |||
764 | if (_randr_version >= RANDR_1_3) | ||
765 | { | ||
766 | modes = | ||
767 | _ecore_xcb_randr_13_output_modes_get(root, output, num, npreferred); | ||
768 | } | ||
769 | else if (_randr_version == RANDR_1_2) | ||
770 | { | ||
771 | modes = | ||
772 | _ecore_xcb_randr_12_output_modes_get(root, output, num, npreferred); | ||
773 | } | ||
774 | #endif | ||
775 | |||
776 | return modes; | ||
777 | } | ||
778 | |||
779 | /* | ||
780 | * @brief get detailed information for a given mode id | ||
781 | * @param root window which's screen's ressources are queried | ||
782 | * @param mode the XID which identifies the mode of interest | ||
783 | * @return mode's detailed information | ||
784 | */ | ||
785 | EAPI Ecore_X_Randr_Mode_Info * | ||
786 | ecore_x_randr_mode_info_get(Ecore_X_Window root, | ||
787 | Ecore_X_Randr_Mode mode) | ||
788 | { | ||
789 | Ecore_X_Randr_Mode_Info *ret = NULL; | ||
790 | |||
791 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
792 | CHECK_XCB_CONN; | ||
793 | |||
794 | #ifdef ECORE_XCB_RANDR | ||
795 | RANDR_CHECK_1_2_RET(NULL); | ||
796 | |||
797 | if (!_ecore_xcb_randr_root_validate(root)) return NULL; | ||
798 | |||
799 | if (_randr_version >= RANDR_1_3) | ||
800 | ret = _ecore_xcb_randr_13_mode_info_get(root, mode); | ||
801 | else if (_randr_version == RANDR_1_2) | ||
802 | ret = _ecore_xcb_randr_12_mode_info_get(root, mode); | ||
803 | #endif | ||
804 | return ret; | ||
805 | } | ||
806 | |||
807 | /* | ||
808 | * @brief get detailed information for all modes related to a root window's screen | ||
809 | * @param root window which's screen's ressources are queried | ||
810 | * @param num number of modes returned | ||
811 | * @return modes' information | ||
812 | */ | ||
813 | EAPI Ecore_X_Randr_Mode_Info ** | ||
814 | ecore_x_randr_modes_info_get(Ecore_X_Window root, | ||
815 | int *num) | ||
816 | { | ||
817 | Ecore_X_Randr_Mode_Info **ret = NULL; | ||
818 | |||
819 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
820 | CHECK_XCB_CONN; | ||
821 | |||
822 | if (num) *num = 0; | ||
823 | |||
824 | #ifdef ECORE_XCB_RANDR | ||
825 | RANDR_CHECK_1_2_RET(NULL); | ||
826 | |||
827 | if (!_ecore_xcb_randr_root_validate(root)) return NULL; | ||
828 | |||
829 | if (_randr_version >= RANDR_1_3) | ||
830 | ret = _ecore_xcb_randr_13_modes_info_get(root, num); | ||
831 | else if (_randr_version == RANDR_1_2) | ||
832 | ret = _ecore_xcb_randr_12_modes_info_get(root, num); | ||
833 | #endif | ||
834 | return ret; | ||
835 | } | ||
836 | |||
837 | /** | ||
838 | * @brief gets the width and hight of a given mode | ||
839 | * @param mode the mode which's size is to be looked up | ||
840 | * @param w width of given mode in px | ||
841 | * @param h height of given mode in px | ||
842 | */ | ||
843 | EAPI void | ||
844 | ecore_x_randr_mode_size_get(Ecore_X_Window root, | ||
845 | Ecore_X_Randr_Mode mode, | ||
846 | int *w, | ||
847 | int *h) | ||
848 | { | ||
849 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
850 | CHECK_XCB_CONN; | ||
851 | |||
852 | #ifdef ECORE_XCB_RANDR | ||
853 | RANDR_CHECK_1_2_RET(); | ||
854 | |||
855 | if (mode == Ecore_X_Randr_None) return; | ||
856 | |||
857 | if (_randr_version >= RANDR_1_3) | ||
858 | _ecore_xcb_randr_13_mode_size_get(root, mode, w, h); | ||
859 | else if (_randr_version == RANDR_1_2) | ||
860 | _ecore_xcb_randr_12_mode_size_get(root, mode, w, h); | ||
861 | #endif | ||
862 | } | ||
863 | |||
864 | /** | ||
865 | * @brief gets the EDID information of an attached output if available. | ||
866 | * Note that this information is not to be compared using ordinary string | ||
867 | * comparison functions, since it includes 0-bytes. | ||
868 | * @param root window this information should be queried from | ||
869 | * @param output the XID of the output | ||
870 | * @param length length of the byte-array. If NULL, request will fail. | ||
871 | */ | ||
872 | EAPI unsigned char * | ||
873 | ecore_x_randr_output_edid_get(Ecore_X_Window root, | ||
874 | Ecore_X_Randr_Output output, | ||
875 | unsigned long *length) | ||
876 | { | ||
877 | unsigned char *ret = NULL; | ||
878 | #ifdef ECORE_XCB_RANDR | ||
879 | xcb_randr_get_output_property_cookie_t cookie; | ||
880 | xcb_randr_get_output_property_reply_t *reply; | ||
881 | Ecore_X_Atom atom; | ||
882 | #endif | ||
883 | |||
884 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
885 | CHECK_XCB_CONN; | ||
886 | |||
887 | #ifdef ECORE_XCB_RANDR | ||
888 | RANDR_CHECK_1_2_RET(NULL); | ||
889 | |||
890 | if ((!length) || (!_ecore_xcb_randr_output_validate(root, output))) | ||
891 | return NULL; | ||
892 | |||
893 | atom = ecore_x_atom_get("EDID"); | ||
894 | cookie = | ||
895 | xcb_randr_get_output_property_unchecked(_ecore_xcb_conn, output, atom, | ||
896 | XCB_GET_PROPERTY_TYPE_ANY, | ||
897 | 0, 100, 0, 0); | ||
898 | reply = | ||
899 | xcb_randr_get_output_property_reply(_ecore_xcb_conn, cookie, NULL); | ||
900 | if (reply) | ||
901 | { | ||
902 | if ((reply->type == XCB_ATOM_INTEGER) && (reply->format == 8)) | ||
903 | { | ||
904 | if (length) *length = reply->num_items; | ||
905 | if ((ret = malloc(reply->num_items * sizeof(unsigned char)))) | ||
906 | { | ||
907 | memcpy(ret, xcb_randr_get_output_property_data(reply), | ||
908 | (reply->num_items * sizeof(unsigned char))); | ||
909 | } | ||
910 | } | ||
911 | free(reply); | ||
912 | } | ||
913 | #endif | ||
914 | return ret; | ||
915 | } | ||
916 | |||
917 | /** | ||
918 | * @brief gets the the outputs which might be used simultenously on the same | ||
919 | * CRTC. | ||
920 | * @param root window that this information should be queried for. | ||
921 | * @param output the output which's clones we concern | ||
922 | * @param num number of possible clones | ||
923 | */ | ||
924 | EAPI Ecore_X_Randr_Output * | ||
925 | ecore_x_randr_output_clones_get(Ecore_X_Window root, | ||
926 | Ecore_X_Randr_Output output, | ||
927 | int *num) | ||
928 | { | ||
929 | Ecore_X_Randr_Output *outputs = NULL; | ||
930 | |||
931 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
932 | CHECK_XCB_CONN; | ||
933 | |||
934 | #ifdef ECORE_XCB_RANDR | ||
935 | RANDR_CHECK_1_2_RET(NULL); | ||
936 | |||
937 | if (output == Ecore_X_Randr_None) return NULL; | ||
938 | |||
939 | if (_randr_version >= RANDR_1_3) | ||
940 | outputs = _ecore_xcb_randr_13_output_clones_get(root, output, num); | ||
941 | else if (_randr_version == RANDR_1_2) | ||
942 | outputs = _ecore_xcb_randr_12_output_clones_get(root, output, num); | ||
943 | #endif | ||
944 | return outputs; | ||
945 | } | ||
946 | |||
947 | EAPI Ecore_X_Randr_Crtc * | ||
948 | ecore_x_randr_output_possible_crtcs_get(Ecore_X_Window root, | ||
949 | Ecore_X_Randr_Output output, | ||
950 | int *num) | ||
951 | { | ||
952 | Ecore_X_Randr_Crtc *crtcs = NULL; | ||
953 | |||
954 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
955 | CHECK_XCB_CONN; | ||
956 | |||
957 | #ifdef ECORE_XCB_RANDR | ||
958 | RANDR_CHECK_1_2_RET(NULL); | ||
959 | |||
960 | if (output == Ecore_X_Randr_None) return NULL; | ||
961 | |||
962 | if (_randr_version >= RANDR_1_3) | ||
963 | crtcs = _ecore_xcb_randr_13_output_possible_crtcs_get(root, output, num); | ||
964 | else if (_randr_version == RANDR_1_2) | ||
965 | crtcs = _ecore_xcb_randr_12_output_possible_crtcs_get(root, output, num); | ||
966 | #endif | ||
967 | return crtcs; | ||
968 | } | ||
969 | |||
970 | /** | ||
971 | * @brief gets the given output's name as reported by X | ||
972 | * @param root the window which's screen will be queried | ||
973 | * @param len length of returned c-string. | ||
974 | * @return name of the output as reported by X | ||
975 | */ | ||
976 | EAPI char * | ||
977 | ecore_x_randr_output_name_get(Ecore_X_Window root, | ||
978 | Ecore_X_Randr_Output output, | ||
979 | int *len) | ||
980 | { | ||
981 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
982 | CHECK_XCB_CONN; | ||
983 | |||
984 | #ifdef ECORE_XCB_RANDR | ||
985 | RANDR_CHECK_1_2_RET(NULL); | ||
986 | |||
987 | if (output == Ecore_X_Randr_None) return NULL; | ||
988 | |||
989 | if (_randr_version >= RANDR_1_3) | ||
990 | return _ecore_xcb_randr_13_output_name_get(root, output, len); | ||
991 | else if (_randr_version == RANDR_1_2) | ||
992 | return _ecore_xcb_randr_12_output_name_get(root, output, len); | ||
993 | #endif | ||
994 | |||
995 | return NULL; | ||
996 | } | ||
997 | |||
998 | EAPI Ecore_X_Randr_Connection_Status | ||
999 | ecore_x_randr_output_connection_status_get(Ecore_X_Window root, | ||
1000 | Ecore_X_Randr_Output output) | ||
1001 | { | ||
1002 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1003 | CHECK_XCB_CONN; | ||
1004 | |||
1005 | #ifdef ECORE_XCB_RANDR | ||
1006 | RANDR_CHECK_1_2_RET(ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN); | ||
1007 | |||
1008 | if (output == Ecore_X_Randr_None) | ||
1009 | return ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN; | ||
1010 | |||
1011 | if (_randr_version >= RANDR_1_3) | ||
1012 | return _ecore_xcb_randr_13_output_connection_status_get(root, output); | ||
1013 | else if (_randr_version == RANDR_1_2) | ||
1014 | return _ecore_xcb_randr_12_output_connection_status_get(root, output); | ||
1015 | #endif | ||
1016 | |||
1017 | return ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN; | ||
1018 | } | ||
1019 | |||
1020 | EAPI Ecore_X_Randr_Output * | ||
1021 | ecore_x_randr_outputs_get(Ecore_X_Window root, | ||
1022 | int *num) | ||
1023 | { | ||
1024 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1025 | CHECK_XCB_CONN; | ||
1026 | |||
1027 | #ifdef ECORE_XCB_RANDR | ||
1028 | RANDR_CHECK_1_2_RET(NULL); | ||
1029 | |||
1030 | if (_randr_version >= RANDR_1_3) | ||
1031 | return _ecore_xcb_randr_13_outputs_get(root, num); | ||
1032 | else if (_randr_version == RANDR_1_2) | ||
1033 | return _ecore_xcb_randr_12_outputs_get(root, num); | ||
1034 | #endif | ||
1035 | |||
1036 | return NULL; | ||
1037 | } | ||
1038 | |||
1039 | EAPI Ecore_X_Randr_Crtc | ||
1040 | ecore_x_randr_output_crtc_get(Ecore_X_Window root, | ||
1041 | Ecore_X_Randr_Output output) | ||
1042 | { | ||
1043 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1044 | CHECK_XCB_CONN; | ||
1045 | |||
1046 | #ifdef ECORE_XCB_RANDR | ||
1047 | RANDR_CHECK_1_2_RET(Ecore_X_Randr_None); | ||
1048 | |||
1049 | if (output == Ecore_X_Randr_None) return Ecore_X_Randr_None; | ||
1050 | |||
1051 | if (_randr_version >= RANDR_1_3) | ||
1052 | return _ecore_xcb_randr_13_output_crtc_get(root, output); | ||
1053 | else if (_randr_version == RANDR_1_2) | ||
1054 | return _ecore_xcb_randr_12_output_crtc_get(root, output); | ||
1055 | #endif | ||
1056 | |||
1057 | return Ecore_X_Randr_None; | ||
1058 | } | ||
1059 | |||
1060 | /** | ||
1061 | * @brief sets the demanded parameters for a given CRTC. Note that the CRTC is | ||
1062 | * auto enabled in it's preferred mode, when it was disabled before. | ||
1063 | * @param root the root window which's default display will be queried | ||
1064 | * @param crtc the CRTC which's configuration should be altered | ||
1065 | * @param outputs an array of outputs, that should display this CRTC's content. | ||
1066 | * @param noutputs number of outputs in the array of outputs. | ||
1067 | * If set to Ecore_X_Randr_Unset, current outputs and number of outputs will be used. | ||
1068 | * If set to Ecore_X_Randr_None, CRTC will be disabled | ||
1069 | * @param x new x coordinate. If <0 (e.g. Ecore_X_Randr_Unset) the current x | ||
1070 | * corrdinate will be assumed. | ||
1071 | * @param y new y coordinate. If <0 (e.g. Ecore_X_Randr_Unset) the current y | ||
1072 | * corrdinate will be assumed. | ||
1073 | * @param mode the new mode to be set. If Ecore_X_Randr_None is passed, the | ||
1074 | * CRTC will be disabled. If Ecore_X_Randr_Unset is passed, the current mode is assumed. | ||
1075 | * @param orientation the new orientation to be set. If Ecore_X_Randr_Unset is used, | ||
1076 | * the current mode is assumed. | ||
1077 | * @return EINA_TRUE if the configuration alteration was successful, else | ||
1078 | * EINA_FALSE | ||
1079 | */ | ||
1080 | EAPI Eina_Bool | ||
1081 | ecore_x_randr_crtc_settings_set(Ecore_X_Window root, | ||
1082 | Ecore_X_Randr_Crtc crtc, | ||
1083 | Ecore_X_Randr_Output *outputs, | ||
1084 | int num, | ||
1085 | int x, | ||
1086 | int y, | ||
1087 | Ecore_X_Randr_Mode mode, | ||
1088 | Ecore_X_Randr_Orientation orientation) | ||
1089 | { | ||
1090 | Eina_Bool ret = EINA_FALSE; | ||
1091 | #ifdef ECORE_XCB_RANDR | ||
1092 | xcb_timestamp_t stamp = 0; | ||
1093 | xcb_randr_get_crtc_info_cookie_t ccookie; | ||
1094 | xcb_randr_get_crtc_info_reply_t *creply; | ||
1095 | #endif | ||
1096 | |||
1097 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1098 | CHECK_XCB_CONN; | ||
1099 | |||
1100 | #ifdef ECORE_XCB_RANDR | ||
1101 | RANDR_CHECK_1_2_RET(EINA_FALSE); | ||
1102 | |||
1103 | if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret; | ||
1104 | |||
1105 | if (_randr_version >= RANDR_1_3) | ||
1106 | stamp = _ecore_xcb_randr_13_get_resource_timestamp(root); | ||
1107 | else if (_randr_version == RANDR_1_2) | ||
1108 | stamp = _ecore_xcb_randr_12_get_resource_timestamp(root); | ||
1109 | |||
1110 | ccookie = | ||
1111 | xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp); | ||
1112 | creply = | ||
1113 | xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ccookie, NULL); | ||
1114 | if (creply) | ||
1115 | { | ||
1116 | xcb_randr_set_crtc_config_cookie_t scookie; | ||
1117 | xcb_randr_set_crtc_config_reply_t *sreply; | ||
1118 | |||
1119 | if ((mode == Ecore_X_Randr_None) || | ||
1120 | (num == Ecore_X_Randr_None)) | ||
1121 | { | ||
1122 | outputs = NULL; | ||
1123 | num = 0; | ||
1124 | } | ||
1125 | else if (num == (int)Ecore_X_Randr_Unset) | ||
1126 | { | ||
1127 | outputs = xcb_randr_get_crtc_info_outputs(creply); | ||
1128 | num = creply->num_outputs; | ||
1129 | } | ||
1130 | if ((int)mode == Ecore_X_Randr_Unset) mode = creply->mode; | ||
1131 | if (x < 0) x = creply->x; | ||
1132 | if (y < 0) y = creply->y; | ||
1133 | if ((int)orientation == Ecore_X_Randr_Unset) | ||
1134 | orientation = creply->rotation; | ||
1135 | |||
1136 | scookie = | ||
1137 | xcb_randr_set_crtc_config_unchecked(_ecore_xcb_conn, | ||
1138 | crtc, XCB_CURRENT_TIME, stamp, | ||
1139 | x, y, mode, orientation, | ||
1140 | num, outputs); | ||
1141 | sreply = | ||
1142 | xcb_randr_set_crtc_config_reply(_ecore_xcb_conn, scookie, NULL); | ||
1143 | if (sreply) | ||
1144 | { | ||
1145 | ret = (sreply->status == XCB_RANDR_SET_CONFIG_SUCCESS) ? | ||
1146 | EINA_TRUE : EINA_FALSE; | ||
1147 | free(sreply); | ||
1148 | } | ||
1149 | free(creply); | ||
1150 | } | ||
1151 | #endif | ||
1152 | |||
1153 | return ret; | ||
1154 | } | ||
1155 | |||
1156 | /** | ||
1157 | * @brief sets a mode for a CRTC and the outputs attached to it | ||
1158 | * @param root the window's screen to be queried | ||
1159 | * @param crtc the CRTC which shall be set | ||
1160 | * @param outputs array of outputs which have to be compatible with the mode. If | ||
1161 | * NULL CRTC will be disabled. | ||
1162 | * @param noutputs number of outputs in array to be used. Use | ||
1163 | * Ecore_X_Randr_Unset (or -1) to use currently used outputs. | ||
1164 | * @param mode XID of the mode to be set. If set to 0 the CRTC will be disabled. | ||
1165 | * If set to -1 the call will fail. | ||
1166 | * @return EINA_TRUE if mode setting was successful. Else EINA_FALSE | ||
1167 | */ | ||
1168 | EAPI Eina_Bool | ||
1169 | ecore_x_randr_crtc_mode_set(Ecore_X_Window root, | ||
1170 | Ecore_X_Randr_Crtc crtc, | ||
1171 | Ecore_X_Randr_Output *outputs, | ||
1172 | int num, | ||
1173 | Ecore_X_Randr_Mode mode) | ||
1174 | { | ||
1175 | Eina_Bool ret = EINA_FALSE; | ||
1176 | |||
1177 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1178 | CHECK_XCB_CONN; | ||
1179 | |||
1180 | #ifdef ECORE_XCB_RANDR | ||
1181 | RANDR_CHECK_1_2_RET(EINA_FALSE); | ||
1182 | |||
1183 | if ((int)mode == Ecore_X_Randr_Unset) return ret; | ||
1184 | ret = | ||
1185 | ecore_x_randr_crtc_settings_set(root, crtc, outputs, num, | ||
1186 | Ecore_X_Randr_Unset, Ecore_X_Randr_Unset, | ||
1187 | mode, Ecore_X_Randr_Unset); | ||
1188 | #endif | ||
1189 | |||
1190 | return ret; | ||
1191 | } | ||
1192 | |||
1193 | /** | ||
1194 | * @brief Get the current set mode of a given CRTC | ||
1195 | * @param root the window's screen to be queried | ||
1196 | * @param crtc the CRTC which's should be queried | ||
1197 | * @return currently set mode or - in case parameters are invalid - | ||
1198 | * Ecore_X_Randr_Unset | ||
1199 | */ | ||
1200 | EAPI Ecore_X_Randr_Mode | ||
1201 | ecore_x_randr_crtc_mode_get(Ecore_X_Window root, | ||
1202 | Ecore_X_Randr_Crtc crtc) | ||
1203 | { | ||
1204 | Ecore_X_Randr_Mode ret = Ecore_X_Randr_Unset; | ||
1205 | #ifdef ECORE_XCB_RANDR | ||
1206 | xcb_timestamp_t stamp = 0; | ||
1207 | xcb_randr_get_crtc_info_cookie_t ocookie; | ||
1208 | xcb_randr_get_crtc_info_reply_t *oreply; | ||
1209 | #endif | ||
1210 | |||
1211 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1212 | CHECK_XCB_CONN; | ||
1213 | |||
1214 | #ifdef ECORE_XCB_RANDR | ||
1215 | RANDR_CHECK_1_2_RET(Ecore_X_Randr_Unset); | ||
1216 | |||
1217 | if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret; | ||
1218 | |||
1219 | if (_randr_version >= RANDR_1_3) | ||
1220 | stamp = _ecore_xcb_randr_13_get_resource_timestamp(root); | ||
1221 | else if (_randr_version == RANDR_1_2) | ||
1222 | stamp = _ecore_xcb_randr_12_get_resource_timestamp(root); | ||
1223 | |||
1224 | ocookie = | ||
1225 | xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp); | ||
1226 | oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL); | ||
1227 | if (oreply) | ||
1228 | { | ||
1229 | ret = oreply->mode; | ||
1230 | free(oreply); | ||
1231 | } | ||
1232 | #endif | ||
1233 | |||
1234 | return ret; | ||
1235 | } | ||
1236 | |||
1237 | EAPI Ecore_X_Randr_Orientation | ||
1238 | ecore_x_randr_crtc_orientation_get(Ecore_X_Window root, | ||
1239 | Ecore_X_Randr_Crtc crtc) | ||
1240 | { | ||
1241 | Ecore_X_Randr_Orientation ret = Ecore_X_Randr_None; | ||
1242 | #ifdef ECORE_XCB_RANDR | ||
1243 | xcb_timestamp_t stamp = 0; | ||
1244 | xcb_randr_get_crtc_info_cookie_t ocookie; | ||
1245 | xcb_randr_get_crtc_info_reply_t *oreply; | ||
1246 | #endif | ||
1247 | |||
1248 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1249 | CHECK_XCB_CONN; | ||
1250 | |||
1251 | #ifdef ECORE_XCB_RANDR | ||
1252 | RANDR_CHECK_1_2_RET(Ecore_X_Randr_None); | ||
1253 | |||
1254 | if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret; | ||
1255 | |||
1256 | if (_randr_version >= RANDR_1_3) | ||
1257 | stamp = _ecore_xcb_randr_13_get_resource_timestamp(root); | ||
1258 | else if (_randr_version == RANDR_1_2) | ||
1259 | stamp = _ecore_xcb_randr_12_get_resource_timestamp(root); | ||
1260 | |||
1261 | ocookie = | ||
1262 | xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp); | ||
1263 | oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL); | ||
1264 | if (oreply) | ||
1265 | { | ||
1266 | ret = oreply->rotation; | ||
1267 | free(oreply); | ||
1268 | } | ||
1269 | #endif | ||
1270 | |||
1271 | return ret; | ||
1272 | } | ||
1273 | |||
1274 | EAPI Eina_Bool | ||
1275 | ecore_x_randr_crtc_orientation_set(Ecore_X_Window root, | ||
1276 | Ecore_X_Randr_Crtc crtc, | ||
1277 | Ecore_X_Randr_Orientation orientation) | ||
1278 | { | ||
1279 | Eina_Bool ret = EINA_FALSE; | ||
1280 | |||
1281 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1282 | CHECK_XCB_CONN; | ||
1283 | |||
1284 | #ifdef ECORE_XCB_RANDR | ||
1285 | RANDR_CHECK_1_2_RET(EINA_FALSE); | ||
1286 | |||
1287 | if (orientation != Ecore_X_Randr_None) | ||
1288 | { | ||
1289 | ret = | ||
1290 | ecore_x_randr_crtc_settings_set(root, crtc, NULL, | ||
1291 | Ecore_X_Randr_Unset, Ecore_X_Randr_Unset, | ||
1292 | Ecore_X_Randr_Unset, Ecore_X_Randr_Unset, | ||
1293 | orientation); | ||
1294 | } | ||
1295 | #endif | ||
1296 | return ret; | ||
1297 | } | ||
1298 | |||
1299 | EAPI Ecore_X_Randr_Orientation | ||
1300 | ecore_x_randr_crtc_orientations_get(Ecore_X_Window root, | ||
1301 | Ecore_X_Randr_Crtc crtc) | ||
1302 | { | ||
1303 | Ecore_X_Randr_Orientation ret = Ecore_X_Randr_None; | ||
1304 | #ifdef ECORE_XCB_RANDR | ||
1305 | xcb_timestamp_t stamp = 0; | ||
1306 | xcb_randr_get_crtc_info_cookie_t ocookie; | ||
1307 | xcb_randr_get_crtc_info_reply_t *oreply; | ||
1308 | #endif | ||
1309 | |||
1310 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1311 | CHECK_XCB_CONN; | ||
1312 | |||
1313 | #ifdef ECORE_XCB_RANDR | ||
1314 | RANDR_CHECK_1_2_RET(Ecore_X_Randr_None); | ||
1315 | |||
1316 | if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret; | ||
1317 | |||
1318 | if (_randr_version >= RANDR_1_3) | ||
1319 | stamp = _ecore_xcb_randr_13_get_resource_timestamp(root); | ||
1320 | else if (_randr_version == RANDR_1_2) | ||
1321 | stamp = _ecore_xcb_randr_12_get_resource_timestamp(root); | ||
1322 | |||
1323 | ocookie = | ||
1324 | xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp); | ||
1325 | oreply = | ||
1326 | xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL); | ||
1327 | if (oreply) | ||
1328 | { | ||
1329 | ret = oreply->rotations; | ||
1330 | free(oreply); | ||
1331 | } | ||
1332 | #endif | ||
1333 | |||
1334 | return ret; | ||
1335 | } | ||
1336 | |||
1337 | /* | ||
1338 | * @brief get a CRTC's possible outputs. | ||
1339 | * @param root the root window which's screen will be queried | ||
1340 | * @param num number of possible outputs referenced by given CRTC | ||
1341 | */ | ||
1342 | EAPI Ecore_X_Randr_Output * | ||
1343 | ecore_x_randr_crtc_possible_outputs_get(Ecore_X_Window root, | ||
1344 | Ecore_X_Randr_Crtc crtc, | ||
1345 | int *num) | ||
1346 | { | ||
1347 | Ecore_X_Randr_Output *ret = NULL; | ||
1348 | #ifdef ECORE_XCB_RANDR | ||
1349 | xcb_timestamp_t stamp = 0; | ||
1350 | xcb_randr_get_crtc_info_cookie_t ocookie; | ||
1351 | xcb_randr_get_crtc_info_reply_t *oreply; | ||
1352 | #endif | ||
1353 | |||
1354 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1355 | CHECK_XCB_CONN; | ||
1356 | |||
1357 | #ifdef ECORE_XCB_RANDR | ||
1358 | RANDR_CHECK_1_2_RET(NULL); | ||
1359 | |||
1360 | if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret; | ||
1361 | |||
1362 | if (_randr_version >= RANDR_1_3) | ||
1363 | stamp = _ecore_xcb_randr_13_get_resource_timestamp(root); | ||
1364 | else if (_randr_version == RANDR_1_2) | ||
1365 | stamp = _ecore_xcb_randr_12_get_resource_timestamp(root); | ||
1366 | |||
1367 | ocookie = | ||
1368 | xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp); | ||
1369 | oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL); | ||
1370 | if (oreply) | ||
1371 | { | ||
1372 | if (num) *num = oreply->num_possible_outputs; | ||
1373 | ret = malloc(sizeof(Ecore_X_Randr_Output) * | ||
1374 | oreply->num_possible_outputs); | ||
1375 | if (ret) | ||
1376 | { | ||
1377 | memcpy(ret, xcb_randr_get_crtc_info_possible(oreply), | ||
1378 | sizeof(Ecore_X_Randr_Output) * | ||
1379 | oreply->num_possible_outputs); | ||
1380 | } | ||
1381 | free(oreply); | ||
1382 | } | ||
1383 | #endif | ||
1384 | |||
1385 | return ret; | ||
1386 | } | ||
1387 | |||
1388 | /* | ||
1389 | * @brief get all known CRTCs related to a root window's screen | ||
1390 | * @param root window which's screen's ressources are queried | ||
1391 | * @param num number of CRTCs returned | ||
1392 | * @return CRTC IDs | ||
1393 | */ | ||
1394 | EAPI Ecore_X_Randr_Crtc * | ||
1395 | ecore_x_randr_crtcs_get(Ecore_X_Window root, | ||
1396 | int *num) | ||
1397 | { | ||
1398 | Ecore_X_Randr_Crtc *ret = NULL; | ||
1399 | |||
1400 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1401 | CHECK_XCB_CONN; | ||
1402 | |||
1403 | #ifdef ECORE_XCB_RANDR | ||
1404 | RANDR_CHECK_1_2_RET(NULL); | ||
1405 | |||
1406 | if (_randr_version >= RANDR_1_3) | ||
1407 | { | ||
1408 | xcb_randr_get_screen_resources_current_reply_t *reply; | ||
1409 | |||
1410 | reply = _ecore_xcb_randr_13_get_resources(root); | ||
1411 | if (reply) | ||
1412 | { | ||
1413 | if (num) *num = reply->num_crtcs; | ||
1414 | ret = malloc(sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs); | ||
1415 | if (ret) | ||
1416 | memcpy(ret, xcb_randr_get_screen_resources_current_crtcs(reply), | ||
1417 | sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs); | ||
1418 | free(reply); | ||
1419 | } | ||
1420 | } | ||
1421 | else if (_randr_version == RANDR_1_2) | ||
1422 | { | ||
1423 | xcb_randr_get_screen_resources_reply_t *reply; | ||
1424 | |||
1425 | reply = _ecore_xcb_randr_12_get_resources(root); | ||
1426 | if (reply) | ||
1427 | { | ||
1428 | if (num) *num = reply->num_crtcs; | ||
1429 | ret = malloc(sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs); | ||
1430 | if (ret) | ||
1431 | memcpy(ret, xcb_randr_get_screen_resources_crtcs(reply), | ||
1432 | sizeof(Ecore_X_Randr_Crtc) * reply->num_crtcs); | ||
1433 | free(reply); | ||
1434 | } | ||
1435 | } | ||
1436 | #endif | ||
1437 | |||
1438 | return ret; | ||
1439 | } | ||
1440 | |||
1441 | /* | ||
1442 | * @brief get a CRTC's outputs. | ||
1443 | * @param root the root window which's screen will be queried | ||
1444 | * @param num number of outputs referenced by given CRTC | ||
1445 | */ | ||
1446 | EAPI Ecore_X_Randr_Output * | ||
1447 | ecore_x_randr_crtc_outputs_get(Ecore_X_Window root, | ||
1448 | Ecore_X_Randr_Crtc crtc, | ||
1449 | int *num) | ||
1450 | { | ||
1451 | Ecore_X_Randr_Output *ret = NULL; | ||
1452 | #ifdef ECORE_XCB_RANDR | ||
1453 | xcb_timestamp_t stamp = 0; | ||
1454 | xcb_randr_get_crtc_info_cookie_t ocookie; | ||
1455 | xcb_randr_get_crtc_info_reply_t *oreply; | ||
1456 | #endif | ||
1457 | |||
1458 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1459 | CHECK_XCB_CONN; | ||
1460 | |||
1461 | #ifdef ECORE_XCB_RANDR | ||
1462 | RANDR_CHECK_1_2_RET(NULL); | ||
1463 | |||
1464 | if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return ret; | ||
1465 | |||
1466 | if (_randr_version >= RANDR_1_3) | ||
1467 | stamp = _ecore_xcb_randr_13_get_resource_timestamp(root); | ||
1468 | else if (_randr_version == RANDR_1_2) | ||
1469 | stamp = _ecore_xcb_randr_12_get_resource_timestamp(root); | ||
1470 | |||
1471 | ocookie = | ||
1472 | xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp); | ||
1473 | oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL); | ||
1474 | if (oreply) | ||
1475 | { | ||
1476 | if (num) *num = oreply->num_outputs; | ||
1477 | ret = malloc(sizeof(Ecore_X_Randr_Output) * oreply->num_outputs); | ||
1478 | if (ret) | ||
1479 | memcpy(ret, xcb_randr_get_crtc_info_outputs(oreply), | ||
1480 | sizeof(Ecore_X_Randr_Output) * oreply->num_outputs); | ||
1481 | free(oreply); | ||
1482 | } | ||
1483 | #endif | ||
1484 | |||
1485 | return ret; | ||
1486 | } | ||
1487 | |||
1488 | EAPI void | ||
1489 | ecore_x_randr_crtc_geometry_get(Ecore_X_Window root, | ||
1490 | Ecore_X_Randr_Crtc crtc, | ||
1491 | int *x, | ||
1492 | int *y, | ||
1493 | int *w, | ||
1494 | int *h) | ||
1495 | { | ||
1496 | #ifdef ECORE_XCB_RANDR | ||
1497 | xcb_timestamp_t stamp = 0; | ||
1498 | xcb_randr_get_crtc_info_cookie_t ocookie; | ||
1499 | xcb_randr_get_crtc_info_reply_t *oreply; | ||
1500 | #endif | ||
1501 | |||
1502 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1503 | CHECK_XCB_CONN; | ||
1504 | |||
1505 | #ifdef ECORE_XCB_RANDR | ||
1506 | RANDR_CHECK_1_2_RET(); | ||
1507 | |||
1508 | if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return; | ||
1509 | |||
1510 | if (_randr_version >= RANDR_1_3) | ||
1511 | stamp = _ecore_xcb_randr_13_get_resource_timestamp(root); | ||
1512 | else if (_randr_version == RANDR_1_2) | ||
1513 | stamp = _ecore_xcb_randr_12_get_resource_timestamp(root); | ||
1514 | |||
1515 | ocookie = | ||
1516 | xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtc, stamp); | ||
1517 | oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, ocookie, NULL); | ||
1518 | if (oreply) | ||
1519 | { | ||
1520 | if (x) *x = oreply->x; | ||
1521 | if (y) *y = oreply->y; | ||
1522 | if (w) *w = oreply->width; | ||
1523 | if (h) *h = oreply->height; | ||
1524 | free(oreply); | ||
1525 | } | ||
1526 | #endif | ||
1527 | } | ||
1528 | |||
1529 | /** | ||
1530 | * @brief sets a CRTC relative to another one. | ||
1531 | * @param crtc_r1 the CRTC to be positioned. | ||
1532 | * @param crtc_r2 the CRTC the position should be relative to | ||
1533 | * @param position the relation between the crtcs | ||
1534 | * @param alignment in case CRTCs size differ, aligns CRTC1 accordingly at CRTC2's | ||
1535 | * borders | ||
1536 | * @return EINA_TRUE if crtc could be successfully positioned. EINA_FALSE if | ||
1537 | * repositioning failed or if position of new crtc would be out of given screen's min/max bounds. | ||
1538 | */ | ||
1539 | EAPI Eina_Bool | ||
1540 | ecore_x_randr_crtc_pos_relative_set(Ecore_X_Window root, | ||
1541 | Ecore_X_Randr_Crtc crtc1, | ||
1542 | Ecore_X_Randr_Crtc crtc2, | ||
1543 | Ecore_X_Randr_Output_Policy policy, | ||
1544 | Ecore_X_Randr_Relative_Alignment alignment) | ||
1545 | { | ||
1546 | #ifdef ECORE_XCB_RANDR | ||
1547 | Eina_Rectangle r1, r2; | ||
1548 | int w_max = 0, h_max = 0, cw = 0, ch = 0, xn = -1, yn = -1; | ||
1549 | #endif | ||
1550 | |||
1551 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1552 | CHECK_XCB_CONN; | ||
1553 | |||
1554 | #ifdef ECORE_XCB_RANDR | ||
1555 | RANDR_CHECK_1_2_RET(EINA_FALSE); | ||
1556 | |||
1557 | if ((ecore_x_randr_crtc_mode_get(root, crtc1) == 0) || | ||
1558 | (ecore_x_randr_crtc_mode_get(root, crtc2) == 0)) | ||
1559 | return EINA_FALSE; | ||
1560 | |||
1561 | if ((!_ecore_xcb_randr_crtc_validate(root, crtc1) || | ||
1562 | (!(crtc1 != crtc2) && (!_ecore_xcb_randr_crtc_validate(root, crtc2))))) | ||
1563 | return EINA_FALSE; | ||
1564 | |||
1565 | ecore_x_randr_crtc_geometry_get(root, crtc1, &r1.x, &r1.y, &r1.w, &r1.h); | ||
1566 | ecore_x_randr_crtc_geometry_get(root, crtc2, &r2.x, &r2.y, &r2.w, &r2.h); | ||
1567 | ecore_x_randr_screen_size_range_get(root, NULL, NULL, &w_max, &h_max); | ||
1568 | ecore_x_randr_screen_current_size_get(root, &cw, &ch, NULL, NULL); | ||
1569 | |||
1570 | switch (policy) | ||
1571 | { | ||
1572 | case ECORE_X_RANDR_OUTPUT_POLICY_RIGHT: | ||
1573 | xn = (r2.x + r2.w); | ||
1574 | if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE) | ||
1575 | yn = -1; | ||
1576 | else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL) | ||
1577 | yn = ((int)(((double)r2.h / 2.0) + (double)r2.y - ((double)r1.h / 2.0))); | ||
1578 | else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR) | ||
1579 | yn = ((int)((double)ch / 2.0) - ((double)r1.h / 2.0)); | ||
1580 | break; | ||
1581 | |||
1582 | case ECORE_X_RANDR_OUTPUT_POLICY_LEFT: | ||
1583 | xn = (r2.x - r1.w); | ||
1584 | if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE) | ||
1585 | yn = -1; | ||
1586 | else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL) | ||
1587 | yn = ((int)(((double)r2.h / 2.0) + (double)r2.y - ((double)r1.h / 2.0))); | ||
1588 | else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR) | ||
1589 | yn = ((int)((double)ch / 2.0) - ((double)r1.h / 2.0)); | ||
1590 | break; | ||
1591 | |||
1592 | case ECORE_X_RANDR_OUTPUT_POLICY_BELOW: | ||
1593 | yn = (r2.y + r2.h); | ||
1594 | if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE) | ||
1595 | xn = -1; | ||
1596 | else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL) | ||
1597 | xn = ((int)((((double)r2.x + (double)r2.w) / 2.0) - ((double)r1.w / 2.0))); | ||
1598 | else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR) | ||
1599 | xn = ((int)((double)cw / 2.0)); | ||
1600 | break; | ||
1601 | |||
1602 | case ECORE_X_RANDR_OUTPUT_POLICY_ABOVE: | ||
1603 | yn = (r2.y - r1.h); | ||
1604 | if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_NONE) | ||
1605 | xn = -1; | ||
1606 | else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_REL) | ||
1607 | xn = ((int)((((double)r2.x + (double)r2.w) / 2.0) - ((double)r1.w / 2.0))); | ||
1608 | else if (alignment == ECORE_X_RANDR_RELATIVE_ALIGNMENT_CENTER_SCR) | ||
1609 | xn = ((int)((double)cw / 2.0)); | ||
1610 | break; | ||
1611 | |||
1612 | case ECORE_X_RANDR_OUTPUT_POLICY_CLONE: | ||
1613 | return ecore_x_randr_crtc_pos_set(root, crtc1, r2.x, r2.y); | ||
1614 | break; | ||
1615 | |||
1616 | case ECORE_X_RANDR_OUTPUT_POLICY_NONE: | ||
1617 | break; | ||
1618 | } | ||
1619 | |||
1620 | if ((xn == r1.x) && (yn == r1.x)) return EINA_TRUE; | ||
1621 | if (((yn + r1.h) > h_max) || ((xn + r1.w) > w_max)) | ||
1622 | return EINA_FALSE; | ||
1623 | |||
1624 | return ecore_x_randr_crtc_pos_set(root, crtc1, xn, yn); | ||
1625 | #endif | ||
1626 | |||
1627 | return EINA_FALSE; | ||
1628 | } | ||
1629 | |||
1630 | EAPI Eina_Bool | ||
1631 | ecore_x_randr_move_all_crtcs_but(Ecore_X_Window root, | ||
1632 | const Ecore_X_Randr_Crtc *not_moved, | ||
1633 | int num, | ||
1634 | int dx, | ||
1635 | int dy) | ||
1636 | { | ||
1637 | Eina_Bool ret = EINA_FALSE; | ||
1638 | #ifdef ECORE_XCB_RANDR | ||
1639 | Ecore_X_Randr_Crtc *crtcs = NULL, *move = NULL; | ||
1640 | int i = 0, j = 0, k = 0, n = 0, total = 0; | ||
1641 | #endif | ||
1642 | |||
1643 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1644 | CHECK_XCB_CONN; | ||
1645 | |||
1646 | #ifdef ECORE_XCB_RANDR | ||
1647 | if ((num <= 0) || (!not_moved) || (!_ecore_xcb_randr_root_validate(root))) | ||
1648 | return EINA_FALSE; | ||
1649 | |||
1650 | crtcs = ecore_x_randr_crtcs_get(root, &total); | ||
1651 | n = (total - num); | ||
1652 | move = malloc(sizeof(Ecore_X_Randr_Crtc) * n); | ||
1653 | if (move) | ||
1654 | { | ||
1655 | for (i = 0, k = 0; (i < total) && (k < n); i++) | ||
1656 | { | ||
1657 | for (j = 0; j < num; j++) | ||
1658 | if (crtcs[i] == not_moved[j]) break; | ||
1659 | if (j == num) | ||
1660 | move[k++] = crtcs[i]; | ||
1661 | } | ||
1662 | ret = ecore_x_randr_move_crtcs(root, move, n, dx, dy); | ||
1663 | free(move); | ||
1664 | free(crtcs); | ||
1665 | } | ||
1666 | #endif | ||
1667 | |||
1668 | return ret; | ||
1669 | } | ||
1670 | |||
1671 | EAPI void | ||
1672 | ecore_x_randr_crtc_pos_get(Ecore_X_Window root, | ||
1673 | Ecore_X_Randr_Crtc crtc, | ||
1674 | int *x, | ||
1675 | int *y) | ||
1676 | { | ||
1677 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1678 | CHECK_XCB_CONN; | ||
1679 | |||
1680 | #ifdef ECORE_XCB_RANDR | ||
1681 | RANDR_CHECK_1_2_RET(); | ||
1682 | |||
1683 | ecore_x_randr_crtc_geometry_get(root, crtc, x, y, NULL, NULL); | ||
1684 | #endif | ||
1685 | } | ||
1686 | |||
1687 | /* | ||
1688 | * @brief sets the position of given CRTC within root window's screen | ||
1689 | * @param root the window's screen to be queried | ||
1690 | * @param crtc the CRTC which's position within the mentioned screen is to be altered | ||
1691 | * @param x position on the x-axis (0 == left) of the screen. if x < 0 current value will be kept. | ||
1692 | * @param y position on the y-ayis (0 == top) of the screen. if y < 0, current value will be kept. | ||
1693 | * @return EINA_TRUE if position could be successfully be altered. | ||
1694 | */ | ||
1695 | EAPI Eina_Bool | ||
1696 | ecore_x_randr_crtc_pos_set(Ecore_X_Window root, | ||
1697 | Ecore_X_Randr_Crtc crtc, | ||
1698 | int x, | ||
1699 | int y) | ||
1700 | { | ||
1701 | Eina_Bool ret = EINA_FALSE; | ||
1702 | #ifdef ECORE_XCB_RANDR | ||
1703 | int w = 0, h = 0, nw = 0, nh = 0; | ||
1704 | Eina_Rectangle rect; | ||
1705 | #endif | ||
1706 | |||
1707 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1708 | CHECK_XCB_CONN; | ||
1709 | |||
1710 | #ifdef ECORE_XCB_RANDR | ||
1711 | RANDR_CHECK_1_2_RET(EINA_FALSE); | ||
1712 | |||
1713 | ecore_x_randr_crtc_geometry_get(root, crtc, | ||
1714 | &rect.x, &rect.y, &rect.w, &rect.h); | ||
1715 | ecore_x_randr_screen_current_size_get(root, &w, &h, NULL, NULL); | ||
1716 | if (x < 0) x = rect.x; | ||
1717 | if (y < 0) y = rect.y; | ||
1718 | if ((x + rect.w) > w) | ||
1719 | nw = (x + rect.w); | ||
1720 | if ((y + rect.h) > h) | ||
1721 | nh = (y + rect.h); | ||
1722 | |||
1723 | if ((nw != 0) || (nh != 0)) | ||
1724 | { | ||
1725 | if (!ecore_x_randr_screen_current_size_set(root, nw, nh, 0, 0)) | ||
1726 | return EINA_FALSE; | ||
1727 | } | ||
1728 | |||
1729 | ret = ecore_x_randr_crtc_settings_set(root, crtc, NULL, -1, x, y, -1, -1); | ||
1730 | #endif | ||
1731 | |||
1732 | return ret; | ||
1733 | } | ||
1734 | |||
1735 | EAPI void | ||
1736 | ecore_x_randr_crtc_size_get(Ecore_X_Window root, | ||
1737 | Ecore_X_Randr_Crtc crtc, | ||
1738 | int *w, | ||
1739 | int *h) | ||
1740 | { | ||
1741 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1742 | CHECK_XCB_CONN; | ||
1743 | |||
1744 | #ifdef ECORE_XCB_RANDR | ||
1745 | RANDR_CHECK_1_2_RET(); | ||
1746 | ecore_x_randr_crtc_geometry_get(root, crtc, NULL, NULL, w, h); | ||
1747 | #endif | ||
1748 | } | ||
1749 | |||
1750 | EAPI Ecore_X_Randr_Refresh_Rate | ||
1751 | ecore_x_randr_crtc_refresh_rate_get(Ecore_X_Window root, | ||
1752 | Ecore_X_Randr_Crtc crtc, | ||
1753 | Ecore_X_Randr_Mode mode) | ||
1754 | { | ||
1755 | Ecore_X_Randr_Refresh_Rate ret = 0.0; | ||
1756 | |||
1757 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1758 | CHECK_XCB_CONN; | ||
1759 | |||
1760 | #ifdef ECORE_XCB_RANDR | ||
1761 | RANDR_CHECK_1_2_RET(0.0); | ||
1762 | |||
1763 | if (!_ecore_xcb_randr_crtc_validate(root, crtc)) return 0.0; | ||
1764 | |||
1765 | if (_randr_version >= RANDR_1_3) | ||
1766 | { | ||
1767 | xcb_randr_get_screen_resources_current_reply_t *reply; | ||
1768 | |||
1769 | reply = _ecore_xcb_randr_13_get_resources(root); | ||
1770 | if (reply) | ||
1771 | { | ||
1772 | xcb_randr_mode_info_iterator_t miter; | ||
1773 | |||
1774 | miter = | ||
1775 | xcb_randr_get_screen_resources_current_modes_iterator(reply); | ||
1776 | while (miter.rem) | ||
1777 | { | ||
1778 | xcb_randr_mode_info_t *minfo; | ||
1779 | |||
1780 | minfo = miter.data; | ||
1781 | if (minfo->id == mode) | ||
1782 | { | ||
1783 | if ((minfo->htotal) && (minfo->vtotal)) | ||
1784 | { | ||
1785 | ret = ((double)minfo->dot_clock / | ||
1786 | ((double)minfo->htotal * | ||
1787 | (double)minfo->vtotal)); | ||
1788 | } | ||
1789 | break; | ||
1790 | } | ||
1791 | xcb_randr_mode_info_next(&miter); | ||
1792 | } | ||
1793 | free(reply); | ||
1794 | } | ||
1795 | } | ||
1796 | else if (_randr_version == RANDR_1_2) | ||
1797 | { | ||
1798 | xcb_randr_get_screen_resources_reply_t *reply; | ||
1799 | |||
1800 | reply = _ecore_xcb_randr_12_get_resources(root); | ||
1801 | if (reply) | ||
1802 | { | ||
1803 | xcb_randr_mode_info_iterator_t miter; | ||
1804 | |||
1805 | miter = xcb_randr_get_screen_resources_modes_iterator(reply); | ||
1806 | while (miter.rem) | ||
1807 | { | ||
1808 | xcb_randr_mode_info_t *minfo; | ||
1809 | |||
1810 | minfo = miter.data; | ||
1811 | if (minfo->id == mode) | ||
1812 | { | ||
1813 | if ((minfo->htotal) && (minfo->vtotal)) | ||
1814 | { | ||
1815 | ret = ((double)minfo->dot_clock / | ||
1816 | ((double)minfo->htotal * | ||
1817 | (double)minfo->vtotal)); | ||
1818 | } | ||
1819 | break; | ||
1820 | } | ||
1821 | xcb_randr_mode_info_next(&miter); | ||
1822 | } | ||
1823 | free(reply); | ||
1824 | } | ||
1825 | } | ||
1826 | #endif | ||
1827 | return ret; | ||
1828 | } | ||
1829 | |||
1830 | /* | ||
1831 | * @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. | ||
1832 | * @param root window which's screen's resources are used | ||
1833 | * @param crtcs list of CRTCs to be moved | ||
1834 | * @param ncrtc number of CRTCs in array | ||
1835 | * @param dx amount of pixels the CRTCs should be moved in x direction | ||
1836 | * @param dy amount of pixels the CRTCs should be moved in y direction | ||
1837 | * @return EINA_TRUE if all crtcs could be moved successfully. | ||
1838 | */ | ||
1839 | EAPI Eina_Bool | ||
1840 | ecore_x_randr_move_crtcs(Ecore_X_Window root, | ||
1841 | const Ecore_X_Randr_Crtc *crtcs, | ||
1842 | int num, | ||
1843 | int dx, | ||
1844 | int dy) | ||
1845 | { | ||
1846 | Eina_Bool ret = EINA_TRUE; | ||
1847 | #ifdef ECORE_XCB_RANDR | ||
1848 | xcb_timestamp_t stamp = 0; | ||
1849 | xcb_randr_get_crtc_info_reply_t *oreply[num]; | ||
1850 | int i = 0, cw = 0, ch = 0; | ||
1851 | int mw = 0, mh = 0, nw = 0, nh = 0; | ||
1852 | #endif | ||
1853 | |||
1854 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1855 | CHECK_XCB_CONN; | ||
1856 | |||
1857 | #ifdef ECORE_XCB_RANDR | ||
1858 | RANDR_CHECK_1_2_RET(EINA_FALSE); | ||
1859 | |||
1860 | if (!_ecore_xcb_randr_root_validate(root)) return EINA_FALSE; | ||
1861 | |||
1862 | if (_randr_version >= RANDR_1_3) | ||
1863 | stamp = _ecore_xcb_randr_13_get_resource_timestamp(root); | ||
1864 | else if (_randr_version == RANDR_1_2) | ||
1865 | stamp = _ecore_xcb_randr_12_get_resource_timestamp(root); | ||
1866 | |||
1867 | ecore_x_randr_screen_size_range_get(root, NULL, NULL, &mw, &mh); | ||
1868 | ecore_x_randr_screen_current_size_get(root, &cw, &ch, NULL, NULL); | ||
1869 | nw = cw; | ||
1870 | nh = ch; | ||
1871 | |||
1872 | for (i = 0; i < num; i++) | ||
1873 | { | ||
1874 | xcb_randr_get_crtc_info_cookie_t ocookie; | ||
1875 | |||
1876 | ocookie = | ||
1877 | xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtcs[i], | ||
1878 | stamp); | ||
1879 | oreply[i] = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, | ||
1880 | ocookie, NULL); | ||
1881 | if (oreply[i]) | ||
1882 | { | ||
1883 | if (((oreply[i]->x + dx) < 0) || | ||
1884 | ((oreply[i]->y + dy) < 0) || | ||
1885 | ((oreply[i]->x + oreply[i]->width + dx) > mw) || | ||
1886 | ((oreply[i]->y + oreply[i]->height + dy) > mh)) | ||
1887 | { | ||
1888 | continue; | ||
1889 | } | ||
1890 | nw = MAX((int)(oreply[i]->x + oreply[i]->width + dx), nw); | ||
1891 | nh = MAX((int)(oreply[i]->y + oreply[i]->height + dy), nh); | ||
1892 | } | ||
1893 | } | ||
1894 | |||
1895 | if ((nw > cw) || (nh > ch)) | ||
1896 | { | ||
1897 | if (!ecore_x_randr_screen_current_size_set(root, nw, nh, -1, -1)) | ||
1898 | { | ||
1899 | for (i = 0; i < num; i++) | ||
1900 | if (oreply[i]) free(oreply[i]); | ||
1901 | |||
1902 | return EINA_FALSE; | ||
1903 | } | ||
1904 | } | ||
1905 | |||
1906 | for (i = 0; ((i < num) && (oreply[i])); i++) | ||
1907 | { | ||
1908 | if (!oreply[i]) continue; | ||
1909 | if (!ecore_x_randr_crtc_settings_set(root, crtcs[i], NULL, -1, | ||
1910 | (oreply[i]->x + dx), | ||
1911 | (oreply[i]->y + dy), | ||
1912 | oreply[i]->mode, | ||
1913 | oreply[i]->rotation)) | ||
1914 | { | ||
1915 | ret = EINA_FALSE; | ||
1916 | break; | ||
1917 | } | ||
1918 | } | ||
1919 | |||
1920 | if (i < num) | ||
1921 | { | ||
1922 | while (i-- >= 0) | ||
1923 | { | ||
1924 | if (oreply[i]) | ||
1925 | ecore_x_randr_crtc_settings_set(root, crtcs[i], NULL, -1, | ||
1926 | (oreply[i]->x - dx), | ||
1927 | (oreply[i]->y - dy), | ||
1928 | oreply[i]->mode, | ||
1929 | oreply[i]->rotation); | ||
1930 | } | ||
1931 | } | ||
1932 | |||
1933 | for (i = 0; i < num; i++) | ||
1934 | if (oreply[i]) free(oreply[i]); | ||
1935 | #endif | ||
1936 | |||
1937 | return ret; | ||
1938 | } | ||
1939 | |||
1940 | /** | ||
1941 | * @brief enable event selection. This enables basic interaction with | ||
1942 | * output/crtc events and requires RRandR >= 1.2. | ||
1943 | * @param win select this window's properties for RandRR events | ||
1944 | * @param on enable/disable selecting | ||
1945 | */ | ||
1946 | EAPI void | ||
1947 | ecore_x_randr_events_select(Ecore_X_Window win, | ||
1948 | Eina_Bool on) | ||
1949 | { | ||
1950 | #ifdef ECORE_XCB_RANDR | ||
1951 | uint16_t mask = 0; | ||
1952 | #endif | ||
1953 | |||
1954 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1955 | CHECK_XCB_CONN; | ||
1956 | |||
1957 | #ifdef ECORE_XCB_RANDR | ||
1958 | if (on) | ||
1959 | { | ||
1960 | mask = XCB_RANDR_NOTIFY_MASK_SCREEN_CHANGE; | ||
1961 | if (_randr_version >= ((1 << 16) | 2)) | ||
1962 | { | ||
1963 | mask |= (XCB_RANDR_NOTIFY_MASK_CRTC_CHANGE | | ||
1964 | XCB_RANDR_NOTIFY_MASK_OUTPUT_CHANGE | | ||
1965 | XCB_RANDR_NOTIFY_MASK_OUTPUT_PROPERTY); | ||
1966 | } | ||
1967 | } | ||
1968 | |||
1969 | xcb_randr_select_input(_ecore_xcb_conn, win, mask); | ||
1970 | #endif | ||
1971 | } | ||
1972 | |||
1973 | /** | ||
1974 | * @brief removes unused screen space. The most upper left CRTC is set to 0x0 | ||
1975 | * and all other CRTCs dx,dy respectively. | ||
1976 | * @param root the window's screen which will be reset. | ||
1977 | */ | ||
1978 | EAPI void | ||
1979 | ecore_x_randr_screen_reset(Ecore_X_Window root) | ||
1980 | { | ||
1981 | #ifdef ECORE_XCB_RANDR | ||
1982 | xcb_timestamp_t stamp = 0; | ||
1983 | Ecore_X_Randr_Crtc *crtcs = NULL; | ||
1984 | int total = 0, i = 0, w = 0, h = 0; | ||
1985 | int dx = 100000, dy = 100000, num = 0; | ||
1986 | #endif | ||
1987 | |||
1988 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1989 | CHECK_XCB_CONN; | ||
1990 | |||
1991 | #ifdef ECORE_XCB_RANDR | ||
1992 | if (!_ecore_xcb_randr_root_validate(root)) return; | ||
1993 | crtcs = ecore_x_randr_crtcs_get(root, &total); | ||
1994 | |||
1995 | if (_randr_version >= RANDR_1_3) | ||
1996 | stamp = _ecore_xcb_randr_13_get_resource_timestamp(root); | ||
1997 | else if (_randr_version == RANDR_1_2) | ||
1998 | stamp = _ecore_xcb_randr_12_get_resource_timestamp(root); | ||
1999 | |||
2000 | /* I hate declaring variables inside code like this, but we need the | ||
2001 | * value of 'total' before we can */ | ||
2002 | Ecore_X_Randr_Crtc enabled[total]; | ||
2003 | |||
2004 | for (i = 0; i < total; i++) | ||
2005 | { | ||
2006 | xcb_randr_get_crtc_info_cookie_t ocookie; | ||
2007 | xcb_randr_get_crtc_info_reply_t *oreply; | ||
2008 | |||
2009 | ocookie = | ||
2010 | xcb_randr_get_crtc_info_unchecked(_ecore_xcb_conn, crtcs[i], stamp); | ||
2011 | oreply = xcb_randr_get_crtc_info_reply(_ecore_xcb_conn, | ||
2012 | ocookie, NULL); | ||
2013 | if (!oreply) continue; | ||
2014 | if ((oreply->mode <= 0) || (oreply->num_outputs == 0)) | ||
2015 | { | ||
2016 | free(oreply); | ||
2017 | continue; | ||
2018 | } | ||
2019 | |||
2020 | enabled[num++] = crtcs[i]; | ||
2021 | if ((int)(oreply->x + oreply->width) > w) | ||
2022 | w = (oreply->x + oreply->width); | ||
2023 | if ((int)(oreply->y + oreply->height) > h) | ||
2024 | h = (oreply->y + oreply->height); | ||
2025 | |||
2026 | if (oreply->x < dx) dx = oreply->x; | ||
2027 | if (oreply->y < dy) dy = oreply->y; | ||
2028 | |||
2029 | free(oreply); | ||
2030 | } | ||
2031 | free(crtcs); | ||
2032 | |||
2033 | if ((dx > 0) || (dy > 0)) | ||
2034 | { | ||
2035 | if (ecore_x_randr_move_crtcs(root, enabled, num, -dx, -dy)) | ||
2036 | { | ||
2037 | w -= dx; | ||
2038 | h -= dy; | ||
2039 | } | ||
2040 | } | ||
2041 | |||
2042 | ecore_x_randr_screen_current_size_set(root, w, h, -1, -1); | ||
2043 | #endif | ||
2044 | } | ||
2045 | |||
2046 | /* | ||
2047 | * @param root window which's screen will be queried | ||
2048 | * @param wmin minimum width the screen can be set to | ||
2049 | * @param hmin minimum height the screen can be set to | ||
2050 | * @param wmax maximum width the screen can be set to | ||
2051 | * @param hmax maximum height the screen can be set to | ||
2052 | */ | ||
2053 | EAPI void | ||
2054 | ecore_x_randr_screen_size_range_get(Ecore_X_Window root, | ||
2055 | int *minw, | ||
2056 | int *minh, | ||
2057 | int *maxw, | ||
2058 | int *maxh) | ||
2059 | { | ||
2060 | #ifdef ECORE_XCB_RANDR | ||
2061 | xcb_randr_get_screen_size_range_cookie_t cookie; | ||
2062 | xcb_randr_get_screen_size_range_reply_t *reply; | ||
2063 | #endif | ||
2064 | |||
2065 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2066 | CHECK_XCB_CONN; | ||
2067 | |||
2068 | #ifdef ECORE_XCB_RANDR | ||
2069 | RANDR_CHECK_1_2_RET(); | ||
2070 | |||
2071 | cookie = xcb_randr_get_screen_size_range_unchecked(_ecore_xcb_conn, root); | ||
2072 | reply = xcb_randr_get_screen_size_range_reply(_ecore_xcb_conn, cookie, NULL); | ||
2073 | if (reply) | ||
2074 | { | ||
2075 | if (minw) *minw = reply->min_width; | ||
2076 | if (minh) *minh = reply->min_height; | ||
2077 | if (maxw) *maxw = reply->max_width; | ||
2078 | if (maxh) *maxh = reply->max_height; | ||
2079 | free(reply); | ||
2080 | } | ||
2081 | #endif | ||
2082 | } | ||
2083 | |||
2084 | /* | ||
2085 | * @param w width of screen in px | ||
2086 | * @param h height of screen in px | ||
2087 | */ | ||
2088 | EAPI void | ||
2089 | ecore_x_randr_screen_current_size_get(Ecore_X_Window root, | ||
2090 | int *w, | ||
2091 | int *h, | ||
2092 | int *w_mm, | ||
2093 | int *h_mm) | ||
2094 | { | ||
2095 | #ifdef ECORE_XCB_RANDR | ||
2096 | Ecore_X_Randr_Screen scr = 0; | ||
2097 | xcb_screen_t *s; | ||
2098 | # define RANDR_VALIDATE_ROOT(screen, root) \ | ||
2099 | ((screen == _ecore_xcb_randr_root_to_screen(root)) != -1) | ||
2100 | #endif | ||
2101 | |||
2102 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2103 | CHECK_XCB_CONN; | ||
2104 | |||
2105 | #ifdef ECORE_XCB_RANDR | ||
2106 | RANDR_CHECK_1_2_RET(); | ||
2107 | |||
2108 | if (!RANDR_VALIDATE_ROOT(scr, root)) return; | ||
2109 | |||
2110 | s = ecore_x_screen_get(scr); | ||
2111 | if (w) *w = s->width_in_pixels; | ||
2112 | if (h) *h = s->height_in_pixels; | ||
2113 | if (w_mm) *w_mm = s->width_in_millimeters; | ||
2114 | if (h_mm) *h_mm = s->height_in_millimeters; | ||
2115 | #endif | ||
2116 | } | ||
2117 | |||
2118 | /* | ||
2119 | * @param root window which's screen's size should be set. If invalid (e.g. NULL) no action is taken. | ||
2120 | * @param w width in px the screen should be set to. If out of valid boundaries, current value is assumed. | ||
2121 | * @param h height in px the screen should be set to. If out of valid boundaries, current value is assumed. | ||
2122 | * @param w_mm width in mm the screen should be set to. If 0, current aspect is assumed. | ||
2123 | * @param h_mm height in mm the screen should be set to. If 0, current aspect is assumed. | ||
2124 | * @return EINA_TRUE if request was successfully sent or screen is already in | ||
2125 | * requested size, EINA_FALSE if parameters are invalid | ||
2126 | */ | ||
2127 | EAPI Eina_Bool | ||
2128 | ecore_x_randr_screen_current_size_set(Ecore_X_Window root, | ||
2129 | int w, | ||
2130 | int h, | ||
2131 | int w_mm, | ||
2132 | int h_mm) | ||
2133 | { | ||
2134 | Eina_Bool ret = EINA_TRUE; | ||
2135 | #ifdef ECORE_XCB_RANDR | ||
2136 | Ecore_X_Randr_Screen scr; | ||
2137 | int wc = 0, hc = 0, w_mm_c = 0, h_mm_c = 0; | ||
2138 | int mw = 0, mh = 0, xw = 0, xh = 0; | ||
2139 | # define RANDR_VALIDATE_ROOT(screen, root) \ | ||
2140 | ((screen == _ecore_xcb_randr_root_to_screen(root)) != -1) | ||
2141 | #endif | ||
2142 | |||
2143 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2144 | CHECK_XCB_CONN; | ||
2145 | |||
2146 | #ifdef ECORE_XCB_RANDR | ||
2147 | RANDR_CHECK_1_2_RET(EINA_FALSE); | ||
2148 | |||
2149 | if (!RANDR_VALIDATE_ROOT(scr, root)) return EINA_FALSE; | ||
2150 | ecore_x_randr_screen_current_size_get(root, &wc, &hc, &w_mm_c, &h_mm_c); | ||
2151 | if ((w == wc) && (h == hc) && (w_mm == w_mm_c) && (h_mm == h_mm_c)) | ||
2152 | return EINA_TRUE; | ||
2153 | ecore_x_randr_screen_size_range_get(root, &mw, &mh, &xw, &xh); | ||
2154 | if (((w != 1) && ((w < mw) || (w > xw))) || | ||
2155 | ((h != -1) && ((h < mh) || (h > xh)))) return EINA_FALSE; | ||
2156 | |||
2157 | if (w <= 0) | ||
2158 | w = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels; | ||
2159 | if (h <= 0) | ||
2160 | h = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_pixels; | ||
2161 | |||
2162 | /* NB: Hmmmm, xlib version divides w_mm by width ... that seems wrong */ | ||
2163 | if (w_mm <= 0) | ||
2164 | w_mm = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_millimeters; | ||
2165 | if (h_mm <= 0) | ||
2166 | h_mm = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_millimeters; | ||
2167 | |||
2168 | xcb_randr_set_screen_size(_ecore_xcb_conn, root, w, h, w_mm, h_mm); | ||
2169 | #endif | ||
2170 | |||
2171 | return ret; | ||
2172 | } | ||
2173 | |||
2174 | /* | ||
2175 | * @brief get the outputs, which display a certain window | ||
2176 | * @param window window the displaying outputs shall be found for | ||
2177 | * @param num the number of outputs displaying the window | ||
2178 | * @return array of outputs that display a certain window. NULL if no outputs | ||
2179 | * was found that displays the specified window. | ||
2180 | */ | ||
2181 | EAPI Ecore_X_Randr_Output * | ||
2182 | ecore_x_randr_window_outputs_get(Ecore_X_Window window, | ||
2183 | int *num) | ||
2184 | { | ||
2185 | #ifdef ECORE_XCB_RANDR | ||
2186 | Ecore_X_Window root; | ||
2187 | Eina_Rectangle w_geo, c_geo; | ||
2188 | Ecore_X_Randr_Crtc *crtcs; | ||
2189 | Ecore_X_Randr_Mode mode; | ||
2190 | Ecore_X_Randr_Output *outputs, *ret = NULL, *tret; | ||
2191 | int ncrtcs, noutputs, i, nret = 0; | ||
2192 | xcb_translate_coordinates_cookie_t cookie; | ||
2193 | xcb_translate_coordinates_reply_t *trans; | ||
2194 | #endif | ||
2195 | |||
2196 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2197 | CHECK_XCB_CONN; | ||
2198 | |||
2199 | if (num) *num = 0; | ||
2200 | |||
2201 | #ifdef ECORE_XCB_RANDR | ||
2202 | RANDR_CHECK_1_2_RET(NULL); | ||
2203 | |||
2204 | ecore_x_window_geometry_get(window, &w_geo.x, &w_geo.y, &w_geo.w, &w_geo.h); | ||
2205 | |||
2206 | root = ecore_x_window_root_get(window); | ||
2207 | crtcs = ecore_x_randr_crtcs_get(root, &ncrtcs); | ||
2208 | if (!crtcs) return NULL; | ||
2209 | |||
2210 | /* now get window RELATIVE to root window - thats what matters. */ | ||
2211 | cookie = xcb_translate_coordinates(_ecore_xcb_conn, window, root, 0, 0); | ||
2212 | trans = xcb_translate_coordinates_reply(_ecore_xcb_conn, cookie, NULL); | ||
2213 | w_geo.x = trans->dst_x; | ||
2214 | w_geo.y = trans->dst_y; | ||
2215 | free(trans); | ||
2216 | |||
2217 | for (i = 0; i < ncrtcs; i++) | ||
2218 | { | ||
2219 | /* if crtc is not enabled, don't bother about it any further */ | ||
2220 | mode = ecore_x_randr_crtc_mode_get(root, crtcs[i]); | ||
2221 | if (mode == Ecore_X_Randr_None) continue; | ||
2222 | |||
2223 | ecore_x_randr_crtc_geometry_get(root, crtcs[i], &c_geo.x, &c_geo.y, | ||
2224 | &c_geo.w, &c_geo.h); | ||
2225 | if (eina_rectangles_intersect(&w_geo, &c_geo)) | ||
2226 | { | ||
2227 | outputs = | ||
2228 | ecore_x_randr_crtc_outputs_get(root, crtcs[i], &noutputs); | ||
2229 | /* The case below should be impossible, but for safety reasons | ||
2230 | * remains */ | ||
2231 | if (!outputs) | ||
2232 | { | ||
2233 | if (num) *num = 0; | ||
2234 | free(ret); | ||
2235 | free(crtcs); | ||
2236 | return NULL; | ||
2237 | } | ||
2238 | tret = realloc(ret, ((nret + noutputs) * | ||
2239 | sizeof(Ecore_X_Randr_Output))); | ||
2240 | if (!tret) | ||
2241 | { | ||
2242 | if (num) *num = 0; | ||
2243 | free(outputs); | ||
2244 | free(ret); | ||
2245 | free(crtcs); | ||
2246 | return NULL; | ||
2247 | } | ||
2248 | ret = tret; | ||
2249 | memcpy(&ret[nret], outputs, | ||
2250 | (noutputs * sizeof(Ecore_X_Randr_Output))); | ||
2251 | nret += noutputs; | ||
2252 | free(outputs); | ||
2253 | } | ||
2254 | } | ||
2255 | free(crtcs); | ||
2256 | |||
2257 | if (num) *num = nret; | ||
2258 | return ret; | ||
2259 | |||
2260 | #endif | ||
2261 | if (num) *num = 0; | ||
2262 | return NULL; | ||
2263 | } | ||
2264 | |||
2265 | /* | ||
2266 | * @brief get the backlight level of the given output | ||
2267 | * @param root window which's screen should be queried | ||
2268 | * @param output from which the backlight level should be retrieved | ||
2269 | * @return the backlight level | ||
2270 | */ | ||
2271 | EAPI double | ||
2272 | ecore_x_randr_output_backlight_level_get(Ecore_X_Window root, | ||
2273 | Ecore_X_Randr_Output output) | ||
2274 | { | ||
2275 | #ifdef ECORE_XCB_RANDR | ||
2276 | Ecore_X_Atom _backlight; | ||
2277 | xcb_intern_atom_cookie_t acookie; | ||
2278 | xcb_intern_atom_reply_t *areply; | ||
2279 | xcb_randr_get_output_property_cookie_t cookie; | ||
2280 | xcb_randr_get_output_property_reply_t *reply; | ||
2281 | xcb_randr_query_output_property_cookie_t qcookie; | ||
2282 | xcb_randr_query_output_property_reply_t *qreply; | ||
2283 | double dvalue; | ||
2284 | long value, max, min; | ||
2285 | #endif | ||
2286 | |||
2287 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2288 | CHECK_XCB_CONN; | ||
2289 | |||
2290 | #ifdef ECORE_XCB_RANDR | ||
2291 | RANDR_CHECK_1_2_RET(-1); | ||
2292 | |||
2293 | acookie = | ||
2294 | xcb_intern_atom_unchecked(_ecore_xcb_conn, 1, | ||
2295 | strlen("Backlight"), "Backlight"); | ||
2296 | areply = xcb_intern_atom_reply(_ecore_xcb_conn, acookie, NULL); | ||
2297 | |||
2298 | if (!areply) | ||
2299 | { | ||
2300 | ERR("Backlight property is not suppported on this server or driver"); | ||
2301 | return -1; | ||
2302 | } | ||
2303 | else | ||
2304 | { | ||
2305 | _backlight = areply->atom; | ||
2306 | free(areply); | ||
2307 | } | ||
2308 | |||
2309 | if (!_ecore_xcb_randr_output_validate(root, output)) | ||
2310 | { | ||
2311 | ERR("Invalid output"); | ||
2312 | return -1; | ||
2313 | } | ||
2314 | |||
2315 | cookie = | ||
2316 | xcb_randr_get_output_property_unchecked(_ecore_xcb_conn, | ||
2317 | output, _backlight, | ||
2318 | XCB_ATOM_NONE, 0, 4, 0, 0); | ||
2319 | reply = | ||
2320 | xcb_randr_get_output_property_reply(_ecore_xcb_conn, cookie, NULL); | ||
2321 | if (!reply) | ||
2322 | { | ||
2323 | WRN("Backlight not supported on this output"); | ||
2324 | return -1; | ||
2325 | } | ||
2326 | |||
2327 | if ((reply->format != 32) || (reply->num_items != 1) || | ||
2328 | (reply->type != XCB_ATOM_INTEGER)) | ||
2329 | { | ||
2330 | free(reply); | ||
2331 | return -1; | ||
2332 | } | ||
2333 | |||
2334 | value = *((long *)xcb_randr_get_output_property_data(reply)); | ||
2335 | free (reply); | ||
2336 | |||
2337 | /* I have the current value of the backlight */ | ||
2338 | /* Now retrieve the min and max intensities of the output */ | ||
2339 | qcookie = | ||
2340 | xcb_randr_query_output_property_unchecked(_ecore_xcb_conn, | ||
2341 | output, _backlight); | ||
2342 | qreply = | ||
2343 | xcb_randr_query_output_property_reply(_ecore_xcb_conn, qcookie, NULL); | ||
2344 | if (qreply) | ||
2345 | { | ||
2346 | dvalue = -1; | ||
2347 | if ((qreply->range) && | ||
2348 | (xcb_randr_query_output_property_valid_values_length(qreply) == 2)) | ||
2349 | { | ||
2350 | int32_t *vals; | ||
2351 | |||
2352 | vals = xcb_randr_query_output_property_valid_values(qreply); | ||
2353 | /* finally convert the current value in the interval [0..1] */ | ||
2354 | min = vals[0]; | ||
2355 | max = vals[1]; | ||
2356 | dvalue = ((double)(value - min)) / ((double)(max - min)); | ||
2357 | } | ||
2358 | free(qreply); | ||
2359 | return dvalue; | ||
2360 | } | ||
2361 | #endif | ||
2362 | return -1; | ||
2363 | } | ||
2364 | |||
2365 | /* | ||
2366 | * @brief set the backlight level of a given output | ||
2367 | * @param root window which's screen should be queried | ||
2368 | * @param output that should be set | ||
2369 | * @param level for which the backlight should be set | ||
2370 | * @return EINA_TRUE in case of success | ||
2371 | */ | ||
2372 | EAPI Eina_Bool | ||
2373 | ecore_x_randr_output_backlight_level_set(Ecore_X_Window root, | ||
2374 | Ecore_X_Randr_Output output, | ||
2375 | double level) | ||
2376 | { | ||
2377 | #ifdef ECORE_XCB_RANDR | ||
2378 | Ecore_X_Atom _backlight; | ||
2379 | xcb_intern_atom_cookie_t acookie; | ||
2380 | xcb_intern_atom_reply_t *areply; | ||
2381 | xcb_randr_query_output_property_cookie_t qcookie; | ||
2382 | xcb_randr_query_output_property_reply_t *qreply; | ||
2383 | #endif | ||
2384 | |||
2385 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2386 | CHECK_XCB_CONN; | ||
2387 | |||
2388 | #ifdef ECORE_XCB_RANDR | ||
2389 | RANDR_CHECK_1_2_RET(EINA_FALSE); | ||
2390 | |||
2391 | if ((level < 0) || (level > 1)) | ||
2392 | { | ||
2393 | ERR("Backlight level should be between 0 and 1"); | ||
2394 | return EINA_FALSE; | ||
2395 | } | ||
2396 | |||
2397 | if (!_ecore_xcb_randr_output_validate(root, output)) | ||
2398 | { | ||
2399 | ERR("Wrong output value"); | ||
2400 | return EINA_FALSE; | ||
2401 | } | ||
2402 | |||
2403 | acookie = | ||
2404 | xcb_intern_atom_unchecked(_ecore_xcb_conn, 1, | ||
2405 | strlen("Backlight"), "Backlight"); | ||
2406 | areply = xcb_intern_atom_reply(_ecore_xcb_conn, acookie, NULL); | ||
2407 | if (!areply) | ||
2408 | { | ||
2409 | WRN("Backlight property is not suppported on this server or driver"); | ||
2410 | return EINA_FALSE; | ||
2411 | } | ||
2412 | else | ||
2413 | { | ||
2414 | _backlight = areply->atom; | ||
2415 | free(areply); | ||
2416 | } | ||
2417 | |||
2418 | qcookie = | ||
2419 | xcb_randr_query_output_property_unchecked(_ecore_xcb_conn, | ||
2420 | output, _backlight); | ||
2421 | qreply = | ||
2422 | xcb_randr_query_output_property_reply(_ecore_xcb_conn, qcookie, NULL); | ||
2423 | if (qreply) | ||
2424 | { | ||
2425 | if ((qreply->range) && (qreply->length == 2)) | ||
2426 | { | ||
2427 | int32_t *vals; | ||
2428 | double min, max, tmp; | ||
2429 | long n; | ||
2430 | |||
2431 | vals = xcb_randr_query_output_property_valid_values(qreply); | ||
2432 | min = vals[0]; | ||
2433 | max = vals[1]; | ||
2434 | tmp = (level * (max - min)) + min; | ||
2435 | n = tmp; | ||
2436 | if (n > max) n = max; | ||
2437 | if (n < min) n = min; | ||
2438 | xcb_randr_change_output_property(_ecore_xcb_conn, output, | ||
2439 | _backlight, XCB_ATOM_INTEGER, | ||
2440 | 32, XCB_PROP_MODE_REPLACE, | ||
2441 | 1, (unsigned char *)&n); | ||
2442 | ecore_x_flush(); // needed | ||
2443 | } | ||
2444 | |||
2445 | free(qreply); | ||
2446 | return EINA_TRUE; | ||
2447 | } | ||
2448 | #endif | ||
2449 | return EINA_FALSE; | ||
2450 | } | ||
2451 | |||
2452 | EAPI int | ||
2453 | ecore_x_randr_edid_version_get(unsigned char *edid, unsigned long edid_length) | ||
2454 | { | ||
2455 | if ((edid_length > _ECORE_X_RANDR_EDID_OFFSET_VERSION_MINOR) && | ||
2456 | (ecore_x_randr_edid_has_valid_header(edid, edid_length))) | ||
2457 | return (edid[_ECORE_X_RANDR_EDID_OFFSET_VERSION_MAJOR] << 8) | | ||
2458 | edid[_ECORE_X_RANDR_EDID_OFFSET_VERSION_MINOR]; | ||
2459 | return ECORE_X_RANDR_EDID_UNKNOWN_VALUE; | ||
2460 | } | ||
2461 | |||
2462 | EAPI char * | ||
2463 | ecore_x_randr_edid_display_name_get(unsigned char *edid, unsigned long edid_length) | ||
2464 | { | ||
2465 | unsigned char *block = NULL; | ||
2466 | int version = 0; | ||
2467 | |||
2468 | version = ecore_x_randr_edid_version_get(edid, edid_length); | ||
2469 | if (version < ECORE_X_RANDR_EDID_VERSION_13) return NULL; | ||
2470 | |||
2471 | _ECORE_X_RANDR_EDID_FOR_EACH_NON_PIXEL_DESCRIPTOR_BLOCK(edid, block) | ||
2472 | { | ||
2473 | if (block[_ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_TYPE] == 0xfc) | ||
2474 | { | ||
2475 | char *name, *p; | ||
2476 | const char *edid_name; | ||
2477 | |||
2478 | edid_name = (const char *)block + | ||
2479 | _ECORE_X_RANDR_EDID_OFFSET_DESCRIPTOR_BLOCK_CONTENT; | ||
2480 | name = | ||
2481 | malloc(sizeof(char) * | ||
2482 | _ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX); | ||
2483 | if (!name) return NULL; | ||
2484 | |||
2485 | strncpy(name, edid_name, | ||
2486 | (_ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX - 1)); | ||
2487 | name[_ECORE_X_RANDR_EDID_DISPLAY_DESCRIPTOR_BLOCK_CONTENT_LENGTH_MAX] = 0; | ||
2488 | for (p = name; *p; p++) | ||
2489 | if ((*p < ' ') || (*p > '~')) *p = 0; | ||
2490 | |||
2491 | return name; | ||
2492 | } | ||
2493 | } | ||
2494 | return NULL; | ||
2495 | } | ||
2496 | |||
2497 | EAPI Eina_Bool | ||
2498 | ecore_x_randr_edid_has_valid_header(unsigned char *edid, unsigned long edid_length) | ||
2499 | { | ||
2500 | const unsigned char header[] = | ||
2501 | { | ||
2502 | 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00 | ||
2503 | }; | ||
2504 | |||
2505 | if ((!edid) || (edid_length < 8)) return EINA_FALSE; | ||
2506 | if (!memcmp(edid, header, 8)) return EINA_TRUE; | ||
2507 | return EINA_FALSE; | ||
2508 | } | ||
2509 | |||
2510 | /* local functions */ | ||
2511 | static Eina_Bool | ||
2512 | _ecore_xcb_randr_output_validate(Ecore_X_Window root, | ||
2513 | Ecore_X_Randr_Output output) | ||
2514 | { | ||
2515 | Eina_Bool ret = EINA_FALSE; | ||
2516 | |||
2517 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2518 | CHECK_XCB_CONN; | ||
2519 | |||
2520 | #ifdef ECORE_XCB_RANDR | ||
2521 | RANDR_CHECK_1_2_RET(EINA_FALSE); | ||
2522 | |||
2523 | if ((output) && (_ecore_xcb_randr_root_validate(root))) | ||
2524 | { | ||
2525 | if (_randr_version >= RANDR_1_3) | ||
2526 | { | ||
2527 | xcb_randr_get_screen_resources_current_reply_t *reply; | ||
2528 | |||
2529 | reply = _ecore_xcb_randr_13_get_resources(root); | ||
2530 | if (reply) | ||
2531 | { | ||
2532 | int len = 0, i = 0; | ||
2533 | xcb_randr_output_t *outputs; | ||
2534 | |||
2535 | len = | ||
2536 | xcb_randr_get_screen_resources_current_outputs_length(reply); | ||
2537 | outputs = | ||
2538 | xcb_randr_get_screen_resources_current_outputs(reply); | ||
2539 | for (i = 0; i < len; i++) | ||
2540 | { | ||
2541 | if (outputs[i] == output) | ||
2542 | { | ||
2543 | ret = EINA_TRUE; | ||
2544 | break; | ||
2545 | } | ||
2546 | } | ||
2547 | free(reply); | ||
2548 | } | ||
2549 | } | ||
2550 | else if (_randr_version == RANDR_1_2) | ||
2551 | { | ||
2552 | xcb_randr_get_screen_resources_reply_t *reply; | ||
2553 | |||
2554 | reply = _ecore_xcb_randr_12_get_resources(root); | ||
2555 | if (reply) | ||
2556 | { | ||
2557 | int len = 0, i = 0; | ||
2558 | xcb_randr_output_t *outputs; | ||
2559 | |||
2560 | len = xcb_randr_get_screen_resources_outputs_length(reply); | ||
2561 | outputs = xcb_randr_get_screen_resources_outputs(reply); | ||
2562 | for (i = 0; i < len; i++) | ||
2563 | { | ||
2564 | if (outputs[i] == output) | ||
2565 | { | ||
2566 | ret = EINA_TRUE; | ||
2567 | break; | ||
2568 | } | ||
2569 | } | ||
2570 | free(reply); | ||
2571 | } | ||
2572 | } | ||
2573 | } | ||
2574 | #endif | ||
2575 | return ret; | ||
2576 | } | ||
2577 | |||
2578 | /** | ||
2579 | * @brief validates a CRTC for a given root window's screen. | ||
2580 | * @param root the window which's default display will be queried | ||
2581 | * @param crtc the CRTC to be validated. | ||
2582 | * @return in case it is found EINA_TRUE will be returned. Else EINA_FALSE is returned. | ||
2583 | */ | ||
2584 | static Eina_Bool | ||
2585 | _ecore_xcb_randr_crtc_validate(Ecore_X_Window root, | ||
2586 | Ecore_X_Randr_Crtc crtc) | ||
2587 | { | ||
2588 | Eina_Bool ret = EINA_FALSE; | ||
2589 | |||
2590 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2591 | CHECK_XCB_CONN; | ||
2592 | |||
2593 | #ifdef ECORE_XCB_RANDR | ||
2594 | RANDR_CHECK_1_2_RET(EINA_FALSE); | ||
2595 | |||
2596 | if (((int)crtc == Ecore_X_Randr_None) || ((int)crtc == Ecore_X_Randr_Unset)) | ||
2597 | return ret; | ||
2598 | |||
2599 | if ((crtc) && (_ecore_xcb_randr_root_validate(root))) | ||
2600 | { | ||
2601 | if (_randr_version >= RANDR_1_3) | ||
2602 | { | ||
2603 | xcb_randr_get_screen_resources_current_reply_t *reply; | ||
2604 | |||
2605 | reply = _ecore_xcb_randr_13_get_resources(root); | ||
2606 | if (reply) | ||
2607 | { | ||
2608 | int i = 0; | ||
2609 | xcb_randr_crtc_t *crtcs; | ||
2610 | |||
2611 | crtcs = xcb_randr_get_screen_resources_current_crtcs(reply); | ||
2612 | for (i = 0; i < reply->num_crtcs; i++) | ||
2613 | { | ||
2614 | if (crtcs[i] == crtc) | ||
2615 | { | ||
2616 | ret = EINA_TRUE; | ||
2617 | break; | ||
2618 | } | ||
2619 | } | ||
2620 | free(reply); | ||
2621 | } | ||
2622 | } | ||
2623 | else if (_randr_version == RANDR_1_2) | ||
2624 | { | ||
2625 | xcb_randr_get_screen_resources_reply_t *reply; | ||
2626 | |||
2627 | reply = _ecore_xcb_randr_12_get_resources(root); | ||
2628 | if (reply) | ||
2629 | { | ||
2630 | int i = 0; | ||
2631 | xcb_randr_crtc_t *crtcs; | ||
2632 | |||
2633 | crtcs = xcb_randr_get_screen_resources_crtcs(reply); | ||
2634 | for (i = 0; i < reply->num_crtcs; i++) | ||
2635 | { | ||
2636 | if (crtcs[i] == crtc) | ||
2637 | { | ||
2638 | ret = EINA_TRUE; | ||
2639 | break; | ||
2640 | } | ||
2641 | } | ||
2642 | free(reply); | ||
2643 | } | ||
2644 | } | ||
2645 | } | ||
2646 | #endif | ||
2647 | |||
2648 | return ret; | ||
2649 | } | ||
2650 | |||
2651 | static Ecore_X_Randr_Mode * | ||
2652 | _ecore_xcb_randr_12_output_modes_get(Ecore_X_Window root, | ||
2653 | Ecore_X_Randr_Output output, | ||
2654 | int *num, | ||
2655 | int *npreferred) | ||
2656 | { | ||
2657 | Ecore_X_Randr_Mode *modes = NULL; | ||
2658 | xcb_randr_get_screen_resources_reply_t *reply; | ||
2659 | |||
2660 | reply = _ecore_xcb_randr_12_get_resources(root); | ||
2661 | if (reply) | ||
2662 | { | ||
2663 | xcb_randr_get_output_info_cookie_t ocookie; | ||
2664 | xcb_randr_get_output_info_reply_t *oreply; | ||
2665 | |||
2666 | ocookie = | ||
2667 | xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, | ||
2668 | reply->config_timestamp); | ||
2669 | oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, | ||
2670 | ocookie, NULL); | ||
2671 | if (oreply) | ||
2672 | { | ||
2673 | if (num) *num = oreply->num_modes; | ||
2674 | if (npreferred) *npreferred = oreply->num_preferred; | ||
2675 | |||
2676 | modes = malloc(sizeof(Ecore_X_Randr_Mode) * | ||
2677 | oreply->num_modes); | ||
2678 | if (modes) | ||
2679 | { | ||
2680 | xcb_randr_mode_t *rmodes; | ||
2681 | int len = 0; | ||
2682 | |||
2683 | len = xcb_randr_get_output_info_modes_length(oreply); | ||
2684 | rmodes = xcb_randr_get_output_info_modes(oreply); | ||
2685 | memcpy(modes, rmodes, sizeof(Ecore_X_Randr_Mode) * len); | ||
2686 | } | ||
2687 | free(oreply); | ||
2688 | } | ||
2689 | free(reply); | ||
2690 | } | ||
2691 | |||
2692 | return modes; | ||
2693 | } | ||
2694 | |||
2695 | static Ecore_X_Randr_Mode * | ||
2696 | _ecore_xcb_randr_13_output_modes_get(Ecore_X_Window root, | ||
2697 | Ecore_X_Randr_Output output, | ||
2698 | int *num, | ||
2699 | int *npreferred) | ||
2700 | { | ||
2701 | Ecore_X_Randr_Mode *modes = NULL; | ||
2702 | xcb_timestamp_t stamp = 0; | ||
2703 | xcb_randr_get_output_info_cookie_t ocookie; | ||
2704 | xcb_randr_get_output_info_reply_t *oreply; | ||
2705 | |||
2706 | stamp = _ecore_xcb_randr_13_get_resource_timestamp(root); | ||
2707 | |||
2708 | ocookie = | ||
2709 | xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, stamp); | ||
2710 | oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, ocookie, NULL); | ||
2711 | if (oreply) | ||
2712 | { | ||
2713 | if (num) *num = oreply->num_modes; | ||
2714 | if (npreferred) *npreferred = oreply->num_preferred; | ||
2715 | |||
2716 | modes = malloc(sizeof(Ecore_X_Randr_Mode) * oreply->num_modes); | ||
2717 | if (modes) | ||
2718 | { | ||
2719 | xcb_randr_mode_t *rmodes; | ||
2720 | int len = 0; | ||
2721 | |||
2722 | len = xcb_randr_get_output_info_modes_length(oreply); | ||
2723 | rmodes = xcb_randr_get_output_info_modes(oreply); | ||
2724 | memcpy(modes, rmodes, sizeof(Ecore_X_Randr_Mode) * len); | ||
2725 | } | ||
2726 | free(oreply); | ||
2727 | } | ||
2728 | |||
2729 | return modes; | ||
2730 | } | ||
2731 | |||
2732 | static Ecore_X_Randr_Mode_Info * | ||
2733 | _ecore_xcb_randr_12_mode_info_get(Ecore_X_Window root, | ||
2734 | Ecore_X_Randr_Mode mode) | ||
2735 | { | ||
2736 | Ecore_X_Randr_Mode_Info *ret = NULL; | ||
2737 | xcb_randr_get_screen_resources_reply_t *reply; | ||
2738 | |||
2739 | reply = _ecore_xcb_randr_12_get_resources(root); | ||
2740 | if (reply) | ||
2741 | { | ||
2742 | if ((ret = malloc(sizeof(Ecore_X_Randr_Mode_Info)))) | ||
2743 | { | ||
2744 | uint8_t *nbuf; | ||
2745 | xcb_randr_mode_info_iterator_t miter; | ||
2746 | |||
2747 | nbuf = xcb_randr_get_screen_resources_names(reply); | ||
2748 | miter = xcb_randr_get_screen_resources_modes_iterator(reply); | ||
2749 | while (miter.rem) | ||
2750 | { | ||
2751 | xcb_randr_mode_info_t *minfo; | ||
2752 | |||
2753 | minfo = miter.data; | ||
2754 | nbuf += minfo->name_len; | ||
2755 | |||
2756 | if (minfo->id == mode) | ||
2757 | { | ||
2758 | ret->xid = minfo->id; | ||
2759 | ret->width = minfo->width; | ||
2760 | ret->height = minfo->height; | ||
2761 | ret->dotClock = minfo->dot_clock; | ||
2762 | ret->hSyncStart = minfo->hsync_start; | ||
2763 | ret->hSyncEnd = minfo->hsync_end; | ||
2764 | ret->hTotal = minfo->htotal; | ||
2765 | ret->vSyncStart = minfo->vsync_start; | ||
2766 | ret->vSyncEnd = minfo->vsync_end; | ||
2767 | ret->vTotal = minfo->vtotal; | ||
2768 | ret->modeFlags = minfo->mode_flags; | ||
2769 | |||
2770 | ret->name = NULL; | ||
2771 | ret->nameLength = minfo->name_len; | ||
2772 | if (ret->nameLength > 0) | ||
2773 | { | ||
2774 | ret->name = malloc(ret->nameLength + 1); | ||
2775 | if (ret->name) | ||
2776 | memcpy(ret->name, nbuf, ret->nameLength + 1); | ||
2777 | } | ||
2778 | |||
2779 | break; | ||
2780 | } | ||
2781 | xcb_randr_mode_info_next(&miter); | ||
2782 | } | ||
2783 | } | ||
2784 | |||
2785 | free(reply); | ||
2786 | } | ||
2787 | return ret; | ||
2788 | } | ||
2789 | |||
2790 | static Ecore_X_Randr_Mode_Info * | ||
2791 | _ecore_xcb_randr_13_mode_info_get(Ecore_X_Window root, | ||
2792 | Ecore_X_Randr_Mode mode) | ||
2793 | { | ||
2794 | Ecore_X_Randr_Mode_Info *ret = NULL; | ||
2795 | xcb_randr_get_screen_resources_current_reply_t *reply; | ||
2796 | |||
2797 | reply = _ecore_xcb_randr_13_get_resources(root); | ||
2798 | if (reply) | ||
2799 | { | ||
2800 | if ((ret = malloc(sizeof(Ecore_X_Randr_Mode_Info)))) | ||
2801 | { | ||
2802 | uint8_t *nbuf; | ||
2803 | xcb_randr_mode_info_iterator_t miter; | ||
2804 | |||
2805 | nbuf = xcb_randr_get_screen_resources_current_names(reply); | ||
2806 | miter = | ||
2807 | xcb_randr_get_screen_resources_current_modes_iterator(reply); | ||
2808 | while (miter.rem) | ||
2809 | { | ||
2810 | xcb_randr_mode_info_t *minfo; | ||
2811 | |||
2812 | minfo = miter.data; | ||
2813 | nbuf += minfo->name_len; | ||
2814 | |||
2815 | if (minfo->id == mode) | ||
2816 | { | ||
2817 | ret->xid = minfo->id; | ||
2818 | ret->width = minfo->width; | ||
2819 | ret->height = minfo->height; | ||
2820 | ret->dotClock = minfo->dot_clock; | ||
2821 | ret->hSyncStart = minfo->hsync_start; | ||
2822 | ret->hSyncEnd = minfo->hsync_end; | ||
2823 | ret->hTotal = minfo->htotal; | ||
2824 | ret->vSyncStart = minfo->vsync_start; | ||
2825 | ret->vSyncEnd = minfo->vsync_end; | ||
2826 | ret->vTotal = minfo->vtotal; | ||
2827 | ret->modeFlags = minfo->mode_flags; | ||
2828 | |||
2829 | ret->name = NULL; | ||
2830 | ret->nameLength = minfo->name_len; | ||
2831 | if (ret->nameLength > 0) | ||
2832 | { | ||
2833 | ret->name = malloc(ret->nameLength + 1); | ||
2834 | if (ret->name) | ||
2835 | memcpy(ret->name, nbuf, ret->nameLength + 1); | ||
2836 | } | ||
2837 | |||
2838 | break; | ||
2839 | } | ||
2840 | xcb_randr_mode_info_next(&miter); | ||
2841 | } | ||
2842 | } | ||
2843 | |||
2844 | free(reply); | ||
2845 | } | ||
2846 | return ret; | ||
2847 | } | ||
2848 | |||
2849 | static Ecore_X_Randr_Mode_Info ** | ||
2850 | _ecore_xcb_randr_12_modes_info_get(Ecore_X_Window root, | ||
2851 | int *num) | ||
2852 | { | ||
2853 | Ecore_X_Randr_Mode_Info **ret = NULL; | ||
2854 | xcb_randr_get_screen_resources_reply_t *reply; | ||
2855 | |||
2856 | reply = _ecore_xcb_randr_12_get_resources(root); | ||
2857 | if (reply) | ||
2858 | { | ||
2859 | if (num) *num = reply->num_modes; | ||
2860 | ret = malloc(sizeof(Ecore_X_Randr_Mode_Info *) * reply->num_modes); | ||
2861 | if (ret) | ||
2862 | { | ||
2863 | xcb_randr_mode_info_iterator_t miter; | ||
2864 | int i = 0; | ||
2865 | uint8_t *nbuf; | ||
2866 | |||
2867 | nbuf = xcb_randr_get_screen_resources_names(reply); | ||
2868 | miter = xcb_randr_get_screen_resources_modes_iterator(reply); | ||
2869 | while (miter.rem) | ||
2870 | { | ||
2871 | xcb_randr_mode_info_t *minfo; | ||
2872 | |||
2873 | minfo = miter.data; | ||
2874 | nbuf += minfo->name_len; | ||
2875 | if ((ret[i] = malloc(sizeof(Ecore_X_Randr_Mode_Info)))) | ||
2876 | { | ||
2877 | ret[i]->xid = minfo->id; | ||
2878 | ret[i]->width = minfo->width; | ||
2879 | ret[i]->height = minfo->height; | ||
2880 | ret[i]->dotClock = minfo->dot_clock; | ||
2881 | ret[i]->hSyncStart = minfo->hsync_start; | ||
2882 | ret[i]->hSyncEnd = minfo->hsync_end; | ||
2883 | ret[i]->hTotal = minfo->htotal; | ||
2884 | ret[i]->vSyncStart = minfo->vsync_start; | ||
2885 | ret[i]->vSyncEnd = minfo->vsync_end; | ||
2886 | ret[i]->vTotal = minfo->vtotal; | ||
2887 | ret[i]->modeFlags = minfo->mode_flags; | ||
2888 | |||
2889 | ret[i]->name = NULL; | ||
2890 | ret[i]->nameLength = minfo->name_len; | ||
2891 | if (ret[i]->nameLength > 0) | ||
2892 | { | ||
2893 | ret[i]->name = malloc(ret[i]->nameLength + 1); | ||
2894 | if (ret[i]->name) | ||
2895 | memcpy(ret[i]->name, nbuf, | ||
2896 | ret[i]->nameLength + 1); | ||
2897 | } | ||
2898 | } | ||
2899 | else | ||
2900 | { | ||
2901 | while (i > 0) | ||
2902 | free(ret[--i]); | ||
2903 | free(ret); | ||
2904 | ret = NULL; | ||
2905 | break; | ||
2906 | } | ||
2907 | i++; | ||
2908 | xcb_randr_mode_info_next(&miter); | ||
2909 | } | ||
2910 | } | ||
2911 | free(reply); | ||
2912 | } | ||
2913 | return ret; | ||
2914 | } | ||
2915 | |||
2916 | static Ecore_X_Randr_Mode_Info ** | ||
2917 | _ecore_xcb_randr_13_modes_info_get(Ecore_X_Window root, | ||
2918 | int *num) | ||
2919 | { | ||
2920 | Ecore_X_Randr_Mode_Info **ret = NULL; | ||
2921 | xcb_randr_get_screen_resources_current_reply_t *reply; | ||
2922 | |||
2923 | reply = _ecore_xcb_randr_13_get_resources(root); | ||
2924 | if (reply) | ||
2925 | { | ||
2926 | if (num) *num = reply->num_modes; | ||
2927 | ret = malloc(sizeof(Ecore_X_Randr_Mode_Info *) * reply->num_modes); | ||
2928 | if (ret) | ||
2929 | { | ||
2930 | xcb_randr_mode_info_iterator_t miter; | ||
2931 | int i = 0; | ||
2932 | uint8_t *nbuf; | ||
2933 | |||
2934 | nbuf = xcb_randr_get_screen_resources_current_names(reply); | ||
2935 | miter = | ||
2936 | xcb_randr_get_screen_resources_current_modes_iterator(reply); | ||
2937 | while (miter.rem) | ||
2938 | { | ||
2939 | xcb_randr_mode_info_t *minfo; | ||
2940 | |||
2941 | minfo = miter.data; | ||
2942 | nbuf += minfo->name_len; | ||
2943 | if ((ret[i] = malloc(sizeof(Ecore_X_Randr_Mode_Info)))) | ||
2944 | { | ||
2945 | ret[i]->xid = minfo->id; | ||
2946 | ret[i]->width = minfo->width; | ||
2947 | ret[i]->height = minfo->height; | ||
2948 | ret[i]->dotClock = minfo->dot_clock; | ||
2949 | ret[i]->hSyncStart = minfo->hsync_start; | ||
2950 | ret[i]->hSyncEnd = minfo->hsync_end; | ||
2951 | ret[i]->hTotal = minfo->htotal; | ||
2952 | ret[i]->vSyncStart = minfo->vsync_start; | ||
2953 | ret[i]->vSyncEnd = minfo->vsync_end; | ||
2954 | ret[i]->vTotal = minfo->vtotal; | ||
2955 | ret[i]->modeFlags = minfo->mode_flags; | ||
2956 | |||
2957 | ret[i]->name = NULL; | ||
2958 | ret[i]->nameLength = minfo->name_len; | ||
2959 | if (ret[i]->nameLength > 0) | ||
2960 | { | ||
2961 | ret[i]->name = malloc(ret[i]->nameLength + 1); | ||
2962 | if (ret[i]->name) | ||
2963 | memcpy(ret[i]->name, nbuf, | ||
2964 | ret[i]->nameLength + 1); | ||
2965 | } | ||
2966 | } | ||
2967 | else | ||
2968 | { | ||
2969 | while (i > 0) | ||
2970 | free(ret[--i]); | ||
2971 | free(ret); | ||
2972 | ret = NULL; | ||
2973 | break; | ||
2974 | } | ||
2975 | i++; | ||
2976 | xcb_randr_mode_info_next(&miter); | ||
2977 | } | ||
2978 | } | ||
2979 | free(reply); | ||
2980 | } | ||
2981 | return ret; | ||
2982 | } | ||
2983 | |||
2984 | static void | ||
2985 | _ecore_xcb_randr_12_mode_size_get(Ecore_X_Window root, | ||
2986 | Ecore_X_Randr_Mode mode, | ||
2987 | int *w, | ||
2988 | int *h) | ||
2989 | { | ||
2990 | xcb_randr_get_screen_resources_reply_t *reply; | ||
2991 | |||
2992 | reply = _ecore_xcb_randr_12_get_resources(root); | ||
2993 | if (reply) | ||
2994 | { | ||
2995 | xcb_randr_mode_info_iterator_t miter; | ||
2996 | |||
2997 | miter = xcb_randr_get_screen_resources_modes_iterator(reply); | ||
2998 | while (miter.rem) | ||
2999 | { | ||
3000 | xcb_randr_mode_info_t *minfo; | ||
3001 | |||
3002 | minfo = miter.data; | ||
3003 | if (minfo->id == mode) | ||
3004 | { | ||
3005 | if (w) *w = minfo->width; | ||
3006 | if (h) *h = minfo->height; | ||
3007 | break; | ||
3008 | } | ||
3009 | xcb_randr_mode_info_next(&miter); | ||
3010 | } | ||
3011 | free(reply); | ||
3012 | } | ||
3013 | } | ||
3014 | |||
3015 | static void | ||
3016 | _ecore_xcb_randr_13_mode_size_get(Ecore_X_Window root, | ||
3017 | Ecore_X_Randr_Mode mode, | ||
3018 | int *w, | ||
3019 | int *h) | ||
3020 | { | ||
3021 | xcb_randr_get_screen_resources_current_reply_t *reply; | ||
3022 | |||
3023 | reply = _ecore_xcb_randr_13_get_resources(root); | ||
3024 | if (reply) | ||
3025 | { | ||
3026 | xcb_randr_mode_info_iterator_t miter; | ||
3027 | |||
3028 | miter = xcb_randr_get_screen_resources_current_modes_iterator(reply); | ||
3029 | while (miter.rem) | ||
3030 | { | ||
3031 | xcb_randr_mode_info_t *minfo; | ||
3032 | |||
3033 | minfo = miter.data; | ||
3034 | if (minfo->id == mode) | ||
3035 | { | ||
3036 | if (w) *w = minfo->width; | ||
3037 | if (h) *h = minfo->height; | ||
3038 | break; | ||
3039 | } | ||
3040 | xcb_randr_mode_info_next(&miter); | ||
3041 | } | ||
3042 | free(reply); | ||
3043 | } | ||
3044 | } | ||
3045 | |||
3046 | static Ecore_X_Randr_Output * | ||
3047 | _ecore_xcb_randr_12_output_clones_get(Ecore_X_Window root, | ||
3048 | Ecore_X_Randr_Output output, | ||
3049 | int *num) | ||
3050 | { | ||
3051 | Ecore_X_Randr_Output *outputs = NULL; | ||
3052 | xcb_randr_get_screen_resources_reply_t *reply; | ||
3053 | |||
3054 | reply = _ecore_xcb_randr_12_get_resources(root); | ||
3055 | if (reply) | ||
3056 | { | ||
3057 | xcb_randr_get_output_info_cookie_t ocookie; | ||
3058 | xcb_randr_get_output_info_reply_t *oreply; | ||
3059 | |||
3060 | ocookie = | ||
3061 | xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, | ||
3062 | reply->config_timestamp); | ||
3063 | oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, | ||
3064 | ocookie, NULL); | ||
3065 | if (oreply) | ||
3066 | { | ||
3067 | if (num) *num = oreply->num_clones; | ||
3068 | |||
3069 | outputs = | ||
3070 | malloc(sizeof(Ecore_X_Randr_Output) * oreply->num_clones); | ||
3071 | if (outputs) | ||
3072 | { | ||
3073 | memcpy(outputs, xcb_randr_get_output_info_clones(oreply), | ||
3074 | sizeof(Ecore_X_Randr_Output) * oreply->num_clones); | ||
3075 | } | ||
3076 | free(oreply); | ||
3077 | } | ||
3078 | free(reply); | ||
3079 | } | ||
3080 | return outputs; | ||
3081 | } | ||
3082 | |||
3083 | static Ecore_X_Randr_Output * | ||
3084 | _ecore_xcb_randr_13_output_clones_get(Ecore_X_Window root, | ||
3085 | Ecore_X_Randr_Output output, | ||
3086 | int *num) | ||
3087 | { | ||
3088 | Ecore_X_Randr_Output *outputs = NULL; | ||
3089 | xcb_randr_get_screen_resources_current_reply_t *reply; | ||
3090 | |||
3091 | reply = _ecore_xcb_randr_13_get_resources(root); | ||
3092 | if (reply) | ||
3093 | { | ||
3094 | xcb_randr_get_output_info_cookie_t ocookie; | ||
3095 | xcb_randr_get_output_info_reply_t *oreply; | ||
3096 | |||
3097 | ocookie = | ||
3098 | xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, | ||
3099 | reply->config_timestamp); | ||
3100 | oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, | ||
3101 | ocookie, NULL); | ||
3102 | if (oreply) | ||
3103 | { | ||
3104 | if (num) *num = oreply->num_clones; | ||
3105 | |||
3106 | outputs = | ||
3107 | malloc(sizeof(Ecore_X_Randr_Output) * oreply->num_clones); | ||
3108 | if (outputs) | ||
3109 | { | ||
3110 | memcpy(outputs, xcb_randr_get_output_info_clones(oreply), | ||
3111 | sizeof(Ecore_X_Randr_Output) * oreply->num_clones); | ||
3112 | } | ||
3113 | free(oreply); | ||
3114 | } | ||
3115 | free(reply); | ||
3116 | } | ||
3117 | return outputs; | ||
3118 | } | ||
3119 | |||
3120 | static Ecore_X_Randr_Crtc * | ||
3121 | _ecore_xcb_randr_12_output_possible_crtcs_get(Ecore_X_Window root, | ||
3122 | Ecore_X_Randr_Output output, | ||
3123 | int *num) | ||
3124 | { | ||
3125 | Ecore_X_Randr_Crtc *crtcs = NULL; | ||
3126 | xcb_randr_get_screen_resources_reply_t *reply; | ||
3127 | |||
3128 | reply = _ecore_xcb_randr_12_get_resources(root); | ||
3129 | if (reply) | ||
3130 | { | ||
3131 | xcb_randr_get_output_info_cookie_t ocookie; | ||
3132 | xcb_randr_get_output_info_reply_t *oreply; | ||
3133 | |||
3134 | ocookie = | ||
3135 | xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, | ||
3136 | reply->config_timestamp); | ||
3137 | oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, | ||
3138 | ocookie, NULL); | ||
3139 | if (oreply) | ||
3140 | { | ||
3141 | if (num) *num = oreply->num_crtcs; | ||
3142 | |||
3143 | crtcs = malloc(sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs); | ||
3144 | if (crtcs) | ||
3145 | { | ||
3146 | memcpy(crtcs, xcb_randr_get_output_info_crtcs(oreply), | ||
3147 | sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs); | ||
3148 | } | ||
3149 | free(oreply); | ||
3150 | } | ||
3151 | free(reply); | ||
3152 | } | ||
3153 | return crtcs; | ||
3154 | } | ||
3155 | |||
3156 | static Ecore_X_Randr_Crtc * | ||
3157 | _ecore_xcb_randr_13_output_possible_crtcs_get(Ecore_X_Window root, | ||
3158 | Ecore_X_Randr_Output output, | ||
3159 | int *num) | ||
3160 | { | ||
3161 | Ecore_X_Randr_Crtc *crtcs = NULL; | ||
3162 | xcb_randr_get_screen_resources_current_reply_t *reply; | ||
3163 | |||
3164 | reply = _ecore_xcb_randr_13_get_resources(root); | ||
3165 | if (reply) | ||
3166 | { | ||
3167 | xcb_randr_get_output_info_cookie_t ocookie; | ||
3168 | xcb_randr_get_output_info_reply_t *oreply; | ||
3169 | |||
3170 | ocookie = | ||
3171 | xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, | ||
3172 | reply->config_timestamp); | ||
3173 | oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, | ||
3174 | ocookie, NULL); | ||
3175 | if (oreply) | ||
3176 | { | ||
3177 | if (num) *num = oreply->num_crtcs; | ||
3178 | |||
3179 | crtcs = malloc(sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs); | ||
3180 | if (crtcs) | ||
3181 | { | ||
3182 | memcpy(crtcs, xcb_randr_get_output_info_crtcs(oreply), | ||
3183 | sizeof(Ecore_X_Randr_Crtc) * oreply->num_crtcs); | ||
3184 | } | ||
3185 | free(oreply); | ||
3186 | } | ||
3187 | free(reply); | ||
3188 | } | ||
3189 | return crtcs; | ||
3190 | } | ||
3191 | |||
3192 | static char * | ||
3193 | _ecore_xcb_randr_12_output_name_get(Ecore_X_Window root, | ||
3194 | Ecore_X_Randr_Output output, | ||
3195 | int *len) | ||
3196 | { | ||
3197 | char *ret = NULL; | ||
3198 | xcb_randr_get_screen_resources_reply_t *reply; | ||
3199 | |||
3200 | reply = _ecore_xcb_randr_12_get_resources(root); | ||
3201 | if (reply) | ||
3202 | { | ||
3203 | xcb_randr_get_output_info_cookie_t ocookie; | ||
3204 | xcb_randr_get_output_info_reply_t *oreply; | ||
3205 | |||
3206 | ocookie = | ||
3207 | xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, | ||
3208 | reply->config_timestamp); | ||
3209 | oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, | ||
3210 | ocookie, NULL); | ||
3211 | if (oreply) | ||
3212 | { | ||
3213 | uint8_t *nbuf; | ||
3214 | |||
3215 | nbuf = xcb_randr_get_output_info_name(oreply); | ||
3216 | nbuf += oreply->name_len; | ||
3217 | |||
3218 | if (len) *len = oreply->name_len; | ||
3219 | if (oreply->name_len > 0) | ||
3220 | { | ||
3221 | ret = malloc(oreply->name_len + 1); | ||
3222 | if (ret) | ||
3223 | memcpy(ret, nbuf, oreply->name_len + 1); | ||
3224 | } | ||
3225 | |||
3226 | free(oreply); | ||
3227 | } | ||
3228 | free(reply); | ||
3229 | } | ||
3230 | return ret; | ||
3231 | } | ||
3232 | |||
3233 | static char * | ||
3234 | _ecore_xcb_randr_13_output_name_get(Ecore_X_Window root, | ||
3235 | Ecore_X_Randr_Output output, | ||
3236 | int *len) | ||
3237 | { | ||
3238 | char *ret = NULL; | ||
3239 | xcb_randr_get_screen_resources_current_reply_t *reply; | ||
3240 | |||
3241 | reply = _ecore_xcb_randr_13_get_resources(root); | ||
3242 | if (reply) | ||
3243 | { | ||
3244 | xcb_randr_get_output_info_cookie_t ocookie; | ||
3245 | xcb_randr_get_output_info_reply_t *oreply; | ||
3246 | |||
3247 | ocookie = | ||
3248 | xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, | ||
3249 | reply->config_timestamp); | ||
3250 | oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, | ||
3251 | ocookie, NULL); | ||
3252 | if (oreply) | ||
3253 | { | ||
3254 | uint8_t *nbuf; | ||
3255 | |||
3256 | nbuf = xcb_randr_get_output_info_name(oreply); | ||
3257 | nbuf += oreply->name_len; | ||
3258 | |||
3259 | if (len) *len = oreply->name_len; | ||
3260 | if (oreply->name_len > 0) | ||
3261 | { | ||
3262 | ret = malloc(oreply->name_len + 1); | ||
3263 | if (ret) | ||
3264 | memcpy(ret, nbuf, oreply->name_len + 1); | ||
3265 | } | ||
3266 | |||
3267 | free(oreply); | ||
3268 | } | ||
3269 | free(reply); | ||
3270 | } | ||
3271 | return ret; | ||
3272 | } | ||
3273 | |||
3274 | static Ecore_X_Randr_Connection_Status | ||
3275 | _ecore_xcb_randr_12_output_connection_status_get(Ecore_X_Window root, | ||
3276 | Ecore_X_Randr_Output output) | ||
3277 | { | ||
3278 | Ecore_X_Randr_Connection_Status ret = ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN; | ||
3279 | xcb_randr_get_screen_resources_reply_t *reply; | ||
3280 | |||
3281 | reply = _ecore_xcb_randr_12_get_resources(root); | ||
3282 | if (reply) | ||
3283 | { | ||
3284 | xcb_randr_get_output_info_cookie_t ocookie; | ||
3285 | xcb_randr_get_output_info_reply_t *oreply; | ||
3286 | |||
3287 | ocookie = | ||
3288 | xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, | ||
3289 | reply->config_timestamp); | ||
3290 | oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, | ||
3291 | ocookie, NULL); | ||
3292 | if (oreply) | ||
3293 | { | ||
3294 | ret = oreply->connection; | ||
3295 | free(oreply); | ||
3296 | } | ||
3297 | free(reply); | ||
3298 | } | ||
3299 | return ret; | ||
3300 | } | ||
3301 | |||
3302 | static Ecore_X_Randr_Connection_Status | ||
3303 | _ecore_xcb_randr_13_output_connection_status_get(Ecore_X_Window root, | ||
3304 | Ecore_X_Randr_Output output) | ||
3305 | { | ||
3306 | Ecore_X_Randr_Connection_Status ret = ECORE_X_RANDR_CONNECTION_STATUS_UNKNOWN; | ||
3307 | xcb_randr_get_screen_resources_current_reply_t *reply; | ||
3308 | |||
3309 | reply = _ecore_xcb_randr_13_get_resources(root); | ||
3310 | if (reply) | ||
3311 | { | ||
3312 | xcb_randr_get_output_info_cookie_t ocookie; | ||
3313 | xcb_randr_get_output_info_reply_t *oreply; | ||
3314 | |||
3315 | ocookie = | ||
3316 | xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, | ||
3317 | reply->config_timestamp); | ||
3318 | oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, | ||
3319 | ocookie, NULL); | ||
3320 | if (oreply) | ||
3321 | { | ||
3322 | ret = oreply->connection; | ||
3323 | free(oreply); | ||
3324 | } | ||
3325 | free(reply); | ||
3326 | } | ||
3327 | return ret; | ||
3328 | } | ||
3329 | |||
3330 | static Ecore_X_Randr_Output * | ||
3331 | _ecore_xcb_randr_12_outputs_get(Ecore_X_Window root, | ||
3332 | int *num) | ||
3333 | { | ||
3334 | Ecore_X_Randr_Output *ret = NULL; | ||
3335 | xcb_randr_get_screen_resources_reply_t *reply; | ||
3336 | |||
3337 | reply = _ecore_xcb_randr_12_get_resources(root); | ||
3338 | if (reply) | ||
3339 | { | ||
3340 | if (num) *num = reply->num_outputs; | ||
3341 | ret = malloc(sizeof(Ecore_X_Randr_Output) * reply->num_outputs); | ||
3342 | if (ret) | ||
3343 | memcpy(ret, xcb_randr_get_screen_resources_outputs(reply), | ||
3344 | sizeof(Ecore_X_Randr_Output) * reply->num_outputs); | ||
3345 | free(reply); | ||
3346 | } | ||
3347 | return ret; | ||
3348 | } | ||
3349 | |||
3350 | static Ecore_X_Randr_Output * | ||
3351 | _ecore_xcb_randr_13_outputs_get(Ecore_X_Window root, | ||
3352 | int *num) | ||
3353 | { | ||
3354 | Ecore_X_Randr_Output *ret = NULL; | ||
3355 | xcb_randr_get_screen_resources_current_reply_t *reply; | ||
3356 | |||
3357 | reply = _ecore_xcb_randr_13_get_resources(root); | ||
3358 | if (reply) | ||
3359 | { | ||
3360 | if (num) *num = reply->num_outputs; | ||
3361 | ret = malloc(sizeof(Ecore_X_Randr_Output) * reply->num_outputs); | ||
3362 | if (ret) | ||
3363 | memcpy(ret, xcb_randr_get_screen_resources_current_outputs(reply), | ||
3364 | sizeof(Ecore_X_Randr_Output) * reply->num_outputs); | ||
3365 | free(reply); | ||
3366 | } | ||
3367 | return ret; | ||
3368 | } | ||
3369 | |||
3370 | static Ecore_X_Randr_Crtc | ||
3371 | _ecore_xcb_randr_12_output_crtc_get(Ecore_X_Window root, | ||
3372 | Ecore_X_Randr_Output output) | ||
3373 | { | ||
3374 | Ecore_X_Randr_Crtc ret = Ecore_X_Randr_None; | ||
3375 | xcb_randr_get_screen_resources_reply_t *reply; | ||
3376 | |||
3377 | reply = _ecore_xcb_randr_12_get_resources(root); | ||
3378 | if (reply) | ||
3379 | { | ||
3380 | xcb_randr_get_output_info_cookie_t ocookie; | ||
3381 | xcb_randr_get_output_info_reply_t *oreply; | ||
3382 | |||
3383 | ocookie = | ||
3384 | xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, | ||
3385 | reply->config_timestamp); | ||
3386 | oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, | ||
3387 | ocookie, NULL); | ||
3388 | if (oreply) | ||
3389 | { | ||
3390 | ret = oreply->crtc; | ||
3391 | free(oreply); | ||
3392 | } | ||
3393 | free(reply); | ||
3394 | } | ||
3395 | return ret; | ||
3396 | } | ||
3397 | |||
3398 | static Ecore_X_Randr_Crtc | ||
3399 | _ecore_xcb_randr_13_output_crtc_get(Ecore_X_Window root, | ||
3400 | Ecore_X_Randr_Output output) | ||
3401 | { | ||
3402 | Ecore_X_Randr_Crtc ret = Ecore_X_Randr_None; | ||
3403 | xcb_randr_get_screen_resources_current_reply_t *reply; | ||
3404 | |||
3405 | reply = _ecore_xcb_randr_13_get_resources(root); | ||
3406 | if (reply) | ||
3407 | { | ||
3408 | xcb_randr_get_output_info_cookie_t ocookie; | ||
3409 | xcb_randr_get_output_info_reply_t *oreply; | ||
3410 | |||
3411 | ocookie = | ||
3412 | xcb_randr_get_output_info_unchecked(_ecore_xcb_conn, output, | ||
3413 | reply->config_timestamp); | ||
3414 | oreply = xcb_randr_get_output_info_reply(_ecore_xcb_conn, | ||
3415 | ocookie, NULL); | ||
3416 | if (oreply) | ||
3417 | { | ||
3418 | ret = oreply->crtc; | ||
3419 | free(oreply); | ||
3420 | } | ||
3421 | free(reply); | ||
3422 | } | ||
3423 | return ret; | ||
3424 | } | ||
3425 | |||
3426 | static xcb_randr_get_screen_resources_reply_t * | ||
3427 | _ecore_xcb_randr_12_get_resources(Ecore_X_Window win) | ||
3428 | { | ||
3429 | xcb_randr_get_screen_resources_cookie_t cookie; | ||
3430 | xcb_randr_get_screen_resources_reply_t *reply; | ||
3431 | |||
3432 | cookie = xcb_randr_get_screen_resources_unchecked(_ecore_xcb_conn, win); | ||
3433 | reply = xcb_randr_get_screen_resources_reply(_ecore_xcb_conn, cookie, NULL); | ||
3434 | return reply; | ||
3435 | } | ||
3436 | |||
3437 | static xcb_randr_get_screen_resources_current_reply_t * | ||
3438 | _ecore_xcb_randr_13_get_resources(Ecore_X_Window win) | ||
3439 | { | ||
3440 | xcb_randr_get_screen_resources_current_cookie_t cookie; | ||
3441 | xcb_randr_get_screen_resources_current_reply_t *reply; | ||
3442 | |||
3443 | cookie = | ||
3444 | xcb_randr_get_screen_resources_current_unchecked(_ecore_xcb_conn, win); | ||
3445 | reply = | ||
3446 | xcb_randr_get_screen_resources_current_reply(_ecore_xcb_conn, | ||
3447 | cookie, NULL); | ||
3448 | return reply; | ||
3449 | } | ||
3450 | |||
3451 | static xcb_timestamp_t | ||
3452 | _ecore_xcb_randr_12_get_resource_timestamp(Ecore_X_Window win) | ||
3453 | { | ||
3454 | xcb_timestamp_t stamp = 0; | ||
3455 | xcb_randr_get_screen_resources_reply_t *reply; | ||
3456 | |||
3457 | reply = _ecore_xcb_randr_12_get_resources(win); | ||
3458 | stamp = reply->config_timestamp; | ||
3459 | free(reply); | ||
3460 | return stamp; | ||
3461 | } | ||
3462 | |||
3463 | static xcb_timestamp_t | ||
3464 | _ecore_xcb_randr_13_get_resource_timestamp(Ecore_X_Window win) | ||
3465 | { | ||
3466 | xcb_timestamp_t stamp = 0; | ||
3467 | xcb_randr_get_screen_resources_current_reply_t *reply; | ||
3468 | |||
3469 | reply = _ecore_xcb_randr_13_get_resources(win); | ||
3470 | stamp = reply->config_timestamp; | ||
3471 | free(reply); | ||
3472 | return stamp; | ||
3473 | } | ||
3474 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_region.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_region.c new file mode 100644 index 0000000..a221d8f --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_region.c | |||
@@ -0,0 +1,159 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #include <pixman.h> | ||
3 | |||
4 | /* | ||
5 | * [ ] XPolygonRegion | ||
6 | * [ ] XShrinkRegion | ||
7 | * [ ] XClipBox | ||
8 | * [ ] XXorRegion | ||
9 | */ | ||
10 | |||
11 | EAPI Ecore_X_XRegion * | ||
12 | ecore_x_xregion_new() | ||
13 | { | ||
14 | pixman_region16_t *region; | ||
15 | |||
16 | region = (pixman_region16_t *)malloc(sizeof(pixman_region16_t)); | ||
17 | if (!region) return NULL; | ||
18 | |||
19 | pixman_region_init(region); | ||
20 | |||
21 | return (Ecore_X_XRegion *)region; | ||
22 | } | ||
23 | |||
24 | EAPI void | ||
25 | ecore_x_xregion_free(Ecore_X_XRegion *region) | ||
26 | { | ||
27 | if (!region) return; | ||
28 | |||
29 | pixman_region_fini(region); | ||
30 | free(region); | ||
31 | } | ||
32 | |||
33 | EAPI Eina_Bool | ||
34 | ecore_x_xregion_set(Ecore_X_XRegion *region, | ||
35 | Ecore_X_GC gc) | ||
36 | { | ||
37 | xcb_rectangle_t *rects; | ||
38 | pixman_box16_t *boxes; | ||
39 | int num = 0, i = 0; | ||
40 | |||
41 | CHECK_XCB_CONN; | ||
42 | |||
43 | if (!region) return EINA_FALSE; | ||
44 | |||
45 | boxes = pixman_region_rectangles((pixman_region16_t *)region, &num); | ||
46 | if ((!boxes) || (num == 0)) return EINA_FALSE; | ||
47 | |||
48 | rects = (xcb_rectangle_t *)malloc(sizeof(xcb_rectangle_t) * num); | ||
49 | if (!rects) return EINA_FALSE; | ||
50 | |||
51 | for (i = 0; i < num; i++) | ||
52 | { | ||
53 | rects[i].x = boxes[i].x1; | ||
54 | rects[i].y = boxes[i].y1; | ||
55 | rects[i].width = boxes[i].x2 - boxes[i].x1 + 1; | ||
56 | rects[i].height = boxes[i].y2 - boxes[i].y1 + 1; | ||
57 | } | ||
58 | |||
59 | xcb_set_clip_rectangles(_ecore_xcb_conn, XCB_CLIP_ORDERING_YX_BANDED, | ||
60 | gc, 0, 0, num, rects); | ||
61 | |||
62 | // ecore_x_flush(); | ||
63 | return EINA_TRUE; | ||
64 | } | ||
65 | |||
66 | EAPI void | ||
67 | ecore_x_xregion_translate(Ecore_X_XRegion *region, | ||
68 | int x, | ||
69 | int y) | ||
70 | { | ||
71 | if (!region) return; | ||
72 | |||
73 | pixman_region_translate((pixman_region16_t *)region, x, y); | ||
74 | } | ||
75 | |||
76 | EAPI Eina_Bool | ||
77 | ecore_x_xregion_intersect(Ecore_X_XRegion *dst, | ||
78 | Ecore_X_XRegion *r1, | ||
79 | Ecore_X_XRegion *r2) | ||
80 | { | ||
81 | return pixman_region_intersect((pixman_region16_t *)dst, | ||
82 | (pixman_region16_t *)r1, | ||
83 | (pixman_region16_t *)r2); | ||
84 | } | ||
85 | |||
86 | EAPI Eina_Bool | ||
87 | ecore_x_xregion_union(Ecore_X_XRegion *dst, | ||
88 | Ecore_X_XRegion *r1, | ||
89 | Ecore_X_XRegion *r2) | ||
90 | { | ||
91 | return pixman_region_union((pixman_region16_t *)dst, | ||
92 | (pixman_region16_t *)r1, | ||
93 | (pixman_region16_t *)r2); | ||
94 | } | ||
95 | |||
96 | EAPI Eina_Bool | ||
97 | ecore_x_xregion_union_rect(Ecore_X_XRegion *dst, | ||
98 | Ecore_X_XRegion *src, | ||
99 | Ecore_X_Rectangle *rect) | ||
100 | { | ||
101 | return pixman_region_union_rect((pixman_region16_t *)dst, | ||
102 | (pixman_region16_t *)src, | ||
103 | rect->x, rect->y, rect->width, rect->height); | ||
104 | } | ||
105 | |||
106 | EAPI Eina_Bool | ||
107 | ecore_x_xregion_subtract(Ecore_X_XRegion *dst, | ||
108 | Ecore_X_XRegion *rm, | ||
109 | Ecore_X_XRegion *rs) | ||
110 | { | ||
111 | return pixman_region_subtract((pixman_region16_t *)dst, | ||
112 | (pixman_region16_t *)rm, | ||
113 | (pixman_region16_t *)rs); | ||
114 | } | ||
115 | |||
116 | EAPI Eina_Bool | ||
117 | ecore_x_xregion_is_empty(Ecore_X_XRegion *region) | ||
118 | { | ||
119 | if (!region) return EINA_TRUE; | ||
120 | |||
121 | return !pixman_region_not_empty((pixman_region16_t *)region); | ||
122 | } | ||
123 | |||
124 | EAPI Eina_Bool | ||
125 | ecore_x_xregion_is_equal(Ecore_X_XRegion *r1, | ||
126 | Ecore_X_XRegion *r2) | ||
127 | { | ||
128 | if ((!r1) || (!r2)) return EINA_FALSE; | ||
129 | |||
130 | return pixman_region_equal((pixman_region16_t *)r1, | ||
131 | (pixman_region16_t *)r2); | ||
132 | } | ||
133 | |||
134 | EAPI Eina_Bool | ||
135 | ecore_x_xregion_point_contain(Ecore_X_XRegion *region, | ||
136 | int x, | ||
137 | int y) | ||
138 | { | ||
139 | if (!region) return EINA_FALSE; | ||
140 | |||
141 | return pixman_region_contains_point((pixman_region16_t *)region, x, y, NULL); | ||
142 | } | ||
143 | |||
144 | EAPI Eina_Bool | ||
145 | ecore_x_xregion_rect_contain(Ecore_X_XRegion *region, | ||
146 | Ecore_X_Rectangle *rect) | ||
147 | { | ||
148 | pixman_box16_t box; | ||
149 | |||
150 | if ((!region) || (!rect)) return EINA_FALSE; | ||
151 | |||
152 | box.x1 = rect->x; | ||
153 | box.y1 = rect->y; | ||
154 | box.x2 = rect->x + rect->width - 1; | ||
155 | box.y2 = rect->y + rect->height - 1; | ||
156 | |||
157 | return pixman_region_contains_rectangle((pixman_region16_t *)region, &box); | ||
158 | } | ||
159 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_render.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_render.c new file mode 100644 index 0000000..f36b4d2 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_render.c | |||
@@ -0,0 +1,225 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #include <ctype.h> // for isupper/tolower | ||
3 | #ifdef ECORE_XCB_RENDER | ||
4 | # include <xcb/render.h> | ||
5 | # include <xcb/xcb_renderutil.h> | ||
6 | #endif | ||
7 | |||
8 | /* local function prototypes */ | ||
9 | static Eina_Bool _ecore_xcb_render_parse_boolean(char *v); | ||
10 | |||
11 | /* local variables */ | ||
12 | static Eina_Bool _render_avail = EINA_FALSE; | ||
13 | static Eina_Bool _render_argb = EINA_FALSE; | ||
14 | static Eina_Bool _render_anim = EINA_FALSE; | ||
15 | |||
16 | void | ||
17 | _ecore_xcb_render_init(void) | ||
18 | { | ||
19 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
20 | |||
21 | #ifdef ECORE_XCB_RENDER | ||
22 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_render_id); | ||
23 | #endif | ||
24 | } | ||
25 | |||
26 | void | ||
27 | _ecore_xcb_render_finalize(void) | ||
28 | { | ||
29 | #ifdef ECORE_XCB_RENDER | ||
30 | const xcb_query_extension_reply_t *ext_reply; | ||
31 | #endif | ||
32 | |||
33 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
34 | |||
35 | #ifdef ECORE_XCB_RENDER | ||
36 | ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_render_id); | ||
37 | if ((ext_reply) && (ext_reply->present)) | ||
38 | { | ||
39 | xcb_render_query_version_cookie_t cookie; | ||
40 | xcb_render_query_version_reply_t *reply; | ||
41 | |||
42 | cookie = | ||
43 | xcb_render_query_version_unchecked(_ecore_xcb_conn, | ||
44 | XCB_RENDER_MAJOR_VERSION, | ||
45 | XCB_RENDER_MINOR_VERSION); | ||
46 | reply = xcb_render_query_version_reply(_ecore_xcb_conn, cookie, NULL); | ||
47 | if (reply) | ||
48 | { | ||
49 | // if ((reply->major_version >= XCB_RENDER_MAJOR_VERSION) && | ||
50 | if (reply->minor_version >= XCB_RENDER_MINOR_VERSION) | ||
51 | { | ||
52 | char *v = NULL; | ||
53 | |||
54 | _render_avail = EINA_TRUE; | ||
55 | _ecore_xcb_xdefaults_init(); | ||
56 | if ((reply->major_version > 0) || (reply->minor_version >= 5)) | ||
57 | { | ||
58 | _render_argb = EINA_TRUE; | ||
59 | v = getenv("XCURSOR_CORE"); | ||
60 | if (!v) | ||
61 | v = _ecore_xcb_xdefaults_string_get("Xcursor", "core"); | ||
62 | if ((v) && (_ecore_xcb_render_parse_boolean(v))) | ||
63 | _render_argb = EINA_FALSE; | ||
64 | } | ||
65 | if ((_render_argb) && | ||
66 | ((reply->major_version > 0) || (reply->minor_version >= 8))) | ||
67 | { | ||
68 | _render_anim = EINA_TRUE; | ||
69 | v = getenv("XCURSOR_ANIM"); | ||
70 | if (!v) | ||
71 | v = _ecore_xcb_xdefaults_string_get("Xcursor", "anim"); | ||
72 | if ((v) && (_ecore_xcb_render_parse_boolean(v))) | ||
73 | _render_anim = EINA_FALSE; | ||
74 | } | ||
75 | _ecore_xcb_xdefaults_shutdown(); | ||
76 | } | ||
77 | } | ||
78 | free(reply); | ||
79 | } | ||
80 | #endif | ||
81 | } | ||
82 | |||
83 | Eina_Bool | ||
84 | _ecore_xcb_render_avail_get(void) | ||
85 | { | ||
86 | return _render_avail; | ||
87 | } | ||
88 | |||
89 | Eina_Bool | ||
90 | _ecore_xcb_render_argb_get(void) | ||
91 | { | ||
92 | return _render_argb; | ||
93 | } | ||
94 | |||
95 | Eina_Bool | ||
96 | _ecore_xcb_render_anim_get(void) | ||
97 | { | ||
98 | return _render_anim; | ||
99 | } | ||
100 | |||
101 | Eina_Bool | ||
102 | _ecore_xcb_render_visual_supports_alpha(Ecore_X_Visual visual) | ||
103 | { | ||
104 | Eina_Bool ret = EINA_FALSE; | ||
105 | #ifdef ECORE_XCB_RENDER | ||
106 | const xcb_render_query_pict_formats_reply_t *reply; | ||
107 | xcb_render_pictvisual_t *vis; | ||
108 | #endif | ||
109 | |||
110 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
111 | CHECK_XCB_CONN; | ||
112 | |||
113 | if (!visual) return EINA_FALSE; | ||
114 | if (!_render_avail) return EINA_FALSE; | ||
115 | |||
116 | #ifdef ECORE_XCB_RENDER | ||
117 | reply = xcb_render_util_query_formats(_ecore_xcb_conn); | ||
118 | if (!reply) return EINA_FALSE; | ||
119 | |||
120 | vis = | ||
121 | xcb_render_util_find_visual_format(reply, | ||
122 | ((xcb_visualtype_t *)visual)->visual_id); | ||
123 | if (vis) | ||
124 | { | ||
125 | xcb_render_pictforminfo_t temp; | ||
126 | xcb_render_pictforminfo_t *format; | ||
127 | |||
128 | temp.id = vis->format; | ||
129 | format = | ||
130 | xcb_render_util_find_format(reply, XCB_PICT_FORMAT_ID, &temp, 0); | ||
131 | |||
132 | if ((format->type == XCB_RENDER_PICT_TYPE_DIRECT) && | ||
133 | (format->direct.alpha_mask)) | ||
134 | ret = EINA_TRUE; | ||
135 | } | ||
136 | |||
137 | #endif | ||
138 | |||
139 | return ret; | ||
140 | } | ||
141 | |||
142 | uint32_t | ||
143 | _ecore_xcb_render_find_visual_id(int type, | ||
144 | Eina_Bool check_alpha) | ||
145 | { | ||
146 | #ifdef ECORE_XCB_RENDER | ||
147 | const xcb_render_query_pict_formats_reply_t *reply; | ||
148 | xcb_render_pictvisual_t *visual = NULL; | ||
149 | xcb_render_pictscreen_iterator_t screens; | ||
150 | xcb_render_pictdepth_iterator_t depths; | ||
151 | xcb_render_pictvisual_iterator_t visuals; | ||
152 | #endif | ||
153 | |||
154 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
155 | CHECK_XCB_CONN; | ||
156 | |||
157 | if (!_render_avail) return 0; | ||
158 | |||
159 | #ifdef ECORE_XCB_RENDER | ||
160 | reply = xcb_render_util_query_formats(_ecore_xcb_conn); | ||
161 | if (!reply) return 0; | ||
162 | |||
163 | for (screens = xcb_render_query_pict_formats_screens_iterator(reply); | ||
164 | screens.rem; xcb_render_pictscreen_next(&screens)) | ||
165 | { | ||
166 | for (depths = xcb_render_pictscreen_depths_iterator(screens.data); | ||
167 | depths.rem; xcb_render_pictdepth_next(&depths)) | ||
168 | { | ||
169 | for (visuals = xcb_render_pictdepth_visuals_iterator(depths.data); | ||
170 | visuals.rem; xcb_render_pictvisual_next(&visuals)) | ||
171 | { | ||
172 | xcb_render_pictforminfo_t temp; | ||
173 | xcb_render_pictforminfo_t *format; | ||
174 | |||
175 | visual = visuals.data; | ||
176 | temp.id = visual->format; | ||
177 | |||
178 | format = | ||
179 | xcb_render_util_find_format(reply, XCB_PICT_FORMAT_ID, | ||
180 | &temp, 0); | ||
181 | if (!format) continue; | ||
182 | if (format->type == type) | ||
183 | { | ||
184 | if (check_alpha) | ||
185 | { | ||
186 | if (format->direct.alpha_mask) | ||
187 | return visual->visual; | ||
188 | } | ||
189 | else | ||
190 | return visual->visual; | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | #endif | ||
196 | |||
197 | return 0; | ||
198 | } | ||
199 | |||
200 | /* local function prototypes */ | ||
201 | static Eina_Bool | ||
202 | _ecore_xcb_render_parse_boolean(char *v) | ||
203 | { | ||
204 | char c; | ||
205 | |||
206 | c = *v; | ||
207 | if (isupper((int)c)) | ||
208 | c = tolower(c); | ||
209 | if ((c == 't') || (c == 'y') || (c == '1')) | ||
210 | return EINA_TRUE; | ||
211 | if ((c == 'f') || (c == 'n') || (c == '0')) | ||
212 | return EINA_FALSE; | ||
213 | if (c == 'o') | ||
214 | { | ||
215 | char d; | ||
216 | |||
217 | d = v[1]; | ||
218 | if (isupper((int)d)) | ||
219 | d = tolower(d); | ||
220 | if (d == 'n') return EINA_TRUE; | ||
221 | if (d == 'f') return EINA_FALSE; | ||
222 | } | ||
223 | return EINA_FALSE; | ||
224 | } | ||
225 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_screensaver.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_screensaver.c new file mode 100644 index 0000000..cb7249f --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_screensaver.c | |||
@@ -0,0 +1,338 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | # ifdef ECORE_XCB_SCREENSAVER | ||
3 | # include <xcb/screensaver.h> | ||
4 | # endif | ||
5 | |||
6 | /* local variables */ | ||
7 | static Eina_Bool _screensaver_avail = EINA_FALSE; | ||
8 | |||
9 | /* external variables */ | ||
10 | int _ecore_xcb_event_screensaver = -1; | ||
11 | |||
12 | void | ||
13 | _ecore_xcb_screensaver_init(void) | ||
14 | { | ||
15 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
16 | |||
17 | #ifdef ECORE_XCB_SCREENSAVER | ||
18 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_screensaver_id); | ||
19 | #endif | ||
20 | } | ||
21 | |||
22 | void | ||
23 | _ecore_xcb_screensaver_finalize(void) | ||
24 | { | ||
25 | #ifdef ECORE_XCB_SCREENSAVER | ||
26 | const xcb_query_extension_reply_t *ext_reply; | ||
27 | #endif | ||
28 | |||
29 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
30 | |||
31 | #ifdef ECORE_XCB_SCREENSAVER | ||
32 | ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_screensaver_id); | ||
33 | if ((ext_reply) && (ext_reply->present)) | ||
34 | { | ||
35 | xcb_screensaver_query_version_cookie_t cookie; | ||
36 | xcb_screensaver_query_version_reply_t *reply; | ||
37 | |||
38 | cookie = | ||
39 | xcb_screensaver_query_version_unchecked(_ecore_xcb_conn, | ||
40 | XCB_SCREENSAVER_MAJOR_VERSION, | ||
41 | XCB_SCREENSAVER_MINOR_VERSION); | ||
42 | reply = | ||
43 | xcb_screensaver_query_version_reply(_ecore_xcb_conn, cookie, NULL); | ||
44 | if (reply) | ||
45 | { | ||
46 | if ((reply->server_major_version >= XCB_SCREENSAVER_MAJOR_VERSION) && | ||
47 | (reply->server_minor_version >= XCB_SCREENSAVER_MINOR_VERSION)) | ||
48 | _screensaver_avail = EINA_TRUE; | ||
49 | |||
50 | free(reply); | ||
51 | } | ||
52 | |||
53 | if (_screensaver_avail) | ||
54 | _ecore_xcb_event_screensaver = ext_reply->first_event; | ||
55 | } | ||
56 | #endif | ||
57 | } | ||
58 | |||
59 | EAPI int | ||
60 | ecore_x_screensaver_idle_time_get(void) | ||
61 | { | ||
62 | int ret = 0; | ||
63 | #ifdef ECORE_XCB_SCREENSAVER | ||
64 | xcb_screensaver_query_info_cookie_t cookie; | ||
65 | xcb_screensaver_query_info_reply_t *reply; | ||
66 | Ecore_X_Window root; | ||
67 | #endif | ||
68 | |||
69 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
70 | CHECK_XCB_CONN; | ||
71 | |||
72 | if (!_screensaver_avail) return 0; | ||
73 | |||
74 | #ifdef ECORE_XCB_SCREENSAVER | ||
75 | root = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
76 | cookie = xcb_screensaver_query_info_unchecked(_ecore_xcb_conn, root); | ||
77 | reply = xcb_screensaver_query_info_reply(_ecore_xcb_conn, cookie, NULL); | ||
78 | if (!reply) return 0; | ||
79 | ret = (reply->ms_until_server / 1000); | ||
80 | free(reply); | ||
81 | #endif | ||
82 | |||
83 | return ret; | ||
84 | } | ||
85 | |||
86 | EAPI void | ||
87 | ecore_x_screensaver_set(int timeout, | ||
88 | int interval, | ||
89 | int prefer_blanking, | ||
90 | int allow_exposures) | ||
91 | { | ||
92 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
93 | CHECK_XCB_CONN; | ||
94 | |||
95 | if (!_screensaver_avail) return; | ||
96 | |||
97 | #ifdef ECORE_XCB_SCREENSAVER | ||
98 | xcb_set_screen_saver(_ecore_xcb_conn, | ||
99 | timeout, interval, prefer_blanking, allow_exposures); | ||
100 | #endif | ||
101 | } | ||
102 | |||
103 | EAPI void | ||
104 | ecore_x_screensaver_timeout_set(int timeout) | ||
105 | { | ||
106 | #ifdef ECORE_XCB_SCREENSAVER | ||
107 | xcb_get_screen_saver_cookie_t cookie; | ||
108 | xcb_get_screen_saver_reply_t *reply; | ||
109 | uint16_t pint; | ||
110 | uint8_t pblank, pexpo; | ||
111 | #endif | ||
112 | |||
113 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
114 | CHECK_XCB_CONN; | ||
115 | |||
116 | if (!_screensaver_avail) return; | ||
117 | |||
118 | #ifdef ECORE_XCB_SCREENSAVER | ||
119 | cookie = xcb_get_screen_saver_unchecked(_ecore_xcb_conn); | ||
120 | reply = xcb_get_screen_saver_reply(_ecore_xcb_conn, cookie, NULL); | ||
121 | if (!reply) return; | ||
122 | pint = reply->interval; | ||
123 | pblank = reply->prefer_blanking; | ||
124 | pexpo = reply->allow_exposures; | ||
125 | free(reply); | ||
126 | xcb_set_screen_saver(_ecore_xcb_conn, timeout, pint, pblank, pexpo); | ||
127 | #endif | ||
128 | } | ||
129 | |||
130 | EAPI int | ||
131 | ecore_x_screensaver_timeout_get(void) | ||
132 | { | ||
133 | int timeout = 0; | ||
134 | #ifdef ECORE_XCB_SCREENSAVER | ||
135 | xcb_get_screen_saver_cookie_t cookie; | ||
136 | xcb_get_screen_saver_reply_t *reply; | ||
137 | #endif | ||
138 | |||
139 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
140 | CHECK_XCB_CONN; | ||
141 | |||
142 | if (!_screensaver_avail) return 0; | ||
143 | |||
144 | #ifdef ECORE_XCB_SCREENSAVER | ||
145 | cookie = xcb_get_screen_saver_unchecked(_ecore_xcb_conn); | ||
146 | reply = xcb_get_screen_saver_reply(_ecore_xcb_conn, cookie, NULL); | ||
147 | if (!reply) return 0; | ||
148 | timeout = reply->timeout; | ||
149 | free(reply); | ||
150 | #endif | ||
151 | |||
152 | return timeout; | ||
153 | } | ||
154 | |||
155 | EAPI void | ||
156 | ecore_x_screensaver_blank_set(int blank) | ||
157 | { | ||
158 | #ifdef ECORE_XCB_SCREENSAVER | ||
159 | xcb_get_screen_saver_cookie_t cookie; | ||
160 | xcb_get_screen_saver_reply_t *reply; | ||
161 | uint16_t pint, pto; | ||
162 | uint8_t pexpo; | ||
163 | #endif | ||
164 | |||
165 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
166 | CHECK_XCB_CONN; | ||
167 | |||
168 | if (!_screensaver_avail) return; | ||
169 | |||
170 | #ifdef ECORE_XCB_SCREENSAVER | ||
171 | cookie = xcb_get_screen_saver_unchecked(_ecore_xcb_conn); | ||
172 | reply = xcb_get_screen_saver_reply(_ecore_xcb_conn, cookie, NULL); | ||
173 | if (!reply) return; | ||
174 | pto = reply->timeout; | ||
175 | pint = reply->interval; | ||
176 | pexpo = reply->allow_exposures; | ||
177 | free(reply); | ||
178 | xcb_set_screen_saver(_ecore_xcb_conn, pto, pint, blank, pexpo); | ||
179 | #endif | ||
180 | } | ||
181 | |||
182 | EAPI int | ||
183 | ecore_x_screensaver_blank_get(void) | ||
184 | { | ||
185 | int blank = 0; | ||
186 | #ifdef ECORE_XCB_SCREENSAVER | ||
187 | xcb_get_screen_saver_cookie_t cookie; | ||
188 | xcb_get_screen_saver_reply_t *reply; | ||
189 | #endif | ||
190 | |||
191 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
192 | CHECK_XCB_CONN; | ||
193 | |||
194 | if (!_screensaver_avail) return 0; | ||
195 | |||
196 | #ifdef ECORE_XCB_SCREENSAVER | ||
197 | cookie = xcb_get_screen_saver_unchecked(_ecore_xcb_conn); | ||
198 | reply = xcb_get_screen_saver_reply(_ecore_xcb_conn, cookie, NULL); | ||
199 | if (!reply) return 0; | ||
200 | blank = reply->prefer_blanking; | ||
201 | free(reply); | ||
202 | #endif | ||
203 | |||
204 | return blank; | ||
205 | } | ||
206 | |||
207 | EAPI void | ||
208 | ecore_x_screensaver_expose_set(int expose) | ||
209 | { | ||
210 | #ifdef ECORE_XCB_SCREENSAVER | ||
211 | xcb_get_screen_saver_cookie_t cookie; | ||
212 | xcb_get_screen_saver_reply_t *reply; | ||
213 | uint16_t pint, pto; | ||
214 | uint8_t pblank; | ||
215 | #endif | ||
216 | |||
217 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
218 | CHECK_XCB_CONN; | ||
219 | |||
220 | if (!_screensaver_avail) return; | ||
221 | |||
222 | #ifdef ECORE_XCB_SCREENSAVER | ||
223 | cookie = xcb_get_screen_saver_unchecked(_ecore_xcb_conn); | ||
224 | reply = xcb_get_screen_saver_reply(_ecore_xcb_conn, cookie, NULL); | ||
225 | if (!reply) return; | ||
226 | pto = reply->timeout; | ||
227 | pint = reply->interval; | ||
228 | pblank = reply->prefer_blanking; | ||
229 | free(reply); | ||
230 | xcb_set_screen_saver(_ecore_xcb_conn, pto, pint, pblank, expose); | ||
231 | #endif | ||
232 | } | ||
233 | |||
234 | EAPI int | ||
235 | ecore_x_screensaver_expose_get(void) | ||
236 | { | ||
237 | int expose = 0; | ||
238 | #ifdef ECORE_XCB_SCREENSAVER | ||
239 | xcb_get_screen_saver_cookie_t cookie; | ||
240 | xcb_get_screen_saver_reply_t *reply; | ||
241 | #endif | ||
242 | |||
243 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
244 | CHECK_XCB_CONN; | ||
245 | |||
246 | if (!_screensaver_avail) return 0; | ||
247 | |||
248 | #ifdef ECORE_XCB_SCREENSAVER | ||
249 | cookie = xcb_get_screen_saver_unchecked(_ecore_xcb_conn); | ||
250 | reply = xcb_get_screen_saver_reply(_ecore_xcb_conn, cookie, NULL); | ||
251 | if (!reply) return 0; | ||
252 | expose = reply->allow_exposures; | ||
253 | free(reply); | ||
254 | #endif | ||
255 | |||
256 | return expose; | ||
257 | } | ||
258 | |||
259 | EAPI void | ||
260 | ecore_x_screensaver_interval_set(int interval) | ||
261 | { | ||
262 | #ifdef ECORE_XCB_SCREENSAVER | ||
263 | xcb_get_screen_saver_cookie_t cookie; | ||
264 | xcb_get_screen_saver_reply_t *reply; | ||
265 | uint16_t pto; | ||
266 | uint8_t pblank, pexpose; | ||
267 | #endif | ||
268 | |||
269 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
270 | CHECK_XCB_CONN; | ||
271 | |||
272 | if (!_screensaver_avail) return; | ||
273 | |||
274 | #ifdef ECORE_XCB_SCREENSAVER | ||
275 | cookie = xcb_get_screen_saver_unchecked(_ecore_xcb_conn); | ||
276 | reply = xcb_get_screen_saver_reply(_ecore_xcb_conn, cookie, NULL); | ||
277 | if (!reply) return; | ||
278 | pto = reply->timeout; | ||
279 | pblank = reply->prefer_blanking; | ||
280 | pexpose = reply->allow_exposures; | ||
281 | free(reply); | ||
282 | xcb_set_screen_saver(_ecore_xcb_conn, pto, interval, pblank, pexpose); | ||
283 | #endif | ||
284 | } | ||
285 | |||
286 | EAPI int | ||
287 | ecore_x_screensaver_interval_get(void) | ||
288 | { | ||
289 | int interval = 0; | ||
290 | #ifdef ECORE_XCB_SCREENSAVER | ||
291 | xcb_get_screen_saver_cookie_t cookie; | ||
292 | xcb_get_screen_saver_reply_t *reply; | ||
293 | #endif | ||
294 | |||
295 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
296 | CHECK_XCB_CONN; | ||
297 | |||
298 | if (!_screensaver_avail) return 0; | ||
299 | |||
300 | #ifdef ECORE_XCB_SCREENSAVER | ||
301 | cookie = xcb_get_screen_saver_unchecked(_ecore_xcb_conn); | ||
302 | reply = xcb_get_screen_saver_reply(_ecore_xcb_conn, cookie, NULL); | ||
303 | if (!reply) return 0; | ||
304 | interval = reply->interval; | ||
305 | free(reply); | ||
306 | #endif | ||
307 | |||
308 | return interval; | ||
309 | } | ||
310 | |||
311 | EAPI void | ||
312 | ecore_x_screensaver_event_listen_set(Eina_Bool on) | ||
313 | { | ||
314 | #ifdef ECORE_XCB_SCREENSAVER | ||
315 | Ecore_X_Window root; | ||
316 | #endif | ||
317 | |||
318 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
319 | CHECK_XCB_CONN; | ||
320 | |||
321 | if (!_screensaver_avail) return; | ||
322 | |||
323 | #ifdef ECORE_XCB_SCREENSAVER | ||
324 | root = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
325 | if (on) | ||
326 | xcb_screensaver_select_input(_ecore_xcb_conn, root, | ||
327 | XCB_SCREENSAVER_EVENT_NOTIFY_MASK); | ||
328 | else | ||
329 | xcb_screensaver_select_input(_ecore_xcb_conn, root, 0); | ||
330 | #endif | ||
331 | } | ||
332 | |||
333 | EAPI Eina_Bool | ||
334 | ecore_x_screensaver_event_available_get(void) | ||
335 | { | ||
336 | return _screensaver_avail; | ||
337 | } | ||
338 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_selection.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_selection.c new file mode 100644 index 0000000..7b994bd --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_selection.c | |||
@@ -0,0 +1,1039 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | //#include "Ecore_X_Atoms.h" | ||
3 | |||
4 | #define ECORE_XCB_SELECTION_DATA(x) ((Ecore_X_Selection_Data *)(x)) | ||
5 | |||
6 | /* local function prototypes */ | ||
7 | static Eina_Bool _ecore_xcb_selection_converter_text(char *target, | ||
8 | void *data, | ||
9 | int size, | ||
10 | void **data_ret, | ||
11 | int *size_ret, | ||
12 | Ecore_X_Atom *type, | ||
13 | int *size_type); | ||
14 | static void *_ecore_xcb_selection_parser_text(const char *target __UNUSED__, | ||
15 | void *data, | ||
16 | int size, | ||
17 | int format __UNUSED__); | ||
18 | static void *_ecore_xcb_selection_parser_files(const char *target, | ||
19 | void *data, | ||
20 | int size, | ||
21 | int format __UNUSED__); | ||
22 | static void *_ecore_xcb_selection_parser_targets(const char *target __UNUSED__, | ||
23 | void *data, | ||
24 | int size, | ||
25 | int format __UNUSED__); | ||
26 | |||
27 | //static int _ecore_xcb_selection_data_free(void *data); | ||
28 | static int _ecore_xcb_selection_data_text_free(void *data); | ||
29 | static int _ecore_xcb_selection_data_targets_free(void *data); | ||
30 | static int _ecore_xcb_selection_data_files_free(void *data); | ||
31 | static int _ecore_xcb_selection_data_default_free(void *data); | ||
32 | static Eina_Bool _ecore_xcb_selection_set(Ecore_X_Window win, | ||
33 | const void *data, | ||
34 | int size, | ||
35 | Ecore_X_Atom selection); | ||
36 | static void _ecore_xcb_selection_request(Ecore_X_Window win, | ||
37 | Ecore_X_Atom selection, | ||
38 | const char *target); | ||
39 | static Ecore_X_Atom _ecore_xcb_selection_target_atom_get(const char *target); | ||
40 | |||
41 | /* local variables */ | ||
42 | static Ecore_X_Selection_Intern _selections[4]; | ||
43 | static Ecore_X_Selection_Converter *_converters = NULL; | ||
44 | static Ecore_X_Selection_Parser *_parsers = NULL; | ||
45 | |||
46 | /* local functions */ | ||
47 | void | ||
48 | _ecore_xcb_selection_init(void) | ||
49 | { | ||
50 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
51 | |||
52 | memset(_selections, 0, sizeof(_selections)); | ||
53 | |||
54 | /* init converters */ | ||
55 | ecore_x_selection_converter_atom_add(ECORE_X_ATOM_TEXT, | ||
56 | _ecore_xcb_selection_converter_text); | ||
57 | ecore_x_selection_converter_atom_add(ECORE_X_ATOM_UTF8_STRING, | ||
58 | _ecore_xcb_selection_converter_text); | ||
59 | ecore_x_selection_converter_atom_add(ECORE_X_ATOM_COMPOUND_TEXT, | ||
60 | _ecore_xcb_selection_converter_text); | ||
61 | ecore_x_selection_converter_atom_add(ECORE_X_ATOM_STRING, | ||
62 | _ecore_xcb_selection_converter_text); | ||
63 | |||
64 | /* init parsers */ | ||
65 | ecore_x_selection_parser_add("text/plain", | ||
66 | _ecore_xcb_selection_parser_text); | ||
67 | ecore_x_selection_parser_add(ECORE_X_SELECTION_TARGET_UTF8_STRING, | ||
68 | _ecore_xcb_selection_parser_text); | ||
69 | ecore_x_selection_parser_add("text/uri-list", | ||
70 | _ecore_xcb_selection_parser_files); | ||
71 | ecore_x_selection_parser_add("_NETSCAPE_URL", | ||
72 | _ecore_xcb_selection_parser_files); | ||
73 | ecore_x_selection_parser_add(ECORE_X_SELECTION_TARGET_TARGETS, | ||
74 | _ecore_xcb_selection_parser_targets); | ||
75 | } | ||
76 | |||
77 | void | ||
78 | _ecore_xcb_selection_shutdown(void) | ||
79 | { | ||
80 | Ecore_X_Selection_Converter *cnv; | ||
81 | Ecore_X_Selection_Parser *prs; | ||
82 | |||
83 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
84 | |||
85 | /* free selection converters */ | ||
86 | cnv = _converters; | ||
87 | while (cnv) | ||
88 | { | ||
89 | Ecore_X_Selection_Converter *tmp; | ||
90 | |||
91 | tmp = cnv->next; | ||
92 | free(cnv); | ||
93 | cnv = tmp; | ||
94 | } | ||
95 | _converters = NULL; | ||
96 | |||
97 | /* free parsers */ | ||
98 | prs = _parsers; | ||
99 | while (prs) | ||
100 | { | ||
101 | Ecore_X_Selection_Parser *tmp; | ||
102 | |||
103 | tmp = prs; | ||
104 | prs = prs->next; | ||
105 | free(tmp->target); | ||
106 | free(tmp); | ||
107 | } | ||
108 | _parsers = NULL; | ||
109 | } | ||
110 | |||
111 | /* public functions */ | ||
112 | EAPI void | ||
113 | ecore_x_selection_converter_atom_add(Ecore_X_Atom target, | ||
114 | Eina_Bool (*func)(char *target, | ||
115 | void *data, | ||
116 | int size, | ||
117 | void **data_ret, | ||
118 | int *size_ret, | ||
119 | Ecore_X_Atom *type, | ||
120 | int *size_type)) | ||
121 | { | ||
122 | Ecore_X_Selection_Converter *cnv; | ||
123 | |||
124 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
125 | |||
126 | cnv = _converters; | ||
127 | if (_converters) | ||
128 | { | ||
129 | while (1) | ||
130 | { | ||
131 | if (cnv->target == target) | ||
132 | { | ||
133 | cnv->convert = func; | ||
134 | return; | ||
135 | } | ||
136 | if (cnv->next) | ||
137 | cnv = cnv->next; | ||
138 | else | ||
139 | break; | ||
140 | } | ||
141 | cnv->next = calloc(1, sizeof(Ecore_X_Selection_Converter)); | ||
142 | if (!cnv->next) return; | ||
143 | cnv = cnv->next; | ||
144 | } | ||
145 | else | ||
146 | { | ||
147 | _converters = calloc(1, sizeof(Ecore_X_Selection_Converter)); | ||
148 | if (!_converters) return; | ||
149 | cnv = _converters; | ||
150 | } | ||
151 | cnv->target = target; | ||
152 | cnv->convert = func; | ||
153 | } | ||
154 | |||
155 | EAPI void | ||
156 | ecore_x_selection_converter_add(char *target, | ||
157 | Eina_Bool (*func)(char *target, | ||
158 | void *data, | ||
159 | int size, | ||
160 | void **date_ret, | ||
161 | int *size_ret, | ||
162 | Ecore_X_Atom *atom_ret, | ||
163 | int *ret)) | ||
164 | { | ||
165 | Ecore_X_Atom atarget; | ||
166 | |||
167 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
168 | |||
169 | if ((!func) || (!target)) return; | ||
170 | atarget = _ecore_xcb_selection_target_atom_get(target); | ||
171 | ecore_x_selection_converter_atom_add(atarget, func); | ||
172 | } | ||
173 | |||
174 | EAPI void | ||
175 | ecore_x_selection_converter_del(char *target) | ||
176 | { | ||
177 | Ecore_X_Atom atarget; | ||
178 | |||
179 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
180 | |||
181 | if (!target) return; | ||
182 | atarget = _ecore_xcb_selection_target_atom_get(target); | ||
183 | ecore_x_selection_converter_atom_del(atarget); | ||
184 | } | ||
185 | |||
186 | EAPI void | ||
187 | ecore_x_selection_converter_atom_del(Ecore_X_Atom target) | ||
188 | { | ||
189 | Ecore_X_Selection_Converter *conv, *pconv = NULL; | ||
190 | |||
191 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
192 | |||
193 | conv = _converters; | ||
194 | while (conv) | ||
195 | { | ||
196 | if (conv->target == target) | ||
197 | { | ||
198 | if (pconv) | ||
199 | pconv->next = conv->next; | ||
200 | else | ||
201 | _converters = conv->next; | ||
202 | free(conv); | ||
203 | return; | ||
204 | } | ||
205 | pconv = conv; | ||
206 | conv = conv->next; | ||
207 | } | ||
208 | } | ||
209 | |||
210 | EAPI void | ||
211 | ecore_x_selection_parser_add(const char *target, | ||
212 | void *(*func)(const char *target, void *data, int size, int format)) | ||
213 | { | ||
214 | Ecore_X_Selection_Parser *prs; | ||
215 | |||
216 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
217 | |||
218 | if (!target) return; | ||
219 | prs = _parsers; | ||
220 | if (prs) | ||
221 | { | ||
222 | while (prs->next) | ||
223 | { | ||
224 | if (!strcmp(prs->target, target)) | ||
225 | { | ||
226 | prs->parse = func; | ||
227 | return; | ||
228 | } | ||
229 | prs = prs->next; | ||
230 | } | ||
231 | prs->next = calloc(1, sizeof(Ecore_X_Selection_Parser)); | ||
232 | prs = prs->next; | ||
233 | } | ||
234 | else | ||
235 | { | ||
236 | _parsers = calloc(1, sizeof(Ecore_X_Selection_Parser)); | ||
237 | prs = _parsers; | ||
238 | } | ||
239 | prs->target = strdup(target); | ||
240 | prs->parse = func; | ||
241 | } | ||
242 | |||
243 | EAPI void | ||
244 | ecore_x_selection_parser_del(const char *target) | ||
245 | { | ||
246 | Ecore_X_Selection_Parser *prs, *pprs = NULL; | ||
247 | |||
248 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
249 | |||
250 | if (!target) return; | ||
251 | |||
252 | prs = _parsers; | ||
253 | while (prs) | ||
254 | { | ||
255 | if (!strcmp(prs->target, target)) | ||
256 | { | ||
257 | if (pprs) | ||
258 | pprs->next = prs->next; | ||
259 | else | ||
260 | _parsers = prs->next; | ||
261 | free(prs->target); | ||
262 | free(prs); | ||
263 | return; | ||
264 | } | ||
265 | pprs = prs; | ||
266 | prs = prs->next; | ||
267 | } | ||
268 | } | ||
269 | |||
270 | /** | ||
271 | * Claim ownership of the PRIMARY selection and set its data. | ||
272 | * @param w The window to which this selection belongs | ||
273 | * @param data The data associated with the selection | ||
274 | * @param size The size of the data buffer in bytes | ||
275 | * @return Returns 1 if the ownership of the selection was successfully | ||
276 | * claimed, or 0 if unsuccessful. | ||
277 | */ | ||
278 | EAPI Eina_Bool | ||
279 | ecore_x_selection_primary_set(Ecore_X_Window win, | ||
280 | const void *data, | ||
281 | int size) | ||
282 | { | ||
283 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
284 | |||
285 | return _ecore_xcb_selection_set(win, data, size, | ||
286 | ECORE_X_ATOM_SELECTION_PRIMARY); | ||
287 | } | ||
288 | |||
289 | /** | ||
290 | * Release ownership of the primary selection | ||
291 | * @return Returns 1 if the selection was successfully cleared, | ||
292 | * or 0 if unsuccessful. | ||
293 | */ | ||
294 | EAPI Eina_Bool | ||
295 | ecore_x_selection_primary_clear(void) | ||
296 | { | ||
297 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
298 | |||
299 | return _ecore_xcb_selection_set(XCB_NONE, NULL, 0, | ||
300 | ECORE_X_ATOM_SELECTION_PRIMARY); | ||
301 | } | ||
302 | |||
303 | EAPI void | ||
304 | ecore_x_selection_primary_request(Ecore_X_Window win, | ||
305 | const char *target) | ||
306 | { | ||
307 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
308 | |||
309 | _ecore_xcb_selection_request(win, ECORE_X_ATOM_SELECTION_PRIMARY, target); | ||
310 | } | ||
311 | |||
312 | /** | ||
313 | * Claim ownership of the SECONDARY selection and set its data. | ||
314 | * @param w The window to which this selection belongs | ||
315 | * @param data The data associated with the selection | ||
316 | * @param size The size of the data buffer in bytes | ||
317 | * @return Returns 1 if the ownership of the selection was successfully | ||
318 | * claimed, or 0 if unsuccessful. | ||
319 | */ | ||
320 | EAPI Eina_Bool | ||
321 | ecore_x_selection_secondary_set(Ecore_X_Window win, | ||
322 | const void *data, | ||
323 | int size) | ||
324 | { | ||
325 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
326 | |||
327 | return _ecore_xcb_selection_set(win, data, size, | ||
328 | ECORE_X_ATOM_SELECTION_SECONDARY); | ||
329 | } | ||
330 | |||
331 | /** | ||
332 | * Release ownership of the secondary selection | ||
333 | * @return Returns 1 if the selection was successfully cleared, | ||
334 | * or 0 if unsuccessful. | ||
335 | */ | ||
336 | EAPI Eina_Bool | ||
337 | ecore_x_selection_secondary_clear(void) | ||
338 | { | ||
339 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
340 | |||
341 | return _ecore_xcb_selection_set(XCB_NONE, NULL, 0, | ||
342 | ECORE_X_ATOM_SELECTION_SECONDARY); | ||
343 | } | ||
344 | |||
345 | EAPI void | ||
346 | ecore_x_selection_secondary_request(Ecore_X_Window win, | ||
347 | const char *target) | ||
348 | { | ||
349 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
350 | |||
351 | _ecore_xcb_selection_request(win, ECORE_X_ATOM_SELECTION_SECONDARY, target); | ||
352 | } | ||
353 | |||
354 | /** | ||
355 | * Claim ownership of the XDND selection and set its data. | ||
356 | * @param w The window to which this selection belongs | ||
357 | * @param data The data associated with the selection | ||
358 | * @param size The size of the data buffer in bytes | ||
359 | * @return Returns 1 if the ownership of the selection was successfully | ||
360 | * claimed, or 0 if unsuccessful. | ||
361 | */ | ||
362 | EAPI Eina_Bool | ||
363 | ecore_x_selection_xdnd_set(Ecore_X_Window win, | ||
364 | const void *data, | ||
365 | int size) | ||
366 | { | ||
367 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
368 | |||
369 | return _ecore_xcb_selection_set(win, data, size, | ||
370 | ECORE_X_ATOM_SELECTION_XDND); | ||
371 | } | ||
372 | |||
373 | /** | ||
374 | * Release ownership of the XDND selection | ||
375 | * @return Returns 1 if the selection was successfully cleared, | ||
376 | * or 0 if unsuccessful. | ||
377 | */ | ||
378 | EAPI Eina_Bool | ||
379 | ecore_x_selection_xdnd_clear(void) | ||
380 | { | ||
381 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
382 | |||
383 | return _ecore_xcb_selection_set(XCB_NONE, NULL, 0, | ||
384 | ECORE_X_ATOM_SELECTION_XDND); | ||
385 | } | ||
386 | |||
387 | EAPI void | ||
388 | ecore_x_selection_xdnd_request(Ecore_X_Window win, | ||
389 | const char *target) | ||
390 | { | ||
391 | Ecore_X_Atom atom; | ||
392 | Ecore_X_DND_Target *_target; | ||
393 | |||
394 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
395 | CHECK_XCB_CONN; | ||
396 | |||
397 | _target = _ecore_xcb_dnd_target_get(); | ||
398 | atom = _ecore_xcb_selection_target_atom_get(target); | ||
399 | |||
400 | xcb_convert_selection(_ecore_xcb_conn, win, ECORE_X_ATOM_SELECTION_XDND, | ||
401 | atom, ECORE_X_ATOM_SELECTION_PROP_XDND, _target->time); | ||
402 | } | ||
403 | |||
404 | /** | ||
405 | * Claim ownership of the CLIPBOARD selection and set its data. | ||
406 | * @param w The window to which this selection belongs | ||
407 | * @param data The data associated with the selection | ||
408 | * @param size The size of the data buffer in bytes | ||
409 | * @return Returns 1 if the ownership of the selection was successfully | ||
410 | * claimed, or 0 if unsuccessful. | ||
411 | * | ||
412 | * Get the converted data from a previous CLIPBOARD selection | ||
413 | * request. The buffer must be freed when done with. | ||
414 | */ | ||
415 | EAPI Eina_Bool | ||
416 | ecore_x_selection_clipboard_set(Ecore_X_Window win, | ||
417 | const void *data, | ||
418 | int size) | ||
419 | { | ||
420 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
421 | |||
422 | return _ecore_xcb_selection_set(win, data, size, | ||
423 | ECORE_X_ATOM_SELECTION_CLIPBOARD); | ||
424 | } | ||
425 | |||
426 | /** | ||
427 | * Release ownership of the clipboard selection | ||
428 | * @return Returns 1 if the selection was successfully cleared, | ||
429 | * or 0 if unsuccessful. | ||
430 | */ | ||
431 | EAPI Eina_Bool | ||
432 | ecore_x_selection_clipboard_clear(void) | ||
433 | { | ||
434 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
435 | |||
436 | return _ecore_xcb_selection_set(XCB_NONE, NULL, 0, | ||
437 | ECORE_X_ATOM_SELECTION_CLIPBOARD); | ||
438 | } | ||
439 | |||
440 | EAPI void | ||
441 | ecore_x_selection_clipboard_request(Ecore_X_Window win, | ||
442 | const char *target) | ||
443 | { | ||
444 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
445 | |||
446 | _ecore_xcb_selection_request(win, ECORE_X_ATOM_SELECTION_CLIPBOARD, target); | ||
447 | } | ||
448 | |||
449 | EAPI Eina_Bool | ||
450 | ecore_x_selection_convert(Ecore_X_Atom selection, | ||
451 | Ecore_X_Atom target, | ||
452 | void **data_ret, | ||
453 | int *size, | ||
454 | Ecore_X_Atom *targtype, | ||
455 | int *typesize) | ||
456 | { | ||
457 | Ecore_X_Selection_Intern *sel; | ||
458 | Ecore_X_Selection_Converter *cnv; | ||
459 | void *data; | ||
460 | char *tgt_str; | ||
461 | |||
462 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
463 | |||
464 | sel = _ecore_xcb_selection_get(selection); | ||
465 | tgt_str = _ecore_xcb_selection_target_get(target); | ||
466 | |||
467 | for (cnv = _converters; cnv; cnv = cnv->next) | ||
468 | { | ||
469 | if (cnv->target == target) | ||
470 | { | ||
471 | int r = 0; | ||
472 | |||
473 | r = cnv->convert(tgt_str, sel->data, sel->length, &data, size, | ||
474 | targtype, typesize); | ||
475 | free(tgt_str); | ||
476 | if (r) | ||
477 | { | ||
478 | if (data_ret) *data_ret = data; | ||
479 | return r; | ||
480 | } | ||
481 | else | ||
482 | return EINA_FALSE; | ||
483 | } | ||
484 | } | ||
485 | |||
486 | return EINA_FALSE; | ||
487 | } | ||
488 | |||
489 | EAPI Eina_Bool | ||
490 | ecore_x_selection_notify_send(Ecore_X_Window requestor, | ||
491 | Ecore_X_Atom selection, | ||
492 | Ecore_X_Atom target, | ||
493 | Ecore_X_Atom property, | ||
494 | Ecore_X_Time tim) | ||
495 | { | ||
496 | xcb_selection_notify_event_t ev; | ||
497 | |||
498 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
499 | CHECK_XCB_CONN; | ||
500 | |||
501 | memset(&ev, 0, sizeof(xcb_selection_notify_event_t)); | ||
502 | |||
503 | ev.response_type = XCB_SELECTION_NOTIFY; | ||
504 | ev.requestor = requestor; | ||
505 | ev.selection = selection; | ||
506 | ev.target = target; | ||
507 | ev.property = property; | ||
508 | ev.time = tim; | ||
509 | |||
510 | xcb_send_event(_ecore_xcb_conn, 0, requestor, | ||
511 | XCB_EVENT_MASK_NO_EVENT, (const char *)&ev); | ||
512 | // ecore_x_flush(); | ||
513 | |||
514 | return EINA_TRUE; | ||
515 | } | ||
516 | |||
517 | EAPI void | ||
518 | ecore_x_selection_owner_set(Ecore_X_Window win, | ||
519 | Ecore_X_Atom atom, | ||
520 | Ecore_X_Time tim) | ||
521 | { | ||
522 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
523 | CHECK_XCB_CONN; | ||
524 | |||
525 | xcb_set_selection_owner(_ecore_xcb_conn, win, atom, tim); | ||
526 | } | ||
527 | |||
528 | EAPI Ecore_X_Window | ||
529 | ecore_x_selection_owner_get(Ecore_X_Atom atom) | ||
530 | { | ||
531 | xcb_get_selection_owner_cookie_t cookie; | ||
532 | xcb_get_selection_owner_reply_t *reply; | ||
533 | Ecore_X_Window ret; | ||
534 | |||
535 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
536 | CHECK_XCB_CONN; | ||
537 | |||
538 | cookie = xcb_get_selection_owner(_ecore_xcb_conn, atom); | ||
539 | reply = xcb_get_selection_owner_reply(_ecore_xcb_conn, cookie, NULL); | ||
540 | if (!reply) return 0; | ||
541 | ret = reply->owner; | ||
542 | free(reply); | ||
543 | return ret; | ||
544 | } | ||
545 | |||
546 | void * | ||
547 | _ecore_xcb_selection_parse(const char *target, | ||
548 | void *data, | ||
549 | int size, | ||
550 | int format) | ||
551 | { | ||
552 | Ecore_X_Selection_Parser *prs; | ||
553 | Ecore_X_Selection_Data *sel; | ||
554 | |||
555 | for (prs = _parsers; prs; prs = prs->next) | ||
556 | { | ||
557 | if (!strcmp(prs->target, target)) | ||
558 | { | ||
559 | sel = prs->parse(target, data, size, format); | ||
560 | if (sel) return sel; | ||
561 | } | ||
562 | } | ||
563 | |||
564 | sel = calloc(1, sizeof(Ecore_X_Selection_Data)); | ||
565 | if (!sel) return NULL; | ||
566 | sel->free = _ecore_xcb_selection_data_default_free; | ||
567 | sel->length = size; | ||
568 | sel->format = format; | ||
569 | sel->data = data; | ||
570 | |||
571 | return sel; | ||
572 | } | ||
573 | |||
574 | Ecore_X_Selection_Intern * | ||
575 | _ecore_xcb_selection_get(Ecore_X_Atom selection) | ||
576 | { | ||
577 | if (selection == ECORE_X_ATOM_SELECTION_PRIMARY) | ||
578 | return &_selections[0]; | ||
579 | else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY) | ||
580 | return &_selections[1]; | ||
581 | else if (selection == ECORE_X_ATOM_SELECTION_XDND) | ||
582 | return &_selections[2]; | ||
583 | else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD) | ||
584 | return &_selections[3]; | ||
585 | else | ||
586 | return NULL; | ||
587 | } | ||
588 | |||
589 | /* local functions */ | ||
590 | static Eina_Bool | ||
591 | _ecore_xcb_selection_set(Ecore_X_Window win, | ||
592 | const void *data, | ||
593 | int size, | ||
594 | Ecore_X_Atom selection) | ||
595 | { | ||
596 | xcb_get_selection_owner_cookie_t cookie; | ||
597 | xcb_get_selection_owner_reply_t *reply; | ||
598 | int in = 0; | ||
599 | |||
600 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
601 | CHECK_XCB_CONN; | ||
602 | |||
603 | xcb_set_selection_owner(_ecore_xcb_conn, win, selection, XCB_CURRENT_TIME); | ||
604 | |||
605 | cookie = xcb_get_selection_owner(_ecore_xcb_conn, selection); | ||
606 | reply = xcb_get_selection_owner_reply(_ecore_xcb_conn, cookie, NULL); | ||
607 | if (!reply) return EINA_FALSE; | ||
608 | |||
609 | if (reply->owner != win) | ||
610 | { | ||
611 | free(reply); | ||
612 | return EINA_FALSE; | ||
613 | } | ||
614 | free(reply); | ||
615 | |||
616 | if (selection == ECORE_X_ATOM_SELECTION_PRIMARY) | ||
617 | in = 0; | ||
618 | else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY) | ||
619 | in = 1; | ||
620 | else if (selection == ECORE_X_ATOM_SELECTION_XDND) | ||
621 | in = 2; | ||
622 | else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD) | ||
623 | in = 3; | ||
624 | else | ||
625 | return EINA_FALSE; | ||
626 | |||
627 | if (data) | ||
628 | { | ||
629 | unsigned char *buff = NULL; | ||
630 | |||
631 | _selections[in].win = win; | ||
632 | _selections[in].selection = selection; | ||
633 | _selections[in].length = size; | ||
634 | _selections[in].time = _ecore_xcb_events_last_time_get(); | ||
635 | |||
636 | buff = malloc(size); | ||
637 | if (!buff) return EINA_FALSE; | ||
638 | memcpy(buff, data, size); | ||
639 | _selections[in].data = buff; | ||
640 | } | ||
641 | else if (_selections[in].data) | ||
642 | { | ||
643 | free(_selections[in].data); | ||
644 | memset(&_selections[in], 0, sizeof(Ecore_X_Selection_Data)); | ||
645 | } | ||
646 | |||
647 | return EINA_TRUE; | ||
648 | } | ||
649 | |||
650 | static void | ||
651 | _ecore_xcb_selection_request(Ecore_X_Window win, | ||
652 | Ecore_X_Atom selection, | ||
653 | const char *target) | ||
654 | { | ||
655 | Ecore_X_Atom atarget, prop; | ||
656 | |||
657 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
658 | CHECK_XCB_CONN; | ||
659 | |||
660 | if (selection == ECORE_X_ATOM_SELECTION_PRIMARY) | ||
661 | prop = ECORE_X_ATOM_SELECTION_PROP_PRIMARY; | ||
662 | else if (selection == ECORE_X_ATOM_SELECTION_SECONDARY) | ||
663 | prop = ECORE_X_ATOM_SELECTION_PROP_SECONDARY; | ||
664 | else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD) | ||
665 | prop = ECORE_X_ATOM_SELECTION_PROP_CLIPBOARD; | ||
666 | else | ||
667 | return; | ||
668 | |||
669 | atarget = _ecore_xcb_selection_target_atom_get(target); | ||
670 | |||
671 | xcb_convert_selection(_ecore_xcb_conn, win, selection, atarget, prop, | ||
672 | XCB_CURRENT_TIME); | ||
673 | } | ||
674 | |||
675 | static Eina_Bool | ||
676 | _ecore_xcb_selection_converter_text(char *target, | ||
677 | void *data, | ||
678 | int size, | ||
679 | void **data_ret, | ||
680 | int *size_ret, | ||
681 | Ecore_X_Atom *type __UNUSED__, | ||
682 | int *size_type __UNUSED__) | ||
683 | { | ||
684 | Ecore_Xcb_Encoding_Style style; | ||
685 | Ecore_Xcb_Textproperty ret; | ||
686 | char *str; | ||
687 | |||
688 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
689 | CHECK_XCB_CONN; | ||
690 | |||
691 | if ((!data) || (!size)) return EINA_FALSE; | ||
692 | |||
693 | if (!strcmp(target, ECORE_X_SELECTION_TARGET_TEXT)) | ||
694 | style = XcbTextStyle; | ||
695 | else if (!strcmp(target, ECORE_X_SELECTION_TARGET_COMPOUND_TEXT)) | ||
696 | style = XcbCompoundTextStyle; | ||
697 | else if (!strcmp(target, ECORE_X_SELECTION_TARGET_STRING)) | ||
698 | style = XcbStringStyle; | ||
699 | else if (!strcmp(target, ECORE_X_SELECTION_TARGET_UTF8_STRING)) | ||
700 | style = XcbUTF8StringStyle; | ||
701 | else | ||
702 | return EINA_FALSE; | ||
703 | |||
704 | str = alloca(size + 1); | ||
705 | memcpy(str, data, size); | ||
706 | str[size] = '\0'; | ||
707 | |||
708 | #ifdef HAVE_ICONV | ||
709 | if (_ecore_xcb_utf8_textlist_to_textproperty(&str, 1, style, &ret)) | ||
710 | { | ||
711 | int size = 0; | ||
712 | |||
713 | size = (strlen((char *)ret.value) + 1); | ||
714 | *data_ret = malloc(size); | ||
715 | if (!*data_ret) return EINA_FALSE; | ||
716 | memcpy(*data_ret, ret.value, size); | ||
717 | *size_ret = size; | ||
718 | if (ret.value) free(ret.value); | ||
719 | return EINA_TRUE; | ||
720 | } | ||
721 | #else | ||
722 | if (_ecore_xcb_mb_textlist_to_textproperty(&str, 1, style, &ret)) | ||
723 | { | ||
724 | int size = 0; | ||
725 | |||
726 | size = (strlen((char *)ret.value) + 1); | ||
727 | *data_ret = malloc(size); | ||
728 | if (!*data_ret) return EINA_FALSE; | ||
729 | memcpy(*data_ret, ret.value, size); | ||
730 | *size_ret = size; | ||
731 | if (ret.value) free(ret.value); | ||
732 | return EINA_TRUE; | ||
733 | } | ||
734 | #endif | ||
735 | else | ||
736 | return EINA_TRUE; | ||
737 | |||
738 | return EINA_FALSE; | ||
739 | } | ||
740 | |||
741 | static void * | ||
742 | _ecore_xcb_selection_parser_text(const char *target __UNUSED__, | ||
743 | void *data, | ||
744 | int size, | ||
745 | int format __UNUSED__) | ||
746 | { | ||
747 | Ecore_X_Selection_Data_Text *sel; | ||
748 | unsigned char *_data; | ||
749 | void *t; | ||
750 | |||
751 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
752 | |||
753 | if (!(_data = data)) return NULL; | ||
754 | |||
755 | sel = calloc(1, sizeof(Ecore_X_Selection_Data_Text)); | ||
756 | if (!sel) return NULL; | ||
757 | |||
758 | if (_data[size - 1]) | ||
759 | { | ||
760 | size++; | ||
761 | t = realloc(_data, size); | ||
762 | if (!t) | ||
763 | { | ||
764 | free(sel); | ||
765 | return NULL; | ||
766 | } | ||
767 | _data = t; | ||
768 | _data[size - 1] = 0; | ||
769 | } | ||
770 | sel->text = (char *)_data; | ||
771 | ECORE_XCB_SELECTION_DATA(sel)->length = size; | ||
772 | ECORE_XCB_SELECTION_DATA(sel)->content = ECORE_X_SELECTION_CONTENT_TEXT; | ||
773 | ECORE_XCB_SELECTION_DATA(sel)->data = _data; | ||
774 | ECORE_XCB_SELECTION_DATA(sel)->free = _ecore_xcb_selection_data_text_free; | ||
775 | return sel; | ||
776 | } | ||
777 | |||
778 | static void * | ||
779 | _ecore_xcb_selection_parser_files(const char *target, | ||
780 | void *data, | ||
781 | int size, | ||
782 | int format __UNUSED__) | ||
783 | { | ||
784 | Ecore_X_Selection_Data_Files *sel; | ||
785 | char *_data, *tmp, *t, **t2; | ||
786 | int i = 0, is = 0; | ||
787 | |||
788 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
789 | |||
790 | if ((strcmp(target, "text/uri-list")) && | ||
791 | (strcmp(target, "_NETSCAPE_URL"))) return NULL; | ||
792 | |||
793 | if (!(_data = data)) return NULL; | ||
794 | |||
795 | sel = calloc(1, sizeof(Ecore_X_Selection_Data_Files)); | ||
796 | if (!sel) return NULL; | ||
797 | |||
798 | ECORE_XCB_SELECTION_DATA(sel)->free = _ecore_xcb_selection_data_files_free; | ||
799 | |||
800 | if (_data[size - 1]) | ||
801 | { | ||
802 | size++; | ||
803 | t = realloc(_data, size); | ||
804 | if (!t) | ||
805 | { | ||
806 | free(sel); | ||
807 | return NULL; | ||
808 | } | ||
809 | _data = t; | ||
810 | _data[size - 1] = 0; | ||
811 | } | ||
812 | |||
813 | tmp = malloc(size); | ||
814 | if (!tmp) | ||
815 | { | ||
816 | free(sel); | ||
817 | return NULL; | ||
818 | } | ||
819 | |||
820 | while ((is < size) && (_data[is])) | ||
821 | { | ||
822 | if ((i == 0) && (_data[is] == '#')) | ||
823 | { | ||
824 | for (; ((_data[is]) && (_data[is] != '\n')); is++) ; | ||
825 | } | ||
826 | else | ||
827 | { | ||
828 | if ((_data[is] != '\r') && (_data[is] != '\n')) | ||
829 | tmp[i++] = _data[is++]; | ||
830 | else | ||
831 | { | ||
832 | while ((_data[is] == '\r') || (_data[is] == '\n')) | ||
833 | is++; | ||
834 | tmp[i] = 0; | ||
835 | sel->num_files++; | ||
836 | t2 = realloc(sel->files, sel->num_files * sizeof(char *)); | ||
837 | if (t2) | ||
838 | { | ||
839 | sel->files = t2; | ||
840 | sel->files[sel->num_files - 1] = strdup(tmp); | ||
841 | } | ||
842 | tmp[0] = 0; | ||
843 | i = 0; | ||
844 | } | ||
845 | } | ||
846 | } | ||
847 | if (i > 0) | ||
848 | { | ||
849 | tmp[i] = 0; | ||
850 | sel->num_files++; | ||
851 | t2 = realloc(sel->files, sel->num_files * sizeof(char *)); | ||
852 | if (t2) | ||
853 | { | ||
854 | sel->files = t2; | ||
855 | sel->files[sel->num_files - 1] = strdup(tmp); | ||
856 | } | ||
857 | } | ||
858 | if (tmp) free(tmp); | ||
859 | if (_data) free(_data); | ||
860 | |||
861 | ECORE_XCB_SELECTION_DATA(sel)->content = ECORE_X_SELECTION_CONTENT_FILES; | ||
862 | ECORE_XCB_SELECTION_DATA(sel)->length = sel->num_files; | ||
863 | |||
864 | return ECORE_XCB_SELECTION_DATA(sel); | ||
865 | } | ||
866 | |||
867 | static void * | ||
868 | _ecore_xcb_selection_parser_targets(const char *target __UNUSED__, | ||
869 | void *data, | ||
870 | int size, | ||
871 | int format __UNUSED__) | ||
872 | { | ||
873 | Ecore_X_Selection_Data_Targets *sel; | ||
874 | unsigned long *targets; | ||
875 | int i = 0; | ||
876 | |||
877 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
878 | CHECK_XCB_CONN; | ||
879 | |||
880 | if (!(targets = (unsigned long *)data)) return NULL; | ||
881 | |||
882 | sel = calloc(1, sizeof(Ecore_X_Selection_Data_Targets)); | ||
883 | if (!sel) return NULL; | ||
884 | |||
885 | sel->num_targets = (size - 2); | ||
886 | sel->targets = malloc((size - 2) * sizeof(char *)); | ||
887 | if (!sel->targets) | ||
888 | { | ||
889 | free(sel); | ||
890 | return NULL; | ||
891 | } | ||
892 | |||
893 | for (i = 2; i < size; i++) | ||
894 | { | ||
895 | xcb_get_atom_name_cookie_t cookie; | ||
896 | xcb_get_atom_name_reply_t *reply; | ||
897 | char *name = NULL; | ||
898 | int len = 0; | ||
899 | |||
900 | cookie = xcb_get_atom_name_unchecked(_ecore_xcb_conn, targets[i]); | ||
901 | reply = xcb_get_atom_name_reply(_ecore_xcb_conn, cookie, NULL); | ||
902 | if (reply) | ||
903 | { | ||
904 | len = xcb_get_atom_name_name_length(reply); | ||
905 | name = (char *)malloc(sizeof(char) * (len + 1)); | ||
906 | if (name) | ||
907 | { | ||
908 | memcpy(name, xcb_get_atom_name_name(reply), len); | ||
909 | name[len] = '\0'; | ||
910 | sel->targets[i - 2] = name; | ||
911 | } | ||
912 | free(reply); | ||
913 | } | ||
914 | } | ||
915 | |||
916 | ECORE_XCB_SELECTION_DATA(sel)->free = | ||
917 | _ecore_xcb_selection_data_targets_free; | ||
918 | ECORE_XCB_SELECTION_DATA(sel)->content = ECORE_X_SELECTION_CONTENT_TARGETS; | ||
919 | ECORE_XCB_SELECTION_DATA(sel)->length = size; | ||
920 | ECORE_XCB_SELECTION_DATA(sel)->data = data; | ||
921 | |||
922 | return sel; | ||
923 | } | ||
924 | |||
925 | /* | ||
926 | static int | ||
927 | _ecore_xcb_selection_data_free(void *data) | ||
928 | { | ||
929 | Ecore_X_Selection_Data *sel; | ||
930 | |||
931 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
932 | |||
933 | if (!(sel = data)) return 0; | ||
934 | if (sel->data) free(sel->data); | ||
935 | free(sel); | ||
936 | return 1; | ||
937 | } | ||
938 | */ | ||
939 | |||
940 | static int | ||
941 | _ecore_xcb_selection_data_text_free(void *data) | ||
942 | { | ||
943 | Ecore_X_Selection_Data_Text *sel; | ||
944 | |||
945 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
946 | |||
947 | if (!(sel = data)) return 0; | ||
948 | if (sel->text) free(sel->text); | ||
949 | free(sel); | ||
950 | return 1; | ||
951 | } | ||
952 | |||
953 | static int | ||
954 | _ecore_xcb_selection_data_targets_free(void *data) | ||
955 | { | ||
956 | Ecore_X_Selection_Data_Targets *sel; | ||
957 | |||
958 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
959 | |||
960 | if (!(sel = data)) return 0; | ||
961 | if (sel->targets) | ||
962 | { | ||
963 | int i = 0; | ||
964 | |||
965 | for (i = 0; i < sel->num_targets; i++) | ||
966 | if (sel->targets[i]) free(sel->targets[i]); | ||
967 | if (sel->targets) free(sel->targets); | ||
968 | } | ||
969 | free(sel); | ||
970 | return 1; | ||
971 | } | ||
972 | |||
973 | static int | ||
974 | _ecore_xcb_selection_data_files_free(void *data) | ||
975 | { | ||
976 | Ecore_X_Selection_Data_Files *sel; | ||
977 | |||
978 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
979 | |||
980 | if (!(sel = data)) return 0; | ||
981 | if (sel->files) | ||
982 | { | ||
983 | int i = 0; | ||
984 | |||
985 | for (i = 0; i < sel->num_files; i++) | ||
986 | if (sel->files[i]) free(sel->files[i]); | ||
987 | if (sel->files) free(sel->files); | ||
988 | } | ||
989 | free(sel); | ||
990 | return 0; | ||
991 | } | ||
992 | |||
993 | static int | ||
994 | _ecore_xcb_selection_data_default_free(void *data) | ||
995 | { | ||
996 | Ecore_X_Selection_Data *sel; | ||
997 | |||
998 | if (!(sel = data)) return 1; | ||
999 | free(sel->data); | ||
1000 | free(sel); | ||
1001 | return 1; | ||
1002 | } | ||
1003 | |||
1004 | static Ecore_X_Atom | ||
1005 | _ecore_xcb_selection_target_atom_get(const char *target) | ||
1006 | { | ||
1007 | Ecore_X_Atom x_target; | ||
1008 | |||
1009 | if (!strcmp(target, ECORE_X_SELECTION_TARGET_TEXT)) | ||
1010 | x_target = ECORE_X_ATOM_TEXT; | ||
1011 | else if (!strcmp(target, ECORE_X_SELECTION_TARGET_COMPOUND_TEXT)) | ||
1012 | x_target = ECORE_X_ATOM_COMPOUND_TEXT; | ||
1013 | else if (!strcmp(target, ECORE_X_SELECTION_TARGET_STRING)) | ||
1014 | x_target = ECORE_X_ATOM_STRING; | ||
1015 | else if (!strcmp(target, ECORE_X_SELECTION_TARGET_UTF8_STRING)) | ||
1016 | x_target = ECORE_X_ATOM_UTF8_STRING; | ||
1017 | else if (!strcmp(target, ECORE_X_SELECTION_TARGET_FILENAME)) | ||
1018 | x_target = ECORE_X_ATOM_FILE_NAME; | ||
1019 | else | ||
1020 | x_target = ecore_x_atom_get(target); | ||
1021 | |||
1022 | return x_target; | ||
1023 | } | ||
1024 | |||
1025 | char * | ||
1026 | _ecore_xcb_selection_target_get(Ecore_X_Atom target) | ||
1027 | { | ||
1028 | if (target == ECORE_X_ATOM_FILE_NAME) | ||
1029 | return strdup(ECORE_X_SELECTION_TARGET_FILENAME); | ||
1030 | else if (target == ECORE_X_ATOM_STRING) | ||
1031 | return strdup(ECORE_X_SELECTION_TARGET_STRING); | ||
1032 | else if (target == ECORE_X_ATOM_UTF8_STRING) | ||
1033 | return strdup(ECORE_X_SELECTION_TARGET_UTF8_STRING); | ||
1034 | else if (target == ECORE_X_ATOM_TEXT) | ||
1035 | return strdup(ECORE_X_SELECTION_TARGET_TEXT); | ||
1036 | else | ||
1037 | return ecore_x_atom_name_get(target); | ||
1038 | } | ||
1039 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_shape.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_shape.c new file mode 100644 index 0000000..913f199 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_shape.c | |||
@@ -0,0 +1,50 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #ifdef ECORE_XCB_SHAPE | ||
3 | # include <xcb/shape.h> | ||
4 | #endif | ||
5 | |||
6 | /* external variables */ | ||
7 | int _ecore_xcb_event_shape = -1; | ||
8 | |||
9 | void | ||
10 | _ecore_xcb_shape_init(void) | ||
11 | { | ||
12 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
13 | |||
14 | #ifdef ECORE_XCB_SHAPE | ||
15 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_shape_id); | ||
16 | #endif | ||
17 | } | ||
18 | |||
19 | void | ||
20 | _ecore_xcb_shape_finalize(void) | ||
21 | { | ||
22 | #ifdef ECORE_XCB_SHAPE | ||
23 | const xcb_query_extension_reply_t *ext_reply; | ||
24 | #endif | ||
25 | |||
26 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
27 | |||
28 | #ifdef ECORE_XCB_SHAPE | ||
29 | ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_shape_id); | ||
30 | if ((ext_reply) && (ext_reply->present)) | ||
31 | { | ||
32 | xcb_shape_query_version_cookie_t cookie; | ||
33 | xcb_shape_query_version_reply_t *reply; | ||
34 | Eina_Bool _shape_avail; | ||
35 | |||
36 | _shape_avail = EINA_FALSE; | ||
37 | cookie = xcb_shape_query_version_unchecked(_ecore_xcb_conn); | ||
38 | reply = xcb_shape_query_version_reply(_ecore_xcb_conn, cookie, NULL); | ||
39 | if (reply) | ||
40 | { | ||
41 | _shape_avail = EINA_TRUE; | ||
42 | free(reply); | ||
43 | } | ||
44 | |||
45 | if (_shape_avail) | ||
46 | _ecore_xcb_event_shape = ext_reply->first_event; | ||
47 | } | ||
48 | #endif | ||
49 | } | ||
50 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_sync.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_sync.c new file mode 100644 index 0000000..75f4e4f --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_sync.c | |||
@@ -0,0 +1,338 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | # ifdef ECORE_XCB_SYNC | ||
3 | # include <xcb/sync.h> | ||
4 | # endif | ||
5 | |||
6 | /* local variables */ | ||
7 | static Eina_Bool _sync_avail = EINA_FALSE; | ||
8 | |||
9 | /* external variables */ | ||
10 | int _ecore_xcb_event_sync = -1; | ||
11 | |||
12 | void | ||
13 | _ecore_xcb_sync_init(void) | ||
14 | { | ||
15 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
16 | |||
17 | #ifdef ECORE_XCB_SYNC | ||
18 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_sync_id); | ||
19 | #endif | ||
20 | } | ||
21 | |||
22 | void | ||
23 | _ecore_xcb_sync_finalize(void) | ||
24 | { | ||
25 | #ifdef ECORE_XCB_SYNC | ||
26 | const xcb_query_extension_reply_t *ext_reply; | ||
27 | #endif | ||
28 | |||
29 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
30 | |||
31 | #ifdef ECORE_XCB_SYNC | ||
32 | ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_sync_id); | ||
33 | if ((ext_reply) && (ext_reply->present)) | ||
34 | { | ||
35 | xcb_sync_initialize_cookie_t cookie; | ||
36 | xcb_sync_initialize_reply_t *reply; | ||
37 | |||
38 | cookie = | ||
39 | xcb_sync_initialize_unchecked(_ecore_xcb_conn, | ||
40 | XCB_SYNC_MAJOR_VERSION, | ||
41 | XCB_SYNC_MINOR_VERSION); | ||
42 | reply = xcb_sync_initialize_reply(_ecore_xcb_conn, cookie, NULL); | ||
43 | if (reply) | ||
44 | { | ||
45 | if (reply->major_version >= 3) _sync_avail = EINA_TRUE; | ||
46 | free(reply); | ||
47 | } | ||
48 | |||
49 | if (_sync_avail) | ||
50 | _ecore_xcb_event_sync = ext_reply->first_event; | ||
51 | } | ||
52 | #endif | ||
53 | } | ||
54 | |||
55 | void | ||
56 | _ecore_xcb_sync_magic_send(int val, | ||
57 | Ecore_X_Window win) | ||
58 | { | ||
59 | xcb_client_message_event_t ev; | ||
60 | |||
61 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
62 | |||
63 | memset(&ev, 0, sizeof(xcb_client_message_event_t)); | ||
64 | ev.response_type = XCB_CLIENT_MESSAGE; | ||
65 | ev.format = 32; | ||
66 | ev.window = win; | ||
67 | ev.type = 27777; | ||
68 | ev.data.data32[0] = 0x7162534; | ||
69 | ev.data.data32[1] = (0x10000000 + val); | ||
70 | ev.data.data32[2] = win; | ||
71 | |||
72 | xcb_send_event(_ecore_xcb_conn, 0, win, XCB_EVENT_MASK_NO_EVENT, | ||
73 | (const char *)&ev); | ||
74 | // ecore_x_flush(); | ||
75 | } | ||
76 | |||
77 | /* public functions */ | ||
78 | EAPI Ecore_X_Sync_Alarm | ||
79 | ecore_x_sync_alarm_new(Ecore_X_Sync_Counter counter) | ||
80 | { | ||
81 | #ifdef ECORE_XCB_SYNC | ||
82 | uint32_t list[6], mask; | ||
83 | xcb_sync_int64_t init; | ||
84 | Ecore_X_Sync_Alarm alarm; | ||
85 | #endif | ||
86 | |||
87 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
88 | CHECK_XCB_CONN; | ||
89 | |||
90 | if ((!_sync_avail) || (!counter)) return 0; | ||
91 | |||
92 | #ifdef ECORE_XCB_SYNC | ||
93 | init.lo = 0; | ||
94 | init.hi = 0; | ||
95 | xcb_sync_set_counter(_ecore_xcb_conn, counter, init); | ||
96 | |||
97 | mask = (XCB_SYNC_CA_COUNTER | XCB_SYNC_CA_VALUE_TYPE | | ||
98 | XCB_SYNC_CA_VALUE | XCB_SYNC_CA_TEST_TYPE | | ||
99 | XCB_SYNC_CA_DELTA | XCB_SYNC_CA_EVENTS); | ||
100 | list[0] = counter; | ||
101 | list[1] = XCB_SYNC_VALUETYPE_ABSOLUTE; | ||
102 | list[2] = 1; | ||
103 | list[3] = XCB_SYNC_TESTTYPE_POSITIVE_COMPARISON; | ||
104 | list[4] = 1; | ||
105 | list[5] = 1; | ||
106 | alarm = xcb_generate_id(_ecore_xcb_conn); | ||
107 | |||
108 | xcb_sync_create_alarm(_ecore_xcb_conn, alarm, mask, list); | ||
109 | ecore_x_sync(); // needed | ||
110 | |||
111 | return alarm; | ||
112 | #endif | ||
113 | return 0; | ||
114 | } | ||
115 | |||
116 | EAPI Eina_Bool | ||
117 | ecore_x_sync_alarm_free(Ecore_X_Sync_Alarm alarm) | ||
118 | { | ||
119 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
120 | CHECK_XCB_CONN; | ||
121 | |||
122 | if ((!_sync_avail) || (!alarm)) return EINA_FALSE; | ||
123 | |||
124 | #ifdef ECORE_XCB_SYNC | ||
125 | xcb_sync_destroy_alarm(_ecore_xcb_conn, alarm); | ||
126 | // ecore_x_flush(); | ||
127 | return EINA_TRUE; | ||
128 | #endif | ||
129 | |||
130 | return EINA_FALSE; | ||
131 | } | ||
132 | |||
133 | EAPI Eina_Bool | ||
134 | ecore_x_sync_counter_query(Ecore_X_Sync_Counter counter, | ||
135 | unsigned int *val) | ||
136 | { | ||
137 | #ifdef ECORE_XCB_SYNC | ||
138 | xcb_sync_query_counter_cookie_t cookie; | ||
139 | xcb_sync_query_counter_reply_t *reply; | ||
140 | #endif | ||
141 | |||
142 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
143 | CHECK_XCB_CONN; | ||
144 | |||
145 | if ((!_sync_avail) || (!counter)) return EINA_FALSE; | ||
146 | |||
147 | #ifdef ECORE_XCB_SYNC | ||
148 | cookie = xcb_sync_query_counter_unchecked(_ecore_xcb_conn, counter); | ||
149 | reply = xcb_sync_query_counter_reply(_ecore_xcb_conn, cookie, NULL); | ||
150 | if (reply) | ||
151 | { | ||
152 | if (val) *val = (unsigned int)reply->counter_value.lo; | ||
153 | free(reply); | ||
154 | return EINA_TRUE; | ||
155 | } | ||
156 | #endif | ||
157 | return EINA_FALSE; | ||
158 | } | ||
159 | |||
160 | EAPI void | ||
161 | ecore_x_sync_counter_inc(Ecore_X_Sync_Counter counter, | ||
162 | int by) | ||
163 | { | ||
164 | #ifdef ECORE_XCB_SYNC | ||
165 | xcb_sync_int64_t v; | ||
166 | #endif | ||
167 | |||
168 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
169 | CHECK_XCB_CONN; | ||
170 | |||
171 | if ((!_sync_avail) || (!counter)) return; | ||
172 | |||
173 | #ifdef ECORE_XCB_SYNC | ||
174 | v.hi = (by < 0) ? ~0 : 0; | ||
175 | v.lo = by; | ||
176 | |||
177 | xcb_sync_change_counter(_ecore_xcb_conn, counter, v); | ||
178 | // ecore_x_flush(); | ||
179 | #endif | ||
180 | } | ||
181 | |||
182 | EAPI void | ||
183 | ecore_x_sync_counter_val_wait(Ecore_X_Sync_Counter counter, | ||
184 | int val) | ||
185 | { | ||
186 | #ifdef ECORE_XCB_SYNC | ||
187 | xcb_sync_query_counter_cookie_t cookie; | ||
188 | xcb_sync_query_counter_reply_t *reply; | ||
189 | xcb_sync_int64_t v1, v2; | ||
190 | xcb_sync_waitcondition_t cond; | ||
191 | #endif | ||
192 | |||
193 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
194 | CHECK_XCB_CONN; | ||
195 | |||
196 | if ((!_sync_avail) || (!counter)) return; | ||
197 | |||
198 | #ifdef ECORE_XCB_SYNC | ||
199 | cookie = xcb_sync_query_counter_unchecked(_ecore_xcb_conn, counter); | ||
200 | reply = xcb_sync_query_counter_reply(_ecore_xcb_conn, cookie, NULL); | ||
201 | if (!reply) return; | ||
202 | v1 = reply->counter_value; | ||
203 | free(reply); | ||
204 | |||
205 | v1.hi = (val < 0) ? ~0 : 0; | ||
206 | v1.lo = val; | ||
207 | v2.hi = ((val + 1) < 0) ? ~0 : 0; | ||
208 | v2.lo = (val + 1); | ||
209 | |||
210 | cond.trigger.counter = counter; | ||
211 | cond.trigger.wait_type = XCB_SYNC_VALUETYPE_ABSOLUTE; | ||
212 | cond.trigger.wait_value = v1; | ||
213 | cond.trigger.test_type = XCB_SYNC_TESTTYPE_POSITIVE_COMPARISON; | ||
214 | cond.event_threshold = v2; | ||
215 | |||
216 | xcb_sync_await(_ecore_xcb_conn, 1, &cond); | ||
217 | // ecore_x_flush(); | ||
218 | #endif | ||
219 | } | ||
220 | |||
221 | EAPI Ecore_X_Sync_Counter | ||
222 | ecore_x_sync_counter_new(int val) | ||
223 | { | ||
224 | #ifdef ECORE_XCB_SYNC | ||
225 | xcb_sync_counter_t counter; | ||
226 | xcb_sync_int64_t v; | ||
227 | #endif | ||
228 | |||
229 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
230 | CHECK_XCB_CONN; | ||
231 | |||
232 | if (!_sync_avail) return 0; | ||
233 | |||
234 | #ifdef ECORE_XCB_SYNC | ||
235 | v.hi = (val < 0) ? ~0 : 0; | ||
236 | v.lo = val; | ||
237 | |||
238 | counter = xcb_generate_id(_ecore_xcb_conn); | ||
239 | xcb_sync_create_counter(_ecore_xcb_conn, counter, v); | ||
240 | // ecore_x_flush(); | ||
241 | |||
242 | return counter; | ||
243 | #endif | ||
244 | |||
245 | return 0; | ||
246 | } | ||
247 | |||
248 | EAPI void | ||
249 | ecore_x_sync_counter_free(Ecore_X_Sync_Counter counter) | ||
250 | { | ||
251 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
252 | CHECK_XCB_CONN; | ||
253 | |||
254 | if ((!_sync_avail) || (!counter)) return; | ||
255 | |||
256 | #ifdef ECORE_XCB_SYNC | ||
257 | xcb_sync_destroy_counter(_ecore_xcb_conn, counter); | ||
258 | // ecore_x_flush(); | ||
259 | #endif | ||
260 | } | ||
261 | |||
262 | EAPI void | ||
263 | ecore_x_sync_counter_set(Ecore_X_Sync_Counter counter, | ||
264 | int val) | ||
265 | { | ||
266 | #ifdef ECORE_XCB_SYNC | ||
267 | xcb_sync_int64_t v; | ||
268 | #endif | ||
269 | |||
270 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
271 | CHECK_XCB_CONN; | ||
272 | |||
273 | if ((!_sync_avail) || (!counter)) return; | ||
274 | |||
275 | #ifdef ECORE_XCB_SYNC | ||
276 | v.hi = (val < 0) ? ~0 : 0; | ||
277 | v.lo = val; | ||
278 | |||
279 | xcb_sync_set_counter(_ecore_xcb_conn, counter, v); | ||
280 | // ecore_x_flush(); | ||
281 | #endif | ||
282 | } | ||
283 | |||
284 | EAPI void | ||
285 | ecore_x_sync_counter_2_set(Ecore_X_Sync_Counter counter, | ||
286 | int val_hi, | ||
287 | unsigned int val_lo) | ||
288 | { | ||
289 | #ifdef ECORE_XCB_SYNC | ||
290 | xcb_sync_int64_t v; | ||
291 | #endif | ||
292 | |||
293 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
294 | CHECK_XCB_CONN; | ||
295 | |||
296 | if ((!_sync_avail) || (!counter)) return; | ||
297 | |||
298 | #ifdef ECORE_XCB_SYNC | ||
299 | v.hi = val_hi; | ||
300 | v.lo = val_lo; | ||
301 | |||
302 | xcb_sync_set_counter(_ecore_xcb_conn, counter, v); | ||
303 | // ecore_x_flush(); | ||
304 | #endif | ||
305 | } | ||
306 | |||
307 | EAPI Eina_Bool | ||
308 | ecore_x_sync_counter_2_query(Ecore_X_Sync_Counter counter, | ||
309 | int *val_hi, | ||
310 | unsigned int *val_lo) | ||
311 | { | ||
312 | #ifdef ECORE_XCB_SYNC | ||
313 | xcb_sync_query_counter_cookie_t cookie; | ||
314 | xcb_sync_query_counter_reply_t *reply; | ||
315 | xcb_sync_int64_t value; | ||
316 | #endif | ||
317 | |||
318 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
319 | CHECK_XCB_CONN; | ||
320 | |||
321 | if ((!_sync_avail) || (!counter)) return EINA_FALSE; | ||
322 | |||
323 | #ifdef ECORE_XCB_SYNC | ||
324 | cookie = | ||
325 | xcb_sync_query_counter_unchecked(_ecore_xcb_conn, | ||
326 | (xcb_sync_counter_t)counter); | ||
327 | reply = xcb_sync_query_counter_reply(_ecore_xcb_conn, cookie, NULL); | ||
328 | if (!reply) return EINA_FALSE; | ||
329 | value = reply->counter_value; | ||
330 | free(reply); | ||
331 | if (val_hi) *val_hi = (int)value.hi; | ||
332 | if (val_lo) *val_lo = (unsigned int)value.lo; | ||
333 | return EINA_TRUE; | ||
334 | #endif | ||
335 | |||
336 | return EINA_FALSE; | ||
337 | } | ||
338 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_textlist.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_textlist.c new file mode 100644 index 0000000..2a5c854 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_textlist.c | |||
@@ -0,0 +1,509 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | //#include "Ecore_X_Atoms.h" | ||
3 | #include <langinfo.h> | ||
4 | #ifdef HAVE_ICONV | ||
5 | # include <iconv.h> | ||
6 | #endif | ||
7 | #ifndef CODESET | ||
8 | # define CODESET "INVALID" | ||
9 | #endif | ||
10 | |||
11 | static int _ecore_xcb_textlist_get_buffer_size(Eina_Bool is_wide, | ||
12 | void *list, | ||
13 | int count); | ||
14 | static int _ecore_xcb_textlist_get_wc_len(wchar_t *wstr); | ||
15 | static void *_ecore_xcb_textlist_alloc_list(Eina_Bool is_wide, | ||
16 | int count, | ||
17 | int nitems); | ||
18 | static void _ecore_xcb_textlist_copy_list(Eina_Bool is_wide, | ||
19 | void *text, | ||
20 | char **list, | ||
21 | int count); | ||
22 | static wchar_t *_ecore_xcb_textlist_copy_wchar(wchar_t *str1, | ||
23 | wchar_t *str2); | ||
24 | static int _ecore_xcb_textlist_len_wchar(wchar_t *str); | ||
25 | |||
26 | #ifdef HAVE_ICONV | ||
27 | Eina_Bool | ||
28 | _ecore_xcb_utf8_textlist_to_textproperty(char **list, | ||
29 | int count, | ||
30 | Ecore_Xcb_Encoding_Style style, | ||
31 | Ecore_Xcb_Textproperty *ret) | ||
32 | { | ||
33 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
34 | |||
35 | return _ecore_xcb_textlist_to_textproperty("utf8string", list, count, | ||
36 | style, ret); | ||
37 | } | ||
38 | |||
39 | #endif | ||
40 | |||
41 | Eina_Bool | ||
42 | _ecore_xcb_mb_textlist_to_textproperty(char **list, | ||
43 | int count, | ||
44 | Ecore_Xcb_Encoding_Style style, | ||
45 | Ecore_Xcb_Textproperty *ret) | ||
46 | { | ||
47 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
48 | |||
49 | return _ecore_xcb_textlist_to_textproperty("multiByte", list, count, | ||
50 | style, ret); | ||
51 | } | ||
52 | |||
53 | /* NB: This Function May Not Be Correct !!! | ||
54 | * (as I do not know text conversion, locales, etc, etc very well) | ||
55 | * | ||
56 | * Portions were ripped from libX11 XTextListToTextProperty | ||
57 | */ | ||
58 | Eina_Bool | ||
59 | _ecore_xcb_textlist_to_textproperty(const char *type, | ||
60 | char **list, | ||
61 | int count, | ||
62 | Ecore_Xcb_Encoding_Style style, | ||
63 | Ecore_Xcb_Textproperty *ret) | ||
64 | { | ||
65 | Eina_Bool is_wide = EINA_FALSE; | ||
66 | Ecore_X_Atom encoding; | ||
67 | int len = 0, nitems = 0, i = 0; | ||
68 | size_t from_left = 0, to_left = 0; | ||
69 | int unconv_num = 0, val = 0; | ||
70 | char *buff, *to, *value, *from; | ||
71 | const char *to_type, *from_type; | ||
72 | char **mb = NULL; | ||
73 | wchar_t **wc = NULL; | ||
74 | #ifdef HAVE_ICONV | ||
75 | iconv_t conv; | ||
76 | #endif | ||
77 | |||
78 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
79 | |||
80 | if (!strcmp("wideChar", type)) is_wide = EINA_TRUE; | ||
81 | len = _ecore_xcb_textlist_get_buffer_size(is_wide, list, count); | ||
82 | if (!(buff = (char *)malloc(len * sizeof(char)))) return EINA_FALSE; | ||
83 | from_type = nl_langinfo(CODESET); | ||
84 | switch (style) | ||
85 | { | ||
86 | case XcbStringStyle: | ||
87 | case XcbStdICCTextStyle: | ||
88 | encoding = ECORE_X_ATOM_STRING; | ||
89 | to_type = nl_langinfo(CODESET); | ||
90 | // to_type = "string"; | ||
91 | break; | ||
92 | |||
93 | case XcbUTF8StringStyle: | ||
94 | encoding = ECORE_X_ATOM_UTF8_STRING; | ||
95 | to_type = "UTF-8"; | ||
96 | break; | ||
97 | |||
98 | case XcbCompoundTextStyle: | ||
99 | encoding = ECORE_X_ATOM_COMPOUND_TEXT; | ||
100 | to_type = nl_langinfo(CODESET); | ||
101 | // to_type = "compoundText"; | ||
102 | break; | ||
103 | |||
104 | case XcbTextStyle: | ||
105 | encoding = ECORE_X_ATOM_TEXT; | ||
106 | to_type = nl_langinfo(CODESET); | ||
107 | // to_type = "multiByte"; | ||
108 | if (!is_wide) | ||
109 | { | ||
110 | nitems = 0; | ||
111 | mb = (char **)list; | ||
112 | to = buff; | ||
113 | for (i = 0; ((i < count) && (len > 0)); i++) | ||
114 | { | ||
115 | if (*mb) strcpy(to, *mb); | ||
116 | else *to = '\0'; | ||
117 | from_left = (*mb ? strlen(*mb) : 0) + 1; | ||
118 | nitems += from_left; | ||
119 | to += from_left; | ||
120 | mb++; | ||
121 | } | ||
122 | unconv_num = 0; | ||
123 | goto done; | ||
124 | } | ||
125 | break; | ||
126 | |||
127 | default: | ||
128 | free(buff); | ||
129 | return EINA_FALSE; | ||
130 | break; | ||
131 | } | ||
132 | |||
133 | if (count < 1) | ||
134 | { | ||
135 | nitems = 0; | ||
136 | goto done; | ||
137 | } | ||
138 | |||
139 | retry: | ||
140 | #ifdef HAVE_ICONV | ||
141 | conv = iconv_open(to_type, from_type); | ||
142 | #endif | ||
143 | |||
144 | if (is_wide) | ||
145 | wc = (wchar_t **)list; | ||
146 | else | ||
147 | mb = (char **)list; | ||
148 | |||
149 | to = buff; | ||
150 | to_left = len; | ||
151 | unconv_num = 0; | ||
152 | for (i = 1; to_left > 0; i++) | ||
153 | { | ||
154 | if (is_wide) | ||
155 | { | ||
156 | from = (char *)*wc; | ||
157 | from_left = _ecore_xcb_textlist_get_wc_len(*wc); | ||
158 | wc++; | ||
159 | } | ||
160 | else | ||
161 | { | ||
162 | from = *mb; | ||
163 | from_left = (*mb ? strlen(*mb) : 0); | ||
164 | mb++; | ||
165 | } | ||
166 | |||
167 | #ifdef HAVE_ICONV | ||
168 | val = iconv(conv, &from, &from_left, &to, &to_left); | ||
169 | #endif | ||
170 | if (val < 0) continue; | ||
171 | if ((val > 0) && (style == XcbStdICCTextStyle) && | ||
172 | (encoding == ECORE_X_ATOM_STRING)) | ||
173 | { | ||
174 | #ifdef HAVE_ICONV | ||
175 | iconv_close(conv); | ||
176 | #endif | ||
177 | encoding = ECORE_X_ATOM_COMPOUND_TEXT; | ||
178 | goto retry; | ||
179 | } | ||
180 | |||
181 | unconv_num += val; | ||
182 | *to++ = '\0'; | ||
183 | to_left--; | ||
184 | if (i >= count) break; | ||
185 | } | ||
186 | |||
187 | #ifdef HAVE_ICONV | ||
188 | iconv_close(conv); | ||
189 | #endif | ||
190 | nitems = (to - buff); | ||
191 | |||
192 | done: | ||
193 | if (nitems <= 0) nitems = 1; | ||
194 | if (!(value = (char *)malloc(nitems * sizeof(char)))) | ||
195 | { | ||
196 | free(buff); | ||
197 | return EINA_FALSE; | ||
198 | } | ||
199 | if (nitems == 1) | ||
200 | *value = 0; | ||
201 | else | ||
202 | memcpy(value, buff, nitems); | ||
203 | nitems--; | ||
204 | free(buff); | ||
205 | |||
206 | ret->value = value; | ||
207 | ret->encoding = encoding; | ||
208 | ret->format = 8; | ||
209 | ret->nitems = nitems; | ||
210 | |||
211 | return EINA_TRUE; | ||
212 | } | ||
213 | |||
214 | #ifdef HAVE_ICONV | ||
215 | Eina_Bool | ||
216 | _ecore_xcb_utf8_textproperty_to_textlist(const Ecore_Xcb_Textproperty *text_prop, | ||
217 | char ***list_ret, | ||
218 | int *count_ret) | ||
219 | { | ||
220 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
221 | |||
222 | return _ecore_xcb_textproperty_to_textlist(text_prop, "utf8String", | ||
223 | list_ret, count_ret); | ||
224 | } | ||
225 | |||
226 | #endif | ||
227 | |||
228 | Eina_Bool | ||
229 | _ecore_xcb_mb_textproperty_to_textlist(const Ecore_Xcb_Textproperty *text_prop, | ||
230 | char ***list_ret, | ||
231 | int *count_ret) | ||
232 | { | ||
233 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
234 | |||
235 | return _ecore_xcb_textproperty_to_textlist(text_prop, "multiByte", | ||
236 | list_ret, count_ret); | ||
237 | } | ||
238 | |||
239 | Eina_Bool | ||
240 | _ecore_xcb_textproperty_to_textlist(const Ecore_Xcb_Textproperty *text_prop, | ||
241 | const char *type, | ||
242 | char ***list_ret, | ||
243 | int *count_ret) | ||
244 | { | ||
245 | Eina_Bool is_wide = EINA_FALSE; | ||
246 | Eina_Bool do_strcpy = EINA_FALSE; | ||
247 | const char *from_type; | ||
248 | char *buff, *to, *from; | ||
249 | char *lptr, *sptr; | ||
250 | int nitems = 0, len = 0, num = 0, ret = 0; | ||
251 | size_t from_left = 0, to_left = 0; | ||
252 | #ifdef HAVE_ICONV | ||
253 | iconv_t conv = 0; | ||
254 | #endif | ||
255 | |||
256 | *list_ret = NULL; | ||
257 | *count_ret = 0; | ||
258 | if (!strcmp("wideChar", type)) is_wide = EINA_TRUE; | ||
259 | |||
260 | nitems = text_prop->nitems; | ||
261 | if (nitems <= 0) return EINA_TRUE; | ||
262 | |||
263 | if (text_prop->format != 8) return EINA_FALSE; | ||
264 | |||
265 | from_type = nl_langinfo(CODESET); | ||
266 | if (text_prop->encoding == ECORE_X_ATOM_UTF8_STRING) | ||
267 | from_type = "UTF-8"; | ||
268 | |||
269 | if (is_wide) | ||
270 | len = (text_prop->nitems + 1) * sizeof(wchar_t); | ||
271 | else | ||
272 | { | ||
273 | if (!strcmp(type, "utf8String")) | ||
274 | len = text_prop->nitems * 6 + 1; | ||
275 | else | ||
276 | len = text_prop->nitems * MB_CUR_MAX + 1; | ||
277 | } | ||
278 | |||
279 | buff = (char *)malloc(len * sizeof(char)); | ||
280 | if (!buff) return EINA_FALSE; | ||
281 | |||
282 | to = buff; | ||
283 | to_left = len; | ||
284 | |||
285 | if (!strcmp(from_type, type)) | ||
286 | do_strcpy = EINA_TRUE; | ||
287 | else | ||
288 | { | ||
289 | #ifdef HAVE_ICONV | ||
290 | conv = iconv_open(type, from_type); | ||
291 | #endif | ||
292 | if (!conv) | ||
293 | { | ||
294 | free(buff); | ||
295 | return EINA_FALSE; | ||
296 | } | ||
297 | } | ||
298 | |||
299 | lptr = sptr = text_prop->value; | ||
300 | num = *count_ret = 0; | ||
301 | while (1) | ||
302 | { | ||
303 | if ((nitems == 0) || (*sptr == 0)) | ||
304 | { | ||
305 | from = lptr; | ||
306 | from_left = sptr - lptr; | ||
307 | lptr = sptr; | ||
308 | if (do_strcpy) | ||
309 | { | ||
310 | int l = 0; | ||
311 | |||
312 | l = MIN(from_left, to_left); | ||
313 | strncpy(to, from, l); | ||
314 | from += len; | ||
315 | to += len; | ||
316 | from_left -= l; | ||
317 | to_left -= l; | ||
318 | ret = 0; | ||
319 | } | ||
320 | else | ||
321 | ret = iconv(conv, &from, &from_left, &to, &to_left); | ||
322 | |||
323 | if (ret < 0) continue; | ||
324 | num += ret; | ||
325 | (*count_ret)++; | ||
326 | if (nitems == 0) break; | ||
327 | lptr = ++sptr; | ||
328 | if (is_wide) | ||
329 | { | ||
330 | *((wchar_t *)to) = (wchar_t)0; | ||
331 | to += sizeof(wchar_t); | ||
332 | to_left -= sizeof(wchar_t); | ||
333 | } | ||
334 | else | ||
335 | { | ||
336 | *((char *)to) = '\0'; | ||
337 | to++; | ||
338 | to_left--; | ||
339 | } | ||
340 | } | ||
341 | else | ||
342 | sptr++; | ||
343 | |||
344 | nitems--; | ||
345 | } | ||
346 | |||
347 | #if HAVE_ICONV | ||
348 | if (!do_strcpy) iconv_close(conv); | ||
349 | #endif | ||
350 | |||
351 | if (is_wide) | ||
352 | { | ||
353 | *((wchar_t *)to) = (wchar_t)0; | ||
354 | to_left -= sizeof(wchar_t); | ||
355 | } | ||
356 | else | ||
357 | { | ||
358 | *((char *)to) = '\0'; | ||
359 | to_left--; | ||
360 | } | ||
361 | |||
362 | *list_ret = | ||
363 | _ecore_xcb_textlist_alloc_list(is_wide, *count_ret, (len - to_left)); | ||
364 | if (*list_ret) | ||
365 | _ecore_xcb_textlist_copy_list(is_wide, buff, *list_ret, *count_ret); | ||
366 | |||
367 | free(buff); | ||
368 | |||
369 | return EINA_TRUE; | ||
370 | } | ||
371 | |||
372 | static int | ||
373 | _ecore_xcb_textlist_get_buffer_size(Eina_Bool is_wide, | ||
374 | void *list, | ||
375 | int count) | ||
376 | { | ||
377 | int len = 0; | ||
378 | char **mb; | ||
379 | wchar_t **wc; | ||
380 | |||
381 | if (!list) return 0; | ||
382 | if (is_wide) | ||
383 | { | ||
384 | wc = (wchar_t **)list; | ||
385 | for (; count-- > 0; wc++) | ||
386 | if (*wc) len += _ecore_xcb_textlist_get_wc_len(*wc) + 1; | ||
387 | len *= 5; | ||
388 | } | ||
389 | else | ||
390 | { | ||
391 | mb = (char **)list; | ||
392 | for (; count-- > 0; mb++) | ||
393 | if (*mb) len += strlen(*mb) + 1; | ||
394 | len *= 3; | ||
395 | } | ||
396 | len = (len / 2048 + 1) * 2048; | ||
397 | return len; | ||
398 | } | ||
399 | |||
400 | static int | ||
401 | _ecore_xcb_textlist_get_wc_len(wchar_t *wstr) | ||
402 | { | ||
403 | wchar_t *ptr; | ||
404 | |||
405 | ptr = wstr; | ||
406 | while (*ptr) | ||
407 | ptr++; | ||
408 | |||
409 | return ptr - wstr; | ||
410 | } | ||
411 | |||
412 | static void * | ||
413 | _ecore_xcb_textlist_alloc_list(Eina_Bool is_wide, | ||
414 | int count, | ||
415 | int nitems) | ||
416 | { | ||
417 | if (is_wide) | ||
418 | { | ||
419 | wchar_t **list; | ||
420 | |||
421 | list = (wchar_t **)malloc(count * sizeof(wchar_t *)); | ||
422 | if (!list) return NULL; | ||
423 | *list = (wchar_t *)malloc(nitems * sizeof(wchar_t)); | ||
424 | if (!*list) | ||
425 | { | ||
426 | free(list); | ||
427 | return NULL; | ||
428 | } | ||
429 | return *list; | ||
430 | } | ||
431 | else | ||
432 | { | ||
433 | char **list; | ||
434 | |||
435 | list = (char **)malloc(count * sizeof(char *)); | ||
436 | if (!list) return NULL; | ||
437 | *list = (char *)malloc(nitems * sizeof(char)); | ||
438 | if (!*list) | ||
439 | { | ||
440 | free(list); | ||
441 | return NULL; | ||
442 | } | ||
443 | return *list; | ||
444 | } | ||
445 | } | ||
446 | |||
447 | static void | ||
448 | _ecore_xcb_textlist_copy_list(Eina_Bool is_wide, | ||
449 | void *text, | ||
450 | char **list, | ||
451 | int count) | ||
452 | { | ||
453 | int len = 0; | ||
454 | |||
455 | if (is_wide) | ||
456 | { | ||
457 | wchar_t *txt, *str, **wlist; | ||
458 | |||
459 | txt = (wchar_t *)text; | ||
460 | wlist = (wchar_t **)list; | ||
461 | for (str = *wlist; count > 0; count--, wlist++) | ||
462 | { | ||
463 | _ecore_xcb_textlist_copy_wchar(str, txt); | ||
464 | *wlist = str; | ||
465 | len = (_ecore_xcb_textlist_len_wchar(str) + 1); | ||
466 | str += len; | ||
467 | txt += len; | ||
468 | } | ||
469 | } | ||
470 | else | ||
471 | { | ||
472 | char *txt, *str, **slist; | ||
473 | |||
474 | txt = (char *)text; | ||
475 | slist = (char **)list; | ||
476 | for (str = *slist; count > 0; count--, slist++) | ||
477 | { | ||
478 | strcpy(str, txt); | ||
479 | *slist = str; | ||
480 | len = strlen(str) + 1; | ||
481 | str += len; | ||
482 | txt += len; | ||
483 | } | ||
484 | } | ||
485 | } | ||
486 | |||
487 | static wchar_t * | ||
488 | _ecore_xcb_textlist_copy_wchar(wchar_t *str1, | ||
489 | wchar_t *str2) | ||
490 | { | ||
491 | wchar_t *tmp; | ||
492 | |||
493 | tmp = str1; | ||
494 | while ((*str1++ = *str2++)) | ||
495 | ; | ||
496 | return tmp; | ||
497 | } | ||
498 | |||
499 | static int | ||
500 | _ecore_xcb_textlist_len_wchar(wchar_t *str) | ||
501 | { | ||
502 | wchar_t *ptr; | ||
503 | |||
504 | ptr = str; | ||
505 | while (*ptr) | ||
506 | ptr++; | ||
507 | return ptr - str; | ||
508 | } | ||
509 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_vsync.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_vsync.c new file mode 100644 index 0000000..47efefc --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_vsync.c | |||
@@ -0,0 +1,375 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | # include <fcntl.h> | ||
3 | # include <dlfcn.h> | ||
4 | # include <X11/Xlib-xcb.h> | ||
5 | |||
6 | #define ECORE_XCB_VSYNC_DRI2 1 | ||
7 | #define DRM_EVENT_CONTEXT_VERSION 2 | ||
8 | |||
9 | #ifdef ECORE_XCB_VSYNC_DRI2 | ||
10 | |||
11 | /* relevant header bits of dri/drm inlined here to avoid needing external */ | ||
12 | /* headers to build drm */ | ||
13 | typedef unsigned int drm_magic_t; | ||
14 | |||
15 | typedef enum | ||
16 | { | ||
17 | DRM_VBLANK_ABSOLUTE = 0x00000000, | ||
18 | DRM_VBLANK_RELATIVE = 0x00000001, | ||
19 | DRM_VBLANK_EVENT = 0x04000000, | ||
20 | DRM_VBLANK_FLIP = 0x08000000, | ||
21 | DRM_VBLANK_NEXTONMISS = 0x10000000, | ||
22 | DRM_VBLANK_SECONDARY = 0x20000000, | ||
23 | DRM_VBLANK_SIGNAL = 0x40000000 | ||
24 | } drmVBlankSeqType; | ||
25 | |||
26 | typedef struct _drmVBlankReq | ||
27 | { | ||
28 | drmVBlankSeqType type; | ||
29 | unsigned int sequence; | ||
30 | unsigned long signal; | ||
31 | } drmVBlankReq; | ||
32 | |||
33 | typedef struct _drmVBlankReply | ||
34 | { | ||
35 | drmVBlankSeqType type; | ||
36 | unsigned int sequence; | ||
37 | long tval_sec, tval_usec; | ||
38 | } drmVBlankReply; | ||
39 | |||
40 | typedef union _drmVBlank | ||
41 | { | ||
42 | drmVBlankReq request; | ||
43 | drmVBlankReply reply; | ||
44 | } drmVBlank; | ||
45 | |||
46 | typedef struct _drmEventContext | ||
47 | { | ||
48 | int version; | ||
49 | void (*vblank_handler)(int fd, | ||
50 | unsigned int sequence, | ||
51 | unsigned int tv_sec, | ||
52 | unsigned int tv_usec, | ||
53 | void *user_data); | ||
54 | void (*page_flip_handler)(int fd, | ||
55 | unsigned int sequence, | ||
56 | unsigned int tv_sec, | ||
57 | unsigned int tv_usec, | ||
58 | void *user_data); | ||
59 | } drmEventContext; | ||
60 | |||
61 | static int (*sym_drmClose)(int fd) = NULL; | ||
62 | static int (*sym_drmGetMagic)(int fd, | ||
63 | drm_magic_t *magic) = NULL; | ||
64 | static int (*sym_drmWaitVBlank)(int fd, | ||
65 | drmVBlank *vbl) = NULL; | ||
66 | static int (*sym_drmHandleEvent)(int fd, | ||
67 | drmEventContext *evctx) = NULL; | ||
68 | |||
69 | /* dri */ | ||
70 | static Bool (*sym_DRI2QueryExtension)(Display *display, | ||
71 | int *eventBase, | ||
72 | int *errorBase) = NULL; | ||
73 | static Bool (*sym_DRI2QueryVersion)(Display *display, | ||
74 | int *major, | ||
75 | int *minor) = NULL; | ||
76 | static Bool (*sym_DRI2Connect)(Display *display, | ||
77 | XID window, | ||
78 | char **driverName, | ||
79 | char **deviceName) = NULL; | ||
80 | static Bool (*sym_DRI2Authenticate)(Display *display, | ||
81 | XID window, | ||
82 | drm_magic_t magic) = NULL; | ||
83 | |||
84 | /* local function prototypes */ | ||
85 | static Eina_Bool _ecore_xcb_dri_link(void); | ||
86 | static Eina_Bool _ecore_xcb_dri_start(void); | ||
87 | static void _ecore_xcb_dri_shutdown(void); | ||
88 | |||
89 | static Eina_Bool _ecore_xcb_dri_cb(void *data __UNUSED__, | ||
90 | Ecore_Fd_Handler *fdh __UNUSED__); | ||
91 | static void _ecore_xcb_dri_tick_begin(void *data __UNUSED__); | ||
92 | static void _ecore_xcb_dri_tick_end(void *data __UNUSED__); | ||
93 | static void _ecore_xcb_dri_tick_schedule(void); | ||
94 | static void _ecore_xcb_dri_vblank_handler(int fd __UNUSED__, | ||
95 | unsigned int frame __UNUSED__, | ||
96 | unsigned int sec __UNUSED__, | ||
97 | unsigned int usec __UNUSED__, | ||
98 | void *data __UNUSED__); | ||
99 | |||
100 | /* local variables */ | ||
101 | static Ecore_X_Window _vsync_root = 0; | ||
102 | static int _drm_fd = -1; | ||
103 | static Ecore_Fd_Handler *_drm_fdh = NULL; | ||
104 | static unsigned int _drm_magic = 0; | ||
105 | static Eina_Bool _drm_event_busy = EINA_FALSE; | ||
106 | static void *_drm_lib = NULL; | ||
107 | static void *_dri_lib = NULL; | ||
108 | static drmEventContext _drm_evctx; | ||
109 | #endif | ||
110 | |||
111 | void | ||
112 | _ecore_xcb_dri_init(void) | ||
113 | { | ||
114 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
115 | } | ||
116 | |||
117 | void | ||
118 | _ecore_xcb_dri_finalize(void) | ||
119 | { | ||
120 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
121 | } | ||
122 | |||
123 | EAPI Eina_Bool | ||
124 | ecore_x_vsync_animator_tick_source_set(Ecore_X_Window win) | ||
125 | { | ||
126 | #ifdef ECORE_XCB_VSYNC_DRI2 | ||
127 | Ecore_X_Window root; | ||
128 | #endif | ||
129 | |||
130 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
131 | CHECK_XCB_CONN; | ||
132 | |||
133 | #ifdef ECORE_XCB_VSYNC_DRI2 | ||
134 | root = ecore_x_window_root_get(win); | ||
135 | if (root != _vsync_root) | ||
136 | { | ||
137 | _vsync_root = root; | ||
138 | if (_vsync_root) | ||
139 | { | ||
140 | if (!_ecore_xcb_dri_link()) | ||
141 | { | ||
142 | ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER); | ||
143 | return EINA_FALSE; | ||
144 | } | ||
145 | _ecore_xcb_dri_shutdown(); | ||
146 | if (!_ecore_xcb_dri_start()) | ||
147 | { | ||
148 | _vsync_root = 0; | ||
149 | ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER); | ||
150 | return EINA_FALSE; | ||
151 | } | ||
152 | ecore_animator_custom_source_tick_begin_callback_set | ||
153 | (_ecore_xcb_dri_tick_begin, NULL); | ||
154 | ecore_animator_custom_source_tick_end_callback_set | ||
155 | (_ecore_xcb_dri_tick_end, NULL); | ||
156 | ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_CUSTOM); | ||
157 | } | ||
158 | else | ||
159 | { | ||
160 | if (_drm_fd >= 0) | ||
161 | { | ||
162 | _ecore_xcb_dri_shutdown(); | ||
163 | ecore_animator_custom_source_tick_begin_callback_set | ||
164 | (NULL, NULL); | ||
165 | ecore_animator_custom_source_tick_end_callback_set | ||
166 | (NULL, NULL); | ||
167 | ecore_animator_source_set(ECORE_ANIMATOR_SOURCE_TIMER); | ||
168 | } | ||
169 | } | ||
170 | } | ||
171 | return EINA_TRUE; | ||
172 | #else | ||
173 | return EINA_FALSE; | ||
174 | win = 0; | ||
175 | #endif | ||
176 | } | ||
177 | |||
178 | /* local functions */ | ||
179 | #ifdef ECORE_XCB_VSYNC_DRI2 | ||
180 | static Eina_Bool | ||
181 | _ecore_xcb_dri_link(void) | ||
182 | { | ||
183 | const char *_drm_libs[] = | ||
184 | { | ||
185 | "libdrm.so.2", | ||
186 | "libdrm.so.1", | ||
187 | "libdrm.so.0", | ||
188 | "libdrm.so", | ||
189 | NULL, | ||
190 | }; | ||
191 | const char *_dri_libs[] = | ||
192 | { | ||
193 | "libdri2.so.2", | ||
194 | "libdri2.so.1", | ||
195 | "libdri2.so.0", | ||
196 | "libdri2.so", | ||
197 | "libGL.so.4", | ||
198 | "libGL.so.3", | ||
199 | "libGL.so.2", | ||
200 | "libGL.so.1", | ||
201 | "libGL.so.0", | ||
202 | "libGL.so", | ||
203 | NULL, | ||
204 | }; | ||
205 | int i = 0, fail = 0; | ||
206 | |||
207 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
208 | |||
209 | # define SYM(lib, xx) \ | ||
210 | do { \ | ||
211 | sym_## xx = dlsym(lib, #xx); \ | ||
212 | if (!(sym_## xx)) { \ | ||
213 | fprintf(stderr, "%s\n", dlerror()); \ | ||
214 | fail = 1; \ | ||
215 | } \ | ||
216 | } while (0); | ||
217 | |||
218 | if (_drm_lib) return EINA_TRUE; | ||
219 | |||
220 | for (i = 0; _drm_libs[i]; i++) | ||
221 | { | ||
222 | _drm_lib = dlopen(_drm_libs[i], (RTLD_LOCAL | RTLD_LAZY)); | ||
223 | if (_drm_lib) | ||
224 | { | ||
225 | fail = 0; | ||
226 | SYM(_drm_lib, drmClose); | ||
227 | SYM(_drm_lib, drmGetMagic); | ||
228 | SYM(_drm_lib, drmWaitVBlank); | ||
229 | SYM(_drm_lib, drmHandleEvent); | ||
230 | if (fail) | ||
231 | { | ||
232 | dlclose(_drm_lib); | ||
233 | _drm_lib = NULL; | ||
234 | } | ||
235 | else | ||
236 | break; | ||
237 | } | ||
238 | } | ||
239 | if (!_drm_lib) return EINA_FALSE; | ||
240 | for (i = 0; _dri_libs[i]; i++) | ||
241 | { | ||
242 | if ((_dri_lib = dlopen(_dri_libs[i], (RTLD_LOCAL | RTLD_LAZY)))) | ||
243 | { | ||
244 | fail = 0; | ||
245 | SYM(_dri_lib, DRI2QueryExtension); | ||
246 | SYM(_dri_lib, DRI2QueryVersion); | ||
247 | SYM(_dri_lib, DRI2Connect); | ||
248 | SYM(_dri_lib, DRI2Authenticate); | ||
249 | if (fail) | ||
250 | { | ||
251 | dlclose(_dri_lib); | ||
252 | _dri_lib = NULL; | ||
253 | } | ||
254 | else | ||
255 | break; | ||
256 | } | ||
257 | } | ||
258 | if (!_dri_lib) | ||
259 | { | ||
260 | dlclose(_drm_lib); | ||
261 | _drm_lib = NULL; | ||
262 | return EINA_FALSE; | ||
263 | } | ||
264 | |||
265 | return EINA_TRUE; | ||
266 | } | ||
267 | |||
268 | static Eina_Bool | ||
269 | _ecore_xcb_dri_start(void) | ||
270 | { | ||
271 | Ecore_X_Display *disp; | ||
272 | int _dri2_event = 0, _dri2_error = 0; | ||
273 | int _dri2_major = 0, _dri2_minor = 0; | ||
274 | char *device = NULL, *driver = NULL; | ||
275 | |||
276 | disp = ecore_x_display_get(); | ||
277 | if (!sym_DRI2QueryExtension(disp, &_dri2_event, &_dri2_error)) | ||
278 | return 0; | ||
279 | if (!sym_DRI2QueryVersion(disp, &_dri2_major, &_dri2_minor)) | ||
280 | return 0; | ||
281 | if (_dri2_major < 2) return 0; | ||
282 | if (!sym_DRI2Connect(disp, _vsync_root, &driver, &device)) | ||
283 | return 0; | ||
284 | |||
285 | _drm_fd = open(device, O_RDWR); | ||
286 | if (_drm_fd < 0) return 0; | ||
287 | |||
288 | sym_drmGetMagic(_drm_fd, &_drm_magic); | ||
289 | if (!sym_DRI2Authenticate(disp, _vsync_root, _drm_magic)) | ||
290 | { | ||
291 | close(_drm_fd); | ||
292 | _drm_fd = -1; | ||
293 | return EINA_FALSE; | ||
294 | } | ||
295 | |||
296 | memset(&_drm_evctx, 0, sizeof(_drm_evctx)); | ||
297 | _drm_evctx.version = DRM_EVENT_CONTEXT_VERSION; | ||
298 | _drm_evctx.vblank_handler = _ecore_xcb_dri_vblank_handler; | ||
299 | _drm_evctx.page_flip_handler = NULL; | ||
300 | |||
301 | _drm_fdh = ecore_main_fd_handler_add(_drm_fd, ECORE_FD_READ, | ||
302 | _ecore_xcb_dri_cb, NULL, NULL, NULL); | ||
303 | if (!_drm_fdh) | ||
304 | { | ||
305 | close(_drm_fd); | ||
306 | _drm_fd = -1; | ||
307 | return EINA_FALSE; | ||
308 | } | ||
309 | |||
310 | return EINA_TRUE; | ||
311 | } | ||
312 | |||
313 | static void | ||
314 | _ecore_xcb_dri_shutdown(void) | ||
315 | { | ||
316 | if (_drm_fd >= 0) | ||
317 | { | ||
318 | close(_drm_fd); | ||
319 | _drm_fd = -1; | ||
320 | } | ||
321 | if (_drm_fdh) | ||
322 | { | ||
323 | ecore_main_fd_handler_del(_drm_fdh); | ||
324 | _drm_fdh = NULL; | ||
325 | } | ||
326 | } | ||
327 | |||
328 | static Eina_Bool | ||
329 | _ecore_xcb_dri_cb(void *data __UNUSED__, | ||
330 | Ecore_Fd_Handler *fdh __UNUSED__) | ||
331 | { | ||
332 | sym_drmHandleEvent(_drm_fd, &_drm_evctx); | ||
333 | return ECORE_CALLBACK_RENEW; | ||
334 | } | ||
335 | |||
336 | static void | ||
337 | _ecore_xcb_dri_tick_begin(void *data __UNUSED__) | ||
338 | { | ||
339 | _drm_event_busy = EINA_TRUE; | ||
340 | _ecore_xcb_dri_tick_schedule(); | ||
341 | } | ||
342 | |||
343 | static void | ||
344 | _ecore_xcb_dri_tick_end(void *data __UNUSED__) | ||
345 | { | ||
346 | _drm_event_busy = EINA_FALSE; | ||
347 | } | ||
348 | |||
349 | static void | ||
350 | _ecore_xcb_dri_tick_schedule(void) | ||
351 | { | ||
352 | drmVBlank vbl; | ||
353 | |||
354 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
355 | CHECK_XCB_CONN; | ||
356 | |||
357 | vbl.request.type = (DRM_VBLANK_RELATIVE | DRM_VBLANK_EVENT); | ||
358 | vbl.request.sequence = 1; | ||
359 | vbl.request.signal = 0; | ||
360 | |||
361 | sym_drmWaitVBlank(_drm_fd, &vbl); | ||
362 | } | ||
363 | |||
364 | static void | ||
365 | _ecore_xcb_dri_vblank_handler(int fd __UNUSED__, | ||
366 | unsigned int frame __UNUSED__, | ||
367 | unsigned int sec __UNUSED__, | ||
368 | unsigned int usec __UNUSED__, | ||
369 | void *data __UNUSED__) | ||
370 | { | ||
371 | ecore_animator_custom_tick(); | ||
372 | if (_drm_event_busy) _ecore_xcb_dri_tick_schedule(); | ||
373 | } | ||
374 | |||
375 | #endif | ||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_window.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_window.c new file mode 100644 index 0000000..2616c93 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_window.c | |||
@@ -0,0 +1,2233 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #ifdef ECORE_XCB_RENDER | ||
3 | # include <xcb/render.h> | ||
4 | #endif | ||
5 | #ifdef ECORE_XCB_SHAPE | ||
6 | # include <xcb/shape.h> | ||
7 | #endif | ||
8 | #ifdef ECORE_XCB_XPRINT | ||
9 | #include <xcb/xprint.h> | ||
10 | #endif | ||
11 | |||
12 | /* local function prototypes */ | ||
13 | static Ecore_X_Window _ecore_xcb_window_argb_internal_new(Ecore_X_Window parent, | ||
14 | int x, | ||
15 | int y, | ||
16 | int w, | ||
17 | int h, | ||
18 | uint8_t override_redirect, | ||
19 | uint8_t save_under); | ||
20 | static Ecore_X_Window _ecore_xcb_window_at_xy_get(Ecore_X_Window base, | ||
21 | int bx, | ||
22 | int by, | ||
23 | int x, | ||
24 | int y, | ||
25 | Ecore_X_Window *skip, | ||
26 | int skip_num); | ||
27 | static int _ecore_xcb_window_modifiers_get(unsigned int state); | ||
28 | static xcb_visualtype_t *_ecore_xcb_window_find_visual_by_id(xcb_visualid_t id); | ||
29 | #ifdef ECORE_XCB_XPRINT | ||
30 | static xcb_screen_t *_ecore_xcb_window_screen_of_display(int screen); | ||
31 | #endif | ||
32 | |||
33 | /* local variables */ | ||
34 | static int ignore_num = 0; | ||
35 | static Ecore_X_Window *ignore_list = NULL; | ||
36 | |||
37 | /* external variables */ | ||
38 | int _ecore_xcb_button_grabs_num = 0; | ||
39 | int _ecore_xcb_key_grabs_num = 0; | ||
40 | Ecore_X_Window *_ecore_xcb_button_grabs = NULL; | ||
41 | Ecore_X_Window *_ecore_xcb_key_grabs = NULL; | ||
42 | Eina_Bool (*_ecore_xcb_window_grab_replay_func)(void *data, | ||
43 | int type, | ||
44 | void *event); | ||
45 | void *_ecore_xcb_window_grab_replay_data; | ||
46 | |||
47 | /** | ||
48 | * @defgroup Ecore_X_Window_Create_Group X Window Creation Functions | ||
49 | * | ||
50 | * Functions that can be used to create an X window. | ||
51 | */ | ||
52 | |||
53 | /** | ||
54 | * Creates a new window. | ||
55 | * @param parent The parent window to use. If @p parent is @c 0, the root | ||
56 | * window of the default display is used. | ||
57 | * @param x X position. | ||
58 | * @param y Y position. | ||
59 | * @param w Width. | ||
60 | * @param h Height. | ||
61 | * @return The new window handle. | ||
62 | * @ingroup Ecore_X_Window_Create_Group | ||
63 | */ | ||
64 | EAPI Ecore_X_Window | ||
65 | ecore_x_window_new(Ecore_X_Window parent, | ||
66 | int x, | ||
67 | int y, | ||
68 | int w, | ||
69 | int h) | ||
70 | { | ||
71 | Ecore_X_Window win; | ||
72 | uint32_t mask, mask_list[9]; | ||
73 | |||
74 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
75 | CHECK_XCB_CONN; | ||
76 | |||
77 | if (parent == 0) | ||
78 | parent = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
79 | |||
80 | /* NB: Order here is very important due to xcb_cw_t enum */ | ||
81 | mask = (XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY | | ||
82 | XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE | | ||
83 | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK | | ||
84 | XCB_CW_DONT_PROPAGATE); | ||
85 | |||
86 | mask_list[0] = XCB_BACK_PIXMAP_NONE; | ||
87 | mask_list[1] = 0; | ||
88 | mask_list[2] = XCB_GRAVITY_NORTH_WEST; | ||
89 | mask_list[3] = XCB_GRAVITY_NORTH_WEST; | ||
90 | mask_list[4] = XCB_BACKING_STORE_NOT_USEFUL; | ||
91 | mask_list[5] = 0; | ||
92 | mask_list[6] = 0; | ||
93 | mask_list[7] = (XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE | | ||
94 | XCB_EVENT_MASK_BUTTON_PRESS | | ||
95 | XCB_EVENT_MASK_BUTTON_RELEASE | | ||
96 | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | | ||
97 | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE | | ||
98 | XCB_EVENT_MASK_VISIBILITY_CHANGE | | ||
99 | XCB_EVENT_MASK_STRUCTURE_NOTIFY | | ||
100 | XCB_EVENT_MASK_FOCUS_CHANGE | | ||
101 | XCB_EVENT_MASK_PROPERTY_CHANGE | | ||
102 | XCB_EVENT_MASK_COLOR_MAP_CHANGE); | ||
103 | mask_list[8] = XCB_EVENT_MASK_NO_EVENT; | ||
104 | |||
105 | win = xcb_generate_id(_ecore_xcb_conn); | ||
106 | xcb_create_window(_ecore_xcb_conn, XCB_COPY_FROM_PARENT, | ||
107 | win, parent, x, y, w, h, 0, | ||
108 | XCB_WINDOW_CLASS_INPUT_OUTPUT, | ||
109 | XCB_COPY_FROM_PARENT, mask, mask_list); | ||
110 | |||
111 | if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root) | ||
112 | ecore_x_window_defaults_set(win); | ||
113 | |||
114 | return win; | ||
115 | } | ||
116 | |||
117 | /** | ||
118 | * Creates a window with the override redirect attribute set to @c True. | ||
119 | * @param parent The parent window to use. If @p parent is @c 0, the root | ||
120 | * window of the default display is used. | ||
121 | * @param x X position. | ||
122 | * @param y Y position. | ||
123 | * @param w Width. | ||
124 | * @param h Height. | ||
125 | * @return The new window handle. | ||
126 | * @ingroup Ecore_X_Window_Create_Group | ||
127 | */ | ||
128 | EAPI Ecore_X_Window | ||
129 | ecore_x_window_override_new(Ecore_X_Window parent, | ||
130 | int x, | ||
131 | int y, | ||
132 | int w, | ||
133 | int h) | ||
134 | { | ||
135 | Ecore_X_Window win; | ||
136 | uint32_t mask, mask_list[9]; | ||
137 | |||
138 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
139 | CHECK_XCB_CONN; | ||
140 | |||
141 | if (parent == 0) | ||
142 | parent = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
143 | |||
144 | /* NB: Order here is very important due to xcb_cw_t enum */ | ||
145 | mask = (XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY | | ||
146 | XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE | | ||
147 | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER | XCB_CW_EVENT_MASK | | ||
148 | XCB_CW_DONT_PROPAGATE); | ||
149 | |||
150 | mask_list[0] = XCB_BACK_PIXMAP_NONE; | ||
151 | mask_list[1] = 0; | ||
152 | mask_list[2] = XCB_GRAVITY_NORTH_WEST; | ||
153 | mask_list[3] = XCB_GRAVITY_NORTH_WEST; | ||
154 | mask_list[4] = XCB_BACKING_STORE_NOT_USEFUL; | ||
155 | mask_list[5] = 1; | ||
156 | mask_list[6] = 0; | ||
157 | mask_list[7] = (XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE | | ||
158 | XCB_EVENT_MASK_BUTTON_PRESS | | ||
159 | XCB_EVENT_MASK_BUTTON_RELEASE | | ||
160 | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | | ||
161 | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE | | ||
162 | XCB_EVENT_MASK_VISIBILITY_CHANGE | | ||
163 | XCB_EVENT_MASK_STRUCTURE_NOTIFY | | ||
164 | XCB_EVENT_MASK_FOCUS_CHANGE | | ||
165 | XCB_EVENT_MASK_PROPERTY_CHANGE | | ||
166 | XCB_EVENT_MASK_COLOR_MAP_CHANGE); | ||
167 | mask_list[8] = XCB_EVENT_MASK_NO_EVENT; | ||
168 | |||
169 | win = xcb_generate_id(_ecore_xcb_conn); | ||
170 | xcb_create_window(_ecore_xcb_conn, XCB_COPY_FROM_PARENT, | ||
171 | win, parent, x, y, w, h, 0, | ||
172 | XCB_WINDOW_CLASS_INPUT_OUTPUT, | ||
173 | XCB_COPY_FROM_PARENT, mask, mask_list); | ||
174 | |||
175 | return win; | ||
176 | } | ||
177 | |||
178 | /** | ||
179 | * Creates a new input window. | ||
180 | * @param parent The parent window to use. If @p parent is @c 0, the root | ||
181 | * window of the default display is used. | ||
182 | * @param x X position. | ||
183 | * @param y Y position. | ||
184 | * @param w Width. | ||
185 | * @param h Height. | ||
186 | * @return The new window. | ||
187 | * @ingroup Ecore_X_Window_Create_Group | ||
188 | */ | ||
189 | EAPI Ecore_X_Window | ||
190 | ecore_x_window_input_new(Ecore_X_Window parent, | ||
191 | int x, | ||
192 | int y, | ||
193 | int w, | ||
194 | int h) | ||
195 | { | ||
196 | Ecore_X_Window win; | ||
197 | uint32_t mask, mask_list[3]; | ||
198 | |||
199 | LOGFN(__FILE__, __LINE__, __FUNCTION__) | ||
200 | CHECK_XCB_CONN; | ||
201 | |||
202 | if (parent == 0) | ||
203 | parent = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
204 | |||
205 | /* NB: Order here is very important due to xcb_cw_t enum */ | ||
206 | mask = (XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK | | ||
207 | XCB_CW_DONT_PROPAGATE); | ||
208 | |||
209 | mask_list[0] = 1; | ||
210 | mask_list[1] = (XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE | | ||
211 | XCB_EVENT_MASK_BUTTON_PRESS | | ||
212 | XCB_EVENT_MASK_BUTTON_RELEASE | | ||
213 | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | | ||
214 | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE | | ||
215 | XCB_EVENT_MASK_VISIBILITY_CHANGE | | ||
216 | XCB_EVENT_MASK_STRUCTURE_NOTIFY | | ||
217 | XCB_EVENT_MASK_FOCUS_CHANGE | | ||
218 | XCB_EVENT_MASK_PROPERTY_CHANGE | | ||
219 | XCB_EVENT_MASK_COLOR_MAP_CHANGE); | ||
220 | mask_list[2] = XCB_EVENT_MASK_NO_EVENT; | ||
221 | |||
222 | win = xcb_generate_id(_ecore_xcb_conn); | ||
223 | xcb_create_window(_ecore_xcb_conn, XCB_COPY_FROM_PARENT, | ||
224 | win, parent, x, y, w, h, 0, | ||
225 | XCB_WINDOW_CLASS_INPUT_ONLY, | ||
226 | XCB_COPY_FROM_PARENT, mask, mask_list); | ||
227 | |||
228 | return win; | ||
229 | } | ||
230 | |||
231 | /** | ||
232 | * Creates a new window. | ||
233 | * @param parent The parent window to use. If @p parent is @c 0, the root | ||
234 | * window of the default display is used. | ||
235 | * @param x X position. | ||
236 | * @param y Y position. | ||
237 | * @param w Width. | ||
238 | * @param h Height. | ||
239 | * @return The new window handle. | ||
240 | * @ingroup Ecore_X_Window_Create_Group | ||
241 | */ | ||
242 | EAPI Ecore_X_Window | ||
243 | ecore_x_window_manager_argb_new(Ecore_X_Window parent, | ||
244 | int x, | ||
245 | int y, | ||
246 | int w, | ||
247 | int h) | ||
248 | { | ||
249 | Ecore_X_Window win = 0; | ||
250 | |||
251 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
252 | |||
253 | win = _ecore_xcb_window_argb_internal_new(parent, x, y, w, h, 1, 0); | ||
254 | |||
255 | return win; | ||
256 | } | ||
257 | |||
258 | /** | ||
259 | * Creates a new window. | ||
260 | * @param parent The parent window to use. If @p parent is @c 0, the root | ||
261 | * window of the default display is used. | ||
262 | * @param x X position. | ||
263 | * @param y Y position. | ||
264 | * @param w Width. | ||
265 | * @param h Height. | ||
266 | * @return The new window handle. | ||
267 | * @ingroup Ecore_X_Window_Create_Group | ||
268 | */ | ||
269 | EAPI Ecore_X_Window | ||
270 | ecore_x_window_argb_new(Ecore_X_Window parent, | ||
271 | int x, | ||
272 | int y, | ||
273 | int w, | ||
274 | int h) | ||
275 | { | ||
276 | Ecore_X_Window win = 0; | ||
277 | |||
278 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
279 | |||
280 | win = _ecore_xcb_window_argb_internal_new(parent, x, y, w, h, 0, 0); | ||
281 | |||
282 | return win; | ||
283 | } | ||
284 | |||
285 | /** | ||
286 | * Creates a window with the override redirect attribute set to @c True. | ||
287 | * @param parent The parent window to use. If @p parent is @c 0, the root | ||
288 | * window of the default display is used. | ||
289 | * @param x X position. | ||
290 | * @param y Y position. | ||
291 | * @param w Width. | ||
292 | * @param h Height. | ||
293 | * @return The new window handle. | ||
294 | * @ingroup Ecore_X_Window_Create_Group | ||
295 | */ | ||
296 | EAPI Ecore_X_Window | ||
297 | ecore_x_window_override_argb_new(Ecore_X_Window parent, | ||
298 | int x, | ||
299 | int y, | ||
300 | int w, | ||
301 | int h) | ||
302 | { | ||
303 | Ecore_X_Window win = 0; | ||
304 | |||
305 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
306 | |||
307 | win = _ecore_xcb_window_argb_internal_new(parent, x, y, w, h, 1, 0); | ||
308 | |||
309 | return win; | ||
310 | } | ||
311 | |||
312 | /** | ||
313 | * @defgroup Ecore_X_Window_Destroy_Group X Window Destroy Functions | ||
314 | * | ||
315 | * Functions to destroy X windows. | ||
316 | */ | ||
317 | |||
318 | /** | ||
319 | * Deletes the given window. | ||
320 | * @param win The given window. | ||
321 | * @ingroup Ecore_X_Window_Destroy_Group | ||
322 | */ | ||
323 | EAPI void | ||
324 | ecore_x_window_free(Ecore_X_Window win) | ||
325 | { | ||
326 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
327 | CHECK_XCB_CONN; | ||
328 | |||
329 | if (win) | ||
330 | { | ||
331 | /* xcb_destroy_notify_event_t ev; */ | ||
332 | /* Ecore_X_Window root; */ | ||
333 | |||
334 | /* if (xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).rem == 1) */ | ||
335 | /* root = ((xcb_screen_t *)_ecore_xcb_screen)->root; */ | ||
336 | /* else */ | ||
337 | /* { */ | ||
338 | /* xcb_get_geometry_cookie_t cookie; */ | ||
339 | /* xcb_get_geometry_reply_t *reply; */ | ||
340 | |||
341 | /* cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win); */ | ||
342 | /* reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL); */ | ||
343 | /* if (!reply) return; */ | ||
344 | /* root = reply->root; */ | ||
345 | /* free(reply); */ | ||
346 | /* } */ | ||
347 | |||
348 | /* memset(&ev, 0, sizeof(xcb_destroy_notify_event_t)); */ | ||
349 | |||
350 | /* ev.response_type = XCB_DESTROY_NOTIFY; */ | ||
351 | /* ev.window = win; */ | ||
352 | /* ev.event = root; */ | ||
353 | |||
354 | /* xcb_send_event(_ecore_xcb_conn, 0, root, */ | ||
355 | /* XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | */ | ||
356 | /* XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT, */ | ||
357 | /* (const char *)&ev); */ | ||
358 | |||
359 | xcb_destroy_window(_ecore_xcb_conn, win); | ||
360 | // ecore_x_flush(); | ||
361 | } | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Sends a delete request to the given window. | ||
366 | * @param win The given window. | ||
367 | * @ingroup Ecore_X_Window_Destroy_Group | ||
368 | */ | ||
369 | EAPI void | ||
370 | ecore_x_window_delete_request_send(Ecore_X_Window win) | ||
371 | { | ||
372 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
373 | |||
374 | if (!win) return; | ||
375 | ecore_x_client_message32_send(win, ECORE_X_ATOM_WM_PROTOCOLS, | ||
376 | XCB_EVENT_MASK_NO_EVENT, | ||
377 | ECORE_X_ATOM_WM_DELETE_WINDOW, | ||
378 | XCB_CURRENT_TIME, 0, 0, 0); | ||
379 | } | ||
380 | |||
381 | EAPI void | ||
382 | ecore_x_window_configure(Ecore_X_Window win, | ||
383 | Ecore_X_Window_Configure_Mask mask, | ||
384 | int x, | ||
385 | int y, | ||
386 | int w, | ||
387 | int h, | ||
388 | int border_width, | ||
389 | Ecore_X_Window sibling, | ||
390 | int stack_mode) | ||
391 | { | ||
392 | uint16_t vmask = 0; | ||
393 | uint32_t vlist[7]; | ||
394 | unsigned int i = 0; | ||
395 | |||
396 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
397 | CHECK_XCB_CONN; | ||
398 | |||
399 | if (!win) return; | ||
400 | |||
401 | if (mask & XCB_CONFIG_WINDOW_X) | ||
402 | { | ||
403 | vmask |= XCB_CONFIG_WINDOW_X; | ||
404 | vlist[i++] = x; | ||
405 | } | ||
406 | if (mask & XCB_CONFIG_WINDOW_Y) | ||
407 | { | ||
408 | vmask |= XCB_CONFIG_WINDOW_Y; | ||
409 | vlist[i++] = y; | ||
410 | } | ||
411 | if (mask & XCB_CONFIG_WINDOW_WIDTH) | ||
412 | { | ||
413 | vmask |= XCB_CONFIG_WINDOW_WIDTH; | ||
414 | vlist[i++] = w; | ||
415 | } | ||
416 | if (mask & XCB_CONFIG_WINDOW_HEIGHT) | ||
417 | { | ||
418 | vmask |= XCB_CONFIG_WINDOW_HEIGHT; | ||
419 | vlist[i++] = h; | ||
420 | } | ||
421 | if (mask & XCB_CONFIG_WINDOW_BORDER_WIDTH) | ||
422 | { | ||
423 | vmask |= XCB_CONFIG_WINDOW_BORDER_WIDTH; | ||
424 | vlist[i++] = border_width; | ||
425 | } | ||
426 | if (mask & XCB_CONFIG_WINDOW_SIBLING) | ||
427 | { | ||
428 | vmask |= XCB_CONFIG_WINDOW_SIBLING; | ||
429 | vlist[i++] = sibling; | ||
430 | } | ||
431 | if (mask & XCB_CONFIG_WINDOW_STACK_MODE) | ||
432 | { | ||
433 | vmask |= XCB_CONFIG_WINDOW_STACK_MODE; | ||
434 | vlist[i++] = stack_mode; | ||
435 | } | ||
436 | |||
437 | xcb_configure_window(_ecore_xcb_conn, win, vmask, | ||
438 | (const uint32_t *)&vlist); | ||
439 | // ecore_x_flush(); | ||
440 | } | ||
441 | |||
442 | /** | ||
443 | * @defgroup Ecore_X_Window_Geometry_Group X Window Geometry Functions | ||
444 | * | ||
445 | * Functions that change or retrieve the geometry of X windows. | ||
446 | */ | ||
447 | |||
448 | /** | ||
449 | * Moves a window to the position @p x, @p y. | ||
450 | * | ||
451 | * The position is relative to the upper left hand corner of the | ||
452 | * parent window. | ||
453 | * | ||
454 | * @param win The window to move. | ||
455 | * @param x X position. | ||
456 | * @param y Y position. | ||
457 | * @ingroup Ecore_X_Window_Geometry_Group | ||
458 | */ | ||
459 | EAPI void | ||
460 | ecore_x_window_move(Ecore_X_Window win, | ||
461 | int x, | ||
462 | int y) | ||
463 | { | ||
464 | uint32_t list[2], mask; | ||
465 | |||
466 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
467 | CHECK_XCB_CONN; | ||
468 | |||
469 | if (!win) return; | ||
470 | |||
471 | mask = (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y); | ||
472 | list[0] = x; | ||
473 | list[1] = y; | ||
474 | |||
475 | xcb_configure_window(_ecore_xcb_conn, win, mask, | ||
476 | (const uint32_t *)&list); | ||
477 | // ecore_x_flush(); | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Resizes a window. | ||
482 | * @param win The window to resize. | ||
483 | * @param w New width of the window. | ||
484 | * @param h New height of the window. | ||
485 | * @ingroup Ecore_X_Window_Geometry_Group | ||
486 | */ | ||
487 | EAPI void | ||
488 | ecore_x_window_resize(Ecore_X_Window win, | ||
489 | int w, | ||
490 | int h) | ||
491 | { | ||
492 | uint32_t list[2], mask; | ||
493 | |||
494 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
495 | CHECK_XCB_CONN; | ||
496 | |||
497 | if (!win) return; | ||
498 | if (w < 1) w = 1; | ||
499 | if (h < 1) h = 1; | ||
500 | |||
501 | mask = (XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT); | ||
502 | list[0] = w; | ||
503 | list[1] = h; | ||
504 | |||
505 | xcb_configure_window(_ecore_xcb_conn, win, mask, | ||
506 | (const uint32_t *)&list); | ||
507 | // ecore_x_flush(); | ||
508 | } | ||
509 | |||
510 | /** | ||
511 | * Moves and resizes a window. | ||
512 | * @param win The window to move and resize. | ||
513 | * @param x New X position of the window. | ||
514 | * @param y New Y position of the window. | ||
515 | * @param w New width of the window. | ||
516 | * @param h New height of the window. | ||
517 | * @ingroup Ecore_X_Window_Geometry_Group | ||
518 | */ | ||
519 | EAPI void | ||
520 | ecore_x_window_move_resize(Ecore_X_Window win, | ||
521 | int x, | ||
522 | int y, | ||
523 | int w, | ||
524 | int h) | ||
525 | { | ||
526 | uint32_t list[4], mask; | ||
527 | |||
528 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
529 | CHECK_XCB_CONN; | ||
530 | |||
531 | if (!win) return; | ||
532 | if (w < 1) w = 1; | ||
533 | if (h < 1) h = 1; | ||
534 | |||
535 | mask = (XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | | ||
536 | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT); | ||
537 | list[0] = x; | ||
538 | list[1] = y; | ||
539 | list[2] = w; | ||
540 | list[3] = h; | ||
541 | |||
542 | xcb_configure_window(_ecore_xcb_conn, win, mask, | ||
543 | (const uint32_t *)&list); | ||
544 | // ecore_x_flush(); | ||
545 | } | ||
546 | |||
547 | /** | ||
548 | * Retrieves the width of the border of the given window. | ||
549 | * @param win The given window. | ||
550 | * @return Width of the border of @p win. | ||
551 | * @ingroup Ecore_X_Window_Geometry_Group | ||
552 | */ | ||
553 | EAPI int | ||
554 | ecore_x_window_border_width_get(Ecore_X_Window win) | ||
555 | { | ||
556 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
557 | |||
558 | if (!win) return 0; | ||
559 | return ecore_x_drawable_border_width_get(win); | ||
560 | } | ||
561 | |||
562 | /** | ||
563 | * Sets the width of the border of the given window. | ||
564 | * @param win The given window. | ||
565 | * @param width The new border width. | ||
566 | * @ingroup Ecore_X_Window_Geometry_Group | ||
567 | */ | ||
568 | EAPI void | ||
569 | ecore_x_window_border_width_set(Ecore_X_Window win, | ||
570 | int border_width) | ||
571 | { | ||
572 | uint32_t list; | ||
573 | |||
574 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
575 | CHECK_XCB_CONN; | ||
576 | |||
577 | if (!win) return; | ||
578 | |||
579 | list = border_width; | ||
580 | |||
581 | xcb_configure_window(_ecore_xcb_conn, win, | ||
582 | XCB_CONFIG_WINDOW_BORDER_WIDTH, &list); | ||
583 | // ecore_x_flush(); | ||
584 | } | ||
585 | |||
586 | /** | ||
587 | * @defgroup Ecore_X_Window_Z_Order_Group X Window Z Order Functions | ||
588 | * | ||
589 | * Functions that change the Z order of X windows. | ||
590 | */ | ||
591 | |||
592 | /** | ||
593 | * Raises the given window. | ||
594 | * @param win The window to raise. | ||
595 | * @ingroup Ecore_X_Window_Z_Order_Group | ||
596 | */ | ||
597 | EAPI void | ||
598 | ecore_x_window_raise(Ecore_X_Window win) | ||
599 | { | ||
600 | uint32_t list[] = { XCB_STACK_MODE_ABOVE }; | ||
601 | |||
602 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
603 | CHECK_XCB_CONN; | ||
604 | |||
605 | xcb_configure_window(_ecore_xcb_conn, win, | ||
606 | XCB_CONFIG_WINDOW_STACK_MODE, list); | ||
607 | // ecore_x_flush(); | ||
608 | } | ||
609 | |||
610 | /** | ||
611 | * Lowers the given window. | ||
612 | * @param win The window to lower. | ||
613 | * @ingroup Ecore_X_Window_Z_Order_Group | ||
614 | */ | ||
615 | EAPI void | ||
616 | ecore_x_window_lower(Ecore_X_Window win) | ||
617 | { | ||
618 | uint32_t list[] = { XCB_STACK_MODE_BELOW }; | ||
619 | |||
620 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
621 | CHECK_XCB_CONN; | ||
622 | |||
623 | xcb_configure_window(_ecore_xcb_conn, win, | ||
624 | XCB_CONFIG_WINDOW_STACK_MODE, list); | ||
625 | // ecore_x_flush(); | ||
626 | } | ||
627 | |||
628 | /** | ||
629 | * Retrieves the depth of the given window. | ||
630 | * @param win The given window. | ||
631 | * @return Depth of the window. | ||
632 | */ | ||
633 | EAPI int | ||
634 | ecore_x_window_depth_get(Ecore_X_Window win) | ||
635 | { | ||
636 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
637 | |||
638 | return ecore_x_drawable_depth_get(win); | ||
639 | } | ||
640 | |||
641 | /** | ||
642 | * @defgroup Ecore_X_Window_Properties_Group X Window Property Functions | ||
643 | * | ||
644 | * Functions that set window properties. | ||
645 | */ | ||
646 | |||
647 | /** | ||
648 | * Sets the default properties for the given window. | ||
649 | * | ||
650 | * The default properties set for the window are @c WM_CLIENT_MACHINE and | ||
651 | * @c _NET_WM_PID. | ||
652 | * | ||
653 | * @param win The given window. | ||
654 | * @ingroup Ecore_X_Window_Properties_Groups | ||
655 | */ | ||
656 | EAPI void | ||
657 | ecore_x_window_defaults_set(Ecore_X_Window win) | ||
658 | { | ||
659 | char buff[MAXHOSTNAMELEN], **argv; | ||
660 | int argc; | ||
661 | pid_t pid; | ||
662 | |||
663 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
664 | CHECK_XCB_CONN; | ||
665 | |||
666 | gethostname(buff, MAXHOSTNAMELEN); | ||
667 | buff[MAXHOSTNAMELEN - 1] = '\0'; | ||
668 | |||
669 | xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, win, | ||
670 | ECORE_X_ATOM_WM_CLIENT_MACHINE, ECORE_X_ATOM_STRING, | ||
671 | 8, strlen(buff), buff); | ||
672 | |||
673 | pid = getpid(); | ||
674 | ecore_x_netwm_pid_set(win, pid); | ||
675 | ecore_x_netwm_window_type_set(win, ECORE_X_WINDOW_TYPE_NORMAL); | ||
676 | ecore_app_args_get(&argc, &argv); | ||
677 | ecore_x_icccm_command_set(win, argc, argv); | ||
678 | } | ||
679 | |||
680 | /** | ||
681 | * @defgroup Ecore_X_Window_Visibility_Group X Window Visibility Functions | ||
682 | * | ||
683 | * Functions to access and change the visibility of X windows. | ||
684 | */ | ||
685 | |||
686 | /** | ||
687 | * Shows a window. | ||
688 | * | ||
689 | * Synonymous to "mapping" a window in X Window System terminology. | ||
690 | * | ||
691 | * @param win The window to show. | ||
692 | * @ingroup Ecore_X_Window_Visibility | ||
693 | */ | ||
694 | EAPI void | ||
695 | ecore_x_window_show(Ecore_X_Window win) | ||
696 | { | ||
697 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
698 | CHECK_XCB_CONN; | ||
699 | |||
700 | if (win) | ||
701 | xcb_map_window(_ecore_xcb_conn, win); | ||
702 | } | ||
703 | |||
704 | /** | ||
705 | * Hides a window. | ||
706 | * | ||
707 | * Synonymous to "unmapping" a window in X Window System terminology. | ||
708 | * | ||
709 | * @param win The window to hide. | ||
710 | * @ingroup Ecore_X_Window_Visibility | ||
711 | */ | ||
712 | EAPI void | ||
713 | ecore_x_window_hide(Ecore_X_Window win) | ||
714 | { | ||
715 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
716 | CHECK_XCB_CONN; | ||
717 | |||
718 | if (win) | ||
719 | { | ||
720 | xcb_unmap_notify_event_t ev; | ||
721 | Ecore_X_Window root; | ||
722 | |||
723 | if (xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)).rem == 1) | ||
724 | root = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
725 | else | ||
726 | { | ||
727 | xcb_get_geometry_cookie_t cookie; | ||
728 | xcb_get_geometry_reply_t *reply; | ||
729 | |||
730 | cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win); | ||
731 | reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL); | ||
732 | if (!reply) return; | ||
733 | root = reply->root; | ||
734 | free(reply); | ||
735 | } | ||
736 | |||
737 | memset(&ev, 0, sizeof(xcb_unmap_notify_event_t)); | ||
738 | |||
739 | ev.response_type = XCB_UNMAP_NOTIFY; | ||
740 | ev.window = win; | ||
741 | ev.event = root; | ||
742 | ev.from_configure = 0; | ||
743 | |||
744 | xcb_send_event(_ecore_xcb_conn, 0, root, | ||
745 | (XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | | ||
746 | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT), | ||
747 | (const char *)&ev); | ||
748 | |||
749 | xcb_unmap_window(_ecore_xcb_conn, win); | ||
750 | // ecore_x_flush(); | ||
751 | } | ||
752 | } | ||
753 | |||
754 | /** | ||
755 | * @defgroup Ecore_X_Window_Focus_Functions X Window Focus Functions | ||
756 | * | ||
757 | * Functions that give the focus to an X Window. | ||
758 | */ | ||
759 | |||
760 | /** | ||
761 | * Sets the focus to the window @p win. | ||
762 | * @param win The window to focus. | ||
763 | * @ingroup Ecore_X_Window_Focus_Functions | ||
764 | */ | ||
765 | EAPI void | ||
766 | ecore_x_window_focus(Ecore_X_Window win) | ||
767 | { | ||
768 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
769 | CHECK_XCB_CONN; | ||
770 | |||
771 | if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
772 | |||
773 | xcb_set_input_focus(_ecore_xcb_conn, | ||
774 | XCB_INPUT_FOCUS_PARENT, win, XCB_CURRENT_TIME); | ||
775 | // ecore_x_flush(); | ||
776 | } | ||
777 | |||
778 | /** | ||
779 | * Sets the focus to the given window at a specific time. | ||
780 | * @param win The window to focus. | ||
781 | * @param t When to set the focus to the window. | ||
782 | * @ingroup Ecore_X_Window_Focus_Functions | ||
783 | */ | ||
784 | EAPI void | ||
785 | ecore_x_window_focus_at_time(Ecore_X_Window win, | ||
786 | Ecore_X_Time time) | ||
787 | { | ||
788 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
789 | CHECK_XCB_CONN; | ||
790 | |||
791 | if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
792 | xcb_set_input_focus(_ecore_xcb_conn, XCB_INPUT_FOCUS_PARENT, win, time); | ||
793 | // ecore_x_flush(); | ||
794 | } | ||
795 | |||
796 | /** | ||
797 | * @defgroup Ecore_X_Window_Parent_Group X Window Parent Functions | ||
798 | * | ||
799 | * Functions that retrieve or changes the parent window of a window. | ||
800 | */ | ||
801 | |||
802 | /** | ||
803 | * Moves a window to within another window at a given position. | ||
804 | * @param win The window to reparent. | ||
805 | * @param new_parent The new parent window. | ||
806 | * @param x X position within new parent window. | ||
807 | * @param y Y position within new parent window. | ||
808 | * @ingroup Ecore_X_Window_Parent_Group | ||
809 | */ | ||
810 | EAPI void | ||
811 | ecore_x_window_reparent(Ecore_X_Window win, | ||
812 | Ecore_X_Window parent, | ||
813 | int x, | ||
814 | int y) | ||
815 | { | ||
816 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
817 | CHECK_XCB_CONN; | ||
818 | |||
819 | if (parent == 0) | ||
820 | parent = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
821 | |||
822 | xcb_reparent_window(_ecore_xcb_conn, win, parent, x, y); | ||
823 | // ecore_x_flush(); | ||
824 | } | ||
825 | |||
826 | EAPI void | ||
827 | ecore_x_window_pixmap_set(Ecore_X_Window win, | ||
828 | Ecore_X_Pixmap pixmap) | ||
829 | { | ||
830 | uint32_t list; | ||
831 | |||
832 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
833 | CHECK_XCB_CONN; | ||
834 | |||
835 | list = pixmap; | ||
836 | |||
837 | xcb_change_window_attributes(_ecore_xcb_conn, win, | ||
838 | XCB_CW_BACK_PIXMAP, &list); | ||
839 | // ecore_x_flush(); | ||
840 | } | ||
841 | |||
842 | /** | ||
843 | * Sets the background color of the given window. | ||
844 | * @param win The given window | ||
845 | * @param r red value (0...65536, 16 bits) | ||
846 | * @param g green value (0...65536, 16 bits) | ||
847 | * @param b blue value (0...65536, 16 bits) | ||
848 | */ | ||
849 | EAPI void | ||
850 | ecore_x_window_background_color_set(Ecore_X_Window win, | ||
851 | unsigned short red, | ||
852 | unsigned short green, | ||
853 | unsigned short blue) | ||
854 | { | ||
855 | xcb_alloc_color_cookie_t cookie; | ||
856 | xcb_alloc_color_reply_t *reply; | ||
857 | uint32_t list; | ||
858 | |||
859 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
860 | CHECK_XCB_CONN; | ||
861 | |||
862 | cookie = | ||
863 | xcb_alloc_color_unchecked(_ecore_xcb_conn, | ||
864 | ((xcb_screen_t *)_ecore_xcb_screen)->default_colormap, | ||
865 | red, green, blue); | ||
866 | reply = xcb_alloc_color_reply(_ecore_xcb_conn, cookie, NULL); | ||
867 | if (!reply) return; | ||
868 | list = reply->pixel; | ||
869 | free(reply); | ||
870 | |||
871 | xcb_change_window_attributes(_ecore_xcb_conn, win, | ||
872 | XCB_CW_BACK_PIXEL, &list); | ||
873 | // ecore_x_flush(); | ||
874 | } | ||
875 | |||
876 | EAPI void | ||
877 | ecore_x_window_pixel_gravity_set(Ecore_X_Window win, | ||
878 | Ecore_X_Gravity gravity) | ||
879 | { | ||
880 | uint32_t list; | ||
881 | |||
882 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
883 | CHECK_XCB_CONN; | ||
884 | |||
885 | list = gravity; | ||
886 | |||
887 | xcb_change_window_attributes(_ecore_xcb_conn, win, | ||
888 | XCB_CW_BIT_GRAVITY, &list); | ||
889 | // ecore_x_flush(); | ||
890 | } | ||
891 | |||
892 | EAPI void | ||
893 | ecore_x_window_gravity_set(Ecore_X_Window win, | ||
894 | Ecore_X_Gravity gravity) | ||
895 | { | ||
896 | uint32_t list; | ||
897 | |||
898 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
899 | CHECK_XCB_CONN; | ||
900 | |||
901 | list = gravity; | ||
902 | |||
903 | xcb_change_window_attributes(_ecore_xcb_conn, win, | ||
904 | XCB_CW_WIN_GRAVITY, &list); | ||
905 | // ecore_x_flush(); | ||
906 | } | ||
907 | |||
908 | EAPI void | ||
909 | ecore_x_window_override_set(Ecore_X_Window win, | ||
910 | Eina_Bool override) | ||
911 | { | ||
912 | uint32_t list; | ||
913 | |||
914 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
915 | CHECK_XCB_CONN; | ||
916 | |||
917 | list = override; | ||
918 | |||
919 | xcb_change_window_attributes(_ecore_xcb_conn, win, | ||
920 | XCB_CW_OVERRIDE_REDIRECT, &list); | ||
921 | // ecore_x_flush(); | ||
922 | } | ||
923 | |||
924 | /** | ||
925 | * To be documented. | ||
926 | * | ||
927 | * FIXME: To be fixed. | ||
928 | */ | ||
929 | EAPI void | ||
930 | ecore_x_window_cursor_show(Ecore_X_Window win, | ||
931 | Eina_Bool show) | ||
932 | { | ||
933 | uint32_t list = 0; | ||
934 | |||
935 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
936 | CHECK_XCB_CONN; | ||
937 | |||
938 | if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
939 | |||
940 | if (!show) | ||
941 | { | ||
942 | Ecore_X_Cursor cursor; | ||
943 | Ecore_X_Pixmap p, m; | ||
944 | Ecore_X_GC gc; | ||
945 | xcb_point_t point; | ||
946 | |||
947 | p = xcb_generate_id(_ecore_xcb_conn); | ||
948 | xcb_create_pixmap(_ecore_xcb_conn, 1, p, win, 1, 1); | ||
949 | m = xcb_generate_id(_ecore_xcb_conn); | ||
950 | xcb_create_pixmap(_ecore_xcb_conn, 1, m, win, 1, 1); | ||
951 | gc = xcb_generate_id(_ecore_xcb_conn); | ||
952 | xcb_create_gc(_ecore_xcb_conn, gc, win, 0, NULL); | ||
953 | xcb_change_gc(_ecore_xcb_conn, gc, XCB_GC_FOREGROUND, &list); | ||
954 | point.x = 0; | ||
955 | point.y = 0; | ||
956 | xcb_poly_point(_ecore_xcb_conn, XCB_COORD_MODE_ORIGIN, | ||
957 | win, gc, 1, &point); | ||
958 | xcb_free_gc(_ecore_xcb_conn, gc); | ||
959 | |||
960 | cursor = xcb_generate_id(_ecore_xcb_conn); | ||
961 | xcb_create_cursor(_ecore_xcb_conn, cursor, | ||
962 | p, m, 0, 0, 0, 0, 0, 0, 0, 0); | ||
963 | list = cursor; | ||
964 | |||
965 | xcb_change_window_attributes(_ecore_xcb_conn, win, | ||
966 | XCB_CW_CURSOR, &list); | ||
967 | |||
968 | xcb_free_cursor(_ecore_xcb_conn, cursor); | ||
969 | xcb_free_pixmap(_ecore_xcb_conn, m); | ||
970 | xcb_free_pixmap(_ecore_xcb_conn, p); | ||
971 | } | ||
972 | else | ||
973 | { | ||
974 | xcb_change_window_attributes(_ecore_xcb_conn, win, | ||
975 | XCB_CW_CURSOR, &list); | ||
976 | } | ||
977 | // ecore_x_flush(); | ||
978 | } | ||
979 | |||
980 | EAPI void | ||
981 | ecore_x_window_cursor_set(Ecore_X_Window win, | ||
982 | Ecore_X_Cursor cursor) | ||
983 | { | ||
984 | uint32_t list; | ||
985 | |||
986 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
987 | CHECK_XCB_CONN; | ||
988 | |||
989 | list = cursor; | ||
990 | |||
991 | xcb_change_window_attributes(_ecore_xcb_conn, win, XCB_CW_CURSOR, &list); | ||
992 | // ecore_x_flush(); | ||
993 | } | ||
994 | |||
995 | EAPI void | ||
996 | ecore_x_window_container_manage(Ecore_X_Window win) | ||
997 | { | ||
998 | uint32_t list; | ||
999 | |||
1000 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1001 | CHECK_XCB_CONN; | ||
1002 | |||
1003 | list = (XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | | ||
1004 | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY); | ||
1005 | |||
1006 | xcb_change_window_attributes(_ecore_xcb_conn, win, | ||
1007 | XCB_CW_EVENT_MASK, &list); | ||
1008 | // ecore_x_flush(); | ||
1009 | } | ||
1010 | |||
1011 | EAPI void | ||
1012 | ecore_x_window_client_manage(Ecore_X_Window win) | ||
1013 | { | ||
1014 | uint32_t list; | ||
1015 | |||
1016 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1017 | CHECK_XCB_CONN; | ||
1018 | |||
1019 | list = (XCB_EVENT_MASK_VISIBILITY_CHANGE | | ||
1020 | XCB_EVENT_MASK_FOCUS_CHANGE | | ||
1021 | XCB_EVENT_MASK_PROPERTY_CHANGE | | ||
1022 | XCB_EVENT_MASK_COLOR_MAP_CHANGE | | ||
1023 | XCB_EVENT_MASK_STRUCTURE_NOTIFY | | ||
1024 | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY); | ||
1025 | |||
1026 | xcb_change_window_attributes(_ecore_xcb_conn, win, | ||
1027 | XCB_CW_EVENT_MASK, &list); | ||
1028 | |||
1029 | #ifdef ECORE_XCB_SHAPE | ||
1030 | xcb_shape_select_input(_ecore_xcb_conn, win, EINA_TRUE); | ||
1031 | #endif | ||
1032 | // ecore_x_flush(); | ||
1033 | } | ||
1034 | |||
1035 | EAPI void | ||
1036 | ecore_x_window_sniff(Ecore_X_Window win) | ||
1037 | { | ||
1038 | uint32_t list; | ||
1039 | |||
1040 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1041 | CHECK_XCB_CONN; | ||
1042 | |||
1043 | list = (XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | | ||
1044 | XCB_EVENT_MASK_PROPERTY_CHANGE); | ||
1045 | |||
1046 | xcb_change_window_attributes(_ecore_xcb_conn, win, | ||
1047 | XCB_CW_EVENT_MASK, &list); | ||
1048 | // ecore_x_flush(); | ||
1049 | } | ||
1050 | |||
1051 | EAPI void | ||
1052 | ecore_x_window_client_sniff(Ecore_X_Window win) | ||
1053 | { | ||
1054 | uint32_t list; | ||
1055 | |||
1056 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1057 | CHECK_XCB_CONN; | ||
1058 | |||
1059 | list = (XCB_EVENT_MASK_VISIBILITY_CHANGE | | ||
1060 | XCB_EVENT_MASK_STRUCTURE_NOTIFY | | ||
1061 | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | | ||
1062 | XCB_EVENT_MASK_FOCUS_CHANGE | | ||
1063 | XCB_EVENT_MASK_PROPERTY_CHANGE | | ||
1064 | XCB_EVENT_MASK_COLOR_MAP_CHANGE); | ||
1065 | |||
1066 | xcb_change_window_attributes(_ecore_xcb_conn, win, | ||
1067 | XCB_CW_EVENT_MASK, &list); | ||
1068 | #ifdef ECORE_XCB_SHAPE | ||
1069 | xcb_shape_select_input(_ecore_xcb_conn, win, EINA_TRUE); | ||
1070 | #endif | ||
1071 | // ecore_x_flush(); | ||
1072 | } | ||
1073 | |||
1074 | EAPI void | ||
1075 | ecore_x_window_area_clear(Ecore_X_Window win, | ||
1076 | int x, | ||
1077 | int y, | ||
1078 | int w, | ||
1079 | int h) | ||
1080 | { | ||
1081 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1082 | CHECK_XCB_CONN; | ||
1083 | |||
1084 | xcb_clear_area(_ecore_xcb_conn, 0, win, x, y, w, h); | ||
1085 | // ecore_x_flush(); | ||
1086 | } | ||
1087 | |||
1088 | EAPI void | ||
1089 | ecore_x_window_area_expose(Ecore_X_Window win, | ||
1090 | int x, | ||
1091 | int y, | ||
1092 | int w, | ||
1093 | int h) | ||
1094 | { | ||
1095 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1096 | CHECK_XCB_CONN; | ||
1097 | |||
1098 | xcb_clear_area(_ecore_xcb_conn, 1, win, x, y, w, h); | ||
1099 | // ecore_x_flush(); | ||
1100 | } | ||
1101 | |||
1102 | EAPI void | ||
1103 | ecore_x_window_save_set_add(Ecore_X_Window win) | ||
1104 | { | ||
1105 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1106 | CHECK_XCB_CONN; | ||
1107 | |||
1108 | xcb_change_save_set(_ecore_xcb_conn, XCB_SET_MODE_INSERT, win); | ||
1109 | } | ||
1110 | |||
1111 | EAPI void | ||
1112 | ecore_x_window_save_set_del(Ecore_X_Window win) | ||
1113 | { | ||
1114 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1115 | CHECK_XCB_CONN; | ||
1116 | |||
1117 | xcb_change_save_set(_ecore_xcb_conn, XCB_SET_MODE_DELETE, win); | ||
1118 | } | ||
1119 | |||
1120 | /** | ||
1121 | * gets the focus to the window @p win. | ||
1122 | * @return The window that has focus. | ||
1123 | * @ingroup Ecore_X_Window_Focus_Functions | ||
1124 | */ | ||
1125 | EAPI Ecore_X_Window | ||
1126 | ecore_x_window_focus_get(void) | ||
1127 | { | ||
1128 | xcb_get_input_focus_cookie_t cookie; | ||
1129 | xcb_get_input_focus_reply_t *reply; | ||
1130 | Ecore_X_Window focus = 0; | ||
1131 | |||
1132 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1133 | CHECK_XCB_CONN; | ||
1134 | |||
1135 | cookie = xcb_get_input_focus_unchecked(_ecore_xcb_conn); | ||
1136 | reply = xcb_get_input_focus_reply(_ecore_xcb_conn, cookie, NULL); | ||
1137 | if (!reply) return 0; | ||
1138 | focus = reply->focus; | ||
1139 | free(reply); | ||
1140 | return focus; | ||
1141 | } | ||
1142 | |||
1143 | EAPI int | ||
1144 | ecore_x_window_argb_get(Ecore_X_Window win) | ||
1145 | { | ||
1146 | uint8_t ret = 0; | ||
1147 | #ifdef ECORE_XCB_RENDER | ||
1148 | Ecore_X_Visual visual; | ||
1149 | #endif | ||
1150 | |||
1151 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1152 | CHECK_XCB_CONN; | ||
1153 | |||
1154 | // if (!win) return ret; | ||
1155 | |||
1156 | #ifdef ECORE_XCB_RENDER | ||
1157 | /* grab the window's visual */ | ||
1158 | visual = _ecore_xcb_window_visual_get(win); | ||
1159 | |||
1160 | /* check if this visual supports alpha */ | ||
1161 | ret = _ecore_xcb_render_visual_supports_alpha(visual); | ||
1162 | #endif | ||
1163 | |||
1164 | return ret; | ||
1165 | } | ||
1166 | |||
1167 | EAPI Eina_Bool | ||
1168 | ecore_x_window_manage(Ecore_X_Window win) | ||
1169 | { | ||
1170 | xcb_get_window_attributes_cookie_t cookie; | ||
1171 | xcb_get_window_attributes_reply_t *reply; | ||
1172 | xcb_void_cookie_t change_cookie; | ||
1173 | xcb_generic_error_t *err; | ||
1174 | uint32_t list; | ||
1175 | |||
1176 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1177 | CHECK_XCB_CONN; | ||
1178 | |||
1179 | cookie = xcb_get_window_attributes(_ecore_xcb_conn, win); | ||
1180 | reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL); | ||
1181 | if (!reply) return EINA_FALSE; | ||
1182 | |||
1183 | ecore_x_sync(); // needed | ||
1184 | |||
1185 | list = (XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | | ||
1186 | XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_RESIZE_REDIRECT | | ||
1187 | XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT | | ||
1188 | XCB_EVENT_MASK_SUBSTRUCTURE_NOTIFY | | ||
1189 | XCB_EVENT_MASK_STRUCTURE_NOTIFY | | ||
1190 | XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE | | ||
1191 | reply->your_event_mask); | ||
1192 | free(reply); | ||
1193 | |||
1194 | change_cookie = xcb_change_window_attributes(_ecore_xcb_conn, win, | ||
1195 | XCB_CW_EVENT_MASK, &list); | ||
1196 | |||
1197 | ecore_x_sync(); // needed | ||
1198 | |||
1199 | err = xcb_request_check(_ecore_xcb_conn, change_cookie); | ||
1200 | if (err) | ||
1201 | { | ||
1202 | _ecore_xcb_error_handle(err); | ||
1203 | free(err); | ||
1204 | return EINA_FALSE; | ||
1205 | } | ||
1206 | |||
1207 | return EINA_TRUE; | ||
1208 | } | ||
1209 | |||
1210 | EAPI Eina_Bool | ||
1211 | ecore_x_window_attributes_get(Ecore_X_Window win, | ||
1212 | Ecore_X_Window_Attributes *att_ret) | ||
1213 | { | ||
1214 | xcb_get_window_attributes_cookie_t cookie; | ||
1215 | xcb_get_window_attributes_reply_t *reply; | ||
1216 | xcb_get_geometry_cookie_t gcookie; | ||
1217 | xcb_get_geometry_reply_t *greply; | ||
1218 | |||
1219 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1220 | CHECK_XCB_CONN; | ||
1221 | |||
1222 | cookie = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, win); | ||
1223 | reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL); | ||
1224 | if (!reply) return EINA_FALSE; | ||
1225 | |||
1226 | memset(att_ret, 0, sizeof(Ecore_X_Window_Attributes)); | ||
1227 | |||
1228 | if (reply->map_state != XCB_MAP_STATE_UNMAPPED) | ||
1229 | att_ret->visible = EINA_TRUE; | ||
1230 | |||
1231 | if (reply->map_state == XCB_MAP_STATE_VIEWABLE) | ||
1232 | att_ret->viewable = EINA_TRUE; | ||
1233 | |||
1234 | if (reply->override_redirect) | ||
1235 | att_ret->override = EINA_TRUE; | ||
1236 | |||
1237 | if (reply->_class == XCB_WINDOW_CLASS_INPUT_ONLY) | ||
1238 | att_ret->input_only = EINA_TRUE; | ||
1239 | |||
1240 | if (reply->save_under) | ||
1241 | att_ret->save_under = EINA_TRUE; | ||
1242 | |||
1243 | att_ret->event_mask.mine = reply->your_event_mask; | ||
1244 | att_ret->event_mask.all = reply->all_event_masks; | ||
1245 | att_ret->event_mask.no_propagate = reply->do_not_propagate_mask; | ||
1246 | att_ret->window_gravity = reply->win_gravity; | ||
1247 | att_ret->pixel_gravity = reply->bit_gravity; | ||
1248 | att_ret->colormap = reply->colormap; | ||
1249 | att_ret->visual = _ecore_xcb_window_find_visual_by_id(reply->visual); | ||
1250 | |||
1251 | free(reply); | ||
1252 | |||
1253 | gcookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win); | ||
1254 | greply = xcb_get_geometry_reply(_ecore_xcb_conn, gcookie, NULL); | ||
1255 | if (!greply) return EINA_TRUE; | ||
1256 | |||
1257 | /* xcb_translate_coordinates_reply_t *trans; */ | ||
1258 | /* xcb_query_tree_cookie_t tcookie; */ | ||
1259 | /* xcb_query_tree_reply_t *treply; */ | ||
1260 | |||
1261 | /* tcookie = xcb_query_tree(_ecore_xcb_conn, win); */ | ||
1262 | /* treply = xcb_query_tree_reply(_ecore_xcb_conn, tcookie, NULL); */ | ||
1263 | |||
1264 | /* trans = */ | ||
1265 | /* xcb_translate_coordinates_reply(_ecore_xcb_conn, */ | ||
1266 | /* xcb_translate_coordinates(_ecore_xcb_conn, */ | ||
1267 | /* win, treply->parent, greply->x, greply->y), NULL); */ | ||
1268 | /* free(treply); */ | ||
1269 | |||
1270 | att_ret->root = greply->root; | ||
1271 | att_ret->depth = greply->depth; | ||
1272 | // att_ret->x = trans->dst_x; | ||
1273 | // att_ret->y = trans->dst_y; | ||
1274 | att_ret->x = greply->x; | ||
1275 | att_ret->y = greply->y; | ||
1276 | att_ret->w = greply->width; | ||
1277 | att_ret->h = greply->height; | ||
1278 | att_ret->border = greply->border_width; | ||
1279 | |||
1280 | // free(trans); | ||
1281 | |||
1282 | free(greply); | ||
1283 | return EINA_TRUE; | ||
1284 | } | ||
1285 | |||
1286 | /** | ||
1287 | * Retrieves the size of the given window. | ||
1288 | * @param win The given window. | ||
1289 | * @param w Pointer to an integer into which the width is to be stored. | ||
1290 | * @param h Pointer to an integer into which the height is to be stored. | ||
1291 | * @ingroup Ecore_X_Window_Geometry_Group | ||
1292 | */ | ||
1293 | EAPI void | ||
1294 | ecore_x_window_size_get(Ecore_X_Window win, | ||
1295 | int *width, | ||
1296 | int *height) | ||
1297 | { | ||
1298 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1299 | CHECK_XCB_CONN; | ||
1300 | |||
1301 | if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
1302 | ecore_x_drawable_geometry_get(win, NULL, NULL, width, height); | ||
1303 | } | ||
1304 | |||
1305 | /** | ||
1306 | * Set if a window should be ignored. | ||
1307 | * @param win The given window. | ||
1308 | * @param ignore if to ignore | ||
1309 | */ | ||
1310 | EAPI void | ||
1311 | ecore_x_window_ignore_set(Ecore_X_Window win, | ||
1312 | int ignore) | ||
1313 | { | ||
1314 | int i = 0, j = 0, count = 0; | ||
1315 | |||
1316 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1317 | CHECK_XCB_CONN; | ||
1318 | |||
1319 | if (ignore) | ||
1320 | { | ||
1321 | if (ignore_list) | ||
1322 | { | ||
1323 | for (i = 0; i < ignore_num; i++) | ||
1324 | if (win == ignore_list[i]) return; | ||
1325 | |||
1326 | ignore_list = | ||
1327 | realloc(ignore_list, (ignore_num + 1) * sizeof(Ecore_X_Window)); | ||
1328 | if (!ignore_list) return; | ||
1329 | |||
1330 | ignore_list[ignore_num++] = win; | ||
1331 | } | ||
1332 | else | ||
1333 | { | ||
1334 | ignore_num = 0; | ||
1335 | ignore_list = malloc(sizeof(Ecore_X_Window)); | ||
1336 | if (!ignore_list) return; | ||
1337 | ignore_list[ignore_num++] = win; | ||
1338 | } | ||
1339 | } | ||
1340 | else | ||
1341 | { | ||
1342 | if (!ignore_list) return; | ||
1343 | for (count = ignore_num, i = 0, j = 0; i < count; i++) | ||
1344 | { | ||
1345 | if (win != ignore_list[i]) | ||
1346 | ignore_list[j++] = ignore_list[i]; | ||
1347 | else | ||
1348 | ignore_num--; | ||
1349 | } | ||
1350 | if (ignore_num <= 0) | ||
1351 | { | ||
1352 | free(ignore_list); | ||
1353 | ignore_list = NULL; | ||
1354 | return; | ||
1355 | } | ||
1356 | |||
1357 | ignore_list = | ||
1358 | realloc(ignore_list, ignore_num * sizeof(Ecore_X_Window)); | ||
1359 | } | ||
1360 | } | ||
1361 | |||
1362 | /** | ||
1363 | * Get the ignore list | ||
1364 | * @param num number of windows in the list | ||
1365 | * @return list of windows to ignore | ||
1366 | */ | ||
1367 | EAPI Ecore_X_Window * | ||
1368 | ecore_x_window_ignore_list(int *num) | ||
1369 | { | ||
1370 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1371 | |||
1372 | if (num) *num = ignore_num; | ||
1373 | return ignore_list; | ||
1374 | } | ||
1375 | |||
1376 | /** | ||
1377 | * Get a list of all the root windows on the server. | ||
1378 | * | ||
1379 | * @note The returned array will need to be freed after use. | ||
1380 | * @param num_ret Pointer to integer to put number of windows returned in. | ||
1381 | * @return An array of all the root windows. @c NULL is returned if memory | ||
1382 | * could not be allocated for the list, or if @p num_ret is @c NULL. | ||
1383 | */ | ||
1384 | EAPI Ecore_X_Window * | ||
1385 | ecore_x_window_root_list(int *num_ret) | ||
1386 | { | ||
1387 | xcb_screen_iterator_t iter; | ||
1388 | uint8_t i, num; | ||
1389 | Ecore_X_Window *roots = NULL; | ||
1390 | #ifdef ECORE_XCB_XPRINT | ||
1391 | const xcb_query_extension_reply_t *ext_reply; | ||
1392 | #endif | ||
1393 | |||
1394 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1395 | CHECK_XCB_CONN; | ||
1396 | |||
1397 | if (!num_ret) return NULL; | ||
1398 | if (num_ret) *num_ret = 0; | ||
1399 | |||
1400 | /* if (xcb_connection_has_error(_ecore_xcb_conn)) */ | ||
1401 | /* { */ | ||
1402 | /* DBG("XCB Connection Has Error !!!"); */ | ||
1403 | /* return NULL; */ | ||
1404 | /* } */ | ||
1405 | |||
1406 | num = ecore_x_screen_count_get(); | ||
1407 | |||
1408 | #ifdef ECORE_XCB_XPRINT | ||
1409 | ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_x_print_id); | ||
1410 | if ((ext_reply) && (ext_reply->present)) | ||
1411 | { | ||
1412 | xcb_x_print_print_query_screens_cookie_t cookie; | ||
1413 | xcb_x_print_print_query_screens_reply_t *reply; | ||
1414 | |||
1415 | cookie = xcb_x_print_print_query_screens_unchecked(_ecore_xcb_conn); | ||
1416 | reply = | ||
1417 | xcb_x_print_print_query_screens_reply(_ecore_xcb_conn, cookie, NULL); | ||
1418 | if (reply) | ||
1419 | { | ||
1420 | xcb_window_t *screens; | ||
1421 | int psnum = 0, overlap = 0, j = 0, k = 0; | ||
1422 | |||
1423 | psnum = xcb_x_print_print_query_screens_roots_length(reply); | ||
1424 | screens = xcb_x_print_print_query_screens_roots(reply); | ||
1425 | for (i = 0; i < num; i++) | ||
1426 | { | ||
1427 | for (j = 0; j < psnum; j++) | ||
1428 | { | ||
1429 | xcb_screen_t *s; | ||
1430 | |||
1431 | if ((s = _ecore_xcb_window_screen_of_display(i))) | ||
1432 | { | ||
1433 | if (s->root == screens[j]) | ||
1434 | overlap++; | ||
1435 | } | ||
1436 | } | ||
1437 | } | ||
1438 | if (!(roots = malloc((num - overlap) | ||
1439 | * sizeof(Ecore_X_Window)))) return NULL; | ||
1440 | for (i = 0; i < num; i++) | ||
1441 | { | ||
1442 | Eina_Bool is_print = EINA_FALSE; | ||
1443 | |||
1444 | for (j = 0; j < psnum; j++) | ||
1445 | { | ||
1446 | xcb_screen_t *s; | ||
1447 | |||
1448 | if ((s = _ecore_xcb_window_screen_of_display(i))) | ||
1449 | { | ||
1450 | if (s->root == screens[j]) | ||
1451 | { | ||
1452 | is_print = EINA_TRUE; | ||
1453 | break; | ||
1454 | } | ||
1455 | } | ||
1456 | } | ||
1457 | if (!is_print) | ||
1458 | { | ||
1459 | xcb_screen_t *s; | ||
1460 | |||
1461 | if ((s = _ecore_xcb_window_screen_of_display(i))) | ||
1462 | { | ||
1463 | roots[k] = s->root; | ||
1464 | k++; | ||
1465 | } | ||
1466 | } | ||
1467 | } | ||
1468 | if (num_ret) *num_ret = k; | ||
1469 | free(reply); | ||
1470 | } | ||
1471 | else | ||
1472 | { | ||
1473 | /* Fallback to default method */ | ||
1474 | iter = | ||
1475 | xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)); | ||
1476 | if (!(roots = malloc(num * sizeof(Ecore_X_Window)))) return NULL; | ||
1477 | if (num_ret) *num_ret = num; | ||
1478 | for (i = 0; iter.rem; xcb_screen_next(&iter), i++) | ||
1479 | roots[i] = iter.data->root; | ||
1480 | } | ||
1481 | } | ||
1482 | else | ||
1483 | { | ||
1484 | /* Fallback to default method */ | ||
1485 | iter = | ||
1486 | xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)); | ||
1487 | if (!(roots = malloc(num * sizeof(Ecore_X_Window)))) return NULL; | ||
1488 | if (num_ret) *num_ret = num; | ||
1489 | for (i = 0; iter.rem; xcb_screen_next(&iter), i++) | ||
1490 | roots[i] = iter.data->root; | ||
1491 | } | ||
1492 | #else | ||
1493 | iter = | ||
1494 | xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)); | ||
1495 | if (!(roots = malloc(num * sizeof(Ecore_X_Window)))) return NULL; | ||
1496 | if (num_ret) *num_ret = num; | ||
1497 | for (i = 0; iter.rem; xcb_screen_next(&iter), i++) | ||
1498 | roots[i] = iter.data->root; | ||
1499 | #endif | ||
1500 | |||
1501 | return roots; | ||
1502 | } | ||
1503 | |||
1504 | EAPI Ecore_X_Window * | ||
1505 | ecore_x_window_children_get(Ecore_X_Window win, | ||
1506 | int *num) | ||
1507 | { | ||
1508 | xcb_query_tree_cookie_t cookie; | ||
1509 | xcb_query_tree_reply_t *reply; | ||
1510 | Ecore_X_Window *windows = NULL; | ||
1511 | |||
1512 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1513 | CHECK_XCB_CONN; | ||
1514 | |||
1515 | if (num) *num = 0; | ||
1516 | cookie = xcb_query_tree_unchecked(_ecore_xcb_conn, win); | ||
1517 | reply = xcb_query_tree_reply(_ecore_xcb_conn, cookie, NULL); | ||
1518 | if (!reply) return NULL; | ||
1519 | |||
1520 | if (num) *num = reply->children_len; | ||
1521 | if (reply->children_len > 0) | ||
1522 | { | ||
1523 | windows = malloc(sizeof(Ecore_X_Window) * reply->children_len); | ||
1524 | if (windows) | ||
1525 | { | ||
1526 | unsigned int i = 0; | ||
1527 | xcb_window_t *w; | ||
1528 | |||
1529 | w = xcb_query_tree_children(reply); | ||
1530 | for (i = 0; i < reply->children_len; i++) | ||
1531 | windows[i] = w[i]; | ||
1532 | } | ||
1533 | } | ||
1534 | |||
1535 | free(reply); | ||
1536 | return windows; | ||
1537 | } | ||
1538 | |||
1539 | /** | ||
1540 | * Retrieves the root window a given window is on. | ||
1541 | * @param win The window to get the root window of | ||
1542 | * @return The root window of @p win | ||
1543 | * @ingroup Ecore_X_Window_Geometry_Group | ||
1544 | */ | ||
1545 | EAPI Ecore_X_Window | ||
1546 | ecore_x_window_root_get(Ecore_X_Window win) | ||
1547 | { | ||
1548 | xcb_get_geometry_cookie_t gcookie; | ||
1549 | xcb_get_geometry_reply_t *greply; | ||
1550 | Ecore_X_Window window = 0; | ||
1551 | |||
1552 | /* LOGFN(__FILE__, __LINE__, __FUNCTION__); */ | ||
1553 | CHECK_XCB_CONN; | ||
1554 | |||
1555 | gcookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win); | ||
1556 | greply = xcb_get_geometry_reply(_ecore_xcb_conn, gcookie, NULL); | ||
1557 | if (!greply) return 0; | ||
1558 | window = greply->root; | ||
1559 | free(greply); | ||
1560 | |||
1561 | return window; | ||
1562 | } | ||
1563 | |||
1564 | EAPI Ecore_X_Window | ||
1565 | ecore_x_window_root_first_get(void) | ||
1566 | { | ||
1567 | return ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
1568 | } | ||
1569 | |||
1570 | /** | ||
1571 | * Retrieves the geometry of the given window. | ||
1572 | * | ||
1573 | * Note that the x & y coordingates are relative to your parent. In | ||
1574 | * particular for reparenting window managers - relative to you window border. | ||
1575 | * If you want screen coordinates either walk the window tree to the root, | ||
1576 | * else for ecore_evas applications see ecore_evas_geometry_get(). Elementary | ||
1577 | * applications can use elm_win_screen_position_get(). | ||
1578 | * | ||
1579 | * @param win The given window. | ||
1580 | * @param x Pointer to an integer in which the X position is to be stored. | ||
1581 | * @param y Pointer to an integer in which the Y position is to be stored. | ||
1582 | * @param w Pointer to an integer in which the width is to be stored. | ||
1583 | * @param h Pointer to an integer in which the height is to be stored. | ||
1584 | * @ingroup Ecore_X_Window_Geometry_Group | ||
1585 | */ | ||
1586 | EAPI void | ||
1587 | ecore_x_window_geometry_get(Ecore_X_Window win, | ||
1588 | int *x, | ||
1589 | int *y, | ||
1590 | int *w, | ||
1591 | int *h) | ||
1592 | { | ||
1593 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1594 | CHECK_XCB_CONN; | ||
1595 | |||
1596 | if (!win) win = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
1597 | ecore_x_drawable_geometry_get(win, x, y, w, h); | ||
1598 | } | ||
1599 | |||
1600 | /** | ||
1601 | * Retrieves the top, visible window at the given location. | ||
1602 | * @param x The given X position. | ||
1603 | * @param y The given Y position. | ||
1604 | * @return The window at that position. | ||
1605 | * @ingroup Ecore_X_Window_Geometry_Group | ||
1606 | */ | ||
1607 | EAPI Ecore_X_Window | ||
1608 | ecore_x_window_at_xy_get(int x, | ||
1609 | int y) | ||
1610 | { | ||
1611 | Ecore_X_Window root, win = 0; | ||
1612 | |||
1613 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1614 | CHECK_XCB_CONN; | ||
1615 | |||
1616 | root = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
1617 | |||
1618 | ecore_x_grab(); | ||
1619 | win = _ecore_xcb_window_at_xy_get(root, 0, 0, x, y, NULL, 0); | ||
1620 | ecore_x_ungrab(); | ||
1621 | |||
1622 | return win ? win : root; | ||
1623 | } | ||
1624 | |||
1625 | /** | ||
1626 | * Retrieves the top, visible window at the given location, | ||
1627 | * but skips the windows in the list. | ||
1628 | * @param x The given X position. | ||
1629 | * @param y The given Y position. | ||
1630 | * @return The window at that position. | ||
1631 | * @ingroup Ecore_X_Window_Geometry_Group | ||
1632 | */ | ||
1633 | EAPI Ecore_X_Window | ||
1634 | ecore_x_window_at_xy_with_skip_get(int x, | ||
1635 | int y, | ||
1636 | Ecore_X_Window *skip, | ||
1637 | int skip_num) | ||
1638 | { | ||
1639 | Ecore_X_Window root, win = 0; | ||
1640 | |||
1641 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1642 | CHECK_XCB_CONN; | ||
1643 | |||
1644 | root = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
1645 | |||
1646 | ecore_x_grab(); | ||
1647 | win = _ecore_xcb_window_at_xy_get(root, 0, 0, x, y, skip, skip_num); | ||
1648 | ecore_x_ungrab(); | ||
1649 | |||
1650 | return win ? win : root; | ||
1651 | } | ||
1652 | |||
1653 | EAPI Ecore_X_Window | ||
1654 | ecore_x_window_at_xy_begin_get(Ecore_X_Window begin, | ||
1655 | int x, | ||
1656 | int y) | ||
1657 | { | ||
1658 | Ecore_X_Window win = 0; | ||
1659 | |||
1660 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1661 | CHECK_XCB_CONN; | ||
1662 | |||
1663 | ecore_x_grab(); | ||
1664 | win = _ecore_xcb_window_at_xy_get(begin, 0, 0, x, y, NULL, 0); | ||
1665 | ecore_x_ungrab(); | ||
1666 | |||
1667 | return win ? win : begin; | ||
1668 | } | ||
1669 | |||
1670 | /** | ||
1671 | * Retrieves the parent window of the given window. | ||
1672 | * @param win The given window. | ||
1673 | * @return The parent window of @p win. | ||
1674 | * @ingroup Ecore_X_Window_Parent_Group | ||
1675 | */ | ||
1676 | EAPI Ecore_X_Window | ||
1677 | ecore_x_window_parent_get(Ecore_X_Window win) | ||
1678 | { | ||
1679 | xcb_query_tree_cookie_t cookie; | ||
1680 | xcb_query_tree_reply_t *reply; | ||
1681 | Ecore_X_Window window = 0; | ||
1682 | |||
1683 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1684 | CHECK_XCB_CONN; | ||
1685 | |||
1686 | // if (!win) return 0; | ||
1687 | cookie = xcb_query_tree(_ecore_xcb_conn, win); | ||
1688 | reply = xcb_query_tree_reply(_ecore_xcb_conn, cookie, NULL); | ||
1689 | if (!reply) return 0; | ||
1690 | window = reply->parent; | ||
1691 | free(reply); | ||
1692 | |||
1693 | return window; | ||
1694 | } | ||
1695 | |||
1696 | /** | ||
1697 | * Finds out whether the given window is currently visible. | ||
1698 | * @param win The given window. | ||
1699 | * @return 1 if the window is visible, otherwise 0. | ||
1700 | * @ingroup Ecore_X_Window_Visibility_Group | ||
1701 | */ | ||
1702 | EAPI int | ||
1703 | ecore_x_window_visible_get(Ecore_X_Window win) | ||
1704 | { | ||
1705 | xcb_get_window_attributes_cookie_t cookie; | ||
1706 | xcb_get_window_attributes_reply_t *reply; | ||
1707 | int ret = EINA_FALSE; | ||
1708 | |||
1709 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1710 | CHECK_XCB_CONN; | ||
1711 | |||
1712 | cookie = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, win); | ||
1713 | reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL); | ||
1714 | if (!reply) return EINA_FALSE; | ||
1715 | |||
1716 | if (reply->map_state == XCB_MAP_STATE_VIEWABLE) | ||
1717 | ret = EINA_TRUE; | ||
1718 | |||
1719 | free(reply); | ||
1720 | return ret; | ||
1721 | } | ||
1722 | |||
1723 | EAPI void | ||
1724 | ecore_x_window_button_grab(Ecore_X_Window win, | ||
1725 | int button, | ||
1726 | Ecore_X_Event_Mask mask, | ||
1727 | int mod, | ||
1728 | int any_mod) | ||
1729 | { | ||
1730 | int i = 0; | ||
1731 | uint16_t m, locks[8], ev; | ||
1732 | uint8_t b; | ||
1733 | Ecore_X_Window *t; | ||
1734 | |||
1735 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1736 | CHECK_XCB_CONN; | ||
1737 | |||
1738 | b = button; | ||
1739 | if (b == 0) | ||
1740 | b = XCB_BUTTON_INDEX_ANY; | ||
1741 | |||
1742 | m = _ecore_xcb_window_modifiers_get(mod); | ||
1743 | if (any_mod) m = XCB_MOD_MASK_ANY; | ||
1744 | |||
1745 | locks[0] = 0; | ||
1746 | locks[1] = ECORE_X_LOCK_CAPS; | ||
1747 | locks[2] = ECORE_X_LOCK_NUM; | ||
1748 | locks[3] = ECORE_X_LOCK_SCROLL; | ||
1749 | locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM; | ||
1750 | locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL; | ||
1751 | locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL; | ||
1752 | locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL; | ||
1753 | |||
1754 | ev = mask; | ||
1755 | for (i = 0; i < 8; i++) | ||
1756 | xcb_grab_button(_ecore_xcb_conn, 0, win, ev, | ||
1757 | XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC, | ||
1758 | XCB_NONE, XCB_NONE, b, m | locks[i]); | ||
1759 | |||
1760 | _ecore_xcb_button_grabs_num++; | ||
1761 | t = realloc(_ecore_xcb_button_grabs, | ||
1762 | _ecore_xcb_button_grabs_num * sizeof(Ecore_X_Window)); | ||
1763 | if (!t) return; | ||
1764 | |||
1765 | _ecore_xcb_button_grabs = t; | ||
1766 | _ecore_xcb_button_grabs[_ecore_xcb_button_grabs_num - 1] = win; | ||
1767 | } | ||
1768 | |||
1769 | EAPI void | ||
1770 | ecore_x_window_button_ungrab(Ecore_X_Window win, | ||
1771 | int button, | ||
1772 | int mod, | ||
1773 | int any_mod) | ||
1774 | { | ||
1775 | int i = 0; | ||
1776 | uint16_t m = 0, locks[8]; | ||
1777 | uint8_t b; | ||
1778 | |||
1779 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1780 | CHECK_XCB_CONN; | ||
1781 | |||
1782 | b = button; | ||
1783 | if (b == 0) b = XCB_BUTTON_INDEX_ANY; | ||
1784 | |||
1785 | m = _ecore_xcb_window_modifiers_get(mod); | ||
1786 | if (any_mod) m = XCB_MOD_MASK_ANY; | ||
1787 | |||
1788 | locks[0] = 0; | ||
1789 | locks[1] = ECORE_X_LOCK_CAPS; | ||
1790 | locks[2] = ECORE_X_LOCK_NUM; | ||
1791 | locks[3] = ECORE_X_LOCK_SCROLL; | ||
1792 | locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM; | ||
1793 | locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL; | ||
1794 | locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL; | ||
1795 | locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL; | ||
1796 | |||
1797 | for (i = 0; i < 8; i++) | ||
1798 | xcb_ungrab_button(_ecore_xcb_conn, b, win, m | locks[i]); | ||
1799 | |||
1800 | _ecore_xcb_sync_magic_send(1, win); | ||
1801 | } | ||
1802 | |||
1803 | EAPI void | ||
1804 | ecore_x_window_key_grab(Ecore_X_Window win, | ||
1805 | const char *key, | ||
1806 | int mod, | ||
1807 | int any_mod) | ||
1808 | { | ||
1809 | xcb_keycode_t keycode = XCB_NO_SYMBOL; | ||
1810 | uint16_t m = 0, locks[8]; | ||
1811 | int i = 0; | ||
1812 | Ecore_X_Window *t; | ||
1813 | |||
1814 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1815 | CHECK_XCB_CONN; | ||
1816 | |||
1817 | keycode = _ecore_xcb_keymap_string_to_keycode(key); | ||
1818 | if (keycode == XCB_NO_SYMBOL) return; | ||
1819 | |||
1820 | m = _ecore_xcb_window_modifiers_get(mod); | ||
1821 | if (any_mod) m = XCB_MOD_MASK_ANY; | ||
1822 | |||
1823 | locks[0] = 0; | ||
1824 | locks[1] = ECORE_X_LOCK_CAPS; | ||
1825 | locks[2] = ECORE_X_LOCK_NUM; | ||
1826 | locks[3] = ECORE_X_LOCK_SCROLL; | ||
1827 | locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM; | ||
1828 | locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL; | ||
1829 | locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL; | ||
1830 | locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL; | ||
1831 | |||
1832 | for (i = 0; i < 8; i++) | ||
1833 | xcb_grab_key(_ecore_xcb_conn, 0, win, m | locks[i], | ||
1834 | keycode, XCB_GRAB_MODE_SYNC, XCB_GRAB_MODE_ASYNC); | ||
1835 | _ecore_xcb_key_grabs_num++; | ||
1836 | t = realloc(_ecore_xcb_key_grabs, | ||
1837 | _ecore_xcb_key_grabs_num * sizeof(Ecore_X_Window)); | ||
1838 | if (!t) return; | ||
1839 | _ecore_xcb_key_grabs = t; | ||
1840 | _ecore_xcb_key_grabs[_ecore_xcb_key_grabs_num - 1] = win; | ||
1841 | } | ||
1842 | |||
1843 | EAPI void | ||
1844 | ecore_x_window_key_ungrab(Ecore_X_Window win, | ||
1845 | const char *key, | ||
1846 | int mod, | ||
1847 | int any_mod) | ||
1848 | { | ||
1849 | xcb_keycode_t keycode = XCB_NO_SYMBOL; | ||
1850 | uint16_t m = 0, locks[8]; | ||
1851 | int i = 0; | ||
1852 | |||
1853 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1854 | CHECK_XCB_CONN; | ||
1855 | |||
1856 | keycode = _ecore_xcb_keymap_string_to_keycode(key); | ||
1857 | if (keycode == XCB_NO_SYMBOL) return; | ||
1858 | |||
1859 | m = _ecore_xcb_window_modifiers_get(mod); | ||
1860 | if (any_mod) m = XCB_MOD_MASK_ANY; | ||
1861 | |||
1862 | locks[0] = 0; | ||
1863 | locks[1] = ECORE_X_LOCK_CAPS; | ||
1864 | locks[2] = ECORE_X_LOCK_NUM; | ||
1865 | locks[3] = ECORE_X_LOCK_SCROLL; | ||
1866 | locks[4] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM; | ||
1867 | locks[5] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_SCROLL; | ||
1868 | locks[6] = ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL; | ||
1869 | locks[7] = ECORE_X_LOCK_CAPS | ECORE_X_LOCK_NUM | ECORE_X_LOCK_SCROLL; | ||
1870 | |||
1871 | for (i = 0; i < 8; i++) | ||
1872 | xcb_ungrab_key(_ecore_xcb_conn, keycode, win, m | locks[i]); | ||
1873 | |||
1874 | _ecore_xcb_sync_magic_send(2, win); | ||
1875 | } | ||
1876 | |||
1877 | /* local functions */ | ||
1878 | Ecore_X_Window | ||
1879 | _ecore_xcb_window_root_of_screen_get(int screen) | ||
1880 | { | ||
1881 | xcb_screen_iterator_t iter; | ||
1882 | |||
1883 | CHECK_XCB_CONN; | ||
1884 | iter = xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)); | ||
1885 | for (; iter.rem; --screen, xcb_screen_next(&iter)) | ||
1886 | if (screen == 0) | ||
1887 | { | ||
1888 | xcb_screen_t *s; | ||
1889 | |||
1890 | if ((s = iter.data)) | ||
1891 | return s->root; | ||
1892 | } | ||
1893 | return 0; | ||
1894 | } | ||
1895 | |||
1896 | static Ecore_X_Window | ||
1897 | _ecore_xcb_window_argb_internal_new(Ecore_X_Window parent, | ||
1898 | int x, | ||
1899 | int y, | ||
1900 | int w, | ||
1901 | int h, | ||
1902 | uint8_t override_redirect, | ||
1903 | uint8_t save_under) | ||
1904 | { | ||
1905 | Ecore_X_Window win = 0; | ||
1906 | #ifdef ECORE_XCB_RENDER | ||
1907 | uint32_t value_list[10]; | ||
1908 | uint32_t value_mask; | ||
1909 | uint32_t vis; | ||
1910 | Ecore_X_Colormap colormap; | ||
1911 | #endif | ||
1912 | |||
1913 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1914 | CHECK_XCB_CONN; | ||
1915 | |||
1916 | #ifdef ECORE_XCB_RENDER | ||
1917 | if (parent == 0) | ||
1918 | parent = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
1919 | |||
1920 | vis = | ||
1921 | _ecore_xcb_render_find_visual_id(XCB_RENDER_PICT_TYPE_DIRECT, EINA_TRUE); | ||
1922 | |||
1923 | colormap = xcb_generate_id(_ecore_xcb_conn); | ||
1924 | xcb_create_colormap(_ecore_xcb_conn, XCB_COLORMAP_ALLOC_NONE, | ||
1925 | colormap, parent, vis); | ||
1926 | |||
1927 | value_mask = (XCB_CW_BACK_PIXMAP | XCB_CW_BORDER_PIXEL | XCB_CW_BIT_GRAVITY | | ||
1928 | XCB_CW_WIN_GRAVITY | XCB_CW_BACKING_STORE | | ||
1929 | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_SAVE_UNDER | | ||
1930 | XCB_CW_EVENT_MASK | XCB_CW_DONT_PROPAGATE | XCB_CW_COLORMAP); | ||
1931 | |||
1932 | value_list[0] = XCB_BACK_PIXMAP_NONE; | ||
1933 | value_list[1] = 0; | ||
1934 | value_list[2] = XCB_GRAVITY_NORTH_WEST; | ||
1935 | value_list[3] = XCB_GRAVITY_NORTH_WEST; | ||
1936 | value_list[4] = XCB_BACKING_STORE_NOT_USEFUL; | ||
1937 | value_list[5] = override_redirect; | ||
1938 | value_list[6] = save_under; | ||
1939 | value_list[7] = (XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_KEY_RELEASE | | ||
1940 | XCB_EVENT_MASK_BUTTON_PRESS | | ||
1941 | XCB_EVENT_MASK_BUTTON_RELEASE | | ||
1942 | XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_LEAVE_WINDOW | | ||
1943 | XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_EXPOSURE | | ||
1944 | XCB_EVENT_MASK_VISIBILITY_CHANGE | | ||
1945 | XCB_EVENT_MASK_STRUCTURE_NOTIFY | | ||
1946 | XCB_EVENT_MASK_FOCUS_CHANGE | | ||
1947 | XCB_EVENT_MASK_PROPERTY_CHANGE | | ||
1948 | XCB_EVENT_MASK_COLOR_MAP_CHANGE); | ||
1949 | value_list[8] = XCB_EVENT_MASK_NO_EVENT; | ||
1950 | value_list[9] = colormap; | ||
1951 | |||
1952 | win = xcb_generate_id(_ecore_xcb_conn); | ||
1953 | xcb_create_window(_ecore_xcb_conn, 32, win, parent, x, y, w, h, 0, | ||
1954 | XCB_WINDOW_CLASS_INPUT_OUTPUT, vis, value_mask, | ||
1955 | value_list); | ||
1956 | |||
1957 | xcb_free_colormap(_ecore_xcb_conn, colormap); | ||
1958 | |||
1959 | if (parent == ((xcb_screen_t *)_ecore_xcb_screen)->root) | ||
1960 | ecore_x_window_defaults_set(win); | ||
1961 | #endif | ||
1962 | |||
1963 | return win; | ||
1964 | } | ||
1965 | |||
1966 | static Ecore_X_Window | ||
1967 | _ecore_xcb_window_at_xy_get(Ecore_X_Window base, | ||
1968 | int bx, | ||
1969 | int by, | ||
1970 | int x, | ||
1971 | int y, | ||
1972 | Ecore_X_Window *skip, | ||
1973 | int skip_num) | ||
1974 | { | ||
1975 | xcb_query_tree_cookie_t cookie; | ||
1976 | xcb_query_tree_reply_t *reply; | ||
1977 | Ecore_X_Window *windows = NULL; | ||
1978 | int wx, wy, ww, wh, num, i = 0; | ||
1979 | Eina_Bool skipit = EINA_FALSE; | ||
1980 | |||
1981 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
1982 | CHECK_XCB_CONN; | ||
1983 | |||
1984 | if (!ecore_x_window_visible_get(base)) return 0; | ||
1985 | |||
1986 | ecore_x_window_geometry_get(base, &wx, &wy, &ww, &wh); | ||
1987 | wx += bx; | ||
1988 | wy += by; | ||
1989 | |||
1990 | if (!((x >= wx) && (y >= wy) && (x < (wx + ww)) && (y < (wy + wh)))) | ||
1991 | return 0; | ||
1992 | |||
1993 | cookie = xcb_query_tree_unchecked(_ecore_xcb_conn, base); | ||
1994 | reply = xcb_query_tree_reply(_ecore_xcb_conn, cookie, NULL); | ||
1995 | if (!reply) return 0; | ||
1996 | |||
1997 | num = reply->children_len; | ||
1998 | windows = xcb_query_tree_children(reply); | ||
1999 | |||
2000 | for (i = (num - 1); i >= 0; --i) | ||
2001 | { | ||
2002 | skipit = EINA_FALSE; | ||
2003 | |||
2004 | if (skip) | ||
2005 | { | ||
2006 | int j = 0; | ||
2007 | |||
2008 | for (j = 0; j < skip_num; j++) | ||
2009 | { | ||
2010 | if (windows[i] == skip[j]) | ||
2011 | { | ||
2012 | skipit = EINA_TRUE; | ||
2013 | goto onward; | ||
2014 | } | ||
2015 | } | ||
2016 | } | ||
2017 | onward: | ||
2018 | if (!skipit) | ||
2019 | { | ||
2020 | Ecore_X_Window child = 0; | ||
2021 | |||
2022 | child = | ||
2023 | _ecore_xcb_window_at_xy_get(windows[i], | ||
2024 | wx, wy, x, y, skip, skip_num); | ||
2025 | if (child) | ||
2026 | { | ||
2027 | if (reply) free(reply); | ||
2028 | return child; | ||
2029 | } | ||
2030 | } | ||
2031 | } | ||
2032 | |||
2033 | if (reply) free(reply); | ||
2034 | return base; | ||
2035 | } | ||
2036 | |||
2037 | Ecore_X_Visual | ||
2038 | _ecore_xcb_window_visual_get(Ecore_X_Window win) | ||
2039 | { | ||
2040 | xcb_get_window_attributes_cookie_t cookie; | ||
2041 | xcb_get_window_attributes_reply_t *reply; | ||
2042 | Ecore_X_Visual visual = 0; | ||
2043 | |||
2044 | CHECK_XCB_CONN; | ||
2045 | |||
2046 | cookie = xcb_get_window_attributes(_ecore_xcb_conn, win); | ||
2047 | reply = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie, NULL); | ||
2048 | if (!reply) return 0; | ||
2049 | visual = _ecore_xcb_window_find_visual_by_id(reply->visual); | ||
2050 | free(reply); | ||
2051 | |||
2052 | return visual; | ||
2053 | } | ||
2054 | |||
2055 | void | ||
2056 | _ecore_xcb_window_button_grab_remove(Ecore_X_Window win) | ||
2057 | { | ||
2058 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2059 | CHECK_XCB_CONN; | ||
2060 | |||
2061 | if (_ecore_xcb_button_grabs_num > 0) | ||
2062 | { | ||
2063 | int i = 0, shuffle = 0; | ||
2064 | |||
2065 | for (i = 0; i < _ecore_xcb_button_grabs_num; i++) | ||
2066 | { | ||
2067 | if (shuffle) | ||
2068 | _ecore_xcb_button_grabs[i - 1] = _ecore_xcb_button_grabs[i]; | ||
2069 | |||
2070 | if ((!shuffle) && (_ecore_xcb_button_grabs[i] == win)) | ||
2071 | shuffle = 1; | ||
2072 | } | ||
2073 | |||
2074 | if (shuffle) | ||
2075 | { | ||
2076 | Ecore_X_Window *t; | ||
2077 | |||
2078 | _ecore_xcb_button_grabs_num--; | ||
2079 | if (_ecore_xcb_button_grabs_num <= 0) | ||
2080 | { | ||
2081 | free(_ecore_xcb_button_grabs); | ||
2082 | _ecore_xcb_button_grabs = NULL; | ||
2083 | return; | ||
2084 | } | ||
2085 | |||
2086 | t = realloc(_ecore_xcb_button_grabs, | ||
2087 | _ecore_xcb_button_grabs_num * sizeof(Ecore_X_Window)); | ||
2088 | if (!t) return; | ||
2089 | _ecore_xcb_button_grabs = t; | ||
2090 | } | ||
2091 | } | ||
2092 | } | ||
2093 | |||
2094 | void | ||
2095 | _ecore_xcb_window_key_grab_remove(Ecore_X_Window win) | ||
2096 | { | ||
2097 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2098 | CHECK_XCB_CONN; | ||
2099 | |||
2100 | if (_ecore_xcb_key_grabs_num > 0) | ||
2101 | { | ||
2102 | int i = 0, shuffle = 0; | ||
2103 | |||
2104 | for (i = 0; i < _ecore_xcb_key_grabs_num; i++) | ||
2105 | { | ||
2106 | if (shuffle) | ||
2107 | _ecore_xcb_key_grabs[i - 1] = _ecore_xcb_key_grabs[i]; | ||
2108 | |||
2109 | if ((!shuffle) && (_ecore_xcb_key_grabs[i] == win)) | ||
2110 | shuffle = 1; | ||
2111 | } | ||
2112 | |||
2113 | if (shuffle) | ||
2114 | { | ||
2115 | Ecore_X_Window *t; | ||
2116 | |||
2117 | _ecore_xcb_key_grabs_num--; | ||
2118 | if (_ecore_xcb_key_grabs_num <= 0) | ||
2119 | { | ||
2120 | free(_ecore_xcb_key_grabs); | ||
2121 | _ecore_xcb_key_grabs = NULL; | ||
2122 | return; | ||
2123 | } | ||
2124 | |||
2125 | t = realloc(_ecore_xcb_key_grabs, | ||
2126 | _ecore_xcb_key_grabs_num * sizeof(Ecore_X_Window)); | ||
2127 | if (!t) return; | ||
2128 | _ecore_xcb_key_grabs = t; | ||
2129 | } | ||
2130 | } | ||
2131 | } | ||
2132 | |||
2133 | void | ||
2134 | _ecore_xcb_window_grab_allow_events(Ecore_X_Window event_win, | ||
2135 | Ecore_X_Window child_win, | ||
2136 | int type, | ||
2137 | void *event, | ||
2138 | Ecore_X_Time timestamp) | ||
2139 | { | ||
2140 | int i = 0; | ||
2141 | |||
2142 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
2143 | CHECK_XCB_CONN; | ||
2144 | |||
2145 | for (i = 0; i < _ecore_xcb_button_grabs_num; i++) | ||
2146 | { | ||
2147 | if ((_ecore_xcb_button_grabs[i] == event_win) || | ||
2148 | (_ecore_xcb_button_grabs[i] == child_win)) | ||
2149 | { | ||
2150 | Eina_Bool replay = EINA_FALSE; | ||
2151 | |||
2152 | if (_ecore_xcb_window_grab_replay_func) | ||
2153 | { | ||
2154 | replay = | ||
2155 | _ecore_xcb_window_grab_replay_func(_ecore_xcb_window_grab_replay_data, | ||
2156 | type, event); | ||
2157 | } | ||
2158 | if (replay) | ||
2159 | { | ||
2160 | xcb_allow_events(_ecore_xcb_conn, | ||
2161 | XCB_ALLOW_REPLAY_POINTER, timestamp); | ||
2162 | } | ||
2163 | else | ||
2164 | { | ||
2165 | xcb_allow_events(_ecore_xcb_conn, | ||
2166 | XCB_ALLOW_ASYNC_POINTER, timestamp); | ||
2167 | } | ||
2168 | break; | ||
2169 | } | ||
2170 | } | ||
2171 | } | ||
2172 | |||
2173 | static int | ||
2174 | _ecore_xcb_window_modifiers_get(unsigned int state) | ||
2175 | { | ||
2176 | int xmodifiers = 0; | ||
2177 | |||
2178 | if (state & ECORE_EVENT_MODIFIER_SHIFT) | ||
2179 | xmodifiers |= ECORE_X_MODIFIER_SHIFT; | ||
2180 | if (state & ECORE_EVENT_MODIFIER_CTRL) | ||
2181 | xmodifiers |= ECORE_X_MODIFIER_CTRL; | ||
2182 | if (state & ECORE_EVENT_MODIFIER_ALT) | ||
2183 | xmodifiers |= ECORE_X_MODIFIER_ALT; | ||
2184 | if (state & ECORE_EVENT_MODIFIER_WIN) | ||
2185 | xmodifiers |= ECORE_X_MODIFIER_WIN; | ||
2186 | if (state & ECORE_EVENT_LOCK_SCROLL) | ||
2187 | xmodifiers |= ECORE_X_LOCK_SCROLL; | ||
2188 | if (state & ECORE_EVENT_LOCK_NUM) | ||
2189 | xmodifiers |= ECORE_X_LOCK_NUM; | ||
2190 | if (state & ECORE_EVENT_LOCK_CAPS) | ||
2191 | xmodifiers |= ECORE_X_LOCK_CAPS; | ||
2192 | if (state & ECORE_EVENT_LOCK_SHIFT) | ||
2193 | xmodifiers |= ECORE_X_LOCK_SHIFT; | ||
2194 | |||
2195 | return xmodifiers; | ||
2196 | } | ||
2197 | |||
2198 | static xcb_visualtype_t * | ||
2199 | _ecore_xcb_window_find_visual_by_id(xcb_visualid_t id) | ||
2200 | { | ||
2201 | xcb_depth_iterator_t diter; | ||
2202 | xcb_visualtype_iterator_t viter; | ||
2203 | |||
2204 | CHECK_XCB_CONN; | ||
2205 | diter = xcb_screen_allowed_depths_iterator(_ecore_xcb_screen); | ||
2206 | for (; diter.rem; xcb_depth_next(&diter)) | ||
2207 | { | ||
2208 | viter = xcb_depth_visuals_iterator(diter.data); | ||
2209 | for (; viter.rem; xcb_visualtype_next(&viter)) | ||
2210 | { | ||
2211 | if (viter.data->visual_id == id) | ||
2212 | return viter.data; | ||
2213 | } | ||
2214 | } | ||
2215 | return 0; | ||
2216 | } | ||
2217 | |||
2218 | #ifdef ECORE_XCB_XPRINT | ||
2219 | static xcb_screen_t * | ||
2220 | _ecore_xcb_window_screen_of_display(int screen) | ||
2221 | { | ||
2222 | xcb_screen_iterator_t iter; | ||
2223 | |||
2224 | CHECK_XCB_CONN; | ||
2225 | iter = xcb_setup_roots_iterator(xcb_get_setup(_ecore_xcb_conn)); | ||
2226 | for (; iter.rem; --screen, xcb_screen_next(&iter)) | ||
2227 | if (screen == 0) | ||
2228 | return iter.data; | ||
2229 | |||
2230 | return NULL; | ||
2231 | } | ||
2232 | |||
2233 | #endif | ||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_window_prop.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_window_prop.c new file mode 100644 index 0000000..e00fdc1 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_window_prop.c | |||
@@ -0,0 +1,720 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #include <xcb/xcb_icccm.h> | ||
3 | |||
4 | EAPI int | ||
5 | ecore_x_window_prop_card32_get(Ecore_X_Window win, | ||
6 | Ecore_X_Atom atom, | ||
7 | unsigned int *val, | ||
8 | unsigned int len) | ||
9 | { | ||
10 | xcb_get_property_cookie_t cookie; | ||
11 | xcb_get_property_reply_t *reply; | ||
12 | int num = 0; | ||
13 | |||
14 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
15 | CHECK_XCB_CONN; | ||
16 | |||
17 | cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, win, atom, | ||
18 | ECORE_X_ATOM_CARDINAL, 0, 0x7fffffff); | ||
19 | reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL); | ||
20 | if (!reply) return -1; | ||
21 | |||
22 | if ((reply->type != ECORE_X_ATOM_CARDINAL) || (reply->format != 32)) | ||
23 | num = -1; | ||
24 | else if (reply->value_len == 0) | ||
25 | num = 0; | ||
26 | else | ||
27 | { | ||
28 | if (reply->value_len < len) | ||
29 | len = reply->value_len; | ||
30 | |||
31 | if (val) | ||
32 | { | ||
33 | unsigned int i = 0; | ||
34 | unsigned char *v; | ||
35 | |||
36 | v = xcb_get_property_value(reply); | ||
37 | for (i = 0; i < len; i++) | ||
38 | val[i] = ((uint32_t *)v)[i]; | ||
39 | num = len; | ||
40 | } | ||
41 | } | ||
42 | |||
43 | if (reply) free(reply); | ||
44 | return num; | ||
45 | } | ||
46 | |||
47 | EAPI void | ||
48 | ecore_x_window_prop_card32_set(Ecore_X_Window win, | ||
49 | Ecore_X_Atom atom, | ||
50 | unsigned int *val, | ||
51 | unsigned int num) | ||
52 | { | ||
53 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
54 | CHECK_XCB_CONN; | ||
55 | |||
56 | #if SIZEOF_INT == SIZEOF_LONG | ||
57 | xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, win, atom, | ||
58 | ECORE_X_ATOM_CARDINAL, 32, num, (unsigned char *)val); | ||
59 | // ecore_x_flush(); | ||
60 | #else | ||
61 | long *v2; | ||
62 | unsigned int i; | ||
63 | |||
64 | v2 = malloc(num * sizeof(long)); | ||
65 | if (!v2) return; | ||
66 | for (i = 0; i < num; i++) | ||
67 | v2[i] = val[i]; | ||
68 | |||
69 | xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, win, atom, | ||
70 | ECORE_X_ATOM_CARDINAL, 32, num, (unsigned char *)v2); | ||
71 | free(v2); | ||
72 | // ecore_x_flush(); | ||
73 | #endif | ||
74 | } | ||
75 | |||
76 | EAPI int | ||
77 | ecore_x_window_prop_card32_list_get(Ecore_X_Window win, | ||
78 | Ecore_X_Atom atom, | ||
79 | unsigned int **list) | ||
80 | { | ||
81 | xcb_get_property_cookie_t cookie; | ||
82 | xcb_get_property_reply_t *reply; | ||
83 | int num = -1; | ||
84 | |||
85 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
86 | CHECK_XCB_CONN; | ||
87 | |||
88 | if (list) *list = NULL; | ||
89 | |||
90 | cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, win, atom, | ||
91 | XCB_ATOM_CARDINAL, 0, 0x7fffffff); | ||
92 | reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL); | ||
93 | if (!reply) return -1; | ||
94 | |||
95 | if ((reply->type != XCB_ATOM_CARDINAL) || (reply->format != 32)) | ||
96 | num = -1; | ||
97 | else if ((reply->value_len == 0) || (!xcb_get_property_value(reply))) | ||
98 | num = 0; | ||
99 | else | ||
100 | { | ||
101 | num = reply->value_len; | ||
102 | if (list) | ||
103 | { | ||
104 | unsigned int *val; | ||
105 | void *data; | ||
106 | int i = 0; | ||
107 | |||
108 | val = malloc(num * sizeof(unsigned int)); | ||
109 | if (!val) | ||
110 | { | ||
111 | free(reply); | ||
112 | return -1; | ||
113 | } | ||
114 | data = xcb_get_property_value(reply); | ||
115 | for (i = 0; i < num; i++) | ||
116 | val[i] = ((uint32_t *)data)[i]; | ||
117 | *list = val; | ||
118 | } | ||
119 | } | ||
120 | |||
121 | free(reply); | ||
122 | return num; | ||
123 | } | ||
124 | |||
125 | EAPI int | ||
126 | ecore_x_window_prop_atom_get(Ecore_X_Window win, | ||
127 | Ecore_X_Atom atom, | ||
128 | Ecore_X_Atom *list, | ||
129 | unsigned int len) | ||
130 | { | ||
131 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
132 | |||
133 | return ecore_x_window_prop_xid_get(win, atom, ECORE_X_ATOM_ATOM, list, len); | ||
134 | } | ||
135 | |||
136 | EAPI void | ||
137 | ecore_x_window_prop_atom_set(Ecore_X_Window win, | ||
138 | Ecore_X_Atom atom, | ||
139 | Ecore_X_Atom *list, | ||
140 | unsigned int num) | ||
141 | { | ||
142 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
143 | |||
144 | /* xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, win, atom, */ | ||
145 | /* ECORE_X_ATOM_ATOM, 32, num, list); */ | ||
146 | ecore_x_window_prop_xid_set(win, atom, ECORE_X_ATOM_ATOM, list, num); | ||
147 | } | ||
148 | |||
149 | EAPI void | ||
150 | ecore_x_window_prop_xid_set(Ecore_X_Window win, | ||
151 | Ecore_X_Atom atom, | ||
152 | Ecore_X_Atom type, | ||
153 | Ecore_X_ID *xids, | ||
154 | unsigned int num) | ||
155 | { | ||
156 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
157 | CHECK_XCB_CONN; | ||
158 | |||
159 | #if SIZEOF_INT == SIZEOF_LONG | ||
160 | xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, win, atom, | ||
161 | type, 32, num, (unsigned char *)xids); | ||
162 | // ecore_x_flush(); | ||
163 | #else | ||
164 | long *v2; | ||
165 | unsigned int i; | ||
166 | |||
167 | v2 = malloc(num * sizeof(long)); | ||
168 | if (!v2) return; | ||
169 | for (i = 0; i < num; i++) | ||
170 | v2[i] = xids[i]; | ||
171 | |||
172 | xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, win, atom, | ||
173 | type, 32, num, (unsigned char *)v2); | ||
174 | free(v2); | ||
175 | // ecore_x_flush(); | ||
176 | #endif | ||
177 | } | ||
178 | |||
179 | EAPI int | ||
180 | ecore_x_window_prop_xid_get(Ecore_X_Window win, | ||
181 | Ecore_X_Atom atom, | ||
182 | Ecore_X_Atom type, | ||
183 | Ecore_X_ID *xids, | ||
184 | unsigned int len) | ||
185 | { | ||
186 | xcb_get_property_cookie_t cookie; | ||
187 | xcb_get_property_reply_t *reply; | ||
188 | int num = 0; | ||
189 | |||
190 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
191 | CHECK_XCB_CONN; | ||
192 | |||
193 | num = len; | ||
194 | cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, win, atom, type, | ||
195 | 0, 0x7fffffff); | ||
196 | reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL); | ||
197 | if (!reply) return -1; | ||
198 | |||
199 | if ((reply->type != type) || (reply->format != 32)) | ||
200 | num = -1; | ||
201 | else if (reply->value_len == 0) | ||
202 | num = 0; | ||
203 | else | ||
204 | { | ||
205 | unsigned int i = 0; | ||
206 | unsigned char *v; | ||
207 | |||
208 | if (reply->value_len < len) | ||
209 | len = reply->value_len; | ||
210 | |||
211 | v = xcb_get_property_value(reply); | ||
212 | for (i = 0; i < len; i++) | ||
213 | xids[i] = ((uint32_t *)v)[i]; | ||
214 | |||
215 | num = len; | ||
216 | } | ||
217 | |||
218 | if (reply) free(reply); | ||
219 | return num; | ||
220 | } | ||
221 | |||
222 | EAPI void | ||
223 | ecore_x_window_prop_string_set(Ecore_X_Window win, | ||
224 | Ecore_X_Atom type, | ||
225 | const char *str) | ||
226 | { | ||
227 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
228 | CHECK_XCB_CONN; | ||
229 | |||
230 | xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, win, type, | ||
231 | ECORE_X_ATOM_UTF8_STRING, 8, strlen(str), str); | ||
232 | // ecore_x_flush(); | ||
233 | } | ||
234 | |||
235 | EAPI char * | ||
236 | ecore_x_window_prop_string_get(Ecore_X_Window win, | ||
237 | Ecore_X_Atom type) | ||
238 | { | ||
239 | xcb_get_property_cookie_t cookie; | ||
240 | xcb_get_property_reply_t *reply; | ||
241 | char *str = NULL; | ||
242 | int len = 0; | ||
243 | |||
244 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
245 | CHECK_XCB_CONN; | ||
246 | |||
247 | cookie = | ||
248 | xcb_get_property_unchecked(_ecore_xcb_conn, 0, | ||
249 | win ? win : ((xcb_screen_t *)_ecore_xcb_screen)->root, | ||
250 | type, XCB_GET_PROPERTY_TYPE_ANY, 0, 1000000L); | ||
251 | reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL); | ||
252 | if (!reply) return NULL; | ||
253 | |||
254 | len = ((reply->value_len * reply->format) / 8); | ||
255 | str = (char *)malloc((len + 1) * sizeof(char)); | ||
256 | memcpy(str, xcb_get_property_value(reply), len); | ||
257 | str[len] = '\0'; | ||
258 | |||
259 | if (reply->type != ECORE_X_ATOM_UTF8_STRING) | ||
260 | { | ||
261 | Ecore_Xcb_Textproperty prop; | ||
262 | int count = 0; | ||
263 | char **list = NULL; | ||
264 | Eina_Bool ret = EINA_FALSE; | ||
265 | |||
266 | prop.value = strdup(str); | ||
267 | prop.nitems = len; | ||
268 | prop.encoding = reply->type; | ||
269 | |||
270 | #ifdef HAVE_ICONV | ||
271 | ret = _ecore_xcb_utf8_textproperty_to_textlist(&prop, &list, &count); | ||
272 | #else | ||
273 | ret = _ecore_xcb_mb_textproperty_to_textlist(&prop, &list, &count); | ||
274 | #endif | ||
275 | if (ret) | ||
276 | { | ||
277 | if (count > 0) | ||
278 | str = strdup(list[0]); | ||
279 | else | ||
280 | str = strdup((char *)prop.value); | ||
281 | |||
282 | if (list) free(list); | ||
283 | } | ||
284 | else | ||
285 | str = strdup((char *)prop.value); | ||
286 | } | ||
287 | |||
288 | free(reply); | ||
289 | return str; | ||
290 | } | ||
291 | |||
292 | EAPI int | ||
293 | ecore_x_window_prop_window_get(Ecore_X_Window win, | ||
294 | Ecore_X_Atom atom, | ||
295 | Ecore_X_Window *list, | ||
296 | unsigned int len) | ||
297 | { | ||
298 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
299 | |||
300 | return ecore_x_window_prop_xid_get(win, atom, ECORE_X_ATOM_WINDOW, list, len); | ||
301 | } | ||
302 | |||
303 | EAPI void | ||
304 | ecore_x_window_prop_window_set(Ecore_X_Window win, | ||
305 | Ecore_X_Atom atom, | ||
306 | Ecore_X_Window *list, | ||
307 | unsigned int num) | ||
308 | { | ||
309 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
310 | |||
311 | ecore_x_window_prop_xid_set(win, atom, ECORE_X_ATOM_WINDOW, list, num); | ||
312 | } | ||
313 | |||
314 | EAPI int | ||
315 | ecore_x_window_prop_window_list_get(Ecore_X_Window win, | ||
316 | Ecore_X_Atom atom, | ||
317 | Ecore_X_Window **plst) | ||
318 | { | ||
319 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
320 | |||
321 | return ecore_x_window_prop_xid_list_get(win, atom, ECORE_X_ATOM_WINDOW, plst); | ||
322 | } | ||
323 | |||
324 | EAPI Ecore_X_Atom | ||
325 | ecore_x_window_prop_any_type(void) | ||
326 | { | ||
327 | return XCB_ATOM_ANY; | ||
328 | } | ||
329 | |||
330 | EAPI void | ||
331 | ecore_x_window_prop_property_del(Ecore_X_Window win, | ||
332 | Ecore_X_Atom property) | ||
333 | { | ||
334 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
335 | CHECK_XCB_CONN; | ||
336 | |||
337 | xcb_delete_property(_ecore_xcb_conn, win, property); | ||
338 | } | ||
339 | |||
340 | EAPI void | ||
341 | ecore_x_window_prop_property_set(Ecore_X_Window win, | ||
342 | Ecore_X_Atom property, | ||
343 | Ecore_X_Atom type, | ||
344 | int size, | ||
345 | void *data, | ||
346 | int num) | ||
347 | { | ||
348 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
349 | CHECK_XCB_CONN; | ||
350 | |||
351 | if (win == 0) | ||
352 | win = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
353 | |||
354 | if (size != 32) | ||
355 | { | ||
356 | xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, win, | ||
357 | property, type, size, num, (unsigned char *)data); | ||
358 | // ecore_x_flush(); | ||
359 | } | ||
360 | else | ||
361 | { | ||
362 | uint32_t *dat; | ||
363 | int i = 0, *ptr; | ||
364 | |||
365 | dat = malloc(sizeof(uint32_t) * num); | ||
366 | if (dat) | ||
367 | { | ||
368 | for (ptr = (int *)data, i = 0; i < num; i++) | ||
369 | dat[i] = ptr[i]; | ||
370 | xcb_change_property(_ecore_xcb_conn, XCB_PROP_MODE_REPLACE, win, | ||
371 | property, type, size, num, | ||
372 | (unsigned char *)dat); | ||
373 | free(dat); | ||
374 | // ecore_x_flush(); | ||
375 | } | ||
376 | } | ||
377 | } | ||
378 | |||
379 | EAPI int | ||
380 | ecore_x_window_prop_property_get(Ecore_X_Window win, | ||
381 | Ecore_X_Atom property, | ||
382 | Ecore_X_Atom type, | ||
383 | int size, | ||
384 | unsigned char **data, | ||
385 | int *num) | ||
386 | { | ||
387 | xcb_get_property_cookie_t cookie; | ||
388 | xcb_get_property_reply_t *reply; | ||
389 | int format = 0; | ||
390 | unsigned int i = 0; | ||
391 | void *value; | ||
392 | |||
393 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
394 | CHECK_XCB_CONN; | ||
395 | |||
396 | if (num) *num = 0; | ||
397 | |||
398 | if (data) | ||
399 | *data = NULL; | ||
400 | else | ||
401 | return 0; | ||
402 | |||
403 | if (win == 0) | ||
404 | win = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
405 | |||
406 | cookie = | ||
407 | xcb_get_property_unchecked(_ecore_xcb_conn, 0, win, | ||
408 | property, type, 0, UINT_MAX); | ||
409 | reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL); | ||
410 | if (!reply) return 0; | ||
411 | if ((reply->format != size) || (reply->value_len == 0)) | ||
412 | { | ||
413 | free(reply); | ||
414 | return 0; | ||
415 | } | ||
416 | |||
417 | if (!(*data = malloc(reply->value_len * reply->format / 8))) | ||
418 | { | ||
419 | free(reply); | ||
420 | return 0; | ||
421 | } | ||
422 | |||
423 | value = xcb_get_property_value(reply); | ||
424 | switch (reply->format) | ||
425 | { | ||
426 | case 8: | ||
427 | for (i = 0; i < reply->value_len; i++) | ||
428 | (*data)[i] = ((unsigned char *)value)[i]; | ||
429 | break; | ||
430 | |||
431 | case 16: | ||
432 | for (i = 0; i < reply->value_len; i++) | ||
433 | ((unsigned short *)*data)[i] = ((unsigned short *)value)[i]; | ||
434 | break; | ||
435 | |||
436 | case 32: | ||
437 | for (i = 0; i < reply->value_len; i++) | ||
438 | ((unsigned int *)*data)[i] = ((uint32_t *)value)[i]; | ||
439 | break; | ||
440 | } | ||
441 | |||
442 | if (num) *num = reply->value_len; | ||
443 | format = reply->format; | ||
444 | free(reply); | ||
445 | return format; | ||
446 | } | ||
447 | |||
448 | EAPI int | ||
449 | ecore_x_window_prop_atom_list_get(Ecore_X_Window win, | ||
450 | Ecore_X_Atom atom, | ||
451 | Ecore_X_Atom **list) | ||
452 | { | ||
453 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
454 | |||
455 | return ecore_x_window_prop_xid_list_get(win, atom, ECORE_X_ATOM_ATOM, list); | ||
456 | } | ||
457 | |||
458 | EAPI void | ||
459 | ecore_x_window_prop_atom_list_change(Ecore_X_Window win, | ||
460 | Ecore_X_Atom atom, | ||
461 | Ecore_X_Atom item, | ||
462 | int op) | ||
463 | { | ||
464 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
465 | ecore_x_window_prop_xid_list_change(win, atom, ECORE_X_ATOM_ATOM, item, op); | ||
466 | } | ||
467 | |||
468 | EAPI int | ||
469 | ecore_x_window_prop_xid_list_get(Ecore_X_Window win, | ||
470 | Ecore_X_Atom atom, | ||
471 | Ecore_X_Atom type, | ||
472 | Ecore_X_ID **xids) | ||
473 | { | ||
474 | xcb_get_property_cookie_t cookie; | ||
475 | xcb_get_property_reply_t *reply; | ||
476 | int num = -1; | ||
477 | |||
478 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
479 | CHECK_XCB_CONN; | ||
480 | |||
481 | if (xids) *xids = NULL; | ||
482 | |||
483 | cookie = xcb_get_property_unchecked(_ecore_xcb_conn, 0, win, atom, type, | ||
484 | 0, 0x7fffffff); | ||
485 | reply = xcb_get_property_reply(_ecore_xcb_conn, cookie, NULL); | ||
486 | if (!reply) return -1; | ||
487 | |||
488 | if ((reply->type != type) || (reply->format != 32)) | ||
489 | num = -1; | ||
490 | else if ((reply->value_len == 0) || (!xcb_get_property_value(reply))) | ||
491 | num = 0; | ||
492 | else | ||
493 | { | ||
494 | Ecore_X_Atom *alst; | ||
495 | void *val; | ||
496 | |||
497 | num = xcb_get_property_value_length(reply); | ||
498 | val = xcb_get_property_value(reply); | ||
499 | alst = malloc(num * sizeof(Ecore_X_ID)); | ||
500 | if (alst) | ||
501 | { | ||
502 | int i = 0; | ||
503 | |||
504 | for (i = 0; i < num; i++) | ||
505 | alst[i] = ((uint32_t *)val)[i]; | ||
506 | *xids = alst; | ||
507 | } | ||
508 | } | ||
509 | |||
510 | free(reply); | ||
511 | return num; | ||
512 | } | ||
513 | |||
514 | EAPI void | ||
515 | ecore_x_window_prop_xid_list_change(Ecore_X_Window win, | ||
516 | Ecore_X_Atom atom, | ||
517 | Ecore_X_Atom type, | ||
518 | Ecore_X_ID item, | ||
519 | int op) | ||
520 | { | ||
521 | Ecore_X_ID *lst; | ||
522 | int i = 0, num = 0; | ||
523 | |||
524 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
525 | CHECK_XCB_CONN; | ||
526 | |||
527 | num = ecore_x_window_prop_xid_list_get(win, atom, type, &lst); | ||
528 | if (num < 0) return; | ||
529 | |||
530 | for (i = 0; i < num; i++) | ||
531 | { | ||
532 | if (lst[i] == item) break; | ||
533 | } | ||
534 | |||
535 | if (i < num) | ||
536 | { | ||
537 | if (op == ECORE_X_PROP_LIST_ADD) | ||
538 | goto done; | ||
539 | num--; | ||
540 | for (; i < num; i++) | ||
541 | lst[i] = lst[i + 1]; | ||
542 | } | ||
543 | else | ||
544 | { | ||
545 | if (op == ECORE_X_PROP_LIST_REMOVE) | ||
546 | goto done; | ||
547 | num++; | ||
548 | lst = realloc(lst, num * sizeof(Ecore_X_ID)); | ||
549 | lst[i] = item; | ||
550 | } | ||
551 | ecore_x_window_prop_xid_set(win, atom, type, lst, num); | ||
552 | |||
553 | done: | ||
554 | if (lst) free(lst); | ||
555 | } | ||
556 | |||
557 | EAPI Eina_Bool | ||
558 | ecore_x_window_prop_protocol_isset(Ecore_X_Window win, | ||
559 | Ecore_X_WM_Protocol protocol) | ||
560 | { | ||
561 | Eina_Bool ret = EINA_FALSE; | ||
562 | Ecore_X_Atom proto; | ||
563 | #ifdef OLD_XCB_VERSION | ||
564 | xcb_get_wm_protocols_reply_t protos; | ||
565 | #else | ||
566 | xcb_icccm_get_wm_protocols_reply_t protos; | ||
567 | #endif | ||
568 | xcb_get_property_cookie_t cookie; | ||
569 | uint8_t reply; | ||
570 | uint32_t count = 0, i = 0; | ||
571 | |||
572 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
573 | CHECK_XCB_CONN; | ||
574 | |||
575 | if (protocol >= ECORE_X_WM_PROTOCOL_NUM) return EINA_FALSE; | ||
576 | |||
577 | proto = _ecore_xcb_atoms_wm_protocol[protocol]; | ||
578 | #ifdef OLD_XCB_VERSION | ||
579 | cookie = xcb_get_wm_protocols_unchecked(_ecore_xcb_conn, win, | ||
580 | ECORE_X_ATOM_WM_PROTOCOLS); | ||
581 | reply = xcb_get_wm_protocols_reply(_ecore_xcb_conn, cookie, &protos, NULL); | ||
582 | #else | ||
583 | cookie = xcb_icccm_get_wm_protocols_unchecked(_ecore_xcb_conn, win, | ||
584 | ECORE_X_ATOM_WM_PROTOCOLS); | ||
585 | reply = xcb_icccm_get_wm_protocols_reply(_ecore_xcb_conn, cookie, | ||
586 | &protos, NULL); | ||
587 | #endif | ||
588 | if (!reply) return EINA_FALSE; | ||
589 | |||
590 | count = protos.atoms_len; | ||
591 | for (i = 0; i < count; i++) | ||
592 | { | ||
593 | if (protos.atoms[i] == proto) | ||
594 | { | ||
595 | ret = EINA_TRUE; | ||
596 | break; | ||
597 | } | ||
598 | } | ||
599 | |||
600 | #ifdef OLD_XCB_VERSION | ||
601 | xcb_get_wm_protocols_reply_wipe(&protos); | ||
602 | #else | ||
603 | xcb_icccm_get_wm_protocols_reply_wipe(&protos); | ||
604 | #endif | ||
605 | return ret; | ||
606 | } | ||
607 | |||
608 | EAPI Ecore_X_WM_Protocol * | ||
609 | ecore_x_window_prop_protocol_list_get(Ecore_X_Window win, | ||
610 | int *num_ret) | ||
611 | { | ||
612 | #ifdef OLD_XCB_VERSION | ||
613 | xcb_get_wm_protocols_reply_t protos; | ||
614 | #else | ||
615 | xcb_icccm_get_wm_protocols_reply_t protos; | ||
616 | #endif | ||
617 | xcb_get_property_cookie_t cookie; | ||
618 | uint8_t reply; | ||
619 | uint32_t count = 0, i = 0; | ||
620 | Ecore_X_WM_Protocol *prot_ret = NULL; | ||
621 | |||
622 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
623 | CHECK_XCB_CONN; | ||
624 | |||
625 | if (!num_ret) return NULL; | ||
626 | |||
627 | *num_ret = 0; | ||
628 | |||
629 | #ifdef OLD_XCB_VERSION | ||
630 | cookie = xcb_get_wm_protocols_unchecked(_ecore_xcb_conn, win, | ||
631 | ECORE_X_ATOM_WM_PROTOCOLS); | ||
632 | reply = xcb_get_wm_protocols_reply(_ecore_xcb_conn, cookie, &protos, NULL); | ||
633 | #else | ||
634 | cookie = xcb_icccm_get_wm_protocols_unchecked(_ecore_xcb_conn, win, | ||
635 | ECORE_X_ATOM_WM_PROTOCOLS); | ||
636 | reply = xcb_icccm_get_wm_protocols_reply(_ecore_xcb_conn, cookie, | ||
637 | &protos, NULL); | ||
638 | #endif | ||
639 | if (!reply) return NULL; | ||
640 | |||
641 | count = protos.atoms_len; | ||
642 | if (count <= 0) | ||
643 | { | ||
644 | #ifdef OLD_XCB_VERSION | ||
645 | xcb_get_wm_protocols_reply_wipe(&protos); | ||
646 | #else | ||
647 | xcb_icccm_get_wm_protocols_reply_wipe(&protos); | ||
648 | #endif | ||
649 | return NULL; | ||
650 | } | ||
651 | |||
652 | prot_ret = calloc(1, count * sizeof(Ecore_X_WM_Protocol)); | ||
653 | if (!prot_ret) | ||
654 | { | ||
655 | #ifdef OLD_XCB_VERSION | ||
656 | xcb_get_wm_protocols_reply_wipe(&protos); | ||
657 | #else | ||
658 | xcb_icccm_get_wm_protocols_reply_wipe(&protos); | ||
659 | #endif | ||
660 | return NULL; | ||
661 | } | ||
662 | |||
663 | for (i = 0; i < count; i++) | ||
664 | { | ||
665 | Ecore_X_WM_Protocol j; | ||
666 | |||
667 | prot_ret[i] = -1; | ||
668 | for (j = 0; j < ECORE_X_WM_PROTOCOL_NUM; j++) | ||
669 | { | ||
670 | if (_ecore_xcb_atoms_wm_protocol[j] == protos.atoms[i]) | ||
671 | prot_ret[i] = j; | ||
672 | } | ||
673 | } | ||
674 | |||
675 | if (num_ret) *num_ret = count; | ||
676 | |||
677 | #ifdef OLD_XCB_VERSION | ||
678 | xcb_get_wm_protocols_reply_wipe(&protos); | ||
679 | #else | ||
680 | xcb_icccm_get_wm_protocols_reply_wipe(&protos); | ||
681 | #endif | ||
682 | return prot_ret; | ||
683 | } | ||
684 | |||
685 | EAPI Ecore_X_Atom * | ||
686 | ecore_x_window_prop_list(Ecore_X_Window win, | ||
687 | int *num) | ||
688 | { | ||
689 | xcb_list_properties_cookie_t cookie; | ||
690 | xcb_list_properties_reply_t *reply; | ||
691 | xcb_atom_t *atm; | ||
692 | Ecore_X_Atom *atoms; | ||
693 | int i = 0; | ||
694 | |||
695 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
696 | CHECK_XCB_CONN; | ||
697 | |||
698 | if (num) *num = 0; | ||
699 | |||
700 | cookie = xcb_list_properties_unchecked(_ecore_xcb_conn, win); | ||
701 | reply = xcb_list_properties_reply(_ecore_xcb_conn, cookie, NULL); | ||
702 | if (!reply) return NULL; | ||
703 | |||
704 | atoms = (Ecore_X_Atom *)malloc(reply->atoms_len * sizeof(Ecore_X_Atom)); | ||
705 | if (!atoms) | ||
706 | { | ||
707 | free(reply); | ||
708 | return NULL; | ||
709 | } | ||
710 | |||
711 | atm = xcb_list_properties_atoms(reply); | ||
712 | for (i = 0; i < reply->atoms_len; i++) | ||
713 | atoms[i] = atm[i]; | ||
714 | |||
715 | if (num) *num = reply->atoms_len; | ||
716 | free(reply); | ||
717 | |||
718 | return atoms; | ||
719 | } | ||
720 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_window_shadow.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_window_shadow.c new file mode 100644 index 0000000..4f24d62 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_window_shadow.c | |||
@@ -0,0 +1,408 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | |||
3 | typedef struct _Shadow Shadow; | ||
4 | struct _Shadow | ||
5 | { | ||
6 | Shadow *parent, **children; | ||
7 | Ecore_X_Window win; | ||
8 | int children_num; | ||
9 | short x, y; | ||
10 | unsigned short w, h; | ||
11 | }; | ||
12 | |||
13 | static Eina_Bool _inside_rects(Shadow *s, | ||
14 | int x, | ||
15 | int y, | ||
16 | int bx, | ||
17 | int by, | ||
18 | Ecore_X_Rectangle *rects, | ||
19 | int num); | ||
20 | |||
21 | //static int shadow_count = 0; | ||
22 | static Shadow **shadow_base = NULL; | ||
23 | static int shadow_num = 0; | ||
24 | |||
25 | /* FIXME: round trips */ | ||
26 | static Shadow * | ||
27 | _ecore_x_window_tree_walk(Ecore_X_Window window) | ||
28 | { | ||
29 | Shadow *s, **sl; | ||
30 | xcb_get_window_attributes_reply_t *reply_attr; | ||
31 | xcb_get_geometry_reply_t *reply_geom; | ||
32 | xcb_query_tree_reply_t *reply_tree; | ||
33 | xcb_get_window_attributes_cookie_t cookie_attr; | ||
34 | xcb_get_geometry_cookie_t cookie_geom; | ||
35 | xcb_query_tree_cookie_t cookie_tree; | ||
36 | int i, j; | ||
37 | |||
38 | CHECK_XCB_CONN; | ||
39 | |||
40 | cookie_attr = xcb_get_window_attributes_unchecked(_ecore_xcb_conn, window); | ||
41 | reply_attr = xcb_get_window_attributes_reply(_ecore_xcb_conn, cookie_attr, NULL); | ||
42 | if (!reply_attr) return NULL; | ||
43 | if (reply_attr->map_state != XCB_MAP_STATE_VIEWABLE) | ||
44 | { | ||
45 | free(reply_attr); | ||
46 | return NULL; | ||
47 | } | ||
48 | |||
49 | free(reply_attr); | ||
50 | |||
51 | cookie_geom = xcb_get_geometry_unchecked(_ecore_xcb_conn, window); | ||
52 | reply_geom = xcb_get_geometry_reply(_ecore_xcb_conn, cookie_geom, NULL); | ||
53 | if (!reply_geom) return NULL; | ||
54 | |||
55 | if (!(s = calloc(1, sizeof(Shadow)))) | ||
56 | { | ||
57 | free(reply_geom); | ||
58 | return NULL; | ||
59 | } | ||
60 | |||
61 | s->win = window; | ||
62 | s->x = reply_geom->x; | ||
63 | s->y = reply_geom->y; | ||
64 | s->w = reply_geom->width; | ||
65 | s->h = reply_geom->height; | ||
66 | |||
67 | free(reply_geom); | ||
68 | |||
69 | cookie_tree = xcb_query_tree_unchecked(_ecore_xcb_conn, window); | ||
70 | reply_tree = xcb_query_tree_reply(_ecore_xcb_conn, cookie_tree, NULL); | ||
71 | if (reply_tree) | ||
72 | { | ||
73 | xcb_window_t *list; | ||
74 | int num; | ||
75 | |||
76 | num = xcb_query_tree_children_length(reply_tree); | ||
77 | list = xcb_query_tree_children(reply_tree); | ||
78 | |||
79 | s->children = calloc(1, sizeof(Shadow *) * num); | ||
80 | if (s->children) | ||
81 | { | ||
82 | s->children_num = num; | ||
83 | for (i = 0; i < num; i++) | ||
84 | { | ||
85 | s->children[i] = _ecore_x_window_tree_walk(list[i]); | ||
86 | if (s->children[i]) | ||
87 | s->children[i]->parent = s; | ||
88 | } | ||
89 | /* compress list down */ | ||
90 | j = 0; | ||
91 | for (i = 0; i < num; i++) | ||
92 | { | ||
93 | if (s->children[i]) | ||
94 | { | ||
95 | s->children[j] = s->children[i]; | ||
96 | j++; | ||
97 | } | ||
98 | } | ||
99 | if (j == 0) | ||
100 | { | ||
101 | free(s->children); | ||
102 | s->children = NULL; | ||
103 | s->children_num = 0; | ||
104 | } | ||
105 | else | ||
106 | { | ||
107 | s->children_num = j; | ||
108 | sl = realloc(s->children, sizeof(Shadow *) * j); | ||
109 | if (sl) s->children = sl; | ||
110 | } | ||
111 | } | ||
112 | |||
113 | free(reply_tree); | ||
114 | } | ||
115 | |||
116 | return s; | ||
117 | } | ||
118 | |||
119 | static void | ||
120 | _ecore_x_window_tree_shadow_free1(Shadow *s) | ||
121 | { | ||
122 | int i = 0; | ||
123 | |||
124 | if (!s) return; | ||
125 | if (s->children) | ||
126 | { | ||
127 | for (i = 0; i < s->children_num; i++) | ||
128 | { | ||
129 | if (s->children[i]) | ||
130 | _ecore_x_window_tree_shadow_free1(s->children[i]); | ||
131 | } | ||
132 | free(s->children); | ||
133 | } | ||
134 | |||
135 | free(s); | ||
136 | } | ||
137 | |||
138 | static void | ||
139 | _ecore_x_window_tree_shadow_free(void) | ||
140 | { | ||
141 | int i = 0; | ||
142 | |||
143 | if (!shadow_base) return; | ||
144 | |||
145 | for (i = 0; i < shadow_num; i++) | ||
146 | { | ||
147 | if (!shadow_base[i]) continue; | ||
148 | _ecore_x_window_tree_shadow_free1(shadow_base[i]); | ||
149 | } | ||
150 | free(shadow_base); | ||
151 | shadow_base = NULL; | ||
152 | shadow_num = 0; | ||
153 | } | ||
154 | |||
155 | static void | ||
156 | _ecore_x_window_tree_shadow_populate(void) | ||
157 | { | ||
158 | Ecore_X_Window *roots = NULL; | ||
159 | int i = 0, num = 0; | ||
160 | |||
161 | if ((roots = ecore_x_window_root_list(&num))) | ||
162 | { | ||
163 | shadow_base = calloc(1, sizeof(Shadow *) * num); | ||
164 | if (shadow_base) | ||
165 | { | ||
166 | shadow_num = num; | ||
167 | for (i = 0; i < num; i++) | ||
168 | shadow_base[i] = _ecore_x_window_tree_walk(roots[i]); | ||
169 | } | ||
170 | |||
171 | free(roots); | ||
172 | } | ||
173 | } | ||
174 | |||
175 | /* | ||
176 | static void | ||
177 | _ecore_x_window_tree_shadow_start(void) | ||
178 | { | ||
179 | shadow_count++; | ||
180 | if (shadow_count > 1) return; | ||
181 | _ecore_x_window_tree_shadow_populate(); | ||
182 | } | ||
183 | |||
184 | static void | ||
185 | _ecore_x_window_tree_shadow_stop(void) | ||
186 | { | ||
187 | shadow_count--; | ||
188 | if (shadow_count != 0) return; | ||
189 | _ecore_x_window_tree_shadow_free(); | ||
190 | } | ||
191 | */ | ||
192 | |||
193 | Shadow * | ||
194 | _ecore_x_window_shadow_tree_find_shadow(Shadow *s, | ||
195 | Ecore_X_Window win) | ||
196 | { | ||
197 | Shadow *ss; | ||
198 | int i = 0; | ||
199 | |||
200 | if (s->win == win) return s; | ||
201 | |||
202 | if (s->children) | ||
203 | { | ||
204 | for (i = 0; i < s->children_num; i++) | ||
205 | { | ||
206 | if (!s->children[i]) continue; | ||
207 | |||
208 | if ((ss = | ||
209 | _ecore_x_window_shadow_tree_find_shadow(s->children[i], win))) | ||
210 | return ss; | ||
211 | } | ||
212 | } | ||
213 | |||
214 | return NULL; | ||
215 | } | ||
216 | |||
217 | Shadow * | ||
218 | _ecore_x_window_shadow_tree_find(Ecore_X_Window base) | ||
219 | { | ||
220 | Shadow *s; | ||
221 | int i = 0; | ||
222 | |||
223 | for (i = 0; i < shadow_num; i++) | ||
224 | { | ||
225 | if (!shadow_base[i]) continue; | ||
226 | |||
227 | if ((s = | ||
228 | _ecore_x_window_shadow_tree_find_shadow(shadow_base[i], base))) | ||
229 | return s; | ||
230 | } | ||
231 | return NULL; | ||
232 | } | ||
233 | |||
234 | static Ecore_X_Window | ||
235 | _ecore_x_window_shadow_tree_at_xy_get_shadow(Shadow *s, | ||
236 | int bx, | ||
237 | int by, | ||
238 | int x, | ||
239 | int y, | ||
240 | Ecore_X_Window *skip, | ||
241 | int skip_num) | ||
242 | { | ||
243 | Ecore_X_Window child; | ||
244 | Ecore_X_Rectangle *rects; | ||
245 | int i = 0, j = 0, wx = 0, wy = 0, num = 0; | ||
246 | |||
247 | wx = s->x + bx; | ||
248 | wy = s->y + by; | ||
249 | if (!((x >= wx) && (y >= wy) && (x < (wx + s->w)) && (y < (wy + s->h)))) | ||
250 | return 0; | ||
251 | |||
252 | rects = ecore_x_window_shape_rectangles_get(s->win, &num); | ||
253 | if (!_inside_rects(s, x, y, bx, by, rects, num)) return 0; | ||
254 | num = 0; | ||
255 | rects = ecore_x_window_shape_input_rectangles_get(s->win, &num); | ||
256 | if (!_inside_rects(s, x, y, bx, by, rects, num)) return 0; | ||
257 | |||
258 | if (s->children) | ||
259 | { | ||
260 | int skipit = 0; | ||
261 | |||
262 | for (i = s->children_num - 1; i >= 0; --i) | ||
263 | { | ||
264 | if (!s->children[i]) continue; | ||
265 | |||
266 | skipit = 0; | ||
267 | if (skip) | ||
268 | { | ||
269 | for (j = 0; j < skip_num; j++) | ||
270 | { | ||
271 | if (s->children[i]->win == skip[j]) | ||
272 | { | ||
273 | skipit = 1; | ||
274 | goto onward; | ||
275 | } | ||
276 | } | ||
277 | } | ||
278 | onward: | ||
279 | if (!skipit) | ||
280 | { | ||
281 | if ((child = | ||
282 | _ecore_x_window_shadow_tree_at_xy_get_shadow(s->children[i], wx, wy, x, y, skip, skip_num))) | ||
283 | return child; | ||
284 | } | ||
285 | } | ||
286 | } | ||
287 | |||
288 | return s->win; | ||
289 | } | ||
290 | |||
291 | static Ecore_X_Window | ||
292 | _ecore_x_window_shadow_tree_at_xy_get(Ecore_X_Window base, | ||
293 | int bx, | ||
294 | int by, | ||
295 | int x, | ||
296 | int y, | ||
297 | Ecore_X_Window *skip, | ||
298 | int skip_num) | ||
299 | { | ||
300 | Shadow *s; | ||
301 | |||
302 | if (!shadow_base) | ||
303 | { | ||
304 | _ecore_x_window_tree_shadow_populate(); | ||
305 | if (!shadow_base) return 0; | ||
306 | } | ||
307 | |||
308 | s = _ecore_x_window_shadow_tree_find(base); | ||
309 | if (!s) return 0; | ||
310 | |||
311 | return _ecore_x_window_shadow_tree_at_xy_get_shadow(s, bx, by, x, y, skip, skip_num); | ||
312 | } | ||
313 | |||
314 | static Eina_Bool | ||
315 | _inside_rects(Shadow *s, | ||
316 | int x, | ||
317 | int y, | ||
318 | int bx, | ||
319 | int by, | ||
320 | Ecore_X_Rectangle *rects, | ||
321 | int num) | ||
322 | { | ||
323 | Eina_Bool inside = EINA_FALSE; | ||
324 | int i = 0; | ||
325 | |||
326 | if (!rects) return EINA_FALSE; | ||
327 | for (i = 0; i < num; i++) | ||
328 | { | ||
329 | if ((x >= s->x + bx + rects[i].x) && | ||
330 | (y >= s->y + by + rects[i].y) && | ||
331 | (x < (int)(s->x + bx + rects[i].x + rects[i].width)) && | ||
332 | (y < (int)(s->y + by + rects[i].y + rects[i].height))) | ||
333 | { | ||
334 | inside = EINA_TRUE; | ||
335 | break; | ||
336 | } | ||
337 | } | ||
338 | free(rects); | ||
339 | return inside; | ||
340 | } | ||
341 | |||
342 | /** | ||
343 | * Retrieves the top, visible window at the given location, | ||
344 | * but skips the windows in the list. This uses a shadow tree built from the | ||
345 | * window tree that is only updated the first time | ||
346 | * ecore_x_window_shadow_tree_at_xy_with_skip_get() is called, or the next time | ||
347 | * it is called after a ecore_x_window_shadow_tree_flush() | ||
348 | * @param base The base window to start searching from (normally root). | ||
349 | * @param x The given X position. | ||
350 | * @param y The given Y position. | ||
351 | * @return The window at that position. | ||
352 | * @ingroup Ecore_X_Window_Geometry_Group | ||
353 | */ | ||
354 | EAPI Ecore_X_Window | ||
355 | ecore_x_window_shadow_tree_at_xy_with_skip_get(Ecore_X_Window base, | ||
356 | int x, | ||
357 | int y, | ||
358 | Ecore_X_Window *skip, | ||
359 | int skip_num) | ||
360 | { | ||
361 | return _ecore_x_window_shadow_tree_at_xy_get(base, 0, 0, x, y, skip, skip_num); | ||
362 | } | ||
363 | |||
364 | /** | ||
365 | * Retrieves the parent window a given window has. This uses the shadow window | ||
366 | * tree. | ||
367 | * @param root The root window of @p win - if 0, this will be automatically determined with extra processing overhead | ||
368 | * @param win The window to get the parent window of | ||
369 | * @return The parent window of @p win | ||
370 | * @ingroup Ecore_X_Window_Geometry_Group | ||
371 | */ | ||
372 | EAPI Ecore_X_Window | ||
373 | ecore_x_window_shadow_parent_get(Ecore_X_Window root __UNUSED__, | ||
374 | Ecore_X_Window win) | ||
375 | { | ||
376 | Shadow *s; | ||
377 | int i = 0; | ||
378 | |||
379 | if (!shadow_base) | ||
380 | { | ||
381 | _ecore_x_window_tree_shadow_populate(); | ||
382 | if (!shadow_base) return 0; | ||
383 | } | ||
384 | |||
385 | for (i = 0; i < shadow_num; i++) | ||
386 | { | ||
387 | if (!shadow_base[i]) continue; | ||
388 | |||
389 | s = _ecore_x_window_shadow_tree_find_shadow(shadow_base[i], win); | ||
390 | if (s) | ||
391 | { | ||
392 | if (!s->parent) return 0; | ||
393 | return s->parent->win; | ||
394 | } | ||
395 | } | ||
396 | return 0; | ||
397 | } | ||
398 | |||
399 | /** | ||
400 | * Flushes the window shadow tree so nothing is stored. | ||
401 | * @ingroup Ecore_X_Window_Geometry_Group | ||
402 | */ | ||
403 | EAPI void | ||
404 | ecore_x_window_shadow_tree_flush(void) | ||
405 | { | ||
406 | _ecore_x_window_tree_shadow_free(); | ||
407 | } | ||
408 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_window_shape.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_window_shape.c new file mode 100644 index 0000000..6206a51 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_window_shape.c | |||
@@ -0,0 +1,790 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #ifdef ECORE_XCB_SHAPE | ||
3 | # include <xcb/shape.h> | ||
4 | #endif | ||
5 | |||
6 | /** | ||
7 | * @defgroup Ecore_X_Window_Shape X Window Shape Functions | ||
8 | * | ||
9 | * These functions use the shape extension of the X server to change | ||
10 | * shape of given windows. | ||
11 | */ | ||
12 | |||
13 | /** | ||
14 | * Sets the input shape of the given window to that given by the pixmap @p mask. | ||
15 | * @param win The given window. | ||
16 | * @param mask A 1-bit depth pixmap that provides the new input shape of the | ||
17 | * window. | ||
18 | * @ingroup Ecore_X_Window_Shape | ||
19 | */ | ||
20 | EAPI void | ||
21 | ecore_x_window_shape_input_mask_set(Ecore_X_Window win, | ||
22 | Ecore_X_Pixmap mask) | ||
23 | { | ||
24 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
25 | CHECK_XCB_CONN; | ||
26 | |||
27 | #ifdef ECORE_XCB_SHAPE | ||
28 | xcb_shape_mask(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, | ||
29 | win, 0, 0, mask); | ||
30 | // ecore_x_flush(); | ||
31 | #else | ||
32 | return; | ||
33 | win = 0; | ||
34 | mask = 0; | ||
35 | #endif | ||
36 | } | ||
37 | |||
38 | /** | ||
39 | * Sets the shape of the given window to that given by the pixmap @p mask. | ||
40 | * @param win The given window. | ||
41 | * @param mask A 2-bit depth pixmap that provides the new shape of the | ||
42 | * window. | ||
43 | * @ingroup Ecore_X_Window_Shape | ||
44 | */ | ||
45 | EAPI void | ||
46 | ecore_x_window_shape_mask_set(Ecore_X_Window win, | ||
47 | Ecore_X_Pixmap mask) | ||
48 | { | ||
49 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
50 | CHECK_XCB_CONN; | ||
51 | |||
52 | #ifdef ECORE_XCB_SHAPE | ||
53 | xcb_shape_mask(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, | ||
54 | win, 0, 0, mask); | ||
55 | // ecore_x_flush(); | ||
56 | #else | ||
57 | return; | ||
58 | win = 0; | ||
59 | mask = 0; | ||
60 | #endif | ||
61 | } | ||
62 | |||
63 | EAPI void | ||
64 | ecore_x_window_shape_window_set(Ecore_X_Window win, | ||
65 | Ecore_X_Window shape_win) | ||
66 | { | ||
67 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
68 | CHECK_XCB_CONN; | ||
69 | |||
70 | #ifdef ECORE_XCB_SHAPE | ||
71 | xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, | ||
72 | XCB_SHAPE_SK_BOUNDING, win, 0, 0, shape_win); | ||
73 | // ecore_x_flush(); | ||
74 | #else | ||
75 | return; | ||
76 | win = 0; | ||
77 | shape_win = 0; | ||
78 | #endif | ||
79 | } | ||
80 | |||
81 | EAPI void | ||
82 | ecore_x_window_shape_window_set_xy(Ecore_X_Window win, | ||
83 | Ecore_X_Window shape_win, | ||
84 | int x, | ||
85 | int y) | ||
86 | { | ||
87 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
88 | CHECK_XCB_CONN; | ||
89 | |||
90 | #ifdef ECORE_XCB_SHAPE | ||
91 | xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_BOUNDING, | ||
92 | XCB_SHAPE_SK_BOUNDING, win, x, y, shape_win); | ||
93 | // ecore_x_flush(); | ||
94 | #else | ||
95 | return; | ||
96 | win = 0; | ||
97 | shape_win = 0; | ||
98 | x = 0; | ||
99 | y = 0; | ||
100 | #endif | ||
101 | } | ||
102 | |||
103 | EAPI void | ||
104 | ecore_x_window_shape_rectangle_set(Ecore_X_Window win, | ||
105 | int x, | ||
106 | int y, | ||
107 | int w, | ||
108 | int h) | ||
109 | { | ||
110 | #ifdef ECORE_XCB_SHAPE | ||
111 | xcb_rectangle_t rect; | ||
112 | #endif | ||
113 | |||
114 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
115 | CHECK_XCB_CONN; | ||
116 | |||
117 | #ifdef ECORE_XCB_SHAPE | ||
118 | rect.x = x; | ||
119 | rect.y = y; | ||
120 | rect.width = w; | ||
121 | rect.height = h; | ||
122 | xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET, | ||
123 | XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED, | ||
124 | win, 0, 0, 1, &rect); | ||
125 | // ecore_x_flush(); | ||
126 | #else | ||
127 | return; | ||
128 | win = 0; | ||
129 | x = 0; | ||
130 | y = 0; | ||
131 | w = 0; | ||
132 | h = 0; | ||
133 | #endif | ||
134 | } | ||
135 | |||
136 | EAPI void | ||
137 | ecore_x_window_shape_rectangles_set(Ecore_X_Window win, | ||
138 | Ecore_X_Rectangle *rects, | ||
139 | int num) | ||
140 | { | ||
141 | #ifdef ECORE_XCB_SHAPE | ||
142 | xcb_rectangle_t *rect = NULL; | ||
143 | #endif | ||
144 | |||
145 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
146 | CHECK_XCB_CONN; | ||
147 | |||
148 | if (!rects) return; | ||
149 | |||
150 | #ifdef ECORE_XCB_SHAPE | ||
151 | if (num > 0) | ||
152 | { | ||
153 | int i = 0; | ||
154 | |||
155 | if (!(rect = malloc(sizeof(xcb_rectangle_t) * num))) | ||
156 | return; | ||
157 | |||
158 | for (i = 0; i < num; i++) | ||
159 | { | ||
160 | rect[i].x = rects[i].x; | ||
161 | rect[i].y = rects[i].y; | ||
162 | rect[i].width = rects[i].width; | ||
163 | rect[i].height = rects[i].height; | ||
164 | } | ||
165 | } | ||
166 | xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET, | ||
167 | XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED, | ||
168 | win, 0, 0, num, (xcb_rectangle_t *)rect); | ||
169 | |||
170 | if (rect) free(rect); | ||
171 | // ecore_x_flush(); | ||
172 | #else | ||
173 | return; | ||
174 | win = 0; | ||
175 | num = 0; | ||
176 | rects = NULL; | ||
177 | #endif | ||
178 | } | ||
179 | |||
180 | EAPI void | ||
181 | ecore_x_window_shape_window_add(Ecore_X_Window win, | ||
182 | Ecore_X_Window shape_win) | ||
183 | { | ||
184 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
185 | CHECK_XCB_CONN; | ||
186 | |||
187 | #ifdef ECORE_XCB_SHAPE | ||
188 | xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, | ||
189 | XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING, | ||
190 | win, 0, 0, shape_win); | ||
191 | // ecore_x_flush(); | ||
192 | #else | ||
193 | return; | ||
194 | win = 0; | ||
195 | shape_win = 0; | ||
196 | #endif | ||
197 | } | ||
198 | |||
199 | EAPI void | ||
200 | ecore_x_window_shape_window_add_xy(Ecore_X_Window win, | ||
201 | Ecore_X_Window shape_win, | ||
202 | int x, | ||
203 | int y) | ||
204 | { | ||
205 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
206 | CHECK_XCB_CONN; | ||
207 | |||
208 | #ifdef ECORE_XCB_SHAPE | ||
209 | xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, | ||
210 | XCB_SHAPE_SK_BOUNDING, XCB_SHAPE_SK_BOUNDING, | ||
211 | win, x, y, shape_win); | ||
212 | // ecore_x_flush(); | ||
213 | #else | ||
214 | return; | ||
215 | win = 0; | ||
216 | shape_win = 0; | ||
217 | x = 0; | ||
218 | y = 0; | ||
219 | #endif | ||
220 | } | ||
221 | |||
222 | EAPI void | ||
223 | ecore_x_window_shape_rectangle_add(Ecore_X_Window win, | ||
224 | int x, | ||
225 | int y, | ||
226 | int w, | ||
227 | int h) | ||
228 | { | ||
229 | #ifdef ECORE_XCB_SHAPE | ||
230 | xcb_rectangle_t rect; | ||
231 | #endif | ||
232 | |||
233 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
234 | CHECK_XCB_CONN; | ||
235 | |||
236 | #ifdef ECORE_XCB_SHAPE | ||
237 | rect.x = x; | ||
238 | rect.y = y; | ||
239 | rect.width = w; | ||
240 | rect.height = h; | ||
241 | xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, | ||
242 | XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED, | ||
243 | win, 0, 0, 1, &rect); | ||
244 | // ecore_x_flush(); | ||
245 | #else | ||
246 | return; | ||
247 | win = 0; | ||
248 | x = 0; | ||
249 | y = 0; | ||
250 | w = 0; | ||
251 | h = 0; | ||
252 | #endif | ||
253 | } | ||
254 | |||
255 | EAPI void | ||
256 | ecore_x_window_shape_rectangle_subtract(Ecore_X_Window win, | ||
257 | int x, | ||
258 | int y, | ||
259 | int w, | ||
260 | int h) | ||
261 | { | ||
262 | #ifdef ECORE_XCB_SHAPE | ||
263 | xcb_rectangle_t rect; | ||
264 | #endif | ||
265 | |||
266 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
267 | CHECK_XCB_CONN; | ||
268 | |||
269 | #ifdef ECORE_XCB_SHAPE | ||
270 | rect.x = x; | ||
271 | rect.y = y; | ||
272 | rect.width = w; | ||
273 | rect.height = h; | ||
274 | xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SUBTRACT, | ||
275 | XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED, | ||
276 | win, 0, 0, 1, &rect); | ||
277 | // ecore_x_flush(); | ||
278 | #else | ||
279 | return; | ||
280 | win = 0; | ||
281 | x = 0; | ||
282 | y = 0; | ||
283 | w = 0; | ||
284 | h = 0; | ||
285 | #endif | ||
286 | } | ||
287 | |||
288 | EAPI void | ||
289 | ecore_x_window_shape_rectangle_clip(Ecore_X_Window win, | ||
290 | int x, | ||
291 | int y, | ||
292 | int w, | ||
293 | int h) | ||
294 | { | ||
295 | #ifdef ECORE_XCB_SHAPE | ||
296 | xcb_rectangle_t rect; | ||
297 | #endif | ||
298 | |||
299 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
300 | CHECK_XCB_CONN; | ||
301 | |||
302 | #ifdef ECORE_XCB_SHAPE | ||
303 | rect.x = x; | ||
304 | rect.y = y; | ||
305 | rect.width = w; | ||
306 | rect.height = h; | ||
307 | xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_INTERSECT, | ||
308 | XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED, | ||
309 | win, 0, 0, 1, &rect); | ||
310 | // ecore_x_flush(); | ||
311 | #else | ||
312 | return; | ||
313 | win = 0; | ||
314 | x = 0; | ||
315 | y = 0; | ||
316 | w = 0; | ||
317 | h = 0; | ||
318 | #endif | ||
319 | } | ||
320 | |||
321 | EAPI void | ||
322 | ecore_x_window_shape_rectangles_add(Ecore_X_Window win, | ||
323 | Ecore_X_Rectangle *rects, | ||
324 | int num) | ||
325 | { | ||
326 | #ifdef ECORE_XCB_SHAPE | ||
327 | xcb_rectangle_t *rect = NULL; | ||
328 | #endif | ||
329 | |||
330 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
331 | CHECK_XCB_CONN; | ||
332 | |||
333 | #ifdef ECORE_XCB_SHAPE | ||
334 | if (num > 0) | ||
335 | { | ||
336 | int i = 0; | ||
337 | |||
338 | if (!(rect = malloc(sizeof(xcb_rectangle_t) * num))) | ||
339 | return; | ||
340 | |||
341 | for (i = 0; i < num; i++) | ||
342 | { | ||
343 | rect[i].x = rects[i].x; | ||
344 | rect[i].y = rects[i].y; | ||
345 | rect[i].width = rects[i].width; | ||
346 | rect[i].height = rects[i].height; | ||
347 | } | ||
348 | } | ||
349 | |||
350 | xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, | ||
351 | XCB_SHAPE_SK_BOUNDING, XCB_CLIP_ORDERING_UNSORTED, | ||
352 | win, 0, 0, num, (xcb_rectangle_t *)&rect); | ||
353 | |||
354 | if (rect) free(rect); | ||
355 | // ecore_x_flush(); | ||
356 | #else | ||
357 | return; | ||
358 | win = 0; | ||
359 | num = 0; | ||
360 | rects = NULL; | ||
361 | #endif | ||
362 | } | ||
363 | |||
364 | EAPI Ecore_X_Rectangle * | ||
365 | ecore_x_window_shape_rectangles_get(Ecore_X_Window win, | ||
366 | int *num_ret) | ||
367 | { | ||
368 | Ecore_X_Rectangle *rects = NULL; | ||
369 | #ifdef ECORE_XCB_SHAPE | ||
370 | xcb_shape_get_rectangles_cookie_t cookie; | ||
371 | xcb_shape_get_rectangles_reply_t *reply; | ||
372 | xcb_rectangle_t *r; | ||
373 | unsigned int i = 0; | ||
374 | #endif | ||
375 | |||
376 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
377 | CHECK_XCB_CONN; | ||
378 | |||
379 | if (num_ret) *num_ret = 0; | ||
380 | |||
381 | #ifdef ECORE_XCB_SHAPE | ||
382 | cookie = | ||
383 | xcb_shape_get_rectangles(_ecore_xcb_conn, win, XCB_SHAPE_SK_BOUNDING); | ||
384 | reply = xcb_shape_get_rectangles_reply(_ecore_xcb_conn, cookie, NULL); | ||
385 | if (!reply) return NULL; | ||
386 | if (num_ret) *num_ret = reply->rectangles_len; | ||
387 | |||
388 | if (reply->rectangles_len < 1) | ||
389 | { | ||
390 | free(reply); | ||
391 | if (num_ret) *num_ret = 0; | ||
392 | return NULL; | ||
393 | } | ||
394 | |||
395 | rects = malloc(sizeof(Ecore_X_Rectangle) * reply->rectangles_len); | ||
396 | if (!rects) | ||
397 | { | ||
398 | free(reply); | ||
399 | if (num_ret) *num_ret = 0; | ||
400 | return NULL; | ||
401 | } | ||
402 | r = xcb_shape_get_rectangles_rectangles(reply); | ||
403 | for (i = 0; i < reply->rectangles_len; i++) | ||
404 | { | ||
405 | rects[i].x = r[i].x; | ||
406 | rects[i].y = r[i].y; | ||
407 | rects[i].width = r[i].width; | ||
408 | rects[i].height = r[i].height; | ||
409 | } | ||
410 | |||
411 | free(reply); | ||
412 | |||
413 | return rects; | ||
414 | #else | ||
415 | return rects; | ||
416 | win = 0; | ||
417 | #endif | ||
418 | } | ||
419 | |||
420 | EAPI void | ||
421 | ecore_x_window_shape_events_select(Ecore_X_Window win, | ||
422 | Eina_Bool on) | ||
423 | { | ||
424 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
425 | CHECK_XCB_CONN; | ||
426 | |||
427 | #ifdef ECORE_XCB_SHAPE | ||
428 | xcb_shape_select_input(_ecore_xcb_conn, win, on); | ||
429 | // ecore_x_flush(); | ||
430 | #else | ||
431 | return; | ||
432 | win = 0; | ||
433 | on = 0; | ||
434 | #endif | ||
435 | } | ||
436 | |||
437 | EAPI Ecore_X_Rectangle * | ||
438 | ecore_x_window_shape_input_rectangles_get(Ecore_X_Window win, | ||
439 | int *num_ret) | ||
440 | { | ||
441 | Ecore_X_Rectangle *rects = NULL; | ||
442 | #ifdef ECORE_XCB_SHAPE | ||
443 | xcb_shape_get_rectangles_cookie_t cookie; | ||
444 | xcb_shape_get_rectangles_reply_t *reply; | ||
445 | xcb_rectangle_t *r; | ||
446 | unsigned int i = 0; | ||
447 | #endif | ||
448 | |||
449 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
450 | CHECK_XCB_CONN; | ||
451 | |||
452 | if (num_ret) *num_ret = 0; | ||
453 | |||
454 | #ifdef ECORE_XCB_SHAPE | ||
455 | cookie = | ||
456 | xcb_shape_get_rectangles(_ecore_xcb_conn, win, XCB_SHAPE_SK_INPUT); | ||
457 | reply = xcb_shape_get_rectangles_reply(_ecore_xcb_conn, cookie, NULL); | ||
458 | if (!reply) return NULL; | ||
459 | if (num_ret) *num_ret = reply->rectangles_len; | ||
460 | |||
461 | if (reply->rectangles_len < 1) | ||
462 | { | ||
463 | free(reply); | ||
464 | if (num_ret) *num_ret = 0; | ||
465 | return NULL; | ||
466 | } | ||
467 | |||
468 | rects = malloc(sizeof(Ecore_X_Rectangle) * reply->rectangles_len); | ||
469 | if (!rects) | ||
470 | { | ||
471 | free(reply); | ||
472 | if (num_ret) *num_ret = 0; | ||
473 | return NULL; | ||
474 | } | ||
475 | r = xcb_shape_get_rectangles_rectangles(reply); | ||
476 | for (i = 0; i < reply->rectangles_len; i++) | ||
477 | { | ||
478 | rects[i].x = r[i].x; | ||
479 | rects[i].y = r[i].y; | ||
480 | rects[i].width = r[i].width; | ||
481 | rects[i].height = r[i].height; | ||
482 | } | ||
483 | |||
484 | free(reply); | ||
485 | |||
486 | return rects; | ||
487 | #else | ||
488 | xcb_get_geometry_cookie_t cookie; | ||
489 | xcb_get_geometry_reply_t *reply; | ||
490 | |||
491 | if (!(rects = malloc(sizeof(Ecore_X_Rectangle)))) | ||
492 | return NULL; | ||
493 | |||
494 | /* get geometry */ | ||
495 | cookie = xcb_get_geometry_unchecked(_ecore_xcb_conn, win); | ||
496 | reply = xcb_get_geometry_reply(_ecore_xcb_conn, cookie, NULL); | ||
497 | if (reply) | ||
498 | { | ||
499 | rects[0].x = reply->x; | ||
500 | rects[0].y = reply->y; | ||
501 | rects[0].width = reply->width; | ||
502 | rects[0].height = reply->height; | ||
503 | free(reply); | ||
504 | } | ||
505 | if (num_ret) *num_ret = 1; | ||
506 | return rects; | ||
507 | #endif | ||
508 | } | ||
509 | |||
510 | EAPI void | ||
511 | ecore_x_window_shape_input_rectangles_set(Ecore_X_Window win, | ||
512 | Ecore_X_Rectangle *rects, | ||
513 | int num) | ||
514 | { | ||
515 | #ifdef ECORE_XCB_SHAPE | ||
516 | xcb_rectangle_t *rect = NULL; | ||
517 | #endif | ||
518 | |||
519 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
520 | CHECK_XCB_CONN; | ||
521 | |||
522 | if (!rects) return; | ||
523 | |||
524 | #ifdef ECORE_XCB_SHAPE | ||
525 | if (num > 0) | ||
526 | { | ||
527 | int i = 0; | ||
528 | |||
529 | if (!(rect = malloc(sizeof(xcb_rectangle_t) * num))) | ||
530 | return; | ||
531 | |||
532 | for (i = 0; i < num; i++) | ||
533 | { | ||
534 | rect[i].x = rects[i].x; | ||
535 | rect[i].y = rects[i].y; | ||
536 | rect[i].width = rects[i].width; | ||
537 | rect[i].height = rects[i].height; | ||
538 | } | ||
539 | } | ||
540 | xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET, | ||
541 | XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED, | ||
542 | win, 0, 0, num, (xcb_rectangle_t *)rect); | ||
543 | |||
544 | if (rect) free(rect); | ||
545 | // ecore_x_flush(); | ||
546 | #else | ||
547 | return; | ||
548 | win = 0; | ||
549 | num = 0; | ||
550 | rects = NULL; | ||
551 | #endif | ||
552 | } | ||
553 | |||
554 | EAPI void | ||
555 | ecore_x_window_shape_input_rectangle_subtract(Ecore_X_Window win, | ||
556 | int x, | ||
557 | int y, | ||
558 | int w, | ||
559 | int h) | ||
560 | { | ||
561 | #ifdef ECORE_XCB_SHAPE | ||
562 | xcb_rectangle_t rect; | ||
563 | #endif | ||
564 | |||
565 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
566 | CHECK_XCB_CONN; | ||
567 | |||
568 | #ifdef ECORE_XCB_SHAPE | ||
569 | rect.x = x; | ||
570 | rect.y = y; | ||
571 | rect.width = w; | ||
572 | rect.height = h; | ||
573 | xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SUBTRACT, | ||
574 | XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED, | ||
575 | win, 0, 0, 1, &rect); | ||
576 | // ecore_x_flush(); | ||
577 | #else | ||
578 | return; | ||
579 | win = 0; | ||
580 | x = 0; | ||
581 | y = 0; | ||
582 | w = 0; | ||
583 | h = 0; | ||
584 | #endif | ||
585 | } | ||
586 | |||
587 | EAPI void | ||
588 | ecore_x_window_shape_input_rectangle_add(Ecore_X_Window win, | ||
589 | int x, | ||
590 | int y, | ||
591 | int w, | ||
592 | int h) | ||
593 | { | ||
594 | #ifdef ECORE_XCB_SHAPE | ||
595 | xcb_rectangle_t rect; | ||
596 | #endif | ||
597 | |||
598 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
599 | CHECK_XCB_CONN; | ||
600 | |||
601 | #ifdef ECORE_XCB_SHAPE | ||
602 | rect.x = x; | ||
603 | rect.y = y; | ||
604 | rect.width = w; | ||
605 | rect.height = h; | ||
606 | xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, | ||
607 | XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED, | ||
608 | win, 0, 0, 1, &rect); | ||
609 | // ecore_x_flush(); | ||
610 | #else | ||
611 | return; | ||
612 | win = 0; | ||
613 | x = 0; | ||
614 | y = 0; | ||
615 | w = 0; | ||
616 | h = 0; | ||
617 | #endif | ||
618 | } | ||
619 | |||
620 | EAPI void | ||
621 | ecore_x_window_shape_input_rectangle_set(Ecore_X_Window win, | ||
622 | int x, | ||
623 | int y, | ||
624 | int w, | ||
625 | int h) | ||
626 | { | ||
627 | #ifdef ECORE_XCB_SHAPE | ||
628 | xcb_rectangle_t rect; | ||
629 | #endif | ||
630 | |||
631 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
632 | CHECK_XCB_CONN; | ||
633 | |||
634 | #ifdef ECORE_XCB_SHAPE | ||
635 | rect.x = x; | ||
636 | rect.y = y; | ||
637 | rect.width = w; | ||
638 | rect.height = h; | ||
639 | xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_SET, | ||
640 | XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED, | ||
641 | win, 0, 0, 1, &rect); | ||
642 | // ecore_x_flush(); | ||
643 | #else | ||
644 | return; | ||
645 | win = 0; | ||
646 | x = 0; | ||
647 | y = 0; | ||
648 | w = 0; | ||
649 | h = 0; | ||
650 | #endif | ||
651 | } | ||
652 | |||
653 | EAPI void | ||
654 | ecore_x_window_shape_input_window_set_xy(Ecore_X_Window win, | ||
655 | Ecore_X_Window shape_win, | ||
656 | int x, | ||
657 | int y) | ||
658 | { | ||
659 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
660 | CHECK_XCB_CONN; | ||
661 | |||
662 | #ifdef ECORE_XCB_SHAPE | ||
663 | xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, | ||
664 | XCB_SHAPE_SK_INPUT, win, x, y, shape_win); | ||
665 | // ecore_x_flush(); | ||
666 | #else | ||
667 | return; | ||
668 | win = 0; | ||
669 | shape_win = 0; | ||
670 | x = 0; | ||
671 | y = 0; | ||
672 | #endif | ||
673 | } | ||
674 | |||
675 | EAPI void | ||
676 | ecore_x_window_shape_input_window_add_xy(Ecore_X_Window win, | ||
677 | Ecore_X_Window shape_win, | ||
678 | int x, | ||
679 | int y) | ||
680 | { | ||
681 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
682 | CHECK_XCB_CONN; | ||
683 | |||
684 | #ifdef ECORE_XCB_SHAPE | ||
685 | xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, XCB_SHAPE_SK_INPUT, | ||
686 | XCB_SHAPE_SK_INPUT, win, x, y, shape_win); | ||
687 | // ecore_x_flush(); | ||
688 | #else | ||
689 | return; | ||
690 | win = 0; | ||
691 | shape_win = 0; | ||
692 | x = 0; | ||
693 | y = 0; | ||
694 | #endif | ||
695 | } | ||
696 | |||
697 | EAPI void | ||
698 | ecore_x_window_shape_input_window_set(Ecore_X_Window win, | ||
699 | Ecore_X_Window shape_win) | ||
700 | { | ||
701 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
702 | CHECK_XCB_CONN; | ||
703 | |||
704 | #ifdef ECORE_XCB_SHAPE | ||
705 | xcb_shape_combine(_ecore_xcb_conn, XCB_SHAPE_SO_SET, XCB_SHAPE_SK_INPUT, | ||
706 | XCB_SHAPE_SK_INPUT, win, 0, 0, shape_win); | ||
707 | // ecore_x_flush(); | ||
708 | #else | ||
709 | return; | ||
710 | win = 0; | ||
711 | shape_win = 0; | ||
712 | #endif | ||
713 | } | ||
714 | |||
715 | EAPI void | ||
716 | ecore_x_window_shape_input_rectangle_clip(Ecore_X_Window win, | ||
717 | int x, | ||
718 | int y, | ||
719 | int w, | ||
720 | int h) | ||
721 | { | ||
722 | #ifdef ECORE_XCB_SHAPE | ||
723 | xcb_rectangle_t rect; | ||
724 | #endif | ||
725 | |||
726 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
727 | CHECK_XCB_CONN; | ||
728 | |||
729 | #ifdef ECORE_XCB_SHAPE | ||
730 | rect.x = x; | ||
731 | rect.y = y; | ||
732 | rect.width = w; | ||
733 | rect.height = h; | ||
734 | xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_INTERSECT, | ||
735 | XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED, | ||
736 | win, 0, 0, 1, &rect); | ||
737 | // ecore_x_flush(); | ||
738 | #else | ||
739 | return; | ||
740 | win = 0; | ||
741 | x = 0; | ||
742 | y = 0; | ||
743 | w = 0; | ||
744 | h = 0; | ||
745 | #endif | ||
746 | } | ||
747 | |||
748 | EAPI void | ||
749 | ecore_x_window_shape_input_rectangles_add(Ecore_X_Window win, | ||
750 | Ecore_X_Rectangle *rects, | ||
751 | int num) | ||
752 | { | ||
753 | #ifdef ECORE_XCB_SHAPE | ||
754 | xcb_rectangle_t *rect = NULL; | ||
755 | #endif | ||
756 | |||
757 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
758 | CHECK_XCB_CONN; | ||
759 | |||
760 | #ifdef ECORE_XCB_SHAPE | ||
761 | if (num > 0) | ||
762 | { | ||
763 | int i = 0; | ||
764 | |||
765 | if (!(rect = malloc(sizeof(xcb_rectangle_t) * num))) | ||
766 | return; | ||
767 | |||
768 | for (i = 0; i < num; i++) | ||
769 | { | ||
770 | rect[i].x = rects[i].x; | ||
771 | rect[i].y = rects[i].y; | ||
772 | rect[i].width = rects[i].width; | ||
773 | rect[i].height = rects[i].height; | ||
774 | } | ||
775 | } | ||
776 | |||
777 | xcb_shape_rectangles(_ecore_xcb_conn, XCB_SHAPE_SO_UNION, | ||
778 | XCB_SHAPE_SK_INPUT, XCB_CLIP_ORDERING_UNSORTED, | ||
779 | win, 0, 0, num, (xcb_rectangle_t *)&rect); | ||
780 | |||
781 | if (rect) free(rect); | ||
782 | // ecore_x_flush(); | ||
783 | #else | ||
784 | return; | ||
785 | win = 0; | ||
786 | num = 0; | ||
787 | rects = NULL; | ||
788 | #endif | ||
789 | } | ||
790 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xdefaults.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xdefaults.c new file mode 100644 index 0000000..e0e5610 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xdefaults.c | |||
@@ -0,0 +1,116 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #include <fnmatch.h> | ||
3 | |||
4 | /* local function prototypes */ | ||
5 | static Eina_Bool _ecore_xcb_xdefaults_glob_match(const char *str, | ||
6 | const char *glob); | ||
7 | |||
8 | /* local variables */ | ||
9 | static Eina_File *_ecore_xcb_xdefaults_file = NULL; | ||
10 | static char *_ecore_xcb_xdefaults_data = NULL; | ||
11 | |||
12 | void | ||
13 | _ecore_xcb_xdefaults_init(void) | ||
14 | { | ||
15 | char buff[PATH_MAX]; | ||
16 | |||
17 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
18 | |||
19 | snprintf(buff, sizeof(buff), "%s/.Xdefaults", getenv("HOME")); | ||
20 | if ((_ecore_xcb_xdefaults_file = eina_file_open(buff, EINA_FALSE))) | ||
21 | { | ||
22 | eina_mmap_safety_enabled_set(EINA_TRUE); | ||
23 | |||
24 | _ecore_xcb_xdefaults_data = | ||
25 | eina_file_map_all(_ecore_xcb_xdefaults_file, EINA_FILE_SEQUENTIAL); | ||
26 | } | ||
27 | } | ||
28 | |||
29 | void | ||
30 | _ecore_xcb_xdefaults_shutdown(void) | ||
31 | { | ||
32 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
33 | |||
34 | if (!_ecore_xcb_xdefaults_file) return; | ||
35 | if (_ecore_xcb_xdefaults_data) | ||
36 | eina_file_map_free(_ecore_xcb_xdefaults_file, _ecore_xcb_xdefaults_data); | ||
37 | if (_ecore_xcb_xdefaults_file) eina_file_close(_ecore_xcb_xdefaults_file); | ||
38 | } | ||
39 | |||
40 | char * | ||
41 | _ecore_xcb_xdefaults_string_get(const char *prog, | ||
42 | const char *param) | ||
43 | { | ||
44 | char buff[1024], ret[1024]; | ||
45 | char *str = NULL; | ||
46 | char **ea = NULL; | ||
47 | unsigned int count = 0, i = 0; | ||
48 | |||
49 | if ((!_ecore_xcb_xdefaults_data) || (!_ecore_xcb_xdefaults_file)) | ||
50 | return NULL; | ||
51 | |||
52 | snprintf(buff, sizeof(buff), "*%s*.*%s*", prog, param); | ||
53 | |||
54 | str = _ecore_xcb_xdefaults_data; | ||
55 | ea = eina_str_split_full(str, "\n", -1, &count); | ||
56 | for (i = 0; i < count; i++) | ||
57 | { | ||
58 | if (_ecore_xcb_xdefaults_glob_match(ea[i], buff)) | ||
59 | sscanf(ea[i], "%*[^:]:%*[ ]%s", ret); | ||
60 | } | ||
61 | if ((ea) && (ea[0])) | ||
62 | { | ||
63 | free(ea[0]); | ||
64 | free(ea); | ||
65 | } | ||
66 | |||
67 | return strdup(ret); | ||
68 | } | ||
69 | |||
70 | int | ||
71 | _ecore_xcb_xdefaults_int_get(const char *prog, | ||
72 | const char *param) | ||
73 | { | ||
74 | char buff[1024]; | ||
75 | char *str = NULL; | ||
76 | char **ea = NULL; | ||
77 | unsigned int count = 0, i = 0; | ||
78 | int ret = -1; | ||
79 | |||
80 | if ((!_ecore_xcb_xdefaults_data) || (!_ecore_xcb_xdefaults_file)) | ||
81 | return 0; | ||
82 | |||
83 | snprintf(buff, sizeof(buff), "*%s*.*%s*", prog, param); | ||
84 | |||
85 | str = _ecore_xcb_xdefaults_data; | ||
86 | ea = eina_str_split_full(str, "\n", -1, &count); | ||
87 | for (i = 0; i < count; i++) | ||
88 | { | ||
89 | if (_ecore_xcb_xdefaults_glob_match(ea[i], buff)) | ||
90 | sscanf(ea[i], "%*[^:]:%*[ ]%d", &ret); | ||
91 | } | ||
92 | if ((ea) && (ea[0])) | ||
93 | { | ||
94 | free(ea[0]); | ||
95 | free(ea); | ||
96 | } | ||
97 | |||
98 | return ret; | ||
99 | } | ||
100 | |||
101 | /* local functions */ | ||
102 | static Eina_Bool | ||
103 | _ecore_xcb_xdefaults_glob_match(const char *str, | ||
104 | const char *glob) | ||
105 | { | ||
106 | if ((!str) || (!glob)) return EINA_FALSE; | ||
107 | if (glob[0] == 0) | ||
108 | { | ||
109 | if (str[0] == 0) return EINA_TRUE; | ||
110 | return EINA_FALSE; | ||
111 | } | ||
112 | if (!strcmp(glob, "*")) return EINA_TRUE; | ||
113 | if (!fnmatch(glob, str, 0)) return EINA_TRUE; | ||
114 | return EINA_FALSE; | ||
115 | } | ||
116 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xfixes.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xfixes.c new file mode 100644 index 0000000..bf9d5ee --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xfixes.c | |||
@@ -0,0 +1,750 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | # ifdef ECORE_XCB_XFIXES | ||
3 | # include <xcb/xfixes.h> | ||
4 | # endif | ||
5 | |||
6 | /* local function prototypes */ | ||
7 | static xcb_rectangle_t *_ecore_xcb_rect_to_xcb(Ecore_X_Rectangle *rects, | ||
8 | int num); | ||
9 | static Ecore_X_Rectangle *_ecore_xcb_rect_to_ecore(xcb_rectangle_t *rects, | ||
10 | int num); | ||
11 | |||
12 | /* local variables */ | ||
13 | static Eina_Bool _xfixes_avail = EINA_FALSE; | ||
14 | |||
15 | /* external variables */ | ||
16 | int _ecore_xcb_event_xfixes = -1; | ||
17 | |||
18 | void | ||
19 | _ecore_xcb_xfixes_init(void) | ||
20 | { | ||
21 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
22 | |||
23 | #ifdef ECORE_XCB_XFIXES | ||
24 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_xfixes_id); | ||
25 | #endif | ||
26 | } | ||
27 | |||
28 | void | ||
29 | _ecore_xcb_xfixes_finalize(void) | ||
30 | { | ||
31 | #ifdef ECORE_XCB_XFIXES | ||
32 | const xcb_query_extension_reply_t *ext_reply; | ||
33 | #endif | ||
34 | |||
35 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
36 | |||
37 | #ifdef ECORE_XCB_XFIXES | ||
38 | ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_xfixes_id); | ||
39 | if ((ext_reply) && (ext_reply->present)) | ||
40 | { | ||
41 | xcb_xfixes_query_version_cookie_t cookie; | ||
42 | xcb_xfixes_query_version_reply_t *reply; | ||
43 | |||
44 | cookie = | ||
45 | xcb_xfixes_query_version_unchecked(_ecore_xcb_conn, | ||
46 | XCB_XFIXES_MAJOR_VERSION, | ||
47 | XCB_XFIXES_MINOR_VERSION); | ||
48 | reply = xcb_xfixes_query_version_reply(_ecore_xcb_conn, cookie, NULL); | ||
49 | if (reply) | ||
50 | { | ||
51 | /* NB: XFixes Extension >= 3 needed for shape stuff. | ||
52 | * for now, I am removing this check so that it matches the | ||
53 | * xlib code closer. If the extension version ends up being | ||
54 | * that important, then re-enable this */ | ||
55 | |||
56 | /* if (reply->major_version >= 3) */ | ||
57 | _xfixes_avail = EINA_TRUE; | ||
58 | free(reply); | ||
59 | } | ||
60 | |||
61 | if (_xfixes_avail) | ||
62 | _ecore_xcb_event_xfixes = ext_reply->first_event; | ||
63 | } | ||
64 | #endif | ||
65 | } | ||
66 | |||
67 | EAPI Eina_Bool | ||
68 | ecore_x_fixes_selection_notification_request(Ecore_X_Atom selection) | ||
69 | { | ||
70 | #ifdef ECORE_XCB_XFIXES | ||
71 | Ecore_X_Window root = 0; | ||
72 | xcb_void_cookie_t cookie; | ||
73 | xcb_generic_error_t *err; | ||
74 | int mask = 0; | ||
75 | #endif | ||
76 | |||
77 | CHECK_XCB_CONN; | ||
78 | |||
79 | if (!_xfixes_avail) return EINA_FALSE; | ||
80 | |||
81 | #ifdef ECORE_XCB_XFIXES | ||
82 | root = ((xcb_screen_t *)_ecore_xcb_screen)->root; | ||
83 | |||
84 | mask = (XCB_XFIXES_SELECTION_EVENT_MASK_SET_SELECTION_OWNER | | ||
85 | XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_WINDOW_DESTROY | | ||
86 | XCB_XFIXES_SELECTION_EVENT_MASK_SELECTION_CLIENT_CLOSE); | ||
87 | |||
88 | cookie = | ||
89 | xcb_xfixes_select_selection_input_checked(_ecore_xcb_conn, root, | ||
90 | selection, mask); | ||
91 | err = xcb_request_check(_ecore_xcb_conn, cookie); | ||
92 | if (err) | ||
93 | { | ||
94 | free(err); | ||
95 | return EINA_FALSE; | ||
96 | } | ||
97 | |||
98 | return EINA_TRUE; | ||
99 | #endif | ||
100 | return EINA_FALSE; | ||
101 | } | ||
102 | |||
103 | Eina_Bool | ||
104 | _ecore_xcb_xfixes_avail_get(void) | ||
105 | { | ||
106 | return _xfixes_avail; | ||
107 | } | ||
108 | |||
109 | /** | ||
110 | * @defgroup Ecore_X_Fixes_Group X Fixes Extension Functions | ||
111 | * | ||
112 | * Functions related to the X Fixes extension. | ||
113 | */ | ||
114 | |||
115 | /** | ||
116 | * Create a region from rectangles. | ||
117 | * @param rects The rectangles used to initialize the region. | ||
118 | * @param num The number of rectangles. | ||
119 | * @return The newly created region. | ||
120 | * | ||
121 | * Create a region initialized to the specified list of rectangles | ||
122 | * @p rects. The rectangles may be specified in any order, their union | ||
123 | * becomes the region. | ||
124 | * @ingroup Ecore_X_Fixes_Group | ||
125 | */ | ||
126 | EAPI Ecore_X_Region | ||
127 | ecore_x_region_new(Ecore_X_Rectangle *rects, | ||
128 | int num) | ||
129 | { | ||
130 | Ecore_X_Region region = 0; | ||
131 | #ifdef ECORE_XCB_XFIXES | ||
132 | xcb_rectangle_t *xrects; | ||
133 | #endif | ||
134 | |||
135 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
136 | CHECK_XCB_CONN; | ||
137 | |||
138 | if (!_xfixes_avail) return 0; | ||
139 | |||
140 | #ifdef ECORE_XCB_XFIXES | ||
141 | xrects = _ecore_xcb_rect_to_xcb(rects, num); | ||
142 | region = xcb_generate_id(_ecore_xcb_conn); | ||
143 | xcb_xfixes_create_region(_ecore_xcb_conn, region, num, xrects); | ||
144 | free(xrects); | ||
145 | // ecore_x_flush(); | ||
146 | #endif | ||
147 | |||
148 | return region; | ||
149 | } | ||
150 | |||
151 | /** | ||
152 | * Create a region from a pixmap. | ||
153 | * @param bitmap The bitmap used to initialize the region. | ||
154 | * @return The newly created region. | ||
155 | * | ||
156 | * Creates a region initialized to the set of 'one' pixels in @p bitmap | ||
157 | * (which must be of depth 1, else Match error). | ||
158 | * @ingroup Ecore_X_Fixes_Group | ||
159 | */ | ||
160 | EAPI Ecore_X_Region | ||
161 | ecore_x_region_new_from_bitmap(Ecore_X_Pixmap bitmap) | ||
162 | { | ||
163 | Ecore_X_Region region = 0; | ||
164 | |||
165 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
166 | CHECK_XCB_CONN; | ||
167 | |||
168 | if (!_xfixes_avail) return 0; | ||
169 | |||
170 | #ifdef ECORE_XCB_XFIXES | ||
171 | region = xcb_generate_id(_ecore_xcb_conn); | ||
172 | xcb_xfixes_create_region_from_bitmap(_ecore_xcb_conn, region, bitmap); | ||
173 | // ecore_x_flush(); | ||
174 | #endif | ||
175 | |||
176 | return region; | ||
177 | } | ||
178 | |||
179 | /** | ||
180 | * Create a region from a window. | ||
181 | * @param window The window used to initialize the region. | ||
182 | * @param type The type of the region. | ||
183 | * @return The newly created region. | ||
184 | * | ||
185 | * Creates a region initialized to the specified @p window region. See | ||
186 | * the Shape extension for the definition of Bounding and Clip | ||
187 | * regions. | ||
188 | * @ingroup Ecore_X_Fixes_Group | ||
189 | */ | ||
190 | EAPI Ecore_X_Region | ||
191 | ecore_x_region_new_from_window(Ecore_X_Window win, | ||
192 | Ecore_X_Region_Type type) | ||
193 | { | ||
194 | Ecore_X_Region region = 0; | ||
195 | |||
196 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
197 | CHECK_XCB_CONN; | ||
198 | |||
199 | if (!_xfixes_avail) return 0; | ||
200 | |||
201 | #ifdef ECORE_XCB_XFIXES | ||
202 | region = xcb_generate_id(_ecore_xcb_conn); | ||
203 | xcb_xfixes_create_region_from_window(_ecore_xcb_conn, region, win, type); | ||
204 | // ecore_x_flush(); | ||
205 | #endif | ||
206 | |||
207 | return region; | ||
208 | } | ||
209 | |||
210 | /** | ||
211 | * Create a region from a graphic context. | ||
212 | * @param gc The graphic context used to initialize the region. | ||
213 | * @return The newly created region. | ||
214 | * | ||
215 | * Creates a region initialized from the clip list of @p gc. | ||
216 | * @ingroup Ecore_X_Fixes_Group | ||
217 | */ | ||
218 | EAPI Ecore_X_Region | ||
219 | ecore_x_region_new_from_gc(Ecore_X_GC gc) | ||
220 | { | ||
221 | Ecore_X_Region region = 0; | ||
222 | |||
223 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
224 | CHECK_XCB_CONN; | ||
225 | |||
226 | if (!_xfixes_avail) return 0; | ||
227 | |||
228 | #ifdef ECORE_XCB_XFIXES | ||
229 | region = xcb_generate_id(_ecore_xcb_conn); | ||
230 | xcb_xfixes_create_region_from_gc(_ecore_xcb_conn, region, gc); | ||
231 | // ecore_x_flush(); | ||
232 | #endif | ||
233 | |||
234 | return region; | ||
235 | } | ||
236 | |||
237 | /** | ||
238 | * Create a region from a picture. | ||
239 | * @param picture The picture used to initialize the region. | ||
240 | * @return The newly created region. | ||
241 | * | ||
242 | * Creates a region initialized from the clip list of @p picture. | ||
243 | * @ingroup Ecore_X_Fixes_Group | ||
244 | */ | ||
245 | EAPI Ecore_X_Region | ||
246 | ecore_x_region_new_from_picture(Ecore_X_Picture picture) | ||
247 | { | ||
248 | Ecore_X_Region region = 0; | ||
249 | |||
250 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
251 | CHECK_XCB_CONN; | ||
252 | |||
253 | if (!_xfixes_avail) return 0; | ||
254 | |||
255 | #ifdef ECORE_XCB_XFIXES | ||
256 | region = xcb_generate_id(_ecore_xcb_conn); | ||
257 | xcb_xfixes_create_region_from_picture(_ecore_xcb_conn, region, picture); | ||
258 | // ecore_x_flush(); | ||
259 | #endif | ||
260 | |||
261 | return region; | ||
262 | } | ||
263 | |||
264 | /** | ||
265 | * Destroy a region. | ||
266 | * @param region The region to destroy. | ||
267 | * | ||
268 | * Destroy the specified @p region. | ||
269 | * @ingroup Ecore_X_Fixes_Group | ||
270 | */ | ||
271 | EAPI void | ||
272 | ecore_x_region_free(Ecore_X_Region region) | ||
273 | { | ||
274 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
275 | CHECK_XCB_CONN; | ||
276 | |||
277 | if (!_xfixes_avail) return; | ||
278 | |||
279 | #ifdef ECORE_XCB_XFIXES | ||
280 | xcb_xfixes_destroy_region(_ecore_xcb_conn, region); | ||
281 | // ecore_x_flush(); | ||
282 | #endif | ||
283 | } | ||
284 | |||
285 | /** | ||
286 | * Set the content of a region. | ||
287 | * @param region The region to destroy. | ||
288 | * @param rects The rectangles used to set the region. | ||
289 | * @param num The number of rectangles. | ||
290 | * | ||
291 | * Replace the current contents of @p region with the region formed | ||
292 | * by the union of the rectangles @p rects. | ||
293 | * @ingroup Ecore_X_Fixes_Group | ||
294 | */ | ||
295 | EAPI void | ||
296 | ecore_x_region_set(Ecore_X_Region region, | ||
297 | Ecore_X_Rectangle *rects, | ||
298 | int num) | ||
299 | { | ||
300 | #ifdef ECORE_XCB_XFIXES | ||
301 | xcb_rectangle_t *xrects; | ||
302 | #endif | ||
303 | |||
304 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
305 | CHECK_XCB_CONN; | ||
306 | |||
307 | if (!_xfixes_avail) return; | ||
308 | |||
309 | #ifdef ECORE_XCB_XFIXES | ||
310 | xrects = _ecore_xcb_rect_to_xcb(rects, num); | ||
311 | xcb_xfixes_set_region(_ecore_xcb_conn, region, num, xrects); | ||
312 | free(xrects); | ||
313 | // ecore_x_flush(); | ||
314 | #endif | ||
315 | } | ||
316 | |||
317 | /** | ||
318 | * Copy the content of a region. | ||
319 | * @param dest The destination region. | ||
320 | * @param source The source region. | ||
321 | * | ||
322 | * Replace the contents of @p dest with the contents of @p source. | ||
323 | * @ingroup Ecore_X_Fixes_Group | ||
324 | */ | ||
325 | EAPI void | ||
326 | ecore_x_region_copy(Ecore_X_Region dest, | ||
327 | Ecore_X_Region source) | ||
328 | { | ||
329 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
330 | CHECK_XCB_CONN; | ||
331 | |||
332 | if (!_xfixes_avail) return; | ||
333 | |||
334 | // NB: Hmmmm...this may need converting to/fro xcb_rectangle_t | ||
335 | #ifdef ECORE_XCB_XFIXES | ||
336 | xcb_xfixes_copy_region(_ecore_xcb_conn, source, dest); | ||
337 | // ecore_x_flush(); | ||
338 | #endif | ||
339 | } | ||
340 | |||
341 | /** | ||
342 | * Make the union of two regions. | ||
343 | * @param dest The destination region. | ||
344 | * @param source1 The first source region. | ||
345 | * @param source2 The second source region. | ||
346 | * | ||
347 | * Replace the contents of @p dest with the union of @p source1 and | ||
348 | * @p source2. | ||
349 | * @ingroup Ecore_X_Fixes_Group | ||
350 | */ | ||
351 | EAPI void | ||
352 | ecore_x_region_combine(Ecore_X_Region dest, | ||
353 | Ecore_X_Region source1, | ||
354 | Ecore_X_Region source2) | ||
355 | { | ||
356 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
357 | CHECK_XCB_CONN; | ||
358 | |||
359 | if (!_xfixes_avail) return; | ||
360 | |||
361 | #ifdef ECORE_XCB_XFIXES | ||
362 | xcb_xfixes_union_region(_ecore_xcb_conn, source1, source2, dest); | ||
363 | // ecore_x_flush(); | ||
364 | #endif | ||
365 | } | ||
366 | |||
367 | /** | ||
368 | * Make the intersection of two regions. | ||
369 | * @param dest The destination region. | ||
370 | * @param source1 The first source region. | ||
371 | * @param source2 The second source region. | ||
372 | * | ||
373 | * Replace the contents of @p dest with the intersection of @p source1 and | ||
374 | * @p source2. | ||
375 | * @ingroup Ecore_X_Fixes_Group | ||
376 | */ | ||
377 | EAPI void | ||
378 | ecore_x_region_intersect(Ecore_X_Region dest, | ||
379 | Ecore_X_Region source1, | ||
380 | Ecore_X_Region source2) | ||
381 | { | ||
382 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
383 | CHECK_XCB_CONN; | ||
384 | |||
385 | if (!_xfixes_avail) return; | ||
386 | |||
387 | #ifdef ECORE_XCB_XFIXES | ||
388 | xcb_xfixes_intersect_region(_ecore_xcb_conn, source1, source2, dest); | ||
389 | // ecore_x_flush(); | ||
390 | #endif | ||
391 | } | ||
392 | |||
393 | /** | ||
394 | * Make the subtraction of two regions. | ||
395 | * @param dest The destination region. | ||
396 | * @param source1 The first source region. | ||
397 | * @param source2 The second source region. | ||
398 | * | ||
399 | * Replace the contents of @p dest with the subtraction of @p source1 by | ||
400 | * @p source2. | ||
401 | * @ingroup Ecore_X_Fixes_Group | ||
402 | */ | ||
403 | EAPI void | ||
404 | ecore_x_region_subtract(Ecore_X_Region dest, | ||
405 | Ecore_X_Region source1, | ||
406 | Ecore_X_Region source2) | ||
407 | { | ||
408 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
409 | CHECK_XCB_CONN; | ||
410 | |||
411 | if (!_xfixes_avail) return; | ||
412 | |||
413 | #ifdef ECORE_XCB_XFIXES | ||
414 | xcb_xfixes_subtract_region(_ecore_xcb_conn, source1, source2, dest); | ||
415 | // ecore_x_flush(); | ||
416 | #endif | ||
417 | } | ||
418 | |||
419 | /** | ||
420 | * Make the subtraction of regions by bounds. | ||
421 | * @param dest The destination region. | ||
422 | * @param bounds The bounds. | ||
423 | * @param source The source region. | ||
424 | * | ||
425 | * The @p source region is subtracted from the region specified by | ||
426 | * @p bounds. The result is placed in @p dest, replacing its | ||
427 | * contents. | ||
428 | * @ingroup Ecore_X_Fixes_Group | ||
429 | */ | ||
430 | EAPI void | ||
431 | ecore_x_region_invert(Ecore_X_Region dest, | ||
432 | Ecore_X_Rectangle *bounds, | ||
433 | Ecore_X_Region source) | ||
434 | { | ||
435 | #ifdef ECORE_XCB_XFIXES | ||
436 | xcb_rectangle_t xrects; | ||
437 | #endif | ||
438 | |||
439 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
440 | CHECK_XCB_CONN; | ||
441 | |||
442 | if (!_xfixes_avail) return; | ||
443 | |||
444 | #ifdef ECORE_XCB_XFIXES | ||
445 | xrects.x = bounds->x; | ||
446 | xrects.y = bounds->y; | ||
447 | xrects.width = bounds->width; | ||
448 | xrects.height = bounds->height; | ||
449 | |||
450 | xcb_xfixes_invert_region(_ecore_xcb_conn, source, xrects, dest); | ||
451 | // ecore_x_flush(); | ||
452 | #endif | ||
453 | } | ||
454 | |||
455 | /** | ||
456 | * Translate a region. | ||
457 | * @param region The region to translate. | ||
458 | * @param dx The horizontal translation. | ||
459 | * @param dy The vertical translation. | ||
460 | * | ||
461 | * The @p region is translated by @p dx and @p dy in place. | ||
462 | * @ingroup Ecore_X_Fixes_Group | ||
463 | */ | ||
464 | EAPI void | ||
465 | ecore_x_region_translate(Ecore_X_Region region, | ||
466 | int dx, | ||
467 | int dy) | ||
468 | { | ||
469 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
470 | CHECK_XCB_CONN; | ||
471 | |||
472 | if (!_xfixes_avail) return; | ||
473 | |||
474 | #ifdef ECORE_XCB_XFIXES | ||
475 | xcb_xfixes_translate_region(_ecore_xcb_conn, region, dx, dy); | ||
476 | // ecore_x_flush(); | ||
477 | #endif | ||
478 | } | ||
479 | |||
480 | /** | ||
481 | * Extent a region. | ||
482 | * @param dest The destination region. | ||
483 | * @param source The source region. | ||
484 | * | ||
485 | * The extents of the @p source region are placed in @p dest. | ||
486 | * @ingroup Ecore_X_Fixes_Group | ||
487 | */ | ||
488 | EAPI void | ||
489 | ecore_x_region_extents(Ecore_X_Region dest, | ||
490 | Ecore_X_Region source) | ||
491 | { | ||
492 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
493 | CHECK_XCB_CONN; | ||
494 | |||
495 | if (!_xfixes_avail) return; | ||
496 | |||
497 | #ifdef ECORE_XCB_XFIXES | ||
498 | xcb_xfixes_region_extents(_ecore_xcb_conn, source, dest); | ||
499 | // ecore_x_flush(); | ||
500 | #endif | ||
501 | } | ||
502 | |||
503 | /** | ||
504 | * Return the rectangles that compose a region. | ||
505 | * @param region The region (Unused). | ||
506 | * @param num The number of returned rectangles. | ||
507 | * @param bounds The returned bounds of the region. | ||
508 | * @return The returned rectangles. | ||
509 | * | ||
510 | * The @p region passed to ecore_xcb_region_fetch_prefetch() is | ||
511 | * returned as a list of rectagles in XY-banded order. | ||
512 | * | ||
513 | * To use this function, you must call before, and in order, | ||
514 | * ecore_xcb_region_fetch_prefetch(), which sends the XFixesFetchRegion request, | ||
515 | * then ecore_xcb_region_fetch_fetch(), which gets the reply. | ||
516 | * @ingroup Ecore_X_Fixes_Group | ||
517 | */ | ||
518 | EAPI Ecore_X_Rectangle * | ||
519 | ecore_x_region_fetch(Ecore_X_Region region, | ||
520 | int *num, | ||
521 | Ecore_X_Rectangle *bounds) | ||
522 | { | ||
523 | Ecore_X_Rectangle extents = { 0, 0, 0, 0 }; | ||
524 | Ecore_X_Rectangle *rects = NULL; | ||
525 | #ifdef ECORE_XCB_XFIXES | ||
526 | xcb_xfixes_fetch_region_cookie_t cookie; | ||
527 | xcb_xfixes_fetch_region_reply_t *reply; | ||
528 | xcb_rectangle_t *r; | ||
529 | int n = 0; | ||
530 | #endif | ||
531 | |||
532 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
533 | CHECK_XCB_CONN; | ||
534 | |||
535 | if (num) *num = 0; | ||
536 | if (bounds) *bounds = extents; | ||
537 | if (!_xfixes_avail) return NULL; | ||
538 | |||
539 | #ifdef ECORE_XCB_XFIXES | ||
540 | cookie = xcb_xfixes_fetch_region_unchecked(_ecore_xcb_conn, region); | ||
541 | reply = xcb_xfixes_fetch_region_reply(_ecore_xcb_conn, cookie, NULL); | ||
542 | if (!reply) return NULL; | ||
543 | |||
544 | r = xcb_xfixes_fetch_region_rectangles(reply); | ||
545 | n = xcb_xfixes_fetch_region_rectangles_length(reply); | ||
546 | rects = _ecore_xcb_rect_to_ecore(r, n); | ||
547 | if (num) *num = n; | ||
548 | |||
549 | /* rects = (Ecore_X_Rectangle *)malloc(n * sizeof(Ecore_X_Rectangle)); */ | ||
550 | /* if (!rects) */ | ||
551 | /* { */ | ||
552 | /* free(reply); */ | ||
553 | /* return NULL; */ | ||
554 | /* } */ | ||
555 | |||
556 | /* for (i = 0; i < n; i++) */ | ||
557 | /* { */ | ||
558 | /* rects[i].x = r[i].x; */ | ||
559 | /* rects[i].y = r[i].y; */ | ||
560 | /* rects[i].width = r[i].width; */ | ||
561 | /* rects[i].height = r[i].height; */ | ||
562 | /* } */ | ||
563 | |||
564 | (*bounds).x = reply->extents.x; | ||
565 | (*bounds).y = reply->extents.y; | ||
566 | (*bounds).width = reply->extents.width; | ||
567 | (*bounds).height = reply->extents.height; | ||
568 | |||
569 | free(reply); | ||
570 | #endif | ||
571 | |||
572 | return rects; | ||
573 | } | ||
574 | |||
575 | /** | ||
576 | * Expand a region. | ||
577 | * @param dest The destination region. | ||
578 | * @param source The source region. | ||
579 | * @param left The number of pixels to add on the left. | ||
580 | * @param right The number of pixels to add on the right. | ||
581 | * @param top The number of pixels to add at the top. | ||
582 | * @param bottom The number of pixels to add at the bottom. | ||
583 | * | ||
584 | * Put in @p dest the area specified by expanding each rectangle in | ||
585 | * the @p source region by the specified number of pixels to the | ||
586 | * @p left, @p right, @p top and @p bottom. | ||
587 | * @ingroup Ecore_X_Fixes_Group | ||
588 | */ | ||
589 | EAPI void | ||
590 | ecore_x_region_expand(Ecore_X_Region dest, | ||
591 | Ecore_X_Region source, | ||
592 | unsigned int left, | ||
593 | unsigned int right, | ||
594 | unsigned int top, | ||
595 | unsigned int bottom) | ||
596 | { | ||
597 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
598 | CHECK_XCB_CONN; | ||
599 | |||
600 | if (!_xfixes_avail) return; | ||
601 | |||
602 | #ifdef ECORE_XCB_XFIXES | ||
603 | xcb_xfixes_expand_region(_ecore_xcb_conn, source, dest, left, right, top, bottom); | ||
604 | // ecore_x_flush(); | ||
605 | #endif | ||
606 | } | ||
607 | |||
608 | /** | ||
609 | * Change clip-mask in a graphic context to the specified region. | ||
610 | * @param region The region to change. | ||
611 | * @param gc The clip-mask graphic context. | ||
612 | * @param x_origin The horizontal translation. | ||
613 | * @param y_origin The vertical translation. | ||
614 | * | ||
615 | * Changes clip-mask in @p gc to the specified @p region and | ||
616 | * sets the clip origin with the values of @p x_origin and @p y_origin. | ||
617 | * Output will be clippped to remain contained within the region. The | ||
618 | * clip origin is interpreted relative to the origin of whatever | ||
619 | * destination drawable is specified in a graphics request. The | ||
620 | * region is interpreted relative to the clip origin. Future changes | ||
621 | * to region have no effect on the gc clip-mask. | ||
622 | * @ingroup Ecore_X_Fixes_Group | ||
623 | */ | ||
624 | EAPI void | ||
625 | ecore_x_region_gc_clip_set(Ecore_X_Region region, | ||
626 | Ecore_X_GC gc, | ||
627 | int x, | ||
628 | int y) | ||
629 | { | ||
630 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
631 | CHECK_XCB_CONN; | ||
632 | |||
633 | if (!_xfixes_avail) return; | ||
634 | |||
635 | #ifdef ECORE_XCB_XFIXES | ||
636 | xcb_xfixes_set_gc_clip_region(_ecore_xcb_conn, gc, region, x, y); | ||
637 | // ecore_x_flush(); | ||
638 | #endif | ||
639 | } | ||
640 | |||
641 | /** | ||
642 | * Change the shape extension of a window. | ||
643 | * @param region The region. | ||
644 | * @param dest The window whose shape is changed. | ||
645 | * @param type The kind of shape. | ||
646 | * @param x_offset The horizontal offset. | ||
647 | * @param y_offset The vertical offset. | ||
648 | * | ||
649 | * Set the specified Shape extension region of @p window to @p region, | ||
650 | * offset by @p x_offset and @p y_offset. Future changes to region | ||
651 | * have no effect on the window shape. | ||
652 | * @ingroup Ecore_X_Fixes_Group | ||
653 | */ | ||
654 | EAPI void | ||
655 | ecore_x_region_window_shape_set(Ecore_X_Region region, | ||
656 | Ecore_X_Window dest, | ||
657 | Ecore_X_Shape_Type type, | ||
658 | int x, | ||
659 | int y) | ||
660 | { | ||
661 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
662 | CHECK_XCB_CONN; | ||
663 | |||
664 | if (!_xfixes_avail) return; | ||
665 | |||
666 | #ifdef ECORE_XCB_XFIXES | ||
667 | xcb_xfixes_set_window_shape_region(_ecore_xcb_conn, dest, type, x, y, region); | ||
668 | // ecore_x_flush(); | ||
669 | #endif | ||
670 | } | ||
671 | |||
672 | /** | ||
673 | * Change clip-mask in picture to the specified region. | ||
674 | * @param region The region. | ||
675 | * @param picture The picture. | ||
676 | * @param x_origin The X coordinate of the origin. | ||
677 | * @param y_origin The Y coordinate of the origin. | ||
678 | * | ||
679 | * Changes clip-mask in picture to the specified @p region | ||
680 | * and sets the clip origin. Input and output will be clipped to | ||
681 | * remain contained within the region. The clip origin is interpreted | ||
682 | * relative to the origin of the drawable associated with @p picture. The | ||
683 | * region is interpreted relative to the clip origin. Future changes | ||
684 | * to region have no effect on the picture clip-mask. | ||
685 | * @ingroup Ecore_X_Fixes_Group | ||
686 | */ | ||
687 | EAPI void | ||
688 | ecore_x_region_picture_clip_set(Ecore_X_Region region, | ||
689 | Ecore_X_Picture picture, | ||
690 | int x, | ||
691 | int y) | ||
692 | { | ||
693 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
694 | CHECK_XCB_CONN; | ||
695 | |||
696 | if (!_xfixes_avail) return; | ||
697 | |||
698 | #ifdef ECORE_XCB_XFIXES | ||
699 | xcb_xfixes_set_picture_clip_region(_ecore_xcb_conn, picture, region, x, y); | ||
700 | // ecore_x_flush(); | ||
701 | #endif | ||
702 | } | ||
703 | |||
704 | /* local function prototypes */ | ||
705 | static xcb_rectangle_t * | ||
706 | _ecore_xcb_rect_to_xcb(Ecore_X_Rectangle *rects, | ||
707 | int num) | ||
708 | { | ||
709 | xcb_rectangle_t *xrect; | ||
710 | int i = 0; | ||
711 | |||
712 | if (!num) return NULL; | ||
713 | |||
714 | xrect = malloc(sizeof(xcb_rectangle_t) * num); | ||
715 | if (!xrect) return NULL; | ||
716 | |||
717 | for (i = 0; i < num; i++) | ||
718 | { | ||
719 | xrect[i].x = rects[i].x; | ||
720 | xrect[i].y = rects[i].y; | ||
721 | xrect[i].width = rects[i].width; | ||
722 | xrect[i].height = rects[i].height; | ||
723 | } | ||
724 | |||
725 | return xrect; | ||
726 | } | ||
727 | |||
728 | static Ecore_X_Rectangle * | ||
729 | _ecore_xcb_rect_to_ecore(xcb_rectangle_t *rects, | ||
730 | int num) | ||
731 | { | ||
732 | Ecore_X_Rectangle *erect; | ||
733 | int i = 0; | ||
734 | |||
735 | if (!num) return NULL; | ||
736 | |||
737 | erect = malloc(sizeof(Ecore_X_Rectangle) * num); | ||
738 | if (!erect) return NULL; | ||
739 | |||
740 | for (i = 0; i < num; i++) | ||
741 | { | ||
742 | erect[i].x = rects[i].x; | ||
743 | erect[i].y = rects[i].y; | ||
744 | erect[i].width = rects[i].width; | ||
745 | erect[i].height = rects[i].height; | ||
746 | } | ||
747 | |||
748 | return erect; | ||
749 | } | ||
750 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xinerama.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xinerama.c new file mode 100644 index 0000000..37a2339 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xinerama.c | |||
@@ -0,0 +1,139 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #ifdef ECORE_XCB_XINERAMA | ||
3 | # include <xcb/xinerama.h> | ||
4 | #endif | ||
5 | |||
6 | /* local variables */ | ||
7 | static Eina_Bool _xinerama_avail = EINA_FALSE; | ||
8 | static Eina_Bool _xinerama_active = EINA_FALSE; | ||
9 | |||
10 | void | ||
11 | _ecore_xcb_xinerama_init(void) | ||
12 | { | ||
13 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
14 | |||
15 | #ifdef ECORE_XCB_XINERAMA | ||
16 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_xinerama_id); | ||
17 | #endif | ||
18 | } | ||
19 | |||
20 | void | ||
21 | _ecore_xcb_xinerama_finalize(void) | ||
22 | { | ||
23 | #ifdef ECORE_XCB_XINERAMA | ||
24 | const xcb_query_extension_reply_t *ext_reply; | ||
25 | #endif | ||
26 | |||
27 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
28 | |||
29 | #ifdef ECORE_XCB_XINERAMA | ||
30 | ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_xinerama_id); | ||
31 | if ((ext_reply) && (ext_reply->present)) | ||
32 | { | ||
33 | xcb_xinerama_query_version_cookie_t cookie; | ||
34 | xcb_xinerama_query_version_reply_t *reply; | ||
35 | |||
36 | cookie = | ||
37 | xcb_xinerama_query_version_unchecked(_ecore_xcb_conn, | ||
38 | XCB_XINERAMA_MAJOR_VERSION, | ||
39 | XCB_XINERAMA_MINOR_VERSION); | ||
40 | reply = | ||
41 | xcb_xinerama_query_version_reply(_ecore_xcb_conn, cookie, NULL); | ||
42 | if (reply) | ||
43 | { | ||
44 | _xinerama_avail = EINA_TRUE; | ||
45 | // NB: Do we need to compare version numbers here ? | ||
46 | free(reply); | ||
47 | } | ||
48 | |||
49 | if (_xinerama_avail) | ||
50 | { | ||
51 | xcb_xinerama_is_active_cookie_t acookie; | ||
52 | xcb_xinerama_is_active_reply_t *areply; | ||
53 | |||
54 | acookie = xcb_xinerama_is_active_unchecked(_ecore_xcb_conn); | ||
55 | areply = | ||
56 | xcb_xinerama_is_active_reply(_ecore_xcb_conn, acookie, NULL); | ||
57 | if (areply) | ||
58 | { | ||
59 | _xinerama_active = areply->state; | ||
60 | free(areply); | ||
61 | } | ||
62 | } | ||
63 | } | ||
64 | #endif | ||
65 | } | ||
66 | |||
67 | EAPI int | ||
68 | ecore_x_xinerama_screen_count_get(void) | ||
69 | { | ||
70 | int count = 0; | ||
71 | #ifdef ECORE_XCB_XINERAMA | ||
72 | xcb_xinerama_query_screens_cookie_t cookie; | ||
73 | xcb_xinerama_query_screens_reply_t *reply; | ||
74 | #endif | ||
75 | |||
76 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
77 | CHECK_XCB_CONN; | ||
78 | |||
79 | if (!_xinerama_avail) return 0; | ||
80 | |||
81 | #ifdef ECORE_XCB_XINERAMA | ||
82 | cookie = xcb_xinerama_query_screens_unchecked(_ecore_xcb_conn); | ||
83 | reply = | ||
84 | xcb_xinerama_query_screens_reply(_ecore_xcb_conn, cookie, NULL); | ||
85 | if (!reply) return 0; | ||
86 | count = reply->number; | ||
87 | #endif | ||
88 | |||
89 | return count; | ||
90 | } | ||
91 | |||
92 | EAPI Eina_Bool | ||
93 | ecore_x_xinerama_screen_geometry_get(int screen, | ||
94 | int *x, | ||
95 | int *y, | ||
96 | int *w, | ||
97 | int *h) | ||
98 | { | ||
99 | #ifdef ECORE_XCB_XINERAMA | ||
100 | xcb_xinerama_query_screens_cookie_t cookie; | ||
101 | xcb_xinerama_query_screens_reply_t *reply; | ||
102 | xcb_xinerama_screen_info_t *info; | ||
103 | #endif | ||
104 | |||
105 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
106 | CHECK_XCB_CONN; | ||
107 | |||
108 | if (x) *x = 0; | ||
109 | if (y) *y = 0; | ||
110 | if (w) *w = ((xcb_screen_t *)_ecore_xcb_screen)->width_in_pixels; | ||
111 | if (h) *h = ((xcb_screen_t *)_ecore_xcb_screen)->height_in_pixels; | ||
112 | |||
113 | if (!_xinerama_avail) return EINA_FALSE; | ||
114 | |||
115 | #ifdef ECORE_XCB_XINERAMA | ||
116 | cookie = xcb_xinerama_query_screens_unchecked(_ecore_xcb_conn); | ||
117 | reply = | ||
118 | xcb_xinerama_query_screens_reply(_ecore_xcb_conn, cookie, NULL); | ||
119 | if (!reply) return EINA_FALSE; | ||
120 | |||
121 | info = xcb_xinerama_query_screens_screen_info(reply); | ||
122 | if (!info) | ||
123 | { | ||
124 | free(reply); | ||
125 | return EINA_FALSE; | ||
126 | } | ||
127 | |||
128 | if (x) *x = info[screen].x_org; | ||
129 | if (y) *y = info[screen].y_org; | ||
130 | if (w) *w = info[screen].width; | ||
131 | if (h) *h = info[screen].height; | ||
132 | |||
133 | free(reply); | ||
134 | return EINA_TRUE; | ||
135 | #endif | ||
136 | |||
137 | return EINA_FALSE; | ||
138 | } | ||
139 | |||
diff --git a/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xtest.c b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xtest.c new file mode 100644 index 0000000..b664dc9 --- /dev/null +++ b/libraries/ecore/src/lib/ecore_x/xcb/ecore_xcb_xtest.c | |||
@@ -0,0 +1,215 @@ | |||
1 | #include "ecore_xcb_private.h" | ||
2 | #ifdef ECORE_XCB_XTEST | ||
3 | # include <xcb/xtest.h> | ||
4 | # include <X11/keysym.h> | ||
5 | #endif | ||
6 | |||
7 | /* local variables */ | ||
8 | static Eina_Bool _test_avail = EINA_FALSE; | ||
9 | |||
10 | void | ||
11 | _ecore_xcb_xtest_init(void) | ||
12 | { | ||
13 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
14 | |||
15 | #ifdef ECORE_XCB_XTEST | ||
16 | xcb_prefetch_extension_data(_ecore_xcb_conn, &xcb_test_id); | ||
17 | #endif | ||
18 | } | ||
19 | |||
20 | void | ||
21 | _ecore_xcb_xtest_finalize(void) | ||
22 | { | ||
23 | #ifdef ECORE_XCB_XTEST | ||
24 | const xcb_query_extension_reply_t *ext_reply; | ||
25 | #endif | ||
26 | |||
27 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
28 | |||
29 | #ifdef ECORE_XCB_XTEST | ||
30 | ext_reply = xcb_get_extension_data(_ecore_xcb_conn, &xcb_test_id); | ||
31 | if ((ext_reply) && (ext_reply->present)) | ||
32 | _test_avail = EINA_TRUE; | ||
33 | #endif | ||
34 | } | ||
35 | |||
36 | EAPI Eina_Bool | ||
37 | #ifdef ECORE_XCB_XTEST | ||
38 | ecore_x_test_fake_key_down(const char *key) | ||
39 | #else | ||
40 | ecore_x_test_fake_key_down(const char *key __UNUSED__) | ||
41 | #endif | ||
42 | { | ||
43 | #ifdef ECORE_XCB_XTEST | ||
44 | xcb_keycode_t keycode = 0; | ||
45 | xcb_void_cookie_t cookie; | ||
46 | xcb_generic_error_t *err; | ||
47 | #endif | ||
48 | |||
49 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
50 | CHECK_XCB_CONN; | ||
51 | |||
52 | if (!_test_avail) return EINA_FALSE; | ||
53 | |||
54 | #ifdef ECORE_XCB_XTEST | ||
55 | keycode = _ecore_xcb_keymap_string_to_keycode(key); | ||
56 | if (keycode == XCB_NO_SYMBOL) return EINA_FALSE; | ||
57 | |||
58 | cookie = | ||
59 | xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_PRESS, | ||
60 | keycode, XCB_CURRENT_TIME, | ||
61 | ((xcb_screen_t *)_ecore_xcb_screen)->root, 0, 0, 0); | ||
62 | err = xcb_request_check(_ecore_xcb_conn, cookie); | ||
63 | if (err) | ||
64 | { | ||
65 | free(err); | ||
66 | return EINA_FALSE; | ||
67 | } | ||
68 | return EINA_TRUE; | ||
69 | #endif | ||
70 | |||
71 | return EINA_FALSE; | ||
72 | } | ||
73 | |||
74 | EAPI Eina_Bool | ||
75 | #ifdef ECORE_XCB_XTEST | ||
76 | ecore_x_test_fake_key_up(const char *key) | ||
77 | #else | ||
78 | ecore_x_test_fake_key_up(const char *key __UNUSED__) | ||
79 | #endif | ||
80 | { | ||
81 | #ifdef ECORE_XCB_XTEST | ||
82 | xcb_keycode_t keycode = 0; | ||
83 | xcb_void_cookie_t cookie; | ||
84 | xcb_generic_error_t *err; | ||
85 | #endif | ||
86 | |||
87 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
88 | CHECK_XCB_CONN; | ||
89 | |||
90 | if (!_test_avail) return EINA_FALSE; | ||
91 | |||
92 | #ifdef ECORE_XCB_XTEST | ||
93 | keycode = _ecore_xcb_keymap_string_to_keycode(key); | ||
94 | if (keycode == XCB_NO_SYMBOL) return EINA_FALSE; | ||
95 | |||
96 | cookie = | ||
97 | xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_RELEASE, | ||
98 | keycode, XCB_CURRENT_TIME, | ||
99 | ((xcb_screen_t *)_ecore_xcb_screen)->root, 0, 0, 0); | ||
100 | err = xcb_request_check(_ecore_xcb_conn, cookie); | ||
101 | if (err) | ||
102 | { | ||
103 | free(err); | ||
104 | return EINA_FALSE; | ||
105 | } | ||
106 | return EINA_TRUE; | ||
107 | #endif | ||
108 | |||
109 | return EINA_FALSE; | ||
110 | } | ||
111 | |||
112 | EAPI Eina_Bool | ||
113 | #ifdef ECORE_XCB_XTEST | ||
114 | ecore_x_test_fake_key_press(const char *key) | ||
115 | #else | ||
116 | ecore_x_test_fake_key_press(const char *key __UNUSED__) | ||
117 | #endif | ||
118 | { | ||
119 | #ifdef ECORE_XCB_XTEST | ||
120 | xcb_keycode_t keycode = 0; | ||
121 | xcb_keysym_t keysym = 0; | ||
122 | xcb_keycode_t shift_code = 0; | ||
123 | xcb_void_cookie_t cookie; | ||
124 | xcb_generic_error_t *err; | ||
125 | Eina_Bool shift = EINA_FALSE; | ||
126 | #endif | ||
127 | |||
128 | LOGFN(__FILE__, __LINE__, __FUNCTION__); | ||
129 | CHECK_XCB_CONN; | ||
130 | |||
131 | if (!_test_avail) return EINA_FALSE; | ||
132 | |||
133 | #ifdef ECORE_XCB_XTEST | ||
134 | keycode = _ecore_xcb_keymap_string_to_keycode(key); | ||
135 | keysym = _ecore_xcb_keymap_keycode_to_keysym(keycode, 0); | ||
136 | if (keysym == XCB_NO_SYMBOL) | ||
137 | { | ||
138 | keysym = _ecore_xcb_keymap_keycode_to_keysym(keycode, 1); | ||
139 | if (keysym != XCB_NO_SYMBOL) | ||
140 | shift = EINA_TRUE; | ||
141 | } | ||
142 | |||
143 | if (shift) | ||
144 | { | ||
145 | xcb_keycode_t *keycodes; | ||
146 | int i = 0; | ||
147 | |||
148 | keycodes = _ecore_xcb_keymap_keysym_to_keycode(XK_Shift_L); | ||
149 | while (keycodes[i] != XCB_NO_SYMBOL) | ||
150 | { | ||
151 | if (keycodes[i] != 0) | ||
152 | { | ||
153 | shift_code = keycodes[i]; | ||
154 | break; | ||
155 | } | ||
156 | i++; | ||
157 | } | ||
158 | } | ||
159 | |||
160 | if (shift) | ||
161 | { | ||
162 | cookie = | ||
163 | xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_PRESS, | ||
164 | shift_code, XCB_CURRENT_TIME, | ||
165 | ((xcb_screen_t *)_ecore_xcb_screen)->root, | ||
166 | 0, 0, 0); | ||
167 | err = xcb_request_check(_ecore_xcb_conn, cookie); | ||
168 | if (err) | ||
169 | { | ||
170 | free(err); | ||
171 | return EINA_FALSE; | ||
172 | } | ||
173 | } | ||
174 | |||
175 | cookie = | ||
176 | xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_PRESS, | ||
177 | keycode, XCB_CURRENT_TIME, | ||
178 | ((xcb_screen_t *)_ecore_xcb_screen)->root, 0, 0, 0); | ||
179 | err = xcb_request_check(_ecore_xcb_conn, cookie); | ||
180 | if (err) | ||
181 | { | ||
182 | free(err); | ||
183 | return EINA_FALSE; | ||
184 | } | ||
185 | cookie = | ||
186 | xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_RELEASE, | ||
187 | keycode, XCB_CURRENT_TIME, | ||
188 | ((xcb_screen_t *)_ecore_xcb_screen)->root, 0, 0, 0); | ||
189 | err = xcb_request_check(_ecore_xcb_conn, cookie); | ||
190 | if (err) | ||
191 | { | ||
192 | free(err); | ||
193 | return EINA_FALSE; | ||
194 | } | ||
195 | |||
196 | if (shift) | ||
197 | { | ||
198 | cookie = | ||
199 | xcb_test_fake_input(_ecore_xcb_conn, XCB_KEY_RELEASE, | ||
200 | shift_code, XCB_CURRENT_TIME, | ||
201 | ((xcb_screen_t *)_ecore_xcb_screen)->root, | ||
202 | 0, 0, 0); | ||
203 | err = xcb_request_check(_ecore_xcb_conn, cookie); | ||
204 | if (err) | ||
205 | { | ||
206 | free(err); | ||
207 | return EINA_FALSE; | ||
208 | } | ||
209 | } | ||
210 | |||
211 | return EINA_TRUE; | ||
212 | #endif | ||
213 | |||
214 | return EINA_FALSE; | ||
215 | } | ||