From 3cc313b01b99007ec4129f83220f791988663a9e Mon Sep 17 00:00:00 2001 From: Myungjae Lee Date: Thu, 25 Nov 2010 15:49:07 +0900 Subject: [PATCH] [ecore] merged svn latest code (svn54830) --- AUTHORS | 3 + Makefile.am | 2 + README.in | 4 +- configure.ac | 30 +- debian/changelog | 40 - debian/libecore-con-svn-01.install | 1 + debian/libecore-con-svn-01.shlibs | 1 + debian/libecore-config-svn-01.install | 1 + debian/libecore-config-svn-01.shlibs | 1 + debian/libecore-evas-svn-01.install | 1 + debian/libecore-evas-svn-01.shlibs | 1 + debian/libecore-fb-svn-01.install | 1 + debian/libecore-fb-svn-01.shlibs | 1 + debian/libecore-file-svn-01.install | 1 + debian/libecore-file-svn-01.shlibs | 1 + debian/libecore-imf-svn-01.install | 2 + debian/libecore-imf-svn-01.shlibs | 2 + debian/libecore-input-svn-01.install | 1 + debian/libecore-input-svn-01.shlibs | 1 + debian/libecore-ipc-svn-01.install | 1 + debian/libecore-ipc-svn-01.shlibs | 1 + debian/libecore-svn-01.install | 1 + debian/libecore-svn-01.shlibs | 1 + debian/libecore-x-svn-01.install | 1 + debian/libecore-x-svn-01.shlibs | 1 + doc/Doxyfile | 203 +- doc/ecore.dox.in | 186 +- doc/img/elementary.png | Bin 7313 -> 0 bytes ecore.supp | 2 +- examples/ecore_con_client_example.c | 90 + examples/ecore_con_server_example.c | 81 + examples/ecore_fd_handler_example.c | 195 ++ m4/ecore_check_module.m4 | 2 +- m4/ecore_check_options.m4 | 4 +- po/pt.po | 29 +- src/lib/ecore/Ecore.h | 288 +- src/lib/ecore/Ecore_Getopt.h | 248 +- src/lib/ecore/Makefile.am | 2 +- src/lib/ecore/ecore.c | 216 +- src/lib/ecore/ecore_anim.c | 114 +- src/lib/ecore/ecore_app.c | 20 + src/lib/ecore/ecore_events.c | 364 +-- src/lib/ecore/ecore_exe.c | 1311 ++++---- src/lib/ecore/ecore_getopt.c | 1410 ++++----- src/lib/ecore/ecore_glib.c | 78 +- src/lib/ecore/ecore_idle_enterer.c | 113 +- src/lib/ecore/ecore_idle_exiter.c | 116 +- src/lib/ecore/ecore_idler.c | 131 +- src/lib/ecore/ecore_job.c | 35 +- src/lib/ecore/ecore_main.c | 807 +++-- src/lib/ecore/ecore_pipe.c | 347 ++- src/lib/ecore/ecore_poll.c | 176 +- src/lib/ecore/ecore_private.h | 29 +- src/lib/ecore/ecore_signal.c | 422 +-- src/lib/ecore/ecore_thread.c | 394 ++- src/lib/ecore/ecore_time.c | 157 +- src/lib/ecore/ecore_timer.c | 258 +- src/lib/ecore_cocoa/Ecore_Cocoa.h | 22 +- src/lib/ecore_con/Ecore_Con.h | 362 ++- src/lib/ecore_con/ecore_con.c | 1161 ++++--- src/lib/ecore_con/ecore_con_info.c | 38 +- src/lib/ecore_con/ecore_con_private.h | 60 +- src/lib/ecore_con/ecore_con_ssl.c | 1505 +++++---- src/lib/ecore_con/ecore_con_url.c | 476 +-- src/lib/ecore_config/ecore_config.c | 5 +- src/lib/ecore_directfb/Ecore_DirectFB.h | 60 +- src/lib/ecore_directfb/ecore_directfb.c | 13 +- src/lib/ecore_evas/Ecore_Evas.h | 92 +- src/lib/ecore_evas/ecore_evas.c | 1025 ++++--- src/lib/ecore_evas/ecore_evas_buffer.c | 164 +- src/lib/ecore_evas/ecore_evas_cocoa.c | 11 +- src/lib/ecore_evas/ecore_evas_directfb.c | 152 +- src/lib/ecore_evas/ecore_evas_fb.c | 274 +- src/lib/ecore_evas/ecore_evas_private.h | 16 +- src/lib/ecore_evas/ecore_evas_sdl.c | 76 +- src/lib/ecore_evas/ecore_evas_util.c | 38 +- src/lib/ecore_evas/ecore_evas_win32.c | 127 +- src/lib/ecore_evas/ecore_evas_wince.c | 152 +- src/lib/ecore_evas/ecore_evas_x.c | 3698 ++++++++++++----------- src/lib/ecore_fb/Ecore_Fb.h | 147 +- src/lib/ecore_fb/ecore_fb.c | 69 +- src/lib/ecore_fb/ecore_fb_kbd.c | 228 +- src/lib/ecore_fb/ecore_fb_keytable.h | 2 +- src/lib/ecore_fb/ecore_fb_li.c | 987 +++--- src/lib/ecore_fb/ecore_fb_private.h | 58 +- src/lib/ecore_fb/ecore_fb_ps2.c | 227 +- src/lib/ecore_fb/ecore_fb_ts.c | 271 +- src/lib/ecore_fb/ecore_fb_vt.c | 356 ++- src/lib/ecore_file/Ecore_File.h | 195 +- src/lib/ecore_file/ecore_file.c | 866 +++--- src/lib/ecore_file/ecore_file_download.c | 243 +- src/lib/ecore_file/ecore_file_monitor.c | 106 +- src/lib/ecore_file/ecore_file_monitor_inotify.c | 142 +- src/lib/ecore_file/ecore_file_monitor_poll.c | 334 +- src/lib/ecore_file/ecore_file_path.c | 93 +- src/lib/ecore_file/ecore_file_private.h | 26 +- src/lib/ecore_imf/Ecore_IMF.h | 53 +- src/lib/ecore_imf/ecore_imf.c | 2 - src/lib/ecore_imf/ecore_imf_context.c | 1 - src/lib/ecore_imf_evas/Ecore_IMF_Evas.h | 20 +- src/lib/ecore_imf_evas/Makefile.am | 2 +- src/lib/ecore_imf_evas/ecore_imf_evas.c | 22 +- src/lib/ecore_input/Ecore_Input.h | 349 ++- src/lib/ecore_input/ecore_input.c | 9 +- src/lib/ecore_input_evas/Ecore_Input_Evas.h | 32 +- src/lib/ecore_input_evas/ecore_input_evas.c | 61 +- src/lib/ecore_ipc/Ecore_Ipc.h | 246 +- src/lib/ecore_ipc/ecore_ipc.c | 1159 +++---- src/lib/ecore_sdl/Ecore_Sdl.h | 54 +- src/lib/ecore_sdl/ecore_sdl.c | 121 +- src/lib/ecore_win32/Ecore_Win32.h | 414 ++- src/lib/ecore_win32/Makefile.am | 2 - src/lib/ecore_win32/ecore_win32.c | 495 +-- src/lib/ecore_win32/ecore_win32_cursor.c | 203 +- src/lib/ecore_win32/ecore_win32_dnd.c | 123 +- src/lib/ecore_win32/ecore_win32_window.c | 659 +++- src/lib/ecore_wince/Ecore_WinCE.h | 199 +- src/lib/ecore_wince/ecore_wince.c | 405 +-- src/lib/ecore_wince/ecore_wince_event.c | 1520 +++++----- src/lib/ecore_wince/ecore_wince_window.c | 317 +- src/lib/ecore_x/Ecore_X.h | 365 ++- src/lib/ecore_x/Ecore_X_Atoms.h | 8 +- src/lib/ecore_x/Ecore_X_Cursor.h | 1 + src/lib/ecore_x/ecore_x_atoms_decl.h | 7 +- src/lib/ecore_x/xcb/ecore_xcb.c | 31 +- src/lib/ecore_x/xcb/ecore_xcb_composite.c | 2 +- src/lib/ecore_x/xcb/ecore_xcb_cursor.c | 2 +- src/lib/ecore_x/xcb/ecore_xcb_damage.c | 2 +- src/lib/ecore_x/xcb/ecore_xcb_dnd.c | 14 +- src/lib/ecore_x/xcb/ecore_xcb_dpms.c | 6 +- src/lib/ecore_x/xcb/ecore_xcb_fixes.c | 6 +- src/lib/ecore_x/xcb/ecore_xcb_icccm.c | 20 +- src/lib/ecore_x/xcb/ecore_xcb_mwm.c | 4 +- src/lib/ecore_x/xcb/ecore_xcb_netwm.c | 40 +- src/lib/ecore_x/xcb/ecore_xcb_randr.c | 69 +- src/lib/ecore_x/xcb/ecore_xcb_region.c | 18 +- src/lib/ecore_x/xcb/ecore_xcb_screensaver.c | 4 +- src/lib/ecore_x/xcb/ecore_xcb_selection.c | 70 +- src/lib/ecore_x/xcb/ecore_xcb_shape.c | 2 +- src/lib/ecore_x/xcb/ecore_xcb_sync.c | 6 +- src/lib/ecore_x/xcb/ecore_xcb_window.c | 12 +- src/lib/ecore_x/xcb/ecore_xcb_window_prop.c | 2 +- src/lib/ecore_x/xcb/ecore_xcb_xinerama.c | 4 +- src/lib/ecore_x/xlib/ecore_x.c | 90 +- src/lib/ecore_x/xlib/ecore_x_atoms.c | 8 +- src/lib/ecore_x/xlib/ecore_x_composite.c | 23 +- src/lib/ecore_x/xlib/ecore_x_cursor.c | 2 +- src/lib/ecore_x/xlib/ecore_x_damage.c | 10 +- src/lib/ecore_x/xlib/ecore_x_dnd.c | 107 +- src/lib/ecore_x/xlib/ecore_x_dpms.c | 28 +- src/lib/ecore_x/xlib/ecore_x_drawable.c | 2 +- src/lib/ecore_x/xlib/ecore_x_e.c | 176 +- src/lib/ecore_x/xlib/ecore_x_events.c | 4 +- src/lib/ecore_x/xlib/ecore_x_icccm.c | 54 +- src/lib/ecore_x/xlib/ecore_x_image.c | 310 +- src/lib/ecore_x/xlib/ecore_x_mwm.c | 12 +- src/lib/ecore_x/xlib/ecore_x_netwm.c | 105 +- src/lib/ecore_x/xlib/ecore_x_private.h | 10 +- src/lib/ecore_x/xlib/ecore_x_randr.c | 2 +- src/lib/ecore_x/xlib/ecore_x_randr_12.c | 87 +- src/lib/ecore_x/xlib/ecore_x_region.c | 44 +- src/lib/ecore_x/xlib/ecore_x_screensaver.c | 7 +- src/lib/ecore_x/xlib/ecore_x_selection.c | 71 +- src/lib/ecore_x/xlib/ecore_x_sync.c | 8 +- src/lib/ecore_x/xlib/ecore_x_test.c | 28 +- src/lib/ecore_x/xlib/ecore_x_window.c | 8 +- src/lib/ecore_x/xlib/ecore_x_window_prop.c | 9 +- src/lib/ecore_x/xlib/ecore_x_window_shape.c | 2 +- src/lib/ecore_x/xlib/ecore_x_xinerama.c | 8 +- 169 files changed, 16989 insertions(+), 13195 deletions(-) create mode 100644 debian/libecore-con-svn-01.install create mode 100644 debian/libecore-con-svn-01.shlibs create mode 100644 debian/libecore-config-svn-01.install create mode 100644 debian/libecore-config-svn-01.shlibs create mode 100644 debian/libecore-evas-svn-01.install create mode 100644 debian/libecore-evas-svn-01.shlibs create mode 100644 debian/libecore-fb-svn-01.install create mode 100644 debian/libecore-fb-svn-01.shlibs create mode 100644 debian/libecore-file-svn-01.install create mode 100644 debian/libecore-file-svn-01.shlibs create mode 100644 debian/libecore-imf-svn-01.install create mode 100644 debian/libecore-imf-svn-01.shlibs create mode 100644 debian/libecore-input-svn-01.install create mode 100644 debian/libecore-input-svn-01.shlibs create mode 100644 debian/libecore-ipc-svn-01.install create mode 100644 debian/libecore-ipc-svn-01.shlibs create mode 100644 debian/libecore-svn-01.install create mode 100644 debian/libecore-svn-01.shlibs create mode 100644 debian/libecore-x-svn-01.install create mode 100644 debian/libecore-x-svn-01.shlibs delete mode 100644 doc/img/elementary.png create mode 100644 examples/ecore_con_client_example.c create mode 100644 examples/ecore_con_server_example.c create mode 100644 examples/ecore_fd_handler_example.c mode change 100755 => 100644 src/lib/ecore_x/Ecore_X.h mode change 100755 => 100644 src/lib/ecore_x/Ecore_X_Atoms.h mode change 100755 => 100644 src/lib/ecore_x/ecore_x_atoms_decl.h mode change 100755 => 100644 src/lib/ecore_x/xlib/ecore_x_atoms.c mode change 100755 => 100644 src/lib/ecore_x/xlib/ecore_x_e.c diff --git a/AUTHORS b/AUTHORS index a91b454..7784236 100644 --- a/AUTHORS +++ b/AUTHORS @@ -33,3 +33,6 @@ Saumsung Electronics Samsung SAIT Nicolas Aguirre Brett Nash +Mike Blumenkrantz +Leif Middelschulte +Mike McCormack diff --git a/Makefile.am b/Makefile.am index 6a4238f..0534d99 100644 --- a/Makefile.am +++ b/Makefile.am @@ -94,6 +94,8 @@ ecore-input.pc.in \ ecore-wince.pc.in \ ecore.spec.in \ ecore.spec \ +examples/ecore_con_server_example.c \ +examples/ecore_con_client_example.c \ m4/ac_abstract_socket.m4 \ m4/ac_attribute.m4 \ m4/check_x_extension.m4 \ diff --git a/README.in b/README.in index f95fc6a..e20ecfe 100644 --- a/README.in +++ b/README.in @@ -1,4 +1,4 @@ -Ecore @VERSION@ +Ecore @VERSION@ BETA ****************************************************************************** @@ -35,7 +35,7 @@ Recommended: evas (1.0.0 or better) Optional: - XCB + XCB (highly experimental - don't use it unless you are fixing it) SDL DirectFB diff --git a/configure.ac b/configure.ac index ff08232..f54edad 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ m4_define([lt_age], v_min) ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## ##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--##--## -AC_INIT([ecore], [v_ver-alpha], [enlightenment-devel@lists.sourceforge.net]) +AC_INIT([ecore], [v_ver.beta], [enlightenment-devel@lists.sourceforge.net]) AC_PREREQ([2.52]) AC_CONFIG_SRCDIR([configure.ac]) AC_CONFIG_MACRO_DIR([m4]) @@ -201,6 +201,7 @@ case "$host_os" in want_signature="yes" want_inotify="yes" want_tslib="yes" + want_ecore_fb="yes" want_ecore_ipc="yes" want_ecore_imf="yes" want_ecore_x="yes" @@ -361,6 +362,7 @@ case "$host_os" in EFL_ECORE_FILE_BUILD="-DEFL_ECORE_FILE_BUILD" EFL_ECORE_EVAS_BUILD="-DEFL_ECORE_EVAS_BUILD" EFL_ECORE_IMF_BUILD="-DEFL_ECORE_IMF_BUILD" + EFL_ECORE_IMF_EVAS_BUILD="-DEFL_ECORE_IMF_EVAS_BUILD" EFL_ECORE_INPUT_BUILD="-DEFL_ECORE_INPUT_BUILD" EFL_ECORE_INPUT_EVAS_BUILD="-DEFL_ECORE_INPUT_EVAS_BUILD" ;; @@ -387,6 +389,7 @@ AC_SUBST(EFL_ECORE_BUILD) AC_SUBST(EFL_ECORE_FILE_BUILD) AC_SUBST(EFL_ECORE_EVAS_BUILD) AC_SUBST(EFL_ECORE_IMF_BUILD) +AC_SUBST(EFL_ECORE_IMF_EVAS_BUILD) AC_SUBST(EFL_ECORE_INPUT_BUILD) AC_SUBST(EFL_ECORE_INPUT_EVAS_BUILD) AC_SUBST(EFL_ECORE_WINCE_BUILD) @@ -407,11 +410,17 @@ case "$host_os" in dlopen_libs="-ldl" ;; *) - AC_CHECK_LIB(dl, dlopen, dlopen_libs=-ldl) + AC_CHECK_LIB([dl], [dlopen], [dlopen_libs=-ldl]) + AC_SEARCH_LIBS([clock_gettime], [rt], + [ + rt_libs=-lrt + AC_DEFINE(HAVE_CLOCK_GETTIME, [1], [Have clock_gettime()]) + ]) ;; esac AC_SUBST(WIN32_LIBS) AC_SUBST(dlopen_libs) +AC_SUBST(rt_libs) # Eina library @@ -903,13 +912,16 @@ m4_ifdef([AC_PROG_OBJC], [ ]) AC_SUBST(cocoa_ldflags) -# check for epoll support -AC_ARG_ENABLE(epoll, AC_HELP_STRING([--enable-epoll], [enable or disable epoll support]), [want_epoll=$enableval]) - -if test "x${want_epoll}" = "xyes" ; then -# check for epoll support -AC_CHECK_HEADERS([sys/epoll.h]) -fi +want_epoll=yes +AC_ARG_ENABLE(epoll, + AC_HELP_STRING([--enable-epoll], [enable or disable epoll support]), + [want_epoll=$enableval]) + +if test "x${want_epoll}" = "xyes" ; then + # check for epoll support + AC_CHECK_HEADERS([sys/epoll.h]) +fi + # basic pthread support diff --git a/debian/changelog b/debian/changelog index 9a32e70..dca0c2e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,43 +1,3 @@ -ecore (1.0.0.001+svn.51480slp2+build24) unstable; urgency=low - - * [Ecore_IMF.h] temp rollback about bool - * Git: 165.213.180.234:/git/slp/pkgs/ecore - * Tag: ecore_1.0.0.001+svn.51480slp2+build24 - - -- WooHyun Jung Tue, 23 Nov 2010 22:07:30 +0900 - -ecore (1.0.0.001+svn.51480slp2+build23) unstable; urgency=low - - * [ecore_imf] add ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW / HIDE - * Git: 165.213.180.234:/git/slp/pkgs/ecore - * Tag: ecore_1.0.0.001+svn.51480slp2+build23 - - -- Jihoon Kim Tue, 23 Nov 2010 20:24:05 +0900 - -ecore (1.0.0.001+svn.51480slp2+build22) unstable; urgency=low - - * [ecore_imf] remove unused enum variables - * Git: 165.213.180.234:/git/slp/pkgs/ecore - * Tag: ecore_1.0.0.001+svn.51480slp2+build22 - - -- Jihoon Kim Tue, 23 Nov 2010 19:40:48 +0900 - -ecore (1.0.0.001+svn.51480slp2+build21) unstable; urgency=low - - * [ecore_imf] remove unused enum variables - * Git: 165.213.180.234:/git/slp/pkgs/ecore - * Tag: ecore_1.0.0.001+svn.51480slp2+build21 - - -- Jihoon Kim Tue, 23 Nov 2010 19:36:42 +0900 - -ecore (1.0.0.001+svn.51480slp2+build20) unstable; urgency=low - - * [ecore_imf] support the attribute of imengine - * Git: 165.213.180.234:/git/slp/pkgs/ecore - * Tag: ecore_1.0.0.001+svn.51480slp2+build20 - - -- Jihoon Kim Mon, 22 Nov 2010 11:22:56 +0900 - ecore (1.0.0.001+svn.51480slp2+build19) unstable; urgency=low * libcurl-dev -> libcurl4-openssl-dev diff --git a/debian/libecore-con-svn-01.install b/debian/libecore-con-svn-01.install new file mode 100644 index 0000000..4e6f99e --- /dev/null +++ b/debian/libecore-con-svn-01.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/libecore_con-*.so.* diff --git a/debian/libecore-con-svn-01.shlibs b/debian/libecore-con-svn-01.shlibs new file mode 100644 index 0000000..d5353f3 --- /dev/null +++ b/debian/libecore-con-svn-01.shlibs @@ -0,0 +1 @@ +libecore_con-ver-pre-svn-01 0 libecore-con-svn-01 (>= 0.9.9.060+svnYYYYMMDD) diff --git a/debian/libecore-config-svn-01.install b/debian/libecore-config-svn-01.install new file mode 100644 index 0000000..d497998 --- /dev/null +++ b/debian/libecore-config-svn-01.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/libecore_config-*.so.* diff --git a/debian/libecore-config-svn-01.shlibs b/debian/libecore-config-svn-01.shlibs new file mode 100644 index 0000000..ec0e971 --- /dev/null +++ b/debian/libecore-config-svn-01.shlibs @@ -0,0 +1 @@ +libecore_config-ver-pre-svn-01 0 libecore-config-svn-01 (>= 0.9.9.060+svnYYYYMMDD) diff --git a/debian/libecore-evas-svn-01.install b/debian/libecore-evas-svn-01.install new file mode 100644 index 0000000..ceb9f01 --- /dev/null +++ b/debian/libecore-evas-svn-01.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/libecore_evas-*.so.* diff --git a/debian/libecore-evas-svn-01.shlibs b/debian/libecore-evas-svn-01.shlibs new file mode 100644 index 0000000..92c2b6d --- /dev/null +++ b/debian/libecore-evas-svn-01.shlibs @@ -0,0 +1 @@ +libecore_evas-ver-pre-svn-01 0 libecore-evas-svn-01 (>= 0.9.9.060+svnYYYYMMDD) diff --git a/debian/libecore-fb-svn-01.install b/debian/libecore-fb-svn-01.install new file mode 100644 index 0000000..72ceee2 --- /dev/null +++ b/debian/libecore-fb-svn-01.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/libecore_fb-*.so.* diff --git a/debian/libecore-fb-svn-01.shlibs b/debian/libecore-fb-svn-01.shlibs new file mode 100644 index 0000000..2593f16 --- /dev/null +++ b/debian/libecore-fb-svn-01.shlibs @@ -0,0 +1 @@ +libecore_fb-ver-pre-svn-01 0 libecore-fb-svn-01 (>= 0.9.9.060+svnYYYYMMDD) diff --git a/debian/libecore-file-svn-01.install b/debian/libecore-file-svn-01.install new file mode 100644 index 0000000..a115a75 --- /dev/null +++ b/debian/libecore-file-svn-01.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/libecore_file-*.so.* diff --git a/debian/libecore-file-svn-01.shlibs b/debian/libecore-file-svn-01.shlibs new file mode 100644 index 0000000..868a4f6 --- /dev/null +++ b/debian/libecore-file-svn-01.shlibs @@ -0,0 +1 @@ +libecore_file-ver-pre-svn-01 0 libecore-file-svn-01 (>= 0.9.9.060+svnYYYYMMDD) diff --git a/debian/libecore-imf-svn-01.install b/debian/libecore-imf-svn-01.install new file mode 100644 index 0000000..8da8885 --- /dev/null +++ b/debian/libecore-imf-svn-01.install @@ -0,0 +1,2 @@ +debian/tmp/usr/lib/libecore_imf-*.so.* +debian/tmp/usr/lib/libecore_imf_evas-*.so.* diff --git a/debian/libecore-imf-svn-01.shlibs b/debian/libecore-imf-svn-01.shlibs new file mode 100644 index 0000000..15aeb84 --- /dev/null +++ b/debian/libecore-imf-svn-01.shlibs @@ -0,0 +1,2 @@ +libecore_imf-ver-pre-svn-01 0 libecore-imf-svn-01 (>= 0.9.9.060+svnYYYYMMDD) +libecore_imf_evas-ver-pre-svn-01 0 libecore-imf-svn-01 (>= 0.9.9.060+svnYYYYMMDD) diff --git a/debian/libecore-input-svn-01.install b/debian/libecore-input-svn-01.install new file mode 100644 index 0000000..34d8efb --- /dev/null +++ b/debian/libecore-input-svn-01.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/libecore_input-*.so.* diff --git a/debian/libecore-input-svn-01.shlibs b/debian/libecore-input-svn-01.shlibs new file mode 100644 index 0000000..b95c6bb --- /dev/null +++ b/debian/libecore-input-svn-01.shlibs @@ -0,0 +1 @@ +libecore_input-ver-pre-svn-01 0 libecore-input-svn-01 (>= 0.9.9.060+svnYYYYMMDD) diff --git a/debian/libecore-ipc-svn-01.install b/debian/libecore-ipc-svn-01.install new file mode 100644 index 0000000..e118708 --- /dev/null +++ b/debian/libecore-ipc-svn-01.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/libecore_ipc-*.so.* diff --git a/debian/libecore-ipc-svn-01.shlibs b/debian/libecore-ipc-svn-01.shlibs new file mode 100644 index 0000000..6a9ae5a --- /dev/null +++ b/debian/libecore-ipc-svn-01.shlibs @@ -0,0 +1 @@ +libecore_ipc-ver-pre-svn-01 0 libecore-ipc-svn-01 (>= 0.9.9.060+svnYYYYMMDD) diff --git a/debian/libecore-svn-01.install b/debian/libecore-svn-01.install new file mode 100644 index 0000000..22c55a3 --- /dev/null +++ b/debian/libecore-svn-01.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/libecore-*.so.* diff --git a/debian/libecore-svn-01.shlibs b/debian/libecore-svn-01.shlibs new file mode 100644 index 0000000..43565e1 --- /dev/null +++ b/debian/libecore-svn-01.shlibs @@ -0,0 +1 @@ +libecore-ver-pre-svn-01 0 libecore-svn-01 (>= 0.9.9.060+svnYYYYMMDD) diff --git a/debian/libecore-x-svn-01.install b/debian/libecore-x-svn-01.install new file mode 100644 index 0000000..8c8007e --- /dev/null +++ b/debian/libecore-x-svn-01.install @@ -0,0 +1 @@ +debian/tmp/usr/lib/libecore_x-*.so.* diff --git a/debian/libecore-x-svn-01.shlibs b/debian/libecore-x-svn-01.shlibs new file mode 100644 index 0000000..b5a9660 --- /dev/null +++ b/debian/libecore-x-svn-01.shlibs @@ -0,0 +1 @@ +libecore_x-ver-pre-svn-01 0 libecore-x-svn-01 (>= 0.9.9.060+svnYYYYMMDD) diff --git a/doc/Doxyfile b/doc/Doxyfile index f898c07..5992902 100644 --- a/doc/Doxyfile +++ b/doc/Doxyfile @@ -1,138 +1,221 @@ +DOXYFILE_ENCODING = UTF-8 PROJECT_NAME = Ecore PROJECT_NUMBER = OUTPUT_DIRECTORY = . -INPUT = ./ecore.dox ../src/lib -IMAGE_PATH = img +CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English -GENERATE_HTML = YES -HTML_OUTPUT = html -HTML_FILE_EXTENSION = .html -HTML_HEADER = head.html -HTML_FOOTER = foot.html -HTML_STYLESHEET = e.css -HTML_ALIGN_MEMBERS = YES -ENUM_VALUES_PER_LINE = 1 -GENERATE_HTMLHELP = NO -CHM_FILE = -HHC_LOCATION = -GENERATE_CHI = NO -BINARY_TOC = NO -TOC_EXPAND = NO -DISABLE_INDEX = YES +BRIEF_MEMBER_DESC = YES +REPEAT_BRIEF = YES +ABBREVIATE_BRIEF = +ALWAYS_DETAILED_SEC = NO +INLINE_INHERITED_MEMB = NO +FULL_PATH_NAMES = NO +STRIP_FROM_PATH = +STRIP_FROM_INC_PATH = +SHORT_NAMES = NO +JAVADOC_AUTOBRIEF = YES +QT_AUTOBRIEF = NO +MULTILINE_CPP_IS_BRIEF = NO +INHERIT_DOCS = YES +SEPARATE_MEMBER_PAGES = NO +TAB_SIZE = 2 +ALIASES = +OPTIMIZE_OUTPUT_FOR_C = YES +OPTIMIZE_OUTPUT_JAVA = NO +OPTIMIZE_FOR_FORTRAN = NO +OPTIMIZE_OUTPUT_VHDL = NO +EXTENSION_MAPPING = +BUILTIN_STL_SUPPORT = NO +CPP_CLI_SUPPORT = NO +SIP_SUPPORT = NO +IDL_PROPERTY_SUPPORT = YES +DISTRIBUTE_GROUP_DOC = NO +SUBGROUPING = YES +TYPEDEF_HIDES_STRUCT = NO +SYMBOL_CACHE_SIZE = 0 EXTRACT_ALL = NO EXTRACT_PRIVATE = NO EXTRACT_STATIC = NO EXTRACT_LOCAL_CLASSES = NO +EXTRACT_LOCAL_METHODS = NO +EXTRACT_ANON_NSPACES = NO HIDE_UNDOC_MEMBERS = YES HIDE_UNDOC_CLASSES = YES HIDE_FRIEND_COMPOUNDS = YES -BRIEF_MEMBER_DESC = YES -REPEAT_BRIEF = YES -ALWAYS_DETAILED_SEC = NO -INLINE_INHERITED_MEMB = NO -FULL_PATH_NAMES = NO -STRIP_FROM_PATH = +HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO -STRIP_CODE_COMMENTS = YES CASE_SENSE_NAMES = YES -SHORT_NAMES = NO HIDE_SCOPE_NAMES = NO -VERBATIM_HEADERS = NO SHOW_INCLUDE_FILES = NO -JAVADOC_AUTOBRIEF = YES -MULTILINE_CPP_IS_BRIEF = NO -DETAILS_AT_TOP = NO -INHERIT_DOCS = YES +FORCE_LOCAL_INCLUDES = NO INLINE_INFO = YES SORT_MEMBER_DOCS = YES -DISTRIBUTE_GROUP_DOC = NO -TAB_SIZE = 2 +SORT_BRIEF_DOCS = NO +SORT_MEMBERS_CTORS_1ST = NO +SORT_GROUP_NAMES = NO +SORT_BY_SCOPE_NAME = NO GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES GENERATE_BUGLIST = YES GENERATE_DEPRECATEDLIST= YES -ALIASES = -ENABLED_SECTIONS = +ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 -OPTIMIZE_OUTPUT_FOR_C = YES -OPTIMIZE_OUTPUT_JAVA = NO SHOW_USED_FILES = NO +SHOW_DIRECTORIES = NO +SHOW_FILES = YES +SHOW_NAMESPACES = YES +FILE_VERSION_FILTER = +LAYOUT_FILE = QUIET = YES WARNINGS = YES WARN_IF_UNDOCUMENTED = YES +WARN_IF_DOC_ERROR = YES +WARN_NO_PARAMDOC = YES WARN_FORMAT = "$file:$line: $text" -WARN_LOGFILE = +WARN_LOGFILE = +INPUT = ./ecore.dox \ + ../src/lib +INPUT_ENCODING = UTF-8 FILE_PATTERNS = -RECURSIVE = YES +RECURSIVE = YES +EXCLUDE = ../src/lib/ecore_config/* ../src/lib/ecore_x/xcb/*.c EXCLUDE_SYMLINKS = NO -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = ecore_config* Ecore_Config* +EXCLUDE_SYMBOLS = Ecore_Config* EXAMPLE_PATH = ../examples/ -EXAMPLE_PATTERNS = -EXAMPLE_RECURSIVE = NO -INPUT_FILTER = +EXAMPLE_PATTERNS = +EXAMPLE_RECURSIVE = YES +IMAGE_PATH = img +INPUT_FILTER = +FILTER_PATTERNS = FILTER_SOURCE_FILES = NO SOURCE_BROWSER = NO INLINE_SOURCES = NO +STRIP_CODE_COMMENTS = YES REFERENCED_BY_RELATION = YES REFERENCES_RELATION = YES +REFERENCES_LINK_SOURCE = YES +USE_HTAGS = NO +VERBATIM_HEADERS = NO ALPHABETICAL_INDEX = YES COLS_IN_ALPHA_INDEX = 2 IGNORE_PREFIX = +GENERATE_HTML = YES +HTML_OUTPUT = html +HTML_FILE_EXTENSION = .html +HTML_HEADER = head.html +HTML_FOOTER = foot.html +HTML_STYLESHEET = e.css +HTML_COLORSTYLE_HUE = 220 +HTML_COLORSTYLE_SAT = 100 +HTML_COLORSTYLE_GAMMA = 80 +HTML_TIMESTAMP = YES +HTML_ALIGN_MEMBERS = YES +HTML_DYNAMIC_SECTIONS = NO +GENERATE_DOCSET = NO +DOCSET_FEEDNAME = "Doxygen generated docs" +DOCSET_BUNDLE_ID = org.doxygen.Project +DOCSET_PUBLISHER_ID = org.doxygen.Publisher +DOCSET_PUBLISHER_NAME = Publisher +GENERATE_HTMLHELP = NO +CHM_FILE = +HHC_LOCATION = +GENERATE_CHI = NO +CHM_INDEX_ENCODING = +BINARY_TOC = NO +TOC_EXPAND = NO +GENERATE_QHP = NO +QCH_FILE = +QHP_NAMESPACE = org.doxygen.Project +QHP_VIRTUAL_FOLDER = doc +QHP_CUST_FILTER_NAME = +QHP_CUST_FILTER_ATTRS = +QHP_SECT_FILTER_ATTRS = +QHG_LOCATION = +GENERATE_ECLIPSEHELP = NO +ECLIPSE_DOC_ID = org.doxygen.Project +DISABLE_INDEX = YES +ENUM_VALUES_PER_LINE = 1 GENERATE_TREEVIEW = NO +USE_INLINE_TREES = NO TREEVIEW_WIDTH = 250 +EXT_LINKS_IN_WINDOW = NO +FORMULA_FONTSIZE = 10 +FORMULA_TRANSPARENT = YES +SEARCHENGINE = NO +SERVER_BASED_SEARCH = NO GENERATE_LATEX = YES LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO PAPER_TYPE = a4wide -EXTRA_PACKAGES = -LATEX_HEADER = +EXTRA_PACKAGES = +LATEX_HEADER = PDF_HYPERLINKS = YES USE_PDFLATEX = NO LATEX_BATCHMODE = NO +LATEX_HIDE_INDICES = NO +LATEX_SOURCE_CODE = NO GENERATE_RTF = NO RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO -RTF_STYLESHEET_FILE = -RTF_EXTENSIONS_FILE = +RTF_STYLESHEET_FILE = +RTF_EXTENSIONS_FILE = GENERATE_MAN = YES MAN_OUTPUT = man MAN_EXTENSION = .3 MAN_LINKS = YES GENERATE_XML = NO -XML_SCHEMA = -XML_DTD = +XML_OUTPUT = xml +XML_SCHEMA = +XML_DTD = +XML_PROGRAMLISTING = YES GENERATE_AUTOGEN_DEF = NO +GENERATE_PERLMOD = NO +PERLMOD_LATEX = NO +PERLMOD_PRETTY = YES +PERLMOD_MAKEVAR_PREFIX = ENABLE_PREPROCESSING = YES -MACRO_EXPANSION = NO -EXPAND_ONLY_PREDEF = NO +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = YES SEARCH_INCLUDES = NO INCLUDE_PATH = -INCLUDE_FILE_PATTERNS = -PREDEFINED = -EXPAND_AS_DEFINED = +INCLUDE_FILE_PATTERNS = +PREDEFINED = __UNUSED__= +EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES -TAGFILES = -GENERATE_TAGFILE = +TAGFILES = +GENERATE_TAGFILE = ALLEXTERNALS = NO EXTERNAL_GROUPS = YES PERL_PATH = /usr/bin/perl CLASS_DIAGRAMS = NO +MSCGEN_PATH = HIDE_UNDOC_RELATIONS = YES HAVE_DOT = NO +DOT_NUM_THREADS = 0 +DOT_FONTNAME = FreeSans.ttf +DOT_FONTSIZE = 10 +DOT_FONTPATH = CLASS_GRAPH = NO COLLABORATION_GRAPH = NO +GROUP_GRAPHS = YES +UML_LOOK = NO TEMPLATE_RELATIONS = NO INCLUDE_GRAPH = NO INCLUDED_BY_GRAPH = NO +CALL_GRAPH = NO +CALLER_GRAPH = NO GRAPHICAL_HIERARCHY = NO +DIRECTORY_GRAPH = YES DOT_IMAGE_FORMAT = png -DOT_PATH = -DOTFILE_DIRS = -MAX_DOT_GRAPH_WIDTH = 512 -MAX_DOT_GRAPH_HEIGHT = 512 +DOT_PATH = +DOTFILE_DIRS = +DOT_GRAPH_MAX_NODES = 50 +MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO +DOT_MULTI_TARGETS = NO GENERATE_LEGEND = YES DOT_CLEANUP = YES -SEARCHENGINE = NO diff --git a/doc/ecore.dox.in b/doc/ecore.dox.in index d75a8ee..07e0b15 100644 --- a/doc/ecore.dox.in +++ b/doc/ecore.dox.in @@ -17,21 +17,52 @@ These routines are used for Ecore Library interaction @author Chris Ross @author Term @author Tilman Sauerbeck +@author Ibukun Olumuyiwa +@author Yuri +@author Nicholas Curran +@author Howell Tam @author Nathan Ingersoll -@date 2000-2004 +@author Andrew Elcock +@author Kim Woelders +@author Sebastian Dransfeld +@author Simon Poole +@author Jorge Luis Zapata Muga +@author dan sinclair +@author Michael 'Mickey' Lauer +@author David 'onefang' Seikel +@author Hisham 'CodeWarrior' Mardam Bey +@author Brian 'rephorm' Mattern +@author Tim Horton +@author Arnaud de Turckheim 'quarium' +@author Matt Barclay +@author Peter Wehrfritz +@author Albin "Lutin" Tonnerre +@author Vincent Torri +@author Lars Munch +@author Andre Dieb +@author Mathieu Taillefumier +@author Rui Miguel Silva Seabra +@author Saumsung Electronics +@author Samsung SAIT +@author Nicolas Aguirre +@author Brett Nash +@author Mike Blumenkrantz +@date 2000-2010 @section intro Introduction Ecore is a library of convenience functions. The Ecore library provides the following modules: -@li @link Ecore.h Ecore - Main Loop and Job Functions. @endlink -@li @link Ecore_Con.h Ecore_Con - Connection functions. @endlink -@li @link Ecore_Config.h Ecore_Config - Configuration functions. @endlink +@li @ref Ecore_Group +@li @ref Ecore_File_Group +@li @ref Ecore_Con_Group @li @link Ecore_Evas.h Ecore_Evas - Evas convenience functions. @endlink -@li @link Ecore_Fb.h Ecore_FB - Frame buffer convenience functions. @endlink +@li @ref Ecore_FB_Group @li @link Ecore_Ipc.h Ecore_IPC - Inter Process Communication functions. @endlink @li @link Ecore_X.h Ecore_X - X Windows System wrapper. @endlink +@li @ref Ecore_Win32_Group +@li @ref Ecore_WinCE_Group @section compiling How to compile using Ecore? @@ -96,7 +127,7 @@ file descriptors etc. Ecore also lets you have functions called when file descriptors become active for reading or writing, allowing for streamlined, non-blocking IO. -Here is an exmaple of a simple program and its basic event loop flow: +Here is an example of a simple program and its basic event loop flow: @image html prog_flow.png @@ -189,7 +220,7 @@ follows the same principles as shown in this example. */ -/** +/* @page Ecore_Config_Page The Enlightened Property Library The Enlightened Property Library (Ecore_Config) is an adbstraction @@ -208,53 +239,6 @@ The following examples show how to use the Enlightened Property Library: */ /** -@page Ecore_ADT_Page Ecore Abstract Data Types - -This page briefly describes the different abstract data types -that are provided by the Ecore library for general usage. You need to -include the @link Ecore_Data.h Ecore_Data.h @endlink to use them. - -@section Ecore_ADT_List List - -A list is a simple data type where one each piece of data points to -another piece of data. - -Associated modules that describe the List ADT include: -@li @ref Ecore_Data_List_Creation_Group -@li @ref Ecore_Data_List_Add_Item_Group -@li @ref Ecore_Data_List_Remove_Item_Group -@li @ref Ecore_Data_List_Traverse_Group -@li @ref Ecore_Data_List_Node_Group - -Examples involving lists include: -@li @link list_example.c list_example.c @endlink - -@section Ecore_ADT_DList Doubly Linked List - -A doubly linked list is like a linked list, only each piece of data -can also point to the piece before it. In other words, you can traverse -a doubly linked list in both directions. - -Associated modules that describe the DList ADT include: -@li @ref Ecore_Data_DList_Creation_Group -@li @ref Ecore_Data_DList_Add_Item_Group -@li @ref Ecore_Data_DList_Remove_Item_Group - -@section Ecore_ADT_Hash Hash - -A hash is an abstract data type where one value is associated with another -value. Instead of each element of the group being accessible using a -number, each element is accessed using another object. - -Associated modules that describe the Hash ADT include: -@li @ref Ecore_Data_Hash_ADT_Creation_Group -@li @ref Ecore_Data_Hash_ADT_Destruction_Group -@li @ref Ecore_Data_Hash_ADT_Data_Group - -@todo Finish this. -*/ - -/** @page X_Window_System_Page X Window System The Ecore library includes a wrapper for handling the X window system. @@ -262,112 +246,40 @@ This page briefly explains what the X window system is and various terms that are used. */ -// GROUP DEFINITIONS - -/** -@defgroup Ecore_Timer_Group Ecore Timer - -The timer allows callbacks to be called at specific intervals. - */ - -/** -@defgroup Ecore_Job_Group Ecore Jobs - -You can queue jobs that are to be done by the main loop when the current -event is dealt with. -*/ - -/** -@defgroup Idle_Group Idle Handlers - -Callbacks that are called when the program enters or exits an idle state. - -The ecore main loop enters an idle state when it is waiting for timers -to time out, data to come in on a file descriptor or any other event -to occur. You can set callbacks to be called when the main loop -enters an idle state, during an idle state or just after the program -wakes up. - -Enterer callbacks are good for updating your program's state, if it -has a state engine. Once all of the enterer handlers are called, the -program will enter a "sleeping" state. - -Idler callbacks are called when the main loop has called all enterer -handlers. They are useful for interfaces that require polling and -timers would be too slow to use. - -If no idler callbacks are specified, then the process literally goes -to sleep. Otherwise, the idler callbacks are called continuously -while the loop is "idle", using as much CPU as is available to the -process. - -Exiter callbacks are called when the main loop wakes up from an idle -state. - -*/ - -/** -@defgroup Ecore_Config_Create_Group Ecore Config Create Functions - -Convenience functions that set default values, bounds, option values and -descriptions in one call. -*/ - -/** -@defgroup Ecore_Config_File_Group Ecore Config File Functions - -Functions that are used to load and save properties from and to files. -*/ - // EXAMPLES /** -@example args_example.c +@example ecore_args_example.c Shows how to set and retrieve the program arguments. */ /** -@example con_server_example.c -Shows how to write a simple server using the Ecore_Con library. -*/ - -/** -@example con_client_example.c -Shows how to write a simple client, that connects to the example server. +@example ecore_event_handler_example.c +Shows how to use event handlers. */ /** -@example event_handler_example.c -Shows how to use event handlers. +@example ecore_fd_handler_example.c +Shows how to use fd handlers. */ /** -@example timer_example.c +@example ecore_timer_example.c Demonstrates use of the ecore_timer. */ -/** -@example config_basic_example.c +/* +@example ecore_config_basic_example.c Provides an example of how to use the basic configuration functions. See the file Ecore_Config.h for the full list of available functions. */ -/** -@example config_listener_example.c +/* +@example ecore_config_listener_example.c Shows how to set up a listener to listen for configuration changes. */ /** -@example list_example.c -Provides a basic example of how to append to and traverse a list. -*/ - -/** -@example list_destroy_example.c -Shows how to set and use a destructor for an Ecore_List. -*/ - -/** -@example x_window_example.c +@example ecore_x_window_example.c Shows the basics of using the X Windows system through Ecore functions. */ diff --git a/doc/img/elementary.png b/doc/img/elementary.png deleted file mode 100644 index 79754891f19704929cf6198da9c17f7f12a7601b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7313 zcmX9@2Rv2p|3CM-xZL8}l8lU0X0|Sw*|PWEn~ZEO*_k1_Hjxoh_LiMQi5tS@;${mO zS^x9>{m<)j&Uu~tI?s7N`+45)o1m?we4U($8~}jpsw#@Q;2r(n2`2%seKIzq;0@+0 zuc{9Rk5IUMJorrJtzzN}05|LYJ0X@#>CE7dH~f^0{q(#X{Q_)!9Dsm;0Dc!wH(xs& zZwG!aAE(?M6cYe2Q>ZG+=?CU*TZE)B4}@K|g*YDX96hC6e>X{n{Pa=~W^;q+WrCgZ zAT)}qm%757lk?{r^Q$yAA4>1`YgpgL--Z0X512sqS zMgpDaNju5;ZI|O`PK4KwJVWZ5o1It#&T^#Jt1+1MnSztNAchK4Ch zZ>E}<=?zk65jgwd;7zadYwY&KcJ67qQp1cl0YTZj7uqsrpAI_gnmkyEy!#J2I0^{c z3m+Ut>!inh%}!3PlfF*o#%)yBrGVyMwU)bJH`*>u)LbapVVSyn(g0GP92;0*^wS)> zdiDk{ab;&RJw7xz7=F3+alF8N>Y*t4$3#H)bY~ND5h~}A{yh^-~A+p6455q+T zFu#olQ2CFH zkPI>cJ^mKPuZZWGZ05w6ha&M3CEPsj1%%!Y@2oK8txF?!3V+Ql8x;!8Vt~!*n%r^5 zb|dWHZu=ycq6XAkFLXmz_$)IR(>nTE?;yIBGic+~_;p>%e3ub4RZ@;FWeF?Z>Ydaq@ zQ$#%1Dq(Z~lY`XNJ}B0P=jZ3g58;1rZ!0}{LTOvi2!0s=X58uTJSk9o@cKWwmvt`< zjWDI{P>DUScVirso@?@GuO3j+6P`^3sts#4z`6Anu+U=t$OZ{4~TuXy|S z=4RioR$rlj9rL`1%hMcTCkg=9pFk6cPZk$^@E|HZohm6gnLS^NBYTwY6s9{Sa2s^7 zpr-HH@87?Z9|r7*n40SwlzK2l)wV1r_U`QLT-hbna7D{5D2`id_{vB3EkUWiO5m>@ z9v?I8gBQErC}MD4;w!WprKGF&1;e7B#Z{=4)ne`a+7{dQQ>zAivr+%A@zz#otWZ;4 zAx%tgpQPk8AxJT~XjAInzkh0%rFC_6JW|LQUWC=(h;!z$!_st>mDdK+jX$-Fn!buDXxjGcIHtgpjvD8(i;v}0meSVkrVKa|=hm?Uoo94DX08|-u+ zm^y7w8Cit|5WOhphx=LeY)n;SW8{my{$1?6y{-s<`tVv`Pk%qm&tj-RIs}=ZC=2fe zA9X8fxw*N?IdLo67fxkPxCxQ%o7F~j;T}UNx8|zC*SR^~>-1C^RFiyK+A~Y4XAD^B z*Yw-dAIkh5B~91{(p6yJoEwnP*ghKo?O-x&|3IZoH|81IoZrZq6qk*agz}dkp2h*snmf<^?=AdQ2?}!nd z&0B?&oSyE-o4oQDKnqM&yKf}Ox}u*%{F@|zwqbe7Ov`2k3Nl0?SZL^YDbSS=25Iu> z6B&DX2^jpUQ!|=?Hf^>s?EI|9C(|={kU=XUaQ0l(`28R;gJeRZ{?-iM<&W{k%ySn^ zjHgXODkAL+Fh>l}_b-cvk8{fTS_IIbMgQ_uzUJ`O>ACahbmS4lJK1Mq^&?vm7a>{SVpdw z!*HXyD2wa{O!tVUA~dqYMM!gUYq8PI$oerou^N#?%7NsdaXi*@CS}w`%_aSU^oOX` zA*Ft@QuxNNRA9;#7848CQLBUOu_g_gFo zh+>wa@$*R-4>5bRW$2#)BSVhBZYF_g$5zMce+c^%$xI)Zj_UnP4k-FQoc#x4*cso0 z#6=#!m?oF3Q|QagTCH`6hy8YaLSSu3S{{jsp1|;hQ?1cho0^~ft+ZTjy5pC zVgZ0ZT{_gn+5Bfx{cQt*U8SjURY98TMGuIpsN`+in5h8sC{U4DLeRl|GRv|B$$pFg zc?yC>_M7x5N?GT`P%FpBp3OCiTt?oSBng%PAkLYkDYBRt64)MwxP6h?0FirA`dAT&Fpqk}H>l9dK#vJ<3Dk=%f>FjN7UYbtipOT`=Em9pxpPD}Qbme}w-00xZ3i0Fyn?fyH|bjK`ywFu^jp&vGJIG}kTdZ7G+Iz0K&YV`OL!O6QAs!eXmiI$i$=cZ)m6r3C( zQUK(KN6jTlfRi8F?qX&+a{}b%Q_}*|;oV19KHRe5B;RN&@?^i!?tL4ur7YQc2Mui9 zA(qgDIVvLAqrbiuz5@oBxt{xl4fA4LpG|b1jWfn@Ki7Qo0uwP{mxVj6U*yIH%Dgdm z;8vujl7BonIJg${w*C2wrJ#a`UJD&gkYAith7>{__!vHlgSEcyRm(>~6jprOz`1c5 zR$D{1fTH@x>76JRomYUI#{z4til7S$Yu@HCKAs<1WhBoKR;7%nyY=yfQK z6@6I0M`_hKf~_8AL#cl~=pbN>-_TLNh^DMd-J2ys#jERR*^8brpGDR1R%Pn zsEOl;KJ--2^iL0?mcsK@ICVwo)fK=o0J?T_kvrO)t0~);((K*e2Q6`Y%|!9{EM*Mm z`*w}FLM8d!D1ri|?6&5Fc?;S&1a;8y!s964_RThI<-h6Cpwp_r?pb77U)|B@nOd&= z$y{7q9Co@sXCtb|1pp@eFDQnd%8<$uV#qWae^;t(zJ;tvkDHNA!L76oe3xyrqLI!R z$Do1$!WXqNA^5LfvVep)u199@XZHayi^0cW`!TkvMYUwnRputwTBFtM#te~%r}axq zOJOzqMs!dYC}91qM2RS=zL|G4aU?@@H9S~ntU6@?wO^lPdJYJs@&?LiYECv}WPUFr zrC^qjDTTTqq3Qr&+!6SP06G8B%&FN<(xQ6 zJqXHtaA{Nn_9pY9mk_$VDzAfg@MPijvS&i%p`04X8G-F zjkWUUq?Ao#w%_tuZDM>0tOHqpnF709DNtN}oWc{n^<*@EFJ>3g_v{&cl zzfA>AzIdr3J~9Acy*e4fx?zqgTrfI84@k5-G~V&>Ugoxt{t%8_xrB#b_gWu)7;zWt z-+c(~*)JPRb}gSY@Ie4v$qRm_AO2w+=$m|_-}S@MRdP;FxCoRm{pEHv+0sKQ@US|fWl7Id)wslZR^ zh|BX^Ph?K*y&ZkTfR6fVkn~;S zO?q4!K}#NE2yMyJZG-V7k4JttlmzCpmzFcOGJa4^-wLy7d)@t?d{f$$+ z{nUB9K$;_0+^dO6o7Z2#8ZIaz^2Q=~y{r>FoZ{q*9g4M`xylZOqths>xlO(6EG-xE z1CW(#gcl3l8gK(R59MK6$d#gIUtMsVQ+CQjcl@30{6)VJ1%dtP6 zB=cSwPOtTol1>#8Tm0~j3sYXh867(9KR>YV%4FX1i~nrf;dVvWVKEcwFnj7P?Z)HL z+!HS9ON-loMpu@%I2ZPLF5hmpk@AiHtFd8h2Rd9#rb8?&ER?bDOfp=`Q5YGPqW1QX z2wwUS?1y))O&*0D)8<`}jhz|OA|{xwCc?T?ZvBVT<|!MtW7=5pt_2KNcWWqU)PFvj z5JUisCmP}u5OAEtSD?(V2wX9v)1vVbeJS|Ew%U*;)biUe;(>``I@{H439DIc=%>QJVE8GevOF z7FZim=yhmcc-MKtUqGN^?&%N39;1dUiI44+gCB0t;PB_$MM9zBLju1jcjd(1f*zw#$Z)z{yx zlL}CC24sSpnfv9JG3;0Q-7U47e>xmh^wfs#mRSJ7N<($b_sE)bGufv727kiQ4S0#L zCJ)M-a><_DjEjZ0=KnI;(5zLJ1K|GNaM3nN$=@P%&CM!S=+(4HP2WLB3*+@49OrmZ zX@SExgrFN(fBY+lF;Pul{;OZ^t;dzzVQR=C({VHZWcW8H>m>j6wuLN)v|<-i!^wvC zgdmF)Jgp4W0`Ue@08R5{zGG`*_=G=ubIIz)amb)+-hkeBGX0?Ldq3on3*l*Fj=hYV z@EG}9ATCc5(!=_LGVeeC{=`8$YnFi_za-NUl2g0+%=i`E=&FxU*G}Q0@HB@exAe-( zY_H7cKMlEyFdZp)w%oDXxnuH^4QaKT#i$!w+B_>D^RO0FFc@--8mEczguJ)FPPxzR zd~y7kUouf$IUuY`5JmrH`@<@I*JuA;mO`U5f=1gdydWDPnK2?eDZ(MpfRt~Lq+4X3o*9QG0hk`m>+lxk9)3WyR z4mWoXV<|`q{NC7r0&jHhz8Z71!IbZZ|J6EM9dSd$0rBo2nUK@G>^ll$m|{Ln*_zYU zjwTO|e63Qjcz`qw?$I@`h7H0nO%cuICwg(^r(Xv$TPxJ=H++E&4>g(_jdz4&MRcdm z$_`)?>{Fil+>spa=gmV7lxW|&n^gFIK6sMcF!zuTAnz%JI7 zI$m)P&fYa!RK`^FYSHl}R-l{r#If=pIbY;Hl*AT;$XgqySsqv}nC@%@Eh_`JJA zSHI{AtFlv}ov6uhsxILgWxjbZSOzB$s)9780Yp;SsmIt4A62>R%qPVcPBXiQcU54*Qo=`<^lTH;<_O{~}m!eXH*@d;BfA#8pG zU-%u6a9w799Z4~*F-5Z;c-r37gY9u&Ic{{DEfa~9M!uasuW7mhPI#Pxw4EDG(bdoR z0}&Zfgb)Vw{VT#<52!tBk-?wt^nv%qsat#akK)8r_rV z$YsfJ%N+rnRsnI3V*P9Ydu14vhtR#2^dL7bS<#?!^~4ABy=YU!uvj5tAu4q&n`-!L zk)tcjz<8GYOh8(h&s5fZGkb_gpEsvGTs$rF)bd4@m|;eBzo_kmr0A1sTWxX1{rJ?(CQE_etO$TK2 z@L}@M3qHkc zT#}G?)3)ANf;u5Hbg;}+BaST`rakW^#fePUdMotc!7>+hf|bWY$7$iw){HPkMDOUw zD1G^Cvw!x*3_ChIGnh8r3R&pRdp}6LMaXuex>xJ!tLq4Q-WC*7GPR7$N9K)UDv;U( z+v}f&kliVzscLHzdZS~~fSq5bJ*nY`rC1%ypC2X$PAuQ8`?wXpJL+^Ts9#qfSW{)A z(7$H$68@(yboKuIy4E$!^^1!O*5m7{KA_&~h$JOr~RK?;T;YsN7G{|fU z^$EeWi1N+%TGR^d1Ox1 zlJnTZsCczH2BB!3!zoXSRsn-F-{3OIkj-cIOdZ9toAN(RrT?cX8Km6Ti(;;+H6!5g zlu&q;J;V~SrF8Ppx8o?WYF^*H#3MkPwD^UyBt!ysg?^Zr50s3);=9=aqNFQN5VK*G zOTT$@QdhQoVb<;>%gM>%VVAAhLs5c6F=%;3YsA&%+nx5^t~nE|2D~I;D=Q)$t*xg-CpsNUS&W>hxbVFtTVY z?(U8V5@AwOR#rAR*6(xz>1>b*6-1%T4}|w~WL|5ebnSgYJPQ3?9Cyi3wvi8Z4e>kf zBx-K$?sHD>mhZEt!Ek#|Y1`8RXpP<(Kg}&HH69E3dw9r}uZ15@=Ma@Px|b#Y;I$tJ zO82UF!*)YbSs#U?h^{dF!3}Lst}x{Z|J6%UQpZI<%@g;9db=U^%xS-@iR-iv{WbOeWKGb+aM}`y z9ZFAeM{{1?9!sBMutWGi-XctVPiYNyXXfXV6A}^~4-w@S zx~=>s@PVgx+k8yC|3%?lkfld|*Wp#XhP4Qof0^sqw(dqmL{ykOgr_s3ZEtS}i|pyv zPoYKBYYmdp($WPmhG%oE=QvU`5KT*@*oJ(K;V19PQ^5Lw+3^tSt)e&~NGGJ|)xOtZ`F^nnSx>PyErP0VF!?6d-0z!`)%NpYrmI@|4zXm`Pw50^}wN?Oq^QaH>Vfl+fa1rvQfSIpzzG6?y*e$CI%)1(d|Qc5&{ zK0$EzAcR77oGrz%E}VmCmBLOJ7fRz6Vg`mQNA!PgwgJ)+0v+B9vDa^Q1y7qe)quqP zk}DwpruOj7}S{ +#include +#include + +/* Ecore_Con client example + * 2010 Mike Blumenkrantz + */ + +/* comment if not using gnutls */ +static void +tls_log_func(int level, const char *str) +{ + fprintf(stderr, "|<%d>| %s", level, str); +} + +Eina_Bool +_add(void *data, int type, Ecore_Con_Event_Server_Add *ev) +{ + printf("Server with ip %s connected!\n", ecore_con_server_ip_get(ev->server)); + ecore_con_server_send(ev->server, "hello!", 6); + ecore_con_server_flush(ev->server); + + return ECORE_CALLBACK_RENEW; +} + + +Eina_Bool +_del(void *data, int type, Ecore_Con_Event_Server_Del *ev) +{ + printf("Lost server with ip %s!\n", ecore_con_server_ip_get(ev->server)); + ecore_main_loop_quit(); + return ECORE_CALLBACK_RENEW; +} + +Eina_Bool +_data(void *data, int type, Ecore_Con_Event_Server_Data *ev) +{ + char fmt[128]; + + snprintf(fmt, sizeof(fmt), + "Received %i bytes from server:\n" + ">>>>>\n" + "%%.%is\n" + ">>>>>\n", + ev->size, ev->size); + + printf(fmt, ev->data); + return ECORE_CALLBACK_RENEW; +} +int main() +{ + Ecore_Con_Server *svr; + Eina_Iterator *it; + const char *ca; + + eina_init(); + ecore_init(); + ecore_con_init(); + +/* comment if not using gnutls */ + gnutls_global_set_log_level(9); + gnutls_global_set_log_function(tls_log_func); + + if (!(it = eina_file_ls("/etc/ssl/certs"))) + exit(1); + + if (!(svr = ecore_con_server_connect(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_MIXED, "www.verisign.com", 443, NULL))) + exit(1); + + /* add all the CAs */ + EINA_ITERATOR_FOREACH(it, ca) + { + if (!ecore_con_ssl_server_cafile_add(svr, ca)) + printf("Could not load CA: %s!\n", ca); + eina_stringshare_del(ca); + } + + eina_iterator_free(it); + ecore_con_ssl_server_verify(svr); + +/* set event handler for server connect */ + ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, (Ecore_Event_Handler_Cb)_add, NULL); +/* set event handler for server disconnect */ + ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, (Ecore_Event_Handler_Cb)_del, NULL); +/* set event handler for receiving server data */ + ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, (Ecore_Event_Handler_Cb)_data, NULL); + +/* start client */ + ecore_main_loop_begin(); +} diff --git a/examples/ecore_con_server_example.c b/examples/ecore_con_server_example.c new file mode 100644 index 0000000..5423eb1 --- /dev/null +++ b/examples/ecore_con_server_example.c @@ -0,0 +1,81 @@ +#include +#include +#include + +/* Ecore_Con server example + * 2010 Mike Blumenkrantz + */ + +/* comment if not using gnutls */ +static void +tls_log_func(int level, const char *str) +{ + fprintf(stderr, "|<%d>| %s", level, str); +} + +Eina_Bool +_add(void *data, int type, Ecore_Con_Event_Client_Add *ev) +{ + printf("Client with ip %s connected!\n", ecore_con_client_ip_get(ev->client)); + ecore_con_client_send(ev->client, "hello!", 6); +// ecore_con_client_flush(ev->client); + ecore_con_client_timeout_set(ev->client, 5); + + return ECORE_CALLBACK_RENEW; +} + + +Eina_Bool +_del(void *data, int type, Ecore_Con_Event_Client_Del *ev) +{ + printf("Lost client with ip %s!\n", ecore_con_client_ip_get(ev->client)); + ecore_main_loop_quit(); + return ECORE_CALLBACK_RENEW; +} + +Eina_Bool +_data(void *data, int type, Ecore_Con_Event_Client_Data *ev) +{ + char fmt[128]; + + snprintf(fmt, sizeof(fmt), + "Received %i bytes from client:\n" + ">>>>>\n" + "%%.%is\n" + ">>>>>\n", + ev->size, ev->size); + + printf(fmt, ev->data); + return ECORE_CALLBACK_RENEW; +} +int main() +{ + Ecore_Con_Server *svr; + eina_init(); + ecore_init(); + ecore_con_init(); + +/* comment if not using gnutls */ + gnutls_global_set_log_level(9); + gnutls_global_set_log_function(tls_log_func); + + +/* to use a PEM certificate with TLS and SSL3, uncomment the lines below */ + if (!(svr = ecore_con_server_add(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_TLS | ECORE_CON_USE_SSL3 | ECORE_CON_LOAD_CERT, "127.0.0.1", 8080, NULL))) + +/* to use simple tcp with ssl/tls, use this line */ +// if (!ecore_con_server_add(ECORE_CON_REMOTE_TCP | ECORE_CON_USE_SSL3, "127.0.0.1", 8080, NULL)) + exit(1); + + ecore_con_ssl_server_cert_add(svr, "server.pem"); + ecore_con_ssl_server_privkey_add(svr, "server.pem"); +/* set event handler for client connect */ + ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, (Ecore_Event_Handler_Cb)_add, NULL); +/* set event handler for client disconnect */ + ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, (Ecore_Event_Handler_Cb)_del, NULL); +/* set event handler for receiving client data */ + ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, (Ecore_Event_Handler_Cb)_data, NULL); + +/* start server */ + ecore_main_loop_begin(); +} diff --git a/examples/ecore_fd_handler_example.c b/examples/ecore_fd_handler_example.c new file mode 100644 index 0000000..b67e04e --- /dev/null +++ b/examples/ecore_fd_handler_example.c @@ -0,0 +1,195 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Ecore_Fd_Handler example + * 2010 Mike Blumenkrantz + * compile with gcc $(pkgconfig --cflags --libs gnutls ecore) + */ + + +#define print(...) fprintf(stderr, "line %i: ", __LINE__); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\n") + +static int done = 0; + +static void +tls_log_func (int level, const char *str) +{ + fprintf(stderr, "|<%d>| %s", level, str); +} + +static const char* +SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_description_t status) +{ + switch (status) + { + case GNUTLS_HANDSHAKE_HELLO_REQUEST: + return "Hello request"; + case GNUTLS_HANDSHAKE_CLIENT_HELLO: + return "Client hello"; + case GNUTLS_HANDSHAKE_SERVER_HELLO: + return "Server hello"; + case GNUTLS_HANDSHAKE_CERTIFICATE_PKT: + return "Certificate packet"; + case GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE: + return "Server key exchange"; + case GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST: + return "Certificate request"; + case GNUTLS_HANDSHAKE_SERVER_HELLO_DONE: + return "Server hello done"; + case GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY: + return "Certificate verify"; + case GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE: + return "Client key exchange"; + case GNUTLS_HANDSHAKE_FINISHED: + return "Finished"; + case GNUTLS_HANDSHAKE_SUPPLEMENTAL: + return "Supplemental"; + } + return NULL; +} + +/* Connects to the peer and returns a socket + * descriptor. + */ +static int +tcp_connect (void) +{ + const char *PORT = "443"; + const char *SERVER = "69.58.181.89"; //verisign.com + int err, sd; + int flag = 1, curstate = 0; + struct sockaddr_in sa; + + /* sets some fd options such as nonblock */ + sd = socket (AF_INET, SOCK_STREAM, 0); + fcntl(sd, F_SETFL, O_NONBLOCK); + fcntl(sd, F_SETFD, FD_CLOEXEC); + setsockopt(sd, SOL_SOCKET, SO_REUSEADDR, (const void *)&curstate, sizeof(curstate)); + + setsockopt(sd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int)); + + memset (&sa, '\0', sizeof (sa)); + sa.sin_family = AF_INET; + sa.sin_port = htons (atoi (PORT)); + inet_pton (AF_INET, SERVER, &sa.sin_addr); + + /* connects to server + */ + err = connect (sd, (struct sockaddr *) &sa, sizeof (sa)); + if ((err < 0) && (errno != EINPROGRESS)) + { + print("Connect error\n"); + exit (1); + } + + return sd; +} + +/* closes the given socket descriptor. + */ +static void +tcp_close (int sd) +{ + shutdown (sd, SHUT_RDWR); /* no more receptions */ + close (sd); +} + +static Eina_Bool +_process_data(gnutls_session_t client, Ecore_Fd_Handler *fd_handler) +{ + static int ret, lastret; + static unsigned int count = 0; + + if (!done) + { + lastret = ret; + ret = gnutls_handshake (client); + count++; + if (gnutls_record_get_direction(client)) + ecore_main_fd_handler_active_set(fd_handler, ECORE_FD_WRITE); + else + ecore_main_fd_handler_active_set(fd_handler, ECORE_FD_READ); + /* avoid printing messages infinity times */ + if (lastret != ret) + { + print("gnutls returned with: %s - %s", gnutls_strerror_name(ret), gnutls_strerror(ret)); + if ((ret == GNUTLS_E_WARNING_ALERT_RECEIVED) || (ret == GNUTLS_E_FATAL_ALERT_RECEIVED)) + print("Also received alert: %s", gnutls_alert_get_name(gnutls_alert_get(client))); + print("last out: %s", SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_get_last_out(client))); + print("last in: %s", SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_get_last_in(client))); + } + + if (gnutls_error_is_fatal(ret)) + { + print("yarrr this be an error!"); + exit(1); + } + + } + if (ret == GNUTLS_E_SUCCESS) + { + done = 1; + print("Handshake successful in %u handshake calls!", count); + ecore_main_loop_quit(); + } + + return ECORE_CALLBACK_RENEW; +} + +int +main (void) +{ + /* credentials */ + gnutls_anon_client_credentials_t c_anoncred; + gnutls_certificate_credentials_t c_certcred; + + gnutls_session_t client; + int sd; + + /* General init. */ + gnutls_global_init (); + ecore_init(); + gnutls_global_set_log_function (tls_log_func); + gnutls_global_set_log_level (6); + + /* Init client */ + gnutls_anon_allocate_client_credentials (&c_anoncred); + gnutls_certificate_allocate_credentials (&c_certcred); + gnutls_init (&client, GNUTLS_CLIENT); + /* set very specific priorities */ + gnutls_priority_set_direct(client, "NONE:%VERIFY_ALLOW_X509_V1_CA_CRT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+COMP-DEFLATE:+COMP-NULL:+CTYPE-X509:+SHA1:+SHA256:+SHA384:+SHA512:+AES-256-CBC:+AES-128-CBC:+3DES-CBC:+VERS-TLS1.2:+VERS-TLS1.1:+VERS-TLS1.0:+VERS-SSL3.0", NULL); + gnutls_credentials_set (client, GNUTLS_CRD_ANON, c_anoncred); + gnutls_credentials_set (client, GNUTLS_CRD_CERTIFICATE, c_certcred); + gnutls_server_name_set(client, GNUTLS_NAME_DNS, "www.verisign.com", strlen("www.verisign.com")); + + + /* connect to the peer + */ + sd = tcp_connect (); + + /* associate gnutls with socket */ + gnutls_transport_set_ptr (client, (gnutls_transport_ptr_t) sd); + /* add a callback for data being available for send/receive on socket */ + if (!ecore_main_fd_handler_add(sd, ECORE_FD_READ | ECORE_FD_WRITE, (Ecore_Fd_Cb)_process_data, client, NULL, NULL)) + { + print("could not create fd handler!"); + exit(1); + } + /* begin main loop */ + ecore_main_loop_begin(); + + gnutls_bye (client, GNUTLS_SHUT_RDWR); + + gnutls_deinit (client); + + tcp_close (sd); + + return 0; +} diff --git a/m4/ecore_check_module.m4 b/m4/ecore_check_module.m4 index 3980e5b..1679b34 100644 --- a/m4/ecore_check_module.m4 +++ b/m4/ecore_check_module.m4 @@ -1,4 +1,4 @@ -dnl use: ECORE_CHECK_MODULE(Foo, default-enabled, description[, dependancy[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]]) +dnl use: ECORE_CHECK_MODULE(Foo, default-enabled, description[, dependency[, ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]]) AC_DEFUN([ECORE_CHECK_MODULE], [ m4_pushdef([UP], m4_translit([[$1]], [-a-z], [_A-Z]))dnl diff --git a/m4/ecore_check_options.m4 b/m4/ecore_check_options.m4 index 81657ad..fb7031a 100644 --- a/m4/ecore_check_options.m4 +++ b/m4/ecore_check_options.m4 @@ -165,14 +165,14 @@ AC_ARG_ENABLE([gnutls], ]) if test "x${_ecore_want_gnutls}" = "xyes" -o "x${_ecore_want_gnutls}" = "xauto" ; then - PKG_CHECK_MODULES([TLS], [gnutls], + PKG_CHECK_MODULES([TLS], [gnutls >= 2.10.2], [ AC_DEFINE([USE_GNUTLS], [1], [Use GnuTLS]) _ecore_have_gnutls="yes" ], [_ecore_have_gnutls="no"]) # for ecore_con_ssl.c - PKG_CHECK_MODULES([TLS2], [gnutls >= 2.0.0], + PKG_CHECK_MODULES([TLS2], [gnutls >= 2.10.2], [AC_DEFINE(USE_GNUTLS2, 1, [Use GnuTLS 2 or higher])], [dummy="no"]) if test "x$_ecore_have_gnutls" = "xyes";then diff --git a/po/pt.po b/po/pt.po index 3719f6d..2037dbb 100644 --- a/po/pt.po +++ b/po/pt.po @@ -7,7 +7,7 @@ msgstr "" "Project-Id-Version: ecore\n" "Report-Msgid-Bugs-To: enlightenment-devel@lists.sourceforge.net\n" "POT-Creation-Date: 2010-08-16 17:14+0900\n" -"PO-Revision-Date: 2010-08-11 18:57-0000\n" +"PO-Revision-Date: 2010-10-06 12:37-0000\n" "Last-Translator: Sérgio Marques \n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -68,19 +68,25 @@ msgstr "ERRO: opção desconhecida -%c.\n" msgid "ERROR: " msgstr "ERRO: " -#: src/lib/ecore/ecore_getopt.c:853 src/lib/ecore/ecore_getopt.c:969 -#: src/lib/ecore/ecore_getopt.c:982 src/lib/ecore/ecore_getopt.c:994 -#: src/lib/ecore/ecore_getopt.c:1008 src/lib/ecore/ecore_getopt.c:1052 -#: src/lib/ecore/ecore_getopt.c:1161 src/lib/ecore/ecore_getopt.c:1198 +#: src/lib/ecore/ecore_getopt.c:853 +#: src/lib/ecore/ecore_getopt.c:969 +#: src/lib/ecore/ecore_getopt.c:982 +#: src/lib/ecore/ecore_getopt.c:994 +#: src/lib/ecore/ecore_getopt.c:1008 +#: src/lib/ecore/ecore_getopt.c:1052 +#: src/lib/ecore/ecore_getopt.c:1161 +#: src/lib/ecore/ecore_getopt.c:1198 msgid "value has no pointer set.\n" msgstr "o valor não está definido.\n" -#: src/lib/ecore/ecore_getopt.c:882 src/lib/ecore/ecore_getopt.c:1072 +#: src/lib/ecore/ecore_getopt.c:882 +#: src/lib/ecore/ecore_getopt.c:1072 #, c-format msgid "unknown boolean value %s.\n" msgstr "valor booleano desconhecido %s.\n" -#: src/lib/ecore/ecore_getopt.c:926 src/lib/ecore/ecore_getopt.c:1152 +#: src/lib/ecore/ecore_getopt.c:926 +#: src/lib/ecore/ecore_getopt.c:1152 #, c-format msgid "invalid number format %s\n" msgstr "formato do número inválido %s\n" @@ -148,11 +154,11 @@ msgstr "ERRO: nenhum valor fornecido.\n" #: src/lib/ecore/ecore_getopt.c:1634 msgid "ERROR: no arguments provided.\n" -msgstr "ERRO: nehum argumento fornecido.\n" +msgstr "ERRO: nenhum argumento fornecido.\n" #: src/lib/ecore/ecore_getopt.c:1660 msgid "ERROR: invalid options found." -msgstr "ERRO: foram encontradas opções inválidas." +msgstr "ERRO: encontradas opções inválidas." #: src/lib/ecore/ecore_getopt.c:1666 #, c-format @@ -167,9 +173,10 @@ msgstr " Veja -%c.\n" #: src/lib/ecore/ecore_getopt.c:1705 #, c-format msgid "ERROR: incorrect geometry value '%s'\n" -msgstr "ERRO: valor geométrico incorrecto '%s'\n" +msgstr "ERRO: valor geométrico incorreto \"%s\"\n" #: src/lib/ecore/ecore_getopt.c:1728 #, c-format msgid "ERROR: incorrect size value '%s'\n" -msgstr "ERRO: tamanho incorrecto '%s'\n" +msgstr "ERRO: tamanho incorreto \"%s\"\n" + diff --git a/src/lib/ecore/Ecore.h b/src/lib/ecore/Ecore.h index 8c71d73..b786de6 100644 --- a/src/lib/ecore/Ecore.h +++ b/src/lib/ecore/Ecore.h @@ -33,28 +33,6 @@ # endif #endif /* ! _WIN32 */ -/** - * @file Ecore.h - * @brief The file that provides the program utility, main loop and timer - * functions. - * - * This header provides the Ecore event handling loop. For more - * details, see @ref Ecore_Main_Loop_Group. - * - * For the main loop to be of any use, you need to be able to add events - * and event handlers. Events for file descriptor events are covered in - * @ref Ecore_FD_Handler_Group. - * - * Time functions are covered in @ref Ecore_Time_Group. - * - * There is also provision for callbacks for when the loop enters or - * exits an idle state. See @ref Idle_Group for more information. - * - * Functions are also provided for spawning child processes using fork. - * See @ref Ecore_Exe_Basic_Group and @ref Ecore_Exe_Signal_Group for - * more details. - */ - #ifdef _WIN32 # include #elif (defined (__FreeBSD__) && (__FreeBSD_version >= 420001)) || defined (__OpenBSD__) @@ -71,6 +49,29 @@ extern "C" { #endif + /** + * @defgroup Ecore_Group Ecore - Main Loop and Job Functions. + * @brief The file that provides the program utility, main loop and timer + * functions. + * + * This header provides the Ecore event handling loop. For more + * details, see @ref Ecore_Main_Loop_Group. + * + * For the main loop to be of any use, you need to be able to add events + * and event handlers. Events for file descriptor events are covered in + * @ref Ecore_FD_Handler_Group. + * + * Time functions are covered in @ref Ecore_Time_Group. + * + * There is also provision for callbacks for when the loop enters or + * exits an idle state. See @ref Idle_Group for more information. + * + * Functions are also provided for spawning child processes using fork. + * See @ref Ecore_Exe_Group for more details. + * + * @{ + */ + #define ECORE_VERSION_MAJOR 1 #define ECORE_VERSION_MINOR 0 @@ -101,29 +102,29 @@ extern "C" { #define ECORE_EXE_PRIORITY_INHERIT 9999 EAPI extern int ECORE_EXE_EVENT_ADD; /**< A child process has been added */ - EAPI extern int ECORE_EXE_EVENT_DEL; /**< A child process has been deleted (it exited, naming consistant with the rest of ecore). */ + EAPI extern int ECORE_EXE_EVENT_DEL; /**< A child process has been deleted (it exited, naming consistent with the rest of ecore). */ EAPI extern int ECORE_EXE_EVENT_DATA; /**< Data from a child process. */ EAPI extern int ECORE_EXE_EVENT_ERROR; /**< Errors from a child process. */ enum _Ecore_Fd_Handler_Flags { - ECORE_FD_READ = 1, /**< Fd Read mask */ - ECORE_FD_WRITE = 2, /**< Fd Write mask */ - ECORE_FD_ERROR = 4 /**< Fd Error mask */ + ECORE_FD_READ = 1, /**< Fd Read mask */ + ECORE_FD_WRITE = 2, /**< Fd Write mask */ + ECORE_FD_ERROR = 4 /**< Fd Error mask */ }; typedef enum _Ecore_Fd_Handler_Flags Ecore_Fd_Handler_Flags; enum _Ecore_Exe_Flags /* flags for executing a child with its stdin and/or stdout piped back */ { - ECORE_EXE_PIPE_READ = 1, /**< Exe Pipe Read mask */ - ECORE_EXE_PIPE_WRITE = 2, /**< Exe Pipe Write mask */ - ECORE_EXE_PIPE_ERROR = 4, /**< Exe Pipe error mask */ - ECORE_EXE_PIPE_READ_LINE_BUFFERED = 8, /**< Reads are buffered until a newline and delivered 1 event per line */ - ECORE_EXE_PIPE_ERROR_LINE_BUFFERED = 16, /**< Errors are buffered until a newline and delivered 1 event per line */ - ECORE_EXE_PIPE_AUTO = 32, /**< stdout and stderr are buffered automatically */ - ECORE_EXE_RESPAWN = 64, /**< FIXME: Exe is restarted if it dies */ - ECORE_EXE_USE_SH = 128, /**< Use /bin/sh to run the command. */ - ECORE_EXE_NOT_LEADER = 256 /**< Do not use setsid() to have the executed process be its own session leader */ + ECORE_EXE_PIPE_READ = 1, /**< Exe Pipe Read mask */ + ECORE_EXE_PIPE_WRITE = 2, /**< Exe Pipe Write mask */ + ECORE_EXE_PIPE_ERROR = 4, /**< Exe Pipe error mask */ + ECORE_EXE_PIPE_READ_LINE_BUFFERED = 8, /**< Reads are buffered until a newline and delivered 1 event per line */ + ECORE_EXE_PIPE_ERROR_LINE_BUFFERED = 16, /**< Errors are buffered until a newline and delivered 1 event per line */ + ECORE_EXE_PIPE_AUTO = 32, /**< stdout and stderr are buffered automatically */ + ECORE_EXE_RESPAWN = 64, /**< FIXME: Exe is restarted if it dies */ + ECORE_EXE_USE_SH = 128, /**< Use /bin/sh to run the command. */ + ECORE_EXE_NOT_LEADER = 256 /**< Do not use setsid() to have the executed process be its own session leader */ }; typedef enum _Ecore_Exe_Flags Ecore_Exe_Flags; @@ -140,7 +141,7 @@ extern "C" { enum _Ecore_Poller_Type /* Poller types */ { - ECORE_POLLER_CORE = 0 /**< The core poller interval */ + ECORE_POLLER_CORE = 0 /**< The core poller interval */ }; typedef enum _Ecore_Poller_Type Ecore_Poller_Type; @@ -210,7 +211,7 @@ extern "C" { typedef void (*Ecore_Thread_Heavy_Cb) (Ecore_Thread *thread, void *data); /** * @typedef Ecore_Thread_Notify_Cb Ecore_Thread_Notify_Cb - * A callback used by the main loop to receive data sent by an @ref Ecore_Thread. + * A callback used by the main loop to receive data sent by an @ref Ecore_Thread_Group. */ typedef void (*Ecore_Thread_Notify_Cb) (Ecore_Thread *thread, void *msg_data, void *data); /** @@ -244,94 +245,118 @@ extern "C" { struct _Ecore_Event_Signal_User /** User signal event */ { - int number; /**< The signal number. Either 1 or 2 */ - void *ext_data; /**< Extension data - not used */ + int number; /**< The signal number. Either 1 or 2 */ + void *ext_data; /**< Extension data - not used */ #ifndef _WIN32 - siginfo_t data; /**< Signal info */ + siginfo_t data; /**< Signal info */ #endif }; struct _Ecore_Event_Signal_Hup /** Hup signal event */ { - void *ext_data; /**< Extension data - not used */ + void *ext_data; /**< Extension data - not used */ #ifndef _WIN32 - siginfo_t data; /**< Signal info */ + siginfo_t data; /**< Signal info */ #endif }; struct _Ecore_Event_Signal_Exit /** Exit request event */ { - unsigned int interrupt : 1; /**< Set if the exit request was an interrupt signal*/ - unsigned int quit : 1; /**< set if the exit request was a quit signal */ - unsigned int terminate : 1; /**< Set if the exit request was a terminate singal */ - void *ext_data; /**< Extension data - not used */ + unsigned int interrupt : 1; /**< Set if the exit request was an interrupt signal*/ + unsigned int quit : 1; /**< set if the exit request was a quit signal */ + unsigned int terminate : 1; /**< Set if the exit request was a terminate singal */ + void *ext_data; /**< Extension data - not used */ #ifndef _WIN32 - siginfo_t data; /**< Signal info */ + siginfo_t data; /**< Signal info */ #endif }; struct _Ecore_Event_Signal_Power /** Power event */ { - void *ext_data; /**< Extension data - not used */ + void *ext_data; /**< Extension data - not used */ #ifndef _WIN32 - siginfo_t data; /**< Signal info */ + siginfo_t data; /**< Signal info */ #endif }; struct _Ecore_Event_Signal_Realtime /** Realtime event */ { - int num; /**< The realtime signal's number */ + int num; /**< The realtime signal's number */ #ifndef _WIN32 - siginfo_t data; /**< Signal info */ + siginfo_t data; /**< Signal info */ #endif }; struct _Ecore_Exe_Event_Add /** Process add event */ { - Ecore_Exe *exe; /**< The handle to the added process */ - void *ext_data; /**< Extension data - not used */ + Ecore_Exe *exe; /**< The handle to the added process */ + void *ext_data; /**< Extension data - not used */ }; struct _Ecore_Exe_Event_Del /** Process exit event */ { - pid_t pid; /**< The process ID of the process that exited */ - int exit_code; /**< The exit code of the process */ - Ecore_Exe *exe; /**< The handle to the exited process, or NULL if not found */ - int exit_signal; /** < The signal that caused the process to exit */ - unsigned int exited : 1; /** < set to 1 if the process exited of its own accord */ - unsigned int signalled : 1; /** < set to 1 id the process exited due to uncaught signal */ - void *ext_data; /**< Extension data - not used */ + pid_t pid; /**< The process ID of the process that exited */ + int exit_code; /**< The exit code of the process */ + Ecore_Exe *exe; /**< The handle to the exited process, or NULL if not found */ + int exit_signal; /** < The signal that caused the process to exit */ + unsigned int exited : 1; /** < set to 1 if the process exited of its own accord */ + unsigned int signalled : 1; /** < set to 1 id the process exited due to uncaught signal */ + void *ext_data; /**< Extension data - not used */ #ifndef _WIN32 - siginfo_t data; /**< Signal info */ + siginfo_t data; /**< Signal info */ #endif }; struct _Ecore_Exe_Event_Data_Line /**< Lines from a child process */ { char *line; - int size; + int size; }; struct _Ecore_Exe_Event_Data /** Data from a child process event */ { - Ecore_Exe *exe; /**< The handle to the process */ - void *data; /**< the raw binary data from the child process that was recieved */ - int size; /**< the size of this data in bytes */ - Ecore_Exe_Event_Data_Line *lines; /**< an array of line data if line buffered, the last one has it's line member set to NULL */ + Ecore_Exe *exe; /**< The handle to the process */ + void *data; /**< the raw binary data from the child process that was received */ + int size; /**< the size of this data in bytes */ + Ecore_Exe_Event_Data_Line *lines; /**< an array of line data if line buffered, the last one has it's line member set to NULL */ }; + /** + * @defgroup Ecore_Init_Group Ecore initialisation and shutdown functions. + */ + EAPI int ecore_init(void); EAPI int ecore_shutdown(void); + /** + * @} + */ + + /** + * @defgroup Ecore_Application_Group Ecore Application functions + * + * @{ + */ + EAPI void ecore_app_args_set(int argc, const char **argv); EAPI void ecore_app_args_get(int *argc, char ***argv); EAPI void ecore_app_restart(void); + /** + * @} + */ + + /** + * @defgroup Ecore_Event_Group Ecore Event functions + * + * @{ + */ + EAPI Ecore_Event_Handler *ecore_event_handler_add(int type, Ecore_Event_Handler_Cb func, const void *data); EAPI void *ecore_event_handler_del(Ecore_Event_Handler *event_handler); EAPI Ecore_Event *ecore_event_add(int type, void *ev, Ecore_End_Cb func_free, void *data); @@ -342,6 +367,15 @@ extern "C" { EAPI int ecore_event_current_type_get(void); EAPI void *ecore_event_current_event_get(void); + /** + * @} + */ + + /** + * @defgroup Ecore_Exe_Group Process Spawning Functions + * + * @{ + */ EAPI void ecore_exe_run_priority_set(int pri); EAPI int ecore_exe_run_priority_get(void); @@ -369,6 +403,16 @@ extern "C" { EAPI void ecore_exe_signal(Ecore_Exe *exe, int num); EAPI void ecore_exe_hup(Ecore_Exe *exe); + /** + * @} + */ + + /** + * @defgroup Ecore_Idle_Group Ecore Idle functions + * + * @{ + */ + EAPI Ecore_Idler *ecore_idler_add(Ecore_Task_Cb func, const void *data); EAPI void *ecore_idler_del(Ecore_Idler *idler); @@ -379,6 +423,16 @@ extern "C" { EAPI Ecore_Idle_Exiter *ecore_idle_exiter_add(Ecore_Task_Cb func, const void *data); EAPI void *ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter); + /** + * @} + */ + + /** + * @defgroup Ecore_Main Loop_Group Ecore Main Loop functions + * + * @{ + */ + EAPI void ecore_main_loop_iterate(void); EAPI void ecore_main_loop_select_func_set(Ecore_Select_Function func); @@ -394,57 +448,82 @@ extern "C" { EAPI void ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Prep_Cb func, const void *data); EAPI void *ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler); EAPI int ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler); - EAPI int ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags); + EAPI Eina_Bool ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags); EAPI void ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags); EAPI Ecore_Win32_Handler *ecore_main_win32_handler_add(void *h, Ecore_Fd_Win32_Cb func, const void *data); EAPI void *ecore_main_win32_handler_del(Ecore_Win32_Handler *win32_handler); + /** + * @} + */ + + /** + * @defgroup Ecore_Pipe_Group Pipe wrapper + * + * @{ + */ + EAPI Ecore_Pipe *ecore_pipe_add(Ecore_Pipe_Cb handler, const void *data); EAPI void *ecore_pipe_del(Ecore_Pipe *p); EAPI Eina_Bool ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes); EAPI void ecore_pipe_write_close(Ecore_Pipe *p); EAPI void ecore_pipe_read_close(Ecore_Pipe *p); + /** + * @} + */ + /** + * @defgroup Ecore_Thread_Group Ecore Thread functions + * + * @{ + */ - EAPI Ecore_Thread *ecore_thread_run(Ecore_Cb, - Ecore_Cb, - Ecore_Cb, + EAPI Ecore_Thread *ecore_thread_run(Ecore_Thread_Heavy_Cb func_blocking, + Ecore_Cb func_end, + Ecore_Cb func_cancel, const void *data); - EAPI Ecore_Thread *ecore_long_run(Ecore_Thread_Heavy_Cb, - Ecore_Thread_Notify_Cb, - Ecore_Cb, - Ecore_Cb, - const void *data, - Eina_Bool try_no_queue); + EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Heavy_Cb func_heavy, + Ecore_Thread_Notify_Cb func_notify, + Ecore_Cb func_end, + Ecore_Cb func_cancel, + const void *data, + Eina_Bool try_no_queue); EAPI Eina_Bool ecore_thread_cancel(Ecore_Thread *thread); EAPI Eina_Bool ecore_thread_check(Ecore_Thread *thread); - EAPI Eina_Bool ecore_thread_notify(Ecore_Thread *thread, const void *msg_data); + EAPI Eina_Bool ecore_thread_feedback(Ecore_Thread *thread, const void *msg_data); EAPI int ecore_thread_active_get(void); EAPI int ecore_thread_pending_get(void); - EAPI int ecore_thread_pending_long_get(void); + EAPI int ecore_thread_pending_feedback_get(void); EAPI int ecore_thread_pending_total_get(void); EAPI int ecore_thread_max_get(void); EAPI void ecore_thread_max_set(int num); EAPI void ecore_thread_max_reset(void); EAPI int ecore_thread_available_get(void); - EAPI Eina_Bool ecore_thread_local_data_add(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct); EAPI void *ecore_thread_local_data_set(Ecore_Thread *thread, const char *key, void *value, Eina_Free_Cb cb); - EAPI void *ecore_thread_local_data_find(Ecore_Thread *thread, const char *key); + EAPI void *ecore_thread_local_data_find(Ecore_Thread *thread, const char *key); EAPI Eina_Bool ecore_thread_local_data_del(Ecore_Thread *thread, const char *key); EAPI Eina_Bool ecore_thread_global_data_add(const char *key, void *value, Eina_Free_Cb cb, Eina_Bool direct); EAPI void *ecore_thread_global_data_set(const char *key, void *value, Eina_Free_Cb cb); - EAPI void *ecore_thread_global_data_find(const char *key); + EAPI void *ecore_thread_global_data_find(const char *key); EAPI Eina_Bool ecore_thread_global_data_del(const char *key); - EAPI void *ecore_thread_global_data_wait(const char *key, double seconds); - + EAPI void *ecore_thread_global_data_wait(const char *key, double seconds); + /** + * @} + */ + /** + * @defgroup Ecore_Time_Group Ecore Time functions + * + * @{ + */ EAPI double ecore_time_get(void); + EAPI double ecore_time_unix_get(void); EAPI double ecore_loop_time_get(void); EAPI Ecore_Timer *ecore_timer_add(double in, Ecore_Task_Cb func, const void *data); @@ -456,17 +535,36 @@ extern "C" { EAPI void ecore_timer_thaw(Ecore_Timer *timer); EAPI void ecore_timer_delay(Ecore_Timer *timer, double add); EAPI double ecore_timer_pending_get(Ecore_Timer *timer); - EAPI double ecore_timer_precision_get(void); EAPI void ecore_timer_precision_set(double precision); + /** + * @} + */ + + /** + * @defgroup Ecore_Animator_Group Ecore Animator functions + * + * @{ + */ + EAPI Ecore_Animator *ecore_animator_add(Ecore_Task_Cb func, const void *data); EAPI void *ecore_animator_del(Ecore_Animator *animator); - EAPI void ecore_animator_freeze(Ecore_Animator *animator); - EAPI void ecore_animator_thaw(Ecore_Animator *animator); + EAPI void ecore_animator_freeze(Ecore_Animator *animator); + EAPI void ecore_animator_thaw(Ecore_Animator *animator); EAPI void ecore_animator_frametime_set(double frametime); EAPI double ecore_animator_frametime_get(void); + /** + * @} + */ + + /** + * @defgroup Ecore_Poller_Group Ecore Poll functions + * + * @{ + */ + EAPI void ecore_poller_poll_interval_set(Ecore_Poller_Type type, double poll_time); EAPI double ecore_poller_poll_interval_get(Ecore_Poller_Type type); EAPI Eina_Bool ecore_poller_poller_interval_set(Ecore_Poller *poller, int interval); @@ -474,9 +572,27 @@ extern "C" { EAPI Ecore_Poller *ecore_poller_add(Ecore_Poller_Type type, int interval, Ecore_Task_Cb func, const void *data); EAPI void *ecore_poller_del(Ecore_Poller *poller); + /** + * @} + */ + + /** + * @defgroup Ecore_Job_Group Ecore Job functions + * + * @{ + */ + EAPI Ecore_Job *ecore_job_add(Ecore_Cb func, const void *data); EAPI void *ecore_job_del(Ecore_Job *job); + /** + * @} + */ + + /** + * @} + */ + #ifdef __cplusplus } #endif diff --git a/src/lib/ecore/Ecore_Getopt.h b/src/lib/ecore/Ecore_Getopt.h index f2ea6f7..18a8459 100644 --- a/src/lib/ecore/Ecore_Getopt.h +++ b/src/lib/ecore/Ecore_Getopt.h @@ -114,15 +114,15 @@ extern "C" { Ecore_Getopt_Desc_Arg_Requirement arg_req; union { - const char *strv; - unsigned char boolv; - short shortv; - int intv; - long longv; - unsigned short ushortv; - unsigned int uintv; - unsigned long ulongv; - double doublev; + const char *strv; + unsigned char boolv; + short shortv; + int intv; + long longv; + unsigned short ushortv; + unsigned int uintv; + unsigned long ulongv; + double doublev; } def; }; @@ -144,12 +144,12 @@ extern "C" { Ecore_Getopt_Action action; /**< define how to handle it */ union { - const Ecore_Getopt_Desc_Store store; - const void *store_const; - const char *const *choices; /* NULL terminated. */ - const Ecore_Getopt_Type append_type; - const Ecore_Getopt_Desc_Callback callback; - const void *dummy; + const Ecore_Getopt_Desc_Store store; + const void *store_const; + const char *const *choices; /* NULL terminated. */ + const Ecore_Getopt_Type append_type; + const Ecore_Getopt_Desc_Callback callback; + const void *dummy; } action_param; }; @@ -166,12 +166,12 @@ extern "C" { }; #define ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, arg_requirement, default_value) \ - {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_STORE, \ + {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_STORE, \ {.store = {type, arg_requirement, default_value}}} #define ECORE_GETOPT_STORE(shortname, longname, help, type) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \ - ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \ + ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {}) #define ECORE_GETOPT_STORE_STR(shortname, longname, help) \ ECORE_GETOPT_STORE(shortname, longname, help, ECORE_GETOPT_TYPE_STR) @@ -194,8 +194,8 @@ extern "C" { #define ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, type) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, \ - ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, type, \ + ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, {}) #define ECORE_GETOPT_STORE_METAVAR_STR(shortname, longname, help, metavar) \ ECORE_GETOPT_STORE_METAVAR(shortname, longname, help, metavar, ECORE_GETOPT_TYPE_STR) @@ -218,155 +218,155 @@ extern "C" { #define ECORE_GETOPT_STORE_DEF(shortname, longname, help, type, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \ - ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL, \ - default_value) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, NULL, type, \ + ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL, \ + default_value) #define ECORE_GETOPT_STORE_DEF_STR(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_STR, \ - {.strv = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_STR, \ + {.strv = default_value}) #define ECORE_GETOPT_STORE_DEF_BOOL(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_BOOL, \ - {.boolv = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_BOOL, \ + {.boolv = default_value}) #define ECORE_GETOPT_STORE_DEF_SHORT(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_SHORT, \ - {.shortv = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_SHORT, \ + {.shortv = default_value}) #define ECORE_GETOPT_STORE_DEF_INT(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_INT, \ - {.intv = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_INT, \ + {.intv = default_value}) #define ECORE_GETOPT_STORE_DEF_LONG(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_LONG, \ - {.longv = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_LONG, \ + {.longv = default_value}) #define ECORE_GETOPT_STORE_DEF_USHORT(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_USHORT, \ - {.ushortv = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_USHORT, \ + {.ushortv = default_value}) #define ECORE_GETOPT_STORE_DEF_UINT(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_UINT, \ - {.uintv = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_UINT, \ + {.uintv = default_value}) #define ECORE_GETOPT_STORE_DEF_ULONG(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_ULONG, \ - {.ulongv = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_ULONG, \ + {.ulongv = default_value}) #define ECORE_GETOPT_STORE_DEF_DOUBLE(shortname, longname, help, default_value) \ - ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ - ECORE_GETOPT_TYPE_DOUBLE, \ - {.doublev = default_value}) + ECORE_GETOPT_STORE_DEF(shortname, longname, help, \ + ECORE_GETOPT_TYPE_DOUBLE, \ + {.doublev = default_value}) #define ECORE_GETOPT_STORE_FULL_STR(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_STR, \ - arg_requirement, \ - {.strv = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_STR, \ + arg_requirement, \ + {.strv = default_value}) #define ECORE_GETOPT_STORE_FULL_BOOL(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_BOOL, \ - arg_requirement, \ - {.boolv = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_BOOL, \ + arg_requirement, \ + {.boolv = default_value}) #define ECORE_GETOPT_STORE_FULL_SHORT(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_SHORT, \ - arg_requirement, \ - {.shortv = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_SHORT, \ + arg_requirement, \ + {.shortv = default_value}) #define ECORE_GETOPT_STORE_FULL_INT(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_INT, \ - arg_requirement, \ - {.intv = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_INT, \ + arg_requirement, \ + {.intv = default_value}) #define ECORE_GETOPT_STORE_FULL_LONG(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_LONG, \ - arg_requirement, \ - {.longv = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_LONG, \ + arg_requirement, \ + {.longv = default_value}) #define ECORE_GETOPT_STORE_FULL_USHORT(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_USHORT, \ - arg_requirement, \ - {.ushortv = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_USHORT, \ + arg_requirement, \ + {.ushortv = default_value}) #define ECORE_GETOPT_STORE_FULL_UINT(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_UINT, \ - arg_requirement, \ - {.uintv = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_UINT, \ + arg_requirement, \ + {.uintv = default_value}) #define ECORE_GETOPT_STORE_FULL_ULONG(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_ULONG, \ - arg_requirement, \ - {.ulongv = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_ULONG, \ + arg_requirement, \ + {.ulongv = default_value}) #define ECORE_GETOPT_STORE_FULL_DOUBLE(shortname, longname, help, metavar, arg_requirement, default_value) \ - ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ - ECORE_GETOPT_TYPE_DOUBLE, \ - arg_requirement, \ - {.doublev = default_value}) + ECORE_GETOPT_STORE_FULL(shortname, longname, help, metavar, \ + ECORE_GETOPT_TYPE_DOUBLE, \ + arg_requirement, \ + {.doublev = default_value}) -#define ECORE_GETOPT_STORE_CONST(shortname, longname, help, value) \ - {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_CONST, \ +#define ECORE_GETOPT_STORE_CONST(shortname, longname, help, value) \ + {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_CONST, \ {.store_const = value}} -#define ECORE_GETOPT_STORE_TRUE(shortname, longname, help) \ - {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_TRUE, \ +#define ECORE_GETOPT_STORE_TRUE(shortname, longname, help) \ + {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_TRUE, \ {.dummy = NULL}} -#define ECORE_GETOPT_STORE_FALSE(shortname, longname, help) \ - {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_FALSE, \ +#define ECORE_GETOPT_STORE_FALSE(shortname, longname, help) \ + {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_STORE_FALSE, \ {.dummy = NULL}} -#define ECORE_GETOPT_CHOICE(shortname, longname, help, choices_array) \ - {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_CHOICE, \ +#define ECORE_GETOPT_CHOICE(shortname, longname, help, choices_array) \ + {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_CHOICE, \ {.choices = choices_array}} #define ECORE_GETOPT_CHOICE_METAVAR(shortname, longname, help, metavar, choices_array) \ - {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CHOICE, \ + {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CHOICE, \ {.choices = choices_array}} -#define ECORE_GETOPT_APPEND(shortname, longname, help, sub_type) \ - {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_APPEND, \ +#define ECORE_GETOPT_APPEND(shortname, longname, help, sub_type) \ + {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_APPEND, \ {.append_type = sub_type}} #define ECORE_GETOPT_APPEND_METAVAR(shortname, longname, help, metavar, type) \ - {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_APPEND, \ + {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_APPEND, \ {.append_type = type}} -#define ECORE_GETOPT_COUNT(shortname, longname, help) \ - {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_COUNT, \ +#define ECORE_GETOPT_COUNT(shortname, longname, help) \ + {shortname, longname, help, NULL, ECORE_GETOPT_ACTION_COUNT, \ {.dummy = NULL}} #define ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, metavar, callback_func, callback_data, argument_requirement, default_value) \ - {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CALLBACK, \ - {.callback = {callback_func, callback_data, \ - argument_requirement, default_value}}} + {shortname, longname, help, metavar, ECORE_GETOPT_ACTION_CALLBACK, \ + {.callback = {callback_func, callback_data, \ + argument_requirement, default_value}}} #define ECORE_GETOPT_CALLBACK_NOARGS(shortname, longname, help, callback_func, callback_data) \ - ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, NULL, \ - callback_func, callback_data, \ - ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO, \ - NULL) + ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, NULL, \ + callback_func, callback_data, \ + ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO, \ + NULL) #define ECORE_GETOPT_CALLBACK_ARGS(shortname, longname, help, metavar, callback_func, callback_data) \ - ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, metavar, \ - callback_func, callback_data, \ - ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, \ - NULL) - -#define ECORE_GETOPT_HELP(shortname, longname) \ - {shortname, longname, "show this message.", NULL, \ - ECORE_GETOPT_ACTION_HELP, \ + ECORE_GETOPT_CALLBACK_FULL(shortname, longname, help, metavar, \ + callback_func, callback_data, \ + ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES, \ + NULL) + +#define ECORE_GETOPT_HELP(shortname, longname) \ + {shortname, longname, "show this message.", NULL, \ + ECORE_GETOPT_ACTION_HELP, \ {.dummy = NULL}} -#define ECORE_GETOPT_VERSION(shortname, longname) \ - {shortname, longname, "show program version.", NULL, \ - ECORE_GETOPT_ACTION_VERSION, \ +#define ECORE_GETOPT_VERSION(shortname, longname) \ + {shortname, longname, "show program version.", NULL, \ + ECORE_GETOPT_ACTION_VERSION, \ {.dummy = NULL}} -#define ECORE_GETOPT_COPYRIGHT(shortname, longname) \ - {shortname, longname, "show copyright.", NULL, \ - ECORE_GETOPT_ACTION_COPYRIGHT, \ +#define ECORE_GETOPT_COPYRIGHT(shortname, longname) \ + {shortname, longname, "show copyright.", NULL, \ + ECORE_GETOPT_ACTION_COPYRIGHT, \ {.dummy = NULL}} -#define ECORE_GETOPT_LICENSE(shortname, longname) \ - {shortname, longname, "show license.", NULL, \ - ECORE_GETOPT_ACTION_LICENSE, \ +#define ECORE_GETOPT_LICENSE(shortname, longname) \ + {shortname, longname, "show license.", NULL, \ + ECORE_GETOPT_ACTION_LICENSE, \ {.dummy = NULL}} #define ECORE_GETOPT_SENTINEL {0, NULL, NULL, NULL, 0, {.dummy = NULL}} diff --git a/src/lib/ecore/Makefile.am b/src/lib/ecore/Makefile.am index 960e9dc..37e7bda 100644 --- a/src/lib/ecore/Makefile.am +++ b/src/lib/ecore/Makefile.am @@ -45,7 +45,7 @@ endif endif -libecore_la_LIBADD = @dlopen_libs@ @EINA_LIBS@ @EVIL_LIBS@ @GLIB_LIBS@ @WIN32_LIBS@ @LTLIBINTL@ @EFL_PTHREAD_LIBS@ -lm +libecore_la_LIBADD = @dlopen_libs@ @EINA_LIBS@ @EVIL_LIBS@ @GLIB_LIBS@ @WIN32_LIBS@ @LTLIBINTL@ @EFL_PTHREAD_LIBS@ @rt_libs@ -lm libecore_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@ EXTRA_DIST = ecore_private.h diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c index 77f486c..ff17209 100644 --- a/src/lib/ecore/ecore.c +++ b/src/lib/ecore/ecore.c @@ -38,8 +38,8 @@ static Ecore_Version _version = { VERS_MAJ, VERS_MIN, VERS_MIC, VERS_REV }; EAPI Ecore_Version *ecore_version = &_version; -#define KEEP_MAX(Global, Local) \ - if (Global < (Local)) \ +#define KEEP_MAX(Global, Local) \ + if (Global < (Local)) \ Global = Local; static Eina_Bool _ecore_memory_statistic(void *data); @@ -50,7 +50,7 @@ static pid_t _ecore_memory_pid = 0; static const char *_ecore_magic_string_get(Ecore_Magic m); static int _ecore_init_count = 0; -EAPI int _ecore_log_dom = -1; +int _ecore_log_dom = -1; int _ecore_fps_debug = 0; /** OpenBSD does not define CODESET @@ -62,6 +62,12 @@ int _ecore_fps_debug = 0; #endif /** + * @addtogroup Ecore_Init_Group Ecore initialisation and shutdown functions. + * + * @{ + */ + +/** * Set up connections, signal handlers, sockets etc. * @return 1 or greater on success, 0 otherwise * @@ -95,7 +101,7 @@ ecore_init(void) /* if (strcmp(nl_langinfo(CODESET), "UTF-8")) { - WRN("Not a utf8 locale!"); + WRN("Not a utf8 locale!"); } */ #ifdef HAVE_EVIL @@ -104,11 +110,12 @@ ecore_init(void) #endif if (!eina_init()) goto shutdown_evil; - _ecore_log_dom = eina_log_domain_register("Ecore",ECORE_DEFAULT_LOG_COLOR); - if (_ecore_log_dom < 0) { - EINA_LOG_ERR("Ecore was unable to create a log domain."); - goto shutdown_log_dom; - } + _ecore_log_dom = eina_log_domain_register("ecore", ECORE_DEFAULT_LOG_COLOR); + if (_ecore_log_dom < 0) + { + EINA_LOG_ERR("Ecore was unable to create a log domain."); + goto shutdown_log_dom; + } if (getenv("ECORE_FPS_DEBUG")) _ecore_fps_debug = 1; if (_ecore_fps_debug) _ecore_fps_debug_init(); _ecore_main_loop_init(); @@ -117,13 +124,13 @@ ecore_init(void) _ecore_thread_init(); _ecore_glib_init(); _ecore_job_init(); - _ecore_loop_time = ecore_time_get(); + _ecore_time_init(); #if HAVE_MALLINFO if (getenv("ECORE_MEM_STAT")) { - _ecore_memory_pid = getpid(); - ecore_animator_add(_ecore_memory_statistic, NULL); + _ecore_memory_pid = getpid(); + ecore_animator_add(_ecore_memory_statistic, NULL); } #endif @@ -177,12 +184,12 @@ ecore_shutdown(void) #if HAVE_MALLINFO if (getenv("ECORE_MEM_STAT")) { - _ecore_memory_statistic(NULL); + _ecore_memory_statistic(NULL); - ERR("[%i] Memory MAX total: %i, free: %i", - _ecore_memory_pid, - _ecore_memory_max_total, - _ecore_memory_max_free); + ERR("[%i] Memory MAX total: %i, free: %i", + _ecore_memory_pid, + _ecore_memory_max_total, + _ecore_memory_max_free); } #endif @@ -196,6 +203,10 @@ ecore_shutdown(void) return _ecore_init_count; } +/** + * @} + */ + EAPI void ecore_print_warning(const char *function, const char *sparam) { @@ -220,13 +231,13 @@ _ecore_magic_fail(const void *d, Ecore_Magic m, Ecore_Magic req_m, const char *f ERR(" Input handle has already been freed!"); else if (m != req_m) ERR(" Input handle is wrong type\n" - " Expected: %08x - %s\n" - " Supplied: %08x - %s", - (unsigned int)req_m, _ecore_magic_string_get(req_m), - (unsigned int)m, _ecore_magic_string_get(m)); + " Expected: %08x - %s\n" + " Supplied: %08x - %s", + (unsigned int)req_m, _ecore_magic_string_get(req_m), + (unsigned int)m, _ecore_magic_string_get(m)); ERR("*** NAUGHTY PROGRAMMER!!!\n" - "*** SPANK SPANK SPANK!!!\n" - "*** Now go fix your code. Tut tut tut!"); + "*** SPANK SPANK SPANK!!!\n" + "*** Now go fix your code. Tut tut tut!"); if (getenv("ECORE_ERROR_ABORT")) abort(); } @@ -236,37 +247,37 @@ _ecore_magic_string_get(Ecore_Magic m) switch (m) { case ECORE_MAGIC_NONE: - return "None (Freed Object)"; - break; + return "None (Freed Object)"; + break; case ECORE_MAGIC_EXE: - return "Ecore_Exe (Executable)"; - break; + return "Ecore_Exe (Executable)"; + break; case ECORE_MAGIC_TIMER: - return "Ecore_Timer (Timer)"; - break; + return "Ecore_Timer (Timer)"; + break; case ECORE_MAGIC_IDLER: - return "Ecore_Idler (Idler)"; - break; + return "Ecore_Idler (Idler)"; + break; case ECORE_MAGIC_IDLE_ENTERER: - return "Ecore_Idle_Enterer (Idler Enterer)"; - break; + return "Ecore_Idle_Enterer (Idler Enterer)"; + break; case ECORE_MAGIC_IDLE_EXITER: - return "Ecore_Idle_Exiter (Idler Exiter)"; - break; + return "Ecore_Idle_Exiter (Idler Exiter)"; + break; case ECORE_MAGIC_FD_HANDLER: - return "Ecore_Fd_Handler (Fd Handler)"; - break; + return "Ecore_Fd_Handler (Fd Handler)"; + break; case ECORE_MAGIC_WIN32_HANDLER: - return "Ecore_Win32_Handler (Win32 Handler)"; - break; + return "Ecore_Win32_Handler (Win32 Handler)"; + break; case ECORE_MAGIC_EVENT_HANDLER: - return "Ecore_Event_Handler (Event Handler)"; - break; + return "Ecore_Event_Handler (Event Handler)"; + break; case ECORE_MAGIC_EVENT: - return "Ecore_Event (Event)"; - break; + return "Ecore_Event (Event)"; + break; default: - return ""; + return ""; }; } @@ -298,40 +309,40 @@ _ecore_fps_debug_init(void) _ecore_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644); if (_ecore_fps_debug_fd < 0) { - unlink(buf); - _ecore_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644); + unlink(buf); + _ecore_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644); } if (_ecore_fps_debug_fd >= 0) { - unsigned int zero = 0; - char *buf = (char *)&zero; - ssize_t todo = sizeof(unsigned int); - - while (todo > 0) - { - ssize_t r = write(_ecore_fps_debug_fd, buf, todo); - if (r > 0) - { - todo -= r; - buf += r; - } - else if ((r < 0) && (errno == EINTR)) - continue; - else - { - ERR("could not write to file '%s' fd %d: %s", - tmp, _ecore_fps_debug_fd, strerror(errno)); - close(_ecore_fps_debug_fd); - _ecore_fps_debug_fd = -1; - return; - } - } - _ecore_fps_runtime_mmap = mmap(NULL, sizeof(unsigned int), - PROT_READ | PROT_WRITE, - MAP_SHARED, - _ecore_fps_debug_fd, 0); - if (_ecore_fps_runtime_mmap == MAP_FAILED) - _ecore_fps_runtime_mmap = NULL; + unsigned int zero = 0; + char *buf = (char *)&zero; + ssize_t todo = sizeof(unsigned int); + + while (todo > 0) + { + ssize_t r = write(_ecore_fps_debug_fd, buf, todo); + if (r > 0) + { + todo -= r; + buf += r; + } + else if ((r < 0) && (errno == EINTR)) + continue; + else + { + ERR("could not write to file '%s' fd %d: %s", + tmp, _ecore_fps_debug_fd, strerror(errno)); + close(_ecore_fps_debug_fd); + _ecore_fps_debug_fd = -1; + return; + } + } + _ecore_fps_runtime_mmap = mmap(NULL, sizeof(unsigned int), + PROT_READ | PROT_WRITE, + MAP_SHARED, + _ecore_fps_debug_fd, 0); + if (_ecore_fps_runtime_mmap == MAP_FAILED) + _ecore_fps_runtime_mmap = NULL; } } @@ -352,15 +363,15 @@ _ecore_fps_debug_shutdown(void) tmp = (char *)evil_tmpdir_get (); #endif /* HAVE_EVIL */ pid = (int)getpid(); - snprintf(buf, sizeof(buf), "%s/.ecore_fps_debug-%i", tmp, pid); - unlink(buf); - if (_ecore_fps_runtime_mmap) - { - munmap(_ecore_fps_runtime_mmap, sizeof(int)); - _ecore_fps_runtime_mmap = NULL; - } - close(_ecore_fps_debug_fd); - _ecore_fps_debug_fd = -1; + snprintf(buf, sizeof(buf), "%s/.ecore_fps_debug-%i", tmp, pid); + unlink(buf); + if (_ecore_fps_runtime_mmap) + { + munmap(_ecore_fps_runtime_mmap, sizeof(int)); + _ecore_fps_runtime_mmap = NULL; + } + close(_ecore_fps_debug_fd); + _ecore_fps_debug_fd = -1; } } @@ -370,16 +381,16 @@ _ecore_fps_debug_runtime_add(double t) if ((_ecore_fps_debug_fd >= 0) && (_ecore_fps_runtime_mmap)) { - unsigned int tm; - - tm = (unsigned int)(t * 1000000.0); - /* i know its not 100% theoretically guaranteed, but i'd say a write */ - /* of an int could be considered atomic for all practical purposes */ - /* oh and since this is cumulative, 1 second = 1,000,000 ticks, so */ - /* this can run for about 4294 seconds becore looping. if you are */ - /* doing performance testing in one run for over an hour... well */ - /* time to restart or handle a loop condition :) */ - *(_ecore_fps_runtime_mmap) += tm; + unsigned int tm; + + tm = (unsigned int)(t * 1000000.0); + /* i know its not 100% theoretically guaranteed, but i'd say a write */ + /* of an int could be considered atomic for all practical purposes */ + /* oh and since this is cumulative, 1 second = 1,000,000 ticks, so */ + /* this can run for about 4294 seconds becore looping. if you are */ + /* doing performance testing in one run for over an hour... well */ + /* time to restart or handle a loop condition :) */ + *(_ecore_fps_runtime_mmap) += tm; } } @@ -394,11 +405,11 @@ _ecore_memory_statistic(__UNUSED__ void *data) mi = mallinfo(); -#define HAS_CHANGED(Global, Local) \ - if (Global != Local) \ - { \ - Global = Local; \ - changed = EINA_TRUE; \ +#define HAS_CHANGED(Global, Local) \ + if (Global != Local) \ + { \ + Global = Local; \ + changed = EINA_TRUE; \ } HAS_CHANGED(uordblks, mi.uordblks); @@ -406,13 +417,14 @@ _ecore_memory_statistic(__UNUSED__ void *data) if (changed) ERR("[%i] Memory total: %i, free: %i", - _ecore_memory_pid, - mi.uordblks, - mi.fordblks); + _ecore_memory_pid, + mi.uordblks, + mi.fordblks); KEEP_MAX(_ecore_memory_max_total, mi.uordblks); KEEP_MAX(_ecore_memory_max_free, mi.fordblks); return ECORE_CALLBACK_RENEW; } + #endif diff --git a/src/lib/ecore/ecore_anim.c b/src/lib/ecore/ecore_anim.c index 0690af1..c86026c 100644 --- a/src/lib/ecore/ecore_anim.c +++ b/src/lib/ecore/ecore_anim.c @@ -18,7 +18,7 @@ struct _Ecore_Animator void *data; Eina_Bool delete_me : 1; - Eina_Bool suspended : 1; + Eina_Bool suspended : 1; }; @@ -30,11 +30,22 @@ static Ecore_Animator *animators = NULL; static double animators_frametime = 1.0 / 30.0; /** + * @addtogroup Ecore_Group Ecore - Main Loop and Job Functions. + * + * @{ + */ + +/** + * @addtogroup Ecore_Animator_Group Ecore Animator functions + * + * @{ + */ + +/** * Add a animator to tick off at every animaton tick during main loop execution. * @param func The function to call when it ticks off * @param data The data to pass to the function * @return A handle to the new animator - * @ingroup Ecore_Animator_Group * * This function adds a animator and returns its handle on success and NULL on * failure. The function @p func will be called every N seconds where N is the @@ -74,7 +85,6 @@ ecore_animator_add(Ecore_Task_Cb func, const void *data) * Delete the specified animator from the animator list. * @param animator The animator to delete * @return The data pointer set for the animator - * @ingroup Ecore_Animator_Group * * Delete the specified @p aqnimator from the set of animators that are executed * during main loop execution. This function returns the data parameter that @@ -87,9 +97,9 @@ ecore_animator_del(Ecore_Animator *animator) { if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR)) { - ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR, - "ecore_animator_del"); - return NULL; + ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR, + "ecore_animator_del"); + return NULL; } if (animator->delete_me) return animator->data; animator->delete_me = EINA_TRUE; @@ -101,7 +111,7 @@ ecore_animator_del(Ecore_Animator *animator) * Set the animator call interval in seconds. * @param frametime The time in seconds in between animator ticks. * - * This function sets the time interval (in seconds) inbetween animator ticks. + * This function sets the time interval (in seconds) between animator ticks. */ EAPI void ecore_animator_frametime_set(double frametime) @@ -111,8 +121,8 @@ ecore_animator_frametime_set(double frametime) animators_frametime = frametime; if (timer) { - ecore_timer_del(timer); - timer = NULL; + ecore_timer_del(timer); + timer = NULL; } if (animators) timer = ecore_timer_add(animators_frametime, _ecore_animator, NULL); @@ -122,7 +132,7 @@ ecore_animator_frametime_set(double frametime) * Get the animator call interval in seconds. * @return The time in second in between animator ticks. * - * this function retrieves the time inbetween animator ticks, in seconds. + * this function retrieves the time between animator ticks, in seconds. */ EAPI double ecore_animator_frametime_get(void) @@ -133,7 +143,6 @@ ecore_animator_frametime_get(void) /** * Suspend the specified animator. * @param animator The animator to delete - * @ingroup Ecore_Animator_Group * * The specified @p animator will be temporarly removed from the set of animators * that are executed during main loop execution. @@ -143,9 +152,9 @@ ecore_animator_freeze(Ecore_Animator *animator) { if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR)) { - ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR, - "ecore_animator_del"); - return; + ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR, + "ecore_animator_del"); + return; } if (animator->delete_me) return; animator->suspended = EINA_TRUE; @@ -154,7 +163,6 @@ ecore_animator_freeze(Ecore_Animator *animator) /** * Restore execution of the specified animator. * @param animator The animator to delete - * @ingroup Ecore_Animator_Group * * The specified @p animator will be put back in the set of animators * that are executed during main loop execution. @@ -164,9 +172,9 @@ ecore_animator_thaw(Ecore_Animator *animator) { if (!ECORE_MAGIC_CHECK(animator, ECORE_MAGIC_ANIMATOR)) { - ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR, - "ecore_animator_del"); - return; + ECORE_MAGIC_FAIL(animator, ECORE_MAGIC_ANIMATOR, + "ecore_animator_del"); + return; } if (animator->delete_me) return; animator->suspended = EINA_FALSE; @@ -177,17 +185,17 @@ _ecore_animator_shutdown(void) { if (timer) { - ecore_timer_del(timer); - timer = NULL; + ecore_timer_del(timer); + timer = NULL; } while (animators) { - Ecore_Animator *animator; + Ecore_Animator *animator; - animator = animators; - animators = (Ecore_Animator *) eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animators)); - ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE); - free(animator); + animator = animators; + animators = (Ecore_Animator *) eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animators)); + ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE); + free(animator); } } @@ -198,36 +206,44 @@ _ecore_animator(void *data __UNUSED__) EINA_INLIST_FOREACH(animators, animator) { - if (!animator->delete_me && !animator->suspended) - { - if (!animator->func(animator->data)) - { - animator->delete_me = EINA_TRUE; - animators_delete_me++; - } - } + if (!animator->delete_me && !animator->suspended) + { + if (!animator->func(animator->data)) + { + animator->delete_me = EINA_TRUE; + animators_delete_me++; + } + } } if (animators_delete_me) { - Ecore_Animator *l; - for(l = animators; l;) - { - animator = l; - l = (Ecore_Animator *) EINA_INLIST_GET(l)->next; - if (animator->delete_me) - { - animators = (Ecore_Animator *) eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animator)); - ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE); - free(animator); - animators_delete_me--; - if (animators_delete_me == 0) break; - } - } + Ecore_Animator *l; + for(l = animators; l;) + { + animator = l; + l = (Ecore_Animator *) EINA_INLIST_GET(l)->next; + if (animator->delete_me) + { + animators = (Ecore_Animator *) eina_inlist_remove(EINA_INLIST_GET(animators), EINA_INLIST_GET(animator)); + ECORE_MAGIC_SET(animator, ECORE_MAGIC_NONE); + free(animator); + animators_delete_me--; + if (animators_delete_me == 0) break; + } + } } if (!animators) { - timer = NULL; - return ECORE_CALLBACK_CANCEL; + timer = NULL; + return ECORE_CALLBACK_CANCEL; } return ECORE_CALLBACK_RENEW; } + +/** + * @} + */ + +/** + * @} + */ diff --git a/src/lib/ecore/ecore_app.c b/src/lib/ecore/ecore_app.c index f9663a5..fe47d81 100644 --- a/src/lib/ecore/ecore_app.c +++ b/src/lib/ecore/ecore_app.c @@ -21,6 +21,18 @@ static int app_argc = 0; static char **app_argv = NULL; /** + * @addtogroup Ecore_Group Ecore - Main Loop and Job Functions. + * + * @{ + */ + +/** + * @addtogroup Ecore_Application_Group Ecore Application functions + * + * @{ + */ + +/** * Set up the programs command-line arguments. * @param argc The same as passed as argc to the programs main() function * @param argv The same as passed as argv to the programs main() function @@ -75,3 +87,11 @@ ecore_app_restart(void) args[i] = NULL; execvp(app_argv[0], args); } + +/** + * @} + */ + +/** + * @} + */ diff --git a/src/lib/ecore/ecore_events.c b/src/lib/ecore/ecore_events.c index a213a00..0c788cd 100644 --- a/src/lib/ecore/ecore_events.c +++ b/src/lib/ecore/ecore_events.c @@ -71,6 +71,18 @@ static void *_ecore_event_del(Ecore_Event *event); /** + * @addtogroup Ecore_Group Ecore - Main Loop and Job Functions. + * + * @{ + */ + +/** + * @addtogroup Ecore_Event_Group Ecore Event functions + * + * @{ + */ + +/** * Add an event handler. * @param type The type of the event this handler will get called for * @param func The function to call when the event is found in the queue @@ -108,26 +120,26 @@ ecore_event_handler_add(int type, Ecore_Event_Handler_Cb func, const void *data) eh->data = (void *)data; if (type >= (event_handlers_num - 1)) { - int p_alloc_num; - - p_alloc_num = event_handlers_alloc_num; - event_handlers_num = type + 1; - if (event_handlers_num > event_handlers_alloc_num) - { - Ecore_Event_Handler **new_handlers; - int i; - - event_handlers_alloc_num = ((event_handlers_num + 16) / 16) * 16; - new_handlers = realloc(event_handlers, event_handlers_alloc_num * sizeof(Ecore_Event_Handler *)); - if (!new_handlers) - { - free(eh); - return NULL; - } - event_handlers = new_handlers; - for (i = p_alloc_num; i < event_handlers_alloc_num; i++) - event_handlers[i] = NULL; - } + int p_alloc_num; + + p_alloc_num = event_handlers_alloc_num; + event_handlers_num = type + 1; + if (event_handlers_num > event_handlers_alloc_num) + { + Ecore_Event_Handler **new_handlers; + int i; + + event_handlers_alloc_num = ((event_handlers_num + 16) / 16) * 16; + new_handlers = realloc(event_handlers, event_handlers_alloc_num * sizeof(Ecore_Event_Handler *)); + if (!new_handlers) + { + free(eh); + return NULL; + } + event_handlers = new_handlers; + for (i = p_alloc_num; i < event_handlers_alloc_num; i++) + event_handlers[i] = NULL; + } } event_handlers[type] = (Ecore_Event_Handler *) eina_inlist_append(EINA_INLIST_GET(event_handlers[type]), EINA_INLIST_GET(eh)); return eh; @@ -148,9 +160,9 @@ ecore_event_handler_del(Ecore_Event_Handler *event_handler) { if (!ECORE_MAGIC_CHECK(event_handler, ECORE_MAGIC_EVENT_HANDLER)) { - ECORE_MAGIC_FAIL(event_handler, ECORE_MAGIC_EVENT_HANDLER, - "ecore_event_handler_del"); - return NULL; + ECORE_MAGIC_FAIL(event_handler, ECORE_MAGIC_EVENT_HANDLER, + "ecore_event_handler_del"); + return NULL; } EINA_SAFETY_ON_TRUE_RETURN_VAL(event_handler->delete_me, NULL); event_handler->delete_me = 1; @@ -208,8 +220,8 @@ ecore_event_del(Ecore_Event *event) { if (!ECORE_MAGIC_CHECK(event, ECORE_MAGIC_EVENT)) { - ECORE_MAGIC_FAIL(event, ECORE_MAGIC_EVENT, "ecore_event_del"); - return NULL; + ECORE_MAGIC_FAIL(event, ECORE_MAGIC_EVENT, "ecore_event_del"); + return NULL; } EINA_SAFETY_ON_TRUE_RETURN_VAL(event->delete_me, NULL); event->delete_me = 1; @@ -284,8 +296,8 @@ ecore_event_filter_del(Ecore_Event_Filter *ef) { if (!ECORE_MAGIC_CHECK(ef, ECORE_MAGIC_EVENT_FILTER)) { - ECORE_MAGIC_FAIL(ef, ECORE_MAGIC_EVENT_FILTER, "ecore_event_filter_del"); - return NULL; + ECORE_MAGIC_FAIL(ef, ECORE_MAGIC_EVENT_FILTER, "ecore_event_filter_del"); + return NULL; } EINA_SAFETY_ON_TRUE_RETURN_VAL(ef->delete_me, NULL); ef->delete_me = 1; @@ -333,6 +345,14 @@ ecore_event_current_event_get(void) return ecore_raw_event_event; } +/** + * @} + */ + +/** + * @} + */ + void _ecore_event_shutdown(void) { @@ -344,12 +364,12 @@ _ecore_event_shutdown(void) event_current = NULL; for (i = 0; i < event_handlers_num; i++) { - while ((eh = event_handlers[i])) - { - event_handlers[i] = (Ecore_Event_Handler *) eina_inlist_remove(EINA_INLIST_GET(event_handlers[i]), EINA_INLIST_GET(event_handlers[i])); - ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE); - if (!eh->delete_me) free(eh); - } + while ((eh = event_handlers[i])) + { + event_handlers[i] = (Ecore_Event_Handler *) eina_inlist_remove(EINA_INLIST_GET(event_handlers[i]), EINA_INLIST_GET(event_handlers[i])); + ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE); + if (!eh->delete_me) free(eh); + } } EINA_LIST_FREE(event_handlers_delete_list, eh) free(eh); @@ -359,9 +379,9 @@ _ecore_event_shutdown(void) event_handlers_alloc_num = 0; while ((ef = event_filters)) { - event_filters = (Ecore_Event_Filter *) eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(event_filters)); - ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE); - free(ef); + event_filters = (Ecore_Event_Filter *) eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(event_filters)); + ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE); + free(ef); } event_filters_delete_me = 0; event_filter_current = NULL; @@ -424,10 +444,10 @@ _ecore_event_purge_deleted(void) inpurge++; while (itr) { - Ecore_Event *next = (Ecore_Event *)EINA_INLIST_GET(itr)->next; - if ((!itr->references) && (itr->delete_me)) - _ecore_event_del(itr); - itr = next; + Ecore_Event *next = (Ecore_Event *)EINA_INLIST_GET(itr)->next; + if ((!itr->references) && (itr->delete_me)) + _ecore_event_del(itr); + itr = next; } inpurge--; while (purge_events) @@ -444,82 +464,82 @@ _ecore_event_filters_apply() if (!event_filter_current) { - /* regular main loop, start from head */ - event_filter_current = event_filters; + /* regular main loop, start from head */ + event_filter_current = event_filters; } else { - /* recursive main loop, continue from where we were */ - event_filter_current = (Ecore_Event_Filter *)EINA_INLIST_GET(event_filter_current)->next; + /* recursive main loop, continue from where we were */ + event_filter_current = (Ecore_Event_Filter *)EINA_INLIST_GET(event_filter_current)->next; } while (event_filter_current) { - Ecore_Event_Filter *ef = event_filter_current; - - if (!ef->delete_me) - { - ef->references++; - - if (ef->func_start) - ef->loop_data = ef->func_start(ef->data); - - if (!event_filter_event_current) - { - /* regular main loop, start from head */ - event_filter_event_current = events; - } - else - { - /* recursive main loop, continue from where we were */ - event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next; - } - - while (event_filter_event_current) - { - Ecore_Event *e = event_filter_event_current; - - if (!ef->func_filter(ef->data, ef->loop_data, - e->type, e->event)) - { - ecore_event_del(e); - } - - if (event_filter_event_current) /* may have changed in recursive main loops */ - event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next; - } - if (ef->func_end) - ef->func_end(ef->data, ef->loop_data); - - ef->references--; - } - - if (event_filter_current) /* may have changed in recursive main loops */ - event_filter_current = (Ecore_Event_Filter *)EINA_INLIST_GET(event_filter_current)->next; + Ecore_Event_Filter *ef = event_filter_current; + + if (!ef->delete_me) + { + ef->references++; + + if (ef->func_start) + ef->loop_data = ef->func_start(ef->data); + + if (!event_filter_event_current) + { + /* regular main loop, start from head */ + event_filter_event_current = events; + } + else + { + /* recursive main loop, continue from where we were */ + event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next; + } + + while (event_filter_event_current) + { + Ecore_Event *e = event_filter_event_current; + + if (!ef->func_filter(ef->data, ef->loop_data, + e->type, e->event)) + { + ecore_event_del(e); + } + + if (event_filter_event_current) /* may have changed in recursive main loops */ + event_filter_event_current = (Ecore_Event *)EINA_INLIST_GET(event_filter_event_current)->next; + } + if (ef->func_end) + ef->func_end(ef->data, ef->loop_data); + + ef->references--; + } + + if (event_filter_current) /* may have changed in recursive main loops */ + event_filter_current = (Ecore_Event_Filter *)EINA_INLIST_GET(event_filter_current)->next; } if (event_filters_delete_me) { - int deleted_in_use = 0; - Ecore_Event_Filter *l; - for (l = event_filters; l;) - { - Ecore_Event_Filter *ef = l; - l = (Ecore_Event_Filter *) EINA_INLIST_GET(l)->next; - if (ef->delete_me) - { - if (ef->references) - { - deleted_in_use++; - continue; - } - - event_filters = (Ecore_Event_Filter *) eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(ef)); - ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE); - free(ef); - } - } - if (!deleted_in_use) - event_filters_delete_me = 0; + int deleted_in_use = 0; + Ecore_Event_Filter *l; + for (l = event_filters; l;) + { + Ecore_Event_Filter *ef = l; + l = (Ecore_Event_Filter *) EINA_INLIST_GET(l)->next; + if (ef->delete_me) + { + if (ef->references) + { + deleted_in_use++; + continue; + } + + event_filters = (Ecore_Event_Filter *) eina_inlist_remove(EINA_INLIST_GET(event_filters), EINA_INLIST_GET(ef)); + ECORE_MAGIC_SET(ef, ECORE_MAGIC_NONE); + free(ef); + } + } + if (!deleted_in_use) + event_filters_delete_me = 0; } } void @@ -532,71 +552,71 @@ _ecore_event_call(void) if (!event_current) { - /* regular main loop, start from head */ - event_current = events; - event_handler_current = NULL; + /* regular main loop, start from head */ + event_current = events; + event_handler_current = NULL; } while (event_current) { - Ecore_Event *e = event_current; - int handle_count = 0; - - if (e->delete_me) - { - event_current = (Ecore_Event *)EINA_INLIST_GET(event_current)->next; - continue; - } - - ecore_raw_event_type = e->type; - ecore_raw_event_event = e->event; - e->references++; - if ((e->type >= 0) && (e->type < event_handlers_num)) - { - if (!event_handler_current) - { - /* regular main loop, start from head */ - event_handler_current = event_handlers[e->type]; - } - else - { - /* recursive main loop, continue from where we were */ - event_handler_current = (Ecore_Event_Handler *)EINA_INLIST_GET(event_handler_current)->next; - } - - while ((event_handler_current) && (!e->delete_me)) - { - Ecore_Event_Handler *eh = event_handler_current; - if (!eh->delete_me) - { - Eina_Bool ret; - - handle_count++; - - eh->references++; - ret = eh->func(eh->data, e->type, e->event); - eh->references--; - - if (!ret) - { - event_handler_current = NULL; - break; /* 0 == "call no further handlers" */ - } - } - - if (event_handler_current) /* may have changed in recursive main loops */ - event_handler_current = (Ecore_Event_Handler *)EINA_INLIST_GET(event_handler_current)->next; - } - } - /* if no handlers were set for EXIT signal - then default is */ - /* to quit the main loop */ - if ((e->type == ECORE_EVENT_SIGNAL_EXIT) && (handle_count == 0)) - ecore_main_loop_quit(); - e->references--; - e->delete_me = 1; - - if (event_current) /* may have changed in recursive main loops */ - event_current = (Ecore_Event *)EINA_INLIST_GET(event_current)->next; + Ecore_Event *e = event_current; + int handle_count = 0; + + if (e->delete_me) + { + event_current = (Ecore_Event *)EINA_INLIST_GET(event_current)->next; + continue; + } + + ecore_raw_event_type = e->type; + ecore_raw_event_event = e->event; + e->references++; + if ((e->type >= 0) && (e->type < event_handlers_num)) + { + if (!event_handler_current) + { + /* regular main loop, start from head */ + event_handler_current = event_handlers[e->type]; + } + else + { + /* recursive main loop, continue from where we were */ + event_handler_current = (Ecore_Event_Handler *)EINA_INLIST_GET(event_handler_current)->next; + } + + while ((event_handler_current) && (!e->delete_me)) + { + Ecore_Event_Handler *eh = event_handler_current; + if (!eh->delete_me) + { + Eina_Bool ret; + + handle_count++; + + eh->references++; + ret = eh->func(eh->data, e->type, e->event); + eh->references--; + + if (!ret) + { + event_handler_current = NULL; + break; /* 0 == "call no further handlers" */ + } + } + + if (event_handler_current) /* may have changed in recursive main loops */ + event_handler_current = (Ecore_Event_Handler *)EINA_INLIST_GET(event_handler_current)->next; + } + } + /* if no handlers were set for EXIT signal - then default is */ + /* to quit the main loop */ + if ((e->type == ECORE_EVENT_SIGNAL_EXIT) && (handle_count == 0)) + ecore_main_loop_quit(); + e->references--; + e->delete_me = 1; + + if (event_current) /* may have changed in recursive main loops */ + event_current = (Ecore_Event *)EINA_INLIST_GET(event_current)->next; } ecore_raw_event_type = ECORE_EVENT_NONE; @@ -606,13 +626,13 @@ _ecore_event_call(void) EINA_LIST_FOREACH_SAFE(event_handlers_delete_list, l, l_next, eh) { - if (eh->references) continue; + if (eh->references) continue; - event_handlers_delete_list = eina_list_remove_list(event_handlers_delete_list, l); + event_handlers_delete_list = eina_list_remove_list(event_handlers_delete_list, l); - event_handlers[eh->type] = (Ecore_Event_Handler *) eina_inlist_remove(EINA_INLIST_GET(event_handlers[eh->type]), EINA_INLIST_GET(eh)); - ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE); - free(eh); + event_handlers[eh->type] = (Ecore_Event_Handler *) eina_inlist_remove(EINA_INLIST_GET(event_handlers[eh->type]), EINA_INLIST_GET(eh)); + ECORE_MAGIC_SET(eh, ECORE_MAGIC_NONE); + free(eh); } } diff --git a/src/lib/ecore/ecore_exe.c b/src/lib/ecore/ecore_exe.c index e8eec95..d088e56 100644 --- a/src/lib/ecore/ecore_exe.c +++ b/src/lib/ecore/ecore_exe.c @@ -34,7 +34,7 @@ * state that it cannot regenerate by just killing it and starting it again. * This includes state that the user code knows about, as the respawn is * transparent to that code. On the other hand, maybe a respawn event might - * be useful, or maybe resend the currently non existant add event. For + * be useful, or maybe resend the currently non existent add event. For * consistancy with ecore_con, an add event is good anyway. * * The Ecore_exe structure is reused for respawning, so that the (opaque) @@ -97,19 +97,19 @@ struct _Ecore_Exe Ecore_Fd_Handler *error_fd_handler; /* the fd_handler to handle errors from child - if this was used, or NULL if not */ void *write_data_buf; /* a data buffer for data to write to the child - * realloced as needed for more data and flushed when the fd handler says writes are possible - */ + */ int write_data_size; /* the size in bytes of the data buffer */ int write_data_offset; /* the offset in bytes in the data buffer */ void *read_data_buf; /* data read from the child awating delivery to an event */ int read_data_size; /* data read from child in bytes */ void *error_data_buf; /* errors read from the child awating delivery to an event */ int error_data_size; /* errors read from child in bytes */ - int child_fd_write; /* fd to write TO to send data to the child */ - int child_fd_read; /* fd to read FROM when child has sent us (the parent) data */ - int child_fd_error; /* fd to read FROM when child has sent us (the parent) errors */ - int child_fd_write_x; /* fd to write TO to send data to the child */ - int child_fd_read_x; /* fd to read FROM when child has sent us (the parent) data */ - int child_fd_error_x; /* fd to read FROM when child has sent us (the parent) errors */ + int child_fd_write; /* fd to write TO to send data to the child */ + int child_fd_read; /* fd to read FROM when child has sent us (the parent) data */ + int child_fd_error; /* fd to read FROM when child has sent us (the parent) errors */ + int child_fd_write_x; /* fd to write TO to send data to the child */ + int child_fd_read_x; /* fd to read FROM when child has sent us (the parent) data */ + int child_fd_error_x; /* fd to read FROM when child has sent us (the parent) errors */ Eina_Bool close_stdin : 1; int start_bytes, end_bytes, start_lines, end_lines; /* Number of bytes/lines to auto pipe at start/end of stdout/stderr. */ @@ -130,7 +130,7 @@ struct _Ecore_Exe * cmd = ecore_exe_comand_parameter_append(cmd, "firefox"); * cmd = ecore_exe_comand_parameter_append(cmd, "http://www.foo.com/bar.html?baz=yes"); * each parameter appended is one argument, and it gets escaped, quoted, and - * appended with a preceeding space. The first is the command off course. + * appended with a preceding space. The first is the command off course. */ struct _ecore_exe_dead_exe @@ -183,7 +183,7 @@ _ecore_exe_check_errno(int result, const char *file, int line) if (result == -1) { - perror("*** errno reports "); + perror("*** errno reports "); /* What is currently supported - * * pipe @@ -239,8 +239,8 @@ _ecore_exe_check_errno(int result, const char *file, int line) * // Something failed, cleanup. * } */ - switch (saved_errno) - { + switch (saved_errno) + { case EACCES: case EAGAIN: case EINTR: @@ -290,7 +290,7 @@ _ecore_exe_check_errno(int result, const char *file, int line) result = 0; break; } - } + } } else /* Everything is fine. */ result = 1; @@ -299,10 +299,19 @@ _ecore_exe_check_errno(int result, const char *file, int line) return result; } + +/** + * @addtogroup Ecore_Group Ecore - Main Loop and Job Functions. + * + * @{ + */ + /** - * @defgroup Ecore_Exe_Basic_Group Process Spawning Functions + * @addtogroup Ecore_Exe_Group Process Spawning Functions + * + * Functions that deal with and send signals to spawned processes. * - * Functions that deal with spawned processes. + * @{ */ static int run_pri = ECORE_EXE_PRIORITY_INHERIT; @@ -322,7 +331,6 @@ static int run_pri = ECORE_EXE_PRIORITY_INHERIT; * * @param pri value a Ecore_Exe_Win32_Priority value on Windows, -20 * to 19 or ECORE_EXE_PRIORITY_INHERIT on other OS. - * @ingroup Ecore_Exe_Basic_Group */ EAPI void ecore_exe_run_priority_set(int pri) @@ -338,7 +346,6 @@ ecore_exe_run_priority_set(int pri) * by this call. * * @return the value set by ecore_exe_run_priority_set() - * @ingroup Ecore_Exe_Basic_Group */ EAPI int ecore_exe_run_priority_get(void) @@ -354,40 +361,11 @@ ecore_exe_run_priority_get(void) * @param exe_cmd The command to run with @c /bin/sh. * @param data Data to attach to the returned process handle. * @return A process handle to the spawned process. - * @ingroup Ecore_Exe_Basic_Group */ EAPI Ecore_Exe * ecore_exe_run(const char *exe_cmd, const void *data) { -/* I'm just being paranoid again, leaving in the original code in case there is a problem. */ -#if 0 - Ecore_Exe *exe; - pid_t pid; - - if (!exe_cmd) - return NULL; - pid = fork(); - if (pid) - { - exe = calloc(1, sizeof(Ecore_Exe)); - if (!exe) - { - kill(pid, SIGKILL); - return NULL; - } - ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE); - exe->pid = pid; - exe->data = (void *)data; - exe->cmd = strdup(exe_cmd); - exes = _ecore_list2_append(exes, exe); - return exe; - } - _ecore_exe_exec_it(exe_cmd, 0); - exit(127); - return NULL; -#else return ecore_exe_pipe_run(exe_cmd, 0, data); -#endif } /** @@ -414,7 +392,6 @@ ecore_exe_run(const char *exe_cmd, const void *data) * @param flags The flag parameters for how to deal with inter-process I/O * @param data Data to attach to the returned process handle. * @return A process handle to the spawned process. - * @ingroup Ecore_Exe_Basic_Group */ EAPI Ecore_Exe * ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data) @@ -447,247 +424,247 @@ ecore_exe_pipe_run(const char *exe_cmd, Ecore_Exe_Flags flags, const void *data) /* Create some pipes. */ if (ok) { - E_IF_NO_ERRNO_NOLOOP(result, pipe(statusPipe), ok) - { - } + E_IF_NO_ERRNO_NOLOOP(result, pipe(statusPipe), ok) + { + } } if (ok && (flags & ECORE_EXE_PIPE_ERROR)) { - E_IF_NO_ERRNO_NOLOOP(result, pipe(errorPipe), ok) - { - exe->child_fd_error = errorPipe[0]; - exe->child_fd_error_x = errorPipe[1]; - } + E_IF_NO_ERRNO_NOLOOP(result, pipe(errorPipe), ok) + { + exe->child_fd_error = errorPipe[0]; + exe->child_fd_error_x = errorPipe[1]; + } } if (ok && (flags & ECORE_EXE_PIPE_READ)) { - E_IF_NO_ERRNO_NOLOOP(result, pipe(readPipe), ok) - { - exe->child_fd_read = readPipe[0]; - exe->child_fd_read_x = readPipe[1]; - } + E_IF_NO_ERRNO_NOLOOP(result, pipe(readPipe), ok) + { + exe->child_fd_read = readPipe[0]; + exe->child_fd_read_x = readPipe[1]; + } } if (ok && (flags & ECORE_EXE_PIPE_WRITE)) { - E_IF_NO_ERRNO_NOLOOP(result, pipe(writePipe), ok) - { - exe->child_fd_write = writePipe[1]; - exe->child_fd_write_x = writePipe[0]; - } + E_IF_NO_ERRNO_NOLOOP(result, pipe(writePipe), ok) + { + exe->child_fd_write = writePipe[1]; + exe->child_fd_write_x = writePipe[0]; + } } if (ok) { - pid_t pid = 0; - volatile int vfork_exec_errno = 0; - - /* FIXME: I should double check this. After a quick look around, this is already done, but via a more modern method. */ - /* signal(SIGPIPE, SIG_IGN); We only want EPIPE on errors */ - pid = fork(); - - if (pid == -1) - { - ERR("Failed to fork process"); - pid = 0; - } - else if (pid == 0) /* child */ - { - if (run_pri != ECORE_EXE_PRIORITY_INHERIT) - { - if ((run_pri >= -20) && (run_pri <= 19)) + pid_t pid = 0; + volatile int vfork_exec_errno = 0; + + /* FIXME: I should double check this. After a quick look around, this is already done, but via a more modern method. */ + /* signal(SIGPIPE, SIG_IGN); We only want EPIPE on errors */ + pid = fork(); + + if (pid == -1) + { + ERR("Failed to fork process"); + pid = 0; + } + else if (pid == 0) /* child */ + { + if (run_pri != ECORE_EXE_PRIORITY_INHERIT) + { + if ((run_pri >= -20) && (run_pri <= 19)) setpriority(PRIO_PROCESS, 0, run_pri); - } - /* dup2 STDERR, STDIN, and STDOUT. dup2() allegedly closes the - * second pipe if it's open. On the other hand, there was the - * Great FD Leak Scare of '06, so let's be paranoid. */ - if (ok && (flags & ECORE_EXE_PIPE_ERROR)) - { - E_NO_ERRNO(result, close(STDERR_FILENO), ok); - E_NO_ERRNO(result, dup2(errorPipe[1], STDERR_FILENO), ok); - } - if (ok && (flags & ECORE_EXE_PIPE_READ)) - { - E_NO_ERRNO(result, close(STDOUT_FILENO), ok); - E_NO_ERRNO(result, dup2(readPipe[1], STDOUT_FILENO), ok); - } - if (ok && (flags & ECORE_EXE_PIPE_WRITE)) - { - E_NO_ERRNO(result, close(STDIN_FILENO), ok); - E_NO_ERRNO(result, dup2(writePipe[0], STDIN_FILENO), ok); - } - - if (ok) - { - /* Setup the status pipe. */ - E_NO_ERRNO(result, close(statusPipe[0]), ok); - E_IF_NO_ERRNO(result, fcntl(statusPipe[1], F_SETFD, FD_CLOEXEC), ok) /* close on exec shows sucess */ - { - /* Run the actual command. */ - _ecore_exe_exec_it(exe_cmd, flags); /* no return */ - } - } - - /* Something went 'orribly wrong. */ - vfork_exec_errno = errno; - - /* Close the pipes. */ - if (flags & ECORE_EXE_PIPE_ERROR) - E_NO_ERRNO(result, close(errorPipe[1]), ok); - if (flags & ECORE_EXE_PIPE_READ) - E_NO_ERRNO(result, close(readPipe[1]), ok); - if (flags & ECORE_EXE_PIPE_WRITE) - E_NO_ERRNO(result, close(writePipe[0]), ok); - E_NO_ERRNO(result, close(statusPipe[1]), ok); - - _exit(-1); - } - else /* parent */ - { - /* Close the unused pipes. */ - E_NO_ERRNO(result, close(statusPipe[1]), ok); - - /* FIXME: after having a good look at the current e fd - * handling, investigate fcntl(dataPipe[x], F_SETSIG, ...) */ - /* FIXME: above F_SETSIG etc. - this is async SIGIO based IO - * which is also linux specific so we probably don't want to - * do this as long as select() is working fine. the only time - * we really want to think of SIGIO async IO is when it all - * actually works basically everywhere and we can turn all - * IO into DMA async activities (i.e. you do a read() then - * the read is complete not on return but when you get a - * SIGIO - the read() just starts the transfer and it is - * completed in the background by DMA (or whatever mechanism - * the kernel choses)) */ - - /* Wait for it to start executing. */ - /* FIXME: this doesn't seem very nice - we sit and block - * waiting on a child process... even though it's just - * the segment between the fork() and the exec) it just feels - * wrong */ - for (;;) - { - char buf; - - E_NO_ERRNO(result, read(statusPipe[0], &buf, 1), ok); - if (result == 0) - { - if (vfork_exec_errno != 0) - { - n = vfork_exec_errno; - ERR("Could not start \"%s\"", exe_cmd); - pid = 0; - } - break; - } - } - - /* Close the status pipe. */ - E_NO_ERRNO(result, close(statusPipe[0]), ok); - } - - if (pid) - { - /* Setup the exe structure. */ - ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE); - exe->start_bytes = -1; - exe->end_bytes = -1; - exe->start_lines = -1; - exe->end_lines = -1; - exe->pid = pid; - exe->flags = flags; - exe->data = (void *)data; - if ((exe->cmd = strdup(exe_cmd))) - { - if (flags & ECORE_EXE_PIPE_ERROR) - { /* Setup the error stuff. */ - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_error, F_SETFL, - O_NONBLOCK), ok) {} - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_error, F_SETFD, - FD_CLOEXEC), ok) {} - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_error_x, F_SETFD, - FD_CLOEXEC), ok) {} - { - exe->error_fd_handler = - ecore_main_fd_handler_add(exe->child_fd_error, - ECORE_FD_READ, - _ecore_exe_data_error_handler, - exe, NULL, NULL); - if (!exe->error_fd_handler) - ok = 0; - } - } - if (ok && (flags & ECORE_EXE_PIPE_READ)) - { /* Setup the read stuff. */ - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_read, F_SETFL, - O_NONBLOCK), ok) {} - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_read, F_SETFD, - FD_CLOEXEC), ok) {} - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_read_x, F_SETFD, - FD_CLOEXEC), ok) {} - { - exe->read_fd_handler = - ecore_main_fd_handler_add(exe->child_fd_read, - ECORE_FD_READ, - _ecore_exe_data_read_handler, - exe, NULL, NULL); - if (!exe->read_fd_handler) - ok = 0; - } - } - if (ok && (flags & ECORE_EXE_PIPE_WRITE)) - { /* Setup the write stuff. */ - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_write, F_SETFL, - O_NONBLOCK), ok) {} - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_write, F_SETFD, - FD_CLOEXEC), ok) {} - E_IF_NO_ERRNO(result, - fcntl(exe->child_fd_write_x, F_SETFD, - FD_CLOEXEC), ok) {} - { - exe->write_fd_handler = - ecore_main_fd_handler_add(exe->child_fd_write, - ECORE_FD_WRITE, - _ecore_exe_data_write_handler, - exe, NULL, NULL); - if (exe->write_fd_handler) - ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); /* Nothing to write to start with. */ - else - ok = 0; - } - } - - exes = (Ecore_Exe *) eina_inlist_append(EINA_INLIST_GET(exes), EINA_INLIST_GET(exe)); - n = 0; - } - else - ok = 0; - } - else - ok = 0; + } + /* dup2 STDERR, STDIN, and STDOUT. dup2() allegedly closes the + * second pipe if it's open. On the other hand, there was the + * Great FD Leak Scare of '06, so let's be paranoid. */ + if (ok && (flags & ECORE_EXE_PIPE_ERROR)) + { + E_NO_ERRNO(result, close(STDERR_FILENO), ok); + E_NO_ERRNO(result, dup2(errorPipe[1], STDERR_FILENO), ok); + } + if (ok && (flags & ECORE_EXE_PIPE_READ)) + { + E_NO_ERRNO(result, close(STDOUT_FILENO), ok); + E_NO_ERRNO(result, dup2(readPipe[1], STDOUT_FILENO), ok); + } + if (ok && (flags & ECORE_EXE_PIPE_WRITE)) + { + E_NO_ERRNO(result, close(STDIN_FILENO), ok); + E_NO_ERRNO(result, dup2(writePipe[0], STDIN_FILENO), ok); + } + + if (ok) + { + /* Setup the status pipe. */ + E_NO_ERRNO(result, close(statusPipe[0]), ok); + E_IF_NO_ERRNO(result, fcntl(statusPipe[1], F_SETFD, FD_CLOEXEC), ok) /* close on exec shows success */ + { + /* Run the actual command. */ + _ecore_exe_exec_it(exe_cmd, flags); /* no return */ + } + } + + /* Something went 'orribly wrong. */ + vfork_exec_errno = errno; + + /* Close the pipes. */ + if (flags & ECORE_EXE_PIPE_ERROR) + E_NO_ERRNO(result, close(errorPipe[1]), ok); + if (flags & ECORE_EXE_PIPE_READ) + E_NO_ERRNO(result, close(readPipe[1]), ok); + if (flags & ECORE_EXE_PIPE_WRITE) + E_NO_ERRNO(result, close(writePipe[0]), ok); + E_NO_ERRNO(result, close(statusPipe[1]), ok); + + _exit(-1); + } + else /* parent */ + { + /* Close the unused pipes. */ + E_NO_ERRNO(result, close(statusPipe[1]), ok); + + /* FIXME: after having a good look at the current e fd + * handling, investigate fcntl(dataPipe[x], F_SETSIG, ...) */ + /* FIXME: above F_SETSIG etc. - this is async SIGIO based IO + * which is also linux specific so we probably don't want to + * do this as long as select() is working fine. the only time + * we really want to think of SIGIO async IO is when it all + * actually works basically everywhere and we can turn all + * IO into DMA async activities (i.e. you do a read() then + * the read is complete not on return but when you get a + * SIGIO - the read() just starts the transfer and it is + * completed in the background by DMA (or whatever mechanism + * the kernel choses)) */ + + /* Wait for it to start executing. */ + /* FIXME: this doesn't seem very nice - we sit and block + * waiting on a child process... even though it's just + * the segment between the fork() and the exec) it just feels + * wrong */ + for (;;) + { + char buf; + + E_NO_ERRNO(result, read(statusPipe[0], &buf, 1), ok); + if (result == 0) + { + if (vfork_exec_errno != 0) + { + n = vfork_exec_errno; + ERR("Could not start \"%s\"", exe_cmd); + pid = 0; + } + break; + } + } + + /* Close the status pipe. */ + E_NO_ERRNO(result, close(statusPipe[0]), ok); + } + + if (pid) + { + /* Setup the exe structure. */ + ECORE_MAGIC_SET(exe, ECORE_MAGIC_EXE); + exe->start_bytes = -1; + exe->end_bytes = -1; + exe->start_lines = -1; + exe->end_lines = -1; + exe->pid = pid; + exe->flags = flags; + exe->data = (void *)data; + if ((exe->cmd = strdup(exe_cmd))) + { + if (flags & ECORE_EXE_PIPE_ERROR) + { /* Setup the error stuff. */ + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_error, F_SETFL, + O_NONBLOCK), ok) {} + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_error, F_SETFD, + FD_CLOEXEC), ok) {} + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_error_x, F_SETFD, + FD_CLOEXEC), ok) {} + { + exe->error_fd_handler = + ecore_main_fd_handler_add(exe->child_fd_error, + ECORE_FD_READ, + _ecore_exe_data_error_handler, + exe, NULL, NULL); + if (!exe->error_fd_handler) + ok = 0; + } + } + if (ok && (flags & ECORE_EXE_PIPE_READ)) + { /* Setup the read stuff. */ + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_read, F_SETFL, + O_NONBLOCK), ok) {} + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_read, F_SETFD, + FD_CLOEXEC), ok) {} + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_read_x, F_SETFD, + FD_CLOEXEC), ok) {} + { + exe->read_fd_handler = + ecore_main_fd_handler_add(exe->child_fd_read, + ECORE_FD_READ, + _ecore_exe_data_read_handler, + exe, NULL, NULL); + if (!exe->read_fd_handler) + ok = 0; + } + } + if (ok && (flags & ECORE_EXE_PIPE_WRITE)) + { /* Setup the write stuff. */ + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_write, F_SETFL, + O_NONBLOCK), ok) {} + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_write, F_SETFD, + FD_CLOEXEC), ok) {} + E_IF_NO_ERRNO(result, + fcntl(exe->child_fd_write_x, F_SETFD, + FD_CLOEXEC), ok) {} + { + exe->write_fd_handler = + ecore_main_fd_handler_add(exe->child_fd_write, + ECORE_FD_WRITE, + _ecore_exe_data_write_handler, + exe, NULL, NULL); + if (exe->write_fd_handler) + ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); /* Nothing to write to start with. */ + else + ok = 0; + } + } + + exes = (Ecore_Exe *) eina_inlist_append(EINA_INLIST_GET(exes), EINA_INLIST_GET(exe)); + n = 0; + } + else + ok = 0; + } + else + ok = 0; } if (!ok) { /* Something went wrong, so pull down everything. */ - if (exe->pid) ecore_exe_terminate(exe); - IF_FN_DEL(ecore_exe_free, exe); + if (exe->pid) ecore_exe_terminate(exe); + IF_FN_DEL(ecore_exe_free, exe); } else { - Ecore_Exe_Event_Add *e; - - e = _ecore_exe_event_add_new(); - e->exe = exe; - if (e) /* Send the event. */ - ecore_event_add(ECORE_EXE_EVENT_ADD, e, - _ecore_exe_event_add_free, NULL); - /* INF("Running as %d for %s.\n", exe->pid, exe->cmd); */ + Ecore_Exe_Event_Add *e; + + e = _ecore_exe_event_add_new(); + e->exe = exe; + if (e) /* Send the event. */ + ecore_event_add(ECORE_EXE_EVENT_ADD, e, + _ecore_exe_event_add_free, NULL); + /* INF("Running as %d for %s.\n", exe->pid, exe->cmd); */ } errno = n; @@ -712,15 +689,15 @@ ecore_exe_callback_pre_free_set(Ecore_Exe *exe, Ecore_Exe_Cb func) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, - "ecore_exe_callback_pre_free_set"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, + "ecore_exe_callback_pre_free_set"); + return; } exe->pre_free_cb = func; } /** - * Sends data to the given child process which it recieves on stdin. + * Sends data to the given child process which it receives on stdin. * * This function writes to a child processes standard in, with unlimited * buffering. This call will never block. It may fail if the system runs out @@ -730,7 +707,6 @@ ecore_exe_callback_pre_free_set(Ecore_Exe *exe, Ecore_Exe_Cb func) * @param data The data to send * @param size The size of the data to send, in bytes * @return EINA_TRUE if successful, EINA_FALSE on failure. - * @ingroup Ecore_Exe_Basic_Group */ EAPI Eina_Bool ecore_exe_send(Ecore_Exe * exe, const void *data, int size) @@ -739,22 +715,22 @@ ecore_exe_send(Ecore_Exe * exe, const void *data, int size) if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_send"); - return EINA_FALSE; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_send"); + return EINA_FALSE; } if (exe->close_stdin) { - ERR("Ecore_Exe %p stdin is closed! Cannot send %d bytes from %p", - exe, size, data); - return EINA_FALSE; + ERR("Ecore_Exe %p stdin is closed! Cannot send %d bytes from %p", + exe, size, data); + return EINA_FALSE; } if (exe->child_fd_write == -1) { - ERR("Ecore_Exe %p created without ECORE_EXE_PIPE_WRITE! " - "Cannot send %d bytes from %p", exe, size, data); - return EINA_FALSE; + ERR("Ecore_Exe %p created without ECORE_EXE_PIPE_WRITE! " + "Cannot send %d bytes from %p", exe, size, data); + return EINA_FALSE; } buf = realloc(exe->write_data_buf, exe->write_data_size + size); @@ -774,15 +750,14 @@ ecore_exe_send(Ecore_Exe * exe, const void *data, int size) * The stdin of the given child process will close when the write buffer is empty. * * @param exe The child process - * @ingroup Ecore_Exe_Basic_Group */ EAPI void ecore_exe_close_stdin(Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_close_stdin"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_close_stdin"); + return; } exe->close_stdin = 1; } @@ -796,15 +771,14 @@ ecore_exe_close_stdin(Ecore_Exe *exe) * @param end_bytes limit of bytes at end of output to buffer. * @param start_lines limit of lines at start of output to buffer. * @param end_lines limit of lines at end of output to buffer. - * @ingroup Ecore_Exe_Basic_Group */ EAPI void ecore_exe_auto_limits_set(Ecore_Exe *exe, int start_bytes, int end_bytes, int start_lines, int end_lines) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_auto_limits_set"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_auto_limits_set"); + return; } /* FIXME: sanitize the input. */ exe->start_bytes = start_bytes; @@ -846,7 +820,7 @@ ecore_exe_auto_limits_set(Ecore_Exe *exe, int start_bytes, int end_bytes, int st * Spank programmer for freeing the event data if it came from the event system, as that autofrees. * Spank the programmer if they try to set the limits bigger than what has been gathered & ignored already, coz they just lost data. * Spank onefang and raster for opening this can of worms. - * Should we have seperate out/err limits? + * Should we have separate out/err limits? * Should we remove from the internal buffer the data that was delivered already? * If so, what to do about limits, start, and end? They could loose their meaning. */ @@ -857,7 +831,6 @@ ecore_exe_auto_limits_set(Ecore_Exe *exe, int start_bytes, int end_bytes, int st * * @param exe The given process handle. * @param flags Is this a ECORE_EXE_PIPE_READ or ECORE_EXE_PIPE_ERROR? - * @ingroup Ecore_Exe_Basic_Group */ EAPI Ecore_Exe_Event_Data * ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags) @@ -869,115 +842,115 @@ ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags) if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_event_data_get"); - return NULL; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_event_data_get"); + return NULL; } /* Sort out what sort of event we are. */ if (flags & ECORE_EXE_PIPE_READ) { - flags = ECORE_EXE_PIPE_READ; - if (exe->flags & ECORE_EXE_PIPE_READ_LINE_BUFFERED) - is_buffered = 1; + flags = ECORE_EXE_PIPE_READ; + if (exe->flags & ECORE_EXE_PIPE_READ_LINE_BUFFERED) + is_buffered = 1; } else { - flags = ECORE_EXE_PIPE_ERROR; - if (exe->flags & ECORE_EXE_PIPE_ERROR_LINE_BUFFERED) - is_buffered = 1; + flags = ECORE_EXE_PIPE_ERROR; + if (exe->flags & ECORE_EXE_PIPE_ERROR_LINE_BUFFERED) + is_buffered = 1; } /* Get the data. */ if (flags & ECORE_EXE_PIPE_READ) { - inbuf = exe->read_data_buf; - inbuf_num = exe->read_data_size; - exe->read_data_buf = NULL; - exe->read_data_size = 0; + inbuf = exe->read_data_buf; + inbuf_num = exe->read_data_size; + exe->read_data_buf = NULL; + exe->read_data_size = 0; } else { - inbuf = exe->error_data_buf; - inbuf_num = exe->error_data_size; - exe->error_data_buf = NULL; - exe->error_data_size = 0; + inbuf = exe->error_data_buf; + inbuf_num = exe->error_data_size; + exe->error_data_buf = NULL; + exe->error_data_size = 0; } e = calloc(1, sizeof(Ecore_Exe_Event_Data)); if (e) { - e->exe = exe; - e->data = inbuf; - e->size = inbuf_num; - - if (is_buffered) - { /* Deal with line buffering. */ - int max = 0; - int count = 0; - int i; - int last = 0; - char *c; - - c = (char *)inbuf; - for (i = 0; i < inbuf_num; i++) /* Find the lines. */ - { - if (inbuf[i] == '\n') - { - if (count >= max) - { - /* In testing, the lines seem to arrive in batches of 500 to 1000 lines at most, roughly speaking. */ - max += 10; /* FIXME: Maybe keep track of the largest number of lines ever sent, and add half that many instead of 10. */ - e->lines = realloc(e->lines, sizeof(Ecore_Exe_Event_Data_Line) * (max + 1)); /* Allow room for the NULL termination. */ - } - /* raster said to leave the line endings as line endings, however - - * This is line buffered mode, we are not dealing with binary here, but lines. - * If we are not dealing with binary, we must be dealing with ASCII, unicode, or some other text format. - * Thus the user is most likely gonna deal with this text as strings. - * Thus the user is most likely gonna pass this data to str functions. - * rasters way - the endings are always gonna be '\n'; onefangs way - they will always be '\0' - * We are handing them the string length as a convenience. - * Thus if they really want it in raw format, they can e->lines[i].line[e->lines[i].size - 1] = '\n'; easily enough. - * In the default case, we can do this conversion quicker than the user can, as we already have the index and pointer. - * Let's make it easy on them to use these as standard C strings. - * - * onefang is proud to announce that he has just set a new personal record for the - * most over documentation of a simple assignment statement. B-) - */ - inbuf[i] = '\0'; - e->lines[count].line = c; - e->lines[count].size = i - last; - last = i + 1; - c = (char *)&inbuf[last]; - count++; - } - } - if (count == 0) /* No lines to send, cancel the event. */ - { - _ecore_exe_event_exe_data_free(NULL, e); - e = NULL; - } - else /* NULL terminate the array, so that people know where the end is. */ - { - e->lines[count].line = NULL; - e->lines[count].size = 0; - } - if (i > last) /* Partial line left over, save it for next time. */ - { - if (e) e->size = last; - if (flags & ECORE_EXE_PIPE_READ) - { - exe->read_data_size = i - last; - exe->read_data_buf = malloc(exe->read_data_size); - memcpy(exe->read_data_buf, c, exe->read_data_size); - } - else - { - exe->error_data_size = i - last; - exe->error_data_buf = malloc(exe->error_data_size); - memcpy(exe->error_data_buf, c, exe->error_data_size); - } - } - } + e->exe = exe; + e->data = inbuf; + e->size = inbuf_num; + + if (is_buffered) + { /* Deal with line buffering. */ + int max = 0; + int count = 0; + int i; + int last = 0; + char *c; + + c = (char *)inbuf; + for (i = 0; i < inbuf_num; i++) /* Find the lines. */ + { + if (inbuf[i] == '\n') + { + if (count >= max) + { + /* In testing, the lines seem to arrive in batches of 500 to 1000 lines at most, roughly speaking. */ + max += 10; /* FIXME: Maybe keep track of the largest number of lines ever sent, and add half that many instead of 10. */ + e->lines = realloc(e->lines, sizeof(Ecore_Exe_Event_Data_Line) * (max + 1)); /* Allow room for the NULL termination. */ + } + /* raster said to leave the line endings as line endings, however - + * This is line buffered mode, we are not dealing with binary here, but lines. + * If we are not dealing with binary, we must be dealing with ASCII, unicode, or some other text format. + * Thus the user is most likely gonna deal with this text as strings. + * Thus the user is most likely gonna pass this data to str functions. + * rasters way - the endings are always gonna be '\n'; onefangs way - they will always be '\0' + * We are handing them the string length as a convenience. + * Thus if they really want it in raw format, they can e->lines[i].line[e->lines[i].size - 1] = '\n'; easily enough. + * In the default case, we can do this conversion quicker than the user can, as we already have the index and pointer. + * Let's make it easy on them to use these as standard C strings. + * + * onefang is proud to announce that he has just set a new personal record for the + * most over documentation of a simple assignment statement. B-) + */ + inbuf[i] = '\0'; + e->lines[count].line = c; + e->lines[count].size = i - last; + last = i + 1; + c = (char *)&inbuf[last]; + count++; + } + } + if (count == 0) /* No lines to send, cancel the event. */ + { + _ecore_exe_event_exe_data_free(NULL, e); + e = NULL; + } + else /* NULL terminate the array, so that people know where the end is. */ + { + e->lines[count].line = NULL; + e->lines[count].size = 0; + } + if (i > last) /* Partial line left over, save it for next time. */ + { + if (e) e->size = last; + if (flags & ECORE_EXE_PIPE_READ) + { + exe->read_data_size = i - last; + exe->read_data_buf = malloc(exe->read_data_size); + memcpy(exe->read_data_buf, c, exe->read_data_size); + } + else + { + exe->error_data_size = i - last; + exe->error_data_buf = malloc(exe->error_data_size); + memcpy(exe->error_data_buf, c, exe->error_data_size); + } + } + } } return e; @@ -988,15 +961,14 @@ ecore_exe_event_data_get(Ecore_Exe *exe, Ecore_Exe_Flags flags) * * @param exe The given process handle. * @param tag The string tag to set on the process handle. - * @ingroup Ecore_Exe_Basic_Group */ EAPI void ecore_exe_tag_set(Ecore_Exe *exe, const char *tag) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_tag_set"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_tag_set"); + return; } IF_FREE(exe->tag); if (tag) @@ -1015,15 +987,14 @@ ecore_exe_tag_set(Ecore_Exe *exe, const char *tag) * @return The string attached to @p exe. It is a handle to existing * internal string and should not be modified, use * ecore_exe_tag_set() to change it. It might be @c NULL. - * @ingroup Ecore_Exe_Basic_Group */ EAPI const char * ecore_exe_tag_get(const Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_tag_get"); - return NULL; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_tag_get"); + return NULL; } return exe->tag; } @@ -1037,7 +1008,6 @@ ecore_exe_tag_get(const Ecore_Exe *exe) * @param exe The given process handle. * @return The data attached to the handle when @ref ecore_exe_run was * called. - * @ingroup Ecore_Exe_Basic_Group */ EAPI void * ecore_exe_free(Ecore_Exe *exe) @@ -1048,8 +1018,8 @@ ecore_exe_free(Ecore_Exe *exe) if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_free"); - return NULL; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_free"); + return NULL; } data = exe->data; @@ -1059,17 +1029,17 @@ ecore_exe_free(Ecore_Exe *exe) if (exe->doomsday_clock) { - struct _ecore_exe_dead_exe *dead; - - ecore_timer_del(exe->doomsday_clock); - exe->doomsday_clock = NULL; - dead = exe->doomsday_clock_dead; - if (dead) - { - IF_FREE(dead->cmd); - free(dead); - exe->doomsday_clock_dead = NULL; - } + struct _ecore_exe_dead_exe *dead; + + ecore_timer_del(exe->doomsday_clock); + exe->doomsday_clock = NULL; + dead = exe->doomsday_clock_dead; + if (dead) + { + IF_FREE(dead->cmd); + free(dead); + exe->doomsday_clock_dead = NULL; + } } IF_FN_DEL(ecore_main_fd_handler_del, exe->write_fd_handler); IF_FN_DEL(ecore_main_fd_handler_del, exe->read_fd_handler); @@ -1102,7 +1072,6 @@ ecore_exe_free(Ecore_Exe *exe) * Frees the given event data. * * @param e The given event data. - * @ingroup Ecore_Exe_Basic_Group */ EAPI void ecore_exe_event_data_free(Ecore_Exe_Event_Data *e) @@ -1117,15 +1086,14 @@ ecore_exe_event_data_free(Ecore_Exe_Event_Data *e) * Retrieves the process ID of the given spawned process. * @param exe Handle to the given spawned process. * @return The process ID on success. @c -1 otherwise. - * @ingroup Ecore_Exe_Basic_Group */ EAPI pid_t ecore_exe_pid_get(const Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pid_get"); - return -1; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pid_get"); + return -1; } return exe->pid; } @@ -1136,15 +1104,14 @@ ecore_exe_pid_get(const Ecore_Exe *exe) * @return The command on success. NULL otherwise. This string is the * pointer to the internal value and must not be modified in * any way. - * @ingroup Ecore_Exe_Basic_Group */ EAPI const char * ecore_exe_cmd_get(const Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_cmd_get"); - return NULL; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_cmd_get"); + return NULL; } return exe->cmd; } @@ -1154,15 +1121,14 @@ ecore_exe_cmd_get(const Ecore_Exe *exe) * @param exe The given process handle. * @return The data pointer attached to @p exe Given to * ecore_exe_run() or ecore_exe_pipe_run() - * @ingroup Ecore_Exe_Basic_Group */ EAPI void * ecore_exe_data_get(const Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get"); - return NULL; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get"); + return NULL; } return exe->data; } @@ -1171,37 +1137,29 @@ ecore_exe_data_get(const Ecore_Exe *exe) * Retrieves the flags attached to the given process handle. * @param exe The given process handle. * @return The flags attached to @p exe. - * @ingroup Ecore_Exe_Basic_Group */ EAPI Ecore_Exe_Flags ecore_exe_flags_get(const Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get"); - return 0; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_data_get"); + return 0; } return exe->flags; } /** - * @defgroup Ecore_Exe_Signal_Group Spawned Process Signal Functions - * - * Functions that send signals to spawned processes. - */ - -/** * Pauses the given process by sending it a @c SIGSTOP signal. * @param exe Process handle to the given process. - * @ingroup Ecore_Exe_Signal_Group */ EAPI void ecore_exe_pause(Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pause"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_pause"); + return; } kill(exe->pid, SIGSTOP); } @@ -1209,15 +1167,14 @@ ecore_exe_pause(Ecore_Exe *exe) /** * Continues the given paused process by sending it a @c SIGCONT signal. * @param exe Process handle to the given process. - * @ingroup Ecore_Exe_Signal_Group */ EAPI void ecore_exe_continue(Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_continue"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_continue"); + return; } kill(exe->pid, SIGCONT); } @@ -1225,15 +1182,14 @@ ecore_exe_continue(Ecore_Exe *exe) /** * Sends the given spawned process a interrupt (@c SIGINT) signal. * @param exe Process handle to the given process. - * @ingroup Ecore_Exe_Signal_Group */ EAPI void ecore_exe_interrupt(Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_interrupt"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_interrupt"); + return; } _ecore_exe_dead_attach(exe); kill(exe->pid, SIGINT); @@ -1242,15 +1198,14 @@ ecore_exe_interrupt(Ecore_Exe *exe) /** * Sends the given spawned process a quit (@c SIGQUIT) signal. * @param exe Process handle to the given process. - * @ingroup Ecore_Exe_Signal_Group */ EAPI void ecore_exe_quit(Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_quit"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_quit"); + return; } _ecore_exe_dead_attach(exe); kill(exe->pid, SIGQUIT); @@ -1259,15 +1214,14 @@ ecore_exe_quit(Ecore_Exe *exe) /** * Sends the given spawned process a terminate (@c SIGTERM) signal. * @param exe Process handle to the given process. - * @ingroup Ecore_Exe_Signal_Group */ EAPI void ecore_exe_terminate(Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_terminate"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_terminate"); + return; } _ecore_exe_dead_attach(exe); INF("Sending TERM signal to %s (%d).", exe->cmd, exe->pid); @@ -1277,7 +1231,6 @@ ecore_exe_terminate(Ecore_Exe *exe) /** * Kills the given spawned process by sending it a @c SIGKILL signal. * @param exe Process handle to the given process. - * @ingroup Ecore_Exe_Signal_Group */ EAPI void ecore_exe_kill(Ecore_Exe *exe) @@ -1286,18 +1239,18 @@ ecore_exe_kill(Ecore_Exe *exe) if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_kill"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_kill"); + return; } dead = calloc(1, sizeof(struct _ecore_exe_dead_exe)); if (dead) { - dead->pid = exe->pid; - dead->cmd = strdup(exe->cmd); - IF_FN_DEL(ecore_timer_del, exe->doomsday_clock); - exe->doomsday_clock = - ecore_timer_add(10.0, _ecore_exe_make_sure_its_really_dead, dead); + dead->pid = exe->pid; + dead->cmd = strdup(exe->cmd); + IF_FN_DEL(ecore_timer_del, exe->doomsday_clock); + exe->doomsday_clock = + ecore_timer_add(10.0, _ecore_exe_make_sure_its_really_dead, dead); } INF("Sending KILL signal to %s (%d).", exe->cmd, exe->pid); @@ -1309,15 +1262,14 @@ ecore_exe_kill(Ecore_Exe *exe) * @param exe Process handle to the given process. * @param num The number user signal to send. Must be either 1 or 2, or * the signal will be ignored. - * @ingroup Ecore_Exe_Signal_Group */ EAPI void ecore_exe_signal(Ecore_Exe *exe, int num) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_signal"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_signal"); + return; } if (num == 1) kill(exe->pid, SIGUSR1); @@ -1328,25 +1280,32 @@ ecore_exe_signal(Ecore_Exe *exe, int num) /** * Sends a @c SIGHUP signal to the given spawned process. * @param exe Process handle to the given process. - * @ingroup Ecore_Exe_Signal_Group */ EAPI void ecore_exe_hup(Ecore_Exe *exe) { if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) { - ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_hup"); - return; + ECORE_MAGIC_FAIL(exe, ECORE_MAGIC_EXE, "ecore_exe_hup"); + return; } kill(exe->pid, SIGHUP); } +/** + * @} + */ + +/** + * @} + */ + static Ecore_Exe * _ecore_exe_is_it_alive(pid_t pid) { Ecore_Exe *exe = NULL; - /* FIXME: There is no nice, safe, OS independant way to tell if a + /* FIXME: There is no nice, safe, OS independent way to tell if a * particular PID is still alive. I have written code to do so * for my urunlevel busybox applet (http://urunlevel.sourceforge.net/), * but it's for linux only, and still not guaranteed. @@ -1371,8 +1330,8 @@ _ecore_exe_is_it_alive(pid_t pid) exe = _ecore_exe_find(pid); if (exe) { - if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) - exe = NULL; + if (!ECORE_MAGIC_CHECK(exe, ECORE_MAGIC_EXE)) + exe = NULL; } return exe; @@ -1386,26 +1345,26 @@ _ecore_exe_make_sure_its_dead(void *data) dead = data; if (dead) { - Ecore_Exe *exe = NULL; - - if ((exe = _ecore_exe_is_it_alive(dead->pid))) - { - if (dead->cmd) - INF("Sending KILL signal to alledgedly dead %s (%d).", - dead->cmd, dead->pid); - else - INF("Sending KILL signal to alledgedly dead PID %d.", - dead->pid); - exe->doomsday_clock = - ecore_timer_add(10.0, _ecore_exe_make_sure_its_really_dead, - dead); - kill(dead->pid, SIGKILL); - } - else - { - IF_FREE(dead->cmd); - free(dead); - } + Ecore_Exe *exe = NULL; + + if ((exe = _ecore_exe_is_it_alive(dead->pid))) + { + if (dead->cmd) + INF("Sending KILL signal to allegedly dead %s (%d).", + dead->cmd, dead->pid); + else + INF("Sending KILL signal to allegedly dead PID %d.", + dead->pid); + exe->doomsday_clock = + ecore_timer_add(10.0, _ecore_exe_make_sure_its_really_dead, + dead); + kill(dead->pid, SIGKILL); + } + else + { + IF_FREE(dead->cmd); + free(dead); + } } return ECORE_CALLBACK_CANCEL; } @@ -1418,19 +1377,19 @@ _ecore_exe_make_sure_its_really_dead(void *data) dead = data; if (dead) { - Ecore_Exe *exe = NULL; - - if ((exe = _ecore_exe_is_it_alive(dead->pid))) - { - ERR("RUN! The zombie wants to eat your brains! And your CPU!"); - if (dead->cmd) - INF("%s (%d) is not really dead.", dead->cmd, dead->pid); - else - INF("PID %d is not really dead.", dead->pid); - exe->doomsday_clock = NULL; - } - IF_FREE(dead->cmd); - free(dead); + Ecore_Exe *exe = NULL; + + if ((exe = _ecore_exe_is_it_alive(dead->pid))) + { + ERR("RUN! The zombie wants to eat your brains! And your CPU!"); + if (dead->cmd) + INF("%s (%d) is not really dead.", dead->cmd, dead->pid); + else + INF("PID %d is not really dead.", dead->pid); + exe->doomsday_clock = NULL; + } + IF_FREE(dead->cmd); + free(dead); } return ECORE_CALLBACK_CANCEL; } @@ -1458,8 +1417,8 @@ _ecore_exe_find(pid_t pid) EINA_INLIST_FOREACH(exes, exe) { - if (exe->pid == pid) - return exe; + if (exe->pid == pid) + return exe; } return NULL; } @@ -1492,76 +1451,76 @@ _ecore_exe_exec_it(const char *exe_cmd, Ecore_Exe_Flags flags) */ if (!strpbrk(exe_cmd, "|&;<>()$`\\\"'*?#")) { - char *token; - char pre_command = 1; - int num_tokens = 0; - - if (!(buf = strdup(exe_cmd))) - return; - - token = strtok(buf, " \t\n\v"); - while (token) - { - if (token[0] == '~') - break; - if (pre_command) - { - if (token[0] == '[') - break; - if (strchr(token, '=')) - break; - else - pre_command = 0; - } - num_tokens++; - token = strtok(NULL, " \t\n\v"); - } - IF_FREE(buf); - if ((!token) && (num_tokens)) - { - int i = 0; - - if (!(buf = strdup(exe_cmd))) - return; - - token = strtok(buf, " \t\n\v"); - use_sh = 0; - if (!(args = (char **)calloc(num_tokens + 1, sizeof(char *)))) - { - IF_FREE(buf); - return; - } - for (i = 0; i < num_tokens; i++) - { - if (token) - args[i] = token; - token = strtok(NULL, " \t\n\v"); - } - args[num_tokens] = NULL; - } + char *token; + char pre_command = 1; + int num_tokens = 0; + + if (!(buf = strdup(exe_cmd))) + return; + + token = strtok(buf, " \t\n\v"); + while (token) + { + if (token[0] == '~') + break; + if (pre_command) + { + if (token[0] == '[') + break; + if (strchr(token, '=')) + break; + else + pre_command = 0; + } + num_tokens++; + token = strtok(NULL, " \t\n\v"); + } + IF_FREE(buf); + if ((!token) && (num_tokens)) + { + int i = 0; + + if (!(buf = strdup(exe_cmd))) + return; + + token = strtok(buf, " \t\n\v"); + use_sh = 0; + if (!(args = (char **)calloc(num_tokens + 1, sizeof(char *)))) + { + IF_FREE(buf); + return; + } + for (i = 0; i < num_tokens; i++) + { + if (token) + args[i] = token; + token = strtok(NULL, " \t\n\v"); + } + args[num_tokens] = NULL; + } } if (!(flags & ECORE_EXE_NOT_LEADER)) setsid(); if ((flags & ECORE_EXE_USE_SH)) { - errno = 0; - execl("/bin/sh", "/bin/sh", "-c", exe_cmd, (char *)NULL); + errno = 0; + execl("/bin/sh", "/bin/sh", "-c", exe_cmd, (char *)NULL); } else if (use_sh) - { /* We have to use a shell to run this. */ - if (!shell) - { /* Find users preferred shell. */ - shell = getenv("SHELL"); - if (!shell) - shell = "/bin/sh"; - } - errno = 0; - execl(shell, shell, "-c", exe_cmd, (char *)NULL); + { /* We have to use a shell to run this. */ + if (!shell) + { /* Find users preferred shell. */ + shell = getenv("SHELL"); + if (!shell) + shell = "/bin/sh"; + } + errno = 0; + execl(shell, shell, "-c", exe_cmd, (char *)NULL); } else - { /* We can run this directly. */ - errno = 0; - execvp(args[0], args); + { /* We can run this directly. */ + errno = 0; + execvp(args[0], args); } save_errno = errno; @@ -1583,117 +1542,117 @@ _ecore_exe_data_generic_handler(void *data, Ecore_Fd_Handler *fd_handler, Ecore_ /* Sort out what sort of handler we are. */ if (flags & ECORE_EXE_PIPE_READ) { - flags = ECORE_EXE_PIPE_READ; - event_type = ECORE_EXE_EVENT_DATA; - child_fd = exe->child_fd_read; + flags = ECORE_EXE_PIPE_READ; + event_type = ECORE_EXE_EVENT_DATA; + child_fd = exe->child_fd_read; } else { - flags = ECORE_EXE_PIPE_ERROR; - event_type = ECORE_EXE_EVENT_ERROR; - child_fd = exe->child_fd_error; + flags = ECORE_EXE_PIPE_ERROR; + event_type = ECORE_EXE_EVENT_ERROR; + child_fd = exe->child_fd_error; } if ((fd_handler) && (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))) { - unsigned char *inbuf; - int inbuf_num; - - /* Get any left over data from last time. */ - if (flags & ECORE_EXE_PIPE_READ) - { - inbuf = exe->read_data_buf; - inbuf_num = exe->read_data_size; - exe->read_data_buf = NULL; - exe->read_data_size = 0; - } - else - { - inbuf = exe->error_data_buf; - inbuf_num = exe->error_data_size; - exe->error_data_buf = NULL; - exe->error_data_size = 0; - } - - for (;;) - { - int num, lost_exe; - char buf[READBUFSIZ]; - - lost_exe = 0; - errno = 0; - if ((num = read(child_fd, buf, READBUFSIZ)) < 1) - /* FIXME: SPEED/SIZE TRADE OFF - add a smaller READBUFSIZE - * (currently 64k) to inbuf, use that instead of buf, and - * save ourselves a memcpy(). */ - { - lost_exe = ((errno == EIO) || - (errno == EBADF) || - (errno == EPIPE) || - (errno == EINVAL) || (errno == ENOSPC)); - if ((errno != EAGAIN) && (errno != EINTR)) - perror("_ecore_exe_generic_handler() read problem "); - } - if (num > 0) - { /* data got read. */ - inbuf = realloc(inbuf, inbuf_num + num); - memcpy(inbuf + inbuf_num, buf, num); - inbuf_num += num; - } - else - { /* No more data to read. */ - if (inbuf) - { - Ecore_Exe_Event_Data *e; - - /* Stash the data away for later. */ - if (flags & ECORE_EXE_PIPE_READ) - { - exe->read_data_buf = inbuf; - exe->read_data_size = inbuf_num; - } - else - { - exe->error_data_buf = inbuf; - exe->error_data_size = inbuf_num; - } - - if (!(exe->flags & ECORE_EXE_PIPE_AUTO)) - { - e = ecore_exe_event_data_get(exe, flags); - if (e) /* Send the event. */ + unsigned char *inbuf; + int inbuf_num; + + /* Get any left over data from last time. */ + if (flags & ECORE_EXE_PIPE_READ) + { + inbuf = exe->read_data_buf; + inbuf_num = exe->read_data_size; + exe->read_data_buf = NULL; + exe->read_data_size = 0; + } + else + { + inbuf = exe->error_data_buf; + inbuf_num = exe->error_data_size; + exe->error_data_buf = NULL; + exe->error_data_size = 0; + } + + for (;;) + { + int num, lost_exe; + char buf[READBUFSIZ]; + + lost_exe = 0; + errno = 0; + if ((num = read(child_fd, buf, READBUFSIZ)) < 1) + /* FIXME: SPEED/SIZE TRADE OFF - add a smaller READBUFSIZE + * (currently 64k) to inbuf, use that instead of buf, and + * save ourselves a memcpy(). */ + { + lost_exe = ((errno == EIO) || + (errno == EBADF) || + (errno == EPIPE) || + (errno == EINVAL) || (errno == ENOSPC)); + if ((errno != EAGAIN) && (errno != EINTR)) + perror("_ecore_exe_generic_handler() read problem "); + } + if (num > 0) + { /* data got read. */ + inbuf = realloc(inbuf, inbuf_num + num); + memcpy(inbuf + inbuf_num, buf, num); + inbuf_num += num; + } + else + { /* No more data to read. */ + if (inbuf) + { + Ecore_Exe_Event_Data *e; + + /* Stash the data away for later. */ + if (flags & ECORE_EXE_PIPE_READ) + { + exe->read_data_buf = inbuf; + exe->read_data_size = inbuf_num; + } + else + { + exe->error_data_buf = inbuf; + exe->error_data_size = inbuf_num; + } + + if (!(exe->flags & ECORE_EXE_PIPE_AUTO)) + { + e = ecore_exe_event_data_get(exe, flags); + if (e) /* Send the event. */ ecore_event_add(event_type, e, _ecore_exe_event_exe_data_free, NULL); - } - } - if (lost_exe) - { - if (flags & ECORE_EXE_PIPE_READ) - { - if (exe->read_data_size) + } + } + if (lost_exe) + { + if (flags & ECORE_EXE_PIPE_READ) + { + if (exe->read_data_size) INF("There are %d bytes left unsent from the dead exe %s.", exe->read_data_size, exe->cmd); - } - else - { - if (exe->error_data_size) + } + else + { + if (exe->error_data_size) INF("There are %d bytes left unsent from the dead exe %s.", exe->error_data_size, exe->cmd); - } - /* Thought about this a bit. If the exe has actually - * died, this won't do any harm as it must have died - * recently and the pid has not had a chance to recycle. - * It is also a paranoid catchall, coz the usual ecore_signal - * mechenism should kick in. But let's give it a good - * kick in the head anyway. - */ - ecore_exe_terminate(exe); - } - break; - } - } + } + /* Thought about this a bit. If the exe has actually + * died, this won't do any harm as it must have died + * recently and the pid has not had a chance to recycle. + * It is also a paranoid catchall, coz the usual ecore_signal + * mechenism should kick in. But let's give it a good + * kick in the head anyway. + */ + ecore_exe_terminate(exe); + } + break; + } + } } return ECORE_CALLBACK_RENEW; @@ -1703,14 +1662,14 @@ static Eina_Bool _ecore_exe_data_error_handler(void *data, Ecore_Fd_Handler *fd_handler) { return _ecore_exe_data_generic_handler(data, fd_handler, - ECORE_EXE_PIPE_ERROR); + ECORE_EXE_PIPE_ERROR); } static Eina_Bool _ecore_exe_data_read_handler(void *data, Ecore_Fd_Handler *fd_handler) { return _ecore_exe_data_generic_handler(data, fd_handler, - ECORE_EXE_PIPE_READ); + ECORE_EXE_PIPE_READ); } static Eina_Bool @@ -1721,23 +1680,23 @@ _ecore_exe_data_write_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED_ exe = data; if ((exe->write_fd_handler) && (ecore_main_fd_handler_active_get - (exe->write_fd_handler, ECORE_FD_WRITE))) + (exe->write_fd_handler, ECORE_FD_WRITE))) _ecore_exe_flush(exe); /* If we have sent all there is to send, and we need to close the pipe, then close it. */ if ((exe->close_stdin == 1) && (exe->write_data_size == exe->write_data_offset)) { - int ok = 0; - int result; - - INF("Closing stdin for %s", exe->cmd); - /* if (exe->child_fd_write != -1) E_NO_ERRNO(result, fsync(exe->child_fd_write), ok); This a) doesn't work, and b) isn't needed. */ - IF_FN_DEL(ecore_main_fd_handler_del, exe->write_fd_handler); - if (exe->child_fd_write != -1) - E_NO_ERRNO(result, close(exe->child_fd_write), ok); - exe->child_fd_write = -1; - IF_FREE(exe->write_data_buf); + int ok = 0; + int result; + + INF("Closing stdin for %s", exe->cmd); + /* if (exe->child_fd_write != -1) E_NO_ERRNO(result, fsync(exe->child_fd_write), ok); This a) doesn't work, and b) isn't needed. */ + IF_FN_DEL(ecore_main_fd_handler_del, exe->write_fd_handler); + if (exe->child_fd_write != -1) + E_NO_ERRNO(result, close(exe->child_fd_write), ok); + exe->child_fd_write = -1; + IF_FREE(exe->write_data_buf); } return ECORE_CALLBACK_RENEW; @@ -1755,28 +1714,28 @@ _ecore_exe_flush(Ecore_Exe *exe) return; count = write(exe->child_fd_write, - (char *)exe->write_data_buf + exe->write_data_offset, - exe->write_data_size - exe->write_data_offset); + (char *)exe->write_data_buf + exe->write_data_offset, + exe->write_data_size - exe->write_data_offset); if (count < 1) { - if (errno == EIO || errno == EBADF || errno == EPIPE || errno == EINVAL || errno == ENOSPC) /* we lost our exe! */ - { - ecore_exe_terminate(exe); - if (exe->write_fd_handler) - ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); - } + if (errno == EIO || errno == EBADF || errno == EPIPE || errno == EINVAL || errno == ENOSPC) /* we lost our exe! */ + { + ecore_exe_terminate(exe); + if (exe->write_fd_handler) + ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); + } } else { - exe->write_data_offset += count; - if (exe->write_data_offset >= exe->write_data_size) - { /* Nothing left to write, clean up. */ - exe->write_data_size = 0; - exe->write_data_offset = 0; - IF_FREE(exe->write_data_buf); - if (exe->write_fd_handler) - ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); - } + exe->write_data_offset += count; + if (exe->write_data_offset >= exe->write_data_size) + { /* Nothing left to write, clean up. */ + exe->write_data_size = 0; + exe->write_data_offset = 0; + IF_FREE(exe->write_data_buf); + if (exe->write_fd_handler) + ecore_main_fd_handler_active_set(exe->write_fd_handler, 0); + } } } @@ -1836,11 +1795,11 @@ _ecore_exe_dead_attach(Ecore_Exe *exe) dead = calloc(1, sizeof(struct _ecore_exe_dead_exe)); if (dead) { - dead->pid = exe->pid; - dead->cmd = strdup(exe->cmd); - IF_FN_DEL(ecore_timer_del, exe->doomsday_clock); - exe->doomsday_clock = - ecore_timer_add(10.0, _ecore_exe_make_sure_its_dead, dead); - exe->doomsday_clock_dead = dead; + dead->pid = exe->pid; + dead->cmd = strdup(exe->cmd); + IF_FN_DEL(ecore_timer_del, exe->doomsday_clock); + exe->doomsday_clock = + ecore_timer_add(10.0, _ecore_exe_make_sure_its_dead, dead); + exe->doomsday_clock_dead = dead; } } diff --git a/src/lib/ecore/ecore_getopt.c b/src/lib/ecore/ecore_getopt.c index f00c46e..5b1c7bf 100644 --- a/src/lib/ecore/ecore_getopt.c +++ b/src/lib/ecore/ecore_getopt.c @@ -51,30 +51,30 @@ _ecore_getopt_help_print_replace_program(FILE *fp, const Ecore_Getopt *parser __ { do { - const char *d = strchr(text, '%'); - - if (!d) - { - fputs(text, fp); - break; - } - - if (fwrite(text, 1, d - text, fp) != (size_t)(d - text)) - return; - d++; - if (strncmp(d, "prog", sizeof("prog") - 1) == 0) - { - fputs(prog ? prog : "???", fp); - d += sizeof("prog") - 1; - } - else - { - if (d[0] == '%') - d++; - fputc('%', fp); - } - - text = d; + const char *d = strchr(text, '%'); + + if (!d) + { + fputs(text, fp); + break; + } + + if (fwrite(text, 1, d - text, fp) != (size_t)(d - text)) + return; + d++; + if (strncmp(d, "prog", sizeof("prog") - 1) == 0) + { + fputs(prog ? prog : "???", fp); + d += sizeof("prog") - 1; + } + else + { + if (d[0] == '%') + d++; + fputc('%', fp); + } + + text = d; } while (text[0] != '\0'); @@ -97,8 +97,8 @@ _ecore_getopt_help_usage(FILE *fp, const Ecore_Getopt *parser) if (!parser->usage) { - fprintf(fp, _("%s [options]\n"), prog); - return; + fprintf(fp, _("%s [options]\n"), prog); + return; } _ecore_getopt_help_print_replace_program(fp, parser, gettext(parser->usage)); @@ -110,75 +110,75 @@ _ecore_getopt_help_line(FILE *fp, const int base, const int total, int used, con int linebreak = 0; do { - /* process line considering spaces (new line and tabs are spaces!) */ - while ((used < total) && (len > 0)) - { - const char *space = NULL; - int i, todo; - - todo = total - used; - if (todo > len) - todo = len; - - for (i = 0; i < todo; i++) - if (isspace(text[i])) - { - space = text + i; - break; - } - - if (space) - { - i = fwrite(text, 1, i, fp); - i++; - text += i; - len -= i; - used += i; - - if (linebreak) - { - linebreak = 0; - continue; - } - - if (space[0] == '\n') - break; - else if (space[0] == '\t') - { - int c; - - used--; - c = ((used / 8) + 1) * 8; - if (c < total) - { - for (; used < c; used++) - fputc(' ', fp); - } - else - { - text--; - len++; - break; - } - } - else if (used < total) - fputc(space[0], fp); - } - else - { - i = fwrite(text, 1, i, fp); - text += i; - len -= i; - used += i; - } - linebreak = 0; - } - if (len <= 0) - break; - linebreak = 1; - fputc('\n', fp); - for (used = 0; used < base; used++) - fputc(' ', fp); + /* process line considering spaces (new line and tabs are spaces!) */ + while ((used < total) && (len > 0)) + { + const char *space = NULL; + int i, todo; + + todo = total - used; + if (todo > len) + todo = len; + + for (i = 0; i < todo; i++) + if (isspace(text[i])) + { + space = text + i; + break; + } + + if (space) + { + i = fwrite(text, 1, i, fp); + i++; + text += i; + len -= i; + used += i; + + if (linebreak) + { + linebreak = 0; + continue; + } + + if (space[0] == '\n') + break; + else if (space[0] == '\t') + { + int c; + + used--; + c = ((used / 8) + 1) * 8; + if (c < total) + { + for (; used < c; used++) + fputc(' ', fp); + } + else + { + text--; + len++; + break; + } + } + else if (used < total) + fputc(space[0], fp); + } + else + { + i = fwrite(text, 1, i, fp); + text += i; + len -= i; + used += i; + } + linebreak = 0; + } + if (len <= 0) + break; + linebreak = 1; + fputc('\n', fp); + for (used = 0; used < base; used++) + fputc(' ', fp); } while (1); @@ -207,34 +207,34 @@ _ecore_getopt_help_description(FILE *fp, const Ecore_Getopt *parser) do { - const char *d = strchr(p, '%'); - - if (!d) - { - _ecore_getopt_help_line(fp, 0, cols, used, p, strlen(p)); - break; - } - - used = _ecore_getopt_help_line(fp, 0, cols, used, p, d - p); - d++; - if (strncmp(d, "prog", sizeof("prog") - 1) == 0) - { - used = _ecore_getopt_help_line(fp, 0, cols, used, prg, prglen); - d += sizeof("prog") - 1; - } - else if (strncmp(d, "version", sizeof("version") - 1) == 0) - { - used = _ecore_getopt_help_line(fp, 0, cols, used, ver, verlen); - d += sizeof("version") - 1; - } - else - { - if (d[0] == '%') - d++; - used = _ecore_getopt_help_line(fp, 0, cols, used, "%", 1); - } - - p = d; + const char *d = strchr(p, '%'); + + if (!d) + { + _ecore_getopt_help_line(fp, 0, cols, used, p, strlen(p)); + break; + } + + used = _ecore_getopt_help_line(fp, 0, cols, used, p, d - p); + d++; + if (strncmp(d, "prog", sizeof("prog") - 1) == 0) + { + used = _ecore_getopt_help_line(fp, 0, cols, used, prg, prglen); + d += sizeof("prog") - 1; + } + else if (strncmp(d, "version", sizeof("version") - 1) == 0) + { + used = _ecore_getopt_help_line(fp, 0, cols, used, ver, verlen); + d += sizeof("version") - 1; + } + else + { + if (d[0] == '%') + d++; + used = _ecore_getopt_help_line(fp, 0, cols, used, "%", 1); + } + + p = d; } while (p[0] != '\0'); @@ -269,27 +269,27 @@ _ecore_getopt_desc_arg_requirement(const Ecore_Getopt_Desc *desc) switch (desc->action) { case ECORE_GETOPT_ACTION_STORE: - return desc->action_param.store.arg_req; + return desc->action_param.store.arg_req; case ECORE_GETOPT_ACTION_STORE_CONST: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; case ECORE_GETOPT_ACTION_STORE_TRUE: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; case ECORE_GETOPT_ACTION_STORE_FALSE: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; case ECORE_GETOPT_ACTION_CHOICE: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES; case ECORE_GETOPT_ACTION_APPEND: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES; case ECORE_GETOPT_ACTION_COUNT: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; case ECORE_GETOPT_ACTION_CALLBACK: - return desc->action_param.callback.arg_req; + return desc->action_param.callback.arg_req; case ECORE_GETOPT_ACTION_HELP: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; case ECORE_GETOPT_ACTION_VERSION: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; default: - return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; + return ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO; } } @@ -298,25 +298,25 @@ _ecore_getopt_help_desc_setup_metavar(const Ecore_Getopt_Desc *desc, char *metav { if (desc->metavar) { - const char *txt = gettext(desc->metavar); - *metavarlen = strlen(txt); - if (*metavarlen > maxsize - 1) - *metavarlen = maxsize - 1; + const char *txt = gettext(desc->metavar); + *metavarlen = strlen(txt); + if (*metavarlen > maxsize - 1) + *metavarlen = maxsize - 1; - memcpy(metavar, txt, *metavarlen); - metavar[*metavarlen] = '\0'; + memcpy(metavar, txt, *metavarlen); + metavar[*metavarlen] = '\0'; } else if (desc->longname) { - int i; + int i; - *metavarlen = strlen(desc->longname); - if (*metavarlen > maxsize - 1) - *metavarlen = maxsize - 1; + *metavarlen = strlen(desc->longname); + if (*metavarlen > maxsize - 1) + *metavarlen = maxsize - 1; - for (i = 0; i < *metavarlen; i++) - metavar[i] = toupper(desc->longname[i]); - metavar[i] = '\0'; + for (i = 0; i < *metavarlen; i++) + metavar[i] = toupper(desc->longname[i]); + metavar[i] = '\0'; } } @@ -332,21 +332,21 @@ _ecore_getopt_help_desc_show_arg(FILE *fp, Ecore_Getopt_Desc_Arg_Requirement req if (requirement == ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL) { - fputc('[', fp); - used++; + fputc('[', fp); + used++; } if (requirement != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) { - fputc('=', fp); - fputs(metavar, fp); - used += metavarlen + 1; + fputc('=', fp); + fputs(metavar, fp); + used += metavarlen + 1; } if (requirement == ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL) { - fputc(']', fp); - used++; + fputc(']', fp); + used++; } return used; @@ -367,44 +367,44 @@ _ecore_getopt_help_desc_store(FILE *fp, const int base, const int total, int use switch (store->type) { case ECORE_GETOPT_TYPE_STR: - str = "STR"; - len = sizeof("STR") - 1; - break; + str = "STR"; + len = sizeof("STR") - 1; + break; case ECORE_GETOPT_TYPE_BOOL: - str = "BOOL"; - len = sizeof("BOOL") - 1; - break; + str = "BOOL"; + len = sizeof("BOOL") - 1; + break; case ECORE_GETOPT_TYPE_SHORT: - str = "SHORT"; - len = sizeof("SHORT") - 1; - break; + str = "SHORT"; + len = sizeof("SHORT") - 1; + break; case ECORE_GETOPT_TYPE_INT: - str = "INT"; - len = sizeof("INT") - 1; - break; + str = "INT"; + len = sizeof("INT") - 1; + break; case ECORE_GETOPT_TYPE_LONG: - str = "LONG"; - len = sizeof("LONG") - 1; - break; + str = "LONG"; + len = sizeof("LONG") - 1; + break; case ECORE_GETOPT_TYPE_USHORT: - str = "USHORT"; - len = sizeof("USHORT") - 1; - break; + str = "USHORT"; + len = sizeof("USHORT") - 1; + break; case ECORE_GETOPT_TYPE_UINT: - str = "UINT"; - len = sizeof("UINT") - 1; - break; + str = "UINT"; + len = sizeof("UINT") - 1; + break; case ECORE_GETOPT_TYPE_ULONG: - str = "ULONG"; - len = sizeof("ULONG") - 1; - break; + str = "ULONG"; + len = sizeof("ULONG") - 1; + break; case ECORE_GETOPT_TYPE_DOUBLE: - str = "DOUBLE"; - len = sizeof("DOUBLE") - 1; - break; + str = "DOUBLE"; + len = sizeof("DOUBLE") - 1; + break; default: - str = "???"; - len = sizeof("???") - 1; + str = "???"; + len = sizeof("???") - 1; } used = _ecore_getopt_help_line @@ -420,58 +420,58 @@ _ecore_getopt_help_desc_store(FILE *fp, const int base, const int total, int use switch (store->type) { case ECORE_GETOPT_TYPE_STR: - str = store->def.strv; - len = str ? strlen(str) : 0; - break; + str = store->def.strv; + len = str ? strlen(str) : 0; + break; case ECORE_GETOPT_TYPE_BOOL: - str = store->def.boolv ? "true" : "false"; - len = strlen(str); - break; + str = store->def.boolv ? "true" : "false"; + len = strlen(str); + break; case ECORE_GETOPT_TYPE_SHORT: - str = buf; - len = snprintf(buf, sizeof(buf), "%hd", store->def.shortv); - if (len > sizeof(buf) - 1) - len = sizeof(buf) - 1; - break; + str = buf; + len = snprintf(buf, sizeof(buf), "%hd", store->def.shortv); + if (len > sizeof(buf) - 1) + len = sizeof(buf) - 1; + break; case ECORE_GETOPT_TYPE_INT: - str = buf; - len = snprintf(buf, sizeof(buf), "%d", store->def.intv); - if (len > sizeof(buf) - 1) - len = sizeof(buf) - 1; - break; + str = buf; + len = snprintf(buf, sizeof(buf), "%d", store->def.intv); + if (len > sizeof(buf) - 1) + len = sizeof(buf) - 1; + break; case ECORE_GETOPT_TYPE_LONG: - str = buf; - len = snprintf(buf, sizeof(buf), "%ld", store->def.longv); - if (len > sizeof(buf) - 1) - len = sizeof(buf) - 1; - break; + str = buf; + len = snprintf(buf, sizeof(buf), "%ld", store->def.longv); + if (len > sizeof(buf) - 1) + len = sizeof(buf) - 1; + break; case ECORE_GETOPT_TYPE_USHORT: - str = buf; - len = snprintf(buf, sizeof(buf), "%hu", store->def.ushortv); - if (len > sizeof(buf) - 1) - len = sizeof(buf) - 1; - break; + str = buf; + len = snprintf(buf, sizeof(buf), "%hu", store->def.ushortv); + if (len > sizeof(buf) - 1) + len = sizeof(buf) - 1; + break; case ECORE_GETOPT_TYPE_UINT: - str = buf; - len = snprintf(buf, sizeof(buf), "%u", store->def.uintv); - if (len > sizeof(buf) - 1) - len = sizeof(buf) - 1; - break; + str = buf; + len = snprintf(buf, sizeof(buf), "%u", store->def.uintv); + if (len > sizeof(buf) - 1) + len = sizeof(buf) - 1; + break; case ECORE_GETOPT_TYPE_ULONG: - str = buf; - len = snprintf(buf, sizeof(buf), "%lu", store->def.ulongv); - if (len > sizeof(buf) - 1) - len = sizeof(buf) - 1; - break; + str = buf; + len = snprintf(buf, sizeof(buf), "%lu", store->def.ulongv); + if (len > sizeof(buf) - 1) + len = sizeof(buf) - 1; + break; case ECORE_GETOPT_TYPE_DOUBLE: - str = buf; - len = snprintf(buf, sizeof(buf), "%f", store->def.doublev); - if (len > sizeof(buf) - 1) - len = sizeof(buf) - 1; - break; + str = buf; + len = snprintf(buf, sizeof(buf), "%f", store->def.doublev); + if (len > sizeof(buf) - 1) + len = sizeof(buf) - 1; + break; default: - str = "???"; - len = sizeof("???") - 1; + str = "???"; + len = sizeof("???") - 1; } used = _ecore_getopt_help_line @@ -491,8 +491,8 @@ _ecore_getopt_help_desc_choices(FILE *fp, const int base, const int total, int u if (used > 0) { - fputc('\n', fp); - used = 0; + fputc('\n', fp); + used = 0; } for (; used < base; used++) fputc(' ', fp); @@ -502,10 +502,10 @@ _ecore_getopt_help_desc_choices(FILE *fp, const int base, const int total, int u for (itr = desc->action_param.choices; *itr; itr++) { - used = _ecore_getopt_help_line - (fp, base, total, used, *itr, strlen(*itr)); - if (itr[1]) - used = _ecore_getopt_help_line(fp, base, total, used, sep, seplen); + used = _ecore_getopt_help_line + (fp, base, total, used, *itr, strlen(*itr)); + if (itr[1]) + used = _ecore_getopt_help_line(fp, base, total, used, sep, seplen); } return _ecore_getopt_help_line(fp, base, total, used, ".", 1); @@ -529,28 +529,28 @@ _ecore_getopt_help_desc(FILE *fp, const Ecore_Getopt_Desc *desc) if (desc->shortname) { - fputc('-', fp); - fputc(desc->shortname, fp); - used += 2; - used += _ecore_getopt_help_desc_show_arg - (fp, arg_req, metavar, metavarlen); + fputc('-', fp); + fputc(desc->shortname, fp); + used += 2; + used += _ecore_getopt_help_desc_show_arg + (fp, arg_req, metavar, metavarlen); } if (desc->shortname && desc->longname) { - fputs(", ", fp); - used += 2; + fputs(", ", fp); + used += 2; } if (desc->longname) { - int namelen = strlen(desc->longname); + int namelen = strlen(desc->longname); - fputs("--", fp); - fputs(desc->longname, fp); - used += 2 + namelen; - used += _ecore_getopt_help_desc_show_arg - (fp, arg_req, metavar, metavarlen); + fputs("--", fp); + fputs(desc->longname, fp); + used += 2 + namelen; + used += _ecore_getopt_help_desc_show_arg + (fp, arg_req, metavar, metavarlen); } if (!desc->help) @@ -558,8 +558,8 @@ _ecore_getopt_help_desc(FILE *fp, const Ecore_Getopt_Desc *desc) if (used + 3 >= helpcol) { - fputc('\n', fp); - used = 0; + fputc('\n', fp); + used = 0; } for (; used < helpcol; used++) @@ -571,13 +571,13 @@ _ecore_getopt_help_desc(FILE *fp, const Ecore_Getopt_Desc *desc) switch (desc->action) { case ECORE_GETOPT_ACTION_STORE: - _ecore_getopt_help_desc_store(fp, helpcol, cols, used, desc); - break; + _ecore_getopt_help_desc_store(fp, helpcol, cols, used, desc); + break; case ECORE_GETOPT_ACTION_CHOICE: - _ecore_getopt_help_desc_choices(fp, helpcol, cols, used, desc); - break; + _ecore_getopt_help_desc_choices(fp, helpcol, cols, used, desc); + break; default: - break; + break; } end: @@ -617,21 +617,21 @@ ecore_getopt_help(FILE *fp, const Ecore_Getopt *parser) if (argc < 1) { - ecore_app_args_get(&argc, &argv); - if ((argc > 0) && (argv[0])) - prog = argv[0]; - else - prog = parser->prog; + ecore_app_args_get(&argc, &argv); + if ((argc > 0) && (argv[0])) + prog = argv[0]; + else + prog = parser->prog; } var = getenv("COLUMNS"); if (var) { - cols = atoi(var); - if (cols < 20) - cols = 20; + cols = atoi(var); + if (cols < 20) + cols = 20; - helpcol = cols / 3; + helpcol = cols / 3; } _ecore_getopt_help_usage(fp, parser); @@ -651,20 +651,20 @@ _ecore_getopt_parse_find_long(const Ecore_Getopt *parser, const char *name) for (; !_ecore_getopt_desc_is_sentinel(desc); desc++) { - if (!desc->longname) - continue; - - if (p) - { - if ((strncmp(name, desc->longname, len) == 0) && - (desc->longname[len] == '\0')) - return desc; - } - else - { - if (strcmp(name, desc->longname) == 0) - return desc; - } + if (!desc->longname) + continue; + + if (p) + { + if ((strncmp(name, desc->longname, len) == 0) && + (desc->longname[len] == '\0')) + return desc; + } + else + { + if (strcmp(name, desc->longname) == 0) + return desc; + } } return NULL; @@ -693,75 +693,75 @@ _ecore_getopt_parse_find_nonargs_base(const Ecore_Getopt *parser, int argc, char base = 0; while (src < argc) { - const Ecore_Getopt_Desc *desc; - Ecore_Getopt_Desc_Arg_Requirement arg_req; - char *arg = argv[src]; - - if (arg[0] != '-') - goto found_nonarg; - - if (arg[1] == '-') - { - if (arg[2] == '\0') /* explicit end of options, "--" */ - { - base = 1; - break; - } - desc = _ecore_getopt_parse_find_long(parser, arg + 2); - } - else - desc = _ecore_getopt_parse_find_short(parser, arg[1]); - - if (!desc) - { - if (arg[1] == '-') - fprintf(stderr, _("ERROR: unknown option --%s.\n"), arg + 2); - else - fprintf(stderr, _("ERROR: unknown option -%c.\n"), arg[1]); - if (parser->strict) - { - memmove(argv + dst, nonargs, used * sizeof(char *)); - return -1; - } - else - goto found_nonarg; - } - - if (src != dst) - argv[dst] = argv[src]; - src++; - dst++; - - arg_req = _ecore_getopt_desc_arg_requirement(desc); - if (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) - continue; - - if (strchr(arg, '=')) - continue; - - if ((src >= argc) || (argv[src][0] == '-')) - continue; - - if (src != dst) - argv[dst] = argv[src]; - src++; - dst++; - continue; + const Ecore_Getopt_Desc *desc; + Ecore_Getopt_Desc_Arg_Requirement arg_req; + char *arg = argv[src]; + + if (arg[0] != '-') + goto found_nonarg; + + if (arg[1] == '-') + { + if (arg[2] == '\0') /* explicit end of options, "--" */ + { + base = 1; + break; + } + desc = _ecore_getopt_parse_find_long(parser, arg + 2); + } + else + desc = _ecore_getopt_parse_find_short(parser, arg[1]); + + if (!desc) + { + if (arg[1] == '-') + fprintf(stderr, _("ERROR: unknown option --%s.\n"), arg + 2); + else + fprintf(stderr, _("ERROR: unknown option -%c.\n"), arg[1]); + if (parser->strict) + { + memmove(argv + dst, nonargs, used * sizeof(char *)); + return -1; + } + else + goto found_nonarg; + } + + if (src != dst) + argv[dst] = argv[src]; + src++; + dst++; + + arg_req = _ecore_getopt_desc_arg_requirement(desc); + if (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) + continue; + + if (strchr(arg, '=')) + continue; + + if ((src >= argc) || (argv[src][0] == '-')) + continue; + + if (src != dst) + argv[dst] = argv[src]; + src++; + dst++; + continue; found_nonarg: - nonargs[used] = arg; - used++; - src++; + nonargs[used] = arg; + used++; + src++; } if (!base) /* '--' not found */ base = dst; else { - base = dst; - if (src != dst) - argv[dst] = argv[src]; - dst++; + base = dst; + if (src != dst) + argv[dst] = argv[src]; + dst++; } memmove(argv + dst, nonargs, used * sizeof(char *)); @@ -777,8 +777,8 @@ _ecore_getopt_desc_print_error(const Ecore_Getopt_Desc *desc, const char *fmt, . if (desc->shortname) { - fputc('-', stderr); - fputc(desc->shortname, stderr); + fputc('-', stderr); + fputc(desc->shortname, stderr); } if (desc->shortname && desc->longname) @@ -786,8 +786,8 @@ _ecore_getopt_desc_print_error(const Ecore_Getopt_Desc *desc, const char *fmt, . if (desc->longname) { - fputs("--", stderr); - fputs(desc->longname, stderr); + fputs("--", stderr); + fputs(desc->longname, stderr); } fputs(": ", stderr); @@ -807,18 +807,18 @@ _ecore_getopt_parse_bool(const char *str, unsigned char *v) (strcasecmp(str, "off") == 0) ) { - *v = 0; - return 1; + *v = 0; + return 1; } else if ((strcmp(str, "1") == 0) || - (strcasecmp(str, "t") == 0) || - (strcasecmp(str, "true") == 0) || - (strcasecmp(str, "yes") == 0) || - (strcasecmp(str, "on") == 0) - ) + (strcasecmp(str, "t") == 0) || + (strcasecmp(str, "true") == 0) || + (strcasecmp(str, "yes") == 0) || + (strcasecmp(str, "on") == 0) + ) { - *v = 1; - return 1; + *v = 1; + return 1; } return 0; @@ -850,73 +850,73 @@ _ecore_getopt_parse_store(const Ecore_Getopt *parser __UNUSED__, const Ecore_Get if (!value->ptrp) { - _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); + return 0; } switch (store->arg_req) { case ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO: - goto use_optional; + goto use_optional; case ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL: - if (!arg_val) - goto use_optional; + if (!arg_val) + goto use_optional; case ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES: - break; + break; } switch (store->type) { case ECORE_GETOPT_TYPE_STR: - *value->strp = (char *)arg_val; - return 1; + *value->strp = (char *)arg_val; + return 1; case ECORE_GETOPT_TYPE_BOOL: - if (_ecore_getopt_parse_bool(arg_val, &b)) - { - *value->boolp = b; - return 1; - } - else - { - _ecore_getopt_desc_print_error - (desc, _("unknown boolean value %s.\n"), arg_val); - return 0; - } + if (_ecore_getopt_parse_bool(arg_val, &b)) + { + *value->boolp = b; + return 1; + } + else + { + _ecore_getopt_desc_print_error + (desc, _("unknown boolean value %s.\n"), arg_val); + return 0; + } case ECORE_GETOPT_TYPE_SHORT: - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - *value->shortp = v; - return 1; + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + *value->shortp = v; + return 1; case ECORE_GETOPT_TYPE_INT: - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - *value->intp = v; - return 1; + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + *value->intp = v; + return 1; case ECORE_GETOPT_TYPE_LONG: - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - *value->longp = v; - return 1; + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + *value->longp = v; + return 1; case ECORE_GETOPT_TYPE_USHORT: - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - *value->ushortp = v; - return 1; + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + *value->ushortp = v; + return 1; case ECORE_GETOPT_TYPE_UINT: - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - *value->uintp = v; - return 1; + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + *value->uintp = v; + return 1; case ECORE_GETOPT_TYPE_ULONG: - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - *value->ulongp = v; - return 1; + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + *value->ulongp = v; + return 1; case ECORE_GETOPT_TYPE_DOUBLE: - if (!_ecore_getopt_parse_double(arg_val, &d)) - goto error; - *value->doublep = d; - break; + if (!_ecore_getopt_parse_double(arg_val, &d)) + goto error; + *value->doublep = d; + break; } return 1; @@ -930,32 +930,32 @@ _ecore_getopt_parse_store(const Ecore_Getopt *parser __UNUSED__, const Ecore_Get switch (store->type) { case ECORE_GETOPT_TYPE_STR: - *value->strp = (char *)store->def.strv; - break; + *value->strp = (char *)store->def.strv; + break; case ECORE_GETOPT_TYPE_BOOL: - *value->boolp = store->def.boolv; - break; + *value->boolp = store->def.boolv; + break; case ECORE_GETOPT_TYPE_SHORT: - *value->shortp = store->def.shortv; - break; + *value->shortp = store->def.shortv; + break; case ECORE_GETOPT_TYPE_INT: - *value->intp = store->def.intv; - break; + *value->intp = store->def.intv; + break; case ECORE_GETOPT_TYPE_LONG: - *value->longp = store->def.longv; - break; + *value->longp = store->def.longv; + break; case ECORE_GETOPT_TYPE_USHORT: - *value->ushortp = store->def.ushortv; - break; + *value->ushortp = store->def.ushortv; + break; case ECORE_GETOPT_TYPE_UINT: - *value->uintp = store->def.uintv; - break; + *value->uintp = store->def.uintv; + break; case ECORE_GETOPT_TYPE_ULONG: - *value->ulongp = store->def.ulongv; - break; + *value->ulongp = store->def.ulongv; + break; case ECORE_GETOPT_TYPE_DOUBLE: - *value->doublep = store->def.doublev; - break; + *value->doublep = store->def.doublev; + break; } return 1; @@ -966,8 +966,8 @@ _ecore_getopt_parse_store_const(const Ecore_Getopt *parser __UNUSED__, const Eco { if (!val->ptrp) { - _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); + return 0; } *val->ptrp = (void *)desc->action_param.store_const; @@ -979,8 +979,8 @@ _ecore_getopt_parse_store_true(const Ecore_Getopt *parser __UNUSED__, const Ecor { if (!val->boolp) { - _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); + return 0; } *val->boolp = 1; return 1; @@ -991,8 +991,8 @@ _ecore_getopt_parse_store_false(const Ecore_Getopt *parser __UNUSED__, const Eco { if (!val->boolp) { - _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); + return 0; } *val->boolp = 0; return 1; @@ -1005,16 +1005,16 @@ _ecore_getopt_parse_choice(const Ecore_Getopt *parser __UNUSED__, const Ecore_Ge if (!val->strp) { - _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); + return 0; } pchoice = desc->action_param.choices; for (; *pchoice; pchoice++) if (strcmp(*pchoice, arg_val) == 0) { - *val->strp = (char *)*pchoice; - return 1; + *val->strp = (char *)*pchoice; + return 1; } _ecore_getopt_desc_print_error @@ -1023,9 +1023,9 @@ _ecore_getopt_parse_choice(const Ecore_Getopt *parser __UNUSED__, const Ecore_Ge pchoice = desc->action_param.choices; for (; *pchoice; pchoice++) { - fputs(*pchoice, stderr); - if (pchoice[1]) - fputs(", ", stderr); + fputs(*pchoice, stderr); + if (pchoice[1]) + fputs(", ", stderr); } fputs(".\n", stderr); @@ -1042,106 +1042,106 @@ _ecore_getopt_parse_append(const Ecore_Getopt *parser __UNUSED__, const Ecore_Ge if (!arg_val) { - _ecore_getopt_desc_print_error - (desc, _("missing parameter to append.\n")); - return 0; + _ecore_getopt_desc_print_error + (desc, _("missing parameter to append.\n")); + return 0; } if (!val->listp) { - _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); + return 0; } switch (desc->action_param.append_type) { case ECORE_GETOPT_TYPE_STR: - data = strdup(arg_val); - break; + data = strdup(arg_val); + break; case ECORE_GETOPT_TYPE_BOOL: - { - if (_ecore_getopt_parse_bool(arg_val, &b)) - { - data = malloc(sizeof(unsigned char)); - if (data) - *(unsigned char *)data = b; - } - else - { - _ecore_getopt_desc_print_error - (desc, _("unknown boolean value %s.\n"), arg_val); - return 0; - } - } - break; + { + if (_ecore_getopt_parse_bool(arg_val, &b)) + { + data = malloc(sizeof(unsigned char)); + if (data) + *(unsigned char *)data = b; + } + else + { + _ecore_getopt_desc_print_error + (desc, _("unknown boolean value %s.\n"), arg_val); + return 0; + } + } + break; case ECORE_GETOPT_TYPE_SHORT: - { - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - data = malloc(sizeof(short)); - if (data) - *(short *)data = (short)v; - } - break; + { + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + data = malloc(sizeof(short)); + if (data) + *(short *)data = (short)v; + } + break; case ECORE_GETOPT_TYPE_INT: - { - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - data = malloc(sizeof(int)); - if (data) - *(int *)data = (int)v; - } - break; + { + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + data = malloc(sizeof(int)); + if (data) + *(int *)data = (int)v; + } + break; case ECORE_GETOPT_TYPE_LONG: - { - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - data = malloc(sizeof(long)); - if (data) - *(long *)data = v; - } - break; + { + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + data = malloc(sizeof(long)); + if (data) + *(long *)data = v; + } + break; case ECORE_GETOPT_TYPE_USHORT: - { - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - data = malloc(sizeof(unsigned short)); - if (data) - *(unsigned short *)data = (unsigned short)v; - } - break; + { + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + data = malloc(sizeof(unsigned short)); + if (data) + *(unsigned short *)data = (unsigned short)v; + } + break; case ECORE_GETOPT_TYPE_UINT: - { - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - data = malloc(sizeof(unsigned int)); - if (data) - *(unsigned int *)data = (unsigned int)v; - } - break; + { + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + data = malloc(sizeof(unsigned int)); + if (data) + *(unsigned int *)data = (unsigned int)v; + } + break; case ECORE_GETOPT_TYPE_ULONG: - { - if (!_ecore_getopt_parse_long(arg_val, &v)) - goto error; - data = malloc(sizeof(unsigned long)); - if (data) - *(unsigned long *)data = v; - } - break; + { + if (!_ecore_getopt_parse_long(arg_val, &v)) + goto error; + data = malloc(sizeof(unsigned long)); + if (data) + *(unsigned long *)data = v; + } + break; case ECORE_GETOPT_TYPE_DOUBLE: - { - if (!_ecore_getopt_parse_double(arg_val, &d)) - goto error; - data = malloc(sizeof(double)); - if (data) - *(double *)data = d; - } - break; + { + if (!_ecore_getopt_parse_double(arg_val, &d)) + goto error; + data = malloc(sizeof(double)); + if (data) + *(double *)data = d; + } + break; default: - { - _ecore_getopt_desc_print_error(desc, _("could not parse value.\n")); - return 0; - } + { + _ecore_getopt_desc_print_error(desc, _("could not parse value.\n")); + return 0; + } } *val->listp = eina_list_append(*val->listp, data); @@ -1158,8 +1158,8 @@ _ecore_getopt_parse_count(const Ecore_Getopt *parser __UNUSED__, const Ecore_Get { if (!val->intp) { - _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("value has no pointer set.\n")); + return 0; } (*val->intp)++; @@ -1174,36 +1174,36 @@ _ecore_getopt_parse_callback(const Ecore_Getopt *parser, const Ecore_Getopt_Desc switch (cb->arg_req) { case ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO: - arg_val = cb->def; - break; + arg_val = cb->def; + break; case ECORE_GETOPT_DESC_ARG_REQUIREMENT_OPTIONAL: - if (!arg_val) - arg_val = cb->def; - break; + if (!arg_val) + arg_val = cb->def; + break; case ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES: - break; + break; } if (cb->arg_req != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) { - if ((!arg_val) || (arg_val[0] == '\0')) - { - _ecore_getopt_desc_print_error(desc, _("missing parameter.\n")); - return 0; - } - - if (!val->ptrp) - { - _ecore_getopt_desc_print_error - (desc, _("value has no pointer set.\n")); - return 0; - } + if ((!arg_val) || (arg_val[0] == '\0')) + { + _ecore_getopt_desc_print_error(desc, _("missing parameter.\n")); + return 0; + } + + if (!val->ptrp) + { + _ecore_getopt_desc_print_error + (desc, _("value has no pointer set.\n")); + return 0; + } } if (!cb->func) { - _ecore_getopt_desc_print_error(desc, _("missing callback function!\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("missing callback function!\n")); + return 0; } return cb->func(parser, desc, arg_val, (void *)cb->data, val); @@ -1225,8 +1225,8 @@ _ecore_getopt_parse_version(const Ecore_Getopt *parser, const Ecore_Getopt_Desc (*val->boolp) = 1; if (!parser->version) { - _ecore_getopt_desc_print_error(desc, _("no version was defined.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("no version was defined.\n")); + return 0; } _ecore_getopt_version(stdout, parser); return 1; @@ -1239,8 +1239,8 @@ _ecore_getopt_parse_copyright(const Ecore_Getopt *parser, const Ecore_Getopt_Des (*val->boolp) = 1; if (!parser->copyright) { - _ecore_getopt_desc_print_error(desc, _("no copyright was defined.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("no copyright was defined.\n")); + return 0; } _ecore_getopt_copyright(stdout, parser); return 1; @@ -1253,8 +1253,8 @@ _ecore_getopt_parse_license(const Ecore_Getopt *parser, const Ecore_Getopt_Desc (*val->boolp) = 1; if (!parser->license) { - _ecore_getopt_desc_print_error(desc, _("no license was defined.\n")); - return 0; + _ecore_getopt_desc_print_error(desc, _("no license was defined.\n")); + return 0; } _ecore_getopt_license(stdout, parser); return 1; @@ -1266,31 +1266,31 @@ _ecore_getopt_desc_handle(const Ecore_Getopt *parser, const Ecore_Getopt_Desc *d switch (desc->action) { case ECORE_GETOPT_ACTION_STORE: - return _ecore_getopt_parse_store(parser, desc, value, arg_val); + return _ecore_getopt_parse_store(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_STORE_CONST: - return _ecore_getopt_parse_store_const(parser, desc, value, arg_val); + return _ecore_getopt_parse_store_const(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_STORE_TRUE: - return _ecore_getopt_parse_store_true(parser, desc, value, arg_val); + return _ecore_getopt_parse_store_true(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_STORE_FALSE: - return _ecore_getopt_parse_store_false(parser, desc, value, arg_val); + return _ecore_getopt_parse_store_false(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_CHOICE: - return _ecore_getopt_parse_choice(parser, desc, value, arg_val); + return _ecore_getopt_parse_choice(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_APPEND: - return _ecore_getopt_parse_append(parser, desc, value, arg_val); + return _ecore_getopt_parse_append(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_COUNT: - return _ecore_getopt_parse_count(parser, desc, value, arg_val); + return _ecore_getopt_parse_count(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_CALLBACK: - return _ecore_getopt_parse_callback(parser, desc, value, arg_val); + return _ecore_getopt_parse_callback(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_HELP: - return _ecore_getopt_parse_help(parser, desc, value, arg_val); + return _ecore_getopt_parse_help(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_VERSION: - return _ecore_getopt_parse_version(parser, desc, value, arg_val); + return _ecore_getopt_parse_version(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_COPYRIGHT: - return _ecore_getopt_parse_copyright(parser, desc, value, arg_val); + return _ecore_getopt_parse_copyright(parser, desc, value, arg_val); case ECORE_GETOPT_ACTION_LICENSE: - return _ecore_getopt_parse_license(parser, desc, value, arg_val); + return _ecore_getopt_parse_license(parser, desc, value, arg_val); default: - return 0; + return 0; } } @@ -1307,12 +1307,12 @@ _ecore_getopt_parse_arg_long(const Ecore_Getopt *parser, Ecore_Getopt_Value *val desc = _ecore_getopt_parse_find_long(parser, arg); if (!desc) { - fprintf(stderr, _("ERROR: unknown option --%s, ignored.\n"), arg); - if (parser->strict) - return 0; + fprintf(stderr, _("ERROR: unknown option --%s, ignored.\n"), arg); + if (parser->strict) + return 0; - (*idx)++; - return 1; + (*idx)++; + return 1; } (*idx)++; @@ -1320,31 +1320,31 @@ _ecore_getopt_parse_arg_long(const Ecore_Getopt *parser, Ecore_Getopt_Value *val arg_req = _ecore_getopt_desc_arg_requirement(desc); if (arg_req != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) { - arg_val = strchr(arg, '='); - if (arg_val) - arg_val++; - else - { - if ((*idx < *nonargs) && (argv[*idx][0] != '-')) - { - arg_val = argv[*idx]; - (*idx)++; - } - else - arg_val = NULL; - } - - if (arg_val && arg_val[0] == '\0') - arg_val = NULL; - - if ((!arg_val) && (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES)) - { - fprintf - (stderr, _("ERROR: option --%s requires an argument!\n"), arg); - if (parser->strict) - return 0; - return 1; - } + arg_val = strchr(arg, '='); + if (arg_val) + arg_val++; + else + { + if ((*idx < *nonargs) && (argv[*idx][0] != '-')) + { + arg_val = argv[*idx]; + (*idx)++; + } + else + arg_val = NULL; + } + + if (arg_val && arg_val[0] == '\0') + arg_val = NULL; + + if ((!arg_val) && (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES)) + { + fprintf + (stderr, _("ERROR: option --%s requires an argument!\n"), arg); + if (parser->strict) + return 0; + return 1; + } } else arg_val = NULL; @@ -1364,71 +1364,71 @@ _ecore_getopt_parse_arg_short(const Ecore_Getopt *parser, Ecore_Getopt_Value *va int run = 1; while (run && (arg[0] != '\0')) { - int opt = arg[0]; - const Ecore_Getopt_Desc *desc; - Ecore_Getopt_Desc_Arg_Requirement arg_req; - const char *arg_val; - int desc_idx; - Ecore_Getopt_Value *value; - unsigned char ret; - - desc = _ecore_getopt_parse_find_short(parser, arg[0]); - if (!desc) - { - fprintf - (stderr, _("ERROR: unknown option -%c, ignored.\n"), arg[0]); - if (parser->strict) - return 0; - - arg++; - continue; - } - - arg++; - - arg_req = _ecore_getopt_desc_arg_requirement(desc); - if (arg_req != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) - { - (*idx)++; - run = 0; - - if (arg[0] == '=') - arg_val = arg + 1; - else if (arg[0] != '\0') - arg_val = arg; - else - { - if ((*idx < *nonargs) && (argv[*idx][0] != '-')) - { - arg_val = argv[*idx]; - (*idx)++; - } - else - arg_val = NULL; - } - - if (arg_val && arg_val[0] == '\0') - arg_val = NULL; - - if ((!arg_val) && - (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES)) - { - fprintf - (stderr, _("ERROR: option -%c requires an argument!\n"), - opt); - if (parser->strict) - return 0; - return 1; - } - } - else - arg_val = NULL; - - desc_idx = desc - parser->descs; - value = values + desc_idx; - ret = _ecore_getopt_desc_handle(parser, desc, value, arg_val); - if ((!ret) && parser->strict) - return 0; + int opt = arg[0]; + const Ecore_Getopt_Desc *desc; + Ecore_Getopt_Desc_Arg_Requirement arg_req; + const char *arg_val; + int desc_idx; + Ecore_Getopt_Value *value; + unsigned char ret; + + desc = _ecore_getopt_parse_find_short(parser, arg[0]); + if (!desc) + { + fprintf + (stderr, _("ERROR: unknown option -%c, ignored.\n"), arg[0]); + if (parser->strict) + return 0; + + arg++; + continue; + } + + arg++; + + arg_req = _ecore_getopt_desc_arg_requirement(desc); + if (arg_req != ECORE_GETOPT_DESC_ARG_REQUIREMENT_NO) + { + (*idx)++; + run = 0; + + if (arg[0] == '=') + arg_val = arg + 1; + else if (arg[0] != '\0') + arg_val = arg; + else + { + if ((*idx < *nonargs) && (argv[*idx][0] != '-')) + { + arg_val = argv[*idx]; + (*idx)++; + } + else + arg_val = NULL; + } + + if (arg_val && arg_val[0] == '\0') + arg_val = NULL; + + if ((!arg_val) && + (arg_req == ECORE_GETOPT_DESC_ARG_REQUIREMENT_YES)) + { + fprintf + (stderr, _("ERROR: option -%c requires an argument!\n"), + opt); + if (parser->strict) + return 0; + return 1; + } + } + else + arg_val = NULL; + + desc_idx = desc - parser->descs; + value = values + desc_idx; + ret = _ecore_getopt_desc_handle(parser, desc, value, arg_val); + if ((!ret) && parser->strict) + return 0; } if (run) @@ -1444,18 +1444,18 @@ _ecore_getopt_parse_arg(const Ecore_Getopt *parser, Ecore_Getopt_Value *values, if (arg[0] != '-') { - char **dst, **src, **src_end; + char **dst, **src, **src_end; - dst = argv + *idx; - src = dst + 1; - src_end = src + *nonargs - *idx - 1; + dst = argv + *idx; + src = dst + 1; + src_end = src + *nonargs - *idx - 1; - for (; src < src_end; src++, dst++) - *dst = *src; + for (; src < src_end; src++, dst++) + *dst = *src; - *dst = arg; - (*nonargs)--; - return 1; + *dst = arg; + (*nonargs)--; + return 1; } if (arg[1] == '-') @@ -1474,11 +1474,11 @@ _ecore_getopt_parse_find_short_other(const Ecore_Getopt *parser, const Ecore_Get for (; !_ecore_getopt_desc_is_sentinel(desc); desc++) { - if (desc == orig) - return NULL; + if (desc == orig) + return NULL; - if (c == desc->shortname) - return desc; + if (c == desc->shortname) + return desc; } return NULL; @@ -1492,11 +1492,11 @@ _ecore_getopt_parse_find_long_other(const Ecore_Getopt *parser, const Ecore_Geto for (; !_ecore_getopt_desc_is_sentinel(desc); desc++) { - if (desc == orig) - return NULL; + if (desc == orig) + return NULL; - if (desc->longname && (strcmp(name, desc->longname) == 0)) - return desc; + if (desc->longname && (strcmp(name, desc->longname) == 0)) + return desc; } return NULL; @@ -1514,38 +1514,38 @@ ecore_getopt_parser_has_duplicates(const Ecore_Getopt *parser) for (; !_ecore_getopt_desc_is_sentinel(desc); desc++) { if (desc->shortname) - { - const Ecore_Getopt_Desc *other; - other = _ecore_getopt_parse_find_short_other(parser, desc); - if (other) - { - _ecore_getopt_desc_print_error - (desc, "short name -%c already exists.", desc->shortname); - - if (other->longname) - fprintf(stderr, " Other is --%s.\n", other->longname); - else - fputc('\n', stderr); - return 1; - } - } + { + const Ecore_Getopt_Desc *other; + other = _ecore_getopt_parse_find_short_other(parser, desc); + if (other) + { + _ecore_getopt_desc_print_error + (desc, "short name -%c already exists.", desc->shortname); + + if (other->longname) + fprintf(stderr, " Other is --%s.\n", other->longname); + else + fputc('\n', stderr); + return 1; + } + } if (desc->longname) - { - const Ecore_Getopt_Desc *other; - other = _ecore_getopt_parse_find_long_other(parser, desc); - if (other) - { - _ecore_getopt_desc_print_error - (desc, "long name --%s already exists.", desc->longname); - - if (other->shortname) - fprintf(stderr, " Other is -%c.\n", other->shortname); - else - fputc('\n', stderr); - return 1; - } - } + { + const Ecore_Getopt_Desc *other; + other = _ecore_getopt_parse_find_long_other(parser, desc); + if (other) + { + _ecore_getopt_desc_print_error + (desc, "long name --%s already exists.", desc->longname); + + if (other->shortname) + fprintf(stderr, " Other is -%c.\n", other->shortname); + else + fputc('\n', stderr); + return 1; + } + } } return 0; } @@ -1617,13 +1617,13 @@ ecore_getopt_parse(const Ecore_Getopt *parser, Ecore_Getopt_Value *values, int a if (!parser) { - fputs(_("ERROR: no parser provided.\n"), stderr); - return -1; + fputs(_("ERROR: no parser provided.\n"), stderr); + return -1; } if (!values) { - fputs(_("ERROR: no values provided.\n"), stderr); - return -1; + fputs(_("ERROR: no values provided.\n"), stderr); + return -1; } if ((argc < 1) || (!argv)) @@ -1631,8 +1631,8 @@ ecore_getopt_parse(const Ecore_Getopt *parser, Ecore_Getopt_Value *values, int a if (argc < 1) { - fputs(_("ERROR: no arguments provided.\n"), stderr); - return -1; + fputs(_("ERROR: no arguments provided.\n"), stderr); + return -1; } if (argv[0]) @@ -1661,11 +1661,11 @@ ecore_getopt_parse(const Ecore_Getopt *parser, Ecore_Getopt_Value *values, int a help = _ecore_getopt_find_help(parser); if (!help) - fputc('\n', stderr); + fputc('\n', stderr); else if (help->longname) - fprintf(stderr, _(" See --%s.\n"), help->longname); + fprintf(stderr, _(" See --%s.\n"), help->longname); else - fprintf(stderr, _(" See -%c.\n"), help->shortname); + fprintf(stderr, _(" See -%c.\n"), help->shortname); } return -1; @@ -1702,8 +1702,8 @@ ecore_getopt_callback_geometry_parse(const Ecore_Getopt *parser __UNUSED__, cons if (sscanf(str, "%d:%d:%d:%d", &v->x, &v->y, &v->w, &v->h) != 4) { - fprintf(stderr, _("ERROR: incorrect geometry value '%s'\n"), str); - return 0; + fprintf(stderr, _("ERROR: incorrect geometry value '%s'\n"), str); + return 0; } return 1; @@ -1725,8 +1725,8 @@ ecore_getopt_callback_size_parse(const Ecore_Getopt *parser __UNUSED__, const Ec if (sscanf(str, "%dx%d", &v->w, &v->h) != 2) { - fprintf(stderr, _("ERROR: incorrect size value '%s'\n"), str); - return 0; + fprintf(stderr, _("ERROR: incorrect size value '%s'\n"), str); + return 0; } v->x = 0; v->y = 0; diff --git a/src/lib/ecore/ecore_glib.c b/src/lib/ecore/ecore_glib.c index 691889a..739c05a 100644 --- a/src/lib/ecore/ecore_glib.c +++ b/src/lib/ecore/ecore_glib.c @@ -26,9 +26,9 @@ _ecore_glib_fds_resize(size_t size) if (!tmp) { - ERR("Could not realloc from %zu to %zu buckets.", - _ecore_glib_fds_size, size); - return EINA_FALSE; + ERR("Could not realloc from %zu to %zu buckets.", + _ecore_glib_fds_size, size); + return EINA_FALSE; } _ecore_glib_fds = tmp; @@ -51,7 +51,7 @@ _ecore_glib_context_query(GMainContext *ctx, int priority, int *p_timer) size_t size; reqfds = g_main_context_query - (ctx, priority, p_timer, _ecore_glib_fds, _ecore_glib_fds_size); + (ctx, priority, p_timer, _ecore_glib_fds, _ecore_glib_fds_size); if (reqfds <= (int)_ecore_glib_fds_size) break; size = (1 + reqfds / ECORE_GLIB_FDS_STEP) * ECORE_GLIB_FDS_STEP; @@ -62,7 +62,7 @@ _ecore_glib_context_query(GMainContext *ctx, int priority, int *p_timer) { size_t size; - size = (1 + reqfds / ECORE_GLIB_FDS_MAX_FREE) * ECORE_GLIB_FDS_MAX_FREE; + size = (1 + reqfds / ECORE_GLIB_FDS_MAX_FREE) * ECORE_GLIB_FDS_MAX_FREE; _ecore_glib_fds_resize(size); } @@ -78,14 +78,14 @@ _ecore_glib_context_poll_from(const GPollFD *pfds, int count, fd_set *rfds, fd_s for (; itr < itr_end; itr++) { if (glib_fds < itr->fd) - glib_fds = itr->fd; + glib_fds = itr->fd; if (itr->events & G_IO_IN) - FD_SET(itr->fd, rfds); + FD_SET(itr->fd, rfds); if (itr->events & G_IO_OUT) - FD_SET(itr->fd, wfds); + FD_SET(itr->fd, wfds); if (itr->events & (G_IO_HUP | G_IO_ERR)) - FD_SET(itr->fd, efds); + FD_SET(itr->fd, efds); } return glib_fds + 1; @@ -100,20 +100,20 @@ _ecore_glib_context_poll_to(GPollFD *pfds, int count, const fd_set *rfds, const { itr->revents = 0; if (FD_ISSET(itr->fd, rfds)) - { - itr->revents |= G_IO_IN; - ready--; - } + { + itr->revents |= G_IO_IN; + ready--; + } if (FD_ISSET(itr->fd, wfds)) - { - itr->revents |= G_IO_OUT; - ready--; - } + { + itr->revents |= G_IO_OUT; + ready--; + } if (FD_ISSET(itr->fd, efds)) - { - itr->revents |= G_IO_ERR; - ready--; - } + { + itr->revents |= G_IO_ERR; + ready--; + } } return ready; } @@ -172,11 +172,11 @@ _ecore_glib_select(int ecore_fds, fd_set *rfds, fd_set *wfds, fd_set *efds, stru g_mutex_lock(mutex); else { - if (!_ecore_glib_cond) - _ecore_glib_cond = g_cond_new(); + if (!_ecore_glib_cond) + _ecore_glib_cond = g_cond_new(); - while (!g_main_context_wait(ctx, _ecore_glib_cond, mutex)) - g_thread_yield(); + while (!g_main_context_wait(ctx, _ecore_glib_cond, mutex)) + g_thread_yield(); } ret = _ecore_glib_select__locked @@ -206,20 +206,32 @@ _ecore_glib_shutdown(void) if (_ecore_glib_fds) { - free(_ecore_glib_fds); - _ecore_glib_fds = NULL; + free(_ecore_glib_fds); + _ecore_glib_fds = NULL; } _ecore_glib_fds_size = 0; if (_ecore_glib_cond) { - g_cond_free(_ecore_glib_cond); - _ecore_glib_cond = NULL; + g_cond_free(_ecore_glib_cond); + _ecore_glib_cond = NULL; } #endif } /** + * @addtogroup Ecore_Group Ecore - Main Loop and Job Functions. + * + * @{ + */ + +/** + * @addtogroup Ecore_Main_Loop_Group Ecore Main Loop functions + * + * @} + */ + +/** * Request ecore to integrate GLib's main loop. * * This will add a small overhead during every main loop interaction @@ -284,3 +296,11 @@ ecore_main_loop_glib_always_integrate_disable(void) { _ecore_glib_always_integrate = 0; } + +/** + * @} + */ + +/** + * @} + */ diff --git a/src/lib/ecore/ecore_idle_enterer.c b/src/lib/ecore/ecore_idle_enterer.c index 52d7111..be1fc4e 100644 --- a/src/lib/ecore/ecore_idle_enterer.c +++ b/src/lib/ecore/ecore_idle_enterer.c @@ -24,12 +24,23 @@ static Ecore_Idle_Enterer *idle_enterer_current = NULL; static int idle_enterers_delete_me = 0; /** + * @addtogroup Ecore_Group Ecore - Main Loop and Job Functions. + * + * @{ + */ + +/** + * @addtogroup Ecore_Idle_Group Ecore Idle functions + * + * @{ + */ + +/** * Add an idle enterer handler. * @param func The function to call when entering an idle state. * @param data The data to be passed to the @p func call * @return A handle to the idle enterer callback if successful. Otherwise, * NULL is returned. - * @ingroup Idle_Group */ EAPI Ecore_Idle_Enterer * ecore_idle_enterer_add(Ecore_Task_Cb func, const void *data) @@ -52,7 +63,6 @@ ecore_idle_enterer_add(Ecore_Task_Cb func, const void *data) * @param data The data to be passed to the @p func call * @return A handle to the idle enterer callback if successful. Otherwise, * NULL is returned. - * @ingroup Idle_Group */ EAPI Ecore_Idle_Enterer * ecore_idle_enterer_before_add(Ecore_Task_Cb func, const void *data) @@ -74,16 +84,15 @@ ecore_idle_enterer_before_add(Ecore_Task_Cb func, const void *data) * @param idle_enterer The idle enterer to delete * @return The data pointer passed to the idler enterer callback on success. * NULL otherwise. - * @ingroup Idle_Group */ EAPI void * ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer) { if (!ECORE_MAGIC_CHECK(idle_enterer, ECORE_MAGIC_IDLE_ENTERER)) { - ECORE_MAGIC_FAIL(idle_enterer, ECORE_MAGIC_IDLE_ENTERER, - "ecore_idle_enterer_del"); - return NULL; + ECORE_MAGIC_FAIL(idle_enterer, ECORE_MAGIC_IDLE_ENTERER, + "ecore_idle_enterer_del"); + return NULL; } EINA_SAFETY_ON_TRUE_RETURN_VAL(idle_enterer->delete_me, NULL); idle_enterer->delete_me = 1; @@ -91,15 +100,23 @@ ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer) return idle_enterer->data; } +/** + * @} + */ + +/** + * @} + */ + void _ecore_idle_enterer_shutdown(void) { Ecore_Idle_Enterer *ie; while ((ie = idle_enterers)) { - idle_enterers = (Ecore_Idle_Enterer *) eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(idle_enterers)); - ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); - free(ie); + idle_enterers = (Ecore_Idle_Enterer *) eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(idle_enterers)); + ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); + free(ie); } idle_enterers_delete_me = 0; idle_enterer_current = NULL; @@ -110,56 +127,56 @@ _ecore_idle_enterer_call(void) { if (!idle_enterer_current) { - /* regular main loop, start from head */ - idle_enterer_current = idle_enterers; + /* regular main loop, start from head */ + idle_enterer_current = idle_enterers; } else { - /* recursive main loop, continue from where we were */ - idle_enterer_current = - (Ecore_Idle_Enterer *)EINA_INLIST_GET(idle_enterer_current)->next; + /* recursive main loop, continue from where we were */ + idle_enterer_current = + (Ecore_Idle_Enterer *)EINA_INLIST_GET(idle_enterer_current)->next; } while (idle_enterer_current) { - Ecore_Idle_Enterer *ie = (Ecore_Idle_Enterer *)idle_enterer_current; - if (!ie->delete_me) - { - ie->references++; - if (!ie->func(ie->data)) - { - if (!ie->delete_me) ecore_idle_enterer_del(ie); - } - ie->references--; - } - if (idle_enterer_current) /* may have changed in recursive main loops */ - idle_enterer_current = - (Ecore_Idle_Enterer *)EINA_INLIST_GET(idle_enterer_current)->next; + Ecore_Idle_Enterer *ie = (Ecore_Idle_Enterer *)idle_enterer_current; + if (!ie->delete_me) + { + ie->references++; + if (!ie->func(ie->data)) + { + if (!ie->delete_me) ecore_idle_enterer_del(ie); + } + ie->references--; + } + if (idle_enterer_current) /* may have changed in recursive main loops */ + idle_enterer_current = + (Ecore_Idle_Enterer *)EINA_INLIST_GET(idle_enterer_current)->next; } if (idle_enterers_delete_me) { Ecore_Idle_Enterer *l; - int deleted_idler_enterers_in_use = 0; - - for (l = idle_enterers; l;) - { - Ecore_Idle_Enterer *ie = l; - l = (Ecore_Idle_Enterer *) EINA_INLIST_GET(l)->next; - if (ie->delete_me) - { - if (ie->references) - { - deleted_idler_enterers_in_use++; - continue; - } - - idle_enterers = (Ecore_Idle_Enterer *) eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie)); - ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); - free(ie); - } - } - if (!deleted_idler_enterers_in_use) - idle_enterers_delete_me = 0; + int deleted_idler_enterers_in_use = 0; + + for (l = idle_enterers; l;) + { + Ecore_Idle_Enterer *ie = l; + l = (Ecore_Idle_Enterer *) EINA_INLIST_GET(l)->next; + if (ie->delete_me) + { + if (ie->references) + { + deleted_idler_enterers_in_use++; + continue; + } + + idle_enterers = (Ecore_Idle_Enterer *) eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie)); + ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); + free(ie); + } + } + if (!deleted_idler_enterers_in_use) + idle_enterers_delete_me = 0; } } diff --git a/src/lib/ecore/ecore_idle_exiter.c b/src/lib/ecore/ecore_idle_exiter.c index a129590..43c9e47 100644 --- a/src/lib/ecore/ecore_idle_exiter.c +++ b/src/lib/ecore/ecore_idle_exiter.c @@ -24,11 +24,22 @@ static Ecore_Idle_Exiter *idle_exiter_current = NULL; static int idle_exiters_delete_me = 0; /** + * @addtogroup Ecore_Group Ecore - Main Loop and Job Functions. + * + * @{ + */ + +/** + * @addtogroup Ecore_Idle_Group Ecore Idle functions + * + * @{ + */ + +/** * Add an idle exiter handler. * @param func The function to call when exiting an idle state. * @param data The data to be passed to the @p func call * @return A handle to the idle exiter callback on success. NULL otherwise. - * @ingroup Idle_Group */ EAPI Ecore_Idle_Exiter * ecore_idle_exiter_add(Ecore_Task_Cb func, const void *data) @@ -50,16 +61,15 @@ ecore_idle_exiter_add(Ecore_Task_Cb func, const void *data) * @param idle_exiter The idle exiter to delete * @return The data pointer that was being being passed to the handler if * successful. NULL otherwise. - * @ingroup Idle_Group */ EAPI void * ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter) { if (!ECORE_MAGIC_CHECK(idle_exiter, ECORE_MAGIC_IDLE_EXITER)) { - ECORE_MAGIC_FAIL(idle_exiter, ECORE_MAGIC_IDLE_EXITER, - "ecore_idle_exiter_del"); - return NULL; + ECORE_MAGIC_FAIL(idle_exiter, ECORE_MAGIC_IDLE_EXITER, + "ecore_idle_exiter_del"); + return NULL; } EINA_SAFETY_ON_TRUE_RETURN_VAL(idle_exiter->delete_me, NULL); idle_exiter->delete_me = 1; @@ -67,15 +77,23 @@ ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter) return idle_exiter->data; } +/** + * @} + */ + +/** + * @} + */ + void _ecore_idle_exiter_shutdown(void) { Ecore_Idle_Exiter *ie; while ((ie = idle_exiters)) { - idle_exiters = (Ecore_Idle_Exiter *) eina_inlist_remove(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(idle_exiters)); - ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); - free(ie); + idle_exiters = (Ecore_Idle_Exiter *) eina_inlist_remove(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(idle_exiters)); + ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); + free(ie); } idle_exiters_delete_me = 0; idle_exiter_current = NULL; @@ -86,57 +104,57 @@ _ecore_idle_exiter_call(void) { if (!idle_exiter_current) { - /* regular main loop, start from head */ - idle_exiter_current = idle_exiters; + /* regular main loop, start from head */ + idle_exiter_current = idle_exiters; } else { - /* recursive main loop, continue from where we were */ - idle_exiter_current = - (Ecore_Idle_Exiter *)EINA_INLIST_GET(idle_exiter_current)->next; + /* recursive main loop, continue from where we were */ + idle_exiter_current = + (Ecore_Idle_Exiter *)EINA_INLIST_GET(idle_exiter_current)->next; } while (idle_exiter_current) { - Ecore_Idle_Exiter *ie = (Ecore_Idle_Exiter *)idle_exiter_current; - if (!ie->delete_me) - { - ie->references++; - if (!ie->func(ie->data)) - { - if (!ie->delete_me) ecore_idle_exiter_del(ie); - } - ie->references--; - } - if (idle_exiter_current) /* may have changed in recursive main loops */ - idle_exiter_current = - (Ecore_Idle_Exiter *)EINA_INLIST_GET(idle_exiter_current)->next; + Ecore_Idle_Exiter *ie = (Ecore_Idle_Exiter *)idle_exiter_current; + if (!ie->delete_me) + { + ie->references++; + if (!ie->func(ie->data)) + { + if (!ie->delete_me) ecore_idle_exiter_del(ie); + } + ie->references--; + } + if (idle_exiter_current) /* may have changed in recursive main loops */ + idle_exiter_current = + (Ecore_Idle_Exiter *)EINA_INLIST_GET(idle_exiter_current)->next; } if (idle_exiters_delete_me) { - Ecore_Idle_Exiter *l; - int deleted_idler_exiters_in_use = 0; - - for (l = idle_exiters; l;) - { - Ecore_Idle_Exiter *ie = l; - - l = (Ecore_Idle_Exiter *) EINA_INLIST_GET(l)->next; - if (ie->delete_me) - { - if (ie->references) - { - deleted_idler_exiters_in_use++; - continue; - } - - idle_exiters = (Ecore_Idle_Exiter *) eina_inlist_remove(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(ie)); - ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); - free(ie); - } - } - if (!deleted_idler_exiters_in_use) - idle_exiters_delete_me = 0; + Ecore_Idle_Exiter *l; + int deleted_idler_exiters_in_use = 0; + + for (l = idle_exiters; l;) + { + Ecore_Idle_Exiter *ie = l; + + l = (Ecore_Idle_Exiter *) EINA_INLIST_GET(l)->next; + if (ie->delete_me) + { + if (ie->references) + { + deleted_idler_exiters_in_use++; + continue; + } + + idle_exiters = (Ecore_Idle_Exiter *) eina_inlist_remove(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(ie)); + ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); + free(ie); + } + } + if (!deleted_idler_exiters_in_use) + idle_exiters_delete_me = 0; } } diff --git a/src/lib/ecore/ecore_idler.c b/src/lib/ecore/ecore_idler.c index 0fa2ddf..edc04d7 100644 --- a/src/lib/ecore/ecore_idler.c +++ b/src/lib/ecore/ecore_idler.c @@ -24,11 +24,45 @@ static Ecore_Idler *idler_current = NULL; static int idlers_delete_me = 0; /** + * @addtogroup Ecore_Group Ecore - Main Loop and Job Functions. + * + * @{ + */ + +/** + * @addtogroup Ecore_Idle_Group Ecore Idle functions + * +Callbacks that are called when the program enters or exits an idle state. + +The ecore main loop enters an idle state when it is waiting for timers +to time out, data to come in on a file descriptor or any other event +to occur. You can set callbacks to be called when the main loop +enters an idle state, during an idle state or just after the program +wakes up. + +Enterer callbacks are good for updating your program's state, if it +has a state engine. Once all of the enterer handlers are called, the +program will enter a "sleeping" state. + +Idler callbacks are called when the main loop has called all enterer +handlers. They are useful for interfaces that require polling and +timers would be too slow to use. + +If no idler callbacks are specified, then the process literally goes +to sleep. Otherwise, the idler callbacks are called continuously +while the loop is "idle", using as much CPU as is available to the +process. + +Exiter callbacks are called when the main loop wakes up from an idle +state. + * @{ + */ + +/** * Add an idler handler. * @param func The function to call when idling. * @param data The data to be passed to this @p func call. * @return A idler handle if successfully added. NULL otherwise. - * @ingroup Idle_Group * * Add an idler handle to the event loop, returning a handle on success and * NULL otherwise. The function @p func will be called repeatedly while @@ -58,16 +92,15 @@ ecore_idler_add(Ecore_Task_Cb func, const void *data) * @param idler The handle of the idler callback to delete * @return The data pointer passed to the idler callback on success. NULL * otherwise. - * @ingroup Idle_Group */ EAPI void * ecore_idler_del(Ecore_Idler *idler) { if (!ECORE_MAGIC_CHECK(idler, ECORE_MAGIC_IDLER)) { - ECORE_MAGIC_FAIL(idler, ECORE_MAGIC_IDLER, - "ecore_idler_del"); - return NULL; + ECORE_MAGIC_FAIL(idler, ECORE_MAGIC_IDLER, + "ecore_idler_del"); + return NULL; } EINA_SAFETY_ON_TRUE_RETURN_VAL(idler->delete_me, NULL); idler->delete_me = 1; @@ -75,15 +108,23 @@ ecore_idler_del(Ecore_Idler *idler) return idler->data; } +/** + * @} + */ + +/** + * @} + */ + void _ecore_idler_shutdown(void) { Ecore_Idler *ie; while ((ie = idlers)) { - idlers = (Ecore_Idler *) eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(idlers)); - ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); - free(ie); + idlers = (Ecore_Idler *) eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(idlers)); + ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); + free(ie); } idlers_delete_me = 0; idler_current = NULL; @@ -94,53 +135,53 @@ _ecore_idler_call(void) { if (!idler_current) { - /* regular main loop, start from head */ - idler_current = idlers; + /* regular main loop, start from head */ + idler_current = idlers; } else { - /* recursive main loop, continue from where we were */ - idler_current = (Ecore_Idler *)EINA_INLIST_GET(idler_current)->next; + /* recursive main loop, continue from where we were */ + idler_current = (Ecore_Idler *)EINA_INLIST_GET(idler_current)->next; } while (idler_current) { - Ecore_Idler *ie = (Ecore_Idler *)idler_current; - if (!ie->delete_me) - { - ie->references++; - if (!ie->func(ie->data)) - { - if (!ie->delete_me) ecore_idler_del(ie); - } - ie->references--; - } - if (idler_current) /* may have changed in recursive main loops */ - idler_current = (Ecore_Idler *)EINA_INLIST_GET(idler_current)->next; + Ecore_Idler *ie = (Ecore_Idler *)idler_current; + if (!ie->delete_me) + { + ie->references++; + if (!ie->func(ie->data)) + { + if (!ie->delete_me) ecore_idler_del(ie); + } + ie->references--; + } + if (idler_current) /* may have changed in recursive main loops */ + idler_current = (Ecore_Idler *)EINA_INLIST_GET(idler_current)->next; } if (idlers_delete_me) { - Ecore_Idler *l; - int deleted_idlers_in_use = 0; - for (l = idlers; l;) - { - Ecore_Idler *ie = l; - l = (Ecore_Idler *) EINA_INLIST_GET(l)->next; - if (ie->delete_me) - { - if (ie->references) - { - deleted_idlers_in_use++; - continue; - } - - idlers = (Ecore_Idler *) eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie)); - ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); - free(ie); - } - } - if (!deleted_idlers_in_use) - idlers_delete_me = 0; + Ecore_Idler *l; + int deleted_idlers_in_use = 0; + for (l = idlers; l;) + { + Ecore_Idler *ie = l; + l = (Ecore_Idler *) EINA_INLIST_GET(l)->next; + if (ie->delete_me) + { + if (ie->references) + { + deleted_idlers_in_use++; + continue; + } + + idlers = (Ecore_Idler *) eina_inlist_remove(EINA_INLIST_GET(idlers), EINA_INLIST_GET(ie)); + ECORE_MAGIC_SET(ie, ECORE_MAGIC_NONE); + free(ie); + } + } + if (!deleted_idlers_in_use) + idlers_delete_me = 0; } if (idlers) return 1; return 0; diff --git a/src/lib/ecore/ecore_job.c b/src/lib/ecore/ecore_job.c index bd50232..c9de10a 100644 --- a/src/lib/ecore/ecore_job.c +++ b/src/lib/ecore/ecore_job.c @@ -36,13 +36,27 @@ _ecore_job_shutdown(void) } /** + * @addtogroup Ecore_Group Ecore - Main Loop and Job Functions. + * + * @{ + */ + +/** + * @addtogroup Ecore_Job_Group Ecore Job functions + * + * You can queue jobs that are to be done by the main loop when the current + * event is dealt with. + * + * @{ + */ + +/** * Add a job to the event queue. * @param func The function to call when the job gets handled. * @param data Data pointer to be passed to the job function when the job is * handled. * @return The handle of the job. @c NULL is returned if the job could not be * added to the queue. - * @ingroup Ecore_Job_Group * @note Once the job has been executed, the job handle is invalid. */ EAPI Ecore_Job * @@ -58,8 +72,8 @@ ecore_job_add(Ecore_Cb func, const void *data) job->event = ecore_event_add(ecore_event_job_type, job, _ecore_job_event_free, NULL); if (!job->event) { - free(job); - return NULL; + free(job); + return NULL; } job->func = func; job->data = (void *)data; @@ -70,7 +84,6 @@ ecore_job_add(Ecore_Cb func, const void *data) * Delete a queued job that has not yet been executed. * @param job Handle of the job to delete. * @return The data pointer that was to be passed to the job. - * @ingroup Ecore_Job_Group */ EAPI void * ecore_job_del(Ecore_Job *job) @@ -79,9 +92,9 @@ ecore_job_del(Ecore_Job *job) if (!ECORE_MAGIC_CHECK(job, ECORE_MAGIC_JOB)) { - ECORE_MAGIC_FAIL(job, ECORE_MAGIC_JOB, - "ecore_job_del"); - return NULL; + ECORE_MAGIC_FAIL(job, ECORE_MAGIC_JOB, + "ecore_job_del"); + return NULL; } data = job->data; ECORE_MAGIC_SET(job, ECORE_MAGIC_NONE); @@ -89,6 +102,14 @@ ecore_job_del(Ecore_Job *job) return data; } +/** + * @} + */ + +/** + * @} + */ + static Eina_Bool _ecore_job_event_handler(void *data __UNUSED__, int type __UNUSED__, void *ev) { diff --git a/src/lib/ecore/ecore_main.c b/src/lib/ecore/ecore_main.c index 10a4fd3..9435cce 100644 --- a/src/lib/ecore/ecore_main.c +++ b/src/lib/ecore/ecore_main.c @@ -24,7 +24,7 @@ #include #ifndef _MSC_VER -#include +# include # include #else # include @@ -54,7 +54,7 @@ #endif #ifdef USE_G_MAIN_LOOP -#include +# include #endif struct _Ecore_Fd_Handler @@ -74,6 +74,9 @@ struct _Ecore_Fd_Handler Eina_Bool write_active : 1; Eina_Bool error_active : 1; Eina_Bool delete_me : 1; +#if defined(USE_G_MAIN_LOOP) && !defined(HAVE_EPOLL) + GPollFD gfd; +#endif }; #ifdef _WIN32 @@ -104,7 +107,7 @@ static void _ecore_main_loop_iterate_internal(int once_only); #ifdef _WIN32 static int _ecore_main_win32_select(int nfds, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timeval *timeout); + fd_set *exceptfds, struct timeval *timeout); static void _ecore_main_win32_handlers_cleanup(void); #endif @@ -130,78 +133,176 @@ static double t2 = 0.0; #ifdef HAVE_EPOLL static int epoll_fd = -1; +static pid_t epoll_pid; #endif #ifdef USE_G_MAIN_LOOP -static GSource *ecore_epoll_source; +#ifdef HAVE_EPOLL static GPollFD ecore_epoll_fd; -static guint ecore_epoll_id; +#endif +static GSource *ecore_glib_source; +static guint ecore_glib_source_id; static GMainLoop* ecore_main_loop; static gboolean ecore_idling; static gboolean ecore_fds_ready; #endif -static inline int _ecore_poll_events_from_fdh(Ecore_Fd_Handler *fdh) +#ifdef HAVE_EPOLL +static inline int +_ecore_get_epoll_fd(void) +{ + if (epoll_pid && epoll_pid != getpid()) + { + /* forked! */ + _ecore_main_loop_shutdown(); + } + if (epoll_pid == 0 && epoll_fd < 0) + { + _ecore_main_loop_init(); + } + return epoll_fd; +} + +static inline int +_ecore_epoll_add(int efd, int fd, int events, void *ptr) +{ + struct epoll_event ev; + + memset(&ev, 0, sizeof (ev)); + ev.events = events; + ev.data.ptr = ptr; + INF("adding poll on %d %08x", fd, events); + return epoll_ctl(efd, EPOLL_CTL_ADD, fd, &ev); +} + +static inline int +_ecore_poll_events_from_fdh(Ecore_Fd_Handler *fdh) { int events = 0; -#ifdef HAVE_EPOLL if (fdh->flags & ECORE_FD_READ) events |= EPOLLIN; if (fdh->flags & ECORE_FD_WRITE) events |= EPOLLOUT; if (fdh->flags & ECORE_FD_ERROR) events |= EPOLLERR; + return events; +} +#else +static inline int +_ecore_poll_events_from_fdh(Ecore_Fd_Handler *fdh __UNUSED__) +{ + return 0; +} #endif + +#ifdef USE_G_MAIN_LOOP +static inline int +_gfd_events_from_fdh(Ecore_Fd_Handler *fdh) +{ + int events = 0; + if (fdh->flags & ECORE_FD_READ) events |= G_IO_IN; + if (fdh->flags & ECORE_FD_WRITE) events |= G_IO_OUT; + if (fdh->flags & ECORE_FD_ERROR) events |= G_IO_ERR; return events; } +#endif -static inline int _ecore_main_fdh_epoll_add(Ecore_Fd_Handler *fdh) +static inline int +_ecore_main_fdh_poll_add(Ecore_Fd_Handler *fdh) { int r = 0; #ifdef HAVE_EPOLL - struct epoll_event ev = {0}; - - ev.events = _ecore_poll_events_from_fdh(fdh); - ev.data.ptr = fdh; - INF("adding poll on %d %08x", fdh->fd, ev.events); - r = epoll_ctl(epoll_fd, EPOLL_CTL_ADD, fdh->fd, &ev); + r = _ecore_epoll_add(_ecore_get_epoll_fd(), fdh->fd, + _ecore_poll_events_from_fdh(fdh), fdh); +#elif USE_G_MAIN_LOOP + fdh->gfd.fd = fdh->fd; + fdh->gfd.events = _gfd_events_from_fdh(fdh); + fdh->gfd.revents = 0; + INF("adding gpoll on %d %08x", fdh->fd, fdh->gfd.events); + g_source_add_poll(ecore_glib_source, &fdh->gfd); +#else + if (!ECORE_MAGIC_CHECK(fdh, ECORE_MAGIC_FD_HANDLER)) + { + ECORE_MAGIC_FAIL(fdh, ECORE_MAGIC_FD_HANDLER, + "_ecore_main_fdh_poll_add"); + } #endif return r; } -static inline void _ecore_main_fdh_epoll_del(Ecore_Fd_Handler *fdh) +static inline void +_ecore_main_fdh_poll_del(Ecore_Fd_Handler *fdh) { #ifdef HAVE_EPOLL - struct epoll_event ev = {0}; - + struct epoll_event ev; + int efd = _ecore_get_epoll_fd(); + + memset(&ev, 0, sizeof (ev)); INF("removing poll on %d", fdh->fd); /* could get an EBADF if somebody closed the FD before removing it */ - if ((epoll_ctl(epoll_fd, EPOLL_CTL_DEL, fdh->fd, &ev) < 0) && - (errno != EBADF)) + if ((epoll_ctl(efd, EPOLL_CTL_DEL, fdh->fd, &ev) < 0)) + { + if (errno == EBADF) + { + WRN("fd %d was closed, can't remove from epoll - reinit!", + fdh->fd); + _ecore_main_loop_shutdown(); + _ecore_main_loop_init(); + } + else + { + ERR("Failed to delete epoll fd %d! (errno=%d)", fdh->fd, errno); + } + } +#elif USE_G_MAIN_LOOP + fdh->gfd.fd = fdh->fd; + fdh->gfd.events = _gfd_events_from_fdh(fdh); + fdh->gfd.revents = 0; + INF("adding gpoll on %d %08x", fdh->fd, fdh->gfd.events); + g_source_add_poll(ecore_glib_source, &fdh->gfd); +#else + if (!ECORE_MAGIC_CHECK(fdh, ECORE_MAGIC_FD_HANDLER)) { - ERR("Failed to delete epoll fd %d! (errno=%d)", fdh->fd, errno); + ECORE_MAGIC_FAIL(fdh, ECORE_MAGIC_FD_HANDLER, + "_ecore_main_fdh_poll_del"); } #endif } -static inline int _ecore_main_fdh_epoll_modify(Ecore_Fd_Handler *fdh) +static inline int +_ecore_main_fdh_poll_modify(Ecore_Fd_Handler *fdh) { int r = 0; #ifdef HAVE_EPOLL - struct epoll_event ev = {0}; + struct epoll_event ev; + int efd = _ecore_get_epoll_fd(); + memset(&ev, 0, sizeof (ev)); ev.events = _ecore_poll_events_from_fdh(fdh); ev.data.ptr = fdh; INF("modifing epoll on %d to %08x", fdh->fd, ev.events); - r = epoll_ctl(epoll_fd, EPOLL_CTL_MOD, fdh->fd, &ev); + r = epoll_ctl(efd, EPOLL_CTL_MOD, fdh->fd, &ev); +#elif USE_G_MAIN_LOOP + fdh->gfd.fd = fdh->fd; + fdh->gfd.events = _gfd_events_from_fdh(fdh); + fdh->gfd.revents = 0; + INF("modifing gpoll on %d to %08x", fdh->fd, fdh->gfd.events); +#else + if (!ECORE_MAGIC_CHECK(fdh, ECORE_MAGIC_FD_HANDLER)) + { + ECORE_MAGIC_FAIL(fdh, ECORE_MAGIC_FD_HANDLER, + "_ecore_main_fdh_poll_modify"); + } #endif return r; } #ifdef HAVE_EPOLL -static inline int _ecore_main_fdh_epoll_mark_active(void) +static inline int _ecore_main_fdh_poll_mark_active(void) { - struct epoll_event ev[32] = {0}; + struct epoll_event ev[32]; int i, ret; + int efd = _ecore_get_epoll_fd(); - ret = epoll_wait(epoll_fd, ev, sizeof(ev) / sizeof(struct epoll_event), 0); + memset(&ev, 0, sizeof (ev)); + ret = epoll_wait(efd, ev, sizeof(ev) / sizeof(struct epoll_event), 0); if (ret < 0) { if (errno == EINTR) return -1; @@ -217,7 +318,7 @@ static inline int _ecore_main_fdh_epoll_mark_active(void) if (!ECORE_MAGIC_CHECK(fdh, ECORE_MAGIC_FD_HANDLER)) { ECORE_MAGIC_FAIL(fdh, ECORE_MAGIC_FD_HANDLER, - "_ecore_main_fdh_epoll_mark_active"); + "_ecore_main_fdh_poll_mark_active"); continue; } if (fdh->delete_me) @@ -225,16 +326,38 @@ static inline int _ecore_main_fdh_epoll_mark_active(void) ERR("deleted fd in epoll"); continue; } - if (ev->events & EPOLLIN) - fdh->read_active = 1; - if (ev->events & EPOLLOUT) - fdh->write_active = 1; - if (ev->events & EPOLLERR) - fdh->error_active = 1; + if (ev->events & EPOLLIN) fdh->read_active = 1; + if (ev->events & EPOLLOUT) fdh->write_active = 1; + if (ev->events & EPOLLERR) fdh->error_active = 1; } return ret; } + +#elif USE_G_MAIN_LOOP + +static inline int _ecore_main_fdh_poll_mark_active(void) +{ + Ecore_Fd_Handler *fdh; + int ret = 0; + + /* call the prepare callback for all handlers */ + EINA_INLIST_FOREACH(fd_handlers, fdh) + { + if (fdh->delete_me) + continue; + + if (fdh->gfd.revents & G_IO_IN) fdh->read_active = 1; + if (fdh->gfd.revents & G_IO_OUT) fdh->write_active = 1; + if (fdh->gfd.revents & G_IO_ERR) fdh->error_active = 1; + if (fdh->gfd.revents & (G_IO_IN|G_IO_OUT|G_IO_ERR)) ret++; + } + + INF("found %d active fds", ret); + + return ret; +} + #endif #ifdef USE_G_MAIN_LOOP @@ -251,7 +374,7 @@ _ecore_main_gsource_prepare(GSource *source, gint *next_time) if (!ecore_idling) { - while (_ecore_timer_call(_ecore_loop_time)); + while (_ecore_timer_call(_ecore_time_loop_time)); _ecore_timer_cleanup(); /* when idling, busy loop checking the fds only */ @@ -292,16 +415,16 @@ _ecore_main_gsource_check(GSource *source) INF("enter"); in_main_loop++; - ecore_fds_ready = (_ecore_main_fdh_epoll_mark_active() > 0); + ecore_fds_ready = (_ecore_main_fdh_poll_mark_active() > 0); _ecore_main_fd_handlers_cleanup(); - _ecore_loop_time = ecore_time_get(); + _ecore_time_loop_time = ecore_time_get(); _ecore_timer_enable_new(); in_main_loop--; INF("leave"); - return TRUE; /* always dispatch */ + return TRUE; /* always dispatch */ } /* like we just came out of main_loop_select in _ecore_main_select */ @@ -356,9 +479,9 @@ _ecore_main_gsource_dispatch(GSource *source, GSourceFunc callback, gpointer use INF("work"); _ecore_main_fd_handlers_call(); _ecore_main_fd_handlers_buf_call(); - while (_ecore_signal_count_get()) _ecore_signal_call(); + while (_ecore_signal_count_get()) _ecore_signal_call(); _ecore_event_call(); - _ecore_main_fd_handlers_cleanup(); + _ecore_main_fd_handlers_cleanup(); } in_main_loop--; @@ -374,7 +497,8 @@ _ecore_main_gsource_finalize(GSource *source) INF("finalize"); } -static GSourceFuncs ecore_gsource_funcs = { +static GSourceFuncs ecore_gsource_funcs = +{ .prepare = _ecore_main_gsource_prepare, .check = _ecore_main_gsource_check, .dispatch = _ecore_main_gsource_dispatch, @@ -390,20 +514,38 @@ _ecore_main_loop_init(void) #ifdef HAVE_EPOLL epoll_fd = epoll_create(1); if (epoll_fd < 0) - CRIT("Failed to create epoll fd!"); + CRIT("Failed to create epoll fd!"); + epoll_pid = getpid(); + + /* add polls on all our file descriptors */ + Ecore_Fd_Handler *fdh; + EINA_INLIST_FOREACH(fd_handlers, fdh) + { + if (fdh->delete_me) + continue; + _ecore_epoll_add(epoll_fd, fdh->fd, + _ecore_poll_events_from_fdh(fdh), fdh); + _ecore_main_fdh_poll_add(fdh); + } + #endif #ifdef USE_G_MAIN_LOOP - ecore_epoll_source = g_source_new(&ecore_gsource_funcs, sizeof (GSource)); - if (!ecore_epoll_source) - CRIT("Failed to create glib source for epoll!"); - ecore_epoll_fd.fd = epoll_fd; - ecore_epoll_fd.events = G_IO_IN; - ecore_epoll_fd.revents = 0; - g_source_add_poll(ecore_epoll_source, &ecore_epoll_fd); - ecore_epoll_id = g_source_attach(ecore_epoll_source, NULL); - if (ecore_epoll_id <= 0) - CRIT("Failed to attach glib source to default context"); + ecore_glib_source = g_source_new(&ecore_gsource_funcs, sizeof (GSource)); + if (!ecore_glib_source) + CRIT("Failed to create glib source for epoll!"); + else + { +#ifdef HAVE_EPOLL + ecore_epoll_fd.fd = epoll_fd; + ecore_epoll_fd.events = G_IO_IN; + ecore_epoll_fd.revents = 0; + g_source_add_poll(ecore_glib_source, &ecore_epoll_fd); +#endif + ecore_glib_source_id = g_source_attach(ecore_glib_source, NULL); + if (ecore_glib_source_id <= 0) + CRIT("Failed to attach glib source to default context"); + } #endif INF("leave"); } @@ -412,17 +554,32 @@ void _ecore_main_loop_shutdown(void) { #ifdef USE_G_MAIN_LOOP - g_source_destroy(ecore_epoll_source); + if (ecore_glib_source) + { + g_source_destroy(ecore_glib_source); + ecore_glib_source = NULL; + } #endif #ifdef HAVE_EPOLL - close(epoll_fd); + if (epoll_fd >= 0) + { + close(epoll_fd); + epoll_fd = -1; + } + + epoll_pid = 0; #endif } +/** + * @addtogroup Ecore_Group Ecore - Main Loop and Job Functions. + * + * @{ + */ /** - * @defgroup Ecore_Main_Loop_Group Main Loop Functions + * @addtogroup Ecore_Main_Loop_Group Ecore Main Loop functions * * These functions control the Ecore event handling loop. This loop is * designed to work on embedded systems all the way to large and @@ -439,12 +596,13 @@ _ecore_main_loop_shutdown(void) * * For examples of setting up and using a main loop, see * @ref event_handler_example.c and @ref timer_example.c. + * + * @{ */ /** * Runs a single iteration of the main loop to process everything on the * queue. - * @ingroup Ecore_Main_Loop_Group */ EAPI void ecore_main_loop_iterate(void) @@ -461,7 +619,6 @@ ecore_main_loop_iterate(void) * * This function will not return until @ref ecore_main_loop_quit is called. * - * @ingroup Ecore_Main_Loop_Group */ EAPI void ecore_main_loop_begin(void) @@ -480,7 +637,6 @@ ecore_main_loop_begin(void) /** * Quits the main loop once all the events currently on the queue have * been processed. - * @ingroup Ecore_Main_Loop_Group */ EAPI void ecore_main_loop_quit(void) @@ -505,7 +661,6 @@ ecore_main_loop_quit(void) * * @warning you don't know how to use, don't even try to use it. * - * @ingroup Ecore_Main_Loop_Group */ EAPI void ecore_main_loop_select_func_set(Ecore_Select_Function func) @@ -517,7 +672,6 @@ ecore_main_loop_select_func_set(Ecore_Select_Function func) * Gets the select function set by ecore_select_func_set(), * or the native select function if none was set. * - * @ingroup Ecore_Main_Loop_Group */ EAPI void * ecore_main_loop_select_func_get(void) @@ -570,17 +724,17 @@ ecore_main_fd_handler_add(int fd, Ecore_Fd_Handler_Flags flags, Ecore_Fd_Cb func Ecore_Fd_Handler *fdh; if ((fd < 0) || (flags == 0) || (!func)) return NULL; - + fdh = calloc(1, sizeof(Ecore_Fd_Handler)); if (!fdh) return NULL; ECORE_MAGIC_SET(fdh, ECORE_MAGIC_FD_HANDLER); fdh->fd = fd; fdh->flags = flags; - if (0 > _ecore_main_fdh_epoll_add(fdh)) + if (_ecore_main_fdh_poll_add(fdh) < 0) { - ERR("Failed to add epoll fd %d (errno = %d)!", fd, errno); - free(fdh); - return NULL; + ERR("Failed to add poll on fd %d (errno = %d)!", fd, errno); + free(fdh); + return NULL; } fdh->read_active = 0; fdh->write_active = 0; @@ -591,8 +745,8 @@ ecore_main_fd_handler_add(int fd, Ecore_Fd_Handler_Flags flags, Ecore_Fd_Cb func fdh->buf_func = buf_func; fdh->buf_data = (void *)buf_data; fd_handlers = (Ecore_Fd_Handler *) - eina_inlist_append(EINA_INLIST_GET(fd_handlers), - EINA_INLIST_GET(fdh)); + eina_inlist_append(EINA_INLIST_GET(fd_handlers), + EINA_INLIST_GET(fdh)); return fdh; } @@ -612,8 +766,8 @@ ecore_main_win32_handler_add(void *h, Ecore_Fd_Win32_Cb func, const void *data) wh->func = func; wh->data = (void *)data; win32_handlers = (Ecore_Win32_Handler *) - eina_inlist_append(EINA_INLIST_GET(win32_handlers), - EINA_INLIST_GET(wh)); + eina_inlist_append(EINA_INLIST_GET(win32_handlers), + EINA_INLIST_GET(wh)); return wh; } #else @@ -642,13 +796,13 @@ ecore_main_fd_handler_del(Ecore_Fd_Handler *fd_handler) { if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER)) { - ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, - "ecore_main_fd_handler_del"); - return NULL; + ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, + "ecore_main_fd_handler_del"); + return NULL; } fd_handler->delete_me = 1; fd_handlers_delete_me = 1; - _ecore_main_fdh_epoll_del(fd_handler); + _ecore_main_fdh_poll_del(fd_handler); return fd_handler->data; } @@ -658,9 +812,9 @@ ecore_main_win32_handler_del(Ecore_Win32_Handler *win32_handler) { if (!ECORE_MAGIC_CHECK(win32_handler, ECORE_MAGIC_WIN32_HANDLER)) { - ECORE_MAGIC_FAIL(win32_handler, ECORE_MAGIC_WIN32_HANDLER, - "ecore_main_win32_handler_del"); - return NULL; + ECORE_MAGIC_FAIL(win32_handler, ECORE_MAGIC_WIN32_HANDLER, + "ecore_main_win32_handler_del"); + return NULL; } win32_handler->delete_me = 1; win32_handlers_delete_me = 1; @@ -679,12 +833,12 @@ ecore_main_fd_handler_prepare_callback_set(Ecore_Fd_Handler *fd_handler, Ecore_F { if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER)) { - ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, - "ecore_main_fd_handler_prepare_callback_set"); - return; + ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, + "ecore_main_fd_handler_prepare_callback_set"); + return; } fd_handler->prep_func = func; - fd_handler->prep_data = (void *) data; + fd_handler->prep_data = (void *)data; } /** @@ -698,9 +852,9 @@ ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler) { if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER)) { - ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, - "ecore_main_fd_handler_fd_get"); - return -1; + ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, + "ecore_main_fd_handler_fd_get"); + return -1; } return fd_handler->fd; } @@ -711,24 +865,23 @@ ecore_main_fd_handler_fd_get(Ecore_Fd_Handler *fd_handler) * @param fd_handler The given FD handler. * @param flags The flags, @c ECORE_FD_READ, @c ECORE_FD_WRITE or * @c ECORE_FD_ERROR to query. - * @return @c 1 if any of the given flags are active. @c 0 otherwise. + * @return #EINA_TRUE if any of the given flags are active. #EINA_FALSE otherwise. * @ingroup Ecore_FD_Handler_Group */ -EAPI int +EAPI Eina_Bool ecore_main_fd_handler_active_get(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_Flags flags) { - int ret; + int ret = EINA_FALSE; if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER)) { - ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, - "ecore_main_fd_handler_active_get"); - return 0; + ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, + "ecore_main_fd_handler_active_get"); + return EINA_FALSE; } - ret = 0; - if ((flags & ECORE_FD_READ) && (fd_handler->read_active)) ret = 1; - if ((flags & ECORE_FD_WRITE) && (fd_handler->write_active)) ret = 1; - if ((flags & ECORE_FD_ERROR) && (fd_handler->error_active)) ret = 1; + if ((flags & ECORE_FD_READ) && (fd_handler->read_active)) ret = EINA_TRUE; + if ((flags & ECORE_FD_WRITE) && (fd_handler->write_active)) ret = EINA_TRUE; + if ((flags & ECORE_FD_ERROR) && (fd_handler->error_active)) ret = EINA_TRUE; return ret; } @@ -743,36 +896,44 @@ ecore_main_fd_handler_active_set(Ecore_Fd_Handler *fd_handler, Ecore_Fd_Handler_ { if (!ECORE_MAGIC_CHECK(fd_handler, ECORE_MAGIC_FD_HANDLER)) { - ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, - "ecore_main_fd_handler_active_set"); - return; + ECORE_MAGIC_FAIL(fd_handler, ECORE_MAGIC_FD_HANDLER, + "ecore_main_fd_handler_active_set"); + return; } fd_handler->flags = flags; - if (0 > _ecore_main_fdh_epoll_modify(fd_handler)) + if (_ecore_main_fdh_poll_modify(fd_handler) < 0) { - ERR("Failed to mod epoll fd %d!", fd_handler->fd); + ERR("Failed to mod epoll fd %d!", fd_handler->fd); } } +/** + * @} + */ + +/** + * @} + */ + void _ecore_main_shutdown(void) { if (in_main_loop) { ERR("\n" - "*** ECORE WARINING: Calling ecore_shutdown() while still in the main loop.\n" - "*** Program may crash or behave strangely now."); - return; + "*** ECORE WARINING: Calling ecore_shutdown() while still in the main loop.\n" + "*** Program may crash or behave strangely now."); + return; } while (fd_handlers) { - Ecore_Fd_Handler *fdh; + Ecore_Fd_Handler *fdh; - fdh = fd_handlers; - fd_handlers = (Ecore_Fd_Handler *) eina_inlist_remove(EINA_INLIST_GET(fd_handlers), - EINA_INLIST_GET(fdh)); - ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE); - free(fdh); + fdh = fd_handlers; + fd_handlers = (Ecore_Fd_Handler *) eina_inlist_remove(EINA_INLIST_GET(fd_handlers), + EINA_INLIST_GET(fdh)); + ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE); + free(fdh); } fd_handlers_delete_me = 0; fd_handler_current = NULL; @@ -780,13 +941,13 @@ _ecore_main_shutdown(void) #ifdef _WIN32 while (win32_handlers) { - Ecore_Win32_Handler *wh; + Ecore_Win32_Handler *wh; - wh = win32_handlers; - win32_handlers = (Ecore_Win32_Handler *) eina_inlist_remove(EINA_INLIST_GET(win32_handlers), - EINA_INLIST_GET(wh)); - ECORE_MAGIC_SET(wh, ECORE_MAGIC_NONE); - free(wh); + wh = win32_handlers; + win32_handlers = (Ecore_Win32_Handler *) eina_inlist_remove(EINA_INLIST_GET(win32_handlers), + EINA_INLIST_GET(wh)); + ECORE_MAGIC_SET(wh, ECORE_MAGIC_NONE); + free(wh); } win32_handlers_delete_me = 0; win32_handler_current = NULL; @@ -819,27 +980,27 @@ _ecore_main_select(double timeout) int ret; t = NULL; - if ((!finite(timeout)) || (timeout == 0.0)) /* finite() tests for NaN, too big, too small, and infinity. */ + if ((!finite(timeout)) || (timeout == 0.0)) /* finite() tests for NaN, too big, too small, and infinity. */ { - tv.tv_sec = 0; - tv.tv_usec = 0; - t = &tv; + tv.tv_sec = 0; + tv.tv_usec = 0; + t = &tv; } else if (timeout > 0.0) { - int sec, usec; + int sec, usec; #ifdef FIX_HZ - timeout += (0.5 / HZ); - sec = (int)timeout; - usec = (int)((timeout - (double)sec) * 1000000); + timeout += (0.5 / HZ); + sec = (int)timeout; + usec = (int)((timeout - (double)sec) * 1000000); #else - sec = (int)timeout; - usec = (int)((timeout - (double)sec) * 1000000); + sec = (int)timeout; + usec = (int)((timeout - (double)sec) * 1000000); #endif - tv.tv_sec = sec; - tv.tv_usec = usec; - t = &tv; + tv.tv_sec = sec; + tv.tv_usec = usec; + t = &tv; } max_fd = 0; FD_ZERO(&rfds); @@ -874,30 +1035,30 @@ _ecore_main_select(double timeout) } #else /* HAVE_EPOLL */ /* polling on the epoll fd will wake when an fd in the epoll set is active */ - FD_SET(epoll_fd, &rfds); - max_fd = epoll_fd; + max_fd = _ecore_get_epoll_fd(); + FD_SET(max_fd, &rfds); #endif /* HAVE_EPOLL */ if (_ecore_signal_count_get()) return -1; ret = main_loop_select(max_fd + 1, &rfds, &wfds, &exfds, t); - _ecore_loop_time = ecore_time_get(); + _ecore_time_loop_time = ecore_time_get(); if (ret < 0) { #ifndef _WIN32 - if (errno == EINTR) return -1; - else if (errno == EBADF) _ecore_main_fd_handlers_bads_rem(); + if (errno == EINTR) return -1; + else if (errno == EBADF) _ecore_main_fd_handlers_bads_rem(); #endif } if (ret > 0) { #ifdef HAVE_EPOLL - _ecore_main_fdh_epoll_mark_active(); + _ecore_main_fdh_poll_mark_active(); #else /* HAVE_EPOLL */ Ecore_Fd_Handler *fdh; - EINA_INLIST_FOREACH(fd_handlers, fdh) + EINA_INLIST_FOREACH(fd_handlers, fdh) { if (!fdh->delete_me) { @@ -910,11 +1071,11 @@ _ecore_main_select(double timeout) } } #endif /* HAVE_EPOLL */ - _ecore_main_fd_handlers_cleanup(); + _ecore_main_fd_handlers_cleanup(); #ifdef _WIN32 - _ecore_main_win32_handlers_cleanup(); + _ecore_main_win32_handlers_cleanup(); #endif - return 1; + return 1; } return 0; } @@ -930,42 +1091,42 @@ _ecore_main_fd_handlers_bads_rem(void) ERR("Removing bad fds"); for (l = EINA_INLIST_GET(fd_handlers); l; ) { - fdh = (Ecore_Fd_Handler *) l; - l = l->next; - errno = 0; - - if ((fcntl(fdh->fd, F_GETFD) < 0) && (errno == EBADF)) - { - ERR("Found bad fd at index %d", fdh->fd); - if (fdh->flags & ECORE_FD_ERROR) - { - ERR("Fd set for error! calling user"); - fdh->references++; - if (!fdh->func(fdh->data, fdh)) - { - ERR("Fd function err returned 0, remove it"); - fdh->delete_me = 1; - fd_handlers_delete_me = 1; + fdh = (Ecore_Fd_Handler *) l; + l = l->next; + errno = 0; + + if ((fcntl(fdh->fd, F_GETFD) < 0) && (errno == EBADF)) + { + ERR("Found bad fd at index %d", fdh->fd); + if (fdh->flags & ECORE_FD_ERROR) + { + ERR("Fd set for error! calling user"); + fdh->references++; + if (!fdh->func(fdh->data, fdh)) + { + ERR("Fd function err returned 0, remove it"); + fdh->delete_me = 1; + fd_handlers_delete_me = 1; found++; - } - fdh->references--; - } - else - { - ERR("Problematic fd found at %d! setting it for delete", fdh->fd); - fdh->delete_me = 1; - fd_handlers_delete_me = 1; + } + fdh->references--; + } + else + { + ERR("Problematic fd found at %d! setting it for delete", fdh->fd); + fdh->delete_me = 1; + fd_handlers_delete_me = 1; found++; - } - } + } + } } if (found == 0) { -#ifdef HAVE_GLIB +# ifdef HAVE_GLIB ERR("No bad fd found. Maybe a foreign fd from glib?"); -#else +# else ERR("No bad fd found. EEEK!"); -#endif +# endif } _ecore_main_fd_handlers_cleanup(); } @@ -981,23 +1142,23 @@ _ecore_main_fd_handlers_cleanup(void) if (!fd_handlers_delete_me) return; for (l = EINA_INLIST_GET(fd_handlers); l; ) { - fdh = (Ecore_Fd_Handler *) l; - - l = l->next; - if (fdh->delete_me) - { - if (fdh->references) - { - deleted_in_use++; - continue; - } + fdh = (Ecore_Fd_Handler *) l; + + l = l->next; + if (fdh->delete_me) + { + if (fdh->references) + { + deleted_in_use++; + continue; + } - fd_handlers = (Ecore_Fd_Handler *) + fd_handlers = (Ecore_Fd_Handler *) eina_inlist_remove(EINA_INLIST_GET(fd_handlers), EINA_INLIST_GET(fdh)); - ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE); - free(fdh); - } + ECORE_MAGIC_SET(fdh, ECORE_MAGIC_NONE); + free(fdh); + } } if (!deleted_in_use) fd_handlers_delete_me = 0; } @@ -1018,11 +1179,11 @@ _ecore_main_win32_handlers_cleanup(void) l = l->next; if (wh->delete_me) { - if (wh->references) - { - deleted_in_use++; - continue; - } + if (wh->references) + { + deleted_in_use++; + continue; + } win32_handlers = (Ecore_Win32_Handler *) eina_inlist_remove(EINA_INLIST_GET(win32_handlers), @@ -1040,41 +1201,41 @@ _ecore_main_fd_handlers_call(void) { if (!fd_handler_current) { - /* regular main loop, start from head */ - fd_handler_current = fd_handlers; + /* regular main loop, start from head */ + fd_handler_current = fd_handlers; } else { - /* recursive main loop, continue from where we were */ - fd_handler_current = (Ecore_Fd_Handler *)EINA_INLIST_GET(fd_handler_current)->next; + /* recursive main loop, continue from where we were */ + fd_handler_current = (Ecore_Fd_Handler *)EINA_INLIST_GET(fd_handler_current)->next; } while (fd_handler_current) { - Ecore_Fd_Handler *fdh = fd_handler_current; - - if (!fdh->delete_me) - { - if ((fdh->read_active) || - (fdh->write_active) || - (fdh->error_active)) - { - fdh->references++; - if (!fdh->func(fdh->data, fdh)) - { - fdh->delete_me = 1; - fd_handlers_delete_me = 1; - } - fdh->references--; - - fdh->read_active = 0; - fdh->write_active = 0; - fdh->error_active = 0; - } - } - - if (fd_handler_current) /* may have changed in recursive main loops */ - fd_handler_current = (Ecore_Fd_Handler *)EINA_INLIST_GET(fd_handler_current)->next; + Ecore_Fd_Handler *fdh = fd_handler_current; + + if (!fdh->delete_me) + { + if ((fdh->read_active) || + (fdh->write_active) || + (fdh->error_active)) + { + fdh->references++; + if (!fdh->func(fdh->data, fdh)) + { + fdh->delete_me = 1; + fd_handlers_delete_me = 1; + } + fdh->references--; + + fdh->read_active = 0; + fdh->write_active = 0; + fdh->error_active = 0; + } + } + + if (fd_handler_current) /* may have changed in recursive main loops */ + fd_handler_current = (Ecore_Fd_Handler *)EINA_INLIST_GET(fd_handler_current)->next; } } @@ -1114,7 +1275,7 @@ _ecore_main_loop_iterate_internal(int once_only) in_main_loop++; /* expire any timers */ - while (_ecore_timer_call(_ecore_loop_time)); + while (_ecore_timer_call(_ecore_time_loop_time)); _ecore_timer_cleanup(); /* process signals into events .... */ @@ -1122,23 +1283,23 @@ _ecore_main_loop_iterate_internal(int once_only) if (_ecore_event_exist()) { _ecore_idle_enterer_call(); - have_event = 1; - _ecore_main_select(0.0); - _ecore_loop_time = ecore_time_get(); + have_event = 1; + _ecore_main_select(0.0); + _ecore_time_loop_time = ecore_time_get(); _ecore_timer_enable_new(); - goto process_events; + goto process_events; } /* call idle enterers ... */ if (!once_only) _ecore_idle_enterer_call(); else { - have_event = have_signal = 0; + have_event = have_signal = 0; - if (_ecore_main_select(0.0) > 0) have_event = 1; - if (_ecore_signal_count_get() > 0) have_signal = 1; - if (have_signal || have_event) + if (_ecore_main_select(0.0) > 0) have_event = 1; + if (_ecore_signal_count_get() > 0) have_signal = 1; + if (have_signal || have_event) { - _ecore_loop_time = ecore_time_get(); + _ecore_time_loop_time = ecore_time_get(); _ecore_timer_enable_new(); goto process_events; } @@ -1147,93 +1308,93 @@ _ecore_main_loop_iterate_internal(int once_only) /* if these calls caused any buffered events to appear - deal with them */ _ecore_main_fd_handlers_buf_call(); - /* if ther are any - jump to processing them */ + /* if there are any - jump to processing them */ if (_ecore_event_exist()) { - have_event = 1; - _ecore_main_select(0.0); - _ecore_loop_time = ecore_time_get(); + have_event = 1; + _ecore_main_select(0.0); + _ecore_time_loop_time = ecore_time_get(); _ecore_timer_enable_new(); - goto process_events; + goto process_events; } if (once_only) { - _ecore_idle_enterer_call(); - in_main_loop--; - _ecore_loop_time = ecore_time_get(); + _ecore_idle_enterer_call(); + in_main_loop--; + _ecore_time_loop_time = ecore_time_get(); _ecore_timer_enable_new(); - return; + return; } if (_ecore_fps_debug) { - t2 = ecore_time_get(); - if ((t1 > 0.0) && (t2 > 0.0)) - _ecore_fps_debug_runtime_add(t2 - t1); + t2 = ecore_time_get(); + if ((t1 > 0.0) && (t2 > 0.0)) + _ecore_fps_debug_runtime_add(t2 - t1); } start_loop: /* any timers re-added as a result of these are allowed to go */ _ecore_timer_enable_new(); if (do_quit) { - _ecore_loop_time = ecore_time_get(); - in_main_loop--; + _ecore_time_loop_time = ecore_time_get(); + in_main_loop--; _ecore_timer_enable_new(); - return; + return; } if (!_ecore_event_exist()) { - /* init flags */ - have_event = have_signal = 0; - next_time = _ecore_timer_next_get(); - /* no timers */ - if (next_time < 0) - { - /* no idlers */ - if (!_ecore_idler_exist()) - { - if (_ecore_main_select(-1.0) > 0) have_event = 1; - } - /* idlers */ - else - { - for (;;) - { - if (!_ecore_idler_call()) goto start_loop; - if (_ecore_event_exist()) break; - if (_ecore_main_select(0.0) > 0) have_event = 1; - if (_ecore_signal_count_get() > 0) have_signal = 1; - if (have_event || have_signal) break; - if (_ecore_timers_exists()) goto start_loop; - if (do_quit) break; - } - } - } - /* timers */ - else - { - /* no idlers */ - if (!_ecore_idler_exist()) - { - if (_ecore_main_select(next_time) > 0) have_event = 1; - } - /* idlers */ - else - { - for (;;) - { - if (!_ecore_idler_call()) goto start_loop; - if (_ecore_event_exist()) break; - if (_ecore_main_select(0.0) > 0) have_event = 1; - if (_ecore_signal_count_get() > 0) have_signal = 1; - if (have_event || have_signal) break; - next_time = _ecore_timer_next_get(); - if (next_time <= 0) break; - if (do_quit) break; - } - } - } - _ecore_loop_time = ecore_time_get(); + /* init flags */ + have_event = have_signal = 0; + next_time = _ecore_timer_next_get(); + /* no timers */ + if (next_time < 0) + { + /* no idlers */ + if (!_ecore_idler_exist()) + { + if (_ecore_main_select(-1.0) > 0) have_event = 1; + } + /* idlers */ + else + { + for (;;) + { + if (!_ecore_idler_call()) goto start_loop; + if (_ecore_event_exist()) break; + if (_ecore_main_select(0.0) > 0) have_event = 1; + if (_ecore_signal_count_get() > 0) have_signal = 1; + if (have_event || have_signal) break; + if (_ecore_timers_exists()) goto start_loop; + if (do_quit) break; + } + } + } + /* timers */ + else + { + /* no idlers */ + if (!_ecore_idler_exist()) + { + if (_ecore_main_select(next_time) > 0) have_event = 1; + } + /* idlers */ + else + { + for (;;) + { + if (!_ecore_idler_call()) goto start_loop; + if (_ecore_event_exist()) break; + if (_ecore_main_select(0.0) > 0) have_event = 1; + if (_ecore_signal_count_get() > 0) have_signal = 1; + if (have_event || have_signal) break; + next_time = _ecore_timer_next_get(); + if (next_time <= 0) break; + if (do_quit) break; + } + } + } + _ecore_time_loop_time = ecore_time_get(); } if (_ecore_fps_debug) t1 = ecore_time_get(); /* we came out of our "wait state" so idle has exited */ @@ -1258,7 +1419,7 @@ _ecore_main_loop_iterate_internal(int once_only) #ifdef _WIN32 static int _ecore_main_win32_select(int nfds __UNUSED__, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds, struct timeval *tv) + fd_set *exceptfds, struct timeval *tv) { HANDLE objects[MAXIMUM_WAIT_OBJECTS]; int sockets[MAXIMUM_WAIT_OBJECTS]; @@ -1281,19 +1442,19 @@ _ecore_main_win32_select(int nfds __UNUSED__, fd_set *readfds, fd_set *writefds, network_event = 0; if (FD_ISSET(fdh->fd, readfds)) - network_event |= FD_READ; + network_event |= FD_READ; if (FD_ISSET(fdh->fd, writefds)) - network_event |= FD_WRITE; + network_event |= FD_WRITE; if (FD_ISSET(fdh->fd, exceptfds)) - network_event |= FD_OOB; + network_event |= FD_OOB; if (network_event) - { + { event = WSACreateEvent(); - WSAEventSelect(fdh->fd, event, network_event); - objects[objects_nbr] = event; - sockets[events_nbr] = fdh->fd; - events_nbr++; + WSAEventSelect(fdh->fd, event, network_event); + objects[objects_nbr] = event; + sockets[events_nbr] = fdh->fd; + events_nbr++; objects_nbr++; } } @@ -1309,8 +1470,8 @@ _ecore_main_win32_select(int nfds __UNUSED__, fd_set *readfds, fd_set *writefds, /* Empty the queue before waiting */ while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - TranslateMessage(&msg); - DispatchMessage(&msg); + TranslateMessage(&msg); + DispatchMessage(&msg); } /* Wait for any message sent or posted to this queue */ @@ -1323,7 +1484,7 @@ _ecore_main_win32_select(int nfds __UNUSED__, fd_set *readfds, fd_set *writefds, if (timeout == 0) return 0; result = MsgWaitForMultipleObjects(objects_nbr, (const HANDLE *)objects, EINA_FALSE, - timeout, QS_ALLINPUT); + timeout, QS_ALLINPUT); FD_ZERO(readfds); FD_ZERO(writefds); @@ -1341,16 +1502,16 @@ _ecore_main_win32_select(int nfds __UNUSED__, fd_set *readfds, fd_set *writefds, } else if (result == WAIT_TIMEOUT) { - ERR("time out\n"); + /* ERR("time out\n"); */ res = 0; } else if (result == (WAIT_OBJECT_0 + objects_nbr)) { while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) - { - TranslateMessage(&msg); - DispatchMessage(&msg); - } + { + TranslateMessage(&msg); + DispatchMessage(&msg); + } res = 0; } @@ -1359,34 +1520,34 @@ _ecore_main_win32_select(int nfds __UNUSED__, fd_set *readfds, fd_set *writefds, WSANETWORKEVENTS network_event; WSAEnumNetworkEvents(sockets[result], objects[result], &network_event); - + if (network_event.lNetworkEvents & FD_READ) - FD_SET(sockets[result], readfds); + FD_SET(sockets[result], readfds); if (network_event.lNetworkEvents & FD_WRITE) - FD_SET(sockets[result], writefds); + FD_SET(sockets[result], writefds); if (network_event.lNetworkEvents & FD_OOB) - FD_SET(sockets[result], exceptfds); - + FD_SET(sockets[result], exceptfds); + res = 1; } else if ((result >= (WAIT_OBJECT_0 + events_nbr)) && (result < (WAIT_OBJECT_0 + objects_nbr))) { - if (!win32_handler_current) - { - /* regular main loop, start from head */ - win32_handler_current = win32_handlers; - } - else - { - /* recursive main loop, continue from where we were */ - win32_handler_current = (Ecore_Win32_Handler *)EINA_INLIST_GET(win32_handler_current)->next; - } - - while (win32_handler_current) - { - wh = win32_handler_current; + if (!win32_handler_current) + { + /* regular main loop, start from head */ + win32_handler_current = win32_handlers; + } + else + { + /* recursive main loop, continue from where we were */ + win32_handler_current = (Ecore_Win32_Handler *)EINA_INLIST_GET(win32_handler_current)->next; + } + while (win32_handler_current) + { + wh = win32_handler_current; + if (objects[result - WAIT_OBJECT_0] == wh->h) { if (!wh->delete_me) diff --git a/src/lib/ecore/ecore_pipe.c b/src/lib/ecore/ecore_pipe.c index 9c26133..054a5f0 100644 --- a/src/lib/ecore/ecore_pipe.c +++ b/src/lib/ecore/ecore_pipe.c @@ -57,15 +57,23 @@ struct _Ecore_Pipe const void *data; Ecore_Pipe_Cb handler; unsigned int len; + int handling; size_t already_read; void *passed_data; + Eina_Bool delete_me : 1; }; static Eina_Bool _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler); /** - * @defgroup Ecore_Pipe_Group Pipe wrapper + * @addtogroup Ecore_Group Ecore - Main Loop and Job Functions. + * + * @{ + */ + +/** + * @addtogroup Ecore_Pipe_Group Pipe wrapper * * These functions wrap the pipe / write / read functions to * easily integrate a loop that is in its own thread to the ecore @@ -275,7 +283,6 @@ static Eina_Bool _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler); * @param data Data to pass to @p handler when it is called. * @return A newly created Ecore_Pipe object if successful. * @c NULL otherwise. - * @ingroup Ecore_Pipe_Group */ EAPI Ecore_Pipe * ecore_pipe_add(Ecore_Pipe_Cb handler, const void *data) @@ -314,7 +321,6 @@ ecore_pipe_add(Ecore_Pipe_Cb handler, const void *data) * * @param p The Ecore_Pipe object to be freed. * @return The pointer to the private data - * @ingroup Ecore_Pipe_Group */ EAPI void * ecore_pipe_del(Ecore_Pipe *p) @@ -323,9 +329,11 @@ ecore_pipe_del(Ecore_Pipe *p) if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE)) { - ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_del"); - return NULL; + ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_del"); + return NULL; } + p->delete_me = EINA_TRUE; + if (p->handling > 0) return (void *)p->data; if (p->fd_handler) ecore_main_fd_handler_del(p->fd_handler); if (p->fd_read != PIPE_FD_INVALID) pipe_close(p->fd_read); if (p->fd_write != PIPE_FD_INVALID) pipe_close(p->fd_write); @@ -338,38 +346,45 @@ ecore_pipe_del(Ecore_Pipe *p) * Close the read end of an Ecore_Pipe object created with ecore_pipe_add(). * * @param p The Ecore_Pipe object. - * @ingroup Ecore_Pipe_Group */ EAPI void ecore_pipe_read_close(Ecore_Pipe *p) { if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE)) { - ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_read_close"); - return; + ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_read_close"); + return; + } + if (p->fd_handler) + { + ecore_main_fd_handler_del(p->fd_handler); + p->fd_handler = NULL; + } + if (p->fd_read != PIPE_FD_INVALID) + { + pipe_close(p->fd_read); + p->fd_read = PIPE_FD_INVALID; } - ecore_main_fd_handler_del(p->fd_handler); - p->fd_handler = NULL; - pipe_close(p->fd_read); - p->fd_read = PIPE_FD_INVALID; } /** * Close the write end of an Ecore_Pipe object created with ecore_pipe_add(). * * @param p The Ecore_Pipe object. - * @ingroup Ecore_Pipe_Group */ EAPI void ecore_pipe_write_close(Ecore_Pipe *p) { if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE)) { - ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_write_close"); - return; + ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_write_close"); + return; + } + if (p->fd_write != PIPE_FD_INVALID) + { + pipe_close(p->fd_write); + p->fd_write = PIPE_FD_INVALID; } - pipe_close(p->fd_write); - p->fd_write = PIPE_FD_INVALID; } /** @@ -379,7 +394,6 @@ ecore_pipe_write_close(Ecore_Pipe *p) * @param buffer The data to write into the pipe. * @param nbytes The size of the @p buffer in bytes * @return Returns EINA_TRUE on a successful write, EINA_FALSE on an error - * @ingroup Ecore_Pipe_Group */ EAPI Eina_Bool ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes) @@ -390,43 +404,45 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes) if (!ECORE_MAGIC_CHECK(p, ECORE_MAGIC_PIPE)) { - ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_write"); - return EINA_FALSE; + ECORE_MAGIC_FAIL(p, ECORE_MAGIC_PIPE, "ecore_pipe_write"); + return EINA_FALSE; } + if (p->delete_me) return EINA_FALSE; + if (p->fd_write == PIPE_FD_INVALID) return EINA_FALSE; /* First write the len into the pipe */ do { - ret = pipe_write(p->fd_write, &nbytes, sizeof(nbytes)); - if (ret == sizeof(nbytes)) - { - retry = ECORE_PIPE_WRITE_RETRY; - break; - } - else if (ret > 0) - { - /* XXX What should we do here? */ - ERR("The length of the data was not written complete" - " to the pipe"); - return EINA_FALSE; - } - else if (ret == PIPE_FD_ERROR && errno == EPIPE) - { - pipe_close(p->fd_write); - p->fd_write = PIPE_FD_INVALID; - return EINA_FALSE; - } - else if (ret == PIPE_FD_ERROR && errno == EINTR) - /* try it again */ - ; - else - { - ERR("An unhandled error (ret: %zd errno: %d)" - "occured while writing to the pipe the length", - ret, errno); - } + ret = pipe_write(p->fd_write, &nbytes, sizeof(nbytes)); + if (ret == sizeof(nbytes)) + { + retry = ECORE_PIPE_WRITE_RETRY; + break; + } + else if (ret > 0) + { + /* XXX What should we do here? */ + ERR("The length of the data was not written complete" + " to the pipe"); + return EINA_FALSE; + } + else if (ret == PIPE_FD_ERROR && errno == EPIPE) + { + pipe_close(p->fd_write); + p->fd_write = PIPE_FD_INVALID; + return EINA_FALSE; + } + else if (ret == PIPE_FD_ERROR && errno == EINTR) + /* try it again */ + ; + else + { + ERR("An unhandled error (ret: %zd errno: %d)" + "occurred while writing to the pipe the length", + ret, errno); + } } while (retry--); @@ -435,144 +451,176 @@ ecore_pipe_write(Ecore_Pipe *p, const void *buffer, unsigned int nbytes) /* and now pass the data to the pipe */ do { - ret = pipe_write(p->fd_write, + ret = pipe_write(p->fd_write, ((unsigned char *)buffer) + already_written, nbytes - already_written); - if (ret == (ssize_t)(nbytes - already_written)) - return EINA_TRUE; - else if (ret >= 0) - { - already_written -= ret; - continue; - } - else if (ret == PIPE_FD_ERROR && errno == EPIPE) - { - pipe_close(p->fd_write); - p->fd_write = PIPE_FD_INVALID; - return EINA_FALSE; - } - else if (ret == PIPE_FD_ERROR && errno == EINTR) - /* try it again */ - ; - else - { - ERR("An unhandled error (ret: %zd errno: %d)" - "occured while writing to the pipe the length", - ret, errno); - } + if (ret == (ssize_t)(nbytes - already_written)) + return EINA_TRUE; + else if (ret >= 0) + { + already_written -= ret; + continue; + } + else if (ret == PIPE_FD_ERROR && errno == EPIPE) + { + pipe_close(p->fd_write); + p->fd_write = PIPE_FD_INVALID; + return EINA_FALSE; + } + else if (ret == PIPE_FD_ERROR && errno == EINTR) + /* try it again */ + ; + else + { + ERR("An unhandled error (ret: %zd errno: %d)" + "occurred while writing to the pipe the length", + ret, errno); + } } while (retry--); return EINA_FALSE; } +/** + * @} + */ + +/** + * @} + */ + /* Private function */ +static void +_ecore_pipe_unhandle(Ecore_Pipe *p) +{ + p->handling--; + if (p->delete_me) + { + ecore_pipe_del(p); + } +} static Eina_Bool _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__) { Ecore_Pipe *p; double start_time; + int i; p = (Ecore_Pipe *)data; start_time = ecore_time_get(); - - do + + p->handling++; + for (i = 0; i < 16; i++) { - ssize_t ret; - - /* if we already have read some data we don't need to read the len - * but to finish the already started job - */ - if (p->len == 0) - { - /* read the len of the passed data */ - ret = pipe_read(p->fd_read, &p->len, sizeof(p->len)); - - /* catch the non error case first */ - if (ret == sizeof(p->len)) - ; - else if (ret > 0) - { - /* XXX What should we do here? */ - ERR("Only read %zd bytes from the pipe, although" - " we need to read %zd bytes.", ret, sizeof(p->len)); - } - else if (ret == 0) - { - p->handler((void *)p->data, NULL, 0); - pipe_close(p->fd_read); - p->fd_read = PIPE_FD_INVALID; - p->fd_handler = NULL; - return ECORE_CALLBACK_CANCEL; - } + ssize_t ret; + + /* if we already have read some data we don't need to read the len + * but to finish the already started job + */ + if (p->len == 0) + { + /* read the len of the passed data */ + ret = pipe_read(p->fd_read, &p->len, sizeof(p->len)); + + /* catch the non error case first */ + if (ret == sizeof(p->len)) + ; + else if (ret > 0) + { + /* XXX What should we do here? */ + ERR("Only read %zd bytes from the pipe, although" + " we need to read %zd bytes.", ret, sizeof(p->len)); + _ecore_pipe_unhandle(p); + return ECORE_CALLBACK_CANCEL; + } + else if (ret == 0) + { + p->handler((void *)p->data, NULL, 0); + pipe_close(p->fd_read); + p->fd_read = PIPE_FD_INVALID; + p->fd_handler = NULL; + _ecore_pipe_unhandle(p); + return ECORE_CALLBACK_CANCEL; + } #ifndef _WIN32 - else if ((ret == PIPE_FD_ERROR) && ((errno == EINTR) || (errno == EAGAIN))) - return ECORE_CALLBACK_RENEW; - else - { - ERR("An unhandled error (ret: %zd errno: %d)" - "occured while reading from the pipe the length", - ret, errno); + else if ((ret == PIPE_FD_ERROR) && ((errno == EINTR) || (errno == EAGAIN))) + { + _ecore_pipe_unhandle(p); return ECORE_CALLBACK_RENEW; - } + } + else + { + ERR("An unhandled error (ret: %zd errno: %d [%s])" + "occurred while reading from the pipe the length", + ret, errno, strerror(errno)); + _ecore_pipe_unhandle(p); + return ECORE_CALLBACK_RENEW; + } #else - else /* ret == PIPE_FD_ERROR is the only other case on Windows */ - { + else /* ret == PIPE_FD_ERROR is the only other case on Windows */ + { if (WSAGetLastError() != WSAEWOULDBLOCK) { p->handler((void *)p->data, NULL, 0); pipe_close(p->fd_read); p->fd_read = PIPE_FD_INVALID; p->fd_handler = NULL; + _ecore_pipe_unhandle(p); return ECORE_CALLBACK_CANCEL; } - } + } #endif - } + } - if (!p->passed_data) - p->passed_data = malloc(p->len); + if (!p->passed_data) + p->passed_data = malloc(p->len); - /* and read the passed data */ - ret = pipe_read(p->fd_read, + /* and read the passed data */ + ret = pipe_read(p->fd_read, ((unsigned char *)p->passed_data) + p->already_read, p->len - p->already_read); - /* catch the non error case first */ - if (ret == (ssize_t)(p->len - p->already_read)) - { - p->handler((void *)p->data, p->passed_data, p->len); - free(p->passed_data); - /* reset all values to 0 */ - p->passed_data = NULL; - p->already_read = 0; - p->len = 0; - } - else if (ret >= 0) - { - p->already_read += ret; - return ECORE_CALLBACK_RENEW; - } - else if (ret == 0) - { - p->handler((void *)p->data, NULL, 0); - pipe_close(p->fd_read); - p->fd_read = PIPE_FD_INVALID; - p->fd_handler = NULL; - return ECORE_CALLBACK_CANCEL; - } + /* catch the non error case first */ + if (ret == (ssize_t)(p->len - p->already_read)) + { + p->handler((void *)p->data, p->passed_data, p->len); + free(p->passed_data); + /* reset all values to 0 */ + p->passed_data = NULL; + p->already_read = 0; + p->len = 0; + } + else if (ret >= 0) + { + p->already_read += ret; + _ecore_pipe_unhandle(p); + return ECORE_CALLBACK_RENEW; + } + else if (ret == 0) + { + p->handler((void *)p->data, NULL, 0); + pipe_close(p->fd_read); + p->fd_read = PIPE_FD_INVALID; + p->fd_handler = NULL; + _ecore_pipe_unhandle(p); + return ECORE_CALLBACK_CANCEL; + } #ifndef _WIN32 - else if (ret == PIPE_FD_ERROR && (errno == EINTR || errno == EAGAIN)) - return ECORE_CALLBACK_RENEW; - else - { - ERR("An unhandled error (ret: %zd errno: %d)" - "occured while reading from the pipe the data", - ret, errno); - return ECORE_CALLBACK_RENEW; - } + else if (ret == PIPE_FD_ERROR && (errno == EINTR || errno == EAGAIN)) + { + return ECORE_CALLBACK_RENEW; + } + else + { + ERR("An unhandled error (ret: %zd errno: %d)" + "occurred while reading from the pipe the data", + ret, errno); + _ecore_pipe_unhandle(p); + return ECORE_CALLBACK_RENEW; + } #else else /* ret == PIPE_FD_ERROR is the only other case on Windows */ { @@ -582,6 +630,7 @@ _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__) pipe_close(p->fd_read); p->fd_read = PIPE_FD_INVALID; p->fd_handler = NULL; + _ecore_pipe_unhandle(p); return ECORE_CALLBACK_CANCEL; } else @@ -589,7 +638,7 @@ _ecore_pipe_read(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__) } #endif } - while (ecore_time_get() - start_time < ecore_animator_frametime_get()); + _ecore_pipe_unhandle(p); return ECORE_CALLBACK_RENEW; } diff --git a/src/lib/ecore/ecore_poll.c b/src/lib/ecore/ecore_poll.c index 1467952..cbf804a 100644 --- a/src/lib/ecore/ecore_poll.c +++ b/src/lib/ecore/ecore_poll.c @@ -52,21 +52,21 @@ _ecore_poller_next_tick_eval(void) min_interval = -1; for (i = 0; i < 15; i++) { - if (pollers[i]) - { - min_interval = i; - break; - } + if (pollers[i]) + { + min_interval = i; + break; + } } if (min_interval < 0) { - /* no pollers */ - if (timer) - { - ecore_timer_del(timer); - timer = NULL; - } - return; + /* no pollers */ + if (timer) + { + ecore_timer_del(timer); + timer = NULL; + } + return; } interval_incr = (1 << min_interval); interval = interval_incr * poll_interval; @@ -76,28 +76,28 @@ _ecore_poller_next_tick_eval(void) * callback will adjust the timer interval at the end anyway */ if (at_tick) { - if (!timer) - timer = ecore_timer_add(interval, _ecore_poller_cb_timer, NULL); + if (!timer) + timer = ecore_timer_add(interval, _ecore_poller_cb_timer, NULL); } else { - double t; - - if (!timer) - timer = ecore_timer_add(interval, _ecore_poller_cb_timer, NULL); - else - { - t = ecore_time_get(); - if (interval != poll_cur_interval) - { - t -= last_tick; /* time since we last ticked */ - /* delete the timer and reset it to tick off in the new - * time interval. at the tick this will be adjusted */ - ecore_timer_del(timer); - timer = ecore_timer_add(interval - t, - _ecore_poller_cb_timer, NULL); - } - } + double t; + + if (!timer) + timer = ecore_timer_add(interval, _ecore_poller_cb_timer, NULL); + else + { + t = ecore_time_get(); + if (interval != poll_cur_interval) + { + t -= last_tick; /* time since we last ticked */ + /* delete the timer and reset it to tick off in the new + * time interval. at the tick this will be adjusted */ + ecore_timer_del(timer); + timer = ecore_timer_add(interval - t, + _ecore_poller_cb_timer, NULL); + } + } } poll_cur_interval = interval; } @@ -116,9 +116,9 @@ _ecore_poller_cb_timer(void *data __UNUSED__) * 7, 16 etc. up to 32768) */ for (i = 0; i < 15; i++) { - poller_counters[i] += interval_incr; - /* wrap back to 0 if we exceed out loop count for the counter */ - if (poller_counters[i] >= (1 << i)) poller_counters[i] = 0; + poller_counters[i] += interval_incr; + /* wrap back to 0 if we exceed out loop count for the counter */ + if (poller_counters[i] >= (1 << i)) poller_counters[i] = 0; } just_added_poller = 0; @@ -126,49 +126,49 @@ _ecore_poller_cb_timer(void *data __UNUSED__) poller_walking++; for (i = 0; i < 15; i++) { - /* if the counter is @ 0 - this means that counter "went off" this - * tick interval, so run all pollers hooked to that counter */ - if (poller_counters[i] == 0) - { - EINA_INLIST_FOREACH(pollers[i], poller) - { - if (!poller->delete_me) - { - if (!poller->func(poller->data)) - { - if (!poller->delete_me) - { - poller->delete_me = 1; - poller_delete_count++; - } - } - } - } - } + /* if the counter is @ 0 - this means that counter "went off" this + * tick interval, so run all pollers hooked to that counter */ + if (poller_counters[i] == 0) + { + EINA_INLIST_FOREACH(pollers[i], poller) + { + if (!poller->delete_me) + { + if (!poller->func(poller->data)) + { + if (!poller->delete_me) + { + poller->delete_me = 1; + poller_delete_count++; + } + } + } + } + } } poller_walking--; /* handle deletes afterwards */ if (poller_delete_count > 0) { - /* FIXME: walk all pollers and remove deleted ones */ - for (i = 0; i < 15; i++) - { + /* FIXME: walk all pollers and remove deleted ones */ + for (i = 0; i < 15; i++) + { for (l = pollers[i]; l;) - { + { poller = l; - l = (Ecore_Poller *) EINA_INLIST_GET(l)->next; - if (poller->delete_me) - { - pollers[i] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(poller)); - free(poller); - poller_delete_count--; - changes++; - if (poller_delete_count <= 0) break; - } - } - if (poller_delete_count <= 0) break; - } + l = (Ecore_Poller *) EINA_INLIST_GET(l)->next; + if (poller->delete_me) + { + pollers[i] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(poller)); + free(poller); + poller_delete_count--; + changes++; + if (poller_delete_count <= 0) break; + } + } + if (poller_delete_count <= 0) break; + } } /* if we deleted or added any pollers, then we need to re-evaluate our * minimum poll interval */ @@ -191,12 +191,20 @@ _ecore_poller_cb_timer(void *data __UNUSED__) } /** - * @defgroup Ecore_Poll_Group Ecore Poll Functions + * @addtogroup Ecore_Group Ecore - Main Loop and Job Functions. + * + * @{ + */ + +/** + * @addtogroup Ecore_Poller_Group Ecore Poll functions * * These functions are for the need to poll information, but provide a shared * abstracted API to pool such polling to minimise wakeup and ensure all the * polling happens in as few spots as possible areound a core poll interval. * For now only 1 core poller type is supprted: ECORE_POLLER_CORE + * + * @{ */ @@ -204,7 +212,6 @@ _ecore_poller_cb_timer(void *data __UNUSED__) * Sets the time between ticks (in seconds) for the given ticker clock. * @param type The ticker type to adjust * @param poll_time The time (in seconds) between ticks of the clock - * @ingroup Ecore_Poller_Group * * This will adjust the time between ticks of the given ticker type defined * by @p type to the time period defined by @p poll_time. @@ -220,7 +227,6 @@ ecore_poller_poll_interval_set(Ecore_Poller_Type type __UNUSED__, double poll_ti * Gets the time between ticks (in seconds) for the given ticker clock. * @param type The ticker type to query * @return The time in seconds between ticks of the ticker clock - * @ingroup Ecore_Poller_Group * * This will get the time between ticks of the specifider ticker clock. */ @@ -238,7 +244,6 @@ ecore_poller_poll_interval_get(Ecore_Poller_Type type __UNUSED__) * rescheduled for the next tick interval. * @param data Data to pass to @p func when it is called. * @return A poller object on success. @c NULL on failure. - * @ingroup Ecore_Poller_Group * * This function adds a poller callback that is to be called regularly * along with all other poller callbacks so the pollers are synchronized with @@ -294,8 +299,8 @@ ecore_poller_add(Ecore_Poller_Type type __UNUSED__, int interval, Ecore_Task_Cb ibit = -1; while (interval != 0) { - ibit++; - interval >>= 1; + ibit++; + interval >>= 1; } /* only allow up to 32768 - i.e. ibit == 15, so limit it */ if (ibit > 15) ibit = 15; @@ -320,7 +325,6 @@ ecore_poller_add(Ecore_Poller_Type type __UNUSED__, int interval, Ecore_Task_Cb * * This allows the changing of a poller's polling interval. It is useful when you want to alter * a poll rate without deleting and re-creating a poller. - * @ingroup Ecore_Poller_Group */ EAPI Eina_Bool ecore_poller_poller_interval_set(Ecore_Poller *poller, int interval) @@ -364,7 +368,6 @@ ecore_poller_poller_interval_set(Ecore_Poller *poller, int interval) * @return Returns the interval, in ticks, that @p poller polls at * * This returns a poller's polling interval, or 0 on error. - * @ingroup Ecore_Poller_Group */ EAPI int ecore_poller_poller_interval_get(Ecore_Poller *poller) @@ -392,7 +395,6 @@ ecore_poller_poller_interval_get(Ecore_Poller *poller) * @param poller The poller to delete. * @return The data pointer set for the timer when @ref ecore_poller_add was * called. @c NULL is returned if the function is unsuccessful. - * @ingroup Ecore_Poller_Group * * Note: @p poller must be a valid handle. If the poller function has already * returned 0, the handle is no longer valid (and does not need to be delete). @@ -425,6 +427,14 @@ ecore_poller_del(Ecore_Poller *poller) return data; } +/** + * @} + */ + +/** + * @} + */ + void _ecore_poller_shutdown(void) { @@ -433,10 +443,10 @@ _ecore_poller_shutdown(void) for (i = 0; i < 15; i++) { - while ((poller = pollers[i])) - { - pollers[i] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(pollers[i])); - free(poller); - } + while ((poller = pollers[i])) + { + pollers[i] = (Ecore_Poller *) eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(pollers[i])); + free(poller); + } } } diff --git a/src/lib/ecore/ecore_private.h b/src/lib/ecore/ecore_private.h index 1708459..00ab920 100644 --- a/src/lib/ecore/ecore_private.h +++ b/src/lib/ecore/ecore_private.h @@ -57,7 +57,7 @@ extern int _ecore_log_dom ; # define CLAMP(x, min, max) (((x) > (max)) ? (max) : (((x) < (min)) ? (min) : (x))) #endif -#define EVAS_FRAME_QUEUING 1 /* for test */ +#define EVAS_FRAME_QUEUING 1 /* for test */ #define READBUFSIZ 65536 @@ -100,23 +100,25 @@ EAPI void ecore_print_warning(const char *function, const char *sparam); #undef CHECK_PARAM_POINTER_RETURN #define CHECK_PARAM_POINTER_RETURN(sparam, param, ret) \ if (!(param)) \ - { \ - ecore_print_warning(__FUNCTION__, sparam); \ - return ret; \ - } + { \ + ecore_print_warning(__FUNCTION__, sparam); \ + return ret; \ + } #undef CHECK_PARAM_POINTER #define CHECK_PARAM_POINTER(sparam, param) \ if (!(param)) \ - { \ - ecore_print_warning(__FUNCTION__, sparam); \ - return; \ - } + { \ + ecore_print_warning(__FUNCTION__, sparam); \ + return; \ + } typedef unsigned int Ecore_Magic; EAPI void _ecore_magic_fail(const void *d, Ecore_Magic m, Ecore_Magic req_m, const char *fname); +void _ecore_time_init(void); + void _ecore_timer_shutdown(void); void _ecore_timer_cleanup(void); void _ecore_timer_enable_new(void); @@ -176,13 +178,6 @@ void _ecore_animator_shutdown(void); void _ecore_poller_shutdown(void); -EAPI void *_ecore_list2_append (void *in_list, void *in_item); -EAPI void *_ecore_list2_prepend (void *in_list, void *in_item); -EAPI void *_ecore_list2_append_relative (void *in_list, void *in_item, void *in_relative); -EAPI void *_ecore_list2_prepend_relative (void *in_list, void *in_item, void *in_relative); -EAPI void *_ecore_list2_remove (void *in_list, void *in_item); -EAPI void *_ecore_list2_find (void *in_list, void *in_item); - void _ecore_fps_debug_init(void); void _ecore_fps_debug_shutdown(void); void _ecore_fps_debug_runtime_add(double t); @@ -200,7 +195,7 @@ void _ecore_main_loop_init(void); void _ecore_main_loop_shutdown(void); extern int _ecore_fps_debug; -extern double _ecore_loop_time; +extern double _ecore_time_loop_time; extern Eina_Bool _ecore_glib_always_integrate; #endif diff --git a/src/lib/ecore/ecore_signal.c b/src/lib/ecore/ecore_signal.c index a07a3c1..f072c06 100644 --- a/src/lib/ecore/ecore_signal.c +++ b/src/lib/ecore/ecore_signal.c @@ -102,23 +102,23 @@ _ecore_signal_shutdown(void) #ifdef SIGRTMIN for (i = 0; i < num; i++) { - _ecore_signal_callback_set(SIGRTMIN + i, (Signal_Handler) SIG_DFL); - sigrt_count[i] = 0; + _ecore_signal_callback_set(SIGRTMIN + i, (Signal_Handler) SIG_DFL); + sigrt_count[i] = 0; } if (sigrt_count) { - free((sig_atomic_t *) sigrt_count); - sigrt_count = NULL; + free((sig_atomic_t *) sigrt_count); + sigrt_count = NULL; } for (i = 0; i < MAXSIGQ; i++) { - if (sigrt_info[i]) - { - free((siginfo_t *) sigrt_info[i]); - sigrt_info[i] = NULL; - } + if (sigrt_info[i]) + { + free((siginfo_t *) sigrt_info[i]); + sigrt_info[i] = NULL; + } } #endif } @@ -149,8 +149,8 @@ _ecore_signal_init(void) for (i = 0; i < MAXSIGQ; i++) { - sigrt_info[i] = calloc(1, sizeof(siginfo_t) * num); - assert(sigrt_info[i]); + sigrt_info[i] = calloc(1, sizeof(siginfo_t) * num); + assert(sigrt_info[i]); } for (i = 0; i < num; i++) @@ -194,220 +194,220 @@ _ecore_signal_call(void) sigprocmask(SIG_BLOCK, &newset, &oldset); if (sigchld_count > MAXSIGQ) WRN("%i SIGCHLD in queue. max queue size %i. losing " - "siginfo for extra signals.", sigchld_count, MAXSIGQ); + "siginfo for extra signals.", sigchld_count, MAXSIGQ); for (n = 0; n < sigchld_count; n++) { - pid_t pid; - int status; - - while ((pid = waitpid(-1, &status, WNOHANG)) > 0) - { - Ecore_Exe_Event_Del *e; - - /* FIXME: If this process is set respawn, respawn with a suitable backoff - * period for those that need too much respawning. - */ - e = _ecore_exe_event_del_new(); - if (e) - { - if (WIFEXITED(status)) - { - e->exit_code = WEXITSTATUS(status); - e->exited = 1; - } - else if (WIFSIGNALED(status)) - { - e->exit_signal = WTERMSIG(status); - e->signalled = 1; - } - e->pid = pid; - e->exe = _ecore_exe_find(pid); - - if ((n < MAXSIGQ) && (sigchld_info[n].si_signo)) - e->data = sigchld_info[n]; /* No need to clone this. */ + pid_t pid; + int status; + + while ((pid = waitpid(-1, &status, WNOHANG)) > 0) + { + Ecore_Exe_Event_Del *e; + + /* FIXME: If this process is set respawn, respawn with a suitable backoff + * period for those that need too much respawning. + */ + e = _ecore_exe_event_del_new(); + if (e) + { + if (WIFEXITED(status)) + { + e->exit_code = WEXITSTATUS(status); + e->exited = 1; + } + else if (WIFSIGNALED(status)) + { + e->exit_signal = WTERMSIG(status); + e->signalled = 1; + } + e->pid = pid; + e->exe = _ecore_exe_find(pid); + + if ((n < MAXSIGQ) && (sigchld_info[n].si_signo)) + e->data = sigchld_info[n]; /* No need to clone this. */ if ((e->exe) && (ecore_exe_flags_get(e->exe) & (ECORE_EXE_PIPE_READ | ECORE_EXE_PIPE_ERROR))) { - /* We want to report the Last Words of the exe, so delay this event. - * This is twice as relevant for stderr. - * There are three possibilities here - - * 1 There are no Last Words. - * 2 There are Last Words, they are not ready to be read. - * 3 There are Last Words, they are ready to be read. - * - * For 1 we don't want to delay, for 3 we want to delay. - * 2 is the problem. If we check for data now and there - * is none, then there is no way to differentiate 1 and 2. - * If we don't delay, we may loose data, but if we do delay, - * there may not be data and the exit event never gets sent. - * - * Any way you look at it, there has to be some time passed - * before the exit event gets sent. So the strategy here is - * to setup a timer event that will send the exit event after - * an arbitrary, but brief, time. - * - * This is probably paranoid, for the less paraniod, we could - * check to see for Last Words, and only delay if there are any. - * This has it's own set of problems. - */ + /* We want to report the Last Words of the exe, so delay this event. + * This is twice as relevant for stderr. + * There are three possibilities here - + * 1 There are no Last Words. + * 2 There are Last Words, they are not ready to be read. + * 3 There are Last Words, they are ready to be read. + * + * For 1 we don't want to delay, for 3 we want to delay. + * 2 is the problem. If we check for data now and there + * is none, then there is no way to differentiate 1 and 2. + * If we don't delay, we may loose data, but if we do delay, + * there may not be data and the exit event never gets sent. + * + * Any way you look at it, there has to be some time passed + * before the exit event gets sent. So the strategy here is + * to setup a timer event that will send the exit event after + * an arbitrary, but brief, time. + * + * This is probably paranoid, for the less paraniod, we could + * check to see for Last Words, and only delay if there are any. + * This has it's own set of problems. + */ Ecore_Timer *doomsday_clock; doomsday_clock = _ecore_exe_doomsday_clock_get(e->exe); IF_FN_DEL(ecore_timer_del, doomsday_clock); _ecore_exe_doomsday_clock_set(e->exe, ecore_timer_add(0.1, _ecore_signal_exe_exit_delay, e)); } - else - { - _ecore_event_add(ECORE_EXE_EVENT_DEL, e, - _ecore_exe_event_del_free, NULL); - } - } - } - sig_count--; + else + { + _ecore_event_add(ECORE_EXE_EVENT_DEL, e, + _ecore_exe_event_del_free, NULL); + } + } + } + sig_count--; } sigchld_count = 0; if (sigusr1_count > MAXSIGQ) WRN("%i SIGUSR1 in queue. max queue size %i. losing " - "siginfo for extra signals.", sigusr1_count, MAXSIGQ); + "siginfo for extra signals.", sigusr1_count, MAXSIGQ); for (n = 0; n < sigusr1_count; n++) { - Ecore_Event_Signal_User *e; + Ecore_Event_Signal_User *e; - e = _ecore_event_signal_user_new(); - if (e) - { - e->number = 1; + e = _ecore_event_signal_user_new(); + if (e) + { + e->number = 1; - if ((n < MAXSIGQ) && (sigusr1_info[n].si_signo)) - e->data = sigusr1_info[n]; + if ((n < MAXSIGQ) && (sigusr1_info[n].si_signo)) + e->data = sigusr1_info[n]; - ecore_event_add(ECORE_EVENT_SIGNAL_USER, e, NULL, NULL); - } - sig_count--; + ecore_event_add(ECORE_EVENT_SIGNAL_USER, e, NULL, NULL); + } + sig_count--; } sigusr1_count = 0; if (sigusr2_count > MAXSIGQ) WRN("%i SIGUSR2 in queue. max queue size %i. losing " - "siginfo for extra signals.", sigusr2_count, MAXSIGQ); + "siginfo for extra signals.", sigusr2_count, MAXSIGQ); for (n = 0; n < sigusr2_count; n++) { - Ecore_Event_Signal_User *e; + Ecore_Event_Signal_User *e; - e = _ecore_event_signal_user_new(); - if (e) - { - e->number = 2; + e = _ecore_event_signal_user_new(); + if (e) + { + e->number = 2; - if ((n < MAXSIGQ) && (sigusr2_info[n].si_signo)) - e->data = sigusr2_info[n]; + if ((n < MAXSIGQ) && (sigusr2_info[n].si_signo)) + e->data = sigusr2_info[n]; - ecore_event_add(ECORE_EVENT_SIGNAL_USER, e, NULL, NULL); - } - sig_count--; + ecore_event_add(ECORE_EVENT_SIGNAL_USER, e, NULL, NULL); + } + sig_count--; } sigusr2_count = 0; if (sighup_count > MAXSIGQ) WRN("%i SIGHUP in queue. max queue size %i. losing " - "siginfo for extra signals.", sighup_count, MAXSIGQ); + "siginfo for extra signals.", sighup_count, MAXSIGQ); for (n = 0; n < sighup_count; n++) { - Ecore_Event_Signal_Hup *e; + Ecore_Event_Signal_Hup *e; - e = _ecore_event_signal_hup_new(); - if (e) - { - if ((n < MAXSIGQ) && (sighup_info[n].si_signo)) - e->data = sighup_info[n]; + e = _ecore_event_signal_hup_new(); + if (e) + { + if ((n < MAXSIGQ) && (sighup_info[n].si_signo)) + e->data = sighup_info[n]; - ecore_event_add(ECORE_EVENT_SIGNAL_HUP, e, NULL, NULL); - } - sig_count--; + ecore_event_add(ECORE_EVENT_SIGNAL_HUP, e, NULL, NULL); + } + sig_count--; } sighup_count = 0; if (sigquit_count > MAXSIGQ) WRN("%i SIGQUIT in queue. max queue size %i. losing " - "siginfo for extra signals.", sigquit_count, MAXSIGQ); + "siginfo for extra signals.", sigquit_count, MAXSIGQ); for (n = 0; n < sigquit_count; n++) { - Ecore_Event_Signal_Exit *e; + Ecore_Event_Signal_Exit *e; - e = _ecore_event_signal_exit_new(); - if (e) - { - e->quit = 1; + e = _ecore_event_signal_exit_new(); + if (e) + { + e->quit = 1; - if ((n < MAXSIGQ) && (sigquit_info[n].si_signo)) - e->data = sigquit_info[n]; + if ((n < MAXSIGQ) && (sigquit_info[n].si_signo)) + e->data = sigquit_info[n]; - ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL, NULL); - } - sig_count--; + ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL, NULL); + } + sig_count--; } sigquit_count = 0; if (sigint_count > MAXSIGQ) WRN("%i SIGINT in queue. max queue size %i. losing " - "siginfo for extra signals.", sigint_count, MAXSIGQ); + "siginfo for extra signals.", sigint_count, MAXSIGQ); for (n = 0; n < sigint_count; n++) { - Ecore_Event_Signal_Exit *e; + Ecore_Event_Signal_Exit *e; - e = _ecore_event_signal_exit_new(); - if (e) - { - e->interrupt = 1; + e = _ecore_event_signal_exit_new(); + if (e) + { + e->interrupt = 1; - if ((n < MAXSIGQ) && (sigint_info[n].si_signo)) - e->data = sigint_info[n]; + if ((n < MAXSIGQ) && (sigint_info[n].si_signo)) + e->data = sigint_info[n]; - ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL, NULL); - } - sig_count--; + ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL, NULL); + } + sig_count--; } sigint_count = 0; if (sigterm_count > MAXSIGQ) WRN("%i SIGTERM in queue. max queue size %i. losing " - "siginfo for extra signals.", sigterm_count, MAXSIGQ); + "siginfo for extra signals.", sigterm_count, MAXSIGQ); for (n = 0; n < sigterm_count; n++) { - Ecore_Event_Signal_Exit *e; + Ecore_Event_Signal_Exit *e; - e = _ecore_event_signal_exit_new(); - if (e) - { - e->terminate = 1; + e = _ecore_event_signal_exit_new(); + if (e) + { + e->terminate = 1; - if ((n < MAXSIGQ) && (sigterm_info[n].si_signo)) - e->data = sigterm_info[n]; + if ((n < MAXSIGQ) && (sigterm_info[n].si_signo)) + e->data = sigterm_info[n]; - ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL, NULL); - } - sig_count--; + ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, e, NULL, NULL); + } + sig_count--; } sigterm_count = 0; #ifdef SIGPWR if (sigpwr_count > MAXSIGQ) WRN("%i SIGPWR in queue. max queue size %i. losing " - "siginfo for extra signals.", sigpwr_count, MAXSIGQ); + "siginfo for extra signals.", sigpwr_count, MAXSIGQ); for (n = 0; n < sigpwr_count; n++) { - Ecore_Event_Signal_Power *e; + Ecore_Event_Signal_Power *e; - e = _ecore_event_signal_power_new(); - if (e) - { - if ((n < MAXSIGQ) && (sigpwr_info[n].si_signo)) - e->data = sigpwr_info[n]; + e = _ecore_event_signal_power_new(); + if (e) + { + if ((n < MAXSIGQ) && (sigpwr_info[n].si_signo)) + e->data = sigpwr_info[n]; - ecore_event_add(ECORE_EVENT_SIGNAL_POWER, e, NULL, NULL); - } - sig_count--; + ecore_event_add(ECORE_EVENT_SIGNAL_POWER, e, NULL, NULL); + } + sig_count--; } sigpwr_count = 0; #endif @@ -415,25 +415,25 @@ _ecore_signal_call(void) #ifdef SIGRTMIN for (i = 0; i < num; i++) { - if (sigrt_count[i] > MAXSIGQ) - WRN("%i SIGRT%i in queue. max queue size %i. losing " - "siginfo for extra signals.", i + 1, sigrt_count[i], MAXSIGQ); - for (n = 0; n < sigrt_count[i]; n++) - { - Ecore_Event_Signal_Realtime *e; - - if ((e = _ecore_event_signal_realtime_new())) - { - e->num = i; - - if ((n < MAXSIGQ) && (sigrt_info[n][i].si_signo)) - e->data = sigrt_info[n][i]; - - ecore_event_add(ECORE_EVENT_SIGNAL_REALTIME, e, NULL, NULL); - } - sig_count--; - } - sigrt_count[i] = 0; + if (sigrt_count[i] > MAXSIGQ) + WRN("%i SIGRT%i in queue. max queue size %i. losing " + "siginfo for extra signals.", i + 1, sigrt_count[i], MAXSIGQ); + for (n = 0; n < sigrt_count[i]; n++) + { + Ecore_Event_Signal_Realtime *e; + + if ((e = _ecore_event_signal_realtime_new())) + { + e->num = i; + + if ((n < MAXSIGQ) && (sigrt_info[n][i].si_signo)) + e->data = sigrt_info[n][i]; + + ecore_event_add(ECORE_EVENT_SIGNAL_REALTIME, e, NULL, NULL); + } + sig_count--; + } + sigrt_count[i] = 0; } #endif sigprocmask(SIG_SETMASK, &oldset, NULL); @@ -462,10 +462,10 @@ _ecore_signal_callback_sigchld(int sig __UNUSED__, siginfo_t *si, void *foo __UN n = sigchld_count; if (n < MAXSIGQ) { - if (si) - sigchld_info[n] = *si; - else - sigchld_info[n].si_signo = 0; + if (si) + sigchld_info[n] = *si; + else + sigchld_info[n].si_signo = 0; } sigchld_count++; @@ -476,13 +476,13 @@ static void _ecore_signal_callback_sigusr1(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__) { volatile sig_atomic_t n; - n = sigchld_count; + n = sigusr1_count; if (n < MAXSIGQ) { - if (si) - sigusr1_info[n] = *si; - else - sigusr1_info[n].si_signo = 0; + if (si) + sigusr1_info[n] = *si; + else + sigusr1_info[n].si_signo = 0; } sigusr1_count++; sig_count++; @@ -492,13 +492,13 @@ static void _ecore_signal_callback_sigusr2(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__) { volatile sig_atomic_t n; - n = sigchld_count; + n = sigusr2_count; if (n < MAXSIGQ) { - if (si) - sigusr2_info[n] = *si; - else - sigusr2_info[n].si_signo = 0; + if (si) + sigusr2_info[n] = *si; + else + sigusr2_info[n].si_signo = 0; } sigusr2_count++; sig_count++; @@ -508,13 +508,13 @@ static void _ecore_signal_callback_sighup(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__) { volatile sig_atomic_t n; - n = sigchld_count; + n = sighup_count; if (n < MAXSIGQ) { - if (si) - sighup_info[n] = *si; - else - sighup_info[n].si_signo = 0; + if (si) + sighup_info[n] = *si; + else + sighup_info[n].si_signo = 0; } sighup_count++; sig_count++; @@ -524,13 +524,13 @@ static void _ecore_signal_callback_sigquit(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__) { volatile sig_atomic_t n; - n = sigchld_count; + n = sigquit_count; if (n < MAXSIGQ) { - if (si) - sigquit_info[n] = *si; - else - sigquit_info[n].si_signo = 0; + if (si) + sigquit_info[n] = *si; + else + sigquit_info[n].si_signo = 0; } sigquit_count++; sig_count++; @@ -540,13 +540,13 @@ static void _ecore_signal_callback_sigint(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__) { volatile sig_atomic_t n; - n = sigchld_count; + n = sigint_count; if (n < MAXSIGQ) { - if (si) - sigint_info[n] = *si; - else - sigint_info[n].si_signo = 0; + if (si) + sigint_info[n] = *si; + else + sigint_info[n].si_signo = 0; } sigint_count++; sig_count++; @@ -556,13 +556,13 @@ static void _ecore_signal_callback_sigterm(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__) { volatile sig_atomic_t n; - n = sigchld_count; + n = sigterm_count; if (n < MAXSIGQ) { - if (si) - sigterm_info[n] = *si; - else - sigterm_info[n].si_signo = 0; + if (si) + sigterm_info[n] = *si; + else + sigterm_info[n].si_signo = 0; } sigterm_count++; sig_count++; @@ -573,13 +573,13 @@ static void _ecore_signal_callback_sigpwr(int sig __UNUSED__, siginfo_t *si, void *foo __UNUSED__) { volatile sig_atomic_t n; - n = sigchld_count; + n = sigpwr_count; if (n < MAXSIGQ) { - if (si) - sigpwr_info[n] = *si; - else - sigpwr_info[n].si_signo = 0; + if (si) + sigpwr_info[n] = *si; + else + sigpwr_info[n].si_signo = 0; } sigpwr_count++; sig_count++; @@ -591,13 +591,13 @@ static void _ecore_signal_callback_sigrt(int sig, siginfo_t *si, void *foo __UNUSED__) { volatile sig_atomic_t n; - n = sigchld_count; + n = sigrt_count[sig - SIGRTMIN]; if (n < MAXSIGQ) { - if (si) - sigrt_info[n][sig - SIGRTMIN] = *si; - else - sigrt_info[n][sig - SIGRTMIN].si_signo = 0; + if (si) + sigrt_info[n][sig - SIGRTMIN] = *si; + else + sigrt_info[n][sig - SIGRTMIN].si_signo = 0; } sigrt_count[sig - SIGRTMIN]++; sig_count++; @@ -612,9 +612,9 @@ _ecore_signal_exe_exit_delay(void *data) e = data; if (e) { - _ecore_exe_doomsday_clock_set(e->exe, NULL); - _ecore_event_add(ECORE_EXE_EVENT_DEL, e, - _ecore_exe_event_del_free, NULL); + _ecore_exe_doomsday_clock_set(e->exe, NULL); + _ecore_event_add(ECORE_EXE_EVENT_DEL, e, + _ecore_exe_event_del_free, NULL); } return ECORE_CALLBACK_CANCEL; } diff --git a/src/lib/ecore/ecore_thread.c b/src/lib/ecore/ecore_thread.c index bfc8af7..6793d17 100644 --- a/src/lib/ecore/ecore_thread.c +++ b/src/lib/ecore/ecore_thread.c @@ -8,6 +8,14 @@ #ifdef EFL_HAVE_PTHREAD # include +# ifdef __linux__ +# include +# include +# include +# include +# include +# include +# endif #endif #include "Ecore.h" @@ -25,30 +33,34 @@ struct _Ecore_Thread_Data struct _Ecore_Pthread_Worker { - union { - struct { - Ecore_Cb func_blocking; - } short_run; - struct { - Ecore_Thread_Heavy_Cb func_heavy; - Ecore_Thread_Notify_Cb func_notify; - Ecore_Pipe *notify; - } long_run; - } u; - - Ecore_Cb func_cancel; - Ecore_Cb func_end; -#ifdef EFL_HAVE_PTHREAD - pthread_t self; - Eina_Hash *hash; - pthread_cond_t cond; - pthread_mutex_t mutex; -#endif - - const void *data; - - Eina_Bool cancel : 1; - Eina_Bool long_run : 1; + union { + struct { + Ecore_Thread_Heavy_Cb func_blocking; + } short_run; + struct { + Ecore_Thread_Heavy_Cb func_heavy; + Ecore_Thread_Notify_Cb func_notify; + Ecore_Pipe *notify; + + int send; + int received; + } feedback_run; + } u; + + Ecore_Cb func_cancel; + Ecore_Cb func_end; +#ifdef EFL_HAVE_PTHREAD + pthread_t self; + Eina_Hash *hash; + pthread_cond_t cond; + pthread_mutex_t mutex; +#endif + + const void *data; + + Eina_Bool cancel : 1; + Eina_Bool feedback_run : 1; + Eina_Bool kill : 1; }; #ifdef EFL_HAVE_PTHREAD @@ -70,7 +82,7 @@ static int _ecore_thread_count = 0; static Eina_List *_ecore_active_job_threads = NULL; static Eina_List *_ecore_pending_job_threads = NULL; -static Eina_List *_ecore_pending_job_threads_long = NULL; +static Eina_List *_ecore_pending_job_threads_feedback = NULL; static Ecore_Event_Handler *del_handler = NULL; static pthread_mutex_t _ecore_pending_job_threads_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -96,6 +108,7 @@ _ecore_thread_pipe_free(void *data __UNUSED__, void *event) Ecore_Pipe *p = event; ecore_pipe_del(p); + eina_threads_shutdown(); } static Eina_Bool @@ -120,14 +133,8 @@ _ecore_thread_end(Ecore_Pthread_Data *pth) } static void -_ecore_thread_handler(void *data __UNUSED__, void *buffer, unsigned int nbyte) +_ecore_thread_kill(Ecore_Pthread_Worker *work) { - Ecore_Pthread_Worker *work; - - if (nbyte != sizeof (Ecore_Pthread_Worker *)) return ; - - work = *(Ecore_Pthread_Worker **)buffer; - if (work->cancel) { if (work->func_cancel) @@ -139,8 +146,8 @@ _ecore_thread_handler(void *data __UNUSED__, void *buffer, unsigned int nbyte) work->func_end((void *) work->data); } - if (work->long_run) - ecore_pipe_del(work->u.long_run.notify); + if (work->feedback_run) + ecore_pipe_del(work->u.feedback_run.notify); pthread_cond_destroy(&work->cond); pthread_mutex_destroy(&work->mutex); if (work->hash) @@ -149,6 +156,27 @@ _ecore_thread_handler(void *data __UNUSED__, void *buffer, unsigned int nbyte) } static void +_ecore_thread_handler(void *data __UNUSED__, void *buffer, unsigned int nbyte) +{ + Ecore_Pthread_Worker *work; + + if (nbyte != sizeof (Ecore_Pthread_Worker *)) return ; + + work = *(Ecore_Pthread_Worker **)buffer; + + if (work->feedback_run) + { + if (work->u.feedback_run.send != work->u.feedback_run.received) + { + work->kill = EINA_TRUE; + return ; + } + } + + _ecore_thread_kill(work); +} + +static void _ecore_notify_handler(void *data, void *buffer, unsigned int nbyte) { Ecore_Pthread_Worker *work = data; @@ -157,9 +185,16 @@ _ecore_notify_handler(void *data, void *buffer, unsigned int nbyte) if (nbyte != sizeof (Ecore_Pthread_Worker *)) return ; user_data = *(void **)buffer; + work->u.feedback_run.received++; + + if (work->u.feedback_run.func_notify) + work->u.feedback_run.func_notify((Ecore_Thread *) work, user_data, (void *) work->data); - if (work->u.long_run.func_notify) - work->u.long_run.func_notify((Ecore_Thread *) work, user_data, (void *) work->data); + /* Force reading all notify event before killing the thread */ + if (work->kill && work->u.feedback_run.send == work->u.feedback_run.received) + { + _ecore_thread_kill(work); + } } static void @@ -178,40 +213,42 @@ _ecore_short_job(Ecore_Pipe *end_pipe) } work = eina_list_data_get(_ecore_pending_job_threads); - _ecore_pending_job_threads = eina_list_remove_list(_ecore_pending_job_threads, _ecore_pending_job_threads); + _ecore_pending_job_threads = eina_list_remove_list(_ecore_pending_job_threads, + _ecore_pending_job_threads); pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); - if (!work->cancel) - work->u.short_run.func_blocking((void *) work->data); + if (!work->cancel) + work->u.short_run.func_blocking((Ecore_Thread*) work, (void *) work->data); ecore_pipe_write(end_pipe, &work, sizeof (Ecore_Pthread_Worker *)); } } static void -_ecore_long_job(Ecore_Pipe *end_pipe, pthread_t thread) +_ecore_feedback_job(Ecore_Pipe *end_pipe, pthread_t thread) { Ecore_Pthread_Worker *work; - while (_ecore_pending_job_threads_long) + while (_ecore_pending_job_threads_feedback) { pthread_mutex_lock(&_ecore_pending_job_threads_mutex); - if (!_ecore_pending_job_threads_long) + if (!_ecore_pending_job_threads_feedback) { pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); break; } - work = eina_list_data_get(_ecore_pending_job_threads_long); - _ecore_pending_job_threads_long = eina_list_remove_list(_ecore_pending_job_threads_long, _ecore_pending_job_threads_long); + work = eina_list_data_get(_ecore_pending_job_threads_feedback); + _ecore_pending_job_threads_feedback = eina_list_remove_list(_ecore_pending_job_threads_feedback, + _ecore_pending_job_threads_feedback); pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); work->self = thread; - if (!work->cancel) - work->u.long_run.func_heavy((Ecore_Thread *) work, (void *) work->data); + if (!work->cancel) + work->u.feedback_run.func_heavy((Ecore_Thread *) work, (void *) work->data); ecore_pipe_write(end_pipe, &work, sizeof (Ecore_Pthread_Worker *)); } @@ -224,6 +261,7 @@ _ecore_direct_worker(Ecore_Pthread_Worker *work) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + eina_sched_prio_drop(); pth = malloc(sizeof (Ecore_Pthread_Data)); if (!pth) return NULL; @@ -237,7 +275,7 @@ _ecore_direct_worker(Ecore_Pthread_Worker *work) pth->thread = pthread_self(); work->self = pth->thread; - work->u.long_run.func_heavy((Ecore_Thread *) work, (void *) work->data); + work->u.feedback_run.func_heavy((Ecore_Thread *) work, (void *) work->data); ecore_pipe_write(pth->p, &work, sizeof (Ecore_Pthread_Worker *)); @@ -254,7 +292,8 @@ _ecore_direct_worker(Ecore_Pthread_Worker *work) work->func_end = (void *) _ecore_thread_end; work->func_cancel = NULL; work->cancel = EINA_FALSE; - work->long_run = EINA_FALSE; + work->feedback_run = EINA_FALSE; + work->kill = EINA_FALSE; work->hash = NULL; pthread_cond_init(&work->cond, NULL); pthread_mutex_init(&work->mutex, NULL); @@ -271,31 +310,46 @@ _ecore_thread_worker(Ecore_Pthread_Data *pth) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL); pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); + eina_sched_prio_drop(); pthread_mutex_lock(&_ecore_pending_job_threads_mutex); _ecore_thread_count++; pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); - on_error: + restart: if (_ecore_pending_job_threads) _ecore_short_job(pth->p); - if (_ecore_pending_job_threads_long) _ecore_long_job(pth->p, pth->thread); + if (_ecore_pending_job_threads_feedback) _ecore_feedback_job(pth->p, pth->thread); - /* FIXME: Check if there is long running task todo, and switch to long run handler. */ + /* FIXME: Check if there is feedback running task todo, and switch to feedback run handler. */ pthread_mutex_lock(&_ecore_pending_job_threads_mutex); if (_ecore_pending_job_threads) { pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); - goto on_error; + goto restart; } - if (_ecore_pending_job_threads_long) + if (_ecore_pending_job_threads_feedback) { pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); - goto on_error; + goto restart; } + pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); - _ecore_thread_count--; + /* Sleep a little to prevent premature death */ + usleep(200); + pthread_mutex_lock(&_ecore_pending_job_threads_mutex); + if (_ecore_pending_job_threads) + { + pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); + goto restart; + } + if (_ecore_pending_job_threads_feedback) + { + pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); + goto restart; + } + _ecore_thread_count--; pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); work = malloc(sizeof (Ecore_Pthread_Worker)); @@ -306,7 +360,8 @@ _ecore_thread_worker(Ecore_Pthread_Data *pth) work->func_end = (void *) _ecore_thread_end; work->func_cancel = NULL; work->cancel = EINA_FALSE; - work->long_run = EINA_FALSE; + work->feedback_run = EINA_FALSE; + work->kill = EINA_FALSE; work->hash = NULL; pthread_cond_init(&work->cond, NULL); pthread_mutex_init(&work->mutex, NULL); @@ -350,6 +405,13 @@ _ecore_thread_shutdown(void) free(work); } + EINA_LIST_FREE(_ecore_pending_job_threads_feedback, work) + { + if (work->func_cancel) + work->func_cancel((void *)work->data); + free(work); + } + pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); EINA_LIST_FREE(_ecore_active_job_threads, pth) @@ -368,14 +430,23 @@ _ecore_thread_shutdown(void) del_handler = NULL; #endif } + +/** + * @addtogroup Ecore_Group Ecore - Main Loop and Job Functions. + * + * @{ + */ + /** - * @addtogroup Ecore_Thread Ecore Thread Functions + * @addtogroup Ecore_Thread_Group Ecore Thread functions + * * These functions allow for ecore-managed threads which integrate with ecore's main loop. + * * @{ */ /** - * @brief Run some blocking code in a parrallel thread to avoid locking the main loop. + * @brief Run some blocking code in a parallel thread to avoid locking the main loop. * @param func_blocking The function that should run in another thread. * @param func_end The function that will be called in the main loop if the thread terminate correctly. * @param func_cancel The function that will be called in the main loop if the thread is cancelled. @@ -385,7 +456,7 @@ _ecore_thread_shutdown(void) * ecore_thread_run provide a facility for easily managing blocking task in a * parallel thread. You should provide three function. The first one, func_blocking, * that will do the blocking work in another thread (so you should not use the - * EFL in it except Eina if you are carefull). The second one, func_end, + * EFL in it except Eina if you are careful). The second one, func_end, * that will be called in Ecore main loop when func_blocking is done. So you * can use all the EFL inside this function. The last one, func_cancel, will * be called in the main loop if the thread is cancelled or could not run at all. @@ -395,34 +466,39 @@ _ecore_thread_shutdown(void) * host CPU can handle. */ EAPI Ecore_Thread * -ecore_thread_run(Ecore_Cb func_blocking, +ecore_thread_run(Ecore_Thread_Heavy_Cb func_blocking, Ecore_Cb func_end, Ecore_Cb func_cancel, const void *data) { -#ifdef EFL_HAVE_PTHREAD Ecore_Pthread_Worker *work; +#ifdef EFL_HAVE_PTHREAD Ecore_Pthread_Data *pth = NULL; +#endif if (!func_blocking) return NULL; work = malloc(sizeof (Ecore_Pthread_Worker)); if (!work) { - func_cancel((void *) data); + if (func_cancel) + func_cancel((void *) data); return NULL; } work->u.short_run.func_blocking = func_blocking; - work->hash = NULL; - pthread_cond_init(&work->cond, NULL); - pthread_mutex_init(&work->mutex, NULL); work->func_end = func_end; work->func_cancel = func_cancel; work->cancel = EINA_FALSE; - work->long_run = EINA_FALSE; + work->feedback_run = EINA_FALSE; + work->kill = EINA_FALSE; work->data = data; +#ifdef EFL_HAVE_PTHREAD + work->hash = NULL; + pthread_cond_init(&work->cond, NULL); + pthread_mutex_init(&work->mutex, NULL); + pthread_mutex_lock(&_ecore_pending_job_threads_mutex); _ecore_pending_job_threads = eina_list_append(_ecore_pending_job_threads, work); @@ -441,18 +517,27 @@ ecore_thread_run(Ecore_Cb func_blocking, pth->p = ecore_pipe_add(_ecore_thread_handler, NULL); if (!pth->p) goto on_error; + eina_threads_init(); + if (pthread_create(&pth->thread, NULL, (void *) _ecore_thread_worker, pth) == 0) - return (Ecore_Thread *) work; + return (Ecore_Thread *) work; + + eina_threads_shutdown(); on_error: if (pth) { if (pth->p) ecore_pipe_del(pth->p); + pth->p = NULL; free(pth); } if (_ecore_thread_count == 0) { + pthread_mutex_lock(&_ecore_pending_job_threads_mutex); + _ecore_pending_job_threads = eina_list_remove(_ecore_pending_job_threads, work); + pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); + if (work->func_cancel) work->func_cancel((void *) work->data); free(work); @@ -464,7 +549,7 @@ ecore_thread_run(Ecore_Cb func_blocking, If no thread and as we don't want to break app that rely on this facility, we will lock the interface until we are done. */ - func_blocking((void *)data); + func_blocking((Ecore_Thread *) work, (void *)data); func_end((void *)data); return NULL; @@ -481,7 +566,9 @@ ecore_thread_run(Ecore_Cb func_blocking, * will return EINA_FALSE, if the destruction is delayed or EINA_TRUE if it is * cancelled after this call. * - * You should use this function only in the main loop. + * This function work in the main loop and in the thread, but you should not pass + * the Ecore_Thread variable from main loop to the worker thread in any structure. + * You should always use the one passed to the Ecore_Thread_Heavy_Cb. * * func_end, func_cancel will destroy the handler, so don't use it after. * And if ecore_thread_cancel return EINA_TRUE, you should not use Ecore_Thread also. @@ -490,37 +577,65 @@ EAPI Eina_Bool ecore_thread_cancel(Ecore_Thread *thread) { #ifdef EFL_HAVE_PTHREAD - Ecore_Pthread_Worker *work = (Ecore_Pthread_Worker *) thread; + Ecore_Pthread_Worker *work = (Ecore_Pthread_Worker *)thread; Eina_List *l; if (!work) - return EINA_TRUE; + return EINA_TRUE; + if (work->cancel) + return EINA_FALSE; + + if (work->feedback_run) + { + if (work->kill) + return EINA_TRUE; + if (work->u.feedback_run.send != work->u.feedback_run.received) + goto on_exit; + } pthread_mutex_lock(&_ecore_pending_job_threads_mutex); - if ((have_main_loop_thread) && - (pthread_equal(main_loop_thread, pthread_self()))) - { - EINA_LIST_FOREACH(_ecore_pending_job_threads, l, work) - { - if ((void *) work == (void *) thread) - { - _ecore_pending_job_threads = eina_list_remove_list(_ecore_pending_job_threads, l); - - pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); - - if (work->func_cancel) - work->func_cancel((void *) work->data); - free(work); - - return EINA_TRUE; - } - } - } - + if ((have_main_loop_thread) && + (pthread_equal(main_loop_thread, pthread_self()))) + { + if (!work->feedback_run) + EINA_LIST_FOREACH(_ecore_pending_job_threads, l, work) + { + if ((void *) work == (void *) thread) + { + _ecore_pending_job_threads = eina_list_remove_list(_ecore_pending_job_threads, l); + + pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); + + if (work->func_cancel) + work->func_cancel((void *) work->data); + free(work); + + return EINA_TRUE; + } + } + else + EINA_LIST_FOREACH(_ecore_pending_job_threads_feedback, l, work) + { + if ((void *) work == (void *) thread) + { + _ecore_pending_job_threads_feedback = eina_list_remove_list(_ecore_pending_job_threads_feedback, l); + + pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); + + if (work->func_cancel) + work->func_cancel((void *) work->data); + free(work); + + return EINA_TRUE; + } + } + } + pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); /* Delay the destruction */ + on_exit: ((Ecore_Pthread_Worker *)thread)->cancel = EINA_TRUE; return EINA_FALSE; #else @@ -546,7 +661,7 @@ ecore_thread_check(Ecore_Thread *thread) } /** - * @brief Run some heavy code in a parrallel thread to avoid locking the main loop. + * @brief Run some heavy code in a parallel thread to avoid locking the main loop. * @param func_heavy The function that should run in another thread. * @param func_notify The function that will receive the data send by func_heavy in the main loop. * @param func_end The function that will be called in the main loop if the thread terminate correctly. @@ -555,10 +670,10 @@ ecore_thread_check(Ecore_Thread *thread) * @param try_no_queue If you wan't to run outside of the thread pool. * @return A reference to the newly created thread instance, or NULL if it failed. * - * ecore_long_run provide a facility for easily managing heavy task in a + * ecore_thread_feedback_run provide a facility for easily managing heavy task in a * parallel thread. You should provide four functions. The first one, func_heavy, * that will do the heavy work in another thread (so you should not use the - * EFL in it except Eina and Eet if you are carefull). The second one, func_notify, + * EFL in it except Eina and Eet if you are careful). The second one, func_notify, * will receive the data send from the thread function (func_heavy) by ecore_thread_notify * in the main loop (and so, can use all the EFL). Tje third, func_end, * that will be called in Ecore main loop when func_heavy is done. So you @@ -566,19 +681,19 @@ ecore_thread_check(Ecore_Thread *thread) * be called in the main loop also, if the thread is cancelled or could not run at all. * * Be aware, that you can't make assumption on the result order of func_end - * after many call to ecore_long_run, as we start as much thread as the + * after many call to ecore_feedback_run, as we start as much thread as the * host CPU can handle. * * If you set try_no_queue, it will try to run outside of the thread pool, this can bring - * the CPU down, so be carefull with that. Of course if it can't start a new thread, it will + * the CPU down, so be careful with that. Of course if it can't start a new thread, it will * try to use one from the pool. */ -EAPI Ecore_Thread *ecore_long_run(Ecore_Thread_Heavy_Cb func_heavy, - Ecore_Thread_Notify_Cb func_notify, - Ecore_Cb func_end, - Ecore_Cb func_cancel, - const void *data, - Eina_Bool try_no_queue) +EAPI Ecore_Thread *ecore_thread_feedback_run(Ecore_Thread_Heavy_Cb func_heavy, + Ecore_Thread_Notify_Cb func_notify, + Ecore_Cb func_end, + Ecore_Cb func_cancel, + const void *data, + Eina_Bool try_no_queue) { #ifdef EFL_HAVE_PTHREAD @@ -590,8 +705,8 @@ EAPI Ecore_Thread *ecore_long_run(Ecore_Thread_Heavy_Cb func_heavy, worker = malloc(sizeof (Ecore_Pthread_Worker)); if (!worker) goto on_error; - worker->u.long_run.func_heavy = func_heavy; - worker->u.long_run.func_notify = func_notify; + worker->u.feedback_run.func_heavy = func_heavy; + worker->u.feedback_run.func_notify = func_notify; worker->hash = NULL; pthread_cond_init(&worker->cond, NULL); pthread_mutex_init(&worker->mutex, NULL); @@ -599,20 +714,23 @@ EAPI Ecore_Thread *ecore_long_run(Ecore_Thread_Heavy_Cb func_heavy, worker->func_end = func_end; worker->data = data; worker->cancel = EINA_FALSE; - worker->long_run = EINA_TRUE; + worker->feedback_run = EINA_TRUE; + worker->kill = EINA_FALSE; + worker->u.feedback_run.send = 0; + worker->u.feedback_run.received = 0; - worker->u.long_run.notify = ecore_pipe_add(_ecore_notify_handler, worker); + worker->u.feedback_run.notify = ecore_pipe_add(_ecore_notify_handler, worker); if (!try_no_queue) { pthread_t t; if (pthread_create(&t, NULL, (void *) _ecore_direct_worker, worker) == 0) - return (Ecore_Thread *) worker; + return (Ecore_Thread *) worker; } pthread_mutex_lock(&_ecore_pending_job_threads_mutex); - _ecore_pending_job_threads_long = eina_list_append(_ecore_pending_job_threads_long, worker); + _ecore_pending_job_threads_feedback = eina_list_append(_ecore_pending_job_threads_feedback, worker); if (_ecore_thread_count == _ecore_thread_count_max) { @@ -629,8 +747,12 @@ EAPI Ecore_Thread *ecore_long_run(Ecore_Thread_Heavy_Cb func_heavy, pth->p = ecore_pipe_add(_ecore_thread_handler, NULL); if (!pth->p) goto on_error; + eina_threads_init(); + if (pthread_create(&pth->thread, NULL, (void *) _ecore_thread_worker, pth) == 0) - return (Ecore_Thread *) worker; + return (Ecore_Thread *) worker; + + eina_threads_shutdown(); on_error: if (pth) @@ -641,11 +763,16 @@ EAPI Ecore_Thread *ecore_long_run(Ecore_Thread_Heavy_Cb func_heavy, if (_ecore_thread_count == 0) { + pthread_mutex_lock(&_ecore_pending_job_threads_mutex); + _ecore_pending_job_threads_feedback = eina_list_remove(_ecore_pending_job_threads_feedback, + worker); + pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); + if (func_cancel) func_cancel((void *) data); if (worker) { - ecore_pipe_del(worker->u.long_run.notify); + ecore_pipe_del(worker->u.feedback_run.notify); free(worker); worker = NULL; } @@ -661,18 +788,21 @@ EAPI Ecore_Thread *ecore_long_run(Ecore_Thread_Heavy_Cb func_heavy, If no thread and as we don't want to break app that rely on this facility, we will lock the interface until we are done. */ - worker.u.long_run.func_heavy = func_heavy; - worker.u.long_run.func_notify = func_notify; - worker.u.long_run.notify = NULL; + worker.u.feedback_run.func_heavy = func_heavy; + worker.u.feedback_run.func_notify = func_notify; + worker.u.feedback_run.notify = NULL; + worker.u.feedback_run.send = 0; + worker.u.feedback_run.received = 0; worker.func_cancel = func_cancel; worker.func_end = func_end; worker.data = data; worker.cancel = EINA_FALSE; - worker.long_run = EINA_TRUE; + worker.feedback_run = EINA_TRUE; + worker.kill = EINA_FALSE; func_heavy((Ecore_Thread *) &worker, (void *)data); - if (worker.cancel) func_cancel((void *)data); + if (worker.func_cancel) func_cancel((void *)data); else func_end((void *)data); return NULL; @@ -692,21 +822,22 @@ EAPI Ecore_Thread *ecore_long_run(Ecore_Thread_Heavy_Cb func_heavy, * You should use this function only in the func_heavy call. */ EAPI Eina_Bool -ecore_thread_notify(Ecore_Thread *thread, const void *data) +ecore_thread_feedback(Ecore_Thread *thread, const void *data) { Ecore_Pthread_Worker *worker = (Ecore_Pthread_Worker *) thread; if (!worker) return EINA_FALSE; - if (!worker->long_run) return EINA_FALSE; + if (!worker->feedback_run) return EINA_FALSE; #ifdef EFL_HAVE_PTHREAD if (!pthread_equal(worker->self, pthread_self())) return EINA_FALSE; - - ecore_pipe_write(worker->u.long_run.notify, &data, sizeof (void *)); + + worker->u.feedback_run.send++; + ecore_pipe_write(worker->u.feedback_run.notify, &data, sizeof (void *)); return EINA_TRUE; #else - worker->u.long_run.func_notify(thread, (void*) data, (void*) worker->data); + worker->u.feedback_run.func_notify(thread, (void*) data, (void*) worker->data); return EINA_TRUE; #endif @@ -749,18 +880,18 @@ ecore_thread_pending_get(void) } /** - * @brief Get number of pending long thread jobs - * @return Number of pending threads running "long" jobs + * @brief Get number of pending feedback thread jobs + * @return Number of pending threads running "feedback" jobs * This returns the number of threads currently running jobs through the - * ecore_long_run api call. + * ecore_thread_feedback_run api call. */ EAPI int -ecore_thread_pending_long_get(void) +ecore_thread_pending_feedback_get(void) { int ret; #ifdef EFL_HAVE_PTHREAD pthread_mutex_lock(&_ecore_pending_job_threads_mutex); - ret = eina_list_count(_ecore_pending_job_threads_long); + ret = eina_list_count(_ecore_pending_job_threads_feedback); pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); return ret; #else @@ -772,7 +903,7 @@ ecore_thread_pending_long_get(void) * @brief Get number of pending thread jobs * @return Number of pending threads running jobs * This returns the number of threads currently running jobs through the - * ecore_thread_run and ecore_long_run api calls combined. + * ecore_thread_run and ecore_thread_feedback_run api calls combined. */ EAPI int ecore_thread_pending_total_get(void) @@ -780,7 +911,7 @@ ecore_thread_pending_total_get(void) int ret; #ifdef EFL_HAVE_PTHREAD pthread_mutex_lock(&_ecore_pending_job_threads_mutex); - ret = eina_list_count(_ecore_pending_job_threads) + eina_list_count(_ecore_pending_job_threads_long); + ret = eina_list_count(_ecore_pending_job_threads) + eina_list_count(_ecore_pending_job_threads_feedback); pthread_mutex_unlock(&_ecore_pending_job_threads_mutex); return ret; #else @@ -832,7 +963,7 @@ ecore_thread_max_reset(void) * @return The number of available threads * This returns the number of threads slots that ecore has currently available. * Assuming that you haven't changed the max number of threads with @ref ecore_thread_max_set - * this should be equal to (num_cpus - (active_running + active_long_running)) + * this should be equal to (num_cpus - (active_running + active_feedback_running)) */ EAPI int ecore_thread_available_get(void) @@ -904,7 +1035,6 @@ ecore_thread_local_data_add(Ecore_Thread *thread, const char *key, void *value, * @param key The name string to add the data with * @param value The data to add * @param cb The callback to free the data with - * @param direct If true, this will not copy the key string (like eina_hash_direct_add) * @return The old data associated with @p key on success if modified, NULL if added * This adds/modifies data in the thread context, adding only if modify fails. * This function can only be called by a *_run thread INSIDE the thread. @@ -1057,7 +1187,7 @@ ecore_thread_global_data_add(const char *key, void *value, Eina_Free_Cb cb, Eina * @param key The name string to add the data with * @param value The data to add * @param cb The optional callback to free the data with once ecore is shut down - * @return An @ref Ecore_Thread_Data on success, NULL on failure + * @return An Ecore_Thread_Data on success, NULL on failure * This adds data to the global thread data and returns NULL, or replaces the previous data * associated with @p key and returning the previous data if it existed. To see if an error occurred, * one must use eina_error_get. @@ -1213,3 +1343,7 @@ ecore_thread_global_data_wait(const char *key, double seconds) /** * @} */ + +/** + * @} + */ diff --git a/src/lib/ecore/ecore_time.c b/src/lib/ecore/ecore_time.c index 9e51df6..5926ca1 100644 --- a/src/lib/ecore/ecore_time.c +++ b/src/lib/ecore/ecore_time.c @@ -15,54 +15,161 @@ #include "Ecore.h" #include "ecore_private.h" +#include +#ifdef HAVE_CLOCK_GETTIME +static clockid_t _ecore_time_clock_id = -1; +#endif +double _ecore_time_loop_time = -1.0; -/* FIXME: clock_gettime() is an option... */ +/** + * @addtogroup Ecore_Group Ecore - Main Loop and Job Functions. + * + * @{ + */ + +/** + * @addtogroup Ecore_Time_Group Ecore Time functions + * + * @{ + */ /** * Retrieves the current system time as a floating point value in seconds. * - * Also see ecore_loop_time_get(). + * This uses a monotonic clock and thus never goes back in time while + * machine is live (even if user changes time or timezone changes, + * however it may be reset whenever the machine is restarted). * - * @return The number of seconds since 12.00AM 1st January 1970. - * @ingroup Ecore_Time_Group + * @see ecore_loop_time_get(). + * @see ecore_time_unix_get(). + * + * @return The number of seconds. Start time is not defined (it may be + * when the machine was booted, unix time, etc), all it is + * defined is that it never goes backwards (unless you got big critical + * messages when the application started). */ EAPI double ecore_time_get(void) { -#ifdef HAVE_EVIL - return evil_time_get(); -#else -# ifdef HAVE_GETTIMEOFDAY - struct timeval timev; +#ifdef HAVE_CLOCK_GETTIME + struct timespec t; - gettimeofday(&timev, NULL); - return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000); + if (EINA_UNLIKELY(_ecore_time_clock_id < 0)) + return ecore_time_unix_get(); + + if (EINA_UNLIKELY(clock_gettime(_ecore_time_clock_id, &t))) + { + CRIT("Cannot get current time."); + /* Try to at least return the latest value retrieved*/ + return _ecore_time_loop_time; + } + + return (double)t.tv_sec + (((double)t.tv_nsec) / 1000000000.0); +#else +# ifdef HAVE_EVIL + return evil_time_get(); # else -# error "Your platform isn't supported yet" + return ecore_time_unix_get(); # endif #endif } -double _ecore_loop_time = -1.0; - /** - * Retrieves the time at which the last loop stopped waiting for timeouts or events + * Retrieves the current UNIX time as a floating point value in seconds. * - * This gets the time (since Jan 1st, 1970, 12:00AM) that the main loop ceased - * waiting for timouts and/or events to come in or for signals or any other - * interrupt source. This should be considered a reference point for all - * time based activity that should calculate its timepoint from the return - * of ecore_loop_time_get(). use this UNLESS you absolutely must get the - * current actual timepoint - then use ecore_time_get(). If this is called - * before any loop has ever been run, then it will call ecore_time_get() for - * you the first time and thus have an initial time reference. + * @see ecore_time_get(). + * @see ecore_loop_time_get(). * * @return The number of seconds since 12.00AM 1st January 1970. - * @ingroup Ecore_Time_Group + */ +EAPI double +ecore_time_unix_get(void) +{ +#ifdef HAVE_GETTIMEOFDAY + struct timeval timev; + + gettimeofday(&timev, NULL); + return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000); +#else +# error "Your platform isn't supported yet" +#endif +} + +/** + * Retrieves the time at which the last loop stopped waiting for timeouts or + * events. + * + * This gets the time that the main loop ceased waiting for timouts and/or + * events to come in or for signals or any other interrupt source. This should + * be considered a reference point for all time based activity that should + * calculate its timepoint from the return of ecore_loop_time_get(). Use this + * UNLESS you absolutely must get the current actual timepoint - then use + * ecore_time_get(). Note that this time is meant to be used as relative to + * other times obtained on this run. If you need absolute time references, use + * ecore_time_unix_get() instead. + * + * This function can be called before any loop has ever been run, but either + * ecore_init() or ecore_time_get() must have been called once. + * + * @return The number of seconds. Start time is not defined (it may be + * when the machine was booted, unix time, etc), all it is + * defined is that it never goes backwards (unless you got big critical + * messages when the application started). */ EAPI double ecore_loop_time_get(void) { - return _ecore_loop_time; + return _ecore_time_loop_time; +} + +/** + * @} + */ + +/** + * @} + */ + + +/********************** Internal methods ********************************/ + +/* TODO: Documentation says "All implementations support the system-wide + * real-time clock, which is identified by CLOCK_REALTIME. Check if the fallback + * to unix time (without specifying the resolution) might be removed + */ +void +_ecore_time_init(void) +{ +#ifdef HAVE_CLOCK_GETTIME + struct timespec t; + + if (_ecore_time_clock_id != -1) return; + + if (!clock_gettime(CLOCK_MONOTONIC, &t)) + { + _ecore_time_clock_id = CLOCK_MONOTONIC; + DBG("using CLOCK_MONOTONIC."); + } + else if (!clock_gettime(CLOCK_REALTIME, &t)) + { + /* may go backwards */ + _ecore_time_clock_id = CLOCK_REALTIME; + WRN("CLOCK_MONOTONIC not available. Fallback to CLOCK_REALTIME."); + } + else + { + _ecore_time_clock_id = -2; + CRIT("Cannot get a valid clock_gettime() clock id! " + "Fallback to unix time."); + } +#else +# ifndef HAVE_EVIL +# warning "Your platform isn't supported yet" + CRIT("Platform does not support clock_gettime. " + "Fallback to unix time."); +# endif +#endif + + _ecore_time_loop_time = ecore_time_get(); } diff --git a/src/lib/ecore/ecore_timer.c b/src/lib/ecore/ecore_timer.c index 466292d..606ccb5 100644 --- a/src/lib/ecore/ecore_timer.c +++ b/src/lib/ecore/ecore_timer.c @@ -37,10 +37,20 @@ static double last_check = 0.0; static double precision = 10.0 / 1000000.0; /** - * @defgroup Ecore_Time_Group Ecore Time Functions + * @addtogroup Ecore_Group Ecore - Main Loop and Job Functions. + * + * @{ + */ + +/** + * @addtogroup Ecore_Time_Group Ecore Time functions * * Functions that deal with time. These functions include those that simply * retrieve it in a given format, and those that create events based on it. + * + * The timer allows callbacks to be called at specific intervals. + * + * @{ */ /** @@ -83,8 +93,8 @@ ecore_timer_precision_set(double value) { if (value < 0.0) { - ERR("Precision %f less than zero, ignored", value); - return; + ERR("Precision %f less than zero, ignored", value); + return; } precision = value; } @@ -96,7 +106,6 @@ ecore_timer_precision_set(double value) * rescheduled for the next interval @p in. * @param data Data to pass to @p func when it is called. * @return A timer object on success. @c NULL on failure. - * @ingroup Ecore_Time_Group * * This function adds a timer and returns its handle on success and NULL on * failure. The function @p func will be called every @p in seconds. The @@ -131,7 +140,6 @@ ecore_timer_add(double in, Ecore_Task_Cb func, const void *data) * rescheduled for the next interval @p in. * @param data Data to pass to @p func when it is called. * @return A timer object on success. @c NULL on failure. - * @ingroup Ecore_Time_Group * * This is the same as ecore_timer_add(), but "now" is the time from * ecore_loop_time_get() not ecore_time_get() as ecore_timer_add() uses. See @@ -158,7 +166,6 @@ ecore_timer_loop_add(double in, Ecore_Task_Cb func, const void *data) * @param timer The timer to delete. * @return The data pointer set for the timer when @ref ecore_timer_add was * called. @c NULL is returned if the function is unsuccessful. - * @ingroup Ecore_Time_Group * * Note: @p timer must be a valid handle. If the timer function has already * returned 0, the handle is no longer valid (and does not need to be delete). @@ -168,22 +175,22 @@ ecore_timer_del(Ecore_Timer *timer) { if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) { - ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, - "ecore_timer_del"); - return NULL; + ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, + "ecore_timer_del"); + return NULL; } if (timer->frozen && !timer->references) { - void *data = timer->data; + void *data = timer->data; - suspended = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer)); + suspended = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer)); - if (timer->delete_me) - timers_delete_me--; + if (timer->delete_me) + timers_delete_me--; - free(timer); - return data; + free(timer); + return data; } EINA_SAFETY_ON_TRUE_RETURN_VAL(timer->delete_me, NULL); @@ -198,16 +205,15 @@ ecore_timer_del(Ecore_Timer *timer) * * @param timer The timer to change. * @param in The interval in seconds. - * @ingroup Ecore_Time_Group */ EAPI void ecore_timer_interval_set(Ecore_Timer *timer, double in) { if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) { - ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, - "ecore_timer_interval_set"); - return; + ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, + "ecore_timer_interval_set"); + return; } timer->in = in; } @@ -217,66 +223,64 @@ ecore_timer_interval_set(Ecore_Timer *timer, double in) * * @param timer The timer to retrieve the interval from * @return The interval on success. -1 on failure. - * @ingroup Ecore_Time_Group */ EAPI double ecore_timer_interval_get(Ecore_Timer *timer) { if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) { - ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, - "ecore_timer_interval_get"); - return -1.0; + ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, + "ecore_timer_interval_get"); + return -1.0; } return timer->in; } /** - * Add some delay for the next occurence of a timer. + * Add some delay for the next occurrence of a timer. * This doesn't affect the interval of a timer. * * @param timer The timer to change. * @param add The dalay to add to the next iteration. - * @ingroup Ecore_Time_Group */ EAPI void ecore_timer_delay(Ecore_Timer *timer, double add) { if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) { - ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, - "ecore_timer_delay"); - return; + ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, + "ecore_timer_delay"); + return; } if (timer->frozen) { - timer->pending += add; + timer->pending += add; } else { - timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); - _ecore_timer_set(timer, timer->at + add, timer->in, timer->func, timer->data); + timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); + _ecore_timer_set(timer, timer->at + add, timer->in, timer->func, timer->data); } } /** * Get the pending time regarding a timer. * - * @param timer The timer to learn from. - * @ingroup Ecore_Time_Group + * @param timer The timer to learn from. + * @ingroup Ecore_Time_Group */ EAPI double ecore_timer_pending_get(Ecore_Timer *timer) { - double now; + double now; if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) { - ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, - "ecore_timer_pending_get"); - return 0; + ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, + "ecore_timer_pending_get"); + return 0; } now = ecore_time_get(); @@ -297,7 +301,7 @@ ecore_timer_freeze(Ecore_Timer *timer) if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) { - ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, + ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, "ecore_timer_freeze"); return ; } @@ -323,7 +327,7 @@ ecore_timer_thaw(Ecore_Timer *timer) if (!ECORE_MAGIC_CHECK(timer, ECORE_MAGIC_TIMER)) { - ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, + ECORE_MAGIC_FAIL(timer, ECORE_MAGIC_TIMER, "ecore_timer_thaw"); return ; } @@ -338,6 +342,14 @@ ecore_timer_thaw(Ecore_Timer *timer) _ecore_timer_set(timer, timer->pending + now, timer->in, timer->func, timer->data); } +/** + * @} + */ + +/** + * @} + */ + void _ecore_timer_shutdown(void) { @@ -345,9 +357,9 @@ _ecore_timer_shutdown(void) while ((timer = timers)) { - timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timers)); - ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE); - free(timer); + timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timers)); + ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE); + free(timer); } while ((timer = suspended)) @@ -369,52 +381,52 @@ _ecore_timer_cleanup(void) if (!timers_delete_me) return; for (l = timers; l;) { - Ecore_Timer *timer = l; - - l = (Ecore_Timer *) EINA_INLIST_GET(l)->next; - if (timer->delete_me) - { - if (timer->references) - { - in_use++; - continue; - } - timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); - ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE); - free(timer); - timers_delete_me--; - done++; - if (timers_delete_me == 0) return; - } + Ecore_Timer *timer = l; + + l = (Ecore_Timer *) EINA_INLIST_GET(l)->next; + if (timer->delete_me) + { + if (timer->references) + { + in_use++; + continue; + } + timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); + ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE); + free(timer); + timers_delete_me--; + done++; + if (timers_delete_me == 0) return; + } } for (l = suspended; l;) { - Ecore_Timer *timer = l; - - l = (Ecore_Timer *) EINA_INLIST_GET(l)->next; - if (timer->delete_me) - { - if (timer->references) - { - in_use++; - continue; - } - suspended = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer)); - ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE); - free(timer); - timers_delete_me--; - done++; - if (timers_delete_me == 0) return; - } + Ecore_Timer *timer = l; + + l = (Ecore_Timer *) EINA_INLIST_GET(l)->next; + if (timer->delete_me) + { + if (timer->references) + { + in_use++; + continue; + } + suspended = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(suspended), EINA_INLIST_GET(timer)); + ECORE_MAGIC_SET(timer, ECORE_MAGIC_NONE); + free(timer); + timers_delete_me--; + done++; + if (timers_delete_me == 0) return; + } } if ((!in_use) && (timers_delete_me)) { - ERR("%d timers to delete, but they were not found!" - "Stats: todo=%d, done=%d, pending=%d, in_use=%d. " - "reset counter.", - timers_delete_me, todo, done, todo - done, in_use); - timers_delete_me = 0; + ERR("%d timers to delete, but they were not found!" + "Stats: todo=%d, done=%d, pending=%d, in_use=%d. " + "reset counter.", + timers_delete_me, todo, done, todo - done, in_use); + timers_delete_me = 0; } } @@ -513,52 +525,52 @@ _ecore_timer_call(double when) if (!timers) return 0; if (last_check > when) { - Ecore_Timer *timer; - /* User set time backwards */ - EINA_INLIST_FOREACH(timers, timer) timer->at -= (last_check - when); + Ecore_Timer *timer; + /* User set time backwards */ + EINA_INLIST_FOREACH(timers, timer) timer->at -= (last_check - when); } last_check = when; if (!timer_current) { - /* regular main loop, start from head */ - timer_current = timers; + /* regular main loop, start from head */ + timer_current = timers; } else { - /* recursive main loop, continue from where we were */ - Ecore_Timer *timer_old = timer_current; - timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next; - _ecore_timer_reschedule(timer_old, when); + /* recursive main loop, continue from where we were */ + Ecore_Timer *timer_old = timer_current; + timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next; + _ecore_timer_reschedule(timer_old, when); } while (timer_current) { - Ecore_Timer *timer = timer_current; - - if (timer->at > when) - { - timer_current = NULL; /* ended walk, next should restart. */ - return 0; - } - - if ((timer->just_added) || (timer->delete_me)) - { - timer_current = (Ecore_Timer*)EINA_INLIST_GET(timer_current)->next; - continue; - } - - timer->references++; - if (!timer->func(timer->data)) - { - if (!timer->delete_me) ecore_timer_del(timer); - } - timer->references--; - - if (timer_current) /* may have changed in recursive main loops */ - timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next; - - _ecore_timer_reschedule(timer, when); + Ecore_Timer *timer = timer_current; + + if (timer->at > when) + { + timer_current = NULL; /* ended walk, next should restart. */ + return 0; + } + + if ((timer->just_added) || (timer->delete_me)) + { + timer_current = (Ecore_Timer*)EINA_INLIST_GET(timer_current)->next; + continue; + } + + timer->references++; + if (!timer->func(timer->data)) + { + if (!timer->delete_me) ecore_timer_del(timer); + } + timer->references--; + + if (timer_current) /* may have changed in recursive main loops */ + timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next; + + _ecore_timer_reschedule(timer, when); } return 0; } @@ -578,14 +590,14 @@ _ecore_timer_set(Ecore_Timer *timer, double at, double in, Ecore_Task_Cb func, v timer->pending = 0.0; if (timers) { - EINA_INLIST_REVERSE_FOREACH(EINA_INLIST_GET(timers), t2) - { - if (timer->at > t2->at) - { - timers = (Ecore_Timer *) eina_inlist_append_relative(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer), EINA_INLIST_GET(t2)); - return; - } - } + EINA_INLIST_REVERSE_FOREACH(EINA_INLIST_GET(timers), t2) + { + if (timer->at > t2->at) + { + timers = (Ecore_Timer *) eina_inlist_append_relative(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer), EINA_INLIST_GET(t2)); + return; + } + } } timers = (Ecore_Timer *) eina_inlist_prepend(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer)); } diff --git a/src/lib/ecore_cocoa/Ecore_Cocoa.h b/src/lib/ecore_cocoa/Ecore_Cocoa.h index ab665e9..f90db7c 100644 --- a/src/lib/ecore_cocoa/Ecore_Cocoa.h +++ b/src/lib/ecore_cocoa/Ecore_Cocoa.h @@ -1,19 +1,29 @@ #ifndef _ECORE_COCOA_H #define _ECORE_COCOA_H +/* + * DO NOT USE THIS HEADER. IT IS WORK IN PROGRESS. IT IS NOT FINAL AND + * THE API MAY CHANGE. + */ + +#ifndef ECORE_COCOA_WIP_GNSIDNQI +# warning "You are using a work in progress API. This API is not stable" +# warning "and is subject to change. You use this at your own risk." +#endif + #ifdef EAPI # undef EAPI #endif -# ifdef __GNUC__ -# if __GNUC__ >= 4 -# define EAPI __attribute__ ((visibility("default"))) -# else -# define EAPI -# endif +#ifdef __GNUC__ +# if __GNUC__ >= 4 +# define EAPI __attribute__ ((visibility("default"))) # else # define EAPI # endif +#else +# define EAPI +#endif #ifdef __cplusplus extern "C" { diff --git a/src/lib/ecore_con/Ecore_Con.h b/src/lib/ecore_con/Ecore_Con.h index a61b06f..d5fc0df 100644 --- a/src/lib/ecore_con/Ecore_Con.h +++ b/src/lib/ecore_con/Ecore_Con.h @@ -33,12 +33,11 @@ #endif /** - * @file Ecore_Con.h - * @brief Sockets functions. + * @defgroup Ecore_Con_Group Ecore_Con - Connection functions * * The Ecore Connection Library ( @c Ecore_Con ) provides simple mechanisms * for communications between programs using reliable sockets. It saves - * the programmer from having to worry about file descripters and waiting + * the programmer from having to worry about file descriptors and waiting * for incoming connections. * * There are two main objects in the @c Ecore_Con library: the @c @@ -53,7 +52,7 @@ * * To connect to a server, call @c ecore_con_server_connect(). Data can * then be sent to the server using the @c ecore_con_server_send(). - * + * * Functions are described in the following groupings: * @li @ref Ecore_Con_Lib_Group * @li @ref Ecore_Con_Server_Group @@ -65,158 +64,127 @@ /** - * @addtogroup Ecore_Con_Events_Group Events - * - * @li @ref ECORE_CON_CLIENT_ADD: Whenever a client connection is made to an - * @c Ecore_Con_Server, an event of this type is emitted, allowing the - * retrieval of the client's ip with @ref ecore_con_client_ip_get and + * @defgroup Ecore_Con_Events_Group Events + * + * @li ECORE_CON_CLIENT_ADD: Whenever a client connection is made to an + * @c Ecore_Con_Server, an event of this type is emitted, allowing the + * retrieval of the client's ip with @ref ecore_con_client_ip_get and * associating data with the client using ecore_con_client_data_set. - * @li @ref ECORE_CON_EVENT_CLIENT_DEL: Whenever a client connection to an + * @li ECORE_CON_EVENT_CLIENT_DEL: Whenever a client connection to an * @c Ecore_Con_Server, an event of this type is emitted. The contents of * the data with this event are variable, but if the client object in the data * is non-null, it must be freed with @ref ecore_con_client_del. - * @li @ref ECORE_CON_EVENT_SERVER_ADD: Whenever a server object is created + * @li ECORE_CON_EVENT_SERVER_ADD: Whenever a server object is created * with @ref ecore_con_server_connect, an event of this type is emitted, * allowing for data to be serialized and sent to the server using * @ref ecore_con_server_send. At this point, the http handshake has * occurred. - * @li @ref ECORE_CON_EVENT_SERVER_DEL: Whenever a server object is destroyed, + * @li ECORE_CON_EVENT_SERVER_DEL: Whenever a server object is destroyed, * usually by the server connection being refused or dropped, an event of this * type is emitted. The contents of the data with this event are variable, * but if the server object in the data is non-null, it must be freed * with @ref ecore_con_server_del. - * @li @ref ECORE_CON_EVENT_CLIENT_DATA: Whenever a client connects to your server + * @li ECORE_CON_EVENT_CLIENT_DATA: Whenever a client connects to your server * object and sends data, an event of this type is emitted. The data will contain both * the size and contents of the message sent by the client. It should be noted that * data within this object is transient, so it must be duplicated in order to be * retained. This event will continue to occur until the client has stopped sending its * message, so a good option for storing this data is an Eina_Strbuf. Once the message has - * been recieved in full, the client object must be freed with @ref ecore_con_client_free. - * @li @ref ECORE_CON_EVENT_SERVER_DATA: Whenever your server object connects to its destination + * been received in full, the client object must be freed with ecore_con_client_free. + * @li ECORE_CON_EVENT_SERVER_DATA: Whenever your server object connects to its destination * and receives data, an event of this type is emitted. The data will contain both * the size and contents of the message sent by the server. It should be noted that * data within this object is transient, so it must be duplicated in order to be * retained. This event will continue to occur until the server has stopped sending its * message, so a good option for storing this data is an Eina_Strbuf. Once the message has - * been recieved in full, the server object must be freed with @ref ecore_con_server_free. + * been received in full, the server object must be freed with ecore_con_server_free. * */ #ifdef __cplusplus extern "C" { #endif +#define ECORE_CON_USE_SSL ECORE_CON_USE_SSL2 +#define ECORE_CON_REMOTE_SYSTEM ECORE_CON_REMOTE_TCP + -/** @typedef Ecore_Con_Server +/** + * @typedef Ecore_Con_Server * A connection handle to a server + * @ingroup Ecore_Con_Server_Group */ typedef struct _Ecore_Con_Server Ecore_Con_Server; -/** @typedef Ecore_Con_Client - * A connection handle to a client - */ -typedef struct _Ecore_Con_Client Ecore_Con_Client; -/** @typedef Ecore_Con_Url - * A handle to an http upload/download object - */ -typedef struct _Ecore_Con_Url Ecore_Con_Url; /** - * @typedef Ecore_Con_Dns_Cb - * A callback type for use with @ref ecore_con_lookup. + * @typedef Ecore_Con_Client + * A connection handle to a client + * @ingroup Ecore_Con_Client_Group */ -typedef void (*Ecore_Con_Dns_Cb)(const char *canonname, - const char *ip, - struct sockaddr *addr, - int addrlen, - void *data); +typedef struct _Ecore_Con_Client Ecore_Con_Client; /** - * @typedef Ecore_Con_Type - * @enum _Ecore_Con_Type - * Types for an ecore_con client/server object. A correct way to set this type is - * with an ECORE_CON_$TYPE, optionally OR'ed with an ECORE_CON_$USE if encryption is desired, - * and LOAD_CERT if the previously loaded certificate should be used. - * @example ECORE_CON_REMOTE_TCP | ECORE_CON_USE_TLS | ECORE_CON_LOAD_CERT + * @typedef Ecore_Con_Url + * A handle to an http upload/download object + * @ingroup Ecore_Con_Url_Group */ -typedef enum _Ecore_Con_Type -{ - /** Socket in ~/.ecore */ - ECORE_CON_LOCAL_USER = 0, - /** Socket in /tmp */ - ECORE_CON_LOCAL_SYSTEM = 1, - /** Abstract socket */ - ECORE_CON_LOCAL_ABSTRACT = 2, - /** Remote server using TCP */ - ECORE_CON_REMOTE_TCP = 3, - /** Remote multicast server */ - ECORE_CON_REMOTE_MCAST = 4, - /** Remote server using UDP */ - ECORE_CON_REMOTE_UDP = 5, - /** Remote broadcast using UDP */ - ECORE_CON_REMOTE_BROADCAST = 6, - ECORE_CON_REMOTE_NODELAY = 7, - /** Use SSL2: UNSUPPORTED. **/ - ECORE_CON_USE_SSL2 = (1 << 4), - /** Use SSL3 */ - ECORE_CON_USE_SSL3 = (1 << 5), - /** Use TLS */ - ECORE_CON_USE_TLS = (1 << 6), - /** Attempt to use the previously loaded certificate */ - ECORE_CON_LOAD_CERT = (1 << 7) -} Ecore_Con_Type; -#define ECORE_CON_USE_SSL ECORE_CON_USE_SSL2 -#define ECORE_CON_REMOTE_SYSTEM ECORE_CON_REMOTE_TCP +typedef struct _Ecore_Con_Url Ecore_Con_Url; -/** - * @typedef Ecore_Con_Url_Time - * @enum _Ecore_Con_Url_Time - * The type of time in the object - */ -typedef enum _Ecore_Con_Url_Time -{ - ECORE_CON_URL_TIME_NONE = 0, - ECORE_CON_URL_TIME_IFMODSINCE, - ECORE_CON_URL_TIME_IFUNMODSINCE, - ECORE_CON_URL_TIME_LASTMOD -} Ecore_Con_Url_Time; /** * @addtogroup Ecore_Con_Events_Group Events * @{ */ -/** @typedef Ecore_Con_Event_Client_Add +/** + * @typedef Ecore_Con_Event_Client_Add * Used as the @p data param for the corresponding event */ typedef struct _Ecore_Con_Event_Client_Add Ecore_Con_Event_Client_Add; -/** @typedef Ecore_Con_Event_Client_Del + +/** + * @typedef Ecore_Con_Event_Client_Del * Used as the @p data param for the corresponding event */ typedef struct _Ecore_Con_Event_Client_Del Ecore_Con_Event_Client_Del; -/** @typedef Ecore_Con_Event_Server_Add + +/** + * @typedef Ecore_Con_Event_Server_Add * Used as the @p data param for the corresponding event */ typedef struct _Ecore_Con_Event_Server_Add Ecore_Con_Event_Server_Add; -/** @typedef Ecore_Con_Event_Server_Del + +/** + * @typedef Ecore_Con_Event_Server_Del * Used as the @p data param for the corresponding event */ typedef struct _Ecore_Con_Event_Server_Del Ecore_Con_Event_Server_Del; -/** @typedef Ecore_Con_Event_Client_Data + +/** + * @typedef Ecore_Con_Event_Client_Data * Used as the @p data param for the corresponding event */ typedef struct _Ecore_Con_Event_Client_Data Ecore_Con_Event_Client_Data; -/** @typedef Ecore_Con_Event_Server_Data + +/** + * @typedef Ecore_Con_Event_Server_Data * Used as the @p data param for the corresponding event */ typedef struct _Ecore_Con_Event_Server_Data Ecore_Con_Event_Server_Data; -/** @typedef Ecore_Con_Event_Url_Data + +/** + * @typedef Ecore_Con_Event_Url_Data * Used as the @p data param for the corresponding event */ typedef struct _Ecore_Con_Event_Url_Data Ecore_Con_Event_Url_Data; -/** @typedef Ecore_Con_Event_Url_Complete + +/** + * @typedef Ecore_Con_Event_Url_Complete * Used as the @p data param for the corresponding event */ typedef struct _Ecore_Con_Event_Url_Complete Ecore_Con_Event_Url_Complete; -/** @typedef Ecore_Con_Event_Url_Progress + +/** + * @typedef Ecore_Con_Event_Url_Progress * Used as the @p data param for the corresponding event */ typedef struct _Ecore_Con_Event_Url_Progress Ecore_Con_Event_Url_Progress; @@ -263,12 +231,9 @@ struct _Ecore_Con_Event_Server_Del */ struct _Ecore_Con_Event_Client_Data { - /** the client that connected */ - Ecore_Con_Client *client; - /** the data that the client sent */ - void *data; - /** the length of the data sent */ - int size; + Ecore_Con_Client *client; /**< the client that connected */ + void *data; /**< the data that the client sent */ + int size; /**< the length of the data sent */ }; /** @@ -277,12 +242,9 @@ struct _Ecore_Con_Event_Client_Data */ struct _Ecore_Con_Event_Server_Data { - /** the server that was connected to */ - Ecore_Con_Server *server; - /** the data that the server sent */ - void *data; - /** the length of the data sent */ - int size; + Ecore_Con_Server *server; /**< the server that was connected to */ + void *data; /**< the data that the server sent */ + int size; /**< the length of the data sent */ }; /** @@ -331,7 +293,7 @@ EAPI extern int ECORE_CON_EVENT_CLIENT_ADD; EAPI extern int ECORE_CON_EVENT_CLIENT_DEL; /** A server was created */ EAPI extern int ECORE_CON_EVENT_SERVER_ADD; -/** A server connection was lost */ +/** A server connection was lost */ EAPI extern int ECORE_CON_EVENT_SERVER_DEL; /** A client connected to the server has sent data */ EAPI extern int ECORE_CON_EVENT_CLIENT_DATA; @@ -343,15 +305,98 @@ EAPI extern int ECORE_CON_EVENT_URL_DATA; EAPI extern int ECORE_CON_EVENT_URL_COMPLETE; /** A URL object has made progress in its transfer */ EAPI extern int ECORE_CON_EVENT_URL_PROGRESS; + /** * @} */ + +/** + * @defgroup Ecore_Con_Lib_Group Ecore Connection Library Functions + * + * @{ + */ + +/** + * @typedef Ecore_Con_Dns_Cb + * A callback type for use with @ref ecore_con_lookup. + */ +typedef void (*Ecore_Con_Dns_Cb)(const char *canonname, + const char *ip, + struct sockaddr *addr, + int addrlen, + void *data); + +/** + * @typedef Ecore_Con_Type + * @enum _Ecore_Con_Type + * Types for an ecore_con client/server object. A correct way to set this type is + * with an ECORE_CON_$TYPE, optionally OR'ed with an ECORE_CON_$USE if encryption is desired, + * and LOAD_CERT if the previously loaded certificate should be used. + * @code + * ECORE_CON_REMOTE_TCP | ECORE_CON_USE_TLS | ECORE_CON_LOAD_CERT + * @endcode + */ +typedef enum _Ecore_Con_Type +{ + /** Socket in ~/.ecore */ + ECORE_CON_LOCAL_USER = 0, + /** Socket in /tmp */ + ECORE_CON_LOCAL_SYSTEM = 1, + /** Abstract socket */ + ECORE_CON_LOCAL_ABSTRACT = 2, + /** Remote server using TCP */ + ECORE_CON_REMOTE_TCP = 3, + /** Remote multicast server */ + ECORE_CON_REMOTE_MCAST = 4, + /** Remote server using UDP */ + ECORE_CON_REMOTE_UDP = 5, + /** Remote broadcast using UDP */ + ECORE_CON_REMOTE_BROADCAST = 6, + ECORE_CON_REMOTE_NODELAY = 7, + /** Use SSL2: UNSUPPORTED. **/ + ECORE_CON_USE_SSL2 = (1 << 4), + /** Use SSL3 */ + ECORE_CON_USE_SSL3 = (1 << 5), + /** Use TLS */ + ECORE_CON_USE_TLS = (1 << 6), + /** Use both TLS and SSL3 */ + ECORE_CON_USE_MIXED = ECORE_CON_USE_SSL3 | ECORE_CON_USE_TLS, + /** Attempt to use the loaded certificate */ + ECORE_CON_LOAD_CERT = (1 << 7) +} Ecore_Con_Type; + EAPI int ecore_con_init(void); EAPI int ecore_con_shutdown(void); -EAPI Eina_Bool ecore_con_server_ssl_cert_add(const char *cert); -EAPI Eina_Bool ecore_con_client_ssl_cert_add(const char *cert_file, - const char *crl_file, - const char *key_file); + +EAPI Eina_Bool ecore_con_lookup(const char *name, + Ecore_Con_Dns_Cb done_cb, + const void *data); + +/** + * @} + */ + +/** + * @defgroup Ecore_Con_SSL_Group Ecore Connection SSL Functions + * + * @{ + */ +EAPI int ecore_con_ssl_available_get(void); +EAPI Eina_Bool ecore_con_ssl_server_cert_add(Ecore_Con_Server *svr, const char *cert); +EAPI Eina_Bool ecore_con_ssl_server_privkey_add(Ecore_Con_Server *svr, const char *key_file); +EAPI Eina_Bool ecore_con_ssl_server_crl_add(Ecore_Con_Server *svr, const char *crl_file); +EAPI Eina_Bool ecore_con_ssl_server_cafile_add(Ecore_Con_Server *svr, const char *ca_file); +EAPI void ecore_con_ssl_server_verify(Ecore_Con_Server *svr); + +/** + * @} + */ + +/** + * @defgroup Ecore_Con_Server_Group Ecore Connection Server Functions + * + * @{ + */ EAPI Ecore_Con_Server *ecore_con_server_add(Ecore_Con_Type type, const char *name, int port, @@ -364,18 +409,31 @@ EAPI void * ecore_con_server_del(Ecore_Con_Server *svr); EAPI void * ecore_con_server_data_get(Ecore_Con_Server *svr); EAPI void * ecore_con_server_data_set(Ecore_Con_Server *svr, void *data); -EAPI int ecore_con_server_connected_get(Ecore_Con_Server *svr); +EAPI Eina_Bool ecore_con_server_connected_get(Ecore_Con_Server *svr); EAPI Eina_List * ecore_con_server_clients_get(Ecore_Con_Server *svr); +EAPI const char * ecore_con_server_name_get(Ecore_Con_Server *svr); +EAPI int ecore_con_server_port_get(Ecore_Con_Server *svr); +EAPI double ecore_con_server_uptime_get(Ecore_Con_Server *svr); EAPI int ecore_con_server_send(Ecore_Con_Server *svr, const void *data, int size); -EAPI void ecore_con_server_client_limit_set( - Ecore_Con_Server *svr, - int client_limit, - char - reject_excess_clients); +EAPI void ecore_con_server_client_limit_set(Ecore_Con_Server *svr, + int client_limit, + char reject_excess_clients); EAPI const char * ecore_con_server_ip_get(Ecore_Con_Server *svr); EAPI void ecore_con_server_flush(Ecore_Con_Server *svr); +EAPI void ecore_con_server_timeout_set(Ecore_Con_Server *svr, double timeout); +EAPI double ecore_con_server_timeout_get(Ecore_Con_Server *svr); + +/** + * @} + */ + +/** + * @defgroup Ecore_Con_Client_Group Ecore Connection Client Functions + * + * @{ + */ EAPI int ecore_con_client_send(Ecore_Con_Client *cl, const void *data, @@ -387,56 +445,88 @@ EAPI void ecore_con_client_data_set(Ecore_Con_Client *cl, EAPI void * ecore_con_client_data_get(Ecore_Con_Client *cl); EAPI const char * ecore_con_client_ip_get(Ecore_Con_Client *cl); EAPI void ecore_con_client_flush(Ecore_Con_Client *cl); +EAPI double ecore_con_client_uptime_get(Ecore_Con_Client *cl); +EAPI double ecore_con_client_timeout_get(Ecore_Con_Client *cl); +EAPI void ecore_con_client_timeout_set(Ecore_Con_Client *cl, double timeout); -EAPI int ecore_con_ssl_available_get(void); +/** + * @} + */ + +/** + * @defgroup Ecore_Con_Url_Group Ecore URL Connection Functions + * + * @{ + */ + +/** + * @typedef Ecore_Con_Url_Time + * @enum _Ecore_Con_Url_Time + * The type of condition to use when making an HTTP request dependent on time, + * so that headers such as "If-Modified-Since" are used. + */ +typedef enum _Ecore_Con_Url_Time +{ + /** + * Do not place time restrictions on the HTTP requests. + */ + ECORE_CON_URL_TIME_NONE = 0, + /** + * Add the "If-Modified-Since" HTTP header, so that the request is performed + * by the server only if the target has been modified since the time value + * passed to it in the request. + */ + ECORE_CON_URL_TIME_IFMODSINCE, + /** + * Add the "If-Unmodified-Since" HTTP header, so that the request is + * performed by the server only if the target has NOT been modified since + * the time value passed to it in the request. + */ + ECORE_CON_URL_TIME_IFUNMODSINCE +} Ecore_Con_Url_Time; EAPI int ecore_con_url_init(void); EAPI int ecore_con_url_shutdown(void); EAPI Ecore_Con_Url * ecore_con_url_new(const char *url); EAPI Ecore_Con_Url * ecore_con_url_custom_new(const char *url, const char *custom_request); -EAPI void ecore_con_url_destroy(Ecore_Con_Url *url_con); +EAPI void ecore_con_url_free(Ecore_Con_Url *url_con); +EAPI Eina_Bool ecore_con_url_url_set(Ecore_Con_Url *url_con, + const char *url); EAPI void ecore_con_url_data_set(Ecore_Con_Url *url_con, void *data); EAPI void * ecore_con_url_data_get(Ecore_Con_Url *url_con); -EAPI void ecore_con_url_additional_header_add( - Ecore_Con_Url *url_con, - const char *key, - const char *value); -EAPI void ecore_con_url_additional_headers_clear( - Ecore_Con_Url *url_con); -EAPI const Eina_List * ecore_con_url_response_headers_get( - Ecore_Con_Url *url_con); -EAPI int ecore_con_url_url_set(Ecore_Con_Url *url_con, - const char *url); +EAPI void ecore_con_url_additional_header_add(Ecore_Con_Url *url_con, + const char *key, + const char *value); +EAPI void ecore_con_url_additional_headers_clear(Ecore_Con_Url *url_con); +EAPI const Eina_List * ecore_con_url_response_headers_get(Ecore_Con_Url *url_con); EAPI void ecore_con_url_fd_set(Ecore_Con_Url *url_con, int fd); EAPI int ecore_con_url_received_bytes_get(Ecore_Con_Url *url_con); -EAPI int ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, +EAPI Eina_Bool ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, const char *username, const char *password, Eina_Bool safe); -EAPI int ecore_con_url_send(Ecore_Con_Url *url_con, - const void *data, size_t length, +EAPI Eina_Bool ecore_con_url_send(Ecore_Con_Url *url_con, + const void *data, long length, const char *content_type); EAPI void ecore_con_url_time(Ecore_Con_Url *url_con, - Ecore_Con_Url_Time condition, - time_t tm); + Ecore_Con_Url_Time time_condition, + double timestamp); -EAPI Eina_Bool ecore_con_lookup(const char *name, - Ecore_Con_Dns_Cb done_cb, - const void *data); - -EAPI int ecore_con_url_ftp_upload(Ecore_Con_Url *url_con, +EAPI Eina_Bool ecore_con_url_ftp_upload(Ecore_Con_Url *url_con, const char *filename, const char *user, const char *pass, const char *upload_dir); EAPI void ecore_con_url_verbose_set(Ecore_Con_Url *url_con, - int verbose); + Eina_Bool verbose); EAPI void ecore_con_url_ftp_use_epsv_set(Ecore_Con_Url *url_con, - int use_epsv); -EAPI int ecore_con_url_http_post_send(Ecore_Con_Url *url_con, - void *curl_httppost); + Eina_Bool use_epsv); + +/** + * @} + */ #ifdef __cplusplus } diff --git a/src/lib/ecore_con/ecore_con.c b/src/lib/ecore_con/ecore_con.c index 5c1bea4..3095fd6 100644 --- a/src/lib/ecore_con/ecore_con.c +++ b/src/lib/ecore_con/ecore_con.c @@ -43,6 +43,9 @@ #include "Ecore_Con.h" #include "ecore_con_private.h" +static Eina_Bool _ecore_con_client_timer(Ecore_Con_Client *cl); +static void _ecore_con_cl_timer_update(Ecore_Con_Client *cl); + static void _ecore_con_cb_tcp_connect(void *data, Ecore_Con_Info *info); static void _ecore_con_cb_udp_connect(void *data, Ecore_Con_Info *info); static void _ecore_con_cb_tcp_listen(void *data, Ecore_Con_Info *info); @@ -51,15 +54,13 @@ static void _ecore_con_cb_udp_listen(void *data, Ecore_Con_Info *info); static void _ecore_con_server_free(Ecore_Con_Server *svr); static void _ecore_con_client_free(Ecore_Con_Client *cl); -static Eina_Bool _ecore_con_svr_handler(void *data, - Ecore_Fd_Handler *fd_handler); +static Eina_Bool _ecore_con_svr_tcp_handler(void *data, Ecore_Fd_Handler *fd_handler); static Eina_Bool _ecore_con_cl_handler(void *data, Ecore_Fd_Handler *fd_handler); -static Eina_Bool _ecore_con_cl_udp_handler(void *data, - Ecore_Fd_Handler *fd_handler); -static Eina_Bool _ecore_con_svr_udp_handler(void *data, - Ecore_Fd_Handler *fd_handler); -static Eina_Bool _ecore_con_svr_cl_handler(void *data, - Ecore_Fd_Handler *fd_handler); +static Eina_Bool _ecore_con_cl_udp_handler(void *data, Ecore_Fd_Handler *fd_handler); +static Eina_Bool _ecore_con_svr_udp_handler(void *data, Ecore_Fd_Handler *fd_handler); + +static void _ecore_con_svr_cl_read(Ecore_Con_Client *cl); +static Eina_Bool _ecore_con_svr_cl_handler(void *data, Ecore_Fd_Handler *fd_handler); static void _ecore_con_server_flush(Ecore_Con_Server *svr); static void _ecore_con_client_flush(Ecore_Con_Client *cl); @@ -112,8 +113,8 @@ ecore_con_init(void) if (!ecore_init()) return --_ecore_con_init_count; - _ecore_con_log_dom = eina_log_domain_register("EcoreCon", - ECORE_CON_DEFAULT_LOG_COLOR); + _ecore_con_log_dom = eina_log_domain_register + ("ecore_con", ECORE_CON_DEFAULT_LOG_COLOR); if(_ecore_con_log_dom < 0) { EINA_LOG_ERR("Impossible to create a log domain for Ecore Con."); @@ -160,17 +161,94 @@ ecore_con_shutdown(void) return _ecore_con_init_count; } -/** @} */ + +/** + * Do an asynchronous DNS lookup. + * + * This function performs a DNS lookup on the hostname specified by @p name, then + * calls @p done_cb with + * + * @param name IP address or server name to translate. + * @param done_cb Callback to notify when done. + * @param data User data to be given to done_cb. + * @return EINA_TRUE if the request did not fail to be set up, EINA_FALSE if it failed. + */ +EAPI Eina_Bool +ecore_con_lookup(const char *name, Ecore_Con_Dns_Cb done_cb, const void *data) +{ + Ecore_Con_Server *svr; + Ecore_Con_Lookup *lk; + struct addrinfo hints; + + if (!name || !done_cb) + return EINA_FALSE; + + svr = calloc(1, sizeof(Ecore_Con_Server)); + if (!svr) + return EINA_FALSE; + + lk = malloc(sizeof (Ecore_Con_Lookup)); + if (!lk) + { + free(svr); + return EINA_FALSE; + } + + lk->done_cb = done_cb; + lk->data = data; + + svr->name = strdup(name); + if (!svr->name) + goto on_error; + + svr->type = ECORE_CON_REMOTE_TCP; + svr->port = 1025; + svr->data = lk; + svr->created = EINA_TRUE; + svr->reject_excess_clients = EINA_FALSE; + svr->client_limit = -1; + svr->clients = NULL; + svr->ppid = getpid(); + + memset(&hints, 0, sizeof(struct addrinfo)); + hints.ai_family = AF_INET6; + hints.ai_socktype = SOCK_STREAM; + hints.ai_flags = AI_CANONNAME; + hints.ai_protocol = IPPROTO_TCP; + hints.ai_canonname = NULL; + hints.ai_next = NULL; + hints.ai_addr = NULL; + + if (ecore_con_info_get(svr, _ecore_con_lookup_done, svr, + &hints)) + return EINA_TRUE; + + free(svr->name); +on_error: + free(lk); + free(svr); + return EINA_FALSE; +} + +/** + * @} + */ /** * @addtogroup Ecore_Con_Server_Group Ecore Connection Server Functions * * Functions that operate on Ecore server objects. + * * @{ */ /** + * @example ecore_con_server_example.c + * Shows how to write a simple server using the Ecore_Con library. +*/ + +/** * Creates a server to listen for connections. * * The socket on which the server listens depends on the connection @@ -195,7 +273,9 @@ ecore_con_shutdown(void) * @return A new Ecore_Con_Server. */ EAPI Ecore_Con_Server * -ecore_con_server_add(Ecore_Con_Type compl_type, const char *name, int port, +ecore_con_server_add(Ecore_Con_Type compl_type, + const char *name, + int port, const void *data) { Ecore_Con_Server *svr; @@ -217,12 +297,15 @@ ecore_con_server_add(Ecore_Con_Type compl_type, const char *name, int port, svr->type = compl_type; svr->port = port; svr->data = (void *)data; - svr->created = 1; - svr->reject_excess_clients = 0; + svr->created = EINA_TRUE; + if (compl_type & ECORE_CON_LOAD_CERT) + svr->use_cert = EINA_TRUE; + svr->reject_excess_clients = EINA_FALSE; svr->client_limit = -1; svr->clients = NULL; svr->ppid = getpid(); - ecore_con_ssl_server_prepare(svr); + if (ecore_con_ssl_server_prepare(svr, compl_type & ECORE_CON_SSL)) + goto error; type = compl_type & ECORE_CON_TYPE; @@ -230,7 +313,7 @@ ecore_con_server_add(Ecore_Con_Type compl_type, const char *name, int port, (type == ECORE_CON_LOCAL_SYSTEM) || (type == ECORE_CON_LOCAL_ABSTRACT)) /* Local */ - if (!ecore_con_local_listen(svr, _ecore_con_svr_handler, svr)) + if (!ecore_con_local_listen(svr, _ecore_con_svr_tcp_handler, svr)) goto error; if ((type == ECORE_CON_REMOTE_TCP) || @@ -305,15 +388,17 @@ error: * @return A new Ecore_Con_Server. */ EAPI Ecore_Con_Server * -ecore_con_server_connect(Ecore_Con_Type compl_type, const char *name, int port, +ecore_con_server_connect(Ecore_Con_Type compl_type, + const char *name, + int port, const void *data) { Ecore_Con_Server *svr; Ecore_Con_Type type; if (!name) - return NULL; /* local user socket: FILE: ~/.ecore/[name]/[port] */ - + return NULL; + /* local user socket: FILE: ~/.ecore/[name]/[port] */ /* local system socket: FILE: /tmp/.ecore_service|[name]|[port] */ /* remote system socket: TCP/IP: [name]:[port] */ svr = calloc(1, sizeof(Ecore_Con_Server)); @@ -327,11 +412,13 @@ ecore_con_server_connect(Ecore_Con_Type compl_type, const char *name, int port, svr->type = compl_type; svr->port = port; svr->data = (void *)data; - svr->created = 0; - svr->reject_excess_clients = 0; + svr->created = EINA_FALSE; + svr->use_cert = (compl_type & ECORE_CON_LOAD_CERT); + svr->reject_excess_clients = EINA_FALSE; svr->clients = NULL; svr->client_limit = -1; - ecore_con_ssl_server_prepare(svr); + if (ecore_con_ssl_server_prepare(svr, compl_type & ECORE_CON_SSL)) + goto error; type = compl_type & ECORE_CON_TYPE; @@ -390,6 +477,44 @@ error: } /** + * Set the default time after which an inactive client will be disconnected + * @param svr The server object + * @param timeout The timeout, in seconds, to disconnect after + * This function is used to set the idle timeout on clients. A value of < 1 + * disables the idle timeout. + */ +EAPI void +ecore_con_server_timeout_set(Ecore_Con_Server *svr, double timeout) +{ + if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) + { + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_server_timeout_set"); + return; + } + + svr->client_disconnect_time = timeout; +} + +/** + * Get the default time after which an inactive client will be disconnected + * @param svr The server object + * @return The timeout, in seconds, to disconnect after + * This function is used to get the idle timeout for clients. A value of < 1 + * means the idle timeout is disabled. + */ +EAPI double +ecore_con_server_timeout_get(Ecore_Con_Server *svr) +{ + if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) + { + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_server_timeout_get"); + return 0; + } + + return svr->client_disconnect_time; +} + +/** * Closes the connection and frees the given server. * @param svr The given server. * @return Data associated with the server when it was created. @@ -411,7 +536,7 @@ ecore_con_server_del(Ecore_Con_Server *svr) data = svr->data; svr->data = NULL; - svr->delete_me = 1; + svr->delete_me = EINA_TRUE; if (svr->event_count > 0) { if (svr->fd_handler) @@ -471,24 +596,23 @@ ecore_con_server_data_set(Ecore_Con_Server *svr, void *data) /** * Retrieves whether the given server is currently connected. - * @todo Check that this function does what the documenter believes it does. * @param svr The given server. - * @return @c 1 if the server is connected. @c 0 otherwise. + * @return #EINA_TRUE if the server is connected. #EINA_FALSE otherwise. */ -EAPI int +EAPI Eina_Bool ecore_con_server_connected_get(Ecore_Con_Server *svr) { if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) { ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_server_connected_get"); - return 0; + return EINA_FALSE; } if (svr->connecting) - return 0; + return EINA_FALSE; - return 1; + return EINA_TRUE; } /** @@ -553,7 +677,9 @@ ecore_con_server_port_get(Ecore_Con_Server *svr) * error. */ EAPI int -ecore_con_server_send(Ecore_Con_Server *svr, const void *data, int size) +ecore_con_server_send(Ecore_Con_Server *svr, + const void *data, + int size) { if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) { @@ -571,8 +697,7 @@ ecore_con_server_send(Ecore_Con_Server *svr, const void *data, int size) return 0; if (svr->fd_handler) - ecore_main_fd_handler_active_set( - svr->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE); + ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE); if (svr->write_buf) { @@ -622,7 +747,8 @@ ecore_con_server_send(Ecore_Con_Server *svr, const void *data, int size) * lower). */ EAPI void -ecore_con_server_client_limit_set(Ecore_Con_Server *svr, int client_limit, +ecore_con_server_client_limit_set(Ecore_Con_Server *svr, + int client_limit, char reject_excess_clients) { if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) @@ -657,6 +783,24 @@ ecore_con_server_ip_get(Ecore_Con_Server *svr) return svr->ip; } + +/** + * @brief Check how long a server has been connected + * @param svr The server to check + * @return The total time, in seconds, that the server has been connected/running + * This function is used to find out how long a server has been connected/running for. + */ +EAPI double +ecore_con_server_uptime_get(Ecore_Con_Server *svr) +{ + if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) + { + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_server_uptime_get"); + return -1; + } + + return ecore_time_get() - svr->start_time; +} /** * Flushes all pending data to the given server. Will return when done. * @@ -674,29 +818,7 @@ ecore_con_server_flush(Ecore_Con_Server *svr) _ecore_con_server_flush(svr); } -/** - * Add an ssl certificate for use in ecore_con_server functions. - * - * Use this function to add a SSL PEM certificate. - * Simply specify the cert here to make it available, - * then OR the @ref ECORE_CON_LOAD_CERT flag into the @ref ecore_con_server_connect - * call to use it. If there is an error loading the certificate upon creating - * the connection, an error will be automatically logged. - * @param cert The path to the certificate. - * @return EINA_FALSE if the file cannot be loaded, - * otherwise EINA_TRUE. - * @note Currently certificate verification is not implemented. - */ - -EAPI Eina_Bool -ecore_con_server_ssl_cert_add(const char *cert) -{ - - if (!eina_str_has_extension(cert, "pem")) - return EINA_FALSE; - return ecore_con_ssl_server_cert_add(cert); -} /** * @} */ @@ -705,10 +827,16 @@ ecore_con_server_ssl_cert_add(const char *cert) * @addtogroup Ecore_Con_Client_Group Ecore Connection Client Functions * * Functions that operate on Ecore connection client objects. + * * @{ */ /** + * @example ecore_con_client_example.c + * Shows how to write a simple client that connects to the example server. +*/ + +/** * Sends the given data to the given client. * @param cl The given client. * @param data The given data. @@ -717,7 +845,9 @@ ecore_con_server_ssl_cert_add(const char *cert) * error. */ EAPI int -ecore_con_client_send(Ecore_Con_Client *cl, const void *data, int size) +ecore_con_client_send(Ecore_Con_Client *cl, + const void *data, + int size) { if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) { @@ -738,8 +868,8 @@ ecore_con_client_send(Ecore_Con_Client *cl, const void *data, int size) ecore_main_fd_handler_active_set( cl->fd_handler, ECORE_FD_READ | ECORE_FD_WRITE); - if(cl->server && ((cl->server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP)) - sendto(cl->server->fd, data, size, 0, (struct sockaddr *)cl->client_addr, + if(cl->host_server && ((cl->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP)) + sendto(cl->host_server->fd, data, size, 0, (struct sockaddr *)cl->client_addr, cl->client_addr_len); else if (cl->buf) { @@ -783,7 +913,48 @@ ecore_con_client_server_get(Ecore_Con_Client *cl) return NULL; } - return cl->server; + return cl->host_server; +} + +/** + * Set the time after which the client will be disconnected when inactive + * @param cl The client object + * @param timeout The timeout, in seconds, to disconnect after + * This function is used to set the idle timeout on a client. A value of < 1 + * disables the idle timeout. + */ +EAPI void +ecore_con_client_timeout_set(Ecore_Con_Client *cl, double timeout) +{ + if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) + { + ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, + "ecore_con_client_timeout_set"); + return; + } + + cl->disconnect_time = timeout; + + _ecore_con_cl_timer_update(cl); +} + +/** + * Get the default time after which the client will be disconnected when inactive + * @param cl The client object + * @return The timeout, in seconds, to disconnect after + * This function is used to get the idle timeout for a client. A value of < 1 + * means the idle timeout is disabled. + */ +EAPI double +ecore_con_client_timeout_get(Ecore_Con_Client *cl) +{ + if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) + { + ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_timeout_get"); + return 0; + } + + return cl->disconnect_time; } /** @@ -802,15 +973,15 @@ ecore_con_client_del(Ecore_Con_Client *cl) return NULL; } - if (cl->client_addr && cl->server && - (((cl->server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP) || - ((cl->server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))) + if (cl->client_addr && cl->host_server && + (((cl->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP) || + ((cl->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST))) free(cl->client_addr); data = cl->data; cl->data = NULL; - cl->delete_me = 1; + cl->delete_me = EINA_TRUE; if (cl->event_count > 0) { if (cl->fd_handler) @@ -821,9 +992,11 @@ ecore_con_client_del(Ecore_Con_Client *cl) } else { - if (cl->server) - cl->server->clients = eina_list_remove( - cl->server->clients, cl); + if (cl->host_server) + { + cl->host_server->clients = eina_list_remove(cl->host_server->clients, cl); + --cl->host_server->client_count; + } _ecore_con_client_free(cl); } @@ -891,6 +1064,24 @@ ecore_con_client_ip_get(Ecore_Con_Client *cl) } /** + * @brief Check how long a client has been connected + * @param cl The client to check + * @return The total time, in seconds, that the client has been connected to the server + * This function is used to find out how long a client has been connected for. + */ +EAPI double +ecore_con_client_uptime_get(Ecore_Con_Client *cl) +{ + if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_CON_CLIENT)) + { + ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_CON_CLIENT, "ecore_con_client_uptime_get"); + return -1; + } + + return ecore_time_get() - cl->start_time; +} + +/** * Flushes all pending data to the given client. Will return when done. * * @param cl The given client. @@ -908,107 +1099,9 @@ ecore_con_client_flush(Ecore_Con_Client *cl) } /** - * @brief Add an ssl certificate for use in ecore_con_client functions. - * - * Use this function to add a SSL PEM certificate. - * Simply specify the cert here to make it available, - * then OR the @ref ECORE_CON_LOAD_CERT flag into the @ref ecore_con_server_add - * call to use it. If there is an error loading the certificate upon creating - * the connection, an error will be automatically logged. - * @param cert_file The path to the certificate. - * @param crl_file The path to the CRL file - * @param key_file The path to the private key file. If not specified, the private key - * from the cert will be loaded. - * @return EINA_FALSE if the file cannot be loaded, - * otherwise EINA_TRUE. - * @note Currently CRL file adding and certificate verification is not implemented, - * so specifying it here has no effect. - */ - -EAPI Eina_Bool -ecore_con_client_ssl_cert_add(const char *cert_file, - const char *crl_file, - const char *key_file) -{ - - if (!eina_str_has_extension(cert_file, "pem")) - return EINA_FALSE; - - return ecore_con_ssl_client_cert_add(cert_file, crl_file, key_file); -} - -/** * @} */ -/** - * Do an asynchronous DNS lookup. - * - * This function performs a DNS lookup on the hostname specified by @p name, then - * calls @p done_cb with - * - * @params name IP address or server name to translate. - * @params done_cb Callback to notify when done. - * @params data User data to be given to done_cb. - * @return EINA_TRUE if the request did not fail to be set up, EINA_FALSE if it failed. - */ -EAPI Eina_Bool -ecore_con_lookup(const char *name, Ecore_Con_Dns_Cb done_cb, const void *data) -{ - Ecore_Con_Server *svr; - Ecore_Con_Lookup *lk; - struct addrinfo hints; - - if (!name || !done_cb) - return EINA_FALSE; - - svr = calloc(1, sizeof(Ecore_Con_Server)); - if (!svr) - return EINA_FALSE; - - lk = malloc(sizeof (Ecore_Con_Lookup)); - if (!lk) - { - free(svr); - return EINA_FALSE; - } - - lk->done_cb = done_cb; - lk->data = data; - - svr->name = strdup(name); - if (!svr->name) - goto on_error; - - svr->type = ECORE_CON_REMOTE_TCP; - svr->port = 1025; - svr->data = lk; - svr->created = 1; - svr->reject_excess_clients = 0; - svr->client_limit = -1; - svr->clients = NULL; - svr->ppid = getpid(); - - memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_INET6; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_CANONNAME; - hints.ai_protocol = IPPROTO_TCP; - hints.ai_canonname = NULL; - hints.ai_next = NULL; - hints.ai_addr = NULL; - - if (ecore_con_info_get(svr, _ecore_con_lookup_done, svr, - &hints)) - return EINA_TRUE; - - free(svr->name); -on_error: - free(lk); - free(svr); - return EINA_FALSE; -} - static void _ecore_con_server_free(Ecore_Con_Server *svr) { @@ -1030,19 +1123,19 @@ _ecore_con_server_free(Ecore_Con_Server *svr) break; } } + if (svr->write_buf) free(svr->write_buf); EINA_LIST_FREE(svr->clients, cl) - _ecore_con_client_free(cl); + _ecore_con_client_free(cl); if ((svr->created) && (svr->path) && (svr->ppid == getpid())) - unlink( - svr->path); + unlink(svr->path); + ecore_con_ssl_server_shutdown(svr); if (svr->fd >= 0) close(svr->fd); - ecore_con_ssl_server_shutdown(svr); if (svr->name) free(svr->name); @@ -1064,6 +1157,29 @@ _ecore_con_client_free(Ecore_Con_Client *cl) { double t_start, t; + if ((!cl->buf) && cl->delete_me && (!cl->dead) && (cl->event_count < 1)) + { + /* this is a catch-all for cases when a client is not properly killed. + * the only example case I've found so far is if a client ssl handshakes + * and then immediately disconnects without sending any further data. + */ + + /* we lost our client! */ + Ecore_Con_Event_Client_Del *e; + + cl->dead = EINA_TRUE; + e = calloc(1, sizeof(Ecore_Con_Event_Client_Del)); + if (e) + { + cl->event_count++; + _ecore_con_cl_timer_update(cl); + e->client = cl; + ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e, + _ecore_con_event_client_del_free, NULL); + return; + } + } + ECORE_MAGIC_SET(cl, ECORE_MAGIC_NONE); t_start = ecore_time_get(); while ((cl->buf) && (!cl->dead)) @@ -1082,6 +1198,9 @@ _ecore_con_client_free(Ecore_Con_Client *cl) if (cl->buf) free(cl->buf); + if (cl->host_server->type & ECORE_CON_SSL) + ecore_con_ssl_client_shutdown(cl); + if (cl->fd >= 0) close(cl->fd); @@ -1092,10 +1211,11 @@ _ecore_con_client_free(Ecore_Con_Client *cl) free(cl->ip); free(cl); + return; } static void -kill_server(Ecore_Con_Server *svr) +_ecore_con_server_kill(Ecore_Con_Server *svr) { if (!svr->delete_me) { @@ -1111,23 +1231,66 @@ kill_server(Ecore_Con_Server *svr) } } - svr->dead = 1; + svr->dead = EINA_TRUE; if (svr->fd_handler) ecore_main_fd_handler_del(svr->fd_handler); svr->fd_handler = NULL; } -static void -_ecore_con_cb_tcp_listen(void *data, Ecore_Con_Info *net_info) +static Eina_Bool +_ecore_con_client_timer(Ecore_Con_Client *cl) { - Ecore_Con_Server *svr; - struct linger lin; + ecore_con_client_del(cl); - svr = data; + return ECORE_CALLBACK_CANCEL; +} - if(!net_info) - goto error; +static void +_ecore_con_cl_timer_update(Ecore_Con_Client *cl) +{ + if (cl->disconnect_time) + { + if (cl->disconnect_time > 0) + { + if (cl->until_deletion) + ecore_timer_interval_set(cl->until_deletion, cl->disconnect_time); + else + cl->until_deletion = ecore_timer_add(cl->disconnect_time, (Ecore_Task_Cb)_ecore_con_client_timer, cl); + } + else if (cl->until_deletion) + { + ecore_timer_del(cl->until_deletion); + cl->until_deletion = NULL; + } + } + else + { + if (cl->host_server->client_disconnect_time > 0) + { + if (cl->until_deletion) + ecore_timer_interval_set(cl->until_deletion, cl->host_server->client_disconnect_time); + else + cl->until_deletion = ecore_timer_add(cl->host_server->client_disconnect_time, (Ecore_Task_Cb)_ecore_con_client_timer, cl); + } + else if (cl->until_deletion) + { + ecore_timer_del(cl->until_deletion); + cl->until_deletion = NULL; + } + } +} + +static void +_ecore_con_cb_tcp_listen(void *data, Ecore_Con_Info *net_info) +{ + Ecore_Con_Server *svr; + struct linger lin; + + svr = data; + + if(!net_info) + goto error; svr->fd = socket(net_info->info.ai_family, net_info->info.ai_socktype, net_info->info.ai_protocol); @@ -1162,9 +1325,8 @@ _ecore_con_cb_tcp_listen(void *data, Ecore_Con_Info *net_info) if (listen(svr->fd, 4096) < 0) goto error; - svr->fd_handler = - ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ, - _ecore_con_svr_handler, svr, NULL, NULL); + svr->fd_handler = ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ, + _ecore_con_svr_tcp_handler, svr, NULL, NULL); if (!svr->fd_handler) goto error; @@ -1172,7 +1334,7 @@ _ecore_con_cb_tcp_listen(void *data, Ecore_Con_Info *net_info) error: ecore_con_ssl_server_shutdown(svr); - kill_server(svr); + _ecore_con_server_kill(svr); } static void @@ -1248,7 +1410,7 @@ _ecore_con_cb_udp_listen(void *data, Ecore_Con_Info *net_info) error: ecore_con_ssl_server_shutdown(svr); - kill_server(svr); + _ecore_con_server_kill(svr); } static void @@ -1301,19 +1463,23 @@ _ecore_con_cb_tcp_connect(void *data, Ecore_Con_Info *net_info) goto error; #endif - svr->connecting = 1; + svr->connecting = EINA_TRUE; svr->fd_handler = ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ | ECORE_FD_WRITE, _ecore_con_cl_handler, svr, NULL, NULL); } else - svr->fd_handler = - ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ, + svr->fd_handler = ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ, _ecore_con_cl_handler, svr, NULL, NULL); if (svr->type & ECORE_CON_SSL) - if (ecore_con_ssl_server_init(svr)) - goto error; + { + svr->handshaking = EINA_TRUE; + svr->ssl_state = ECORE_CON_SSL_STATE_INIT; + DBG("beginning ssl handshake"); + if (ecore_con_ssl_server_init(svr)) + goto error; + } if (!svr->fd_handler) goto error; @@ -1324,7 +1490,7 @@ _ecore_con_cb_tcp_connect(void *data, Ecore_Con_Info *net_info) error: ecore_con_ssl_server_shutdown(svr); - kill_server(svr); + _ecore_con_server_kill(svr); } static void @@ -1357,16 +1523,13 @@ _ecore_con_cb_udp_connect(void *data, Ecore_Con_Info *net_info) goto error; } else if (setsockopt(svr->fd, SOL_SOCKET, SO_REUSEADDR, - (const void *)&curstate, - sizeof(curstate)) < 0) + (const void *)&curstate, sizeof(curstate)) < 0) goto error; - if (connect(svr->fd, net_info->info.ai_addr, - net_info->info.ai_addrlen) < 0) + if (connect(svr->fd, net_info->info.ai_addr, net_info->info.ai_addrlen) < 0) goto error; - else - svr->fd_handler = - ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ | ECORE_FD_WRITE, + + svr->fd_handler = ecore_main_fd_handler_add(svr->fd, ECORE_FD_READ | ECORE_FD_WRITE, _ecore_con_cl_udp_handler, svr, NULL, NULL); if (!svr->fd_handler) @@ -1378,7 +1541,7 @@ _ecore_con_cb_udp_connect(void *data, Ecore_Con_Info *net_info) error: ecore_con_ssl_server_shutdown(svr); - kill_server(svr); + _ecore_con_server_kill(svr); } static Ecore_Con_State @@ -1408,61 +1571,36 @@ svr_try_connect_plain(Ecore_Con_Server *svr) if (so_err != 0) { /* we lost our server! */ - kill_server(svr); + _ecore_con_server_kill(svr); return ECORE_CON_DISCONNECTED; } - else + + if ((!svr->delete_me) && (!svr->handshaking) && svr->connecting) { - if (!svr->delete_me) - { - /* we got our server! */ - Ecore_Con_Event_Server_Add *e; + /* we got our server! */ + Ecore_Con_Event_Server_Add *e; - svr->connecting = 0; - e = calloc(1, sizeof(Ecore_Con_Event_Server_Add)); - if (e) - { - svr->event_count++; - e->server = svr; - ecore_event_add(ECORE_CON_EVENT_SERVER_ADD, e, - _ecore_con_event_server_add_free, NULL); - } + svr->connecting = EINA_FALSE; + e = calloc(1, sizeof(Ecore_Con_Event_Server_Add)); + if (e) + { + svr->event_count++; + svr->start_time = ecore_time_get(); + e->server = svr; + ecore_event_add(ECORE_CON_EVENT_SERVER_ADD, e, + _ecore_con_event_server_add_free, NULL); } - - if (svr->fd_handler) - if (!svr->write_buf) - ecore_main_fd_handler_active_set(svr->fd_handler, - ECORE_FD_READ); - } + if (svr->fd_handler && (!svr->write_buf)) + ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ); + if (!svr->dead) return ECORE_CON_CONNECTED; else return ECORE_CON_DISCONNECTED; } -/* returns 1 on success, 0 on failure */ -static Ecore_Con_State svr_try_connect(Ecore_Con_Server *svr) -{ - if (!(svr->type & ECORE_CON_SSL)) - return svr_try_connect_plain(svr); - else - { - switch (ecore_con_ssl_server_try(svr)) { - case ECORE_CON_CONNECTED: - return svr_try_connect_plain(svr); - - case ECORE_CON_DISCONNECTED: - kill_server(svr); - return ECORE_CON_DISCONNECTED; - - default: - return ECORE_CON_INPROGRESS; - } - } -} - static char * _ecore_con_pretty_ip(struct sockaddr *client_addr, socklen_t size) { @@ -1495,9 +1633,10 @@ _ecore_con_pretty_ip(struct sockaddr *client_addr, socklen_t size) } static Eina_Bool -_ecore_con_svr_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__) +_ecore_con_svr_tcp_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__) { Ecore_Con_Server *svr; + Ecore_Con_Client *cl = NULL; int new_fd; unsigned char incoming[256]; size_t size_in; @@ -1509,10 +1648,9 @@ _ecore_con_svr_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__) if (svr->delete_me) return ECORE_CALLBACK_RENEW; - if ((svr->client_limit >= 0) && (!svr->reject_excess_clients)) - if (eina_list_count(svr->clients) >= - (unsigned int)svr->client_limit) - return ECORE_CALLBACK_RENEW; + if ((svr->client_limit >= 0) && (!svr->reject_excess_clients) && + (svr->client_count >= (unsigned int)svr->client_limit)) + return ECORE_CALLBACK_RENEW; /* a new client */ @@ -1520,68 +1658,144 @@ _ecore_con_svr_handler(void *data, Ecore_Fd_Handler *fd_handler __UNUSED__) memset(&incoming, 0, size_in); new_fd = accept(svr->fd, (struct sockaddr *)&incoming, (socklen_t *)&size_in); - if (new_fd >= 0) + if (new_fd < 0) + /* error! */ + return ECORE_CALLBACK_RENEW; + + if ((svr->client_limit >= 0) && (svr->reject_excess_clients) && + (svr->client_count >= (unsigned int)svr->client_limit)) + goto error; + + cl = calloc(1, sizeof(Ecore_Con_Client)); + if (!cl) + goto error; + + fcntl(new_fd, F_SETFL, O_NONBLOCK); + fcntl(new_fd, F_SETFD, FD_CLOEXEC); + cl->fd = new_fd; + cl->host_server = svr; + + cl->fd_handler = ecore_main_fd_handler_add(cl->fd, ECORE_FD_READ, + _ecore_con_svr_cl_handler, cl, NULL, NULL); + ECORE_MAGIC_SET(cl, ECORE_MAGIC_CON_CLIENT); + + + if (svr->type & ECORE_CON_SSL) { - Ecore_Con_Client *cl; + cl->handshaking = EINA_TRUE; + cl->ssl_state = ECORE_CON_SSL_STATE_INIT; + if (ecore_con_ssl_client_init(cl)) + goto error; + } - if ((svr->client_limit >= 0) && (svr->reject_excess_clients)) - if (eina_list_count(svr->clients) >= (unsigned int)svr->client_limit) - { - close(new_fd); - return ECORE_CALLBACK_RENEW; - } + svr->clients = eina_list_append(svr->clients, cl); + svr->client_count++; + if (!svr->path) + cl->ip = _ecore_con_pretty_ip((struct sockaddr *)&incoming, size_in); - cl = calloc(1, sizeof(Ecore_Con_Client)); - if (!cl) + if ((!cl->delete_me) && (!cl->handshaking)) + { + Ecore_Con_Event_Client_Add *e; + + e = calloc(1, sizeof(Ecore_Con_Event_Client_Add)); + if (e) { - close(new_fd); - return ECORE_CALLBACK_RENEW; + cl->event_count++; + _ecore_con_cl_timer_update(cl); + e->client = cl; + ecore_event_add(ECORE_CON_EVENT_CLIENT_ADD, e, + _ecore_con_event_client_add_free, NULL); } + } - fcntl(new_fd, F_SETFL, O_NONBLOCK); - fcntl(new_fd, F_SETFD, FD_CLOEXEC); - cl->fd = new_fd; - cl->server = svr; + return ECORE_CALLBACK_RENEW; - if ((svr->type & ECORE_CON_SSL) && - (ecore_con_ssl_client_init(cl))) +error: + close(new_fd); + if (cl->fd_handler) + ecore_main_fd_handler_del(cl->fd_handler); + return ECORE_CALLBACK_RENEW; +} + + +static void +_ecore_con_cl_read(Ecore_Con_Server *svr) +{ + unsigned char *inbuf = NULL; + int inbuf_num = 0; + int tries; + + /* only possible with non-ssl connections */ + if (svr->connecting && (svr_try_connect_plain(svr) != ECORE_CON_CONNECTED)) + return; + + for (tries = 0; tries < 16; tries++) + { + int num = 0; + Eina_Bool lost_server = EINA_TRUE; + unsigned char buf[READBUFSIZ]; + + if (svr->handshaking) { - close(new_fd); - ecore_con_ssl_client_shutdown(cl); - return ECORE_CALLBACK_RENEW; + DBG("Continuing ssl handshake"); + if (!ecore_con_ssl_server_init(svr)) + lost_server = EINA_FALSE; } - cl->fd_handler = - ecore_main_fd_handler_add(cl->fd, ECORE_FD_READ, - _ecore_con_svr_cl_handler, cl, NULL, NULL); - ECORE_MAGIC_SET(cl, ECORE_MAGIC_CON_CLIENT); - svr->clients = eina_list_append(svr->clients, cl); - if (!svr->path) - cl->ip = _ecore_con_pretty_ip( - (struct sockaddr *)&incoming, size_in); - - if (!cl->delete_me) + if (!(svr->type & ECORE_CON_SSL)) { - Ecore_Con_Event_Client_Add *e; + num = read(svr->fd, buf, READBUFSIZ); + if ((num < 0) && (errno == EAGAIN)) + lost_server = EINA_FALSE; + } + else if (!(num = ecore_con_ssl_server_read(svr, buf, READBUFSIZ))) + lost_server = EINA_FALSE; - e = calloc(1, sizeof(Ecore_Con_Event_Client_Add)); - if (e) + if (num < 1) + { + if (inbuf && (!svr->delete_me)) { - cl->event_count++; - e->client = cl; - ecore_event_add(ECORE_CON_EVENT_CLIENT_ADD, e, - _ecore_con_event_client_add_free, NULL); + Ecore_Con_Event_Server_Data *e; + + e = malloc(sizeof(Ecore_Con_Event_Server_Data)); + if (e) + { + svr->event_count++; + e->server = svr; + e->data = inbuf; + e->size = inbuf_num; + ecore_event_add(ECORE_CON_EVENT_SERVER_DATA, e, + _ecore_con_event_server_data_free, NULL); + } } + + if (lost_server) + _ecore_con_server_kill(svr); + + break; } + + inbuf = realloc(inbuf, inbuf_num + num); + memcpy(inbuf + inbuf_num, buf, num); + inbuf_num += num; } - return ECORE_CALLBACK_RENEW; +/* #if USE_OPENSSL */ +/* if (svr->fd_handler) */ +/* { */ +/* if (svr->ssl && ssl_err == SSL_ERROR_WANT_READ) */ +/* ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ); */ +/* else if (svr->ssl && ssl_err == SSL_ERROR_WANT_WRITE) */ +/* ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE); */ +/* } */ +/* #endif */ } static Eina_Bool _ecore_con_cl_handler(void *data, Ecore_Fd_Handler *fd_handler) { Ecore_Con_Server *svr; + Eina_Bool want_read, want_write; svr = data; if (svr->dead) @@ -1590,79 +1804,59 @@ _ecore_con_cl_handler(void *data, Ecore_Fd_Handler *fd_handler) if (svr->delete_me) return ECORE_CALLBACK_RENEW; - if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) - { - unsigned char *inbuf = NULL; - int inbuf_num = 0; - int tries; + want_read = ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ); + want_write = ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE); - if (svr->connecting && - (svr_try_connect(svr) != - ECORE_CON_CONNECTED)) - return ECORE_CALLBACK_RENEW; - - for (tries = 0; tries < 16; tries++) + if (svr->handshaking && (want_read || want_write)) + { + DBG("Continuing ssl handshake: preparing to %s...", want_read ? "read" : "write"); +#ifdef PRINT_LOTS_OF_DEBUG + if (want_read) + { + char buf[32768]; + ssize_t len; + len = recv(svr->fd, buf, sizeof(buf), MSG_DONTWAIT | MSG_PEEK); + DBG("%zu bytes in buffer", len); + } +#endif + if (ecore_con_ssl_server_init(svr)) { - int num; - int lost_server = 1; - unsigned char buf[READBUFSIZ]; + ERR("ssl handshaking failed!"); + Ecore_Con_Event_Server_Del *e; - if (!(svr->type & ECORE_CON_SSL)) + e = calloc(1, sizeof(Ecore_Con_Event_Server_Del)); + if (e) { - if ((num = read(svr->fd, buf, READBUFSIZ)) <= 0) - if ((num < 0) && (errno == EAGAIN)) - lost_server = 0; - + svr->event_count++; + e->server = svr; + ecore_event_add(ECORE_CON_EVENT_SERVER_DEL, e, + _ecore_con_event_server_del_free, NULL); } - else if (!(num = - ecore_con_ssl_server_read(svr, buf, - READBUFSIZ))) - lost_server = 0; + } + else if (!svr->ssl_state) + { + /* we got our server! */ + Ecore_Con_Event_Server_Add *e; - if (num < 1) + svr->connecting = EINA_FALSE; + e = calloc(1, sizeof(Ecore_Con_Event_Server_Add)); + if (e) { - if (inbuf && !svr->delete_me) - { - Ecore_Con_Event_Server_Data *e; - - e = calloc(1, sizeof(Ecore_Con_Event_Server_Data)); - if (e) - { - svr->event_count++; - e->server = svr; - e->data = inbuf; - e->size = inbuf_num; - ecore_event_add(ECORE_CON_EVENT_SERVER_DATA, e, - _ecore_con_event_server_data_free, - NULL); - } - } - - if (lost_server) - kill_server(svr); - - break; + svr->event_count++; + svr->start_time = ecore_time_get(); + e->server = svr; + ecore_event_add(ECORE_CON_EVENT_SERVER_ADD, e, + _ecore_con_event_server_add_free, NULL); } - - inbuf = realloc(inbuf, inbuf_num + num); - memcpy(inbuf + inbuf_num, buf, num); - inbuf_num += num; } -/* #if USE_OPENSSL */ -/* if (svr->fd_handler) */ -/* { */ -/* if (svr->ssl && ssl_err == SSL_ERROR_WANT_READ) */ -/* ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ); */ -/* else if (svr->ssl && ssl_err == SSL_ERROR_WANT_WRITE) */ -/* ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE); */ -/* } */ -/* #endif */ } - else if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE)) - { - if (svr->connecting && - !svr_try_connect (svr)) + + else if (want_read) + _ecore_con_cl_read(svr); + else if (want_write) + { /* only possible with non-ssl connections */ + if (svr->connecting && (!svr_try_connect_plain(svr))) return ECORE_CALLBACK_RENEW; _ecore_con_server_flush(svr); @@ -1686,7 +1880,7 @@ _ecore_con_cl_udp_handler(void *data, Ecore_Fd_Handler *fd_handler) if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) { unsigned char buf[65536]; - int num = 0; + int num; errno = 0; num = read(svr->fd, buf, 65536); @@ -1719,7 +1913,7 @@ _ecore_con_cl_udp_handler(void *data, Ecore_Fd_Handler *fd_handler) else if ((errno == EIO) || (errno == EBADF) || (errno == EPIPE) || (errno == EINVAL) || (errno == ENOSPC) || (errno == ECONNREFUSED)) - kill_server(svr); + _ecore_con_server_kill(svr); } else if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE)) @@ -1779,7 +1973,7 @@ _ecore_con_svr_udp_handler(void *data, Ecore_Fd_Handler *fd_handler) cl->buf = NULL; cl->fd = 0; cl->fd_handler = NULL; - cl->server = svr; + cl->host_server = svr; cl->client_addr = calloc(1, client_addr_len); cl->client_addr_len = client_addr_len; if(!cl->client_addr) @@ -1791,6 +1985,7 @@ _ecore_con_svr_udp_handler(void *data, Ecore_Fd_Handler *fd_handler) memcpy(cl->client_addr, &client_addr, client_addr_len); ECORE_MAGIC_SET(cl, ECORE_MAGIC_CON_CLIENT); svr->clients = eina_list_append(svr->clients, cl); + svr->client_count++; cl->ip = _ecore_con_pretty_ip(cl->client_addr, cl->client_addr_len); @@ -1809,6 +2004,7 @@ _ecore_con_svr_udp_handler(void *data, Ecore_Fd_Handler *fd_handler) if (e) { svr->event_count++; + _ecore_con_cl_timer_update(cl); e->client = cl; e->data = inbuf; e->size = num; @@ -1817,7 +2013,7 @@ _ecore_con_svr_udp_handler(void *data, Ecore_Fd_Handler *fd_handler) NULL); } - if(!cl->delete_me) + if (!cl->delete_me) { Ecore_Con_Event_Client_Add *add; @@ -1826,10 +2022,9 @@ _ecore_con_svr_udp_handler(void *data, Ecore_Fd_Handler *fd_handler) { /*cl->event_count++;*/ add->client = cl; - ecore_event_add(ECORE_CON_EVENT_CLIENT_ADD, - add, - _ecore_con_event_client_add_free, - NULL); + _ecore_con_cl_timer_update(cl); + ecore_event_add(ECORE_CON_EVENT_CLIENT_ADD, add, + _ecore_con_event_client_add_free, NULL); } } } @@ -1849,13 +2044,12 @@ _ecore_con_svr_udp_handler(void *data, Ecore_Fd_Handler *fd_handler) svr->event_count++; /* be explicit here */ e->client = NULL; - ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e, - _ecore_con_event_client_del_free, - NULL); + ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e, + _ecore_con_event_client_del_free, NULL); } } - svr->dead = 1; + svr->dead = EINA_TRUE; if (svr->fd_handler) ecore_main_fd_handler_del(svr->fd_handler); @@ -1869,6 +2063,93 @@ _ecore_con_svr_udp_handler(void *data, Ecore_Fd_Handler *fd_handler) return ECORE_CALLBACK_RENEW; } +static void +_ecore_con_svr_cl_read(Ecore_Con_Client *cl) +{ + unsigned char *inbuf = NULL; + int inbuf_num = 0; + int tries; + + for (tries = 0; tries < 16; tries++) + { + int num = 0; + Eina_Bool lost_client = EINA_TRUE; + unsigned char buf[READBUFSIZ]; + + errno = 0; + + if (cl->handshaking) + { + if (ecore_con_ssl_client_init(cl)) + lost_client = EINA_FALSE; + + _ecore_con_cl_timer_update(cl); + } + + if (!(cl->host_server->type & ECORE_CON_SSL)) + { + if ((num = read(cl->fd, buf, READBUFSIZ)) <= 0) + if ((num < 0) && (errno == EAGAIN)) + lost_client = EINA_FALSE; + + } + else if (!(num = ecore_con_ssl_client_read(cl, buf, READBUFSIZ))) + lost_client = EINA_FALSE; + + if (num > 0) + { + inbuf = realloc(inbuf, inbuf_num + num); + memcpy(inbuf + inbuf_num, buf, num); + inbuf_num += num; + continue; + } + + if (inbuf && (!cl->delete_me)) + { + Ecore_Con_Event_Client_Data *e; + + e = malloc(sizeof(Ecore_Con_Event_Client_Data)); + if (e) + { + cl->event_count++; + _ecore_con_cl_timer_update(cl); + e->client = cl; + e->data = inbuf; + e->size = inbuf_num; + ecore_event_add(ECORE_CON_EVENT_CLIENT_DATA, e, + _ecore_con_event_client_data_free, NULL); + } + } + + if (lost_client && (!cl->delete_me)) + { + /* we lost our client! */ + Ecore_Con_Event_Client_Del *e; + + e = calloc(1, sizeof(Ecore_Con_Event_Client_Del)); + if (e) + { + cl->event_count++; + _ecore_con_cl_timer_update(cl); + e->client = cl; + ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e, + _ecore_con_event_client_del_free, NULL); + } + } + + if (lost_client) + { + cl->dead = EINA_TRUE; + if (cl->fd_handler) + ecore_main_fd_handler_del(cl->fd_handler); + + cl->fd_handler = NULL; + } + + break; + } +} + static Eina_Bool _ecore_con_svr_cl_handler(void *data, Ecore_Fd_Handler *fd_handler) { @@ -1881,91 +2162,47 @@ _ecore_con_svr_cl_handler(void *data, Ecore_Fd_Handler *fd_handler) if (cl->delete_me) return ECORE_CALLBACK_RENEW; - if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) + if (cl->handshaking && ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ | ECORE_FD_WRITE)) { - unsigned char *inbuf = NULL; - int inbuf_num = 0; - int tries; - - for (tries = 0; tries < 16; tries++) + if (ecore_con_ssl_client_init(cl)) { - int num; - int lost_client = 1; - unsigned char buf[READBUFSIZ]; - - errno = 0; + ERR("ssl handshaking failed!"); + /* we lost our client! */ + Ecore_Con_Event_Client_Del *e; - if (!(cl->server->type & ECORE_CON_SSL)) + cl->dead = EINA_TRUE; + e = calloc(1, sizeof(Ecore_Con_Event_Client_Del)); + if (e) { - if ((num = read(cl->fd, buf, READBUFSIZ)) <= 0) - if ((num < 0) && (errno == EAGAIN)) - lost_client = 0; - + cl->event_count++; + _ecore_con_cl_timer_update(cl); + e->client = cl; + ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e, + _ecore_con_event_client_del_free, NULL); } - else if (!(num = - ecore_con_ssl_client_read(cl, buf, - READBUFSIZ))) - lost_client = 0; - - if (num < 1) - { - if (inbuf && !cl->delete_me) - { - Ecore_Con_Event_Client_Data *e; - - e = calloc(1, sizeof(Ecore_Con_Event_Client_Data)); - if (e) - { - cl->event_count++; - e->client = cl; - e->data = inbuf; - e->size = inbuf_num; - ecore_event_add(ECORE_CON_EVENT_CLIENT_DATA, e, - _ecore_con_event_client_data_free, - NULL); - } - } - - if (lost_client) - { - if (!cl->delete_me) - { - /* we lost our client! */ - Ecore_Con_Event_Client_Del *e; - - e = calloc(1, sizeof(Ecore_Con_Event_Client_Del)); - if (e) - { - cl->event_count++; - e->client = cl; - ecore_event_add( - ECORE_CON_EVENT_CLIENT_DEL, - e, - _ecore_con_event_client_del_free, - NULL); - } - } - cl->dead = 1; - if (cl->fd_handler) - ecore_main_fd_handler_del(cl->fd_handler); - - cl->fd_handler = NULL; - } + } + else if (!cl->ssl_state) + { + Ecore_Con_Event_Client_Add *add; - break; - } - else + add = calloc(1, sizeof(Ecore_Con_Event_Client_Add)); + if(add) { - inbuf = realloc(inbuf, inbuf_num + num); - memcpy(inbuf + inbuf_num, buf, num); - inbuf_num += num; +/*cl->event_count++;*/ + add->client = cl; + _ecore_con_cl_timer_update(cl); + ecore_event_add(ECORE_CON_EVENT_CLIENT_ADD, add, + _ecore_con_event_client_add_free, NULL); } } } - else if (ecore_main_fd_handler_active_get(fd_handler, - ECORE_FD_WRITE)) - _ecore_con_client_flush(cl); + + else if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ)) + _ecore_con_svr_cl_read(cl); + + else if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE)) + _ecore_con_client_flush(cl); return ECORE_CALLBACK_RENEW; } @@ -1987,17 +2224,23 @@ _ecore_con_server_flush(Ecore_Con_Server *svr) num = svr->write_buf_size - svr->write_buf_offset; + if (svr->handshaking) + { + DBG("Continuing ssl handshake"); + if (ecore_con_ssl_server_init(svr)) + _ecore_con_server_kill(svr); + return; + } + if (!(svr->type & ECORE_CON_SSL)) - count = write( - svr->fd, svr->write_buf + svr->write_buf_offset, num); + count = write(svr->fd, svr->write_buf + svr->write_buf_offset, num); else - count = ecore_con_ssl_server_write( - svr, svr->write_buf + svr->write_buf_offset, num); + count = ecore_con_ssl_server_write(svr, svr->write_buf + svr->write_buf_offset, num); - if (count < 1) + if (count < 0) { /* we lost our server! */ - kill_server(svr); + _ecore_con_server_kill(svr); return; } @@ -2009,27 +2252,37 @@ _ecore_con_server_flush(Ecore_Con_Server *svr) free(svr->write_buf); svr->write_buf = NULL; if (svr->fd_handler) - ecore_main_fd_handler_active_set(svr->fd_handler, - ECORE_FD_READ); + ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ); } } static void _ecore_con_client_flush(Ecore_Con_Client *cl) { - int count, num; + int num, count = 0; if (!cl->buf) return; - num = cl->buf_size - cl->buf_offset; - if (!(cl->server->type & ECORE_CON_SSL)) - count = write( - cl->fd, cl->buf + cl->buf_offset, num); - else - count = ecore_con_ssl_client_write(cl, cl->buf + cl->buf_offset, num); + if (cl->handshaking) + { + if (ecore_con_ssl_client_init(cl)) + count = -1; - if (count < 1) + _ecore_con_cl_timer_update(cl); + return; + } + + if (!count) + { + num = cl->buf_size - cl->buf_offset; + if (!(cl->host_server->type & ECORE_CON_SSL)) + count = write(cl->fd, cl->buf + cl->buf_offset, num); + else + count = ecore_con_ssl_client_write(cl, cl->buf + cl->buf_offset, num); + } + + if (count < 0) { if ((errno == EIO) || (errno == EBADF) || (errno == EPIPE) || (errno == EINVAL) || (errno == ENOSPC) || (errno == ECONNREFUSED)) @@ -2042,12 +2295,13 @@ _ecore_con_client_flush(Ecore_Con_Client *cl) if (e) { cl->event_count++; + _ecore_con_cl_timer_update(cl); e->client = cl; ecore_event_add(ECORE_CON_EVENT_CLIENT_DEL, e, _ecore_con_event_client_del_free, NULL); } - cl->dead = 1; + cl->dead = EINA_TRUE; if (cl->fd_handler) ecore_main_fd_handler_del(cl->fd_handler); @@ -2065,8 +2319,7 @@ _ecore_con_client_flush(Ecore_Con_Client *cl) free(cl->buf); cl->buf = NULL; if (cl->fd_handler) - ecore_main_fd_handler_active_set(cl->fd_handler, - ECORE_FD_READ); + ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_READ); } } @@ -2091,8 +2344,7 @@ _ecore_con_event_client_del_free(void *data __UNUSED__, void *ev) e = ev; e->client->event_count--; - if ((e->client->event_count == 0) && - (e->client->delete_me)) + if ((e->client->event_count == 0) && (e->client->delete_me)) ecore_con_client_del(e->client); free(e); @@ -2109,9 +2361,9 @@ _ecore_con_event_client_data_free(void *data __UNUSED__, void *ev) free(e->data); if (((e->client->event_count == 0) && (e->client->delete_me)) || - ((e->client->server && - ((e->client->server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP || - (e->client->server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST)))) + ((e->client->host_server && + ((e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_UDP || + (e->client->host_server->type & ECORE_CON_TYPE) == ECORE_CON_REMOTE_MCAST)))) ecore_con_client_del(e->client); free(e); @@ -2182,4 +2434,3 @@ _ecore_con_lookup_done(void *data, Ecore_Con_Info *infos) free(lk); free(svr); } - diff --git a/src/lib/ecore_con/ecore_con_info.c b/src/lib/ecore_con/ecore_con_info.c index edb8b63..55fd609 100644 --- a/src/lib/ecore_con/ecore_con_info.c +++ b/src/lib/ecore_con/ecore_con_info.c @@ -246,16 +246,16 @@ ecore_con_info_get(Ecore_Con_Server *svr, { if (result->ai_canonname) canonname_len = strlen(result->ai_canonname) + 1; - + tosend_len = sizeof(Ecore_Con_Info) + result->ai_addrlen + canonname_len; - + if (!(tosend = alloca(tosend_len))) goto on_error; memset(tosend, 0, tosend_len); - + container = (Ecore_Con_Info *)tosend; container->size = tosend_len; - + memcpy(&container->info, result, sizeof(struct addrinfo)); @@ -265,7 +265,7 @@ ecore_con_info_get(Ecore_Con_Server *svr, memcpy(tosend + sizeof(Ecore_Con_Info) + result->ai_addrlen, result->ai_canonname, canonname_len); - + if (!getnameinfo(result->ai_addr, result->ai_addrlen, hbuf, sizeof(hbuf), sbuf, sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) @@ -273,14 +273,14 @@ ecore_con_info_get(Ecore_Con_Server *svr, memcpy(container->ip, hbuf, sizeof(container->ip)); memcpy(container->service, sbuf, sizeof(container->service)); } - + err = write(fd[1], tosend, tosend_len); } on_error: if (result) freeaddrinfo(result); - + err = write(fd[1], "", 1); close(fd[1]); #ifdef __USE_ISOC99 @@ -289,7 +289,7 @@ on_error: _exit(0); #endif } - + /* PARENT */ cbdata->handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _ecore_con_info_exit_handler, @@ -302,7 +302,7 @@ on_error: close(fd[0]); return 0; } - + info_slaves = (CB_Data *)eina_inlist_append(EINA_INLIST_GET( info_slaves), EINA_INLIST_GET(cbdata)); @@ -325,13 +325,13 @@ _ecore_con_info_readdata(CB_Data *cbdata) { torecv_len = container.size; torecv = malloc(torecv_len); - + memcpy(torecv, &container, sizeof(Ecore_Con_Info)); - - size = read(ecore_main_fd_handler_fd_get(cbdata->fdh), + + size = read(ecore_main_fd_handler_fd_get(cbdata->fdh), torecv + sizeof(Ecore_Con_Info), torecv_len - sizeof(Ecore_Con_Info)); - if ((size > 0) && + if ((size > 0) && ((size_t)size == torecv_len - sizeof(Ecore_Con_Info))) { recv = (Ecore_Con_Info *)torecv; @@ -340,15 +340,15 @@ _ecore_con_info_readdata(CB_Data *cbdata) (struct sockaddr *)(torecv + sizeof(Ecore_Con_Info)); if ((size_t)torecv_len != (sizeof(Ecore_Con_Info) + recv->info.ai_addrlen)) - recv->info.ai_canonname = - torecv + sizeof(Ecore_Con_Info) + recv->info.ai_addrlen; + recv->info.ai_canonname = (char *) + (torecv + sizeof(Ecore_Con_Info) + recv->info.ai_addrlen); else recv->info.ai_canonname = NULL; - + recv->info.ai_next = NULL; - + cbdata->cb_done(cbdata->data, recv); - + free(torecv); } else @@ -356,7 +356,7 @@ _ecore_con_info_readdata(CB_Data *cbdata) } else cbdata->cb_done(cbdata->data, NULL); - + cbdata->cb_done = NULL; } diff --git a/src/lib/ecore_con/ecore_con_private.h b/src/lib/ecore_con/ecore_con_private.h index feaa9aa..5eaaf47 100644 --- a/src/lib/ecore_con/ecore_con_private.h +++ b/src/lib/ecore_con/ecore_con_private.h @@ -75,11 +75,18 @@ typedef enum _Ecore_Con_Ssl_Error ECORE_CON_SSL_ERROR_SSL2_NOT_SUPPORTED } Ecore_Con_Ssl_Error; +typedef enum _Ecore_Con_Ssl_Handshake +{ + ECORE_CON_SSL_STATE_DONE = 0, + ECORE_CON_SSL_STATE_HANDSHAKING, + ECORE_CON_SSL_STATE_INIT +} Ecore_Con_Ssl_State; + struct _Ecore_Con_Client { ECORE_MAGIC; int fd; - Ecore_Con_Server *server; + Ecore_Con_Server *host_server; void *data; Ecore_Fd_Handler *fd_handler; int buf_size; @@ -89,15 +96,20 @@ struct _Ecore_Con_Client int event_count; struct sockaddr *client_addr; int client_addr_len; + double start_time; + Ecore_Timer *until_deletion; + double disconnect_time; #if USE_GNUTLS - gnutls_session session; + gnutls_datum_t session_ticket; + gnutls_session_t session; #elif USE_OPENSSL - SSL_CTX *ssl_ctx; SSL *ssl; int ssl_err; #endif - char dead : 1; - char delete_me : 1; + Eina_Bool handshaking : 1; + Ecore_Con_Ssl_State ssl_state; + Eina_Bool dead : 1; + Eina_Bool delete_me : 1; }; struct _Ecore_Con_Server @@ -111,6 +123,7 @@ struct _Ecore_Con_Server void *data; Ecore_Fd_Handler *fd_handler; Eina_List *clients; + unsigned int client_count; int write_buf_size; int write_buf_offset; unsigned char *write_buf; @@ -118,21 +131,31 @@ struct _Ecore_Con_Server int client_limit; pid_t ppid; #if USE_GNUTLS - gnutls_session session; + gnutls_session_t session; gnutls_anon_client_credentials_t anoncred_c; gnutls_anon_server_credentials_t anoncred_s; + gnutls_psk_client_credentials_t pskcred_c; + gnutls_psk_server_credentials_t pskcred_s; gnutls_certificate_credentials_t cert; + char *cert_file; + gnutls_dh_params_t dh_params; #elif USE_OPENSSL SSL_CTX *ssl_ctx; SSL *ssl; int ssl_err; #endif + double start_time; + double client_disconnect_time; char *ip; - char dead : 1; - char created : 1; - char connecting : 1; - char reject_excess_clients : 1; - char delete_me : 1; + Eina_Bool dead : 1; + Eina_Bool created : 1; /* EINA_TRUE if server is our listening server */ + Eina_Bool connecting : 1; /* EINA_FALSE if just initialized or connected */ + Eina_Bool handshaking : 1; /* EINA_TRUE if server is ssl handshaking */ + Eina_Bool use_cert : 1; /* EINA_TRUE if using certificate auth */ + Ecore_Con_Ssl_State ssl_state; /* current state of ssl handshake on the server */ + Eina_Bool verify : 1; /* EINA_TRUE if certificates will be verified */ + Eina_Bool reject_excess_clients : 1; + Eina_Bool delete_me : 1; }; #ifdef HAVE_CURL @@ -141,13 +164,12 @@ struct _Ecore_Con_Url ECORE_MAGIC; CURL *curl_easy; struct curl_slist *headers; - struct curl_httppost *post; Eina_List *additional_headers; Eina_List *response_headers; char *url; - Ecore_Con_Url_Time condition; - time_t time; + Ecore_Con_Url_Time time_condition; + double timestamp; void *data; Ecore_Fd_Handler *fd_handler; @@ -157,7 +179,7 @@ struct _Ecore_Con_Url int received; int write_fd; - unsigned char active : 1; + Eina_Bool active : 1; }; #endif @@ -211,14 +233,9 @@ int ecore_con_info_mcast_listen(Ecore_Con_Server *svr, /* from ecore_con_ssl.c */ Ecore_Con_Ssl_Error ecore_con_ssl_init(void); Ecore_Con_Ssl_Error ecore_con_ssl_shutdown(void); -Eina_Bool ecore_con_ssl_server_cert_add(const char *cert); -Eina_Bool ecore_con_ssl_client_cert_add(const char *cert_file, - const char *crl_file, - const char *key_file); -void ecore_con_ssl_server_prepare(Ecore_Con_Server *svr); +Ecore_Con_Ssl_Error ecore_con_ssl_server_prepare(Ecore_Con_Server *svr, int ssl_type); Ecore_Con_Ssl_Error ecore_con_ssl_server_init(Ecore_Con_Server *svr); Ecore_Con_Ssl_Error ecore_con_ssl_server_shutdown(Ecore_Con_Server *svr); -Ecore_Con_State ecore_con_ssl_server_try(Ecore_Con_Server *svr); int ecore_con_ssl_server_read(Ecore_Con_Server *svr, unsigned char *buf, int size); @@ -227,7 +244,6 @@ int ecore_con_ssl_server_write(Ecore_Con_Server *svr, int size); Ecore_Con_Ssl_Error ecore_con_ssl_client_init(Ecore_Con_Client *svr); Ecore_Con_Ssl_Error ecore_con_ssl_client_shutdown(Ecore_Con_Client *svr); -Ecore_Con_State ecore_con_ssl_client_try(Ecore_Con_Client *svr); int ecore_con_ssl_client_read(Ecore_Con_Client *svr, unsigned char *buf, int size); diff --git a/src/lib/ecore_con/ecore_con_ssl.c b/src/lib/ecore_con/ecore_con_ssl.c index 31469f2..ebc70ad 100644 --- a/src/lib/ecore_con/ecore_con_ssl.c +++ b/src/lib/ecore_con/ecore_con_ssl.c @@ -9,6 +9,7 @@ #elif USE_OPENSSL # include # include +# include #endif #ifdef HAVE_WS2TCPIP_H @@ -24,6 +25,7 @@ static int _init_con_ssl_init_count = 0; #if USE_GNUTLS # ifdef EFL_HAVE_PTHREAD +#include GCRY_THREAD_OPTION_PTHREAD_IMPL; # endif @@ -43,51 +45,91 @@ static int _client_connected = 0; #endif #if USE_GNUTLS -typedef struct _cert_thingy +static void +_gnutls_print_errors(int ret) +{ + if (ret) + ERR("gnutls returned with error: %s - %s", gnutls_strerror_name(ret), gnutls_strerror(ret)); +} + + +static const char* +SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_description_t status) { - gnutls_certificate_credentials_t cert; - int count; -} gnutls; -static gnutls *client_cert = NULL; -static gnutls *server_cert = NULL; + switch (status) + { + case GNUTLS_HANDSHAKE_HELLO_REQUEST: + return "Hello request"; + case GNUTLS_HANDSHAKE_CLIENT_HELLO: + return "Client hello"; + case GNUTLS_HANDSHAKE_SERVER_HELLO: + return "Server hello"; + case GNUTLS_HANDSHAKE_NEW_SESSION_TICKET: + return "New session ticket"; + case GNUTLS_HANDSHAKE_CERTIFICATE_PKT: + return "Certificate packet"; + case GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE: + return "Server key exchange"; + case GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST: + return "Certificate request"; + case GNUTLS_HANDSHAKE_SERVER_HELLO_DONE: + return "Server hello done"; + case GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY: + return "Certificate verify"; + case GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE: + return "Client key exchange"; + case GNUTLS_HANDSHAKE_FINISHED: + return "Finished"; + case GNUTLS_HANDSHAKE_SUPPLEMENTAL: + return "Supplemental"; + } + return NULL; +} + #elif USE_OPENSSL -typedef struct _cert_thingy -{ - X509 *cert; - int count; -} openssl; -typedef struct _key_thingy -{ - EVP_PKEY *key; - int count; -} openssl_pkey; -static openssl_pkey *private_key = NULL; -static openssl *client_cert = NULL; -static openssl *server_cert = NULL; + +static void +_openssl_print_errors(void) +{ + do + { + unsigned long err; + + err = ERR_get_error(); + if (!err) break; + ERR("openssl error: %s", ERR_reason_error_string(err)); + } while (1); +} #endif +#define SSL_ERROR_CHECK_GOTO_ERROR(X) \ +do \ + { \ + if ((X)) \ + { \ + ERR("Error at %s:%s:%d!", __FILE__, __PRETTY_FUNCTION__, __LINE__); \ + goto error; \ + } \ + } \ +while (0) + + static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_init) (void); static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_shutdown) (void); -static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_client_cert_add) (const char * - cert_file, - const char * - crl_file, - const char * - key_file); -static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cert_add) (const char *cert); +static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cafile_add) (Ecore_Con_Server *svr, const char *ca_file); +static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_crl_add) (Ecore_Con_Server *svr, const char *crl_file); +static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_cert_add) (Ecore_Con_Server *svr, const char *cert); +static Eina_Bool SSL_SUFFIX(_ecore_con_ssl_server_privkey_add) (Ecore_Con_Server *svr, const char *key_file); -static void SSL_SUFFIX(_ecore_con_ssl_server_prepare) (Ecore_Con_Server * - svr); +static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_prepare)(Ecore_Con_Server *svr, int ssl_type); static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_init) (Ecore_Con_Server * svr); static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_server_shutdown) (Ecore_Con_Server * svr); -static Ecore_Con_State - SSL_SUFFIX(_ecore_con_ssl_server_try) (Ecore_Con_Server * svr); static int SSL_SUFFIX(_ecore_con_ssl_server_read) (Ecore_Con_Server * svr, unsigned char *buf, int size); @@ -96,9 +138,6 @@ static int svr, unsigned char *buf, int size); -static void - SSL_SUFFIX(_ecore_con_ssl_client_prepare) (Ecore_Con_Client * - cl); static Ecore_Con_Ssl_Error SSL_SUFFIX(_ecore_con_ssl_client_init) (Ecore_Con_Client * cl); static Ecore_Con_Ssl_Error @@ -128,67 +167,35 @@ Ecore_Con_Ssl_Error ecore_con_ssl_shutdown(void) { if (!--_init_con_ssl_init_count) - { -#if USE_OPENSSL || USE_GNUTLS - if (client_cert) - client_cert->count = 0; - - if (server_cert) - server_cert->count = 0; -#endif -#if USE_OPENSSL && !USE_GNUTLS - if (private_key) - private_key->count = 0; - -#endif - SSL_SUFFIX(_ecore_con_ssl_shutdown) (); - } + SSL_SUFFIX(_ecore_con_ssl_shutdown) (); return _init_con_ssl_init_count; } -/** - * Returns if SSL support is available - * @return 1 if SSL is available, 0 if it is not. - * @ingroup Ecore_Con_Client_Group - */ -int -ecore_con_ssl_available_get(void) -{ - return _ECORE_CON_SSL_AVAILABLE; -} - - -void -ecore_con_ssl_server_prepare(Ecore_Con_Server *svr) +Ecore_Con_Ssl_Error +ecore_con_ssl_server_prepare(Ecore_Con_Server *svr, int ssl_type) { - SSL_SUFFIX(_ecore_con_ssl_server_prepare) (svr); + if (!ssl_type) + return ECORE_CON_SSL_ERROR_NONE; + return SSL_SUFFIX(_ecore_con_ssl_server_prepare) (svr, ssl_type); } Ecore_Con_Ssl_Error ecore_con_ssl_server_init(Ecore_Con_Server *svr) { + if (!(svr->type & ECORE_CON_SSL)) + return ECORE_CON_SSL_ERROR_NONE; return SSL_SUFFIX(_ecore_con_ssl_server_init) (svr); } -Eina_Bool -ecore_con_ssl_server_cert_add(const char *cert) -{ - return SSL_SUFFIX(_ecore_con_ssl_server_cert_add) (cert); -} - Ecore_Con_Ssl_Error ecore_con_ssl_server_shutdown(Ecore_Con_Server *svr) { + if (!(svr->type & ECORE_CON_SSL)) + return ECORE_CON_SSL_ERROR_NONE; return SSL_SUFFIX(_ecore_con_ssl_server_shutdown) (svr); } -Ecore_Con_State -ecore_con_ssl_server_try(Ecore_Con_Server *svr) -{ - return SSL_SUFFIX(_ecore_con_ssl_server_try) (svr); -} - int ecore_con_ssl_server_read(Ecore_Con_Server *svr, unsigned char *buf, int size) { @@ -204,21 +211,16 @@ ecore_con_ssl_server_write(Ecore_Con_Server *svr, unsigned char *buf, int size) Ecore_Con_Ssl_Error ecore_con_ssl_client_init(Ecore_Con_Client *cl) { + if (!(cl->host_server->type & ECORE_CON_SSL)) + return ECORE_CON_SSL_ERROR_NONE; return SSL_SUFFIX(_ecore_con_ssl_client_init) (cl); } -Eina_Bool -ecore_con_ssl_client_cert_add(const char *cert_file, - const char *crl_file, - const char *key_file) -{ - return SSL_SUFFIX(_ecore_con_ssl_client_cert_add) (cert_file, crl_file, - key_file); -} - Ecore_Con_Ssl_Error ecore_con_ssl_client_shutdown(Ecore_Con_Client *cl) { + if (!(cl->host_server->type & ECORE_CON_SSL)) + return ECORE_CON_SSL_ERROR_NONE; return SSL_SUFFIX(_ecore_con_ssl_client_shutdown) (cl); } @@ -234,6 +236,142 @@ ecore_con_ssl_client_write(Ecore_Con_Client *cl, unsigned char *buf, int size) return SSL_SUFFIX(_ecore_con_ssl_client_write) (cl, buf, size); } +/** + * Returns if SSL support is available + * @return 1 if SSL is available and provided by gnutls, 2 if provided by openssl, + * 0 if it is not available. + * @ingroup Ecore_Con_Client_Group + */ +EAPI int +ecore_con_ssl_available_get(void) +{ + return _ECORE_CON_SSL_AVAILABLE; +} + +/** + * @addtogroup Ecore_Con_SSL_Group Ecore Connection SSL Functions + * + * Functions that operate on Ecore connection objects pertaining to SSL. + * + * @{ + */ + +/** + * @brief Enable certificate verification on a server object + * + * Call this function on a server object before main loop has started + * to enable verification of certificates against loaded certificates. + * @param svr The server object + */ +EAPI void +ecore_con_ssl_server_verify(Ecore_Con_Server *svr) +{ + if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) + { + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_ssl_server_verify"); + return; + } + svr->verify = EINA_TRUE; +} + +/** + * @brief Add an ssl certificate for use in ecore_con functions. + * + * Use this function to add a SSL PEM certificate. + * Simply specify the cert here to use it in the server object for connecting or listening. + * If there is an error loading the certificate, an error will automatically be logged. + * @param cert The path to the certificate. + * @return EINA_FALSE if the file cannot be loaded, otherwise EINA_TRUE. + */ + +EAPI Eina_Bool +ecore_con_ssl_server_cert_add(Ecore_Con_Server *svr, + const char *cert) +{ + if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) + { + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_ssl_server_cert_add"); + return EINA_FALSE; + } + + return SSL_SUFFIX(_ecore_con_ssl_server_cert_add)(svr, cert); +} + +/** + * @brief Add an ssl CA file for use in ecore_con functions. + * + * Use this function to add a SSL PEM CA file. + * Simply specify the file here to use it in the server object for connecting or listening. + * If there is an error loading the CAs, an error will automatically be logged. + * @param ca_file The path to the CA file. + * @return EINA_FALSE if the file cannot be loaded, otherwise EINA_TRUE. + */ + +EAPI Eina_Bool +ecore_con_ssl_server_cafile_add(Ecore_Con_Server *svr, + const char *ca_file) +{ + if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) + { + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_ssl_server_cafile_add"); + return EINA_FALSE; + } + + return SSL_SUFFIX(_ecore_con_ssl_server_cafile_add)(svr, ca_file); +} + +/** + * @brief Add an ssl private key for use in ecore_con functions. + * + * Use this function to add a SSL PEM private key + * Simply specify the key file here to use it in the server object for connecting or listening. + * If there is an error loading the key, an error will automatically be logged. + * @param key_file The path to the key file. + * @return EINA_FALSE if the file cannot be loaded, + * otherwise EINA_TRUE. + */ + +EAPI Eina_Bool +ecore_con_ssl_server_privkey_add(Ecore_Con_Server *svr, + const char *key_file) +{ + if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) + { + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_ssl_server_privkey_add"); + return EINA_FALSE; + } + + return SSL_SUFFIX(_ecore_con_ssl_server_privkey_add)(svr, key_file); +} + +/** + * @brief Add an ssl CRL for use in ecore_con functions. + * + * Use this function to add a SSL PEM CRL file + * Simply specify the CRL file here to use it in the server object for connecting or listening. + * If there is an error loading the CRL, an error will automatically be logged. + * @param crl_file The path to the CRL file. + * @return EINA_FALSE if the file cannot be loaded, + * otherwise EINA_TRUE. + */ + +EAPI Eina_Bool +ecore_con_ssl_server_crl_add(Ecore_Con_Server *svr, + const char *crl_file) +{ + if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_CON_SERVER)) + { + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_CON_SERVER, "ecore_con_ssl_server_crl_add"); + return EINA_FALSE; + } + + return SSL_SUFFIX(_ecore_con_ssl_server_crl_add)(svr, crl_file); +} + +/** + * @} + */ + #if USE_GNUTLS /* @@ -263,12 +401,39 @@ _ecore_con_ssl_shutdown_gnutls(void) return ECORE_CON_SSL_ERROR_NONE; } -static void -_ecore_con_ssl_server_prepare_gnutls(Ecore_Con_Server *svr) +static Ecore_Con_Ssl_Error +_ecore_con_ssl_server_prepare_gnutls(Ecore_Con_Server *svr, int ssl_type __UNUSED__) { - svr->session = NULL; - svr->anoncred_c = NULL; - return; + int ret; + + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_certificate_allocate_credentials(&svr->cert)); + + if (svr->created) + { + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_dh_params_init(&svr->dh_params)); + INF("Generating DH params"); + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_dh_params_generate2(svr->dh_params, 1024)); + + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_anon_allocate_server_credentials(&svr->anoncred_s)); + /* TODO: implement PSK */ + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_psk_allocate_server_credentials(&svr->pskcred_s)); + + gnutls_anon_set_server_dh_params(svr->anoncred_s, svr->dh_params); + gnutls_certificate_set_dh_params(svr->cert, svr->dh_params); + gnutls_psk_set_server_dh_params(svr->pskcred_s, svr->dh_params); + } + else + { + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_psk_allocate_client_credentials(&svr->pskcred_c)); + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_anon_allocate_client_credentials(&svr->anoncred_c)); + } + + return ECORE_CON_SSL_ERROR_NONE; + +error: + _gnutls_print_errors(ret); + _ecore_con_ssl_server_shutdown_gnutls(svr); + return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; } /* Tries to connect an Ecore_Con_Server to an SSL host. @@ -278,105 +443,173 @@ _ecore_con_ssl_server_prepare_gnutls(Ecore_Con_Server *svr) static Ecore_Con_Ssl_Error _ecore_con_ssl_server_init_gnutls(Ecore_Con_Server *svr) { - const int *proto = NULL; + const gnutls_datum_t *cert_list; + unsigned int iter, cert_list_size; + gnutls_x509_crt_t cert = NULL; + const char *priority = "NONE:%VERIFY_ALLOW_X509_V1_CA_CRT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+COMP-DEFLATE:+COMP-NULL:+CTYPE-X509:+SHA1:+SHA256:+SHA384:+SHA512:+AES-256-CBC:+AES-128-CBC:+3DES-CBC:+VERS-TLS1.2:+VERS-TLS1.1:+VERS-TLS1.0:+VERS-SSL3.0"; int ret = 0; - const int kx[] = { GNUTLS_KX_ANON_DH, 0 }; - const int ssl3_proto[] = { GNUTLS_SSL3, 0 }; - const int tls_proto[] = { - GNUTLS_TLS1_0, - GNUTLS_TLS1_1, -#ifdef USE_GNUTLS2 - GNUTLS_TLS1_2, -#endif - 0 - }; - switch (svr->type & ECORE_CON_SSL) + switch (svr->ssl_state) { - case ECORE_CON_USE_SSL2: /* not supported because of security issues */ - return ECORE_CON_SSL_ERROR_SSL2_NOT_SUPPORTED; - - case ECORE_CON_USE_SSL3: - proto = ssl3_proto; - break; + case ECORE_CON_SSL_STATE_DONE: + return ECORE_CON_SSL_ERROR_NONE; + case ECORE_CON_SSL_STATE_INIT: + if (svr->type & ECORE_CON_USE_SSL2) /* not supported because of security issues */ + return ECORE_CON_SSL_ERROR_SSL2_NOT_SUPPORTED; - case ECORE_CON_USE_TLS: - proto = tls_proto; - break; + switch (svr->type & ECORE_CON_SSL) + { + case ECORE_CON_USE_SSL3: + case ECORE_CON_USE_SSL3 | ECORE_CON_LOAD_CERT: + priority = "NONE:%VERIFY_ALLOW_X509_V1_CA_CRT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+COMP-DEFLATE:+COMP-NULL:+CTYPE-X509:+SHA1:+SHA256:+SHA384:+SHA512:+AES-256-CBC:+AES-128-CBC:+3DES-CBC:!VERS-TLS1.0:!VERS-TLS1.1"; + break; + + case ECORE_CON_USE_TLS: + case ECORE_CON_USE_TLS | ECORE_CON_LOAD_CERT: + priority = "NONE:%VERIFY_ALLOW_X509_V1_CA_CRT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+COMP-DEFLATE:+COMP-NULL:+CTYPE-X509:+SHA1:+SHA256:+SHA384:+SHA512:+AES-256-CBC:+AES-128-CBC:+3DES-CBC:!VERS-SSL3.0"; + break; + + case ECORE_CON_USE_MIXED: + case ECORE_CON_USE_MIXED | ECORE_CON_LOAD_CERT: + break; + + default: + return ECORE_CON_SSL_ERROR_NONE; + } + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_init(&svr->session, GNUTLS_CLIENT)); + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_session_ticket_enable_client(svr->session)); + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_server_name_set(svr->session, GNUTLS_NAME_DNS, svr->name, strlen(svr->name))); + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_priority_set_direct(svr->session, priority, NULL)); + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_credentials_set(svr->session, GNUTLS_CRD_CERTIFICATE, svr->cert)); + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_credentials_set(svr->session, GNUTLS_CRD_PSK, svr->pskcred_c)); + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_credentials_set(svr->session, GNUTLS_CRD_ANON, svr->anoncred_c)); + + gnutls_dh_set_prime_bits(svr->session, 512); + gnutls_transport_set_ptr(svr->session, (gnutls_transport_ptr_t)svr->fd); + svr->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING; + case ECORE_CON_SSL_STATE_HANDSHAKING: + ret = gnutls_handshake(svr->session); + DBG("calling gnutls_handshake(): returned with '%s'", gnutls_strerror_name(ret)); + SSL_ERROR_CHECK_GOTO_ERROR(gnutls_error_is_fatal(ret)); + if (!ret) + { + svr->handshaking = EINA_FALSE; + svr->ssl_state = ECORE_CON_SSL_STATE_DONE; + } + else + { + if (gnutls_record_get_direction(svr->session)) + ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE); + else + ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ); + return ECORE_CON_SSL_ERROR_NONE; + } default: - return ECORE_CON_SSL_ERROR_NONE; + break; } - if ((server_cert) && (server_cert->cert) && - ((svr->type & ECORE_CON_TYPE) & ECORE_CON_LOAD_CERT)) + if (!svr->verify) + /* not verifying certificates, so we're done! */ + return ECORE_CON_SSL_ERROR_NONE; + ret = 0; + /* use CRL/CA lists to verify */ + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_certificate_verify_peers2(svr->session, &iter)); + if (iter & GNUTLS_CERT_INVALID) + ERR("The certificate is not trusted."); + else if (iter & GNUTLS_CERT_SIGNER_NOT_FOUND) + ERR("The certificate hasn't got a known issuer."); + else if (iter & GNUTLS_CERT_REVOKED) + ERR("The certificate has been revoked."); + else if (iter & GNUTLS_CERT_EXPIRED) + ERR("The certificate has expired"); + else if (iter & GNUTLS_CERT_NOT_ACTIVATED) + ERR("The certificate is not yet activated"); + + if (iter) + goto error; + + if (gnutls_certificate_type_get(svr->session) != GNUTLS_CRT_X509) { - svr->cert = server_cert->cert; - server_cert->count++; + ERR("Warning: PGP certificates are not yet supported!"); + goto error; } - gnutls_init(&(svr->session), GNUTLS_CLIENT); - gnutls_set_default_priority(svr->session); - gnutls_kx_set_priority(svr->session, kx); - if (svr->cert) - gnutls_credentials_set(svr->session, GNUTLS_CRD_CERTIFICATE, - svr->cert); - else - { - gnutls_anon_allocate_client_credentials(&svr->anoncred_c); - gnutls_credentials_set(svr->session, GNUTLS_CRD_ANON, svr->anoncred_c); - } - gnutls_kx_set_priority(svr->session, kx); - gnutls_protocol_set_priority(svr->session, proto); - gnutls_dh_set_prime_bits(svr->session, 2048); + SSL_ERROR_CHECK_GOTO_ERROR(!(cert_list = gnutls_certificate_get_peers(svr->session, &cert_list_size))); + SSL_ERROR_CHECK_GOTO_ERROR(!cert_list_size); - gnutls_transport_set_ptr(svr->session, (gnutls_transport_ptr_t)svr->fd); + SSL_ERROR_CHECK_GOTO_ERROR(gnutls_x509_crt_init(&cert)); + SSL_ERROR_CHECK_GOTO_ERROR(gnutls_x509_crt_import(cert, &cert_list[0], GNUTLS_X509_FMT_DER)); - while ((ret = gnutls_handshake(svr->session)) < 0) - { - if ((ret == GNUTLS_E_AGAIN) || - (ret == GNUTLS_E_INTERRUPTED)) - continue; + SSL_ERROR_CHECK_GOTO_ERROR(!gnutls_x509_crt_check_hostname(cert, svr->name)); + gnutls_x509_crt_deinit(cert); + DBG("SSL certificate verification succeeded!"); + return ECORE_CON_SSL_ERROR_NONE; - _ecore_con_ssl_server_shutdown_gnutls(svr); - return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; +error: + _gnutls_print_errors(ret); + if ((ret == GNUTLS_E_WARNING_ALERT_RECEIVED) || (ret == GNUTLS_E_FATAL_ALERT_RECEIVED)) + ERR("Also received alert: %s", gnutls_alert_get_name(gnutls_alert_get(svr->session))); + if (svr->ssl_state != ECORE_CON_SSL_STATE_DONE) + { + ERR("last out: %s", SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_get_last_out(svr->session))); + ERR("last in: %s", SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_get_last_in(svr->session))); } + if (cert) + gnutls_x509_crt_deinit(cert); + _ecore_con_ssl_server_shutdown_gnutls(svr); + return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; +} - return ECORE_CON_SSL_ERROR_NONE; +static Eina_Bool +_ecore_con_ssl_server_cafile_add_gnutls(Ecore_Con_Server *svr, const char *ca_file) +{ + SSL_ERROR_CHECK_GOTO_ERROR(gnutls_certificate_set_x509_trust_file(svr->cert, ca_file, + GNUTLS_X509_FMT_PEM) < 1); + + return EINA_TRUE; +error: + ERR("Could not load CA file!"); + return EINA_FALSE; } static Eina_Bool -_ecore_con_ssl_server_cert_add_gnutls(const char *cert_file) +_ecore_con_ssl_server_crl_add_gnutls(Ecore_Con_Server *svr, const char *crl_file) { - gnutls_certificate_credentials_t cert = NULL; + SSL_ERROR_CHECK_GOTO_ERROR(gnutls_certificate_set_x509_crl_file(svr->cert, crl_file, + GNUTLS_X509_FMT_PEM) < 1); - /* cert load */ - if (gnutls_certificate_set_x509_trust_file(cert, cert_file, - GNUTLS_X509_FMT_PEM) < 0) - goto on_error; + return EINA_TRUE; +error: + ERR("Could not load CRL file!"); + return EINA_FALSE; +} - if (!server_cert) - { - server_cert = malloc(sizeof(gnutls)); - if (!server_cert) - return EINA_FALSE; - } - else if ((server_cert->cert) && ((--server_cert->count) < 1)) - gnutls_certificate_free_credentials(server_cert->cert); - server_cert->cert = cert; - server_cert->count = 1; +static Eina_Bool +_ecore_con_ssl_server_privkey_add_gnutls(Ecore_Con_Server *svr, const char *key_file) +{ + SSL_ERROR_CHECK_GOTO_ERROR(gnutls_certificate_set_x509_key_file(svr->cert, svr->cert_file, key_file, + GNUTLS_X509_FMT_PEM)); return EINA_TRUE; +error: + ERR("Could not load certificate/key file!"); + return EINA_FALSE; +} -on_error: - if (cert) - gnutls_certificate_free_credentials(cert); - return EINA_FALSE; +static Eina_Bool +_ecore_con_ssl_server_cert_add_gnutls(Ecore_Con_Server *svr, const char *cert_file) +{ + if (!(svr->cert_file = strdup(cert_file))) + return EINA_FALSE; + + return EINA_TRUE; } + static Ecore_Con_Ssl_Error _ecore_con_ssl_server_shutdown_gnutls(Ecore_Con_Server *svr) { @@ -386,28 +619,44 @@ _ecore_con_ssl_server_shutdown_gnutls(Ecore_Con_Server *svr) gnutls_deinit(svr->session); } - if (((svr->type & ECORE_CON_TYPE) & ECORE_CON_LOAD_CERT) && - (server_cert) && - (server_cert->cert) && (--server_cert->count < 1)) + if (svr->cert_file) + free(svr->cert_file); + svr->cert_file = NULL; + if (svr->cert) + gnutls_certificate_free_credentials(svr->cert); + svr->cert = NULL; + + if ((svr->type & ECORE_CON_SSL) && svr->created) + { + if (svr->dh_params) + { + gnutls_dh_params_deinit(svr->dh_params); + svr->dh_params = NULL; + } + if (svr->anoncred_s) + gnutls_anon_free_server_credentials(svr->anoncred_s); + if (svr->pskcred_s) + gnutls_psk_free_server_credentials(svr->pskcred_s); + + svr->anoncred_s = NULL; + svr->pskcred_s = NULL; + } + else if (svr->type & ECORE_CON_SSL) { - gnutls_certificate_free_credentials(server_cert->cert); - free(server_cert); - server_cert = NULL; + if (svr->anoncred_c) + gnutls_anon_free_client_credentials(svr->anoncred_c); + if (svr->pskcred_c) + gnutls_psk_free_client_credentials(svr->pskcred_c); + + svr->anoncred_c = NULL; + svr->pskcred_c = NULL; } - else if (svr->anoncred_c) - gnutls_anon_free_client_credentials(svr->anoncred_c); - _ecore_con_ssl_server_prepare_gnutls(svr); + svr->session = NULL; return ECORE_CON_SSL_ERROR_NONE; } -/* this is a stub function, the handshake is done in _init_gnutls */ -static Ecore_Con_State -_ecore_con_ssl_server_try_gnutls(Ecore_Con_Server *svr __UNUSED__) -{ - return ECORE_CON_CONNECTED; -} static int _ecore_con_ssl_server_read_gnutls(Ecore_Con_Server *svr, unsigned char *buf, @@ -415,13 +664,29 @@ _ecore_con_ssl_server_read_gnutls(Ecore_Con_Server *svr, unsigned char *buf, { int num; + if (svr->ssl_state == ECORE_CON_SSL_STATE_HANDSHAKING) + { + DBG("Continuing gnutls handshake"); + if (!_ecore_con_ssl_server_init_gnutls(svr)) + return 0; + return -1; + } + num = gnutls_record_recv(svr->session, buf, size); if (num > 0) return num; - if ((num == GNUTLS_E_AGAIN) || - (num == GNUTLS_E_REHANDSHAKE) || - (num == GNUTLS_E_INTERRUPTED)) + if (num == GNUTLS_E_REHANDSHAKE) + { + WRN("Rehandshake request ignored"); + return 0; + + svr->handshaking = EINA_TRUE; + svr->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING; + if (!_ecore_con_ssl_server_init_gnutls(svr)) + return 0; + } + else if ((num == GNUTLS_E_AGAIN) || (num == GNUTLS_E_INTERRUPTED)) return 0; return -1; @@ -433,113 +698,113 @@ _ecore_con_ssl_server_write_gnutls(Ecore_Con_Server *svr, unsigned char *buf, { int num; + + if (svr->ssl_state == ECORE_CON_SSL_STATE_HANDSHAKING) + { + DBG("Continuing gnutls handshake"); + if (!_ecore_con_ssl_server_init_gnutls(svr)) + return 0; + return -1; + } + num = gnutls_record_send(svr->session, buf, size); if (num > 0) return num; - if ((num == GNUTLS_E_AGAIN) || - (num == GNUTLS_E_REHANDSHAKE) || - (num == GNUTLS_E_INTERRUPTED)) + if (num == GNUTLS_E_REHANDSHAKE) + { + WRN("Rehandshake request ignored"); + return 0; +/* this is only partly functional I think? */ + svr->handshaking = EINA_TRUE; + svr->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING; + if (!_ecore_con_ssl_server_init_gnutls(svr)) + return 0; + } + else if ((num == GNUTLS_E_AGAIN) || (num == GNUTLS_E_INTERRUPTED)) return 0; return -1; } -static void -_ecore_con_ssl_client_prepare_gnutls(Ecore_Con_Client *cl) -{ - cl->session = NULL; - if (!_client_connected) - { - cl->server->anoncred_s = NULL; - cl->server->cert = NULL; - } -} static Ecore_Con_Ssl_Error _ecore_con_ssl_client_init_gnutls(Ecore_Con_Client *cl) { - const int *proto = NULL; - gnutls_dh_params_t dh_params; - int ret; - const int kx[] = { GNUTLS_KX_ANON_DH, 0 }; - const int ssl3_proto[] = { GNUTLS_SSL3, 0 }; - const int tls_proto[] = { - GNUTLS_TLS1_0, - GNUTLS_TLS1_1, -#ifdef USE_GNUTLS2 - GNUTLS_TLS1_2, -#endif - 0 - }; + const char *priority = "NONE:%VERIFY_ALLOW_X509_V1_CA_CRT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+COMP-DEFLATE:+COMP-NULL:+CTYPE-X509:+SHA1:+SHA256:+SHA384:+SHA512:+AES-256-CBC:+AES-128-CBC:+3DES-CBC:+VERS-TLS1.2:+VERS-TLS1.1:+VERS-TLS1.0:+VERS-SSL3.0"; + int ret = 0; - switch (cl->server->type & ECORE_CON_SSL) + switch (cl->ssl_state) { - case ECORE_CON_USE_SSL2: /* not supported because of security issues */ - return ECORE_CON_SSL_ERROR_SSL2_NOT_SUPPORTED; - - case ECORE_CON_USE_SSL3: - proto = ssl3_proto; - break; - - case ECORE_CON_USE_TLS: - proto = tls_proto; - break; - - default: - return ECORE_CON_SSL_ERROR_NONE; - } + case ECORE_CON_SSL_STATE_DONE: + return ECORE_CON_SSL_ERROR_NONE; + case ECORE_CON_SSL_STATE_INIT: + if (cl->host_server->type & ECORE_CON_USE_SSL2) /* not supported because of security issues */ + return ECORE_CON_SSL_ERROR_SSL2_NOT_SUPPORTED; - _client_connected++; - - gnutls_dh_params_init(&dh_params); - gnutls_dh_params_generate2(dh_params, 1024); + switch (cl->host_server->type & ECORE_CON_SSL) + { + case ECORE_CON_USE_SSL3: + case ECORE_CON_USE_SSL3 | ECORE_CON_LOAD_CERT: + priority = "NONE:%VERIFY_ALLOW_X509_V1_CA_CRT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+COMP-DEFLATE:+COMP-NULL:+CTYPE-X509:+SHA1:+SHA256:+SHA384:+SHA512:+AES-256-CBC:+AES-128-CBC:+3DES-CBC:!VERS-TLS1.0:!VERS-TLS1.1"; + break; + + case ECORE_CON_USE_TLS: + case ECORE_CON_USE_TLS | ECORE_CON_LOAD_CERT: + priority = "NONE:%VERIFY_ALLOW_X509_V1_CA_CRT:+RSA:+DHE-RSA:+DHE-DSS:+ANON-DH:+COMP-DEFLATE:+COMP-NULL:+CTYPE-X509:+SHA1:+SHA256:+SHA384:+SHA512:+AES-256-CBC:+AES-128-CBC:+3DES-CBC:!VERS-SSL3.0"; + break; + + default: + return ECORE_CON_SSL_ERROR_NONE; + } - if ((client_cert) && (client_cert->cert) && - ((cl->server->type & ECORE_CON_TYPE) & ECORE_CON_LOAD_CERT)) - { - cl->server->cert = client_cert->cert; - client_cert->count++; - gnutls_certificate_set_dh_params(cl->server->cert, dh_params); - } + _client_connected++; - if ((!cl->server->anoncred_s) && (!cl->server->cert)) - { - gnutls_anon_allocate_server_credentials(&(cl->server->anoncred_s)); - gnutls_anon_set_server_dh_params(cl->server->anoncred_s, dh_params); - } + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_init(&cl->session, GNUTLS_SERVER)); +#ifdef USE_GNUTLS_2_10 + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_session_ticket_key_generate(&cl->session_ticket)); + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_session_ticket_enable_server(cl->session, &cl->session_ticket)); +#endif + SSL_ERROR_CHECK_GOTO_ERROR(ret = gnutls_priority_set_direct(cl->session, priority, NULL)); - gnutls_init(&(cl->session), GNUTLS_SERVER); - gnutls_set_default_priority(cl->session); - if (cl->server->cert) - { - gnutls_credentials_set(cl->session, - GNUTLS_CRD_CERTIFICATE, - cl->server->cert); gnutls_certificate_server_set_request(cl->session, GNUTLS_CERT_REQUEST); - } - else - gnutls_credentials_set(cl->session, GNUTLS_CRD_ANON, - cl->server->anoncred_s); - - gnutls_kx_set_priority(cl->session, kx); - gnutls_protocol_set_priority(cl->session, proto); - - gnutls_transport_set_ptr(cl->session, (gnutls_transport_ptr_t)cl->fd); - - while ((ret = gnutls_handshake(cl->session)) < 0) - { - if ((ret == GNUTLS_E_AGAIN) || - (ret == GNUTLS_E_INTERRUPTED)) - continue; + gnutls_dh_set_prime_bits(cl->session, 2048); + gnutls_transport_set_ptr(cl->session, (gnutls_transport_ptr_t)cl->fd); + cl->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING; + case ECORE_CON_SSL_STATE_HANDSHAKING: + DBG("calling gnutls_handshake()"); + ret = gnutls_handshake(cl->session); + SSL_ERROR_CHECK_GOTO_ERROR(gnutls_error_is_fatal(ret)); - _ecore_con_ssl_client_shutdown_gnutls(cl); - return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; + if (!ret) + { + cl->handshaking = EINA_FALSE; + cl->ssl_state = ECORE_CON_SSL_STATE_DONE; + } + else + { + if (gnutls_record_get_direction(cl->session)) + ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_WRITE); + else + ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_READ); + return ECORE_CON_SSL_ERROR_NONE; + } + default: + break; } /* TODO: add cert verification support */ return ECORE_CON_SSL_ERROR_NONE; + +error: + _gnutls_print_errors(ret); + if ((ret == GNUTLS_E_WARNING_ALERT_RECEIVED) || (ret == GNUTLS_E_FATAL_ALERT_RECEIVED)) + ERR("Also received alert: %s", gnutls_alert_get_name(gnutls_alert_get(cl->session))); + ERR("last out: %s", SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_get_last_out(cl->session))); + ERR("last in: %s", SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_get_last_in(cl->session))); + _ecore_con_ssl_client_shutdown_gnutls(cl); + return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; } static Ecore_Con_Ssl_Error @@ -549,75 +814,15 @@ _ecore_con_ssl_client_shutdown_gnutls(Ecore_Con_Client *cl) { gnutls_bye(cl->session, GNUTLS_SHUT_RDWR); gnutls_deinit(cl->session); + gnutls_free(cl->session_ticket.data); + cl->session_ticket.data = NULL; } - if (cl->server->anoncred_s && !--_client_connected) - gnutls_anon_free_server_credentials(cl->server->anoncred_s); - - if (((cl->server->type & ECORE_CON_TYPE) & ECORE_CON_LOAD_CERT) && - (client_cert) && - (client_cert->cert) && (--client_cert->count < 1)) - { - gnutls_certificate_free_credentials(client_cert->cert); - free(client_cert); - client_cert = NULL; - } - - _ecore_con_ssl_client_prepare_gnutls(cl); + cl->session = NULL; return ECORE_CON_SSL_ERROR_NONE; } -static Eina_Bool -_ecore_con_ssl_client_cert_add_gnutls(const char *cert_file, - const char *crl_file, - const char *key_file) -{ - gnutls_certificate_credentials_t cert = NULL; - - if (gnutls_certificate_allocate_credentials(&cert) < 0) - return EINA_FALSE; - - /* cert load */ - if (gnutls_certificate_set_x509_trust_file(cert, cert_file, - GNUTLS_X509_FMT_PEM) < 0) - goto on_error; - - /* private key load */ - if (gnutls_certificate_set_x509_key_file(cert, cert_file, key_file, - GNUTLS_X509_FMT_PEM) < 0) - goto on_error; - -#if 0 - //TODO: uncomment once we implement cert checking - if (crl_file) - /* CRL file load */ - if (gnutls_certificate_set_x509_crl_mem(cert, crl_file, - GNUTLS_X509_FMT_PEM) < 0) - goto on_error; - -} -#endif - if (!client_cert) - { - client_cert = malloc(sizeof(gnutls)); - if (!client_cert) - return EINA_FALSE; - } - else if ((client_cert->cert) && ((--client_cert->count) < 1)) - gnutls_certificate_free_credentials(client_cert->cert); - - client_cert->cert = cert; - client_cert->count = 1; - - return EINA_TRUE; - -on_error: - if (cert) - gnutls_certificate_free_credentials(cert); - - return EINA_FALSE; -} static int _ecore_con_ssl_client_read_gnutls(Ecore_Con_Client *cl, unsigned char *buf, @@ -625,13 +830,29 @@ _ecore_con_ssl_client_read_gnutls(Ecore_Con_Client *cl, unsigned char *buf, { int num; + if (cl->ssl_state == ECORE_CON_SSL_STATE_HANDSHAKING) + { + if (!_ecore_con_ssl_client_init_gnutls(cl)) + return 0; + return -1; + } + num = gnutls_record_recv(cl->session, buf, size); if (num > 0) return num; - if ((num == GNUTLS_E_AGAIN) || - (num == GNUTLS_E_REHANDSHAKE) || - (num == GNUTLS_E_INTERRUPTED)) + if (num == GNUTLS_E_REHANDSHAKE) + { + WRN("Rehandshake request ignored"); + return 0; + cl->handshaking = EINA_TRUE; + cl->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING; + if (!_ecore_con_ssl_client_init_gnutls(cl)) + return 0; + WRN("Rehandshake request ignored"); + return 0; + } + else if ((num == GNUTLS_E_AGAIN) || (num == GNUTLS_E_INTERRUPTED)) return 0; return -1; @@ -643,13 +864,28 @@ _ecore_con_ssl_client_write_gnutls(Ecore_Con_Client *cl, unsigned char *buf, { int num; + + if (cl->ssl_state == ECORE_CON_SSL_STATE_HANDSHAKING) + { + if (!_ecore_con_ssl_client_init_gnutls(cl)) + return 0; + return -1; + } + num = gnutls_record_send(cl->session, buf, size); if (num > 0) return num; - if ((num == GNUTLS_E_AGAIN) || - (num == GNUTLS_E_REHANDSHAKE) || - (num == GNUTLS_E_INTERRUPTED)) + if (num == GNUTLS_E_REHANDSHAKE) + { + WRN("Rehandshake request ignored"); + return 0; + cl->handshaking = EINA_TRUE; + cl->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING; + if (!_ecore_con_ssl_client_init_gnutls(cl)) + return 0; + } + else if ((num == GNUTLS_E_AGAIN) || (num == GNUTLS_E_INTERRUPTED)) return 0; return -1; @@ -666,6 +902,7 @@ _ecore_con_ssl_init_openssl(void) { SSL_library_init(); SSL_load_error_strings(); + OpenSSL_add_all_algorithms(); return ECORE_CON_SSL_ERROR_NONE; } @@ -674,105 +911,239 @@ static Ecore_Con_Ssl_Error _ecore_con_ssl_shutdown_openssl(void) { ERR_free_strings(); + EVP_cleanup(); return ECORE_CON_SSL_ERROR_NONE; } -static void -_ecore_con_ssl_server_prepare_openssl(Ecore_Con_Server *svr) -{ - svr->ssl = NULL; - svr->ssl_ctx = NULL; - svr->ssl_err = SSL_ERROR_NONE; -} - static Ecore_Con_Ssl_Error -_ecore_con_ssl_server_init_openssl(Ecore_Con_Server *svr) +_ecore_con_ssl_server_prepare_openssl(Ecore_Con_Server *svr, int ssl_type) { - switch (svr->type & ECORE_CON_SSL) - { - case ECORE_CON_USE_SSL2: - /* Unsafe version of SSL */ - if (!(svr->ssl_ctx = - SSL_CTX_new(SSLv2_client_method()))) - return - ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; + long options; + int dh = 0; - break; + if (ssl_type & ECORE_CON_USE_SSL2) + return ECORE_CON_SSL_ERROR_SSL2_NOT_SUPPORTED; + switch (ssl_type) + { case ECORE_CON_USE_SSL3: - if (!(svr->ssl_ctx = - SSL_CTX_new(SSLv3_client_method()))) - return - ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; - + case ECORE_CON_USE_SSL3 | ECORE_CON_LOAD_CERT: + if (!svr->created) + SSL_ERROR_CHECK_GOTO_ERROR(!(svr->ssl_ctx = SSL_CTX_new(SSLv3_client_method()))); + else + SSL_ERROR_CHECK_GOTO_ERROR(!(svr->ssl_ctx = SSL_CTX_new(SSLv3_server_method()))); break; case ECORE_CON_USE_TLS: - if (!(svr->ssl_ctx = - SSL_CTX_new(TLSv1_client_method()))) - return - ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; + case ECORE_CON_USE_TLS | ECORE_CON_LOAD_CERT: + if (!svr->created) + SSL_ERROR_CHECK_GOTO_ERROR(!(svr->ssl_ctx = SSL_CTX_new(TLSv1_client_method()))); + else + SSL_ERROR_CHECK_GOTO_ERROR(!(svr->ssl_ctx = SSL_CTX_new(TLSv1_server_method()))); + break; + case ECORE_CON_USE_MIXED: + case ECORE_CON_USE_MIXED | ECORE_CON_LOAD_CERT: + if (!svr->created) + SSL_ERROR_CHECK_GOTO_ERROR(!(svr->ssl_ctx = SSL_CTX_new(SSLv23_client_method()))); + else + SSL_ERROR_CHECK_GOTO_ERROR(!(svr->ssl_ctx = SSL_CTX_new(SSLv23_server_method()))); + options = SSL_CTX_get_options(svr->ssl_ctx); + SSL_CTX_set_options(svr->ssl_ctx, options | SSL_OP_NO_SSLv2 | SSL_OP_SINGLE_DH_USE); break; default: - return ECORE_CON_SSL_ERROR_NONE; + break; } - if (!(svr->ssl = SSL_new(svr->ssl_ctx))) + + if ((!svr->use_cert) && svr->created) { - SSL_CTX_free(svr->ssl_ctx); - return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; + DH *dh_params; + INF("Generating DH params"); + SSL_ERROR_CHECK_GOTO_ERROR(!(dh_params = DH_new())); + SSL_ERROR_CHECK_GOTO_ERROR(!DH_generate_parameters_ex(dh_params, 1024, DH_GENERATOR_5, NULL)); + SSL_ERROR_CHECK_GOTO_ERROR(!DH_check(dh_params, &dh)); + SSL_ERROR_CHECK_GOTO_ERROR((dh & DH_CHECK_P_NOT_PRIME) || (dh & DH_CHECK_P_NOT_SAFE_PRIME)); + SSL_ERROR_CHECK_GOTO_ERROR(!DH_generate_key(dh_params)); + SSL_ERROR_CHECK_GOTO_ERROR(!SSL_CTX_set_tmp_dh(svr->ssl_ctx, dh_params)); + DH_free(dh_params); + SSL_ERROR_CHECK_GOTO_ERROR(!SSL_CTX_set_cipher_list(svr->ssl_ctx, "aNULL:!eNULL:!LOW:!EXPORT:@STRENGTH")); } + else if (!svr->use_cert) + SSL_ERROR_CHECK_GOTO_ERROR(!SSL_CTX_set_cipher_list(svr->ssl_ctx, "aNULL:!eNULL:!LOW:!EXPORT:!ECDH:RSA:AES:!PSK:@STRENGTH")); + + SSL_CTX_set_verify(svr->ssl_ctx, SSL_VERIFY_PEER, NULL); - if ((server_cert) && (server_cert->cert) && - ((svr->type & ECORE_CON_TYPE) & ECORE_CON_LOAD_CERT)) + return ECORE_CON_SSL_ERROR_NONE; + +error: + if (dh) { - //FIXME: just log and go on without cert if loading fails? - if (!SSL_CTX_use_certificate(svr->ssl_ctx, server_cert->cert)) - ERR( - "ssl cert load failed: %s", ERR_reason_error_string(ERR_get_error())); + if (dh & DH_CHECK_P_NOT_PRIME) + ERR("openssl error: dh_params could not generate a prime!"); + else + ERR("openssl error: dh_params could not generate a safe prime!"); + } + else + _openssl_print_errors(); + _ecore_con_ssl_server_shutdown_openssl(svr); + return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; +} + + + - server_cert->count++; +static Ecore_Con_Ssl_Error +_ecore_con_ssl_server_init_openssl(Ecore_Con_Server *svr) +{ + int ret = -1; + + switch (svr->ssl_state) + { + case ECORE_CON_SSL_STATE_DONE: + return ECORE_CON_SSL_ERROR_NONE; + case ECORE_CON_SSL_STATE_INIT: + SSL_ERROR_CHECK_GOTO_ERROR(!(svr->ssl = SSL_new(svr->ssl_ctx))); + + SSL_ERROR_CHECK_GOTO_ERROR(!SSL_set_fd(svr->ssl, svr->fd)); + SSL_set_connect_state(svr->ssl); + svr->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING; + case ECORE_CON_SSL_STATE_HANDSHAKING: + ret = SSL_do_handshake(svr->ssl); + svr->ssl_err = SSL_get_error(svr->ssl, ret); + SSL_ERROR_CHECK_GOTO_ERROR((svr->ssl_err == SSL_ERROR_SYSCALL) || (svr->ssl_err == SSL_ERROR_SSL)); + + if (ret == 1) + { + svr->handshaking = EINA_FALSE; + svr->ssl_state = ECORE_CON_SSL_STATE_DONE; + } + else + { + if (svr->ssl_err == SSL_ERROR_WANT_READ) + ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ); + else if (svr->ssl_err == SSL_ERROR_WANT_WRITE) + ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE); + return ECORE_CON_SSL_ERROR_NONE; + } + default: + break; } - SSL_set_fd(svr->ssl, svr->fd); + { + /* print session info into DBG */ + SSL_SESSION *s; + BIO *b; + char log[4096]; + + + memset(log, 0, sizeof(log)); + s = SSL_get_session(svr->ssl); + b = BIO_new(BIO_s_mem()); + SSL_SESSION_print(b, s); + while (BIO_read(b, log, sizeof(log)) > 0) + DBG("%s", log); + + BIO_free(b); + } + + if (!svr->verify) + /* not verifying certificates, so we're done! */ + return ECORE_CON_SSL_ERROR_NONE; + + /* use CRL/CA lists to verify */ + if (SSL_get_peer_certificate(svr->ssl)) + SSL_ERROR_CHECK_GOTO_ERROR(SSL_get_verify_result(svr->ssl)); + DBG("SSL certificate verification succeeded!"); return ECORE_CON_SSL_ERROR_NONE; + +error: + _openssl_print_errors(); + _ecore_con_ssl_server_shutdown_openssl(svr); + return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; +} + +static Eina_Bool +_ecore_con_ssl_server_cafile_add_openssl(Ecore_Con_Server *svr, const char *ca_file) +{ + SSL_ERROR_CHECK_GOTO_ERROR(!SSL_CTX_load_verify_locations(svr->ssl_ctx, ca_file, NULL)); + return EINA_TRUE; + +error: + _openssl_print_errors(); + return EINA_FALSE; } static Eina_Bool -_ecore_con_ssl_server_cert_add_openssl(const char *cert_file) +_ecore_con_ssl_server_crl_add_openssl(Ecore_Con_Server *svr, const char *crl_file) +{ + X509_STORE *st; + X509_LOOKUP *lu; + static Eina_Bool flag = EINA_FALSE; + + SSL_ERROR_CHECK_GOTO_ERROR(!(st = SSL_CTX_get_cert_store(svr->ssl_ctx))); + SSL_ERROR_CHECK_GOTO_ERROR(!(lu = X509_STORE_add_lookup(st, X509_LOOKUP_file()))); + SSL_ERROR_CHECK_GOTO_ERROR(X509_load_crl_file(lu, crl_file, X509_FILETYPE_PEM) < 1); + if (!flag) + { + X509_STORE_set_flags(st, X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL); + flag = EINA_TRUE; + } + + return EINA_TRUE; + +error: + _openssl_print_errors(); + return EINA_FALSE; +} + +static Eina_Bool +_ecore_con_ssl_server_privkey_add_openssl(Ecore_Con_Server *svr, const char *key_file) { FILE *fp = NULL; - X509 *cert = NULL; + EVP_PKEY *privkey = NULL; - if (!(fp = fopen(cert_file, "r"))) - goto on_error; + if (!(fp = fopen(key_file, "r"))) + goto error; - if (!(cert = PEM_read_X509(fp, NULL, NULL, NULL))) - goto on_error; + SSL_ERROR_CHECK_GOTO_ERROR(!(privkey = PEM_read_PrivateKey(fp, NULL, NULL, NULL))); fclose(fp); + SSL_ERROR_CHECK_GOTO_ERROR(SSL_CTX_use_PrivateKey(svr->ssl_ctx, privkey) < 1); + SSL_ERROR_CHECK_GOTO_ERROR(SSL_CTX_check_private_key(svr->ssl_ctx) < 1); - if (!server_cert) - { - server_cert = malloc(sizeof(openssl)); - if (!server_cert) - return EINA_FALSE; - } - else if ((server_cert->cert) && ((--server_cert->count) < 1)) - X509_free(server_cert->cert); + return EINA_TRUE; - server_cert->cert = cert; +error: + if (fp) + fclose(fp); + _openssl_print_errors(); + return EINA_FALSE; +} - server_cert->count = 1; + +static Eina_Bool +_ecore_con_ssl_server_cert_add_openssl(Ecore_Con_Server *svr, const char *cert_file) +{ + FILE *fp = NULL; + X509 *cert = NULL; + + if (!(fp = fopen(cert_file, "r"))) + goto error; + + SSL_ERROR_CHECK_GOTO_ERROR(!(cert = PEM_read_X509(fp, NULL, NULL, NULL))); + + fclose(fp); + + SSL_ERROR_CHECK_GOTO_ERROR(SSL_CTX_use_certificate(svr->ssl_ctx, cert) < 1); return EINA_TRUE; -on_error: +error: if (fp) fclose(fp); - + _openssl_print_errors(); return EINA_FALSE; } @@ -787,61 +1158,16 @@ _ecore_con_ssl_server_shutdown_openssl(Ecore_Con_Server *svr) SSL_free(svr->ssl); } - if (((svr->type & ECORE_CON_TYPE) & ECORE_CON_LOAD_CERT) && - (server_cert) && (server_cert->cert) && - (--server_cert->count < 1)) - { - X509_free(server_cert->cert); - free(server_cert); - server_cert = NULL; - } - if (svr->ssl_ctx) SSL_CTX_free(svr->ssl_ctx); - _ecore_con_ssl_server_prepare_openssl(svr); + svr->ssl = NULL; + svr->ssl_ctx = NULL; + svr->ssl_err = SSL_ERROR_NONE; return ECORE_CON_SSL_ERROR_NONE; } -/* Tries to connect an Ecore_Con_Server to an SSL host. - * Returns 1 on success, -1 on fatal errors and 0 if the caller - * should try again later. - */ -static Ecore_Con_State -_ecore_con_ssl_server_try_openssl(Ecore_Con_Server *svr) -{ - int res, flag = 0; - - if ((res = SSL_connect(svr->ssl)) == 1) - return ECORE_CON_CONNECTED; - - svr->ssl_err = SSL_get_error(svr->ssl, res); - - switch (svr->ssl_err) - { - case SSL_ERROR_NONE: - return ECORE_CON_CONNECTED; - - case SSL_ERROR_WANT_READ: - flag = ECORE_FD_READ; - break; - - case SSL_ERROR_WANT_WRITE: - flag = ECORE_FD_WRITE; - break; - - default: - return ECORE_CON_DISCONNECTED; - } - - if (svr->fd_handler && flag) - ecore_main_fd_handler_active_set(svr->fd_handler, - flag); - - return ECORE_CON_INPROGRESS; -} - static int _ecore_con_ssl_server_read_openssl(Ecore_Con_Server *svr, unsigned char *buf, int size) @@ -853,15 +1179,10 @@ _ecore_con_ssl_server_read_openssl(Ecore_Con_Server *svr, unsigned char *buf, if (svr->fd_handler) { - if (svr->ssl && svr->ssl_err == - SSL_ERROR_WANT_READ) - ecore_main_fd_handler_active_set(svr->fd_handler, - ECORE_FD_READ); - else if (svr->ssl && svr->ssl_err == - SSL_ERROR_WANT_WRITE) - ecore_main_fd_handler_active_set( - svr->fd_handler, - ECORE_FD_WRITE); + if (svr->ssl && svr->ssl_err == SSL_ERROR_WANT_READ) + ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ); + else if (svr->ssl && svr->ssl_err == SSL_ERROR_WANT_WRITE) + ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_WRITE); } if ((svr->ssl_err == SSL_ERROR_ZERO_RETURN) || @@ -886,15 +1207,10 @@ _ecore_con_ssl_server_write_openssl(Ecore_Con_Server *svr, unsigned char *buf, if (svr->fd_handler) { - if (svr->ssl && svr->ssl_err == - SSL_ERROR_WANT_READ) - ecore_main_fd_handler_active_set(svr->fd_handler, - ECORE_FD_READ); - else if (svr->ssl && svr->ssl_err == - SSL_ERROR_WANT_WRITE) - ecore_main_fd_handler_active_set( - svr->fd_handler, - ECORE_FD_WRITE); + if (svr->ssl && svr->ssl_err == SSL_ERROR_WANT_READ) + ecore_main_fd_handler_active_set(svr->fd_handler, ECORE_FD_READ); + else if (svr->ssl && svr->ssl_err == SSL_ERROR_WANT_WRITE) + ecore_main_fd_handler_active_set( svr->fd_handler, ECORE_FD_WRITE); } if ((svr->ssl_err == SSL_ERROR_ZERO_RETURN) || @@ -908,137 +1224,76 @@ _ecore_con_ssl_server_write_openssl(Ecore_Con_Server *svr, unsigned char *buf, return num; } -static void -_ecore_con_ssl_client_prepare_openssl(Ecore_Con_Client *cl) -{ - cl->ssl = NULL; - cl->ssl_ctx = NULL; - cl->ssl_err = SSL_ERROR_NONE; -} - static Ecore_Con_Ssl_Error _ecore_con_ssl_client_init_openssl(Ecore_Con_Client *cl) { - switch (cl->server->type & ECORE_CON_SSL) + int ret = -1; + switch (cl->ssl_state) { - case ECORE_CON_USE_SSL2: - /* Unsafe version of SSL */ - if (!(cl->ssl_ctx = - SSL_CTX_new(SSLv2_client_method()))) - return - ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; - - break; - - case ECORE_CON_USE_SSL3: - if (!(cl->ssl_ctx = - SSL_CTX_new(SSLv3_client_method()))) - return - ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; - - break; - - case ECORE_CON_USE_TLS: - if (!(cl->ssl_ctx = - SSL_CTX_new(TLSv1_client_method()))) - return - ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; - - break; - + case ECORE_CON_SSL_STATE_DONE: + return ECORE_CON_SSL_ERROR_NONE; + case ECORE_CON_SSL_STATE_INIT: + SSL_ERROR_CHECK_GOTO_ERROR(!(cl->ssl = SSL_new(cl->host_server->ssl_ctx))); + + SSL_ERROR_CHECK_GOTO_ERROR(!SSL_set_fd(cl->ssl, cl->fd)); + SSL_set_accept_state(cl->ssl); + cl->ssl_state = ECORE_CON_SSL_STATE_HANDSHAKING; + case ECORE_CON_SSL_STATE_HANDSHAKING: + ret = SSL_do_handshake(cl->ssl); + cl->ssl_err = SSL_get_error(cl->ssl, ret); + SSL_ERROR_CHECK_GOTO_ERROR((cl->ssl_err == SSL_ERROR_SYSCALL) || (cl->ssl_err == SSL_ERROR_SSL)); + if (ret == 1) + { + cl->handshaking = EINA_FALSE; + cl->ssl_state = ECORE_CON_SSL_STATE_DONE; + } + else + { + if (cl->ssl_err == SSL_ERROR_WANT_READ) + ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_READ); + else if (cl->ssl_err == SSL_ERROR_WANT_WRITE) + ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_WRITE); + return ECORE_CON_SSL_ERROR_NONE; + } default: - return ECORE_CON_SSL_ERROR_NONE; - } - if (!(cl->ssl = SSL_new(cl->ssl_ctx))) - { - SSL_CTX_free(cl->ssl_ctx); - return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; + break; } - if ((client_cert) && (client_cert->cert) && (private_key->key) && - ((cl->server->type & ECORE_CON_TYPE) & ECORE_CON_LOAD_CERT)) - { - //FIXME: just log and go on without cert if loading fails? - if (!SSL_CTX_use_certificate(cl->server->ssl_ctx, client_cert->cert) || - !SSL_CTX_use_PrivateKey(cl->server->ssl_ctx, private_key->key) || - !SSL_CTX_check_private_key(cl->server->ssl_ctx)) - ERR( - "ssl cert load failed: %s", ERR_reason_error_string(ERR_get_error())); - - client_cert->count++; - private_key->count++; - } + { + /* print session info into DBG */ + SSL_SESSION *s; + BIO *b; + char log[4096]; + - SSL_set_fd(cl->ssl, cl->fd); + memset(log, 0, sizeof(log)); + s = SSL_get_session(cl->ssl); + b = BIO_new(BIO_s_mem()); + SSL_SESSION_print(b, s); + while (BIO_read(b, log, sizeof(log)) > 0) + DBG("%s", log); - return ECORE_CON_SSL_ERROR_NONE; -} + BIO_free(b); + } -static Eina_Bool -_ecore_con_ssl_client_cert_add_openssl(const char *cert_file, - const char *crl_file, - const char *key_file) -{ - FILE *fp = NULL; - EVP_PKEY *privkey = NULL; - X509 *cert = NULL; - - if (!(fp = fopen(cert_file, "r"))) - goto on_error; - - if (!(cert = PEM_read_X509(fp, NULL, NULL, NULL))) - goto on_error; - - if (key_file) - { - fclose(fp); - if (!(fp = fopen(key_file, "r"))) - goto on_error; - } - - if (!(privkey = PEM_read_PrivateKey(fp, NULL, NULL, NULL))) - goto on_error; - - fclose(fp); - - if (!client_cert) - { - client_cert = malloc(sizeof(openssl)); - if (!client_cert) - return EINA_FALSE; - } - else if ((client_cert->cert) && (--client_cert->count < 1)) - X509_free(client_cert->cert); + if (!cl->host_server->verify) + /* not verifying certificates, so we're done! */ + return ECORE_CON_SSL_ERROR_NONE; + + /* use CRL/CA lists to verify */ + if (SSL_get_peer_certificate(cl->ssl)) + SSL_ERROR_CHECK_GOTO_ERROR(SSL_get_verify_result(cl->ssl)); - if (!private_key) - { - private_key = malloc(sizeof(openssl_pkey)); - if (!private_key) return EINA_FALSE; - } - else if ((private_key->key) && ((--private_key->count) < 1)) - EVP_PKEY_free(private_key->key); - - private_key->key = privkey; - client_cert->cert = cert; - - private_key->count = client_cert->count = 1; - - return EINA_TRUE; - -on_error: - if (fp) - fclose(fp); - - if (cert) - X509_free(cert); - - if (privkey) - EVP_PKEY_free(privkey); + return ECORE_CON_SSL_ERROR_NONE; - return EINA_FALSE; +error: + _openssl_print_errors(); + _ecore_con_ssl_client_shutdown_openssl(cl); + return ECORE_CON_SSL_ERROR_SERVER_INIT_FAILED; } + static Ecore_Con_Ssl_Error _ecore_con_ssl_client_shutdown_openssl(Ecore_Con_Client *cl) { @@ -1050,27 +1305,8 @@ _ecore_con_ssl_client_shutdown_openssl(Ecore_Con_Client *cl) SSL_free(cl->ssl); } - if (cl->ssl_ctx) - { - SSL_CTX_free(cl->ssl_ctx); - if (((cl->server->type & ECORE_CON_TYPE) & ECORE_CON_LOAD_CERT) && - (client_cert) && (client_cert->cert) && (--client_cert->count < 1)) - { - X509_free(client_cert->cert); - free(client_cert); - client_cert = NULL; - } - - if (((cl->server->type & ECORE_CON_TYPE) & ECORE_CON_LOAD_CERT) && - (private_key) && (private_key->key) && (--private_key->count < 1)) - { - EVP_PKEY_free(private_key->key); - free(private_key); - private_key = NULL; - } - } - - _ecore_con_ssl_client_prepare_openssl(cl); + cl->ssl = NULL; + cl->ssl_err = SSL_ERROR_NONE; return ECORE_CON_SSL_ERROR_NONE; } @@ -1086,15 +1322,10 @@ _ecore_con_ssl_client_read_openssl(Ecore_Con_Client *cl, unsigned char *buf, if (cl->fd_handler) { - if (cl->ssl && cl->ssl_err == - SSL_ERROR_WANT_READ) - ecore_main_fd_handler_active_set(cl->fd_handler, - ECORE_FD_READ); - else if (cl->ssl && cl->ssl_err == - SSL_ERROR_WANT_WRITE) - ecore_main_fd_handler_active_set( - cl->fd_handler, - ECORE_FD_WRITE); + if (cl->ssl && cl->ssl_err == SSL_ERROR_WANT_READ) + ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_READ); + else if (cl->ssl && cl->ssl_err == SSL_ERROR_WANT_WRITE) + ecore_main_fd_handler_active_set( cl->fd_handler, ECORE_FD_WRITE); } if ((cl->ssl_err == SSL_ERROR_ZERO_RETURN) || @@ -1119,15 +1350,10 @@ _ecore_con_ssl_client_write_openssl(Ecore_Con_Client *cl, unsigned char *buf, if (cl->fd_handler) { - if (cl->ssl && cl->ssl_err == - SSL_ERROR_WANT_READ) - ecore_main_fd_handler_active_set(cl->fd_handler, - ECORE_FD_READ); - else if (cl->ssl && cl->ssl_err == - SSL_ERROR_WANT_WRITE) - ecore_main_fd_handler_active_set( - cl->fd_handler, - ECORE_FD_WRITE); + if (cl->ssl && cl->ssl_err == SSL_ERROR_WANT_READ) + ecore_main_fd_handler_active_set(cl->fd_handler, ECORE_FD_READ); + else if (cl->ssl && cl->ssl_err == SSL_ERROR_WANT_WRITE) + ecore_main_fd_handler_active_set( cl->fd_handler, ECORE_FD_WRITE); } if ((cl->ssl_err == SSL_ERROR_ZERO_RETURN) || @@ -1159,89 +1385,84 @@ _ecore_con_ssl_shutdown_none(void) return ECORE_CON_SSL_ERROR_NONE; } -static void -_ecore_con_ssl_server_prepare_none(Ecore_Con_Server *svr) +static Ecore_Con_Ssl_Error +_ecore_con_ssl_server_prepare_none(Ecore_Con_Server *svr __UNUSED__, int ssl_type __UNUSED__) { + return ECORE_CON_SSL_ERROR_NONE; } static Ecore_Con_Ssl_Error -_ecore_con_ssl_server_init_none(Ecore_Con_Server *svr) +_ecore_con_ssl_server_init_none(Ecore_Con_Server *svr __UNUSED__) { return ECORE_CON_SSL_ERROR_NOT_SUPPORTED; } static Eina_Bool -_ecore_con_ssl_server_cert_add_none(const char *cert_file) +_ecore_con_ssl_server_cafile_add_none(Ecore_Con_Server *svr __UNUSED__, const char *ca_file __UNUSED__) { - return EINA_TRUE; + return EINA_FALSE; } -static Ecore_Con_Ssl_Error -_ecore_con_ssl_server_shutdown_none(Ecore_Con_Server *svr) +static Eina_Bool +_ecore_con_ssl_server_cert_add_none(Ecore_Con_Server *svr __UNUSED__, const char *cert_file __UNUSED__) { - return ECORE_CON_SSL_ERROR_NOT_SUPPORTED; + return EINA_FALSE; } -/* Tries to connect an Ecore_Con_Server to an SSL host. - * Returns 1 on success, -1 on fatal errors and 0 if the caller - * should try again later. - */ -static Ecore_Con_State -_ecore_con_ssl_server_try_none(Ecore_Con_Server *svr) +static Eina_Bool +_ecore_con_ssl_server_privkey_add_none(Ecore_Con_Server *svr __UNUSED__, const char *key_file __UNUSED__) { - return ECORE_CON_DISCONNECTED; + return EINA_FALSE; } -static int -_ecore_con_ssl_server_read_none(Ecore_Con_Server *svr, unsigned char *buf, - int size) +static Eina_Bool +_ecore_con_ssl_server_crl_add_none(Ecore_Con_Server *svr __UNUSED__, const char *crl_file __UNUSED__) { - return -1; + return EINA_FALSE; +} + +static Ecore_Con_Ssl_Error +_ecore_con_ssl_server_shutdown_none(Ecore_Con_Server *svr __UNUSED__) +{ + return ECORE_CON_SSL_ERROR_NOT_SUPPORTED; } static int -_ecore_con_ssl_server_write_none(Ecore_Con_Server *svr, unsigned char *buf, - int size) +_ecore_con_ssl_server_read_none(Ecore_Con_Server *svr __UNUSED__, unsigned char *buf __UNUSED__, + int size __UNUSED__) { return -1; } -static void -_ecore_con_ssl_client_prepare_none(Ecore_Con_Client *cl) +static int +_ecore_con_ssl_server_write_none(Ecore_Con_Server *svr __UNUSED__, unsigned char *buf __UNUSED__, + int size __UNUSED__) { - return; + return -1; } static Ecore_Con_Ssl_Error -_ecore_con_ssl_client_init_none(Ecore_Con_Client *cl) +_ecore_con_ssl_client_init_none(Ecore_Con_Client *cl __UNUSED__) { return ECORE_CON_SSL_ERROR_NOT_SUPPORTED; } -static Eina_Bool -_ecore_con_ssl_client_cert_add_none(const char *cert_file, - const char *crl_file, - const char *key_file) -{ - return EINA_TRUE; -} - static Ecore_Con_Ssl_Error -_ecore_con_ssl_client_shutdown_none(Ecore_Con_Client *cl) +_ecore_con_ssl_client_shutdown_none(Ecore_Con_Client *cl __UNUSED__) { return ECORE_CON_SSL_ERROR_NOT_SUPPORTED; } static int -_ecore_con_ssl_client_read_none(Ecore_Con_Client *cl, unsigned char *buf, - int size) +_ecore_con_ssl_client_read_none(Ecore_Con_Client *cl __UNUSED__, unsigned char *buf __UNUSED__, + int size __UNUSED__) { return -1; } static int -_ecore_con_ssl_client_write_none(Ecore_Con_Client *cl, unsigned char *buf, - int size) +_ecore_con_ssl_client_write_none(Ecore_Con_Client *cl __UNUSED__, unsigned char *buf __UNUSED__, + int size __UNUSED__) { return -1; } diff --git a/src/lib/ecore_con/ecore_con_url.c b/src/lib/ecore_con/ecore_con_url.c index 09a0e8c..d915966 100644 --- a/src/lib/ecore_con/ecore_con_url.c +++ b/src/lib/ecore_con/ecore_con_url.c @@ -59,14 +59,6 @@ #include "Ecore_Con.h" #include "ecore_con_private.h" -/** - * @defgroup Ecore_Con_Url_Group Ecore URL Connection Functions - * - * Utility functions that set up, use and shut down the Ecore URL - * Connection library. - * FIXME: write detailed description - */ - int ECORE_CON_EVENT_URL_DATA = 0; int ECORE_CON_EVENT_URL_COMPLETE = 0; int ECORE_CON_EVENT_URL_PROGRESS = 0; @@ -74,7 +66,7 @@ int ECORE_CON_EVENT_URL_PROGRESS = 0; #ifdef HAVE_CURL static Eina_Bool _ecore_con_url_fd_handler(void *data, Ecore_Fd_Handler *fd_handler); -static int _ecore_con_url_perform(Ecore_Con_Url *url_con); +static Eina_Bool _ecore_con_url_perform(Ecore_Con_Url *url_con); static size_t _ecore_con_url_header_cb(void *ptr, size_t size, size_t nitems, void *stream); static size_t _ecore_con_url_data_cb(void *buffer, @@ -89,13 +81,13 @@ static size_t _ecore_con_url_read_cb(void *ptr, size_t size, size_t nitems, static void _ecore_con_event_url_free(void *data __UNUSED__, void *ev); static int _ecore_con_url_process_completed_jobs( Ecore_Con_Url *url_con_to_match); -static Eina_Bool _ecore_con_url_idler_handler(void *data __UNUSED__); +static Eina_Bool _ecore_con_url_idler_handler(void *data); static Ecore_Idler *_fd_idler_handler = NULL; static Eina_List *_url_con_list = NULL; -static CURLM *curlm = NULL; +static CURLM *_curlm = NULL; static fd_set _current_fd_set; -static int init_count = 0; +static int _init_count = 0; static Ecore_Timer *_curl_timeout = NULL; typedef struct _Ecore_Con_Url_Event Ecore_Con_Url_Event; @@ -132,19 +124,29 @@ _url_complete_push_event(int type, void *ev) #endif /** + * @addtogroup Ecore_Con_Url_Group Ecore URL Connection Functions + * + * Utility functions that set up, use and shut down the Ecore URL + * Connection library. + * + * @todo write detailed description of Ecore_Con_Url + * + * @{ + */ + +/** * Initialises the Ecore_Con_Url library. * @return Number of times the library has been initialised without being * shut down. - * @ingroup Ecore_Con_Url_Group */ EAPI int ecore_con_url_init(void) { #ifdef HAVE_CURL - init_count++; + _init_count++; - if (init_count > 1) - return init_count; + if (_init_count > 1) + return _init_count; if (!ECORE_CON_EVENT_URL_DATA) { @@ -153,7 +155,7 @@ ecore_con_url_init(void) ECORE_CON_EVENT_URL_PROGRESS = ecore_event_type_new(); } - if (!curlm) + if (!_curlm) { long ms; @@ -161,21 +163,21 @@ ecore_con_url_init(void) if (curl_global_init(CURL_GLOBAL_NOTHING)) { while (_url_con_list) - ecore_con_url_destroy(eina_list_data_get(_url_con_list)); + ecore_con_url_free(eina_list_data_get(_url_con_list)); return 0; } - curlm = curl_multi_init(); - if (!curlm) + _curlm = curl_multi_init(); + if (!_curlm) { while (_url_con_list) - ecore_con_url_destroy(eina_list_data_get(_url_con_list)); + ecore_con_url_free(eina_list_data_get(_url_con_list)); - init_count--; + _init_count--; return 0; } - curl_multi_timeout(curlm, &ms); + curl_multi_timeout(_curlm, &ms); if (ms <= 0) ms = 1000; @@ -194,19 +196,18 @@ ecore_con_url_init(void) /** * Shuts down the Ecore_Con_Url library. * @return Number of calls that still uses Ecore_Con_Url - * @ingroup Ecore_Con_Url_Group */ EAPI int ecore_con_url_shutdown(void) { #ifdef HAVE_CURL - if (!init_count) + if (!_init_count) return 0; - init_count--; + _init_count--; - if (init_count != 0) - return init_count; + if (_init_count != 0) + return _init_count; if (_fd_idler_handler) ecore_idler_del(_fd_idler_handler); @@ -219,12 +220,12 @@ ecore_con_url_shutdown(void) _curl_timeout = NULL; while (_url_con_list) - ecore_con_url_destroy(eina_list_data_get(_url_con_list)); + ecore_con_url_free(eina_list_data_get(_url_con_list)); - if (curlm) + if (_curlm) { - curl_multi_cleanup(curlm); - curlm = NULL; + curl_multi_cleanup(_curlm); + _curlm = NULL; } curl_global_cleanup(); @@ -243,7 +244,6 @@ ecore_con_url_shutdown(void) * * @return NULL on error, a new Ecore_Con_Url on success. * - * @ingroup Ecore_Con_Url_Group * * @see ecore_con_url_custom_new() * @see ecore_con_url_url_set() @@ -253,14 +253,18 @@ ecore_con_url_new(const char *url) { #ifdef HAVE_CURL Ecore_Con_Url *url_con; + CURLcode ret; - if (!init_count) + if (!_init_count) return NULL; url_con = calloc(1, sizeof(Ecore_Con_Url)); if (!url_con) return NULL; + url_con->fd = -1; + url_con->write_fd = -1; + url_con->curl_easy = curl_easy_init(); if (!url_con->curl_easy) { @@ -270,7 +274,20 @@ ecore_con_url_new(const char *url) ECORE_MAGIC_SET(url_con, ECORE_MAGIC_CON_URL); - ecore_con_url_url_set(url_con, url); + if (!ecore_con_url_url_set(url_con, url)) + { + ecore_con_url_free(url_con); + return NULL; + } + + ret = curl_easy_setopt(url_con->curl_easy, CURLOPT_ENCODING, "gzip,deflate"); + if (ret != CURLE_OK) + { + ERR("Could not set CURLOPT_ENCODING to \"gzip,deflate\": %s", + curl_easy_strerror(ret)); + ecore_con_url_free(url_con); + return NULL; + } curl_easy_setopt(url_con->curl_easy, CURLOPT_WRITEFUNCTION, _ecore_con_url_data_cb); @@ -293,13 +310,6 @@ ecore_con_url_new(const char *url) curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEOUT, 300); curl_easy_setopt(url_con->curl_easy, CURLOPT_FOLLOWLOCATION, 1); - curl_easy_setopt(url_con->curl_easy, CURLOPT_ENCODING, "gzip,deflate"); - - url_con->fd = -1; - url_con->write_fd = -1; - url_con->additional_headers = NULL; - url_con->response_headers = NULL; - return url_con; #else return NULL; @@ -319,7 +329,6 @@ ecore_con_url_new(const char *url) * * @return NULL on error, a new Ecore_Con_Url on success. * - * @ingroup Ecore_Con_Url_Group * * @see ecore_con_url_new() * @see ecore_con_url_url_set() @@ -329,6 +338,7 @@ ecore_con_url_custom_new(const char *url, const char *custom_request) { #ifdef HAVE_CURL Ecore_Con_Url *url_con; + CURLcode ret; if (!url) return NULL; @@ -341,7 +351,14 @@ ecore_con_url_custom_new(const char *url, const char *custom_request) if (!url_con) return NULL; - curl_easy_setopt(url_con->curl_easy, CURLOPT_CUSTOMREQUEST, custom_request); + ret = curl_easy_setopt(url_con->curl_easy, CURLOPT_CUSTOMREQUEST, custom_request); + if (ret != CURLE_OK) + { + ERR("Could not set a custom request string: %s", + curl_easy_strerror(ret)); + ecore_con_url_free(url_con); + return NULL; + } return url_con; #else @@ -354,22 +371,23 @@ ecore_con_url_custom_new(const char *url, const char *custom_request) /** * Destroys a Ecore_Con_Url connection object. * - * @ingroup Ecore_Con_Url_Group + * @param url_con Connection object to free. * * @see ecore_con_url_new() */ EAPI void -ecore_con_url_destroy(Ecore_Con_Url *url_con) +ecore_con_url_free(Ecore_Con_Url *url_con) { #ifdef HAVE_CURL char *s; + CURLMcode ret; if (!url_con) return; if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_destroy"); + ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_free"); return; } @@ -384,11 +402,6 @@ ecore_con_url_destroy(Ecore_Con_Url *url_con) url_con->fd_handler = NULL; } - if (url_con->post) - curl_formfree(url_con->post); - - url_con->post = NULL; - if (url_con->curl_easy) { // FIXME: For an unknown reason, progress continue to arrive after destruction @@ -397,9 +410,12 @@ ecore_con_url_destroy(Ecore_Con_Url *url_con) if (url_con->active) { - url_con->active = 0; + url_con->active = EINA_FALSE; - curl_multi_remove_handle(curlm, url_con->curl_easy); + ret = curl_multi_remove_handle(_curlm, url_con->curl_easy); + if (ret != CURLM_OK) + ERR("curl_multi_remove_handle failed: %s", + curl_multi_strerror(ret)); } curl_easy_cleanup(url_con->curl_easy); @@ -408,9 +424,9 @@ ecore_con_url_destroy(Ecore_Con_Url *url_con) _url_con_list = eina_list_remove(_url_con_list, url_con); curl_slist_free_all(url_con->headers); EINA_LIST_FREE(url_con->additional_headers, s) - free(s); + free(s); EINA_LIST_FREE(url_con->response_headers, s) - free(s); + free(s); free(url_con->url); free(url_con); #else @@ -425,22 +441,21 @@ ecore_con_url_destroy(Ecore_Con_Url *url_con) * @param url_con Connection object through which the request will be sent. * @param url URL that will receive the request * - * @return 1 on success, 0 on error. + * @return EINA_TRUE on success, EINA_FALSE on error. * - * @ingroup Ecore_Con_Url_Group */ -EAPI int +EAPI Eina_Bool ecore_con_url_url_set(Ecore_Con_Url *url_con, const char *url) { #ifdef HAVE_CURL if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) { ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_url_set"); - return 0; + return EINA_FALSE; } if (url_con->active) - return 0; + return EINA_FALSE; if (url_con->url) free(url_con->url); @@ -455,11 +470,11 @@ ecore_con_url_url_set(Ecore_Con_Url *url_con, const char *url) else curl_easy_setopt(url_con->curl_easy, CURLOPT_URL, ""); - return 1; + return EINA_TRUE; #else - return 0; - url_con = NULL; - url = NULL; + return EINA_FALSE; + (void)url; + (void)url_con; #endif } @@ -472,7 +487,6 @@ ecore_con_url_url_set(Ecore_Con_Url *url_con, const char *url) * @param url_con Connection object to associate data. * @param data Data to be set. * - * @ingroup Ecore_Con_Url_Group * * @see ecore_con_url_data_get() */ @@ -504,7 +518,6 @@ ecore_con_url_data_set(Ecore_Con_Url *url_con, void *data) * @param key Header key * @param value Header value * - * @ingroup Ecore_Con_Url_Group * * @see ecore_con_url_send() * @see ecore_con_url_additional_headers_clear() @@ -538,7 +551,7 @@ ecore_con_url_additional_header_add(Ecore_Con_Url *url_con, const char *key, #endif } -/* +/** * Cleans additional headers. * * Cleans additional headers associated with a connection object (previously @@ -546,7 +559,6 @@ ecore_con_url_additional_header_add(Ecore_Con_Url *url_con, const char *key, * * @param url_con Connection object to clean additional headers. * - * @ingroup Ecore_Con_Url_Group * * @see ecore_con_url_additional_header_add() * @see ecore_con_url_send() @@ -565,7 +577,7 @@ ecore_con_url_additional_headers_clear(Ecore_Con_Url *url_con) } EINA_LIST_FREE(url_con->additional_headers, s) - free(s); + free(s); #else return; url_con = NULL; @@ -578,11 +590,10 @@ ecore_con_url_additional_headers_clear(Ecore_Con_Url *url_con) * Retrieves data associated with a Ecore_Con_Url connection object (previously * set with ecore_con_url_data_set()). * - * @param Connection object to retrieve data from. + * @param url_con Connection object to retrieve data from. * * @return Data associated with the given object. * - * @ingroup Ecore_Con_Url_Group * * @see ecore_con_url_data_set() */ @@ -604,13 +615,18 @@ ecore_con_url_data_get(Ecore_Con_Url *url_con) } /** - * FIXME - * Sets the @ref Ecore_Con_Url object's condition/time members. - * @ingroup Ecore_Con_Url_Group + * Sets whether HTTP requests should be conditional, dependent on + * modification time. + * + * @param url_con Ecore_Con_Url to act upon. + * @param condition Condition to use for HTTP requests. + * @param timestamp Time since 1 Jan 1970 to use in the condition. + * + * @sa ecore_con_url_send() */ EAPI void ecore_con_url_time(Ecore_Con_Url *url_con, Ecore_Con_Url_Time condition, - time_t tm) + double timestamp) { #ifdef HAVE_CURL if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) @@ -619,13 +635,13 @@ ecore_con_url_time(Ecore_Con_Url *url_con, Ecore_Con_Url_Time condition, return; } - url_con->condition = condition; - url_con->time = tm; + url_con->time_condition = condition; + url_con->timestamp = timestamp; #else return; - url_con = NULL; - condition = 0; - tm = 0; + (void)url_con; + (void)condition; + (void)timestamp; #endif } @@ -639,7 +655,6 @@ ecore_con_url_time(Ecore_Con_Url *url_con, Ecore_Con_Url_Time condition, * @param url_con Connection object to set file * @param fd File descriptor associated with the file * - * @ingroup Ecore_Con_Url_Group */ EAPI void ecore_con_url_fd_set(Ecore_Con_Url *url_con, int fd) @@ -665,7 +680,6 @@ ecore_con_url_fd_set(Ecore_Con_Url *url_con, int fd) * * @return Number of bytes received on request. * - * @ingroup Ecore_Con_Url_Group * * @see ecore_con_url_send() */ @@ -697,7 +711,6 @@ ecore_con_url_received_bytes_get(Ecore_Con_Url *url_con) * * @return List of response headers. This list must not be modified by the user. * - * @ingroup Ecore_Con_Url_Group */ EAPI const Eina_List * ecore_con_url_response_headers_get(Ecore_Con_Url *url_con) @@ -718,21 +731,21 @@ ecore_con_url_response_headers_get(Ecore_Con_Url *url_con) * @param password Password to use in authentication * @param safe Whether to use "safer" methods (eg, NOT http basic auth) * - * @return 1 on success, 0 on error. + * @return #EINA_TRUE on success, #EINA_FALSE on error. * - * @ingroup Ecore_Con_Url_Group */ -EAPI int +EAPI Eina_Bool ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, const char *username, - const char *password, - Eina_Bool safe) + const char *password, Eina_Bool safe) { #ifdef HAVE_CURL + CURLcode ret; + if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) { ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_httpauth_set"); - return 0; + return EINA_FALSE; } # if LIBCURL_VERSION_NUM >= 0x071301 @@ -744,14 +757,28 @@ ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, const char *username, else curl_easy_setopt(url_con->curl_easy, CURLOPT_HTTPAUTH, CURLAUTH_ANY); - curl_easy_setopt(url_con->curl_easy, CURLOPT_USERNAME, username); - curl_easy_setopt(url_con->curl_easy, CURLOPT_PASSWORD, password); - return 1; - } + ret = curl_easy_setopt(url_con->curl_easy, CURLOPT_USERNAME, username); + if (ret != CURLE_OK) + { + ERR("Could not set username for HTTP authentication: %s", + curl_easy_strerror(ret)); + return EINA_FALSE; + } + + ret = curl_easy_setopt(url_con->curl_easy, CURLOPT_PASSWORD, password); + if (ret != CURLE_OK) + { + ERR("Could not set password for HTTP authentication: %s", + curl_easy_strerror(ret)); + return EINA_FALSE; + } + return EINA_TRUE; + } # endif #endif - return 0; + + return EINA_FALSE; } /** @@ -759,13 +786,12 @@ ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, const char *username, * * @param url_con Connection object to perform a request on, previously created * with ecore_con_url_new() or ecore_con_url_custom_new(). - * @param data Payload (data sent on the request) - * @param length Payload length + * @param data Payload (data sent on the request) + * @param length Payload length. If @c -1, rely on automatic length + * calculation via @c strlen() on @p data. * @param content_type Content type of the payload (e.g. text/xml) * - * @return 1 on success, 0 on error. - * - * @ingroup Ecore_Con_Url_Group + * @return #EINA_TRUE on success, #EINA_FALSE on error. * * @see ecore_con_url_custom_new() * @see ecore_con_url_additional_headers_clear() @@ -773,9 +799,10 @@ ecore_con_url_httpauth_set(Ecore_Con_Url *url_con, const char *username, * @see ecore_con_url_data_set() * @see ecore_con_url_data_get() * @see ecore_con_url_response_headers_get() + * @see ecore_con_url_time() */ -EAPI int -ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, size_t length, +EAPI Eina_Bool +ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, long length, const char *content_type) { #ifdef HAVE_CURL @@ -786,17 +813,18 @@ ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, size_t length, if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) { ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_send"); - return 0; + return EINA_FALSE; } if (url_con->active) - return 0; + return EINA_FALSE; if (!url_con->url) - return 0; + return EINA_FALSE; /* Free response headers from previous send() calls */ - EINA_LIST_FREE(url_con->response_headers, s) free((char *)s); + EINA_LIST_FREE(url_con->response_headers, s) + free((char *)s); url_con->response_headers = NULL; curl_slist_free_all(url_con->headers); @@ -804,20 +832,17 @@ ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, size_t length, if (data) { - curl_easy_setopt(url_con->curl_easy, CURLOPT_POSTFIELDS, data); - curl_easy_setopt(url_con->curl_easy, CURLOPT_POSTFIELDSIZE, length); - - if (content_type && (strlen(content_type) < 200)) + if ((content_type) && (strlen(content_type) < 200)) { - sprintf(tmp, "Content-type: %s", content_type); + snprintf(tmp, sizeof(tmp), "Content-Type: %s", content_type); url_con->headers = curl_slist_append(url_con->headers, tmp); } - sprintf(tmp, "Content-length: %zu", length); - url_con->headers = curl_slist_append(url_con->headers, tmp); + curl_easy_setopt(url_con->curl_easy, CURLOPT_POSTFIELDS, data); + curl_easy_setopt(url_con->curl_easy, CURLOPT_POSTFIELDSIZE, length); } - switch (url_con->condition) + switch (url_con->time_condition) { case ECORE_CON_URL_TIME_NONE: curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION, @@ -827,35 +852,29 @@ ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, size_t length, case ECORE_CON_URL_TIME_IFMODSINCE: curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE); - curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE, url_con->time); + curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE, + (long)url_con->timestamp); break; case ECORE_CON_URL_TIME_IFUNMODSINCE: curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFUNMODSINCE); - curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE, url_con->time); - break; - - case ECORE_CON_URL_TIME_LASTMOD: - curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMECONDITION, - CURL_TIMECOND_LASTMOD); - curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE, url_con->time); + curl_easy_setopt(url_con->curl_easy, CURLOPT_TIMEVALUE, + (long)url_con->timestamp); break; } /* Additional headers */ EINA_LIST_FOREACH(url_con->additional_headers, l, s) - url_con->headers = curl_slist_append(url_con->headers, s); + url_con->headers = curl_slist_append(url_con->headers, s); curl_easy_setopt(url_con->curl_easy, CURLOPT_HTTPHEADER, url_con->headers); url_con->received = 0; - int res = _ecore_con_url_perform(url_con); - - return res; + return _ecore_con_url_perform(url_con); #else - return 0; + return EINA_FALSE; url_con = NULL; data = NULL; length = 0; @@ -864,11 +883,17 @@ ecore_con_url_send(Ecore_Con_Url *url_con, const void *data, size_t length, } /** - * Makes a FTP upload - * @return FIXME: To be more documented. - * @ingroup Ecore_Con_Url_Group + * @brief Uploads a file to an ftp site. + * @param url_con The Ecore_Con_Url object to send with + * @param filename The path to the file to send + * @param user The username to log in with + * @param pass The password to log in with + * @param upload_dir The directory to which the file should be uploaded + * @return #EINA_TRUE on success, else #EINA_FALSE. + * Upload @p filename to an ftp server set in @p url_con using @p user + * and @p pass to directory @p upload_dir */ -EAPI int +EAPI Eina_Bool ecore_con_url_ftp_upload(Ecore_Con_Url *url_con, const char *filename, const char *user, const char *pass, const char *upload_dir) @@ -878,108 +903,89 @@ ecore_con_url_ftp_upload(Ecore_Con_Url *url_con, const char *filename, char userpwd[4096]; FILE *fd; struct stat file_info; + CURLcode ret; if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) { ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, "ecore_con_url_ftp_upload"); - return 0; + return EINA_FALSE; } if (url_con->active) - return 0; + return EINA_FALSE; if (!url_con->url) - return 0; + return EINA_FALSE; if (filename) { - char tmp[PATH_MAX]; + if (stat(filename, &file_info)) + return EINA_FALSE; - snprintf(tmp, PATH_MAX, "%s", filename); + snprintf(userpwd, sizeof(userpwd), "%s:%s", user, pass); + ret = curl_easy_setopt(url_con->curl_easy, CURLOPT_USERPWD, userpwd); + if (ret != CURLE_OK) + { + ERR("Could not set username and password for FTP upload: %s", + curl_easy_strerror(ret)); + return EINA_FALSE; + } - if (stat(filename, &file_info)) - return 0; + char tmp[PATH_MAX]; + snprintf(tmp, PATH_MAX, "%s", filename); - fd = fopen(filename, "rb"); if (upload_dir) - snprintf(url, sizeof(url), "ftp://%s/%s/%s", url_con->url, - upload_dir, basename(tmp)); + snprintf(url, sizeof(url), "ftp://%s/%s/%s", url_con->url, + upload_dir, basename(tmp)); else - snprintf(url, sizeof(url), "ftp://%s/%s", url_con->url, - basename(tmp)); + snprintf(url, sizeof(url), "ftp://%s/%s", url_con->url, + basename(tmp)); + + if (!ecore_con_url_url_set(url_con, url)) + return EINA_FALSE; - snprintf(userpwd, sizeof(userpwd), "%s:%s", user, pass); curl_easy_setopt(url_con->curl_easy, CURLOPT_INFILESIZE_LARGE, (curl_off_t)file_info.st_size); - curl_easy_setopt(url_con->curl_easy, CURLOPT_USERPWD, userpwd); curl_easy_setopt(url_con->curl_easy, CURLOPT_UPLOAD, 1); curl_easy_setopt(url_con->curl_easy, CURLOPT_READFUNCTION, _ecore_con_url_read_cb); + + fd = fopen(filename, "rb"); + if (!fd) + { + ERR("Could not open \"%s\" for FTP upload", filename); + return EINA_FALSE; + } curl_easy_setopt(url_con->curl_easy, CURLOPT_READDATA, fd); - ecore_con_url_url_set(url_con, url); return _ecore_con_url_perform(url_con); } - else - return 0; + return EINA_FALSE; #else - return 0; - url_con = NULL; - filename = NULL; - user = NULL; - pass = NULL; - upload_dir = NULL; + return EINA_FALSE; + (void)url_con; + (void)filename; + (void)user; + (void)pass; + (void)upload_dir; #endif } /** - * Send a Curl httppost - * @return 1 on success, 0 on error. - * @ingroup Ecore_Con_Url_Group - */ -EAPI int -ecore_con_url_http_post_send(Ecore_Con_Url *url_con, void *httppost) -{ -#ifdef HAVE_CURL - if (url_con->post) - curl_formfree(url_con->post); - - url_con->post = NULL; - - if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) - { - ECORE_MAGIC_FAIL(url_con, ECORE_MAGIC_CON_URL, - "ecore_con_url_http_post_send"); - return 0; - } - - url_con->post = httppost; - - if (url_con->active) - return 0; - - if (!url_con->url) - return 0; - - curl_easy_setopt(url_con->curl_easy, CURLOPT_HTTPPOST, httppost); - - return ecore_con_url_send(url_con, NULL, 0, NULL); -#else - return 0; - url_con = NULL; -#endif -} - -/** - * Enable or disable libcurl verbose output, useful for debug - * @return FIXME: To be more documented. - * @ingroup Ecore_Con_Url_Group + * Toggle libcurl's verbose output. + * + * If @p verbose is @c EINA_TRUE, libcurl will output a lot of verbose + * information about its operations, which is useful for + * debugging. The verbose information will be sent to stderr. + * + * @param url_con Ecore_Con_Url instance which will be acted upon. + * @param verbose Whether or not to enable libcurl's verbose output. */ EAPI void -ecore_con_url_verbose_set(Ecore_Con_Url *url_con, int verbose) +ecore_con_url_verbose_set(Ecore_Con_Url *url_con, Eina_Bool verbose) { #ifdef HAVE_CURL if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) @@ -995,23 +1001,19 @@ ecore_con_url_verbose_set(Ecore_Con_Url *url_con, int verbose) if (!url_con->url) return; - if (verbose == - EINA_TRUE) - curl_easy_setopt(url_con->curl_easy, CURLOPT_VERBOSE, - 1); - else - curl_easy_setopt(url_con->curl_easy, CURLOPT_VERBOSE, 0); - + curl_easy_setopt(url_con->curl_easy, CURLOPT_VERBOSE, (int)verbose); +#else + (void)url_con; + (void)verbose; #endif } /** * Enable or disable EPSV extension * @return FIXME: To be more documented. - * @ingroup Ecore_Con_Url_Group */ EAPI void -ecore_con_url_ftp_use_epsv_set(Ecore_Con_Url *url_con, int use_epsv) +ecore_con_url_ftp_use_epsv_set(Ecore_Con_Url *url_con, Eina_Bool use_epsv) { #ifdef HAVE_CURL if (!ECORE_MAGIC_CHECK(url_con, ECORE_MAGIC_CON_URL)) @@ -1027,16 +1029,16 @@ ecore_con_url_ftp_use_epsv_set(Ecore_Con_Url *url_con, int use_epsv) if (!url_con->url) return; - if (use_epsv == - EINA_TRUE) - curl_easy_setopt(url_con->curl_easy, CURLOPT_FTP_USE_EPSV, - 1); - else - curl_easy_setopt(url_con->curl_easy, CURLOPT_FTP_USE_EPSV, 0); - + curl_easy_setopt(url_con->curl_easy, CURLOPT_FTP_USE_EPSV, (int)use_epsv); #endif + (void)url_con; + (void)use_epsv; } +/** + * @} + */ + #ifdef HAVE_CURL static int _ecore_con_url_suspend_fd_handler(void) @@ -1227,20 +1229,21 @@ _ecore_con_url_read_cb(void *ptr, size_t size, size_t nitems, void *stream) return retcode; } -static int +static Eina_Bool _ecore_con_url_perform(Ecore_Con_Url *url_con) { fd_set read_set, write_set, exc_set; int fd_max, fd; int flags, still_running; int completed_immediately = 0; + CURLMcode ret; _url_con_list = eina_list_append(_url_con_list, url_con); - url_con->active = 1; - curl_multi_add_handle(curlm, url_con->curl_easy); + url_con->active = EINA_TRUE; + curl_multi_add_handle(_curlm, url_con->curl_easy); /* This one can't be stopped, or the download never start. */ - while (curl_multi_perform(curlm, &still_running) == CURLM_CALL_MULTI_PERFORM) ; + while (curl_multi_perform(_curlm, &still_running) == CURLM_CALL_MULTI_PERFORM) ; completed_immediately = _ecore_con_url_process_completed_jobs(url_con); @@ -1257,7 +1260,14 @@ _ecore_con_url_perform(Ecore_Con_Url *url_con) FD_ZERO(&exc_set); /* Stupid curl, why can't I get the fd to the current added job? */ - curl_multi_fdset(curlm, &read_set, &write_set, &exc_set, &fd_max); + ret = curl_multi_fdset(_curlm, &read_set, &write_set, &exc_set, + &fd_max); + if (ret != CURLM_OK) + { + ERR("curl_multi_fdset failed: %s", curl_multi_strerror(ret)); + return EINA_FALSE; + } + for (fd = 0; fd <= fd_max; fd++) { if (!FD_ISSET(fd, &_current_fd_set)) @@ -1276,7 +1286,11 @@ _ecore_con_url_perform(Ecore_Con_Url *url_con) { long ms = 0; - curl_multi_timeout(curlm, &ms); + ret = curl_multi_timeout(_curlm, &ms); + if (ret != CURLM_OK) + ERR("curl_multi_timeout failed: %s", + curl_multi_strerror(ret)); + if (ms == 0) ms = 1000; @@ -1295,16 +1309,21 @@ _ecore_con_url_perform(Ecore_Con_Url *url_con) { /* Failed to set up an fd_handler */ ecore_timer_freeze(_curl_timeout); - curl_multi_remove_handle(curlm, url_con->curl_easy); - url_con->active = 0; + + ret = curl_multi_remove_handle(_curlm, url_con->curl_easy); + if (ret != CURLM_OK) + ERR("curl_multi_remove_handle failed: %s", + curl_multi_strerror(ret)); + + url_con->active = EINA_FALSE; url_con->fd = -1; - return 0; + return EINA_FALSE; } ecore_timer_thaw(_curl_timeout); } - return 1; + return EINA_TRUE; } static Eina_Bool @@ -1314,7 +1333,7 @@ _ecore_con_url_idler_handler(void *data) int done = 1, still_running; start = ecore_time_get(); - while (curl_multi_perform(curlm, &still_running) == CURLM_CALL_MULTI_PERFORM) + while (curl_multi_perform(_curlm, &still_running) == CURLM_CALL_MULTI_PERFORM) /* make this not more than a frametime to keep interactivity high */ if ((ecore_time_get() - start) > ecore_animator_frametime_get()) { @@ -1359,11 +1378,12 @@ _ecore_con_url_process_completed_jobs(Ecore_Con_Url *url_con_to_match) Ecore_Con_Url *url_con; Ecore_Con_Event_Url_Complete *e; CURLMsg *curlmsg; + CURLMcode ret; int n_remaining; int job_matched = 0; /* Loop jobs and check if any are done */ - while ((curlmsg = curl_multi_info_read(curlm, &n_remaining))) + while ((curlmsg = curl_multi_info_read(_curlm, &n_remaining))) { if (curlmsg->msg != CURLMSG_DONE) continue; @@ -1389,7 +1409,7 @@ _ecore_con_url_process_completed_jobs(Ecore_Con_Url *url_con_to_match) } _url_con_list = eina_list_remove(_url_con_list, url_con); - url_con->active = 0; + url_con->active = EINA_FALSE; e = calloc(1, sizeof(Ecore_Con_Event_Url_Complete)); if (e) { @@ -1409,7 +1429,11 @@ _ecore_con_url_process_completed_jobs(Ecore_Con_Url *url_con_to_match) _url_complete_push_event(ECORE_CON_EVENT_URL_COMPLETE, e); } - curl_multi_remove_handle(curlm, url_con->curl_easy); + ret = curl_multi_remove_handle(_curlm, url_con->curl_easy); + if (ret != CURLM_OK) + ERR("curl_multi_remove_handle failed: %s", + curl_multi_strerror(ret)); + break; } } diff --git a/src/lib/ecore_config/ecore_config.c b/src/lib/ecore_config/ecore_config.c index f258a0b..ddfc64f 100644 --- a/src/lib/ecore_config/ecore_config.c +++ b/src/lib/ecore_config/ecore_config.c @@ -1670,7 +1670,8 @@ ecore_config_init(const char *name) { char *path; Ecore_Config_Prop *list; - _ecore_config_log_dom = eina_log_domain_register("EcoreConfig", ECORE_CONFIG_DEFAULT_LOG_COLOR); + _ecore_config_log_dom = eina_log_domain_register + ("ecore_config", ECORE_CONFIG_DEFAULT_LOG_COLOR); if(_ecore_config_log_dom < 0) { EINA_LOG_ERR("Impossible to create a log domain for the Ecore config module."); @@ -1788,7 +1789,7 @@ _ecore_config_system_load(void) { snprintf(buf, PATH_MAX, "%s/.e/config.eet", p); if (ecore_config_file_load(buf) != 0) { - /* even if this file (system.eet) dosen't exist we can + /* even if this file (system.eet) doesn't exist we can * continue without it as it isn't striclty necessary. */ ecore_config_file_load(PACKAGE_DATA_DIR "/system.eet"); diff --git a/src/lib/ecore_directfb/Ecore_DirectFB.h b/src/lib/ecore_directfb/Ecore_DirectFB.h index 30aa82b..1f6fc63 100644 --- a/src/lib/ecore_directfb/Ecore_DirectFB.h +++ b/src/lib/ecore_directfb/Ecore_DirectFB.h @@ -3,26 +3,21 @@ #include +#include + #ifdef EAPI -#undef EAPI +# undef EAPI #endif /* ifdef EAPI */ -#ifdef _MSC_VER -# ifdef BUILDING_DLL -# define EAPI __declspec(dllexport) -# else /* ifdef BUILDING_DLL */ -# define EAPI __declspec(dllimport) -# endif /* ifdef BUILDING_DLL */ -#else /* ifdef _MSC_VER */ -# ifdef __GNUC__ -# if __GNUC__ >= 4 -# define EAPI __attribute__ ((visibility("default"))) -# else /* if __GNUC__ >= 4 */ -# define EAPI -# endif /* if __GNUC__ >= 4 */ -# else /* ifdef __GNUC__ */ + +#ifdef __GNUC__ +# if __GNUC__ >= 4 +# define EAPI __attribute__ ((visibility("default"))) +# else /* if __GNUC__ >= 4 */ # define EAPI -# endif /* ifdef __GNUC__ */ -#endif /* ifdef _MSC_VER */ +# endif /* if __GNUC__ >= 4 */ +#else /* ifdef __GNUC__ */ +# define EAPI +#endif /* ifdef __GNUC__ */ #ifdef __cplusplus extern "C" { @@ -113,6 +108,8 @@ struct _Ecore_DirectFB_Event_Button_Up int x, y; unsigned int time; DFBWindowID win; + int double_click : 1; + int triple_click : 1; }; struct _Ecore_DirectFB_Event_Motion { @@ -160,21 +157,22 @@ struct _Ecore_DirectFB_Event_Lost_Focus }; /* main functions */ -EAPI int ecore_directfb_init(const char *name); -EAPI int ecore_directfb_shutdown(void); -EAPI IDirectFB * ecore_directfb_interface_get(void); +EAPI int ecore_directfb_init(const char *name); +EAPI int ecore_directfb_shutdown(void); +EAPI IDirectFB * ecore_directfb_interface_get(void); + /* window operations */ -EAPI Ecore_DirectFB_Window * ecore_directfb_window_new(int x, int y, int w, int h); -EAPI void ecore_directfb_window_free(Ecore_DirectFB_Window *window); -EAPI void ecore_directfb_window_move(Ecore_DirectFB_Window *window, int x, int y); -EAPI void ecore_directfb_window_resize(Ecore_DirectFB_Window *window, int w, int h); -EAPI void ecore_directfb_window_focus(Ecore_DirectFB_Window *window); -EAPI void ecore_directfb_window_show(Ecore_DirectFB_Window *window); -EAPI void ecore_directfb_window_hide(Ecore_DirectFB_Window *window); -EAPI void ecore_directfb_window_shaped_set(Ecore_DirectFB_Window *window, int set); -EAPI void ecore_directfb_window_fullscreen_set(Ecore_DirectFB_Window *window, int set); -EAPI void ecore_directfb_window_size_get(Ecore_DirectFB_Window *window, int *w, int *h); -EAPI void ecore_directfb_window_cursor_show(Ecore_DirectFB_Window *window, int show); +EAPI Ecore_DirectFB_Window *ecore_directfb_window_new(int x, int y, int w, int h); +EAPI void ecore_directfb_window_free(Ecore_DirectFB_Window *window); +EAPI void ecore_directfb_window_move(Ecore_DirectFB_Window *window, int x, int y); +EAPI void ecore_directfb_window_resize(Ecore_DirectFB_Window *window, int w, int h); +EAPI void ecore_directfb_window_focus(Ecore_DirectFB_Window *window); +EAPI void ecore_directfb_window_show(Ecore_DirectFB_Window *window); +EAPI void ecore_directfb_window_hide(Ecore_DirectFB_Window *window); +EAPI void ecore_directfb_window_shaped_set(Ecore_DirectFB_Window *window, Eina_Bool set); +EAPI void ecore_directfb_window_fullscreen_set(Ecore_DirectFB_Window *window, Eina_Bool set); +EAPI void ecore_directfb_window_size_get(Ecore_DirectFB_Window *window, int *w, int *h); +EAPI void ecore_directfb_window_cursor_show(Ecore_DirectFB_Window *window, Eina_Bool show); #ifdef __cplusplus } diff --git a/src/lib/ecore_directfb/ecore_directfb.c b/src/lib/ecore_directfb/ecore_directfb.c index dbcfaa1..f45b3c3 100644 --- a/src/lib/ecore_directfb/ecore_directfb.c +++ b/src/lib/ecore_directfb/ecore_directfb.c @@ -55,7 +55,7 @@ static IDirectFB *_dfb = NULL; // the main interface static IDirectFBEventBuffer *_window_event; // the main event buffer (all windows are attached to this) static IDirectFBEventBuffer *_input_event; // the main event buffer (all windows are attached to this) static IDirectFBDisplayLayer *_layer; // the main layer -static DFBResult _err; // usefull for DFBCHECK +static DFBResult _err; // useful for DFBCHECK /*******************/ /* local functions */ @@ -561,7 +561,7 @@ ecore_directfb_window_focus(Ecore_DirectFB_Window *ecore_window) EAPI void ecore_directfb_window_hide(Ecore_DirectFB_Window *ecore_window) { - DFBCHECK(ecore_window->window->SetOpacity(ecore_window->window,0)); + DFBCHECK(ecore_window->window->SetOpacity(ecore_window->window, 0)); } /* ecore_directfb_window_hide */ EAPI void @@ -571,7 +571,7 @@ ecore_directfb_window_show(Ecore_DirectFB_Window *ecore_window) } /* ecore_directfb_window_show */ EAPI void -ecore_directfb_window_shaped_set(Ecore_DirectFB_Window *ecore_window, int set) +ecore_directfb_window_shaped_set(Ecore_DirectFB_Window *ecore_window, Eina_Bool set) { DFBWindowOptions opts; @@ -591,7 +591,7 @@ ecore_directfb_window_shaped_set(Ecore_DirectFB_Window *ecore_window, int set) } /* ecore_directfb_window_shaped_set */ EAPI void -ecore_directfb_window_cursor_show(Ecore_DirectFB_Window *ecore_window, int show) +ecore_directfb_window_cursor_show(Ecore_DirectFB_Window *ecore_window, Eina_Bool show) { if(!show) { @@ -642,7 +642,7 @@ ecore_directfb_window_cursor_set(Ecore_DirectFB_Window *ecore_window, Ecore_Dire } /* ecore_directfb_window_cursor_set */ EAPI void -ecore_directfb_window_fullscreen_set(Ecore_DirectFB_Window *ecore_window, int on) +ecore_directfb_window_fullscreen_set(Ecore_DirectFB_Window *ecore_window, Eina_Bool on) { // always release the surface (we are going to get a new one in both cases) DFBCHECK(ecore_window->surface->Release(ecore_window->surface)); @@ -683,7 +683,8 @@ ecore_directfb_init(const char *name __UNUSED__) if (++_ecore_directfb_init_count != 1) return _ecore_directfb_init_count; - _ecore_directfb_log_dom = eina_log_domain_register("EcoreDirectFB", ECORE_DIRECTFB_DEFAULT_LOG_COLOR); + _ecore_directfb_log_dom = eina_log_domain_register + ("ecore_directfb", ECORE_DIRECTFB_DEFAULT_LOG_COLOR); if(_ecore_directfb_log_dom < 0) { EINA_LOG_ERR("Impossible to create a log domain for the Ecore directFB module."); diff --git a/src/lib/ecore_evas/Ecore_Evas.h b/src/lib/ecore_evas/Ecore_Evas.h index dcc33c0..53e5296 100644 --- a/src/lib/ecore_evas/Ecore_Evas.h +++ b/src/lib/ecore_evas/Ecore_Evas.h @@ -133,8 +133,8 @@ EAPI int ecore_evas_engine_type_supported_get(Ecore_Evas_Engine_Type eng EAPI int ecore_evas_init(void); EAPI int ecore_evas_shutdown(void); -EAPI void ecore_evas_app_comp_sync_set(int do_sync); -EAPI int ecore_evas_app_comp_sync_get(void); +EAPI void ecore_evas_app_comp_sync_set(Eina_Bool do_sync); +EAPI Eina_Bool ecore_evas_app_comp_sync_get(void); EAPI Eina_List *ecore_evas_engines_get(void); EAPI void ecore_evas_engines_free(Eina_List *engines); @@ -144,8 +144,8 @@ EAPI Ecore_Evas *ecore_evas_new(const char *engine_name, int x, int y, int w, in /* engine/target specific init calls */ EAPI Ecore_Evas *ecore_evas_software_x11_new(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h); EAPI Ecore_X_Window ecore_evas_software_x11_window_get(const Ecore_Evas *ee); -EAPI void ecore_evas_software_x11_direct_resize_set(Ecore_Evas *ee, int on); -EAPI int ecore_evas_software_x11_direct_resize_get(const Ecore_Evas *ee); +EAPI void ecore_evas_software_x11_direct_resize_set(Ecore_Evas *ee, Eina_Bool on); +EAPI Eina_Bool ecore_evas_software_x11_direct_resize_get(const Ecore_Evas *ee); EAPI void ecore_evas_software_x11_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win); #define ECORE_EVAS_GL_X11_OPT_NONE 0 @@ -155,29 +155,28 @@ EAPI void ecore_evas_software_x11_extra_event_window_add(Ecore_Evas * EAPI Ecore_Evas *ecore_evas_gl_x11_new(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h); EAPI Ecore_Evas *ecore_evas_gl_x11_options_new(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h, const int *opt); EAPI Ecore_X_Window ecore_evas_gl_x11_window_get(const Ecore_Evas *ee); -EAPI void ecore_evas_gl_x11_direct_resize_set(Ecore_Evas *ee, int on); -EAPI int ecore_evas_gl_x11_direct_resize_get(const Ecore_Evas *ee); +EAPI void ecore_evas_gl_x11_direct_resize_set(Ecore_Evas *ee, Eina_Bool on); +EAPI Eina_Bool ecore_evas_gl_x11_direct_resize_get(const Ecore_Evas *ee); EAPI void ecore_evas_gl_x11_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win); EAPI void ecore_evas_gl_x11_pre_post_swap_callback_set(const Ecore_Evas *ee, void *data, void (*pre_cb) (void *data, Evas *e), void (*post_cb) (void *data, Evas *e)); -EAPI void ecore_evas_gl_x11_no_swap_set(const Ecore_Evas *ee, Eina_Bool no_swap); EAPI Ecore_Evas *ecore_evas_xrender_x11_new(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h); EAPI Ecore_X_Window ecore_evas_xrender_x11_window_get(const Ecore_Evas *ee); -EAPI void ecore_evas_xrender_x11_direct_resize_set(Ecore_Evas *ee, int on); -EAPI int ecore_evas_xrender_x11_direct_resize_get(const Ecore_Evas *ee); +EAPI void ecore_evas_xrender_x11_direct_resize_set(Ecore_Evas *ee, Eina_Bool on); +EAPI Eina_Bool ecore_evas_xrender_x11_direct_resize_get(const Ecore_Evas *ee); EAPI void ecore_evas_xrender_x11_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win); EAPI Ecore_Evas *ecore_evas_software_x11_8_new(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h); EAPI Ecore_X_Window ecore_evas_software_x11_8_window_get(const Ecore_Evas *ee); EAPI Ecore_X_Window ecore_evas_software_x11_8_subwindow_get(const Ecore_Evas *ee); -EAPI void ecore_evas_software_x11_8_direct_resize_set(Ecore_Evas *ee, int on); -EAPI int ecore_evas_software_x11_8_direct_resize_get(const Ecore_Evas *ee); +EAPI void ecore_evas_software_x11_8_direct_resize_set(Ecore_Evas *ee, Eina_Bool on); +EAPI Eina_Bool ecore_evas_software_x11_8_direct_resize_get(const Ecore_Evas *ee); EAPI void ecore_evas_software_x11_8_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win); EAPI Ecore_Evas *ecore_evas_software_x11_16_new(const char *disp_name, Ecore_X_Window parent, int x, int y, int w, int h); EAPI Ecore_X_Window ecore_evas_software_x11_16_window_get(const Ecore_Evas *ee); -EAPI void ecore_evas_software_x11_16_direct_resize_set(Ecore_Evas *ee, int on); -EAPI int ecore_evas_software_x11_16_direct_resize_get(const Ecore_Evas *ee); +EAPI void ecore_evas_software_x11_16_direct_resize_set(Ecore_Evas *ee, Eina_Bool on); +EAPI Eina_Bool ecore_evas_software_x11_16_direct_resize_get(const Ecore_Evas *ee); EAPI void ecore_evas_software_x11_16_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window win); EAPI Ecore_Evas *ecore_evas_fb_new(const char *disp_name, int rotation, int w, int h); @@ -291,12 +290,12 @@ EAPI void ecore_evas_geometry_get(const Ecore_Evas *ee, int *x, int *y, i EAPI void ecore_evas_rotation_set(Ecore_Evas *ee, int rot); EAPI void ecore_evas_rotation_with_resize_set(Ecore_Evas *ee, int rot); EAPI int ecore_evas_rotation_get(const Ecore_Evas *ee); -EAPI void ecore_evas_shaped_set(Ecore_Evas *ee, int shaped); -EAPI int ecore_evas_shaped_get(const Ecore_Evas *ee); -EAPI void ecore_evas_alpha_set(Ecore_Evas *ee, int alpha); -EAPI int ecore_evas_alpha_get(const Ecore_Evas *ee); -EAPI void ecore_evas_transparent_set(Ecore_Evas *ee, int transparent); -EAPI int ecore_evas_transparent_get(const Ecore_Evas *ee); +EAPI void ecore_evas_shaped_set(Ecore_Evas *ee, Eina_Bool shaped); +EAPI Eina_Bool ecore_evas_shaped_get(const Ecore_Evas *ee); +EAPI void ecore_evas_alpha_set(Ecore_Evas *ee, Eina_Bool alpha); +EAPI Eina_Bool ecore_evas_alpha_get(const Ecore_Evas *ee); +EAPI void ecore_evas_transparent_set(Ecore_Evas *ee, Eina_Bool transparent); +EAPI Eina_Bool ecore_evas_transparent_get(const Ecore_Evas *ee); EAPI void ecore_evas_show(Ecore_Evas *ee); EAPI void ecore_evas_hide(Ecore_Evas *ee); EAPI int ecore_evas_visibility_get(const Ecore_Evas *ee); @@ -320,37 +319,36 @@ EAPI void ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, EAPI void ecore_evas_cursor_get(const Ecore_Evas *ee, Evas_Object **obj, int *layer, int *hot_x, int *hot_y); EAPI void ecore_evas_layer_set(Ecore_Evas *ee, int layer); EAPI int ecore_evas_layer_get(const Ecore_Evas *ee); -EAPI void ecore_evas_focus_set(Ecore_Evas *ee, int on); -EAPI int ecore_evas_focus_get(const Ecore_Evas *ee); -EAPI void ecore_evas_iconified_set(Ecore_Evas *ee, int on); -EAPI int ecore_evas_iconified_get(const Ecore_Evas *ee); -EAPI void ecore_evas_borderless_set(Ecore_Evas *ee, int on); -EAPI int ecore_evas_borderless_get(const Ecore_Evas *ee); -EAPI void ecore_evas_override_set(Ecore_Evas *ee, int on); -EAPI int ecore_evas_override_get(const Ecore_Evas *ee); -EAPI void ecore_evas_maximized_set(Ecore_Evas *ee, int on); -EAPI int ecore_evas_maximized_get(const Ecore_Evas *ee); -EAPI void ecore_evas_fullscreen_set(Ecore_Evas *ee, int on); -EAPI int ecore_evas_fullscreen_get(const Ecore_Evas *ee); +EAPI void ecore_evas_focus_set(Ecore_Evas *ee, Eina_Bool on); +EAPI Eina_Bool ecore_evas_focus_get(const Ecore_Evas *ee); +EAPI void ecore_evas_iconified_set(Ecore_Evas *ee, Eina_Bool on); +EAPI Eina_Bool ecore_evas_iconified_get(const Ecore_Evas *ee); +EAPI void ecore_evas_borderless_set(Ecore_Evas *ee, Eina_Bool on); +EAPI Eina_Bool ecore_evas_borderless_get(const Ecore_Evas *ee); +EAPI void ecore_evas_override_set(Ecore_Evas *ee, Eina_Bool on); +EAPI Eina_Bool ecore_evas_override_get(const Ecore_Evas *ee); +EAPI void ecore_evas_maximized_set(Ecore_Evas *ee, Eina_Bool on); +EAPI Eina_Bool ecore_evas_maximized_get(const Ecore_Evas *ee); +EAPI void ecore_evas_fullscreen_set(Ecore_Evas *ee, Eina_Bool on); +EAPI Eina_Bool ecore_evas_fullscreen_get(const Ecore_Evas *ee); EAPI void ecore_evas_avoid_damage_set(Ecore_Evas *ee, Ecore_Evas_Avoid_Damage_Type on); EAPI Ecore_Evas_Avoid_Damage_Type ecore_evas_avoid_damage_get(const Ecore_Evas *ee); -EAPI void ecore_evas_withdrawn_set(Ecore_Evas *ee, int withdrawn); -EAPI int ecore_evas_withdrawn_get(const Ecore_Evas *ee); -EAPI void ecore_evas_sticky_set(Ecore_Evas *ee, int sticky); -EAPI int ecore_evas_sticky_get(const Ecore_Evas *ee); -EAPI void ecore_evas_ignore_events_set(Ecore_Evas *ee, int ignore); -EAPI int ecore_evas_ignore_events_get(const Ecore_Evas *ee); -EAPI void ecore_evas_manual_render_set(Ecore_Evas *ee, int manual_render); -EAPI int ecore_evas_manual_render_get(const Ecore_Evas *ee); +EAPI void ecore_evas_withdrawn_set(Ecore_Evas *ee, Eina_Bool withdrawn); +EAPI Eina_Bool ecore_evas_withdrawn_get(const Ecore_Evas *ee); +EAPI void ecore_evas_sticky_set(Ecore_Evas *ee, Eina_Bool sticky); +EAPI Eina_Bool ecore_evas_sticky_get(const Ecore_Evas *ee); +EAPI void ecore_evas_ignore_events_set(Ecore_Evas *ee, Eina_Bool ignore); +EAPI Eina_Bool ecore_evas_ignore_events_get(const Ecore_Evas *ee); +EAPI void ecore_evas_manual_render_set(Ecore_Evas *ee, Eina_Bool manual_render); +EAPI Eina_Bool ecore_evas_manual_render_get(const Ecore_Evas *ee); EAPI void ecore_evas_manual_render(Ecore_Evas *ee); -EAPI void ecore_evas_comp_sync_set(Ecore_Evas *ee, int do_sync); -EAPI int ecore_evas_comp_sync_get(const Ecore_Evas *ee); +EAPI void ecore_evas_comp_sync_set(Ecore_Evas *ee, Eina_Bool do_sync); +EAPI Eina_Bool ecore_evas_comp_sync_get(const Ecore_Evas *ee); EAPI Ecore_Window ecore_evas_window_get(const Ecore_Evas *ee); - -EAPI int ecore_evas_object_associate(Ecore_Evas *ee, Evas_Object *obj, Ecore_Evas_Object_Associate_Flags flags); -EAPI int ecore_evas_object_dissociate(Ecore_Evas *ee, Evas_Object *obj); +EAPI Eina_Bool ecore_evas_object_associate(Ecore_Evas *ee, Evas_Object *obj, Ecore_Evas_Object_Associate_Flags flags); +EAPI Eina_Bool ecore_evas_object_dissociate(Ecore_Evas *ee, Evas_Object *obj); EAPI Evas_Object *ecore_evas_object_associate_get(const Ecore_Evas *ee); /* helper function to be used with ECORE_GETOPT_CALLBACK_*() */ @@ -358,7 +356,11 @@ EAPI unsigned char ecore_getopt_callback_ecore_evas_list_engines(const Ecore_Get EAPI Eina_List *ecore_evas_ecore_evas_list_get(void); - +/* specific calls to an x11 environment ecore_evas */ +EAPI void ecore_evas_x11_leader_set(Ecore_Evas *ee, Ecore_X_Window win); +EAPI Ecore_X_Window ecore_evas_x11_leader_get(Ecore_Evas *ee); +EAPI void ecore_evas_x11_leader_default_set(Ecore_Evas *ee); + #ifdef __cplusplus } #endif diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c index 9bd4673..4f65880 100644 --- a/src/lib/ecore_evas/ecore_evas.c +++ b/src/lib/ecore_evas/ecore_evas.c @@ -59,7 +59,7 @@ _ecore_evas_idle_enter(void *data __UNUSED__) /** * Query if a particular renginering engine target has support * @param engine The engine to check support for - * @return 1 if the particualr engine is supported, 0 if it is not + * @return 1 if the particular engine is supported, 0 if it is not * * Query if engine @param engine is supported by ecore_evas. 1 is returned if * it is, and 0 is returned if it is not supported. @@ -71,63 +71,63 @@ ecore_evas_engine_type_supported_get(Ecore_Evas_Engine_Type engine) { case ECORE_EVAS_ENGINE_SOFTWARE_BUFFER: #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER - return 1; + return 1; #else - return 0; + return 0; #endif case ECORE_EVAS_ENGINE_SOFTWARE_XLIB: #ifdef BUILD_ECORE_EVAS_SOFTWARE_XLIB - return 1; + return 1; #else - return 0; + return 0; #endif case ECORE_EVAS_ENGINE_XRENDER_X11: #ifdef BUILD_ECORE_EVAS_XRENDER_X11 - return 1; + return 1; #else - return 0; + return 0; #endif case ECORE_EVAS_ENGINE_OPENGL_X11: #ifdef BUILD_ECORE_EVAS_OPENGL_X11 - return 1; + return 1; #else - return 0; + return 0; #endif case ECORE_EVAS_ENGINE_SOFTWARE_XCB: #ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB - return 1; + return 1; #else - return 0; + return 0; #endif case ECORE_EVAS_ENGINE_XRENDER_XCB: #ifdef BUILD_ECORE_EVAS_XRENDER_XCB - return 1; + return 1; #else - return 0; + return 0; #endif case ECORE_EVAS_ENGINE_SOFTWARE_GDI: #ifdef BUILD_ECORE_EVAS_SOFTWARE_GDI - return 1; + return 1; #else - return 0; + return 0; #endif case ECORE_EVAS_ENGINE_SOFTWARE_DDRAW: #ifdef BUILD_ECORE_EVAS_SOFTWARE_DDRAW - return 1; + return 1; #else - return 0; + return 0; #endif case ECORE_EVAS_ENGINE_DIRECT3D: #ifdef BUILD_ECORE_EVAS_DIRECT3D - return 1; + return 1; #else - return 0; + return 0; #endif case ECORE_EVAS_ENGINE_OPENGL_GLEW: #ifdef BUILD_ECORE_EVAS_OPENGL_GLEW - return 1; + return 1; #else - return 0; + return 0; #endif case ECORE_EVAS_ENGINE_SOFTWARE_SDL: #ifdef BUILD_ECORE_EVAS_SOFTWARE_SDL @@ -143,51 +143,51 @@ ecore_evas_engine_type_supported_get(Ecore_Evas_Engine_Type engine) #endif case ECORE_EVAS_ENGINE_DIRECTFB: #ifdef BUILD_ECORE_EVAS_DIRECTFB - return 1; + return 1; #else - return 0; + return 0; #endif case ECORE_EVAS_ENGINE_SOFTWARE_FB: #ifdef BUILD_ECORE_EVAS_FB - return 1; + return 1; #else - return 0; + return 0; #endif - case ECORE_EVAS_ENGINE_SOFTWARE_8_X11: + case ECORE_EVAS_ENGINE_SOFTWARE_8_X11: #ifdef BUILD_ECORE_EVAS_SOFTWARE_8_X11 - return 1; + return 1; #else - return 0; + return 0; #endif case ECORE_EVAS_ENGINE_SOFTWARE_16_X11: #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_X11 - return 1; + return 1; #else - return 0; + return 0; #endif case ECORE_EVAS_ENGINE_SOFTWARE_16_DDRAW: #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_DDRAW - return 1; + return 1; #else - return 0; + return 0; #endif case ECORE_EVAS_ENGINE_SOFTWARE_16_WINCE: #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_WINCE - return 1; + return 1; #else - return 0; + return 0; #endif case ECORE_EVAS_ENGINE_COCOA: #ifdef BUILD_ECORE_EVAS_COCOA - return 1; + return 1; #else - return 0; + return 0; #endif default: - return 0; - break; + return 0; + break; }; } @@ -211,19 +211,20 @@ ecore_evas_init(void) if (!ecore_init()) goto shutdown_evas; - _ecore_evas_log_dom = eina_log_domain_register("Ecore_Evas", ECORE_EVAS_DEFAULT_LOG_COLOR); - if(_ecore_evas_log_dom < 0) + _ecore_evas_log_dom = eina_log_domain_register + ("ecore_evas", ECORE_EVAS_DEFAULT_LOG_COLOR); + if(_ecore_evas_log_dom < 0) { - EINA_LOG_ERR("Impossible to create a log domain for Ecore_Evas."); - goto shutdown_ecore; + EINA_LOG_ERR("Impossible to create a log domain for Ecore_Evas."); + goto shutdown_ecore; } fd = evas_async_events_fd_get(); if (fd > 0) _ecore_evas_async_events_fd = ecore_main_fd_handler_add(fd, - ECORE_FD_READ, - _ecore_evas_async_events_fd_handler, NULL, - NULL, NULL); + ECORE_FD_READ, + _ecore_evas_async_events_fd_handler, NULL, + NULL, NULL); ecore_evas_idle_enterer = ecore_idle_enterer_add(_ecore_evas_idle_enter, NULL); @@ -287,15 +288,15 @@ ecore_evas_shutdown(void) return _ecore_evas_init_count; } -int _ecore_evas_app_comp_sync = 1; +Eina_Bool _ecore_evas_app_comp_sync = 1; EAPI void -ecore_evas_app_comp_sync_set(int do_sync) +ecore_evas_app_comp_sync_set(Eina_Bool do_sync) { _ecore_evas_app_comp_sync = do_sync; } -EAPI int +EAPI Eina_Bool ecore_evas_app_comp_sync_get(void) { return _ecore_evas_app_comp_sync; @@ -314,31 +315,31 @@ _ecore_evas_parse_extra_options_str(const char *extra_options, const char *key, while (extra_options) { - const char *p; - - if (strncmp(extra_options, key, len) != 0) - { - extra_options = strchr(extra_options, ';'); - if (extra_options) - extra_options++; - continue; - } - - extra_options += len; - p = strchr(extra_options, ';'); - if (p) - { - len = p - extra_options; - *value = malloc(len + 1); - memcpy(*value, extra_options, len); - (*value)[len] = '\0'; - extra_options = p + 1; - } - else - { - *value = strdup(extra_options); - extra_options = NULL; - } + const char *p; + + if (strncmp(extra_options, key, len) != 0) + { + extra_options = strchr(extra_options, ';'); + if (extra_options) + extra_options++; + continue; + } + + extra_options += len; + p = strchr(extra_options, ';'); + if (p) + { + len = p - extra_options; + *value = malloc(len + 1); + memcpy(*value, extra_options, len); + (*value)[len] = '\0'; + extra_options = p + 1; + } + else + { + *value = strdup(extra_options); + extra_options = NULL; + } } return extra_options; } @@ -351,24 +352,24 @@ _ecore_evas_parse_extra_options_uint(const char *extra_options, const char *key, while (extra_options) { - const char *p; + const char *p; - if (strncmp(extra_options, key, len) != 0) - { - extra_options = strchr(extra_options, ';'); - if (extra_options) - extra_options++; - continue; - } + if (strncmp(extra_options, key, len) != 0) + { + extra_options = strchr(extra_options, ';'); + if (extra_options) + extra_options++; + continue; + } - extra_options += len; - *value = strtol(extra_options, NULL, 0); + extra_options += len; + *value = strtol(extra_options, NULL, 0); - p = strchr(extra_options, ';'); - if (p) - extra_options = p + 1; - else - extra_options = NULL; + p = strchr(extra_options, ';'); + if (p) + extra_options = p + 1; + else + extra_options = NULL; } return extra_options; } @@ -651,18 +652,18 @@ static const struct ecore_evas_engine _engines[] = { #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11 {"software_x11", _ecore_evas_constructor_software_x11}, #endif -#ifdef BUILD_ECORE_EVAS_XRENDER_X11 - {"xrender_x11", _ecore_evas_constructor_xrender_x11}, -#endif #ifdef BUILD_ECORE_EVAS_OPENGL_X11 {"opengl_x11", _ecore_evas_constructor_opengl_x11}, #endif -#ifdef BUILD_ECORE_EVAS_XRENDER_XCB - {"xrender_xcb", _ecore_evas_constructor_xrender_x11}, -#endif #ifdef BUILD_ECORE_EVAS_SOFTWARE_8_X11 {"software_8_x11", _ecore_evas_constructor_software_8_x11}, #endif +#ifdef BUILD_ECORE_EVAS_XRENDER_X11 + {"xrender_x11", _ecore_evas_constructor_xrender_x11}, +#endif +#ifdef BUILD_ECORE_EVAS_XRENDER_XCB + {"xrender_xcb", _ecore_evas_constructor_xrender_x11}, +#endif #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_X11 {"software_16_x11", _ecore_evas_constructor_software_16_x11}, #endif @@ -755,12 +756,12 @@ _ecore_evas_new_auto_discover(int x, int y, int w, int h, const char *extra_opti for (itr = _engines; itr->constructor; itr++) { - Ecore_Evas *ee = itr->constructor(x, y, w, h, extra_options); - if (ee) - { - INF("auto discovered '%s'", itr->name); - return ee; - } + Ecore_Evas *ee = itr->constructor(x, y, w, h, extra_options); + if (ee) + { + INF("auto discovered '%s'", itr->name); + return ee; + } } WRN("could not auto discover."); @@ -793,10 +794,10 @@ ecore_evas_new(const char *engine_name, int x, int y, int w, int h, const char * if (!engine_name) { - engine_name = getenv("ECORE_EVAS_ENGINE"); - if (engine_name) - DBG("no engine_name provided, using ECORE_EVAS_ENGINE='%s'", - engine_name); + engine_name = getenv("ECORE_EVAS_ENGINE"); + if (engine_name) + DBG("no engine_name provided, using ECORE_EVAS_ENGINE='%s'", + engine_name); } if (!engine_name) return _ecore_evas_new_auto_discover(x, y, w, h, extra_options); @@ -804,9 +805,9 @@ ecore_evas_new(const char *engine_name, int x, int y, int w, int h, const char * for (itr = _engines; itr->name; itr++) if (strcmp(itr->name, engine_name) == 0) { - INF("using engine '%s', extra_options=%s", - engine_name, extra_options ? extra_options : "(null)"); - return itr->constructor(x, y, w, h, extra_options); + INF("using engine '%s', extra_options=%s", + engine_name, extra_options ? extra_options : "(null)"); + return itr->constructor(x, y, w, h, extra_options); } WRN("unknown engine '%s'", engine_name); @@ -850,9 +851,9 @@ ecore_evas_free(Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_free"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_free"); + return; } _ecore_evas_free(ee); return; @@ -876,9 +877,9 @@ ecore_evas_data_get(const Ecore_Evas *ee, const char *key) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_data_get"); - return NULL; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_data_get"); + return NULL; } if (!key) return NULL; @@ -907,9 +908,9 @@ ecore_evas_data_set(Ecore_Evas *ee, const char *key, const void *data) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_data_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_data_set"); + return; } if (!key) return; @@ -919,7 +920,7 @@ ecore_evas_data_set(Ecore_Evas *ee, const char *key, const void *data) if (data) { if (!ee->data) - ee->data = eina_hash_string_superfast_new(NULL); + ee->data = eina_hash_string_superfast_new(NULL); eina_hash_add(ee->data, key, data); } } @@ -940,9 +941,9 @@ ecore_evas_callback_resize_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee)) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_callback_resize_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_callback_resize_set"); + return; } IFC(ee, fn_callback_resize_set) (ee, func); IFE; @@ -962,9 +963,9 @@ ecore_evas_callback_move_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee)) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_callback_move_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_callback_move_set"); + return; } IFC(ee, fn_callback_move_set) (ee, func); IFE; @@ -984,9 +985,9 @@ ecore_evas_callback_show_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee)) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_callback_show_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_callback_show_set"); + return; } IFC(ee, fn_callback_show_set) (ee, func); IFE; @@ -1006,9 +1007,9 @@ ecore_evas_callback_hide_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee)) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_callback_hide_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_callback_hide_set"); + return; } IFC(ee, fn_callback_hide_set) (ee, func); IFE; @@ -1028,9 +1029,9 @@ ecore_evas_callback_delete_request_set(Ecore_Evas *ee, void (*func) (Ecore_Evas { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_callback_delete_request_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_callback_delete_request_set"); + return; } IFC(ee, fn_callback_delete_request_set) (ee, func); IFE; @@ -1050,9 +1051,9 @@ ecore_evas_callback_destroy_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee)) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_callback_destroy_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_callback_destroy_set"); + return; } IFC(ee, fn_callback_destroy_set) (ee, func); IFE; @@ -1072,9 +1073,9 @@ ecore_evas_callback_focus_in_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee)) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_callback_focus_in_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_callback_focus_in_set"); + return; } IFC(ee, fn_callback_focus_in_set) (ee, func); IFE; @@ -1094,9 +1095,9 @@ ecore_evas_callback_focus_out_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee)) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_callback_focus_out_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_callback_focus_out_set"); + return; } IFC(ee, fn_callback_focus_out_set) (ee, func); IFE; @@ -1116,9 +1117,9 @@ ecore_evas_callback_sticky_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee)) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_callback_sticky_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_callback_sticky_set"); + return; } IFC(ee, fn_callback_sticky_set) (ee, func); IFE; @@ -1138,9 +1139,9 @@ ecore_evas_callback_unsticky_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee)) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_callback_unsticky_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_callback_unsticky_set"); + return; } IFC(ee, fn_callback_unsticky_set) (ee, func); IFE; @@ -1160,9 +1161,9 @@ ecore_evas_callback_mouse_in_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee)) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_callback_mouse_in_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_callback_mouse_in_set"); + return; } IFC(ee, fn_callback_mouse_in_set) (ee, func); IFE; @@ -1182,9 +1183,9 @@ ecore_evas_callback_mouse_out_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee)) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_callback_mouse_out_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_callback_mouse_out_set"); + return; } IFC(ee, fn_callback_mouse_out_set) (ee, func); IFE; @@ -1204,9 +1205,9 @@ ecore_evas_callback_pre_render_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_callback_pre_render_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_callback_pre_render_set"); + return; } IFC(ee, fn_callback_pre_render_set) (ee, func); IFE; @@ -1226,9 +1227,9 @@ ecore_evas_callback_post_render_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_callback_post_render_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_callback_post_render_set"); + return; } IFC(ee, fn_callback_post_render_set) (ee, func); IFE; @@ -1248,9 +1249,9 @@ ecore_evas_callback_pre_free_set(Ecore_Evas *ee, void (*func) (Ecore_Evas *ee)) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_callback_pre_free_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_callback_pre_free_set"); + return; } ee->func.fn_pre_free = func; } @@ -1267,9 +1268,9 @@ ecore_evas_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_get"); - return NULL; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_get"); + return NULL; } return ee->evas; } @@ -1287,9 +1288,9 @@ ecore_evas_move(Ecore_Evas *ee, int x, int y) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_move"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_move"); + return; } if (ee->prop.fullscreen) return; IFC(ee, fn_move) (ee, x, y); @@ -1309,9 +1310,9 @@ ecore_evas_managed_move(Ecore_Evas *ee, int x, int y) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_move"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_move"); + return; } IFC(ee, fn_managed_move) (ee, x, y); IFE; @@ -1330,22 +1331,22 @@ ecore_evas_resize(Ecore_Evas *ee, int w, int h) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_resize"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_resize"); + return; } if (ee->prop.fullscreen) return; if (w < 1) w = 1; if (h < 1) h = 1; if ((ee->rotation == 90) || (ee->rotation == 270)) { - IFC(ee, fn_resize) (ee, h, w); - IFE; + IFC(ee, fn_resize) (ee, h, w); + IFE; } else { - IFC(ee, fn_resize) (ee, w, h); - IFE; + IFC(ee, fn_resize) (ee, w, h); + IFE; } } @@ -1366,22 +1367,22 @@ ecore_evas_move_resize(Ecore_Evas *ee, int x, int y, int w, int h) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_move_resize"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_move_resize"); + return; } if (ee->prop.fullscreen) return; if (w < 1) w = 1; if (h < 1) h = 1; if ((ee->rotation == 90) || (ee->rotation == 270)) { - IFC(ee, fn_move_resize) (ee, x, y, h, w); - IFE; + IFC(ee, fn_move_resize) (ee, x, y, h, w); + IFE; } else { - IFC(ee, fn_move_resize) (ee, x, y, w, h); - IFE; + IFC(ee, fn_move_resize) (ee, x, y, w, h); + IFE; } } @@ -1407,23 +1408,23 @@ ecore_evas_geometry_get(const Ecore_Evas *ee, int *x, int *y, int *w, int *h) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_geometry_get"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_geometry_get"); + return; } if ((ee->rotation == 90) || (ee->rotation == 270)) { - if (x) *x = ee->x; - if (y) *y = ee->y; - if (w) *w = ee->h; - if (h) *h = ee->w; + if (x) *x = ee->x; + if (y) *y = ee->y; + if (w) *w = ee->h; + if (h) *h = ee->w; } else { - if (x) *x = ee->x; - if (y) *y = ee->y; - if (w) *w = ee->w; - if (h) *h = ee->h; + if (x) *x = ee->x; + if (y) *y = ee->y; + if (w) *w = ee->w; + if (h) *h = ee->h; } } @@ -1441,9 +1442,9 @@ ecore_evas_rotation_set(Ecore_Evas *ee, int rot) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_rotation_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_rotation_set"); + return; } rot = rot % 360; while (rot < 0) rot += 360; @@ -1469,9 +1470,9 @@ ecore_evas_rotation_with_resize_set(Ecore_Evas *ee, int rot) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_rotation_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_rotation_set"); + return; } rot = rot % 360; while (rot < 0) rot += 360; @@ -1495,9 +1496,9 @@ ecore_evas_rotation_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_rotation_get"); - return 0; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_rotation_get"); + return 0; } return ee->rotation; } @@ -1505,23 +1506,23 @@ ecore_evas_rotation_get(const Ecore_Evas *ee) /** * Set whether an Ecore_Evas is shaped or not. * @param ee The Ecore_Evas to shape - * @param shaped 1 to shape, 0 to not + * @param shaped EINA_TRUE to shape, EINA_FALSE to not * * This function allows one to make an Ecore_Evas shaped to the contents of the - * evas. If @p shaped is 1, @p ee will be transparent in parts of the evas that - * contain no objects. If @p shaped is 0, then @p ee will be rectangular, and + * evas. If @p shaped is EINA_TRUE, @p ee will be transparent in parts of the evas that + * contain no objects. If @p shaped is EINA_FALSE, then @p ee will be rectangular, and * and parts with no data will show random framebuffer artifacting. For * non-shaped Ecore_Evases, it is recommend to cover the entire evas with a * background object. */ EAPI void -ecore_evas_shaped_set(Ecore_Evas *ee, int shaped) +ecore_evas_shaped_set(Ecore_Evas *ee, Eina_Bool shaped) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_shaped_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_shaped_set"); + return; } IFC(ee, fn_shaped_set) (ee, shaped); IFE; @@ -1530,26 +1531,26 @@ ecore_evas_shaped_set(Ecore_Evas *ee, int shaped) /** * Query whether an Ecore_Evas is shaped or not. * @param ee The Ecore_Evas to query. - * @return 1 if shaped, 0 if not. + * @return EINA_TRUE if shaped, EINA_FALSE if not. * - * This function returns 1 if @p ee is shaped, and 0 if not. + * This function returns EINA_TRUE if @p ee is shaped, and EINA_FALSE if not. */ -EAPI int +EAPI Eina_Bool ecore_evas_shaped_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_shaped_get"); - return 0; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_shaped_get"); + return EINA_FALSE; } - return ee->shaped ? 1:0; + return ee->shaped ? EINA_TRUE : EINA_FALSE; } /** * Set whether an Ecore_Evas has an alpha channel or not. * @param ee The Ecore_Evas to shape - * @param alpha 1 to enable the alpha channel, 0 to disable it + * @param alpha EINA_TRUE to enable the alpha channel, EINA_FALSE to disable it * * This function allows you to make an Ecore_Evas translucent using an * alpha channel. See ecore_evas_shaped_set() for details. The difference @@ -1559,13 +1560,13 @@ ecore_evas_shaped_get(const Ecore_Evas *ee) * it's transparent). */ EAPI void -ecore_evas_alpha_set(Ecore_Evas *ee, int alpha) +ecore_evas_alpha_set(Ecore_Evas *ee, Eina_Bool alpha) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_alpha_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_alpha_set"); + return; } IFC(ee, fn_alpha_set) (ee, alpha); IFE; @@ -1574,27 +1575,27 @@ ecore_evas_alpha_set(Ecore_Evas *ee, int alpha) /** * Query whether an Ecore_Evas has an alpha channel. * @param ee The Ecore_Evas to query. - * @return 1 if ee has an alpha channel, 0 if it does not. + * @return EINA_TRUE if ee has an alpha channel, EINA_FALSE if it does not. * - * This function returns 1 if @p ee has an alpha channel, and 0 if + * This function returns EINA_TRUE if @p ee has an alpha channel, and EINA_FALSE if * it does not. */ -EAPI int +EAPI Eina_Bool ecore_evas_alpha_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_alpha_get"); - return 0; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_alpha_get"); + return EINA_FALSE; } - return ee->alpha ? 1:0; + return ee->alpha ? EINA_TRUE : EINA_FALSE; } /** * Set whether an Ecore_Evas has an transparent window or not. * @param ee The Ecore_Evas to shape - * @param transparent 1 to enable the transparent window, 0 to disable it + * @param transparent EINA_TRUE to enable the transparent window, EINA_FALSE to disable it * * This function allows you to make an Ecore_Evas translucent using an * alpha channel. See ecore_evas_shaped_set() for details. The difference @@ -1604,13 +1605,13 @@ ecore_evas_alpha_get(const Ecore_Evas *ee) * it's transparent). */ EAPI void -ecore_evas_transparent_set(Ecore_Evas *ee, int transparent) +ecore_evas_transparent_set(Ecore_Evas *ee, Eina_Bool transparent) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_transparent_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_transparent_set"); + return; } IFC(ee, fn_transparent_set) (ee, transparent); IFE; @@ -1619,21 +1620,21 @@ ecore_evas_transparent_set(Ecore_Evas *ee, int transparent) /** * Query whether an Ecore_Evas has an alpha channel. * @param ee The Ecore_Evas to query. - * @return 1 if ee has an alpha channel, 0 if it does not. + * @return EINA_TRUE if ee has an alpha channel, EINA_FALSE if it does not. * - * This function returns 1 if @p ee has an alpha channel, and 0 if + * This function returns EINA_TRUE if @p ee has an alpha channel, and EINA_FALSE if * it does not. */ -EAPI int +EAPI Eina_Bool ecore_evas_transparent_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_transparent_get"); - return 0; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_transparent_get"); + return EINA_FALSE; } - return ee->transparent ? 1:0; + return ee->transparent ? EINA_TRUE : 0; } /** @@ -1647,9 +1648,9 @@ ecore_evas_show(Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_show"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_show"); + return; } IFC(ee, fn_show) (ee); IFE; @@ -1666,9 +1667,9 @@ ecore_evas_hide(Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_hide"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_hide"); + return; } IFC(ee, fn_hide) (ee); IFE; @@ -1686,9 +1687,9 @@ ecore_evas_visibility_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_visibility_get"); - return 0; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_visibility_get"); + return 0; } return ee->visible ? 1:0; } @@ -1704,9 +1705,9 @@ ecore_evas_raise(Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_raise"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_raise"); + return; } IFC(ee, fn_raise) (ee); IFE; @@ -1723,9 +1724,9 @@ ecore_evas_lower(Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_lower"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_lower"); + return; } IFC(ee, fn_lower) (ee); IFE; @@ -1742,9 +1743,9 @@ ecore_evas_activate(Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_activate"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_activate"); + return; } IFC(ee, fn_activate) (ee); IFE; @@ -1762,9 +1763,9 @@ ecore_evas_title_set(Ecore_Evas *ee, const char *t) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_title_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_title_set"); + return; } IFC(ee, fn_title_set) (ee, t); IFE; @@ -1782,9 +1783,9 @@ ecore_evas_title_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_title_get"); - return NULL; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_title_get"); + return NULL; } return ee->prop.title; } @@ -1802,9 +1803,9 @@ ecore_evas_name_class_set(Ecore_Evas *ee, const char *n, const char *c) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_name_class_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_name_class_set"); + return; } IFC(ee, fn_name_class_set) (ee, n, c); IFE; @@ -1824,9 +1825,9 @@ ecore_evas_name_class_get(const Ecore_Evas *ee, const char **n, const char **c) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_name_class_get"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_name_class_get"); + return; } if (n) *n = ee->prop.name; if (c) *c = ee->prop.clas; @@ -1845,21 +1846,21 @@ ecore_evas_size_min_set(Ecore_Evas *ee, int w, int h) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_size_min_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_size_min_set"); + return; } if (w < 0) w = 0; if (h < 0) h = 0; if ((ee->rotation == 90) || (ee->rotation == 270)) { - IFC(ee, fn_size_min_set) (ee, h, w); - IFE; + IFC(ee, fn_size_min_set) (ee, h, w); + IFE; } else { - IFC(ee, fn_size_min_set) (ee, w, h); - IFE; + IFC(ee, fn_size_min_set) (ee, w, h); + IFE; } } @@ -1876,19 +1877,19 @@ ecore_evas_size_min_get(const Ecore_Evas *ee, int *w, int *h) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_size_min_get"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_size_min_get"); + return; } if ((ee->rotation == 90) || (ee->rotation == 270)) { - if (w) *w = ee->prop.min.h; - if (h) *h = ee->prop.min.w; + if (w) *w = ee->prop.min.h; + if (h) *h = ee->prop.min.w; } else { - if (w) *w = ee->prop.min.w; - if (h) *h = ee->prop.min.h; + if (w) *w = ee->prop.min.w; + if (h) *h = ee->prop.min.h; } } @@ -1905,21 +1906,21 @@ ecore_evas_size_max_set(Ecore_Evas *ee, int w, int h) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_size_max_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_size_max_set"); + return; } if (w < 0) w = 0; if (h < 0) h = 0; if ((ee->rotation == 90) || (ee->rotation == 270)) { - IFC(ee, fn_size_max_set) (ee, h, w); - IFE; + IFC(ee, fn_size_max_set) (ee, h, w); + IFE; } else { - IFC(ee, fn_size_max_set) (ee, w, h); - IFE; + IFC(ee, fn_size_max_set) (ee, w, h); + IFE; } } @@ -1936,19 +1937,19 @@ ecore_evas_size_max_get(const Ecore_Evas *ee, int *w, int *h) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_size_max_get"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_size_max_get"); + return; } if ((ee->rotation == 90) || (ee->rotation == 270)) { - if (w) *w = ee->prop.max.h; - if (h) *h = ee->prop.max.w; + if (w) *w = ee->prop.max.h; + if (h) *h = ee->prop.max.w; } else { - if (w) *w = ee->prop.max.w; - if (h) *h = ee->prop.max.h; + if (w) *w = ee->prop.max.w; + if (h) *h = ee->prop.max.h; } } @@ -1965,21 +1966,21 @@ ecore_evas_size_base_set(Ecore_Evas *ee, int w, int h) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_size_base_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_size_base_set"); + return; } if (w < 0) w = 0; if (h < 0) h = 0; if ((ee->rotation == 90) || (ee->rotation == 270)) { - IFC(ee, fn_size_base_set) (ee, h, w); - IFE; + IFC(ee, fn_size_base_set) (ee, h, w); + IFE; } else { - IFC(ee, fn_size_base_set) (ee, w, h); - IFE; + IFC(ee, fn_size_base_set) (ee, w, h); + IFE; } } @@ -1996,19 +1997,19 @@ ecore_evas_size_base_get(const Ecore_Evas *ee, int *w, int *h) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_size_base_get"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_size_base_get"); + return; } if ((ee->rotation == 90) || (ee->rotation == 270)) { - if (w) *w = ee->prop.base.h; - if (h) *h = ee->prop.base.w; + if (w) *w = ee->prop.base.h; + if (h) *h = ee->prop.base.w; } else { - if (w) *w = ee->prop.base.w; - if (h) *h = ee->prop.base.h; + if (w) *w = ee->prop.base.w; + if (h) *h = ee->prop.base.h; } } @@ -2026,21 +2027,21 @@ ecore_evas_size_step_set(Ecore_Evas *ee, int w, int h) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_size_step_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_size_step_set"); + return; } if (w < 0) w = 0; if (h < 0) h = 0; if ((ee->rotation == 90) || (ee->rotation == 270)) { - IFC(ee, fn_size_step_set) (ee, h, w); - IFE; + IFC(ee, fn_size_step_set) (ee, h, w); + IFE; } else { - IFC(ee, fn_size_step_set) (ee, w, h); - IFE; + IFC(ee, fn_size_step_set) (ee, w, h); + IFE; } } @@ -2057,19 +2058,19 @@ ecore_evas_size_step_get(const Ecore_Evas *ee, int *w, int *h) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_size_step_get"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_size_step_get"); + return; } if ((ee->rotation == 90) || (ee->rotation == 270)) { - if (w) *w = ee->prop.step.h; - if (h) *h = ee->prop.step.w; + if (w) *w = ee->prop.step.h; + if (h) *h = ee->prop.step.w; } else { - if (w) *w = ee->prop.step.w; - if (h) *h = ee->prop.step.h; + if (w) *w = ee->prop.step.w; + if (h) *h = ee->prop.step.h; } } @@ -2093,9 +2094,9 @@ ecore_evas_cursor_set(Ecore_Evas *ee, const char *file, int layer, int hot_x, in if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_cursor_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_cursor_set"); + return; } if (file) @@ -2131,9 +2132,9 @@ ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int ho { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_cursor_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_cursor_set"); + return; } IFC(ee, fn_object_cursor_set) (ee, obj, layer, hot_x, hot_y); IFE; @@ -2154,9 +2155,9 @@ ecore_evas_cursor_get(const Ecore_Evas *ee, Evas_Object **obj, int *layer, int * { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_cursor_get"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_cursor_get"); + return; } if (obj) *obj = ee->prop.cursor.object; if (layer) *layer = ee->prop.cursor.layer; @@ -2176,9 +2177,9 @@ ecore_evas_layer_set(Ecore_Evas *ee, int layer) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_layer_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_layer_set"); + return; } IFC(ee, fn_layer_set) (ee, layer); IFE; @@ -2195,9 +2196,9 @@ ecore_evas_layer_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_layer_get"); - return 0; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_layer_get"); + return 0; } return ee->prop.layer; } @@ -2205,18 +2206,18 @@ ecore_evas_layer_get(const Ecore_Evas *ee) /** * Set the focus of an Ecore_Evas' window * @param ee The Ecore_Evas - * @param on 1 for focus, 0 to defocus. + * @param on EINA_TRUE for focus, EINA_FALSE to defocus. * - * This function focuses @p ee if @p on is 1, or defocuses @p ee if @p on is 0. + * This function focuses @p ee if @p on is EINA_TRUE, or defocuses @p ee if @p on is EINA_FALSE. */ EAPI void -ecore_evas_focus_set(Ecore_Evas *ee, int on) +ecore_evas_focus_set(Ecore_Evas *ee, Eina_Bool on) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_focus_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_focus_set"); + return; } IFC(ee, fn_focus_set) (ee, on); IFE; @@ -2225,37 +2226,37 @@ ecore_evas_focus_set(Ecore_Evas *ee, int on) /** * Query whether an Ecore_Evas' window is focused or not * @param ee The Ecore_Evas to set - * @return 1 if @p ee if focused, 0 if not. + * @return EINA_TRUE if @p ee if focused, EINA_FALSE if not. * */ -EAPI int +EAPI Eina_Bool ecore_evas_focus_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_focus_get"); - return 0; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_focus_get"); + return EINA_FALSE; } - return ee->prop.focused ? 1:0; + return ee->prop.focused ? EINA_TRUE : EINA_FALSE; } /** * Iconify or uniconify an Ecore_Evas' window * @param ee The Ecore_Evas - * @param on 1 to iconify, 0 to uniconify. + * @param on EINA_TRUE to iconify, EINA_FALSE to uniconify. * - * This function iconifies @p ee if @p on is 1, or uniconifies @p ee if @p on - * is 0. + * This function iconifies @p ee if @p on is EINA_TRUE, or uniconifies @p ee if @p on + * is EINA_FALSE. */ EAPI void -ecore_evas_iconified_set(Ecore_Evas *ee, int on) +ecore_evas_iconified_set(Ecore_Evas *ee, Eina_Bool on) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_iconified_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_iconified_set"); + return; } IFC(ee, fn_iconified_set) (ee, on); IFE; @@ -2264,37 +2265,37 @@ ecore_evas_iconified_set(Ecore_Evas *ee, int on) /** * Query whether an Ecore_Evas' window is iconified or not * @param ee The Ecore_Evas to set - * @return 1 if @p ee is iconified, 0 if not. + * @return EINA_TRUE if @p ee is iconified, EINA_FALSE if not. * */ -EAPI int +EAPI Eina_Bool ecore_evas_iconified_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_iconified_get"); - return 0; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_iconified_get"); + return EINA_FALSE; } - return ee->prop.iconified ? 1:0; + return ee->prop.iconified ? EINA_TRUE : EINA_FALSE; } /** * Set whether an Ecore_Evas' window is borderless or not * @param ee The Ecore_Evas - * @param on 1 for borderless, 0 for bordered. + * @param on EINA_TRUE for borderless, EINA_FALSE for bordered. * - * This function makes @p ee borderless if @p on is 1, or bordered if @p on - * is 0. + * This function makes @p ee borderless if @p on is EINA_TRUE, or bordered if @p on + * is EINA_FALSE. */ EAPI void -ecore_evas_borderless_set(Ecore_Evas *ee, int on) +ecore_evas_borderless_set(Ecore_Evas *ee, Eina_Bool on) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_borderless_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_borderless_set"); + return; } IFC(ee, fn_borderless_set) (ee, on); IFE; @@ -2303,37 +2304,37 @@ ecore_evas_borderless_set(Ecore_Evas *ee, int on) /** * Query whether an Ecore_Evas' window is borderless or not * @param ee The Ecore_Evas to set - * @return 1 if @p ee is borderless, 0 if not. + * @return EINA_TRUE if @p ee is borderless, EINA_FALSE if not. * */ -EAPI int +EAPI Eina_Bool ecore_evas_borderless_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_borderless_get"); - return 0; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_borderless_get"); + return EINA_FALSE; } - return ee->prop.borderless ? 1:0; + return ee->prop.borderless ? EINA_TRUE : EINA_FALSE; } /** * Tell the WM whether or not to ignore an Ecore_Evas' window * @param ee The Ecore_Evas - * @param on 1 to ignore, 0 to not. + * @param on EINA_TRUE to ignore, EINA_FALSE to not. * - * This function causes the window manager to ignore @p ee if @p on is 1, - * or not ignore @p ee if @p on is 0. + * This function causes the window manager to ignore @p ee if @p on is EINA_TRUE, + * or not ignore @p ee if @p on is EINA_FALSE. */ EAPI void -ecore_evas_override_set(Ecore_Evas *ee, int on) +ecore_evas_override_set(Ecore_Evas *ee, Eina_Bool on) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_override_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_override_set"); + return; } IFC(ee, fn_override_set) (ee, on); IFE; @@ -2342,37 +2343,37 @@ ecore_evas_override_set(Ecore_Evas *ee, int on) /** * Query whether an Ecore_Evas' window is overridden or not * @param ee The Ecore_Evas to set - * @return 1 if @p ee is overridden, 0 if not. + * @return EINA_TRUE if @p ee is overridden, EINA_FALSE if not. * */ -EAPI int +EAPI Eina_Bool ecore_evas_override_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_override_get"); - return 0; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_override_get"); + return EINA_FALSE; } - return ee->prop.override ? 1:0; + return ee->prop.override ? EINA_TRUE : EINA_FALSE; } /** * Maximize (or unmaximize) an Ecore_Evas' window * @param ee The Ecore_Evas - * @param on 1 to maximize, 0 to unmaximize. + * @param on EINA_TRUE to maximize, EINA_FALSE to unmaximize. * - * This function maximizes @p ee if @p on is 1, or unmaximizes @p ee - * if @p on is 0. + * This function maximizes @p ee if @p on is EINA_TRUE, or unmaximizes @p ee + * if @p on is EINA_FALSE. */ EAPI void -ecore_evas_maximized_set(Ecore_Evas *ee, int on) +ecore_evas_maximized_set(Ecore_Evas *ee, Eina_Bool on) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_maximized_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_maximized_set"); + return; } IFC(ee, fn_maximized_set) (ee, on); IFE; @@ -2381,37 +2382,37 @@ ecore_evas_maximized_set(Ecore_Evas *ee, int on) /** * Query whether an Ecore_Evas' window is maximized or not * @param ee The Ecore_Evas to set - * @return 1 if @p ee is maximized, 0 if not. + * @return EINA_TRUE if @p ee is maximized, EINA_FALSE if not. * */ -EAPI int +EAPI Eina_Bool ecore_evas_maximized_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_maximized_get"); - return 0; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_maximized_get"); + return EINA_FALSE; } - return ee->prop.maximized ? 1:0; + return ee->prop.maximized ? EINA_TRUE : EINA_FALSE; } /** * Set whether or not an Ecore_Evas' window is fullscreen * @param ee The Ecore_Evas - * @param on 1 fullscreen, 0 not. + * @param on EINA_TRUE fullscreen, EINA_FALSE not. * - * This function causes @p ee to be fullscreen if @p on is 1, - * or not if @p on is 0. + * This function causes @p ee to be fullscreen if @p on is EINA_TRUE, + * or not if @p on is EINA_FALSE. */ EAPI void -ecore_evas_fullscreen_set(Ecore_Evas *ee, int on) +ecore_evas_fullscreen_set(Ecore_Evas *ee, Eina_Bool on) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_fullscreen_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_fullscreen_set"); + return; } IFC(ee, fn_fullscreen_set) (ee, on); IFE; @@ -2420,26 +2421,26 @@ ecore_evas_fullscreen_set(Ecore_Evas *ee, int on) /** * Query whether an Ecore_Evas' window is fullscreen or not * @param ee The Ecore_Evas to set - * @return 1 if @p ee is fullscreen, 0 if not. + * @return EINA_TRUE if @p ee is fullscreen, EINA_FALSE if not. * */ -EAPI int +EAPI Eina_Bool ecore_evas_fullscreen_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_fullscreen_get"); - return 0; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_fullscreen_get"); + return EINA_FALSE; } - return ee->prop.fullscreen ? 1:0; + return ee->prop.fullscreen ? EINA_TRUE : EINA_FALSE; } /** * Set whether or not an Ecore_Evas' window should avoid damage * * @param ee The Ecore_Evas - * @param on 1 to avoid damage, 0 to not + * @param The type of the damage management * * This function causes @p ee to be drawn to a pixmap to avoid recalculations. * On expose events it will copy from the pixmap to the window. @@ -2449,9 +2450,9 @@ ecore_evas_avoid_damage_set(Ecore_Evas *ee, Ecore_Evas_Avoid_Damage_Type on) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_avoid_damage_set"); - return; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_avoid_damage_set"); + return; } IFC(ee, fn_avoid_damage_set) (ee, on); IFE; @@ -2460,7 +2461,7 @@ ecore_evas_avoid_damage_set(Ecore_Evas *ee, Ecore_Evas_Avoid_Damage_Type on) /** * Query whether an Ecore_Evas' window avoids damage or not * @param ee The Ecore_Evas to set - * @return 1 if @p ee avoids damage, 0 if not. + * @return The type of the damage management * */ EAPI Ecore_Evas_Avoid_Damage_Type @@ -2468,9 +2469,9 @@ ecore_evas_avoid_damage_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { - ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, - "ecore_evas_avoid_damage_get"); - return 0; + ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, + "ecore_evas_avoid_damage_get"); + return ECORE_EVAS_AVOID_DAMAGE_NONE; } return ee->prop.avoid_damage; } @@ -2482,7 +2483,7 @@ ecore_evas_avoid_damage_get(const Ecore_Evas *ee) * */ EAPI void -ecore_evas_withdrawn_set(Ecore_Evas *ee, int withdrawn) +ecore_evas_withdrawn_set(Ecore_Evas *ee, Eina_Bool withdrawn) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { @@ -2501,16 +2502,16 @@ ecore_evas_withdrawn_set(Ecore_Evas *ee, int withdrawn) * @return The Ecore_Evas window's withdrawn state. * */ -EAPI int +EAPI Eina_Bool ecore_evas_withdrawn_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, "ecore_evas_withdrawn_get"); - return 0; + return EINA_FALSE; } else - return ee->prop.withdrawn ? 1:0; + return ee->prop.withdrawn ? EINA_TRUE : EINA_FALSE; } /** @@ -2521,7 +2522,7 @@ ecore_evas_withdrawn_get(const Ecore_Evas *ee) * */ EAPI void -ecore_evas_sticky_set(Ecore_Evas *ee, int sticky) +ecore_evas_sticky_set(Ecore_Evas *ee, Eina_Bool sticky) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { @@ -2541,16 +2542,16 @@ ecore_evas_sticky_set(Ecore_Evas *ee, int sticky) * @return The Ecore_Evas window's sticky state. * */ -EAPI int +EAPI Eina_Bool ecore_evas_sticky_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, "ecore_evas_sticky_get"); - return 0; + return EINA_FALSE; } else - return ee->prop.sticky ? 1:0; + return ee->prop.sticky ? EINA_TRUE : EINA_FALSE; } /** @@ -2561,7 +2562,7 @@ ecore_evas_sticky_get(const Ecore_Evas *ee) * */ EAPI void -ecore_evas_ignore_events_set(Ecore_Evas *ee, int ignore) +ecore_evas_ignore_events_set(Ecore_Evas *ee, Eina_Bool ignore) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { @@ -2581,20 +2582,20 @@ ecore_evas_ignore_events_set(Ecore_Evas *ee, int ignore) * @return The Ecore_Evas window's ignore state. * */ -EAPI int +EAPI Eina_Bool ecore_evas_ignore_events_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, "ecore_evas_ignore_events_get"); - return 0; + return EINA_FALSE; } - return ee->ignore_events ? 1 : 0; + return ee->ignore_events ? EINA_TRUE : EINA_FALSE; } EAPI void -ecore_evas_manual_render_set(Ecore_Evas *ee, int manual_render) +ecore_evas_manual_render_set(Ecore_Evas *ee, Eina_Bool manual_render) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { @@ -2605,16 +2606,16 @@ ecore_evas_manual_render_set(Ecore_Evas *ee, int manual_render) ee->manual_render = manual_render; } -EAPI int +EAPI Eina_Bool ecore_evas_manual_render_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, "ecore_evas_manual_render_get"); - return 0; + return EINA_FALSE; } - return ee->manual_render ? 1 : 0; + return ee->manual_render ? EINA_TRUE : EINA_FALSE; } EAPI void @@ -2631,7 +2632,7 @@ ecore_evas_manual_render(Ecore_Evas *ee) } EAPI void -ecore_evas_comp_sync_set(Ecore_Evas *ee, int do_sync) +ecore_evas_comp_sync_set(Ecore_Evas *ee, Eina_Bool do_sync) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { @@ -2642,14 +2643,14 @@ ecore_evas_comp_sync_set(Ecore_Evas *ee, int do_sync) ee->no_comp_sync = !do_sync; } -EAPI int +EAPI Eina_Bool ecore_evas_comp_sync_get(const Ecore_Evas *ee) { if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, "ecore_evas_comp_sync_get"); - return 0; + return EINA_FALSE; } return !ee->no_comp_sync; } @@ -2685,40 +2686,40 @@ _ecore_evas_fps_debug_init(void) _ecore_evas_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644); if (_ecore_evas_fps_debug_fd < 0) { - unlink(buf); - _ecore_evas_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644); + unlink(buf); + _ecore_evas_fps_debug_fd = open(buf, O_CREAT | O_TRUNC | O_RDWR, 0644); } if (_ecore_evas_fps_debug_fd >= 0) { - unsigned int zero = 0; - char *buf = (char *)&zero; - ssize_t todo = sizeof(unsigned int); - - while (todo > 0) - { - ssize_t r = write(_ecore_evas_fps_debug_fd, buf, todo); - if (r > 0) - { - todo -= r; - buf += r; - } - else if ((r < 0) && (errno == EINTR)) - continue; - else - { - ERR("could not write to file '%s' fd %d: %s", - buf, _ecore_evas_fps_debug_fd, strerror(errno)); - close(_ecore_evas_fps_debug_fd); - _ecore_evas_fps_debug_fd = -1; - return; - } - } - _ecore_evas_fps_rendertime_mmap = mmap(NULL, sizeof(unsigned int), - PROT_READ | PROT_WRITE, - MAP_SHARED, - _ecore_evas_fps_debug_fd, 0); - if (_ecore_evas_fps_rendertime_mmap == MAP_FAILED) - _ecore_evas_fps_rendertime_mmap = NULL; + unsigned int zero = 0; + char *buf = (char *)&zero; + ssize_t todo = sizeof(unsigned int); + + while (todo > 0) + { + ssize_t r = write(_ecore_evas_fps_debug_fd, buf, todo); + if (r > 0) + { + todo -= r; + buf += r; + } + else if ((r < 0) && (errno == EINTR)) + continue; + else + { + ERR("could not write to file '%s' fd %d: %s", + buf, _ecore_evas_fps_debug_fd, strerror(errno)); + close(_ecore_evas_fps_debug_fd); + _ecore_evas_fps_debug_fd = -1; + return; + } + } + _ecore_evas_fps_rendertime_mmap = mmap(NULL, sizeof(unsigned int), + PROT_READ | PROT_WRITE, + MAP_SHARED, + _ecore_evas_fps_debug_fd, 0); + if (_ecore_evas_fps_rendertime_mmap == MAP_FAILED) + _ecore_evas_fps_rendertime_mmap = NULL; } } @@ -2729,17 +2730,17 @@ _ecore_evas_fps_debug_shutdown(void) if (_ecore_evas_fps_debug_init_count > 0) return; if (_ecore_evas_fps_debug_fd >= 0) { - char buf[4096]; + char buf[4096]; - snprintf(buf, sizeof(buf), "/tmp/.ecore_evas_fps_debug-%i", (int)getpid()); - unlink(buf); - if (_ecore_evas_fps_rendertime_mmap) - { - munmap(_ecore_evas_fps_rendertime_mmap, sizeof(int)); - _ecore_evas_fps_rendertime_mmap = NULL; - } - close(_ecore_evas_fps_debug_fd); - _ecore_evas_fps_debug_fd = -1; + snprintf(buf, sizeof(buf), "/tmp/.ecore_evas_fps_debug-%i", (int)getpid()); + unlink(buf); + if (_ecore_evas_fps_rendertime_mmap) + { + munmap(_ecore_evas_fps_rendertime_mmap, sizeof(int)); + _ecore_evas_fps_rendertime_mmap = NULL; + } + close(_ecore_evas_fps_debug_fd); + _ecore_evas_fps_debug_fd = -1; } } @@ -2760,15 +2761,13 @@ _ecore_evas_fps_debug_rendertime_add(double t) rlapse = tim; flapse = frames; } - else if ((tim - rlapse) >= 0.1) + else if ((tim - rlapse) >= 0.5) { - printf("%.6f \t", tim); printf("FRAME: %i, FPS: %3.1f, RTIME %3.0f%%\n", frames, (frames - flapse) / (tim - rlapse), (100.0 * rtime) / (tim - rlapse) ); - fflush(stdout); rlapse = tim; flapse = frames; rtime = 0.0; @@ -2789,7 +2788,7 @@ _ecore_evas_free(Ecore_Evas *ee) if (ee->func.fn_pre_free) ee->func.fn_pre_free(ee); while (ee->sub_ecore_evas) { - _ecore_evas_free(ee->sub_ecore_evas->data); + _ecore_evas_free(ee->sub_ecore_evas->data); } if (ee->data) eina_hash_free(ee->data); ee->data = NULL; @@ -2843,8 +2842,8 @@ _ecore_evas_idle_timeout_update(Ecore_Evas *ee) if (ee->engine.idle_flush_timer) ecore_timer_del(ee->engine.idle_flush_timer); ee->engine.idle_flush_timer = ecore_timer_add(IDLE_FLUSH_TIME, - _ecore_evas_cb_idle_flush, - ee); + _ecore_evas_cb_idle_flush, + ee); } void @@ -2854,23 +2853,23 @@ _ecore_evas_mouse_move_process(Ecore_Evas *ee, int x, int y, unsigned int timest ee->mouse.y = y; if (ee->prop.cursor.object) { - evas_object_show(ee->prop.cursor.object); - if (ee->rotation == 0) - evas_object_move(ee->prop.cursor.object, - x - ee->prop.cursor.hot.x, - y - ee->prop.cursor.hot.y); - else if (ee->rotation == 90) - evas_object_move(ee->prop.cursor.object, - ee->h - y - 1 - ee->prop.cursor.hot.x, - x - ee->prop.cursor.hot.y); - else if (ee->rotation == 180) - evas_object_move(ee->prop.cursor.object, - ee->w - x - 1 - ee->prop.cursor.hot.x, - ee->h - y - 1 - ee->prop.cursor.hot.y); - else if (ee->rotation == 270) - evas_object_move(ee->prop.cursor.object, - y - ee->prop.cursor.hot.x, - ee->w - x - 1 - ee->prop.cursor.hot.y); + evas_object_show(ee->prop.cursor.object); + if (ee->rotation == 0) + evas_object_move(ee->prop.cursor.object, + x - ee->prop.cursor.hot.x, + y - ee->prop.cursor.hot.y); + else if (ee->rotation == 90) + evas_object_move(ee->prop.cursor.object, + ee->h - y - 1 - ee->prop.cursor.hot.x, + x - ee->prop.cursor.hot.y); + else if (ee->rotation == 180) + evas_object_move(ee->prop.cursor.object, + ee->w - x - 1 - ee->prop.cursor.hot.x, + ee->h - y - 1 - ee->prop.cursor.hot.y); + else if (ee->rotation == 270) + evas_object_move(ee->prop.cursor.object, + y - ee->prop.cursor.hot.x, + ee->w - x - 1 - ee->prop.cursor.hot.y); } if (ee->rotation == 0) evas_event_feed_mouse_move(ee->evas, x, y, timestamp, NULL); @@ -2898,7 +2897,7 @@ ecore_evas_ecore_evas_list_get(void){ EINA_INLIST_FOREACH(ecore_evases, ee) { - l = eina_list_append(l, ee); + l = eina_list_append(l, ee); } return l; diff --git a/src/lib/ecore_evas/ecore_evas_buffer.c b/src/lib/ecore_evas/ecore_evas_buffer.c index 6902b47..7e22260 100644 --- a/src/lib/ecore_evas/ecore_evas_buffer.c +++ b/src/lib/ecore_evas/ecore_evas_buffer.c @@ -24,15 +24,15 @@ _ecore_evas_buffer_free(Ecore_Evas *ee) { if (ee->engine.buffer.image) { - Ecore_Evas *ee2; + Ecore_Evas *ee2; - ee2 = evas_object_data_get(ee->engine.buffer.image, "Ecore_Evas_Parent"); - evas_object_del(ee->engine.buffer.image); - ee2->sub_ecore_evas = eina_list_remove(ee2->sub_ecore_evas, ee); + ee2 = evas_object_data_get(ee->engine.buffer.image, "Ecore_Evas_Parent"); + evas_object_del(ee->engine.buffer.image); + ee2->sub_ecore_evas = eina_list_remove(ee2->sub_ecore_evas, ee); } else { - ee->engine.buffer.free_func(ee->engine.buffer.data, + ee->engine.buffer.free_func(ee->engine.buffer.data, ee->engine.buffer.pixels); } _ecore_evas_buffer_shutdown(); @@ -42,6 +42,7 @@ static void _ecore_evas_resize(Ecore_Evas *ee, int w, int h) { Evas_Engine_Info_Buffer *einfo; + int stride = 0; if (w < 1) w = 1; if (h < 1) h = 1; @@ -54,29 +55,34 @@ _ecore_evas_resize(Ecore_Evas *ee, int w, int h) if (ee->engine.buffer.image) { - ee->engine.buffer.pixels = evas_object_image_data_get(ee->engine.buffer.image, 1); + ee->engine.buffer.pixels = evas_object_image_data_get(ee->engine.buffer.image, 1); + stride = evas_object_image_stride_get(ee->engine.buffer.image); } else { - if (ee->engine.buffer.pixels) + if (ee->engine.buffer.pixels) ee->engine.buffer.free_func(ee->engine.buffer.data, ee->engine.buffer.pixels); - ee->engine.buffer.pixels = + ee->engine.buffer.pixels = ee->engine.buffer.alloc_func(ee->engine.buffer.data, ee->w * ee->h * sizeof(int)); + stride = ee->w * sizeof(int); } einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas); if (einfo) { - einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32; - einfo->info.dest_buffer = ee->engine.buffer.pixels; - einfo->info.dest_buffer_row_bytes = ee->w * sizeof(int); - einfo->info.use_color_key = 0; - einfo->info.alpha_threshold = 0; - einfo->info.func.new_update_region = NULL; - einfo->info.func.free_update_region = NULL; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32; + einfo->info.dest_buffer = ee->engine.buffer.pixels; + einfo->info.dest_buffer_row_bytes = stride; + einfo->info.use_color_key = 0; + einfo->info.alpha_threshold = 0; + einfo->info.func.new_update_region = NULL; + einfo->info.func.free_update_region = NULL; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } } if (ee->func.fn_resize) ee->func.fn_resize(ee); } @@ -101,31 +107,31 @@ _ecore_evas_buffer_render(Ecore_Evas *ee) EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2) { - if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2); - rend |= _ecore_evas_buffer_render(ee2); - if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2); + if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2); + rend |= _ecore_evas_buffer_render(ee2); + if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2); } if (ee->engine.buffer.image) { - int w, h; + int w, h; - evas_object_image_size_get(ee->engine.buffer.image, &w, &h); - if ((w != ee->w) || (h != ee->h)) - _ecore_evas_resize(ee, w, h); + evas_object_image_size_get(ee->engine.buffer.image, &w, &h); + if ((w != ee->w) || (h != ee->h)) + _ecore_evas_resize(ee, w, h); } updates = evas_render_updates(ee->evas); if (ee->engine.buffer.image) { Eina_Rectangle *r; - EINA_LIST_FOREACH(updates, l, r) - evas_object_image_data_update_add(ee->engine.buffer.image, - r->x, r->y, r->w, r->h); + EINA_LIST_FOREACH(updates, l, r) + evas_object_image_data_update_add(ee->engine.buffer.image, + r->x, r->y, r->w, r->h); } if (updates) { - evas_render_updates_free(updates); - _ecore_evas_idle_timeout_update(ee); + evas_render_updates_free(updates); + _ecore_evas_idle_timeout_update(ee); } return updates ? 1 : rend; @@ -561,14 +567,17 @@ ecore_evas_buffer_allocfunc_new(int w, int h, void *(*alloc_func) (void *data, i einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas); if (einfo) { - einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32; - einfo->info.dest_buffer = ee->engine.buffer.pixels; - einfo->info.dest_buffer_row_bytes = ee->w * sizeof(int); - einfo->info.use_color_key = 0; - einfo->info.alpha_threshold = 0; - einfo->info.func.new_update_region = NULL; - einfo->info.func.free_update_region = NULL; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32; + einfo->info.dest_buffer = ee->engine.buffer.pixels; + einfo->info.dest_buffer_row_bytes = ee->w * sizeof(int); + einfo->info.use_color_key = 0; + einfo->info.alpha_threshold = 0; + einfo->info.func.new_update_region = NULL; + einfo->info.func.free_update_region = NULL; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } } evas_key_modifier_add(ee->evas, "Shift"); evas_key_modifier_add(ee->evas, "Control"); @@ -660,64 +669,67 @@ ecore_evas_object_image_new(Ecore_Evas *ee_target) ee->engine.buffer.pixels = evas_object_image_data_get(o, 1); evas_object_image_data_set(o, ee->engine.buffer.pixels); evas_object_event_callback_add(ee->engine.buffer.image, - EVAS_CALLBACK_MOUSE_IN, - _ecore_evas_buffer_cb_mouse_in, ee); + EVAS_CALLBACK_MOUSE_IN, + _ecore_evas_buffer_cb_mouse_in, ee); evas_object_event_callback_add(ee->engine.buffer.image, - EVAS_CALLBACK_MOUSE_OUT, - _ecore_evas_buffer_cb_mouse_out, ee); + EVAS_CALLBACK_MOUSE_OUT, + _ecore_evas_buffer_cb_mouse_out, ee); evas_object_event_callback_add(ee->engine.buffer.image, - EVAS_CALLBACK_MOUSE_DOWN, - _ecore_evas_buffer_cb_mouse_down, ee); + EVAS_CALLBACK_MOUSE_DOWN, + _ecore_evas_buffer_cb_mouse_down, ee); evas_object_event_callback_add(ee->engine.buffer.image, - EVAS_CALLBACK_MOUSE_UP, - _ecore_evas_buffer_cb_mouse_up, ee); + EVAS_CALLBACK_MOUSE_UP, + _ecore_evas_buffer_cb_mouse_up, ee); evas_object_event_callback_add(ee->engine.buffer.image, - EVAS_CALLBACK_MOUSE_MOVE, - _ecore_evas_buffer_cb_mouse_move, ee); + EVAS_CALLBACK_MOUSE_MOVE, + _ecore_evas_buffer_cb_mouse_move, ee); evas_object_event_callback_add(ee->engine.buffer.image, - EVAS_CALLBACK_MOUSE_WHEEL, - _ecore_evas_buffer_cb_mouse_wheel, ee); + EVAS_CALLBACK_MOUSE_WHEEL, + _ecore_evas_buffer_cb_mouse_wheel, ee); evas_object_event_callback_add(ee->engine.buffer.image, - EVAS_CALLBACK_MULTI_DOWN, - _ecore_evas_buffer_cb_multi_down, ee); + EVAS_CALLBACK_MULTI_DOWN, + _ecore_evas_buffer_cb_multi_down, ee); evas_object_event_callback_add(ee->engine.buffer.image, - EVAS_CALLBACK_MULTI_UP, - _ecore_evas_buffer_cb_multi_up, ee); + EVAS_CALLBACK_MULTI_UP, + _ecore_evas_buffer_cb_multi_up, ee); evas_object_event_callback_add(ee->engine.buffer.image, - EVAS_CALLBACK_MULTI_MOVE, - _ecore_evas_buffer_cb_multi_move, ee); + EVAS_CALLBACK_MULTI_MOVE, + _ecore_evas_buffer_cb_multi_move, ee); evas_object_event_callback_add(ee->engine.buffer.image, - EVAS_CALLBACK_FREE, - _ecore_evas_buffer_cb_free, ee); + EVAS_CALLBACK_FREE, + _ecore_evas_buffer_cb_free, ee); evas_object_event_callback_add(ee->engine.buffer.image, - EVAS_CALLBACK_KEY_DOWN, - _ecore_evas_buffer_cb_key_down, ee); + EVAS_CALLBACK_KEY_DOWN, + _ecore_evas_buffer_cb_key_down, ee); evas_object_event_callback_add(ee->engine.buffer.image, - EVAS_CALLBACK_KEY_UP, - _ecore_evas_buffer_cb_key_up, ee); + EVAS_CALLBACK_KEY_UP, + _ecore_evas_buffer_cb_key_up, ee); evas_object_event_callback_add(ee->engine.buffer.image, - EVAS_CALLBACK_FOCUS_IN, - _ecore_evas_buffer_cb_focus_in, ee); + EVAS_CALLBACK_FOCUS_IN, + _ecore_evas_buffer_cb_focus_in, ee); evas_object_event_callback_add(ee->engine.buffer.image, - EVAS_CALLBACK_FOCUS_OUT, - _ecore_evas_buffer_cb_focus_out, ee); + EVAS_CALLBACK_FOCUS_OUT, + _ecore_evas_buffer_cb_focus_out, ee); evas_object_event_callback_add(ee->engine.buffer.image, - EVAS_CALLBACK_SHOW, - _ecore_evas_buffer_cb_show, ee); + EVAS_CALLBACK_SHOW, + _ecore_evas_buffer_cb_show, ee); evas_object_event_callback_add(ee->engine.buffer.image, - EVAS_CALLBACK_HIDE, - _ecore_evas_buffer_cb_hide, ee); + EVAS_CALLBACK_HIDE, + _ecore_evas_buffer_cb_hide, ee); einfo = (Evas_Engine_Info_Buffer *)evas_engine_info_get(ee->evas); if (einfo) { - einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32; - einfo->info.dest_buffer = ee->engine.buffer.pixels; - einfo->info.dest_buffer_row_bytes = ee->w * sizeof(int); - einfo->info.use_color_key = 0; - einfo->info.alpha_threshold = 0; - einfo->info.func.new_update_region = NULL; - einfo->info.func.free_update_region = NULL; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_ARGB32; + einfo->info.dest_buffer = ee->engine.buffer.pixels; + einfo->info.dest_buffer_row_bytes = evas_object_image_stride_get(o); + einfo->info.use_color_key = 0; + einfo->info.alpha_threshold = 0; + einfo->info.func.new_update_region = NULL; + einfo->info.func.free_update_region = NULL; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } } evas_key_modifier_add(ee->evas, "Shift"); evas_key_modifier_add(ee->evas, "Control"); diff --git a/src/lib/ecore_evas/ecore_evas_cocoa.c b/src/lib/ecore_evas/ecore_evas_cocoa.c index bdc7cd4..21fdd0b 100644 --- a/src/lib/ecore_evas/ecore_evas_cocoa.c +++ b/src/lib/ecore_evas/ecore_evas_cocoa.c @@ -18,7 +18,7 @@ #include "Ecore_Cocoa.h" #include "Evas_Engine_Quartz.h" -// FIXME: this engine has lots of problems. only 1 window at a time, drawRect looks wrong, doesnt handle resizes and more +// FIXME: this engine has lots of problems. only 1 window at a time, drawRect looks wrong, doesn't handle resizes and more static int _ecore_evas_init_count = 0; static Ecore_Evas *ecore_evases = NULL; @@ -32,7 +32,7 @@ static const char *ecore_evas_cocoa_default = "EFL Cocoa"; @interface EvasView : NSView { - CGContextRef ctx; + CGContextRef ctx; } @end @@ -411,7 +411,7 @@ ecore_evas_cocoa_new(const char* name, int w, int h) // Create our main window, and embed an EvasView in it main_window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,w,h) styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask) backing:NSBackingStoreBuffered defer:NO screen:nil]; - /* FIXME: manage the case where main_window is NULL witht a goto free_evas; */ + /* FIXME: manage the case where main_window is NULL with a goto free_evas; */ [main_window makeKeyAndOrderFront:NSApp]; [main_window setTitle:[NSString stringWithUTF8String:name]]; [main_window makeMainWindow]; @@ -432,7 +432,10 @@ ecore_evas_cocoa_new(const char* name, int w, int h) goto free_window; einfo->info.context = [[evas_view context] retain]; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } ecore_evases = (Ecore_Evas *) eina_inlist_prepend(EINA_INLIST_GET(ecore_evases), EINA_INLIST_GET(ee)); diff --git a/src/lib/ecore_evas/ecore_evas_directfb.c b/src/lib/ecore_evas/ecore_evas_directfb.c index b3cf77c..7bea20e 100644 --- a/src/lib/ecore_evas/ecore_evas_directfb.c +++ b/src/lib/ecore_evas/ecore_evas_directfb.c @@ -29,17 +29,17 @@ _ecore_evas_directfb_render(Ecore_Evas *ee) #ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2) { - if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2); - rend |= _ecore_evas_buffer_render(ee2); - if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2); + if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2); + rend |= _ecore_evas_buffer_render(ee2); + if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2); } #endif if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee); updates = evas_render_updates(ee->evas); if (updates) { - evas_render_updates_free(updates); - _ecore_evas_idle_timeout_update(ee); + evas_render_updates_free(updates); + _ecore_evas_idle_timeout_update(ee); } if (ee->func.fn_post_render) ee->func.fn_post_render(ee); @@ -229,10 +229,10 @@ _ecore_evas_directfb_shutdown(void) _ecore_evas_init_count--; if (_ecore_evas_init_count == 0) { - int i; + int i; - for (i = 0; i < 8; i++) - ecore_event_handler_del(ecore_evas_event_handlers[i]); + for (i = 0; i < 8; i++) + ecore_event_handler_del(ecore_evas_event_handlers[i]); } if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0; return _ecore_evas_init_count; @@ -292,13 +292,13 @@ _ecore_evas_directfb_resize(Ecore_Evas *ee, int w, int h) ee->h = h; if ((ee->rotation == 90) || (ee->rotation == 270)) { - evas_output_size_set(ee->evas, ee->h, ee->w); - evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); + evas_output_size_set(ee->evas, ee->h, ee->w); + evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); } else { - evas_output_size_set(ee->evas, ee->w, ee->h); - evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); + evas_output_size_set(ee->evas, ee->w, ee->h); + evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); } } @@ -354,12 +354,12 @@ _ecore_evas_directfb_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int lay if (!obj) { - ee->prop.cursor.object = NULL; - ee->prop.cursor.layer = 0; - ee->prop.cursor.hot.x = 0; - ee->prop.cursor.hot.y = 0; - ecore_directfb_window_cursor_show(ee->engine.directfb.window, 1); - return; + ee->prop.cursor.object = NULL; + ee->prop.cursor.layer = 0; + ee->prop.cursor.hot.x = 0; + ee->prop.cursor.hot.y = 0; + ecore_directfb_window_cursor_show(ee->engine.directfb.window, 1); + return; } @@ -399,30 +399,33 @@ _ecore_evas_directfb_fullscreen_set(Ecore_Evas *ee, int on) ecore_directfb_window_size_get(ee->engine.directfb.window, &w, &h); if( (ee->w != w) || (ee->h != h)) { - resized = 1; - ee->w = w; - ee->h = h; - if ((ee->rotation == 90) || (ee->rotation == 270)) - { - evas_output_size_set(ee->evas, ee->h, ee->w); - evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); - } - else - { - evas_output_size_set(ee->evas, ee->w, ee->h); - evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); - } + resized = 1; + ee->w = w; + ee->h = h; + if ((ee->rotation == 90) || (ee->rotation == 270)) + { + evas_output_size_set(ee->evas, ee->h, ee->w); + evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); + } + else + { + evas_output_size_set(ee->evas, ee->w, ee->h); + evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); + } } einfo = (Evas_Engine_Info_DirectFB *)evas_engine_info_get(ee->evas); if (einfo) { - einfo->info.surface = ee->engine.directfb.window->surface; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + einfo->info.surface = ee->engine.directfb.window->surface; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } } ee->prop.fullscreen = on; if (resized) { - if(ee->func.fn_resize) ee->func.fn_resize(ee); + if(ee->func.fn_resize) ee->func.fn_resize(ee); } } @@ -436,49 +439,49 @@ _ecore_evas_directfb_window_get(const Ecore_Evas *ee) #ifdef BUILD_ECORE_EVAS_DIRECTFB static Ecore_Evas_Engine_Func _ecore_directfb_engine_func = { - _ecore_evas_directfb_free, /* free an ecore_evas */ - NULL, /* cb resize */ - NULL, /* cb move */ - NULL, /* cb show */ - NULL, /* cb hide */ - NULL, /* cb delete request */ - NULL, /* cb destroy */ - NULL, /* cb focus in */ - NULL, /* cb focus out */ + _ecore_evas_directfb_free, /* free an ecore_evas */ + NULL, /* cb resize */ + NULL, /* cb move */ + NULL, /* cb show */ + NULL, /* cb hide */ + NULL, /* cb delete request */ + NULL, /* cb destroy */ + NULL, /* cb focus in */ + NULL, /* cb focus out */ NULL, /* cb sticky */ NULL, /* cb unsticky */ - NULL, /* cb mouse in */ - NULL, /* cb mouse out */ - NULL, /* cb pre render */ - NULL, /* cb post render */ - _ecore_evas_directfb_move, /* move */ + NULL, /* cb mouse in */ + NULL, /* cb mouse out */ + NULL, /* cb pre render */ + NULL, /* cb post render */ + _ecore_evas_directfb_move, /* move */ NULL, /* managed move */ - _ecore_evas_directfb_resize, /* resize */ - NULL, /* move resize */ + _ecore_evas_directfb_resize, /* resize */ + NULL, /* move resize */ NULL,//_ecore_evas_directfb_rotation_set,/* rotation */ _ecore_evas_directfb_shaped_set, /* shaped */ - _ecore_evas_directfb_show, /* show */ - _ecore_evas_directfb_hide, /* hide */ - NULL, /* raise */ - NULL, /* lower */ - NULL, /* activate */ - NULL, /* title set */ - NULL, /* name class set */ - NULL, /* size min */ - NULL, /* size max */ - NULL, /* size base */ - NULL, /* size step */ + _ecore_evas_directfb_show, /* show */ + _ecore_evas_directfb_hide, /* hide */ + NULL, /* raise */ + NULL, /* lower */ + NULL, /* activate */ + NULL, /* title set */ + NULL, /* name class set */ + NULL, /* size min */ + NULL, /* size max */ + NULL, /* size base */ + NULL, /* size step */ _ecore_evas_directfb_object_cursor_set, /* set cursor to an evas object */ - NULL, /* layer set */ - _ecore_evas_directfb_focus_set, /* focus */ - NULL, /* iconified */ - NULL, /* borderless */ - NULL, /* override */ - NULL, /* maximized */ + NULL, /* layer set */ + _ecore_evas_directfb_focus_set, /* focus */ + NULL, /* iconified */ + NULL, /* borderless */ + NULL, /* override */ + NULL, /* maximized */ _ecore_evas_directfb_fullscreen_set,/* fullscreen */ - NULL, /* avoid damage */ - NULL, /* withdrawn */ - NULL, /* sticky */ + NULL, /* avoid damage */ + NULL, /* withdrawn */ + NULL, /* sticky */ NULL, /* ignore events */ NULL, /* alpha */ NULL, //transparent @@ -536,9 +539,12 @@ ecore_evas_directfb_new(const char *disp_name, int windowed, int x, int y, int w ee->engine.directfb.window = window; if (einfo) { - einfo->info.dfb = ecore_directfb_interface_get(); - einfo->info.surface = window->surface; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + einfo->info.dfb = ecore_directfb_interface_get(); + einfo->info.surface = window->surface; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } } ee->engine.func->fn_render = _ecore_evas_directfb_render; diff --git a/src/lib/ecore_evas/ecore_evas_fb.c b/src/lib/ecore_evas/ecore_evas_fb.c index 46b4142..5c4389f 100644 --- a/src/lib/ecore_evas/ecore_evas_fb.c +++ b/src/lib/ecore_evas/ecore_evas_fb.c @@ -32,23 +32,23 @@ _ecore_evas_mouse_move_process_fb(Ecore_Evas *ee, int x, int y, unsigned int tim ecore_fb_size_get(&fbw, &fbh); if (ee->prop.cursor.object) { - evas_object_show(ee->prop.cursor.object); + evas_object_show(ee->prop.cursor.object); if (ee->rotation == 0) - evas_object_move(ee->prop.cursor.object, - x - ee->prop.cursor.hot.x, - y - ee->prop.cursor.hot.y); - else if (ee->rotation == 90) - evas_object_move(ee->prop.cursor.object, - (fbh - ee->h) + ee->h - y - 1 - ee->prop.cursor.hot.x, - x - ee->prop.cursor.hot.y); - else if (ee->rotation == 180) - evas_object_move(ee->prop.cursor.object, - (fbw - ee->w) + ee->w - x - 1 - ee->prop.cursor.hot.x, - (fbh - ee->h) + ee->h - y - 1 - ee->prop.cursor.hot.y); - else if (ee->rotation == 270) - evas_object_move(ee->prop.cursor.object, - y - ee->prop.cursor.hot.x, - (fbw - ee->w) + ee->w - x - 1 - ee->prop.cursor.hot.y); + evas_object_move(ee->prop.cursor.object, + x - ee->prop.cursor.hot.x, + y - ee->prop.cursor.hot.y); + else if (ee->rotation == 90) + evas_object_move(ee->prop.cursor.object, + (fbh - ee->h) + ee->h - y - 1 - ee->prop.cursor.hot.x, + x - ee->prop.cursor.hot.y); + else if (ee->rotation == 180) + evas_object_move(ee->prop.cursor.object, + (fbw - ee->w) + ee->w - x - 1 - ee->prop.cursor.hot.x, + (fbh - ee->h) + ee->h - y - 1 - ee->prop.cursor.hot.y); + else if (ee->rotation == 270) + evas_object_move(ee->prop.cursor.object, + y - ee->prop.cursor.hot.x, + (fbw - ee->w) + ee->w - x - 1 - ee->prop.cursor.hot.y); } if (ee->rotation == 0) evas_event_feed_mouse_move(ee->evas, x, y, timestamp, NULL); @@ -71,7 +71,6 @@ _ecore_evas_fb_match(void) static void _ecore_evas_fb_lose(void *data __UNUSED__) { - Ecore_Evas *ee; Eina_List *ll; Ecore_Fb_Input_Device *dev; @@ -92,11 +91,11 @@ _ecore_evas_fb_gain(void *data __UNUSED__) { ee = fb_ee; - ee->visible = 1; - if ((ee->rotation == 90) || (ee->rotation == 270)) - evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); - else - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + ee->visible = 1; + if ((ee->rotation == 90) || (ee->rotation == 270)) + evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); + else + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); } EINA_LIST_FOREACH(ecore_evas_input_devices, ll, dev) @@ -186,6 +185,7 @@ _ecore_evas_event_mouse_wheel(void *data __UNUSED__, int type __UNUSED__, void * return EINA_FALSE; /* dont pass it on */ } +/* XXX: unused static int _ecore_evas_fb_render(Ecore_Evas *ee) { @@ -221,6 +221,7 @@ _ecore_evas_fb_render(Ecore_Evas *ee) evas_norender(ee->evas); return rend; } +*/ static int _ecore_evas_fb_init(int w, int h) @@ -242,60 +243,60 @@ _ecore_evas_fb_init(int w, int h) while ((input_entry = readdir(input_dir))) { - char device_path[256]; + char device_path[256]; - if (strncmp(input_entry->d_name, "event", 5) != 0) - continue; + if (strncmp(input_entry->d_name, "event", 5) != 0) + continue; - snprintf(device_path, 256, "/dev/input/%s", input_entry->d_name); - if (!(device = ecore_fb_input_device_open(device_path))) - continue; + snprintf(device_path, 256, "/dev/input/%s", input_entry->d_name); + if (!(device = ecore_fb_input_device_open(device_path))) + continue; - caps = ecore_fb_input_device_cap_get(device); + caps = ecore_fb_input_device_cap_get(device); - /* Mouse */ + /* Mouse */ #ifdef HAVE_TSLIB - if (caps & ECORE_FB_INPUT_DEVICE_CAP_RELATIVE) + if (caps & ECORE_FB_INPUT_DEVICE_CAP_RELATIVE) #else - if ((caps & ECORE_FB_INPUT_DEVICE_CAP_RELATIVE) || (caps & ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE)) + if ((caps & ECORE_FB_INPUT_DEVICE_CAP_RELATIVE) || (caps & ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE)) #endif - { - ecore_fb_input_device_axis_size_set(device, w, h); - ecore_fb_input_device_listen(device,1); - ecore_evas_input_devices = eina_list_append(ecore_evas_input_devices, device); - if (!mouse_handled) - { - ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, _ecore_evas_event_mouse_button_down, NULL); - ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, _ecore_evas_event_mouse_button_up, NULL); - ecore_evas_event_handlers[4] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_MOVE, _ecore_evas_event_mouse_move, NULL); - ecore_evas_event_handlers[5] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_WHEEL, _ecore_evas_event_mouse_wheel, NULL); - mouse_handled = 1; - } - } - /* Keyboard */ - else if ((caps & ECORE_FB_INPUT_DEVICE_CAP_KEYS_OR_BUTTONS) && !(caps & ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE)) - { - ecore_fb_input_device_listen(device,1); - ecore_evas_input_devices = eina_list_append(ecore_evas_input_devices, device); - if (!keyboard_handled) - { - ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_FB_EVENT_KEY_DOWN, _ecore_evas_event_key_down, NULL); - ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_FB_EVENT_KEY_UP, _ecore_evas_event_key_up, NULL); - keyboard_handled = 1; - } - } + { + ecore_fb_input_device_axis_size_set(device, w, h); + ecore_fb_input_device_listen(device,1); + ecore_evas_input_devices = eina_list_append(ecore_evas_input_devices, device); + if (!mouse_handled) + { + ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, _ecore_evas_event_mouse_button_down, NULL); + ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, _ecore_evas_event_mouse_button_up, NULL); + ecore_evas_event_handlers[4] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_MOVE, _ecore_evas_event_mouse_move, NULL); + ecore_evas_event_handlers[5] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_WHEEL, _ecore_evas_event_mouse_wheel, NULL); + mouse_handled = 1; + } + } + /* Keyboard */ + else if ((caps & ECORE_FB_INPUT_DEVICE_CAP_KEYS_OR_BUTTONS) && !(caps & ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE)) + { + ecore_fb_input_device_listen(device,1); + ecore_evas_input_devices = eina_list_append(ecore_evas_input_devices, device); + if (!keyboard_handled) + { + ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_FB_EVENT_KEY_DOWN, _ecore_evas_event_key_down, NULL); + ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_FB_EVENT_KEY_UP, _ecore_evas_event_key_up, NULL); + keyboard_handled = 1; + } + } } closedir(input_dir); if (!mouse_handled) { - if (ecore_fb_ts_init()) - { - ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, _ecore_evas_event_mouse_button_down, NULL); - ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, _ecore_evas_event_mouse_button_up, NULL); - ecore_evas_event_handlers[4] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_MOVE, _ecore_evas_event_mouse_move, NULL); - mouse_handled = 1; - } + if (ecore_fb_ts_init()) + { + ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, _ecore_evas_event_mouse_button_down, NULL); + ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, _ecore_evas_event_mouse_button_up, NULL); + ecore_evas_event_handlers[4] = ecore_event_handler_add(ECORE_FB_EVENT_MOUSE_MOVE, _ecore_evas_event_mouse_move, NULL); + mouse_handled = 1; + } } return _ecore_evas_init_count; } @@ -351,7 +352,7 @@ _ecore_evas_move_resize(Ecore_Evas *ee, int x __UNUSED__, int y __UNUSED__, int } static void -_ecore_evas_rotation_set(Ecore_Evas *ee, int rotation, int resize) +_ecore_evas_rotation_set(Ecore_Evas *ee, int rotation, int resize __UNUSED__) { Evas_Engine_Info_FB *einfo; int rot_dif; @@ -364,36 +365,42 @@ _ecore_evas_rotation_set(Ecore_Evas *ee, int rotation, int resize) if (rot_dif != 180) { - einfo->info.rotation = rotation; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); - if (!ee->prop.fullscreen) - { - int tmp; - - tmp = ee->w; - ee->w = ee->h; - ee->h = tmp; - } - else - { - if ((rotation == 0) || (rotation == 180)) - { - evas_output_size_set(ee->evas, ee->w, ee->h); - evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); - } - else - { - evas_output_size_set(ee->evas, ee->h, ee->w); - evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); - } - } - ee->rotation = rotation; + einfo->info.rotation = rotation; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } + if (!ee->prop.fullscreen) + { + int tmp; + + tmp = ee->w; + ee->w = ee->h; + ee->h = tmp; + } + else + { + if ((rotation == 0) || (rotation == 180)) + { + evas_output_size_set(ee->evas, ee->w, ee->h); + evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); + } + else + { + evas_output_size_set(ee->evas, ee->h, ee->w); + evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); + } + } + ee->rotation = rotation; } else { - einfo->info.rotation = rotation; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); - ee->rotation = rotation; + einfo->info.rotation = rotation; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } + ee->rotation = rotation; } if ((ee->rotation == 90) || (ee->rotation == 270)) evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); @@ -422,11 +429,11 @@ _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int h if (!obj) { - ee->prop.cursor.object = NULL; - ee->prop.cursor.layer = 0; - ee->prop.cursor.hot.x = 0; - ee->prop.cursor.hot.y = 0; - return; + ee->prop.cursor.object = NULL; + ee->prop.cursor.layer = 0; + ee->prop.cursor.hot.x = 0; + ee->prop.cursor.hot.y = 0; + return; } ee->prop.cursor.object = obj; @@ -436,8 +443,8 @@ _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int h evas_pointer_output_xy_get(ee->evas, &x, &y); evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); evas_object_move(ee->prop.cursor.object, - x - ee->prop.cursor.hot.x, - y - ee->prop.cursor.hot.y); + x - ee->prop.cursor.hot.x, + y - ee->prop.cursor.hot.y); evas_object_pass_events_set(ee->prop.cursor.object, 1); if (evas_pointer_inside_get(ee->evas)) evas_object_show(ee->prop.cursor.object); @@ -456,33 +463,33 @@ _ecore_evas_fullscreen_set(Ecore_Evas *ee, int on) ((!ee->prop.fullscreen) && (!on))) return; if (on) { - int w, h; - - ee->engine.fb.real_w = ee->w; - ee->engine.fb.real_h = ee->h; - w = ee->w; - h = ee->h; - ecore_fb_size_get(&w, &h); - if ((w == 0) && (h == 0)) - { - w = ee->w; - h = ee->h; - } - if ((w != ee->w) || (h != ee->h)) resized = 1; - ee->w = w; - ee->h = h; - evas_output_size_set(ee->evas, ee->w, ee->h); - evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + int w, h; + + ee->engine.fb.real_w = ee->w; + ee->engine.fb.real_h = ee->h; + w = ee->w; + h = ee->h; + ecore_fb_size_get(&w, &h); + if ((w == 0) && (h == 0)) + { + w = ee->w; + h = ee->h; + } + if ((w != ee->w) || (h != ee->h)) resized = 1; + ee->w = w; + ee->h = h; + evas_output_size_set(ee->evas, ee->w, ee->h); + evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); } else { - if ((ee->engine.fb.real_w != ee->w) || (ee->engine.fb.real_h != ee->h)) resized = 1; - ee->w = ee->engine.fb.real_w; - ee->h = ee->engine.fb.real_h; - evas_output_size_set(ee->evas, ee->w, ee->h); - evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + if ((ee->engine.fb.real_w != ee->w) || (ee->engine.fb.real_h != ee->h)) resized = 1; + ee->w = ee->engine.fb.real_w; + ee->h = ee->engine.fb.real_h; + evas_output_size_set(ee->evas, ee->w, ee->h); + evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); } ee->prop.fullscreen = on; EINA_LIST_FOREACH(ecore_evas_input_devices, l, dev) @@ -490,7 +497,7 @@ _ecore_evas_fullscreen_set(Ecore_Evas *ee, int on) /* rescale the input device area */ if (resized) { - if (ee->func.fn_resize) ee->func.fn_resize(ee); + if (ee->func.fn_resize) ee->func.fn_resize(ee); } } @@ -500,14 +507,14 @@ _ecore_evas_fb_shutdown(void) _ecore_evas_init_count--; if (_ecore_evas_init_count == 0) { - int i; + int i; - for (i = 0; i < 6; i++) + for (i = 0; i < 6; i++) { if (ecore_evas_event_handlers[i]) ecore_event_handler_del(ecore_evas_event_handlers[i]); } - ecore_fb_ts_shutdown(); + ecore_fb_ts_shutdown(); } if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0; return _ecore_evas_init_count; @@ -638,11 +645,14 @@ ecore_evas_fb_new(const char *disp_name, int rotation, int w, int h) einfo = (Evas_Engine_Info_FB *)evas_engine_info_get(ee->evas); if (einfo) { - einfo->info.virtual_terminal = 0; - einfo->info.device_number = strtol(disp_name, NULL, 10); - einfo->info.refresh = 0; - einfo->info.rotation = ee->rotation; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + einfo->info.virtual_terminal = 0; + einfo->info.device_number = strtol(disp_name, NULL, 10); + einfo->info.refresh = 0; + einfo->info.rotation = ee->rotation; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } } evas_key_modifier_add(ee->evas, "Shift"); evas_key_modifier_add(ee->evas, "Control"); diff --git a/src/lib/ecore_evas/ecore_evas_private.h b/src/lib/ecore_evas/ecore_evas_private.h index 8b15b63..a02557b 100644 --- a/src/lib/ecore_evas/ecore_evas_private.h +++ b/src/lib/ecore_evas/ecore_evas_private.h @@ -201,6 +201,7 @@ struct _Ecore_Evas_Engine Ecore_X_GC gc; Ecore_X_XRegion *damages; Ecore_X_Sync_Counter sync_counter; + Ecore_X_Window leader; int sync_val; // bigger! this will screw up at 2 billion frames (414 days of continual rendering @ 60fps) int screen_num; int px, py, pw, ph; @@ -246,17 +247,18 @@ struct _Ecore_Evas_Engine #ifdef BUILD_ECORE_EVAS_WIN32 struct { Ecore_Win32_Window *parent; - struct { - unsigned char fullscreen : 1; - } state; + struct { + unsigned char region : 1; + unsigned char fullscreen : 1; + } state; } win32; #endif #ifdef BUILD_ECORE_EVAS_SOFTWARE_16_WINCE struct { Ecore_WinCE_Window *window; - struct { - unsigned char fullscreen : 1; - } state; + struct { + unsigned char fullscreen : 1; + } state; } wince; #endif @@ -379,6 +381,6 @@ void _ecore_evas_free(Ecore_Evas *ee); void _ecore_evas_idle_timeout_update(Ecore_Evas *ee); void _ecore_evas_mouse_move_process(Ecore_Evas *ee, int x, int y, unsigned int timestamp); -extern int _ecore_evas_app_comp_sync; +extern Eina_Bool _ecore_evas_app_comp_sync; #endif diff --git a/src/lib/ecore_evas/ecore_evas_sdl.c b/src/lib/ecore_evas/ecore_evas_sdl.c index 6a55927..6c19af3 100644 --- a/src/lib/ecore_evas/ecore_evas_sdl.c +++ b/src/lib/ecore_evas/ecore_evas_sdl.c @@ -35,7 +35,7 @@ static Ecore_Event_Handler *ecore_evas_event_handlers[4] = { static const char *ecore_evas_sdl_default = "EFL SDL"; static int _ecore_evas_fps_debug = 0; static Ecore_Poller *ecore_evas_event; -static Ecore_Evas *ecore_evases = NULL; +static Ecore_Evas *ecore_evases = NULL; static Ecore_Evas * _ecore_evas_sdl_match(void) @@ -110,8 +110,8 @@ _ecore_evas_render(Ecore_Evas *ee) updates = evas_render_updates(ee->evas); if (updates) { - evas_render_updates_free(updates); - _ecore_evas_idle_timeout_update(ee); + evas_render_updates_free(updates); + _ecore_evas_idle_timeout_update(ee); } return updates ? 1 : 0; } @@ -189,15 +189,15 @@ _ecore_evas_sdl_shutdown(void) _ecore_evas_init_count--; if (_ecore_evas_init_count == 0) { - int i; + int i; for (i = 0; i < sizeof (ecore_evas_event_handlers) / sizeof (Ecore_Event_Handler*); i++) - ecore_event_handler_del(ecore_evas_event_handlers[i]); - ecore_event_evas_shutdown(); + ecore_event_handler_del(ecore_evas_event_handlers[i]); + ecore_event_evas_shutdown(); ecore_poller_del(ecore_evas_event); ecore_evas_event = NULL; #ifndef _WIN32 - if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_shutdown(); + if (_ecore_evas_fps_debug) _ecore_evas_fps_debug_shutdown(); #endif /* _WIN32 */ } if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0; @@ -261,11 +261,11 @@ _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int h if (!obj) { - ee->prop.cursor.object = NULL; - ee->prop.cursor.layer = 0; - ee->prop.cursor.hot.x = 0; - ee->prop.cursor.hot.y = 0; - return; + ee->prop.cursor.object = NULL; + ee->prop.cursor.layer = 0; + ee->prop.cursor.hot.x = 0; + ee->prop.cursor.hot.y = 0; + return; } ee->prop.cursor.object = obj; @@ -275,8 +275,8 @@ _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int h evas_pointer_output_xy_get(ee->evas, &x, &y); evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); evas_object_move(ee->prop.cursor.object, - x - ee->prop.cursor.hot.x, - y - ee->prop.cursor.hot.y); + x - ee->prop.cursor.hot.x, + y - ee->prop.cursor.hot.y); evas_object_pass_events_set(ee->prop.cursor.object, 1); if (evas_pointer_inside_get(ee->evas)) evas_object_show(ee->prop.cursor.object); @@ -386,37 +386,43 @@ _ecore_evas_internal_sdl_new(int rmethod, const char* name, int w, int h, int fu if (rmethod == evas_render_method_lookup("software_sdl")) { #ifdef BUILD_ECORE_EVAS_SOFTWARE_SDL - einfo = evas_engine_info_get(ee->evas); - if (einfo) - { - ((Evas_Engine_Info_SDL *)einfo)->info.rotation = 0; - ((Evas_Engine_Info_SDL *)einfo)->info.fullscreen = fullscreen; - ((Evas_Engine_Info_SDL *)einfo)->info.hwsurface = hwsurface; - ((Evas_Engine_Info_SDL *)einfo)->info.noframe = noframe; - ((Evas_Engine_Info_SDL *)einfo)->info.alpha = alpha; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); - } + einfo = evas_engine_info_get(ee->evas); + if (einfo) + { + ((Evas_Engine_Info_SDL *)einfo)->info.rotation = 0; + ((Evas_Engine_Info_SDL *)einfo)->info.fullscreen = fullscreen; + ((Evas_Engine_Info_SDL *)einfo)->info.hwsurface = hwsurface; + ((Evas_Engine_Info_SDL *)einfo)->info.noframe = noframe; + ((Evas_Engine_Info_SDL *)einfo)->info.alpha = alpha; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } + } #endif } else if (rmethod == evas_render_method_lookup("gl_sdl")) { #ifdef BUILD_ECORE_EVAS_OPENGL_SDL - einfo = evas_engine_info_get(ee->evas); - if (einfo) - { - ((Evas_Engine_Info_GL_SDL *)einfo)->flags.fullscreen = fullscreen; - ((Evas_Engine_Info_GL_SDL *)einfo)->flags.noframe = noframe; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); - } + einfo = evas_engine_info_get(ee->evas); + if (einfo) + { + ((Evas_Engine_Info_GL_SDL *)einfo)->flags.fullscreen = fullscreen; + ((Evas_Engine_Info_GL_SDL *)einfo)->flags.noframe = noframe; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } + } #endif } if (!ecore_sdl_init(name)) { - evas_free(ee->evas); - if (ee->name) free(ee->name); - free(ee); - return NULL; + evas_free(ee->evas); + if (ee->name) free(ee->name); + free(ee); + return NULL; } _ecore_evas_sdl_init(w, h); diff --git a/src/lib/ecore_evas/ecore_evas_util.c b/src/lib/ecore_evas/ecore_evas_util.c index edca36d..f479edb 100644 --- a/src/lib/ecore_evas/ecore_evas_util.c +++ b/src/lib/ecore_evas/ecore_evas_util.c @@ -255,9 +255,9 @@ _ecore_evas_object_evas_check(const char *function, const Ecore_Evas *ee, const * @param ee The Ecore_Evas to associate to @a obj * @param obj The object to associate to @a ee * @param flags The association flags. - * @return 1 on success, 0 otherwise. + * @return EINA_TRUE on success, EINA_FALSE otherwise. */ -EAPI int +EAPI Eina_Bool ecore_evas_object_associate(Ecore_Evas *ee, Evas_Object *obj, Ecore_Evas_Object_Associate_Flags flags) { Ecore_Evas *old_ee; @@ -266,12 +266,12 @@ ecore_evas_object_associate(Ecore_Evas *ee, Evas_Object *obj, Ecore_Evas_Object_ if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, __FUNCTION__); - return 0; + return EINA_FALSE; } - CHECK_PARAM_POINTER_RETURN("obj", obj, 0); + CHECK_PARAM_POINTER_RETURN("obj", obj, EINA_FALSE); if (!_ecore_evas_object_evas_check(__FUNCTION__, ee, obj)) - return 0; + return EINA_FALSE; old_ee = _evas_object_associate_get(obj);; if (old_ee) @@ -282,7 +282,7 @@ ecore_evas_object_associate(Ecore_Evas *ee, Evas_Object *obj, Ecore_Evas_Object_ ecore_evas_object_dissociate(ee, old_obj); _ecore_evas_object_associate(ee, obj, flags); - return 1; + return EINA_TRUE; } /** @@ -290,9 +290,9 @@ ecore_evas_object_associate(Ecore_Evas *ee, Evas_Object *obj, Ecore_Evas_Object_ * * @param ee The Ecore_Evas to dissociate from @a obj * @param obj The object to dissociate from @a ee - * @return 1 on success, 0 otherwise. + * @return EINA_TRUE on success, EINA_FALSE otherwise. */ -EAPI int +EAPI Eina_Bool ecore_evas_object_dissociate(Ecore_Evas *ee, Evas_Object *obj) { Ecore_Evas *old_ee; @@ -301,27 +301,27 @@ ecore_evas_object_dissociate(Ecore_Evas *ee, Evas_Object *obj) if (!ECORE_MAGIC_CHECK(ee, ECORE_MAGIC_EVAS)) { ECORE_MAGIC_FAIL(ee, ECORE_MAGIC_EVAS, __FUNCTION__); - return 0; + return EINA_FALSE; } - CHECK_PARAM_POINTER_RETURN("obj", obj, 0); + CHECK_PARAM_POINTER_RETURN("obj", obj, EINA_FALSE); old_ee = _evas_object_associate_get(obj); if (ee != old_ee) { ERR("ERROR: trying to dissociate object that is not using " - "this Ecore_Evas: %p != %p", ee, old_ee); - return 0; + "this Ecore_Evas: %p != %p", ee, old_ee); + return EINA_FALSE; } old_obj = _ecore_evas_associate_get(ee); if (old_obj != obj) { ERR("ERROR: trying to dissociate object that is not being " - "used by this Ecore_Evas: %p != %p", old_obj, obj); - return 0; + "used by this Ecore_Evas: %p != %p", old_obj, obj); + return EINA_FALSE; } _ecore_evas_object_dissociate(ee, obj); - return 1; + return EINA_TRUE; } EAPI Evas_Object * @@ -430,13 +430,13 @@ _ecore_evas_object_dissociate(Ecore_Evas *ee, Evas_Object *obj) else { if (ee->func.fn_delete_request == _ecore_evas_delete_request) - ecore_evas_callback_delete_request_set(ee, NULL); + ecore_evas_callback_delete_request_set(ee, NULL); if (ee->func.fn_destroy == _ecore_evas_destroy) - ecore_evas_callback_destroy_set(ee, NULL); + ecore_evas_callback_destroy_set(ee, NULL); if (ee->func.fn_resize == _ecore_evas_resize) - ecore_evas_callback_resize_set(ee, NULL); + ecore_evas_callback_resize_set(ee, NULL); if (ee->func.fn_pre_free == _ecore_evas_pre_free) - ecore_evas_callback_pre_free_set(ee, NULL); + ecore_evas_callback_pre_free_set(ee, NULL); _ecore_evas_associate_del(ee); } diff --git a/src/lib/ecore_evas/ecore_evas_win32.c b/src/lib/ecore_evas/ecore_evas_win32.c index e1d283b..852c922 100644 --- a/src/lib/ecore_evas/ecore_evas_win32.c +++ b/src/lib/ecore_evas/ecore_evas_win32.c @@ -319,9 +319,8 @@ _ecore_evas_win32_event_window_configure(void *data __UNUSED__, int type __UNUSE ecore_evas_avoid_damage_set(ee, 0); ecore_evas_avoid_damage_set(ee, 1); } - /* FIXME: to do... */ -/* if (ee->shaped) */ -/* _ecore_evas_x_resize_shape(ee); */ +/* if (ee->shaped) */ +/* _ecore_evas_win32_region_border_resize(ee); */ if ((ee->expecting_resize.w > 0) && (ee->expecting_resize.h > 0)) { @@ -413,8 +412,16 @@ _ecore_evas_win32_resize(Ecore_Evas *ee, int width, int height) evas_output_size_set(ee->evas, ee->w, ee->h); evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); } - /* FIXME: damage and shape */ + if (ee->prop.avoid_damage) + { + int pdam; + pdam = ecore_evas_avoid_damage_get(ee); + ecore_evas_avoid_damage_set(ee, 0); + ecore_evas_avoid_damage_set(ee, pdam); + } +/* if ((ee->shaped) || (ee->alpha)) */ +/* _ecore_evas_win32_region_border_resize(ee); */ if (ee->func.fn_resize) ee->func.fn_resize(ee); } } @@ -448,7 +455,16 @@ _ecore_evas_win32_move_resize(Ecore_Evas *ee, int x, int y, int width, int heigh evas_output_size_set(ee->evas, ee->w, ee->h); evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); } - /* FIXME: damage and shape */ + if (ee->prop.avoid_damage) + { + int pdam; + + pdam = ecore_evas_avoid_damage_get(ee); + ecore_evas_avoid_damage_set(ee, 0); + ecore_evas_avoid_damage_set(ee, pdam); + } +/* if ((ee->shaped) || (ee->alpha)) */ +/* _ecore_evas_win32_region_border_resize(ee); */ if (change_pos) { if (ee->func.fn_move) ee->func.fn_move(ee); @@ -540,7 +556,10 @@ _ecore_evas_win32_rotation_set(Ecore_Evas *ee, int rotation, int resize) einfo = (Evas_Engine_Info_Software_Gdi *)evas_engine_info_get(ee->evas); if (!einfo) return; einfo->info.rotation = rotation; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } _ecore_evas_win32_rotation_set_internal(ee, rotation); } #endif /* BUILD_ECORE_EVAS_SOFTWARE_GDI */ @@ -553,13 +572,46 @@ _ecore_evas_win32_rotation_set(Ecore_Evas *ee, int rotation, int resize) einfo = (Evas_Engine_Info_Software_DDraw *)evas_engine_info_get(ee->evas); if (!einfo) return; einfo->info.rotation = rotation; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } _ecore_evas_win32_rotation_set_internal(ee, rotation); } #endif /* BUILD_ECORE_EVAS_SOFTWARE_DDRAW */ } static void +_ecore_evas_win32_shaped_set(Ecore_Evas *ee, int shaped) +{ + if (((ee->shaped) && (shaped)) || ((!ee->shaped) && (!shaped))) + return; + + if (!strcmp(ee->driver, "software_ddraw")) return; + +#ifdef BUILD_ECORE_EVAS_SOFTWARE_GDI + if (!strcmp(ee->driver, "software_gdi")) + { + Evas_Engine_Info_Software_Gdi *einfo; + + einfo = (Evas_Engine_Info_Software_Gdi *)evas_engine_info_get(ee->evas); + ee->shaped = shaped; + if (einfo) + { + ee->engine.win32.state.region = ee->shaped; + einfo->info.region = ee->engine.win32.state.region; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } + if (ee->shaped) + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + } +#endif /* BUILD_ECORE_EVAS_SOFTWARE_GDI */ + } +} + +static void _ecore_evas_win32_show(Ecore_Evas *ee) { INF("ecore evas show"); @@ -731,6 +783,25 @@ _ecore_evas_win32_borderless_set(Ecore_Evas *ee, int on) ee->prop.borderless = on; ecore_win32_window_borderless_set((struct _Ecore_Win32_Window *)ee->prop.window, ee->prop.borderless); + +#ifdef BUILD_ECORE_EVAS_SOFTWARE_GDI + if (!strcmp(ee->driver, "software_gdi")) + { + Evas_Engine_Info_Software_Gdi *einfo; + + einfo = (Evas_Engine_Info_Software_Gdi *)evas_engine_info_get(ee->evas); + if (einfo) + { + einfo->info.borderless = ee->prop.borderless; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } + if (ee->prop.borderless) + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + } + } +#endif /* BUILD_ECORE_EVAS_SOFTWARE_GDI */ } static void @@ -777,7 +848,10 @@ _ecore_evas_win32_fullscreen_set(Ecore_Evas *ee, int on) { einfo->info.fullscreen = !!on; /* einfo->info.layered = window->shape.layered; */ - evas_engine_info_set(ecore_evas_get(ee), (Evas_Engine_Info *)einfo); + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } } } #endif /* BUILD_ECORE_EVAS_SOFTWARE_DDRAW */ @@ -792,7 +866,10 @@ _ecore_evas_win32_fullscreen_set(Ecore_Evas *ee, int on) { einfo->info.fullscreen = !!on; einfo->info.layered = window->shape.layered; - evas_engine_info_set(ecore_evas_get(ee), (Evas_Engine_Info *)einfo); + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } } } #endif /* BUILD_ECORE_EVAS_DIRECT3D */ @@ -821,7 +898,7 @@ static Ecore_Evas_Engine_Func _ecore_win32_engine_func = _ecore_evas_win32_resize, _ecore_evas_win32_move_resize, _ecore_evas_win32_rotation_set, - NULL, /* _ecore_evas_x_shaped_set */ + _ecore_evas_win32_shaped_set, _ecore_evas_win32_show, _ecore_evas_win32_hide, _ecore_evas_win32_raise, @@ -877,11 +954,15 @@ _ecore_evas_engine_software_gdi_init(Ecore_Evas *ee) { /* FIXME: REDRAW_DEBUG missing for now */ einfo->info.window = ((struct _Ecore_Win32_Window *)ee->prop.window)->window; - einfo->info.mask = NULL; einfo->info.depth = ecore_win32_screen_depth_get(); einfo->info.rotation = 0; + einfo->info.borderless = 0; einfo->info.fullscreen = 0; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + einfo->info.region = 0; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } } return 1; @@ -912,7 +993,10 @@ _ecore_evas_engine_software_ddraw_init(Ecore_Evas *ee) einfo->info.window = ((struct _Ecore_Win32_Window *)ee->prop.window)->window; einfo->info.depth = ecore_win32_screen_depth_get(); einfo->info.rotation = 0; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } } return 1; @@ -943,7 +1027,10 @@ _ecore_evas_engine_direct3d_init(Ecore_Evas *ee) einfo->info.window = ((struct _Ecore_Win32_Window *)ee->prop.window)->window; einfo->info.depth = ecore_win32_screen_depth_get(); einfo->info.rotation = 0; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } } return 1; @@ -973,7 +1060,10 @@ _ecore_evas_engine_opengl_glew_init(Ecore_Evas *ee) /* FIXME: REDRAW_DEBUG missing for now */ einfo->info.window = ((struct _Ecore_Win32_Window *)ee->prop.window)->window; einfo->info.depth = ecore_win32_screen_depth_get(); - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } } return 1; @@ -1007,7 +1097,10 @@ _ecore_evas_engine_software_16_ddraw_init(Ecore_Evas *ee) einfo->info.window = ((struct _Ecore_Win32_Window *)ee->prop.window)->window; einfo->info.depth = ecore_win32_screen_depth_get(); einfo->info.rotation = 0; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } } return 1; @@ -1077,7 +1170,7 @@ _ecore_evas_win32_new_internal(int (*_ecore_evas_engine_init)(Ecore_Evas *ee), ee->engine.func->fn_render = _ecore_evas_win32_render; _ecore_evas_register(ee); - ecore_event_window_register(ee->prop.window, ee, ee->evas, _ecore_evas_mouse_move_process); + ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process); return ee; } diff --git a/src/lib/ecore_evas/ecore_evas_wince.c b/src/lib/ecore_evas/ecore_evas_wince.c index 1c3cbb4..c1de52c 100644 --- a/src/lib/ecore_evas/ecore_evas_wince.c +++ b/src/lib/ecore_evas/ecore_evas_wince.c @@ -52,9 +52,9 @@ _ecore_evas_wince_render(Ecore_Evas *ee) EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2) { - if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2); - rend |= _ecore_evas_buffer_render(ee2); - if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2); + if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2); + rend |= _ecore_evas_buffer_render(ee2); + if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2); } #endif if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee); @@ -110,10 +110,10 @@ _ecore_evas_wince_shutdown(void) _ecore_evas_init_count--; if (_ecore_evas_init_count == 0) { - int i; + int i; - for (i = 0; i < ECORE_EVAS_EVENT_COUNT; i++) - ecore_event_handler_del(ecore_evas_event_handlers[i]); + for (i = 0; i < ECORE_EVAS_EVENT_COUNT; i++) + ecore_event_handler_del(ecore_evas_event_handlers[i]); ecore_event_evas_shutdown(); } @@ -400,65 +400,65 @@ _ecore_evas_wince_move_resize(Ecore_Evas *ee, int x, int y, int width, int heigh /* if (rot_dif < 0) rot_dif = -rot_dif; */ /* if (!strcmp(ee->driver, "software_ddraw")) */ /* { */ -/* Evas_Engine_Info_Software_16_WinCE *einfo; */ - -/* einfo = (Evas_Engine_Info_Software_16_WinCE *)evas_engine_info_get(ee->evas); */ -/* if (!einfo) return; */ -/* if (rot_dif != 180) */ -/* { */ -/* int minw, minh, maxw, maxh, basew, baseh, stepw, steph; */ - -/* einfo->info.rotation = rotation; */ -/* evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); */ -/* if (!ee->prop.fullscreen) */ -/* { */ -/* ecore_wince_window_resize(ee->prop.window, ee->h, ee->w); */ -/* ee->expecting_resize.w = ee->h; */ -/* ee->expecting_resize.h = ee->w; */ -/* } */ -/* else */ -/* { */ -/* int w, h; */ - -/* ecore_wince_window_size_get(ee->prop.window, &w, &h); */ -/* ecore_wince_window_resize(ee->prop.window, h, w); */ -/* if ((rotation == 0) || (rotation == 180)) */ -/* { */ -/* evas_output_size_set(ee->evas, ee->w, ee->h); */ -/* evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); */ -/* } */ -/* else */ -/* { */ -/* evas_output_size_set(ee->evas, ee->h, ee->w); */ -/* evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); */ -/* } */ -/* if (ee->func.fn_resize) ee->func.fn_resize(ee); */ -/* } */ -/* ecore_evas_size_min_get(ee, &minw, &minh); */ -/* ecore_evas_size_max_get(ee, &maxw, &maxh); */ -/* ecore_evas_size_base_get(ee, &basew, &baseh); */ -/* ecore_evas_size_step_get(ee, &stepw, &steph); */ -/* ee->rotation = rotation; */ -/* ecore_evas_size_min_set(ee, minh, minw); */ -/* ecore_evas_size_max_set(ee, maxh, maxw); */ -/* ecore_evas_size_base_set(ee, baseh, basew); */ -/* ecore_evas_size_step_set(ee, steph, stepw); */ -/* _ecore_evas_wince_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, */ +/* Evas_Engine_Info_Software_16_WinCE *einfo; */ + +/* einfo = (Evas_Engine_Info_Software_16_WinCE *)evas_engine_info_get(ee->evas); */ +/* if (!einfo) return; */ +/* if (rot_dif != 180) */ +/* { */ +/* int minw, minh, maxw, maxh, basew, baseh, stepw, steph; */ + +/* einfo->info.rotation = rotation; */ +/* evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); */ +/* if (!ee->prop.fullscreen) */ +/* { */ +/* ecore_wince_window_resize(ee->prop.window, ee->h, ee->w); */ +/* ee->expecting_resize.w = ee->h; */ +/* ee->expecting_resize.h = ee->w; */ +/* } */ +/* else */ +/* { */ +/* int w, h; */ + +/* ecore_wince_window_size_get(ee->prop.window, &w, &h); */ +/* ecore_wince_window_resize(ee->prop.window, h, w); */ +/* if ((rotation == 0) || (rotation == 180)) */ +/* { */ +/* evas_output_size_set(ee->evas, ee->w, ee->h); */ +/* evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); */ +/* } */ +/* else */ +/* { */ +/* evas_output_size_set(ee->evas, ee->h, ee->w); */ +/* evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); */ +/* } */ +/* if (ee->func.fn_resize) ee->func.fn_resize(ee); */ +/* } */ +/* ecore_evas_size_min_get(ee, &minw, &minh); */ +/* ecore_evas_size_max_get(ee, &maxw, &maxh); */ +/* ecore_evas_size_base_get(ee, &basew, &baseh); */ +/* ecore_evas_size_step_get(ee, &stepw, &steph); */ +/* ee->rotation = rotation; */ +/* ecore_evas_size_min_set(ee, minh, minw); */ +/* ecore_evas_size_max_set(ee, maxh, maxw); */ +/* ecore_evas_size_base_set(ee, baseh, basew); */ +/* ecore_evas_size_step_set(ee, steph, stepw); */ +/* _ecore_evas_wince_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, */ /* ecore_wince_current_time_get()); */ -/* } */ -/* else */ -/* { */ -/* einfo->info.rotation = rotation; */ -/* evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); */ -/* ee->rotation = rotation; */ -/* _ecore_evas_wince_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, */ +/* } */ +/* else */ +/* { */ +/* einfo->info.rotation = rotation; */ +/* evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); */ +/* ee->rotation = rotation; */ +/* _ecore_evas_wince_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, */ /* ecore_wince_current_time_get()); */ -/* if (ee->func.fn_resize) ee->func.fn_resize(ee); */ -/* } */ -/* if ((ee->rotation == 90) || (ee->rotation == 270)) */ -/* evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); */ -/* else */ -/* evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); */ +/* if (ee->func.fn_resize) ee->func.fn_resize(ee); */ +/* } */ +/* if ((ee->rotation == 90) || (ee->rotation == 270)) */ +/* evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); */ +/* else */ +/* evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); */ /* } */ /* } */ @@ -567,12 +567,12 @@ _ecore_evas_wince_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int ho if (obj == NULL) { - ee->prop.cursor.object = NULL; - ee->prop.cursor.layer = 0; - ee->prop.cursor.hot.x = 0; - ee->prop.cursor.hot.y = 0; - ecore_wince_window_cursor_show(ee->prop.window, 1); - return; + ee->prop.cursor.object = NULL; + ee->prop.cursor.layer = 0; + ee->prop.cursor.hot.x = 0; + ee->prop.cursor.hot.y = 0; + ecore_wince_window_cursor_show(ee->prop.window, 1); + return; } ee->prop.cursor.object = obj; @@ -585,8 +585,8 @@ _ecore_evas_wince_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int ho evas_pointer_output_xy_get(ee->evas, &x, &y); evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); evas_object_move(ee->prop.cursor.object, - x - ee->prop.cursor.hot.x, - y - ee->prop.cursor.hot.y); + x - ee->prop.cursor.hot.x, + y - ee->prop.cursor.hot.y); evas_object_pass_events_set(ee->prop.cursor.object, 1); if (evas_pointer_inside_get(ee->evas)) evas_object_show(ee->prop.cursor.object); @@ -665,7 +665,10 @@ _ecore_evas_wince_fullscreen_set(Ecore_Evas *ee, int on) { einfo->info.fullscreen = !!on; /* einfo->info.layered = window->shape.layered; */ - evas_engine_info_set(ecore_evas_get(ee), (Evas_Engine_Info *)einfo); + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } } } @@ -805,7 +808,10 @@ ecore_evas_software_wince_new_internal(int backend, einfo->info.backend = backend; einfo->info.rotation = 0; einfo->info.fullscreen = fullscreen; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } ecore_wince_window_backend_set((Ecore_WinCE_Window *)ee->prop.window, backend); ecore_wince_window_suspend_set((Ecore_WinCE_Window *)ee->prop.window, einfo->func.suspend); diff --git a/src/lib/ecore_evas/ecore_evas_x.c b/src/lib/ecore_evas/ecore_evas_x.c index f767eac..1cb168c 100644 --- a/src/lib/ecore_evas/ecore_evas_x.c +++ b/src/lib/ecore_evas/ecore_evas_x.c @@ -10,8 +10,17 @@ #ifdef BUILD_ECORE_EVAS_X11 # include # include +#else +# undef BUILD_ECORE_EVAS_OPENGL_X11 +# undef BUILD_ECORE_EVAS_SOFTWARE_X11 +# undef BUILD_ECORE_EVAS_XRENDER_X11 #endif +#ifndef HAVE_ECORE_X_XCB +# undef BUILD_ECORE_EVAS_XRENDER_XCB +# undef BUILD_ECORE_EVAS_SOFTWARE_XCB +#endif + #include "ecore_evas_private.h" #include "Ecore_Evas.h" @@ -20,6 +29,49 @@ static int _ecore_evas_init_count = 0; static Ecore_Event_Handler *ecore_evas_event_handlers[13]; +static int leader_ref = 0; +static Ecore_X_Window leader_win = 0; + +static void +_ecore_evas_x_group_leader_set(Ecore_Evas *ee) +{ + leader_ref++; + if (leader_ref == 1) + { + leader_win = ecore_x_window_override_new(ee->engine.x.win_root, 1234, 5678, 1, 2); + ecore_x_window_defaults_set(leader_win); + if (getenv("DESKTOP_STARTUP_ID")) + ecore_x_netwm_startup_id_set(leader_win, + getenv("DESKTOP_STARTUP_ID")); + ecore_x_icccm_client_leader_set(leader_win, leader_win); + } + ee->engine.x.leader = leader_win; + ecore_x_icccm_client_leader_set(ee->prop.window, leader_win); +} + +static void +_ecore_evas_x_group_leader_unset(Ecore_Evas *ee) +{ + ecore_x_window_prop_property_del(ee->prop.window, ECORE_X_ATOM_WM_CLIENT_LEADER); + if (ee->engine.x.leader == leader_win) + { + leader_ref--; + if (leader_ref <= 0) + { + ecore_x_window_free(leader_win); + leader_win = 0; + } + ee->engine.x.leader = 0; + } +} + +static void +_ecore_evas_x_group_leader_update(Ecore_Evas *ee) +{ + if (ee->engine.x.leader) + ecore_x_icccm_client_leader_set(ee->prop.window, ee->engine.x.leader); +} + static void _ecore_evas_x_protocols_set(Ecore_Evas *ee) { @@ -27,7 +79,7 @@ _ecore_evas_x_protocols_set(Ecore_Evas *ee) int num = 0; if (ee->func.fn_delete_request) - protos[num++] = ECORE_X_ATOM_WM_DELETE_WINDOW; + protos[num++] = ECORE_X_ATOM_WM_DELETE_WINDOW; protos[num++] = ECORE_X_ATOM_NET_WM_PING; ecore_x_icccm_protocol_atoms_set(ee->prop.window, protos, num); } @@ -35,16 +87,17 @@ _ecore_evas_x_protocols_set(Ecore_Evas *ee) static void _ecore_evas_x_sync_set(Ecore_Evas *ee) { - if ((ecore_x_e_comp_sync_supported_get(ee->engine.x.win_root)) && - (!ee->no_comp_sync) && (_ecore_evas_app_comp_sync)) + if (((ee->should_be_visible) || (ee->visible)) && + ((ecore_x_e_comp_sync_supported_get(ee->engine.x.win_root)) && + (!ee->no_comp_sync) && (_ecore_evas_app_comp_sync))) { if (!ee->engine.x.sync_counter) - ee->engine.x.sync_counter = ecore_x_sync_counter_new(0); + ee->engine.x.sync_counter = ecore_x_sync_counter_new(0); } else { if (ee->engine.x.sync_counter) - ecore_x_sync_counter_free(ee->engine.x.sync_counter); + ecore_x_sync_counter_free(ee->engine.x.sync_counter); ee->engine.x.sync_counter = 0; } ecore_x_e_comp_sync_counter_set(ee->prop.window, ee->engine.x.sync_counter); @@ -96,8 +149,8 @@ _ecore_evas_x_gl_window_new(Ecore_Evas *ee, Ecore_X_Window parent, int x, int y, einfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(ee->evas); if (einfo) { - XSetWindowAttributes attr; - int screen; + XSetWindowAttributes attr; + int screen; if (opt) { @@ -113,42 +166,42 @@ _ecore_evas_x_gl_window_new(Ecore_Evas *ee, Ecore_X_Window parent, int x, int y, } } - /* FIXME: this is inefficient as its 1 or more round trips */ - screen = DefaultScreen(ecore_x_display_get()); - if (ScreenCount(ecore_x_display_get()) > 1) - { - Ecore_X_Window *roots; - int num, i; - - num = 0; - roots = ecore_x_window_root_list(&num); - if (roots) - { - XWindowAttributes at; - - if (XGetWindowAttributes(ecore_x_display_get(), - parent, &at)) - { - for (i = 0; i < num; i++) - { - if (at.root == roots[i]) - { - screen = i; - break; - } - } - } - free(roots); - } - } - einfo->info.display = ecore_x_display_get(); + /* FIXME: this is inefficient as its 1 or more round trips */ + screen = DefaultScreen(ecore_x_display_get()); + if (ScreenCount(ecore_x_display_get()) > 1) + { + Ecore_X_Window *roots; + int num, i; + + num = 0; + roots = ecore_x_window_root_list(&num); + if (roots) + { + XWindowAttributes at; + + if (XGetWindowAttributes(ecore_x_display_get(), + parent, &at)) + { + for (i = 0; i < num; i++) + { + if (at.root == roots[i]) + { + screen = i; + break; + } + } + } + free(roots); + } + } + einfo->info.display = ecore_x_display_get(); einfo->info.screen = screen; einfo->info.destination_alpha = argb; - einfo->info.visual = einfo->func.best_visual_get(einfo); - einfo->info.colormap = einfo->func.best_colormap_get(einfo); - einfo->info.depth = einfo->func.best_depth_get(einfo); + einfo->info.visual = einfo->func.best_visual_get(einfo); + einfo->info.colormap = einfo->func.best_colormap_get(einfo); + einfo->info.depth = einfo->func.best_depth_get(einfo); if ((!einfo->info.visual) || @@ -156,44 +209,44 @@ _ecore_evas_x_gl_window_new(Ecore_Evas *ee, Ecore_X_Window parent, int x, int y, (!einfo->info.depth)) { WRN("OpenGL X11 init engine '%s' failed - no visual, colormap or depth.", ee->driver); - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); - return 0; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + return 0; + } } - attr.backing_store = NotUseful; - attr.override_redirect = override; - attr.colormap = einfo->info.colormap; - attr.border_pixel = 0; - attr.background_pixmap = None; - attr.event_mask = - KeyPressMask | KeyReleaseMask | - ExposureMask | ButtonPressMask | ButtonReleaseMask | - EnterWindowMask | LeaveWindowMask | - PointerMotionMask | StructureNotifyMask | VisibilityChangeMask | - FocusChangeMask | PropertyChangeMask | ColormapChangeMask; - attr.bit_gravity = ForgetGravity; - - win = - XCreateWindow(einfo->info.display, parent, x, y, w, h, 0, - einfo->info.depth, InputOutput, einfo->info.visual, - CWBackingStore | CWColormap | CWBackPixmap | + attr.backing_store = NotUseful; + attr.override_redirect = override; + attr.colormap = einfo->info.colormap; + attr.border_pixel = 0; + attr.background_pixmap = None; + attr.event_mask = + KeyPressMask | KeyReleaseMask | + ExposureMask | ButtonPressMask | ButtonReleaseMask | + EnterWindowMask | LeaveWindowMask | + PointerMotionMask | StructureNotifyMask | VisibilityChangeMask | + FocusChangeMask | PropertyChangeMask | ColormapChangeMask; + attr.bit_gravity = ForgetGravity; + + win = + XCreateWindow(einfo->info.display, parent, x, y, w, h, 0, + einfo->info.depth, InputOutput, einfo->info.visual, + CWBackingStore | CWColormap | CWBackPixmap | CWBorderPixel | CWBitGravity | CWEventMask | - CWOverrideRedirect, &attr); - einfo->info.drawable = win; - - if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + CWOverrideRedirect, &attr); + einfo->info.drawable = win; + + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { - WRN("evas_engine_info_set() init engine '%s' failed.", ee->driver); + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); XDestroyWindow(einfo->info.display, win); return 0; } - ecore_x_window_defaults_set(win); - _ecore_evas_x_protocols_set(ee); - _ecore_evas_x_sync_set(ee); } else { - win = 0; + win = 0; } return win; } @@ -217,22 +270,22 @@ _ecore_evas_x_render(Ecore_Evas *ee) EINA_LIST_FOREACH(ee->sub_ecore_evas, ll, ee2) { - if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2); - rend |= _ecore_evas_buffer_render(ee2); - if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2); + if (ee2->func.fn_pre_render) ee2->func.fn_pre_render(ee2); + rend |= _ecore_evas_buffer_render(ee2); + if (ee2->func.fn_post_render) ee2->func.fn_post_render(ee2); } #endif if (ee->func.fn_pre_render) ee->func.fn_pre_render(ee); if (ee->prop.avoid_damage) { - updates = evas_render_updates(ee->evas); - if (ee->engine.x.using_bg_pixmap) - { - if (updates) - { - EINA_LIST_FOREACH(updates, l, r) - ecore_x_window_area_clear(ee->prop.window, r->x, r->y, r->w, r->h); - if ((ee->shaped) && (updates)) + updates = evas_render_updates(ee->evas); + if (ee->engine.x.using_bg_pixmap) + { + if (updates) + { + EINA_LIST_FOREACH(updates, l, r) + ecore_x_window_area_clear(ee->prop.window, r->x, r->y, r->w, r->h); + if ((ee->shaped) && (updates)) { #ifdef EVAS_FRAME_QUEUING /* wait until ee->engine.x.mask being updated */ @@ -240,7 +293,7 @@ _ecore_evas_x_render(Ecore_Evas *ee) #endif ecore_x_window_shape_mask_set(ee->prop.window, ee->engine.x.mask); } - if ((ee->alpha) && (updates)) + if ((ee->alpha) && (updates)) { #ifdef EVAS_FRAME_QUEUING /* wait until ee->engine.x.mask being updated */ @@ -248,116 +301,116 @@ _ecore_evas_x_render(Ecore_Evas *ee) #endif // ecore_x_window_shape_input_mask_set(ee->prop.window, ee->engine.x.mask); } - evas_render_updates_free(updates); - _ecore_evas_idle_timeout_update(ee); + evas_render_updates_free(updates); + _ecore_evas_idle_timeout_update(ee); rend = 1; - } - } - else - { - EINA_LIST_FOREACH(updates, l, r) - { - Ecore_X_Rectangle rect; - Ecore_X_XRegion *tmpr; - - if (!ee->engine.x.damages) - ee->engine.x.damages = ecore_x_xregion_new(); - tmpr = ecore_x_xregion_new(); - if (ee->rotation == 0) - { - rect.x = r->x; - rect.y = r->y; - rect.width = r->w; - rect.height = r->h; - } - else if (ee->rotation == 90) - { - rect.x = r->y; - rect.y = ee->h - r->x - r->w; - rect.width = r->h; - rect.height = r->w; - } - else if (ee->rotation == 180) - { - rect.x = ee->w - r->x - r->w; - rect.y = ee->h - r->y - r->h; - rect.width = r->w; - rect.height = r->h; - } - else if (ee->rotation == 270) - { - rect.x = ee->w - r->y - r->h; - rect.y = r->x; - rect.width = r->h; - rect.height = r->w; - } + } + } + else + { + EINA_LIST_FOREACH(updates, l, r) + { + Ecore_X_Rectangle rect; + Ecore_X_XRegion *tmpr; + + if (!ee->engine.x.damages) + ee->engine.x.damages = ecore_x_xregion_new(); + tmpr = ecore_x_xregion_new(); + if (ee->rotation == 0) + { + rect.x = r->x; + rect.y = r->y; + rect.width = r->w; + rect.height = r->h; + } + else if (ee->rotation == 90) + { + rect.x = r->y; + rect.y = ee->h - r->x - r->w; + rect.width = r->h; + rect.height = r->w; + } + else if (ee->rotation == 180) + { + rect.x = ee->w - r->x - r->w; + rect.y = ee->h - r->y - r->h; + rect.width = r->w; + rect.height = r->h; + } + else if (ee->rotation == 270) + { + rect.x = ee->w - r->y - r->h; + rect.y = r->x; + rect.width = r->h; + rect.height = r->w; + } ecore_x_xregion_union_rect(tmpr, ee->engine.x.damages, &rect); - ecore_x_xregion_free(ee->engine.x.damages); - ee->engine.x.damages = tmpr; - } - if (ee->engine.x.damages) - { - /* if we have a damage pixmap - we can avoid exposures by - * disabling them just for setting the mask */ - ecore_x_event_mask_set(ee->prop.window, - ECORE_X_EVENT_MASK_KEY_DOWN | - ECORE_X_EVENT_MASK_KEY_UP | - ECORE_X_EVENT_MASK_MOUSE_DOWN | - ECORE_X_EVENT_MASK_MOUSE_UP | - ECORE_X_EVENT_MASK_MOUSE_IN | - ECORE_X_EVENT_MASK_MOUSE_OUT | - ECORE_X_EVENT_MASK_MOUSE_MOVE | -// ECORE_X_EVENT_MASK_WINDOW_DAMAGE | - ECORE_X_EVENT_MASK_WINDOW_VISIBILITY | - ECORE_X_EVENT_MASK_WINDOW_CONFIGURE | - ECORE_X_EVENT_MASK_WINDOW_FOCUS_CHANGE | - ECORE_X_EVENT_MASK_WINDOW_PROPERTY | - ECORE_X_EVENT_MASK_WINDOW_COLORMAP - ); - if ((ee->shaped) && (updates)) - ecore_x_window_shape_mask_set(ee->prop.window, ee->engine.x.mask); - /* and re-enable them again */ - ecore_x_event_mask_set(ee->prop.window, - ECORE_X_EVENT_MASK_KEY_DOWN | - ECORE_X_EVENT_MASK_KEY_UP | - ECORE_X_EVENT_MASK_MOUSE_DOWN | - ECORE_X_EVENT_MASK_MOUSE_UP | - ECORE_X_EVENT_MASK_MOUSE_IN | - ECORE_X_EVENT_MASK_MOUSE_OUT | - ECORE_X_EVENT_MASK_MOUSE_MOVE | - ECORE_X_EVENT_MASK_WINDOW_DAMAGE | - ECORE_X_EVENT_MASK_WINDOW_VISIBILITY | - ECORE_X_EVENT_MASK_WINDOW_CONFIGURE | - ECORE_X_EVENT_MASK_WINDOW_FOCUS_CHANGE | - ECORE_X_EVENT_MASK_WINDOW_PROPERTY | - ECORE_X_EVENT_MASK_WINDOW_COLORMAP - ); - ecore_x_xregion_set(ee->engine.x.damages, ee->engine.x.gc); - /* debug rendering */ - /* - XSetForeground(ecore_x_display_get(), ee->engine.x.gc, rand()); - XFillRectangle(ecore_x_display_get(), ee->prop.window, ee->engine.x.gc, - 0, 0, ee->w, ee->h); - XSync(ecore_x_display_get(), False); - usleep(20000); - XSync(ecore_x_display_get(), False); - */ - ecore_x_pixmap_paste(ee->engine.x.pmap, ee->prop.window, ee->engine.x.gc, - 0, 0, ee->w, ee->h, 0, 0); - ecore_x_xregion_free(ee->engine.x.damages); - ee->engine.x.damages = NULL; - } - if (updates) - { - evas_render_updates_free(updates); - _ecore_evas_idle_timeout_update(ee); + ecore_x_xregion_free(ee->engine.x.damages); + ee->engine.x.damages = tmpr; + } + if (ee->engine.x.damages) + { + /* if we have a damage pixmap - we can avoid exposures by + * disabling them just for setting the mask */ + ecore_x_event_mask_set(ee->prop.window, + ECORE_X_EVENT_MASK_KEY_DOWN | + ECORE_X_EVENT_MASK_KEY_UP | + ECORE_X_EVENT_MASK_MOUSE_DOWN | + ECORE_X_EVENT_MASK_MOUSE_UP | + ECORE_X_EVENT_MASK_MOUSE_IN | + ECORE_X_EVENT_MASK_MOUSE_OUT | + ECORE_X_EVENT_MASK_MOUSE_MOVE | +// ECORE_X_EVENT_MASK_WINDOW_DAMAGE | + ECORE_X_EVENT_MASK_WINDOW_VISIBILITY | + ECORE_X_EVENT_MASK_WINDOW_CONFIGURE | + ECORE_X_EVENT_MASK_WINDOW_FOCUS_CHANGE | + ECORE_X_EVENT_MASK_WINDOW_PROPERTY | + ECORE_X_EVENT_MASK_WINDOW_COLORMAP + ); + if ((ee->shaped) && (updates)) + ecore_x_window_shape_mask_set(ee->prop.window, ee->engine.x.mask); + /* and re-enable them again */ + ecore_x_event_mask_set(ee->prop.window, + ECORE_X_EVENT_MASK_KEY_DOWN | + ECORE_X_EVENT_MASK_KEY_UP | + ECORE_X_EVENT_MASK_MOUSE_DOWN | + ECORE_X_EVENT_MASK_MOUSE_UP | + ECORE_X_EVENT_MASK_MOUSE_IN | + ECORE_X_EVENT_MASK_MOUSE_OUT | + ECORE_X_EVENT_MASK_MOUSE_MOVE | + ECORE_X_EVENT_MASK_WINDOW_DAMAGE | + ECORE_X_EVENT_MASK_WINDOW_VISIBILITY | + ECORE_X_EVENT_MASK_WINDOW_CONFIGURE | + ECORE_X_EVENT_MASK_WINDOW_FOCUS_CHANGE | + ECORE_X_EVENT_MASK_WINDOW_PROPERTY | + ECORE_X_EVENT_MASK_WINDOW_COLORMAP + ); + ecore_x_xregion_set(ee->engine.x.damages, ee->engine.x.gc); + /* debug rendering */ + /* + XSetForeground(ecore_x_display_get(), ee->engine.x.gc, rand()); + XFillRectangle(ecore_x_display_get(), ee->prop.window, ee->engine.x.gc, + 0, 0, ee->w, ee->h); + XSync(ecore_x_display_get(), False); + usleep(20000); + XSync(ecore_x_display_get(), False); + */ + ecore_x_pixmap_paste(ee->engine.x.pmap, ee->prop.window, ee->engine.x.gc, + 0, 0, ee->w, ee->h, 0, 0); + ecore_x_xregion_free(ee->engine.x.damages); + ee->engine.x.damages = NULL; + } + if (updates) + { + evas_render_updates_free(updates); + _ecore_evas_idle_timeout_update(ee); rend = 1; - } - } + } + } } else if (((ee->visible) && (ee->draw_ok)) || - ((ee->should_be_visible) && (ee->prop.fullscreen)) || - ((ee->should_be_visible) && (ee->prop.override))) + ((ee->should_be_visible) && (ee->prop.fullscreen)) || + ((ee->should_be_visible) && (ee->prop.override))) { updates = evas_render_updates(ee->evas); if (updates) @@ -413,16 +466,16 @@ _ecore_evas_x_resize_shape(Ecore_Evas *ee) if (!strcmp(ee->driver, "software_x11")) { #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11 - Evas_Engine_Info_Software_X11 *einfo; + Evas_Engine_Info_Software_X11 *einfo; - einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas); - if (einfo) - { + einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas); + if (einfo) + { unsigned int foreground; - Ecore_X_GC gc; + Ecore_X_GC gc; - if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); - ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1); + if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); + ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1); foreground = 0; gc = ecore_x_gc_new(ee->engine.x.mask, ECORE_X_GC_VALUE_MASK_FOREGROUND, @@ -430,79 +483,79 @@ _ecore_evas_x_resize_shape(Ecore_Evas *ee) ecore_x_drawable_rectangle_fill(ee->engine.x.mask, gc, 0, 0, ee->w, ee->h); ecore_x_gc_free(gc); - einfo->info.mask = ee->engine.x.mask; + einfo->info.mask = ee->engine.x.mask; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); - } + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + } #endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */ } else if (!strcmp(ee->driver, "xrender_x11")) { #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB) - Evas_Engine_Info_XRender_X11 *einfo; + Evas_Engine_Info_XRender_X11 *einfo; - einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas); - if (einfo) - { + einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas); + if (einfo) + { unsigned int foreground; - Ecore_X_GC gc; + Ecore_X_GC gc; - if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); - ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1); + if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); + ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1); foreground = 0; gc = ecore_x_gc_new(ee->engine.x.mask, - ECORE_X_GC_VALUE_MASK_FOREGROUND, - &foreground); + ECORE_X_GC_VALUE_MASK_FOREGROUND, + &foreground); ecore_x_drawable_rectangle_fill(ee->engine.x.mask, gc, 0, 0, ee->w, ee->h); ecore_x_gc_free(gc); - einfo->info.mask = ee->engine.x.mask; + einfo->info.mask = ee->engine.x.mask; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); - } + } #endif /* BUILD_ECORE_EVAS_XRENDER_X11 || BUILD_ECORE_EVAS_XRENDER_XCB */ } else if (!strcmp(ee->driver, "software_16_x11")) { #if BUILD_ECORE_EVAS_SOFTWARE_16_X11 # if 0 /* XXX no shaped window support for software_16_x11 */ - Evas_Engine_Info_Software_16_X11 *einfo; - - einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas); - if (einfo) - { - if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); - ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1); - einfo->info.mask = ee->engine.x.mask; + Evas_Engine_Info_Software_16_X11 *einfo; + + einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas); + if (einfo) + { + if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); + ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1); + einfo->info.mask = ee->engine.x.mask; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); - } + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + } # endif /* XXX no shaped window support for software_16_x11 */ #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */ } if (!strcmp(ee->driver, "software_8_x11")) { #if defined (BUILD_ECORE_EVAS_SOFTWARE_8_X11) - Evas_Engine_Info_Software_8_X11 *einfo; + Evas_Engine_Info_Software_8_X11 *einfo; - einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas); - if (einfo) - { + einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas); + if (einfo) + { unsigned int foreground; - Ecore_X_GC gc; + Ecore_X_GC gc; - if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); - ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1); + if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); + ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1); foreground = 0; gc = ecore_x_gc_new(ee->engine.x.mask, ECORE_X_GC_VALUE_MASK_FOREGROUND, @@ -510,13 +563,13 @@ _ecore_evas_x_resize_shape(Ecore_Evas *ee) ecore_x_drawable_rectangle_fill(ee->engine.x.mask, gc, 0, 0, ee->w, ee->h); ecore_x_gc_free(gc); - einfo->info.mask = ee->engine.x.mask; + einfo->info.mask = ee->engine.x.mask; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); - } + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + } #endif /* BUILD_ECORE_EVAS_SOFTWARE_8_X11 */ } } @@ -534,90 +587,90 @@ _ecore_evas_x_event_property_change(void *data __UNUSED__, int type __UNUSED__, if (e->win != ee->prop.window) return ECORE_CALLBACK_PASS_ON; if (e->atom == ECORE_X_ATOM_NET_WM_STATE) { - unsigned int i, num; - Ecore_X_Window_State *state; - int sticky; + unsigned int i, num; + Ecore_X_Window_State *state; + int sticky; #ifdef HAVE_ECORE_X_XCB ecore_x_netwm_window_state_get_prefetch(e->win); #endif /* HAVE_ECORE_X_XCB */ - sticky = 0; - - /* TODO: we need to move those to the end, with if statements */ - ee->engine.x.state.modal = 0; - ee->engine.x.state.maximized_v = 0; - ee->engine.x.state.maximized_h = 0; - ee->engine.x.state.shaded = 0; - ee->engine.x.state.skip_taskbar = 0; - ee->engine.x.state.skip_pager = 0; - ee->prop.fullscreen = 0; - ee->engine.x.state.fullscreen = 0; - ee->engine.x.state.above = 0; - ee->engine.x.state.below = 0; + sticky = 0; + + /* TODO: we need to move those to the end, with if statements */ + ee->engine.x.state.modal = 0; + ee->engine.x.state.maximized_v = 0; + ee->engine.x.state.maximized_h = 0; + ee->engine.x.state.shaded = 0; + ee->engine.x.state.skip_taskbar = 0; + ee->engine.x.state.skip_pager = 0; + ee->prop.fullscreen = 0; + ee->engine.x.state.fullscreen = 0; + ee->engine.x.state.above = 0; + ee->engine.x.state.below = 0; #ifdef HAVE_ECORE_X_XCB ecore_x_netwm_window_state_get_fetch(); #endif /* HAVE_ECORE_X_XCB */ - ecore_x_netwm_window_state_get(e->win, &state, &num); - if (state) - { - for (i = 0; i < num; i++) - { - switch (state[i]) - { - case ECORE_X_WINDOW_STATE_MODAL: - ee->engine.x.state.modal = 1; - break; - case ECORE_X_WINDOW_STATE_STICKY: - if (ee->prop.sticky && ee->engine.x.state.sticky) - break; - - sticky = 1; - ee->prop.sticky = 1; - ee->engine.x.state.sticky = 1; - if (ee->func.fn_sticky) ee->func.fn_sticky(ee); - break; - case ECORE_X_WINDOW_STATE_MAXIMIZED_VERT: - ee->engine.x.state.maximized_v = 1; - break; - case ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ: - ee->engine.x.state.maximized_h = 1; - break; - case ECORE_X_WINDOW_STATE_SHADED: - ee->engine.x.state.shaded = 1; - break; - case ECORE_X_WINDOW_STATE_SKIP_TASKBAR: - ee->engine.x.state.skip_taskbar = 1; - break; - case ECORE_X_WINDOW_STATE_SKIP_PAGER: - ee->engine.x.state.skip_pager = 1; - break; - case ECORE_X_WINDOW_STATE_FULLSCREEN: - ee->prop.fullscreen = 1; - ee->engine.x.state.fullscreen = 1; - break; - case ECORE_X_WINDOW_STATE_ABOVE: - ee->engine.x.state.above = 1; - break; - case ECORE_X_WINDOW_STATE_BELOW: - ee->engine.x.state.below = 1; - break; - default: - break; - } - } - free(state); - } + ecore_x_netwm_window_state_get(e->win, &state, &num); + if (state) + { + for (i = 0; i < num; i++) + { + switch (state[i]) + { + case ECORE_X_WINDOW_STATE_MODAL: + ee->engine.x.state.modal = 1; + break; + case ECORE_X_WINDOW_STATE_STICKY: + if (ee->prop.sticky && ee->engine.x.state.sticky) + break; + + sticky = 1; + ee->prop.sticky = 1; + ee->engine.x.state.sticky = 1; + if (ee->func.fn_sticky) ee->func.fn_sticky(ee); + break; + case ECORE_X_WINDOW_STATE_MAXIMIZED_VERT: + ee->engine.x.state.maximized_v = 1; + break; + case ECORE_X_WINDOW_STATE_MAXIMIZED_HORZ: + ee->engine.x.state.maximized_h = 1; + break; + case ECORE_X_WINDOW_STATE_SHADED: + ee->engine.x.state.shaded = 1; + break; + case ECORE_X_WINDOW_STATE_SKIP_TASKBAR: + ee->engine.x.state.skip_taskbar = 1; + break; + case ECORE_X_WINDOW_STATE_SKIP_PAGER: + ee->engine.x.state.skip_pager = 1; + break; + case ECORE_X_WINDOW_STATE_FULLSCREEN: + ee->prop.fullscreen = 1; + ee->engine.x.state.fullscreen = 1; + break; + case ECORE_X_WINDOW_STATE_ABOVE: + ee->engine.x.state.above = 1; + break; + case ECORE_X_WINDOW_STATE_BELOW: + ee->engine.x.state.below = 1; + break; + default: + break; + } + } + free(state); + } #ifdef HAVE_ECORE_X_XCB ecore_xcb_reply_free(); #endif /* HAVE_ECORE_X_XCB */ - if (ee->prop.sticky && !sticky) - { - ee->prop.sticky = 0; - ee->engine.x.state.sticky = 0; - if (ee->func.fn_unsticky) ee->func.fn_unsticky(ee); - } + if (ee->prop.sticky && !sticky) + { + ee->prop.sticky = 0; + ee->engine.x.state.sticky = 0; + if (ee->func.fn_unsticky) ee->func.fn_unsticky(ee); + } } return ECORE_CALLBACK_PASS_ON; @@ -660,7 +713,7 @@ _ecore_evas_x_event_client_message(void *data __UNUSED__, int type __UNUSED__, v if (!ee->engine.x.sync_began) { // qeue a damage + draw. work around an event re-ordering thing. - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); } ee->engine.x.sync_began = 1; ee->engine.x.sync_cancel = 0; @@ -699,31 +752,31 @@ _ecore_evas_x_event_mouse_in(void *data __UNUSED__, int type __UNUSED__, void *e /* char *ct; */ /* const char *modes[] = { */ -/* "MODE_NORMAL", */ -/* "MODE_WHILE_GRABBED", */ -/* "MODE_GRAB", */ -/* "MODE_UNGRAB" */ +/* "MODE_NORMAL", */ +/* "MODE_WHILE_GRABBED", */ +/* "MODE_GRAB", */ +/* "MODE_UNGRAB" */ /* }; */ /* const char *details[] = { */ -/* "DETAIL_ANCESTOR", */ -/* "DETAIL_VIRTUAL", */ -/* "DETAIL_INFERIOR", */ -/* "DETAIL_NON_LINEAR", */ -/* "DETAIL_NON_LINEAR_VIRTUAL", */ -/* "DETAIL_POINTER", */ -/* "DETAIL_POINTER_ROOT", */ -/* "DETAIL_DETAIL_NONE" */ +/* "DETAIL_ANCESTOR", */ +/* "DETAIL_VIRTUAL", */ +/* "DETAIL_INFERIOR", */ +/* "DETAIL_NON_LINEAR", */ +/* "DETAIL_NON_LINEAR_VIRTUAL", */ +/* "DETAIL_POINTER", */ +/* "DETAIL_POINTER_ROOT", */ +/* "DETAIL_DETAIL_NONE" */ /* }; */ /* t = time(NULL); */ /* ct = ctime(&t); */ /* ct[strlen(ct) - 1] = 0; */ /* printf("@@ ->IN 0x%x 0x%x %s md=%s dt=%s\n", */ -/* e->win, e->event_win, */ -/* ct, */ -/* modes[e->mode], */ -/* details[e->detail]); */ +/* e->win, e->event_win, */ +/* ct, */ +/* modes[e->mode], */ +/* details[e->detail]); */ /* } */ - // disable. causes mroe problems than it fixes + // disable. causes more problems than it fixes // if ((e->mode == ECORE_X_EVENT_MODE_GRAB) || // (e->mode == ECORE_X_EVENT_MODE_UNGRAB)) // return 0; @@ -751,29 +804,29 @@ _ecore_evas_x_event_mouse_out(void *data __UNUSED__, int type __UNUSED__, void * /* char *ct; */ /* const char *modes[] = { */ -/* "MODE_NORMAL", */ -/* "MODE_WHILE_GRABBED", */ -/* "MODE_GRAB", */ -/* "MODE_UNGRAB" */ +/* "MODE_NORMAL", */ +/* "MODE_WHILE_GRABBED", */ +/* "MODE_GRAB", */ +/* "MODE_UNGRAB" */ /* }; */ /* const char *details[] = { */ -/* "DETAIL_ANCESTOR", */ -/* "DETAIL_VIRTUAL", */ -/* "DETAIL_INFERIOR", */ -/* "DETAIL_NON_LINEAR", */ -/* "DETAIL_NON_LINEAR_VIRTUAL", */ -/* "DETAIL_POINTER", */ -/* "DETAIL_POINTER_ROOT", */ -/* "DETAIL_DETAIL_NONE" */ +/* "DETAIL_ANCESTOR", */ +/* "DETAIL_VIRTUAL", */ +/* "DETAIL_INFERIOR", */ +/* "DETAIL_NON_LINEAR", */ +/* "DETAIL_NON_LINEAR_VIRTUAL", */ +/* "DETAIL_POINTER", */ +/* "DETAIL_POINTER_ROOT", */ +/* "DETAIL_DETAIL_NONE" */ /* }; */ /* t = time(NULL); */ /* ct = ctime(&t); */ /* ct[strlen(ct) - 1] = 0; */ /* printf("@@ ->OUT 0x%x 0x%x %s md=%s dt=%s\n", */ -/* e->win, e->event_win, */ -/* ct, */ -/* modes[e->mode], */ -/* details[e->detail]); */ +/* e->win, e->event_win, */ +/* ct, */ +/* modes[e->mode], */ +/* details[e->detail]); */ /* } */ // disable. causes more problems than it fixes // if ((e->mode == ECORE_X_EVENT_MODE_GRAB) || @@ -840,56 +893,56 @@ _ecore_evas_x_event_window_damage(void *data __UNUSED__, int type __UNUSED__, vo // printf("EXPOSE %p [%i] %i %i %ix%i\n", ee, ee->prop.avoid_damage, e->x, e->y, e->w, e->h); if (ee->prop.avoid_damage) { - Ecore_X_Rectangle rect; - Ecore_X_XRegion *tmpr; - - if (!ee->engine.x.damages) ee->engine.x.damages = ecore_x_xregion_new(); - tmpr = ecore_x_xregion_new(); - rect.x = e->x; - rect.y = e->y; - rect.width = e->w; - rect.height = e->h; - ecore_x_xregion_union_rect(tmpr, ee->engine.x.damages, &rect); - ecore_x_xregion_free(ee->engine.x.damages); - ee->engine.x.damages = tmpr; + Ecore_X_Rectangle rect; + Ecore_X_XRegion *tmpr; + + if (!ee->engine.x.damages) ee->engine.x.damages = ecore_x_xregion_new(); + tmpr = ecore_x_xregion_new(); + rect.x = e->x; + rect.y = e->y; + rect.width = e->w; + rect.height = e->h; + ecore_x_xregion_union_rect(tmpr, ee->engine.x.damages, &rect); + ecore_x_xregion_free(ee->engine.x.damages); + ee->engine.x.damages = tmpr; /* no - this breaks things badly. disable. Ecore_X_Rectangle != XRectangle - see * the typedefs in x's headers and ecore_x's. also same with Region - it's a pointer in x - not an X ID - Ecore_X_Rectangle rect; - Ecore_X_XRegion *tmpr; - - if (!ee->engine.x.damages) ee->engine.x.damages = ecore_x_xregion_new(); - tmpr = ecore_x_xregion_new(); - rect.x = e->x; - rect.y = e->y; - rect.width = e->w; - rect.height = e->h; - ecore_x_xregion_union_rect(tmpr, ee->engine.x.damages, &rect); - ecore_x_xregion_free(ee->engine.x.damages); - ee->engine.x.damages = tmpr; + Ecore_X_Rectangle rect; + Ecore_X_XRegion *tmpr; + + if (!ee->engine.x.damages) ee->engine.x.damages = ecore_x_xregion_new(); + tmpr = ecore_x_xregion_new(); + rect.x = e->x; + rect.y = e->y; + rect.width = e->w; + rect.height = e->h; + ecore_x_xregion_union_rect(tmpr, ee->engine.x.damages, &rect); + ecore_x_xregion_free(ee->engine.x.damages); + ee->engine.x.damages = tmpr; */ } else { - if (ee->rotation == 0) - evas_damage_rectangle_add(ee->evas, - e->x, - e->y, - e->w, e->h); - else if (ee->rotation == 90) - evas_damage_rectangle_add(ee->evas, - ee->h - e->y - e->h, - e->x, - e->h, e->w); - else if (ee->rotation == 180) - evas_damage_rectangle_add(ee->evas, - ee->w - e->x - e->w, - ee->h - e->y - e->h, - e->w, e->h); - else if (ee->rotation == 270) - evas_damage_rectangle_add(ee->evas, - e->y, - ee->w - e->x - e->w, - e->h, e->w); + if (ee->rotation == 0) + evas_damage_rectangle_add(ee->evas, + e->x, + e->y, + e->w, e->h); + else if (ee->rotation == 90) + evas_damage_rectangle_add(ee->evas, + ee->h - e->y - e->h, + e->x, + e->h, e->w); + else if (ee->rotation == 180) + evas_damage_rectangle_add(ee->evas, + ee->w - e->x - e->w, + ee->h - e->y - e->h, + e->w, e->h); + else if (ee->rotation == 270) + evas_damage_rectangle_add(ee->evas, + e->y, + ee->w - e->x - e->w, + e->h, e->w); } return ECORE_CALLBACK_PASS_ON; } @@ -924,52 +977,52 @@ _ecore_evas_x_event_window_configure(void *data __UNUSED__, int type __UNUSED__, if ((e->from_wm) || (ee->prop.override)) { - if ((ee->x != e->x) || (ee->y != e->y)) - { - ee->x = e->x; - ee->y = e->y; + if ((ee->x != e->x) || (ee->y != e->y)) + { + ee->x = e->x; + ee->y = e->y; ee->req.x = ee->x; ee->req.y = ee->y; - if (ee->func.fn_move) ee->func.fn_move(ee); - } + if (ee->func.fn_move) ee->func.fn_move(ee); + } } if ((ee->w != e->w) || (ee->h != e->h)) { - ee->w = e->w; - ee->h = e->h; + ee->w = e->w; + ee->h = e->h; ee->req.w = ee->w; ee->req.h = ee->h; - if ((ee->rotation == 90) || (ee->rotation == 270)) - { - evas_output_size_set(ee->evas, ee->h, ee->w); - evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); - } - else - { - evas_output_size_set(ee->evas, ee->w, ee->h); - evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); - } - if (ee->prop.avoid_damage) - { - int pdam; - - pdam = ecore_evas_avoid_damage_get(ee); - ecore_evas_avoid_damage_set(ee, 0); - ecore_evas_avoid_damage_set(ee, pdam); - } - if ((ee->shaped) || (ee->alpha)) - _ecore_evas_x_resize_shape(ee); - if ((ee->expecting_resize.w > 0) && - (ee->expecting_resize.h > 0)) - { - if ((ee->expecting_resize.w == ee->w) && - (ee->expecting_resize.h == ee->h)) - _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, - ecore_x_current_time_get()); - ee->expecting_resize.w = 0; - ee->expecting_resize.h = 0; - } - if (ee->func.fn_resize) ee->func.fn_resize(ee); + if ((ee->rotation == 90) || (ee->rotation == 270)) + { + evas_output_size_set(ee->evas, ee->h, ee->w); + evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); + } + else + { + evas_output_size_set(ee->evas, ee->w, ee->h); + evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); + } + if (ee->prop.avoid_damage) + { + int pdam; + + pdam = ecore_evas_avoid_damage_get(ee); + ecore_evas_avoid_damage_set(ee, 0); + ecore_evas_avoid_damage_set(ee, pdam); + } + if ((ee->shaped) || (ee->alpha)) + _ecore_evas_x_resize_shape(ee); + if ((ee->expecting_resize.w > 0) && + (ee->expecting_resize.h > 0)) + { + if ((ee->expecting_resize.w == ee->w) && + (ee->expecting_resize.h == ee->h)) + _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, + ecore_x_current_time_get()); + ee->expecting_resize.w = 0; + ee->expecting_resize.h = 0; + } + if (ee->func.fn_resize) ee->func.fn_resize(ee); } return ECORE_CALLBACK_PASS_ON; } @@ -1005,10 +1058,10 @@ _ecore_evas_x_event_window_show(void *data __UNUSED__, int type __UNUSED__, void first_map_bug = atoi(getenv("ECORE_EVAS_GL_FIRST_MAP_BUG")); else first_map_bug = 0; - if ((first_map_bug) && - (!strcmp(ee->driver, "opengl_x11"))) - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); } + if ((first_map_bug) && + (!strcmp(ee->driver, "opengl_x11"))) + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); if (ee->visible) return ECORE_CALLBACK_DONE; // printf("SHOW EVENT %p\n", ee); ee->visible = 1; @@ -1043,18 +1096,18 @@ _ecore_evas_x_size_pos_hints_update(Ecore_Evas *ee) ecore_x_icccm_size_pos_hints_get_fetch(); # endif /* HAVE_ECORE_X_XCB */ ecore_x_icccm_size_pos_hints_set(ee->prop.window, - ee->prop.request_pos /*request_pos */, - ECORE_X_GRAVITY_NW /* gravity */, - ee->prop.min.w /* min_w */, - ee->prop.min.h /* min_h */, - ee->prop.max.w /* max_w */, - ee->prop.max.h /* max_h */, - ee->prop.base.w /* base_w */, - ee->prop.base.h /* base_h */, - ee->prop.step.w /* step_x */, - ee->prop.step.h /* step_y */, - 0 /* min_aspect */, - 0 /* max_aspect */); + ee->prop.request_pos /*request_pos */, + ECORE_X_GRAVITY_NW /* gravity */, + ee->prop.min.w /* min_w */, + ee->prop.min.h /* min_h */, + ee->prop.max.w /* max_w */, + ee->prop.max.h /* max_h */, + ee->prop.base.w /* base_w */, + ee->prop.base.h /* base_h */, + ee->prop.step.w /* step_x */, + ee->prop.step.h /* step_y */, + 0 /* min_aspect */, + 0 /* max_aspect */); # ifdef HAVE_ECORE_X_XCB ecore_xcb_reply_free(); # endif /* HAVE_ECORE_X_XCB */ @@ -1104,90 +1157,90 @@ _ecore_evas_x_layer_update(Ecore_Evas *ee) { if (ee->should_be_visible) { - /* We need to send a netwm request to the wm */ - /* FIXME: Do we have to remove old state before adding new? */ - if (ee->prop.layer < 3) - { - if (ee->engine.x.state.above) - { - ee->engine.x.state.above = 0; - ecore_x_netwm_state_request_send(ee->prop.window, - ee->engine.x.win_root, - ECORE_X_WINDOW_STATE_ABOVE, -1, 0); - } - if (!ee->engine.x.state.below) - { - ee->engine.x.state.below = 1; - ecore_x_netwm_state_request_send(ee->prop.window, - ee->engine.x.win_root, - ECORE_X_WINDOW_STATE_BELOW, -1, 1); - } - } - else if (ee->prop.layer > 5) - { - if (ee->engine.x.state.below) - { - ee->engine.x.state.below = 0; - ecore_x_netwm_state_request_send(ee->prop.window, - ee->engine.x.win_root, - ECORE_X_WINDOW_STATE_BELOW, -1, 0); - } - if (!ee->engine.x.state.above) - { - ee->engine.x.state.above = 1; - ecore_x_netwm_state_request_send(ee->prop.window, - ee->engine.x.win_root, - ECORE_X_WINDOW_STATE_ABOVE, -1, 1); - } - } - else - { - if (ee->engine.x.state.below) - { - ee->engine.x.state.below = 0; - ecore_x_netwm_state_request_send(ee->prop.window, - ee->engine.x.win_root, - ECORE_X_WINDOW_STATE_BELOW, -1, 0); - } - if (ee->engine.x.state.above) - { - ee->engine.x.state.above = 0; - ecore_x_netwm_state_request_send(ee->prop.window, - ee->engine.x.win_root, - ECORE_X_WINDOW_STATE_ABOVE, -1, 0); - } - } + /* We need to send a netwm request to the wm */ + /* FIXME: Do we have to remove old state before adding new? */ + if (ee->prop.layer < 3) + { + if (ee->engine.x.state.above) + { + ee->engine.x.state.above = 0; + ecore_x_netwm_state_request_send(ee->prop.window, + ee->engine.x.win_root, + ECORE_X_WINDOW_STATE_ABOVE, -1, 0); + } + if (!ee->engine.x.state.below) + { + ee->engine.x.state.below = 1; + ecore_x_netwm_state_request_send(ee->prop.window, + ee->engine.x.win_root, + ECORE_X_WINDOW_STATE_BELOW, -1, 1); + } + } + else if (ee->prop.layer > 5) + { + if (ee->engine.x.state.below) + { + ee->engine.x.state.below = 0; + ecore_x_netwm_state_request_send(ee->prop.window, + ee->engine.x.win_root, + ECORE_X_WINDOW_STATE_BELOW, -1, 0); + } + if (!ee->engine.x.state.above) + { + ee->engine.x.state.above = 1; + ecore_x_netwm_state_request_send(ee->prop.window, + ee->engine.x.win_root, + ECORE_X_WINDOW_STATE_ABOVE, -1, 1); + } + } + else + { + if (ee->engine.x.state.below) + { + ee->engine.x.state.below = 0; + ecore_x_netwm_state_request_send(ee->prop.window, + ee->engine.x.win_root, + ECORE_X_WINDOW_STATE_BELOW, -1, 0); + } + if (ee->engine.x.state.above) + { + ee->engine.x.state.above = 0; + ecore_x_netwm_state_request_send(ee->prop.window, + ee->engine.x.win_root, + ECORE_X_WINDOW_STATE_ABOVE, -1, 0); + } + } } else { - /* Just set the state */ - if (ee->prop.layer < 3) - { - if ((ee->engine.x.state.above) || (!ee->engine.x.state.below)) - { - ee->engine.x.state.above = 0; - ee->engine.x.state.below = 1; - _ecore_evas_x_state_update(ee); - } - } - else if (ee->prop.layer > 5) - { - if ((!ee->engine.x.state.above) || (ee->engine.x.state.below)) - { - ee->engine.x.state.above = 1; - ee->engine.x.state.below = 0; - _ecore_evas_x_state_update(ee); - } - } - else - { - if ((ee->engine.x.state.above) || (ee->engine.x.state.below)) - { - ee->engine.x.state.above = 0; - ee->engine.x.state.below = 0; - _ecore_evas_x_state_update(ee); - } - } + /* Just set the state */ + if (ee->prop.layer < 3) + { + if ((ee->engine.x.state.above) || (!ee->engine.x.state.below)) + { + ee->engine.x.state.above = 0; + ee->engine.x.state.below = 1; + _ecore_evas_x_state_update(ee); + } + } + else if (ee->prop.layer > 5) + { + if ((!ee->engine.x.state.above) || (ee->engine.x.state.below)) + { + ee->engine.x.state.above = 1; + ee->engine.x.state.below = 0; + _ecore_evas_x_state_update(ee); + } + } + else + { + if ((ee->engine.x.state.above) || (ee->engine.x.state.below)) + { + ee->engine.x.state.above = 0; + ee->engine.x.state.below = 0; + _ecore_evas_x_state_update(ee); + } + } } /* FIXME: Set gnome layer */ } @@ -1217,6 +1270,7 @@ _ecore_evas_x_init(void) static void _ecore_evas_x_free(Ecore_Evas *ee) { + _ecore_evas_x_group_leader_unset(ee); _ecore_evas_x_sync_set(ee); ecore_x_window_free(ee->prop.window); if (ee->engine.x.pmap) ecore_x_pixmap_free(ee->engine.x.pmap); @@ -1230,12 +1284,12 @@ _ecore_evas_x_free(Ecore_Evas *ee) ecore_event_window_unregister(ee->prop.window); while (ee->engine.x.win_extra) { - Ecore_X_Window *winp; + Ecore_X_Window *winp; - winp = ee->engine.x.win_extra->data; - ee->engine.x.win_extra = eina_list_remove_list(ee->engine.x.win_extra, ee->engine.x.win_extra); - ecore_event_window_unregister(*winp); - free(winp); + winp = ee->engine.x.win_extra->data; + ee->engine.x.win_extra = eina_list_remove_list(ee->engine.x.win_extra, ee->engine.x.win_extra); + ecore_event_window_unregister(*winp); + free(winp); } _ecore_evas_x_shutdown(); ecore_x_shutdown(); @@ -1256,37 +1310,37 @@ _ecore_evas_x_move(Ecore_Evas *ee, int x, int y) ee->req.y = y; if (ee->engine.x.direct_resize) { - if (!ee->engine.x.managed) - { - if ((x != ee->x) || (y != ee->y)) - { - ee->x = x; - ee->y = y; - ecore_x_window_move(ee->prop.window, x, y); - if (!ee->should_be_visible) - { - /* We need to request pos */ - ee->prop.request_pos = 1; - _ecore_evas_x_size_pos_hints_update(ee); - } - if (ee->func.fn_move) ee->func.fn_move(ee); - } - } + if (!ee->engine.x.managed) + { + if ((x != ee->x) || (y != ee->y)) + { + ee->x = x; + ee->y = y; + ecore_x_window_move(ee->prop.window, x, y); + if (!ee->should_be_visible) + { + /* We need to request pos */ + ee->prop.request_pos = 1; + _ecore_evas_x_size_pos_hints_update(ee); + } + if (ee->func.fn_move) ee->func.fn_move(ee); + } + } } else { - ecore_x_window_move(ee->prop.window, x, y); - if (!ee->should_be_visible) - { - /* We need to request pos */ - ee->prop.request_pos = 1; - _ecore_evas_x_size_pos_hints_update(ee); - } - if (!ee->engine.x.managed) - { - ee->x = x; - ee->y = y; - } + ecore_x_window_move(ee->prop.window, x, y); + if (!ee->should_be_visible) + { + /* We need to request pos */ + ee->prop.request_pos = 1; + _ecore_evas_x_size_pos_hints_update(ee); + } + if (!ee->engine.x.managed) + { + ee->x = x; + ee->y = y; + } } } @@ -1297,13 +1351,13 @@ _ecore_evas_x_managed_move(Ecore_Evas *ee, int x, int y) ee->req.y = y; if (ee->engine.x.direct_resize) { - ee->engine.x.managed = 1; - if ((x != ee->x) || (y != ee->y)) - { - ee->x = x; - ee->y = y; - if (ee->func.fn_move) ee->func.fn_move(ee); - } + ee->engine.x.managed = 1; + if ((x != ee->x) || (y != ee->y)) + { + ee->x = x; + ee->y = y; + if (ee->func.fn_move) ee->func.fn_move(ee); + } } } @@ -1314,33 +1368,33 @@ _ecore_evas_x_resize(Ecore_Evas *ee, int w, int h) ee->req.h = h; if (ee->engine.x.direct_resize) { - if ((ee->w != w) || (ee->h != h)) - { - ecore_x_window_resize(ee->prop.window, w, h); - ee->w = w; - ee->h = h; - if ((ee->rotation == 90) || (ee->rotation == 270)) - { - evas_output_size_set(ee->evas, ee->h, ee->w); - evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); - } - else - { - evas_output_size_set(ee->evas, ee->w, ee->h); - evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); - } - if (ee->prop.avoid_damage) - { - int pdam; - - pdam = ecore_evas_avoid_damage_get(ee); - ecore_evas_avoid_damage_set(ee, 0); - ecore_evas_avoid_damage_set(ee, pdam); - } - if ((ee->shaped) || (ee->alpha)) - _ecore_evas_x_resize_shape(ee); - if (ee->func.fn_resize) ee->func.fn_resize(ee); - } + if ((ee->w != w) || (ee->h != h)) + { + ecore_x_window_resize(ee->prop.window, w, h); + ee->w = w; + ee->h = h; + if ((ee->rotation == 90) || (ee->rotation == 270)) + { + evas_output_size_set(ee->evas, ee->h, ee->w); + evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); + } + else + { + evas_output_size_set(ee->evas, ee->w, ee->h); + evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); + } + if (ee->prop.avoid_damage) + { + int pdam; + + pdam = ecore_evas_avoid_damage_get(ee); + ecore_evas_avoid_damage_set(ee, 0); + ecore_evas_avoid_damage_set(ee, pdam); + } + if ((ee->shaped) || (ee->alpha)) + _ecore_evas_x_resize_shape(ee); + if (ee->func.fn_resize) ee->func.fn_resize(ee); + } } else ecore_x_window_resize(ee->prop.window, w, h); @@ -1355,67 +1409,67 @@ _ecore_evas_x_move_resize(Ecore_Evas *ee, int x, int y, int w, int h) ee->req.h = h; if (ee->engine.x.direct_resize) { - if ((ee->w != w) || (ee->h != h) || (x != ee->x) || (y != ee->y)) - { - int change_size = 0, change_pos = 0; - - if ((ee->w != w) || (ee->h != h)) change_size = 1; - if (!ee->engine.x.managed) - { - if ((x != ee->x) || (y != ee->y)) change_pos = 1; - } - ecore_x_window_move_resize(ee->prop.window, x, y, w, h); - if (!ee->engine.x.managed) - { - ee->x = x; - ee->y = y; - } - ee->w = w; - ee->h = h; - if ((ee->rotation == 90) || (ee->rotation == 270)) - { - evas_output_size_set(ee->evas, ee->h, ee->w); - evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); - } - else - { - evas_output_size_set(ee->evas, ee->w, ee->h); - evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); - } - if (ee->prop.avoid_damage) - { - int pdam; - - pdam = ecore_evas_avoid_damage_get(ee); - ecore_evas_avoid_damage_set(ee, 0); - ecore_evas_avoid_damage_set(ee, pdam); - } - if ((ee->shaped) || (ee->alpha)) - _ecore_evas_x_resize_shape(ee); - if (change_pos) - { - if (ee->func.fn_move) ee->func.fn_move(ee); - } - if (change_size) - { - if (ee->func.fn_resize) ee->func.fn_resize(ee); - } - } + if ((ee->w != w) || (ee->h != h) || (x != ee->x) || (y != ee->y)) + { + int change_size = 0, change_pos = 0; + + if ((ee->w != w) || (ee->h != h)) change_size = 1; + if (!ee->engine.x.managed) + { + if ((x != ee->x) || (y != ee->y)) change_pos = 1; + } + ecore_x_window_move_resize(ee->prop.window, x, y, w, h); + if (!ee->engine.x.managed) + { + ee->x = x; + ee->y = y; + } + ee->w = w; + ee->h = h; + if ((ee->rotation == 90) || (ee->rotation == 270)) + { + evas_output_size_set(ee->evas, ee->h, ee->w); + evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); + } + else + { + evas_output_size_set(ee->evas, ee->w, ee->h); + evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); + } + if (ee->prop.avoid_damage) + { + int pdam; + + pdam = ecore_evas_avoid_damage_get(ee); + ecore_evas_avoid_damage_set(ee, 0); + ecore_evas_avoid_damage_set(ee, pdam); + } + if ((ee->shaped) || (ee->alpha)) + _ecore_evas_x_resize_shape(ee); + if (change_pos) + { + if (ee->func.fn_move) ee->func.fn_move(ee); + } + if (change_size) + { + if (ee->func.fn_resize) ee->func.fn_resize(ee); + } + } } else { - ecore_x_window_move_resize(ee->prop.window, x, y, w, h); - if (!ee->engine.x.managed) - { - ee->x = x; - ee->y = y; - } + ecore_x_window_move_resize(ee->prop.window, x, y, w, h); + if (!ee->engine.x.managed) + { + ee->x = x; + ee->y = y; + } } } static void _ecore_evas_x_rotation_set_internal(Ecore_Evas *ee, int rotation, int resize, - Evas_Engine_Info *einfo) + Evas_Engine_Info *einfo) { int rot_dif; @@ -1424,14 +1478,14 @@ _ecore_evas_x_rotation_set_internal(Ecore_Evas *ee, int rotation, int resize, if (rot_dif != 180) { - int minw, minh, maxw, maxh, basew, baseh, stepw, steph; + int minw, minh, maxw, maxh, basew, baseh, stepw, steph; - if (!evas_engine_info_set(ee->evas, einfo)) + if (!evas_engine_info_set(ee->evas, einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - if (!resize) + if (!resize) { if (!ee->prop.fullscreen) { @@ -1462,49 +1516,49 @@ _ecore_evas_x_rotation_set_internal(Ecore_Evas *ee, int rotation, int resize, else evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h); } - else + else { - int w, h; + int w, h; - ecore_x_window_size_get(ee->prop.window, &w, &h); - if ((rotation == 0) || (rotation == 180)) - { - evas_output_size_set(ee->evas, ee->w, ee->h); - evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); - } - else - { - evas_output_size_set(ee->evas, ee->h, ee->w); - evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); - } - if (ee->func.fn_resize) ee->func.fn_resize(ee); + ecore_x_window_size_get(ee->prop.window, &w, &h); + if ((rotation == 0) || (rotation == 180)) + { + evas_output_size_set(ee->evas, ee->w, ee->h); + evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h); + } + else + { + evas_output_size_set(ee->evas, ee->h, ee->w); + evas_output_viewport_set(ee->evas, 0, 0, ee->h, ee->w); + } + if (ee->func.fn_resize) ee->func.fn_resize(ee); if ((ee->rotation == 90) || (ee->rotation == 270)) evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); else evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); } - ecore_evas_size_min_get(ee, &minw, &minh); - ecore_evas_size_max_get(ee, &maxw, &maxh); - ecore_evas_size_base_get(ee, &basew, &baseh); - ecore_evas_size_step_get(ee, &stepw, &steph); - ee->rotation = rotation; - ecore_evas_size_min_set(ee, minh, minw); - ecore_evas_size_max_set(ee, maxh, maxw); - ecore_evas_size_base_set(ee, baseh, basew); - ecore_evas_size_step_set(ee, steph, stepw); - _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, - ecore_x_current_time_get()); + ecore_evas_size_min_get(ee, &minw, &minh); + ecore_evas_size_max_get(ee, &maxw, &maxh); + ecore_evas_size_base_get(ee, &basew, &baseh); + ecore_evas_size_step_get(ee, &stepw, &steph); + ee->rotation = rotation; + ecore_evas_size_min_set(ee, minh, minw); + ecore_evas_size_max_set(ee, maxh, maxw); + ecore_evas_size_base_set(ee, baseh, basew); + ecore_evas_size_step_set(ee, steph, stepw); + _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, + ecore_x_current_time_get()); } else { - if (!evas_engine_info_set(ee->evas, einfo)) + if (!evas_engine_info_set(ee->evas, einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - ee->rotation = rotation; - _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, - ecore_x_current_time_get()); - if (ee->func.fn_resize) ee->func.fn_resize(ee); + ee->rotation = rotation; + _ecore_evas_mouse_move_process(ee, ee->mouse.x, ee->mouse.y, + ecore_x_current_time_get()); + if (ee->func.fn_resize) ee->func.fn_resize(ee); if ((ee->rotation == 90) || (ee->rotation == 270)) evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); @@ -1513,128 +1567,59 @@ _ecore_evas_x_rotation_set_internal(Ecore_Evas *ee, int rotation, int resize, } } -/* added by gl77.lee 101001 - for EFL rotation effect */ -#define _USE_WIN_ROT_EFFECT 1 - -#if _USE_WIN_ROT_EFFECT -static void _ecore_evas_x_flush_pre(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__); - -typedef struct _Ecore_Evas_X_Rotation_Effect Ecore_Evas_X_Rotation_Effect; -struct _Ecore_Evas_X_Rotation_Effect -{ - Eina_Bool wait_for_comp_reply; -}; - -static Ecore_Evas_X_Rotation_Effect _rot_effect = -{ - EINA_FALSE -}; - -static void -_ecore_evas_x_rotation_effect_setup(void) -{ - _rot_effect.wait_for_comp_reply = EINA_TRUE; -} -#endif /* end of _USE_WIN_ROT_EFFECT */ - static void _ecore_evas_x_rotation_set(Ecore_Evas *ee, int rotation, int resize) { if (ee->rotation == rotation) return; if (!strcmp(ee->driver, "xrender_x11")) return; - - #if _USE_WIN_ROT_EFFECT - int angles[2]; - angles[0] = rotation; - angles[1] = ee->rotation; - #endif /* end of _USE_WIN_ROT_EFFECT */ - if (!strcmp(ee->driver, "opengl_x11")) { #ifdef BUILD_ECORE_EVAS_OPENGL_X11 - Evas_Engine_Info_GL_X11 *einfo; - - einfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(ee->evas); - if (!einfo) return; - einfo->info.rotation = rotation; - _ecore_evas_x_rotation_set_internal - (ee, rotation, resize, (Evas_Engine_Info *)einfo); - - /* added by doyoun.kang 100218 - for rotation */ - #if _USE_WIN_ROT_EFFECT - ecore_x_window_prop_property_set (ee->prop.window, - ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE, - ECORE_X_ATOM_CARDINAL, 32, &angles, 2); - #else - ecore_x_window_prop_property_set (ee->prop.window, - ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE, - ECORE_X_ATOM_CARDINAL, 32, &rotation, 1); - #endif + Evas_Engine_Info_GL_X11 *einfo; + + einfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(ee->evas); + if (!einfo) return; + einfo->info.rotation = rotation; + _ecore_evas_x_rotation_set_internal + (ee, rotation, resize, (Evas_Engine_Info *)einfo); #endif /* BUILD_ECORE_EVAS_OPENGL_X11 */ } else if (!strcmp(ee->driver, "software_x11")) { #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11 - Evas_Engine_Info_Software_X11 *einfo; - - einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas); - if (!einfo) return; - einfo->info.rotation = rotation; - _ecore_evas_x_rotation_set_internal - (ee, rotation, resize, (Evas_Engine_Info *)einfo); - - /* added by doyoun.kang 100218 - for rotation */ - #if _USE_WIN_ROT_EFFECT - ecore_x_window_prop_property_set (ee->prop.window, - ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE, - ECORE_X_ATOM_CARDINAL, 32, &angles, 2); - #else - ecore_x_window_prop_property_set (ee->prop.window, - ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE, - ECORE_X_ATOM_CARDINAL, 32, &rotation, 1); - #endif + Evas_Engine_Info_Software_X11 *einfo; + + einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas); + if (!einfo) return; + einfo->info.rotation = rotation; + _ecore_evas_x_rotation_set_internal + (ee, rotation, resize, (Evas_Engine_Info *)einfo); #endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */ } else if (!strcmp(ee->driver, "software_16_x11")) { #if BUILD_ECORE_EVAS_SOFTWARE_16_X11 - Evas_Engine_Info_Software_16_X11 *einfo; - - einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas); - if (!einfo) return; - einfo->info.rotation = rotation; - _ecore_evas_x_rotation_set_internal - (ee, rotation, resize, (Evas_Engine_Info *)einfo); - - /* added by doyoun.kang 100218 - for rotation */ - #if _USE_WIN_ROT_EFFECT - ecore_x_window_prop_property_set (ee->prop.window, - ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE, - ECORE_X_ATOM_CARDINAL, 32, &angles, 2); - #else - ecore_x_window_prop_property_set (ee->prop.window, - ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE, - ECORE_X_ATOM_CARDINAL, 32, &rotation, 1); - #endif + Evas_Engine_Info_Software_16_X11 *einfo; + + einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas); + if (!einfo) return; + einfo->info.rotation = rotation; + _ecore_evas_x_rotation_set_internal + (ee, rotation, resize, (Evas_Engine_Info *)einfo); #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */ } else if (!strcmp(ee->driver, "software_8_x11")) { #if BUILD_ECORE_EVAS_SOFTWARE_8_X11 - Evas_Engine_Info_Software_8_X11 *einfo; + Evas_Engine_Info_Software_8_X11 *einfo; - einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas); - if (!einfo) return; - einfo->info.rotation = rotation; - _ecore_evas_x_rotation_set_internal - (ee, rotation, resize, (Evas_Engine_Info *)einfo); + einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas); + if (!einfo) return; + einfo->info.rotation = rotation; + _ecore_evas_x_rotation_set_internal + (ee, rotation, resize, (Evas_Engine_Info *)einfo); #endif /* BUILD_ECORE_EVAS_SOFTWARE_8_X11 */ } - - #if _USE_WIN_ROT_EFFECT - _ecore_evas_x_rotation_effect_setup(); - _ecore_evas_x_flush_pre(ee, NULL, NULL); - #endif /* end of _USE_WIN_ROT_EFFECT */ } static void @@ -1646,19 +1631,19 @@ _ecore_evas_x_shaped_set(Ecore_Evas *ee, int shaped) if (!strcmp(ee->driver, "software_x11")) { #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11 - Evas_Engine_Info_Software_X11 *einfo; - - einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas); - ee->shaped = shaped; - if (einfo) - { - if (ee->shaped) - { + Evas_Engine_Info_Software_X11 *einfo; + + einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas); + ee->shaped = shaped; + if (einfo) + { + if (ee->shaped) + { unsigned int foreground; Ecore_X_GC gc; - if (!ee->engine.x.mask) - ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1); + if (!ee->engine.x.mask) + ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1); foreground = 0; gc = ecore_x_gc_new(ee->engine.x.mask, ECORE_X_GC_VALUE_MASK_FOREGROUND, @@ -1666,42 +1651,45 @@ _ecore_evas_x_shaped_set(Ecore_Evas *ee, int shaped) ecore_x_drawable_rectangle_fill(ee->engine.x.mask, gc, 0, 0, ee->w, ee->h); ecore_x_gc_free(gc); - einfo->info.mask = ee->engine.x.mask; - if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + einfo->info.mask = ee->engine.x.mask; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + ecore_x_window_shape_input_mask_set(ee->prop.window, 0); + } + else + { + if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); + ee->engine.x.mask = 0; + einfo->info.mask = 0; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); - ecore_x_window_shape_input_mask_set(ee->prop.window, 0); - } - else - { - if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); - ee->engine.x.mask = 0; - einfo->info.mask = 0; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); - ecore_x_window_shape_mask_set(ee->prop.window, 0); - ecore_x_window_shape_input_mask_set(ee->prop.window, 0); - } - } + ecore_x_window_shape_mask_set(ee->prop.window, 0); + ecore_x_window_shape_input_mask_set(ee->prop.window, 0); + } + } #endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */ } else if (!strcmp(ee->driver, "xrender_x11")) { #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB) - Evas_Engine_Info_XRender_X11 *einfo; - - ee->shaped = shaped; - einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas); - if (einfo) - { - if (ee->shaped) - { + Evas_Engine_Info_XRender_X11 *einfo; + + ee->shaped = shaped; + einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas); + if (einfo) + { + if (ee->shaped) + { unsigned int foreground; Ecore_X_GC gc; - if (!ee->engine.x.mask) - ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1); + if (!ee->engine.x.mask) + ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1); foreground = 0; gc = ecore_x_gc_new(ee->engine.x.mask, ECORE_X_GC_VALUE_MASK_FOREGROUND, @@ -1709,83 +1697,83 @@ _ecore_evas_x_shaped_set(Ecore_Evas *ee, int shaped) ecore_x_drawable_rectangle_fill(ee->engine.x.mask, gc, 0, 0, ee->w, ee->h); ecore_x_gc_free(gc); - einfo->info.mask = ee->engine.x.mask; - if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + einfo->info.mask = ee->engine.x.mask; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); - ecore_x_window_shape_input_mask_set(ee->prop.window, 0); - } - else - { - if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); - ee->engine.x.mask = 0; - einfo->info.mask = 0; - if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + ecore_x_window_shape_input_mask_set(ee->prop.window, 0); + } + else + { + if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); + ee->engine.x.mask = 0; + einfo->info.mask = 0; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - ecore_x_window_shape_mask_set(ee->prop.window, 0); - ecore_x_window_shape_input_mask_set(ee->prop.window, 0); - } - } + ecore_x_window_shape_mask_set(ee->prop.window, 0); + ecore_x_window_shape_input_mask_set(ee->prop.window, 0); + } + } #endif /* BUILD_ECORE_EVAS_XRENDER_X11 || BUILD_ECORE_EVAS_XRENDER_XCB */ } else if (!strcmp(ee->driver, "software_16_x11")) { #if BUILD_ECORE_EVAS_SOFTWARE_16_X11 # if 0 /* XXX no shaped window support for software_16_x11 */ - Evas_Engine_Info_Software_16_X11 *einfo; - - einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas); - ee->shaped = shaped; - if (einfo) - { - if (ee->shaped) - { - GC gc; - XGCValues gcv; - - ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1); - einfo->info.mask = ee->engine.x.mask; - if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + Evas_Engine_Info_Software_16_X11 *einfo; + + einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas); + ee->shaped = shaped; + if (einfo) + { + if (ee->shaped) + { + GC gc; + XGCValues gcv; + + ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1); + einfo->info.mask = ee->engine.x.mask; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); - } - else - { - if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); - ee->engine.x.mask = 0; - einfo->info.mask = 0; - if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + } + else + { + if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); + ee->engine.x.mask = 0; + einfo->info.mask = 0; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - ecore_x_window_shape_mask_set(ee->prop.window, 0); - } - } + ecore_x_window_shape_mask_set(ee->prop.window, 0); + } + } # endif /* XXX no shaped window support for software_16_x11 */ #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */ } if (!strcmp(ee->driver, "software_8_x11")) { #if defined (BUILD_ECORE_EVAS_SOFTWARE_8_X11) - Evas_Engine_Info_Software_8_X11 *einfo; - - einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas); - ee->shaped = shaped; - if (einfo) - { - if (ee->shaped) - { + Evas_Engine_Info_Software_8_X11 *einfo; + + einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas); + ee->shaped = shaped; + if (einfo) + { + if (ee->shaped) + { unsigned int foreground; Ecore_X_GC gc; - if (!ee->engine.x.mask) - ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1); + if (!ee->engine.x.mask) + ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 1); foreground = 0; gc = ecore_x_gc_new(ee->engine.x.mask, ECORE_X_GC_VALUE_MASK_FOREGROUND, @@ -1793,24 +1781,27 @@ _ecore_evas_x_shaped_set(Ecore_Evas *ee, int shaped) ecore_x_drawable_rectangle_fill(ee->engine.x.mask, gc, 0, 0, ee->w, ee->h); ecore_x_gc_free(gc); - einfo->info.mask = ee->engine.x.mask; - if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + einfo->info.mask = ee->engine.x.mask; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); + } + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + ecore_x_window_shape_input_mask_set(ee->prop.window, 0); + } + else + { + if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); + ee->engine.x.mask = 0; + einfo->info.mask = 0; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); - ecore_x_window_shape_input_mask_set(ee->prop.window, 0); - } - else - { - if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); - ee->engine.x.mask = 0; - einfo->info.mask = 0; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); - ecore_x_window_shape_mask_set(ee->prop.window, 0); - ecore_x_window_shape_input_mask_set(ee->prop.window, 0); - } - } + ecore_x_window_shape_mask_set(ee->prop.window, 0); + ecore_x_window_shape_input_mask_set(ee->prop.window, 0); + } + } #endif /* BUILD_ECORE_EVAS_SOFTWARE_8_X11 */ } } @@ -1834,86 +1825,88 @@ _ecore_evas_x_alpha_set(Ecore_Evas *ee, int alpha) if (!strcmp(ee->driver, "software_x11")) { #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11 - Evas_Engine_Info_Software_X11 *einfo; - - einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas); - if (!einfo) return; - - if (!ecore_x_composite_query()) return; - - ee->shaped = 0; - ee->alpha = alpha; - ecore_x_window_free(ee->prop.window); - ecore_event_window_unregister(ee->prop.window); - if (ee->alpha) - { - if (ee->prop.override) - ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - else - ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - if (!ee->engine.x.mask) - ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->req.w, ee->req.h, 1); - } - else - { - if (ee->prop.override) - ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - else - ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); - ee->engine.x.mask = 0; - ecore_x_window_shape_input_mask_set(ee->prop.window, 0); - } - - einfo->info.destination_alpha = alpha; + Evas_Engine_Info_Software_X11 *einfo; + + einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas); + if (!einfo) return; + + if (!ecore_x_composite_query()) return; + + ee->shaped = 0; + ee->alpha = alpha; + ecore_x_window_free(ee->prop.window); + ecore_event_window_unregister(ee->prop.window); + if (ee->alpha) + { + if (ee->prop.override) + ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + else + ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + if (!ee->engine.x.mask) + ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->req.w, ee->req.h, 1); + } + else + { + if (ee->prop.override) + ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + else + ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); + ee->engine.x.mask = 0; + ecore_x_window_shape_input_mask_set(ee->prop.window, 0); + } + + einfo->info.destination_alpha = alpha; # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB - cookie_geom = xcb_get_geometry_unchecked(ecore_x_connection_get(), ee->prop.window); - cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window); - - reply_geom = xcb_get_geometry_reply(ecore_x_connection_get(), cookie_geom, NULL); - reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL); - einfo->info.visual = xcb_visualtype_get(ecore_x_default_screen_get(), reply_attr->visual); - einfo->info.colormap = reply_attr->colormap; - einfo->info.depth = reply_geom->depth; - free(reply_geom); - free(reply_attr); + cookie_geom = xcb_get_geometry_unchecked(ecore_x_connection_get(), ee->prop.window); + cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window); + + reply_geom = xcb_get_geometry_reply(ecore_x_connection_get(), cookie_geom, NULL); + reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL); + einfo->info.visual = xcb_visualtype_get(ecore_x_default_screen_get(), reply_attr->visual); + einfo->info.colormap = reply_attr->colormap; + einfo->info.depth = reply_geom->depth; + free(reply_geom); + free(reply_attr); # else - XGetWindowAttributes(ecore_x_display_get(), ee->prop.window, &att); - einfo->info.visual = att.visual; - einfo->info.colormap = att.colormap; - einfo->info.depth = att.depth; + XGetWindowAttributes(ecore_x_display_get(), ee->prop.window, &att); + einfo->info.visual = att.visual; + einfo->info.colormap = att.colormap; + einfo->info.depth = att.depth; # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */ -// if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); -// ee->engine.x.mask = 0; - einfo->info.mask = ee->engine.x.mask; - einfo->info.drawable = ee->prop.window; +// if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); +// ee->engine.x.mask = 0; + einfo->info.mask = ee->engine.x.mask; + einfo->info.drawable = ee->prop.window; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h); - ecore_x_window_shape_mask_set(ee->prop.window, 0); + evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h); + ecore_x_window_shape_mask_set(ee->prop.window, 0); ecore_x_input_multi_select(ee->prop.window); - ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process); - if (ee->prop.borderless) - ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless); - if (ee->visible) ecore_x_window_show(ee->prop.window); - if (ee->prop.focused) ecore_x_window_focus(ee->prop.window); - if (ee->prop.title) - { - ecore_x_icccm_title_set(ee->prop.window, ee->prop.title); - ecore_x_netwm_name_set(ee->prop.window, ee->prop.title); - } - ecore_x_icccm_hints_set(ee->prop.window, - 1 /* accepts_focus */, - ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */, - 0 /* icon_pixmap */, - 0 /* icon_mask */, - 0 /* icon_window */, - 0 /* window_group */, - 0 /* is_urgent */); + ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process); + if (ee->prop.borderless) + ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless); + if (ee->visible) ecore_x_window_show(ee->prop.window); + if (ee->prop.focused) ecore_x_window_focus(ee->prop.window); + if (ee->prop.title) + { + ecore_x_icccm_title_set(ee->prop.window, ee->prop.title); + ecore_x_netwm_name_set(ee->prop.window, ee->prop.title); + } + ecore_x_icccm_hints_set(ee->prop.window, + 1 /* accepts_focus */, + ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */, + 0 /* icon_pixmap */, + 0 /* icon_mask */, + 0 /* icon_window */, + 0 /* window_group */, + 0 /* is_urgent */); + _ecore_evas_x_group_leader_update(ee); + ecore_x_window_defaults_set(ee->prop.window); _ecore_evas_x_protocols_set(ee); _ecore_evas_x_sync_set(ee); #endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */ @@ -1924,26 +1917,26 @@ _ecore_evas_x_alpha_set(Ecore_Evas *ee, int alpha) /* NB: on linux this may simply empty the env as opposed to completely * unset it to being empty - unsure as solartis libc crashes looking * for the '=' char */ - // putenv((char*)"DESKTOP_STARTUP_ID="); + // putenv((char*)"DESKTOP_STARTUP_ID="); } } else if (!strcmp(ee->driver, "opengl_x11")) { #ifdef BUILD_ECORE_EVAS_OPENGL_X11 - Evas_Engine_Info_GL_X11 *einfo; + Evas_Engine_Info_GL_X11 *einfo; - einfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(ee->evas); - if (!einfo) return; + einfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(ee->evas); + if (!einfo) return; - if (!ecore_x_composite_query()) return; + if (!ecore_x_composite_query()) return; - ee->shaped = 0; - ee->alpha = alpha; - ecore_x_window_free(ee->prop.window); - ecore_event_window_unregister(ee->prop.window); + ee->shaped = 0; + ee->alpha = alpha; + ecore_x_window_free(ee->prop.window); + ecore_event_window_unregister(ee->prop.window); ee->prop.window = 0; - einfo->info.destination_alpha = alpha; + einfo->info.destination_alpha = alpha; if (ee->engine.x.win_root != 0) { @@ -1971,61 +1964,63 @@ _ecore_evas_x_alpha_set(Ecore_Evas *ee, int alpha) return; } /* - if (ee->alpha) - { - if (ee->prop.override) - ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - else - ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - if (!ee->engine.x.mask) - ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->req.w, ee->req.h, 1); - } - else - { - if (ee->prop.override) - ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - else - ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); - ee->engine.x.mask = 0; - ecore_x_window_shape_input_mask_set(ee->prop.window, 0); - } + if (ee->alpha) + { + if (ee->prop.override) + ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + else + ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + if (!ee->engine.x.mask) + ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->req.w, ee->req.h, 1); + } + else + { + if (ee->prop.override) + ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + else + ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); + ee->engine.x.mask = 0; + ecore_x_window_shape_input_mask_set(ee->prop.window, 0); + } */ - XGetWindowAttributes(ecore_x_display_get(), ee->prop.window, &att); - einfo->info.visual = att.visual; - einfo->info.colormap = att.colormap; - einfo->info.depth = att.depth; + XGetWindowAttributes(ecore_x_display_get(), ee->prop.window, &att); + einfo->info.visual = att.visual; + einfo->info.colormap = att.colormap; + einfo->info.depth = att.depth; -// if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); -// ee->engine.x.mask = 0; -// einfo->info.mask = ee->engine.x.mask; - einfo->info.drawable = ee->prop.window; +// if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); +// ee->engine.x.mask = 0; +// einfo->info.mask = ee->engine.x.mask; + einfo->info.drawable = ee->prop.window; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h); -// ecore_x_window_shape_mask_set(ee->prop.window, 0); + evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h); +// ecore_x_window_shape_mask_set(ee->prop.window, 0); ecore_x_input_multi_select(ee->prop.window); - ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process); - if (ee->prop.borderless) - ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless); - if (ee->visible) ecore_x_window_show(ee->prop.window); - if (ee->prop.focused) ecore_x_window_focus(ee->prop.window); - if (ee->prop.title) - { - ecore_x_icccm_title_set(ee->prop.window, ee->prop.title); - ecore_x_netwm_name_set(ee->prop.window, ee->prop.title); - } - ecore_x_icccm_hints_set(ee->prop.window, - 1 /* accepts_focus */, - ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */, - 0 /* icon_pixmap */, - 0 /* icon_mask */, - 0 /* icon_window */, - 0 /* window_group */, - 0 /* is_urgent */); + ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process); + if (ee->prop.borderless) + ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless); + if (ee->visible) ecore_x_window_show(ee->prop.window); + if (ee->prop.focused) ecore_x_window_focus(ee->prop.window); + if (ee->prop.title) + { + ecore_x_icccm_title_set(ee->prop.window, ee->prop.title); + ecore_x_netwm_name_set(ee->prop.window, ee->prop.title); + } + ecore_x_icccm_hints_set(ee->prop.window, + 1 /* accepts_focus */, + ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */, + 0 /* icon_pixmap */, + 0 /* icon_mask */, + 0 /* icon_window */, + 0 /* window_group */, + 0 /* is_urgent */); + _ecore_evas_x_group_leader_update(ee); + ecore_x_window_defaults_set(ee->prop.window); _ecore_evas_x_protocols_set(ee); _ecore_evas_x_sync_set(ee); #endif /* BUILD_ECORE_EVAS_OPENGL_X11 */ @@ -2036,84 +2031,86 @@ _ecore_evas_x_alpha_set(Ecore_Evas *ee, int alpha) /* NB: on linux this may simply empty the env as opposed to completely * unset it to being empty - unsure as solartis libc crashes looking * for the '=' char */ - // putenv((char*)"DESKTOP_STARTUP_ID="); + // putenv((char*)"DESKTOP_STARTUP_ID="); } } else if (!strcmp(ee->driver, "xrender_x11")) { #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB) - Evas_Engine_Info_XRender_X11 *einfo; - - einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas); - if (!einfo) return; - if (!ecore_x_composite_query()) return; - - ee->shaped = 0; - ee->alpha = alpha; - ecore_x_window_free(ee->prop.window); - ecore_event_window_unregister(ee->prop.window); - if (ee->alpha) - { - if (ee->prop.override) - ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - else - ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - if (!ee->engine.x.mask) - ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->req.w, ee->req.h, 1); - } - else - { - if (ee->prop.override) - ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - else - ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); - ee->engine.x.mask = 0; - ecore_x_window_shape_input_mask_set(ee->prop.window, 0); - } - - einfo->info.destination_alpha = alpha; + Evas_Engine_Info_XRender_X11 *einfo; + + einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas); + if (!einfo) return; + if (!ecore_x_composite_query()) return; + + ee->shaped = 0; + ee->alpha = alpha; + ecore_x_window_free(ee->prop.window); + ecore_event_window_unregister(ee->prop.window); + if (ee->alpha) + { + if (ee->prop.override) + ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + else + ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + if (!ee->engine.x.mask) + ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->req.w, ee->req.h, 1); + } + else + { + if (ee->prop.override) + ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + else + ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); + ee->engine.x.mask = 0; + ecore_x_window_shape_input_mask_set(ee->prop.window, 0); + } + + einfo->info.destination_alpha = alpha; # ifdef BUILD_ECORE_EVAS_XRENDER_XCB - cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window); - reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL); + cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window); + reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL); - einfo->info.visual = reply_attr->visual; - free(reply_attr); + einfo->info.visual = reply_attr->visual; + free(reply_attr); # else - XGetWindowAttributes(ecore_x_display_get(), ee->prop.window, &att); - einfo->info.visual = att.visual; + XGetWindowAttributes(ecore_x_display_get(), ee->prop.window, &att); + einfo->info.visual = att.visual; # endif /* ! BUILD_ECORE_EVAS_XRENDER_XCB */ -// if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); -// ee->engine.x.mask = 0; +// if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); +// ee->engine.x.mask = 0; einfo->info.mask = ee->engine.x.mask; - einfo->info.drawable = ee->prop.window; + einfo->info.drawable = ee->prop.window; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h); - ecore_x_window_shape_mask_set(ee->prop.window, 0); + evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h); + ecore_x_window_shape_mask_set(ee->prop.window, 0); ecore_x_input_multi_select(ee->prop.window); - ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process); - if (ee->prop.borderless) - ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless); - if (ee->visible) ecore_x_window_show(ee->prop.window); - if (ee->prop.focused) ecore_x_window_focus(ee->prop.window); - if (ee->prop.title) - { - ecore_x_icccm_title_set(ee->prop.window, ee->prop.title); - ecore_x_netwm_name_set(ee->prop.window, ee->prop.title); - } - ecore_x_icccm_hints_set(ee->prop.window, - 1 /* accepts_focus */, - ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */, - 0 /* icon_pixmap */, - 0 /* icon_mask */, - 0 /* icon_window */, - 0 /* window_group */, - 0 /* is_urgent */); + ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process); + if (ee->prop.borderless) + ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless); + if (ee->visible) ecore_x_window_show(ee->prop.window); + if (ee->prop.focused) ecore_x_window_focus(ee->prop.window); + if (ee->prop.title) + { + ecore_x_icccm_title_set(ee->prop.window, ee->prop.title); + ecore_x_netwm_name_set(ee->prop.window, ee->prop.title); + } + ecore_x_icccm_hints_set(ee->prop.window, + 1 /* accepts_focus */, + ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */, + 0 /* icon_pixmap */, + 0 /* icon_mask */, + 0 /* icon_window */, + 0 /* window_group */, + 0 /* is_urgent */); + _ecore_evas_x_group_leader_update(ee); + ecore_x_window_defaults_set(ee->prop.window); _ecore_evas_x_protocols_set(ee); _ecore_evas_x_sync_set(ee); #endif /* BUILD_ECORE_EVAS_XRENDER_X11 || BUILD_ECORE_EVAS_XRENDER_XCB */ @@ -2124,77 +2121,79 @@ _ecore_evas_x_alpha_set(Ecore_Evas *ee, int alpha) /* NB: on linux this may simply empty the env as opposed to completely * unset it to being empty - unsure as solartis libc crashes looking * for the '=' char */ - // putenv((char*)"DESKTOP_STARTUP_ID="); + // putenv((char*)"DESKTOP_STARTUP_ID="); } } else if (!strcmp(ee->driver, "software_16_x11")) { #if BUILD_ECORE_EVAS_SOFTWARE_16_X11 - Evas_Engine_Info_Software_16_X11 *einfo; - - einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas); - if (!einfo) return; - - ee->shaped = 0; - ee->alpha = alpha; - ecore_x_window_free(ee->prop.window); - ecore_event_window_unregister(ee->prop.window); - if (ee->alpha) - { - if (ee->prop.override) - ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - else - ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - if (!ee->engine.x.mask) - ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->req.w, ee->req.h, 1); - } - else - { - if (ee->prop.override) - ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - else - ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); - ee->engine.x.mask = 0; - ecore_x_window_shape_input_mask_set(ee->prop.window, 0); - } + Evas_Engine_Info_Software_16_X11 *einfo; + + einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas); + if (!einfo) return; + + ee->shaped = 0; + ee->alpha = alpha; + ecore_x_window_free(ee->prop.window); + ecore_event_window_unregister(ee->prop.window); + if (ee->alpha) + { + if (ee->prop.override) + ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + else + ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + if (!ee->engine.x.mask) + ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->req.w, ee->req.h, 1); + } + else + { + if (ee->prop.override) + ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + else + ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); + ee->engine.x.mask = 0; + ecore_x_window_shape_input_mask_set(ee->prop.window, 0); + } # if 0 /* XXX no alpha window support for software_16_x11 */ - einfo->info.destination_alpha = alpha; + einfo->info.destination_alpha = alpha; # endif /* XXX no alpha window support for software_16_x11 */ # if 0 /* XXX no shaped window support for software_16_x11 */ -// if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); -// ee->engine.x.mask = 0; +// if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); +// ee->engine.x.mask = 0; einfo->info.mask = ee->engine.x.mask; # endif /* XXX no shaped window support for software_16_x11 */ - einfo->info.drawable = ee->prop.window; + einfo->info.drawable = ee->prop.window; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h); - ecore_x_window_shape_mask_set(ee->prop.window, 0); + evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h); + ecore_x_window_shape_mask_set(ee->prop.window, 0); ecore_x_input_multi_select(ee->prop.window); - ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process); - if (ee->prop.borderless) - ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless); - if (ee->visible) ecore_x_window_show(ee->prop.window); - if (ee->prop.focused) ecore_x_window_focus(ee->prop.window); - if (ee->prop.title) - { - ecore_x_icccm_title_set(ee->prop.window, ee->prop.title); - ecore_x_netwm_name_set(ee->prop.window, ee->prop.title); - } - ecore_x_icccm_hints_set(ee->prop.window, - 1 /* accepts_focus */, - ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */, - 0 /* icon_pixmap */, - 0 /* icon_mask */, - 0 /* icon_window */, - 0 /* window_group */, - 0 /* is_urgent */); + ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process); + if (ee->prop.borderless) + ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless); + if (ee->visible) ecore_x_window_show(ee->prop.window); + if (ee->prop.focused) ecore_x_window_focus(ee->prop.window); + if (ee->prop.title) + { + ecore_x_icccm_title_set(ee->prop.window, ee->prop.title); + ecore_x_netwm_name_set(ee->prop.window, ee->prop.title); + } + ecore_x_icccm_hints_set(ee->prop.window, + 1 /* accepts_focus */, + ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */, + 0 /* icon_pixmap */, + 0 /* icon_mask */, + 0 /* icon_window */, + 0 /* window_group */, + 0 /* is_urgent */); + _ecore_evas_x_group_leader_update(ee); + ecore_x_window_defaults_set(ee->prop.window); _ecore_evas_x_protocols_set(ee); _ecore_evas_x_sync_set(ee); #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */ @@ -2205,83 +2204,85 @@ _ecore_evas_x_alpha_set(Ecore_Evas *ee, int alpha) /* NB: on linux this may simply empty the env as opposed to completely * unset it to being empty - unsure as solartis libc crashes looking * for the '=' char */ - // putenv((char*)"DESKTOP_STARTUP_ID="); + // putenv((char*)"DESKTOP_STARTUP_ID="); } } else if (!strcmp(ee->driver, "software_8_x11")) { #if defined (BUILD_ECORE_EVAS_SOFTWARE_8_X11) - Evas_Engine_Info_Software_8_X11 *einfo; - - einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas); - if (!einfo) return; - - ee->shaped = 0; - ee->alpha = alpha; - ecore_x_window_free(ee->prop.window); - ecore_event_window_unregister(ee->prop.window); - if (ee->alpha) - { - if (ee->prop.override) - ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - else - ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - if (!ee->engine.x.mask) - ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->req.w, ee->req.h, 1); - } - else - { - if (ee->prop.override) - ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - else - ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); - if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); - ee->engine.x.mask = 0; - ecore_x_window_shape_input_mask_set(ee->prop.window, 0); - } - - einfo->info.destination_alpha = alpha; - - cookie_geom = xcb_get_geometry_unchecked(ecore_x_connection_get(), ee->prop.window); - cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window); - - reply_geom = xcb_get_geometry_reply(ecore_x_connection_get(), cookie_geom, NULL); - reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL); - einfo->info.visual = xcb_visualtype_get(ecore_x_default_screen_get(), reply_attr->visual); - einfo->info.colormap = reply_attr->colormap; - einfo->info.depth = reply_geom->depth; - free(reply_geom); - free(reply_attr); - -// if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); -// ee->engine.x.mask = 0; - einfo->info.mask = ee->engine.x.mask; - einfo->info.drawable = ee->prop.window; + Evas_Engine_Info_Software_8_X11 *einfo; + + einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas); + if (!einfo) return; + + ee->shaped = 0; + ee->alpha = alpha; + ecore_x_window_free(ee->prop.window); + ecore_event_window_unregister(ee->prop.window); + if (ee->alpha) + { + if (ee->prop.override) + ee->prop.window = ecore_x_window_override_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + else + ee->prop.window = ecore_x_window_argb_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + if (!ee->engine.x.mask) + ee->engine.x.mask = ecore_x_pixmap_new(ee->prop.window, ee->req.w, ee->req.h, 1); + } + else + { + if (ee->prop.override) + ee->prop.window = ecore_x_window_override_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + else + ee->prop.window = ecore_x_window_new(ee->engine.x.win_root, ee->req.x, ee->req.y, ee->req.w, ee->req.h); + if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); + ee->engine.x.mask = 0; + ecore_x_window_shape_input_mask_set(ee->prop.window, 0); + } + + einfo->info.destination_alpha = alpha; + + cookie_geom = xcb_get_geometry_unchecked(ecore_x_connection_get(), ee->prop.window); + cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window); + + reply_geom = xcb_get_geometry_reply(ecore_x_connection_get(), cookie_geom, NULL); + reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL); + einfo->info.visual = xcb_visualtype_get(ecore_x_default_screen_get(), reply_attr->visual); + einfo->info.colormap = reply_attr->colormap; + einfo->info.depth = reply_geom->depth; + free(reply_geom); + free(reply_attr); + +// if (ee->engine.x.mask) ecore_x_pixmap_free(ee->engine.x.mask); +// ee->engine.x.mask = 0; + einfo->info.mask = ee->engine.x.mask; + einfo->info.drawable = ee->prop.window; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h); - ecore_x_window_shape_mask_set(ee->prop.window, 0); + evas_damage_rectangle_add(ee->evas, 0, 0, ee->req.w, ee->req.h); + ecore_x_window_shape_mask_set(ee->prop.window, 0); ecore_x_input_multi_select(ee->prop.window); - ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process); - if (ee->prop.borderless) - ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless); - if (ee->visible) ecore_x_window_show(ee->prop.window); - if (ee->prop.focused) ecore_x_window_focus(ee->prop.window); - if (ee->prop.title) - { - ecore_x_icccm_title_set(ee->prop.window, ee->prop.title); - ecore_x_netwm_name_set(ee->prop.window, ee->prop.title); - } - ecore_x_icccm_hints_set(ee->prop.window, - 1 /* accepts_focus */, - ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */, - 0 /* icon_pixmap */, - 0 /* icon_mask */, - 0 /* icon_window */, - 0 /* window_group */, - 0 /* is_urgent */); + ecore_event_window_register(ee->prop.window, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process); + if (ee->prop.borderless) + ecore_x_mwm_borderless_set(ee->prop.window, ee->prop.borderless); + if (ee->visible) ecore_x_window_show(ee->prop.window); + if (ee->prop.focused) ecore_x_window_focus(ee->prop.window); + if (ee->prop.title) + { + ecore_x_icccm_title_set(ee->prop.window, ee->prop.title); + ecore_x_netwm_name_set(ee->prop.window, ee->prop.title); + } + ecore_x_icccm_hints_set(ee->prop.window, + 1 /* accepts_focus */, + ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */, + 0 /* icon_pixmap */, + 0 /* icon_mask */, + 0 /* icon_window */, + 0 /* window_group */, + 0 /* is_urgent */); + _ecore_evas_x_group_leader_update(ee); + ecore_x_window_defaults_set(ee->prop.window); _ecore_evas_x_protocols_set(ee); _ecore_evas_x_sync_set(ee); @@ -2292,7 +2293,7 @@ _ecore_evas_x_alpha_set(Ecore_Evas *ee, int alpha) /* NB: on linux this may simply empty the env as opposed to completely * unset it to being empty - unsure as solartis libc crashes looking * for the '=' char */ - // putenv((char*)"DESKTOP_STARTUP_ID="); + // putenv((char*)"DESKTOP_STARTUP_ID="); } #endif /* BUILD_ECORE_EVAS_SOFTWARE_8_X11 */ } @@ -2308,18 +2309,18 @@ _ecore_evas_x_transparent_set(Ecore_Evas *ee, int transparent) if (!strcmp(ee->driver, "software_x11")) { #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11 - Evas_Engine_Info_Software_X11 *einfo; + Evas_Engine_Info_Software_X11 *einfo; - einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas); - if (!einfo) return; + einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas); + if (!einfo) return; - ee->transparent = transparent; - einfo->info.destination_alpha = transparent; + ee->transparent = transparent; + einfo->info.destination_alpha = transparent; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); #endif } } @@ -2332,6 +2333,7 @@ _ecore_evas_x_show(Ecore_Evas *ee) ee->should_be_visible = 1; if (ee->prop.avoid_damage) _ecore_evas_x_render(ee); + _ecore_evas_x_sync_set(ee); ecore_x_window_show(ee->prop.window); if (ee->prop.fullscreen) ecore_x_window_focus(ee->prop.window); @@ -2342,6 +2344,7 @@ _ecore_evas_x_hide(Ecore_Evas *ee) { ecore_x_window_hide(ee->prop.window); ee->should_be_visible = 0; + _ecore_evas_x_sync_set(ee); } static void @@ -2366,7 +2369,7 @@ static void _ecore_evas_x_activate(Ecore_Evas *ee) { ecore_x_netwm_client_active_request(ee->engine.x.win_root, - ee->prop.window, 2, 0); + ee->prop.window, 2, 0); } static void @@ -2454,12 +2457,12 @@ _ecore_evas_x_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int if (!obj) { - ee->prop.cursor.object = NULL; - ee->prop.cursor.layer = 0; - ee->prop.cursor.hot.x = 0; - ee->prop.cursor.hot.y = 0; - ecore_x_window_cursor_show(ee->prop.window, 1); - return; + ee->prop.cursor.object = NULL; + ee->prop.cursor.layer = 0; + ee->prop.cursor.hot.x = 0; + ee->prop.cursor.hot.y = 0; + ecore_x_window_cursor_show(ee->prop.window, 1); + return; } ee->prop.cursor.object = obj; @@ -2472,8 +2475,8 @@ _ecore_evas_x_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int evas_pointer_output_xy_get(ee->evas, &x, &y); evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer); evas_object_move(ee->prop.cursor.object, - x - ee->prop.cursor.hot.x, - y - ee->prop.cursor.hot.y); + x - ee->prop.cursor.hot.x, + y - ee->prop.cursor.hot.y); evas_object_pass_events_set(ee->prop.cursor.object, 1); if (evas_pointer_inside_get(ee->evas)) evas_object_show(ee->prop.cursor.object); @@ -2518,27 +2521,27 @@ _ecore_evas_x_iconified_set(Ecore_Evas *ee, int on) ee->prop.iconified = on; if (on) { - ecore_x_icccm_hints_set(ee->prop.window, - 1 /* accepts_focus */, - ECORE_X_WINDOW_STATE_HINT_ICONIC /* initial_state */, - 0 /* icon_pixmap */, - 0 /* icon_mask */, - 0 /* icon_window */, - 0 /* window_group */, - 0 /* is_urgent */); - ecore_x_icccm_iconic_request_send(ee->prop.window, ee->engine.x.win_root); + ecore_x_icccm_hints_set(ee->prop.window, + 1 /* accepts_focus */, + ECORE_X_WINDOW_STATE_HINT_ICONIC /* initial_state */, + 0 /* icon_pixmap */, + 0 /* icon_mask */, + 0 /* icon_window */, + 0 /* window_group */, + 0 /* is_urgent */); + ecore_x_icccm_iconic_request_send(ee->prop.window, ee->engine.x.win_root); } else { - ecore_x_icccm_hints_set(ee->prop.window, - 1 /* accepts_focus */, - ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */, - 0 /* icon_pixmap */, - 0 /* icon_mask */, - 0 /* icon_window */, - 0 /* window_group */, - 0 /* is_urgent */); - ecore_evas_show(ee); + ecore_x_icccm_hints_set(ee->prop.window, + 1 /* accepts_focus */, + ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */, + 0 /* icon_pixmap */, + 0 /* icon_mask */, + 0 /* icon_window */, + 0 /* window_group */, + 0 /* is_urgent */); + ecore_evas_show(ee); } } @@ -2568,13 +2571,13 @@ _ecore_evas_x_withdrawn_set(Ecore_Evas *ee, int withdrawn) hint = ECORE_X_WINDOW_STATE_HINT_NORMAL; ecore_x_icccm_hints_set(ee->prop.window, - 1 /* accepts_focus */, - hint /* initial_state */, - 0 /* icon_pixmap */, - 0 /* icon_mask */, - 0 /* icon_window */, - 0 /* window_group */, - 0 /* is_urgent */); + 1 /* accepts_focus */, + hint /* initial_state */, + 0 /* icon_pixmap */, + 0 /* icon_mask */, + 0 /* icon_window */, + 0 /* window_group */, + 0 /* is_urgent */); } static void @@ -2591,7 +2594,7 @@ _ecore_evas_x_sticky_set(Ecore_Evas *ee, int sticky) ee->engine.x.state.sticky = sticky; if (ee->should_be_visible) ecore_x_netwm_state_request_send(ee->prop.window, ee->engine.x.win_root, - ECORE_X_WINDOW_STATE_STICKY, -1, sticky); + ECORE_X_WINDOW_STATE_STICKY, -1, sticky); else _ecore_evas_x_state_update(ee); } @@ -2604,15 +2607,15 @@ _ecore_evas_x_ignore_events_set(Ecore_Evas *ee, int ignore) if (ignore) { - ee->ignore_events = 1; - if (ee->prop.window) - ecore_x_window_ignore_set(ee->prop.window, 1); + ee->ignore_events = 1; + if (ee->prop.window) + ecore_x_window_ignore_set(ee->prop.window, 1); } else { - ee->ignore_events = 0; - if (ee->prop.window) - ecore_x_window_ignore_set(ee->prop.window, 0); + ee->ignore_events = 0; + if (ee->prop.window) + ecore_x_window_ignore_set(ee->prop.window, 0); } } @@ -2623,40 +2626,40 @@ _ecore_evas_x_reinit_win(Ecore_Evas *ee) if (!strcmp(ee->driver, "software_x11")) { #ifdef BUILD_ECORE_EVAS_X11 - Evas_Engine_Info_Software_X11 *einfo; - - einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas); - if (einfo) - { - einfo->info.drawable = ee->prop.window; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); - } + Evas_Engine_Info_Software_X11 *einfo; + + einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas); + if (einfo) + { + einfo->info.drawable = ee->prop.window; + evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + } #endif } else if (!strcmp(ee->driver, "xrender_x11")) { #ifdef BUILD_ECORE_EVAS_XRENDER_X11 - Evas_Engine_Info_XRender_X11 *einfo; - - einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas); - if (einfo) - { - einfo->info.drawable = ee->prop.window; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); - } + Evas_Engine_Info_XRender_X11 *einfo; + + einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas); + if (einfo) + { + einfo->info.drawable = ee->prop.window; + evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + } #endif } else if (!strcmp(ee->driver, "opengl_x11")) { #ifdef BUILD_ECORE_EVAS_OPENGL_X11 - Evas_Engine_Info_GL_X11 *einfo; - - einfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(ee->evas); - if (einfo) - { - einfo->info.drawable = ee->prop.window; - evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); - } + Evas_Engine_Info_GL_X11 *einfo; + + einfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(ee->evas); + if (einfo) + { + einfo->info.drawable = ee->prop.window; + evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo); + } #endif } } @@ -2685,7 +2688,7 @@ _ecore_evas_x_fullscreen_set(Ecore_Evas *ee, int on) ee->engine.x.state.fullscreen = on; if (ee->should_be_visible) ecore_x_netwm_state_request_send(ee->prop.window, ee->engine.x.win_root, - ECORE_X_WINDOW_STATE_FULLSCREEN, -1, on); + ECORE_X_WINDOW_STATE_FULLSCREEN, -1, on); else _ecore_evas_x_state_update(ee); } @@ -2700,165 +2703,165 @@ _ecore_evas_x_avoid_damage_set(Ecore_Evas *ee, int on) if (!strcmp(ee->driver, "software_x11")) { #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11 - Evas_Engine_Info_Software_X11 *einfo; - - ee->prop.avoid_damage = on; - einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas); - if (einfo) - { - if (ee->prop.avoid_damage) - { - ee->engine.x.pmap = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, einfo->info.depth); - ee->engine.x.gc = ecore_x_gc_new(ee->engine.x.pmap, 0, NULL); - einfo->info.drawable = ee->engine.x.pmap; + Evas_Engine_Info_Software_X11 *einfo; + + ee->prop.avoid_damage = on; + einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas); + if (einfo) + { + if (ee->prop.avoid_damage) + { + ee->engine.x.pmap = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, einfo->info.depth); + ee->engine.x.gc = ecore_x_gc_new(ee->engine.x.pmap, 0, NULL); + einfo->info.drawable = ee->engine.x.pmap; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - if ((ee->rotation == 90) || (ee->rotation == 270)) - evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); - else - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); - if (ee->prop.avoid_damage == ECORE_EVAS_AVOID_DAMAGE_BUILT_IN) - { - ee->engine.x.using_bg_pixmap = 1; - ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap); - ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h); - } - if (ee->engine.x.direct_resize) - { - /* Turn this off for now - ee->engine.x.using_bg_pixmap = 1; - ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap); - */ - } - } - else - { - if (ee->engine.x.pmap) ecore_x_pixmap_free(ee->engine.x.pmap); - if (ee->engine.x.gc) ecore_x_gc_free(ee->engine.x.gc); - if (ee->engine.x.using_bg_pixmap) - { - ecore_x_window_pixmap_set(ee->prop.window, 0); - ee->engine.x.using_bg_pixmap = 0; - ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h); - } - ee->engine.x.pmap = 0; - ee->engine.x.gc = 0; - einfo->info.drawable = ee->prop.window; + if ((ee->rotation == 90) || (ee->rotation == 270)) + evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); + else + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + if (ee->prop.avoid_damage == ECORE_EVAS_AVOID_DAMAGE_BUILT_IN) + { + ee->engine.x.using_bg_pixmap = 1; + ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap); + ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h); + } + if (ee->engine.x.direct_resize) + { + /* Turn this off for now + ee->engine.x.using_bg_pixmap = 1; + ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap); + */ + } + } + else + { + if (ee->engine.x.pmap) ecore_x_pixmap_free(ee->engine.x.pmap); + if (ee->engine.x.gc) ecore_x_gc_free(ee->engine.x.gc); + if (ee->engine.x.using_bg_pixmap) + { + ecore_x_window_pixmap_set(ee->prop.window, 0); + ee->engine.x.using_bg_pixmap = 0; + ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h); + } + ee->engine.x.pmap = 0; + ee->engine.x.gc = 0; + einfo->info.drawable = ee->prop.window; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - } - } + } + } #endif /* BUILD_ECORE_EVAS_SOFTWARE_X11 */ } else if (!strcmp(ee->driver, "software_16_x11")) { #if BUILD_ECORE_EVAS_SOFTWARE_16_X11 - Evas_Engine_Info_Software_16_X11 *einfo; - ee->prop.avoid_damage = on; - - einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas); - if (einfo) - { - if (ee->prop.avoid_damage) - { - ee->engine.x.pmap = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 16); - ee->engine.x.gc = ecore_x_gc_new(ee->engine.x.pmap, 0, NULL); - einfo->info.drawable = ee->engine.x.pmap; + Evas_Engine_Info_Software_16_X11 *einfo; + ee->prop.avoid_damage = on; + + einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas); + if (einfo) + { + if (ee->prop.avoid_damage) + { + ee->engine.x.pmap = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, 16); + ee->engine.x.gc = ecore_x_gc_new(ee->engine.x.pmap, 0, NULL); + einfo->info.drawable = ee->engine.x.pmap; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - if ((ee->rotation == 90) || (ee->rotation == 270)) - evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); - else - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); - if (ee->engine.x.direct_resize) - { - /* Turn this off for now - ee->engine.x.using_bg_pixmap = 1; - ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap); - */ - } - } - else - { - if (ee->engine.x.pmap) ecore_x_pixmap_free(ee->engine.x.pmap); - if (ee->engine.x.gc) ecore_x_gc_free(ee->engine.x.gc); - if (ee->engine.x.using_bg_pixmap) - { - ecore_x_window_pixmap_set(ee->prop.window, 0); - ee->engine.x.using_bg_pixmap = 0; - } - ee->engine.x.pmap = 0; - ee->engine.x.gc = 0; - einfo->info.drawable = ee->prop.window; + if ((ee->rotation == 90) || (ee->rotation == 270)) + evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); + else + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + if (ee->engine.x.direct_resize) + { + /* Turn this off for now + ee->engine.x.using_bg_pixmap = 1; + ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap); + */ + } + } + else + { + if (ee->engine.x.pmap) ecore_x_pixmap_free(ee->engine.x.pmap); + if (ee->engine.x.gc) ecore_x_gc_free(ee->engine.x.gc); + if (ee->engine.x.using_bg_pixmap) + { + ecore_x_window_pixmap_set(ee->prop.window, 0); + ee->engine.x.using_bg_pixmap = 0; + } + ee->engine.x.pmap = 0; + ee->engine.x.gc = 0; + einfo->info.drawable = ee->prop.window; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - } - } + } + } #endif /* BUILD_ECORE_EVAS_SOFTWARE_16_X11 */ } else if (!strcmp(ee->driver, "software_8_x11")) { #if BUILD_ECORE_EVAS_SOFTWARE_8_X11 - Evas_Engine_Info_Software_8_X11 *einfo; - - ee->prop.avoid_damage = on; - einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas); - if (einfo) - { - if (ee->prop.avoid_damage) - { - ee->engine.x.pmap = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, einfo->info.depth); - ee->engine.x.gc = ecore_x_gc_new(ee->engine.x.pmap, 0, NULL); - einfo->info.drawable = ee->engine.x.pmap; + Evas_Engine_Info_Software_8_X11 *einfo; + + ee->prop.avoid_damage = on; + einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas); + if (einfo) + { + if (ee->prop.avoid_damage) + { + ee->engine.x.pmap = ecore_x_pixmap_new(ee->prop.window, ee->w, ee->h, einfo->info.depth); + ee->engine.x.gc = ecore_x_gc_new(ee->engine.x.pmap, 0, NULL); + einfo->info.drawable = ee->engine.x.pmap; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - if ((ee->rotation == 90) || (ee->rotation == 270)) - evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); - else - evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); - if (ee->prop.avoid_damage == ECORE_EVAS_AVOID_DAMAGE_BUILT_IN) - { - ee->engine.x.using_bg_pixmap = 1; - ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap); - ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h); - } - if (ee->engine.x.direct_resize) - { - /* Turn this off for now - ee->engine.x.using_bg_pixmap = 1; - ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap); - */ - } - } - else - { - if (ee->engine.x.pmap) ecore_x_pixmap_free(ee->engine.x.pmap); - if (ee->engine.x.gc) ecore_x_gc_free(ee->engine.x.gc); - if (ee->engine.x.using_bg_pixmap) - { - ecore_x_window_pixmap_set(ee->prop.window, 0); - ee->engine.x.using_bg_pixmap = 0; - ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h); - } - ee->engine.x.pmap = 0; - ee->engine.x.gc = 0; - einfo->info.drawable = ee->prop.window; + if ((ee->rotation == 90) || (ee->rotation == 270)) + evas_damage_rectangle_add(ee->evas, 0, 0, ee->h, ee->w); + else + evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h); + if (ee->prop.avoid_damage == ECORE_EVAS_AVOID_DAMAGE_BUILT_IN) + { + ee->engine.x.using_bg_pixmap = 1; + ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap); + ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h); + } + if (ee->engine.x.direct_resize) + { + /* Turn this off for now + ee->engine.x.using_bg_pixmap = 1; + ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap); + */ + } + } + else + { + if (ee->engine.x.pmap) ecore_x_pixmap_free(ee->engine.x.pmap); + if (ee->engine.x.gc) ecore_x_gc_free(ee->engine.x.gc); + if (ee->engine.x.using_bg_pixmap) + { + ecore_x_window_pixmap_set(ee->prop.window, 0); + ee->engine.x.using_bg_pixmap = 0; + ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h); + } + ee->engine.x.pmap = 0; + ee->engine.x.gc = 0; + einfo->info.drawable = ee->prop.window; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } - } - } + } + } #endif /* BUILD_ECORE_EVAS_SOFTWARE_8_X11 */ } } @@ -2869,14 +2872,14 @@ _ecore_evas_x_shutdown(void) _ecore_evas_init_count--; if (_ecore_evas_init_count == 0) { - unsigned int i; + unsigned int i; - for (i = 0; i < sizeof(ecore_evas_event_handlers) / sizeof(Ecore_Event_Handler*); i++) + for (i = 0; i < sizeof(ecore_evas_event_handlers) / sizeof(Ecore_Event_Handler*); i++) { if (ecore_evas_event_handlers[i]) ecore_event_handler_del(ecore_evas_event_handlers[i]); } - ecore_event_evas_shutdown(); + ecore_event_evas_shutdown(); } if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0; return _ecore_evas_init_count; @@ -2937,7 +2940,7 @@ static Ecore_Evas_Engine_Func _ecore_x_engine_func = /* * FIXME: there are some round trips. Especially, we can split - * ecore_x_init in 2 functions and supress some round trips. + * ecore_x_init in 2 functions and suppress some round trips. */ #if defined (BUILD_ECORE_EVAS_SOFTWARE_X11) || defined (BUILD_ECORE_EVAS_OPENGL_X11) || defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB) || defined (BUILD_ECORE_EVAS_SOFTWARE_16_X11) || defined (BUILD_ECORE_EVAS_SOFTWARE_8_X11) @@ -2966,7 +2969,7 @@ static void _ecore_evas_x_flush_post(void *data, Evas *e __UNUSED__, void *event_info __UNUSED__) { Ecore_Evas *ee = data; - + if (ee->no_comp_sync) return; if (!_ecore_evas_app_comp_sync) return; if (ee->engine.x.sync_counter) @@ -2991,7 +2994,7 @@ _ecore_evas_x_flush_post(void *data, Evas *e __UNUSED__, void *event_info __UNUS #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11 EAPI Ecore_Evas * ecore_evas_software_x11_new(const char *disp_name, Ecore_X_Window parent, - int x, int y, int w, int h) + int x, int y, int w, int h) { Evas_Engine_Info_Software_X11 *einfo; Ecore_Evas *ee; @@ -3048,119 +3051,119 @@ ecore_evas_software_x11_new(const char *disp_name, Ecore_X_Window parent, { ee->engine.x.screen_num = 1; /* FIXME: get real scren # */ /* FIXME: round trip in ecore_x_window_argb_get */ - if (ecore_x_window_argb_get(parent)) - { - ee->prop.window = ecore_x_window_argb_new(parent, x, y, w, h); - argb = 1; - } - else - ee->prop.window = ecore_x_window_new(parent, x, y, w, h); + if (ecore_x_window_argb_get(parent)) + { + ee->prop.window = ecore_x_window_argb_new(parent, x, y, w, h); + argb = 1; + } + else + ee->prop.window = ecore_x_window_new(parent, x, y, w, h); } else ee->prop.window = ecore_x_window_new(parent, x, y, w, h); if (getenv("DESKTOP_STARTUP_ID")) { - ecore_x_netwm_startup_id_set(ee->prop.window, - getenv("DESKTOP_STARTUP_ID")); - /* NB: on linux this may simply empty the env as opposed to completely - * unset it to being empty - unsure as solartis libc crashes looking - * for the '=' char */ -// putenv((char*)"DESKTOP_STARTUP_ID="); + ecore_x_netwm_startup_id_set(ee->prop.window, + getenv("DESKTOP_STARTUP_ID")); + /* NB: on linux this may simply empty the env as opposed to completely + * unset it to being empty - unsure as solartis libc crashes looking + * for the '=' char */ +// putenv((char*)"DESKTOP_STARTUP_ID="); } einfo = (Evas_Engine_Info_Software_X11 *)evas_engine_info_get(ee->evas); if (einfo) { # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB xcb_screen_iterator_t iter; - xcb_screen_t *screen; + xcb_screen_t *screen; # else - int screen; + int screen; # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */ - /* FIXME: this is inefficient as its a round trip */ + /* FIXME: this is inefficient as its a round trip */ # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB - screen = ecore_x_default_screen_get(); + screen = ecore_x_default_screen_get(); iter = xcb_setup_roots_iterator (xcb_get_setup (ecore_x_connection_get())); - if (iter.rem > 1) - { + if (iter.rem > 1) + { xcb_get_geometry_cookie_t cookie; xcb_get_geometry_reply_t *reply; - Ecore_X_Window *roots; - int num; - uint8_t i; + Ecore_X_Window *roots; + int num; + uint8_t i; - num = 0; + num = 0; cookie = xcb_get_geometry_unchecked(ecore_x_connection_get(), parent); - roots = ecore_x_window_root_list(&num); - if (roots) - { + roots = ecore_x_window_root_list(&num); + if (roots) + { reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL); - if (reply) - { - for (i = 0; i < num; xcb_screen_next (&iter), i++) - { - if (reply->root == roots[i]) - { - screen = iter.data; - break; - } - } + if (reply) + { + for (i = 0; i < num; xcb_screen_next (&iter), i++) + { + if (reply->root == roots[i]) + { + screen = iter.data; + break; + } + } free(reply); - } - free(roots); - } + } + free(roots); + } else { reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL); if (reply) free(reply); } - } + } # else - screen = DefaultScreen(ecore_x_display_get()); - if (ScreenCount(ecore_x_display_get()) > 1) - { - Ecore_X_Window *roots; - int num, i; - - num = 0; - roots = ecore_x_window_root_list(&num); - if (roots) - { - XWindowAttributes at; - - if (XGetWindowAttributes(ecore_x_display_get(), - parent, &at)) - { - for (i = 0; i < num; i++) - { - if (at.root == roots[i]) - { - screen = i; - break; - } - } - } - free(roots); - } - } + screen = DefaultScreen(ecore_x_display_get()); + if (ScreenCount(ecore_x_display_get()) > 1) + { + Ecore_X_Window *roots; + int num, i; + + num = 0; + roots = ecore_x_window_root_list(&num); + if (roots) + { + XWindowAttributes at; + + if (XGetWindowAttributes(ecore_x_display_get(), + parent, &at)) + { + for (i = 0; i < num; i++) + { + if (at.root == roots[i]) + { + screen = i; + break; + } + } + } + free(roots); + } + } # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */ - if (redraw_debug < 0) - { - if (getenv("REDRAW_DEBUG")) - redraw_debug = atoi(getenv("REDRAW_DEBUG")); - else - redraw_debug = 0; - } + if (redraw_debug < 0) + { + if (getenv("REDRAW_DEBUG")) + redraw_debug = atoi(getenv("REDRAW_DEBUG")); + else + redraw_debug = 0; + } # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB einfo->info.backend = EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XCB; - einfo->info.connection = ecore_x_connection_get(); - einfo->info.screen = screen; + einfo->info.connection = ecore_x_connection_get(); + einfo->info.screen = screen; # else einfo->info.backend = EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XLIB; - einfo->info.connection = ecore_x_display_get(); - einfo->info.screen = NULL; + einfo->info.connection = ecore_x_display_get(); + einfo->info.screen = NULL; #ifdef EVAS_FRAME_QUEUING { char *render_mode; @@ -3173,68 +3176,69 @@ ecore_evas_software_x11_new(const char *disp_name, Ecore_X_Window parent, #endif # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */ - einfo->info.drawable = ee->prop.window; - if (argb) - { - /* FIXME: round trip */ + einfo->info.drawable = ee->prop.window; + if (argb) + { + /* FIXME: round trip */ # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB xcb_get_geometry_cookie_t cookie_geom; xcb_get_window_attributes_cookie_t cookie_attr; xcb_get_geometry_reply_t *reply_geom; xcb_get_window_attributes_reply_t *reply_attr; - cookie_geom = xcb_get_geometry_unchecked(ecore_x_connection_get(), ee->prop.window); - cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window); + cookie_geom = xcb_get_geometry_unchecked(ecore_x_connection_get(), ee->prop.window); + cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window); reply_geom = xcb_get_geometry_reply(ecore_x_connection_get(), cookie_geom, NULL); reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL); - if (reply_attr && reply_geom) - { + if (reply_attr && reply_geom) + { einfo->info.visual = xcb_visualtype_get(ecore_x_default_screen_get(), reply_attr->visual); - einfo->info.colormap = reply_attr->colormap; - einfo->info.depth = reply_geom->depth; - einfo->info.destination_alpha = 1; + einfo->info.colormap = reply_attr->colormap; + einfo->info.depth = reply_geom->depth; + einfo->info.destination_alpha = 1; free(reply_geom); free(reply_attr); - } + } # else - XWindowAttributes at; - - if (XGetWindowAttributes(ecore_x_display_get(), ee->prop.window, - &at)) - { - einfo->info.visual = at.visual; - einfo->info.colormap = at.colormap; - einfo->info.depth = at.depth; - einfo->info.destination_alpha = 1; - } + XWindowAttributes at; + + if (XGetWindowAttributes(ecore_x_display_get(), ee->prop.window, + &at)) + { + einfo->info.visual = at.visual; + einfo->info.colormap = at.colormap; + einfo->info.depth = at.depth; + einfo->info.destination_alpha = 1; + } # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */ - } - else - { + } + else + { # ifdef BUILD_ECORE_EVAS_SOFTWARE_XCB xcb_screen_t *screen; screen = ecore_x_default_screen_get(); - einfo->info.visual = xcb_visualtype_get(screen, screen->root_visual); - einfo->info.colormap = screen->default_colormap; - einfo->info.depth = screen->root_depth; + einfo->info.visual = xcb_visualtype_get(screen, screen->root_visual); + einfo->info.colormap = screen->default_colormap; + einfo->info.depth = screen->root_depth; #else - einfo->info.visual = DefaultVisual(ecore_x_display_get(), screen); - einfo->info.colormap = DefaultColormap(ecore_x_display_get(), screen); - einfo->info.depth = DefaultDepth(ecore_x_display_get(), screen); + einfo->info.visual = DefaultVisual(ecore_x_display_get(), screen); + einfo->info.colormap = DefaultColormap(ecore_x_display_get(), screen); + einfo->info.depth = DefaultDepth(ecore_x_display_get(), screen); # endif /* ! BUILD_ECORE_EVAS_SOFTWARE_XCB */ - einfo->info.destination_alpha = 0; - } - einfo->info.rotation = 0; - einfo->info.debug = redraw_debug; + einfo->info.destination_alpha = 0; + } + einfo->info.rotation = 0; + einfo->info.debug = redraw_debug; if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { - WRN("evas_engine_info_set() init engine '%s' failed.", ee->driver); + ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver); ecore_evas_free(ee); return NULL; } } + ecore_x_icccm_hints_set(ee->prop.window, 1 /* accepts_focus */, ECORE_X_WINDOW_STATE_HINT_NORMAL /* initial_state */, @@ -3243,6 +3247,10 @@ ecore_evas_software_x11_new(const char *disp_name, Ecore_X_Window parent, 0 /* icon_window */, 0 /* window_group */, 0 /* is_urgent */); + _ecore_evas_x_group_leader_set(ee); + ecore_x_window_defaults_set(ee->prop.window); + _ecore_evas_x_protocols_set(ee); + _ecore_evas_x_sync_set(ee); ee->engine.func->fn_render = _ecore_evas_x_render; _ecore_evas_register(ee); @@ -3253,7 +3261,7 @@ ecore_evas_software_x11_new(const char *disp_name, Ecore_X_Window parent, #else EAPI Ecore_Evas * ecore_evas_software_x11_new(const char *disp_name __UNUSED__, Ecore_X_Window parent __UNUSED__, - int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__) + int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__) { return NULL; } @@ -3285,31 +3293,31 @@ ecore_evas_software_x11_window_get(const Ecore_Evas *ee __UNUSED__) */ #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11 EAPI void -ecore_evas_software_x11_direct_resize_set(Ecore_Evas *ee, int on) +ecore_evas_software_x11_direct_resize_set(Ecore_Evas *ee, Eina_Bool on) { ee->engine.x.direct_resize = on; if (ee->prop.avoid_damage) { - if (ee->engine.x.direct_resize) - { + if (ee->engine.x.direct_resize) + { /* turn this off for now - ee->engine.x.using_bg_pixmap = 1; - ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap); + ee->engine.x.using_bg_pixmap = 1; + ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap); */ - } - else - { + } + else + { /* turn this off too- bg pixmap is controlled by avoid damage directly - ee->engine.x.using_bg_pixmap = 0; - ecore_x_window_pixmap_set(ee->prop.window, 0); - ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h); + ee->engine.x.using_bg_pixmap = 0; + ecore_x_window_pixmap_set(ee->prop.window, 0); + ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h); */ - } + } } } #else EAPI void -ecore_evas_software_x11_direct_resize_set(Ecore_Evas *ee __UNUSED__, int on __UNUSED__) +ecore_evas_software_x11_direct_resize_set(Ecore_Evas *ee __UNUSED__, Eina_Bool on __UNUSED__) { } #endif @@ -3320,13 +3328,13 @@ ecore_evas_software_x11_direct_resize_set(Ecore_Evas *ee __UNUSED__, int on __UN * FIXME: To be fixed. */ #ifdef BUILD_ECORE_EVAS_SOFTWARE_X11 -EAPI int +EAPI Eina_Bool ecore_evas_software_x11_direct_resize_get(const Ecore_Evas *ee) { return ee->engine.x.direct_resize; } #else -EAPI int +EAPI Eina_Bool ecore_evas_software_x11_direct_resize_get(const Ecore_Evas *ee __UNUSED__) { return 0; @@ -3347,10 +3355,10 @@ ecore_evas_software_x11_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window wi winp = malloc(sizeof(Ecore_X_Window)); if (winp) { - *winp = win; - ee->engine.x.win_extra = eina_list_append(ee->engine.x.win_extra, winp); + *winp = win; + ee->engine.x.win_extra = eina_list_append(ee->engine.x.win_extra, winp); ecore_x_input_multi_select(win); - ecore_event_window_register(win, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process); + ecore_event_window_register(win, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process); } } #else @@ -3368,7 +3376,7 @@ ecore_evas_software_x11_extra_event_window_add(Ecore_Evas *ee __UNUSED__, Ecore_ #ifdef BUILD_ECORE_EVAS_OPENGL_X11 EAPI Ecore_Evas * ecore_evas_gl_x11_new(const char *disp_name, Ecore_X_Window parent, - int x, int y, int w, int h) + int x, int y, int w, int h) { return ecore_evas_gl_x11_options_new(disp_name, parent, x, y, w, h, NULL); } @@ -3431,12 +3439,12 @@ ecore_evas_gl_x11_options_new(const char *disp_name, Ecore_X_Window parent, { ee->engine.x.screen_num = 1; /* FIXME: get real scren # */ /* FIXME: round trip in ecore_x_window_argb_get */ - if (ecore_x_window_argb_get(ee->engine.x.win_root)) - { + if (ecore_x_window_argb_get(ee->engine.x.win_root)) + { ee->prop.window = _ecore_evas_x_gl_window_new (ee, ee->engine.x.win_root, x, y, w, h, 0, 1, opt); - } - else + } + else ee->prop.window = _ecore_evas_x_gl_window_new (ee, ee->engine.x.win_root, x, y, w, h, 0, 0, opt); } @@ -3450,12 +3458,12 @@ ecore_evas_gl_x11_options_new(const char *disp_name, Ecore_X_Window parent, } if (getenv("DESKTOP_STARTUP_ID")) { - ecore_x_netwm_startup_id_set(ee->prop.window, - getenv("DESKTOP_STARTUP_ID")); - /* NB: on linux this may simply empty the env as opposed to completely - * unset it to being empty - unsure as solartis libc crashes looking - * for the '=' char */ -// putenv((char*)"DESKTOP_STARTUP_ID="); + ecore_x_netwm_startup_id_set(ee->prop.window, + getenv("DESKTOP_STARTUP_ID")); + /* NB: on linux this may simply empty the env as opposed to completely + * unset it to being empty - unsure as solartis libc crashes looking + * for the '=' char */ +// putenv((char*)"DESKTOP_STARTUP_ID="); } ecore_x_icccm_hints_set(ee->prop.window, @@ -3466,7 +3474,11 @@ ecore_evas_gl_x11_options_new(const char *disp_name, Ecore_X_Window parent, 0 /* icon_window */, 0 /* window_group */, 0 /* is_urgent */); - + _ecore_evas_x_group_leader_set(ee); + ecore_x_window_defaults_set(ee->prop.window); + _ecore_evas_x_protocols_set(ee); + _ecore_evas_x_sync_set(ee); + ee->engine.func->fn_render = _ecore_evas_x_render; _ecore_evas_register(ee); ecore_x_input_multi_select(ee->prop.window); @@ -3478,7 +3490,7 @@ ecore_evas_gl_x11_options_new(const char *disp_name, Ecore_X_Window parent, #else EAPI Ecore_Evas * ecore_evas_gl_x11_new(const char *disp_name __UNUSED__, Ecore_X_Window parent __UNUSED__, - int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__) + int x __UNUSED__, int y __UNUSED__, int w __UNUSED__, int h __UNUSED__) { return NULL; } @@ -3516,13 +3528,13 @@ ecore_evas_gl_x11_window_get(const Ecore_Evas *ee __UNUSED__) */ #ifdef BUILD_ECORE_EVAS_OPENGL_X11 EAPI void -ecore_evas_gl_x11_direct_resize_set(Ecore_Evas *ee, int on) +ecore_evas_gl_x11_direct_resize_set(Ecore_Evas *ee, Eina_Bool on) { ee->engine.x.direct_resize = on; } #else EAPI void -ecore_evas_gl_x11_direct_resize_set(Ecore_Evas *ee __UNUSED__, int on __UNUSED__) +ecore_evas_gl_x11_direct_resize_set(Ecore_Evas *ee __UNUSED__, Eina_Bool on __UNUSED__) { } #endif /* ! BUILD_ECORE_EVAS_OPENGL_X11 */ @@ -3533,13 +3545,13 @@ ecore_evas_gl_x11_direct_resize_set(Ecore_Evas *ee __UNUSED__, int on __UNUSED__ * FIXME: To be fixed. */ #ifdef BUILD_ECORE_EVAS_OPENGL_X11 -EAPI int +EAPI Eina_Bool ecore_evas_gl_x11_direct_resize_get(const Ecore_Evas *ee) { return ee->engine.x.direct_resize; } #else -EAPI int +EAPI Eina_Bool ecore_evas_gl_x11_direct_resize_get(const Ecore_Evas *ee __UNUSED__) { return 0; @@ -3583,7 +3595,7 @@ ecore_evas_gl_x11_pre_post_swap_callback_set(const Ecore_Evas *ee, void *data, v einfo->callback.pre_swap = pre_cb; einfo->callback.pre_swap = post_cb; einfo->callback.data = data; - if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); } @@ -3597,36 +3609,6 @@ ecore_evas_gl_x11_pre_post_swap_callback_set(const Ecore_Evas *ee, void *data, v } #endif /* ! BUILD_ECORE_EVAS_OPENGL_X11 */ - -/* - * @param ee - * @param no_swap If = 1, ee doesn't perform swap buffer. - * If = 0, ee performs swap buffer. - */ -#ifdef BUILD_ECORE_EVAS_OPENGL_X11 -EAPI void -ecore_evas_gl_x11_no_swap_set(const Ecore_Evas *ee, Eina_Bool no_swap) -{ - Evas_Engine_Info_GL_X11 *einfo; - if (!(!strcmp(ee->driver, "opengl_x11"))) return; - einfo = (Evas_Engine_Info_GL_X11 *)evas_engine_info_get(ee->evas); - if (einfo) - { - einfo->no_swap = no_swap; - if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) - { - ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver); - } - } -} -#else -EAPI void -ecore_evas_gl_x11_no_swap_set(const Ecore_Evas *ee, Eina_Bool no_swap) -{ - return; -} -#endif /* ! BUILD_ECORE_EVAS_OPENGL_X11 */ - /** * To be documented. * @@ -3635,7 +3617,7 @@ ecore_evas_gl_x11_no_swap_set(const Ecore_Evas *ee, Eina_Bool no_swap) #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB) EAPI Ecore_Evas * ecore_evas_xrender_x11_new(const char *disp_name, Ecore_X_Window parent, - int x, int y, int w, int h) + int x, int y, int w, int h) { Evas_Engine_Info_XRender_X11 *einfo; Ecore_Evas *ee; @@ -3687,102 +3669,102 @@ ecore_evas_xrender_x11_new(const char *disp_name, Ecore_X_Window parent, ee->prop.window = ecore_x_window_new(parent, x, y, w, h); if (getenv("DESKTOP_STARTUP_ID")) { - ecore_x_netwm_startup_id_set(ee->prop.window, - getenv("DESKTOP_STARTUP_ID")); - /* NB: on linux this may simply empty the env as opposed to completely - * unset it to being empty - unsure as solartis libc crashes looking - * for the '=' char */ -// putenv((char*)"DESKTOP_STARTUP_ID="); + ecore_x_netwm_startup_id_set(ee->prop.window, + getenv("DESKTOP_STARTUP_ID")); + /* NB: on linux this may simply empty the env as opposed to completely + * unset it to being empty - unsure as solartis libc crashes looking + * for the '=' char */ +// putenv((char*)"DESKTOP_STARTUP_ID="); } einfo = (Evas_Engine_Info_XRender_X11 *)evas_engine_info_get(ee->evas); if (einfo) { # ifdef BUILD_ECORE_EVAS_XRENDER_XCB xcb_screen_iterator_t iter; - xcb_screen_t *screen; + xcb_screen_t *screen; - /* FIXME: this is inefficient as its a round trip */ - screen = ecore_x_default_screen_get(); + /* FIXME: this is inefficient as its a round trip */ + screen = ecore_x_default_screen_get(); iter = xcb_setup_roots_iterator (xcb_get_setup (ecore_x_connection_get())); - if (iter.rem > 1) - { + if (iter.rem > 1) + { xcb_get_geometry_cookie_t cookie; xcb_get_geometry_reply_t *reply; - Ecore_X_Window *roots; - int num; - uint8_t i; + Ecore_X_Window *roots; + int num; + uint8_t i; - num = 0; + num = 0; cookie = xcb_get_geometry_unchecked(ecore_x_connection_get(), parent); - roots = ecore_x_window_root_list(&num); - if (roots) - { + roots = ecore_x_window_root_list(&num); + if (roots) + { reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL); - if (reply) - { - for (i = 0; i < num; xcb_screen_next (&iter), i++) - { - if (reply->root == roots[i]) - { - screen = iter.data; - break; - } - } + if (reply) + { + for (i = 0; i < num; xcb_screen_next (&iter), i++) + { + if (reply->root == roots[i]) + { + screen = iter.data; + break; + } + } free(reply); - } - free(roots); - } + } + free(roots); + } else { reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL); if (reply) free(reply); } - } - einfo->info.backend = EVAS_ENGINE_INFO_XRENDER_BACKEND_XCB; - einfo->info.connection = ecore_x_connection_get(); - einfo->info.screen = screen; - einfo->info.visual = screen->root_visual; + } + einfo->info.backend = EVAS_ENGINE_INFO_XRENDER_BACKEND_XCB; + einfo->info.connection = ecore_x_connection_get(); + einfo->info.screen = screen; + einfo->info.visual = screen->root_visual; # elif BUILD_ECORE_EVAS_XRENDER_X11 - int screen; - - /* FIXME: this is inefficient as its a round trip */ - screen = DefaultScreen(ecore_x_display_get()); - if (ScreenCount(ecore_x_display_get()) > 1) - { - Ecore_X_Window *roots; - int num, i; - - num = 0; - roots = ecore_x_window_root_list(&num); - if (roots) - { - XWindowAttributes at; - - if (XGetWindowAttributes(ecore_x_display_get(), - parent, &at)) - { - for (i = 0; i < num; i++) - { - if (at.root == roots[i]) - { - screen = i; - break; - } - } - } - free(roots); - } - } - einfo->info.backend = EVAS_ENGINE_INFO_XRENDER_BACKEND_XLIB; - einfo->info.connection = ecore_x_display_get(); - einfo->info.screen = NULL; - einfo->info.visual = DefaultVisual(ecore_x_display_get(), screen); + int screen; + + /* FIXME: this is inefficient as its a round trip */ + screen = DefaultScreen(ecore_x_display_get()); + if (ScreenCount(ecore_x_display_get()) > 1) + { + Ecore_X_Window *roots; + int num, i; + + num = 0; + roots = ecore_x_window_root_list(&num); + if (roots) + { + XWindowAttributes at; + + if (XGetWindowAttributes(ecore_x_display_get(), + parent, &at)) + { + for (i = 0; i < num; i++) + { + if (at.root == roots[i]) + { + screen = i; + break; + } + } + } + free(roots); + } + } + einfo->info.backend = EVAS_ENGINE_INFO_XRENDER_BACKEND_XLIB; + einfo->info.connection = ecore_x_display_get(); + einfo->info.screen = NULL; + einfo->info.visual = DefaultVisual(ecore_x_display_get(), screen); # endif /* BUILD_ECORE_EVAS_XRENDER_(XCB|X11) */ - einfo->info.drawable = ee->prop.window; - if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + einfo->info.drawable = ee->prop.window; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { - WRN("evas_engine_info_set() init engine '%s' failed.", ee->driver); + ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver); ecore_evas_free(ee); return NULL; } @@ -3796,7 +3778,11 @@ ecore_evas_xrender_x11_new(const char *disp_name, Ecore_X_Window parent, 0 /* icon_window */, 0 /* window_group */, 0 /* is_urgent */); - + _ecore_evas_x_group_leader_set(ee); + ecore_x_window_defaults_set(ee->prop.window); + _ecore_evas_x_protocols_set(ee); + _ecore_evas_x_sync_set(ee); + ee->engine.func->fn_render = _ecore_evas_x_render; _ecore_evas_register(ee); ecore_x_input_multi_select(ee->prop.window); @@ -3838,13 +3824,13 @@ ecore_evas_xrender_x11_window_get(const Ecore_Evas *ee __UNUSED__) */ #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB) EAPI void -ecore_evas_xrender_x11_direct_resize_set(Ecore_Evas *ee, int on) +ecore_evas_xrender_x11_direct_resize_set(Ecore_Evas *ee, Eina_Bool on) { ee->engine.x.direct_resize = on; } #else EAPI void -ecore_evas_xrender_x11_direct_resize_set(Ecore_Evas *ee __UNUSED__, int on __UNUSED__) +ecore_evas_xrender_x11_direct_resize_set(Ecore_Evas *ee __UNUSED__, Eina_Bool on __UNUSED__) { } #endif /* ! BUILD_ECORE_EVAS_XRENDER_X11 && ! BUILD_ECORE_EVAS_XRENDER_XCB */ @@ -3855,13 +3841,13 @@ ecore_evas_xrender_x11_direct_resize_set(Ecore_Evas *ee __UNUSED__, int on __UNU * FIXME: To be fixed. */ #if defined (BUILD_ECORE_EVAS_XRENDER_X11) || defined (BUILD_ECORE_EVAS_XRENDER_XCB) -EAPI int +EAPI Eina_Bool ecore_evas_xrender_x11_direct_resize_get(const Ecore_Evas *ee) { return ee->engine.x.direct_resize; } #else -EAPI int +EAPI Eina_Bool ecore_evas_xrender_x11_direct_resize_get(const Ecore_Evas *ee __UNUSED__) { return 0; @@ -3947,65 +3933,65 @@ ecore_evas_software_x11_16_new(const char *disp_name, Ecore_X_Window parent, if (parent != 0) { /* FIXME: round trip in ecore_x_window_argb_get */ - if (ecore_x_window_argb_get(parent)) - { - ee->prop.window = ecore_x_window_argb_new(parent, x, y, w, h); - } - else - ee->prop.window = ecore_x_window_new(parent, x, y, w, h); + if (ecore_x_window_argb_get(parent)) + { + ee->prop.window = ecore_x_window_argb_new(parent, x, y, w, h); + } + else + ee->prop.window = ecore_x_window_new(parent, x, y, w, h); } else ee->prop.window = ecore_x_window_new(parent, x, y, w, h); if (getenv("DESKTOP_STARTUP_ID")) { - ecore_x_netwm_startup_id_set(ee->prop.window, - getenv("DESKTOP_STARTUP_ID")); - /* NB: on linux this may simply empty the env as opposed to completely - * unset it to being empty - unsure as solartis libc crashes looking - * for the '=' char */ -// putenv((char*)"DESKTOP_STARTUP_ID="); + ecore_x_netwm_startup_id_set(ee->prop.window, + getenv("DESKTOP_STARTUP_ID")); + /* NB: on linux this may simply empty the env as opposed to completely + * unset it to being empty - unsure as solartis libc crashes looking + * for the '=' char */ +// putenv((char*)"DESKTOP_STARTUP_ID="); } einfo = (Evas_Engine_Info_Software_16_X11 *)evas_engine_info_get(ee->evas); if (einfo) { - if (ScreenCount(ecore_x_display_get()) > 1) - { - Ecore_X_Window *roots; - int num, i; - - num = 0; - roots = ecore_x_window_root_list(&num); - if (roots) - { - XWindowAttributes at; - - if (XGetWindowAttributes(ecore_x_display_get(), - parent, &at)) - { - for (i = 0; i < num; i++) - { - if (at.root == roots[i]) - break; - } - } - free(roots); - } - } - - if (redraw_debug < 0) - { - if (getenv("REDRAW_DEBUG")) - redraw_debug = atoi(getenv("REDRAW_DEBUG")); - else - redraw_debug = 0; - } - einfo->info.display = ecore_x_display_get(); - einfo->info.drawable = ee->prop.window; - - if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + if (ScreenCount(ecore_x_display_get()) > 1) + { + Ecore_X_Window *roots; + int num, i; + + num = 0; + roots = ecore_x_window_root_list(&num); + if (roots) + { + XWindowAttributes at; + + if (XGetWindowAttributes(ecore_x_display_get(), + parent, &at)) + { + for (i = 0; i < num; i++) + { + if (at.root == roots[i]) + break; + } + } + free(roots); + } + } + + if (redraw_debug < 0) + { + if (getenv("REDRAW_DEBUG")) + redraw_debug = atoi(getenv("REDRAW_DEBUG")); + else + redraw_debug = 0; + } + einfo->info.display = ecore_x_display_get(); + einfo->info.drawable = ee->prop.window; + + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) { - WRN("evas_engine_info_set() init engine '%s' failed.", ee->driver); + ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver); ecore_evas_free(ee); return NULL; } @@ -4019,7 +4005,11 @@ ecore_evas_software_x11_16_new(const char *disp_name, Ecore_X_Window parent, 0 /* icon_window */, 0 /* window_group */, 0 /* is_urgent */); - + _ecore_evas_x_group_leader_set(ee); + ecore_x_window_defaults_set(ee->prop.window); + _ecore_evas_x_protocols_set(ee); + _ecore_evas_x_sync_set(ee); + ee->engine.func->fn_render = _ecore_evas_x_render; _ecore_evas_register(ee); ecore_x_input_multi_select(ee->prop.window); @@ -4061,31 +4051,31 @@ ecore_evas_software_x11_16_window_get(const Ecore_Evas *ee __UNUSED__) */ #if BUILD_ECORE_EVAS_SOFTWARE_16_X11 EAPI void -ecore_evas_software_x11_16_direct_resize_set(Ecore_Evas *ee, int on) +ecore_evas_software_x11_16_direct_resize_set(Ecore_Evas *ee, Eina_Bool on) { ee->engine.x.direct_resize = on; if (ee->prop.avoid_damage) { - if (ee->engine.x.direct_resize) - { + if (ee->engine.x.direct_resize) + { /* turn this off for now - ee->engine.x.using_bg_pixmap = 1; - ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap); + ee->engine.x.using_bg_pixmap = 1; + ecore_x_window_pixmap_set(ee->prop.window, ee->engine.x.pmap); */ - } - else - { + } + else + { /* turn this off too- bg pixmap is controlled by avoid damage directly - ee->engine.x.using_bg_pixmap = 0; - ecore_x_window_pixmap_set(ee->prop.window, 0); - ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h); + ee->engine.x.using_bg_pixmap = 0; + ecore_x_window_pixmap_set(ee->prop.window, 0); + ecore_x_window_area_expose(ee->prop.window, 0, 0, ee->w, ee->h); */ - } + } } } #else EAPI void -ecore_evas_software_x11_16_direct_resize_set(Ecore_Evas *ee __UNUSED__, int on __UNUSED__) +ecore_evas_software_x11_16_direct_resize_set(Ecore_Evas *ee __UNUSED__, Eina_Bool on __UNUSED__) { } #endif /* ! BUILD_ECORE_EVAS_SOFTWARE_16_X11 */ @@ -4096,13 +4086,13 @@ ecore_evas_software_x11_16_direct_resize_set(Ecore_Evas *ee __UNUSED__, int on _ * FIXME: To be fixed. */ #if BUILD_ECORE_EVAS_SOFTWARE_16_X11 -EAPI int +EAPI Eina_Bool ecore_evas_software_x11_16_direct_resize_get(const Ecore_Evas *ee) { return ee->engine.x.direct_resize; } #else -EAPI int +EAPI Eina_Bool ecore_evas_software_x11_16_direct_resize_get(const Ecore_Evas *ee __UNUSED__) { return 0; @@ -4123,10 +4113,10 @@ ecore_evas_software_x11_16_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window winp = malloc(sizeof(Ecore_X_Window)); if (winp) { - *winp = win; - ee->engine.x.win_extra = eina_list_append(ee->engine.x.win_extra, winp); + *winp = win; + ee->engine.x.win_extra = eina_list_append(ee->engine.x.win_extra, winp); ecore_x_input_multi_select(win); - ecore_event_window_register(win, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process); + ecore_event_window_register(win, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process); } } #else @@ -4199,122 +4189,122 @@ ecore_evas_software_x11_8_new(const char *disp_name, Ecore_X_Window parent, // if (parent != 0) // { // /* FIXME: round trip in ecore_x_window_argb_get */ - // if (ecore_x_window_argb_get(parent)) - // { - // ee->engine.x.win = ecore_x_window_argb_new(parent, x, y, w, h); - // argb = 1; - // } - // else - // ee->engine.x.win = ecore_x_window_new(parent, x, y, w, h); + // if (ecore_x_window_argb_get(parent)) + // { + // ee->engine.x.win = ecore_x_window_argb_new(parent, x, y, w, h); + // argb = 1; + // } + // else + // ee->engine.x.win = ecore_x_window_new(parent, x, y, w, h); // } // else ee->prop.window = ecore_x_window_new(parent, x, y, w, h); if (getenv("DESKTOP_STARTUP_ID")) { - ecore_x_netwm_startup_id_set(ee->prop.window, - getenv("DESKTOP_STARTUP_ID")); - /* NB: on linux this may simply empty the env as opposed to completely - * unset it to being empty - unsure as solartis libc crashes looking - * for the '=' char */ - // putenv((char*)"DESKTOP_STARTUP_ID="); + ecore_x_netwm_startup_id_set(ee->prop.window, + getenv("DESKTOP_STARTUP_ID")); + /* NB: on linux this may simply empty the env as opposed to completely + * unset it to being empty - unsure as solartis libc crashes looking + * for the '=' char */ + // putenv((char*)"DESKTOP_STARTUP_ID="); } einfo = (Evas_Engine_Info_Software_8_X11 *)evas_engine_info_get(ee->evas); if (einfo) { - xcb_screen_iterator_t iter; - xcb_screen_t *screen; - - /* FIXME: this is inefficient as its a round trip */ - //einfo->info.backend = 1; - screen = ecore_x_default_screen_get(); - iter = xcb_setup_roots_iterator (xcb_get_setup (ecore_x_connection_get())); - if (iter.rem > 1) - { - xcb_get_geometry_cookie_t cookie; - xcb_get_geometry_reply_t *reply; - Ecore_X_Window *roots; - int num; - uint8_t i; - - num = 0; - cookie = xcb_get_geometry_unchecked(ecore_x_connection_get(), parent); - roots = ecore_x_window_root_list(&num); - if (roots) - { - reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL); - - if (reply) - { - for (i = 0; i < num; xcb_screen_next (&iter), i++) - { - if (reply->root == roots[i]) - { - screen = iter.data; - break; - } - } - free(reply); - } - free(roots); - } - else - { - reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL); - if (reply) free(reply); - } - } - - if (redraw_debug < 0) - { - if (getenv("REDRAW_DEBUG")) - redraw_debug = atoi(getenv("REDRAW_DEBUG")); - else - redraw_debug = 0; - } - einfo->info.connection = ecore_x_connection_get(); - einfo->info.screen = screen; - einfo->info.drawable = ee->prop.window; - if (argb) - { - /* FIXME: round trip */ - xcb_get_geometry_cookie_t cookie_geom; - xcb_get_window_attributes_cookie_t cookie_attr; - xcb_get_geometry_reply_t *reply_geom; - xcb_get_window_attributes_reply_t *reply_attr; - - cookie_geom = xcb_get_geometry_unchecked(ecore_x_connection_get(), ee->prop.window); - cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window); - - reply_geom = xcb_get_geometry_reply(ecore_x_connection_get(), cookie_geom, NULL); - reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL); - if (reply_attr && reply_geom) - { - einfo->info.visual = xcb_visualtype_get(ecore_x_default_screen_get(), reply_attr->visual); - einfo->info.colormap = reply_attr->colormap; - einfo->info.depth = reply_geom->depth; - einfo->info.destination_alpha = 1; - free(reply_geom); - free(reply_attr); - } - } - else - { - xcb_screen_t *screen; - - screen = ecore_x_default_screen_get(); - einfo->info.visual = xcb_visualtype_get(screen, screen->root_visual); - einfo->info.colormap = screen->default_colormap; - einfo->info.depth = screen->root_depth; - einfo->info.destination_alpha = 0; - } - einfo->info.rotation = 0; - einfo->info.debug = redraw_debug; - if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) - { - WRN("evas_engine_info_set() init engine '%s' failed.", ee->driver); - ecore_evas_free(ee); - return NULL; - } + xcb_screen_iterator_t iter; + xcb_screen_t *screen; + + /* FIXME: this is inefficient as its a round trip */ + //einfo->info.backend = 1; + screen = ecore_x_default_screen_get(); + iter = xcb_setup_roots_iterator (xcb_get_setup (ecore_x_connection_get())); + if (iter.rem > 1) + { + xcb_get_geometry_cookie_t cookie; + xcb_get_geometry_reply_t *reply; + Ecore_X_Window *roots; + int num; + uint8_t i; + + num = 0; + cookie = xcb_get_geometry_unchecked(ecore_x_connection_get(), parent); + roots = ecore_x_window_root_list(&num); + if (roots) + { + reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL); + + if (reply) + { + for (i = 0; i < num; xcb_screen_next (&iter), i++) + { + if (reply->root == roots[i]) + { + screen = iter.data; + break; + } + } + free(reply); + } + free(roots); + } + else + { + reply = xcb_get_geometry_reply(ecore_x_connection_get(), cookie, NULL); + if (reply) free(reply); + } + } + + if (redraw_debug < 0) + { + if (getenv("REDRAW_DEBUG")) + redraw_debug = atoi(getenv("REDRAW_DEBUG")); + else + redraw_debug = 0; + } + einfo->info.connection = ecore_x_connection_get(); + einfo->info.screen = screen; + einfo->info.drawable = ee->prop.window; + if (argb) + { + /* FIXME: round trip */ + xcb_get_geometry_cookie_t cookie_geom; + xcb_get_window_attributes_cookie_t cookie_attr; + xcb_get_geometry_reply_t *reply_geom; + xcb_get_window_attributes_reply_t *reply_attr; + + cookie_geom = xcb_get_geometry_unchecked(ecore_x_connection_get(), ee->prop.window); + cookie_attr = xcb_get_window_attributes_unchecked(ecore_x_connection_get(), ee->prop.window); + + reply_geom = xcb_get_geometry_reply(ecore_x_connection_get(), cookie_geom, NULL); + reply_attr = xcb_get_window_attributes_reply(ecore_x_connection_get(), cookie_attr, NULL); + if (reply_attr && reply_geom) + { + einfo->info.visual = xcb_visualtype_get(ecore_x_default_screen_get(), reply_attr->visual); + einfo->info.colormap = reply_attr->colormap; + einfo->info.depth = reply_geom->depth; + einfo->info.destination_alpha = 1; + free(reply_geom); + free(reply_attr); + } + } + else + { + xcb_screen_t *screen; + + screen = ecore_x_default_screen_get(); + einfo->info.visual = xcb_visualtype_get(screen, screen->root_visual); + einfo->info.colormap = screen->default_colormap; + einfo->info.depth = screen->root_depth; + einfo->info.destination_alpha = 0; + } + einfo->info.rotation = 0; + einfo->info.debug = redraw_debug; + if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo)) + { + ERR("evas_engine_info_set() init engine '%s' failed.", ee->driver); + ecore_evas_free(ee); + return NULL; + } } ecore_x_icccm_hints_set(ee->prop.window, @@ -4325,6 +4315,10 @@ ecore_evas_software_x11_8_new(const char *disp_name, Ecore_X_Window parent, 0 /* icon_window */, 0 /* window_group */, 0 /* is_urgent */); + _ecore_evas_x_group_leader_set(ee); + ecore_x_window_defaults_set(ee->prop.window); + _ecore_evas_x_protocols_set(ee); + _ecore_evas_x_sync_set(ee); ee->engine.func->fn_render = _ecore_evas_x_render; _ecore_evas_register(ee); @@ -4334,6 +4328,12 @@ ecore_evas_software_x11_8_new(const char *disp_name, Ecore_X_Window parent, return ee; #else return NULL; + disp_name = NULL; + parent = 0; + x = 0; + y = 0; + w = 0; + h = 0; #endif /* ! BUILD_ECORE_EVAS_SOFTWARE_8_X11 */ } @@ -4349,6 +4349,7 @@ ecore_evas_software_x11_8_window_get(const Ecore_Evas *ee) return (Ecore_X_Window) ecore_evas_window_get(ee); #else return 0; + ee = NULL; #endif } @@ -4364,6 +4365,7 @@ ecore_evas_software_x11_8_subwindow_get(const Ecore_Evas *ee) return (Ecore_X_Window) ecore_evas_window_get(ee); #else return 0; + ee = NULL; #endif } @@ -4373,30 +4375,32 @@ ecore_evas_software_x11_8_subwindow_get(const Ecore_Evas *ee) * FIXME: To be fixed. */ EAPI void -ecore_evas_software_x11_8_direct_resize_set(Ecore_Evas *ee, int on) +ecore_evas_software_x11_8_direct_resize_set(Ecore_Evas *ee, Eina_Bool on) { #if defined (BUILD_ECORE_EVAS_SOFTWARE_8_X11) ee->engine.x.direct_resize = on; if (ee->prop.avoid_damage) { - if (ee->engine.x.direct_resize) - { - /* turn this off for now - ee->engine.x.using_bg_pixmap = 1; - ecore_x_window_pixmap_set(ee->engine.x.win, ee->engine.x.pmap); - */ - } - else - { - /* turn this off too- bg pixmap is controlled by avoid damage directly - ee->engine.x.using_bg_pixmap = 0; - ecore_x_window_pixmap_set(ee->engine.x.win, 0); - ecore_x_window_area_expose(ee->engine.x.win, 0, 0, ee->w, ee->h); - */ - } + if (ee->engine.x.direct_resize) + { + /* turn this off for now + ee->engine.x.using_bg_pixmap = 1; + ecore_x_window_pixmap_set(ee->engine.x.win, ee->engine.x.pmap); + */ + } + else + { + /* turn this off too- bg pixmap is controlled by avoid damage directly + ee->engine.x.using_bg_pixmap = 0; + ecore_x_window_pixmap_set(ee->engine.x.win, 0); + ecore_x_window_area_expose(ee->engine.x.win, 0, 0, ee->w, ee->h); + */ + } } #else return; + ee = NULL; + on = 0; #endif } @@ -4405,13 +4409,14 @@ ecore_evas_software_x11_8_direct_resize_set(Ecore_Evas *ee, int on) * * FIXME: To be fixed. */ -EAPI int +EAPI Eina_Bool ecore_evas_software_x11_8_direct_resize_get(const Ecore_Evas *ee) { #if defined (BUILD_ECORE_EVAS_SOFTWARE_8_X11) return ee->engine.x.direct_resize; #else return 0; + ee = NULL; #endif } @@ -4429,11 +4434,52 @@ ecore_evas_software_x11_8_extra_event_window_add(Ecore_Evas *ee, Ecore_X_Window winp = malloc(sizeof(Ecore_X_Window)); if (winp) { - *winp = win; - ee->engine.x.win_extra = eina_list_append(ee->engine.x.win_extra, winp); + *winp = win; + ee->engine.x.win_extra = eina_list_append(ee->engine.x.win_extra, winp); ecore_x_input_multi_select(win); - ecore_event_window_register(win, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process); + ecore_event_window_register(win, ee, ee->evas, (Ecore_Event_Mouse_Move_Cb) _ecore_evas_mouse_move_process); } #else + return; + ee = NULL; + win = 0; +#endif +} + +EAPI void +ecore_evas_x11_leader_set(Ecore_Evas *ee, Ecore_X_Window win) +{ +#ifdef BUILD_ECORE_EVAS_X11 + _ecore_evas_x_group_leader_unset(ee); + ee->engine.x.leader = win; + _ecore_evas_x_group_leader_update(ee); +#else + return; + ee = NULL; + win = 0; +#endif +} + +EAPI Ecore_X_Window +ecore_evas_x11_leader_get(Ecore_Evas *ee) +{ +#ifdef BUILD_ECORE_EVAS_X11 + return ee->engine.x.leader; +#else + return 0; + ee = NULL; +#endif +} + +EAPI void +ecore_evas_x11_leader_default_set(Ecore_Evas *ee) +{ +#ifdef BUILD_ECORE_EVAS_X11 + _ecore_evas_x_group_leader_unset(ee); + _ecore_evas_x_group_leader_set(ee); +#else + return; + ee = NULL; #endif } + diff --git a/src/lib/ecore_fb/Ecore_Fb.h b/src/lib/ecore_fb/Ecore_Fb.h index 5374817..416ab9d 100644 --- a/src/lib/ecore_fb/Ecore_Fb.h +++ b/src/lib/ecore_fb/Ecore_Fb.h @@ -1,37 +1,27 @@ #ifndef _ECORE_FB_H #define _ECORE_FB_H +#include + #ifdef EAPI -#undef EAPI +# undef EAPI #endif -#ifdef _MSC_VER -# ifdef BUILDING_DLL -# define EAPI __declspec(dllexport) -# else -# define EAPI __declspec(dllimport) -# endif -#else -# ifdef __GNUC__ -# if __GNUC__ >= 4 -# define EAPI __attribute__ ((visibility("default"))) -# else -# define EAPI -# endif + +#ifdef __GNUC__ +# if __GNUC__ >= 4 +# define EAPI __attribute__ ((visibility("default"))) # else # define EAPI # endif +#else +# define EAPI #endif -/** - * @file - * @brief Ecore frame buffer system functions. - */ - /* FIXME: * maybe a new module? * - code to get battery info * - code to get thermal info - * ecore evas fb isnt good enough for weird things, like multiple fb's, same happens here. + * ecore evas fb isn't good enough for weird things, like multiple fb's, same happens here. * backlight support using new kernel interface * absolute axis * joystick @@ -43,16 +33,36 @@ extern "C" { #endif -typedef struct _Ecore_Fb_Input_Device Ecore_Fb_Input_Device; /* an input device handler */ +/** + * @defgroup Ecore_FB_Group Ecore_FB - Frame buffer convenience functions. + * + * Functions used to set up and shut down the Ecore_Framebuffer functions. + * + * @{ + */ + +/** + * @typedef Ecore_Fb_Input_Device + * Input device handler. + */ +typedef struct _Ecore_Fb_Input_Device Ecore_Fb_Input_Device; -/* device capabilities */ +/** + * @enum _Ecore_Fb_Input_Device_Cap + * Device capabilities. + */ enum _Ecore_Fb_Input_Device_Cap { ECORE_FB_INPUT_DEVICE_CAP_NONE = 0x00000000, - ECORE_FB_INPUT_DEVICE_CAP_RELATIVE = 0x00000001, - ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE = 0x00000002, - ECORE_FB_INPUT_DEVICE_CAP_KEYS_OR_BUTTONS = 0x00000004 + ECORE_FB_INPUT_DEVICE_CAP_RELATIVE = 0x00000001, + ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE = 0x00000002, + ECORE_FB_INPUT_DEVICE_CAP_KEYS_OR_BUTTONS = 0x00000004 }; + +/** + * @typedef Ecore_Fb_Input_Device_Cap + * Device capabilities. + */ typedef enum _Ecore_Fb_Input_Device_Cap Ecore_Fb_Input_Device_Cap; EAPI extern int ECORE_FB_EVENT_KEY_DOWN; /**< FB Key Down event */ @@ -69,23 +79,35 @@ typedef struct _Ecore_Fb_Event_Mouse_Button_Up Ecore_Fb_Event_Mouse_Button_Up; typedef struct _Ecore_Fb_Event_Mouse_Move Ecore_Fb_Event_Mouse_Move; /**< FB Mouse Move event */ typedef struct _Ecore_Fb_Event_Mouse_Wheel Ecore_Fb_Event_Mouse_Wheel; /**< FB Mouse Wheel event */ -struct _Ecore_Fb_Event_Key_Down /** FB Key Down event */ +/** + * @struct _Ecore_Fb_Event_Key_Down + * Framebuffer Key Down event. + */ +struct _Ecore_Fb_Event_Key_Down { Ecore_Fb_Input_Device *dev; /**< The device associated with the event */ char *keyname; /**< The name of the key that was pressed */ char *keysymbol; /**< The logical symbol of the key that was pressed */ char *key_compose; /**< The UTF-8 string conversion if any */ }; - -struct _Ecore_Fb_Event_Key_Up /** FB Key Up event */ + +/** + * @struct _Ecore_Fb_Event_Key_Up + * Framebuffer Key Up event. + */ +struct _Ecore_Fb_Event_Key_Up { Ecore_Fb_Input_Device *dev; /**< The device associated with the event */ char *keyname; /**< The name of the key that was released */ char *keysymbol; /**< The logical symbol of the key that was pressed */ char *key_compose; /**< The UTF-8 string conversion if any */ }; - -struct _Ecore_Fb_Event_Mouse_Button_Down /** FB Mouse Down event */ + +/** + * @struct _Ecore_Fb_Event_Mouse_Button_Down + * Framebuffer Mouse Down event. + */ +struct _Ecore_Fb_Event_Mouse_Button_Down { Ecore_Fb_Input_Device *dev; /**< The device associated with the event */ int button; /**< Mouse button that was pressed (1 - 32) */ @@ -94,23 +116,37 @@ struct _Ecore_Fb_Event_Mouse_Button_Down /** FB Mouse Down event */ int double_click : 1; /**< Set if click was a double click */ int triple_click : 1; /**< Set if click was a triple click */ }; - -struct _Ecore_Fb_Event_Mouse_Button_Up /** FB Mouse Up event */ + +/** + * @struct _Ecore_Fb_Event_Mouse_Button_Up + * Framebuffer Mouse Up event. + */ +struct _Ecore_Fb_Event_Mouse_Button_Up { Ecore_Fb_Input_Device *dev; /**< The device associated with the event */ int button; /**< Mouse button that was released (1 - 32) */ int x; /**< Mouse co-ordinates when mouse button was raised */ int y; /**< Mouse co-ordinates when mouse button was raised */ + int double_click : 1; /**< Set if click was a double click */ + int triple_click : 1; /**< Set if click was a triple click */ }; - -struct _Ecore_Fb_Event_Mouse_Move /** FB Mouse Move event */ + +/** + * @struct _Ecore_Fb_Event_Mouse_Move + * Framebuffer Mouse Move event. + */ +struct _Ecore_Fb_Event_Mouse_Move { Ecore_Fb_Input_Device *dev; /**< The device associated with the event */ int x; /**< Mouse co-ordinates where the mouse cursor moved to */ int y; /**< Mouse co-ordinates where the mouse cursor moved to */ }; - -struct _Ecore_Fb_Event_Mouse_Wheel /** FB Mouse Wheel event */ + +/** + * @struct _Ecore_Fb_Event_Mouse_Wheel + * Framebuffer Mouse Wheel event. + */ +struct _Ecore_Fb_Event_Mouse_Wheel { Ecore_Fb_Input_Device *dev; int x,y; @@ -119,25 +155,32 @@ struct _Ecore_Fb_Event_Mouse_Wheel /** FB Mouse Wheel event */ }; /* ecore_fb_vt.c */ -EAPI void ecore_fb_callback_gain_set(void (*func) (void *data), void *data); -EAPI void ecore_fb_callback_lose_set(void (*func) (void *data), void *data); +EAPI void ecore_fb_callback_gain_set(void (*func) (void *data), void *data); +EAPI void ecore_fb_callback_lose_set(void (*func) (void *data), void *data); + /* ecore_fb_li.c */ -EAPI Ecore_Fb_Input_Device *ecore_fb_input_device_open(const char *dev); -EAPI void ecore_fb_input_device_close(Ecore_Fb_Input_Device *dev); -EAPI void ecore_fb_input_device_listen(Ecore_Fb_Input_Device *dev, int listen); -EAPI const char *ecore_fb_input_device_name_get(Ecore_Fb_Input_Device *dev); -EAPI Ecore_Fb_Input_Device_Cap ecore_fb_input_device_cap_get(Ecore_Fb_Input_Device *dev); -EAPI void ecore_fb_input_device_axis_size_set(Ecore_Fb_Input_Device *dev, int w, int h); -EAPI void ecore_fb_input_threshold_click_set(Ecore_Fb_Input_Device *dev, double threshold); -EAPI double ecore_fb_input_threshold_click_get(Ecore_Fb_Input_Device *dev); +EAPI Ecore_Fb_Input_Device *ecore_fb_input_device_open(const char *dev); +EAPI void ecore_fb_input_device_close(Ecore_Fb_Input_Device *dev); +EAPI void ecore_fb_input_device_listen(Ecore_Fb_Input_Device *dev, Eina_Bool listen); +EAPI const char *ecore_fb_input_device_name_get(Ecore_Fb_Input_Device *dev); +EAPI Ecore_Fb_Input_Device_Cap ecore_fb_input_device_cap_get(Ecore_Fb_Input_Device *dev); +EAPI void ecore_fb_input_device_axis_size_set(Ecore_Fb_Input_Device *dev, int w, int h); +EAPI void ecore_fb_input_threshold_click_set(Ecore_Fb_Input_Device *dev, double threshold); +EAPI double ecore_fb_input_threshold_click_get(Ecore_Fb_Input_Device *dev); + /* ecore_fb.c */ -EAPI int ecore_fb_init(const char *name); -EAPI int ecore_fb_shutdown(void); -EAPI void ecore_fb_size_get(int *w, int *h); -EAPI void ecore_fb_touch_screen_calibrate_set(int xscale, int xtrans, int yscale, int ytrans, int xyswap); -EAPI void ecore_fb_touch_screen_calibrate_get(int *xscale, int *xtrans, int *yscale, int *ytrans, int *xyswap); - +EAPI int ecore_fb_init(const char *name); +EAPI int ecore_fb_shutdown(void); +EAPI void ecore_fb_size_get(int *w, int *h); + +EAPI void ecore_fb_touch_screen_calibrate_set(int xscale, int xtrans, int yscale, int ytrans, int xyswap); +EAPI void ecore_fb_touch_screen_calibrate_get(int *xscale, int *xtrans, int *yscale, int *ytrans, int *xyswap); + +/** + * @} + */ + #ifdef __cplusplus } #endif diff --git a/src/lib/ecore_fb/ecore_fb.c b/src/lib/ecore_fb/ecore_fb.c index 3507ed7..53b379b 100644 --- a/src/lib/ecore_fb/ecore_fb.c +++ b/src/lib/ecore_fb/ecore_fb.c @@ -18,31 +18,34 @@ static int _ecore_fb_init_count = 0; static int _ecore_fb_console_w = 0; static int _ecore_fb_console_h = 0; -static double _ecore_fb_double_click_time = 0.25; - - /** - * @defgroup Ecore_FB_Library_Group Framebuffer Library Functions + * @addtogroup Ecore_FB_Group Ecore_FB - Frame buffer convenience functions. * - * Functions used to set up and shut down the Ecore_Framebuffer functions. + * @{ */ /** - * Sets up the Ecore_Fb library. - * @param name device target name - * @return @c 0 on failure. Otherwise, the number of times the library has - * been initialised without being shut down. - * @ingroup Ecore_FB_Library_Group + * @brief Initialize the Ecore_Fb library. + * + * @param name Device target name. + * @return 1 or greater on success, 0 on error. + * + * This function sets up all the Ecore_Fb library. It returns 0 on + * failure, otherwise it returns the number of times it has already + * been called. + * + * When Ecore_Fb is not used anymore, call ecore_fb_shutdown() to shut down + * the Ecore_Fb library. */ EAPI int ecore_fb_init(const char *name __UNUSED__) { if (++_ecore_fb_init_count != 1) - return _ecore_fb_init_count; - + return _ecore_fb_init_count; + if (!ecore_fb_vt_init()) - return --_ecore_fb_init_count; - + return --_ecore_fb_init_count; + ECORE_FB_EVENT_KEY_DOWN = ecore_event_type_new(); ECORE_FB_EVENT_KEY_UP = ecore_event_type_new(); ECORE_FB_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new(); @@ -55,16 +58,19 @@ ecore_fb_init(const char *name __UNUSED__) } /** - * Shuts down the Ecore_Fb library. - * @return @c The number of times the system has been initialised without - * being shut down. - * @ingroup Ecore_FB_Library_Group + * @brief Shut down the Ecore_Fb library. + * + * @return 0 when the library is completely shut down, 1 or + * greater otherwise. + * + * This function shuts down the Ecore_Fb library. It returns 0 when it has + * been called the same number of times than ecore_fb_init(). */ EAPI int ecore_fb_shutdown(void) { if (--_ecore_fb_init_count != 0) - return _ecore_fb_init_count; + return _ecore_fb_init_count; ecore_fb_vt_shutdown(); @@ -73,9 +79,16 @@ ecore_fb_shutdown(void) /** - * Retrieves the width and height of the current frame buffer in pixels. + * @brief Retrieve the width and height of the current frame buffer in + * pixels. + * * @param w Pointer to an integer in which to store the width. * @param h Pointer to an interge in which to store the height. + * + * This function retrieves the size of the current frame buffer in + * pixels. @p w and @p h can be buffers that will be filled with the + * corresponding values. If one of them is @c NULL, nothing will be + * done for that parameter. */ EAPI void ecore_fb_size_get(int *w, int *h) @@ -93,18 +106,22 @@ _ecore_fb_size_get(int *w, int *h) fb = open("/dev/fb0", O_RDWR); if (fb < 0) { - if (w) *w = 0; - if (h) *h = 0; - return; + if (w) *w = 0; + if (h) *h = 0; + return; } if (ioctl(fb, FBIOGET_VSCREENINFO, &fb_var) == -1) { - if (w) *w = 0; - if (h) *h = 0; + if (w) *w = 0; + if (h) *h = 0; close(fb); - return; + return; } close(fb); if (w) *w = fb_var.xres; if (h) *h = fb_var.yres; } + +/** + * @} + */ diff --git a/src/lib/ecore_fb/ecore_fb_kbd.c b/src/lib/ecore_fb/ecore_fb_kbd.c index aa8190e..5d2a6a6 100644 --- a/src/lib/ecore_fb/ecore_fb_kbd.c +++ b/src/lib/ecore_fb/ecore_fb_kbd.c @@ -160,116 +160,116 @@ _ecore_fb_kbd_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __U do { - unsigned char buf; - - v = read(_ecore_fb_kbd_fd, &buf, 1); - if (v < 0) return EINA_TRUE; - if (v < 1) return EINA_TRUE; - if (!(buf & 0x80)) - { - /* DOWN */ - int vt_switch = -1; - Ecore_Fb_Event_Key_Down *e; - - e = calloc(1, sizeof(Ecore_Fb_Event_Key_Down)); - if (!e) goto retry; - if (_ecore_fb_kbd_fd == _ecore_fb_tty_fd) - { - int add = 0; - - if (_ecore_fb_shift) add = 1; - else if (_ecore_fb_lock) add = 2; - e->keyname = strdup(_ecore_fb_kbd_syms[(buf & 0x7f) * 6]); - e->keysymbol = strdup(_ecore_fb_kbd_syms[((buf & 0x7f) * 6) + add]); - e->key_compose = strdup(_ecore_fb_kbd_syms[((buf & 0x7f) * 6) + 3 + add]); - } - else - e->keyname = strdup(_ecore_fb_btn_syms[buf & 0x7f]); - if (!e->keyname) - { - free(e); - goto retry; - } - ecore_event_add(ECORE_FB_EVENT_KEY_DOWN, e, _ecore_fb_event_free_key_down, NULL); - if (!strcmp(e->keyname, "Control_L")) - _ecore_fb_ctrl++; - else if (!strcmp(e->keyname, "Control_R")) - _ecore_fb_ctrl++; - else if (!strcmp(e->keyname, "Alt_L")) - _ecore_fb_alt++; - else if (!strcmp(e->keyname, "Alt_R")) - _ecore_fb_alt++; - else if (!strcmp(e->keyname, "Shift_L")) - _ecore_fb_shift++; - else if (!strcmp(e->keyname, "Shift_R")) - _ecore_fb_shift++; - else if (!strcmp(e->keyname, "Caps_Lock")) - _ecore_fb_lock++; - else if (!strcmp(e->keyname, "F1")) vt_switch = 0; - else if (!strcmp(e->keyname, "F2")) vt_switch = 1; - else if (!strcmp(e->keyname, "F3")) vt_switch = 2; - else if (!strcmp(e->keyname, "F4")) vt_switch = 3; - else if (!strcmp(e->keyname, "F5")) vt_switch = 4; - else if (!strcmp(e->keyname, "F6")) vt_switch = 5; - else if (!strcmp(e->keyname, "F7")) vt_switch = 6; - else if (!strcmp(e->keyname, "F8")) vt_switch = 7; - else if (!strcmp(e->keyname, "F9")) vt_switch = 8; - else if (!strcmp(e->keyname, "F10")) vt_switch = 9; - else if (!strcmp(e->keyname, "F11")) vt_switch = 10; - else if (!strcmp(e->keyname, "F12")) vt_switch = 11; - if (_ecore_fb_ctrl > 2) _ecore_fb_ctrl = 2; - if (_ecore_fb_alt > 2) _ecore_fb_alt = 2; - if ((vt_switch >= 0) && - (_ecore_fb_ctrl) && - (_ecore_fb_alt)) - _ecore_fb_vt_switch(vt_switch); - } - else - { - /* UP */ - Ecore_Fb_Event_Key_Up *e; - - e = calloc(1, sizeof(Ecore_Fb_Event_Key_Up)); - if (!e) goto retry; - if (_ecore_fb_kbd_fd == _ecore_fb_tty_fd) - { - int add = 0; - - if (_ecore_fb_shift) add = 1; - else if (_ecore_fb_lock) add = 2; - e->keyname = strdup(_ecore_fb_kbd_syms[(buf & 0x7f) * 6]); - e->keysymbol = strdup(_ecore_fb_kbd_syms[((buf & 0x7f) * 6) + add]); - e->key_compose = strdup(_ecore_fb_kbd_syms[((buf & 0x7f) * 6) + 3 + add]); - } - else - e->keyname = strdup(_ecore_fb_btn_syms[buf & 0x7f]); - if (!e->keyname) - { - free(e); - goto retry; - } - ecore_event_add(ECORE_FB_EVENT_KEY_UP, e, _ecore_fb_event_free_key_up, NULL); - if (!strcmp(e->keyname, "Control_L")) - _ecore_fb_ctrl--; - else if (!strcmp(e->keyname, "Control_R")) - _ecore_fb_ctrl--; - else if (!strcmp(e->keyname, "Alt_L")) - _ecore_fb_alt--; - else if (!strcmp(e->keyname, "Alt_R")) - _ecore_fb_alt--; - else if (!strcmp(e->keyname, "Shift_L")) - _ecore_fb_shift--; - else if (!strcmp(e->keyname, "Shift_R")) - _ecore_fb_shift--; - else if (!strcmp(e->keyname, "Caps_Lock")) - _ecore_fb_lock--; - if (_ecore_fb_ctrl < 0) _ecore_fb_ctrl = 0; - if (_ecore_fb_alt < 0) _ecore_fb_alt = 0; - if (_ecore_fb_shift < 0) _ecore_fb_shift = 0; - if (_ecore_fb_lock < 0) _ecore_fb_lock = 0; - } - retry: - ; + unsigned char buf; + + v = read(_ecore_fb_kbd_fd, &buf, 1); + if (v < 0) return EINA_TRUE; + if (v < 1) return EINA_TRUE; + if (!(buf & 0x80)) + { + /* DOWN */ + int vt_switch = -1; + Ecore_Fb_Event_Key_Down *e; + + e = calloc(1, sizeof(Ecore_Fb_Event_Key_Down)); + if (!e) goto retry; + if (_ecore_fb_kbd_fd == _ecore_fb_tty_fd) + { + int add = 0; + + if (_ecore_fb_shift) add = 1; + else if (_ecore_fb_lock) add = 2; + e->keyname = strdup(_ecore_fb_kbd_syms[(buf & 0x7f) * 6]); + e->keysymbol = strdup(_ecore_fb_kbd_syms[((buf & 0x7f) * 6) + add]); + e->key_compose = strdup(_ecore_fb_kbd_syms[((buf & 0x7f) * 6) + 3 + add]); + } + else + e->keyname = strdup(_ecore_fb_btn_syms[buf & 0x7f]); + if (!e->keyname) + { + free(e); + goto retry; + } + ecore_event_add(ECORE_FB_EVENT_KEY_DOWN, e, _ecore_fb_event_free_key_down, NULL); + if (!strcmp(e->keyname, "Control_L")) + _ecore_fb_ctrl++; + else if (!strcmp(e->keyname, "Control_R")) + _ecore_fb_ctrl++; + else if (!strcmp(e->keyname, "Alt_L")) + _ecore_fb_alt++; + else if (!strcmp(e->keyname, "Alt_R")) + _ecore_fb_alt++; + else if (!strcmp(e->keyname, "Shift_L")) + _ecore_fb_shift++; + else if (!strcmp(e->keyname, "Shift_R")) + _ecore_fb_shift++; + else if (!strcmp(e->keyname, "Caps_Lock")) + _ecore_fb_lock++; + else if (!strcmp(e->keyname, "F1")) vt_switch = 0; + else if (!strcmp(e->keyname, "F2")) vt_switch = 1; + else if (!strcmp(e->keyname, "F3")) vt_switch = 2; + else if (!strcmp(e->keyname, "F4")) vt_switch = 3; + else if (!strcmp(e->keyname, "F5")) vt_switch = 4; + else if (!strcmp(e->keyname, "F6")) vt_switch = 5; + else if (!strcmp(e->keyname, "F7")) vt_switch = 6; + else if (!strcmp(e->keyname, "F8")) vt_switch = 7; + else if (!strcmp(e->keyname, "F9")) vt_switch = 8; + else if (!strcmp(e->keyname, "F10")) vt_switch = 9; + else if (!strcmp(e->keyname, "F11")) vt_switch = 10; + else if (!strcmp(e->keyname, "F12")) vt_switch = 11; + if (_ecore_fb_ctrl > 2) _ecore_fb_ctrl = 2; + if (_ecore_fb_alt > 2) _ecore_fb_alt = 2; + if ((vt_switch >= 0) && + (_ecore_fb_ctrl) && + (_ecore_fb_alt)) + _ecore_fb_vt_switch(vt_switch); + } + else + { + /* UP */ + Ecore_Fb_Event_Key_Up *e; + + e = calloc(1, sizeof(Ecore_Fb_Event_Key_Up)); + if (!e) goto retry; + if (_ecore_fb_kbd_fd == _ecore_fb_tty_fd) + { + int add = 0; + + if (_ecore_fb_shift) add = 1; + else if (_ecore_fb_lock) add = 2; + e->keyname = strdup(_ecore_fb_kbd_syms[(buf & 0x7f) * 6]); + e->keysymbol = strdup(_ecore_fb_kbd_syms[((buf & 0x7f) * 6) + add]); + e->key_compose = strdup(_ecore_fb_kbd_syms[((buf & 0x7f) * 6) + 3 + add]); + } + else + e->keyname = strdup(_ecore_fb_btn_syms[buf & 0x7f]); + if (!e->keyname) + { + free(e); + goto retry; + } + ecore_event_add(ECORE_FB_EVENT_KEY_UP, e, _ecore_fb_event_free_key_up, NULL); + if (!strcmp(e->keyname, "Control_L")) + _ecore_fb_ctrl--; + else if (!strcmp(e->keyname, "Control_R")) + _ecore_fb_ctrl--; + else if (!strcmp(e->keyname, "Alt_L")) + _ecore_fb_alt--; + else if (!strcmp(e->keyname, "Alt_R")) + _ecore_fb_alt--; + else if (!strcmp(e->keyname, "Shift_L")) + _ecore_fb_shift--; + else if (!strcmp(e->keyname, "Shift_R")) + _ecore_fb_shift--; + else if (!strcmp(e->keyname, "Caps_Lock")) + _ecore_fb_lock--; + if (_ecore_fb_ctrl < 0) _ecore_fb_ctrl = 0; + if (_ecore_fb_alt < 0) _ecore_fb_alt = 0; + if (_ecore_fb_shift < 0) _ecore_fb_shift = 0; + if (_ecore_fb_lock < 0) _ecore_fb_lock = 0; + } +retry: + ; } while (v > 0); return EINA_TRUE; @@ -283,9 +283,9 @@ ecore_fb_kbd_init(void) prev_flags = fcntl(_ecore_fb_kbd_fd, F_GETFL); fcntl(_ecore_fb_kbd_fd, F_SETFL, prev_flags | O_NONBLOCK); _ecore_fb_kbd_fd_handler_handle = ecore_main_fd_handler_add(_ecore_fb_kbd_fd, - ECORE_FD_READ, - _ecore_fb_kbd_fd_handler, NULL, - NULL, NULL); + ECORE_FD_READ, + _ecore_fb_kbd_fd_handler, NULL, + NULL, NULL); if(!_ecore_fb_kbd_fd_handler_handle) return 0; return 1; } @@ -294,7 +294,7 @@ void ecore_fb_kbd_shutdown(void) { if (_ecore_fb_kbd_fd_handler_handle) - ecore_main_fd_handler_del(_ecore_fb_kbd_fd_handler_handle); + ecore_main_fd_handler_del(_ecore_fb_kbd_fd_handler_handle); if (_ecore_fb_kbd_fd >= 0) close(_ecore_fb_kbd_fd); _ecore_fb_kbd_fd = 0; _ecore_fb_kbd_fd_handler_handle = NULL; diff --git a/src/lib/ecore_fb/ecore_fb_keytable.h b/src/lib/ecore_fb/ecore_fb_keytable.h index ff03497..c943cfd 100644 --- a/src/lib/ecore_fb/ecore_fb_keytable.h +++ b/src/lib/ecore_fb/ecore_fb_keytable.h @@ -83,7 +83,7 @@ "KP_Next", "KP_3", "KP_Next", /**/"", "3", "",/***/ "KP_Insert", "KP_0", "KP_Insert", /**/"", "0", "",/***/ "KP_Delete", "KP_Decimal", "KP_Delete", /**/"", ".", "",/***/ - "0x54", "0x54", "0x54", /**/"", "", "",/***/ + "0x54", "0x54", "0x54", /**/"", "", "",/***/ "0x55", "0x55", "0x55", /**/"", "", "",/***/ "0x56", "0x56", "0x56", /**/"", "", "",/***/ "F11", "F11", "F11", /**/"", "", "",/***/ diff --git a/src/lib/ecore_fb/ecore_fb_li.c b/src/lib/ecore_fb/ecore_fb_li.c index cc04b5a..b25c28e 100644 --- a/src/lib/ecore_fb/ecore_fb_li.c +++ b/src/lib/ecore_fb/ecore_fb_li.c @@ -22,552 +22,595 @@ static const char *_ecore_fb_li_kbd_syms[128 * 6] = * Moved to static inline in order to force compiler to otimized * the unsued part away or force a link error if long has an unexpected * size. - * - bigeasy + * - bigeasy */ extern int long_has_neither_32_nor_64_bits(void); -static inline int test_bit(int bit, unsigned long *array) +static inline int +test_bit(int bit, unsigned long *array) { - if (sizeof(long) == 4) - return array[bit / 32] & (1 << (bit % 32)); - - else if (sizeof(long) == 8) - return array[bit / 64] & (1 << (bit % 64)); - - else long_has_neither_32_nor_64_bits(); + if (sizeof(long) == 4) + return array[bit / 32] & (1 << (bit % 32)); + else if (sizeof(long) == 8) + return array[bit / 64] & (1 << (bit % 64)); + else long_has_neither_32_nor_64_bits(); } -static void -_ecore_fb_li_event_free_key_down(void *data, void *ev) +static void +_ecore_fb_li_event_free_key_down(void *data __UNUSED__, void *ev) { + Ecore_Fb_Event_Key_Up *e; - Ecore_Fb_Event_Key_Up *e; - - e = ev; - free(e->keyname); - if (e->keysymbol) free(e->keysymbol); - if (e->key_compose) free(e->key_compose); - free(e); + e = ev; + free(e->keyname); + if (e->keysymbol) free(e->keysymbol); + if (e->key_compose) free(e->key_compose); + free(e); } -static void -_ecore_fb_li_event_free_key_up(void *data, void *ev) +static void +_ecore_fb_li_event_free_key_up(void *data __UNUSED__, void *ev) { + Ecore_Fb_Event_Key_Up *e; - Ecore_Fb_Event_Key_Up *e; - - e = ev; - free(e->keyname); - if (e->keysymbol) free(e->keysymbol); - if (e->key_compose) free(e->key_compose); - free(e); + e = ev; + free(e->keyname); + if (e->keysymbol) free(e->keysymbol); + if (e->key_compose) free(e->key_compose); + free(e); } static void _ecore_fb_li_device_event_key(Ecore_Fb_Input_Device *dev, struct input_event *iev) { - if(!dev->listen) - return; - - /* check for basic keyboard keys */ - if(iev->code >= KEY_ESC && iev->code <= KEY_COMPOSE) - { - /* check the key table */ - if(iev->value) - { - int offset = 0; - Ecore_Fb_Event_Key_Down *ev; - - ev = calloc(1, sizeof(Ecore_Fb_Event_Key_Down)); - if(dev->keyboard.shift) offset = 1; - else if(dev->keyboard.lock) offset = 2; - ev->keyname = strdup(_ecore_fb_li_kbd_syms[iev->code * 6]); - - ev->keysymbol = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + offset]); - ev->key_compose = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + 3 + offset]); - ev->dev = dev; - ecore_event_add(ECORE_FB_EVENT_KEY_DOWN, ev, _ecore_fb_li_event_free_key_down, NULL); - /* its a repeated key, dont increment */ - if(iev->value == 2) - return; - if (!strcmp(ev->keyname, "Control_L")) - dev->keyboard.ctrl++; - else if (!strcmp(ev->keyname, "Control_R")) - dev->keyboard.ctrl++; - else if (!strcmp(ev->keyname, "Alt_L")) - dev->keyboard.alt++; - else if (!strcmp(ev->keyname, "Alt_R")) - dev->keyboard.alt++; - else if (!strcmp(ev->keyname, "Shift_L")) - dev->keyboard.shift++; - else if (!strcmp(ev->keyname, "Shift_R")) - dev->keyboard.shift++; - else if (!strcmp(ev->keyname, "Caps_Lock")) - dev->keyboard.lock++; - if (dev->keyboard.ctrl > 2) dev->keyboard.ctrl = 2; - if (dev->keyboard.alt > 2) dev->keyboard.alt = 2; - if (dev->keyboard.shift > 2) dev->keyboard.shift = 2; - if (dev->keyboard.lock > 1) dev->keyboard.lock = 1; - } - else - { - int offset = 0; - Ecore_Fb_Event_Key_Up *ev; - - ev = calloc(1, sizeof(Ecore_Fb_Event_Key_Up)); - if(dev->keyboard.shift) offset = 1; - else if(dev->keyboard.lock) offset = 2; - ev->keyname = strdup(_ecore_fb_li_kbd_syms[iev->code * 6]); - - ev->keysymbol = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + offset]); - ev->key_compose = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + 3 + offset]); - ev->dev = dev; - ecore_event_add(ECORE_FB_EVENT_KEY_UP, ev, _ecore_fb_li_event_free_key_up, NULL); - if (!strcmp(ev->keyname, "Control_L")) - dev->keyboard.ctrl--; - else if (!strcmp(ev->keyname, "Control_R")) - dev->keyboard.ctrl--; - else if (!strcmp(ev->keyname, "Alt_L")) - dev->keyboard.alt--; - else if (!strcmp(ev->keyname, "Alt_R")) - dev->keyboard.alt--; - else if (!strcmp(ev->keyname, "Shift_L")) - dev->keyboard.shift--; - else if (!strcmp(ev->keyname, "Shift_R")) - dev->keyboard.shift--; - else if (!strcmp(ev->keyname, "Caps_Lock")) - dev->keyboard.lock--; - if (dev->keyboard.ctrl < 0) dev->keyboard.ctrl = 0; - if (dev->keyboard.alt < 0) dev->keyboard.alt = 0; - if (dev->keyboard.shift < 0) dev->keyboard.shift = 0; - if (dev->keyboard.lock < 0) dev->keyboard.lock = 0; - } - } - /* check for mouse button events */ - else if(iev->code >= BTN_MOUSE && iev->code < BTN_JOYSTICK) - { - int button; - - button = ((iev->code & 0x00F) + 1); - if(iev->value) - { - Ecore_Fb_Event_Mouse_Button_Down *ev; - double current; - - ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down)); - ev->dev = dev; - ev->button = button; - ev->x = dev->mouse.x; - ev->y = dev->mouse.y; - - current = ecore_time_get(); - if((current - dev->mouse.prev) <= dev->mouse.threshold) - { - ev->double_click = 1; - } - if((current - dev->mouse.last) <= (2 * dev->mouse.threshold)) - { - ev->triple_click = 1; - /* reset */ - dev->mouse.prev = 0; - dev->mouse.last = 0; - current = 0; - } - else - { - /* update values */ - dev->mouse.last = dev->mouse.prev; - dev->mouse.prev = current; - } - ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, ev, NULL ,NULL); - } - else - { - Ecore_Fb_Event_Mouse_Button_Up *ev; - - ev = calloc(1,sizeof(Ecore_Fb_Event_Mouse_Button_Up)); - ev->dev = dev; - ev->button = button; - ev->x = dev->mouse.x; - ev->y = dev->mouse.y; - - ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, ev, NULL ,NULL); - } - } + if (!dev->listen) return; + + /* check for basic keyboard keys */ + if ((iev->code >= KEY_ESC) && (iev->code <= KEY_COMPOSE)) + { + /* check the key table */ + if (iev->value) + { + int offset = 0; + Ecore_Fb_Event_Key_Down *ev; + + ev = calloc(1, sizeof(Ecore_Fb_Event_Key_Down)); + if (dev->keyboard.shift) offset = 1; + else if (dev->keyboard.lock) offset = 2; + ev->keyname = strdup(_ecore_fb_li_kbd_syms[iev->code * 6]); + + ev->keysymbol = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + offset]); + ev->key_compose = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + 3 + offset]); + ev->dev = dev; + ecore_event_add(ECORE_FB_EVENT_KEY_DOWN, ev, _ecore_fb_li_event_free_key_down, NULL); + /* its a repeated key, dont increment */ + if (iev->value == 2) + return; + if (!strcmp(ev->keyname, "Control_L")) + dev->keyboard.ctrl++; + else if (!strcmp(ev->keyname, "Control_R")) + dev->keyboard.ctrl++; + else if (!strcmp(ev->keyname, "Alt_L")) + dev->keyboard.alt++; + else if (!strcmp(ev->keyname, "Alt_R")) + dev->keyboard.alt++; + else if (!strcmp(ev->keyname, "Shift_L")) + dev->keyboard.shift++; + else if (!strcmp(ev->keyname, "Shift_R")) + dev->keyboard.shift++; + else if (!strcmp(ev->keyname, "Caps_Lock")) + dev->keyboard.lock++; + if (dev->keyboard.ctrl > 2) dev->keyboard.ctrl = 2; + if (dev->keyboard.alt > 2) dev->keyboard.alt = 2; + if (dev->keyboard.shift > 2) dev->keyboard.shift = 2; + if (dev->keyboard.lock > 1) dev->keyboard.lock = 1; + } + else + { + int offset = 0; + Ecore_Fb_Event_Key_Up *ev; + + ev = calloc(1, sizeof(Ecore_Fb_Event_Key_Up)); + if (dev->keyboard.shift) offset = 1; + else if (dev->keyboard.lock) offset = 2; + ev->keyname = strdup(_ecore_fb_li_kbd_syms[iev->code * 6]); + + ev->keysymbol = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + offset]); + ev->key_compose = strdup(_ecore_fb_li_kbd_syms[(iev->code * 6) + 3 + offset]); + ev->dev = dev; + ecore_event_add(ECORE_FB_EVENT_KEY_UP, ev, _ecore_fb_li_event_free_key_up, NULL); + if (!strcmp(ev->keyname, "Control_L")) + dev->keyboard.ctrl--; + else if (!strcmp(ev->keyname, "Control_R")) + dev->keyboard.ctrl--; + else if (!strcmp(ev->keyname, "Alt_L")) + dev->keyboard.alt--; + else if (!strcmp(ev->keyname, "Alt_R")) + dev->keyboard.alt--; + else if (!strcmp(ev->keyname, "Shift_L")) + dev->keyboard.shift--; + else if (!strcmp(ev->keyname, "Shift_R")) + dev->keyboard.shift--; + else if (!strcmp(ev->keyname, "Caps_Lock")) + dev->keyboard.lock--; + if (dev->keyboard.ctrl < 0) dev->keyboard.ctrl = 0; + if (dev->keyboard.alt < 0) dev->keyboard.alt = 0; + if (dev->keyboard.shift < 0) dev->keyboard.shift = 0; + if (dev->keyboard.lock < 0) dev->keyboard.lock = 0; + } + } + /* check for mouse button events */ + else if ((iev->code >= BTN_MOUSE) && (iev->code < BTN_JOYSTICK)) + { + int button; + + button = ((iev->code & 0x00F) + 1); + if (iev->value) + { + Ecore_Fb_Event_Mouse_Button_Down *ev; + double current; + + ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down)); + ev->dev = dev; + ev->button = button; + ev->x = dev->mouse.x; + ev->y = dev->mouse.y; + + current = ecore_time_get(); + if ((current - dev->mouse.prev) <= dev->mouse.threshold) + ev->double_click = 1; + if ((current - dev->mouse.last) <= (2 * dev->mouse.threshold)) + { + ev->triple_click = 1; + /* reset */ + dev->mouse.prev = 0; + dev->mouse.last = 0; + current = 0; + } + else + { + /* update values */ + dev->mouse.last = dev->mouse.prev; + dev->mouse.prev = current; + } + ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, ev, NULL ,NULL); + } + else + { + Ecore_Fb_Event_Mouse_Button_Up *ev; + + ev = calloc(1,sizeof(Ecore_Fb_Event_Mouse_Button_Up)); + ev->dev = dev; + ev->button = button; + ev->x = dev->mouse.x; + ev->y = dev->mouse.y; + ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, ev, NULL ,NULL); + } + } } static void _ecore_fb_li_device_event_rel(Ecore_Fb_Input_Device *dev, struct input_event *iev) { - if(!dev->listen) - return; - /* dispatch the button events if they are queued */ - switch(iev->code) - { - case REL_X: - case REL_Y: - { - Ecore_Fb_Event_Mouse_Move *ev; - if(iev->code == REL_X) - { - dev->mouse.x += iev->value; - if(dev->mouse.x > dev->mouse.w - 1) - dev->mouse.x = dev->mouse.w; - else if(dev->mouse.x < 0) - dev->mouse.x = 0; - } - else - { - dev->mouse.y += iev->value; - if(dev->mouse.y > dev->mouse.h - 1) - dev->mouse.y = dev->mouse.h; - else if(dev->mouse.y < 0) - dev->mouse.y = 0; - } - ev = calloc(1,sizeof(Ecore_Fb_Event_Mouse_Move)); - ev->x = dev->mouse.x; - ev->y = dev->mouse.y; - ev->dev = dev; - - ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE,ev,NULL,NULL); - break; - } - case REL_WHEEL: - case REL_HWHEEL: - { - Ecore_Fb_Event_Mouse_Wheel *ev; - ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Wheel)); - - ev->x = dev->mouse.x; - ev->y = dev->mouse.y; - if(iev->code == REL_HWHEEL) - ev->direction = 1; - ev->wheel = iev->value; - ev->dev = dev; - ecore_event_add(ECORE_FB_EVENT_MOUSE_WHEEL, ev, NULL, NULL); - break; - } - default: - break; - } + if (!dev->listen) return; + /* dispatch the button events if they are queued */ + switch (iev->code) + { + case REL_X: + case REL_Y: + { + Ecore_Fb_Event_Mouse_Move *ev; + if(iev->code == REL_X) + { + dev->mouse.x += iev->value; + if(dev->mouse.x > dev->mouse.w - 1) + dev->mouse.x = dev->mouse.w; + else if(dev->mouse.x < 0) + dev->mouse.x = 0; + } + else + { + dev->mouse.y += iev->value; + if(dev->mouse.y > dev->mouse.h - 1) + dev->mouse.y = dev->mouse.h; + else if(dev->mouse.y < 0) + dev->mouse.y = 0; + } + ev = calloc(1,sizeof(Ecore_Fb_Event_Mouse_Move)); + ev->x = dev->mouse.x; + ev->y = dev->mouse.y; + ev->dev = dev; + + ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE,ev,NULL,NULL); + break; + } + case REL_WHEEL: + case REL_HWHEEL: + { + Ecore_Fb_Event_Mouse_Wheel *ev; + ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Wheel)); + + ev->x = dev->mouse.x; + ev->y = dev->mouse.y; + if (iev->code == REL_HWHEEL) ev->direction = 1; + ev->wheel = iev->value; + ev->dev = dev; + ecore_event_add(ECORE_FB_EVENT_MOUSE_WHEEL, ev, NULL, NULL); + break; + } + default: + break; + } } static void _ecore_fb_li_device_event_abs(Ecore_Fb_Input_Device *dev, struct input_event *iev) { - static int prev_pressure = 0; - int pressure; - - if(!dev->listen) - return; - switch(iev->code) - { - case ABS_X: - if(dev->mouse.w != 0) - { - int tmp; - - tmp = (int)((double)(iev->value - dev->mouse.min_w) / dev->mouse.rel_w); - if(tmp < 0) - dev->mouse.x = 0; - else if(tmp > dev->mouse.w) - dev->mouse.x = dev->mouse.w; - else - dev->mouse.x = tmp; - dev->mouse.event = ECORE_FB_EVENT_MOUSE_MOVE; - } - break; - - case ABS_Y: - if(dev->mouse.h != 0) - { - int tmp; - - tmp = (int)((double)(iev->value - dev->mouse.min_h) / dev->mouse.rel_h); - if(tmp < 0) - dev->mouse.y = 0; - else if(tmp > dev->mouse.h) - dev->mouse.y = dev->mouse.h; - else - dev->mouse.y = tmp; - dev->mouse.event = ECORE_FB_EVENT_MOUSE_MOVE; - } - break; - - case ABS_PRESSURE: - pressure = iev->value; - if ((pressure) && (!prev_pressure)) - { - /* DOWN: mouse is down, but was not now */ - dev->mouse.event = ECORE_FB_EVENT_MOUSE_BUTTON_DOWN; - } - else if ((!pressure) && (prev_pressure)) - { - /* UP: mouse was down, but is not now */ - dev->mouse.event = ECORE_FB_EVENT_MOUSE_BUTTON_UP; - } - prev_pressure = pressure; - break; - } + static int prev_pressure = 0; + int pressure; + + if (!dev->listen) return; + switch (iev->code) + { + case ABS_X: + if (dev->mouse.w != 0) + { + int tmp; + + tmp = (int)((double)(iev->value - dev->mouse.min_w) / dev->mouse.rel_w); + if (tmp < 0) dev->mouse.x = 0; + else if (tmp > dev->mouse.w) dev->mouse.x = dev->mouse.w; + else dev->mouse.x = tmp; + dev->mouse.event = ECORE_FB_EVENT_MOUSE_MOVE; + } + break; + + case ABS_Y: + if(dev->mouse.h != 0) + { + int tmp; + + tmp = (int)((double)(iev->value - dev->mouse.min_h) / dev->mouse.rel_h); + if (tmp < 0) dev->mouse.y = 0; + else if (tmp > dev->mouse.h) dev->mouse.y = dev->mouse.h; + else dev->mouse.y = tmp; + dev->mouse.event = ECORE_FB_EVENT_MOUSE_MOVE; + } + break; + + case ABS_PRESSURE: + pressure = iev->value; + if ((pressure) && (!prev_pressure)) + { + /* DOWN: mouse is down, but was not now */ + dev->mouse.event = ECORE_FB_EVENT_MOUSE_BUTTON_DOWN; + } + else if ((!pressure) && (prev_pressure)) + { + /* UP: mouse was down, but is not now */ + dev->mouse.event = ECORE_FB_EVENT_MOUSE_BUTTON_UP; + } + prev_pressure = pressure; + break; + } } static void -_ecore_fb_li_device_event_syn(Ecore_Fb_Input_Device *dev, struct input_event *iev) +_ecore_fb_li_device_event_syn(Ecore_Fb_Input_Device *dev, struct input_event *iev __UNUSED__) { - if(!dev->listen) - return; - - if(dev->mouse.event == ECORE_FB_EVENT_MOUSE_MOVE) - { - Ecore_Fb_Event_Mouse_Move *ev; - ev = calloc(1,sizeof(Ecore_Fb_Event_Mouse_Move)); - ev->x = dev->mouse.x; - ev->y = dev->mouse.y; - ev->dev = dev; - ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE, ev, NULL, NULL); - } - else if(dev->mouse.event == ECORE_FB_EVENT_MOUSE_BUTTON_DOWN) - { - Ecore_Fb_Event_Mouse_Button_Down *ev; - ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down)); - ev->x = dev->mouse.x; - ev->y = dev->mouse.y; - ev->button = 1; - ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL); - } - else if(dev->mouse.event == ECORE_FB_EVENT_MOUSE_BUTTON_UP) - { - Ecore_Fb_Event_Mouse_Button_Up *ev; - ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Up)); - ev->x = dev->mouse.x; - ev->y = dev->mouse.y; - ev->button = 1; - ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL); - } + if (!dev->listen) return; + + if (dev->mouse.event == ECORE_FB_EVENT_MOUSE_MOVE) + { + Ecore_Fb_Event_Mouse_Move *ev; + ev = calloc(1,sizeof(Ecore_Fb_Event_Mouse_Move)); + ev->x = dev->mouse.x; + ev->y = dev->mouse.y; + ev->dev = dev; + ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE, ev, NULL, NULL); + } + else if (dev->mouse.event == ECORE_FB_EVENT_MOUSE_BUTTON_DOWN) + { + Ecore_Fb_Event_Mouse_Button_Down *ev; + ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down)); + ev->x = dev->mouse.x; + ev->y = dev->mouse.y; + ev->button = 1; + ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL); + } + else if (dev->mouse.event == ECORE_FB_EVENT_MOUSE_BUTTON_UP) + { + Ecore_Fb_Event_Mouse_Button_Up *ev; + ev = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Up)); + ev->x = dev->mouse.x; + ev->y = dev->mouse.y; + ev->button = 1; + ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL); + } } static Eina_Bool -_ecore_fb_li_device_fd_callback(void *data, Ecore_Fd_Handler *fdh) +_ecore_fb_li_device_fd_callback(void *data, Ecore_Fd_Handler *fdh __UNUSED__) { - Ecore_Fb_Input_Device *dev; - struct input_event ev[64]; - int len; - int i; - - dev = (Ecore_Fb_Input_Device*)data; - /* read up to 64 events at once */ - len = read(dev->fd, &ev, sizeof(ev)); - // printf("[ecore_fb_li_device:fd_callback] received %d data\n", len); - for(i = 0; i < len/sizeof(ev[0]); i++) - { - switch(ev[i].type) - { - case EV_SYN: - _ecore_fb_li_device_event_syn(dev, &ev[i]); - break; - case EV_ABS: - _ecore_fb_li_device_event_abs(dev, &ev[i]); - break; - case EV_REL: - _ecore_fb_li_device_event_rel(dev, &ev[i]); - break; - case EV_KEY: - _ecore_fb_li_device_event_key(dev, &ev[i]); - break; - default: - break; - } - } - return EINA_TRUE; + Ecore_Fb_Input_Device *dev; + struct input_event ev[64]; + int len; + int i; + + dev = (Ecore_Fb_Input_Device*)data; + /* read up to 64 events at once */ + len = read(dev->fd, &ev, sizeof(ev)); + // printf("[ecore_fb_li_device:fd_callback] received %d data\n", len); + for(i = 0; i < (int)(len / sizeof(ev[0])); i++) + { + switch(ev[i].type) + { + case EV_SYN: + _ecore_fb_li_device_event_syn(dev, &ev[i]); + break; + case EV_ABS: + _ecore_fb_li_device_event_abs(dev, &ev[i]); + break; + case EV_REL: + _ecore_fb_li_device_event_rel(dev, &ev[i]); + break; + case EV_KEY: + _ecore_fb_li_device_event_key(dev, &ev[i]); + break; + default: + break; + } + } + return EINA_TRUE; } -/** - * @brief Sets the listen mode for an input device - * @param dev The device to set the mode of - * @param listen The mode of listening (0 for off, 1 for on) - * This enables or disables listening on an input device. +/** + * @addtogroup Ecore_FB_Group Ecore_FB - Frame buffer convenience functions. + * + * @{ */ -EAPI void -ecore_fb_input_device_listen(Ecore_Fb_Input_Device *dev, int listen) + +/** + * @brief Set the listen mode for an input device . + * + * @param dev The device to set the mode of. + * @param listen EINA_FALSE to disable listening mode, EINA_TRUE to enable it. + * + * This function enables or disables listening on the input device @p + * dev. If @p listen is #EINA_FALSE, listening mode is disabled, if it + * is #EINA_TRUE, it is enabled. + */ +EAPI void +ecore_fb_input_device_listen(Ecore_Fb_Input_Device *dev, Eina_Bool listen) { - if(!dev) return; - if((listen && dev->listen) || (!listen && !dev->listen)) return; - if(listen) - { - /* if the device already had a handler */ - if(!dev->handler) - dev->handler = ecore_main_fd_handler_add(dev->fd, ECORE_FD_READ, _ecore_fb_li_device_fd_callback, dev, NULL, NULL); - - } - dev->listen = listen; + if (!dev) return; + if ((listen && dev->listen) || (!listen && !dev->listen)) return; + if (listen) + { + /* if the device already had a handler */ + if (!dev->handler) + dev->handler = ecore_main_fd_handler_add(dev->fd, ECORE_FD_READ, _ecore_fb_li_device_fd_callback, dev, NULL, NULL); + + } + dev->listen = listen; } #ifndef EV_CNT -#define EV_CNT (EV_MAX+1) +# define EV_CNT (EV_MAX+1) #endif -/* - * @brief Opens an input device - * @param dev The device to open - * @return The @ref Ecore_Fb_Input_Device object that has been opened - * This opens an input device and returns the object for it, or returns NULL on failure. +/** + * @brief Open an input device. + * + * @param dev The device to open. + * @return The @ref Ecore_Fb_Input_Device object that has been opened. + * + * This function opens the input device named @p dev and returns the + * object for it, or returns @c NULL on failure. */ EAPI Ecore_Fb_Input_Device * ecore_fb_input_device_open(const char *dev) { - Ecore_Fb_Input_Device *device; - unsigned long event_type_bitmask[EV_CNT / 32 + 1]; - int event_type; - int fd; - - if(!dev) return NULL; - device = calloc(1, sizeof(Ecore_Fb_Input_Device)); - if(!device) return NULL; - - if((fd = open(dev, O_RDONLY, O_NONBLOCK)) < 0) - { - fprintf(stderr, "[ecore_fb_li:device_open] %s %s", dev, strerror(errno)); - goto error_open; - } - /* query capabilities */ - if(ioctl(fd, EVIOCGBIT(0, EV_MAX), event_type_bitmask) < 0) - { - fprintf(stderr,"[ecore_fb_li:device_open] query capabilities %s %s", dev, strerror(errno)); - goto error_caps; - } - /* query name */ - device->info.name = calloc(256, sizeof(char)); - if(ioctl(fd, EVIOCGNAME(sizeof(char) * 256), device->info.name) < 0) - { - fprintf(stderr, "[ecore_fb_li:device_open] get name %s %s", dev, strerror(errno)); - strcpy(device->info.name, "Unknown"); - } - device->fd = fd; - device->info.dev = strdup(dev); - /* common */ - device->mouse.threshold = CLICK_THRESHOLD_DEFAULT; - - /* set info */ - for(event_type = 0; event_type < EV_MAX; event_type++) - { - if(!test_bit(event_type, event_type_bitmask)) - continue; - switch(event_type) - { - case EV_SYN : - break; - - case EV_KEY: - device->info.cap |= ECORE_FB_INPUT_DEVICE_CAP_KEYS_OR_BUTTONS; - break; - - case EV_REL: - device->info.cap |= ECORE_FB_INPUT_DEVICE_CAP_RELATIVE; - break; - - case EV_ABS: - device->info.cap |= ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE; - break; - - case EV_MSC: - case EV_LED: - case EV_SND: - case EV_REP: - case EV_FF : - case EV_FF_STATUS: - case EV_PWR: - default: - break; - } - } - _ecore_fb_li_devices = eina_list_append(_ecore_fb_li_devices, device); - return device; - - error_caps: - close(fd); - error_open: - free(device); - return NULL; - + Ecore_Fb_Input_Device *device; + unsigned long event_type_bitmask[EV_CNT / 32 + 1]; + int event_type; + int fd; + + if (!dev) return NULL; + device = calloc(1, sizeof(Ecore_Fb_Input_Device)); + if (!device) return NULL; + + if ((fd = open(dev, O_RDONLY, O_NONBLOCK)) < 0) + { + fprintf(stderr, "[ecore_fb_li:device_open] %s %s", dev, strerror(errno)); + goto error_open; + } + /* query capabilities */ + if (ioctl(fd, EVIOCGBIT(0, EV_MAX), event_type_bitmask) < 0) + { + fprintf(stderr,"[ecore_fb_li:device_open] query capabilities %s %s", dev, strerror(errno)); + goto error_caps; + } + /* query name */ + device->info.name = calloc(256, sizeof(char)); + if (ioctl(fd, EVIOCGNAME(sizeof(char) * 256), device->info.name) < 0) + { + fprintf(stderr, "[ecore_fb_li:device_open] get name %s %s", dev, strerror(errno)); + strcpy(device->info.name, "Unknown"); + } + device->fd = fd; + device->info.dev = strdup(dev); + /* common */ + device->mouse.threshold = CLICK_THRESHOLD_DEFAULT; + + /* set info */ + for (event_type = 0; event_type < EV_MAX; event_type++) + { + if(!test_bit(event_type, event_type_bitmask)) + continue; + switch (event_type) + { + case EV_SYN: + break; + case EV_KEY: + device->info.cap |= ECORE_FB_INPUT_DEVICE_CAP_KEYS_OR_BUTTONS; + break; + case EV_REL: + device->info.cap |= ECORE_FB_INPUT_DEVICE_CAP_RELATIVE; + break; + case EV_ABS: + device->info.cap |= ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE; + break; + case EV_MSC: + case EV_LED: + case EV_SND: + case EV_REP: + case EV_FF : + case EV_FF_STATUS: + case EV_PWR: + default: + break; + } + } + _ecore_fb_li_devices = eina_list_append(_ecore_fb_li_devices, device); + return device; + +error_caps: + close(fd); +error_open: + free(device); + return NULL; } +/** + * @brief Close the given device. + * + * @param dev The device to close + * + * This function closes the device @p dev. If @p dev is @c NULL, this + * function does nothing. + */ EAPI void ecore_fb_input_device_close(Ecore_Fb_Input_Device *dev) { - /* close the fd */ - close(dev->fd); - /* remove the element from the list */ - _ecore_fb_li_devices = eina_list_remove(_ecore_fb_li_devices, dev); - free(dev); + if (!dev || dev->fd < 0) return; + /* close the fd */ + close(dev->fd); + /* remove the element from the list */ + _ecore_fb_li_devices = eina_list_remove(_ecore_fb_li_devices, dev); + free(dev); } -/* - * If the device is a relative input device, - * we must set a width and height for it. If its - * absolute set the ioctl correctly, if not, unsupported - * device +/** + * @brief Set the axis size of the given device. + * + * @param dev The device to set the axis size to. + * @param w The width of the axis. + * @param h The height of the axis. + * + * This function sets set the width @p w and height @p h of the axis + * of device @p dev. If @p dev is a relative input device, a width and + * height must set for it. If its absolute set the ioctl correctly, if + * not, unsupported device. */ EAPI void ecore_fb_input_device_axis_size_set(Ecore_Fb_Input_Device *dev, int w, int h) { - if(!dev) - return; - if(w < 0 || h < 0) - return; - /* FIXME - * this code is for a touchscreen device, - * make it configurable (ABSOLUTE | RELATIVE) - */ - if(dev->info.cap & ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE) - { - /* FIXME looks like some kernels dont include this struct */ - struct input_absinfo abs_features; - - ioctl(dev->fd, EVIOCGABS(ABS_X), &abs_features); - dev->mouse.min_w = abs_features.minimum; - dev->mouse.rel_w = (double)(abs_features.maximum - abs_features.minimum)/(double)(w); - - ioctl(dev->fd, EVIOCGABS(ABS_Y), &abs_features); - dev->mouse.min_h = abs_features.minimum; - dev->mouse.rel_h = (double)(abs_features.maximum - abs_features.minimum)/(double)(h); - } - else if(!(dev->info.cap & ECORE_FB_INPUT_DEVICE_CAP_RELATIVE)) - return; - - /* update the local values */ - if(dev->mouse.x > w - 1) - dev->mouse.x = w -1; - if(dev->mouse.y > h - 1) - dev->mouse.y = h -1; - dev->mouse.w = w; - dev->mouse.h = h; + if (!dev) return; + if ((w < 0) || (h < 0)) return; + /* FIXME + * this code is for a touchscreen device, + * make it configurable (ABSOLUTE | RELATIVE) + */ + if (dev->info.cap & ECORE_FB_INPUT_DEVICE_CAP_ABSOLUTE) + { + /* FIXME looks like some kernels dont include this struct */ + struct input_absinfo abs_features; + + ioctl(dev->fd, EVIOCGABS(ABS_X), &abs_features); + dev->mouse.min_w = abs_features.minimum; + dev->mouse.rel_w = (double)(abs_features.maximum - abs_features.minimum)/(double)(w); + + ioctl(dev->fd, EVIOCGABS(ABS_Y), &abs_features); + dev->mouse.min_h = abs_features.minimum; + dev->mouse.rel_h = (double)(abs_features.maximum - abs_features.minimum)/(double)(h); + } + else if (!(dev->info.cap & ECORE_FB_INPUT_DEVICE_CAP_RELATIVE)) + return; + + /* update the local values */ + if (dev->mouse.x > w - 1) dev->mouse.x = w -1; + if (dev->mouse.y > h - 1) dev->mouse.y = h -1; + dev->mouse.w = w; + dev->mouse.h = h; } - +/** + * @brief Retrieve the name of the given device. + * + * @param dev The device to get the name from. + * @return The name of the device. + * + * This function returns the name of the device @p dev. If @p dev is + * @c NULL, this function returns @c NULL. + */ EAPI const char * ecore_fb_input_device_name_get(Ecore_Fb_Input_Device *dev) { - if(!dev) - return NULL; - return dev->info.name; + if (!dev) return NULL; + return dev->info.name; } + +/** + * @brief Retrieve the capability of the given device. + * + * @param dev The device to get the name from. + * @return The capability of the device. + * + * This function returns the capability of the device @p dev. If @p dev is + * @c NULL, this function returns #ECORE_FB_INPUT_DEVICE_CAP_NONE. + */ EAPI Ecore_Fb_Input_Device_Cap ecore_fb_input_device_cap_get(Ecore_Fb_Input_Device *dev) { - if(!dev) - return ECORE_FB_INPUT_DEVICE_CAP_NONE; - return dev->info.cap; + if (!dev) return ECORE_FB_INPUT_DEVICE_CAP_NONE; + return dev->info.cap; } + +/** + * @brief Set the threshold of mouse clicks of the given device. + * + * @param dev The device to set the threshodl mouse click to. + * @param threshold The threshold value. + * + * This function sets the threshold of mouse clicks of the device + * @p dev to @p threshold. If @p dev is @c NULL, this function does + * nothing. + */ EAPI void ecore_fb_input_device_threshold_click_set(Ecore_Fb_Input_Device *dev, double threshold) { - if(!dev) return; - if(threshold == dev->mouse.threshold || threshold == 0) return; - dev->mouse.threshold = threshold; + if (!dev) return; + if ((threshold == dev->mouse.threshold) || (threshold == 0)) return; + dev->mouse.threshold = threshold; } + +/** + * @brief Get the threshold of mouse clicks of the given device. + * + * @param dev The device to set the threshodl mouse click from. + * @return The threshold value. + * + * This function returns the threshold of mouse clicks of the device + * @p dev. If @p dev is @c NULL, this function returns 0.0. + */ EAPI double ecore_fb_input_device_threshold_click_get(Ecore_Fb_Input_Device *dev) { - if(!dev) return 0; - return dev->mouse.threshold; + if (!dev) return 0; + return dev->mouse.threshold; } + +/** + * @} + */ diff --git a/src/lib/ecore_fb/ecore_fb_private.h b/src/lib/ecore_fb/ecore_fb_private.h index 121f69e..0b51bc7 100644 --- a/src/lib/ecore_fb/ecore_fb_private.h +++ b/src/lib/ecore_fb/ecore_fb_private.h @@ -32,35 +32,35 @@ /* ecore_fb_li.c */ struct _Ecore_Fb_Input_Device { - int fd; - Ecore_Fd_Handler *handler; - int listen; - struct { - Ecore_Fb_Input_Device_Cap cap; - char *name; - char *dev; - } info; - struct - { - /* common mouse */ - int x,y; - int w,h; - - double last; - double prev; - double threshold; - /* absolute axis */ - int min_w, min_h; - double rel_w, rel_h; - int event; - } mouse; - struct - { - int shift; - int ctrl; - int alt; - int lock; - } keyboard; + int fd; + Ecore_Fd_Handler *handler; + int listen; + struct { + Ecore_Fb_Input_Device_Cap cap; + char *name; + char *dev; + } info; + struct + { + /* common mouse */ + int x,y; + int w,h; + + double last; + double prev; + double threshold; + /* absolute axis */ + int min_w, min_h; + double rel_w, rel_h; + int event; + } mouse; + struct + { + int shift; + int ctrl; + int alt; + int lock; + } keyboard; }; /* ecore_fb_ts.c */ diff --git a/src/lib/ecore_fb/ecore_fb_ps2.c b/src/lib/ecore_fb/ecore_fb_ps2.c index 161c200..e57da15 100644 --- a/src/lib/ecore_fb/ecore_fb_ps2.c +++ b/src/lib/ecore_fb/ecore_fb_ps2.c @@ -18,19 +18,19 @@ ecore_fb_ps2_init(void) _ecore_fb_ps2_fd = open("/dev/psaux", O_RDWR); if (_ecore_fb_ps2_fd >= 0) { - prev_flags = fcntl(_ecore_fb_ps2_fd, F_GETFL); - fcntl(_ecore_fb_ps2_fd, F_SETFL, prev_flags | O_NONBLOCK); - _ecore_fb_ts_fd_handler_handle = ecore_main_fd_handler_add(_ecore_fb_ps2_fd, - ECORE_FD_READ, - _ecore_fb_ps2_fd_handler, NULL, NULL, NULL); - if (!_ecore_fb_ts_fd_handler_handle) - { - close(_ecore_fb_ps2_fd); - return 0; - } - return 1; + prev_flags = fcntl(_ecore_fb_ps2_fd, F_GETFL); + fcntl(_ecore_fb_ps2_fd, F_SETFL, prev_flags | O_NONBLOCK); + _ecore_fb_ts_fd_handler_handle = ecore_main_fd_handler_add(_ecore_fb_ps2_fd, + ECORE_FD_READ, + _ecore_fb_ps2_fd_handler, NULL, NULL, NULL); + if (!_ecore_fb_ts_fd_handler_handle) + { + close(_ecore_fb_ps2_fd); + return 0; + } + return 1; } - return 0; + return 0; } void @@ -47,101 +47,118 @@ _ecore_fb_ps2_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __U static double last_time = 0; static double last_last_time = 0; int v = 0; - + do { - int x, y, button, i; - int num; - char *ptr; - double t; - int did_triple = 0; - - ptr = (char *)&(_ecore_fb_ps2_event); - ptr += _ecore_fb_ps2_event_byte_count; - num = sizeof(Ecore_Fb_Ps2_Event) - _ecore_fb_ps2_event_byte_count; - v = read(_ecore_fb_ps2_fd, ptr, num); - if (v < 0) return EINA_TRUE; - _ecore_fb_ps2_event_byte_count += v; - if (v < num) return EINA_TRUE; - t = ecore_time_get(); - _ecore_fb_ps2_event_byte_count = 0; - if (_ecore_fb_ps2_event.button & 0x10) - x = prev_x + (0xffffff00 | _ecore_fb_ps2_event.x); - else - x = prev_x + _ecore_fb_ps2_event.x; - if (_ecore_fb_ps2_event.button & 0x20) - y = prev_y - (0xffffff00 | _ecore_fb_ps2_event.y); - else - y = prev_y - _ecore_fb_ps2_event.y; - button = _ecore_fb_ps2_event.button & 0x7; - if (x < 0) x = 0; - if (y < 0) y = 0; - if (x >= _ecore_fb_console_w) x = _ecore_fb_console_w - 1; - if (y >= _ecore_fb_console_h) y = _ecore_fb_console_h - 1; - /* add event to queue */ - /* always add a move event */ - if (1) - { - /* MOVE: mouse is down and was */ - Ecore_Fb_Event_Mouse_Move *e; - - e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Move)); - if (!e) goto retry; - e->x = x; - e->y = y; - ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE, e, NULL, NULL); - } - for (i = 1; i <= 3; i++) - { - int mask; - - mask = 1 << (i - 1); - if (((button & mask)) && (!(prev_button & mask))) - { - /* DOWN: mouse is down, but was not now */ - Ecore_Fb_Event_Mouse_Button_Down *e; - - e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down)); - if (!e) goto retry; - e->x = x; - e->y = y; - e->button = 1; - if ((t - last_time) <= _ecore_fb_double_click_time) - e->double_click = 1; - if ((t - last_last_time) <= (2 * _ecore_fb_double_click_time)) - { - did_triple = 1; - e->triple_click = 1; - } - ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL); - } - else if ((!(button & mask)) && ((prev_button & mask))) - { - /* UP: mouse was down, but is not now */ - Ecore_Fb_Event_Mouse_Button_Up *e; - - e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Up)); - if (!e) goto retry; - e->x = x; - e->y = y; - e->button = 1; - ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL); - } - } - if (did_triple) - { - last_time = 0; - last_last_time = 0; - } - else - { - last_last_time = last_time; - last_time = t; - } - retry: - prev_x = x; - prev_y = y; - prev_button = button; + int x, y, button, i; + int num; + char *ptr; + double t; + static int did_double = 0; + static int did_triple = 0; + + ptr = (char *)&(_ecore_fb_ps2_event); + ptr += _ecore_fb_ps2_event_byte_count; + num = sizeof(Ecore_Fb_Ps2_Event) - _ecore_fb_ps2_event_byte_count; + v = read(_ecore_fb_ps2_fd, ptr, num); + if (v < 0) return EINA_TRUE; + _ecore_fb_ps2_event_byte_count += v; + if (v < num) return EINA_TRUE; + t = ecore_time_get(); + _ecore_fb_ps2_event_byte_count = 0; + if (_ecore_fb_ps2_event.button & 0x10) + x = prev_x + (0xffffff00 | _ecore_fb_ps2_event.x); + else + x = prev_x + _ecore_fb_ps2_event.x; + if (_ecore_fb_ps2_event.button & 0x20) + y = prev_y - (0xffffff00 | _ecore_fb_ps2_event.y); + else + y = prev_y - _ecore_fb_ps2_event.y; + button = _ecore_fb_ps2_event.button & 0x7; + if (x < 0) x = 0; + if (y < 0) y = 0; + if (x >= _ecore_fb_console_w) x = _ecore_fb_console_w - 1; + if (y >= _ecore_fb_console_h) y = _ecore_fb_console_h - 1; + /* add event to queue */ + /* always add a move event */ + if (1) + { + /* MOVE: mouse is down and was */ + Ecore_Fb_Event_Mouse_Move *e; + + e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Move)); + if (!e) goto retry; + e->x = x; + e->y = y; + ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE, e, NULL, NULL); + } + for (i = 1; i <= 3; i++) + { + int mask; + + mask = 1 << (i - 1); + if (((button & mask)) && (!(prev_button & mask))) + { + /* DOWN: mouse is down, but was not now */ + Ecore_Fb_Event_Mouse_Button_Down *e; + + e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down)); + if (!e) goto retry; + e->x = x; + e->y = y; + e->button = i; + if ((t - last_time) <= _ecore_fb_double_click_time) + { + e->double_click = 1; + did_double = 1; + } + else + { + did_double = 0; + did_triple = 0; + } + if ((t - last_last_time) <= (2 * _ecore_fb_double_click_time)) + { + did_triple = 1; + e->triple_click = 1; + } + else + { + did_triple = 0; + } + ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL); + } + else if ((!(button & mask)) && ((prev_button & mask))) + { + /* UP: mouse was down, but is not now */ + Ecore_Fb_Event_Mouse_Button_Up *e; + + e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Up)); + if (!e) goto retry; + e->x = x; + e->y = y; + e->button = i; + if (did_double) + e->double_click = 1; + if (did_triple) + e->triple_click = 1; + ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL); + } + } + if (did_triple) + { + last_time = 0; + last_last_time = 0; + } + else + { + last_last_time = last_time; + last_time = t; + } + retry: + prev_x = x; + prev_y = y; + prev_button = button; } while (v > 0); return EINA_TRUE; diff --git a/src/lib/ecore_fb/ecore_fb_ts.c b/src/lib/ecore_fb/ecore_fb_ts.c index c1e1f08..caef71b 100644 --- a/src/lib/ecore_fb/ecore_fb_ts.c +++ b/src/lib/ecore_fb/ecore_fb_ts.c @@ -81,44 +81,44 @@ ecore_fb_ts_init(void) #ifdef HAVE_TSLIB char *tslib_tsdevice = NULL; if ( (tslib_tsdevice = getenv("TSLIB_TSDEVICE")) ) - { + { printf( "ECORE_FB: TSLIB_TSDEVICE = '%s'\n", tslib_tsdevice ); _ecore_fb_tslib_tsdev = ts_open( tslib_tsdevice, 1 ); /* 1 = nonblocking, 0 = blocking */ - + if ( !_ecore_fb_tslib_tsdev ) - { - printf( "ECORE_FB: Can't ts_open (%s)\n", strerror( errno ) ); - return 0; - } - + { + printf( "ECORE_FB: Can't ts_open (%s)\n", strerror( errno ) ); + return 0; + } + if ( ts_config( _ecore_fb_tslib_tsdev ) ) - { - printf( "ECORE_FB: Can't ts_config (%s)\n", strerror( errno ) ); - return 0; - } + { + printf( "ECORE_FB: Can't ts_config (%s)\n", strerror( errno ) ); + return 0; + } _ecore_fb_ts_fd = ts_fd( _ecore_fb_tslib_tsdev ); if ( _ecore_fb_ts_fd < 0 ) - { - printf( "ECORE_FB: Can't open touchscreen (%s)\n", strerror( errno ) ); - return 0; - } - } + { + printf( "ECORE_FB: Can't open touchscreen (%s)\n", strerror( errno ) ); + return 0; + } + } #else _ecore_fb_ts_fd = open("/dev/touchscreen/0", O_RDONLY); #endif if (_ecore_fb_ts_fd >= 0) { - _ecore_fb_ts_fd_handler_handle = ecore_main_fd_handler_add(_ecore_fb_ts_fd, - ECORE_FD_READ, - _ecore_fb_ts_fd_handler, NULL, - NULL, NULL); - if (!_ecore_fb_ts_fd_handler_handle) - { - close(_ecore_fb_ts_fd); - return 0; - } - // FIXME _ecore_fb_kbd_fd = open("/dev/touchscreen/key", O_RDONLY); - return 1; + _ecore_fb_ts_fd_handler_handle = ecore_main_fd_handler_add(_ecore_fb_ts_fd, + ECORE_FD_READ, + _ecore_fb_ts_fd_handler, NULL, + NULL, NULL); + if (!_ecore_fb_ts_fd_handler_handle) + { + close(_ecore_fb_ts_fd); + return 0; + } + // FIXME _ecore_fb_kbd_fd = open("/dev/touchscreen/key", O_RDONLY); + return 1; } return 0; } @@ -127,7 +127,7 @@ EAPI void ecore_fb_ts_shutdown(void) { if (_ecore_fb_ts_fd_handler_handle) - ecore_main_fd_handler_del(_ecore_fb_ts_fd_handler_handle); + ecore_main_fd_handler_del(_ecore_fb_ts_fd_handler_handle); if (_ecore_fb_ts_fd >= 0) close(_ecore_fb_ts_fd); _ecore_fb_ts_fd = -1; _ecore_fb_ts_fd_handler_handle = NULL; @@ -138,8 +138,8 @@ ecore_fb_ts_shutdown(void) * * Functions that calibrate the screen. */ - - + + /** * Calibrates the touschreen using the given parameters. * @param xscale X scaling, where 256 = 1.0 @@ -162,9 +162,8 @@ ecore_fb_touch_screen_calibrate_set(int xscale, int xtrans, int yscale, int ytra cal.xyswap = xyswap; if (ioctl(_ecore_fb_ts_fd, TS_SET_CAL, (void *)&cal)) { - _ecore_fb_ts_cal = cal; - _ecore_fb_ts_apply_cal = 1; - + _ecore_fb_ts_cal = cal; + _ecore_fb_ts_apply_cal = 1; } } @@ -186,12 +185,11 @@ ecore_fb_touch_screen_calibrate_get(int *xscale, int *xtrans, int *yscale, int * if (_ecore_fb_ts_fd < 0) return; if (!_ecore_fb_ts_apply_cal) { - if (ioctl(_ecore_fb_ts_fd, TS_GET_CAL, (void *)&cal)) - _ecore_fb_ts_cal = cal; - + if (ioctl(_ecore_fb_ts_fd, TS_GET_CAL, (void *)&cal)) + _ecore_fb_ts_cal = cal; } else - cal = _ecore_fb_ts_cal; + cal = _ecore_fb_ts_cal; if (xscale) *xscale = cal.xscale; if (xtrans) *xtrans = cal.xtrans; if (yscale) *yscale = cal.yscale; @@ -209,102 +207,119 @@ _ecore_fb_ts_fd_handler(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler __UN do { - int x, y, pressure; - int num; - char *ptr; - double t; - int did_triple = 0; + int x, y, pressure; + int num; + char *ptr; + double t = 0.0; + static int did_double = 0; + static int did_triple = 0; #ifdef HAVE_TSLIB - if (_ecore_fb_ts_apply_cal) - num = ts_read_raw(_ecore_fb_tslib_tsdev, &_ecore_fb_tslib_event, 1); - else - num = ts_read(_ecore_fb_tslib_tsdev, &_ecore_fb_tslib_event, 1); - if (num != 1) return 1; /* no more samples at this time */ - x = _ecore_fb_tslib_event.x; - y = _ecore_fb_tslib_event.y; - pressure = _ecore_fb_tslib_event.pressure; - v = 1; /* loop, there might be more samples */ - t = ecore_time_get(); + if (_ecore_fb_ts_apply_cal) + num = ts_read_raw(_ecore_fb_tslib_tsdev, &_ecore_fb_tslib_event, 1); + else + num = ts_read(_ecore_fb_tslib_tsdev, &_ecore_fb_tslib_event, 1); + if (num != 1) return 1; /* no more samples at this time */ + x = _ecore_fb_tslib_event.x; + y = _ecore_fb_tslib_event.y; + pressure = _ecore_fb_tslib_event.pressure; + v = 1; /* loop, there might be more samples */ + t = ecore_time_get(); #else - ptr = (char *)&(_ecore_fb_ts_event); - ptr += _ecore_fb_ts_event_byte_count; - num = sizeof(Ecore_Fb_Ts_Event) - _ecore_fb_ts_event_byte_count; - v = read(_ecore_fb_ts_fd, ptr, num); - if (v < 0) return 1; - _ecore_fb_ts_event_byte_count += v; - if (v < num) return 1; - _ecore_fb_ts_event_byte_count = 0; - if (_ecore_fb_ts_apply_cal) - { - x = ((_ecore_fb_ts_cal.xscale * _ecore_fb_ts_event.x) >> 8) + _ecore_fb_ts_cal.xtrans; - y = ((_ecore_fb_ts_cal.yscale * _ecore_fb_ts_event.y) >> 8) + _ecore_fb_ts_cal.ytrans; - } - else - { - x = _ecore_fb_ts_event.x; - y = _ecore_fb_ts_event.y; - } - pressure = _ecore_fb_ts_event.pressure; + ptr = (char *)&(_ecore_fb_ts_event); + ptr += _ecore_fb_ts_event_byte_count; + num = sizeof(Ecore_Fb_Ts_Event) - _ecore_fb_ts_event_byte_count; + v = read(_ecore_fb_ts_fd, ptr, num); + if (v < 0) return 1; + _ecore_fb_ts_event_byte_count += v; + if (v < num) return 1; + _ecore_fb_ts_event_byte_count = 0; + if (_ecore_fb_ts_apply_cal) + { + x = ((_ecore_fb_ts_cal.xscale * _ecore_fb_ts_event.x) >> 8) + _ecore_fb_ts_cal.xtrans; + y = ((_ecore_fb_ts_cal.yscale * _ecore_fb_ts_event.y) >> 8) + _ecore_fb_ts_cal.ytrans; + } + else + { + x = _ecore_fb_ts_event.x; + y = _ecore_fb_ts_event.y; + } + pressure = _ecore_fb_ts_event.pressure; #endif - /* add event to queue */ - /* always add a move event */ - if ((pressure) || (prev_pressure)) - { - /* MOVE: mouse is down and was */ - Ecore_Fb_Event_Mouse_Move *e; - - e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Move)); - if (!e) goto retry; - e->x = x; - e->y = y; - ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE, e, NULL, NULL); - } - if ((pressure) && (!prev_pressure)) - { - /* DOWN: mouse is down, but was not now */ - Ecore_Fb_Event_Mouse_Button_Down *e; - - e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down)); - if (!e) goto retry; - e->x = x; - e->y = y; - e->button = 1; - if ((t - last_time) <= _ecore_fb_double_click_time) - e->double_click = 1; - if ((t - last_last_time) <= (2 * _ecore_fb_double_click_time)) - { - did_triple = 1; - e->triple_click = 1; - } - ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL); - } - else if ((!pressure) && (prev_pressure)) - { - /* UP: mouse was down, but is not now */ - Ecore_Fb_Event_Mouse_Button_Up *e; - - e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Up)); - if (!e) goto retry; - e->x = prev_x; - e->y = prev_y; - e->button = 1; - ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL); - } + /* add event to queue */ + /* always add a move event */ + if ((pressure) || (prev_pressure)) + { + /* MOVE: mouse is down and was */ + Ecore_Fb_Event_Mouse_Move *e; + + e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Move)); + if (!e) goto retry; + e->x = x; + e->y = y; + ecore_event_add(ECORE_FB_EVENT_MOUSE_MOVE, e, NULL, NULL); + } + if ((pressure) && (!prev_pressure)) + { + /* DOWN: mouse is down, but was not now */ + Ecore_Fb_Event_Mouse_Button_Down *e; + + e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Down)); + if (!e) goto retry; + e->x = x; + e->y = y; + e->button = 1; + if ((t - last_time) <= _ecore_fb_double_click_time) + { + e->double_click = 1; + did_double = 1; + } + else + { + did_double = 0; + did_triple = 0; + } + if ((t - last_last_time) <= (2 * _ecore_fb_double_click_time)) + { + did_triple = 1; + e->triple_click = 1; + } + else + { + did_triple = 0; + } + ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL); + } + else if ((!pressure) && (prev_pressure)) + { + /* UP: mouse was down, but is not now */ + Ecore_Fb_Event_Mouse_Button_Up *e; + + e = calloc(1, sizeof(Ecore_Fb_Event_Mouse_Button_Up)); + if (!e) goto retry; + e->x = prev_x; + e->y = prev_y; + e->button = 1; + if (did_double) + e->double_click = 1; + if (did_triple) + e->triple_click = 1; + ecore_event_add(ECORE_FB_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL); + } if (did_triple) - { - last_time = 0; - last_last_time = 0; - } - else - { - last_last_time = last_time; - last_time = t; - } - retry: - prev_x = x; - prev_y = y; - prev_pressure = pressure; + { + last_time = 0; + last_last_time = 0; + } + else + { + last_last_time = last_time; + last_time = t; + } +retry: + prev_x = x; + prev_y = y; + prev_pressure = pressure; } while (v > 0); return 1; diff --git a/src/lib/ecore_fb/ecore_fb_vt.c b/src/lib/ecore_fb/ecore_fb_vt.c index 29c6839..65f2013 100644 --- a/src/lib/ecore_fb/ecore_fb_vt.c +++ b/src/lib/ecore_fb/ecore_fb_vt.c @@ -34,193 +34,206 @@ static Eina_Bool _ecore_fb_event_filter_filter(void *data, void *loop_data, in static void _ecore_fb_event_filter_end(void *data, void *loop_data); /* prototypes */ +/* XXX: unused static void _ecore_fb_vt_switch(int vt); +*/ static Eina_Bool _ecore_fb_signal_usr_handler(void *data __UNUSED__, int type __UNUSED__, void *ev) { - - Ecore_Event_Signal_User *e; + Ecore_Event_Signal_User *e; - e = (Ecore_Event_Signal_User *)ev; - if (e->number == 1) - { - /* release vt */ - if (_ecore_fb_func_fb_lost) _ecore_fb_func_fb_lost(_ecore_fb_func_fb_lost_data); - /* TODO stop listening from the devices? let the callback do it? */ - ioctl(_ecore_fb_vt_tty_fd, VT_RELDISP, 1); - } - else if (e->number == 2) - { - /* attach vt */ - if (_ecore_fb_func_fb_gain) _ecore_fb_func_fb_gain(_ecore_fb_func_fb_gain_data); - /* TODO reattach all devices */ - } - return 1; + e = (Ecore_Event_Signal_User *)ev; + if (e->number == 1) + { + /* release vt */ + if (_ecore_fb_func_fb_lost) _ecore_fb_func_fb_lost(_ecore_fb_func_fb_lost_data); + /* TODO stop listening from the devices? let the callback do it? */ + ioctl(_ecore_fb_vt_tty_fd, VT_RELDISP, 1); + } + else if (e->number == 2) + { + /* attach vt */ + if (_ecore_fb_func_fb_gain) _ecore_fb_func_fb_gain(_ecore_fb_func_fb_gain_data); + /* TODO reattach all devices */ + } + return 1; } +/* XXX: unused static void _ecore_fb_vt_switch(int vt) { - vt++; - if (_ecore_fb_vt_tty_fd != 0) - { - if (vt != _ecore_fb_vt_current_vt) - { - tcsetattr(_ecore_fb_vt_tty_fd, TCSAFLUSH, &_ecore_fb_tty_prev_tio_mode); - ioctl(_ecore_fb_vt_tty_fd, KDSETMODE, _ecore_fb_tty_prev_kd_mode); - ioctl(_ecore_fb_vt_tty_fd, KDSKBMODE, _ecore_fb_tty_prev_mode); - } - } - ioctl(_ecore_fb_vt_tty_fd, VT_ACTIVATE, vt); + vt++; + if (_ecore_fb_vt_tty_fd != 0) + { + if (vt != _ecore_fb_vt_current_vt) + { + tcsetattr(_ecore_fb_vt_tty_fd, TCSAFLUSH, &_ecore_fb_tty_prev_tio_mode); + ioctl(_ecore_fb_vt_tty_fd, KDSETMODE, _ecore_fb_tty_prev_kd_mode); + ioctl(_ecore_fb_vt_tty_fd, KDSKBMODE, _ecore_fb_tty_prev_mode); + } + } + ioctl(_ecore_fb_vt_tty_fd, VT_ACTIVATE, vt); } +*/ static int _ecore_fb_vt_setup(void) { - char buf[64]; - struct termios tio; - struct vt_mode new_vtmode; - - if(_ecore_fb_vt_current_vt != _ecore_fb_vt_prev_vt) - { - snprintf(buf, sizeof(buf), "/dev/tty%i", _ecore_fb_vt_current_vt); - if((_ecore_fb_vt_tty_fd = open(buf, O_RDWR)) < 0) - { - printf("[ecore_fb:vt_setup] cant open tty %d\n", _ecore_fb_vt_current_vt); - return 0; - } - close(_ecore_fb_vt_tty0_fd); - _ecore_fb_vt_tty0_fd = 0; - /* FIXME detach the process from current tty ? */ - } - else - _ecore_fb_vt_tty_fd = _ecore_fb_vt_tty0_fd; - /* for backup */ - tcgetattr(_ecore_fb_vt_tty_fd, &_ecore_fb_tty_prev_tio_mode); - ioctl(_ecore_fb_vt_tty_fd, KDGETMODE, &_ecore_fb_tty_prev_kd_mode); - ioctl(_ecore_fb_vt_tty_fd, VT_GETMODE, &_ecore_fb_vt_prev_mode); - - if(ioctl(_ecore_fb_vt_tty_fd, KDSETMODE, KD_GRAPHICS) < 0) - { - perror("[ecore_fb:vt_setup] cant set the mode to KD_GRAPHICS"); - close(_ecore_fb_vt_tty_fd); - return 0; - } - ioctl(_ecore_fb_vt_tty_fd, KDGKBMODE, &_ecore_fb_tty_prev_mode); - - /* support of switching */ - new_vtmode.mode = VT_PROCESS; - new_vtmode.waitv = 0; - new_vtmode.relsig = SIGUSR1; - new_vtmode.acqsig = SIGUSR2; - if(ioctl(_ecore_fb_vt_tty_fd, VT_SETMODE, &new_vtmode) < 0) - { - perror("[ecore_fb:vt_setup] cant set the tty mode"); - close(_ecore_fb_vt_tty_fd); - return 0; - } - /* register signal handlers when alloc/detach of vt */ - _ecore_fb_user_handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER, - _ecore_fb_signal_usr_handler, - NULL); - /* What does this does? */ - _ecore_fb_filter_handler = ecore_event_filter_add(_ecore_fb_event_filter_start, _ecore_fb_event_filter_filter, _ecore_fb_event_filter_end, NULL); - - usleep(40000); - if(ioctl(_ecore_fb_vt_tty_fd, VT_ACTIVATE, _ecore_fb_vt_current_vt) < 0) - { - perror("[ecore_fb:vt_setup] error on VT_ACTIVATE"); - close(_ecore_fb_vt_tty_fd); - return 0; - } - if(ioctl(_ecore_fb_vt_tty_fd, VT_WAITACTIVE, _ecore_fb_vt_current_vt) < 0) - { - perror("[ecore_fb:vt_setup] error on VT_WAITACTIVE"); - close(_ecore_fb_vt_tty_fd); - return 0; - } - /* FIXME assign the fb to the tty in case isnt setup */ - return 1; + char buf[64]; +// XXX: unused +// struct termios tio; + struct vt_mode new_vtmode; + + if (_ecore_fb_vt_current_vt != _ecore_fb_vt_prev_vt) + { + snprintf(buf, sizeof(buf), "/dev/tty%i", _ecore_fb_vt_current_vt); + if ((_ecore_fb_vt_tty_fd = open(buf, O_RDWR)) < 0) + { + printf("[ecore_fb:vt_setup] can't open tty %d\n", _ecore_fb_vt_current_vt); + return 0; + } + close(_ecore_fb_vt_tty0_fd); + _ecore_fb_vt_tty0_fd = 0; + /* FIXME detach the process from current tty ? */ + } + else + _ecore_fb_vt_tty_fd = _ecore_fb_vt_tty0_fd; + /* for backup */ + tcgetattr(_ecore_fb_vt_tty_fd, &_ecore_fb_tty_prev_tio_mode); + ioctl(_ecore_fb_vt_tty_fd, KDGETMODE, &_ecore_fb_tty_prev_kd_mode); + ioctl(_ecore_fb_vt_tty_fd, VT_GETMODE, &_ecore_fb_vt_prev_mode); + + if (ioctl(_ecore_fb_vt_tty_fd, KDSETMODE, KD_GRAPHICS) < 0) + { + perror("[ecore_fb:vt_setup] can't set the mode to KD_GRAPHICS"); + close(_ecore_fb_vt_tty_fd); + return 0; + } + ioctl(_ecore_fb_vt_tty_fd, KDGKBMODE, &_ecore_fb_tty_prev_mode); + + /* support of switching */ + new_vtmode.mode = VT_PROCESS; + new_vtmode.waitv = 0; + new_vtmode.relsig = SIGUSR1; + new_vtmode.acqsig = SIGUSR2; + if (ioctl(_ecore_fb_vt_tty_fd, VT_SETMODE, &new_vtmode) < 0) + { + perror("[ecore_fb:vt_setup] can't set the tty mode"); + close(_ecore_fb_vt_tty_fd); + return 0; + } + /* register signal handlers when alloc/detach of vt */ + _ecore_fb_user_handler = ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER, + _ecore_fb_signal_usr_handler, + NULL); + /* What does this do? */ + _ecore_fb_filter_handler = ecore_event_filter_add(_ecore_fb_event_filter_start, _ecore_fb_event_filter_filter, _ecore_fb_event_filter_end, NULL); + + usleep(40000); + if (ioctl(_ecore_fb_vt_tty_fd, VT_ACTIVATE, _ecore_fb_vt_current_vt) < 0) + { + perror("[ecore_fb:vt_setup] error on VT_ACTIVATE"); + close(_ecore_fb_vt_tty_fd); + return 0; + } + if(ioctl(_ecore_fb_vt_tty_fd, VT_WAITACTIVE, _ecore_fb_vt_current_vt) < 0) + { + perror("[ecore_fb:vt_setup] error on VT_WAITACTIVE"); + close(_ecore_fb_vt_tty_fd); + return 0; + } + /* FIXME assign the fb to the tty in case isn't setup */ + return 1; } int ecore_fb_vt_init(void) { - struct vt_stat vtstat; - - /* as root you can allocate another tty */ - if(!geteuid()) - _ecore_fb_vt_do_switch = 1; - if((_ecore_fb_vt_tty0_fd = open("/dev/tty0", O_RDONLY)) < 0) - { - printf("[ecore_fb:init] cant open /dev/tty0\n"); - return 0; - } - /* query current vt state */ - if((ioctl(_ecore_fb_vt_tty0_fd, VT_GETSTATE, &vtstat)) < 0) - { - printf("[ecore_fb:init] cant get current tty state\n"); - return 0; - } - _ecore_fb_vt_prev_vt = vtstat.v_active; - /* switch to another tty */ - if(_ecore_fb_vt_do_switch) - { - int vtno; - - if ((ioctl(_ecore_fb_vt_tty0_fd, VT_OPENQRY, &vtno) < 0)) - { - printf("[ecore_fb:init] cant query for a vt\n"); - return 0; - } - _ecore_fb_vt_current_vt = vtno; - } - /* use current tty */ - else - _ecore_fb_vt_current_vt = _ecore_fb_vt_prev_vt; - if(!_ecore_fb_vt_setup()) - { - printf("[ecore_fb:init] cant setup the vt, restoring previous mode...\n"); - /* TODO finish this */ - if(_ecore_fb_vt_do_switch) - { - printf("[ecore_fb:init] switching back to vt %d\n", _ecore_fb_vt_prev_vt); - } - return 0; - } - return 1; + struct vt_stat vtstat; + + /* as root you can allocate another tty */ + if (!geteuid()) + _ecore_fb_vt_do_switch = 1; + if ((_ecore_fb_vt_tty0_fd = open("/dev/tty0", O_RDONLY)) < 0) + { + printf("[ecore_fb:init] can't open /dev/tty0\n"); + return 0; + } + /* query current vt state */ + if ((ioctl(_ecore_fb_vt_tty0_fd, VT_GETSTATE, &vtstat)) < 0) + { + printf("[ecore_fb:init] can't get current tty state\n"); + return 0; + } + _ecore_fb_vt_prev_vt = vtstat.v_active; + /* switch to another tty */ + if (_ecore_fb_vt_do_switch) + { + int vtno; + + if ((ioctl(_ecore_fb_vt_tty0_fd, VT_OPENQRY, &vtno) < 0)) + { + printf("[ecore_fb:init] can't query for a vt\n"); + return 0; + } + _ecore_fb_vt_current_vt = vtno; + } + /* use current tty */ + else + _ecore_fb_vt_current_vt = _ecore_fb_vt_prev_vt; + if (!_ecore_fb_vt_setup()) + { + printf("[ecore_fb:init] can't setup the vt, restoring previous mode...\n"); + /* TODO finish this */ + if (_ecore_fb_vt_do_switch) + { + printf("[ecore_fb:init] switching back to vt %d\n", _ecore_fb_vt_prev_vt); + } + return 0; + } + return 1; } void ecore_fb_vt_shutdown(void) { - /* restore the previous mode */ - if(_ecore_fb_vt_tty_fd != 0) - { - tcsetattr(_ecore_fb_vt_tty_fd, TCSAFLUSH, &_ecore_fb_tty_prev_tio_mode); - ioctl(_ecore_fb_vt_tty_fd, KDSETMODE, _ecore_fb_tty_prev_kd_mode); - ioctl(_ecore_fb_vt_tty_fd, KDSKBMODE, _ecore_fb_tty_prev_mode); - ioctl(_ecore_fb_vt_tty_fd, VT_SETMODE, &_ecore_fb_vt_prev_mode); - /* go back to previous vt */ - close(_ecore_fb_vt_tty_fd); - _ecore_fb_vt_tty_fd = 0; - } - - if(_ecore_fb_user_handler) - ecore_event_handler_del(_ecore_fb_user_handler); - _ecore_fb_user_handler = NULL; - - if(_ecore_fb_filter_handler) - ecore_event_filter_del(_ecore_fb_filter_handler); - _ecore_fb_filter_handler = NULL; + /* restore the previous mode */ + if (_ecore_fb_vt_tty_fd != 0) + { + tcsetattr(_ecore_fb_vt_tty_fd, TCSAFLUSH, &_ecore_fb_tty_prev_tio_mode); + ioctl(_ecore_fb_vt_tty_fd, KDSETMODE, _ecore_fb_tty_prev_kd_mode); + ioctl(_ecore_fb_vt_tty_fd, KDSKBMODE, _ecore_fb_tty_prev_mode); + ioctl(_ecore_fb_vt_tty_fd, VT_SETMODE, &_ecore_fb_vt_prev_mode); + /* go back to previous vt */ + close(_ecore_fb_vt_tty_fd); + _ecore_fb_vt_tty_fd = 0; + } + + if (_ecore_fb_user_handler) ecore_event_handler_del(_ecore_fb_user_handler); + _ecore_fb_user_handler = NULL; + + if (_ecore_fb_filter_handler) ecore_event_filter_del(_ecore_fb_filter_handler); + _ecore_fb_filter_handler = NULL; } /** - * To be documented. + * @addtogroup Ecore_FB_Group Ecore_FB - Frame buffer convenience functions. * - * FIXME: To be fixed. - * @todo Documentation: Find out what this does. + * @{ + */ + +/** + * @brief Set a callback called when a virtual terminal is gained. + * + * @param func The callback called when vt is gained. + * @param data The data to pass to the callback. + * + * This function sets the callback @p func which will be called when a + * virtual terminal is gained (for example you press Ctrl-Alt-F1 to go + * to vt1 and your app was using vt1). @p data will be pass to @p func if + * the callback is called. */ EAPI void ecore_fb_callback_gain_set(void (*func) (void *data), void *data) @@ -230,19 +243,30 @@ ecore_fb_callback_gain_set(void (*func) (void *data), void *data) } /** - * To be documented. + * @brief Set a callback called when a virtual terminal is lost. + * + * @param func The callback called when vt is lost. + * @param data The data to pass to the callback. * - * FIXME: To be fixed. - * @todo Documentation: Find out what this does. + * This function sets the callback @p func which will be called when a + * virtual terminal is lost (someone wants the tv from you and you + * want to give up that vt). @p data will be pass to @p func if the + * callback is called. */ EAPI void ecore_fb_callback_lose_set(void (*func) (void *data), void *data) { _ecore_fb_func_fb_lost = func; _ecore_fb_func_fb_lost_data = data; + } + +/** + * @} + */ + typedef struct _Ecore_Fb_Filter_Data Ecore_Fb_Filter_Data; - + struct _Ecore_Fb_Filter_Data { int last_event_type; @@ -266,11 +290,11 @@ _ecore_fb_event_filter_filter(void *data __UNUSED__, void *loop_data,int type, v if (!filter_data) return EINA_TRUE; if (type == ECORE_FB_EVENT_MOUSE_MOVE) { - if ((filter_data->last_event_type) == ECORE_FB_EVENT_MOUSE_MOVE) - { - filter_data->last_event_type = type; - return EINA_FALSE; - } + if ((filter_data->last_event_type) == ECORE_FB_EVENT_MOUSE_MOVE) + { + filter_data->last_event_type = type; + return EINA_FALSE; + } } filter_data->last_event_type = type; return EINA_TRUE; diff --git a/src/lib/ecore_file/Ecore_File.h b/src/lib/ecore_file/Ecore_File.h index c7fedda..8b843cb 100644 --- a/src/lib/ecore_file/Ecore_File.h +++ b/src/lib/ecore_file/Ecore_File.h @@ -43,82 +43,125 @@ extern "C" { #endif - typedef struct _Ecore_File_Monitor Ecore_File_Monitor; - typedef struct _Ecore_File_Monitor_Event Ecore_File_Monitor_Event; - typedef struct _Ecore_File_Download_Job Ecore_File_Download_Job; - - typedef enum - { - ECORE_FILE_EVENT_NONE, - ECORE_FILE_EVENT_CREATED_FILE, - ECORE_FILE_EVENT_CREATED_DIRECTORY, - ECORE_FILE_EVENT_DELETED_FILE, - ECORE_FILE_EVENT_DELETED_DIRECTORY, - ECORE_FILE_EVENT_DELETED_SELF, - ECORE_FILE_EVENT_MODIFIED - } Ecore_File_Event; - - - EAPI int ecore_file_init (void); - EAPI int ecore_file_shutdown (void); - EAPI long long ecore_file_mod_time (const char *file); - EAPI long long ecore_file_size (const char *file); - EAPI Eina_Bool ecore_file_exists (const char *file); - EAPI Eina_Bool ecore_file_is_dir (const char *file); - EAPI Eina_Bool ecore_file_mkdir (const char *dir); - EAPI int ecore_file_mkdirs (const char **dirs); - EAPI int ecore_file_mksubdirs (const char *base, const char **subdirs); - EAPI Eina_Bool ecore_file_rmdir (const char *dir); - EAPI Eina_Bool ecore_file_recursive_rm (const char *dir); - EAPI Eina_Bool ecore_file_mkpath (const char *path); - EAPI int ecore_file_mkpaths (const char **paths); - EAPI Eina_Bool ecore_file_cp (const char *src, const char *dst); - EAPI Eina_Bool ecore_file_mv (const char *src, const char *dst); - EAPI Eina_Bool ecore_file_symlink (const char *src, const char *dest); - EAPI char *ecore_file_realpath (const char *file); - EAPI Eina_Bool ecore_file_unlink (const char *file); - EAPI Eina_Bool ecore_file_remove (const char *file); - EAPI const char *ecore_file_file_get (const char *path); - EAPI char *ecore_file_dir_get (const char *path); - - EAPI Eina_Bool ecore_file_can_read (const char *file); - EAPI Eina_Bool ecore_file_can_write (const char *file); - EAPI Eina_Bool ecore_file_can_exec (const char *file); - EAPI char *ecore_file_readlink (const char *link); - EAPI Eina_List *ecore_file_ls (const char *dir); - EAPI Eina_Iterator *ecore_file_ls_iterator(const char *dir); - EAPI char *ecore_file_app_exe_get (const char *app); - EAPI char *ecore_file_escape_name (const char *filename); - EAPI char *ecore_file_strip_ext (const char *file); - EAPI int ecore_file_dir_is_empty (const char *dir); - - EAPI Ecore_File_Monitor * ecore_file_monitor_add(const char *path, - void (*func) (void *data, Ecore_File_Monitor *em, - Ecore_File_Event event, - const char *path), - void *data); - EAPI void ecore_file_monitor_del(Ecore_File_Monitor *ecore_file_monitor); - EAPI const char *ecore_file_monitor_path_get(Ecore_File_Monitor *ecore_file_monitor); - - EAPI int ecore_file_path_dir_exists(const char *in_dir); - EAPI int ecore_file_app_installed(const char *exe); - EAPI Eina_List *ecore_file_app_list(void); - - EAPI int ecore_file_download(const char *url, const char *dst, - void (*completion_cb)(void *data, - const char *file, - int status), - int (*progress_cb)(void *data, - const char *file, - long int dltotal, - long int dlnow, - long int ultotal, - long int ulnow), - void *data, - Ecore_File_Download_Job **job_ret); - EAPI void ecore_file_download_abort_all(void); - EAPI void ecore_file_download_abort(Ecore_File_Download_Job *job); - EAPI int ecore_file_download_protocol_available(const char *protocol); +/** + * @defgroup Ecore_File_Group Ecore_File - Files and direcotries convenience functions + * + * @{ + */ + +/** + * @typedef Ecore_File_Monitor + * Abstract type used when monitoring a directory. + */ +typedef struct _Ecore_File_Monitor Ecore_File_Monitor; + +/** + * @typedef Ecore_File_Download_Job + * Abstract type used when aborting a download. + */ +typedef struct _Ecore_File_Download_Job Ecore_File_Download_Job; + +/** + * @typedef Ecore_File_Event + * The event type returned when a file or directory is monitored. + */ +typedef enum _Ecore_File_Event +{ + ECORE_FILE_EVENT_NONE, /**< No event. */ + ECORE_FILE_EVENT_CREATED_FILE, /**< Created file event. */ + ECORE_FILE_EVENT_CREATED_DIRECTORY, /**< Created directory event. */ + ECORE_FILE_EVENT_DELETED_FILE, /**< Deleted file event. */ + ECORE_FILE_EVENT_DELETED_DIRECTORY, /**< Deleted directory event. */ + ECORE_FILE_EVENT_DELETED_SELF, /**< Deleted monitored directory event. */ + ECORE_FILE_EVENT_MODIFIED /**< Modified file or directory event. */ +} Ecore_File_Event; + +/** + * @typedef Ecore_File_Monitor_Cb + * Callback type used when a monitored directory has changes. + */ +typedef void (*Ecore_File_Monitor_Cb)(void *data, Ecore_File_Monitor *em, Ecore_File_Event event, const char *path); + +/** + * @typedef Ecore_File_Download_Completion_Cb + * Callback type used when a download is finished. + */ +typedef void (*Ecore_File_Download_Completion_Cb)(void *data, const char *file, int status); + +/** + * @typedef Ecore_File_Download_Progress_Cb + * Callback type used when a download is finished. + */ +typedef int (*Ecore_File_Download_Progress_Cb)(void *data, + const char *file, + long int dltotal, + long int dlnow, + long int ultotal, + long int ulnow); + +/* File operations */ + +EAPI int ecore_file_init (void); +EAPI int ecore_file_shutdown (void); +EAPI long long ecore_file_mod_time (const char *file); +EAPI long long ecore_file_size (const char *file); +EAPI Eina_Bool ecore_file_exists (const char *file); +EAPI Eina_Bool ecore_file_is_dir (const char *file); +EAPI Eina_Bool ecore_file_mkdir (const char *dir); +EAPI int ecore_file_mkdirs (const char **dirs); +EAPI int ecore_file_mksubdirs (const char *base, const char **subdirs); +EAPI Eina_Bool ecore_file_rmdir (const char *dir); +EAPI Eina_Bool ecore_file_recursive_rm (const char *dir); +EAPI Eina_Bool ecore_file_mkpath (const char *path); +EAPI int ecore_file_mkpaths (const char **paths); +EAPI Eina_Bool ecore_file_cp (const char *src, const char *dst); +EAPI Eina_Bool ecore_file_mv (const char *src, const char *dst); +EAPI Eina_Bool ecore_file_symlink (const char *src, const char *dest); +EAPI char *ecore_file_realpath (const char *file); +EAPI Eina_Bool ecore_file_unlink (const char *file); +EAPI Eina_Bool ecore_file_remove (const char *file); +EAPI const char *ecore_file_file_get (const char *path); +EAPI char *ecore_file_dir_get (const char *path); +EAPI Eina_Bool ecore_file_can_read (const char *file); +EAPI Eina_Bool ecore_file_can_write (const char *file); +EAPI Eina_Bool ecore_file_can_exec (const char *file); +EAPI char *ecore_file_readlink (const char *link); +EAPI Eina_List *ecore_file_ls (const char *dir); +EAPI Eina_Iterator *ecore_file_ls_iterator (const char *dir); +EAPI char *ecore_file_app_exe_get (const char *app); +EAPI char *ecore_file_escape_name (const char *filename); +EAPI char *ecore_file_strip_ext (const char *file); +EAPI int ecore_file_dir_is_empty (const char *dir); + +/* Monitoring */ + +EAPI Ecore_File_Monitor *ecore_file_monitor_add(const char *path, + Ecore_File_Monitor_Cb func, + void *data); +EAPI void ecore_file_monitor_del(Ecore_File_Monitor *ecore_file_monitor); +EAPI const char *ecore_file_monitor_path_get(Ecore_File_Monitor *ecore_file_monitor); + +/* Path */ + +EAPI Eina_Bool ecore_file_path_dir_exists(const char *in_dir); +EAPI Eina_Bool ecore_file_app_installed(const char *exe); +EAPI Eina_List *ecore_file_app_list(void); + +/* Download */ + +EAPI Eina_Bool ecore_file_download(const char *url, + const char *dst, + Ecore_File_Download_Completion_Cb completion_cb, + Ecore_File_Download_Progress_Cb progress_cb, + void *data, + Ecore_File_Download_Job **job_ret); +EAPI void ecore_file_download_abort_all(void); +EAPI void ecore_file_download_abort(Ecore_File_Download_Job *job); +EAPI Eina_Bool ecore_file_download_protocol_available(const char *protocol); + +/** + * @} + */ #ifdef __cplusplus } diff --git a/src/lib/ecore_file/ecore_file.c b/src/lib/ecore_file/ecore_file.c index ec0a1f7..b568ca2 100644 --- a/src/lib/ecore_file/ecore_file.c +++ b/src/lib/ecore_file/ecore_file.c @@ -26,19 +26,34 @@ int _ecore_file_log_dom = -1; static int _ecore_file_init_count = 0; /* externally accessible functions */ + /** - * Initialize Ecore_File and the services it will use. Call this function - * once before you use any of the ecore file functions. - * @return Return the number howoften ecore_file_init() was call succesfully; - * 0 if it failed. + * @addtogroup Ecore_File_Group Ecore_File - Files and direcotries convenience functions + * + * @{ + */ + +/** + * @brief Initialize the Ecore_File library. + * + * @return 1 or greater on success, 0 on error. + * + * This function sets up Ecore_File and the services it will use + * (monitoring, downloading, PATH related feature). It returns 0 on + * failure, otherwise it returns the number of times it has already + * been called. + * + * When Ecore_File is not used anymore, call ecore_file_shutdown() + * to shut down the Ecore_File library. */ EAPI int ecore_file_init() { if (++_ecore_file_init_count != 1) return _ecore_file_init_count; - _ecore_file_log_dom = eina_log_domain_register("EcoreFile", ECORE_FILE_DEFAULT_LOG_COLOR); - if(_ecore_file_log_dom < 0) + _ecore_file_log_dom = eina_log_domain_register + ("ecore_file", ECORE_FILE_DEFAULT_LOG_COLOR); + if(_ecore_file_log_dom < 0) { EINA_LOG_ERR("Impossible to create a log domain for the ecore file module."); return --_ecore_file_init_count; @@ -70,8 +85,14 @@ ecore_file_init() } /** - * Shutdown the Ecore_File - * @return returns the number of libraries that still uses Ecore_File + * @brief Shut down the Ecore_File library. + * + * @return 0 when the library is completely shut down, 1 or + * greater otherwise. + * + * This function shuts down the Ecore_File library. It returns 0 when it has + * been called the same number of times than ecore_file_init(). In that case + * it shuts down all the services it uses. */ EAPI int ecore_file_shutdown() @@ -88,10 +109,14 @@ ecore_file_shutdown() } /** - * Get the time of the last modification to the give file - * @param file The name of the file - * @return Return the time of the last data modification, if an error should - * occur it will return 0 + * @brief Get the time of the last modification to the given file. + * + * @param file The name of the file. + * @return Return the time of the last data modification, or 0 on + * failure. + * + * This function returns the time of the last modification of + * @p file. On failure, it returns 0. */ EAPI long long ecore_file_mod_time(const char *file) @@ -103,9 +128,13 @@ ecore_file_mod_time(const char *file) } /** - * Get the size of the given file - * @param file The name of the file - * @return The size of the file in byte + * @brief Get the size of the given file. + * + * @param file The name of the file. + * @return Return the size of the file in bytes, or 0 on failure. + * + * This function returns the size of @p file in bytes. On failure, it + * returns 0. */ EAPI long long ecore_file_size(const char *file) @@ -117,9 +146,13 @@ ecore_file_size(const char *file) } /** - * Check if file exists - * @param file The name of the file - * @return EINA_TRUE if file exists on local filesystem, EINA_FALSE otherwise + * @brief Check if the given file exists. + * + * @param file The name of the file. + * @return Return EINA_TRUE if the file exists, EINA_FALSE otherwise. + * + * This function returns EINA_TRUE if @p file exists on local filesystem, + * EINA_FALSE otherwise. */ EAPI Eina_Bool ecore_file_exists(const char *file) @@ -132,9 +165,14 @@ ecore_file_exists(const char *file) } /** - * Check if file is a directory - * @param file The name of the file - * @return EINA_TRUE if file exist and is a directory, EINA_FALSE otherwise + * @brief Check if the given file is a directory. + * + * @param file The name of the file. + * @return Return EINA_TRUE if the file exists and is a directory, + * EINA_FALSE otherwise. + * + * This function returns EINA_TRUE if @p file exists exists and is a + * directory on local filesystem, EINA_FALSE otherwise. */ EAPI Eina_Bool ecore_file_is_dir(const char *file) @@ -149,11 +187,14 @@ ecore_file_is_dir(const char *file) static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; /** - * Create a new directory + * @brief Create a new directory. + * * @param dir The name of the directory to create - * @return EINA_TRUE on successfull creation, EINA_FALSE on failure + * @return EINA_TRUE on successful creation, EINA_FALSE otherwise. * - * The directory is created with the mode: S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH + * This function creates the directory @p dir with the mode S_IRUSR | + * S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH. On + * success, it returns EINA_TRUE, EINA_FALSE otherwise. */ EAPI Eina_Bool ecore_file_mkdir(const char *dir) @@ -163,12 +204,17 @@ ecore_file_mkdir(const char *dir) } /** - * Create complete directory in a batch. + * @brief Create complete directory in a batch. * - * @param dirs list of directories, null terminated. - * @return number of successfull directories created, -1 if dirs is NULL. + * @param dirs The list of directories, null terminated. + * @return The number of successful directories created, -1 if dirs is + * @c NULL. * - * @see ecore_file_mkdir() and ecore_file_mkpaths() + * This function creates all the directories that are in the null + * terminated array @p dirs. The function loops over the directories + * and call ecore_file_mkdir(). This function returns -1 if @p dirs is + * @c NULL, otherwise if returns the number of suceesfully created + * directories. */ EAPI int ecore_file_mkdirs(const char **dirs) @@ -184,19 +230,22 @@ ecore_file_mkdirs(const char **dirs) } /** - * Create complete list of sub-directories in a batch (optimized). + * @brief Create complete list of sub-directories in a batch (optimized). * - * @param base the base directory to act on, will be created if does - * not exists. - * @param subdirs list of directories, null terminated. These are - * created similarly to ecore_file_mkdir(), so same mode and whole - * path to that point must exists. So if creating base/a/b/c, - * provide subdirs with "a", "a/b" and "a/b/c" in that order! + * @param base The base directory to act on. + * @param subdirs The list of directories, null terminated. + * @return number of successful directories created, -1 on failure. * - * @return number of successfull directories created, -1 if subdirs or - * base is NULL or invalid. - * - * @see ecore_file_mkdir() and ecore_file_mkpaths() + * This function creates all the directories that are in the null + * terminated array @p dirs in the @p base directory. If @p base does + * not exist, it will be created. The function loops over the directories + * and call ecore_file_mkdir(). The whole path of the directories must + * exist. So if base/a/b/c wants to be created, @p subdirs must + * contain "a", "a/b" and "a/b/c", in that order. This function + * returns -1 if @p dirs or @p base are @c NULL, or if @p base is + * empty ("\0"). It returns 0 is @p base is not a directory or + * invalid, or if it can't be created. Otherwise if returns the number + * of suceesfully created directories. */ EAPI int ecore_file_mksubdirs(const char *base, const char **subdirs) @@ -223,8 +272,8 @@ ecore_file_mksubdirs(const char *base, const char **subdirs) if (buf[baselen - 1] != '/') { - buf[baselen] = '/'; - baselen++; + buf[baselen] = '/'; + baselen++; } #else dir = opendir(base); @@ -236,36 +285,36 @@ ecore_file_mksubdirs(const char *base, const char **subdirs) i = 0; for (; *subdirs; subdirs++) { - struct stat st; + struct stat st; #ifndef HAVE_ATFILE_SOURCE - eina_strlcpy(buf + baselen, *subdirs, sizeof(buf) - baselen); - if (stat(buf, &st) == 0) + eina_strlcpy(buf + baselen, *subdirs, sizeof(buf) - baselen); + if (stat(buf, &st) == 0) #else - if (fstatat(fd, *subdirs, &st, 0) == 0) + if (fstatat(fd, *subdirs, &st, 0) == 0) #endif - { - if (S_ISDIR(st.st_mode)) - { - i++; - continue; - } - } - else - { - if (errno == ENOENT) - { + { + if (S_ISDIR(st.st_mode)) + { + i++; + continue; + } + } + else + { + if (errno == ENOENT) + { #ifndef HAVE_ATFILE_SOURCE - if (mkdir(buf, default_mode) == 0) + if (mkdir(buf, default_mode) == 0) #else - if (mkdirat(fd, *subdirs, default_mode) == 0) + if (mkdirat(fd, *subdirs, default_mode) == 0) #endif - { - i++; - continue; - } - } - } + { + i++; + continue; + } + } + } } #ifdef HAVE_ATFILE_SOURCE @@ -276,9 +325,13 @@ ecore_file_mksubdirs(const char *base, const char **subdirs) } /** - * Delete the given dir - * @param dir The name of the directory to delete - * @return EINA_TRUE on success, EINA_FALSE on failure + * @brief Delete the given directory. + * + * @param dir The name of the directory to delete. + * @return EINA_TRUE on success, EINA_FALSE otherwise. + * + * This function deletes @p dir. It returns EINA_TRUE on success, + * EINA_FALSE otherwise. */ EAPI Eina_Bool ecore_file_rmdir(const char *dir) @@ -288,9 +341,13 @@ ecore_file_rmdir(const char *dir) } /** - * Delete the given file - * @param file The name of the file to delete - * @return EINA_TRUE on success, EINA_FALSE on failure + * @brief Delete the given file. + * + * @param file The name of the file to delete. + * @return EINA_TRUE on success, EINA_FALSE otherwise. + * + * This function deletes @p file. It returns EINA_TRUE on success, + * EINA_FALSE otherwise. */ EAPI Eina_Bool ecore_file_unlink(const char *file) @@ -300,9 +357,13 @@ ecore_file_unlink(const char *file) } /** - * Remove the given file or directory - * @param file The name of the file or directory to delete - * @return EINA_TRUE on success, EINA_FALSE on failure + * @brief Remove the given file or directory. + * + * @param file The name of the file or directory to delete. + * @return EINA_TRUE on success, EINA_FALSE otherwise. + * + * This function removes @p file. It returns EINA_TRUE on success, + * EINA_FALSE otherwise. */ EAPI Eina_Bool ecore_file_remove(const char *file) @@ -312,11 +373,14 @@ ecore_file_remove(const char *file) } /** - * Delete a directory and all its contents - * @param dir The name of the directory to delete - * @return EINA_TRUE on success, EINA_FALSE on failure + * @brief Delete the given directory and all its contents. * - * If dir is a link only the link is removed + * @param dir The name of the directory to delete. + * @return EINA_TRUE on success, EINA_FALSE otherwise. + * + * This function delete @p dir and all its contents. If @p dir is a + * link only the link is removed. It returns EINA_TRUE on success, + * EINA_FALSE otherwise. */ EAPI Eina_Bool ecore_file_recursive_rm(const char *dir) @@ -333,23 +397,23 @@ ecore_file_recursive_rm(const char *dir) ret = stat(dir, &st); if ((ret == 0) && (S_ISDIR(st.st_mode))) { - ret = 1; - if (stat(dir, &st) == -1) return EINA_FALSE; - dirp = opendir(dir); - if (dirp) - { - while ((dp = readdir(dirp))) - { - if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, ".."))) - { - snprintf(path, PATH_MAX, "%s/%s", dir, dp->d_name); - if (!ecore_file_recursive_rm(path)) - ret = 0; - } - } - closedir(dirp); - } - if (!ecore_file_rmdir(dir)) ret = 0; + ret = 1; + if (stat(dir, &st) == -1) return EINA_FALSE; + dirp = opendir(dir); + if (dirp) + { + while ((dp = readdir(dirp))) + { + if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, ".."))) + { + snprintf(path, PATH_MAX, "%s/%s", dir, dp->d_name); + if (!ecore_file_recursive_rm(path)) + ret = 0; + } + } + closedir(dirp); + } + if (!ecore_file_rmdir(dir)) ret = 0; if (ret) return EINA_TRUE; else @@ -357,8 +421,8 @@ ecore_file_recursive_rm(const char *dir) } else { - if (ret == -1) return EINA_FALSE; - return ecore_file_unlink(dir); + if (ret == -1) return EINA_FALSE; + return ecore_file_unlink(dir); } } @@ -376,11 +440,15 @@ _ecore_file_mkpath_if_not_exists(const char *path) } /** - * Create a complete path + * @brief Create a complete path. + * * @param path The path to create - * @return EINA_TRUE on success, EINA_FALSE on failure + * @return EINA_TRUE on success, EINA_FALSE otherwise. * - * @see ecore_file_mkpaths() and ecore_file_mkdir() + * This function create @p path and all the subdirectories it + * contains. The separator is '/' so, on Windows, '\' must be replaced + * by '/'. If @p path exists, this function returns EINA_TRUE + * immediatly. It returns EINA_TRUE on success, EINA_FALSE otherwise. */ EAPI Eina_Bool ecore_file_mkpath(const char *path) @@ -393,25 +461,30 @@ ecore_file_mkpath(const char *path) for (i = 0; path[i] != '\0'; ss[i] = path[i], i++) { - if (i == sizeof(ss) - 1) return EINA_FALSE; - if ((path[i] == '/') && (i > 0)) - { - ss[i] = '\0'; - if (!_ecore_file_mkpath_if_not_exists(ss)) - return EINA_FALSE; - } + if (i == sizeof(ss) - 1) return EINA_FALSE; + if ((path[i] == '/') && (i > 0)) + { + ss[i] = '\0'; + if (!_ecore_file_mkpath_if_not_exists(ss)) + return EINA_FALSE; + } } ss[i] = '\0'; return _ecore_file_mkpath_if_not_exists(ss); } /** - * Create complete paths in a batch. + * @brief Create complete paths in a batch. * * @param paths list of paths, null terminated. - * @return number of successfull paths created, -1 if paths is NULL. + * @return number of successful paths created, -1 if paths is NULL. * - * @see ecore_file_mkpath() and ecore_file_mkdirs() + * This function creates all the directories that are in the null + * terminated array @p paths. The function loops over the directories + * and call ecore_file_mkpath(), hence on Windows, '\' must be + * replaced by '/' before calling that function. This function + * returns -1 if @p paths is @c NULL. Otherwise if returns the number + * of suceesfully created directories. */ EAPI int ecore_file_mkpaths(const char **paths) @@ -427,10 +500,16 @@ ecore_file_mkpaths(const char **paths) } /** - * Copy a file - * @param src The name of the source file - * @param dst The name of the destination file - * @return EINA_TRUE on success, EINA_FALSE on failure + * @brief Copy the given file to the given destination. + * + * @param src The name of the source file. + * @param dst The name of the destination file. + * @return EINA_TRUE on success, EINA_FALSE otherwise. + * + * This function copies @p src to @p dst. If the absolute path name of + * @p src and @p dst can not be computed, or if they are equal, or if + * the copy fails, the function returns EINA_FALSE, otherwise it + * returns EINA_TRUE. */ EAPI Eina_Bool ecore_file_cp(const char *src, const char *dst) @@ -449,12 +528,12 @@ ecore_file_cp(const char *src, const char *dst) f2 = fopen(dst, "wb"); if (!f2) { - fclose(f1); - return EINA_FALSE; + fclose(f1); + return EINA_FALSE; } while ((num = fread(buf, 1, sizeof(buf), f1)) > 0) { - if (fwrite(buf, 1, num, f2) != num) ret = EINA_FALSE; + if (fwrite(buf, 1, num, f2) != num) ret = EINA_FALSE; } fclose(f1); fclose(f2); @@ -462,10 +541,14 @@ ecore_file_cp(const char *src, const char *dst) } /** - * Move a file - * @param src The name of the source file - * @param dst The name of the destination file - * @return EINA_TRUE on success, EINA_FALSE on failure + * @brief Move the given file to the given destination. + * + * @param src The name of the source file. + * @param dst The name of the destination file. + * @return EINA_TRUE on success, EINA_FALSE otherwise. + * + * This function moves @p src to @p dst. It returns EINA_TRUE on + * success, EINA_FALSE otherwise. */ EAPI Eina_Bool ecore_file_mv(const char *src, const char *dst) @@ -477,55 +560,55 @@ ecore_file_mv(const char *src, const char *dst) { // File cannot be moved directly because // it resides on a different mount point. - if (errno == EXDEV) - { - struct stat st; + if (errno == EXDEV) + { + struct stat st; // Make sure this is a regular file before // we do anything fancy. - stat(src, &st); - if (S_ISREG(st.st_mode)) - { - char *dir; - - dir = ecore_file_dir_get(dst); - // Since we can't directly rename, try to - // copy to temp file in the dst directory - // and then rename. - snprintf(buf, sizeof(buf), "%s/.%s.tmp.XXXXXX", - dir, ecore_file_file_get(dst)); - free(dir); - fd = mkstemp(buf); - if (fd < 0) - { - perror("mkstemp"); - goto FAIL; - } - close(fd); - - // Copy to temp file - if (!ecore_file_cp(src, buf)) - goto FAIL; - - // Set file permissions of temp file to match src - chmod(buf, st.st_mode); - - // Try to atomically move temp file to dst - if (rename(buf, dst)) - { - // If we still cannot atomically move - // do a normal copy and hope for the best. - if (!ecore_file_cp(buf, dst)) - goto FAIL; - } - - // Delete temporary file and src - ecore_file_unlink(buf); - ecore_file_unlink(src); - goto PASS; - } - } - goto FAIL; + stat(src, &st); + if (S_ISREG(st.st_mode)) + { + char *dir; + + dir = ecore_file_dir_get(dst); + // Since we can't directly rename, try to + // copy to temp file in the dst directory + // and then rename. + snprintf(buf, sizeof(buf), "%s/.%s.tmp.XXXXXX", + dir, ecore_file_file_get(dst)); + free(dir); + fd = mkstemp(buf); + if (fd < 0) + { + perror("mkstemp"); + goto FAIL; + } + close(fd); + + // Copy to temp file + if (!ecore_file_cp(src, buf)) + goto FAIL; + + // Set file permissions of temp file to match src + chmod(buf, st.st_mode); + + // Try to atomically move temp file to dst + if (rename(buf, dst)) + { + // If we still cannot atomically move + // do a normal copy and hope for the best. + if (!ecore_file_cp(buf, dst)) + goto FAIL; + } + + // Delete temporary file and src + ecore_file_unlink(buf); + ecore_file_unlink(src); + goto PASS; + } + } + goto FAIL; } PASS: @@ -536,10 +619,15 @@ FAIL: } /** - * Create a symbolic link - * @param src The name of the file to link - * @param dest The name of link - * @return EINA_TRUE on success, EINA_FALSE on failure + * @brief Create a symbolic link. + * + * @param src The name of the file to link. + * @param dest The name of link. + * @return EINA_TRUE on success, EINA_FALSE otherwise. + * + * This function create the symbolic link @p dest of @p src. This + * function does not work on Windows. It returns EINA_TRUE on success, + * EINA_FALSE otherwise. */ EAPI Eina_Bool ecore_file_symlink(const char *src, const char *dest) @@ -550,10 +638,16 @@ ecore_file_symlink(const char *src, const char *dest) } /** - * Get the canonicalized absolute pathname - * @param file The file path - * @return The canonicalized absolute pathname; on failure it will return - * an empty string + * @brief Get the canonicalized absolute path name. + * + * @param file The file path. + * @return The canonicalized absolute pathname or an empty string on + * failure. + * + * This function returns the absolute path name of @p file as a newly + * allocated string. If @p file is @c NULL, or on error, this function + * returns an empty string. Otherwise, it returns the absolute path + * name. When not needed anymore, the returned value must be freed. */ EAPI char * ecore_file_realpath(const char *file) @@ -571,9 +665,13 @@ ecore_file_realpath(const char *file) } /** - * Get the filename from a give path - * @param path The complete path - * @return Only the file name + * Get the filename from a given path. + * + * @param path The complete path. + * @return The file name. + * + * This function returns the file name of @p path. If @p path is + * @c NULL, the functions returns @c NULL. */ EAPI const char * ecore_file_file_get(const char *path) @@ -587,9 +685,15 @@ ecore_file_file_get(const char *path) } /** - * Get the directory where file reside - * @param file The name of the file - * @return The directory name + * @brief Get the directory where the given file resides. + * + * @param file The name of the file. + * @return The directory name. + * + * This function returns the directory where @p file resides as anewly + * allocated string. If @p file is @c NULL or on error, this function + * returns @c NULL. When not needed anymore, the returned value must + * be freed. */ EAPI char * ecore_file_dir_get(const char *file) @@ -605,9 +709,13 @@ ecore_file_dir_get(const char *file) } /** - * Check if file can be read - * @param file The name of the file - * @return EINA_TRUE if the file is readable, EINA_FALSE otherwise + * @brief Check if the given file can be read. + * + * @param file The name of the file. + * @return EINA_TRUE if the file is readable, EINA_FALSE otherwise. + * + * This function returns EINA_TRUE if @p file can be read, EINA_FALSE + * otherwise. */ EAPI Eina_Bool ecore_file_can_read(const char *file) @@ -618,9 +726,13 @@ ecore_file_can_read(const char *file) } /** - * Check if file can be written - * @param file The name of the file - * @return EINA_TRUE if the file is writable, EINA_FALSE otherwise + * @brief Check if the given file can be written. + * + * @param file The name of the file. + * @return EINA_TRUE if the file is writable, EINA_FALSE otherwise. + * + * This function returns EINA_TRUE if @p file can be written, EINA_FALSE + * otherwise. */ EAPI Eina_Bool ecore_file_can_write(const char *file) @@ -631,9 +743,13 @@ ecore_file_can_write(const char *file) } /** - * Check if file can be executed - * @param file The name of the file - * @return EINA_TRUE if the file can be executed, EINA_FALSE otherwise + * @bbrief Check if the given file can be executed. + * + * @param file The name of the file. + * @return EINA_TRUE if the file can be executed, EINA_FALSE otherwise. + * + * This function returns EINA_TRUE if @p file can be executed, EINA_FALSE + * otherwise. */ EAPI Eina_Bool ecore_file_can_exec(const char *file) @@ -644,9 +760,15 @@ ecore_file_can_exec(const char *file) } /** - * Get the path pointed by link - * @param link The name of the link - * @return The path pointed by link or NULL + * @brief Get the path pointed by the given link. + * + * @param link The name of the link. + * @return The path pointed by link or NULL. + * + * This function returns the path pointed by @p link as a newly + * allocated string. This function does not work on Windows. On + * failure, the function returns @c NULL. When not needed anymore, the + * returned value must be freed. */ EAPI char * ecore_file_readlink(const char *link) @@ -660,14 +782,21 @@ ecore_file_readlink(const char *link) } /** - * Get the list of the files and directories in a given directory. The list - * will be sorted with strcoll as compare function. That means that you may - * want to set the current locale for the category LC_COLLATE with setlocale(). - * For more information see the manual pages of strcoll and setlocale. - * The list will not contain the directory entries for '.' and '..'. + * @brief Get the list of the files and directories in the given + * directory. + * * @param dir The name of the directory to list * @return Return an Eina_List containing all the files in the directory; * on failure it returns NULL. + * + * This function returns a list of allocated strings of all the files + * and directories contained in @p dir. The list will be sorted with + * strcoll as compare function. That means that you may want to set + * the current locale for the category LC_COLLATE with + * setlocale(). For more information see the manual pages of strcoll + * and setlocale. The list will not contain the directory entries for + * '.' and '..'. On failure, @c NULL is returned. When not needed + * anymore, the list elements must be freed. */ EAPI Eina_List * ecore_file_ls(const char *dir) @@ -682,11 +811,11 @@ ecore_file_ls(const char *dir) while ((dp = readdir(dirp))) { - if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, ".."))) - { - f = strdup(dp->d_name); - list = eina_list_append(list, f); - } + if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, ".."))) + { + f = strdup(dp->d_name); + list = eina_list_append(list, f); + } } closedir(dirp); @@ -696,7 +825,14 @@ ecore_file_ls(const char *dir) } /** - * FIXME: To be documented. + * @brief Return the executable from the given command. + * + * @param app The application command, with parameters. + * + * This function returns the executable from @p app as a newly + * allocated string. Arguments are removed and escae characters are + * handled. If @p app is @c NULL, or on failure, the function returns + * @c NULL. When not needed anymore, the returned value must be freed. */ EAPI char * ecore_file_app_exe_get(const char *app) @@ -713,61 +849,61 @@ restart: exe1 = p; while (*p) { - if (in_quot_sing) - { - if (*p == '\'') - in_quot_sing = 0; - } - else if (in_quot_dbl) - { - if (*p == '\"') - in_quot_dbl = 0; - } - else - { - if (*p == '\'') - in_quot_sing = 1; - else if (*p == '\"') - in_quot_dbl = 1; - if ((isspace(*p)) && (!((p > app) && (p[-1] != '\\')))) - break; - } - p++; + if (in_quot_sing) + { + if (*p == '\'') + in_quot_sing = 0; + } + else if (in_quot_dbl) + { + if (*p == '\"') + in_quot_dbl = 0; + } + else + { + if (*p == '\'') + in_quot_sing = 1; + else if (*p == '\"') + in_quot_dbl = 1; + if ((isspace(*p)) && (!((p > app) && (p[-1] != '\\')))) + break; + } + p++; } exe2 = p; if (exe2 == exe1) return NULL; if (*exe1 == '~') { - char *homedir; - int len; - - /* Skip ~ */ - exe1++; - - homedir = getenv("HOME"); - if (!homedir) return NULL; - len = strlen(homedir); - if (exe) free(exe); - exe = malloc(len + exe2 - exe1 + 2); - if (!exe) return NULL; - pp = exe; - if (len) - { - strcpy(exe, homedir); - pp += len; - if (*(pp - 1) != '/') - { - *pp = '/'; - pp++; - } - } + char *homedir; + int len; + + /* Skip ~ */ + exe1++; + + homedir = getenv("HOME"); + if (!homedir) return NULL; + len = strlen(homedir); + if (exe) free(exe); + exe = malloc(len + exe2 - exe1 + 2); + if (!exe) return NULL; + pp = exe; + if (len) + { + strcpy(exe, homedir); + pp += len; + if (*(pp - 1) != '/') + { + *pp = '/'; + pp++; + } + } } else { - if (exe) free(exe); - exe = malloc(exe2 - exe1 + 1); - if (!exe) return NULL; - pp = exe; + if (exe) free(exe); + exe = malloc(exe2 - exe1 + 1); + if (!exe) return NULL; + pp = exe; } p = exe1; restart = 0; @@ -775,79 +911,85 @@ restart: in_quot_sing = 0; while (*p) { - if (in_quot_sing) - { - if (*p == '\'') - in_quot_sing = 0; - else - { - *pp = *p; - pp++; - } - } - else if (in_quot_dbl) - { - if (*p == '\"') - in_quot_dbl = 0; - else - { - /* techcincally this is wrong. double quotes also accept - * special chars: - * - * $, `, \ - */ - *pp = *p; - pp++; - } - } - else - { - /* technically we should handle special chars: - * - * $, `, \, etc. - */ - if ((p > exe1) && (p[-1] == '\\')) - { - if (*p != '\n') - { - *pp = *p; - pp++; - } - } - else if ((p > exe1) && (*p == '=')) - { - restart = 1; - *pp = *p; - pp++; - } - else if (*p == '\'') - in_quot_sing = 1; - else if (*p == '\"') - in_quot_dbl = 1; - else if (isspace(*p)) - { - if (restart) - goto restart; - else - break; - } - else - { - *pp = *p; - pp++; - } - } - p++; + if (in_quot_sing) + { + if (*p == '\'') + in_quot_sing = 0; + else + { + *pp = *p; + pp++; + } + } + else if (in_quot_dbl) + { + if (*p == '\"') + in_quot_dbl = 0; + else + { + /* technically this is wrong. double quotes also accept + * special chars: + * + * $, `, \ + */ + *pp = *p; + pp++; + } + } + else + { + /* technically we should handle special chars: + * + * $, `, \, etc. + */ + if ((p > exe1) && (p[-1] == '\\')) + { + if (*p != '\n') + { + *pp = *p; + pp++; + } + } + else if ((p > exe1) && (*p == '=')) + { + restart = 1; + *pp = *p; + pp++; + } + else if (*p == '\'') + in_quot_sing = 1; + else if (*p == '\"') + in_quot_dbl = 1; + else if (isspace(*p)) + { + if (restart) + goto restart; + else + break; + } + else + { + *pp = *p; + pp++; + } + } + p++; } *pp = 0; return exe; } /** - * Add the escape sequence ('\\') to the given filename - * @param filename The file name - * @return The file name with special characters escaped; if the length of the - * resulting string is longer than PATH_MAX it will return NULL + * @brief Add the escape sequence ('\\') to the given file name. + * + * @param filename The file name. + * @return The file name with special characters escaped. + * + * This function adds the escape sequence ('\\') to the given file + * name and returns the result as a newly allocated string. If the + * length of the returned string is longer than PATH_MAX, or on + * failure, @c NULL is returned. When not needed anymore, the returned + * value must be freed. */ EAPI char * ecore_file_escape_name(const char *filename) @@ -860,59 +1002,75 @@ ecore_file_escape_name(const char *filename) q = buf; while (*p) { - if ((q - buf) > (PATH_MAX - 6)) return NULL; - if ( - (*p == ' ') || (*p == '\t') || (*p == '\n') || - (*p == '\\') || (*p == '\'') || (*p == '\"') || - (*p == ';') || (*p == '!') || (*p == '#') || - (*p == '$') || (*p == '%') || (*p == '&') || - (*p == '*') || (*p == '(') || (*p == ')') || - (*p == '[') || (*p == ']') || (*p == '{') || - (*p == '}') || (*p == '|') || (*p == '<') || - (*p == '>') || (*p == '?') - ) - { - *q = '\\'; - q++; - } - *q = *p; - q++; - p++; + if ((q - buf) > (PATH_MAX - 6)) return NULL; + if ( + (*p == ' ') || (*p == '\t') || (*p == '\n') || + (*p == '\\') || (*p == '\'') || (*p == '\"') || + (*p == ';') || (*p == '!') || (*p == '#') || + (*p == '$') || (*p == '%') || (*p == '&') || + (*p == '*') || (*p == '(') || (*p == ')') || + (*p == '[') || (*p == ']') || (*p == '{') || + (*p == '}') || (*p == '|') || (*p == '<') || + (*p == '>') || (*p == '?') + ) + { + *q = '\\'; + q++; + } + *q = *p; + q++; + p++; } *q = 0; return strdup(buf); } /** - * Remove the extension from a given path - * @param path The name of the file - * @return A newly allocated string with the extension stripped out or NULL on errors + * @bried Remove the extension from the given file name. + * + * @param path The name of the file. + * @return A newly allocated string with the extension stripped out or + * NULL on errors. + * + * This function removes the extension from @p path and returns the + * result as a newly allocated string. If @p path is @c NULL, or on + * failure, the function returns @c NULL. When not needed anymore, the + * returned value must be freed. */ EAPI char * ecore_file_strip_ext(const char *path) { char *p, *file = NULL; + if (!path) + return NULL; + p = strrchr(path, '.'); if (!p) file = strdup(path); else if (p != path) { - file = malloc(((p - path) + 1) * sizeof(char)); - if (file) - { - memcpy(file, path, (p - path)); - file[p - path] = 0; - } + file = malloc(((p - path) + 1) * sizeof(char)); + if (file) + { + memcpy(file, path, (p - path)); + file[p - path] = 0; + } } return file; } /** - * Check if the given directory is empty. The '.' and '..' files will be ignored. - * @param dir The name of the directory to check - * @return 1 if directory is empty, 0 if it has at least one file or -1 in case of errors + * @brief Check if the given directory is empty. + * + * @param dir The name of the directory to check. + * @return 1 if directory is empty, 0 if it has at least one file or + * -1 in case of errors. + * + * This functions checks if @p dir is empty. The '.' and '..' files + * will be ignored. If @p dir is empty, 1 is returned, if it contains + * at least 1 file, 0 is returned. On failure, -1 is returned. */ EAPI int ecore_file_dir_is_empty(const char *dir) @@ -925,13 +1083,17 @@ ecore_file_dir_is_empty(const char *dir) while ((dp = readdir(dirp))) { - if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, ".."))) - { - closedir(dirp); - return 0; - } + if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, ".."))) + { + closedir(dirp); + return 0; + } } closedir(dirp); return 1; } + +/** + * @} + */ diff --git a/src/lib/ecore_file/ecore_file_download.c b/src/lib/ecore_file/ecore_file_download.c index c25b6d5..aa4b6a1 100644 --- a/src/lib/ecore_file/ecore_file_download.c +++ b/src/lib/ecore_file/ecore_file_download.c @@ -13,37 +13,34 @@ #ifdef BUILD_ECORE_CON -#define ECORE_MAGIC_FILE_DOWNLOAD_JOB 0xf7427cb8 +#define ECORE_MAGIC_FILE_DOWNLOAD_JOB 0xf7427cb8 struct _Ecore_File_Download_Job { ECORE_MAGIC; - Ecore_Con_Url *url_con; - FILE *file; + Ecore_Con_Url *url_con; + FILE *file; - char *dst; + char *dst; - void (*completion_cb)(void *data, const char *file, int status); - - int (*progress_cb) (void *data, const char *file, - long int dltotal, long int dlnow, - long int ultotal, long int ulnow); + Ecore_File_Download_Completion_Cb completion_cb; + Ecore_File_Download_Progress_Cb progress_cb; }; #ifdef HAVE_CURL Ecore_File_Download_Job *_ecore_file_download_curl(const char *url, const char *dst, - void (*completion_cb)(void *data, const char *file, int status), - int (*progress_cb)(void *data, const char *file, long int dltotal, long int dlnow, long int ultotal, long int ulnow), - void *data); + Ecore_File_Download_Completion_Cb completion_cb, + Ecore_File_Download_Progress_Cb progress_cb, + void *data); static Eina_Bool _ecore_file_download_url_complete_cb(void *data, int type, void *event); static Eina_Bool _ecore_file_download_url_progress_cb(void *data, int type, void *event); #endif -static Ecore_Event_Handler *_url_complete_handler = NULL; -static Ecore_Event_Handler *_url_progress_download = NULL; -static Eina_List *_job_list; +static Ecore_Event_Handler *_url_complete_handler = NULL; +static Ecore_Event_Handler *_url_progress_download = NULL; +static Eina_List *_job_list; #endif /* BUILD_ECORE_CON */ @@ -80,108 +77,118 @@ ecore_file_download_shutdown(void) #endif /* BUILD_ECORE_CON */ } -EAPI void -ecore_file_download_abort_all(void) -{ -#ifdef BUILD_ECORE_CON - Ecore_File_Download_Job *job; - - EINA_LIST_FREE(_job_list, job) - ecore_file_download_abort(job); -#endif /* BUILD_ECORE_CON */ -} +/** + * @addtogroup Ecore_File_Group Ecore_File - Files and direcotries convenience functions + * + * @{ + */ /** - * Download @p url to the given @p dst - * @param url The complete url to download - * @param dst The local file to save the downloaded to - * @param completion_cb A callback called on download complete - * @param progress_cb A callback called during the download operation - * @param data User data passed to both callbacks - * @param job_ret If the protocol in use is http or ftp, this parameter will be - * filled with the job. Then you can use ecore_file_download_abort() to cancel it. - * - * @return 1 if the download start or 0 on failure + * @brief Download the given url to the given destination. + * + * @param url The complete url to download. + * @param dst The local file to save the downloaded to. + * @param completion_cb A callback called on download complete. + * @param progress_cb A callback called during the download operation. + * @param data User data passed to both callbacks. + * @param job_ret Job used to abort the download. + * @return EINA_TRUE if the download start or EINA_FALSE on failure * - * You must provide the full url, including 'http://', 'ftp://' or 'file://'.\n - * If @p dst already exist it will not be overwritten and the function will fail.\n - * Ecore must be compiled with CURL to download using http and ftp protocols.\n - * The @p status param in the @p completion_cb() will be 0 if the download goes well or - * 1 in case of failure. + * This function starts the download of the URL @p url and saves it to + * @p dst. @p url must provide the protocol, including 'http://', + * 'ftp://' or 'file://'. Ecore_File must be compiled with CURL to + * download using http and ftp protocols. If @p dst is ill-formed, or + * if it already exists, the function returns EINA_FALSE. When the + * download is complete, the callback @p completion_cb is called and + * @p data is passed to it. The @p status parameter of @p completion_cb + * will be filled with the status of the download (200, 404,...). The + * @p progress_cb is called during the download operation, each time a + * packet i received or when CURL wants. It can be used to display the + * percentage of the downloaded file. The only operations that can be + * aborted are those with protocol 'http' or 'ftp'. In that case @p job_ret + * can be filled. It can be used with ecore_file_download_abort() or + * ecore_file_download_abort_all() to respectively abort one or all + * download operations. This function returns EINA_TRUE if the + * download starts, EINA_FALSE otherwise. */ -EAPI int -ecore_file_download(const char *url, const char *dst, - void (*completion_cb)(void *data, const char *file, int status), - int (*progress_cb)(void *data, const char *file, long int dltotal, long int dlnow, long int ultotal, long int ulnow), - void *data, Ecore_File_Download_Job **job_ret) +EAPI Eina_Bool +ecore_file_download(const char *url, + const char *dst, + Ecore_File_Download_Completion_Cb completion_cb, + Ecore_File_Download_Progress_Cb progress_cb, + void *data, + Ecore_File_Download_Job **job_ret) { #ifdef BUILD_ECORE_CON char *dir = ecore_file_dir_get(dst); if (!ecore_file_is_dir(dir)) { - free(dir); - return 0; + free(dir); + return EINA_FALSE; } free(dir); - if (ecore_file_exists(dst)) return 0; + if (ecore_file_exists(dst)) return EINA_FALSE; /* FIXME: Add handlers for http and ftp! */ if (!strncmp(url, "file://", 7)) { - /* FIXME: Maybe fork? Might take a while to copy. - * Check filesize? */ - /* Just copy it */ - - url += 7; - /* skip hostname */ - url = strchr(url, '/'); - return ecore_file_cp(url, dst); + /* FIXME: Maybe fork? Might take a while to copy. + * Check filesize? */ + /* Just copy it */ + + url += 7; + /* skip hostname */ + url = strchr(url, '/'); + return ecore_file_cp(url, dst); } # ifdef HAVE_CURL else if ((!strncmp(url, "http://", 7)) || - (!strncmp(url, "ftp://", 6))) + (!strncmp(url, "ftp://", 6))) { - /* download */ - Ecore_File_Download_Job *job; + /* download */ + Ecore_File_Download_Job *job; - job = _ecore_file_download_curl(url, dst, completion_cb, progress_cb, data); - if(job_ret) *job_ret = job; - return !!job; + job = _ecore_file_download_curl(url, dst, completion_cb, progress_cb, data); + if(job_ret) *job_ret = job; + return job ? EINA_TRUE : EINA_FALSE; } # endif else { - return 0; + return EINA_FALSE; } #else completion_cb = NULL; progress_cb = NULL; data = NULL; - return 0; + return EINA_FALSE; #endif /* BUILD_ECORE_CON */ } /** - * Check if the given protocol is available - * @param protocol The protocol to check - * @return 1 if protocol is handled or 0 if not + * @brief Check if the given protocol is available. * - * @p protocol can be 'http://', 'ftp://' or 'file://'.\n - * Ecore must be compiled with CURL to handle http and ftp protocols. + * @param protocol The protocol to check. + * @return EINA_TRUE if protocol is handled, EINA_FALSE otherwise. + * + * This function returns EINA_TRUE if @p protocol is supported, + * EINA_FALSE otherwise. @p protocol can be 'http://', 'ftp://' or + * 'file://'. Ecore_FILE must be compiled with CURL to handle http and + * ftp protocols. */ -EAPI int +EAPI Eina_Bool ecore_file_download_protocol_available(const char *protocol) { #ifdef BUILD_ECORE_CON - if (!strncmp(protocol, "file://", 7)) return 1; + if (!strncmp(protocol, "file://", 7)) return EINA_TRUE; # ifdef HAVE_CURL - else if (!strncmp(protocol, "http://", 7)) return 1; - else if (!strncmp(protocol, "ftp://", 6)) return 1; + else if (!strncmp(protocol, "http://", 7)) return EINA_TRUE; + else if (!strncmp(protocol, "ftp://", 6)) return EINA_TRUE; # endif #endif /* BUILD_ECORE_CON */ - return 0; + return EINA_FALSE; } #ifdef BUILD_ECORE_CON @@ -190,8 +197,8 @@ ecore_file_download_protocol_available(const char *protocol) static int _ecore_file_download_url_compare_job(const void *data1, const void *data2) { - const Ecore_File_Download_Job *job = data1; - const Ecore_Con_Url *url = data2; + const Ecore_File_Download_Job *job = data1; + const Ecore_Con_Url *url = data2; if (job->url_con == url) return 0; return -1; @@ -200,8 +207,8 @@ _ecore_file_download_url_compare_job(const void *data1, const void *data2) static Eina_Bool _ecore_file_download_url_complete_cb(void *data __UNUSED__, int type __UNUSED__, void *event) { - Ecore_Con_Event_Url_Complete *ev = event; - Ecore_File_Download_Job *job; + Ecore_Con_Event_Url_Complete *ev = event; + Ecore_File_Download_Job *job; job = eina_list_search_unsorted(_job_list, _ecore_file_download_url_compare_job, ev->url_con); if (!ECORE_MAGIC_CHECK(job, ECORE_MAGIC_FILE_DOWNLOAD_JOB)) return ECORE_CALLBACK_PASS_ON; @@ -212,6 +219,7 @@ _ecore_file_download_url_complete_cb(void *data __UNUSED__, int type __UNUSED__, _job_list = eina_list_remove(_job_list, job); fclose(job->file); free(job->dst); + ecore_con_url_free(job->url_con); free(job); return ECORE_CALLBACK_DONE; @@ -222,23 +230,23 @@ _ecore_file_download_url_progress_cb(void *data __UNUSED__, int type __UNUSED__, { /* this reports the downloads progress. if we return 0, then download * continues, if we return anything else, then the download stops */ - Ecore_Con_Event_Url_Progress *ev = event; - Ecore_File_Download_Job *job; + Ecore_Con_Event_Url_Progress *ev = event; + Ecore_File_Download_Job *job; job = eina_list_search_unsorted(_job_list, _ecore_file_download_url_compare_job, ev->url_con); if (!ECORE_MAGIC_CHECK(job, ECORE_MAGIC_FILE_DOWNLOAD_JOB)) return ECORE_CALLBACK_PASS_ON; if (job->progress_cb) if (job->progress_cb(ecore_con_url_data_get(job->url_con), job->dst, - (long int) ev->down.total, (long int) ev->down.now, - (long int) ev->up.total, (long int) ev->up.now) != 0) + (long int) ev->down.total, (long int) ev->down.now, + (long int) ev->up.total, (long int) ev->up.now) != 0) { - _job_list = eina_list_remove(_job_list, job); - fclose(job->file); - free(job->dst); - free(job); + _job_list = eina_list_remove(_job_list, job); + fclose(job->file); + free(job->dst); + free(job); - return ECORE_CALLBACK_PASS_ON; + return ECORE_CALLBACK_PASS_ON; } return ECORE_CALLBACK_DONE; @@ -246,12 +254,9 @@ _ecore_file_download_url_progress_cb(void *data __UNUSED__, int type __UNUSED__, Ecore_File_Download_Job * _ecore_file_download_curl(const char *url, const char *dst, - void (*completion_cb)(void *data, const char *file, - int status), - int (*progress_cb)(void *data, const char *file, - long int dltotal, long int dlnow, - long int ultotal, long int ulnow), - void *data) + Ecore_File_Download_Completion_Cb completion_cb, + Ecore_File_Download_Progress_Cb progress_cb, + void *data) { Ecore_File_Download_Job *job; @@ -263,15 +268,15 @@ _ecore_file_download_curl(const char *url, const char *dst, job->file = fopen(dst, "wb"); if (!job->file) { - free(job); - return NULL; + free(job); + return NULL; } job->url_con = ecore_con_url_new(url); if (!job->url_con) { - fclose(job->file); - free(job); - return NULL; + fclose(job->file); + free(job); + return NULL; } ecore_con_url_fd_set(job->url_con, fileno(job->file)); @@ -291,19 +296,28 @@ _ecore_file_download_curl(const char *url, const char *dst, #endif /** - * Abort the given download job and call the @p completion_cb function with a - * @status of 1 (error) - * @param job The download job to abort + * @brief Abort the given download job and call the completion_cb + * callbck with a status of 1 (error). + * + * @param job The download job to abort. + * + * This function aborts a download operation started by + * ecore_file_download(). @p job is the #Ecore_File_Download_Job + * structure filled by ecore_file_download(). If it is @c NULL, this + * function does nothing. To abort all the currently downloading + * operations, call ecore_file_download_abort_all(). */ - EAPI void ecore_file_download_abort(Ecore_File_Download_Job *job) { + if (!job) + return; + #ifdef BUILD_ECORE_CON if (job->completion_cb) job->completion_cb(ecore_con_url_data_get(job->url_con), job->dst, 1); # ifdef HAVE_CURL - ecore_con_url_destroy(job->url_con); + ecore_con_url_free(job->url_con); # endif _job_list = eina_list_remove(_job_list, job); fclose(job->file); @@ -311,3 +325,26 @@ ecore_file_download_abort(Ecore_File_Download_Job *job) free(job); #endif /* BUILD_ECORE_CON */ } + +/** + * @brief Abort all downloads. + * + * This function aborts all the downloads that have been started by + * ecore_file_download(). It loops over the started downloads and call + * ecore_file_download_abort() for each of them. To abort only one + * specific download operation, call ecore_file_download_abort(). + */ +EAPI void +ecore_file_download_abort_all(void) +{ +#ifdef BUILD_ECORE_CON + Ecore_File_Download_Job *job; + + EINA_LIST_FREE(_job_list, job) + ecore_file_download_abort(job); +#endif /* BUILD_ECORE_CON */ +} + +/** + * @} + */ diff --git a/src/lib/ecore_file/ecore_file_monitor.c b/src/lib/ecore_file/ecore_file_monitor.c index 0b74eb9..15028fa 100644 --- a/src/lib/ecore_file/ecore_file_monitor.c +++ b/src/lib/ecore_file/ecore_file_monitor.c @@ -47,96 +47,134 @@ ecore_file_monitor_shutdown(void) switch (monitor_type) { case ECORE_FILE_MONITOR_TYPE_NONE: - break; + break; #ifdef HAVE_INOTIFY case ECORE_FILE_MONITOR_TYPE_INOTIFY: - ecore_file_monitor_inotify_shutdown(); - break; + ecore_file_monitor_inotify_shutdown(); + break; #endif #ifdef HAVE_NOTIFY_WIN32 case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32: - ecore_file_monitor_win32_shutdown(); - break; + ecore_file_monitor_win32_shutdown(); + break; #endif #ifdef HAVE_POLL case ECORE_FILE_MONITOR_TYPE_POLL: - ecore_file_monitor_poll_shutdown(); - break; + ecore_file_monitor_poll_shutdown(); + break; #endif } } /** - * Monitor a path using inotify or polling - * @param path The path to monitor - * @param func The function to call on changes - * @param data The data passed to func - * @return An Ecore_File_Monitor pointer or NULL on failure + * @addtogroup Ecore_File_Group Ecore_File - Files and direcotries convenience functions + * + * @{ + */ + +/** + * @brief Monitor the given path using inotify, Windows notification, or polling. + * + * @param path The path to monitor. + * @param func The function to call on changes. + * @param data The data passed to func. + * @return An Ecore_File_Monitor pointer or NULL on failure. + * + * This function monitors @p path. If @p path is @c NULL, or is an + * empty string, or none of the notify methods (Inotify, Windows + * notification or polling) is available, or if @p path is not a file, + * the function returns @c NULL. Otherwise, it returns a newly + * allocated Ecore_File_Monitor object and the monitoring begins. When + * one of the #Ecore_File_Event event is notified, @p func is called + * and @p data is passed to @p func. Call ecore_file_monitor_del() to + * stop the monitoring. */ EAPI Ecore_File_Monitor * -ecore_file_monitor_add(const char *path, - void (*func) (void *data, - Ecore_File_Monitor *em, - Ecore_File_Event event, - const char *path), - void *data) +ecore_file_monitor_add(const char *path, + Ecore_File_Monitor_Cb func, + void *data) { + if (!path || !*path) + return NULL; + switch (monitor_type) { case ECORE_FILE_MONITOR_TYPE_NONE: - return NULL; + return NULL; #ifdef HAVE_INOTIFY case ECORE_FILE_MONITOR_TYPE_INOTIFY: - return ecore_file_monitor_inotify_add(path, func, data); + return ecore_file_monitor_inotify_add(path, func, data); #endif #ifdef HAVE_NOTIFY_WIN32 case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32: - return ecore_file_monitor_win32_add(path, func, data); + return ecore_file_monitor_win32_add(path, func, data); #endif #ifdef HAVE_POLL case ECORE_FILE_MONITOR_TYPE_POLL: - return ecore_file_monitor_poll_add(path, func, data); + return ecore_file_monitor_poll_add(path, func, data); #endif } return NULL; } /** - * Stop monitoring a path - * @param em The Ecore_File_Monitor to stop + * @brief Stop the monitoring of the given path. + * + * @param em The Ecore_File_Monitor to stop. + * + * This function stops the the monitoring of the path that has been + * monitored by ecore_file_monitor_add(). @p em must be the value + * returned by ecore_file_monitor_add(). If @p em is @c NULL, or none + * of the notify methods (Inotify, Windows notification or polling) is + * availablethis function does nothing. */ EAPI void ecore_file_monitor_del(Ecore_File_Monitor *em) { + if (!em) + return; + switch (monitor_type) { case ECORE_FILE_MONITOR_TYPE_NONE: - break; + break; #ifdef HAVE_INOTIFY case ECORE_FILE_MONITOR_TYPE_INOTIFY: - ecore_file_monitor_inotify_del(em); - break; + ecore_file_monitor_inotify_del(em); + break; #endif #ifdef HAVE_NOTIFY_WIN32 case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32: - ecore_file_monitor_win32_del(em); - break; + ecore_file_monitor_win32_del(em); + break; #endif #ifdef HAVE_POLL case ECORE_FILE_MONITOR_TYPE_POLL: - ecore_file_monitor_poll_del(em); - break; + ecore_file_monitor_poll_del(em); + break; #endif } } /** - * Get the monitored path - * @param em The Ecore_File_Monitor to query - * @return The path that is monitored by @p em + * @brief Get the monitored path. + * + * @param em The Ecore_File_Monitor to query. + * @return The path that is monitored by @p em. + * + * This function returns the monitored path that has been + * monitored by ecore_file_monitor_add(). @p em must be the value + * returned by ecore_file_monitor_add(). If @p em is @c NULL, the + * function returns @c NULL. */ EAPI const char * ecore_file_monitor_path_get(Ecore_File_Monitor *em) { + if (!em) + return NULL; return em->path; } + +/** + * @} + */ diff --git a/src/lib/ecore_file/ecore_file_monitor_inotify.c b/src/lib/ecore_file/ecore_file_monitor_inotify.c index 2fc002e..abad382 100644 --- a/src/lib/ecore_file/ecore_file_monitor_inotify.c +++ b/src/lib/ecore_file/ecore_file_monitor_inotify.c @@ -65,11 +65,11 @@ ecore_file_monitor_inotify_init(void) return 0; _fdh = ecore_main_fd_handler_add(fd, ECORE_FD_READ, _ecore_file_monitor_inotify_handler, - NULL, NULL, NULL); + NULL, NULL, NULL); if (!_fdh) { - close(fd); - return 0; + close(fd); + return 0; } return 1; @@ -81,23 +81,23 @@ ecore_file_monitor_inotify_shutdown(void) int fd; while(_monitors) - ecore_file_monitor_inotify_del(_monitors); + ecore_file_monitor_inotify_del(_monitors); if (_fdh) { - fd = ecore_main_fd_handler_fd_get(_fdh); - ecore_main_fd_handler_del(_fdh); - close(fd); + fd = ecore_main_fd_handler_fd_get(_fdh); + ecore_main_fd_handler_del(_fdh); + close(fd); } return 1; } Ecore_File_Monitor * ecore_file_monitor_inotify_add(const char *path, - void (*func) (void *data, Ecore_File_Monitor *em, - Ecore_File_Event event, - const char *path), - void *data) + void (*func) (void *data, Ecore_File_Monitor *em, + Ecore_File_Event event, + const char *path), + void *data) { Ecore_File_Monitor *em; int len; @@ -117,13 +117,13 @@ ecore_file_monitor_inotify_add(const char *path, if (ecore_file_exists(em->path)) { - if (!_ecore_file_monitor_inotify_monitor(em, em->path)) - return NULL; + if (!_ecore_file_monitor_inotify_monitor(em, em->path)) + return NULL; } else { - ecore_file_monitor_inotify_del(em); - return NULL; + ecore_file_monitor_inotify_del(em); + return NULL; } return em; @@ -156,14 +156,14 @@ _ecore_file_monitor_inotify_handler(void *data __UNUSED__, Ecore_Fd_Handler *fdh size = read(ecore_main_fd_handler_fd_get(fdh), buffer, sizeof(buffer)); while (i < size) { - event = (struct inotify_event *)&buffer[i]; - event_size = sizeof(struct inotify_event) + event->len; - i += event_size; + event = (struct inotify_event *)&buffer[i]; + event_size = sizeof(struct inotify_event) + event->len; + i += event_size; - em = _ecore_file_monitor_inotify_monitor_find(event->wd); - if (!em) continue; + em = _ecore_file_monitor_inotify_monitor_find(event->wd); + if (!em) continue; - _ecore_file_monitor_inotify_events(em, (event->len ? event->name : NULL), event->mask); + _ecore_file_monitor_inotify_events(em, (event->len ? event->name : NULL), event->mask); } return ECORE_CALLBACK_RENEW; @@ -176,8 +176,8 @@ _ecore_file_monitor_inotify_monitor_find(int wd) EINA_INLIST_FOREACH(_monitors, l) { - if (ECORE_FILE_MONITOR_INOTIFY(l)->wd == wd) - return l; + if (ECORE_FILE_MONITOR_INOTIFY(l)->wd == wd) + return l; } return NULL; } @@ -200,62 +200,62 @@ _ecore_file_monitor_inotify_events(Ecore_File_Monitor *em, char *file, int mask) if (mask & IN_MODIFY) { - if (!isdir) - em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, buf); + if (!isdir) + em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, buf); } if (mask & IN_MOVED_FROM) { - if (isdir) - em->func(em->data, em, ECORE_FILE_EVENT_DELETED_DIRECTORY, buf); - else - em->func(em->data, em, ECORE_FILE_EVENT_DELETED_FILE, buf); + if (isdir) + em->func(em->data, em, ECORE_FILE_EVENT_DELETED_DIRECTORY, buf); + else + em->func(em->data, em, ECORE_FILE_EVENT_DELETED_FILE, buf); } if (mask & IN_MOVED_TO) { - if (isdir) - em->func(em->data, em, ECORE_FILE_EVENT_CREATED_DIRECTORY, buf); - else - em->func(em->data, em, ECORE_FILE_EVENT_CREATED_FILE, buf); + if (isdir) + em->func(em->data, em, ECORE_FILE_EVENT_CREATED_DIRECTORY, buf); + else + em->func(em->data, em, ECORE_FILE_EVENT_CREATED_FILE, buf); } if (mask & IN_DELETE) { - if (isdir) - em->func(em->data, em, ECORE_FILE_EVENT_DELETED_DIRECTORY, buf); - else - em->func(em->data, em, ECORE_FILE_EVENT_DELETED_FILE, buf); + if (isdir) + em->func(em->data, em, ECORE_FILE_EVENT_DELETED_DIRECTORY, buf); + else + em->func(em->data, em, ECORE_FILE_EVENT_DELETED_FILE, buf); } if (mask & IN_CREATE) { - if (isdir) - em->func(em->data, em, ECORE_FILE_EVENT_CREATED_DIRECTORY, buf); - else - em->func(em->data, em, ECORE_FILE_EVENT_CREATED_FILE, buf); + if (isdir) + em->func(em->data, em, ECORE_FILE_EVENT_CREATED_DIRECTORY, buf); + else + em->func(em->data, em, ECORE_FILE_EVENT_CREATED_FILE, buf); } if (mask & IN_DELETE_SELF) { - em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path); + em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path); } if (mask & IN_MOVE_SELF) { - /* We just call delete. The dir is gone... */ - em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path); + /* We just call delete. The dir is gone... */ + em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path); } if (mask & IN_UNMOUNT) { - /* We just call delete. The dir is gone... */ - em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path); + /* We just call delete. The dir is gone... */ + em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path); } if (mask & IN_IGNORED) { - /* The watch is removed. If the file name still exists monitor the new one, - * else delete it */ - if (ecore_file_exists(em->path)) - { - if (!_ecore_file_monitor_inotify_monitor(em, em->path)) - em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path); - } - else - em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path); + /* The watch is removed. If the file name still exists monitor the new one, + * else delete it */ + if (ecore_file_exists(em->path)) + { + if (!_ecore_file_monitor_inotify_monitor(em, em->path)) + em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path); + } + else + em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path); } } @@ -264,17 +264,17 @@ _ecore_file_monitor_inotify_monitor(Ecore_File_Monitor *em, const char *path) { int mask; mask = IN_MODIFY| - IN_MOVED_FROM|IN_MOVED_TO| - IN_DELETE|IN_CREATE| - IN_DELETE_SELF|IN_MOVE_SELF| - IN_UNMOUNT; + IN_MOVED_FROM|IN_MOVED_TO| + IN_DELETE|IN_CREATE| + IN_DELETE_SELF|IN_MOVE_SELF| + IN_UNMOUNT; ECORE_FILE_MONITOR_INOTIFY(em)->wd = inotify_add_watch(ecore_main_fd_handler_fd_get(_fdh), - path, mask); + path, mask); if (ECORE_FILE_MONITOR_INOTIFY(em)->wd < 0) { - ERR("inotify_add_watch error"); - ecore_file_monitor_inotify_del(em); - return 0; + ERR("inotify_add_watch error"); + ecore_file_monitor_inotify_del(em); + return 0; } return 1; } @@ -312,35 +312,35 @@ _ecore_file_monitor_inotify_print(char *file, int mask) if (mask & IN_MODIFY) { - WRN("Inotify modified %s: %s", type, file); + WRN("Inotify modified %s: %s", type, file); } if (mask & IN_MOVED_FROM) { - WRN("Inotify moved from %s: %s", type, file); + WRN("Inotify moved from %s: %s", type, file); } if (mask & IN_MOVED_TO) { - WRN("Inotify moved to %s: %s", type, file); + WRN("Inotify moved to %s: %s", type, file); } if (mask & IN_DELETE) { - WRN("Inotify delete %s: %s", type, file); + WRN("Inotify delete %s: %s", type, file); } if (mask & IN_CREATE) { - WRN("Inotify create %s: %s", type, file); + WRN("Inotify create %s: %s", type, file); } if (mask & IN_DELETE_SELF) { - WRN("Inotify delete self %s: %s", type, file); + WRN("Inotify delete self %s: %s", type, file); } if (mask & IN_MOVE_SELF) { - WRN("Inotify move self %s: %s", type, file); + WRN("Inotify move self %s: %s", type, file); } if (mask & IN_UNMOUNT) { - WRN("Inotify unmount %s: %s", type, file); + WRN("Inotify unmount %s: %s", type, file); } } #endif diff --git a/src/lib/ecore_file/ecore_file_monitor_poll.c b/src/lib/ecore_file/ecore_file_monitor_poll.c index 52d028b..16410a0 100644 --- a/src/lib/ecore_file/ecore_file_monitor_poll.c +++ b/src/lib/ecore_file/ecore_file_monitor_poll.c @@ -51,22 +51,22 @@ int ecore_file_monitor_poll_shutdown(void) { while(_monitors) - ecore_file_monitor_poll_del(_monitors); + ecore_file_monitor_poll_del(_monitors); if (_timer) { - ecore_timer_del(_timer); - _timer = NULL; + ecore_timer_del(_timer); + _timer = NULL; } return 1; } Ecore_File_Monitor * ecore_file_monitor_poll_add(const char *path, - void (*func) (void *data, Ecore_File_Monitor *em, - Ecore_File_Event event, - const char *path), - void *data) + void (*func) (void *data, Ecore_File_Monitor *em, + Ecore_File_Event event, + const char *path), + void *data) { Ecore_File_Monitor *em; size_t len; @@ -95,37 +95,37 @@ ecore_file_monitor_poll_add(const char *path, if (ecore_file_exists(em->path)) { - if (ecore_file_is_dir(em->path)) - { - /* Check for subdirs */ - Eina_List *files; - char *file; - - files = ecore_file_ls(em->path); - EINA_LIST_FREE(files, file) - { - Ecore_File *f; - char buf[PATH_MAX]; - - f = calloc(1, sizeof(Ecore_File)); - if (!f) - { - free(file); - continue; - } - - snprintf(buf, sizeof(buf), "%s/%s", em->path, file); - f->name = file; - f->mtime = ecore_file_mod_time(buf); - f->is_dir = ecore_file_is_dir(buf); - em->files = (Ecore_File *) eina_inlist_append(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f)); - } - } + if (ecore_file_is_dir(em->path)) + { + /* Check for subdirs */ + Eina_List *files; + char *file; + + files = ecore_file_ls(em->path); + EINA_LIST_FREE(files, file) + { + Ecore_File *f; + char buf[PATH_MAX]; + + f = calloc(1, sizeof(Ecore_File)); + if (!f) + { + free(file); + continue; + } + + snprintf(buf, sizeof(buf), "%s/%s", em->path, file); + f->name = file; + f->mtime = ecore_file_mod_time(buf); + f->is_dir = ecore_file_is_dir(buf); + em->files = (Ecore_File *) eina_inlist_append(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f)); + } + } } else { - ecore_file_monitor_poll_del(em); - return NULL; + ecore_file_monitor_poll_del(em); + return NULL; } return em; @@ -138,22 +138,22 @@ ecore_file_monitor_poll_del(Ecore_File_Monitor *em) if (_lock) { - ECORE_FILE_MONITOR_POLL(em)->deleted = 1; - return; + ECORE_FILE_MONITOR_POLL(em)->deleted = 1; + return; } /* Remove files */ /*It's possible there weren't any files to monitor, so check if the list is init*/ if (em->files) { - for (l = em->files; l;) - { - Ecore_File *file = l; - - l = (Ecore_File *) EINA_INLIST_GET(l)->next; - free(file->name); - free(file); - } + for (l = em->files; l;) + { + Ecore_File *file = l; + + l = (Ecore_File *) EINA_INLIST_GET(l)->next; + free(file->name); + free(file); + } } if (_monitors) @@ -164,13 +164,13 @@ ecore_file_monitor_poll_del(Ecore_File_Monitor *em) if (_timer) { - if (!_monitors) - { - ecore_timer_del(_timer); - _timer = NULL; - } - else - ecore_timer_interval_set(_timer, ECORE_FILE_INTERVAL_MIN); + if (!_monitors) + { + ecore_timer_del(_timer); + _timer = NULL; + } + else + ecore_timer_interval_set(_timer, ECORE_FILE_INTERVAL_MIN); } } @@ -183,7 +183,7 @@ _ecore_file_monitor_poll_handler(void *data __UNUSED__) _lock = 1; EINA_INLIST_FOREACH(_monitors, l) - _ecore_file_monitor_poll_check(l); + _ecore_file_monitor_poll_check(l); _lock = 0; if (_interval > ECORE_FILE_INTERVAL_MAX) @@ -192,11 +192,11 @@ _ecore_file_monitor_poll_handler(void *data __UNUSED__) for (l = _monitors; l;) { - Ecore_File_Monitor *em = l; + Ecore_File_Monitor *em = l; - l = ECORE_FILE_MONITOR(EINA_INLIST_GET(l)->next); - if (ECORE_FILE_MONITOR_POLL(em)->deleted) - ecore_file_monitor_del(em); + l = ECORE_FILE_MONITOR(EINA_INLIST_GET(l)->next); + if (ECORE_FILE_MONITOR_POLL(em)->deleted) + ecore_file_monitor_del(em); } return ECORE_CALLBACK_RENEW; } @@ -209,117 +209,117 @@ _ecore_file_monitor_poll_check(Ecore_File_Monitor *em) mtime = ecore_file_mod_time(em->path); if (mtime < ECORE_FILE_MONITOR_POLL(em)->mtime) { - Ecore_File *l; - Ecore_File_Event event; - - /* Notify all files deleted */ - for (l = em->files; l;) - { - Ecore_File *f = l; - char buf[PATH_MAX]; - - l = (Ecore_File *) EINA_INLIST_GET(l)->next; - - snprintf(buf, sizeof(buf), "%s/%s", em->path, f->name); - if (f->is_dir) - event = ECORE_FILE_EVENT_DELETED_DIRECTORY; - else - event = ECORE_FILE_EVENT_DELETED_FILE; - em->func(em->data, em, event, buf); - free(f->name); - free(f); - } - em->files = NULL; - em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path); - _interval = ECORE_FILE_INTERVAL_MIN; + Ecore_File *l; + Ecore_File_Event event; + + /* Notify all files deleted */ + for (l = em->files; l;) + { + Ecore_File *f = l; + char buf[PATH_MAX]; + + l = (Ecore_File *) EINA_INLIST_GET(l)->next; + + snprintf(buf, sizeof(buf), "%s/%s", em->path, f->name); + if (f->is_dir) + event = ECORE_FILE_EVENT_DELETED_DIRECTORY; + else + event = ECORE_FILE_EVENT_DELETED_FILE; + em->func(em->data, em, event, buf); + free(f->name); + free(f); + } + em->files = NULL; + em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path); + _interval = ECORE_FILE_INTERVAL_MIN; } else { - Ecore_File *l; - - /* Check for changed files */ - for (l = em->files; l;) - { - Ecore_File *f = l; - char buf[PATH_MAX]; - int mtime; - Ecore_File_Event event; - - l = (Ecore_File *) EINA_INLIST_GET(l)->next; - - snprintf(buf, sizeof(buf), "%s/%s", em->path, f->name); - mtime = ecore_file_mod_time(buf); - if (mtime < f->mtime) - { - if (f->is_dir) - event = ECORE_FILE_EVENT_DELETED_DIRECTORY; - else - event = ECORE_FILE_EVENT_DELETED_FILE; - - em->func(em->data, em, event, buf); - em->files = (Ecore_File *) eina_inlist_remove(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f)); - free(f->name); - free(f); - _interval = ECORE_FILE_INTERVAL_MIN; - } - else if ((mtime > f->mtime) && !(f->is_dir)) - { - em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, buf); - _interval = ECORE_FILE_INTERVAL_MIN; - f->mtime = mtime; - } - else - f->mtime = mtime; - } - - /* Check for new files */ - if (ECORE_FILE_MONITOR_POLL(em)->mtime < mtime) - { - Eina_List *files; - Eina_List *l; - char *file; - - /* Files have been added or removed */ - files = ecore_file_ls(em->path); - if (files) - { - /* Are we a directory? We should check first, rather than rely on null here*/ - EINA_LIST_FOREACH(files, l, file) - { - Ecore_File *f; - char buf[PATH_MAX]; - Ecore_File_Event event; - - if (_ecore_file_monitor_poll_checking(em, file)) - continue; - - snprintf(buf, sizeof(buf), "%s/%s", em->path, file); - f = calloc(1, sizeof(Ecore_File)); - if (!f) - continue; - - f->name = strdup(file); - f->mtime = ecore_file_mod_time(buf); - f->is_dir = ecore_file_mod_time(buf); - if (f->is_dir) - event = ECORE_FILE_EVENT_CREATED_DIRECTORY; - else - event = ECORE_FILE_EVENT_CREATED_FILE; - em->func(em->data, em, event, buf); - em->files = (Ecore_File *) eina_inlist_append(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f)); - } - while (files) - { - file = eina_list_data_get(files); - free(file); - files = eina_list_remove_list(files, files); - } - } - - if (!ecore_file_is_dir(em->path)) - em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, em->path); - _interval = ECORE_FILE_INTERVAL_MIN; - } + Ecore_File *l; + + /* Check for changed files */ + for (l = em->files; l;) + { + Ecore_File *f = l; + char buf[PATH_MAX]; + int mtime; + Ecore_File_Event event; + + l = (Ecore_File *) EINA_INLIST_GET(l)->next; + + snprintf(buf, sizeof(buf), "%s/%s", em->path, f->name); + mtime = ecore_file_mod_time(buf); + if (mtime < f->mtime) + { + if (f->is_dir) + event = ECORE_FILE_EVENT_DELETED_DIRECTORY; + else + event = ECORE_FILE_EVENT_DELETED_FILE; + + em->func(em->data, em, event, buf); + em->files = (Ecore_File *) eina_inlist_remove(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f)); + free(f->name); + free(f); + _interval = ECORE_FILE_INTERVAL_MIN; + } + else if ((mtime > f->mtime) && !(f->is_dir)) + { + em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, buf); + _interval = ECORE_FILE_INTERVAL_MIN; + f->mtime = mtime; + } + else + f->mtime = mtime; + } + + /* Check for new files */ + if (ECORE_FILE_MONITOR_POLL(em)->mtime < mtime) + { + Eina_List *files; + Eina_List *l; + char *file; + + /* Files have been added or removed */ + files = ecore_file_ls(em->path); + if (files) + { + /* Are we a directory? We should check first, rather than rely on null here*/ + EINA_LIST_FOREACH(files, l, file) + { + Ecore_File *f; + char buf[PATH_MAX]; + Ecore_File_Event event; + + if (_ecore_file_monitor_poll_checking(em, file)) + continue; + + snprintf(buf, sizeof(buf), "%s/%s", em->path, file); + f = calloc(1, sizeof(Ecore_File)); + if (!f) + continue; + + f->name = strdup(file); + f->mtime = ecore_file_mod_time(buf); + f->is_dir = ecore_file_mod_time(buf); + if (f->is_dir) + event = ECORE_FILE_EVENT_CREATED_DIRECTORY; + else + event = ECORE_FILE_EVENT_CREATED_FILE; + em->func(em->data, em, event, buf); + em->files = (Ecore_File *) eina_inlist_append(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f)); + } + while (files) + { + file = eina_list_data_get(files); + free(file); + files = eina_list_remove_list(files, files); + } + } + + if (!ecore_file_is_dir(em->path)) + em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, em->path); + _interval = ECORE_FILE_INTERVAL_MIN; + } } ECORE_FILE_MONITOR_POLL(em)->mtime = mtime; } @@ -331,8 +331,8 @@ _ecore_file_monitor_poll_checking(Ecore_File_Monitor *em, char *name) EINA_INLIST_FOREACH(em->files, l) { - if (!strcmp(l->name, name)) - return 1; + if (!strcmp(l->name, name)) + return 1; } return 0; } diff --git a/src/lib/ecore_file/ecore_file_path.c b/src/lib/ecore_file/ecore_file_path.c index ed2882c..e029d50 100644 --- a/src/lib/ecore_file/ecore_file_path.c +++ b/src/lib/ecore_file/ecore_file_path.c @@ -45,8 +45,8 @@ _ecore_file_path_from_env(const char *env) if (!*p) { - if (!ecore_file_path_dir_exists(last)) - path = eina_list_append(path, strdup(last)); + if (!ecore_file_path_dir_exists(last)) + path = eina_list_append(path, strdup(last)); last = p + 1; } } @@ -58,56 +58,83 @@ _ecore_file_path_from_env(const char *env) } /** - * Check if the given directory is in PATH - * @param The name of the directory to search in PATH - * @return 1 if the directory exist in PATH, 0 otherwise + * @addtogroup Ecore_File_Group Ecore_File - Files and direcotries convenience functions + * + * @{ */ -EAPI int + +/** + * @brief Check if the given directory is in PATH. + * + * @param The name of the directory to search in PATH. + * @return EINA_TRUE if the directory exist in PATH, EINA_FALSE otherwise. + * + * This function checks if @p in_dir is in the environment variable + * PATH. If @p in_dir is @c NULL, or if PATH is empty, or @p in_dir is + * not in PATH, the function returns EINA_FALSE, otherwise it returns + * EINA_TRUE. + */ +EAPI Eina_Bool ecore_file_path_dir_exists(const char *in_dir) { Eina_List *l; char *dir; - if (!__ecore_file_path_bin) return 0; + if (!in_dir) + return EINA_FALSE; + + if (!__ecore_file_path_bin) return EINA_FALSE; EINA_LIST_FOREACH(__ecore_file_path_bin, l, dir) { - if (strcmp(dir, in_dir)) - return 1; + if (strcmp(dir, in_dir)) + return EINA_TRUE; } - return 0; + return EINA_FALSE; } /** - * Check if the given application is installed + * @brief Check if the given application is installed. + * * @param exe The name of the application - * @return 1 if the exe is in PATH and is executable + * @return EINA_TRUE if the exe is in PATH and is executable, + * EINA_FALSE otherwise. + * * - * This function check if the given name exist in PATH and is executable + * This function checks if @p exe exists in PATH and is executable. If + * @p exe is @c NULL or is not executable, the function returns + * EINA_FALSE, otherwise it returns EINA_TRUE. */ -EAPI int +EAPI Eina_Bool ecore_file_app_installed(const char *exe) { Eina_List *l; char *dir; char buf[PATH_MAX]; - if (!exe) return 0; - if (ecore_file_can_exec(exe)) return 1; + if (!exe) return EINA_FALSE; + if (ecore_file_can_exec(exe)) return EINA_TRUE; EINA_LIST_FOREACH(__ecore_file_path_bin, l, dir) { - snprintf(buf, sizeof(buf), "%s/%s", dir, exe); - if (ecore_file_can_exec(buf)) - return 1; + snprintf(buf, sizeof(buf), "%s/%s", dir, exe); + if (ecore_file_can_exec(buf)) + return EINA_TRUE; } - return 0; + return EINA_FALSE; } /** - * Get a list of all the applications installed on the system - * @return An Eina_List containing all the executable files in the system + * @brief Get a list of all the applications installed on the system. + * + * @return An Eina_List containing all the executable files in the + * system. + * + * This function returns a list of allocated strings of all the + * executable files. If no files are found, the function returns + * @c NULL. When not needed anymore, the element of the list must be + * freed. */ EAPI Eina_List * ecore_file_app_list(void) @@ -119,16 +146,20 @@ ecore_file_app_list(void) EINA_LIST_FOREACH(__ecore_file_path_bin, l, dir) { - files = ecore_file_ls(dir); - EINA_LIST_FREE(files, exe) - { - snprintf(buf, sizeof(buf), "%s/%s", dir, exe); - if ((ecore_file_can_exec(buf)) && - (!ecore_file_is_dir(buf))) - list = eina_list_append(list, strdup(buf)); - free(exe); - } + files = ecore_file_ls(dir); + EINA_LIST_FREE(files, exe) + { + snprintf(buf, sizeof(buf), "%s/%s", dir, exe); + if ((ecore_file_can_exec(buf)) && + (!ecore_file_is_dir(buf))) + list = eina_list_append(list, strdup(buf)); + free(exe); + } } return list; } + +/** + * @} + */ diff --git a/src/lib/ecore_file/ecore_file_private.h b/src/lib/ecore_file/ecore_file_private.h index 11606df..9d798e4 100644 --- a/src/lib/ecore_file/ecore_file_private.h +++ b/src/lib/ecore_file/ecore_file_private.h @@ -73,9 +73,9 @@ struct _Ecore_File_Monitor { EINA_INLIST; void (*func) (void *data, - Ecore_File_Monitor *ecore_file_monitor, - Ecore_File_Event event, - const char *path); + Ecore_File_Monitor *ecore_file_monitor, + Ecore_File_Event event, + const char *path); char *path; void *data; @@ -86,11 +86,11 @@ struct _Ecore_File_Monitor int ecore_file_monitor_inotify_init(void); int ecore_file_monitor_inotify_shutdown(void); Ecore_File_Monitor *ecore_file_monitor_inotify_add(const char *path, - void (*func) (void *data, - Ecore_File_Monitor *ecore_file_monitor, - Ecore_File_Event event, - const char *path), - void *data); + void (*func) (void *data, + Ecore_File_Monitor *ecore_file_monitor, + Ecore_File_Event event, + const char *path), + void *data); void ecore_file_monitor_inotify_del(Ecore_File_Monitor *ecore_file_monitor); #endif @@ -110,11 +110,11 @@ void ecore_file_monitor_win32_del(Ecore_File_Monitor *ecore_file_ int ecore_file_monitor_poll_init(void); int ecore_file_monitor_poll_shutdown(void); Ecore_File_Monitor *ecore_file_monitor_poll_add(const char *path, - void (*func) (void *data, - Ecore_File_Monitor *ecore_file_monitor, - Ecore_File_Event event, - const char *path), - void *data); + void (*func) (void *data, + Ecore_File_Monitor *ecore_file_monitor, + Ecore_File_Event event, + const char *path), + void *data); void ecore_file_monitor_poll_del(Ecore_File_Monitor *ecore_file_monitor); #endif diff --git a/src/lib/ecore_imf/Ecore_IMF.h b/src/lib/ecore_imf/Ecore_IMF.h index fb03046..b8f6f14 100644 --- a/src/lib/ecore_imf/Ecore_IMF.h +++ b/src/lib/ecore_imf/Ecore_IMF.h @@ -54,6 +54,31 @@ extern "C" { #endif + // will be deleted soon + /* ecore_imf_context_ise_state_add_listener() flag */ + typedef enum + { + ISE_STATE_EVENT, /**< ISE STATE Event */ + ISE_MODE_EVENT, /**< ISE MODE Event */ + ISE_LANGUAGE_EVENT, /**< ISE LANGUAGE Event */ + ISE_SHIFT_MODE_EVENT, /**< ISE SHIFT MODE */ + ISE_PREEDIT_MODE_EVENT, /**< ISE PREEDIT MODE */ + ISE_COMPLETION_MODE_EVENT, /**< ISE COMPLETION MODE */ + ISE_CUSTOM_INPUT_MODE_EVENT, /**< ISE CUSTOM INPUT MODE */ + + ISE_PRIVATE_CONTEXT_01, /**< ISE PRIVATE CONTEXT */ + ISE_PRIVATE_CONTEXT_02, /**< ISE PRIVATE CONTEXT */ + ISE_PRIVATE_CONTEXT_03, /**< ISE PRIVATE CONTEXT */ + ISE_PRIVATE_CONTEXT_04, /**< ISE PRIVATE CONTEXT */ + ISE_PRIVATE_CONTEXT_05, /**< ISE PRIVATE CONTEXT */ + ISE_PRIVATE_CONTEXT_06, /**< ISE PRIVATE CONTEXT */ + ISE_PRIVATE_CONTEXT_07, /**< ISE PRIVATE CONTEXT */ + ISE_PRIVATE_CONTEXT_08, /**< ISE PRIVATE CONTEXT */ + ISE_PRIVATE_CONTEXT_09, /**< ISE PRIVATE CONTEXT */ + ISE_PRIVATE_CONTEXT_10, /**< ISE PRIVATE CONTEXT */ + ISE_EVENT_INVALID + } ISE_EVENT; + /* ecore_imf_context_input_panel_event_callback_add() flag */ typedef enum { @@ -78,15 +103,31 @@ extern "C" { ECORE_IMF_INPUT_PANEL_EVENT_INVALID } Ecore_IMF_Input_Panel_Event; + // will be deleted soon. Use Ecore_IMF_Input_Panel_State instead. + typedef enum + { + ISE_STATE_SHOW, /**< Show ISE */ + ISE_STATE_SHOW_ALWAYS, /**< Show ISE always*/ + ISE_STATE_HIDE, /**< Hide ISE */ + ISE_STATE_INVALID + } ISE_STATE; + typedef enum { ECORE_IMF_INPUT_PANEL_STATE_SHOW, /**< Show Input panel */ ECORE_IMF_INPUT_PANEL_STATE_HIDE, /**< Hide Input panel */ - ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW, /**< Input panel will be shown */ - ECORE_IMF_INPUT_PANEL_STATE_WILL_HIDE, /**< Input panel will be hidden */ ECORE_IMF_INPUT_PANEL_STATE_INVALID } Ecore_IMF_Input_Panel_State; + // will be deleted soon, Use Ecore_IMF_Input_Mode instead. + typedef enum + { + ISE_MODE_NATIVE, /**< Follow current locale mode */ + ISE_MODE_ENGLISH, /**< English mode*/ + ISE_MODE_NUMBER, /**< Number mode*/ + ISE_MODE_INVALID + } ISE_MODE; + typedef enum { ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL, /**< Default 4x4 layout */ @@ -130,6 +171,12 @@ extern "C" { ECORE_IMF_AUTOCORRECTION_INVALID } Ecore_IMF_Autocorrection; + // will be deleted soon + typedef struct + { + bool fUseImEffect; /**< whether use Im effect or not */ + } ISE_STYLE; + typedef enum { ECORE_IMF_INPUT_PANEL_CAPS_MODE_OFF, /**< Off */ @@ -1227,4 +1274,4 @@ extern "C" { #endif -/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/ +/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/ \ No newline at end of file diff --git a/src/lib/ecore_imf/ecore_imf.c b/src/lib/ecore_imf/ecore_imf.c index a6314c1..060b8f2 100644 --- a/src/lib/ecore_imf/ecore_imf.c +++ b/src/lib/ecore_imf/ecore_imf.c @@ -70,5 +70,3 @@ ecore_imf_shutdown(void) ecore_shutdown(); return _ecore_imf_init_count; } - -/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/ \ No newline at end of file diff --git a/src/lib/ecore_imf/ecore_imf_context.c b/src/lib/ecore_imf/ecore_imf_context.c index b89c8f4..abac079 100644 --- a/src/lib/ecore_imf/ecore_imf_context.c +++ b/src/lib/ecore_imf/ecore_imf_context.c @@ -90,7 +90,6 @@ ecore_imf_context_default_id_by_canvas_type_get(const char *canvas_type) int best_goodness = 0; id = getenv("ECORE_IMF_MODULE"); - //printf ("id is %s \n", id); if (id) { if (strcmp(id, "none") == 0) return NULL; diff --git a/src/lib/ecore_imf_evas/Ecore_IMF_Evas.h b/src/lib/ecore_imf_evas/Ecore_IMF_Evas.h index 53753b6..5f7cdb9 100644 --- a/src/lib/ecore_imf_evas/Ecore_IMF_Evas.h +++ b/src/lib/ecore_imf_evas/Ecore_IMF_Evas.h @@ -9,7 +9,7 @@ #endif #ifdef _WIN32 -# ifdef EFL_ECORE_IMF_BUILD +# ifdef EFL_ECORE_IMF_EVAS_BUILD # ifdef DLL_EXPORT # define EAPI __declspec(dllexport) # else @@ -17,7 +17,7 @@ # endif /* ! DLL_EXPORT */ # else # define EAPI __declspec(dllimport) -# endif /* ! EFL_ECORE_EVAS_BUILD */ +# endif /* ! EFL_ECORE_IMF_BUILD */ #else # ifdef __GNUC__ # if __GNUC__ >= 4 @@ -34,14 +34,14 @@ extern "C" { #endif - EAPI void ecore_imf_evas_event_mouse_in_wrap(Evas_Event_Mouse_In *evas_event, Ecore_IMF_Event_Mouse_In *imf_event); - EAPI void ecore_imf_evas_event_mouse_out_wrap(Evas_Event_Mouse_Out *evas_event, Ecore_IMF_Event_Mouse_Out *imf_event); - EAPI void ecore_imf_evas_event_mouse_move_wrap(Evas_Event_Mouse_Move *evas_event, Ecore_IMF_Event_Mouse_Move *imf_event); - EAPI void ecore_imf_evas_event_mouse_down_wrap(Evas_Event_Mouse_Down *evas_event, Ecore_IMF_Event_Mouse_Down *imf_event); - EAPI void ecore_imf_evas_event_mouse_up_wrap(Evas_Event_Mouse_Up *evas_event, Ecore_IMF_Event_Mouse_Up *imf_event); - EAPI void ecore_imf_evas_event_mouse_wheel_wrap(Evas_Event_Mouse_Wheel *evas_event, Ecore_IMF_Event_Mouse_Wheel *imf_event); - EAPI void ecore_imf_evas_event_key_down_wrap(Evas_Event_Key_Down *evas_event, Ecore_IMF_Event_Key_Down *imf_event); - EAPI void ecore_imf_evas_event_key_up_wrap(Evas_Event_Key_Up *evas_event, Ecore_IMF_Event_Key_Up *imf_event); +EAPI void ecore_imf_evas_event_mouse_in_wrap(Evas_Event_Mouse_In *evas_event, Ecore_IMF_Event_Mouse_In *imf_event); +EAPI void ecore_imf_evas_event_mouse_out_wrap(Evas_Event_Mouse_Out *evas_event, Ecore_IMF_Event_Mouse_Out *imf_event); +EAPI void ecore_imf_evas_event_mouse_move_wrap(Evas_Event_Mouse_Move *evas_event, Ecore_IMF_Event_Mouse_Move *imf_event); +EAPI void ecore_imf_evas_event_mouse_down_wrap(Evas_Event_Mouse_Down *evas_event, Ecore_IMF_Event_Mouse_Down *imf_event); +EAPI void ecore_imf_evas_event_mouse_up_wrap(Evas_Event_Mouse_Up *evas_event, Ecore_IMF_Event_Mouse_Up *imf_event); +EAPI void ecore_imf_evas_event_mouse_wheel_wrap(Evas_Event_Mouse_Wheel *evas_event, Ecore_IMF_Event_Mouse_Wheel *imf_event); +EAPI void ecore_imf_evas_event_key_down_wrap(Evas_Event_Key_Down *evas_event, Ecore_IMF_Event_Key_Down *imf_event); +EAPI void ecore_imf_evas_event_key_up_wrap(Evas_Event_Key_Up *evas_event, Ecore_IMF_Event_Key_Up *imf_event); #ifdef __cplusplus } diff --git a/src/lib/ecore_imf_evas/Makefile.am b/src/lib/ecore_imf_evas/Makefile.am index ab21665..37d9a8f 100644 --- a/src/lib/ecore_imf_evas/Makefile.am +++ b/src/lib/ecore_imf_evas/Makefile.am @@ -4,7 +4,7 @@ if BUILD_ECORE_IMF_EVAS AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib/ecore \ -I$(top_srcdir)/src/lib/ecore_imf \ -@EFL_ECORE_IMF_BUILD@ \ +@EFL_ECORE_IMF_EVAS_BUILD@ \ @EVAS_CFLAGS@ \ @EINA_CFLAGS@ diff --git a/src/lib/ecore_imf_evas/ecore_imf_evas.c b/src/lib/ecore_imf_evas/ecore_imf_evas.c index de0f1ef..86badf5 100644 --- a/src/lib/ecore_imf_evas/ecore_imf_evas.c +++ b/src/lib/ecore_imf_evas/ecore_imf_evas.c @@ -15,7 +15,7 @@ static const char *_ecore_imf_evas_event_empty = ""; /* Converts the Evas modifiers to Ecore_IMF keyboard modifiers */ static void _ecore_imf_evas_event_modifiers_wrap(Evas_Modifier *evas_modifiers, - Ecore_IMF_Keyboard_Modifiers *imf_keyboard_modifiers) + Ecore_IMF_Keyboard_Modifiers *imf_keyboard_modifiers) { if (!evas_modifiers || !imf_keyboard_modifiers) return; @@ -34,7 +34,7 @@ _ecore_imf_evas_event_modifiers_wrap(Evas_Modifier *evas_modifiers, /* Converts the Evas locks to Ecore_IMF keyboard locks */ static void _ecore_imf_evas_event_locks_wrap(Evas_Lock *evas_locks, - Ecore_IMF_Keyboard_Locks *imf_keyboard_locks) + Ecore_IMF_Keyboard_Locks *imf_keyboard_locks) { if (!evas_locks || !imf_keyboard_locks) return; @@ -51,7 +51,7 @@ _ecore_imf_evas_event_locks_wrap(Evas_Lock *evas_locks, /* Converts the Evas mouse flags to Ecore_IMF mouse flags */ static void _ecore_imf_evas_event_mouse_flags_wrap(Evas_Button_Flags evas_flags, - Ecore_IMF_Mouse_Flags *imf_flags) + Ecore_IMF_Mouse_Flags *imf_flags) { if (!imf_flags) return; @@ -72,7 +72,7 @@ _ecore_imf_evas_event_mouse_flags_wrap(Evas_Button_Flags evas_flags, */ EAPI void ecore_imf_evas_event_mouse_in_wrap(Evas_Event_Mouse_In *evas_event, - Ecore_IMF_Event_Mouse_In *imf_event) + Ecore_IMF_Event_Mouse_In *imf_event) { if (!evas_event || !imf_event) return; @@ -96,7 +96,7 @@ ecore_imf_evas_event_mouse_in_wrap(Evas_Event_Mouse_In *evas_event, */ EAPI void ecore_imf_evas_event_mouse_out_wrap(Evas_Event_Mouse_Out *evas_event, - Ecore_IMF_Event_Mouse_Out *imf_event) + Ecore_IMF_Event_Mouse_Out *imf_event) { if (!evas_event || !imf_event) return; @@ -120,7 +120,7 @@ ecore_imf_evas_event_mouse_out_wrap(Evas_Event_Mouse_Out *evas_event, */ EAPI void ecore_imf_evas_event_mouse_move_wrap(Evas_Event_Mouse_Move *evas_event, - Ecore_IMF_Event_Mouse_Move *imf_event) + Ecore_IMF_Event_Mouse_Move *imf_event) { if (!evas_event || !imf_event) return; @@ -148,7 +148,7 @@ ecore_imf_evas_event_mouse_move_wrap(Evas_Event_Mouse_Move *evas_event, */ EAPI void ecore_imf_evas_event_mouse_down_wrap(Evas_Event_Mouse_Down *evas_event, - Ecore_IMF_Event_Mouse_Down *imf_event) + Ecore_IMF_Event_Mouse_Down *imf_event) { if (!evas_event || !imf_event) return; @@ -173,7 +173,7 @@ ecore_imf_evas_event_mouse_down_wrap(Evas_Event_Mouse_Down *evas_event, */ EAPI void ecore_imf_evas_event_mouse_up_wrap(Evas_Event_Mouse_Up *evas_event, - Ecore_IMF_Event_Mouse_Up *imf_event) + Ecore_IMF_Event_Mouse_Up *imf_event) { if (!evas_event || !imf_event) return; @@ -198,7 +198,7 @@ ecore_imf_evas_event_mouse_up_wrap(Evas_Event_Mouse_Up *evas_event, */ EAPI void ecore_imf_evas_event_mouse_wheel_wrap(Evas_Event_Mouse_Wheel *evas_event, - Ecore_IMF_Event_Mouse_Wheel *imf_event) + Ecore_IMF_Event_Mouse_Wheel *imf_event) { if (!evas_event || !imf_event) return; @@ -224,7 +224,7 @@ ecore_imf_evas_event_mouse_wheel_wrap(Evas_Event_Mouse_Wheel *evas_event, */ EAPI void ecore_imf_evas_event_key_down_wrap(Evas_Event_Key_Down *evas_event, - Ecore_IMF_Event_Key_Down *imf_event) + Ecore_IMF_Event_Key_Down *imf_event) { if (!evas_event || !imf_event) return; @@ -247,7 +247,7 @@ ecore_imf_evas_event_key_down_wrap(Evas_Event_Key_Down *evas_event, */ EAPI void ecore_imf_evas_event_key_up_wrap(Evas_Event_Key_Up *evas_event, - Ecore_IMF_Event_Key_Up *imf_event) + Ecore_IMF_Event_Key_Up *imf_event) { imf_event->keyname = evas_event->keyname ? evas_event->keyname : _ecore_imf_evas_event_empty; imf_event->key = evas_event->key ? evas_event->key : _ecore_imf_evas_event_empty; diff --git a/src/lib/ecore_input/Ecore_Input.h b/src/lib/ecore_input/Ecore_Input.h index 3b844ea..52af19d 100644 --- a/src/lib/ecore_input/Ecore_Input.h +++ b/src/lib/ecore_input/Ecore_Input.h @@ -32,191 +32,180 @@ extern "C" { #endif -EAPI extern int ECORE_EVENT_KEY_DOWN; -EAPI extern int ECORE_EVENT_KEY_UP; -EAPI extern int ECORE_EVENT_MOUSE_BUTTON_DOWN; -EAPI extern int ECORE_EVENT_MOUSE_BUTTON_UP; -EAPI extern int ECORE_EVENT_MOUSE_MOVE; -EAPI extern int ECORE_EVENT_MOUSE_WHEEL; -EAPI extern int ECORE_EVENT_MOUSE_IN; -EAPI extern int ECORE_EVENT_MOUSE_OUT; - -#define ECORE_EVENT_MODIFIER_SHIFT 0x0001 -#define ECORE_EVENT_MODIFIER_CTRL 0x0002 -#define ECORE_EVENT_MODIFIER_ALT 0x0004 -#define ECORE_EVENT_MODIFIER_WIN 0x0008 -#define ECORE_EVENT_MODIFIER_SCROLL 0x0010 -#define ECORE_EVENT_MODIFIER_NUM 0x0020 -#define ECORE_EVENT_MODIFIER_CAPS 0x0040 -#define ECORE_EVENT_LOCK_SCROLL 0x0080 -#define ECORE_EVENT_LOCK_NUM 0x0100 -#define ECORE_EVENT_LOCK_CAPS 0x0200 - -typedef uintptr_t Ecore_Window; - -typedef struct _Ecore_Event_Key Ecore_Event_Key; -struct _Ecore_Event_Key -{ - const char *keyname; - const char *key; - const char *string; - const char *compose; - Ecore_Window window; - Ecore_Window root_window; - Ecore_Window event_window; - - unsigned int timestamp; - unsigned int modifiers; - - int same_screen; -}; - -typedef struct _Ecore_Event_Mouse_Button Ecore_Event_Mouse_Button; -struct _Ecore_Event_Mouse_Button -{ - Ecore_Window window; - Ecore_Window root_window; - Ecore_Window event_window; - - unsigned int timestamp; - unsigned int modifiers; - unsigned int buttons; - unsigned int double_click; - unsigned int triple_click; - int same_screen; - - int x; - int y; - struct - { - int x; - int y; - } root; + EAPI extern int ECORE_EVENT_KEY_DOWN; + EAPI extern int ECORE_EVENT_KEY_UP; + EAPI extern int ECORE_EVENT_MOUSE_BUTTON_DOWN; + EAPI extern int ECORE_EVENT_MOUSE_BUTTON_UP; + EAPI extern int ECORE_EVENT_MOUSE_MOVE; + EAPI extern int ECORE_EVENT_MOUSE_WHEEL; + EAPI extern int ECORE_EVENT_MOUSE_IN; + EAPI extern int ECORE_EVENT_MOUSE_OUT; + +#define ECORE_EVENT_MODIFIER_SHIFT 0x0001 +#define ECORE_EVENT_MODIFIER_CTRL 0x0002 +#define ECORE_EVENT_MODIFIER_ALT 0x0004 +#define ECORE_EVENT_MODIFIER_WIN 0x0008 +#define ECORE_EVENT_MODIFIER_SCROLL 0x0010 +#define ECORE_EVENT_MODIFIER_NUM 0x0020 +#define ECORE_EVENT_MODIFIER_CAPS 0x0040 +#define ECORE_EVENT_LOCK_SCROLL 0x0080 +#define ECORE_EVENT_LOCK_NUM 0x0100 +#define ECORE_EVENT_LOCK_CAPS 0x0200 + + typedef uintptr_t Ecore_Window; + typedef struct _Ecore_Event_Key Ecore_Event_Key; + typedef struct _Ecore_Event_Mouse_Button Ecore_Event_Mouse_Button; + typedef struct _Ecore_Event_Mouse_Wheel Ecore_Event_Mouse_Wheel; + typedef struct _Ecore_Event_Mouse_Move Ecore_Event_Mouse_Move; + typedef struct _Ecore_Event_Mouse_IO Ecore_Event_Mouse_IO; + typedef struct _Ecore_Event_Modifiers Ecore_Event_Modifiers; - struct + typedef enum _Ecore_Event_Modifier { - int device; /* 0 if normal mouse, 1+ for other mouse-devices (eg multi-touch - other fingers) */ - double radius, radius_x, radius_y; /* radius of press point - radius_x and y if its an ellipse (radius is the average of the 2) */ - double pressure; /* pressure - 1.0 == normal, > 1.0 == more, 0.0 == none */ - double angle; /* angle relative to perpendicular (0.0 == perpendicular), in degrees */ - double x, y; /* same as x, y root.x, root.y, but with sub-pixel precision, if available */ - struct - { - double x, y; - } root; - } multi; -}; - -typedef struct _Ecore_Event_Mouse_Wheel Ecore_Event_Mouse_Wheel; -struct _Ecore_Event_Mouse_Wheel -{ - Ecore_Window window; - Ecore_Window root_window; - Ecore_Window event_window; - - unsigned int timestamp; - unsigned int modifiers; - - int same_screen; - int direction; - int z; - - int x; - int y; - struct - { - int x; - int y; - } root; -}; - -typedef struct _Ecore_Event_Mouse_Move Ecore_Event_Mouse_Move; -struct _Ecore_Event_Mouse_Move -{ - Ecore_Window window; - Ecore_Window root_window; - Ecore_Window event_window; - - unsigned int timestamp; - unsigned int modifiers; - - int same_screen; - - int x; - int y; - struct - { - int x; - int y; - } root; - - struct + ECORE_NONE, + ECORE_SHIFT, + ECORE_CTRL, + ECORE_ALT, + ECORE_WIN, + ECORE_SCROLL, + ECORE_CAPS, + ECORE_LAST + } Ecore_Event_Modifier; + + typedef enum _Ecore_Event_Press { - int device; /* 0 if normal mouse, 1+ for other mouse-devices (eg multi-touch - other fingers) */ - double radius, radius_x, radius_y; /* radius of press point - radius_x and y if its an ellipse (radius is the average of the 2) */ - double pressure; /* pressure - 1.0 == normal, > 1.0 == more, 0.0 == none */ - double angle; /* angle relative to perpendicular (0.0 == perpendicular), in degrees */ - double x, y; /* same as x, y root.x, root.y, but with sub-pixel precision, if available */ - struct - { - double x, y; - } root; - } multi; -}; - -typedef struct _Ecore_Event_Mouse_IO Ecore_Event_Mouse_IO; -struct _Ecore_Event_Mouse_IO -{ - Ecore_Window window; - Ecore_Window event_window; - - unsigned int timestamp; - unsigned int modifiers; + ECORE_DOWN, + ECORE_UP + } Ecore_Event_Press; - int x; - int y; -}; - -enum _Ecore_Event_Modifier -{ - ECORE_NONE, - ECORE_SHIFT, - ECORE_CTRL, - ECORE_ALT, - ECORE_WIN, - ECORE_SCROLL, - ECORE_CAPS, - ECORE_LAST -}; - -enum _Ecore_Event_Press -{ - ECORE_DOWN, - ECORE_UP -}; - -enum _Ecore_Event_IO -{ - ECORE_IN, - ECORE_OUT -}; - -typedef enum _Ecore_Event_IO Ecore_Event_IO; -typedef enum _Ecore_Event_Press Ecore_Event_Press; -typedef enum _Ecore_Event_Modifier Ecore_Event_Modifier; - -typedef struct _Ecore_Event_Modifiers Ecore_Event_Modifiers; -struct _Ecore_Event_Modifiers -{ - unsigned int size; - unsigned int array[ECORE_LAST]; -}; - -EAPI int ecore_event_init(void); -EAPI int ecore_event_shutdown(void); + typedef enum _Ecore_Event_IO + { + ECORE_IN, + ECORE_OUT + } Ecore_Event_IO; -EAPI unsigned int ecore_event_modifier_mask(Ecore_Event_Modifier modifier); -EAPI Ecore_Event_Modifier ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc); + struct _Ecore_Event_Key + { + const char *keyname; + const char *key; + const char *string; + const char *compose; + Ecore_Window window; + Ecore_Window root_window; + Ecore_Window event_window; + + unsigned int timestamp; + unsigned int modifiers; + + int same_screen; + }; + + struct _Ecore_Event_Mouse_Button + { + Ecore_Window window; + Ecore_Window root_window; + Ecore_Window event_window; + + unsigned int timestamp; + unsigned int modifiers; + unsigned int buttons; + unsigned int double_click; + unsigned int triple_click; + int same_screen; + + int x; + int y; + struct { + int x; + int y; + } root; + + struct { + int device; /* 0 if normal mouse, 1+ for other mouse-devices (eg multi-touch - other fingers) */ + double radius, radius_x, radius_y; /* radius of press point - radius_x and y if its an ellipse (radius is the average of the 2) */ + double pressure; /* pressure - 1.0 == normal, > 1.0 == more, 0.0 == none */ + double angle; /* angle relative to perpendicular (0.0 == perpendicular), in degrees */ + double x, y; /* same as x, y root.x, root.y, but with sub-pixel precision, if available */ + struct { + double x, y; + } root; + } multi; + }; + + struct _Ecore_Event_Mouse_Wheel + { + Ecore_Window window; + Ecore_Window root_window; + Ecore_Window event_window; + + unsigned int timestamp; + unsigned int modifiers; + + int same_screen; + int direction; + int z; + + int x; + int y; + struct { + int x; + int y; + } root; + }; + + struct _Ecore_Event_Mouse_Move + { + Ecore_Window window; + Ecore_Window root_window; + Ecore_Window event_window; + + unsigned int timestamp; + unsigned int modifiers; + + int same_screen; + + int x; + int y; + struct { + int x; + int y; + } root; + + struct { + int device; /* 0 if normal mouse, 1+ for other mouse-devices (eg multi-touch - other fingers) */ + double radius, radius_x, radius_y; /* radius of press point - radius_x and y if its an ellipse (radius is the average of the 2) */ + double pressure; /* pressure - 1.0 == normal, > 1.0 == more, 0.0 == none */ + double angle; /* angle relative to perpendicular (0.0 == perpendicular), in degrees */ + double x, y; /* same as x, y root.x, root.y, but with sub-pixel precision, if available */ + struct { + double x, y; + } root; + } multi; + }; + + struct _Ecore_Event_Mouse_IO + { + Ecore_Window window; + Ecore_Window event_window; + + unsigned int timestamp; + unsigned int modifiers; + + int x; + int y; + }; + + struct _Ecore_Event_Modifiers + { + unsigned int size; + unsigned int array[ECORE_LAST]; + }; + + EAPI int ecore_event_init(void); + EAPI int ecore_event_shutdown(void); + + EAPI unsigned int ecore_event_modifier_mask(Ecore_Event_Modifier modifier); + EAPI Ecore_Event_Modifier ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, int inc); #ifdef __cplusplus } diff --git a/src/lib/ecore_input/ecore_input.c b/src/lib/ecore_input/ecore_input.c index ab11d90..22740bf 100644 --- a/src/lib/ecore_input/ecore_input.c +++ b/src/lib/ecore_input/ecore_input.c @@ -31,7 +31,8 @@ ecore_event_init(void) if (++_ecore_event_init_count != 1) return _ecore_event_init_count; - _ecore_input_log_dom = eina_log_domain_register("EcoreInput", ECORE_INPUT_DEFAULT_LOG_COLOR); + _ecore_input_log_dom = eina_log_domain_register + ("ecore_input", ECORE_INPUT_DEFAULT_LOG_COLOR); if(_ecore_input_log_dom < 0) { EINA_LOG_ERR("Impossible to create a log domain for the ecore input module."); @@ -110,9 +111,9 @@ ecore_event_update_modifier(const char *key, Ecore_Event_Modifiers *modifiers, i for (i = 0; i < sizeof (matchs) / sizeof (Ecore_Event_Modifier_Match); i++) if (strcmp(matchs[i].key, key) == 0) { - if (modifiers && matchs[i].modifier < modifiers->size) - modifiers->array[matchs[i].modifier] += inc; - return matchs[i].modifier; + if (modifiers && matchs[i].modifier < modifiers->size) + modifiers->array[matchs[i].modifier] += inc; + return matchs[i].modifier; } return ECORE_NONE; diff --git a/src/lib/ecore_input_evas/Ecore_Input_Evas.h b/src/lib/ecore_input_evas/Ecore_Input_Evas.h index 984bb74..836d3e0 100644 --- a/src/lib/ecore_input_evas/Ecore_Input_Evas.h +++ b/src/lib/ecore_input_evas/Ecore_Input_Evas.h @@ -16,7 +16,7 @@ # endif /* ! DLL_EXPORT */ # else # define EAPI __declspec(dllimport) -# endif /* ! EFL_ECORE_INPUT_BUILD */ +# endif /* ! EFL_ECORE_INPUT_EVAS_BUILD */ #else # ifdef __GNUC__ # if __GNUC__ >= 4 @@ -35,24 +35,24 @@ extern "C" { typedef void (*Ecore_Event_Mouse_Move_Cb)(void *window, int x, int y, unsigned int timestamp); -EAPI int ecore_event_evas_init(void); -EAPI int ecore_event_evas_shutdown(void); +EAPI int ecore_event_evas_init(void); +EAPI int ecore_event_evas_shutdown(void); -EAPI Eina_Bool ecore_event_evas_key_down(void *data, int type, void *event); -EAPI Eina_Bool ecore_event_evas_key_up(void *data, int type, void *event); -EAPI Eina_Bool ecore_event_evas_mouse_button_up(void *data, int type, void *event); -EAPI Eina_Bool ecore_event_evas_mouse_button_down(void *data, int type, void *event); -EAPI Eina_Bool ecore_event_evas_mouse_wheel(void *data, int type, void *event); -EAPI Eina_Bool ecore_event_evas_mouse_move(void *data, int type, void *event); -EAPI Eina_Bool ecore_event_evas_mouse_in(void *data, int type, void *event); -EAPI Eina_Bool ecore_event_evas_mouse_out(void *data, int type, void *event); +EAPI Eina_Bool ecore_event_evas_key_down(void *data, int type, void *event); +EAPI Eina_Bool ecore_event_evas_key_up(void *data, int type, void *event); +EAPI Eina_Bool ecore_event_evas_mouse_button_up(void *data, int type, void *event); +EAPI Eina_Bool ecore_event_evas_mouse_button_down(void *data, int type, void *event); +EAPI Eina_Bool ecore_event_evas_mouse_wheel(void *data, int type, void *event); +EAPI Eina_Bool ecore_event_evas_mouse_move(void *data, int type, void *event); +EAPI Eina_Bool ecore_event_evas_mouse_in(void *data, int type, void *event); +EAPI Eina_Bool ecore_event_evas_mouse_out(void *data, int type, void *event); -EAPI void ecore_event_window_register(Ecore_Window id, void *window, Evas *evas, Ecore_Event_Mouse_Move_Cb move_mouse); -EAPI void ecore_event_window_unregister(Ecore_Window id); -EAPI void* ecore_event_window_match(Ecore_Window id); -EAPI void ecore_event_window_ignore_events(Ecore_Window id, int ignore_event); +EAPI void ecore_event_window_register(Ecore_Window id, void *window, Evas *evas, Ecore_Event_Mouse_Move_Cb move_mouse); +EAPI void ecore_event_window_unregister(Ecore_Window id); +EAPI void *ecore_event_window_match(Ecore_Window id); +EAPI void ecore_event_window_ignore_events(Ecore_Window id, int ignore_event); -EAPI void ecore_event_evas_modifier_lock_update(Evas *e, unsigned int modifiers); +EAPI void ecore_event_evas_modifier_lock_update(Evas *e, unsigned int modifiers); #ifdef __cplusplus } diff --git a/src/lib/ecore_input_evas/ecore_input_evas.c b/src/lib/ecore_input_evas/ecore_input_evas.c index 6bf5d7a..174d540 100644 --- a/src/lib/ecore_input_evas/ecore_input_evas.c +++ b/src/lib/ecore_input_evas/ecore_input_evas.c @@ -42,13 +42,13 @@ ecore_event_evas_modifier_lock_update(Evas *e, unsigned int modifiers) if (modifiers & ECORE_EVENT_MODIFIER_WIN) { - evas_key_modifier_on(e, "Super"); - evas_key_modifier_on(e, "Hyper"); + evas_key_modifier_on(e, "Super"); + evas_key_modifier_on(e, "Hyper"); } else { - evas_key_modifier_off(e, "Super"); - evas_key_modifier_off(e, "Hyper"); + evas_key_modifier_off(e, "Super"); + evas_key_modifier_off(e, "Hyper"); } if (modifiers & ECORE_EVENT_LOCK_SCROLL) @@ -214,13 +214,13 @@ _ecore_event_evas_mouse_io(Ecore_Event_Mouse_IO *e, Ecore_Event_IO io) switch (io) { case ECORE_IN: - evas_event_feed_mouse_in(lookup->evas, e->timestamp, NULL); - break; + evas_event_feed_mouse_in(lookup->evas, e->timestamp, NULL); + break; case ECORE_OUT: - evas_event_feed_mouse_out(lookup->evas, e->timestamp, NULL); - break; + evas_event_feed_mouse_out(lookup->evas, e->timestamp, NULL); + break; default: - break; + break; } lookup->move_mouse(lookup->window, e->x, e->y, e->timestamp); @@ -271,7 +271,8 @@ ecore_event_evas_init(void) if (++_ecore_event_evas_init_count != 1) return _ecore_event_evas_init_count; - _ecore_input_evas_log_dom = eina_log_domain_register("EcoreInputEvas", ECORE_INPUT_EVAS_DEFAULT_LOG_COLOR); + _ecore_input_evas_log_dom = eina_log_domain_register + ("ecore_input_evas", ECORE_INPUT_EVAS_DEFAULT_LOG_COLOR); if (_ecore_input_evas_log_dom < 0) { EINA_LOG_ERR("Impossible to create a log domain for the ecore input evas_module."); @@ -280,38 +281,38 @@ ecore_event_evas_init(void) if (!ecore_init()) { - return --_ecore_event_evas_init_count; + return --_ecore_event_evas_init_count; } if (!ecore_event_init()) { - goto shutdown_ecore; + goto shutdown_ecore; } ecore_event_evas_handlers[0] = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, - ecore_event_evas_key_down, - NULL); + ecore_event_evas_key_down, + NULL); ecore_event_evas_handlers[1] = ecore_event_handler_add(ECORE_EVENT_KEY_UP, - ecore_event_evas_key_up, - NULL); + ecore_event_evas_key_up, + NULL); ecore_event_evas_handlers[2] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, - ecore_event_evas_mouse_button_down, - NULL); + ecore_event_evas_mouse_button_down, + NULL); ecore_event_evas_handlers[3] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, - ecore_event_evas_mouse_button_up, - NULL); + ecore_event_evas_mouse_button_up, + NULL); ecore_event_evas_handlers[4] = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, - ecore_event_evas_mouse_move, - NULL); + ecore_event_evas_mouse_move, + NULL); ecore_event_evas_handlers[5] = ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, - ecore_event_evas_mouse_wheel, - NULL); + ecore_event_evas_mouse_wheel, + NULL); ecore_event_evas_handlers[6] = ecore_event_handler_add(ECORE_EVENT_MOUSE_IN, - ecore_event_evas_mouse_in, - NULL); + ecore_event_evas_mouse_in, + NULL); ecore_event_evas_handlers[7] = ecore_event_handler_add(ECORE_EVENT_MOUSE_OUT, - ecore_event_evas_mouse_out, - NULL); + ecore_event_evas_mouse_out, + NULL); _window_hash = eina_hash_pointer_new(free); @@ -335,8 +336,8 @@ ecore_event_evas_shutdown(void) _window_hash = NULL; for (i = 0; i < sizeof(ecore_event_evas_handlers) / sizeof(Ecore_Event_Handler *); i++) { - ecore_event_handler_del(ecore_event_evas_handlers[i]); - ecore_event_evas_handlers[i] = NULL; + ecore_event_handler_del(ecore_event_evas_handlers[i]); + ecore_event_evas_handlers[i] = NULL; } ecore_event_shutdown(); diff --git a/src/lib/ecore_ipc/Ecore_Ipc.h b/src/lib/ecore_ipc/Ecore_Ipc.h index a4c6651..000fca9 100644 --- a/src/lib/ecore_ipc/Ecore_Ipc.h +++ b/src/lib/ecore_ipc/Ecore_Ipc.h @@ -40,8 +40,8 @@ extern "C" { /** * Macros used for generic data packing */ -EAPI unsigned short _ecore_ipc_swap_16(unsigned short v); -EAPI unsigned int _ecore_ipc_swap_32(unsigned int v); +EAPI unsigned short _ecore_ipc_swap_16(unsigned short v); +EAPI unsigned int _ecore_ipc_swap_32(unsigned int v); EAPI unsigned long long _ecore_ipc_swap_64(unsigned long long v); #ifdef WORDS_BIGENDIAN @@ -68,44 +68,44 @@ EAPI unsigned long long _ecore_ipc_swap_64(unsigned long long v); /* unpacking */ #define ECORE_IPC_GET64(v)\ { \ - p->v = ECORE_IPC_SWAP2CPU64(*(long long *)(ptr)); \ - ptr += 8; \ + p->v = ECORE_IPC_SWAP2CPU64(*(long long *)(ptr)); \ + ptr += 8; \ } #define ECORE_IPC_GET32(v)\ { \ - p->v = ECORE_IPC_SWAP2CPU32(*(int *)(ptr)); \ - ptr += 4; \ + p->v = ECORE_IPC_SWAP2CPU32(*(int *)(ptr)); \ + ptr += 4; \ } #define ECORE_IPC_GET16(v)\ { \ - p->v = ECORE_IPC_SWAP2CPU16(*(short *)(ptr)); \ - ptr += 2; \ + p->v = ECORE_IPC_SWAP2CPU16(*(short *)(ptr)); \ + ptr += 2; \ } #define ECORE_IPC_GET8(v) \ { \ - p->v = ECORE_IPC_SWAP2CPU8(*(char *)(ptr)); \ - ptr += 1; \ + p->v = ECORE_IPC_SWAP2CPU8(*(char *)(ptr)); \ + ptr += 1; \ } /* packing */ #define ECORE_IPC_PUT64(v)\ { \ - *(long long *)(ptr) = ECORE_IPC_SWAP2NET64(p->v); \ - ptr += 8; \ + *(long long *)(ptr) = ECORE_IPC_SWAP2NET64(p->v); \ + ptr += 8; \ } #define ECORE_IPC_PUT32(v)\ { \ - *(int *)(ptr) = ECORE_IPC_SWAP2NET32(p->v); \ - ptr += 4; \ + *(int *)(ptr) = ECORE_IPC_SWAP2NET32(p->v); \ + ptr += 4; \ } #define ECORE_IPC_PUT16(v)\ { \ - *(short *)(ptr) = ECORE_IPC_SWAP2NET16(p->v); \ - ptr += 2; \ + *(short *)(ptr) = ECORE_IPC_SWAP2NET16(p->v); \ + ptr += 2; \ } #define ECORE_IPC_PUT8(v) \ { \ - *(char *)(ptr) = ECORE_IPC_SWAP2NET8(p->v); \ - ptr += 1; \ + *(char *)(ptr) = ECORE_IPC_SWAP2NET8(p->v); \ + ptr += 1; \ } /* padding data */ #define ECORE_IPC_PAD8() ptr += 1 @@ -123,16 +123,16 @@ EAPI unsigned long long _ecore_ipc_swap_64(unsigned long long v); #define ECORE_IPC_CHEKS() if (*((unsigned char *)d + s - 1) != 0) return 0; #define ECORE_IPC_GETS(v) \ { \ - if (ptr < ((unsigned char *)d + s)) \ - { \ - p->v = (char *)ptr; \ - ptr += strlen(p->v) + 1; \ - } \ + if (ptr < ((unsigned char *)d + s)) \ + { \ + p->v = (char *)ptr; \ + ptr += strlen(p->v) + 1; \ + } \ } #define ECORE_IPC_PUTS(v, l)\ { \ - strcpy((char *)ptr, p->v); \ - ptr += l + 1; \ + strcpy((char *)ptr, p->v); \ + ptr += l + 1; \ } /* handy to calculate what sized block we need to alloc */ @@ -189,7 +189,7 @@ EAPI unsigned long long _ecore_ipc_swap_64(unsigned long long v); p = malloc(sizeof(typ)); #define ECORE_IPC_DEC_EINA_LIST_FOOT() \ - l = eina_list_append(l, p); \ + l = eina_list_append(l, p); \ } \ return l #define ECORE_IPC_ENC_EINA_LIST_HEAD_START(typ) \ @@ -216,108 +216,108 @@ EAPI unsigned long long _ecore_ipc_swap_64(unsigned long long v); } \ return d - typedef enum _Ecore_Ipc_Type - { - ECORE_IPC_LOCAL_USER, - ECORE_IPC_LOCAL_SYSTEM, - ECORE_IPC_REMOTE_SYSTEM, - ECORE_IPC_USE_SSL = 16 - } Ecore_Ipc_Type; +typedef enum _Ecore_Ipc_Type +{ + ECORE_IPC_LOCAL_USER, + ECORE_IPC_LOCAL_SYSTEM, + ECORE_IPC_REMOTE_SYSTEM, + ECORE_IPC_USE_SSL = 16 +} Ecore_Ipc_Type; - typedef struct _Ecore_Ipc_Event_Client_Add Ecore_Ipc_Event_Client_Add; - typedef struct _Ecore_Ipc_Event_Client_Del Ecore_Ipc_Event_Client_Del; - typedef struct _Ecore_Ipc_Event_Server_Add Ecore_Ipc_Event_Server_Add; - typedef struct _Ecore_Ipc_Event_Server_Del Ecore_Ipc_Event_Server_Del; - typedef struct _Ecore_Ipc_Event_Client_Data Ecore_Ipc_Event_Client_Data; - typedef struct _Ecore_Ipc_Event_Server_Data Ecore_Ipc_Event_Server_Data; - - struct _Ecore_Ipc_Event_Client_Add - { - Ecore_Ipc_Client *client; - }; - - struct _Ecore_Ipc_Event_Client_Del - { - Ecore_Ipc_Client *client; - }; - - struct _Ecore_Ipc_Event_Server_Add - { - Ecore_Ipc_Server *server; - }; - - struct _Ecore_Ipc_Event_Server_Del - { - Ecore_Ipc_Server *server; - }; - - struct _Ecore_Ipc_Event_Client_Data - { - Ecore_Ipc_Client *client; - /* FIXME: this needs to become an ipc message */ - int major; - int minor; - int ref; - int ref_to; - int response; - void *data; - int size; - }; - - struct _Ecore_Ipc_Event_Server_Data - { - Ecore_Ipc_Server *server; - /* FIXME: this needs to become an ipc message */ - int major; - int minor; - int ref; - int ref_to; - int response; - void *data; - int size; - }; - - EAPI extern int ECORE_IPC_EVENT_CLIENT_ADD; - EAPI extern int ECORE_IPC_EVENT_CLIENT_DEL; - EAPI extern int ECORE_IPC_EVENT_SERVER_ADD; - EAPI extern int ECORE_IPC_EVENT_SERVER_DEL; - EAPI extern int ECORE_IPC_EVENT_CLIENT_DATA; - EAPI extern int ECORE_IPC_EVENT_SERVER_DATA; - - EAPI int ecore_ipc_init(void); - EAPI int ecore_ipc_shutdown(void); - - /* FIXME: need to add protocol type parameter */ - EAPI Ecore_Ipc_Server *ecore_ipc_server_add(Ecore_Ipc_Type type, const char *name, int port, const void *data); +typedef struct _Ecore_Ipc_Event_Client_Add Ecore_Ipc_Event_Client_Add; +typedef struct _Ecore_Ipc_Event_Client_Del Ecore_Ipc_Event_Client_Del; +typedef struct _Ecore_Ipc_Event_Server_Add Ecore_Ipc_Event_Server_Add; +typedef struct _Ecore_Ipc_Event_Server_Del Ecore_Ipc_Event_Server_Del; +typedef struct _Ecore_Ipc_Event_Client_Data Ecore_Ipc_Event_Client_Data; +typedef struct _Ecore_Ipc_Event_Server_Data Ecore_Ipc_Event_Server_Data; + +struct _Ecore_Ipc_Event_Client_Add +{ + Ecore_Ipc_Client *client; +}; + +struct _Ecore_Ipc_Event_Client_Del +{ + Ecore_Ipc_Client *client; +}; + +struct _Ecore_Ipc_Event_Server_Add +{ + Ecore_Ipc_Server *server; +}; + +struct _Ecore_Ipc_Event_Server_Del +{ + Ecore_Ipc_Server *server; +}; - /* FIXME: need to add protocol type parameter */ - EAPI Ecore_Ipc_Server *ecore_ipc_server_connect(Ecore_Ipc_Type type, char *name, int port, const void *data); - EAPI void *ecore_ipc_server_del(Ecore_Ipc_Server *svr); - EAPI void *ecore_ipc_server_data_get(Ecore_Ipc_Server *svr); - EAPI int ecore_ipc_server_connected_get(Ecore_Ipc_Server *svr); - EAPI Eina_List *ecore_ipc_server_clients_get(Ecore_Ipc_Server *svr); +struct _Ecore_Ipc_Event_Client_Data +{ + Ecore_Ipc_Client *client; /* FIXME: this needs to become an ipc message */ - EAPI int ecore_ipc_server_send(Ecore_Ipc_Server *svr, int major, int minor, int ref, int ref_to, int response, const void *data, int size); - EAPI void ecore_ipc_server_client_limit_set(Ecore_Ipc_Server *svr, int client_limit, char reject_excess_clients); - EAPI void ecore_ipc_server_data_size_max_set(Ecore_Ipc_Server *srv, int size); - EAPI int ecore_ipc_server_data_size_max_get(Ecore_Ipc_Server *srv); - EAPI const char *ecore_ipc_server_ip_get(Ecore_Ipc_Server *svr); - EAPI void ecore_ipc_server_flush(Ecore_Ipc_Server *svr); - + int major; + int minor; + int ref; + int ref_to; + int response; + void *data; + int size; +}; + +struct _Ecore_Ipc_Event_Server_Data +{ + Ecore_Ipc_Server *server; /* FIXME: this needs to become an ipc message */ - EAPI int ecore_ipc_client_send(Ecore_Ipc_Client *cl, int major, int minor, int ref, int ref_to, int response, const void *data, int size); - EAPI Ecore_Ipc_Server *ecore_ipc_client_server_get(Ecore_Ipc_Client *cl); - EAPI void *ecore_ipc_client_del(Ecore_Ipc_Client *cl); - EAPI void ecore_ipc_client_data_set(Ecore_Ipc_Client *cl, const void *data); - EAPI void *ecore_ipc_client_data_get(Ecore_Ipc_Client *cl); - EAPI void ecore_ipc_client_data_size_max_set(Ecore_Ipc_Client *cl, int size); - EAPI int ecore_ipc_client_data_size_max_get(Ecore_Ipc_Client *cl); - EAPI const char *ecore_ipc_client_ip_get(Ecore_Ipc_Client *cl); - EAPI void ecore_ipc_client_flush(Ecore_Ipc_Client *cl); + int major; + int minor; + int ref; + int ref_to; + int response; + void *data; + int size; +}; - EAPI int ecore_ipc_ssl_available_get(void); - /* FIXME: need to add a callback to "ok" large ipc messages greater than */ - /* a certain size (seurity/DOS attack safety) */ +EAPI extern int ECORE_IPC_EVENT_CLIENT_ADD; +EAPI extern int ECORE_IPC_EVENT_CLIENT_DEL; +EAPI extern int ECORE_IPC_EVENT_SERVER_ADD; +EAPI extern int ECORE_IPC_EVENT_SERVER_DEL; +EAPI extern int ECORE_IPC_EVENT_CLIENT_DATA; +EAPI extern int ECORE_IPC_EVENT_SERVER_DATA; + +EAPI int ecore_ipc_init(void); +EAPI int ecore_ipc_shutdown(void); + +/* FIXME: need to add protocol type parameter */ +EAPI Ecore_Ipc_Server *ecore_ipc_server_add(Ecore_Ipc_Type type, const char *name, int port, const void *data); + +/* FIXME: need to add protocol type parameter */ +EAPI Ecore_Ipc_Server *ecore_ipc_server_connect(Ecore_Ipc_Type type, char *name, int port, const void *data); +EAPI void *ecore_ipc_server_del(Ecore_Ipc_Server *svr); +EAPI void *ecore_ipc_server_data_get(Ecore_Ipc_Server *svr); +EAPI Eina_Bool ecore_ipc_server_connected_get(Ecore_Ipc_Server *svr); +EAPI Eina_List *ecore_ipc_server_clients_get(Ecore_Ipc_Server *svr); +/* FIXME: this needs to become an ipc message */ +EAPI int ecore_ipc_server_send(Ecore_Ipc_Server *svr, int major, int minor, int ref, int ref_to, int response, const void *data, int size); +EAPI void ecore_ipc_server_client_limit_set(Ecore_Ipc_Server *svr, int client_limit, char reject_excess_clients); +EAPI void ecore_ipc_server_data_size_max_set(Ecore_Ipc_Server *srv, int size); +EAPI int ecore_ipc_server_data_size_max_get(Ecore_Ipc_Server *srv); +EAPI const char *ecore_ipc_server_ip_get(Ecore_Ipc_Server *svr); +EAPI void ecore_ipc_server_flush(Ecore_Ipc_Server *svr); + +/* FIXME: this needs to become an ipc message */ +EAPI int ecore_ipc_client_send(Ecore_Ipc_Client *cl, int major, int minor, int ref, int ref_to, int response, const void *data, int size); +EAPI Ecore_Ipc_Server *ecore_ipc_client_server_get(Ecore_Ipc_Client *cl); +EAPI void *ecore_ipc_client_del(Ecore_Ipc_Client *cl); +EAPI void ecore_ipc_client_data_set(Ecore_Ipc_Client *cl, const void *data); +EAPI void *ecore_ipc_client_data_get(Ecore_Ipc_Client *cl); +EAPI void ecore_ipc_client_data_size_max_set(Ecore_Ipc_Client *cl, int size); +EAPI int ecore_ipc_client_data_size_max_get(Ecore_Ipc_Client *cl); +EAPI const char *ecore_ipc_client_ip_get(Ecore_Ipc_Client *cl); +EAPI void ecore_ipc_client_flush(Ecore_Ipc_Client *cl); + +EAPI int ecore_ipc_ssl_available_get(void); +/* FIXME: need to add a callback to "ok" large ipc messages greater than */ +/* a certain size (seurity/DOS attack safety) */ #ifdef __cplusplus } diff --git a/src/lib/ecore_ipc/ecore_ipc.c b/src/lib/ecore_ipc/ecore_ipc.c index 517509c..4024280 100644 --- a/src/lib/ecore_ipc/ecore_ipc.c +++ b/src/lib/ecore_ipc/ecore_ipc.c @@ -84,78 +84,78 @@ _ecore_ipc_dlt_int(int out, int prev, int *mode) /* 0 byte */ if (out == 0) { - *mode = DLT_ZERO; - return 0; + *mode = DLT_ZERO; + return 0; } if (out == (int)0xffffffff) { - *mode = DLT_ONE; - return 0; + *mode = DLT_ONE; + return 0; } if (out == prev) { - *mode = DLT_SAME; - return 0; + *mode = DLT_SAME; + return 0; } if (out == prev << 1) { - *mode = DLT_SHL; - return 0; + *mode = DLT_SHL; + return 0; } if (out == prev >> 1) { - *mode = DLT_SHR; - return 0; + *mode = DLT_SHR; + return 0; } /* 1 byte */ dlt = out - prev; if (!(dlt & 0xffffff00)) { - *mode = DLT_ADD8; - return dlt & 0xff; + *mode = DLT_ADD8; + return dlt & 0xff; } dlt = prev - out; if (!(dlt & 0xffffff00)) { - *mode = DLT_DEL8; - return dlt & 0xff; + *mode = DLT_DEL8; + return dlt & 0xff; } dlt = out - prev; if (!(dlt & 0x00ffffff)) { - *mode = DLT_ADDU8; - return (dlt >> 24) & 0xff; + *mode = DLT_ADDU8; + return (dlt >> 24) & 0xff; } dlt = prev - out; if (!(dlt & 0x00ffffff)) { - *mode = DLT_DELU8; - return (dlt >> 24) & 0xff; + *mode = DLT_DELU8; + return (dlt >> 24) & 0xff; } /* 2 byte */ dlt = out - prev; if (!(dlt & 0xffff0000)) { - *mode = DLT_ADD16; - return dlt & 0xffff; + *mode = DLT_ADD16; + return dlt & 0xffff; } dlt = prev - out; if (!(dlt & 0xffff0000)) { - *mode = DLT_DEL16; - return dlt & 0xffff; + *mode = DLT_DEL16; + return dlt & 0xffff; } dlt = out - prev; if (!(dlt & 0x0000ffff)) { - *mode = DLT_ADDU16; - return (dlt >> 16) & 0xffff; + *mode = DLT_ADDU16; + return (dlt >> 16) & 0xffff; } dlt = prev - out; if (!(dlt & 0x0000ffff)) { - *mode = DLT_DELU16; - return (dlt >> 16) & 0xffff; + *mode = DLT_DELU16; + return (dlt >> 16) & 0xffff; } /* 4 byte */ *mode = DLT_SET; @@ -168,55 +168,55 @@ _ecore_ipc_ddlt_int(int in, int prev, int mode) switch (mode) { case DLT_ZERO: - return 0; - break; + return 0; + break; case DLT_ONE: - return 0xffffffff; - break; + return 0xffffffff; + break; case DLT_SAME: - return prev; - break; + return prev; + break; case DLT_SHL: - return prev << 1; - break; + return prev << 1; + break; case DLT_SHR: - return prev >> 1; - break; + return prev >> 1; + break; case DLT_ADD8: - return prev + in; - break; + return prev + in; + break; case DLT_DEL8: - return prev - in; - break; + return prev - in; + break; case DLT_ADDU8: - return prev + (in << 24); - break; + return prev + (in << 24); + break; case DLT_DELU8: - return prev - (in << 24); - break; + return prev - (in << 24); + break; case DLT_ADD16: - return prev + in; - break; + return prev + in; + break; case DLT_DEL16: - return prev - in; - break; + return prev - in; + break; case DLT_ADDU16: - return prev + (in << 16); - break; + return prev + (in << 16); + break; case DLT_DELU16: - return prev - (in << 16); - break; + return prev - (in << 16); + break; case DLT_SET: - return in; - break; + return in; + break; case DLT_R1: - return 0; - break; + return 0; + break; case DLT_R2: - return 0; - break; + return 0; + break; default: - break; + break; } return 0; } @@ -264,7 +264,8 @@ ecore_ipc_init(void) if (++_ecore_ipc_init_count != 1) return _ecore_ipc_init_count; - _ecore_ipc_log_dom = eina_log_domain_register("EcoreIpc", ECORE_IPC_DEFAULT_LOG_COLOR); + _ecore_ipc_log_dom = eina_log_domain_register + ("ecore_ipc", ECORE_IPC_DEFAULT_LOG_COLOR); if(_ecore_ipc_log_dom < 0) { EINA_LOG_ERR("Impossible to create a log domain for the Ecore IPC module."); @@ -281,17 +282,17 @@ ecore_ipc_init(void) ECORE_IPC_EVENT_SERVER_DATA = ecore_event_type_new(); handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_ADD, - _ecore_ipc_event_client_add, NULL); + _ecore_ipc_event_client_add, NULL); handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DEL, - _ecore_ipc_event_client_del, NULL); + _ecore_ipc_event_client_del, NULL); handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_ADD, - _ecore_ipc_event_server_add, NULL); + _ecore_ipc_event_server_add, NULL); handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DEL, - _ecore_ipc_event_server_del, NULL); + _ecore_ipc_event_server_del, NULL); handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_CLIENT_DATA, - _ecore_ipc_event_client_data, NULL); + _ecore_ipc_event_client_data, NULL); handler[i] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA, - _ecore_ipc_event_server_data, NULL); + _ecore_ipc_event_server_data, NULL); return _ecore_ipc_init_count; } @@ -355,22 +356,22 @@ ecore_ipc_server_add(Ecore_Ipc_Type compl_type, const char *name, int port, cons switch (type) { case ECORE_IPC_LOCAL_USER: - svr->server = ecore_con_server_add(ECORE_CON_LOCAL_USER | extra, name, port, svr); - break; + svr->server = ecore_con_server_add(ECORE_CON_LOCAL_USER | extra, name, port, svr); + break; case ECORE_IPC_LOCAL_SYSTEM: - svr->server = ecore_con_server_add(ECORE_CON_LOCAL_SYSTEM | extra, name, port, svr); - break; + svr->server = ecore_con_server_add(ECORE_CON_LOCAL_SYSTEM | extra, name, port, svr); + break; case ECORE_IPC_REMOTE_SYSTEM: - svr->server = ecore_con_server_add(ECORE_CON_REMOTE_SYSTEM | extra, name, port, svr); - break; + svr->server = ecore_con_server_add(ECORE_CON_REMOTE_SYSTEM | extra, name, port, svr); + break; default: - free(svr); - return NULL; + free(svr); + return NULL; } if (!svr->server) { - free(svr); - return NULL; + free(svr); + return NULL; } svr->max_buf_size = 32 * 1024; svr->data = (void *)data; @@ -411,22 +412,22 @@ ecore_ipc_server_connect(Ecore_Ipc_Type compl_type, char *name, int port, const switch (type) { case ECORE_IPC_LOCAL_USER: - svr->server = ecore_con_server_connect(ECORE_CON_LOCAL_USER | extra, name, port, svr); - break; + svr->server = ecore_con_server_connect(ECORE_CON_LOCAL_USER | extra, name, port, svr); + break; case ECORE_IPC_LOCAL_SYSTEM: - svr->server = ecore_con_server_connect(ECORE_CON_LOCAL_SYSTEM | extra, name, port, svr); - break; + svr->server = ecore_con_server_connect(ECORE_CON_LOCAL_SYSTEM | extra, name, port, svr); + break; case ECORE_IPC_REMOTE_SYSTEM: - svr->server = ecore_con_server_connect(ECORE_CON_REMOTE_SYSTEM | extra, name, port, svr); - break; + svr->server = ecore_con_server_connect(ECORE_CON_REMOTE_SYSTEM | extra, name, port, svr); + break; default: - free(svr); - return NULL; + free(svr); + return NULL; } if (!svr->server) { - free(svr); - return NULL; + free(svr); + return NULL; } svr->max_buf_size = -1; svr->data = (void *)data; @@ -448,9 +449,9 @@ ecore_ipc_server_del(Ecore_Ipc_Server *svr) if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER)) { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, - "ecore_ipc_server_del"); - return NULL; + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, + "ecore_ipc_server_del"); + return NULL; } if (svr->delete_me) return NULL; @@ -459,16 +460,16 @@ ecore_ipc_server_del(Ecore_Ipc_Server *svr) svr->delete_me = 1; if (svr->event_count == 0) { - Ecore_Ipc_Client *cl; + Ecore_Ipc_Client *cl; - EINA_LIST_FREE(svr->clients, cl) - ecore_ipc_client_del(cl); - ecore_con_server_del(svr->server); - servers = eina_list_remove(servers, svr); + EINA_LIST_FREE(svr->clients, cl) + ecore_ipc_client_del(cl); + ecore_con_server_del(svr->server); + servers = eina_list_remove(servers, svr); - if (svr->buf) free(svr->buf); - ECORE_MAGIC_SET(svr, ECORE_MAGIC_NONE); - free(svr); + if (svr->buf) free(svr->buf); + ECORE_MAGIC_SET(svr, ECORE_MAGIC_NONE); + free(svr); } return data; } @@ -484,9 +485,9 @@ ecore_ipc_server_data_get(Ecore_Ipc_Server *svr) { if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER)) { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, - "ecore_ipc_server_data_get"); - return NULL; + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, + "ecore_ipc_server_data_get"); + return NULL; } return svr->data; } @@ -494,17 +495,17 @@ ecore_ipc_server_data_get(Ecore_Ipc_Server *svr) /** * Retrieves whether the given IPC server is currently connected. * @param svr The given IPC server. - * @return @c 1 if the server is connected. @c 0 otherwise. + * @return #EINA_TRUE if the server is connected. #EINA_FALSE otherwise. * @ingroup Ecore_IPC_Server_Group */ -EAPI int +EAPI Eina_Bool ecore_ipc_server_connected_get(Ecore_Ipc_Server *svr) { if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER)) { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, - "ecore_ipc_server_connected_get"); - return 0; + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, + "ecore_ipc_server_connected_get"); + return EINA_FALSE; } return ecore_con_server_connected_get(svr->server); } @@ -520,9 +521,9 @@ ecore_ipc_server_clients_get(Ecore_Ipc_Server *svr) { if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER)) { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, - "ecore_ipc_server_clients_get"); - return NULL; + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, + "ecore_ipc_server_clients_get"); + return NULL; } return svr->client_list; } @@ -531,32 +532,32 @@ ecore_ipc_server_clients_get(Ecore_Ipc_Server *svr) d = _ecore_ipc_dlt_int(msg._member, svr->prev.o._member, &md); \ if (md >= DLT_SET) \ { \ - unsigned int v; \ - unsigned char *dd; \ - dd = (unsigned char *)&v; \ - v = d; \ - v = htonl(v); \ - *(dat + s + 0) = dd[0]; \ - *(dat + s + 1) = dd[1]; \ - *(dat + s + 2) = dd[2]; \ - *(dat + s + 3) = dd[3]; \ - s += 4; \ + unsigned int v; \ + unsigned char *dd; \ + dd = (unsigned char *)&v; \ + v = d; \ + v = htonl(v); \ + *(dat + s + 0) = dd[0]; \ + *(dat + s + 1) = dd[1]; \ + *(dat + s + 2) = dd[2]; \ + *(dat + s + 3) = dd[3]; \ + s += 4; \ } \ else if (md >= DLT_ADD16) \ { \ - unsigned short v; \ - unsigned char *dd; \ - dd = (unsigned char *)&v; \ - v = d; \ - v = htons(v); \ - *(dat + s + 0) = dd[0]; \ - *(dat + s + 1) = dd[1]; \ - s += 2; \ + unsigned short v; \ + unsigned char *dd; \ + dd = (unsigned char *)&v; \ + v = d; \ + v = htons(v); \ + *(dat + s + 0) = dd[0]; \ + *(dat + s + 1) = dd[1]; \ + s += 2; \ } \ else if (md >= DLT_ADD8) \ { \ - *(dat + s + 0) = (unsigned char)d; \ - s += 1; \ + *(dat + s + 0) = (unsigned char)d; \ + s += 1; \ } /** @@ -588,9 +589,9 @@ ecore_ipc_server_send(Ecore_Ipc_Server *svr, int major, int minor, int ref, int if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER)) { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, - "ecore_ipc_server_send"); - return 0; + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, + "ecore_ipc_server_send"); + return 0; } if (size < 0) size = 0; msg.major = major; @@ -647,9 +648,9 @@ ecore_ipc_server_client_limit_set(Ecore_Ipc_Server *svr, int client_limit, char { if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER)) { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, - "ecore_ipc_server_client_limit_set"); - return; + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, + "ecore_ipc_server_client_limit_set"); + return; } ecore_con_server_client_limit_set(svr->server, client_limit, reject_excess_clients); } @@ -666,9 +667,9 @@ ecore_ipc_server_data_size_max_set(Ecore_Ipc_Server *svr, int size) { if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER)) { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, - "ecore_ipc_server_data_size_max_set"); - return; + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, + "ecore_ipc_server_data_size_max_set"); + return; } svr->max_buf_size = size; } @@ -685,9 +686,9 @@ ecore_ipc_server_data_size_max_get(Ecore_Ipc_Server *svr) { if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER)) { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, - "ecore_ipc_server_data_size_max_get"); - return -1; + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, + "ecore_ipc_server_data_size_max_get"); + return -1; } return svr->max_buf_size; } @@ -707,9 +708,9 @@ ecore_ipc_server_ip_get(Ecore_Ipc_Server *svr) { if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER)) { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, - "ecore_ipc_server_ip_get"); - return NULL; + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, + "ecore_ipc_server_ip_get"); + return NULL; } return ecore_con_server_ip_get(svr->server); } @@ -725,9 +726,9 @@ ecore_ipc_server_flush(Ecore_Ipc_Server *svr) { if (!ECORE_MAGIC_CHECK(svr, ECORE_MAGIC_IPC_SERVER)) { - ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, - "ecore_ipc_server_server_flush"); - return; + ECORE_MAGIC_FAIL(svr, ECORE_MAGIC_IPC_SERVER, + "ecore_ipc_server_server_flush"); + return; } ecore_con_server_flush(svr->server); } @@ -736,32 +737,32 @@ ecore_ipc_server_flush(Ecore_Ipc_Server *svr) d = _ecore_ipc_dlt_int(msg._member, cl->prev.o._member, &md); \ if (md >= DLT_SET) \ { \ - unsigned int v; \ - unsigned char *dd; \ - dd = (unsigned char *)&v; \ - v = d; \ - v = htonl(v); \ - *(dat + s + 0) = dd[0]; \ - *(dat + s + 1) = dd[1]; \ - *(dat + s + 2) = dd[2]; \ - *(dat + s + 3) = dd[3]; \ - s += 4; \ + unsigned int v; \ + unsigned char *dd; \ + dd = (unsigned char *)&v; \ + v = d; \ + v = htonl(v); \ + *(dat + s + 0) = dd[0]; \ + *(dat + s + 1) = dd[1]; \ + *(dat + s + 2) = dd[2]; \ + *(dat + s + 3) = dd[3]; \ + s += 4; \ } \ else if (md >= DLT_ADD16) \ { \ - unsigned short v; \ - unsigned char *dd; \ - dd = (unsigned char *)&v; \ - v = d; \ - v = htons(v); \ - *(dat + s + 0) = dd[0]; \ - *(dat + s + 1) = dd[1]; \ - s += 2; \ + unsigned short v; \ + unsigned char *dd; \ + dd = (unsigned char *)&v; \ + v = d; \ + v = htons(v); \ + *(dat + s + 0) = dd[0]; \ + *(dat + s + 1) = dd[1]; \ + s += 2; \ } \ else if (md >= DLT_ADD8) \ { \ - *(dat + s) = (unsigned char)d; \ - s += 1; \ + *(dat + s) = (unsigned char)d; \ + s += 1; \ } /** @@ -796,9 +797,9 @@ ecore_ipc_client_send(Ecore_Ipc_Client *cl, int major, int minor, int ref, int r if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT)) { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, - "ecore_ipc_client_send"); - return 0; + ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, + "ecore_ipc_client_send"); + return 0; } if (size < 0) size = 0; msg.major = major; @@ -839,9 +840,9 @@ ecore_ipc_client_server_get(Ecore_Ipc_Client *cl) { if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT)) { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, - "ecore_ipc_client_server_get"); - return NULL; + ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, + "ecore_ipc_client_server_get"); + return NULL; } return (ecore_con_server_data_get(ecore_con_client_server_get(cl->client))); } @@ -861,21 +862,21 @@ ecore_ipc_client_del(Ecore_Ipc_Client *cl) if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT)) { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, - "ecore_ipc_client_del"); - return NULL; + ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, + "ecore_ipc_client_del"); + return NULL; } data = cl->data; cl->data = NULL; cl->delete_me = 1; if (cl->event_count == 0) { - svr = ecore_con_server_data_get(ecore_con_client_server_get(cl->client)); - ecore_con_client_del(cl->client); - svr->clients = eina_list_remove(svr->clients, cl); - if (cl->buf) free(cl->buf); - ECORE_MAGIC_SET(cl, ECORE_MAGIC_NONE); - free(cl); + svr = ecore_con_server_data_get(ecore_con_client_server_get(cl->client)); + ecore_con_client_del(cl->client); + svr->clients = eina_list_remove(svr->clients, cl); + if (cl->buf) free(cl->buf); + ECORE_MAGIC_SET(cl, ECORE_MAGIC_NONE); + free(cl); } return data; } @@ -891,9 +892,9 @@ ecore_ipc_client_data_set(Ecore_Ipc_Client *cl, const void *data) { if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT)) { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, - "ecore_ipc_client_data_set"); - return; + ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, + "ecore_ipc_client_data_set"); + return; } cl->data = (void *)data; } @@ -909,9 +910,9 @@ ecore_ipc_client_data_get(Ecore_Ipc_Client *cl) { if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT)) { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, - "ecore_ipc_client_data_get"); - return NULL; + ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, + "ecore_ipc_client_data_get"); + return NULL; } return cl->data; } @@ -928,9 +929,9 @@ ecore_ipc_client_data_size_max_set(Ecore_Ipc_Client *cl, int size) { if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT)) { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, - "ecore_ipc_client_data_size_max_set"); - return; + ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, + "ecore_ipc_client_data_size_max_set"); + return; } cl->max_buf_size = size; } @@ -947,9 +948,9 @@ ecore_ipc_client_data_size_max_get(Ecore_Ipc_Client *cl) { if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT)) { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, - "ecore_ipc_client_data_size_max_get"); - return -1; + ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, + "ecore_ipc_client_data_size_max_get"); + return -1; } return cl->max_buf_size; } @@ -969,9 +970,9 @@ ecore_ipc_client_ip_get(Ecore_Ipc_Client *cl) { if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT)) { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, - "ecore_ipc_client_ip_get"); - return NULL; + ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, + "ecore_ipc_client_ip_get"); + return NULL; } return ecore_con_client_ip_get(cl->client); } @@ -987,9 +988,9 @@ ecore_ipc_client_flush(Ecore_Ipc_Client *cl) { if (!ECORE_MAGIC_CHECK(cl, ECORE_MAGIC_IPC_CLIENT)) { - ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, - "ecore_ipc_client_flush"); - return; + ECORE_MAGIC_FAIL(cl, ECORE_MAGIC_IPC_CLIENT, + "ecore_ipc_client_flush"); + return; } ecore_con_client_flush(cl->client); } @@ -1015,31 +1016,31 @@ _ecore_ipc_event_client_add(void *data __UNUSED__, int ev_type __UNUSED__, void if (!eina_list_data_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return ECORE_CALLBACK_RENEW; /* handling code here */ { - Ecore_Ipc_Client *cl; - Ecore_Ipc_Server *svr; - - cl = calloc(1, sizeof(Ecore_Ipc_Client)); - if (!cl) return ECORE_CALLBACK_CANCEL; - svr = ecore_con_server_data_get(ecore_con_client_server_get(e->client)); - ECORE_MAGIC_SET(cl, ECORE_MAGIC_IPC_CLIENT); - cl->client = e->client; - cl->max_buf_size = 32 * 1024; - ecore_con_client_data_set(cl->client, (void *)cl); - svr->clients = eina_list_append(svr->clients, cl); - svr->client_list = eina_list_append(svr->client_list, cl); - if (!cl->delete_me) - { - Ecore_Ipc_Event_Client_Add *e2; - - e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Add)); - if (e2) - { + Ecore_Ipc_Client *cl; + Ecore_Ipc_Server *svr; + + cl = calloc(1, sizeof(Ecore_Ipc_Client)); + if (!cl) return ECORE_CALLBACK_CANCEL; + svr = ecore_con_server_data_get(ecore_con_client_server_get(e->client)); + ECORE_MAGIC_SET(cl, ECORE_MAGIC_IPC_CLIENT); + cl->client = e->client; + cl->max_buf_size = 32 * 1024; + ecore_con_client_data_set(cl->client, (void *)cl); + svr->clients = eina_list_append(svr->clients, cl); + svr->client_list = eina_list_append(svr->client_list, cl); + if (!cl->delete_me) + { + Ecore_Ipc_Event_Client_Add *e2; + + e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Add)); + if (e2) + { cl->event_count++; - e2->client = cl; - ecore_event_add(ECORE_IPC_EVENT_CLIENT_ADD, e2, - _ecore_ipc_event_client_add_free, NULL); - } - } + e2->client = cl; + ecore_event_add(ECORE_IPC_EVENT_CLIENT_ADD, e2, + _ecore_ipc_event_client_add_free, NULL); + } + } } return ECORE_CALLBACK_CANCEL; } @@ -1053,27 +1054,27 @@ _ecore_ipc_event_client_del(void *data __UNUSED__, int ev_type __UNUSED__, void if (!eina_list_data_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return ECORE_CALLBACK_RENEW; /* handling code here */ { - Ecore_Ipc_Client *cl; - - cl = ecore_con_client_data_get(e->client); - { - Ecore_Ipc_Event_Client_Del *e2; - Ecore_Ipc_Server *svr; - - svr = ecore_con_server_data_get(ecore_con_client_server_get(e->client)); - svr->client_list = eina_list_remove(svr->client_list, cl); - if (!cl->delete_me) - { - e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Del)); - if (e2) - { - cl->event_count++; - e2->client = cl; - ecore_event_add(ECORE_IPC_EVENT_CLIENT_DEL, e2, - _ecore_ipc_event_client_del_free, NULL); - } - } - } + Ecore_Ipc_Client *cl; + + cl = ecore_con_client_data_get(e->client); + { + Ecore_Ipc_Event_Client_Del *e2; + Ecore_Ipc_Server *svr; + + svr = ecore_con_server_data_get(ecore_con_client_server_get(e->client)); + svr->client_list = eina_list_remove(svr->client_list, cl); + if (!cl->delete_me) + { + e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Del)); + if (e2) + { + cl->event_count++; + e2->client = cl; + ecore_event_add(ECORE_IPC_EVENT_CLIENT_DEL, e2, + _ecore_ipc_event_client_del_free, NULL); + } + } + } } return ECORE_CALLBACK_CANCEL; } @@ -1087,22 +1088,22 @@ _ecore_ipc_event_server_add(void *data __UNUSED__, int ev_type __UNUSED__, void if (!eina_list_data_find(servers, ecore_con_server_data_get(e->server))) return ECORE_CALLBACK_RENEW; /* handling code here */ { - Ecore_Ipc_Server *svr; + Ecore_Ipc_Server *svr; - svr = ecore_con_server_data_get(e->server); - if (!svr->delete_me) - { - Ecore_Ipc_Event_Server_Add *e2; + svr = ecore_con_server_data_get(e->server); + if (!svr->delete_me) + { + Ecore_Ipc_Event_Server_Add *e2; - e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Add)); - if (e2) - { + e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Add)); + if (e2) + { svr->event_count++; - e2->server = svr; - ecore_event_add(ECORE_IPC_EVENT_SERVER_ADD, e2, - _ecore_ipc_event_server_add_free, NULL); - } - } + e2->server = svr; + ecore_event_add(ECORE_IPC_EVENT_SERVER_ADD, e2, + _ecore_ipc_event_server_add_free, NULL); + } + } } return ECORE_CALLBACK_CANCEL; } @@ -1116,22 +1117,22 @@ _ecore_ipc_event_server_del(void *data __UNUSED__, int ev_type __UNUSED__, void if (!eina_list_data_find(servers, ecore_con_server_data_get(e->server))) return ECORE_CALLBACK_RENEW; /* handling code here */ { - Ecore_Ipc_Server *svr; + Ecore_Ipc_Server *svr; - svr = ecore_con_server_data_get(e->server); - if (!svr->delete_me) - { - Ecore_Ipc_Event_Server_Del *e2; + svr = ecore_con_server_data_get(e->server); + if (!svr->delete_me) + { + Ecore_Ipc_Event_Server_Del *e2; - e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Del)); - if (e2) - { + e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Del)); + if (e2) + { svr->event_count++; - e2->server = svr; - ecore_event_add(ECORE_IPC_EVENT_SERVER_DEL, e2, - _ecore_ipc_event_server_del_free, NULL); - } - } + e2->server = svr; + ecore_event_add(ECORE_IPC_EVENT_SERVER_DEL, e2, + _ecore_ipc_event_server_del_free, NULL); + } + } } return ECORE_CALLBACK_CANCEL; } @@ -1146,34 +1147,34 @@ _ecore_ipc_event_server_del(void *data __UNUSED__, int ev_type __UNUSED__, void md = ((head >> (4 * _n)) & 0xf); \ if (md >= DLT_SET) \ { \ - unsigned int v; \ - unsigned char *dv; \ - dv = (unsigned char *)&v; \ - dv[0] = *(cl->buf + offset + s + 0); \ - dv[1] = *(cl->buf + offset + s + 1); \ - dv[2] = *(cl->buf + offset + s + 2); \ - dv[3] = *(cl->buf + offset + s + 3); \ - d = (int)ntohl(v); \ - s += 4; \ + unsigned int v; \ + unsigned char *dv; \ + dv = (unsigned char *)&v; \ + dv[0] = *(cl->buf + offset + s + 0); \ + dv[1] = *(cl->buf + offset + s + 1); \ + dv[2] = *(cl->buf + offset + s + 2); \ + dv[3] = *(cl->buf + offset + s + 3); \ + d = (int)ntohl(v); \ + s += 4; \ } \ else if (md >= DLT_ADD16) \ { \ - unsigned short v; \ - unsigned char *dv; \ - dv = (unsigned char *)&v; \ - dv[0] = *(cl->buf + offset + s + 0); \ - dv[1] = *(cl->buf + offset + s + 1); \ - d = (int)ntohs(v); \ - s += 2; \ + unsigned short v; \ + unsigned char *dv; \ + dv = (unsigned char *)&v; \ + dv[0] = *(cl->buf + offset + s + 0); \ + dv[1] = *(cl->buf + offset + s + 1); \ + d = (int)ntohs(v); \ + s += 2; \ } \ else if (md >= DLT_ADD8) \ { \ - unsigned char v; \ - unsigned char *dv; \ - dv = (unsigned char *)&v; \ - dv[0] = *(cl->buf + offset + s + 0); \ - d = (int)v; \ - s += 1; \ + unsigned char v; \ + unsigned char *dv; \ + dv = (unsigned char *)&v; \ + dv[0] = *(cl->buf + offset + s + 0); \ + d = (int)v; \ + s += 1; \ } \ msg._member = _ecore_ipc_ddlt_int(d, cl->prev.i._member, md); @@ -1186,144 +1187,144 @@ _ecore_ipc_event_client_data(void *data __UNUSED__, int ev_type __UNUSED__, void if (!eina_list_data_find(servers, ecore_con_server_data_get(ecore_con_client_server_get(e->client)))) return ECORE_CALLBACK_RENEW; /* handling code here */ { - Ecore_Ipc_Client *cl; - Ecore_Ipc_Msg_Head msg; - int offset = 0; - unsigned char *buf; - - cl = ecore_con_client_data_get(e->client); - - if (!cl->buf) - { - cl->buf_size = e->size; - cl->buf = e->data; - e->data = NULL; /* take it out of the old event */ - } - else - { - buf = realloc(cl->buf, cl->buf_size + e->size); - if (!buf) - { - free(cl->buf); - cl->buf = 0; - cl->buf_size = 0; - return ECORE_CALLBACK_CANCEL; - } - cl->buf = buf; - memcpy(cl->buf + cl->buf_size, e->data, e->size); - cl->buf_size += e->size; - } - /* examine header */ - redo: - if ((cl->buf_size - offset) >= (int)sizeof(int)) - { - int s, md, d = 0, head; - unsigned char *dd; - - dd = (unsigned char *)&head; - dd[0] = *(cl->buf + offset + 0); - dd[1] = *(cl->buf + offset + 1); - dd[2] = *(cl->buf + offset + 2); - dd[3] = *(cl->buf + offset + 3); - head = ntohl(head); - dd = (unsigned char *)&d; - s = 4; - CLSZ(0); - CLSZ(1); - CLSZ(2); - CLSZ(3); - CLSZ(4); - CLSZ(5); - if ((cl->buf_size - offset) < s) - { - if (offset > 0) goto scroll; - return ECORE_CALLBACK_CANCEL; - } - - s = 4; - CLDEC(0, major); - CLDEC(1, minor); - CLDEC(2, ref); - CLDEC(3, ref_to); - CLDEC(4, response); - CLDEC(5, size); - if (msg.size < 0) msg.size = 0; - /* there is enough data in the buffer for a full message */ - if ((cl->buf_size - offset) >= (s + msg.size)) - { - Ecore_Ipc_Event_Client_Data *e2; - Ecore_Ipc_Server *svr; - int max, max2; - - buf = NULL; - svr = ecore_con_server_data_get(ecore_con_client_server_get(cl->client)); - max = svr->max_buf_size; - max2 = cl->max_buf_size; - if ((max >= 0) && (max2 >= 0)) - { - if (max2 < max) max = max2; - } - else - { - if (max < 0) max = max2; - } - if ((max < 0) || (msg.size <= max)) - { - if (msg.size > 0) - { - buf = malloc(msg.size); - if (!buf) return ECORE_CALLBACK_CANCEL; - memcpy(buf, cl->buf + offset + s, msg.size); - } - if (!cl->delete_me) - { - e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Data)); - if (e2) - { - cl->event_count++; - e2->client = cl; - e2->major = msg.major; - e2->minor = msg.minor; - e2->ref = msg.ref; - e2->ref_to = msg.ref_to; - e2->response = msg.response; - e2->size = msg.size; - e2->data = buf; - ecore_event_add(ECORE_IPC_EVENT_CLIENT_DATA, e2, - _ecore_ipc_event_client_data_free, - NULL); - } - } - } - cl->prev.i = msg; - offset += (s + msg.size); - if (cl->buf_size == offset) - { - free(cl->buf); - cl->buf = NULL; - cl->buf_size = 0; - return ECORE_CALLBACK_CANCEL; - } - goto redo; - } - else goto scroll; - } - else - { - scroll: - buf = malloc(cl->buf_size - offset); - if (!buf) - { - free(cl->buf); - cl->buf = NULL; - cl->buf_size = 0; - return ECORE_CALLBACK_CANCEL; - } - memcpy(buf, cl->buf + offset, cl->buf_size - offset); - free(cl->buf); - cl->buf = buf; - cl->buf_size -= offset; - } + Ecore_Ipc_Client *cl; + Ecore_Ipc_Msg_Head msg; + int offset = 0; + unsigned char *buf; + + cl = ecore_con_client_data_get(e->client); + + if (!cl->buf) + { + cl->buf_size = e->size; + cl->buf = e->data; + e->data = NULL; /* take it out of the old event */ + } + else + { + buf = realloc(cl->buf, cl->buf_size + e->size); + if (!buf) + { + free(cl->buf); + cl->buf = 0; + cl->buf_size = 0; + return ECORE_CALLBACK_CANCEL; + } + cl->buf = buf; + memcpy(cl->buf + cl->buf_size, e->data, e->size); + cl->buf_size += e->size; + } + /* examine header */ + redo: + if ((cl->buf_size - offset) >= (int)sizeof(int)) + { + int s, md, d = 0, head; + unsigned char *dd; + + dd = (unsigned char *)&head; + dd[0] = *(cl->buf + offset + 0); + dd[1] = *(cl->buf + offset + 1); + dd[2] = *(cl->buf + offset + 2); + dd[3] = *(cl->buf + offset + 3); + head = ntohl(head); + dd = (unsigned char *)&d; + s = 4; + CLSZ(0); + CLSZ(1); + CLSZ(2); + CLSZ(3); + CLSZ(4); + CLSZ(5); + if ((cl->buf_size - offset) < s) + { + if (offset > 0) goto scroll; + return ECORE_CALLBACK_CANCEL; + } + + s = 4; + CLDEC(0, major); + CLDEC(1, minor); + CLDEC(2, ref); + CLDEC(3, ref_to); + CLDEC(4, response); + CLDEC(5, size); + if (msg.size < 0) msg.size = 0; + /* there is enough data in the buffer for a full message */ + if ((cl->buf_size - offset) >= (s + msg.size)) + { + Ecore_Ipc_Event_Client_Data *e2; + Ecore_Ipc_Server *svr; + int max, max2; + + buf = NULL; + svr = ecore_con_server_data_get(ecore_con_client_server_get(cl->client)); + max = svr->max_buf_size; + max2 = cl->max_buf_size; + if ((max >= 0) && (max2 >= 0)) + { + if (max2 < max) max = max2; + } + else + { + if (max < 0) max = max2; + } + if ((max < 0) || (msg.size <= max)) + { + if (msg.size > 0) + { + buf = malloc(msg.size); + if (!buf) return ECORE_CALLBACK_CANCEL; + memcpy(buf, cl->buf + offset + s, msg.size); + } + if (!cl->delete_me) + { + e2 = calloc(1, sizeof(Ecore_Ipc_Event_Client_Data)); + if (e2) + { + cl->event_count++; + e2->client = cl; + e2->major = msg.major; + e2->minor = msg.minor; + e2->ref = msg.ref; + e2->ref_to = msg.ref_to; + e2->response = msg.response; + e2->size = msg.size; + e2->data = buf; + ecore_event_add(ECORE_IPC_EVENT_CLIENT_DATA, e2, + _ecore_ipc_event_client_data_free, + NULL); + } + } + } + cl->prev.i = msg; + offset += (s + msg.size); + if (cl->buf_size == offset) + { + free(cl->buf); + cl->buf = NULL; + cl->buf_size = 0; + return ECORE_CALLBACK_CANCEL; + } + goto redo; + } + else goto scroll; + } + else + { + scroll: + buf = malloc(cl->buf_size - offset); + if (!buf) + { + free(cl->buf); + cl->buf = NULL; + cl->buf_size = 0; + return ECORE_CALLBACK_CANCEL; + } + memcpy(buf, cl->buf + offset, cl->buf_size - offset); + free(cl->buf); + cl->buf = buf; + cl->buf_size -= offset; + } } return ECORE_CALLBACK_CANCEL; } @@ -1338,34 +1339,34 @@ _ecore_ipc_event_client_data(void *data __UNUSED__, int ev_type __UNUSED__, void md = ((head >> (4 * _n)) & 0xf); \ if (md >= DLT_SET) \ { \ - unsigned int v; \ - unsigned char *dv; \ - dv = (unsigned char *)&v; \ - dv[0] = *(svr->buf + offset + s + 0); \ - dv[1] = *(svr->buf + offset + s + 1); \ - dv[2] = *(svr->buf + offset + s + 2); \ - dv[3] = *(svr->buf + offset + s + 3); \ - d = (int)ntohl(v); \ - s += 4; \ + unsigned int v; \ + unsigned char *dv; \ + dv = (unsigned char *)&v; \ + dv[0] = *(svr->buf + offset + s + 0); \ + dv[1] = *(svr->buf + offset + s + 1); \ + dv[2] = *(svr->buf + offset + s + 2); \ + dv[3] = *(svr->buf + offset + s + 3); \ + d = (int)ntohl(v); \ + s += 4; \ } \ else if (md >= DLT_ADD16) \ { \ - unsigned short v; \ - unsigned char *dv; \ - dv = (unsigned char *)&v; \ - dv[0] = *(svr->buf + offset + s + 0); \ - dv[1] = *(svr->buf + offset + s + 1); \ - d = (int)ntohs(v); \ - s += 2; \ + unsigned short v; \ + unsigned char *dv; \ + dv = (unsigned char *)&v; \ + dv[0] = *(svr->buf + offset + s + 0); \ + dv[1] = *(svr->buf + offset + s + 1); \ + d = (int)ntohs(v); \ + s += 2; \ } \ else if (md >= DLT_ADD8) \ { \ - unsigned char v; \ - unsigned char *dv; \ - dv = (unsigned char *)&v; \ - dv[0] = *(svr->buf + offset + s + 0); \ - d = (int)v; \ - s += 1; \ + unsigned char v; \ + unsigned char *dv; \ + dv = (unsigned char *)&v; \ + dv[0] = *(svr->buf + offset + s + 0); \ + d = (int)v; \ + s += 1; \ } \ msg._member = _ecore_ipc_ddlt_int(d, svr->prev.i._member, md); @@ -1378,133 +1379,133 @@ _ecore_ipc_event_server_data(void *data __UNUSED__, int ev_type __UNUSED__, void if (!eina_list_data_find(servers, ecore_con_server_data_get(e->server))) return ECORE_CALLBACK_RENEW; /* handling code here */ { - Ecore_Ipc_Server *svr; - Ecore_Ipc_Msg_Head msg; - int offset = 0; - unsigned char *buf; - - svr = ecore_con_server_data_get(e->server); - - if (!svr->buf) - { - svr->buf_size = e->size; - svr->buf = e->data; - e->data = NULL; /* take it out of the old event */ - } - else - { - buf = realloc(svr->buf, svr->buf_size + e->size); - if (!buf) - { - free(svr->buf); - svr->buf = 0; - svr->buf_size = 0; - return ECORE_CALLBACK_CANCEL; - } - svr->buf = buf; - memcpy(svr->buf + svr->buf_size, e->data, e->size); - svr->buf_size += e->size; - } - /* examine header */ - redo: - if ((svr->buf_size - offset) >= (int)sizeof(int)) - { - int s, md, d = 0, head; - unsigned char *dd; - - dd = (unsigned char *)&head; - dd[0] = *(svr->buf + offset + 0); - dd[1] = *(svr->buf + offset + 1); - dd[2] = *(svr->buf + offset + 2); - dd[3] = *(svr->buf + offset + 3); - head = ntohl(head); - dd = (unsigned char *)&d; - s = 4; - SVSZ(0); - SVSZ(1); - SVSZ(2); - SVSZ(3); - SVSZ(4); - SVSZ(5); - if ((svr->buf_size - offset) < s) - { - if (offset > 0) goto scroll; - return ECORE_CALLBACK_CANCEL; - } - - s = 4; - SVDEC(0, major); - SVDEC(1, minor); - SVDEC(2, ref); - SVDEC(3, ref_to); - SVDEC(4, response); - SVDEC(5, size); - if (msg.size < 0) msg.size = 0; - /* there is enough data in the buffer for a full message */ - if ((svr->buf_size - offset) >= (s + msg.size)) - { - Ecore_Ipc_Event_Server_Data *e2; - int max; - - buf = NULL; - max = svr->max_buf_size; - if ((max < 0) || (msg.size <= max)) - { - if (msg.size > 0) - { - buf = malloc(msg.size); - if (!buf) return ECORE_CALLBACK_CANCEL; - memcpy(buf, svr->buf + offset + s, msg.size); - } - if (!svr->delete_me) - { - e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Data)); - if (e2) - { - svr->event_count++; - e2->server = svr; - e2->major = msg.major; - e2->minor = msg.minor; - e2->ref = msg.ref; - e2->ref_to = msg.ref_to; - e2->response = msg.response; - e2->size = msg.size; - e2->data = buf; - ecore_event_add(ECORE_IPC_EVENT_SERVER_DATA, e2, - _ecore_ipc_event_server_data_free, - NULL); - } - } - } - svr->prev.i = msg; - offset += (s + msg.size); - if (svr->buf_size == offset) - { - free(svr->buf); - svr->buf = NULL; - svr->buf_size = 0; - return ECORE_CALLBACK_CANCEL; - } - goto redo; - } - else goto scroll; - } - else - { - scroll: - buf = malloc(svr->buf_size - offset); - if (!buf) - { - free(svr->buf); - svr->buf = NULL; - svr->buf_size = 0; - return ECORE_CALLBACK_CANCEL; - } - memcpy(buf, svr->buf + offset, svr->buf_size - offset); - free(svr->buf); - svr->buf = buf; - svr->buf_size -= offset; - } + Ecore_Ipc_Server *svr; + Ecore_Ipc_Msg_Head msg; + int offset = 0; + unsigned char *buf; + + svr = ecore_con_server_data_get(e->server); + + if (!svr->buf) + { + svr->buf_size = e->size; + svr->buf = e->data; + e->data = NULL; /* take it out of the old event */ + } + else + { + buf = realloc(svr->buf, svr->buf_size + e->size); + if (!buf) + { + free(svr->buf); + svr->buf = 0; + svr->buf_size = 0; + return ECORE_CALLBACK_CANCEL; + } + svr->buf = buf; + memcpy(svr->buf + svr->buf_size, e->data, e->size); + svr->buf_size += e->size; + } + /* examine header */ + redo: + if ((svr->buf_size - offset) >= (int)sizeof(int)) + { + int s, md, d = 0, head; + unsigned char *dd; + + dd = (unsigned char *)&head; + dd[0] = *(svr->buf + offset + 0); + dd[1] = *(svr->buf + offset + 1); + dd[2] = *(svr->buf + offset + 2); + dd[3] = *(svr->buf + offset + 3); + head = ntohl(head); + dd = (unsigned char *)&d; + s = 4; + SVSZ(0); + SVSZ(1); + SVSZ(2); + SVSZ(3); + SVSZ(4); + SVSZ(5); + if ((svr->buf_size - offset) < s) + { + if (offset > 0) goto scroll; + return ECORE_CALLBACK_CANCEL; + } + + s = 4; + SVDEC(0, major); + SVDEC(1, minor); + SVDEC(2, ref); + SVDEC(3, ref_to); + SVDEC(4, response); + SVDEC(5, size); + if (msg.size < 0) msg.size = 0; + /* there is enough data in the buffer for a full message */ + if ((svr->buf_size - offset) >= (s + msg.size)) + { + Ecore_Ipc_Event_Server_Data *e2; + int max; + + buf = NULL; + max = svr->max_buf_size; + if ((max < 0) || (msg.size <= max)) + { + if (msg.size > 0) + { + buf = malloc(msg.size); + if (!buf) return ECORE_CALLBACK_CANCEL; + memcpy(buf, svr->buf + offset + s, msg.size); + } + if (!svr->delete_me) + { + e2 = calloc(1, sizeof(Ecore_Ipc_Event_Server_Data)); + if (e2) + { + svr->event_count++; + e2->server = svr; + e2->major = msg.major; + e2->minor = msg.minor; + e2->ref = msg.ref; + e2->ref_to = msg.ref_to; + e2->response = msg.response; + e2->size = msg.size; + e2->data = buf; + ecore_event_add(ECORE_IPC_EVENT_SERVER_DATA, e2, + _ecore_ipc_event_server_data_free, + NULL); + } + } + } + svr->prev.i = msg; + offset += (s + msg.size); + if (svr->buf_size == offset) + { + free(svr->buf); + svr->buf = NULL; + svr->buf_size = 0; + return ECORE_CALLBACK_CANCEL; + } + goto redo; + } + else goto scroll; + } + else + { + scroll: + buf = malloc(svr->buf_size - offset); + if (!buf) + { + free(svr->buf); + svr->buf = NULL; + svr->buf_size = 0; + return ECORE_CALLBACK_CANCEL; + } + memcpy(buf, svr->buf + offset, svr->buf_size - offset); + free(svr->buf); + svr->buf = buf; + svr->buf_size -= offset; + } } return ECORE_CALLBACK_CANCEL; } diff --git a/src/lib/ecore_sdl/Ecore_Sdl.h b/src/lib/ecore_sdl/Ecore_Sdl.h index 27257f5..317b0fc 100644 --- a/src/lib/ecore_sdl/Ecore_Sdl.h +++ b/src/lib/ecore_sdl/Ecore_Sdl.h @@ -50,63 +50,63 @@ EAPI extern int ECORE_SDL_EVENT_EXPOSE; typedef struct _Ecore_Sdl_Event_Key_Down Ecore_Sdl_Event_Key_Down; struct _Ecore_Sdl_Event_Key_Down /** SDL Key Down event */ { - const char *keyname; /**< The name of the key that was pressed */ - const char *keycompose; /**< The UTF-8 string conversion if any */ - unsigned int time; + const char *keyname; /**< The name of the key that was pressed */ + const char *keycompose; /**< The UTF-8 string conversion if any */ + unsigned int time; }; typedef struct _Ecore_Sdl_Event_Key_Up Ecore_Sdl_Event_Key_Up; struct _Ecore_Sdl_Event_Key_Up /** SDL Key Up event */ { - const char *keyname; /**< The name of the key that was released */ - const char *keycompose; /**< The UTF-8 string conversion if any */ - unsigned int time; + const char *keyname; /**< The name of the key that was released */ + const char *keycompose; /**< The UTF-8 string conversion if any */ + unsigned int time; }; typedef struct _Ecore_Sdl_Event_Mouse_Button_Down Ecore_Sdl_Event_Mouse_Button_Down; struct _Ecore_Sdl_Event_Mouse_Button_Down /** SDL Mouse Down event */ { - int button; /**< Mouse button that was pressed (1 - 32) */ - int x; /**< Mouse co-ordinates when mouse button was pressed */ - int y; /**< Mouse co-ordinates when mouse button was pressed */ - int double_click : 1; /**< Set if click was a double click */ - int triple_click : 1; /**< Set if click was a triple click */ - unsigned int time; + int button; /**< Mouse button that was pressed (1 - 32) */ + int x; /**< Mouse co-ordinates when mouse button was pressed */ + int y; /**< Mouse co-ordinates when mouse button was pressed */ + int double_click : 1; /**< Set if click was a double click */ + int triple_click : 1; /**< Set if click was a triple click */ + unsigned int time; }; typedef struct _Ecore_Sdl_Event_Mouse_Button_Up Ecore_Sdl_Event_Mouse_Button_Up; struct _Ecore_Sdl_Event_Mouse_Button_Up /** SDL Mouse Up event */ { - int button; /**< Mouse button that was released (1 - 32) */ - int x; /**< Mouse co-ordinates when mouse button was raised */ - int y; /**< Mouse co-ordinates when mouse button was raised */ - int double_click : 1; /**< Set if click was a double click */ - int triple_click : 1; /**< Set if click was a triple click */ - unsigned int time; + int button; /**< Mouse button that was released (1 - 32) */ + int x; /**< Mouse co-ordinates when mouse button was raised */ + int y; /**< Mouse co-ordinates when mouse button was raised */ + int double_click : 1; /**< Set if click was a double click */ + int triple_click : 1; /**< Set if click was a triple click */ + unsigned int time; }; typedef struct _Ecore_Sdl_Event_Mouse_Move Ecore_Sdl_Event_Mouse_Move; struct _Ecore_Sdl_Event_Mouse_Move /** SDL Mouse Move event */ { - int x; /**< Mouse co-ordinates where the mouse cursor moved to */ - int y; /**< Mouse co-ordinates where the mouse cursor moved to */ - unsigned int time; + int x; /**< Mouse co-ordinates where the mouse cursor moved to */ + int y; /**< Mouse co-ordinates where the mouse cursor moved to */ + unsigned int time; }; typedef struct _Ecore_Sdl_Event_Mouse_Wheel Ecore_Sdl_Event_Mouse_Wheel; struct _Ecore_Sdl_Event_Mouse_Wheel /** SDL Mouse Wheel event */ { - int x,y; - int direction; /* 0 = vertical, 1 = horizontal */ - int wheel; /* value 1 (left/up), -1 (right/down) */ - unsigned int time; + int x,y; + int direction; /* 0 = vertical, 1 = horizontal */ + int wheel; /* value 1 (left/up), -1 (right/down) */ + unsigned int time; }; typedef struct _Ecore_Sdl_Event_Video_Resize Ecore_Sdl_Event_Video_Resize; struct _Ecore_Sdl_Event_Video_Resize { - int w; - int h; + int w; + int h; }; EAPI int ecore_sdl_init(const char *name); diff --git a/src/lib/ecore_sdl/ecore_sdl.c b/src/lib/ecore_sdl/ecore_sdl.c index 766bf30..89984aa 100644 --- a/src/lib/ecore_sdl/ecore_sdl.c +++ b/src/lib/ecore_sdl/ecore_sdl.c @@ -34,17 +34,17 @@ static Eina_Rbtree *repeat = NULL; static Eina_Rbtree_Direction _ecore_sdl_pressed_key(const Ecore_SDL_Pressed *left, - const Ecore_SDL_Pressed *right, - __UNUSED__ void *data) + const Ecore_SDL_Pressed *right, + __UNUSED__ void *data) { return left->key < right->key ? EINA_RBTREE_LEFT : EINA_RBTREE_RIGHT; } static int _ecore_sdl_pressed_node(const Ecore_SDL_Pressed *node, - const SDLKey *key, - __UNUSED__ int length, - __UNUSED__ void *data) + const SDLKey *key, + __UNUSED__ int length, + __UNUSED__ void *data) { return node->key - *key; } @@ -67,7 +67,8 @@ ecore_sdl_init(const char *name __UNUSED__) { if(++_ecore_sdl_init_count != 1) return _ecore_sdl_init_count; - _ecore_sdl_log_dom = eina_log_domain_register("EcoreSdl", ECORE_SDL_DEFAULT_LOG_COLOR); + _ecore_sdl_log_dom = eina_log_domain_register + ("ecore_sdl", ECORE_SDL_DEFAULT_LOG_COLOR); if(_ecore_sdl_log_dom < 0) { EINA_LOG_ERR("Impossible to create a log domain for the Ecore SDL module."); @@ -139,10 +140,10 @@ _ecore_sdl_event_key(SDL_Event *event, double time) for (i = 0; i < sizeof(keystable) / sizeof(struct _ecore_sdl_keys_s); ++i) if (keystable[i].code == event->key.keysym.sym) { - ev->keyname = keystable[i].name; - ev->string = keystable[i].compose; + ev->keyname = keystable[i].name; + ev->string = keystable[i].compose; - return ev; + return ev; } free(ev); @@ -162,18 +163,18 @@ ecore_sdl_feed_events(void) { case SDL_MOUSEMOTION: { - Ecore_Event_Mouse_Move *ev; + Ecore_Event_Mouse_Move *ev; - ev = malloc(sizeof(Ecore_Event_Mouse_Move)); - if (!ev) return ; + ev = malloc(sizeof(Ecore_Event_Mouse_Move)); + if (!ev) return ; - ev->timestamp = time; - ev->window = 0; - ev->modifiers = 0; /* FIXME: keep modifier around. */ + ev->timestamp = time; + ev->window = 0; + ev->modifiers = 0; /* FIXME: keep modifier around. */ ev->x = event.motion.x; ev->y = event.motion.y; - ev->root.x = ev->x; - ev->root.y = ev->y; + ev->root.x = ev->x; + ev->root.y = ev->y; ecore_event_add(ECORE_EVENT_MOUSE_MOVE, ev, NULL, NULL); break; @@ -186,11 +187,11 @@ ecore_sdl_feed_events(void) Ecore_Event_Mouse_Wheel *ev; ev = malloc(sizeof(Ecore_Event_Mouse_Wheel)); - if (!ev) return ; + if (!ev) return ; - ev->timestamp = time; - ev->window = 0; - ev->modifiers = 0; /* FIXME: keep modifier around. */ + ev->timestamp = time; + ev->window = 0; + ev->modifiers = 0; /* FIXME: keep modifier around. */ ev->direction = 0; ev->z = event.button.button == SDL_BUTTON_WHEELDOWN ? -1 : 1; @@ -201,11 +202,11 @@ ecore_sdl_feed_events(void) Ecore_Event_Mouse_Button *ev; ev = malloc(sizeof(Ecore_Event_Mouse_Button)); - if (!ev) return ; + if (!ev) return ; - ev->timestamp = time; - ev->window = 0; - ev->modifiers = 0; /* FIXME: keep modifier around. */ + ev->timestamp = time; + ev->window = 0; + ev->modifiers = 0; /* FIXME: keep modifier around. */ ev->buttons = event.button.button; ev->double_click = 0; ev->triple_click = 0; @@ -219,10 +220,10 @@ ecore_sdl_feed_events(void) Ecore_Event_Mouse_Button *ev; ev = malloc(sizeof(Ecore_Event_Mouse_Button)); - if (!ev) return ; - ev->timestamp = time; - ev->window = 0; - ev->modifiers = 0; /* FIXME: keep modifier around. */ + if (!ev) return ; + ev->timestamp = time; + ev->window = 0; + ev->modifiers = 0; /* FIXME: keep modifier around. */ ev->buttons = event.button.button; ev->double_click = 0; ev->triple_click = 0; @@ -250,48 +251,48 @@ ecore_sdl_feed_events(void) case SDL_KEYDOWN: { - Ecore_SDL_Pressed *entry; + Ecore_SDL_Pressed *entry; Ecore_Event_Key *ev; - entry = (Ecore_SDL_Pressed*) eina_rbtree_inline_lookup(repeat, &event.key.keysym.sym, sizeof (event.key.keysym.sym), - EINA_RBTREE_CMP_KEY_CB(_ecore_sdl_pressed_node), NULL); - if (entry) - { - ev = _ecore_sdl_event_key(&event, time); - if (ev) ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL); - } + entry = (Ecore_SDL_Pressed*) eina_rbtree_inline_lookup(repeat, &event.key.keysym.sym, sizeof (event.key.keysym.sym), + EINA_RBTREE_CMP_KEY_CB(_ecore_sdl_pressed_node), NULL); + if (entry) + { + ev = _ecore_sdl_event_key(&event, time); + if (ev) ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL); + } - ev = _ecore_sdl_event_key(&event, time); - if (ev) ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL); + ev = _ecore_sdl_event_key(&event, time); + if (ev) ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL); - if (!entry) - { - entry = malloc(sizeof (Ecore_SDL_Pressed)); - if (!entry) break; + if (!entry) + { + entry = malloc(sizeof (Ecore_SDL_Pressed)); + if (!entry) break; - entry->key = event.key.keysym.sym; + entry->key = event.key.keysym.sym; - repeat = eina_rbtree_inline_insert(repeat, EINA_RBTREE_GET(entry), - EINA_RBTREE_CMP_NODE_CB(_ecore_sdl_pressed_key), NULL); - } + repeat = eina_rbtree_inline_insert(repeat, EINA_RBTREE_GET(entry), + EINA_RBTREE_CMP_NODE_CB(_ecore_sdl_pressed_key), NULL); + } break; } case SDL_KEYUP: { Ecore_Event_Key *ev; - Ecore_SDL_Pressed *entry; - - entry = (Ecore_SDL_Pressed*) eina_rbtree_inline_lookup(repeat, &event.key.keysym.sym, sizeof (event.key.keysym.sym), - EINA_RBTREE_CMP_KEY_CB(_ecore_sdl_pressed_node), NULL); - if (entry) - { - repeat = eina_rbtree_inline_remove(repeat, EINA_RBTREE_GET(entry), - EINA_RBTREE_CMP_NODE_CB(_ecore_sdl_pressed_key), NULL); - free(entry); - } - - ev = _ecore_sdl_event_key(&event, time); - if (ev) ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL); + Ecore_SDL_Pressed *entry; + + entry = (Ecore_SDL_Pressed*) eina_rbtree_inline_lookup(repeat, &event.key.keysym.sym, sizeof (event.key.keysym.sym), + EINA_RBTREE_CMP_KEY_CB(_ecore_sdl_pressed_node), NULL); + if (entry) + { + repeat = eina_rbtree_inline_remove(repeat, EINA_RBTREE_GET(entry), + EINA_RBTREE_CMP_NODE_CB(_ecore_sdl_pressed_key), NULL); + free(entry); + } + + ev = _ecore_sdl_event_key(&event, time); + if (ev) ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL); break; } case SDL_ACTIVEEVENT: diff --git a/src/lib/ecore_win32/Ecore_Win32.h b/src/lib/ecore_win32/Ecore_Win32.h index 090dff5..63e2d87 100644 --- a/src/lib/ecore_win32/Ecore_Win32.h +++ b/src/lib/ecore_win32/Ecore_Win32.h @@ -1,6 +1,17 @@ #ifndef __ECORE_WIN32_H__ #define __ECORE_WIN32_H__ +/* + * DO NOT USE THIS HEADER. IT IS WORK IN PROGRESS. IT IS NOT FINAL AND + * THE API MAY CHANGE. + */ + +#ifndef ECORE_WIN32_WIP_POZEFLKSD +# warning "You are using a work in progress API. This API is not stable" +# warning "and is subject to change. You use this at your own risk." +#endif + +#include #ifdef EAPI # undef EAPI @@ -33,210 +44,322 @@ extern "C" { #endif +/** + * @defgroup Ecore_Win32_Group Ecore_Win32 library + * + * @{ + */ -typedef struct _Ecore_Win32_Window Ecore_Win32_Window; -typedef void Ecore_Win32_Cursor; - -/* Window state */ - +/** + * @typedef Ecore_Win32_Window_State + * State of a window. + */ typedef enum { - /* The window is iconified. */ - ECORE_WIN32_WINDOW_STATE_ICONIFIED, - /* The window is a modal dialog box. */ - ECORE_WIN32_WINDOW_STATE_MODAL, - /* The window manager should keep the window's position fixed - * even if the virtual desktop scrolls. */ - ECORE_WIN32_WINDOW_STATE_STICKY, - /* The window has the maximum vertical size. */ - ECORE_WIN32_WINDOW_STATE_MAXIMIZED_VERT, - /* The window has the maximum horizontal size. */ - ECORE_WIN32_WINDOW_STATE_MAXIMIZED_HORZ, - /* The window has the maximum horizontal and vertical size. */ - ECORE_WIN32_WINDOW_STATE_MAXIMIZED, - /* The window is shaded. */ - ECORE_WIN32_WINDOW_STATE_SHADED, - /* The window is invisible (i.e. minimized/iconified) */ - ECORE_WIN32_WINDOW_STATE_HIDDEN, - /* The window should fill the entire screen and have no - * window border/decorations */ - ECORE_WIN32_WINDOW_STATE_FULLSCREEN, - /* The following are not documented because they are not - * intended for use in applications. */ - ECORE_WIN32_WINDOW_STATE_ABOVE, - ECORE_WIN32_WINDOW_STATE_BELOW, - /* FIXME: Documentation */ - ECORE_WIN32_WINDOW_STATE_DEMANDS_ATTENTION, - /* Unknown state */ - ECORE_WIN32_WINDOW_STATE_UNKNOWN + ECORE_WIN32_WINDOW_STATE_ICONIFIED, /**< iconified window */ + ECORE_WIN32_WINDOW_STATE_MODAL, /**< modal dialog box */ + ECORE_WIN32_WINDOW_STATE_STICKY, /**< sticky window */ + ECORE_WIN32_WINDOW_STATE_MAXIMIZED_VERT, /**< maximum vertical sized window */ + ECORE_WIN32_WINDOW_STATE_MAXIMIZED_HORZ, /**< maximum horizontal sized window */ + ECORE_WIN32_WINDOW_STATE_MAXIMIZED, /**< maximum sized window */ + ECORE_WIN32_WINDOW_STATE_SHADED, /**< shaded window */ + ECORE_WIN32_WINDOW_STATE_HIDDEN, /**< hidden (minimized or iconified) window */ + ECORE_WIN32_WINDOW_STATE_FULLSCREEN, /**< fullscreen window */ + ECORE_WIN32_WINDOW_STATE_ABOVE, /**< above window */ + ECORE_WIN32_WINDOW_STATE_BELOW, /**< below window */ + ECORE_WIN32_WINDOW_STATE_DEMANDS_ATTENTION, /**< To document */ + ECORE_WIN32_WINDOW_STATE_UNKNOWN /**< Unknown state */ } Ecore_Win32_Window_State; -/* Window type */ - +/** + * @typedef Ecore_Win32_Window_Type + * Type of a window. + */ typedef enum { - /* Desktop feature*/ - ECORE_WIN32_WINDOW_TYPE_DESKTOP, - /* Dock window (should be on top of other windows */ - ECORE_WIN32_WINDOW_TYPE_DOCK, - /* Toolbar window */ - ECORE_WIN32_WINDOW_TYPE_TOOLBAR, - /* Menu window */ - ECORE_WIN32_WINDOW_TYPE_MENU, - /* Small persistent utility window, such as a palette or toolbox */ - ECORE_WIN32_WINDOW_TYPE_UTILITY, - /* Splash screen window displayed as an application is starting up */ - ECORE_WIN32_WINDOW_TYPE_SPLASH, - /* Dialog window */ - ECORE_WIN32_WINDOW_TYPE_DIALOG, - /* Normal top-level window */ - ECORE_WIN32_WINDOW_TYPE_NORMAL, - /* Unknown type */ - ECORE_WIN32_WINDOW_TYPE_UNKNOWN + ECORE_WIN32_WINDOW_TYPE_DESKTOP, /**< Desktop feature */ + ECORE_WIN32_WINDOW_TYPE_DOCK, /**< Dock window (should be on top of other windows) */ + ECORE_WIN32_WINDOW_TYPE_TOOLBAR, /**< Toolbar window */ + ECORE_WIN32_WINDOW_TYPE_MENU, /**< Menu window */ + ECORE_WIN32_WINDOW_TYPE_UTILITY, /**< Small persistent utility window, such as a palette or toolbox */ + ECORE_WIN32_WINDOW_TYPE_SPLASH, /**< Splash screen window displayed as an application is starting up */ + ECORE_WIN32_WINDOW_TYPE_DIALOG, /**< Dialog window */ + ECORE_WIN32_WINDOW_TYPE_NORMAL, /**< Normal top-level window */ + ECORE_WIN32_WINDOW_TYPE_UNKNOWN /**< Unknown type */ } Ecore_Win32_Window_Type; -/*cursor shapes */ - +/** + * @typedef Ecore_Win32_Cursor_Shape + * Shape of a cursor. + */ typedef enum { - ECORE_WIN32_CURSOR_SHAPE_APP_STARTING, /* Standard arrow and small hourglass */ - ECORE_WIN32_CURSOR_SHAPE_ARROW, /* Standard arrow */ - ECORE_WIN32_CURSOR_SHAPE_CROSS, /* Crosshair */ - ECORE_WIN32_CURSOR_SHAPE_HAND, /* Hand */ - ECORE_WIN32_CURSOR_SHAPE_HELP, /* Arrow and question mark */ - ECORE_WIN32_CURSOR_SHAPE_I_BEAM, /* I-beam */ - ECORE_WIN32_CURSOR_SHAPE_NO, /* Slashed circle */ - ECORE_WIN32_CURSOR_SHAPE_SIZE_ALL, /* Four-pointed arrow pointing north, south, east, and west */ - ECORE_WIN32_CURSOR_SHAPE_SIZE_NESW, /* Double-pointed arrow pointing northeast and southwest */ - ECORE_WIN32_CURSOR_SHAPE_SIZE_NS, /* Double-pointed arrow pointing north and south */ - ECORE_WIN32_CURSOR_SHAPE_SIZE_NWSE, /* Double-pointed arrow pointing northwest and southeast */ - ECORE_WIN32_CURSOR_SHAPE_SIZE_WE, /* Double-pointed arrow pointing west and east */ - ECORE_WIN32_CURSOR_SHAPE_UP_ARROW, /* Vertical arrow */ - ECORE_WIN32_CURSOR_SHAPE_WAIT /* Hourglass */ + ECORE_WIN32_CURSOR_SHAPE_APP_STARTING, /**< Standard arrow and small hourglass */ + ECORE_WIN32_CURSOR_SHAPE_ARROW, /**< Standard arrow */ + ECORE_WIN32_CURSOR_SHAPE_CROSS, /**< Crosshair */ + ECORE_WIN32_CURSOR_SHAPE_HAND, /**< Hand */ + ECORE_WIN32_CURSOR_SHAPE_HELP, /**< Arrow and question mark */ + ECORE_WIN32_CURSOR_SHAPE_I_BEAM, /**< I-beam */ + ECORE_WIN32_CURSOR_SHAPE_NO, /**< Slashed circle */ + ECORE_WIN32_CURSOR_SHAPE_SIZE_ALL, /**< Four-pointed arrow pointing north, south, east, and west */ + ECORE_WIN32_CURSOR_SHAPE_SIZE_NESW, /**< Double-pointed arrow pointing northeast and southwest */ + ECORE_WIN32_CURSOR_SHAPE_SIZE_NS, /**< Double-pointed arrow pointing north and south */ + ECORE_WIN32_CURSOR_SHAPE_SIZE_NWSE, /**< Double-pointed arrow pointing northwest and southeast */ + ECORE_WIN32_CURSOR_SHAPE_SIZE_WE, /**< Double-pointed arrow pointing west and east */ + ECORE_WIN32_CURSOR_SHAPE_UP_ARROW, /**< Vertical arrow */ + ECORE_WIN32_CURSOR_SHAPE_WAIT /**< Hourglass */ } Ecore_Win32_Cursor_Shape; -/* Events */ +/** + * @typedef Ecore_Win32_DnD_State + * State of a DnD operation. + */ +typedef enum +{ + ECORE_WIN32_DND_EVENT_DRAG_ENTER = 1, /**< Drag enter */ + ECORE_WIN32_DND_EVENT_DRAG_OVER = 2, /**< Drag over */ + ECORE_WIN32_DND_EVENT_DRAG_LEAVE = 3, /**< Drag leave */ + ECORE_WIN32_DND_EVENT_DROP = 4 /**< Drop */ +} Ecore_Win32_DnD_State; + +/** + * @typedef Ecore_Win32_Window + * Abstract type for a window. + */ +typedef struct _Ecore_Win32_Window Ecore_Win32_Window; + +/** + * @typedef Ecore_Win32_Cursor + * Abstract type for a cursor. + */ +typedef void Ecore_Win32_Cursor; + +/** + * @typedef Ecore_Win32_Event_Mouse_In + * Event sent when the mouse enters the window. + */ typedef struct _Ecore_Win32_Event_Mouse_In Ecore_Win32_Event_Mouse_In; + +/** + * @typedef Ecore_Win32_Event_Mouse_Out + * Event sent when the mouse leaves the window. + */ typedef struct _Ecore_Win32_Event_Mouse_Out Ecore_Win32_Event_Mouse_Out; + +/** + * @typedef Ecore_Win32_Event_Window_Focus_In + * Event sent when the window gets the focus. + */ typedef struct _Ecore_Win32_Event_Window_Focus_In Ecore_Win32_Event_Window_Focus_In; + +/** + * @typedef Ecore_Win32_Event_Window_Focus_Out + * Event sent when the window looses the focus. + */ typedef struct _Ecore_Win32_Event_Window_Focus_Out Ecore_Win32_Event_Window_Focus_Out; + +/** + * @typedef Ecore_Win32_Event_Window_Damage + * Event sent when the window is damaged. + */ typedef struct _Ecore_Win32_Event_Window_Damage Ecore_Win32_Event_Window_Damage; + +/** + * @typedef Ecore_Win32_Event_Window_Create + * Event sent when the window is created. + */ typedef struct _Ecore_Win32_Event_Window_Create Ecore_Win32_Event_Window_Create; + +/** + * @typedef Ecore_Win32_Event_Window_Destroy + * Event sent when the window is destroyed. + */ typedef struct _Ecore_Win32_Event_Window_Destroy Ecore_Win32_Event_Window_Destroy; + +/** + * @typedef Ecore_Win32_Event_Window_Hide + * Event sent when the window is hidden. + */ typedef struct _Ecore_Win32_Event_Window_Hide Ecore_Win32_Event_Window_Hide; + +/** + * @typedef Ecore_Win32_Event_Window_Show + * Event sent when the window is shown. + */ typedef struct _Ecore_Win32_Event_Window_Show Ecore_Win32_Event_Window_Show; + +/** + * @typedef Ecore_Win32_Event_Window_Configure + * Event sent when the window is configured. + */ typedef struct _Ecore_Win32_Event_Window_Configure Ecore_Win32_Event_Window_Configure; + +/** + * @typedef Ecore_Win32_Event_Window_Resize + * Event sent when the window is resized. + */ typedef struct _Ecore_Win32_Event_Window_Resize Ecore_Win32_Event_Window_Resize; + +/** + * @typedef Ecore_Win32_Event_Window_Delete_Request + * Event sent when the window is deleted. + */ typedef struct _Ecore_Win32_Event_Window_Delete_Request Ecore_Win32_Event_Window_Delete_Request; +/** + * @struct _Ecore_Win32_Event_Mouse_In + * Event sent when the mouse enters the window. + */ struct _Ecore_Win32_Event_Mouse_In { - Ecore_Win32_Window *window; - int x; - int y; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + int x; /**< The x coordinate where the mouse leaved */ + int y; /**< The y coordinate where the mouse entered */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Mouse_Out + * Event sent when the mouse leaves the window. + */ struct _Ecore_Win32_Event_Mouse_Out { - Ecore_Win32_Window *window; - int x; - int y; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + int x; /**< The x coordinate where the mouse leaved */ + int y; /**< The y coordinate where the mouse leaved */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Focus_In + * Event sent when the window gets the focus. + */ struct _Ecore_Win32_Event_Window_Focus_In { - Ecore_Win32_Window *window; - long long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + long long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Focus_Out + * Event sent when the window looses the focus. + */ struct _Ecore_Win32_Event_Window_Focus_Out { - Ecore_Win32_Window *window; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Damage + * Event sent when the window is damaged. + */ struct _Ecore_Win32_Event_Window_Damage { - Ecore_Win32_Window *window; - int x; - int y; - int width; - int height; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + int x; /**< The x coordinate of the top left corner of the damaged region */ + int y; /**< The y coordinate of the top left corner of the damaged region */ + int width; /**< The width of the damaged region */ + int height; /**< The time the event occured */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Create + * Event sent when the window is created. + */ struct _Ecore_Win32_Event_Window_Create { - Ecore_Win32_Window *window; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Destroy + * Event sent when the window is destroyed. + */ struct _Ecore_Win32_Event_Window_Destroy { - Ecore_Win32_Window *window; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Hide + * Event sent when the window is hidden. + */ struct _Ecore_Win32_Event_Window_Hide { - Ecore_Win32_Window *window; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Show + * Event sent when the window is shown. + */ struct _Ecore_Win32_Event_Window_Show { - Ecore_Win32_Window *window; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Configure + * Event sent when the window is configured. + */ struct _Ecore_Win32_Event_Window_Configure { - Ecore_Win32_Window *window; + Ecore_Win32_Window *window; /**< The window that received the event */ Ecore_Win32_Window *abovewin; - int x; - int y; - int width; - int height; - long time; + int x; /**< The new x coordinate of the top left corner */ + int y; /**< The new y coordinate of the top left corner */ + int width; /**< The new width */ + int height; /**< The new height */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Resize + * Event sent when the window is resized. + */ struct _Ecore_Win32_Event_Window_Resize { - Ecore_Win32_Window *window; - int width; - int height; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + int width; /**< The new width */ + int height; /**< The new height */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_Win32_Event_Window_Delete_Request + * Event sent when the window is deleted. + */ struct _Ecore_Win32_Event_Window_Delete_Request { - Ecore_Win32_Window *window; - long time; + Ecore_Win32_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; -#define ECORE_WIN32_DND_EVENT_DRAG_ENTER 1 -#define ECORE_WIN32_DND_EVENT_DRAG_OVER 2 -#define ECORE_WIN32_DND_EVENT_DRAG_LEAVE 3 -#define ECORE_WIN32_DND_EVENT_DROP 4 - - +/** + * @typedef Ecore_Win32_Dnd_DropTarget_Callback + * Callback type for Drop operations. See ecore_win32_dnd_register_drop_target(). + */ typedef int (*Ecore_Win32_Dnd_DropTarget_Callback)(void *window, int event, int pt_x, int pt_y, void *data, int size); -EAPI extern int ECORE_WIN32_EVENT_MOUSE_IN; -EAPI extern int ECORE_WIN32_EVENT_MOUSE_OUT; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_FOCUS_IN; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_DAMAGE; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_CREATE; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_DESTROY; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_HIDE; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_SHOW; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_CONFIGURE; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_RESIZE; -EAPI extern int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST; +EAPI extern int ECORE_WIN32_EVENT_MOUSE_IN; /**< Ecore_Event for the #Ecore_Win32_Event_Mouse_In event */ +EAPI extern int ECORE_WIN32_EVENT_MOUSE_OUT; /**< Ecore_Event for the #Ecore_Win32_Event_Mouse_Out event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_FOCUS_IN; /**< Ecore_Event for the #Ecore_Win32_Event_Window_Focus_In event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT; /**< Ecore_Event for the #Ecore_Win32_Event_Window_Focus_Out event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_DAMAGE; /**< Ecore_Event for the #Ecore_Win32_Event_Damage event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_CREATE; /**< Ecore_Event for the #Ecore_Win32_Event_Create event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_DESTROY; /**< Ecore_Event for the #Ecore_Win32_Event_Destroy event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_HIDE; /**< Ecore_Event for the #Ecore_Win32_Event_Hide event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_SHOW; /**< Ecore_Event for the #Ecore_Win32_Event_Show event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_CONFIGURE; /**< Ecore_Event for the #Ecore_Win32_Event_Configure event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_RESIZE; /**< Ecore_Event for the #Ecore_Win32_Event_Resize event */ +EAPI extern int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST; /**< Ecore_Event for the #Ecore_Win32_Event_Window_Delete_Request event */ /* Core */ @@ -244,8 +367,9 @@ EAPI extern int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST; EAPI int ecore_win32_init(); EAPI int ecore_win32_shutdown(); EAPI int ecore_win32_screen_depth_get(); +EAPI void ecore_win32_double_click_time_set(double t); +EAPI double ecore_win32_double_click_time_get(void); EAPI long ecore_win32_current_time_get(void); -EAPI void ecore_win32_message_loop_begin (void); /* Window */ @@ -334,18 +458,18 @@ EAPI void ecore_win32_window_title_set(Ecore_Win32_Window *window, EAPI void ecore_win32_window_focus_set(Ecore_Win32_Window *window); EAPI void ecore_win32_window_iconified_set(Ecore_Win32_Window *window, - int on); + Eina_Bool on); EAPI void ecore_win32_window_borderless_set(Ecore_Win32_Window *window, - int on); + Eina_Bool on); EAPI void ecore_win32_window_fullscreen_set(Ecore_Win32_Window *window, - int on); + Eina_Bool on); -EAPI void ecore_win32_window_shape_set(Ecore_Win32_Window *window, - unsigned short width, - unsigned short height, - unsigned char *mask); +EINA_DEPRECATED EAPI void ecore_win32_window_shape_set(Ecore_Win32_Window *window, + unsigned short width, + unsigned short height, + unsigned char *mask); EAPI void ecore_win32_window_cursor_set(Ecore_Win32_Window *window, Ecore_Win32_Cursor *cursor); @@ -372,20 +496,24 @@ EAPI Ecore_Win32_Cursor *ecore_win32_cursor_new(const void *pixels_and, EAPI void ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor); -EAPI Ecore_Win32_Cursor *ecore_win32_cursor_shape_get(Ecore_Win32_Cursor_Shape shape); +EAPI Ecore_Win32_Cursor *ecore_win32_cursor_shaped_new(Ecore_Win32_Cursor_Shape shape); -EAPI int ecore_win32_cursor_size_get(void); +EAPI void ecore_win32_cursor_size_get(int *width, int *height); /* Drag and drop */ -EAPI int ecore_win32_dnd_init(); -EAPI int ecore_win32_dnd_shutdown(); -EAPI int ecore_win32_dnd_begin(const char *data, - int size); -EAPI int ecore_win32_dnd_register_drop_target(Ecore_Win32_Window *window, - Ecore_Win32_Dnd_DropTarget_Callback callback); -EAPI void ecore_win32_dnd_unregister_drop_target(Ecore_Win32_Window *window); +EAPI int ecore_win32_dnd_init(); +EAPI int ecore_win32_dnd_shutdown(); +EAPI Eina_Bool ecore_win32_dnd_begin(const char *data, + int size); +EAPI Eina_Bool ecore_win32_dnd_register_drop_target(Ecore_Win32_Window *window, + Ecore_Win32_Dnd_DropTarget_Callback callback); +EAPI void ecore_win32_dnd_unregister_drop_target(Ecore_Win32_Window *window); + +/** + * @} + */ #ifdef __cplusplus diff --git a/src/lib/ecore_win32/Makefile.am b/src/lib/ecore_win32/Makefile.am index 027313a..2f4ced9 100644 --- a/src/lib/ecore_win32/Makefile.am +++ b/src/lib/ecore_win32/Makefile.am @@ -6,7 +6,6 @@ AM_CPPFLAGS = \ -I$(top_builddir)/src/lib/ecore \ -I$(top_builddir)/src/lib/ecore_input \ @EFL_ECORE_WIN32_BUILD@ \ -@EVAS_CFLAGS@ \ @EINA_CFLAGS@ \ @WIN32_CPPFLAGS@ @@ -34,7 +33,6 @@ libecore_win32_la_LIBADD = \ @WIN32_LIBS@ \ $(top_builddir)/src/lib/ecore/libecore.la \ $(top_builddir)/src/lib/ecore_input/libecore_input.la \ -@EVAS_LIBS@ \ @EINA_LIBS@ libecore_win32_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ @release_info@ diff --git a/src/lib/ecore_win32/ecore_win32.c b/src/lib/ecore_win32/ecore_win32.c index fc3686a..0726234 100644 --- a/src/lib/ecore_win32/ecore_win32.c +++ b/src/lib/ecore_win32/ecore_win32.c @@ -17,6 +17,13 @@ #include "Ecore_Win32.h" #include "ecore_win32_private.h" +/*============================================================================* + * Local * + *============================================================================*/ + +/** + * @cond LOCAL + */ /* OLE IID for Drag'n Drop */ @@ -28,229 +35,8 @@ DEFINE_OLEGUID(IID_IDropSource, 0x00000121L, 0, 0); DEFINE_OLEGUID(IID_IDropTarget, 0x00000122L, 0, 0); DEFINE_OLEGUID(IID_IUnknown, 0x00000000L, 0, 0); - -/***** Global declarations *****/ - -HINSTANCE _ecore_win32_instance = NULL; -double _ecore_win32_double_click_time = 0.25; -long _ecore_win32_event_last_time = 0; -Ecore_Win32_Window *_ecore_win32_event_last_window = NULL; -int _ecore_win32_log_dom_global = -1; - -int ECORE_WIN32_EVENT_MOUSE_IN = 0; -int ECORE_WIN32_EVENT_MOUSE_OUT = 0; -int ECORE_WIN32_EVENT_WINDOW_FOCUS_IN = 0; -int ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT = 0; -int ECORE_WIN32_EVENT_WINDOW_DAMAGE = 0; -int ECORE_WIN32_EVENT_WINDOW_CREATE = 0; -int ECORE_WIN32_EVENT_WINDOW_DESTROY = 0; -int ECORE_WIN32_EVENT_WINDOW_SHOW = 0; -int ECORE_WIN32_EVENT_WINDOW_HIDE = 0; -int ECORE_WIN32_EVENT_WINDOW_CONFIGURE = 0; -int ECORE_WIN32_EVENT_WINDOW_RESIZE = 0; -int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = 0; - - -/***** Private declarations *****/ - static int _ecore_win32_init_count = 0; -LRESULT CALLBACK _ecore_win32_window_procedure(HWND window, - UINT message, - WPARAM window_param, - LPARAM data_param); - -static void _ecore_win32_error_print_cb(const Eina_Log_Domain *d, - Eina_Log_Level level, - const char *file, - const char *fnc, - int line, - const char *fmt, - void *data, - va_list args); - - -/***** API *****/ - - -int -ecore_win32_init() -{ - WNDCLASS wc; - - if (++_ecore_win32_init_count != 1) - return _ecore_win32_init_count; - - if (!eina_init()) - return --_ecore_win32_init_count; - - eina_log_print_cb_set(_ecore_win32_error_print_cb, NULL); - _ecore_win32_log_dom_global = eina_log_domain_register("ecore_win32", ECORE_WIN32_DEFAULT_LOG_COLOR); - if (_ecore_win32_log_dom_global < 0) - { - EINA_LOG_ERR("Ecore_Win32: Could not register log domain"); - goto shutdown_eina; - } - - if (!ecore_event_init()) - { - ERR("Ecore_Win32: Could not init ecore_event"); - goto unregister_log_domain; - } - - _ecore_win32_instance = GetModuleHandle(NULL); - if (!_ecore_win32_instance) - { - ERR("GetModuleHandle() failed"); - goto shutdown_ecore_event; - } - - memset (&wc, 0, sizeof (WNDCLASS)); - wc.style = CS_HREDRAW | CS_VREDRAW; - wc.lpfnWndProc = _ecore_win32_window_procedure; - wc.cbClsExtra = 0; - wc.cbWndExtra = 0; - wc.hInstance = _ecore_win32_instance; - wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); - wc.hCursor = LoadCursor (NULL, IDC_ARROW); - wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE); - wc.lpszMenuName = NULL; - wc.lpszClassName = ECORE_WIN32_WINDOW_CLASS; - - if(!RegisterClass(&wc)) - { - ERR("RegisterClass() failed"); - goto free_library; - } - - if (!ecore_win32_dnd_init()) - { - ERR("ecore_win32_dnd_init() failed"); - goto unregister_class; - } - - if (!ECORE_WIN32_EVENT_MOUSE_IN) - { - ECORE_WIN32_EVENT_MOUSE_IN = ecore_event_type_new(); - ECORE_WIN32_EVENT_MOUSE_OUT = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_FOCUS_IN = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_DAMAGE = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_CREATE = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_DESTROY = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_SHOW = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_HIDE = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_CONFIGURE = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_RESIZE = ecore_event_type_new(); - ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = ecore_event_type_new(); - } - - return _ecore_win32_init_count; - - unregister_class: - UnregisterClass(ECORE_WIN32_WINDOW_CLASS, _ecore_win32_instance); - free_library: - FreeLibrary(_ecore_win32_instance); - shutdown_ecore_event: - ecore_event_shutdown(); - unregister_log_domain: - eina_log_domain_unregister(_ecore_win32_log_dom_global); - shutdown_eina: - eina_shutdown(); - - return --_ecore_win32_init_count; -} - -int -ecore_win32_shutdown() -{ - if (--_ecore_win32_init_count != 0) - return _ecore_win32_init_count; - - ecore_win32_dnd_shutdown(); - - if (!UnregisterClass(ECORE_WIN32_WINDOW_CLASS, _ecore_win32_instance)) - INF("UnregisterClass() failed"); - - if (!FreeLibrary(_ecore_win32_instance)) - INF("FreeLibrary() failed"); - - _ecore_win32_instance = NULL; - - ecore_event_shutdown(); - eina_log_domain_unregister(_ecore_win32_log_dom_global); - _ecore_win32_log_dom_global = -1; - eina_shutdown(); - - return _ecore_win32_init_count; -} - -int -ecore_win32_screen_depth_get() -{ - HDC dc; - int depth; - - INF("getting screen depth"); - - dc = GetDC(NULL); - if (!dc) - { - ERR("GetDC() failed"); - return 0; - } - - depth = GetDeviceCaps(dc, BITSPIXEL); - if (!ReleaseDC(NULL, dc)) - { - ERR("ReleaseDC() failed (device context not released)"); - } - - return depth; -} - -/** - * Sets the timeout for a double and triple clicks to be flagged. - * - * This sets the time between clicks before the double_click flag is - * set in a button down event. If 3 clicks occur within double this - * time, the triple_click flag is also set. - * - * @param t The time in seconds - */ -void -ecore_win32_double_click_time_set(double t) -{ - if (t < 0.0) t = 0.0; - _ecore_win32_double_click_time = t; -} - -/** - * Retrieves the double and triple click flag timeout. - * - * See @ref ecore_win32_double_click_time_set for more information. - * - * @return The timeout for double clicks in seconds. - */ -double -ecore_win32_double_click_time_get(void) -{ - return _ecore_win32_double_click_time; -} - -/** - * Return the last event time - */ -long -ecore_win32_current_time_get(void) -{ - return _ecore_win32_event_last_time; -} - - -/***** Private functions definitions *****/ - - LRESULT CALLBACK _ecore_win32_window_procedure(HWND window, UINT message, @@ -363,7 +149,7 @@ _ecore_win32_window_procedure(HWND window, return 0; case WM_SHOWWINDOW: if ((data->data_param == SW_OTHERUNZOOM) || - (data->data_param == SW_OTHERUNZOOM)) + (data->data_param == SW_OTHERZOOM)) return 0; if (data->window_param) @@ -435,16 +221,259 @@ _ecore_win32_window_procedure(HWND window, } } -static void -_ecore_win32_error_print_cb(const Eina_Log_Domain *d __UNUSED__, - Eina_Log_Level level __UNUSED__, - const char *file __UNUSED__, - const char *fnc, - int line, - const char *fmt, - void *data __UNUSED__, - va_list args) +/** + * @endcond + */ + + +/*============================================================================* + * Global * + *============================================================================*/ + + +HINSTANCE _ecore_win32_instance = NULL; +double _ecore_win32_double_click_time = 0.25; +long _ecore_win32_event_last_time = 0; +Ecore_Win32_Window *_ecore_win32_event_last_window = NULL; +int _ecore_win32_log_dom_global = -1; + +int ECORE_WIN32_EVENT_MOUSE_IN = 0; +int ECORE_WIN32_EVENT_MOUSE_OUT = 0; +int ECORE_WIN32_EVENT_WINDOW_FOCUS_IN = 0; +int ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT = 0; +int ECORE_WIN32_EVENT_WINDOW_DAMAGE = 0; +int ECORE_WIN32_EVENT_WINDOW_CREATE = 0; +int ECORE_WIN32_EVENT_WINDOW_DESTROY = 0; +int ECORE_WIN32_EVENT_WINDOW_SHOW = 0; +int ECORE_WIN32_EVENT_WINDOW_HIDE = 0; +int ECORE_WIN32_EVENT_WINDOW_CONFIGURE = 0; +int ECORE_WIN32_EVENT_WINDOW_RESIZE = 0; +int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = 0; + +/*============================================================================* + * API * + *============================================================================*/ + +/** + * @addtogroup Ecore_Win32_Group Ecore_Win32 library + * + * Ecore_Win32 is a library that wraps Windows graphic functions + * and integrate them nicely into the Ecore main loop. + * + * @{ + */ + +/** + * @brief Initialize the Ecore_Win32 library. + * + * @return 1 or greater on success, 0 on error. + * + * This function sets up the Windows graphic system. It returns 0 on + * failure, otherwise it returns the number of times it has already been + * called. + * + * When Ecore_Win32 is not used anymore, call ecore_win32_shutdown() + * to shut down the Ecore_Win32 library. + */ +EAPI int +ecore_win32_init() +{ + WNDCLASS wc; + + if (++_ecore_win32_init_count != 1) + return _ecore_win32_init_count; + + if (!eina_init()) + return --_ecore_win32_init_count; + + _ecore_win32_log_dom_global = eina_log_domain_register + ("ecore_win32", ECORE_WIN32_DEFAULT_LOG_COLOR); + if (_ecore_win32_log_dom_global < 0) + { + EINA_LOG_ERR("Ecore_Win32: Could not register log domain"); + goto shutdown_eina; + } + + if (!ecore_event_init()) + { + ERR("Ecore_Win32: Could not init ecore_event"); + goto unregister_log_domain; + } + + _ecore_win32_instance = GetModuleHandle(NULL); + if (!_ecore_win32_instance) + { + ERR("GetModuleHandle() failed"); + goto shutdown_ecore_event; + } + + memset (&wc, 0, sizeof (WNDCLASS)); + wc.style = CS_HREDRAW | CS_VREDRAW; + wc.lpfnWndProc = _ecore_win32_window_procedure; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + wc.hInstance = _ecore_win32_instance; + wc.hIcon = LoadIcon (NULL, IDI_APPLICATION); + wc.hCursor = LoadCursor (NULL, IDC_ARROW); + wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE); + wc.lpszMenuName = NULL; + wc.lpszClassName = ECORE_WIN32_WINDOW_CLASS; + + if(!RegisterClass(&wc)) + { + ERR("RegisterClass() failed"); + goto free_library; + } + + if (!ecore_win32_dnd_init()) + { + ERR("ecore_win32_dnd_init() failed"); + goto unregister_class; + } + + if (!ECORE_WIN32_EVENT_MOUSE_IN) + { + ECORE_WIN32_EVENT_MOUSE_IN = ecore_event_type_new(); + ECORE_WIN32_EVENT_MOUSE_OUT = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_FOCUS_IN = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_FOCUS_OUT = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_DAMAGE = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_CREATE = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_DESTROY = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_SHOW = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_HIDE = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_CONFIGURE = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_RESIZE = ecore_event_type_new(); + ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = ecore_event_type_new(); + } + + return _ecore_win32_init_count; + + unregister_class: + UnregisterClass(ECORE_WIN32_WINDOW_CLASS, _ecore_win32_instance); + free_library: + FreeLibrary(_ecore_win32_instance); + shutdown_ecore_event: + ecore_event_shutdown(); + unregister_log_domain: + eina_log_domain_unregister(_ecore_win32_log_dom_global); + shutdown_eina: + eina_shutdown(); + + return --_ecore_win32_init_count; +} + +/** + * @brief Shut down the Ecore_Win32 library. + * + * @return 0 when the library is completely shut down, 1 or + * greater otherwise. + * + * This function shuts down the Ecore_Win32 library. It returns 0 when it has + * been called the same number of times than ecore_win32_init(). In that case + * it shuts down all the Windows graphic system. + */ +EAPI int +ecore_win32_shutdown() { - fprintf(stderr, "[%s:%d] ", fnc, line); - vfprintf(stderr, fmt, args); + if (--_ecore_win32_init_count != 0) + return _ecore_win32_init_count; + + ecore_win32_dnd_shutdown(); + + if (!UnregisterClass(ECORE_WIN32_WINDOW_CLASS, _ecore_win32_instance)) + INF("UnregisterClass() failed"); + + if (!FreeLibrary(_ecore_win32_instance)) + INF("FreeLibrary() failed"); + + _ecore_win32_instance = NULL; + + ecore_event_shutdown(); + eina_log_domain_unregister(_ecore_win32_log_dom_global); + _ecore_win32_log_dom_global = -1; + eina_shutdown(); + + return _ecore_win32_init_count; } + +/** + * @brief Retrieve the depth of the screen. + * + * @return The depth of the screen. + * + * This function returns the depth of the screen. If an error occurs, + * it returns 0. + */ +EAPI int +ecore_win32_screen_depth_get() +{ + HDC dc; + int depth; + + INF("getting screen depth"); + + dc = GetDC(NULL); + if (!dc) + { + ERR("GetDC() failed"); + return 0; + } + + depth = GetDeviceCaps(dc, BITSPIXEL); + if (!ReleaseDC(NULL, dc)) + { + ERR("ReleaseDC() failed (device context not released)"); + } + + return depth; +} + +/** + * @brief Sets the timeout for a double and triple clicks to be flagged. + * + * @param t The time in seconds. + * + * This function sets the time @p t between clicks before the + * double_click flag is set in a button down event. If 3 clicks occur + * within double this time, the triple_click flag is also set. + */ +EAPI void +ecore_win32_double_click_time_set(double t) +{ + if (t < 0.0) t = 0.0; + _ecore_win32_double_click_time = t; +} + +/** + * @brief Retrieve the double and triple click flag timeout. + * + * @return The timeout for double clicks in seconds. + * + * This function returns the double clicks in seconds. If + * ecore_win32_double_click_time_set() has not been called, the + * default value is returned. See ecore_win32_double_click_time_set() + * for more informations. + */ +EAPI double +ecore_win32_double_click_time_get(void) +{ + return _ecore_win32_double_click_time; +} + +/** + * @brief Return the last event time. + * + * @return The last envent time. + * + * This function returns the last event time. + */ +EAPI long +ecore_win32_current_time_get(void) +{ + return _ecore_win32_event_last_time; +} + +/** + * @} + */ diff --git a/src/lib/ecore_win32/ecore_win32_cursor.c b/src/lib/ecore_win32/ecore_win32_cursor.c index 08d2a30..e842259 100644 --- a/src/lib/ecore_win32/ecore_win32_cursor.c +++ b/src/lib/ecore_win32/ecore_win32_cursor.c @@ -11,10 +11,156 @@ #include "Ecore_Win32.h" #include "ecore_win32_private.h" +/*============================================================================* + * Local * + *============================================================================*/ -/***** API *****/ -Ecore_Win32_Cursor * +/*============================================================================* + * Global * + *============================================================================*/ + + +/*============================================================================* + * API * + *============================================================================*/ + +/** + * @addtogroup Ecore_Win32_Group Ecore_Win32 library + * + * @{ + */ + +/** + * @brief Create a new cursor. + * + * @param pixels_and The array of bytes containing the bit values for + * the AND mask of the cursor. + * @param pixels_xor The array of bytes containing the bit values for + * the XOR mask of the cursor. + * @param width The width of the cursor. + * @param height The height of the cursor. + * @param hot_x The horizontal position of the cursor's hot spot. + * @param hot_y The vertical position of the cursor's hot spot. + * @return A newly user-defined cursor. + * + * This function creates a new cursor of size @p width and @p + * height. They must be valid size. To determine the valid size of a + * cursor, useecore_win32_cursor_size_get(). @p pixels_and is an array + * of bytes (unsigned char) containing the bits of the cursor that + * will be visible. @p pixels_xor is similar but will allow the cursor + * to have a shape. Here is the truth table for the masks: + * + * + * + * + * + * + * + *
AND maskXOR maskDisplay
0 0 Black
0 1 White
1 0 Screen
1 1 Reverse screen
+ * + * @p hot_x and @p hot_y are the position of the hot spot of the + * cursor. If @p pixels_and or @p pixels_xor are @c NULL, the function + * returns NULL. If @p width or @p height does not match the valid + * size of a cursor, the function returns @c NULL. On success, the + * function creates a user-defined cursor, otherwise it returns + * @c NULL. + * + * Once the cursor is not used anymore, use ecore_win32_cursor_free() + * to free the ressources. + * + * Example of use: + * + * @code + * unsigned char pixels_and[] ={ + * 0xFF, 0xFC, 0x3F, 0xFF, // line 1 + * 0xFF, 0xC0, 0x1F, 0xFF, // line 2 + * 0xFF, 0x00, 0x3F, 0xFF, // line 3 + * 0xFE, 0x00, 0xFF, 0xFF, // line 4 + * + * 0xF7, 0x01, 0xFF, 0xFF, // line 5 + * 0xF0, 0x03, 0xFF, 0xFF, // line 6 + * 0xF0, 0x03, 0xFF, 0xFF, // line 7 + * 0xE0, 0x07, 0xFF, 0xFF, // line 8 + * + * 0xC0, 0x07, 0xFF, 0xFF, // line 9 + * 0xC0, 0x0F, 0xFF, 0xFF, // line 10 + * 0x80, 0x0F, 0xFF, 0xFF, // line 11 + * 0x80, 0x0F, 0xFF, 0xFF, // line 12 + * + * 0x80, 0x07, 0xFF, 0xFF, // line 13 + * 0x00, 0x07, 0xFF, 0xFF, // line 14 + * 0x00, 0x03, 0xFF, 0xFF, // line 15 + * 0x00, 0x00, 0xFF, 0xFF, // line 16 + * + * 0x00, 0x00, 0x7F, 0xFF, // line 17 + * 0x00, 0x00, 0x1F, 0xFF, // line 18 + * 0x00, 0x00, 0x0F, 0xFF, // line 19 + * 0x80, 0x00, 0x0F, 0xFF, // line 20 + * + * 0x80, 0x00, 0x07, 0xFF, // line 21 + * 0x80, 0x00, 0x07, 0xFF, // line 22 + * 0xC0, 0x00, 0x07, 0xFF, // line 23 + * 0xC0, 0x00, 0x0F, 0xFF, // line 24 + * + * 0xE0, 0x00, 0x0F, 0xFF, // line 25 + * 0xF0, 0x00, 0x1F, 0xFF, // line 26 + * 0xF0, 0x00, 0x1F, 0xFF, // line 27 + * 0xF8, 0x00, 0x3F, 0xFF, // line 28 + * + * 0xFE, 0x00, 0x7F, 0xFF, // line 29 + * 0xFF, 0x00, 0xFF, 0xFF, // line 30 + * 0xFF, 0xC3, 0xFF, 0xFF, // line 31 + * 0xFF, 0xFF, 0xFF, 0xFF // line 32 + * }; + * + * unsigned char pixels_xor[] = + * { + * 0x00, 0x00, 0x00, 0x00, // line 1 + * 0x00, 0x03, 0xC0, 0x00, // line 2 + * 0x00, 0x3F, 0x00, 0x00, // line 3 + * 0x00, 0xFE, 0x00, 0x00, // line 4 + * + * 0x0E, 0xFC, 0x00, 0x00, // line 5 + * 0x07, 0xF8, 0x00, 0x00, // line 6 + * 0x07, 0xF8, 0x00, 0x00, // line 7 + * 0x0F, 0xF0, 0x00, 0x00, // line 8 + * + * 0x1F, 0xF0, 0x00, 0x00, // line 9 + * 0x1F, 0xE0, 0x00, 0x00, // line 10 + * 0x3F, 0xE0, 0x00, 0x00, // line 11 + * 0x3F, 0xE0, 0x00, 0x00, // line 12 + * + * 0x3F, 0xF0, 0x00, 0x00, // line 13 + * 0x7F, 0xF0, 0x00, 0x00, // line 14 + * 0x7F, 0xF8, 0x00, 0x00, // line 15 + * 0x7F, 0xFC, 0x00, 0x00, // line 16 + * + * 0x7F, 0xFF, 0x00, 0x00, // line 17 + * 0x7F, 0xFF, 0x80, 0x00, // line 18 + * 0x7F, 0xFF, 0xE0, 0x00, // line 19 + * 0x3F, 0xFF, 0xE0, 0x00, // line 20 + * + * 0x3F, 0xC7, 0xF0, 0x00, // line 21 + * 0x3F, 0x83, 0xF0, 0x00, // line 22 + * 0x1F, 0x83, 0xF0, 0x00, // line 23 + * 0x1F, 0x83, 0xE0, 0x00, // line 24 + * + * 0x0F, 0xC7, 0xE0, 0x00, // line 25 + * 0x07, 0xFF, 0xC0, 0x00, // line 26 + * 0x07, 0xFF, 0xC0, 0x00, // line 27 + * 0x01, 0xFF, 0x80, 0x00, // line 28 + * + * 0x00, 0xFF, 0x00, 0x00, // line 29 + * 0x00, 0x3C, 0x00, 0x00, // line 30 + * 0x00, 0x00, 0x00, 0x00, // line 31 + * 0x00, 0x00, 0x00, 0x00 // line 32 + * }; + * + * Ecore_Win32_Cursor cursor = ecore_win32_cursor_new(pixels_and, pixels_xor, 32, 32, 19, 2); + * @endcode + */ +EAPI Ecore_Win32_Cursor * ecore_win32_cursor_new(const void *pixels_and, const void *pixels_xor, int width, @@ -28,6 +174,9 @@ ecore_win32_cursor_new(const void *pixels_and, INF("creating cursor"); + if (!pixels_and || !pixels_xor) + return NULL; + cursor_width = GetSystemMetrics(SM_CXCURSOR); cursor_height = GetSystemMetrics(SM_CYCURSOR); @@ -45,7 +194,15 @@ ecore_win32_cursor_new(const void *pixels_and, return cursor; } -void +/** + * @brief Free the given cursor. + * + * @param cursor The cursor to free. + * + * This function free @p cursor. @p cursor must have been obtained + * with ecore_win32_cursor_new(). + */ +EAPI void ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor) { INF("destroying cursor"); @@ -53,8 +210,18 @@ ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor) DestroyCursor(cursor); } -Ecore_Win32_Cursor * -ecore_win32_cursor_shape_get(Ecore_Win32_Cursor_Shape shape) +/** + * @brief Create a cursor from a Windows ressource. + * + * @param shape The pre-defined shape of the cursor. + * @return The new cursor. + * + * This funtion returns a pre-defined cursor with a specified + * @p shape. This cursor does not need to be freed, as it is loaded + * from an existing resource. + */ +EAPI Ecore_Win32_Cursor * +ecore_win32_cursor_shaped_new(Ecore_Win32_Cursor_Shape shape) { Ecore_Win32_Cursor *cursor = NULL; const char *cursor_name; @@ -115,15 +282,25 @@ ecore_win32_cursor_shape_get(Ecore_Win32_Cursor_Shape shape) return cursor; } -int -ecore_win32_cursor_size_get(void) +/** + * @brief Retrieve the size of a valid cursor. + * + * @param width The width of a valid cursor. + * @param height The height of a valid cursor. + * + * This function returns the size of a cursor that must be passed to + * ecore_win32_cursor_new(). @p width and @p height are buffers that + * will be filled with the correct size. They can be @c NULL. + */ +EAPI void +ecore_win32_cursor_size_get(int *width, int *height) { - int width; - int height; - INF("geting size cursor"); - width = GetSystemMetrics(SM_CXCURSOR); - height = GetSystemMetrics(SM_CYCURSOR); - return (width > height) ? width : height; + if (*width) *width = GetSystemMetrics(SM_CXCURSOR); + if (*height) *height = GetSystemMetrics(SM_CYCURSOR); } + +/** + * @} + */ diff --git a/src/lib/ecore_win32/ecore_win32_dnd.c b/src/lib/ecore_win32/ecore_win32_dnd.c index 415f812..a8eaf9c 100755 --- a/src/lib/ecore_win32/ecore_win32_dnd.c +++ b/src/lib/ecore_win32/ecore_win32_dnd.c @@ -7,6 +7,14 @@ #include "Ecore_Win32.h" #include "ecore_win32_private.h" +/*============================================================================* + * Local * + *============================================================================*/ + +/** + * @cond LOCAL + */ + static int _ecore_win32_dnd_init_count = 0; @@ -18,8 +26,42 @@ static HANDLE DataToHandle(const char *data, int size) return ptr; } - -int +/** + * @endcond + */ + + +/*============================================================================* + * Global * + *============================================================================*/ + + +/*============================================================================* + * API * + *============================================================================*/ + +/** + * @addtogroup Ecore_Win32_Group Ecore_Win32 library + * + * Ecore_Win32 is a library that wraps Windows CE graphic functions + * and integrate them nicely into the Ecore main loop. + * + * @{ + */ + +/** + * @brief Initialize the Ecore_Win32 Drag and Drop module. + * + * @return 1 or greater on success, 0 on error. + * + * This function initialize the Drag and Drop module. It returns 0 on + * failure, otherwise it returns the number of times it has already + * been called. + * + * When the Drag and Drop module is not used anymore, call + * ecore_win32_dnd_shutdown() to shut down the module. + */ +EAPI int ecore_win32_dnd_init() { if (_ecore_win32_dnd_init_count > 0) @@ -36,7 +78,18 @@ ecore_win32_dnd_init() return _ecore_win32_dnd_init_count; } -int ecore_win32_dnd_shutdown() +/** + * @brief Shut down the Ecore_Win32 Drag and Drop module. + * + * @return 0 when the module is completely shut down, 1 or + * greater otherwise. + * + * This function shuts down the Drag and Drop module. It returns 0 when it has + * been called the same number of times than ecore_win32_dnd_init(). In that case + * it shut down the module. + */ +EAPI int +ecore_win32_dnd_shutdown() { _ecore_win32_dnd_init_count--; if (_ecore_win32_dnd_init_count > 0) return _ecore_win32_dnd_init_count; @@ -48,17 +101,31 @@ int ecore_win32_dnd_shutdown() return _ecore_win32_dnd_init_count; } -int ecore_win32_dnd_begin(const char *data, - int size) +/** + * @brief Begin a DnD operation. + * + * @param data The name pf the Drag operation. + * @param size The size of the name. + * @return EINA_TRUE on success, EINA_FALSE otherwise. + * + * This function start a Drag operation with the name @p data. If + * @p data is @c NULL, EINA_FALSE is returned. if @p size is less than + * 0, it is set to the length (as strlen()) of @p data. On success the + * function returns EINA_TRUE, otherwise it returns EINA_FALSE. + */ +EAPI Eina_Bool +ecore_win32_dnd_begin(const char *data, + int size) { IDataObject *pDataObject = NULL; IDropSource *pDropSource = NULL; FORMATETC fmtetc = { CF_TEXT, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; STGMEDIUM stgmed = { TYMED_HGLOBAL, { 0 }, 0 }; - int res = 0; + Eina_Bool res = EINA_FALSE; if (!data) - return 0; + return EINA_FALSE; + if (size < 0) size = strlen(data) + 1; @@ -92,7 +159,7 @@ int ecore_win32_dnd_begin(const char *data, //else // printf("DND error\n"); - res = 1; + res = EINA_TRUE; } _ecore_win32_dnd_data_object_free(pDataObject); @@ -100,24 +167,48 @@ int ecore_win32_dnd_begin(const char *data, // cleanup ReleaseStgMedium(&stgmed); - return (int)res; + + return res; } -int ecore_win32_dnd_register_drop_target(Ecore_Win32_Window *window, - Ecore_Win32_Dnd_DropTarget_Callback callback) +/** + * @brief Register a Drop operation. + * + * @param window The destination of the Drop operation. + * @param callback The callback called when the Drop operation + * finishes. + * @return EINA_TRUE on success, EINA_FALSE otherwise. + * + * This function register a Drop operation on @p window. Once the Drop + * operation finishes, @p callback is called. If @p window is @c NULL, + * the function returns EINA_FALSE. On success, it returns EINA_TRUE, + * otherwise it returns EINA_FALSE. + */ +EAPI Eina_Bool +ecore_win32_dnd_register_drop_target(Ecore_Win32_Window *window, + Ecore_Win32_Dnd_DropTarget_Callback callback) { struct _Ecore_Win32_Window *wnd = (struct _Ecore_Win32_Window *)window; if (!window) - return 0; + return EINA_FALSE; wnd->dnd_drop_target = _ecore_win32_dnd_register_drop_window(wnd->window, callback, (void *)wnd); - return (int)(!!wnd->dnd_drop_target); + return wnd->dnd_drop_target ? EINA_TRUE : EINA_FALSE; } -void ecore_win32_dnd_unregister_drop_target(Ecore_Win32_Window *window) +/** + * @brief Unregister a Drop operation. + * + * @param window The destination of the Drop operation. + * + * This function unregister a Drop operation on @p window. If + * @p window is @c NULL, the function does nothing. + */ +EAPI void +ecore_win32_dnd_unregister_drop_target(Ecore_Win32_Window *window) { struct _Ecore_Win32_Window *wnd = (struct _Ecore_Win32_Window *)window; @@ -127,3 +218,7 @@ void ecore_win32_dnd_unregister_drop_target(Ecore_Win32_Window *window) if (wnd->dnd_drop_target) _ecore_win32_dnd_unregister_drop_window(wnd->window, wnd->dnd_drop_target); } + +/** + * @} + */ diff --git a/src/lib/ecore_win32/ecore_win32_window.c b/src/lib/ecore_win32/ecore_win32_window.c index 102ea69..7ca6748 100644 --- a/src/lib/ecore_win32/ecore_win32_window.c +++ b/src/lib/ecore_win32/ecore_win32_window.c @@ -5,8 +5,6 @@ #include #include /* for printf */ -#define _WIN32_WINNT 0x0500 // For WS_EX_LAYERED - #define WIN32_LEAN_AND_MEAN #include #undef WIN32_LEAN_AND_MEAN @@ -16,8 +14,13 @@ #include "Ecore_Win32.h" #include "ecore_win32_private.h" +/*============================================================================* + * Local * + *============================================================================*/ -/***** Private declarations *****/ +/** + * @cond LOCAL + */ typedef enum _Ecore_Win32_Window_Z_Order Ecore_Win32_Window_Z_Order; @@ -29,17 +32,151 @@ enum _Ecore_Win32_Window_Z_Order ECORE_WIN32_WINDOW_Z_ORDER_TOPMOST }; -static Ecore_Win32_Window *ecore_win32_window_internal_new(Ecore_Win32_Window *parent, - int x, - int y, - int width, - int height, - DWORD style); +static Ecore_Win32_Window * +ecore_win32_window_internal_new(Ecore_Win32_Window *parent, + int x, + int y, + int width, + int height, + DWORD style) +{ + RECT rect; + struct _Ecore_Win32_Window *w; + int minimal_width; + int minimal_height; + + w = (struct _Ecore_Win32_Window *)calloc(1, sizeof(struct _Ecore_Win32_Window)); + if (!w) + { + ERR("malloc() failed"); + return NULL; + } + + rect.left = 0; + rect.top = 0; + rect.right = width; + rect.bottom = height; + if (!AdjustWindowRect(&rect, style, FALSE)) + { + ERR("AdjustWindowRect() failed"); + free(w); + return NULL; + } + minimal_width = GetSystemMetrics(SM_CXMIN); + minimal_height = GetSystemMetrics(SM_CYMIN); +/* if (((rect.right - rect.left) < minimal_width) || */ +/* ((rect.bottom - rect.top) < minimal_height)) */ +/* { */ +/* fprintf (stderr, "[Ecore] [Win32] ERROR !!\n"); */ +/* fprintf (stderr, " Wrong size %ld\n", rect.right - rect.left); */ +/* free(w); */ +/* return NULL; */ +/* } */ + if ((rect.right - rect.left) < minimal_width) + { + rect.right = rect.left + minimal_width; + } -/***** API *****/ + w->window = CreateWindowEx(0, + ECORE_WIN32_WINDOW_CLASS, "", + style, + x, y, + rect.right - rect.left, + rect.bottom - rect.top, + parent ? ((struct _Ecore_Win32_Window *)parent)->window : NULL, + NULL, _ecore_win32_instance, NULL); + if (!w->window) + { + ERR("CreateWindowEx() failed"); + free(w); + return NULL; + } -Ecore_Win32_Window * + SetLastError(0); + if (!SetWindowLongPtr(w->window, GWL_USERDATA, (LONG)w) && (GetLastError() != 0)) + { + ERR("SetWindowLongPtr() failed"); + DestroyWindow(w->window); + free(w); + return NULL; + } + + w->min_width = 0; + w->min_height = 0; + w->max_width = 32767; + w->max_height = 32767; + w->base_width = -1; + w->base_height = -1; + w->step_width = -1; + w->step_height = -1; + + w->state.iconified = 0; + w->state.modal = 0; + w->state.sticky = 0; + w->state.maximized_vert = 0; + w->state.maximized_horz = 0; + w->state.shaded = 0; + w->state.hidden = 0; + w->state.fullscreen = 0; + w->state.above = 0; + w->state.below = 0; + w->state.demands_attention = 0; + + w->type.desktop = 0; + w->type.dock = 0; + w->type.toolbar = 0; + w->type.menu = 0; + w->type.utility = 0; + w->type.splash = 0; + w->type.dialog = 0; + w->type.normal = 0; + + w->pointer_is_in = 0; + w->borderless = 0; + w->iconified = 0; + w->fullscreen = 0; + + return w; +} + +/** + * @endcond + */ + + +/*============================================================================* + * Global * + *============================================================================*/ + +/*============================================================================* + * API * + *============================================================================*/ + +/** + * @addtogroup Ecore_Win32_Group Ecore_Win32 library + * + * @{ + */ + +/** + * @brief Creates a new window. + * + * @param parent The parent window. + * @param x The x coordinate of the top-left corner of the window. + * @param y The y coordinate of the top-left corner of the window. + * @param width The width of the window. + * @param height The height of hte window. + * @return A newly allocated window. + * + * This function creates a new window which parent is @p parent. @p width and + * @p height are the size of the window content (the client part), + * without the border and title bar. @p x and @p y are the system + * coordinates of the top left cerner of the window (that is, of the + * title bar). This function returns a newly created window on + * success, and @c NULL on failure. + */ +EAPI Ecore_Win32_Window * ecore_win32_window_new(Ecore_Win32_Window *parent, int x, int y, @@ -54,8 +191,20 @@ ecore_win32_window_new(Ecore_Win32_Window *parent, WS_OVERLAPPEDWINDOW | WS_SIZEBOX); } -/* simulate X11 override windows */ -Ecore_Win32_Window * +/** + * @brief Creates a new borderless window. + * + * @param parent The parent window. + * @param x The x coordinate of the top-left corner of the window. + * @param y The y coordinate of the top-left corner of the window. + * @param width The width of the window. + * @param height The height of hte window. + * @return A newly allocated window. + * + * This function is the same than ecore_win32_window_override_new() + * but the returned window is borderless. + */ +EAPI Ecore_Win32_Window * ecore_win32_window_override_new(Ecore_Win32_Window *parent, int x, int y, @@ -70,7 +219,15 @@ ecore_win32_window_override_new(Ecore_Win32_Window *parent, WS_POPUP); } -void +/** + * @brief Free the given window. + * + * @param window The window to free. + * + * This function frees @p window. If @p window is @c NULL, this + * function does nothing. + */ +EAPI void ecore_win32_window_free(Ecore_Win32_Window *window) { struct _Ecore_Win32_Window *wnd = window; @@ -86,7 +243,15 @@ ecore_win32_window_free(Ecore_Win32_Window *window) free(window); } -void * +/** + * @brief Return the window HANDLE associated to the given window. + * + * @param window The window to retrieve the HANDLE from. + * + * This function returns the window HANDLE associated to @p window. If + * @p window is @c NULL, this function returns @c NULL. + */ +EAPI void * ecore_win32_window_hwnd_get(Ecore_Win32_Window *window) { if (!window) return NULL; @@ -126,7 +291,18 @@ ecore_win32_window_configure(Ecore_Win32_Window *window, } */ -void +/** + * @brief Move the given window to a given position. + * + * @param window The window to move. + * @param x The x coordinate of the destination position. + * @param y The y coordinate of the destination position. + * + * This function move @p window to the new position of coordinates @p x + * and @p y. If @p window is @c NULL, or if it is fullscreen, or on + * error, this function does nothing. + */ +EAPI void ecore_win32_window_move(Ecore_Win32_Window *window, int x, int y) @@ -134,6 +310,7 @@ ecore_win32_window_move(Ecore_Win32_Window *window, RECT rect; HWND w; + /* FIXME: on fullscreen, should not move it */ if (!window) return; INF("moving window (%dx%d)", x, y); @@ -154,7 +331,18 @@ ecore_win32_window_move(Ecore_Win32_Window *window, } } -void +/** + * @brief Resize the given window to a given size. + * + * @param window The window to resize. + * @param width The new width. + * @param height The new height. + * + * This function resize @p window to the new @p width and @p height. + * If @p window is @c NULL, or if it is fullscreen, or on error, this + * function does nothing. + */ +EAPI void ecore_win32_window_resize(Ecore_Win32_Window *window, int width, int height) @@ -165,6 +353,7 @@ ecore_win32_window_resize(Ecore_Win32_Window *window, int x; int y; + /* FIXME: on fullscreen, should not resize it */ if (!window) return; INF("resizing window (%dx%d)", width, height); @@ -209,7 +398,20 @@ ecore_win32_window_resize(Ecore_Win32_Window *window, } } -void +/** + * @brief Move and resize the given window to a given position and size. + * + * @param window The window to move and resize. + * @param x The x coordinate of the destination position. + * @param y The x coordinate of the destination position. + * @param width The new width. + * @param height The new height. + * + * This function resize @p window to the new position of coordinates @p x + * and @p y and the new @p width and @p height. If @p window is @c NULL, + * or if it is fullscreen, or on error, this function does nothing. + */ +EAPI void ecore_win32_window_move_resize(Ecore_Win32_Window *window, int x, int y, @@ -220,6 +422,7 @@ ecore_win32_window_move_resize(Ecore_Win32_Window *window, struct _Ecore_Win32_Window *w; DWORD style; + /* FIXME: on fullscreen, should not move/resize it */ if (!window) return; INF("moving and resizing window (%dx%d %dx%d)", x, y, width, height); @@ -253,7 +456,23 @@ ecore_win32_window_move_resize(Ecore_Win32_Window *window, } } -void +/** + * @brief Get the geometry of the given window. + * + * @param window The window to retrieve the geometry from. + * @param x The x coordinate of the position. + * @param y The x coordinate of the position. + * @param width The width. + * @param height The height. + * + * This function retrieves the position and size of @p window. @p x, + * @p y, @p width and @p height can be buffers that will be filled with + * the corresponding values. If one of them is @c NULL, nothing will + * be done for that parameter. If @p window is @c NULL, and if the + * buffers are not @c NULL, they will be filled with respectively 0, + * 0, the size of the screen and the height of the screen. + */ +EAPI void ecore_win32_window_geometry_get(Ecore_Win32_Window *window, int *x, int *y, @@ -311,7 +530,21 @@ ecore_win32_window_geometry_get(Ecore_Win32_Window *window, if (height) *height = h; } -void +/** + * @brief Get the size of the given window. + * + * @param window The window to retrieve the size from. + * @param width The width. + * @param height The height. + * + * This function retrieves the size of @p window. @p width and + * @p height can be buffers that will be filled with the corresponding + * values. If one of them is @c NULL, nothing will be done for that + * parameter. If @p window is @c NULL, and if the buffers are not + * @c NULL, they will be filled with respectively the size of the screen + * and the height of the screen. + */ +EAPI void ecore_win32_window_size_get(Ecore_Win32_Window *window, int *width, int *height) @@ -341,7 +574,18 @@ ecore_win32_window_size_get(Ecore_Win32_Window *window, if (height) *height = rect.bottom - rect.top; } -void +/** + * @brief Set the minimum size of the given window. + * + * @param window The window. + * @param min_width The minimal width. + * @param min_height The minimal height. + * + * This function sets the minimum size of @p window to @p min_width + * and *p min_height. If @p window is @c NULL, this functions does + * nothing. + */ +EAPI void ecore_win32_window_size_min_set(Ecore_Win32_Window *window, unsigned int min_width, unsigned int min_height) @@ -356,7 +600,18 @@ ecore_win32_window_size_min_set(Ecore_Win32_Window *window, w->min_height = min_height; } -void +/** + * @brief Get the minimum size of the given window. + * + * @param window The window. + * @param min_width The minimal width. + * @param min_height The minimal height. + * + * This function fills the minimum size of @p window in the buffers + * @p min_width and *p min_height. They both can be @c NULL. If + * @p window is @c NULL, this functions does nothing. + */ +EAPI void ecore_win32_window_size_min_get(Ecore_Win32_Window *window, unsigned int *min_width, unsigned int *min_height) @@ -371,7 +626,18 @@ ecore_win32_window_size_min_get(Ecore_Win32_Window *window, if (min_height) *min_height = w->min_height; } -void +/** + * @brief Set the maximum size of the given window. + * + * @param window The window. + * @param max_width The maximal width. + * @param max_height The maximal height. + * + * This function sets the maximum size of @p window to @p max_width + * and *p max_height. If @p window is @c NULL, this functions does + * nothing. + */ +EAPI void ecore_win32_window_size_max_set(Ecore_Win32_Window *window, unsigned int max_width, unsigned int max_height) @@ -386,7 +652,18 @@ ecore_win32_window_size_max_set(Ecore_Win32_Window *window, w->max_height = max_height; } -void +/** + * @brief Get the maximum size of the given window. + * + * @param window The window. + * @param max_width The maximal width. + * @param max_height The maximal height. + * + * This function fills the maximum size of @p window in the buffers + * @p max_width and *p max_height. They both can be @c NULL. If + * @p window is @c NULL, this functions does nothing. + */ +EAPI void ecore_win32_window_size_max_get(Ecore_Win32_Window *window, unsigned int *max_width, unsigned int *max_height) @@ -401,7 +678,18 @@ ecore_win32_window_size_max_get(Ecore_Win32_Window *window, if (max_height) *max_height = w->max_height; } -void +/** + * @brief Set the base size of the given window. + * + * @param window The window. + * @param base_width The base width. + * @param base_height The base height. + * + * This function sets the base size of @p window to @p base_width + * and *p base_height. If @p window is @c NULL, this functions does + * nothing. + */ +EAPI void ecore_win32_window_size_base_set(Ecore_Win32_Window *window, unsigned int base_width, unsigned int base_height) @@ -416,7 +704,18 @@ ecore_win32_window_size_base_set(Ecore_Win32_Window *window, w->base_height = base_height; } -void +/** + * @brief Get the base size of the given window. + * + * @param window The window. + * @param base_width The base width. + * @param base_height The bas height. + * + * This function fills the base size of @p window in the buffers + * @p base_width and *p base_height. They both can be @c NULL. If + * @p window is @c NULL, this functions does nothing. + */ +EAPI void ecore_win32_window_size_base_get(Ecore_Win32_Window *window, unsigned int *base_width, unsigned int *base_height) @@ -431,7 +730,18 @@ ecore_win32_window_size_base_get(Ecore_Win32_Window *window, if (base_height) *base_height = w->base_height; } -void +/** + * @brief Set the step size of the given window. + * + * @param window The window. + * @param step_width The step width. + * @param step_height The step height. + * + * This function sets the step size of @p window to @p step_width + * and *p step_height. If @p window is @c NULL, this functions does + * nothing. + */ +EAPI void ecore_win32_window_size_step_set(Ecore_Win32_Window *window, unsigned int step_width, unsigned int step_height) @@ -446,7 +756,18 @@ ecore_win32_window_size_step_set(Ecore_Win32_Window *window, w->step_height = step_height; } -void +/** + * @brief Get the step size of the given window. + * + * @param window The window. + * @param step_width The step width. + * @param step_height The bas height. + * + * This function fills the step size of @p window in the buffers + * @p step_width and *p step_height. They both can be @c NULL. If + * @p window is @c NULL, this functions does nothing. + */ +EAPI void ecore_win32_window_size_step_get(Ecore_Win32_Window *window, unsigned int *step_width, unsigned int *step_height) @@ -461,7 +782,7 @@ ecore_win32_window_size_step_get(Ecore_Win32_Window *window, if (step_height) *step_height = w->step_height; } -void +EAPI void ecore_win32_window_shape_set(Ecore_Win32_Window *window, unsigned short width, unsigned short height, @@ -598,7 +919,15 @@ ecore_win32_window_shape_set(Ecore_Win32_Window *window, } } -void +/** + * @brief Show the given window. + * + * @param window The window to show. + * + * This function shows @p window. If @p window is @c NULL, or on + * error, this function does nothing. + */ +EAPI void ecore_win32_window_show(Ecore_Win32_Window *window) { if (!window) return; @@ -613,7 +942,15 @@ ecore_win32_window_show(Ecore_Win32_Window *window) } /* FIXME: seems to block the taskbar */ -void +/** + * @brief Hide the given window. + * + * @param window The window to show. + * + * This function hides @p window. If @p window is @c NULL, or on + * error, this function does nothing. + */ +EAPI void ecore_win32_window_hide(Ecore_Win32_Window *window) { if (!window) return; @@ -623,7 +960,15 @@ ecore_win32_window_hide(Ecore_Win32_Window *window) ShowWindow(((struct _Ecore_Win32_Window *)window)->window, SW_HIDE); } -void +/** + * @brief Place the given window at the top of the Z order. + * + * @param window The window to place at the top. + * + * This function places @p window at the top of the Z order. If + * @p window is @c NULL, this function does nothing. + */ +EAPI void ecore_win32_window_raise(Ecore_Win32_Window *window) { if (!window) return; @@ -638,7 +983,15 @@ ecore_win32_window_raise(Ecore_Win32_Window *window) } } -void +/** + * @brief Place the given window at the bottom of the Z order. + * + * @param window The window to place at the bottom. + * + * This function places @p window at the bottom of the Z order. If + * @p window is @c NULL, this function does nothing. + */ +EAPI void ecore_win32_window_lower(Ecore_Win32_Window *window) { if (!window) return; @@ -653,7 +1006,17 @@ ecore_win32_window_lower(Ecore_Win32_Window *window) } } -void +/** + * @brief Set the title of the given window. + * + * @param window The window to set the title. + * @param title The new title. + * + * This function sets the title of @p window to @p title. If @p window + * is @c NULL, or if @p title is @c NULL or empty, or on error, this + * function does nothing. + */ +EAPI void ecore_win32_window_title_set(Ecore_Win32_Window *window, const char *title) { @@ -669,7 +1032,15 @@ ecore_win32_window_title_set(Ecore_Win32_Window *window, } } -void +/** + * @brief Set the focus to the given window. + * + * @param window The window to give focus to. + * + * This function gives the focus to @p window. If @p window is + * @c NULL, this function does nothing. + */ +EAPI void ecore_win32_window_focus_set(Ecore_Win32_Window *window) { if (!window) return; @@ -682,9 +1053,21 @@ ecore_win32_window_focus_set(Ecore_Win32_Window *window) } } -void +/** + * @brief Iconify or restore the given window. + * + * @param window The window. + * @param on EINA_TRUE to iconify the window, EINA_FALSE to restore it. + * + * This function iconify or restore @p window. If @p on + * is set to EINA_TRUE, the window will be iconified, if it is set to + * EINA_FALSE, it will be restored. If @p window is @c NULL or if the + * state does not change (like iconifying the window while it is + * already iconified), this function does nothing. + */ +EAPI void ecore_win32_window_iconified_set(Ecore_Win32_Window *window, - int on) + Eina_Bool on) { struct _Ecore_Win32_Window *ew; @@ -701,9 +1084,21 @@ ecore_win32_window_iconified_set(Ecore_Win32_Window *window, ew->iconified = on; } -void +/** + * @brief Remove or restore the border of the given window. + * + * @param window The window. + * @param on EINA_TRUE to remove the border, EINA_FALSE to restore it. + * + * This function remove or restore the border of @p window. If @p on + * is set to EINA_TRUE, the window will have no border, if it is set to + * EINA_FALSE, it will have a border. If @p window is @c NULL or if the + * state does not change (like setting to borderless while the window + * has no border), this function does nothing. + */ +EAPI void ecore_win32_window_borderless_set(Ecore_Win32_Window *window, - int on) + Eina_Bool on) { RECT rect; DWORD style; @@ -767,9 +1162,21 @@ ecore_win32_window_borderless_set(Ecore_Win32_Window *window, ew->borderless = on; } -void +/** + * @brief Set the given window to fullscreen. + * + * @param window The window. + * @param on EINA_TRUE for fullscreen mode, EINA_FALSE for windowed mode. + * + * This function set @p window to fullscreen or windowed mode. If @p on + * is set to EINA_TRUE, the window will be fullscreen, if it is set to + * EINA_FALSE, it will be windowed. If @p window is @c NULL or if the + * state does not change (like setting to fullscreen while the window + * is already fullscreen), this function does nothing. + */ +EAPI void ecore_win32_window_fullscreen_set(Ecore_Win32_Window *window, - int on) + Eina_Bool on) { struct _Ecore_Win32_Window *ew; HWND w; @@ -849,12 +1256,26 @@ ecore_win32_window_fullscreen_set(Ecore_Win32_Window *window, } } -void +/** + * @brief Set the given cursor to the given window. + * + * @param window The window to modify the cursor. + * @param cursor The new cursor. + * + * This function sets @p cursor to @p window. @p cursor must have been + * obtained by ecore_win32_cursor_new() or + * ecore_win32_cursor_shaped_new(). If @p window or @p cursor is + * @c NULL, the function does nothing. + */ +EAPI void ecore_win32_window_cursor_set(Ecore_Win32_Window *window, Ecore_Win32_Cursor *cursor) { INF("setting cursor"); + if (!window || !cursor) + return; + if (!SetClassLong(((struct _Ecore_Win32_Window *)window)->window, GCL_HCURSOR, (LONG)cursor)) { @@ -862,14 +1283,25 @@ ecore_win32_window_cursor_set(Ecore_Win32_Window *window, } } -void +/** + * @brief Set the state of the given window. + * + * @param window The window to modify the state. + * @param state An array of the new states. + * @param num The number of states in the array. + * + * This function set the state of @p window. @p state is an array of + * states of size @p num. If @p window or @p state are @c NULL, or if + * @p num is less or equal than 0, the function does nothing. + */ +EAPI void ecore_win32_window_state_set(Ecore_Win32_Window *window, Ecore_Win32_Window_State *state, unsigned int num) { unsigned int i; - if (!window || !state || !num) + if (!window || !state || (num <= 0)) return; INF("setting cursor state"); @@ -922,7 +1354,20 @@ ecore_win32_window_state_set(Ecore_Win32_Window *window, } } -void +/** + * @brief Apply the modification of the state to the given window. + * + * @param window The window. + * @param state The state to apply changes. + * @param set The value of the state change. + * + * This function applies the modification of the state @p state of + * @p window. @p set is used only for + * #ECORE_WIN32_WINDOW_STATE_ICONIFIED and + * #ECORE_WIN32_WINDOW_STATE_FULLSCREEN. If @p window is @c NULL, the + * function does nothing. + */ +EAPI void ecore_win32_window_state_request_send(Ecore_Win32_Window *window, Ecore_Win32_Window_State state, unsigned int set) @@ -1060,7 +1505,16 @@ ecore_win32_window_state_request_send(Ecore_Win32_Window *window, } } -void +/** + * @brief Set the type of the given window. + * + * @param window The window to modify the type. + * @param type The new types. + * + * This function set the type of @p window to @p type. If + * @p window is @c NULL, the function does nothing. + */ +EAPI void ecore_win32_window_type_set(Ecore_Win32_Window *window, Ecore_Win32_Window_Type type) { @@ -1101,113 +1555,6 @@ ecore_win32_window_type_set(Ecore_Win32_Window *window, } } - -/***** Private functions definitions *****/ - -static Ecore_Win32_Window * -ecore_win32_window_internal_new(Ecore_Win32_Window *parent, - int x, - int y, - int width, - int height, - DWORD style) -{ - RECT rect; - struct _Ecore_Win32_Window *w; - int minimal_width; - int minimal_height; - - w = (struct _Ecore_Win32_Window *)calloc(1, sizeof(struct _Ecore_Win32_Window)); - if (!w) - { - ERR("malloc() failed"); - return NULL; - } - - rect.left = 0; - rect.top = 0; - rect.right = width; - rect.bottom = height; - if (!AdjustWindowRect(&rect, style, FALSE)) - { - ERR("AdjustWindowRect() failed"); - free(w); - return NULL; - } - - minimal_width = GetSystemMetrics(SM_CXMIN); - minimal_height = GetSystemMetrics(SM_CYMIN); -/* if (((rect.right - rect.left) < minimal_width) || */ -/* ((rect.bottom - rect.top) < minimal_height)) */ -/* { */ -/* fprintf (stderr, "[Ecore] [Win32] ERROR !!\n"); */ -/* fprintf (stderr, " Wrong size %ld\n", rect.right - rect.left); */ -/* free(w); */ -/* return NULL; */ -/* } */ - if ((rect.right - rect.left) < minimal_width) - { - rect.right = rect.left + minimal_width; - } - - w->window = CreateWindowEx(0, - ECORE_WIN32_WINDOW_CLASS, "", - style, - x, y, - rect.right - rect.left, - rect.bottom - rect.top, - parent ? ((struct _Ecore_Win32_Window *)parent)->window : NULL, - NULL, _ecore_win32_instance, NULL); - if (!w->window) - { - ERR("CreateWindowEx() failed"); - free(w); - return NULL; - } - - SetLastError(0); - if (!SetWindowLongPtr(w->window, GWL_USERDATA, (LONG)w) && (GetLastError() != 0)) - { - ERR("SetWindowLongPtr() failed"); - DestroyWindow(w->window); - free(w); - return NULL; - } - - w->min_width = 0; - w->min_height = 0; - w->max_width = 32767; - w->max_height = 32767; - w->base_width = -1; - w->base_height = -1; - w->step_width = -1; - w->step_height = -1; - - w->state.iconified = 0; - w->state.modal = 0; - w->state.sticky = 0; - w->state.maximized_vert = 0; - w->state.maximized_horz = 0; - w->state.shaded = 0; - w->state.hidden = 0; - w->state.fullscreen = 0; - w->state.above = 0; - w->state.below = 0; - w->state.demands_attention = 0; - - w->type.desktop = 0; - w->type.dock = 0; - w->type.toolbar = 0; - w->type.menu = 0; - w->type.utility = 0; - w->type.splash = 0; - w->type.dialog = 0; - w->type.normal = 0; - - w->pointer_is_in = 0; - w->borderless = 0; - w->iconified = 0; - w->fullscreen = 0; - - return w; -} +/** + * @} + */ diff --git a/src/lib/ecore_wince/Ecore_WinCE.h b/src/lib/ecore_wince/Ecore_WinCE.h index de535a3..160886a 100644 --- a/src/lib/ecore_wince/Ecore_WinCE.h +++ b/src/lib/ecore_wince/Ecore_WinCE.h @@ -1,12 +1,23 @@ #ifndef __ECORE_WINCE_H__ #define __ECORE_WINCE_H__ +/* + * DO NOT USE THIS HEADER. IT IS WORK IN PROGRESS. IT IS NOT FINAL AND + * THE API MAY CHANGE. + */ + +#ifndef ECORE_WINCE_WIP_OSXCKQSD +# warning "You are using a work in progress API. This API is not stable" +# warning "and is subject to change. You use this at your own risk." +#endif + +#include #ifdef EAPI # undef EAPI #endif -#ifdef _WINCE +#ifdef _WIN32 # ifdef EFL_ECORE_WINCE_BUILD # ifdef DLL_EXPORT # define EAPI __declspec(dllexport) @@ -32,112 +43,207 @@ extern "C" { #endif +/** + * @defgroup Ecore_WinCE_Group Ecore_WinCE library + * + * @{ + */ + #ifndef _ECORE_EVAS_H typedef void Ecore_WinCE_Window; #endif -/* Events */ - +/** + * @typedef Ecore_WinCE_Event_Mouse_In + * Event sent when the mouse enters the window. + */ typedef struct _Ecore_WinCE_Event_Mouse_In Ecore_WinCE_Event_Mouse_In; + +/** + * @typedef Ecore_WinCE_Event_Mouse_Out + * Event sent when the mouse leaves the window. + */ typedef struct _Ecore_WinCE_Event_Mouse_Out Ecore_WinCE_Event_Mouse_Out; + +/** + * @typedef Ecore_WinCE_Event_Window_Focus_In + * Event sent when the window gets the focus. + */ typedef struct _Ecore_WinCE_Event_Window_Focus_In Ecore_WinCE_Event_Window_Focus_In; + +/** + * @typedef Ecore_WinCE_Event_Window_Focus_Out + * Event sent when the window looses the focus. + */ typedef struct _Ecore_WinCE_Event_Window_Focus_Out Ecore_WinCE_Event_Window_Focus_Out; + +/** + * @typedef Ecore_WinCE_Event_Window_Damage + * Event sent when the window is damaged. + */ typedef struct _Ecore_WinCE_Event_Window_Damage Ecore_WinCE_Event_Window_Damage; + +/** + * @typedef Ecore_WinCE_Event_Window_Create + * Event sent when the window is created. + */ typedef struct _Ecore_WinCE_Event_Window_Create Ecore_WinCE_Event_Window_Create; + +/** + * @typedef Ecore_WinCE_Event_Window_Destroy + * Event sent when the window is destroyed. + */ typedef struct _Ecore_WinCE_Event_Window_Destroy Ecore_WinCE_Event_Window_Destroy; + +/** + * @typedef Ecore_WinCE_Event_Window_Hide + * Event sent when the window is hidden. + */ typedef struct _Ecore_WinCE_Event_Window_Hide Ecore_WinCE_Event_Window_Hide; + +/** + * @typedef Ecore_WinCE_Event_Window_Show + * Event sent when the window is shown. + */ typedef struct _Ecore_WinCE_Event_Window_Show Ecore_WinCE_Event_Window_Show; + +/** + * @typedef Ecore_WinCE_Event_Window_Delete_Request + * Event sent when the window is deleted. + */ typedef struct _Ecore_WinCE_Event_Window_Delete_Request Ecore_WinCE_Event_Window_Delete_Request; + +/** + * @struct _Ecore_WinCE_Event_Mouse_In + * Event sent when the mouse enters the window. + */ struct _Ecore_WinCE_Event_Mouse_In { - Ecore_WinCE_Window *window; - int x; - int y; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + int x; /**< The x coordinate where the mouse entered */ + int y; /**< The y coordinate where the mouse entered */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Mouse_Out + * Event sent when the mouse leaves the window. + */ struct _Ecore_WinCE_Event_Mouse_Out { - Ecore_WinCE_Window *window; - int x; - int y; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + int x; /**< The x coordinate where the mouse leaved */ + int y; /**< The y coordinate where the mouse leaved */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Window_Focus_In + * Event sent when the window gets the focus. + */ struct _Ecore_WinCE_Event_Window_Focus_In { - Ecore_WinCE_Window *window; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Window_Focus_Out + * Event sent when the window looses the focus. + */ struct _Ecore_WinCE_Event_Window_Focus_Out { - Ecore_WinCE_Window *window; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Window_Damage + * Event sent when the window is damaged. + */ struct _Ecore_WinCE_Event_Window_Damage { - Ecore_WinCE_Window *window; - int x; - int y; - int width; - int height; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + int x; /**< The x coordinate of the top left corner of the damaged region */ + int y; /**< The y coordinate of the top left corner of the damaged region */ + int width; /**< The width of the damaged region */ + int height; /**< The height of the damaged region */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Window_Create + * Event sent when the window is created. + */ struct _Ecore_WinCE_Event_Window_Create { - Ecore_WinCE_Window *window; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Window_Destroy + * Event sent when the window is destroyed. + */ struct _Ecore_WinCE_Event_Window_Destroy { - Ecore_WinCE_Window *window; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Window_Hide + * Event sent when the window is hidden. + */ struct _Ecore_WinCE_Event_Window_Hide { - Ecore_WinCE_Window *window; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Window_Show + * Event sent when the window is shown. + */ struct _Ecore_WinCE_Event_Window_Show { - Ecore_WinCE_Window *window; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; +/** + * @struct _Ecore_WinCE_Event_Window_Delete_Request + * Event sent when the window is deleted. + */ struct _Ecore_WinCE_Event_Window_Delete_Request { - Ecore_WinCE_Window *window; - long time; + Ecore_WinCE_Window *window; /**< The window that received the event */ + long time; /**< The time the event occured */ }; -EAPI extern int ECORE_WINCE_EVENT_MOUSE_IN; -EAPI extern int ECORE_WINCE_EVENT_MOUSE_OUT; -EAPI extern int ECORE_WINCE_EVENT_WINDOW_FOCUS_IN; -EAPI extern int ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT; -EAPI extern int ECORE_WINCE_EVENT_WINDOW_DAMAGE; -EAPI extern int ECORE_WINCE_EVENT_WINDOW_CREATE; -EAPI extern int ECORE_WINCE_EVENT_WINDOW_DESTROY; -EAPI extern int ECORE_WINCE_EVENT_WINDOW_HIDE; -EAPI extern int ECORE_WINCE_EVENT_WINDOW_SHOW; -EAPI extern int ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST; +EAPI extern int ECORE_WINCE_EVENT_MOUSE_IN; /**< Ecore_Event for the #Ecore_WinCE_Event_Mouse_In event */ +EAPI extern int ECORE_WINCE_EVENT_MOUSE_OUT; /**< Ecore_Event for the #Ecore_WinCE_Event_Mouse_Out event */ +EAPI extern int ECORE_WINCE_EVENT_WINDOW_FOCUS_IN; /**< Ecore_Event for the #Ecore_WinCE_Event_Window_Focus_In event */ +EAPI extern int ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT; /**< Ecore_Event for the #Ecore_WinCE_Event_Window_Focus_Out event */ +EAPI extern int ECORE_WINCE_EVENT_WINDOW_DAMAGE; /**< Ecore_Event for the #Ecore_WinCE_Event_Damage event */ +EAPI extern int ECORE_WINCE_EVENT_WINDOW_CREATE; /**< Ecore_Event for the #Ecore_WinCE_Event_Create event */ +EAPI extern int ECORE_WINCE_EVENT_WINDOW_DESTROY; /**< Ecore_Event for the #Ecore_WinCE_Event_Destroy event */ +EAPI extern int ECORE_WINCE_EVENT_WINDOW_HIDE; /**< Ecore_Event for the #Ecore_WinCE_Event_Hide event */ +EAPI extern int ECORE_WINCE_EVENT_WINDOW_SHOW; /**< Ecore_Event for the #Ecore_WinCE_Event_Show event */ +EAPI extern int ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST; /**< Ecore_Event for the #Ecore_WinCE_Event_Window_Delete_Request event */ /* Core */ EAPI int ecore_wince_init(); EAPI int ecore_wince_shutdown(); +EAPI void ecore_wince_double_click_time_set(double t); +EAPI double ecore_wince_double_click_time_get(void); EAPI long ecore_wince_current_time_get(void); -EAPI void ecore_wince_message_loop_begin (void); /* Window */ @@ -174,9 +280,9 @@ EAPI void ecore_wince_window_title_set(Ecore_WinCE_Window *window, EAPI void ecore_wince_window_backend_set(Ecore_WinCE_Window *window, int backend); -EAPI void ecore_wince_window_suspend_set(Ecore_WinCE_Window *window, int (*suspend)(int)); +EAPI void ecore_wince_window_suspend_set(Ecore_WinCE_Window *window, int (*suspend_cb)(int)); -EAPI void ecore_wince_window_resume_set(Ecore_WinCE_Window *window, int (*resume)(int)); +EAPI void ecore_wince_window_resume_set(Ecore_WinCE_Window *window, int (*resume_cb)(int)); EAPI void ecore_wince_window_geometry_get(Ecore_WinCE_Window *window, int *x, @@ -189,8 +295,11 @@ EAPI void ecore_wince_window_size_get(Ecore_WinCE_Window *window, int *height); EAPI void ecore_wince_window_fullscreen_set(Ecore_WinCE_Window *window, - int on); + Eina_Bool on); +/** + * @} + */ #ifdef __cplusplus } diff --git a/src/lib/ecore_wince/ecore_wince.c b/src/lib/ecore_wince/ecore_wince.c index a663823..89b7906 100644 --- a/src/lib/ecore_wince/ecore_wince.c +++ b/src/lib/ecore_wince/ecore_wince.c @@ -16,8 +16,173 @@ #include "Ecore_WinCE.h" #include "ecore_wince_private.h" +/*============================================================================* + * Local * + *============================================================================*/ + +/** + * @cond LOCAL + */ + +static int _ecore_wince_init_count = 0; + +LRESULT CALLBACK +_ecore_wince_window_procedure(HWND window, + UINT message, + WPARAM window_param, + LPARAM data_param) +{ + Ecore_WinCE_Callback_Data *data; + POINTS pt; + DWORD coord; + + data = (Ecore_WinCE_Callback_Data *)malloc(sizeof(Ecore_WinCE_Callback_Data)); + if (!data) return DefWindowProc(window, message, window_param, data_param); + + data->window = window; + data->message = message; + data->window_param = window_param; + data->data_param = data_param; + data->time = GetTickCount(); + coord = GetMessagePos(); + pt = MAKEPOINTS(coord); + data->x = pt.x; + data->y = pt.y; + + switch (data->message) + { + /* Keyboard input notifications */ + case WM_CHAR: + _ecore_wince_event_handle_key_press(data, 0); + break; + case WM_HOTKEY: + _ecore_wince_event_handle_key_press(data, 1); + break; + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + _ecore_wince_event_handle_key_press(data, 1); + break; + case WM_KEYUP: + case WM_SYSKEYUP: + _ecore_wince_event_handle_key_release(data, 1); + break; + case WM_SETFOCUS: + _ecore_wince_event_handle_focus_in(data); + break; + case WM_KILLFOCUS: + _ecore_wince_event_handle_focus_out(data); + break; + /* Mouse input notifications */ + case WM_LBUTTONDOWN: + _ecore_wince_event_handle_button_press(data, 1); + break; + case WM_LBUTTONUP: + _ecore_wince_event_handle_button_release(data, 1); + break; + case WM_MOUSEMOVE: + { + RECT rect; + struct _Ecore_WinCE_Window *w = NULL; + + w = (struct _Ecore_WinCE_Window *)GetWindowLong(window, GWL_USERDATA); + + if (GetClientRect(window, &rect)) + { + POINT pt; + + INF("mouse in window"); + + pt.x = LOWORD(data_param); + pt.y = HIWORD(data_param); + if (!PtInRect(&rect, pt)) + { + if (w->pointer_is_in) + { + w->pointer_is_in = 0; + _ecore_wince_event_handle_leave_notify(data); + } + } + else + { + if (!w->pointer_is_in) + { + w->pointer_is_in = 1; + _ecore_wince_event_handle_enter_notify(data); + } + } + } + else + { + ERR("GetClientRect() failed"); + } + _ecore_wince_event_handle_motion_notify(data); + + break; + } + /* Window notifications */ + case WM_CREATE: + _ecore_wince_event_handle_create_notify(data); + break; + case WM_DESTROY: + _ecore_wince_event_handle_destroy_notify(data); + break; + case WM_SHOWWINDOW: + if ((data->data_param == SW_OTHERUNZOOM) || + (data->data_param == SW_OTHERZOOM)) + break; + + if (data->window_param) + _ecore_wince_event_handle_map_notify(data); + else + _ecore_wince_event_handle_unmap_notify(data); + + break; + case WM_CLOSE: + _ecore_wince_event_handle_delete_request(data); + break; + /* GDI notifications */ + case WM_PAINT: + { + PAINTSTRUCT paint; + + if (BeginPaint(window, &paint)) + { + data->update = paint.rcPaint; + _ecore_wince_event_handle_expose(data); + EndPaint(window, &paint); + } + break; + } + default: + return DefWindowProc(window, message, window_param, data_param); + } + + return 0; +} + +static void +_ecore_wince_error_print_cb(const Eina_Log_Domain *d __UNUSED__, + Eina_Log_Level level __UNUSED__, + const char *file __UNUSED__, + const char *fnc, + int line, + const char *fmt, + void *data __UNUSED__, + va_list args) +{ + fprintf(stderr, "[%s:%d] ", fnc, line); + vfprintf(stderr, fmt, args); +} + +/** + * @endcond + */ + + +/*============================================================================* + * Global * + *============================================================================*/ -/***** Global declarations *****/ double _ecore_wince_double_click_time = 0.25; long _ecore_wince_event_last_time = 0; @@ -36,29 +201,32 @@ int ECORE_WINCE_EVENT_WINDOW_SHOW = 0; int ECORE_WINCE_EVENT_WINDOW_HIDE = 0; int ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST = 0; +/*============================================================================* + * API * + *============================================================================*/ -/***** Private declarations *****/ - -static int _ecore_wince_init_count = 0; - -LRESULT CALLBACK _ecore_wince_window_procedure(HWND window, - UINT message, - WPARAM window_param, - LPARAM data_param); - -static void _ecore_wince_error_print_cb(const Eina_Log_Domain *d, - Eina_Log_Level level, - const char *file, - const char *fnc, - int line, - const char *fmt, - void *data, - va_list args); - - -/***** API *****/ +/** + * @addtogroup Ecore_WinCE_Group Ecore_WinCE library + * + * Ecore_WinCE is a library that wraps Windows CE graphic functions + * and integrate them nicely into the Ecore main loop. + * + * @{ + */ -int +/** + * @brief Initialize the Ecore_WinCE library. + * + * @return 1 or greater on success, 0 on error. + * + * This function sets up the Windows CE graphic system. It returns 0 on + * failure, otherwise it returns the number of times it has already been + * called. + * + * When Ecore_WinCE is not used anymore, call ecore_wince_shutdown() + * to shut down the Ecore_WinCE library. + */ +EAPI int ecore_wince_init() { WNDCLASS wc; @@ -70,7 +238,8 @@ ecore_wince_init() return --_ecore_wince_init_count; eina_log_print_cb_set(_ecore_wince_error_print_cb, NULL); - _ecore_wince_log_dom_global = eina_log_domain_register("ecore_wince", ECORE_WINCE_DEFAULT_LOG_COLOR); + _ecore_wince_log_dom_global = eina_log_domain_register + ("ecore_wince", ECORE_WINCE_DEFAULT_LOG_COLOR); if (_ecore_wince_log_dom_global < 0) { EINA_LOG_ERR("Ecore_WinCE: Could not register log domain"); @@ -136,7 +305,17 @@ ecore_wince_init() return --_ecore_wince_init_count; } -int +/** + * @brief Shut down the Ecore_WinCE library. + * + * @return 0 when the library is completely shut down, 1 or + * greater otherwise. + * + * This function shuts down the Ecore_WinCE library. It returns 0 when it has + * been called the same number of times than ecore_wince_init(). In that case + * it shuts down all the Windows CE graphic system. + */ +EAPI int ecore_wince_shutdown() { HWND task_bar; @@ -170,13 +349,13 @@ ecore_wince_shutdown() } /** - * Sets the timeout for a double and triple clicks to be flagged. + * @brief Set the timeout for a double and triple clicks to be flagged. * - * This sets the time between clicks before the double_click flag is - * set in a button down event. If 3 clicks occur within double this - * time, the triple_click flag is also set. + * @param t The time in seconds. * - * @param t The time in seconds + * This function sets the time @p t between clicks before the + * double_click flag is set in a button down event. If 3 clicks occur + * within double this time, the triple_click flag is also set. */ EAPI void ecore_wince_double_click_time_set(double t) @@ -186,11 +365,14 @@ ecore_wince_double_click_time_set(double t) } /** - * Retrieves the double and triple click flag timeout. - * - * See @ref ecore_wince_double_click_time_set for more information. + * @brief Retrieve the double and triple click flag timeout. * * @return The timeout for double clicks in seconds. + * + * This function returns the double clicks in seconds. If + * ecore_wince_double_click_time_set() has not been called, the + * default value is returned. See ecore_wince_double_click_time_set() + * for more informations. */ EAPI double ecore_wince_double_click_time_get(void) @@ -199,7 +381,11 @@ ecore_wince_double_click_time_get(void) } /** - * Return the last event time + * @brief Return the last event time. + * + * @return The last envent time. + * + * This function returns the last event time. */ EAPI long ecore_wince_current_time_get(void) @@ -207,153 +393,6 @@ ecore_wince_current_time_get(void) return _ecore_wince_event_last_time; } - -/***** Private functions definitions *****/ - -LRESULT CALLBACK -_ecore_wince_window_procedure(HWND window, - UINT message, - WPARAM window_param, - LPARAM data_param) -{ - Ecore_WinCE_Callback_Data *data; - POINTS pt; - DWORD coord; - - data = (Ecore_WinCE_Callback_Data *)malloc(sizeof(Ecore_WinCE_Callback_Data)); - if (!data) return DefWindowProc(window, message, window_param, data_param); - - data->window = window; - data->message = message; - data->window_param = window_param; - data->data_param = data_param; - data->time = GetTickCount(); - coord = GetMessagePos(); - pt = MAKEPOINTS(coord); - data->x = pt.x; - data->y = pt.y; - - switch (data->message) - { - /* Keyboard input notifications */ - case WM_CHAR: - _ecore_wince_event_handle_key_press(data, 0); - break; - case WM_HOTKEY: - _ecore_wince_event_handle_key_press(data, 1); - break; - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - _ecore_wince_event_handle_key_press(data, 1); - break; - case WM_KEYUP: - case WM_SYSKEYUP: - _ecore_wince_event_handle_key_release(data, 1); - break; - case WM_SETFOCUS: - _ecore_wince_event_handle_focus_in(data); - break; - case WM_KILLFOCUS: - _ecore_wince_event_handle_focus_out(data); - break; - /* Mouse input notifications */ - case WM_LBUTTONDOWN: - _ecore_wince_event_handle_button_press(data, 1); - break; - case WM_LBUTTONUP: - _ecore_wince_event_handle_button_release(data, 1); - break; - case WM_MOUSEMOVE: - { - RECT rect; - struct _Ecore_WinCE_Window *w = NULL; - - w = (struct _Ecore_WinCE_Window *)GetWindowLong(window, GWL_USERDATA); - - if (GetClientRect(window, &rect)) - { - POINT pt; - - INF("mouse in window"); - - pt.x = LOWORD(data_param); - pt.y = HIWORD(data_param); - if (!PtInRect(&rect, pt)) - { - if (w->pointer_is_in) - { - w->pointer_is_in = 0; - _ecore_wince_event_handle_leave_notify(data); - } - } - else - { - if (!w->pointer_is_in) - { - w->pointer_is_in = 1; - _ecore_wince_event_handle_enter_notify(data); - } - } - } - else - { - ERR("GetClientRect() failed"); - } - _ecore_wince_event_handle_motion_notify(data); - - break; - } - /* Window notifications */ - case WM_CREATE: - _ecore_wince_event_handle_create_notify(data); - break; - case WM_DESTROY: - _ecore_wince_event_handle_destroy_notify(data); - break; - case WM_SHOWWINDOW: - if ((data->data_param == SW_OTHERUNZOOM) || - (data->data_param == SW_OTHERUNZOOM)) - break; - - if (data->window_param) - _ecore_wince_event_handle_map_notify(data); - else - _ecore_wince_event_handle_unmap_notify(data); - - break; - case WM_CLOSE: - _ecore_wince_event_handle_delete_request(data); - break; - /* GDI notifications */ - case WM_PAINT: - { - PAINTSTRUCT paint; - - if (BeginPaint(window, &paint)) - { - data->update = paint.rcPaint; - _ecore_wince_event_handle_expose(data); - EndPaint(window, &paint); - } - break; - } - default: - return DefWindowProc(window, message, window_param, data_param); - } - - return 0; -} - -static void -_ecore_wince_error_print_cb(const Eina_Log_Domain *d __UNUSED__, - Eina_Log_Level level __UNUSED__, - const char *file __UNUSED__, - const char *fnc, - int line, - const char *fmt, - void *data __UNUSED__, - va_list args) -{ - fprintf(stderr, "[%s:%d] ", fnc, line); - vfprintf(stderr, fmt, args); -} +/** + * @} + */ diff --git a/src/lib/ecore_wince/ecore_wince_event.c b/src/lib/ecore_wince/ecore_wince_event.c index 5e35b5a..e2599d9 100644 --- a/src/lib/ecore_wince/ecore_wince_event.c +++ b/src/lib/ecore_wince/ecore_wince_event.c @@ -15,8 +15,13 @@ #include "Ecore_WinCE.h" #include "ecore_wince_private.h" +/*============================================================================* + * Local * + *============================================================================*/ -/***** Private declarations *****/ +/** + * @cond LOCAL + */ static Ecore_WinCE_Window *_ecore_wince_mouse_down_last_window = NULL; static Ecore_WinCE_Window *_ecore_wince_mouse_down_last_last_window = NULL; @@ -25,282 +30,527 @@ static long _ecore_wince_mouse_down_last_last_time = 0; static int _ecore_wince_mouse_down_did_triple = 0; static int _ecore_wince_mouse_up_count = 0; - -static void _ecore_wince_event_free_key_down(void *data, - void *ev); - -static void _ecore_wince_event_free_key_up(void *data, - void *ev); - -static int _ecore_wince_event_keystroke_get(int key, - char **keyname, - char **keysymbol, - char **keycompose); - -static int _ecore_wince_event_char_get(int key, - char **keyname, - char **keysymbol, - char **keycompose); - - -/***** Global functions *****/ - -void -_ecore_wince_event_handle_key_press(Ecore_WinCE_Callback_Data *msg, - int is_keystroke) +static void +_ecore_wince_event_free_key_down(void *data __UNUSED__, + void *ev) { Ecore_Event_Key *e; - INF("key pressed"); - - e = (Ecore_Event_Key *)malloc(sizeof(Ecore_Event_Key)); - if (!e) return; - - if (is_keystroke) - { - if (!_ecore_wince_event_keystroke_get(LOWORD(msg->window_param), - (char **)&e->keyname, - (char **)&e->key, - (char **)&e->string)) - { - free(e); - return; - } - } - else - { - if (!_ecore_wince_event_char_get(LOWORD(msg->window_param), - (char **)&e->keyname, - (char **)&e->key, - (char **)&e->string)) - { - free(e); - return; - } - } - - e->window = (Ecore_Window)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - e->timestamp = msg->time; - - _ecore_wince_event_last_time = e->timestamp; - - ecore_event_add(ECORE_EVENT_KEY_DOWN, e, _ecore_wince_event_free_key_down, NULL); + e = ev; + if (e->keyname) free((char *)e->keyname); + if (e->key) free((char *)e->key); + if (e->string) free((char *)e->string); + free(e); } -void -_ecore_wince_event_handle_key_release(Ecore_WinCE_Callback_Data *msg, - int is_keystroke) +static void +_ecore_wince_event_free_key_up(void *data __UNUSED__, + void *ev) { Ecore_Event_Key *e; - INF("key released"); - - e = (Ecore_Event_Key *)calloc(1, sizeof(Ecore_Event_Key)); - if (!e) return; - - if (is_keystroke) - { - if (!_ecore_wince_event_keystroke_get(LOWORD(msg->window_param), - (char **)&e->keyname, - (char **)&e->key, - (char **)&e->string)) - { - free(e); - return; - } - } - else - { - if (!_ecore_wince_event_char_get(LOWORD(msg->window_param), - (char **)&e->keyname, - (char **)&e->key, - (char **)&e->string)) - { - free(e); - return; - } - } - - e->window = (Ecore_Window)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - e->timestamp = msg->time; - - _ecore_wince_event_last_time = e->timestamp; - - ecore_event_add(ECORE_EVENT_KEY_UP, e, _ecore_wince_event_free_key_up, NULL); -} - -void -_ecore_wince_event_handle_button_press(Ecore_WinCE_Callback_Data *msg, - int button) -{ - Ecore_WinCE_Window *window; - - INF("mouse button pressed"); - - window = (Ecore_WinCE_Window *)GetWindowLong(msg->window, GWL_USERDATA); - - { - Ecore_Event_Mouse_Move *e; - - e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); - if (!e) return; - - e->window = (Ecore_Window)window; - e->x = LOWORD(msg->data_param); - e->y = HIWORD(msg->data_param); - e->timestamp = msg->time; - - _ecore_wince_event_last_time = e->timestamp; - _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; - - ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); - } - - { - Ecore_Event_Mouse_Button *e; - - if (_ecore_wince_mouse_down_did_triple) - { - _ecore_wince_mouse_down_last_window = NULL; - _ecore_wince_mouse_down_last_last_window = NULL; - _ecore_wince_mouse_down_last_time = 0; - _ecore_wince_mouse_down_last_last_time = 0; - } - - e = (Ecore_Event_Mouse_Button *)calloc(1, sizeof(Ecore_Event_Mouse_Button)); - if (!e) return; - - e->window = (Ecore_Window)window; - e->buttons = button; - e->x = LOWORD(msg->data_param); - e->y = HIWORD(msg->data_param); - e->timestamp = msg->time; - - if (((e->timestamp - _ecore_wince_mouse_down_last_time) <= (long)(1000 * _ecore_wince_double_click_time)) && - (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window)) - e->double_click = 1; - - if (((e->timestamp - _ecore_wince_mouse_down_last_last_time) <= (long)(2 * 1000 * _ecore_wince_double_click_time)) && - (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window) && - (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_last_window)) - { - e->triple_click = 1; - _ecore_wince_mouse_down_did_triple = 1; - } - else - _ecore_wince_mouse_down_did_triple = 0; - - if (!e->double_click && !e->triple_click) - _ecore_wince_mouse_up_count = 0; - - _ecore_wince_event_last_time = e->timestamp; - _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; - - if (!_ecore_wince_mouse_down_did_triple) - { - _ecore_wince_mouse_down_last_last_window = _ecore_wince_mouse_down_last_window; - _ecore_wince_mouse_down_last_window = (Ecore_WinCE_Window *)e->window; - _ecore_wince_mouse_down_last_last_time = _ecore_wince_mouse_down_last_time; - _ecore_wince_mouse_down_last_time = e->timestamp; - } - - ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL); - } + e = ev; + if (e->keyname) free((char *)e->keyname); + if (e->key) free((char *)e->key); + if (e->string) free((char *)e->string); + free(e); } -void -_ecore_wince_event_handle_button_release(Ecore_WinCE_Callback_Data *msg, - int button) +static int +_ecore_wince_event_keystroke_get(int key, + char **keyname, + char **keysymbol, + char **keycompose) { - Ecore_WinCE_Window *window; - - INF("mouse button released"); - - window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - - { - Ecore_Event_Mouse_Move *e; - - e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); - if (!e) return; - - e->window = (Ecore_Window)window; - e->x = LOWORD(msg->data_param); - e->y = HIWORD(msg->data_param); - e->timestamp = msg->time; - - _ecore_wince_event_last_time = e->timestamp; - _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; - - ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); - } - - { - Ecore_Event_Mouse_Button *e; - - e = (Ecore_Event_Mouse_Button *)calloc(1, sizeof(Ecore_Event_Mouse_Button)); - if (!e) return; - - e->window = (Ecore_Window)window; - e->buttons = button; - e->x = LOWORD(msg->data_param); - e->y = HIWORD(msg->data_param); - e->timestamp = msg->time; - - _ecore_wince_mouse_up_count++; - - if ((_ecore_wince_mouse_up_count >= 2) && - ((e->timestamp - _ecore_wince_mouse_down_last_time) <= (long)(1000 * _ecore_wince_double_click_time)) && - (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window)) - e->double_click = 1; - - if ((_ecore_wince_mouse_up_count >= 3) && - ((e->timestamp - _ecore_wince_mouse_down_last_last_time) <= (long)(2 * 1000 * _ecore_wince_double_click_time)) && - (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window) && - (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_last_window)) - e->triple_click = 1; - - _ecore_wince_event_last_time = e->timestamp; - _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; + char *kn; + char *ks; + char *kc; - ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL); - } -} + *keyname = NULL; + *keysymbol = NULL; + *keycompose = NULL; -void -_ecore_wince_event_handle_motion_notify(Ecore_WinCE_Callback_Data *msg) -{ - Ecore_Event_Mouse_Move *e; + switch (key) + { + /* Keystroke */ + case VK_PRIOR: + kn = "Prior"; + ks = "Prior"; + kc = "Prior"; + break; + case VK_NEXT: + kn = "Next"; + ks = "Next"; + kc = "Next"; + break; + case VK_END: + kn = "End"; + ks = "End"; + kc = "End"; + break; + case VK_HOME: + kn = "Home"; + ks = "Home"; + kc = "Home"; + break; + case VK_LEFT: + kn = "Left"; + ks = "Left"; + kc = "Left"; + break; + case VK_UP: + kn = "Up"; + ks = "Up"; + kc = "Up"; + break; + case VK_RIGHT: + kn = "Right"; + ks = "Right"; + kc = "Right"; + break; + case VK_DOWN: + kn = "Down"; + ks = "Down"; + kc = "Down"; + break; + case VK_INSERT: + kn = "Insert"; + ks = "Insert"; + kc = "Insert"; + break; + case VK_DELETE: + kn = "Delete"; + ks = "Delete"; + kc = "Delete"; + break; + case VK_F1: + kn = "F1"; + ks = "F1"; + kc = ""; + break; + case VK_F2: + kn = "F2"; + ks = "F2"; + kc = ""; + break; + case VK_F3: + kn = "F3"; + ks = "F3"; + kc = ""; + break; + case VK_F4: + kn = "F4"; + ks = "F4"; + kc = ""; + break; + case VK_F5: + kn = "F5"; + ks = "F5"; + kc = ""; + break; + case VK_F6: + kn = "F6"; + ks = "F6"; + kc = ""; + break; + case VK_F7: + kn = "F7"; + ks = "F7"; + kc = ""; + break; + case VK_F8: + kn = "F8"; + ks = "F8"; + kc = ""; + break; + case VK_F9: + kn = "F9"; + ks = "F9"; + kc = ""; + break; + case VK_F10: + kn = "F10"; + ks = "F10"; + kc = ""; + break; + case VK_F11: + kn = "F11"; + ks = "F11"; + kc = ""; + break; + case VK_F12: + kn = "F12"; + ks = "F12"; + kc = ""; + break; + case VK_F13: + kn = "F13"; + ks = "F13"; + kc = ""; + break; + case VK_F14: + kn = "F14"; + ks = "F14"; + kc = ""; + break; + case VK_F15: + kn = "F15"; + ks = "F15"; + kc = ""; + break; + case VK_F16: + kn = "F16"; + ks = "F16"; + kc = ""; + break; + case VK_F17: + kn = "F17"; + ks = "F17"; + kc = ""; + break; + case VK_F18: + kn = "F18"; + ks = "F18"; + kc = ""; + break; + case VK_F19: + kn = "F19"; + ks = "F19"; + kc = ""; + break; + case VK_F20: + /* + * VK_F20 indicates that an arrow key came from a rocker. + * This can safely be ignored. + */ + return 0; + case VK_F21: + /* + * VK_F21 indicates that an arrow key came from a directional + * pad. This can safely be ignored. + */ + return 0; + case VK_F22: + kn = "F22"; + ks = "F22"; + kc = ""; + break; + case VK_F23: + /* + * Sent with VK_RETURN when doing an action (usually the middle + * button on a directional pad. This can safely be ignored. + */ + return 0; + case VK_F24: + kn = "F24"; + ks = "F24"; + kc = ""; + break; + case VK_APPS: + kn = "Application"; + ks = "Application"; + kc = ""; + break; + case VK_MENU: + kn = "Menu"; + ks = "Menu"; + kc = ""; + break; + default: + /* other non keystroke characters */ + return 0; + } + *keyname = strdup(kn); + if (!*keyname) return 0; + *keysymbol = strdup(ks); + if (!*keysymbol) + { + free(*keyname); + *keyname = NULL; + return 0; + } + *keycompose = strdup(kc); + if (!*keycompose) + { + free(*keyname); + free(*keysymbol); + *keyname = NULL; + *keysymbol = NULL; + return 0; + } - INF("mouse moved"); + return 1; +} - e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); +static int +_ecore_wince_event_char_get(int key, + char **keyname, + char **keysymbol, + char **keycompose) +{ + char kn[32]; + char ks[32]; + char kc[32]; + + *keyname = NULL; + *keysymbol = NULL; + *keycompose = NULL; + + switch (key) + { + case VK_APP3: + case VK_BACK: + strncpy(kn, "BackSpace", 32); + strncpy(ks, "BackSpace", 32); + strncpy(kc, "BackSpace", 32); + break; + case VK_APP4: + case VK_TAB: + strncpy(kn, "Tab", 32); + strncpy(ks, "Tab", 32); + strncpy(kc, "Tab", 32); + break; + case VK_APP5: + case 0x0a: + /* Line feed (Shift + Enter) */ + strncpy(kn, "LineFeed", 32); + strncpy(ks, "LineFeed", 32); + strncpy(kc, "LineFeed", 32); + break; + case VK_APP2: + case VK_RETURN: + strncpy(kn, "Return", 32); + strncpy(ks, "Return", 32); + strncpy(kc, "Return", 32); + break; + case VK_APP1: + case VK_ESCAPE: + strncpy(kn, "Escape", 32); + strncpy(ks, "Escape", 32); + strncpy(kc, "Escape", 32); + break; + default: + /* displayable characters */ + printf (" * key : %d\n", key); + kn[0] = (TCHAR)key; + kn[1] = '\0'; + ks[0] = (TCHAR)key; + ks[1] = '\0'; + kc[0] = (TCHAR)key; + kc[1] = '\0'; + break; + } + *keyname = strdup(kn); + if (!*keyname) return 0; + *keysymbol = strdup(ks); + if (!*keysymbol) + { + free(*keyname); + *keyname = NULL; + return 0; + } + *keycompose = strdup(kc); + if (!*keycompose) + { + free(*keyname); + free(*keysymbol); + *keyname = NULL; + *keysymbol = NULL; + return 0; + } + + return 1; +} + +/** + * @endcond + */ + + +/*============================================================================* + * Global * + *============================================================================*/ + +void +_ecore_wince_event_handle_key_press(Ecore_WinCE_Callback_Data *msg, + int is_keystroke) +{ + Ecore_Event_Key *e; + + INF("key pressed"); + + e = (Ecore_Event_Key *)malloc(sizeof(Ecore_Event_Key)); if (!e) return; + if (is_keystroke) + { + if (!_ecore_wince_event_keystroke_get(LOWORD(msg->window_param), + (char **)&e->keyname, + (char **)&e->key, + (char **)&e->string)) + { + free(e); + return; + } + } + else + { + if (!_ecore_wince_event_char_get(LOWORD(msg->window_param), + (char **)&e->keyname, + (char **)&e->key, + (char **)&e->string)) + { + free(e); + return; + } + } + e->window = (Ecore_Window)GetWindowLong(msg->window, GWL_USERDATA); - e->x = LOWORD(msg->data_param); - e->y = HIWORD(msg->data_param); + if (!e->window) + { + free(e); + return; + } e->timestamp = msg->time; - ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); + _ecore_wince_event_last_time = e->timestamp; + + ecore_event_add(ECORE_EVENT_KEY_DOWN, e, _ecore_wince_event_free_key_down, NULL); } void -_ecore_wince_event_handle_enter_notify(Ecore_WinCE_Callback_Data *msg) +_ecore_wince_event_handle_key_release(Ecore_WinCE_Callback_Data *msg, + int is_keystroke) +{ + Ecore_Event_Key *e; + + INF("key released"); + + e = (Ecore_Event_Key *)calloc(1, sizeof(Ecore_Event_Key)); + if (!e) return; + + if (is_keystroke) + { + if (!_ecore_wince_event_keystroke_get(LOWORD(msg->window_param), + (char **)&e->keyname, + (char **)&e->key, + (char **)&e->string)) + { + free(e); + return; + } + } + else + { + if (!_ecore_wince_event_char_get(LOWORD(msg->window_param), + (char **)&e->keyname, + (char **)&e->key, + (char **)&e->string)) + { + free(e); + return; + } + } + + e->window = (Ecore_Window)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) + { + free(e); + return; + } + e->timestamp = msg->time; + + _ecore_wince_event_last_time = e->timestamp; + + ecore_event_add(ECORE_EVENT_KEY_UP, e, _ecore_wince_event_free_key_up, NULL); +} + +void +_ecore_wince_event_handle_button_press(Ecore_WinCE_Callback_Data *msg, + int button) +{ + Ecore_WinCE_Window *window; + + INF("mouse button pressed"); + + window = (Ecore_WinCE_Window *)GetWindowLong(msg->window, GWL_USERDATA); + + { + Ecore_Event_Mouse_Move *e; + + e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); + if (!e) return; + + e->window = (Ecore_Window)window; + e->x = LOWORD(msg->data_param); + e->y = HIWORD(msg->data_param); + e->timestamp = msg->time; + + _ecore_wince_event_last_time = e->timestamp; + _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; + + ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); + } + + { + Ecore_Event_Mouse_Button *e; + + if (_ecore_wince_mouse_down_did_triple) + { + _ecore_wince_mouse_down_last_window = NULL; + _ecore_wince_mouse_down_last_last_window = NULL; + _ecore_wince_mouse_down_last_time = 0; + _ecore_wince_mouse_down_last_last_time = 0; + } + + e = (Ecore_Event_Mouse_Button *)calloc(1, sizeof(Ecore_Event_Mouse_Button)); + if (!e) return; + + e->window = (Ecore_Window)window; + e->buttons = button; + e->x = LOWORD(msg->data_param); + e->y = HIWORD(msg->data_param); + e->timestamp = msg->time; + + if (((e->timestamp - _ecore_wince_mouse_down_last_time) <= (long)(1000 * _ecore_wince_double_click_time)) && + (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window)) + e->double_click = 1; + + if (((e->timestamp - _ecore_wince_mouse_down_last_last_time) <= (long)(2 * 1000 * _ecore_wince_double_click_time)) && + (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window) && + (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_last_window)) + { + e->triple_click = 1; + _ecore_wince_mouse_down_did_triple = 1; + } + else + _ecore_wince_mouse_down_did_triple = 0; + + if (!e->double_click && !e->triple_click) + _ecore_wince_mouse_up_count = 0; + + _ecore_wince_event_last_time = e->timestamp; + _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; + + if (!_ecore_wince_mouse_down_did_triple) + { + _ecore_wince_mouse_down_last_last_window = _ecore_wince_mouse_down_last_window; + _ecore_wince_mouse_down_last_window = (Ecore_WinCE_Window *)e->window; + _ecore_wince_mouse_down_last_last_time = _ecore_wince_mouse_down_last_time; + _ecore_wince_mouse_down_last_time = e->timestamp; + } + + ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, e, NULL, NULL); + } +} + +void +_ecore_wince_event_handle_button_release(Ecore_WinCE_Callback_Data *msg, + int button) { Ecore_WinCE_Window *window; - INF("mouse in"); + INF("mouse button released"); window = (void *)GetWindowLong(msg->window, GWL_USERDATA); @@ -311,8 +561,8 @@ _ecore_wince_event_handle_enter_notify(Ecore_WinCE_Callback_Data *msg) if (!e) return; e->window = (Ecore_Window)window; - e->x = msg->x; - e->y = msg->y; + e->x = LOWORD(msg->data_param); + e->y = HIWORD(msg->data_param); e->timestamp = msg->time; _ecore_wince_event_last_time = e->timestamp; @@ -322,28 +572,61 @@ _ecore_wince_event_handle_enter_notify(Ecore_WinCE_Callback_Data *msg) } { - Ecore_WinCE_Event_Mouse_In *e; + Ecore_Event_Mouse_Button *e; - e = (Ecore_WinCE_Event_Mouse_In *)calloc(1, sizeof(Ecore_WinCE_Event_Mouse_In)); + e = (Ecore_Event_Mouse_Button *)calloc(1, sizeof(Ecore_Event_Mouse_Button)); if (!e) return; - e->window = window; - e->x = msg->x; - e->y = msg->y; - e->time = msg->time; + e->window = (Ecore_Window)window; + e->buttons = button; + e->x = LOWORD(msg->data_param); + e->y = HIWORD(msg->data_param); + e->timestamp = msg->time; - _ecore_wince_event_last_time = e->time; + _ecore_wince_mouse_up_count++; - ecore_event_add(ECORE_WINCE_EVENT_MOUSE_IN, e, NULL, NULL); + if ((_ecore_wince_mouse_up_count >= 2) && + ((e->timestamp - _ecore_wince_mouse_down_last_time) <= (long)(1000 * _ecore_wince_double_click_time)) && + (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window)) + e->double_click = 1; + + if ((_ecore_wince_mouse_up_count >= 3) && + ((e->timestamp - _ecore_wince_mouse_down_last_last_time) <= (long)(2 * 1000 * _ecore_wince_double_click_time)) && + (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_window) && + (e->window == (Ecore_Window)_ecore_wince_mouse_down_last_last_window)) + e->triple_click = 1; + + _ecore_wince_event_last_time = e->timestamp; + _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; + + ecore_event_add(ECORE_EVENT_MOUSE_BUTTON_UP, e, NULL, NULL); } } void -_ecore_wince_event_handle_leave_notify(Ecore_WinCE_Callback_Data *msg) +_ecore_wince_event_handle_motion_notify(Ecore_WinCE_Callback_Data *msg) +{ + Ecore_Event_Mouse_Move *e; + + INF("mouse moved"); + + e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); + if (!e) return; + + e->window = (Ecore_Window)GetWindowLong(msg->window, GWL_USERDATA); + e->x = LOWORD(msg->data_param); + e->y = HIWORD(msg->data_param); + e->timestamp = msg->time; + + ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); +} + +void +_ecore_wince_event_handle_enter_notify(Ecore_WinCE_Callback_Data *msg) { Ecore_WinCE_Window *window; - INF("mouse out"); + INF("mouse in"); window = (void *)GetWindowLong(msg->window, GWL_USERDATA); @@ -365,9 +648,9 @@ _ecore_wince_event_handle_leave_notify(Ecore_WinCE_Callback_Data *msg) } { - Ecore_WinCE_Event_Mouse_Out *e; + Ecore_WinCE_Event_Mouse_In *e; - e = (Ecore_WinCE_Event_Mouse_Out *)calloc(1, sizeof(Ecore_WinCE_Event_Mouse_Out)); + e = (Ecore_WinCE_Event_Mouse_In *)calloc(1, sizeof(Ecore_WinCE_Event_Mouse_In)); if (!e) return; e->window = window; @@ -377,537 +660,250 @@ _ecore_wince_event_handle_leave_notify(Ecore_WinCE_Callback_Data *msg) _ecore_wince_event_last_time = e->time; - ecore_event_add(ECORE_WINCE_EVENT_MOUSE_OUT, e, NULL, NULL); + ecore_event_add(ECORE_WINCE_EVENT_MOUSE_IN, e, NULL, NULL); } } void -_ecore_wince_event_handle_focus_in(Ecore_WinCE_Callback_Data *msg) -{ - Ecore_WinCE_Event_Window_Focus_In *e; - struct _Ecore_WinCE_Window *window; - - INF("focus in"); - - e = (Ecore_WinCE_Event_Window_Focus_In *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Focus_In)); - if (!e) return; - - window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - - if (window->resume) - window->resume(window->backend); - - e->window = window; - - e->time = _ecore_wince_event_last_time; - _ecore_wince_event_last_time = e->time; - - ecore_event_add(ECORE_WINCE_EVENT_WINDOW_FOCUS_IN, e, NULL, NULL); -} - -void -_ecore_wince_event_handle_focus_out(Ecore_WinCE_Callback_Data *msg) -{ - Ecore_WinCE_Event_Window_Focus_Out *e; - struct _Ecore_WinCE_Window *window; - - INF("focus out"); - - e = (Ecore_WinCE_Event_Window_Focus_Out *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Focus_Out)); - if (!e) return; - - window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - if (window->suspend) - window->suspend(window->backend); - - e->window = window; - - e->time = _ecore_wince_event_last_time; - _ecore_wince_event_last_time = e->time; - - ecore_event_add(ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT, e, NULL, NULL); -} - -void -_ecore_wince_event_handle_expose(Ecore_WinCE_Callback_Data *msg) -{ - Ecore_WinCE_Event_Window_Damage *e; - - INF("window expose"); - - e = (Ecore_WinCE_Event_Window_Damage *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Damage)); - if (!e) return; - - e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - - e->x = msg->update.left; - e->y = msg->update.top; - e->width = msg->update.right - msg->update.left; - e->height = msg->update.bottom - msg->update.top; - INF("window expose size: %dx%d", e->width, e->height); - - e->time = _ecore_wince_event_last_time; - - ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DAMAGE, e, NULL, NULL); -} - -void -_ecore_wince_event_handle_create_notify(Ecore_WinCE_Callback_Data *msg) -{ - Ecore_WinCE_Event_Window_Create *e; - - INF("window create notify"); - - e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Create)); - if (!e) return; - - e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - - e->time = _ecore_wince_event_last_time; - - ecore_event_add(ECORE_WINCE_EVENT_WINDOW_CREATE, e, NULL, NULL); -} - -void -_ecore_wince_event_handle_destroy_notify(Ecore_WinCE_Callback_Data *msg) -{ - Ecore_WinCE_Event_Window_Destroy *e; - - INF("window destroy notify"); - - e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Destroy)); - if (!e) return; - - e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - - e->time = _ecore_wince_event_last_time; -/* if (e->window == _ecore_wince_event_last_window) _ecore_wince_event_last_window = NULL; */ - - ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DESTROY, e, NULL, NULL); -} - -void -_ecore_wince_event_handle_map_notify(Ecore_WinCE_Callback_Data *msg) -{ - Ecore_WinCE_Event_Window_Show *e; - - INF("window map notify"); - - e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Show)); - if (!e) return; - - e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - - e->time = _ecore_wince_event_last_time; - - ecore_event_add(ECORE_WINCE_EVENT_WINDOW_SHOW, e, NULL, NULL); -} - -void -_ecore_wince_event_handle_unmap_notify(Ecore_WinCE_Callback_Data *msg) -{ - Ecore_WinCE_Event_Window_Hide *e; - - INF("window unmap notify"); - - e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Hide)); - if (!e) return; - - e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } - - e->time = _ecore_wince_event_last_time; - - ecore_event_add(ECORE_WINCE_EVENT_WINDOW_HIDE, e, NULL, NULL); -} - -void -_ecore_wince_event_handle_delete_request(Ecore_WinCE_Callback_Data *msg) +_ecore_wince_event_handle_leave_notify(Ecore_WinCE_Callback_Data *msg) { - Ecore_WinCE_Event_Window_Delete_Request *e; - - INF("window delete request"); + Ecore_WinCE_Window *window; - e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Delete_Request)); - if (!e) return; + INF("mouse out"); - e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - if (!e->window) - { - free(e); - return; - } + window = (void *)GetWindowLong(msg->window, GWL_USERDATA); - e->time = _ecore_wince_event_last_time; + { + Ecore_Event_Mouse_Move *e; - ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL); -} + e = (Ecore_Event_Mouse_Move *)calloc(1, sizeof(Ecore_Event_Mouse_Move)); + if (!e) return; + e->window = (Ecore_Window)window; + e->x = msg->x; + e->y = msg->y; + e->timestamp = msg->time; -/***** Private functions definitions *****/ + _ecore_wince_event_last_time = e->timestamp; + _ecore_wince_event_last_window = (Ecore_WinCE_Window *)e->window; -static void -_ecore_wince_event_free_key_down(void *data __UNUSED__, - void *ev) -{ - Ecore_Event_Key *e; + ecore_event_add(ECORE_EVENT_MOUSE_MOVE, e, NULL, NULL); + } - e = ev; - if (e->keyname) free((char *)e->keyname); - if (e->key) free((char *)e->key); - if (e->string) free((char *)e->string); - free(e); -} + { + Ecore_WinCE_Event_Mouse_Out *e; -static void -_ecore_wince_event_free_key_up(void *data __UNUSED__, - void *ev) -{ - Ecore_Event_Key *e; + e = (Ecore_WinCE_Event_Mouse_Out *)calloc(1, sizeof(Ecore_WinCE_Event_Mouse_Out)); + if (!e) return; - e = ev; - if (e->keyname) free((char *)e->keyname); - if (e->key) free((char *)e->key); - if (e->string) free((char *)e->string); - free(e); -} + e->window = window; + e->x = msg->x; + e->y = msg->y; + e->time = msg->time; -static int -_ecore_wince_event_keystroke_get(int key, - char **keyname, - char **keysymbol, - char **keycompose) -{ - char *kn; - char *ks; - char *kc; + _ecore_wince_event_last_time = e->time; - *keyname = NULL; - *keysymbol = NULL; - *keycompose = NULL; + ecore_event_add(ECORE_WINCE_EVENT_MOUSE_OUT, e, NULL, NULL); + } +} - switch (key) - { - /* Keystroke */ - case VK_PRIOR: - kn = "Prior"; - ks = "Prior"; - kc = "Prior"; - break; - case VK_NEXT: - kn = "Next"; - ks = "Next"; - kc = "Next"; - break; - case VK_END: - kn = "End"; - ks = "End"; - kc = "End"; - break; - case VK_HOME: - kn = "Home"; - ks = "Home"; - kc = "Home"; - break; - case VK_LEFT: - kn = "Left"; - ks = "Left"; - kc = "Left"; - break; - case VK_UP: - kn = "Up"; - ks = "Up"; - kc = "Up"; - break; - case VK_RIGHT: - kn = "Right"; - ks = "Right"; - kc = "Right"; - break; - case VK_DOWN: - kn = "Down"; - ks = "Down"; - kc = "Down"; - break; - case VK_INSERT: - kn = "Insert"; - ks = "Insert"; - kc = "Insert"; - break; - case VK_DELETE: - kn = "Delete"; - ks = "Delete"; - kc = "Delete"; - break; - case VK_F1: - kn = "F1"; - ks = "F1"; - kc = ""; - break; - case VK_F2: - kn = "F2"; - ks = "F2"; - kc = ""; - break; - case VK_F3: - kn = "F3"; - ks = "F3"; - kc = ""; - break; - case VK_F4: - kn = "F4"; - ks = "F4"; - kc = ""; - break; - case VK_F5: - kn = "F5"; - ks = "F5"; - kc = ""; - break; - case VK_F6: - kn = "F6"; - ks = "F6"; - kc = ""; - break; - case VK_F7: - kn = "F7"; - ks = "F7"; - kc = ""; - break; - case VK_F8: - kn = "F8"; - ks = "F8"; - kc = ""; - break; - case VK_F9: - kn = "F9"; - ks = "F9"; - kc = ""; - break; - case VK_F10: - kn = "F10"; - ks = "F10"; - kc = ""; - break; - case VK_F11: - kn = "F11"; - ks = "F11"; - kc = ""; - break; - case VK_F12: - kn = "F12"; - ks = "F12"; - kc = ""; - break; - case VK_F13: - kn = "F13"; - ks = "F13"; - kc = ""; - break; - case VK_F14: - kn = "F14"; - ks = "F14"; - kc = ""; - break; - case VK_F15: - kn = "F15"; - ks = "F15"; - kc = ""; - break; - case VK_F16: - kn = "F16"; - ks = "F16"; - kc = ""; - break; - case VK_F17: - kn = "F17"; - ks = "F17"; - kc = ""; - break; - case VK_F18: - kn = "F18"; - ks = "F18"; - kc = ""; - break; - case VK_F19: - kn = "F19"; - ks = "F19"; - kc = ""; - break; - case VK_F20: - /* - * VK_F20 indicates that an arrow key came from a rocker. - * This can safely be ignored. - */ - return 0; - case VK_F21: - /* - * VK_F21 indicates that an arrow key came from a directional - * pad. This can safely be ignored. - */ - return 0; - case VK_F22: - kn = "F22"; - ks = "F22"; - kc = ""; - break; - case VK_F23: - /* - * Sent with VK_RETURN when doing an action (usually the middle - * button on a directional pad. This can safely be ignored. - */ - return 0; - case VK_F24: - kn = "F24"; - ks = "F24"; - kc = ""; - break; - case VK_APPS: - kn = "Application"; - ks = "Application"; - kc = ""; - break; - case VK_MENU: - kn = "Menu"; - ks = "Menu"; - kc = ""; - break; - default: - /* other non keystroke characters */ - return 0; +void +_ecore_wince_event_handle_focus_in(Ecore_WinCE_Callback_Data *msg) +{ + Ecore_WinCE_Event_Window_Focus_In *e; + struct _Ecore_WinCE_Window *window; + + INF("focus in"); + + e = (Ecore_WinCE_Event_Window_Focus_In *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Focus_In)); + if (!e) return; + + window = (void *)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) + { + free(e); + return; } - *keyname = strdup(kn); - if (!*keyname) return 0; - *keysymbol = strdup(ks); - if (!*keysymbol) + + if (window->resume) + window->resume(window->backend); + + e->window = window; + + e->time = _ecore_wince_event_last_time; + _ecore_wince_event_last_time = e->time; + + ecore_event_add(ECORE_WINCE_EVENT_WINDOW_FOCUS_IN, e, NULL, NULL); +} + +void +_ecore_wince_event_handle_focus_out(Ecore_WinCE_Callback_Data *msg) +{ + Ecore_WinCE_Event_Window_Focus_Out *e; + struct _Ecore_WinCE_Window *window; + + INF("focus out"); + + e = (Ecore_WinCE_Event_Window_Focus_Out *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Focus_Out)); + if (!e) return; + + window = (void *)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) { - free(*keyname); - *keyname = NULL; - return 0; + free(e); + return; } - *keycompose = strdup(kc); - if (!*keycompose) + if (window->suspend) + window->suspend(window->backend); + + e->window = window; + + e->time = _ecore_wince_event_last_time; + _ecore_wince_event_last_time = e->time; + + ecore_event_add(ECORE_WINCE_EVENT_WINDOW_FOCUS_OUT, e, NULL, NULL); +} + +void +_ecore_wince_event_handle_expose(Ecore_WinCE_Callback_Data *msg) +{ + Ecore_WinCE_Event_Window_Damage *e; + + INF("window expose"); + + e = (Ecore_WinCE_Event_Window_Damage *)calloc(1, sizeof(Ecore_WinCE_Event_Window_Damage)); + if (!e) return; + + e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) { - free(*keyname); - free(*keysymbol); - *keyname = NULL; - *keysymbol = NULL; - return 0; + free(e); + return; } - return 1; + e->x = msg->update.left; + e->y = msg->update.top; + e->width = msg->update.right - msg->update.left; + e->height = msg->update.bottom - msg->update.top; + INF("window expose size: %dx%d", e->width, e->height); + + e->time = _ecore_wince_event_last_time; + + ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DAMAGE, e, NULL, NULL); } -static int -_ecore_wince_event_char_get(int key, - char **keyname, - char **keysymbol, - char **keycompose) +void +_ecore_wince_event_handle_create_notify(Ecore_WinCE_Callback_Data *msg) { - char kn[32]; - char ks[32]; - char kc[32]; + Ecore_WinCE_Event_Window_Create *e; - *keyname = NULL; - *keysymbol = NULL; - *keycompose = NULL; + INF("window create notify"); - switch (key) + e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Create)); + if (!e) return; + + e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) { - case VK_APP3: - case VK_BACK: - strncpy(kn, "BackSpace", 32); - strncpy(ks, "BackSpace", 32); - strncpy(kc, "BackSpace", 32); - break; - case VK_APP4: - case VK_TAB: - strncpy(kn, "Tab", 32); - strncpy(ks, "Tab", 32); - strncpy(kc, "Tab", 32); - break; - case VK_APP5: - case 0x0a: - /* Line feed (Shift + Enter) */ - strncpy(kn, "LineFeed", 32); - strncpy(ks, "LineFeed", 32); - strncpy(kc, "LineFeed", 32); - break; - case VK_APP2: - case VK_RETURN: - strncpy(kn, "Return", 32); - strncpy(ks, "Return", 32); - strncpy(kc, "Return", 32); - break; - case VK_APP1: - case VK_ESCAPE: - strncpy(kn, "Escape", 32); - strncpy(ks, "Escape", 32); - strncpy(kc, "Escape", 32); - break; - default: - /* displayable characters */ - printf (" * key : %d\n", key); - kn[0] = (TCHAR)key; - kn[1] = '\0'; - ks[0] = (TCHAR)key; - ks[1] = '\0'; - kc[0] = (TCHAR)key; - kc[1] = '\0'; - break; + free(e); + return; } - *keyname = strdup(kn); - if (!*keyname) return 0; - *keysymbol = strdup(ks); - if (!*keysymbol) + + e->time = _ecore_wince_event_last_time; + + ecore_event_add(ECORE_WINCE_EVENT_WINDOW_CREATE, e, NULL, NULL); +} + +void +_ecore_wince_event_handle_destroy_notify(Ecore_WinCE_Callback_Data *msg) +{ + Ecore_WinCE_Event_Window_Destroy *e; + + INF("window destroy notify"); + + e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Destroy)); + if (!e) return; + + e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) { - free(*keyname); - *keyname = NULL; - return 0; + free(e); + return; } - *keycompose = strdup(kc); - if (!*keycompose) + + e->time = _ecore_wince_event_last_time; +/* if (e->window == _ecore_wince_event_last_window) _ecore_wince_event_last_window = NULL; */ + + ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DESTROY, e, NULL, NULL); +} + +void +_ecore_wince_event_handle_map_notify(Ecore_WinCE_Callback_Data *msg) +{ + Ecore_WinCE_Event_Window_Show *e; + + INF("window map notify"); + + e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Show)); + if (!e) return; + + e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) { - free(*keyname); - free(*keysymbol); - *keyname = NULL; - *keysymbol = NULL; - return 0; + free(e); + return; } - return 1; + e->time = _ecore_wince_event_last_time; + + ecore_event_add(ECORE_WINCE_EVENT_WINDOW_SHOW, e, NULL, NULL); +} + +void +_ecore_wince_event_handle_unmap_notify(Ecore_WinCE_Callback_Data *msg) +{ + Ecore_WinCE_Event_Window_Hide *e; + + INF("window unmap notify"); + + e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Hide)); + if (!e) return; + + e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) + { + free(e); + return; + } + + e->time = _ecore_wince_event_last_time; + + ecore_event_add(ECORE_WINCE_EVENT_WINDOW_HIDE, e, NULL, NULL); +} + +void +_ecore_wince_event_handle_delete_request(Ecore_WinCE_Callback_Data *msg) +{ + Ecore_WinCE_Event_Window_Delete_Request *e; + + INF("window delete request"); + + e = calloc(1, sizeof(Ecore_WinCE_Event_Window_Delete_Request)); + if (!e) return; + + e->window = (void *)GetWindowLong(msg->window, GWL_USERDATA); + if (!e->window) + { + free(e); + return; + } + + e->time = _ecore_wince_event_last_time; + + ecore_event_add(ECORE_WINCE_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL); } + +/*============================================================================* + * API * + *============================================================================*/ + diff --git a/src/lib/ecore_wince/ecore_wince_window.c b/src/lib/ecore_wince/ecore_wince_window.c index 1863f07..12cbcfb 100644 --- a/src/lib/ecore_wince/ecore_wince_window.c +++ b/src/lib/ecore_wince/ecore_wince_window.c @@ -12,17 +12,87 @@ #include "Ecore_WinCE.h" #include "ecore_wince_private.h" +/*============================================================================* + * Local * + *============================================================================*/ + +/** + * @cond LOCAL + */ -/***** Private declarations *****/ typedef BOOL (__stdcall *UnregisterFunc1Proc)(UINT, UINT); -static int _ecore_wince_hardware_keys_register(HWND window); +static int +_ecore_wince_hardware_keys_register(HWND window) +{ + HINSTANCE core_dll; + UnregisterFunc1Proc unregister_fct; + int i; + core_dll = LoadLibrary(L"coredll.dll"); + if (!core_dll) + { + ERR("LoadLibrary() failed"); + return 0; + } -/***** API *****/ + unregister_fct = (UnregisterFunc1Proc)GetProcAddress(core_dll, L"UnregisterFunc1"); + if (!unregister_fct) + { + ERR("GetProcAddress() failed"); + FreeLibrary(core_dll); + return 0; + } + + for (i = 0xc1; i <= 0xcf; i++) + { + unregister_fct(MOD_WIN, i); + RegisterHotKey(window, i, MOD_WIN, i); + } + + FreeLibrary(core_dll); + + return 1; +} -Ecore_WinCE_Window * +/** + * @endcond + */ + + +/*============================================================================* + * Global * + *============================================================================*/ + +/*============================================================================* + * API * + *============================================================================*/ + +/** + * @addtogroup Ecore_WinCE_Group Ecore_WinCE library + * + * @{ + */ + +/** + * @brief Creates a new window. + * + * @param parent The parent window. + * @param x The x coordinate of the top-left corner of the window. + * @param y The y coordinate of the top-left corner of the window. + * @param width The width of the window. + * @param height The height of hte window. + * @return A newly allocated window. + * + * This function creates a new window which parent is @p parent. @p width and + * @p height are the size of the window content (the client part), + * without the border and title bar. @p x and @p y are the system + * coordinates of the top left cerner of the window (that is, of the + * title bar). This function returns a newly created window on + * success, and @c NULL on failure. + */ +EAPI Ecore_WinCE_Window * ecore_wince_window_new(Ecore_WinCE_Window *parent, int x, int y, @@ -92,7 +162,15 @@ ecore_wince_window_new(Ecore_WinCE_Window *parent, return w; } -void +/** + * @brief Free the given window. + * + * @param window The window to free. + * + * This function frees @p window. If @p window is @c NULL, this + * function does nothing. + */ +EAPI void ecore_wince_window_free(Ecore_WinCE_Window *window) { if (!window) return; @@ -103,7 +181,15 @@ ecore_wince_window_free(Ecore_WinCE_Window *window) free(window); } -void * +/** + * @brief Return the window HANDLE associated to the given window. + * + * @param window The window to retrieve the HANDLE from. + * + * This function returns the window HANDLE associated to @p window. If + * @p window is @c NULL, this function returns @c NULL. + */ +EAPI void * ecore_wince_window_hwnd_get(Ecore_WinCE_Window *window) { if (!window) @@ -112,7 +198,18 @@ ecore_wince_window_hwnd_get(Ecore_WinCE_Window *window) return ((struct _Ecore_WinCE_Window *)window)->window; } -void +/** + * @brief Move the given window to a given position. + * + * @param window The window to move. + * @param x The x coordinate of the destination position. + * @param y The y coordinate of the destination position. + * + * This function move @p window to the new position of coordinates @p x + * and @p y. If @p window is @c NULL, or if it is fullscreen, or on + * error, this function does nothing. + */ +EAPI void ecore_wince_window_move(Ecore_WinCE_Window *window, int x, int y) @@ -141,7 +238,18 @@ ecore_wince_window_move(Ecore_WinCE_Window *window, } } -void +/** + * @brief Resize the given window to a given size. + * + * @param window The window to resize. + * @param width The new width. + * @param height The new height. + * + * This function resize @p window to the new @p width and @p height. + * If @p window is @c NULL, or if it is fullscreen, or on error, this + * function does nothing. + */ +EAPI void ecore_wince_window_resize(Ecore_WinCE_Window *window, int width, int height) @@ -196,7 +304,20 @@ ecore_wince_window_resize(Ecore_WinCE_Window *window, } } -void +/** + * @brief Move and resize the given window to a given position and size. + * + * @param window The window to move and resize. + * @param x The x coordinate of the destination position. + * @param y The x coordinate of the destination position. + * @param width The new width. + * @param height The new height. + * + * This function resize @p window to the new position of coordinates @p x + * and @p y and the new @p width and @p height. If @p window is @c NULL, + * or if it is fullscreen, or on error, this function does nothing. + */ +EAPI void ecore_wince_window_move_resize(Ecore_WinCE_Window *window, int x, int y, @@ -243,7 +364,15 @@ ecore_wince_window_move_resize(Ecore_WinCE_Window *window, } } -void +/** + * @brief Show the given window. + * + * @param window The window to show. + * + * This function shows @p window. If @p window is @c NULL, or on + * error, this function does nothing. + */ +EAPI void ecore_wince_window_show(Ecore_WinCE_Window *window) { if (!window) return; @@ -265,7 +394,15 @@ ecore_wince_window_show(Ecore_WinCE_Window *window) } } -void +/** + * @brief Hide the given window. + * + * @param window The window to show. + * + * This function hides @p window. If @p window is @c NULL, or on + * error, this function does nothing. + */ +EAPI void ecore_wince_window_hide(Ecore_WinCE_Window *window) { if (!window) return; @@ -283,7 +420,17 @@ ecore_wince_window_hide(Ecore_WinCE_Window *window) } } -void +/** + * @brief Set the title of the given window. + * + * @param window The window to set the title. + * @param title The new title. + * + * This function sets the title of @p window to @p title. If @p window + * is @c NULL, or if @p title is @c NULL or empty, or on error, this + * function does nothing. + */ +EAPI void ecore_wince_window_title_set(Ecore_WinCE_Window *window, const char *title) { @@ -305,8 +452,30 @@ ecore_wince_window_title_set(Ecore_WinCE_Window *window, free(wtitle); } -void -ecore_wince_window_backend_set(Ecore_WinCE_Window *window, int backend) +/** + * @brief Set the graphic backend used for the given window. + * + * @param window The window. + * @param backend The backend. + * + * This function sets the graphic backend to use with @p window to + * @p backend. If @p window if @c NULL, this function does nothing. + * + * The valid values for @p backend are + * + * @li 0: automatic choice of the backend. + * @li 1: the framebuffer (fast but could be not well suported). + * @li 2: GAPI (less fast but almost always supported). + * @li 3: DirectDraw (less fast than GAPI but almost always + * supported). + * @li 4: GDI (the slowest but always supported). + * + * The @p backend is used only in Evas and Ecore_Evas. So this + * function should not be called if Ecore_Evas is used. + */ +EAPI void +ecore_wince_window_backend_set(Ecore_WinCE_Window *window, + int backend) { struct _Ecore_WinCE_Window *w; @@ -319,8 +488,20 @@ ecore_wince_window_backend_set(Ecore_WinCE_Window *window, int backend) w->backend = backend; } -void -ecore_wince_window_suspend_set(Ecore_WinCE_Window *window, int (*suspend)(int)) +/** + * @brief Set the suspend callback used for the given window. + * + * @param window The window. + * @param suspend_cb The suspend callback. + * + * This function sets the suspend callback to use with @p window to + * @p suspend_cb. If @p window if @c NULL, this function does nothing. + * + * The @p suspend_cb is used only in Evas and Ecore_Evas. So this + * function should not be called if Ecore_Evas is used. + */ +EAPI void +ecore_wince_window_suspend_set(Ecore_WinCE_Window *window, int (*suspend_cb)(int)) { struct _Ecore_WinCE_Window *w; @@ -333,8 +514,20 @@ ecore_wince_window_suspend_set(Ecore_WinCE_Window *window, int (*suspend)(int)) w->suspend = suspend; } -void -ecore_wince_window_resume_set(Ecore_WinCE_Window *window, int (*resume)(int)) +/** + * @brief Set the resume callback used for the given window. + * + * @param window The window. + * @param resume_cb The resume callback. + * + * This function sets the resume callback to use with @p window to + * @p resume_cb. If @p window if @c NULL, this function does nothing. + * + * The @p resume_cb is used only in Evas and Ecore_Evas. So this + * function should not be called if Ecore_Evas is used. + */ +EAPI void +ecore_wince_window_resume_set(Ecore_WinCE_Window *window, int (*resume_cb)(int)) { struct _Ecore_WinCE_Window *w; @@ -347,7 +540,23 @@ ecore_wince_window_resume_set(Ecore_WinCE_Window *window, int (*resume)(int)) w->resume = resume; } -void +/** + * @brief Get the geometry of the given window. + * + * @param window The window to retrieve the geometry from. + * @param x The x coordinate of the position. + * @param y The x coordinate of the position. + * @param width The width. + * @param height The height. + * + * This function retrieves the position and size of @p window. @p x, + * @p y, @p width and @p height can be buffers that will be filled with + * the corresponding values. If one of them is @c NULL, nothing will + * be done for that parameter. If @p window is @c NULL, and if the + * buffers are not @c NULL, they will be filled with respectively 0, + * 0, the size of the screen and the height of the screen. + */ +EAPI void ecore_wince_window_geometry_get(Ecore_WinCE_Window *window, int *x, int *y, @@ -405,7 +614,21 @@ ecore_wince_window_geometry_get(Ecore_WinCE_Window *window, if (height) *height = h; } -void +/** + * @brief Get the size of the given window. + * + * @param window The window to retrieve the size from. + * @param width The width. + * @param height The height. + * + * This function retrieves the size of @p window. @p width and + * @p height can be buffers that will be filled with the corresponding + * values. If one of them is @c NULL, nothing will be done for that + * parameter. If @p window is @c NULL, and if the buffers are not + * @c NULL, they will be filled with respectively the size of the screen + * and the height of the screen. + */ +EAPI void ecore_wince_window_size_get(Ecore_WinCE_Window *window, int *width, int *height) @@ -435,9 +658,21 @@ ecore_wince_window_size_get(Ecore_WinCE_Window *window, if (height) *height = rect.bottom - rect.top; } -void +/** + * @brief Set the given window to fullscreen. + * + * @param window The window. + * @param on EINA_TRUE for fullscreen mode, EINA_FALSE for windowed mode. + * + * This function set @p window to fullscreen or windowed mode. If @p on + * is set to EINA_TRUE, the window will be fullscreen, if it is set to + * EINA_FALSE, it will be windowed. If @p window is @c NULL or if the + * state does not change (like setting to fullscreen while the window + * is already fullscreen), this function does nothing. + */ +EAPI void ecore_wince_window_fullscreen_set(Ecore_WinCE_Window *window, - int on) + Eina_Bool on) { struct _Ecore_WinCE_Window *ew; HWND w; @@ -555,38 +790,6 @@ ecore_wince_window_fullscreen_set(Ecore_WinCE_Window *window, } } - -/***** Private functions definitions *****/ - -static int -_ecore_wince_hardware_keys_register(HWND window) -{ - HINSTANCE core_dll; - UnregisterFunc1Proc unregister_fct; - int i; - - core_dll = LoadLibrary(L"coredll.dll"); - if (!core_dll) - { - ERR("LoadLibrary() failed"); - return 0; - } - - unregister_fct = (UnregisterFunc1Proc)GetProcAddress(core_dll, L"UnregisterFunc1"); - if (!unregister_fct) - { - ERR("GetProcAddress() failed"); - FreeLibrary(core_dll); - return 0; - } - - for (i = 0xc1; i <= 0xcf; i++) - { - unregister_fct(MOD_WIN, i); - RegisterHotKey(window, i, MOD_WIN, i); - } - - FreeLibrary(core_dll); - - return 1; -} +/** + * @} + */ diff --git a/src/lib/ecore_x/Ecore_X.h b/src/lib/ecore_x/Ecore_X.h old mode 100755 new mode 100644 index f2a7253..f3697df --- a/src/lib/ecore_x/Ecore_X.h +++ b/src/lib/ecore_x/Ecore_X.h @@ -299,6 +299,19 @@ typedef enum _Ecore_X_Shape_Type ECORE_X_SHAPE_INPUT } Ecore_X_Shape_Type; +typedef enum _Ecore_X_Mapping_Type +{ + ECORE_X_MAPPING_MODIFIER, + ECORE_X_MAPPING_KEYBOARD, + ECORE_X_MAPPING_MOUSE +} Ecore_X_Mapping_Type; + +typedef enum _Ecore_X_Randr_Property_Change +{ + ECORE_X_RANDR_PROPERTY_CHANGE_ADD, + ECORE_X_RANDR_PROPERTY_CHANGE_DEL +} Ecore_X_Randr_Property_Change; + typedef struct _Ecore_X_Event_Mouse_In Ecore_X_Event_Mouse_In; typedef struct _Ecore_X_Event_Mouse_Out Ecore_X_Event_Mouse_Out; typedef struct _Ecore_X_Event_Window_Focus_In Ecore_X_Event_Window_Focus_In; @@ -320,6 +333,7 @@ typedef struct _Ecore_X_Event_Window_Stack Ecore_X_Event_Window_Stack; typedef struct _Ecore_X_Event_Window_Stack_Request Ecore_X_Event_Window_Stack_Request; typedef struct _Ecore_X_Event_Window_Property Ecore_X_Event_Window_Property; typedef struct _Ecore_X_Event_Window_Colormap Ecore_X_Event_Window_Colormap; +typedef struct _Ecore_X_Event_Mapping_Change Ecore_X_Event_Mapping_Change; typedef struct _Ecore_X_Event_Window_Mapping Ecore_X_Event_Window_Mapping; typedef struct _Ecore_X_Event_Selection_Clear Ecore_X_Event_Selection_Clear; typedef struct _Ecore_X_Event_Selection_Request Ecore_X_Event_Selection_Request; @@ -344,33 +358,12 @@ typedef struct _Ecore_X_Event_Randr_Crtc_Change Ecore_X_Event_Randr_Crtc_Chang typedef struct _Ecore_X_Event_Randr_Output_Change Ecore_X_Event_Randr_Output_Change; typedef struct _Ecore_X_Event_Randr_Output_Property_Notify Ecore_X_Event_Randr_Output_Property_Notify; -typedef struct _Ecore_X_Event_Window_Delete_Request -Ecore_X_Event_Window_Delete_Request; -typedef struct _Ecore_X_Event_Window_Prop_Title_Change -Ecore_X_Event_Window_Prop_Title_Change; -typedef struct _Ecore_X_Event_Window_Prop_Visible_Title_Change -Ecore_X_Event_Window_Prop_Visible_Title_Change; -typedef struct _Ecore_X_Event_Window_Prop_Icon_Name_Change -Ecore_X_Event_Window_Prop_Icon_Name_Change; -typedef struct _Ecore_X_Event_Window_Prop_Visible_Icon_Name_Change -Ecore_X_Event_Window_Prop_Visible_Icon_Name_Change; -typedef struct _Ecore_X_Event_Window_Prop_Client_Machine_Change -Ecore_X_Event_Window_Prop_Client_Machine_Change; -typedef struct _Ecore_X_Event_Window_Prop_Name_Class_Change -Ecore_X_Event_Window_Prop_Name_Class_Change; -typedef struct _Ecore_X_Event_Window_Prop_Pid_Change -Ecore_X_Event_Window_Prop_Pid_Change; -typedef struct _Ecore_X_Event_Window_Prop_Desktop_Change -Ecore_X_Event_Window_Prop_Desktop_Change; - -typedef struct _Ecore_X_Event_Window_Move_Resize_Request -Ecore_X_Event_Window_Move_Resize_Request; -typedef struct _Ecore_X_Event_Window_State_Request -Ecore_X_Event_Window_State_Request; -typedef struct _Ecore_X_Event_Frame_Extents_Request -Ecore_X_Event_Frame_Extents_Request; -typedef struct _Ecore_X_Event_Ping Ecore_X_Event_Ping; -typedef struct _Ecore_X_Event_Desktop_Change Ecore_X_Event_Desktop_Change; +typedef struct _Ecore_X_Event_Window_Delete_Request Ecore_X_Event_Window_Delete_Request; +typedef struct _Ecore_X_Event_Window_Move_Resize_Request Ecore_X_Event_Window_Move_Resize_Request; +typedef struct _Ecore_X_Event_Window_State_Request Ecore_X_Event_Window_State_Request; +typedef struct _Ecore_X_Event_Frame_Extents_Request Ecore_X_Event_Frame_Extents_Request; +typedef struct _Ecore_X_Event_Ping Ecore_X_Event_Ping; +typedef struct _Ecore_X_Event_Desktop_Change Ecore_X_Event_Desktop_Change; typedef struct _Ecore_X_Event_Startup_Sequence Ecore_X_Event_Startup_Sequence; @@ -379,16 +372,15 @@ typedef struct _Ecore_X_Event_Generic Ecore_X_Event_Generic; typedef struct _Ecore_X_Randr_Screen_Size Ecore_X_Randr_Screen_Size; typedef struct _Ecore_X_Randr_Screen_Size_MM Ecore_X_Randr_Screen_Size_MM; -typedef struct _Ecore_X_Xdnd_Position Ecore_X_Xdnd_Position; +typedef struct _Ecore_X_Xdnd_Position Ecore_X_Xdnd_Position; struct _Ecore_X_Event_Mouse_In { int modifiers; int x, y; - int same_screen; - struct - { - int x, y; + Eina_Bool same_screen : 1; + struct { + int x, y; } root; Ecore_X_Window win; Ecore_X_Window event_win; @@ -403,9 +395,8 @@ struct _Ecore_X_Event_Mouse_Out int modifiers; int x, y; int same_screen; - struct - { - int x, y; + struct { + int x, y; } root; Ecore_X_Window win; Ecore_X_Window event_win; @@ -504,8 +495,8 @@ struct _Ecore_X_Event_Window_Configure Ecore_X_Window abovewin; int x, y, w, h; int border; - unsigned int override : 1; - unsigned int from_wm : 1; + Eina_Bool override : 1; + Eina_Bool from_wm : 1; Ecore_X_Time time; }; @@ -562,10 +553,17 @@ struct _Ecore_X_Event_Window_Colormap { Ecore_X_Window win; Ecore_X_Colormap cmap; - int installed; + Eina_Bool installed : 1; Ecore_X_Time time; }; +struct _Ecore_X_Event_Mapping_Change +{ + Ecore_X_Mapping_Type type; + int keycode; + int num; +}; + struct _Ecore_X_Event_Selection_Clear { Ecore_X_Window win; @@ -641,26 +639,24 @@ struct _Ecore_X_Event_Xdnd_Enter struct _Ecore_X_Event_Xdnd_Position { Ecore_X_Window win, source; - struct - { - int x, y; + struct { + int x, y; } position; Ecore_X_Atom action; }; -struct _Ecore_X_Xdnd_Position +struct _Ecore_X_Xdnd_Position { Ecore_X_Window win, prev; - struct - { - int x, y; + struct { + int x, y; } position; }; struct _Ecore_X_Event_Xdnd_Status { Ecore_X_Window win, target; - int will_accept; + Eina_Bool will_accept : 1; Ecore_X_Rectangle rectangle; Ecore_X_Atom action; }; @@ -674,16 +670,15 @@ struct _Ecore_X_Event_Xdnd_Drop { Ecore_X_Window win, source; Ecore_X_Atom action; - struct - { - int x, y; + struct { + int x, y; } position; }; struct _Ecore_X_Event_Xdnd_Finished { Ecore_X_Window win, target; - int completed; + Eina_Bool completed : 1; Ecore_X_Atom action; }; @@ -693,26 +688,26 @@ struct _Ecore_X_Event_Client_Message Ecore_X_Atom message_type; int format; union { - char b[20]; - short s[10]; - long l[5]; - } data; + char b[20]; + short s[10]; + long l[5]; + } data; Ecore_X_Time time; }; struct _Ecore_X_Event_Window_Shape { - Ecore_X_Window win; - Ecore_X_Time time; + Ecore_X_Window win; + Ecore_X_Time time; Ecore_X_Shape_Type type; - int x, y, w, h; - Eina_Bool shaped : 1; + int x, y, w, h; + Eina_Bool shaped : 1; }; struct _Ecore_X_Event_Screensaver_Notify { Ecore_X_Window win; - int on; + Eina_Bool on : 1; Ecore_X_Time time; }; @@ -771,11 +766,11 @@ struct _Ecore_X_Event_Randr_Output_Change struct _Ecore_X_Event_Randr_Output_Property_Notify { - Ecore_X_Window win; - Ecore_X_Randr_Output output; - Ecore_X_Atom property; - Ecore_X_Time time; - int state; /* NewValue, Deleted */ + Ecore_X_Window win; + Ecore_X_Randr_Output output; + Ecore_X_Atom property; + Ecore_X_Time time; + Ecore_X_Randr_Property_Change state; }; struct _Ecore_X_Event_Window_Delete_Request @@ -917,6 +912,7 @@ EAPI extern int ECORE_X_EVENT_WINDOW_STACK_REQUEST; EAPI extern int ECORE_X_EVENT_WINDOW_PROPERTY; EAPI extern int ECORE_X_EVENT_WINDOW_COLORMAP; EAPI extern int ECORE_X_EVENT_WINDOW_MAPPING; +EAPI extern int ECORE_X_EVENT_MAPPING_CHANGE; EAPI extern int ECORE_X_EVENT_SELECTION_CLEAR; EAPI extern int ECORE_X_EVENT_SELECTION_REQUEST; EAPI extern int ECORE_X_EVENT_SELECTION_NOTIFY; @@ -1140,35 +1136,35 @@ EAPI void ecore_x_event_mask_set(Ecore_X_Window w, EAPI void ecore_x_event_mask_unset(Ecore_X_Window w, Ecore_X_Event_Mask mask); -EAPI int ecore_x_selection_notify_send(Ecore_X_Window requestor, +EAPI Eina_Bool ecore_x_selection_notify_send(Ecore_X_Window requestor, Ecore_X_Atom selection, Ecore_X_Atom target, Ecore_X_Atom property, Ecore_X_Time time); EAPI void ecore_x_selection_primary_prefetch(void); EAPI void ecore_x_selection_primary_fetch(void); -EAPI int ecore_x_selection_primary_set(Ecore_X_Window w, +EAPI Eina_Bool ecore_x_selection_primary_set(Ecore_X_Window w, const void *data, int size); -EAPI int ecore_x_selection_primary_clear(void); +EAPI Eina_Bool ecore_x_selection_primary_clear(void); EAPI void ecore_x_selection_secondary_prefetch(void); EAPI void ecore_x_selection_secondary_fetch(void); -EAPI int ecore_x_selection_secondary_set(Ecore_X_Window w, +EAPI Eina_Bool ecore_x_selection_secondary_set(Ecore_X_Window w, const void *data, int size); -EAPI int ecore_x_selection_secondary_clear(void); +EAPI Eina_Bool ecore_x_selection_secondary_clear(void); EAPI void ecore_x_selection_xdnd_prefetch(void); EAPI void ecore_x_selection_xdnd_fetch(void); -EAPI int ecore_x_selection_xdnd_set(Ecore_X_Window w, +EAPI Eina_Bool ecore_x_selection_xdnd_set(Ecore_X_Window w, const void *data, int size); -EAPI int ecore_x_selection_xdnd_clear(void); +EAPI Eina_Bool ecore_x_selection_xdnd_clear(void); EAPI void ecore_x_selection_clipboard_prefetch(void); EAPI void ecore_x_selection_clipboard_fetch(void); -EAPI int ecore_x_selection_clipboard_set(Ecore_X_Window w, +EAPI Eina_Bool ecore_x_selection_clipboard_set(Ecore_X_Window w, const void *data, int size); -EAPI int ecore_x_selection_clipboard_clear(void); +EAPI Eina_Bool ecore_x_selection_clipboard_clear(void); EAPI void ecore_x_selection_primary_request(Ecore_X_Window w, const char *target); EAPI void ecore_x_selection_secondary_request(Ecore_X_Window w, @@ -1177,13 +1173,13 @@ EAPI void ecore_x_selection_xdnd_request(Ecore_X_Window w, const char *target); EAPI void ecore_x_selection_clipboard_request(Ecore_X_Window w, const char *target); -EAPI int ecore_x_selection_convert(Ecore_X_Atom selection, +EAPI Eina_Bool ecore_x_selection_convert(Ecore_X_Atom selection, Ecore_X_Atom target, void **data_ret, int *len, Ecore_X_Atom *targprop, int *targsize); -EAPI void ecore_x_selection_converter_add(char *target, int (*func)( +EAPI void ecore_x_selection_converter_add(char *target, Eina_Bool (*func)( char *target, void *data, int size, @@ -1191,7 +1187,7 @@ EAPI void ecore_x_selection_converter_add(char *target, int ( int *size_ret, Ecore_X_Atom *, int *)); -EAPI void ecore_x_selection_converter_atom_add(Ecore_X_Atom target, int (*func)( +EAPI void ecore_x_selection_converter_atom_add(Ecore_X_Atom target, Eina_Bool (*func)( char *target, void *data, int size, @@ -1208,17 +1204,17 @@ EAPI void ecore_x_selection_parser_add(const char *target, int format)); EAPI void ecore_x_selection_parser_del(const char *target); -EAPI void ecore_x_dnd_aware_set(Ecore_X_Window win, int on); +EAPI void ecore_x_dnd_aware_set(Ecore_X_Window win, Eina_Bool on); EAPI void ecore_x_dnd_version_get_prefetch(Ecore_X_Window window); EAPI void ecore_x_dnd_version_get_fetch(void); EAPI int ecore_x_dnd_version_get(Ecore_X_Window win); EAPI void ecore_x_dnd_type_get_prefetch(Ecore_X_Window window); EAPI void ecore_x_dnd_type_get_fetch(void); -EAPI int ecore_x_dnd_type_isset(Ecore_X_Window win, +EAPI Eina_Bool ecore_x_dnd_type_isset(Ecore_X_Window win, const char *type); EAPI void ecore_x_dnd_type_set(Ecore_X_Window win, const char *type, - int on); + Eina_Bool on); EAPI void ecore_x_dnd_types_set(Ecore_X_Window win, const char **types, unsigned int num_types); @@ -1227,19 +1223,19 @@ EAPI void ecore_x_dnd_actions_set(Ecore_X_Window win, unsigned int num_actions); EAPI void ecore_x_dnd_begin_prefetch(Ecore_X_Window source); EAPI void ecore_x_dnd_begin_fetch(void); -EAPI int ecore_x_dnd_begin(Ecore_X_Window source, +EAPI Eina_Bool ecore_x_dnd_begin(Ecore_X_Window source, unsigned char *data, int size); -EAPI int ecore_x_dnd_drop(void); -EAPI void ecore_x_dnd_send_status(int will_accept, - int suppress, +EAPI Eina_Bool ecore_x_dnd_drop(void); +EAPI void ecore_x_dnd_send_status(Eina_Bool will_accept, + Eina_Bool suppress, Ecore_X_Rectangle rectangle, Ecore_X_Atom action); EAPI void ecore_x_dnd_send_finished(void); EAPI void ecore_x_dnd_source_action_set(Ecore_X_Atom action); EAPI Ecore_X_Atom ecore_x_dnd_source_action_get(void); EAPI void ecore_x_dnd_callback_pos_update_set(void (*cb)(void *, Ecore_X_Xdnd_Position *data), - const void *data); + const void *data); EAPI Ecore_X_Window ecore_x_window_new(Ecore_X_Window parent, int x, @@ -1332,7 +1328,7 @@ EAPI void ecore_x_window_border_width_set( int width); EAPI int ecore_x_window_depth_get(Ecore_X_Window win); EAPI void ecore_x_window_cursor_show(Ecore_X_Window win, - int show); + Eina_Bool show); EAPI void ecore_x_window_defaults_set(Ecore_X_Window win); EAPI int ecore_x_window_visible_get(Ecore_X_Window win); EAPI Ecore_X_Window ecore_x_window_shadow_tree_at_xy_with_skip_get( @@ -1387,7 +1383,7 @@ EAPI void ecore_x_window_area_expose(Ecore_X_Window win, int w, int h); EAPI void ecore_x_window_override_set(Ecore_X_Window win, - int override); + Eina_Bool override); EAPI void ecore_x_window_prop_card32_set( Ecore_X_Window win, @@ -1537,7 +1533,7 @@ EAPI void ecore_x_window_prop_string_get_fetch(void); EAPI char * ecore_x_window_prop_string_get( Ecore_X_Window win, Ecore_X_Atom type); -EAPI int ecore_x_window_prop_protocol_isset( +EAPI Eina_Bool ecore_x_window_prop_protocol_isset( Ecore_X_Window win, Ecore_X_WM_Protocol protocol); EAPI Ecore_X_WM_Protocol * ecore_x_window_prop_protocol_list_get( @@ -1596,7 +1592,7 @@ EAPI Ecore_X_Rectangle * ecore_x_window_shape_rectangles_get( int *num_ret); EAPI void ecore_x_window_shape_events_select( Ecore_X_Window win, - int on); + Eina_Bool on); EAPI void ecore_x_window_shape_input_mask_set( Ecore_X_Window win, Ecore_X_Pixmap mask); @@ -1627,7 +1623,7 @@ EAPI Ecore_X_GC ecore_x_gc_new(Ecore_X_Drawable draw, const unsigned int *value_list); EAPI void ecore_x_gc_free(Ecore_X_GC gc); -EAPI int ecore_x_client_message32_send(Ecore_X_Window win, +EAPI Eina_Bool ecore_x_client_message32_send(Ecore_X_Window win, Ecore_X_Atom type, Ecore_X_Event_Mask mask, long d0, @@ -1635,18 +1631,18 @@ EAPI int ecore_x_client_message32_send(Ecore_X_Window win, long d2, long d3, long d4); -EAPI int ecore_x_client_message8_send(Ecore_X_Window win, +EAPI Eina_Bool ecore_x_client_message8_send(Ecore_X_Window win, Ecore_X_Atom type, const void *data, int len); -EAPI int ecore_x_mouse_move_send(Ecore_X_Window win, +EAPI Eina_Bool ecore_x_mouse_move_send(Ecore_X_Window win, int x, int y); -EAPI int ecore_x_mouse_down_send(Ecore_X_Window win, +EAPI Eina_Bool ecore_x_mouse_down_send(Ecore_X_Window win, int x, int y, int b); -EAPI int ecore_x_mouse_up_send(Ecore_X_Window win, +EAPI Eina_Bool ecore_x_mouse_up_send(Ecore_X_Window win, int x, int y, int b); @@ -1670,7 +1666,7 @@ EAPI void ecore_x_drawable_rectangle_fill( int width, int height); -EAPI int ecore_x_cursor_color_supported_get(void); +EAPI Eina_Bool ecore_x_cursor_color_supported_get(void); EAPI Ecore_X_Cursor ecore_x_cursor_new(Ecore_X_Window win, int *pixels, int w, @@ -1685,7 +1681,7 @@ EAPI int ecore_x_cursor_size_get(void); /* FIXME: these funcs need categorising */ EAPI Ecore_X_Window * ecore_x_window_root_list(int *num_ret); EAPI Ecore_X_Window ecore_x_window_root_first_get(void); -EAPI int ecore_x_window_manage(Ecore_X_Window win); +EAPI Eina_Bool ecore_x_window_manage(Ecore_X_Window win); EAPI void ecore_x_window_container_manage( Ecore_X_Window win); EAPI void ecore_x_window_client_manage(Ecore_X_Window win); @@ -1723,7 +1719,7 @@ EAPI void ecore_x_icccm_move_resize_send( int h); EAPI void ecore_x_icccm_hints_set( Ecore_X_Window win, - int accepts_focus, + Eina_Bool accepts_focus, Ecore_X_Window_State_Hint initial_state, Ecore_X_Pixmap @@ -1733,17 +1729,17 @@ EAPI void ecore_x_icccm_hints_set( icon_window, Ecore_X_Window window_group, - int is_urgent); -EAPI int ecore_x_icccm_hints_get(Ecore_X_Window win, - int *accepts_focus, + Eina_Bool is_urgent); +EAPI Eina_Bool ecore_x_icccm_hints_get(Ecore_X_Window win, + Eina_Bool *accepts_focus, Ecore_X_Window_State_Hint *initial_state, Ecore_X_Pixmap *icon_pixmap, Ecore_X_Pixmap *icon_mask, Ecore_X_Window *icon_window, Ecore_X_Window *window_group, - int *is_urgent); + Eina_Bool *is_urgent); EAPI void ecore_x_icccm_size_pos_hints_set(Ecore_X_Window win, - int request_pos, + Eina_Bool request_pos, Ecore_X_Gravity gravity, int min_w, int min_h, int max_w, int max_h, @@ -1751,8 +1747,8 @@ EAPI void ecore_x_icccm_size_pos_hints_set(Ecore_X_Window win, int step_x, int step_y, double min_aspect, double max_aspect); -EAPI int ecore_x_icccm_size_pos_hints_get(Ecore_X_Window win, - int *request_pos, +EAPI Eina_Bool ecore_x_icccm_size_pos_hints_get(Ecore_X_Window win, + Eina_Bool *request_pos, Ecore_X_Gravity *gravity, int *min_w, int *min_h, int *max_w, int *max_h, @@ -1767,8 +1763,8 @@ EAPI void ecore_x_icccm_protocol_atoms_set(Ecore_X_Window win, int num); EAPI void ecore_x_icccm_protocol_set(Ecore_X_Window win, Ecore_X_WM_Protocol protocol, - int on); -EAPI int ecore_x_icccm_protocol_isset(Ecore_X_Window win, + Eina_Bool on); +EAPI Eina_Bool ecore_x_icccm_protocol_isset(Ecore_X_Window win, Ecore_X_WM_Protocol protocol); EAPI void ecore_x_icccm_name_class_set(Ecore_X_Window win, const char *n, @@ -1835,7 +1831,7 @@ typedef enum _Ecore_X_MWM_Hint_Input EAPI void ecore_x_mwm_hints_get_prefetch( Ecore_X_Window window); EAPI void ecore_x_mwm_hints_get_fetch(void); -EAPI int ecore_x_mwm_hints_get( +EAPI Eina_Bool ecore_x_mwm_hints_get( Ecore_X_Window win, Ecore_X_MWM_Hint_Func *fhint, @@ -1845,7 +1841,7 @@ EAPI int ecore_x_mwm_hints_get( *ihint); EAPI void ecore_x_mwm_borderless_set( Ecore_X_Window win, - int borderless); + Eina_Bool borderless); /* netwm */ EAPI void ecore_x_netwm_init(void); @@ -1861,7 +1857,7 @@ EAPI void ecore_x_netwm_supported_set( EAPI void ecore_x_netwm_supported_get_prefetch( Ecore_X_Window root); EAPI void ecore_x_netwm_supported_get_fetch(void); -EAPI int ecore_x_netwm_supported_get( +EAPI Eina_Bool ecore_x_netwm_supported_get( Ecore_X_Window root, Ecore_X_Atom **supported, int *num); @@ -1899,7 +1895,7 @@ EAPI void ecore_x_netwm_desk_layout_set( int starting_corner); EAPI void ecore_x_netwm_showing_desktop_set( Ecore_X_Window root, - int on); + Eina_Bool on); EAPI void ecore_x_netwm_client_list_set( Ecore_X_Window root, Ecore_X_Window *p_clients, @@ -1966,7 +1962,7 @@ EAPI void ecore_x_netwm_desktop_set( EAPI void ecore_x_netwm_desktop_get_prefetch( Ecore_X_Window window); EAPI void ecore_x_netwm_desktop_get_fetch(void); -EAPI int ecore_x_netwm_desktop_get( +EAPI Eina_Bool ecore_x_netwm_desktop_get( Ecore_X_Window win, unsigned int *desk); EAPI void ecore_x_netwm_strut_set(Ecore_X_Window win, @@ -1977,7 +1973,7 @@ EAPI void ecore_x_netwm_strut_set(Ecore_X_Window win, EAPI void ecore_x_netwm_strut_get_prefetch( Ecore_X_Window window); EAPI void ecore_x_netwm_strut_get_fetch(void); -EAPI int ecore_x_netwm_strut_get(Ecore_X_Window win, +EAPI Eina_Bool ecore_x_netwm_strut_get(Ecore_X_Window win, int *left, int *right, int *top, @@ -1999,7 +1995,7 @@ EAPI void ecore_x_netwm_strut_partial_set( EAPI void ecore_x_netwm_strut_partial_get_prefetch( Ecore_X_Window window); EAPI void ecore_x_netwm_strut_partial_get_fetch(void); -EAPI int ecore_x_netwm_strut_partial_get( +EAPI Eina_Bool ecore_x_netwm_strut_partial_get( Ecore_X_Window win, int *left, int *right, @@ -2016,7 +2012,7 @@ EAPI int ecore_x_netwm_strut_partial_get( EAPI void ecore_x_netwm_icons_get_prefetch( Ecore_X_Window window); EAPI void ecore_x_netwm_icons_get_fetch(void); -EAPI int ecore_x_netwm_icons_get(Ecore_X_Window win, +EAPI Eina_Bool ecore_x_netwm_icons_get(Ecore_X_Window win, Ecore_X_Icon **icon, int *num); EAPI void ecore_x_netwm_icon_geometry_set( @@ -2028,7 +2024,7 @@ EAPI void ecore_x_netwm_icon_geometry_set( EAPI void ecore_x_netwm_icon_geometry_get_prefetch( Ecore_X_Window window); EAPI void ecore_x_netwm_icon_geometry_get_fetch(void); -EAPI int ecore_x_netwm_icon_geometry_get( +EAPI Eina_Bool ecore_x_netwm_icon_geometry_get( Ecore_X_Window win, int *x, int *y, @@ -2039,14 +2035,14 @@ EAPI void ecore_x_netwm_pid_set(Ecore_X_Window w EAPI void ecore_x_netwm_pid_get_prefetch( Ecore_X_Window window); EAPI void ecore_x_netwm_pid_get_fetch(void); -EAPI int ecore_x_netwm_pid_get(Ecore_X_Window win, +EAPI Eina_Bool ecore_x_netwm_pid_get(Ecore_X_Window win, int *pid); EAPI void ecore_x_netwm_handled_icons_set( Ecore_X_Window win); EAPI void ecore_x_netwm_handled_icons_get_prefetch( Ecore_X_Window window); EAPI void ecore_x_netwm_handled_icons_get_fetch(void); -EAPI int ecore_x_netwm_handled_icons_get( +EAPI Eina_Bool ecore_x_netwm_handled_icons_get( Ecore_X_Window win); EAPI void ecore_x_netwm_user_time_set( Ecore_X_Window win, @@ -2054,7 +2050,7 @@ EAPI void ecore_x_netwm_user_time_set( EAPI void ecore_x_netwm_user_time_get_prefetch( Ecore_X_Window window); EAPI void ecore_x_netwm_user_time_get_fetch(void); -EAPI int ecore_x_netwm_user_time_get( +EAPI Eina_Bool ecore_x_netwm_user_time_get( Ecore_X_Window win, unsigned int *time); EAPI void ecore_x_netwm_window_state_set( @@ -2064,7 +2060,7 @@ EAPI void ecore_x_netwm_window_state_set( EAPI void ecore_x_netwm_window_state_get_prefetch( Ecore_X_Window window); EAPI void ecore_x_netwm_window_state_get_fetch(void); -EAPI int ecore_x_netwm_window_state_get( +EAPI Eina_Bool ecore_x_netwm_window_state_get( Ecore_X_Window win, Ecore_X_Window_State **state, unsigned int *num); @@ -2074,13 +2070,13 @@ EAPI void ecore_x_netwm_window_type_set( EAPI void ecore_x_netwm_window_type_get_prefetch( Ecore_X_Window window); EAPI void ecore_x_netwm_window_type_get_fetch(void); -EAPI int ecore_x_netwm_window_type_get( +EAPI Eina_Bool ecore_x_netwm_window_type_get( Ecore_X_Window win, Ecore_X_Window_Type *type); EAPI int ecore_x_netwm_window_types_get( Ecore_X_Window win, Ecore_X_Window_Type **types); -EAPI int ecore_x_netwm_allowed_action_isset( +EAPI Eina_Bool ecore_x_netwm_allowed_action_isset( Ecore_X_Window win, Ecore_X_Action action); EAPI void ecore_x_netwm_allowed_action_set( @@ -2091,7 +2087,7 @@ EAPI void ecore_x_netwm_allowed_action_get_prefe Ecore_X_Window window); EAPI void ecore_x_netwm_allowed_action_get_fetch( void); -EAPI int ecore_x_netwm_allowed_action_get( +EAPI Eina_Bool ecore_x_netwm_allowed_action_get( Ecore_X_Window win, Ecore_X_Action **action, unsigned int *num); @@ -2101,7 +2097,7 @@ EAPI void ecore_x_netwm_opacity_set( EAPI void ecore_x_netwm_opacity_get_prefetch( Ecore_X_Window window); EAPI void ecore_x_netwm_opacity_get_fetch(void); -EAPI int ecore_x_netwm_opacity_get( +EAPI Eina_Bool ecore_x_netwm_opacity_get( Ecore_X_Window win, unsigned int *opacity); EAPI void ecore_x_netwm_frame_size_set( @@ -2113,7 +2109,7 @@ EAPI void ecore_x_netwm_frame_size_set( EAPI void ecore_x_netwm_frame_size_get_prefetch( Ecore_X_Window window); EAPI void ecore_x_netwm_frame_size_get_fetch(void); -EAPI int ecore_x_netwm_frame_size_get( +EAPI Eina_Bool ecore_x_netwm_frame_size_get( Ecore_X_Window win, int *fl, int *fr, @@ -2122,7 +2118,7 @@ EAPI int ecore_x_netwm_frame_size_get( EAPI void ecore_x_netwm_sync_counter_get_prefetch( Ecore_X_Window window); EAPI void ecore_x_netwm_sync_counter_get_fetch(void); -EAPI int ecore_x_netwm_sync_counter_get( +EAPI Eina_Bool ecore_x_netwm_sync_counter_get( Ecore_X_Window win, Ecore_X_Sync_Counter *counter); EAPI void ecore_x_netwm_ping_send(Ecore_X_Window win); @@ -2134,7 +2130,7 @@ EAPI void ecore_x_netwm_state_request_send( Ecore_X_Window root, Ecore_X_Window_State s1, Ecore_X_Window_State s2, - int set); + Eina_Bool set); EAPI void ecore_x_netwm_desktop_request_send( Ecore_X_Window win, Ecore_X_Window root, @@ -2150,7 +2146,7 @@ EAPI void ecore_x_e_frame_size_set( EAPI void ecore_x_e_virtual_keyboard_set( Ecore_X_Window win, unsigned int is_keyboard); -EAPI int ecore_x_e_virtual_keyboard_get( +EAPI Eina_Bool ecore_x_e_virtual_keyboard_get( Ecore_X_Window win); EAPI void ecore_x_e_virtual_keyboard_state_set( Ecore_X_Window win, @@ -2174,7 +2170,7 @@ EAPI void ecore_x_e_illume_zone_list_set( EAPI void ecore_x_e_illume_conformant_set( Ecore_X_Window win, unsigned int is_conformant); -EAPI int ecore_x_e_illume_conformant_get( +EAPI Eina_Bool ecore_x_e_illume_conformant_get( Ecore_X_Window win); EAPI void ecore_x_e_illume_mode_set( Ecore_X_Window win, @@ -2199,12 +2195,12 @@ EAPI void ecore_x_e_illume_home_del_send( EAPI void ecore_x_e_illume_drag_set( Ecore_X_Window win, unsigned int drag); -EAPI int ecore_x_e_illume_drag_get( +EAPI Eina_Bool ecore_x_e_illume_drag_get( Ecore_X_Window win); EAPI void ecore_x_e_illume_drag_locked_set( Ecore_X_Window win, unsigned int is_locked); -EAPI int ecore_x_e_illume_drag_locked_get( +EAPI Eina_Bool ecore_x_e_illume_drag_locked_get( Ecore_X_Window win); EAPI void ecore_x_e_illume_drag_start_send( Ecore_X_Window win); @@ -2216,7 +2212,7 @@ EAPI void ecore_x_e_illume_indicator_geometry_se int y, int w, int h); -EAPI int ecore_x_e_illume_indicator_geometry_get( +EAPI Eina_Bool ecore_x_e_illume_indicator_geometry_get( Ecore_X_Window win, int *x, int *y, @@ -2228,7 +2224,7 @@ EAPI void ecore_x_e_illume_softkey_geometry_set( int y, int w, int h); -EAPI int ecore_x_e_illume_softkey_geometry_get( +EAPI Eina_Bool ecore_x_e_illume_softkey_geometry_get( Ecore_X_Window win, int *x, int *y, @@ -2240,7 +2236,7 @@ EAPI void ecore_x_e_illume_keyboard_geometry_set int y, int w, int h); -EAPI int ecore_x_e_illume_keyboard_geometry_get( +EAPI Eina_Bool ecore_x_e_illume_keyboard_geometry_get( Ecore_X_Window win, int *x, int *y, @@ -2249,7 +2245,7 @@ EAPI int ecore_x_e_illume_keyboard_geometry_get EAPI void ecore_x_e_illume_quickpanel_set( Ecore_X_Window win, unsigned int is_quickpanel); -EAPI int ecore_x_e_illume_quickpanel_get( +EAPI Eina_Bool ecore_x_e_illume_quickpanel_get( Ecore_X_Window win); EAPI void ecore_x_e_illume_quickpanel_state_set( Ecore_X_Window win, @@ -2261,19 +2257,15 @@ EAPI void ecore_x_e_illume_quickpanel_state_send Ecore_X_Illume_Quickpanel_State state); EAPI void ecore_x_e_illume_quickpanel_state_toggle( Ecore_X_Window win); -EAPI void - ecore_x_e_illume_quickpanel_priority_major_set( +EAPI void ecore_x_e_illume_quickpanel_priority_major_set( Ecore_X_Window win, unsigned int priority); -EAPI int - ecore_x_e_illume_quickpanel_priority_major_get( +EAPI int ecore_x_e_illume_quickpanel_priority_major_get( Ecore_X_Window win); -EAPI void - ecore_x_e_illume_quickpanel_priority_minor_set( +EAPI void ecore_x_e_illume_quickpanel_priority_minor_set( Ecore_X_Window win, unsigned int priority); -EAPI int - ecore_x_e_illume_quickpanel_priority_minor_get( +EAPI int ecore_x_e_illume_quickpanel_priority_minor_get( Ecore_X_Window win); EAPI void ecore_x_e_illume_quickpanel_zone_set( Ecore_X_Window win, @@ -2336,14 +2328,14 @@ EAPI void ecore_x_e_comp_pixmap_set( EAPI Ecore_X_Pixmap ecore_x_e_comp_pixmap_get( Ecore_X_Window win); -EAPI void ecore_x_e_comp_dri_buff_flip_supported_set(Ecore_X_Window root, Eina_Bool enabled); -EAPI Eina_Bool ecore_x_e_comp_dri_buff_flip_supported_get(Ecore_X_Window root); - +EAPI void ecore_x_e_comp_dri_buff_flip_supported_set(Ecore_X_Window root, Eina_Bool enabled); +EAPI Eina_Bool ecore_x_e_comp_dri_buff_flip_supported_get(Ecore_X_Window root); + EAPI Ecore_X_Sync_Alarm ecore_x_sync_alarm_new( Ecore_X_Sync_Counter counter); -EAPI int ecore_x_sync_alarm_free( +EAPI Eina_Bool ecore_x_sync_alarm_free( Ecore_X_Sync_Alarm alarm); -EAPI int ecore_x_sync_counter_query( +EAPI Eina_Bool ecore_x_sync_counter_query( Ecore_X_Sync_Counter counter, unsigned int *val); EAPI Ecore_X_Sync_Counter ecore_x_sync_counter_new(int val); @@ -2360,14 +2352,14 @@ EAPI void ecore_x_xinerama_query_screens_prefetc void); EAPI void ecore_x_xinerama_query_screens_fetch(void); EAPI int ecore_x_xinerama_screen_count_get(void); -EAPI int ecore_x_xinerama_screen_geometry_get( +EAPI Eina_Bool ecore_x_xinerama_screen_geometry_get( int screen, int *x, int *y, int *w, int *h); -EAPI int ecore_x_screensaver_event_available_get( +EAPI Eina_Bool ecore_x_screensaver_event_available_get( void); EAPI void ecore_x_screensaver_idle_time_prefetch( void); @@ -2390,7 +2382,7 @@ EAPI void ecore_x_screensaver_interval_set( int timeout); EAPI int ecore_x_screensaver_interval_get(void); EAPI void ecore_x_screensaver_event_listen_set( - int on); + Eina_Bool on); /* FIXME: these funcs need categorising */ @@ -2424,7 +2416,7 @@ typedef struct _Ecore_X_Window_Attributes EAPI void ecore_x_get_window_attributes_prefetch( Ecore_X_Window window); EAPI void ecore_x_get_window_attributes_fetch(void); -EAPI int ecore_x_window_attributes_get( +EAPI Eina_Bool ecore_x_window_attributes_get( Ecore_X_Window win, Ecore_X_Window_Attributes * att_ret); @@ -2432,23 +2424,23 @@ EAPI void ecore_x_window_save_set_add(Ecore_X_Window win); EAPI void ecore_x_window_save_set_del(Ecore_X_Window win); EAPI Ecore_X_Window * ecore_x_window_children_get(Ecore_X_Window win, int *num); -EAPI int ecore_x_pointer_control_set(int accel_num, +EAPI Eina_Bool ecore_x_pointer_control_set(int accel_num, int accel_denom, int threshold); EAPI void ecore_x_pointer_control_get_prefetch(void); EAPI void ecore_x_pointer_control_get_fetch(void); -EAPI int ecore_x_pointer_control_get(int *accel_num, +EAPI Eina_Bool ecore_x_pointer_control_get(int *accel_num, int *accel_denom, int *threshold); -EAPI int ecore_x_pointer_mapping_set(unsigned char *map, int nmap); +EAPI Eina_Bool ecore_x_pointer_mapping_set(unsigned char *map, int nmap); EAPI void ecore_x_pointer_mapping_get_prefetch(void); EAPI void ecore_x_pointer_mapping_get_fetch(void); -EAPI int ecore_x_pointer_mapping_get(unsigned char *map, int nmap); -EAPI int ecore_x_pointer_grab(Ecore_X_Window win); -EAPI int ecore_x_pointer_confine_grab(Ecore_X_Window win); +EAPI Eina_Bool ecore_x_pointer_mapping_get(unsigned char *map, int nmap); +EAPI Eina_Bool ecore_x_pointer_grab(Ecore_X_Window win); +EAPI Eina_Bool ecore_x_pointer_confine_grab(Ecore_X_Window win); EAPI void ecore_x_pointer_ungrab(void); -EAPI int ecore_x_pointer_warp(Ecore_X_Window win, int x, int y); -EAPI int ecore_x_keyboard_grab(Ecore_X_Window win); +EAPI Eina_Bool ecore_x_pointer_warp(Ecore_X_Window win, int x, int y); +EAPI Eina_Bool ecore_x_keyboard_grab(Ecore_X_Window win); EAPI void ecore_x_keyboard_ungrab(void); EAPI void ecore_x_grab(void); EAPI void ecore_x_ungrab(void); @@ -2480,32 +2472,32 @@ EAPI void ecore_x_pointer_xy_get_fetch(void); EAPI void ecore_x_pointer_xy_get(Ecore_X_Window win, int *x, int *y); /* ecore_x_region.c */ -EAPI Ecore_X_XRegion * ecore_x_xregion_new(); +EAPI Ecore_X_XRegion * ecore_x_xregion_new(void); EAPI void ecore_x_xregion_free(Ecore_X_XRegion *region); -EAPI int ecore_x_xregion_set(Ecore_X_XRegion *region, +EAPI Eina_Bool ecore_x_xregion_set(Ecore_X_XRegion *region, Ecore_X_GC gc); EAPI void ecore_x_xregion_translate(Ecore_X_XRegion *region, int x, int y); -EAPI int ecore_x_xregion_intersect(Ecore_X_XRegion *dst, +EAPI Eina_Bool ecore_x_xregion_intersect(Ecore_X_XRegion *dst, Ecore_X_XRegion *r1, Ecore_X_XRegion *r2); -EAPI int ecore_x_xregion_union(Ecore_X_XRegion *dst, +EAPI Eina_Bool ecore_x_xregion_union(Ecore_X_XRegion *dst, Ecore_X_XRegion *r1, Ecore_X_XRegion *r2); -EAPI int ecore_x_xregion_union_rect(Ecore_X_XRegion *dst, +EAPI Eina_Bool ecore_x_xregion_union_rect(Ecore_X_XRegion *dst, Ecore_X_XRegion *src, Ecore_X_Rectangle *rect); -EAPI int ecore_x_xregion_subtract(Ecore_X_XRegion *dst, +EAPI Eina_Bool ecore_x_xregion_subtract(Ecore_X_XRegion *dst, Ecore_X_XRegion *r1, Ecore_X_XRegion *r2); -EAPI int ecore_x_xregion_is_empty(Ecore_X_XRegion *region); -EAPI int ecore_x_xregion_is_equal(Ecore_X_XRegion *r1, +EAPI Eina_Bool ecore_x_xregion_is_empty(Ecore_X_XRegion *region); +EAPI Eina_Bool ecore_x_xregion_is_equal(Ecore_X_XRegion *r1, Ecore_X_XRegion *r2); -EAPI int ecore_x_xregion_point_contain(Ecore_X_XRegion *region, +EAPI Eina_Bool ecore_x_xregion_point_contain(Ecore_X_XRegion *region, int x, int y); -EAPI int ecore_x_xregion_rect_contain(Ecore_X_XRegion *region, +EAPI Eina_Bool ecore_x_xregion_rect_contain(Ecore_X_XRegion *region, Ecore_X_Rectangle *rect); /* ecore_x_randr.c */ @@ -2909,7 +2901,7 @@ EAPI void ecore_x_region_picture_clip_set(Ecore_X_Region regi int y_origin); /* XComposite Extension Support */ -EAPI int ecore_x_composite_query(void); +EAPI Eina_Bool ecore_x_composite_query(void); EAPI void ecore_x_composite_redirect_window(Ecore_X_Window win, Ecore_X_Composite_Update_Type type); EAPI void ecore_x_composite_redirect_subwindows(Ecore_X_Window win, @@ -2947,7 +2939,7 @@ struct _Ecore_X_Event_Damage typedef struct _Ecore_X_Event_Damage Ecore_X_Event_Damage; -EAPI int ecore_x_damage_query(void); +EAPI Eina_Bool ecore_x_damage_query(void); EAPI Ecore_X_Damage ecore_x_damage_new(Ecore_X_Drawable d, Ecore_X_Damage_Report_Level level); EAPI void ecore_x_damage_free(Ecore_X_Damage damage); @@ -2955,24 +2947,24 @@ EAPI void ecore_x_damage_subtract(Ecore_X_Damage damage, Ecore_X_Region repair, Ecore_X_Region parts); -EAPI int ecore_x_screen_is_composited(int screen); +EAPI Eina_Bool ecore_x_screen_is_composited(int screen); EAPI void ecore_x_screen_is_composited_set(int screen, Ecore_X_Window win); -EAPI int ecore_x_dpms_query(void); +EAPI Eina_Bool ecore_x_dpms_query(void); EAPI void ecore_x_dpms_capable_get_prefetch(void); EAPI void ecore_x_dpms_capable_get_fetch(void); -EAPI int ecore_x_dpms_capable_get(void); +EAPI Eina_Bool ecore_x_dpms_capable_get(void); EAPI void ecore_x_dpms_enable_get_prefetch(void); EAPI void ecore_x_dpms_enable_get_fetch(void); -EAPI int ecore_x_dpms_enabled_get(void); +EAPI Eina_Bool ecore_x_dpms_enabled_get(void); EAPI void ecore_x_dpms_enabled_set(int enabled); EAPI void ecore_x_dpms_timeouts_get_prefetch(void); EAPI void ecore_x_dpms_timeouts_get_fetch(void); EAPI void ecore_x_dpms_timeouts_get(unsigned int *standby, unsigned int *suspend, unsigned int *off); -EAPI int ecore_x_dpms_timeouts_set(unsigned int standby, +EAPI Eina_Bool ecore_x_dpms_timeouts_set(unsigned int standby, unsigned int suspend, unsigned int off); EAPI unsigned int ecore_x_dpms_timeout_standby_get(void); @@ -2982,9 +2974,9 @@ EAPI void ecore_x_dpms_timeout_standby_set(unsigned int new_timeo EAPI void ecore_x_dpms_timeout_suspend_set(unsigned int new_timeout); EAPI void ecore_x_dpms_timeout_off_set(unsigned int new_timeout); -EAPI int ecore_x_test_fake_key_down(const char *key); -EAPI int ecore_x_test_fake_key_up(const char *key); -EAPI int ecore_x_test_fake_key_press(const char *key); +EAPI Eina_Bool ecore_x_test_fake_key_down(const char *key); +EAPI Eina_Bool ecore_x_test_fake_key_up(const char *key); +EAPI Eina_Bool ecore_x_test_fake_key_press(const char *key); EAPI const char * ecore_x_keysym_string_get(int keysym); typedef struct _Ecore_X_Image Ecore_X_Image; @@ -3004,6 +2996,7 @@ EAPI Eina_Bool ecore_x_image_get(Ecore_X_Image *im, int h); EAPI void ecore_x_image_put(Ecore_X_Image *im, Ecore_X_Drawable draw, + Ecore_X_GC gc, int x, int y, int sx, @@ -3014,21 +3007,15 @@ EAPI void * ecore_x_image_data_get(Ecore_X_Image *im, int *bpl, int *rows, int *bpp); +EAPI Eina_Bool ecore_x_image_is_argb32_get(Ecore_X_Image *im); + EAPI Eina_Bool ecore_x_image_to_argb_convert(void *src, int sbpp, - int sbpl, int srows, - Ecore_X_Colormap c, - Ecore_X_Visual v, - int x, int y, int w, int h, - void *dst, int dbpp, - int dbpl, int drows, - int dx, int dy); -EAPI Eina_Bool ecore_x_image_from_argb_convert(void *src, int sbpp, - int sbpl, int srows, + int sbpl, Ecore_X_Colormap c, Ecore_X_Visual v, int x, int y, int w, int h, - void *dst, int dbpp, - int dbpl, int drows, + unsigned int *dst, + int dbpl, int dx, int dy); EAPI Eina_Bool ecore_x_input_multi_select(Ecore_X_Window win); diff --git a/src/lib/ecore_x/Ecore_X_Atoms.h b/src/lib/ecore_x/Ecore_X_Atoms.h old mode 100755 new mode 100644 index 6c91e71..7284948 --- a/src/lib/ecore_x/Ecore_X_Atoms.h +++ b/src/lib/ecore_x/Ecore_X_Atoms.h @@ -186,7 +186,7 @@ EAPI extern Ecore_X_Atom ECORE_X_ATOM_SELECTION_PROP_PRIMARY; EAPI extern Ecore_X_Atom ECORE_X_ATOM_SELECTION_PROP_SECONDARY; EAPI extern Ecore_X_Atom ECORE_X_ATOM_SELECTION_PROP_CLIPBOARD; -/* currenly E specific virtual keyboard extension, aim to submit to netwm spec +/* currently E specific virtual keyboard extension, aim to submit to netwm spec * later */ EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_VIRTUAL_KEYBOARD; @@ -247,9 +247,11 @@ EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_COMP_SYNC_CANCEL; EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_COMP_FLUSH; EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_COMP_DUMP; EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_COMP_PIXMAP; -EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_COMP_DRI_BUFF_FLIP_SUPPORTED; -/* added by doyoun.kang 100218 - for rotation */ +EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_USER_CREATED_WINDOW; +EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_PARENT_BORDER_WINDOW; +EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_COMP_DRI_BUFF_FLIP_SUPPORTED; +EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE; EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE; EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_AVAILABLE_ANGLE; EAPI extern Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_ROTATE_OPERATOR; diff --git a/src/lib/ecore_x/Ecore_X_Cursor.h b/src/lib/ecore_x/Ecore_X_Cursor.h index 0080a90..807541e 100644 --- a/src/lib/ecore_x/Ecore_X_Cursor.h +++ b/src/lib/ecore_x/Ecore_X_Cursor.h @@ -11,6 +11,7 @@ #define ECORE_X_CURSOR_BASED_ARROW_DOWN 4 #define ECORE_X_CURSOR_UP 6 #define ECORE_X_CURSOR_BOAT 8 +#define ECORE_X_CURSOR_BOGOSITY 10 #define ECORE_X_CURSOR_BOTTOM_LEFT_CORNER 12 #define ECORE_X_CURSOR_BOTTOM_RIGHT_CORNER 14 #define ECORE_X_CURSOR_BOTTOM_SIDE 16 diff --git a/src/lib/ecore_x/ecore_x_atoms_decl.h b/src/lib/ecore_x/ecore_x_atoms_decl.h old mode 100755 new mode 100644 index f6d44cd..2cf9334 --- a/src/lib/ecore_x/ecore_x_atoms_decl.h +++ b/src/lib/ecore_x/ecore_x_atoms_decl.h @@ -275,9 +275,10 @@ EAPI Ecore_X_Atom ECORE_X_ATOM_E_COMP_FLUSH = 0; EAPI Ecore_X_Atom ECORE_X_ATOM_E_COMP_DUMP = 0; EAPI Ecore_X_Atom ECORE_X_ATOM_E_COMP_PIXMAP = 0; +EAPI Ecore_X_Atom ECORE_X_ATOM_E_USER_CREATED_WINDOW = 0; +EAPI Ecore_X_Atom ECORE_X_ATOM_E_PARENT_BORDER_WINDOW = 0; EAPI Ecore_X_Atom ECORE_X_ATOM_E_COMP_DRI_BUFF_FLIP_SUPPORTED = 0; - -/* added by doyoun.kang 100218 - for rotation */ +EAPI Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE = 0; EAPI Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE = 0; EAPI Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_AVAILABLE_ANGLE = 0; EAPI Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_ROTATE_OPERATOR = 0; @@ -289,8 +290,6 @@ EAPI Ecore_X_Atom ECORE_X_ATOM_USER_CREATED_WINDOW = 0; /* added by gl77.lee - XID that points to the parent border window */ EAPI Ecore_X_Atom ECORE_X_ATOM_PARENT_BORDER_WINDOW = 0; -/* added by doyoun.kang - for indicator's state */ -EAPI Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE = 0; /* added by doyoun.kang - for sliding window */ EAPI Ecore_X_Atom ECORE_X_ATOM_E_ILLUME_SLIDING_WIN_STATE = 0; diff --git a/src/lib/ecore_x/xcb/ecore_xcb.c b/src/lib/ecore_x/xcb/ecore_xcb.c index 35c3259..8a2ef77 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb.c +++ b/src/lib/ecore_x/xcb/ecore_xcb.c @@ -196,7 +196,8 @@ ecore_x_init(const char *name) if (!eina_init()) return --_ecore_xcb_init_count; - _ecore_x11xcb_log_dom = eina_log_domain_register("EcoreXCB", ECORE_XLIB_XCB_DEFAULT_LOG_COLOR); + _ecore_x11xcb_log_dom = eina_log_domain_register + ("ecore_x", ECORE_XLIB_XCB_DEFAULT_LOG_COLOR); if (_ecore_x11xcb_log_dom < 0) { EINA_LOG_ERR("Impossible to create a log domain the Ecore XCB module."); @@ -1249,7 +1250,7 @@ _ecore_x_window_manage_error(void *data __UNUSED__) } /* _ecore_x_window_manage_error */ /* FIXME: round trip */ -EAPI int +EAPI Eina_Bool ecore_x_window_manage(Ecore_X_Window window) { xcb_get_window_attributes_cookie_t cookie_attr; @@ -1310,7 +1311,7 @@ ecore_x_window_manage(Ecore_X_Window window) return 1; } /* ecore_x_window_manage */ -EAPI int +EAPI Eina_Bool ecore_x_pointer_control_set(int accel_num, int accel_denom, int threshold) @@ -1341,7 +1342,7 @@ ecore_x_pointer_control_get_fetch(void) _ecore_xcb_reply_cache(reply); } /* ecore_x_pointer_control_get_fetch */ -EAPI int +EAPI Eina_Bool ecore_x_pointer_control_get(int *accel_num, int *accel_denom, int *threshold) @@ -1373,7 +1374,7 @@ ecore_x_pointer_control_get(int *accel_num, return 1; } /* ecore_x_pointer_control_get */ -EAPI int +EAPI Eina_Bool ecore_x_pointer_mapping_set(unsigned char *map, int nmap) { @@ -1401,7 +1402,7 @@ ecore_x_pointer_mapping_get_fetch(void) _ecore_xcb_reply_cache(reply); } /* ecore_x_pointer_mapping_get_fetch */ -EAPI int +EAPI Eina_Bool ecore_x_pointer_mapping_get(unsigned char *map, int nmap) { @@ -1426,7 +1427,7 @@ ecore_x_pointer_mapping_get(unsigned char *map, return 1; } /* ecore_x_pointer_mapping_get */ -EAPI int +EAPI Eina_Bool ecore_x_pointer_grab(Ecore_X_Window window) { xcb_grab_pointer_cookie_t cookie; @@ -1451,7 +1452,7 @@ ecore_x_pointer_grab(Ecore_X_Window window) return 1; } /* ecore_x_pointer_grab */ -EAPI int +EAPI Eina_Bool ecore_x_pointer_confine_grab(Ecore_X_Window window) { xcb_grab_pointer_cookie_t cookie; @@ -1482,7 +1483,7 @@ ecore_x_pointer_ungrab(void) xcb_ungrab_pointer(_ecore_xcb_conn, XCB_CURRENT_TIME); } /* ecore_x_pointer_ungrab */ -EAPI int +EAPI Eina_Bool ecore_x_pointer_warp(Ecore_X_Window window, int x, int y) @@ -1492,7 +1493,7 @@ ecore_x_pointer_warp(Ecore_X_Window window, return 1; } /* ecore_x_pointer_warp */ -EAPI int +EAPI Eina_Bool ecore_x_keyboard_grab(Ecore_X_Window window) { xcb_grab_keyboard_cookie_t cookie; @@ -1792,7 +1793,7 @@ ecore_x_window_key_ungrab(Ecore_X_Window window, * * @return !0 on success. */ -EAPI int +EAPI Eina_Bool ecore_x_client_message32_send(Ecore_X_Window window, Ecore_X_Atom type, Ecore_X_Event_Mask mask, @@ -1829,7 +1830,7 @@ ecore_x_client_message32_send(Ecore_X_Window window, * * @return !0 on success. */ -EAPI int +EAPI Eina_Bool ecore_x_client_message8_send(Ecore_X_Window window, Ecore_X_Atom type, const void *data, @@ -1853,7 +1854,7 @@ ecore_x_client_message8_send(Ecore_X_Window window, } /* ecore_x_client_message8_send */ /* FIXME: round trip */ -EAPI int +EAPI Eina_Bool ecore_x_mouse_move_send(Ecore_X_Window window, int x, int y) @@ -1899,7 +1900,7 @@ ecore_x_mouse_move_send(Ecore_X_Window window, } /* ecore_x_mouse_move_send */ /* FIXME: round trip */ -EAPI int +EAPI Eina_Bool ecore_x_mouse_down_send(Ecore_X_Window window, int x, int y, @@ -1946,7 +1947,7 @@ ecore_x_mouse_down_send(Ecore_X_Window window, } /* ecore_x_mouse_down_send */ /* FIXME: round trip */ -EAPI int +EAPI Eina_Bool ecore_x_mouse_up_send(Ecore_X_Window window, int x, int y, diff --git a/src/lib/ecore_x/xcb/ecore_xcb_composite.c b/src/lib/ecore_x/xcb/ecore_xcb_composite.c index 883f982..bf7b9aa 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_composite.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_composite.c @@ -55,7 +55,7 @@ _ecore_x_composite_init_finalize(void) * or greater, 0 otherwise. * @ingroup Ecore_X_Composite_Group */ -EAPI int +EAPI Eina_Bool ecore_x_composite_query(void) { #ifdef ECORE_XCB_COMPOSITE diff --git a/src/lib/ecore_x/xcb/ecore_xcb_cursor.c b/src/lib/ecore_x/xcb/ecore_xcb_cursor.c index 50f78d0..2895d0b 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_cursor.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_cursor.c @@ -4,7 +4,7 @@ extern int _ecore_xcb_xcursor; -EAPI int +EAPI Eina_Bool ecore_x_cursor_color_supported_get(void) { return _ecore_xcb_xcursor; diff --git a/src/lib/ecore_x/xcb/ecore_xcb_damage.c b/src/lib/ecore_x/xcb/ecore_xcb_damage.c index f9b8da9..ab97445 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_damage.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_damage.c @@ -54,7 +54,7 @@ _ecore_x_damage_init_finalize(void) * 0 otherwise. * @ingroup Ecore_X_Damage_Group */ -EAPI int +EAPI Eina_Bool ecore_x_damage_query(void) { #ifdef ECORE_XCB_DAMAGE diff --git a/src/lib/ecore_x/xcb/ecore_xcb_dnd.c b/src/lib/ecore_x/xcb/ecore_xcb_dnd.c index 9a30019..9e289d1 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_dnd.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_dnd.c @@ -65,7 +65,7 @@ _ecore_x_dnd_shutdown(void) EAPI void ecore_x_dnd_aware_set(Ecore_X_Window window, - int on) + Eina_Bool on) { Ecore_X_Atom prop_data = ECORE_X_DND_VERSION; @@ -180,7 +180,7 @@ ecore_x_dnd_type_get_fetch(void) * ecore_x_dnd_type_get_prefetch(), which sends the GetProperty request, * then ecore_x_dnd_type_get_fetch(), which gets the reply. */ -EAPI int +EAPI Eina_Bool ecore_x_dnd_type_isset(Ecore_X_Window window, const char *type) { @@ -246,7 +246,7 @@ ecore_x_dnd_type_isset(Ecore_X_Window window, EAPI void ecore_x_dnd_type_set(Ecore_X_Window window, const char *type, - int on) + Eina_Bool on) { xcb_intern_atom_cookie_t cookie; xcb_intern_atom_reply_t *reply; @@ -477,7 +477,7 @@ ecore_x_dnd_begin_fetch(void) * ecore_x_dnd_begin_prefetch(), which sends the GetProperty request, * then ecore_x_dnd_begin_fetch(), which gets the reply. */ -EAPI int +EAPI Eina_Bool ecore_x_dnd_begin(Ecore_X_Window source, unsigned char *data, int size) @@ -507,7 +507,7 @@ ecore_x_dnd_begin(Ecore_X_Window source, return 1; } /* ecore_x_dnd_begin */ -EAPI int +EAPI Eina_Bool ecore_x_dnd_drop(void) { uint8_t status = 0; @@ -555,8 +555,8 @@ ecore_x_dnd_drop(void) } /* ecore_x_dnd_drop */ EAPI void -ecore_x_dnd_send_status(int will_accept, - int suppress, +ecore_x_dnd_send_status(Eina_Bool will_accept, + Eina_Bool suppress, Ecore_X_Rectangle rectangle, Ecore_X_Atom action) { diff --git a/src/lib/ecore_x/xcb/ecore_xcb_dpms.c b/src/lib/ecore_x/xcb/ecore_xcb_dpms.c index 4ffd5b1..1bc0f49 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_dpms.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_dpms.c @@ -54,7 +54,7 @@ _ecore_x_dpms_init_finalize(void) * 0 otherwise. * @ingroup Ecore_X_DPMS_Group */ -EAPI int +EAPI Eina_Bool ecore_x_dpms_query(void) { #ifdef ECORE_XCB_DPMS @@ -105,7 +105,7 @@ ecore_x_dpms_capable_get_fetch(void) * then ecore_x_dpms_capable_get_fetch(), which gets the reply. * @ingroup Ecore_X_DPMS_Group */ -EAPI int +EAPI Eina_Bool ecore_x_dpms_capable_get(void) { int capable = 0; @@ -205,7 +205,7 @@ ecore_x_dpms_enabled_set(int enabled) * @return Returns always 1. * @ingroup Ecore_X_DPMS_Group */ -EAPI int +EAPI Eina_Bool ecore_x_dpms_timeouts_set(unsigned int standby, unsigned int suspend, unsigned int off) diff --git a/src/lib/ecore_x/xcb/ecore_xcb_fixes.c b/src/lib/ecore_x/xcb/ecore_xcb_fixes.c index 01d2428..555eab8 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_fixes.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_fixes.c @@ -271,12 +271,12 @@ ecore_x_region_intersect(Ecore_X_Region dest, } /* ecore_x_region_intersect */ /** - * Make the substraction of two regions. + * Make the subtraction of two regions. * @param dest The destination region. * @param source1 The first source region. * @param source2 The second source region. * - * Replace the contents of @p dest with the substraction of @p source1 by + * Replace the contents of @p dest with the subtraction of @p source1 by * @p source2. * @ingroup Ecore_X_Fixes_Group */ @@ -291,7 +291,7 @@ ecore_x_region_subtract(Ecore_X_Region dest, } /* ecore_x_region_subtract */ /** - * Make the substraction of regions by bounds. + * Make the subtraction of regions by bounds. * @param dest The destination region. * @param bounds The bounds. * @param source The source region. diff --git a/src/lib/ecore_x/xcb/ecore_xcb_icccm.c b/src/lib/ecore_x/xcb/ecore_xcb_icccm.c index dce2309..291e22e 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_icccm.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_icccm.c @@ -262,13 +262,13 @@ ecore_x_icccm_move_resize_send(Ecore_X_Window window, */ EAPI void ecore_x_icccm_hints_set(Ecore_X_Window window, - int accepts_focus, + Eina_Bool accepts_focus, Ecore_X_Window_State_Hint initial_state, Ecore_X_Pixmap icon_pixmap, Ecore_X_Pixmap icon_mask, Ecore_X_Window icon_window, Ecore_X_Window window_group, - int is_urgent) + Eina_Bool is_urgent) { xcb_wm_hints_t hints; @@ -347,15 +347,15 @@ ecore_x_icccm_hints_get_fetch(void) * then ecore_x_icccm_hints_get_fetch(), which gets the reply. * @ingroup Ecore_X_ICCCM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_icccm_hints_get(Ecore_X_Window window __UNUSED__, - int *accepts_focus, + Eina_Bool *accepts_focus, Ecore_X_Window_State_Hint *initial_state, Ecore_X_Pixmap *icon_pixmap, Ecore_X_Pixmap *icon_mask, Ecore_X_Window *icon_window, Ecore_X_Window *window_group, - int *is_urgent) + Eina_Bool *is_urgent) { xcb_wm_hints_t hints; xcb_get_property_reply_t *reply; @@ -509,7 +509,7 @@ ecore_x_icccm_size_pos_hints_get_fetch(void) */ EAPI void ecore_x_icccm_size_pos_hints_set(Ecore_X_Window window, - int request_pos, + Eina_Bool request_pos, Ecore_X_Gravity gravity, int min_w, int min_h, @@ -603,9 +603,9 @@ ecore_x_icccm_size_pos_hints_set(Ecore_X_Window window, * then ecore_x_icccm_size_pos_hints_get_fetch(), which gets the reply. * @ingroup Ecore_X_ICCCM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_icccm_size_pos_hints_get(Ecore_X_Window window __UNUSED__, - int *request_pos, + Eina_Bool *request_pos, Ecore_X_Gravity *gravity, int *min_w, int *min_h, @@ -941,7 +941,7 @@ ecore_x_icccm_protocol_get_fetch(void) EAPI void ecore_x_icccm_protocol_set(Ecore_X_Window window, Ecore_X_WM_Protocol protocol, - int on) + Eina_Bool on) { xcb_get_property_reply_t *reply; Ecore_X_Atom *protos = NULL; @@ -1035,7 +1035,7 @@ ecore_x_icccm_protocol_set(Ecore_X_Window window, * then ecore_x_icccm_protocol_get_fetch(), which gets the reply. * @ingroup Ecore_X_ICCCM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_icccm_protocol_isset(Ecore_X_Window window __UNUSED__, Ecore_X_WM_Protocol protocol) { diff --git a/src/lib/ecore_x/xcb/ecore_xcb_mwm.c b/src/lib/ecore_x/xcb/ecore_xcb_mwm.c index d692c91..872bdec 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_mwm.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_mwm.c @@ -75,7 +75,7 @@ ecore_x_mwm_hints_get_fetch(void) * then ecore_x_mwm_hints_get_fetch(), which gets the reply. * @ingroup Ecore_X_MWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_mwm_hints_get(Ecore_X_Window window __UNUSED__, Ecore_X_MWM_Hint_Func *fhint, Ecore_X_MWM_Hint_Decor *dhint, @@ -134,7 +134,7 @@ ecore_x_mwm_hints_get(Ecore_X_Window window __UNUSED__, */ EAPI void ecore_x_mwm_borderless_set(Ecore_X_Window window, - int borderless) + Eina_Bool borderless) { uint32_t data[5] = {0, 0, 0, 0, 0}; diff --git a/src/lib/ecore_x/xcb/ecore_xcb_netwm.c b/src/lib/ecore_x/xcb/ecore_xcb_netwm.c index e6a14f5..ff0f42b 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_netwm.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_netwm.c @@ -174,7 +174,7 @@ ecore_x_netwm_supported_get_fetch(void) * then ecore_x_netwm_supported_get_fetch(), which gets the reply. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_supported_get(Ecore_X_Window root, Ecore_X_Atom **supported, int *num) @@ -504,7 +504,7 @@ ecore_x_netwm_desk_current_set(Ecore_X_Window root, */ EAPI void ecore_x_netwm_showing_desktop_set(Ecore_X_Window root, - int on) + Eina_Bool on) { uint32_t val; @@ -1045,7 +1045,7 @@ ecore_x_netwm_desktop_get_fetch(void) * then ecore_x_netwm_desktop_get_fetch(), which gets the reply. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_desktop_get(Ecore_X_Window window, unsigned int *desk) { @@ -1155,7 +1155,7 @@ ecore_x_netwm_strut_get_fetch(void) * then ecore_x_netwm_strut_get_fetch(), which gets the reply. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_strut_get(Ecore_X_Window window, int *left, int *right, @@ -1301,7 +1301,7 @@ ecore_x_netwm_strut_partial_get_fetch(void) * then ecore_x_netwm_strut_partial_get_fetch(), which gets the reply. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_strut_partial_get(Ecore_X_Window window, int *left, int *right, @@ -1408,7 +1408,7 @@ ecore_x_netwm_icons_get_fetch(void) * then ecore_x_netwm_icons_get_fetch(), which gets the reply. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_icons_get(Ecore_X_Window window, Ecore_X_Icon **icon, int *num) @@ -1601,7 +1601,7 @@ ecore_x_netwm_icon_geometry_get_fetch(void) * then ecore_x_netwm_icon_geometry_get_fetch(), which gets the reply. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_icon_geometry_get(Ecore_X_Window window, int *x, int *y, @@ -1701,7 +1701,7 @@ ecore_x_netwm_pid_get_fetch(void) * then ecore_x_netwm_pid_get_fetch(), which gets the reply. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_pid_get(Ecore_X_Window window, int *pid) { @@ -1780,7 +1780,7 @@ ecore_x_netwm_handled_icons_get_fetch(void) * then ecore_x_netwm_handled_icons_get_fetch(), which gets the reply. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_handled_icons_get(Ecore_X_Window window) { int ret = 0; @@ -1857,7 +1857,7 @@ ecore_x_netwm_user_time_get_fetch(void) * then ecore_x_netwm_user_time_get_fetch(), which gets the reply. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_user_time_get(Ecore_X_Window window, unsigned int *time) { @@ -2039,7 +2039,7 @@ ecore_x_netwm_window_state_get_fetch(void) * then ecore_x_netwm_window_state_get_fetch(), which gets the reply. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_window_state_get(Ecore_X_Window window, Ecore_X_Window_State **state, unsigned int *num) @@ -2212,7 +2212,7 @@ ecore_x_netwm_window_type_get_fetch(void) * then ecore_x_netwm_window_type_get_fetch(), which gets the reply. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_window_type_get(Ecore_X_Window window, Ecore_X_Window_Type *type) { @@ -2345,7 +2345,7 @@ ecore_x_netwm_allowed_action_get_fetch(void) * then ecore_x_netwm_allowed_action_get_fetch(), which gets the reply. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_allowed_action_isset(Ecore_X_Window window, Ecore_X_Action action) { @@ -2434,7 +2434,7 @@ ecore_x_netwm_allowed_action_set(Ecore_X_Window window, * then ecore_x_netwm_allowed_action_get_fetch(), which gets the reply. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_allowed_action_get(Ecore_X_Window window, Ecore_X_Action **action, unsigned int *num) @@ -2536,14 +2536,14 @@ ecore_x_netwm_opacity_get_fetch(void) * @return 1 on success, 0 otherwise. * * Retriee the opacity value of @p window and store it in - * @p opacity. This function returns 1 on sucess, 0 otherwise. + * @p opacity. This function returns 1 on success, 0 otherwise. * * To use this function, you must call before, and in order, * ecore_x_netwm_opacity_get_prefetch(), which sends the GetProperty request, * then ecore_x_netwm_opacity_get_fetch(), which gets the reply. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_opacity_get(Ecore_X_Window window, unsigned int *opacity) { @@ -2641,7 +2641,7 @@ ecore_x_netwm_frame_size_get_fetch(void) * then ecore_x_netwm_frame_size_get_fetch(), which gets the reply. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_frame_size_get(Ecore_X_Window window, int *fl, int *fr, @@ -2715,7 +2715,7 @@ ecore_x_netwm_sync_counter_get_fetch(void) * then ecore_x_netwm_frame_size_get_fetch(), which gets the reply. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_sync_counter_get(Ecore_X_Window window, Ecore_X_Sync_Counter *counter) { @@ -2815,7 +2815,7 @@ ecore_x_netwm_state_request_send(Ecore_X_Window window, Ecore_X_Window root, Ecore_X_Window_State s1, Ecore_X_Window_State s2, - int set) + Eina_Bool set) { xcb_client_message_event_t ev; @@ -3346,7 +3346,7 @@ _ecore_x_netwm_startup_info_free(void *data) * Return 1 if @p screen is composited, 0 otherwise. * @ingroup Ecore_X_NetWM_Group */ -EAPI int +EAPI Eina_Bool ecore_x_screen_is_composited(int screen) { char buf[32]; diff --git a/src/lib/ecore_x/xcb/ecore_xcb_randr.c b/src/lib/ecore_x/xcb/ecore_xcb_randr.c index d0af1c5..84806d4 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_randr.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_randr.c @@ -55,7 +55,7 @@ _ecore_x_randr_init_finalize(void) * 0 otherwise. * @ingroup Ecore_X_RandR_Group */ -EAPI int +EAPI Eina_Bool ecore_x_randr_query(void) { #ifdef ECORE_XCB_RANDR @@ -94,7 +94,8 @@ _xcb_randr_root_to_screen(Ecore_X_Window root) * the client connected, to avoid race conditions. * @ingroup Ecore_X_RandR_Group */ -EAPI int +/* +EAPI Eina_Bool ecore_x_randr_events_select(Ecore_X_Window window, int on) { @@ -102,10 +103,10 @@ ecore_x_randr_events_select(Ecore_X_Window window, xcb_randr_select_input(_ecore_xcb_conn, window, on ? XCB_RANDR_SCREEN_CHANGE_NOTIFY : 0); return 1; -#else /* ifdef ECORE_XCB_RANDR */ +#else return 0; -#endif /* ECORE_XCB_RANDR */ -} /* ecore_x_randr_events_select */ +#endif +}*/ /** * Sends the GetScreenInfo request. @@ -155,6 +156,7 @@ ecore_x_randr_get_screen_info_fetch(void) * then ecore_x_randr_get_screen_info_fetch(), which gets the reply. * @ingroup Ecore_X_RandR_Group */ +/* EAPI Ecore_X_Randr_Rotation ecore_x_randr_screen_rotations_get(Ecore_X_Window root __UNUSED__) { @@ -166,10 +168,10 @@ ecore_x_randr_screen_rotations_get(Ecore_X_Window root __UNUSED__) return 0; return reply->rotations; -#else /* ifdef ECORE_XCB_RANDR */ +#else return 0; -#endif /* ECORE_XCB_RANDR */ -} /* ecore_x_randr_screen_rotations_get */ +#endif +}*/ /** * Get the rotation. @@ -185,6 +187,7 @@ ecore_x_randr_screen_rotations_get(Ecore_X_Window root __UNUSED__) * then ecore_x_randr_get_screen_info_fetch(), which gets the reply. * @ingroup Ecore_X_RandR_Group */ +/* EAPI Ecore_X_Randr_Rotation ecore_x_randr_screen_rotation_get(Ecore_X_Window root __UNUSED__) { @@ -196,10 +199,10 @@ ecore_x_randr_screen_rotation_get(Ecore_X_Window root __UNUSED__) return 0; return reply->rotation; -#else /* ifdef ECORE_XCB_RANDR */ +#else return 0; -#endif /* ECORE_XCB_RANDR */ -} /* ecore_x_randr_screen_rotation_get */ +#endif +}*/ /** * Get the frame buffer sizes. @@ -217,6 +220,7 @@ ecore_x_randr_screen_rotation_get(Ecore_X_Window root __UNUSED__) * then ecore_x_randr_get_screen_info_fetch(), which gets the reply. * @ingroup Ecore_X_RandR_Group */ +/* EAPI Ecore_X_Screen_Size * ecore_x_randr_screen_sizes_get(Ecore_X_Window root __UNUSED__, int *num) @@ -251,13 +255,13 @@ ecore_x_randr_screen_sizes_get(Ecore_X_Window root __UNUSED__, } return ret; -#else /* ifdef ECORE_XCB_RANDR */ +#else if (num) *num = 0; return NULL; -#endif /* ECORE_XCB_RANDR */ -} /* ecore_x_randr_screen_sizes_get */ +#endif +}*/ /** * Get the current frame buffer size. @@ -273,6 +277,7 @@ ecore_x_randr_screen_sizes_get(Ecore_X_Window root __UNUSED__, * then ecore_x_randr_get_screen_info_fetch(), which gets the reply. * @ingroup Ecore_X_RandR_Group */ +/* EAPI Ecore_X_Screen_Size ecore_x_randr_current_screen_size_get(Ecore_X_Window root __UNUSED__) { @@ -294,10 +299,10 @@ ecore_x_randr_current_screen_size_get(Ecore_X_Window root __UNUSED__) ret.height = sizes[size_index].mheight; } -#endif /* ECORE_XCB_RANDR */ +#endif return ret; -} /* ecore_x_randr_current_screen_size_get */ +}*/ /** * Get the current refresh rate. @@ -313,6 +318,7 @@ ecore_x_randr_current_screen_size_get(Ecore_X_Window root __UNUSED__) * then ecore_x_randr_get_screen_info_fetch(), which gets the reply. * @ingroup Ecore_X_RandR_Group */ +/* EAPI Ecore_X_Screen_Refresh_Rate ecore_x_randr_current_screen_refresh_rate_get(Ecore_X_Window root __UNUSED__) { @@ -325,10 +331,10 @@ ecore_x_randr_current_screen_refresh_rate_get(Ecore_X_Window root __UNUSED__) return ret; ret.rate = reply->rate; -#endif /* ECORE_XCB_RANDR */ +#endif return ret; -} /* ecore_x_randr_current_screen_refresh_rate_get */ +}*/ /** * Get the refresh rates. @@ -348,6 +354,7 @@ ecore_x_randr_current_screen_refresh_rate_get(Ecore_X_Window root __UNUSED__) * then ecore_x_randr_get_screen_info_fetch(), which gets the reply. * @ingroup Ecore_X_RandR_Group */ +/* EAPI Ecore_X_Screen_Refresh_Rate * ecore_x_randr_screen_refresh_rates_get(Ecore_X_Window root __UNUSED__, int size_id __UNUSED__, @@ -375,7 +382,6 @@ ecore_x_randr_screen_refresh_rates_get(Ecore_X_Window root __UNUSED__, if (num) *num = n; - /* FIXME: maybe there's a missing function in xcb randr implementation */ iter = xcb_randr_get_screen_info_rates_iterator(reply); tmp = ret; for (; iter.rem; xcb_randr_refresh_rates_next(&iter), tmp++) @@ -384,13 +390,13 @@ ecore_x_randr_screen_refresh_rates_get(Ecore_X_Window root __UNUSED__, } return ret; -#else /* ifdef ECORE_XCB_RANDR */ +#else if (num) *num = 0; return NULL; -#endif /* ECORE_XCB_RANDR */ -} /* ecore_x_randr_screen_refresh_rates_get */ +#endif +}*/ /* FIXME: round trip. Should we remove it ? */ @@ -404,6 +410,7 @@ ecore_x_randr_screen_refresh_rates_get(Ecore_X_Window root __UNUSED__, * Note that that function is blocking. * @ingroup Ecore_X_RandR_Group */ +/* EAPI void ecore_x_randr_screen_rotation_set(Ecore_X_Window root, Ecore_X_Randr_Rotation rot) @@ -427,8 +434,8 @@ ecore_x_randr_screen_rotation_set(Ecore_X_Window root, if (reply_config) free(reply_config); -#endif /* ECORE_XCB_RANDR */ -} /* ecore_x_randr_screen_rotation_set */ +#endif +}*/ /* FIXME: round trip. Should we remove it ? */ @@ -442,6 +449,7 @@ ecore_x_randr_screen_rotation_set(Ecore_X_Window root, * Note that that function is blocking. * @ingroup Ecore_X_RandR_Group */ +/* EAPI int ecore_x_randr_screen_size_set(Ecore_X_Window root, Ecore_X_Screen_Size size) @@ -486,10 +494,10 @@ ecore_x_randr_screen_size_set(Ecore_X_Window root, free(reply_config); return 1; -#else /* ifdef ECORE_XCB_RANDR */ +#else return 0; -#endif /* ECORE_XCB_RANDR */ -} /* ecore_x_randr_screen_size_set */ +#endif +}*/ /* FIXME: round trip. Should we remove it ? */ @@ -505,6 +513,7 @@ ecore_x_randr_screen_size_set(Ecore_X_Window root, * Note that that function is blocking. * @ingroup Ecore_X_RandR_Group */ +/* EAPI int ecore_x_randr_screen_refresh_rate_set(Ecore_X_Window root, Ecore_X_Screen_Size size, @@ -550,8 +559,8 @@ ecore_x_randr_screen_refresh_rate_set(Ecore_X_Window root, free(reply_config); return 1; -#else /* ifdef ECORE_XCB_RANDR */ +#else return 0; -#endif /* ECORE_XCB_RANDR */ -} /* ecore_x_randr_screen_refresh_rate_set */ +#endif +}*/ diff --git a/src/lib/ecore_x/xcb/ecore_xcb_region.c b/src/lib/ecore_x/xcb/ecore_xcb_region.c index b10f77b..369ad3b 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_region.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_region.c @@ -53,7 +53,7 @@ ecore_x_xregion_free(Ecore_X_XRegion *region) free(region); } /* ecore_x_xregion_free */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_set(Ecore_X_XRegion *region, Ecore_X_GC gc) { xcb_rectangle_t *rects; @@ -99,32 +99,32 @@ ecore_x_xregion_translate(Ecore_X_XRegion *region, int x, int y) pixman_region_translate((pixman_region16_t *)region, x, y); } /* ecore_x_xregion_translate */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_intersect(Ecore_X_XRegion *dst, Ecore_X_XRegion *r1, Ecore_X_XRegion *r2) { return pixman_region_intersect((pixman_region16_t *)dst, (pixman_region16_t *)r1, (pixman_region16_t *)r2); } /* ecore_x_xregion_intersect */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_union(Ecore_X_XRegion *dst, Ecore_X_XRegion *r1, Ecore_X_XRegion *r2) { return pixman_region_union((pixman_region16_t *)dst, (pixman_region16_t *)r1, (pixman_region16_t *)r2); } /* ecore_x_xregion_union */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_union_rect(Ecore_X_XRegion *dst, Ecore_X_XRegion *src, Ecore_X_Rectangle *rect) { return pixman_region_union_rect((pixman_region16_t *)dst, (pixman_region16_t *)src, rect->x, rect->y, rect->width, rect->height); } /* ecore_x_xregion_union_rect */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_subtract(Ecore_X_XRegion *dst, Ecore_X_XRegion *rm, Ecore_X_XRegion *rs) { return pixman_region_subtract((pixman_region16_t *)dst, (pixman_region16_t *)rm, (pixman_region16_t *)rs); } /* ecore_x_xregion_subtract */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_is_empty(Ecore_X_XRegion *region) { if (!region) @@ -133,7 +133,7 @@ ecore_x_xregion_is_empty(Ecore_X_XRegion *region) return !pixman_region_not_empty((pixman_region16_t *)region); } /* ecore_x_xregion_is_empty */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_is_equal(Ecore_X_XRegion *r1, Ecore_X_XRegion *r2) { if (!r1 || !r2) @@ -142,7 +142,7 @@ ecore_x_xregion_is_equal(Ecore_X_XRegion *r1, Ecore_X_XRegion *r2) return pixman_region_equal((pixman_region16_t *)r1, (pixman_region16_t *)r2); } /* ecore_x_xregion_is_equal */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_point_contain(Ecore_X_XRegion *region, int x, int y) { if (!region) @@ -151,7 +151,7 @@ ecore_x_xregion_point_contain(Ecore_X_XRegion *region, int x, int y) return pixman_region_contains_point((pixman_region16_t *)region, x, y, NULL); } /* ecore_x_xregion_point_contain */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_rect_contain(Ecore_X_XRegion *region, Ecore_X_Rectangle *rect) { pixman_box16_t box; diff --git a/src/lib/ecore_x/xcb/ecore_xcb_screensaver.c b/src/lib/ecore_x/xcb/ecore_xcb_screensaver.c index a395c04..3f8f0bf 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_screensaver.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_screensaver.c @@ -55,7 +55,7 @@ _ecore_x_screensaver_init_finalize(void) * 0 otherwise. * @ingroup Ecore_X_ScreenSaver_Group */ -EAPI int +EAPI Eina_Bool ecore_x_screensaver_event_available_get(void) { return 1; @@ -390,7 +390,7 @@ ecore_x_screensaver_expose_get(void) * @ingroup Ecore_X_ScreenSaver_Group */ EAPI void -ecore_x_screensaver_event_listen_set(int on) +ecore_x_screensaver_event_listen_set(Eina_Bool on) { #ifdef ECORE_XCB_SCREENSAVER xcb_screensaver_select_input(_ecore_xcb_conn, diff --git a/src/lib/ecore_x/xcb/ecore_xcb_selection.c b/src/lib/ecore_x/xcb/ecore_xcb_selection.c index de551c7..ec5f664 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_selection.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_selection.c @@ -7,14 +7,14 @@ static Ecore_X_Selection_Intern selections[4]; static Ecore_X_Selection_Converter *converters = NULL; static Ecore_X_Selection_Parser *parsers = NULL; -static int _ecore_x_selection_converter_text(char *target, void *data, int size, void **data_ret, int *size_ret, Ecore_X_Atom *tprop, int *); -static int _ecore_x_selection_data_default_free(void *data); +static Eina_Bool _ecore_x_selection_converter_text(char *target, void *data, int size, void **data_ret, int *size_ret, Ecore_X_Atom *tprop, int *); +static Eina_Bool _ecore_x_selection_data_default_free(void *data); static void * _ecore_x_selection_parser_files(const char *target, void *data, int size, int format); -static int _ecore_x_selection_data_files_free(void *data); +static Eina_Bool _ecore_x_selection_data_files_free(void *data); static void * _ecore_x_selection_parser_text(const char *target, void *data, int size, int format); -static int _ecore_x_selection_data_text_free(void *data); +static Eina_Bool _ecore_x_selection_data_text_free(void *data); static void * _ecore_x_selection_parser_targets(const char *target, void *data, int size, int format); -static int _ecore_x_selection_data_targets_free(void *data); +static Eina_Bool _ecore_x_selection_data_targets_free(void *data); #define ECORE_X_SELECTION_DATA(x) ((Ecore_X_Selection_Data *)(x)) @@ -215,7 +215,7 @@ ecore_x_selection_primary_fetch(void) * ecore_x_selection_primary_prefetch(), which sends the GetSelectionOwner request, * then ecore_x_selection_primary_fetch(), which gets the reply. */ -EAPI int +EAPI Eina_Bool ecore_x_selection_primary_set(Ecore_X_Window window, const void *data, int size) @@ -232,7 +232,7 @@ ecore_x_selection_primary_set(Ecore_X_Window window, * ecore_x_selection_primary_prefetch(), which sends the GetSelectionOwner request, * then ecore_x_selection_primary_fetch(), which gets the reply. */ -EAPI int +EAPI Eina_Bool ecore_x_selection_primary_clear(void) { return _ecore_x_selection_set(XCB_NONE, NULL, 0, ECORE_X_ATOM_SELECTION_PRIMARY); @@ -276,7 +276,7 @@ ecore_x_selection_secondary_fetch(void) * ecore_x_selection_secondary_prefetch(), which sends the GetSelectionOwner request, * then ecore_x_selection_secondary_fetch(), which gets the reply. */ -EAPI int +EAPI Eina_Bool ecore_x_selection_secondary_set(Ecore_X_Window window, const void *data, int size) @@ -293,7 +293,7 @@ ecore_x_selection_secondary_set(Ecore_X_Window window, * ecore_x_selection_secondary_prefetch(), which sends the GetSelectionOwner request, * then ecore_x_selection_secondary_fetch(), which gets the reply. */ -EAPI int +EAPI Eina_Bool ecore_x_selection_secondary_clear(void) { return _ecore_x_selection_set(XCB_NONE, NULL, 0, ECORE_X_ATOM_SELECTION_SECONDARY); @@ -337,7 +337,7 @@ ecore_x_selection_xdnd_fetch(void) * ecore_x_selection_xdnd_prefetch(), which sends the GetSelectionOwner request, * then ecore_x_selection_xdnd_fetch(), which gets the reply. */ -EAPI int +EAPI Eina_Bool ecore_x_selection_xdnd_set(Ecore_X_Window window, const void *data, int size) @@ -354,7 +354,7 @@ ecore_x_selection_xdnd_set(Ecore_X_Window window, * ecore_x_selection_xdnd_prefetch(), which sends the GetSelectionOwner request, * then ecore_x_selection_xdnd_fetch(), which gets the reply. */ -EAPI int +EAPI Eina_Bool ecore_x_selection_xdnd_clear(void) { return _ecore_x_selection_set(XCB_NONE, NULL, 0, ECORE_X_ATOM_SELECTION_XDND); @@ -401,7 +401,7 @@ ecore_x_selection_clipboard_fetch(void) * ecore_x_selection_clipboard_prefetch(), which sends the GetSelectionOwner request, * then ecore_x_selection_clipboard_fetch(), which gets the reply. */ -EAPI int +EAPI Eina_Bool ecore_x_selection_clipboard_set(Ecore_X_Window window, const void *data, int size) @@ -418,7 +418,7 @@ ecore_x_selection_clipboard_set(Ecore_X_Window window, * ecore_x_selection_clipboard_prefetch(), which sends the GetSelectionOwner request, * then ecore_x_selection_clipboard_fetch(), which gets the reply. */ -EAPI int +EAPI Eina_Bool ecore_x_selection_clipboard_clear(void) { return _ecore_x_selection_set(XCB_NONE, NULL, 0, ECORE_X_ATOM_SELECTION_CLIPBOARD); @@ -555,13 +555,14 @@ ecore_x_selection_clipboard_request(Ecore_X_Window window, const char *target) EAPI void ecore_x_selection_converter_atom_add(Ecore_X_Atom target, - int (*func)(char *target, - void *data, - int size, - void **data_ret, - int *size_ret, - Ecore_X_Atom *ttype, - int *tsize)) + Eina_Bool (*func) + (char *target, + void *data, + int size, + void **data_ret, + int *size_ret, + Ecore_X_Atom *ttype, + int *tsize)) { Ecore_X_Selection_Converter *cnv; @@ -597,13 +598,14 @@ ecore_x_selection_converter_atom_add(Ecore_X_Atom EAPI void ecore_x_selection_converter_add(char *target, - int (*func)(char *target, - void *data, - int size, - void **data_ret, - int *size_ret, - Ecore_X_Atom *, - int *)) + Eina_Bool (*func) + (char *target, + void *data, + int size, + void **data_ret, + int *size_ret, + Ecore_X_Atom *, + int *)) { Ecore_X_Atom x_target; @@ -654,7 +656,7 @@ ecore_x_selection_converter_del(char *target) ecore_x_selection_converter_atom_del(x_target); } /* ecore_x_selection_converter_del */ -EAPI int +EAPI Eina_Bool ecore_x_selection_notify_send(Ecore_X_Window requestor, Ecore_X_Atom selection, Ecore_X_Atom target, @@ -677,7 +679,7 @@ ecore_x_selection_notify_send(Ecore_X_Window requestor, } /* ecore_x_selection_notify_send */ /* Locate and run conversion callback for specified selection target */ -EAPI int +EAPI Eina_Bool ecore_x_selection_convert(Ecore_X_Atom selection, Ecore_X_Atom target, void **data_ret, @@ -720,7 +722,7 @@ ecore_x_selection_convert(Ecore_X_Atom selection, /* TODO: We need to work out a mechanism for automatic conversion to any requested * locale using Ecore_Txt functions */ /* Converter for standard non-utf8 text targets */ -static int +static Eina_Bool _ecore_x_selection_converter_text(char *target, void *data, int size, void **data_ret, int *size_ret, Ecore_X_Atom *targprop, int *s) { /* FIXME: to do... */ @@ -875,7 +877,7 @@ _ecore_x_selection_parse(const char *target, void *data, int size, int format) return sel; } /* _ecore_x_selection_parse */ -static int +static Eina_Bool _ecore_x_selection_data_default_free(void *data) { Ecore_X_Selection_Data *sel; @@ -954,7 +956,7 @@ _ecore_x_selection_parser_files(const char *target, void *_data, int size, int f return ECORE_X_SELECTION_DATA(sel); } /* _ecore_x_selection_parser_files */ -static int +static Eina_Bool _ecore_x_selection_data_files_free(void *data) { Ecore_X_Selection_Data_Files *sel; @@ -998,7 +1000,7 @@ _ecore_x_selection_parser_text(const char *target __UNUSED__, return sel; } /* _ecore_x_selection_parser_text */ -static int +static Eina_Bool _ecore_x_selection_data_text_free(void *data) { Ecore_X_Selection_Data_Text *sel; @@ -1052,7 +1054,7 @@ _ecore_x_selection_parser_targets(const char *target __UNUSED__, return sel; } /* _ecore_x_selection_parser_targets */ -static int +static Eina_Bool _ecore_x_selection_data_targets_free(void *data) { Ecore_X_Selection_Data_Targets *sel; diff --git a/src/lib/ecore_x/xcb/ecore_xcb_shape.c b/src/lib/ecore_x/xcb/ecore_xcb_shape.c index cd79da4..3bd330d 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_shape.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_shape.c @@ -280,7 +280,7 @@ ecore_x_window_shape_rectangles_get(Ecore_X_Window window __UNUSED__, EAPI void ecore_x_window_shape_events_select(Ecore_X_Window dest_win, - int on) + Eina_Bool on) { #ifdef ECORE_XCB_SHAPE xcb_shape_select_input(_ecore_xcb_conn, dest_win, on ? 1 : 0); diff --git a/src/lib/ecore_x/xcb/ecore_xcb_sync.c b/src/lib/ecore_x/xcb/ecore_xcb_sync.c index c0ef82f..b4e867c 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_sync.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_sync.c @@ -56,7 +56,7 @@ _ecore_x_sync_init_finalize(void) * 0 otherwise. * @ingroup Ecore_X_Sync_Group */ -EAPI int +EAPI Eina_Bool ecore_x_sync_query(void) { #ifdef ECORE_XCB_SYNC @@ -118,7 +118,7 @@ ecore_x_sync_alarm_new(Ecore_X_Sync_Counter counter) * Delete the @p alarm. Returns 1 on success, 0 otherwise. * @ingroup Ecore_X_Sync_Group */ -EAPI int +EAPI Eina_Bool ecore_x_sync_alarm_free(Ecore_X_Sync_Alarm alarm) { #ifdef ECORE_XCB_SYNC @@ -131,7 +131,7 @@ ecore_x_sync_alarm_free(Ecore_X_Sync_Alarm alarm) /* FIXME: round trip */ -EAPI int +EAPI Eina_Bool ecore_x_sync_counter_query(Ecore_X_Sync_Counter counter, unsigned int *val) { #ifdef ECORE_XCB_SYNC diff --git a/src/lib/ecore_x/xcb/ecore_xcb_window.c b/src/lib/ecore_x/xcb/ecore_xcb_window.c index 59d2324..c76b1f5 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_window.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_window.c @@ -873,7 +873,7 @@ ecore_x_window_gravity_set(Ecore_X_Window window, */ EAPI void ecore_x_window_override_set(Ecore_X_Window window, - int override_redirect) + Eina_Bool override_redirect) { uint32_t value_list; @@ -890,7 +890,7 @@ ecore_x_window_override_set(Ecore_X_Window window, */ EAPI void ecore_x_window_cursor_show(Ecore_X_Window window, - int show) + Eina_Bool show) { if (window == 0) window = ((xcb_screen_t *)_ecore_xcb_screen)->root; @@ -1227,7 +1227,7 @@ ecore_x_get_window_attributes_fetch(void) * then ecore_x_get_window_attributes_fetch(), which gets the reply. * @ingroup Ecore_X_Window_Get_Attributes_Group */ -EAPI int +EAPI Eina_Bool ecore_x_window_attributes_get(Ecore_X_Window window __UNUSED__, Ecore_X_Window_Attributes *att_ret) { @@ -1331,7 +1331,7 @@ ecore_x_pointer_xy_get_fetch(void) * Retrieves the coordinates of the pointer. * If the window used in * ecore_x_query_pointer_prefetch() is not on the same screen than - * the root window or if an error occured, @p x and @p y are set + * the root window or if an error occurred, @p x and @p y are set * to 0. Otherwise, they are respectively set to the X and Y * coordinates of the pointer. * @@ -1400,7 +1400,7 @@ ecore_x_query_tree_fetch(void) * @return The parent window of @p window. * * Retrieves the parent window of the given window. If - * an error occured, @c 0 is returned. + * an error occurred, @c 0 is returned. * * To use this function, you must call before, and in order, * ecore_x_query_tree_prefetch(), which sends the QueryTree request, @@ -1426,7 +1426,7 @@ ecore_x_window_parent_get(Ecore_X_Window window __UNUSED__) * @return The children windows. * * Retrieves the children windows of the given window. If - * an error occured, @c 0 is returned. + * an error occurred, @c 0 is returned. * * To use this function, you must call before, and in order, * ecore_x_query_tree_prefetch(), which sends the QueryTree request, diff --git a/src/lib/ecore_x/xcb/ecore_xcb_window_prop.c b/src/lib/ecore_x/xcb/ecore_xcb_window_prop.c index a60037f..07f8433 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_window_prop.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_window_prop.c @@ -789,7 +789,7 @@ ecore_x_window_prop_string_get(Ecore_X_Window window __UNUSED__, /* FIXME : round trips because of GetWMProtocols */ /* should we rewrite its code ? */ -EAPI int +EAPI Eina_Bool ecore_x_window_prop_protocol_isset(Ecore_X_Window window, Ecore_X_WM_Protocol protocol) { diff --git a/src/lib/ecore_x/xcb/ecore_xcb_xinerama.c b/src/lib/ecore_x/xcb/ecore_xcb_xinerama.c index 8c360ea..04e4f14 100644 --- a/src/lib/ecore_x/xcb/ecore_xcb_xinerama.c +++ b/src/lib/ecore_x/xcb/ecore_xcb_xinerama.c @@ -55,7 +55,7 @@ _ecore_x_xinerama_init_finalize(void) * 0 otherwise. * @ingroup Ecore_X_Xinerama_Group */ -EAPI int +EAPI Eina_Bool ecore_x_xinerama_query(void) { #ifdef ECORE_XCB_XINERAMA @@ -144,7 +144,7 @@ ecore_x_xinerama_screen_count_get(void) * then ecore_x_xinerama_query_screens_fetch(), which gets the reply. * @ingroup Ecore_X_Xinerama_Group */ -EAPI int +EAPI Eina_Bool ecore_x_xinerama_screen_geometry_get(int screen, int *x, int *y, diff --git a/src/lib/ecore_x/xlib/ecore_x.c b/src/lib/ecore_x/xlib/ecore_x.c index 8bd53ba..fb00931 100644 --- a/src/lib/ecore_x/xlib/ecore_x.c +++ b/src/lib/ecore_x/xlib/ecore_x.c @@ -58,7 +58,7 @@ Time _ecore_x_event_last_time = 0; Window _ecore_x_event_last_win = 0; int _ecore_x_event_last_root_x = 0; int _ecore_x_event_last_root_y = 0; -int _ecore_x_xcursor = 0; +Eina_Bool _ecore_x_xcursor = EINA_FALSE; XIC _ecore_x_ic = NULL; /* Input context for composed characters */ XIM _ecore_x_im = NULL; @@ -253,8 +253,8 @@ ecore_x_init(const char *name) #endif /* ifdef LOGRT */ eina_init(); - _ecore_xlib_log_dom = eina_log_domain_register("EcoreX11", - ECORE_XLIB_DEFAULT_LOG_COLOR); + _ecore_xlib_log_dom = eina_log_domain_register + ("ecore_x", ECORE_XLIB_DEFAULT_LOG_COLOR); if(_ecore_xlib_log_dom < 0) { EINA_LOG_ERR( @@ -333,7 +333,7 @@ ecore_x_init(const char *name) goto close_display; #ifdef ECORE_XCURSOR - _ecore_x_xcursor = XcursorSupportsARGB(_ecore_x_disp); + _ecore_x_xcursor = XcursorSupportsARGB(_ecore_x_disp) ? EINA_TRUE : EINA_FALSE; #endif /* ifdef ECORE_XCURSOR */ _ecore_x_event_handlers[AnyXEvent] = _ecore_x_event_handle_any_event; _ecore_x_event_handlers[KeyPress] = _ecore_x_event_handle_key_press; @@ -677,7 +677,11 @@ _ecore_x_shutdown(int close_display) if (close_display) XCloseDisplay(_ecore_x_disp); else - close(ConnectionNumber(_ecore_x_disp)); + { + close(ConnectionNumber(_ecore_x_disp)); + // FIXME: may have to clean up x display internal here + XFree(_ecore_x_disp); + } free(_ecore_x_event_handlers); _ecore_x_fd_handler_handle = NULL; @@ -1173,14 +1177,14 @@ _ecore_x_window_manage_error(void *data __UNUSED__) _ecore_x_window_manage_failed = 1; } /* _ecore_x_window_manage_error */ -EAPI int +EAPI Eina_Bool ecore_x_window_manage(Ecore_X_Window win) { XWindowAttributes att; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (XGetWindowAttributes(_ecore_x_disp, win, &att) != True) - return 0; + return EINA_FALSE; ecore_x_sync(); _ecore_x_window_manage_failed = 0; @@ -1201,10 +1205,10 @@ ecore_x_window_manage(Ecore_X_Window win) if (_ecore_x_window_manage_failed) { _ecore_x_window_manage_failed = 0; - return 0; + return EINA_FALSE; } - return 1; + return EINA_TRUE; } /* ecore_x_window_manage */ EAPI void @@ -1255,7 +1259,7 @@ ecore_x_window_client_sniff(Ecore_X_Window win) XShapeSelectInput(_ecore_x_disp, win, ShapeNotifyMask); } /* ecore_x_window_client_sniff */ -EAPI int +EAPI Eina_Bool ecore_x_window_attributes_get(Ecore_X_Window win, Ecore_X_Window_Attributes *att_ret) { @@ -1263,7 +1267,7 @@ ecore_x_window_attributes_get(Ecore_X_Window win, LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!XGetWindowAttributes(_ecore_x_disp, win, &att)) - return 0; + return EINA_FALSE; memset(att_ret, 0, sizeof(Ecore_X_Window_Attributes)); att_ret->root = att.root; @@ -1295,7 +1299,7 @@ ecore_x_window_attributes_get(Ecore_X_Window win, att_ret->pixel_gravity = att.bit_gravity; att_ret->colormap = att.colormap; att_ret->visual = att.visual; - return 1; + return EINA_TRUE; } /* ecore_x_window_attributes_get */ EAPI void @@ -1342,37 +1346,37 @@ ecore_x_window_children_get(Ecore_X_Window win, int *num) return windows; } /* ecore_x_window_children_get */ -EAPI int +EAPI Eina_Bool ecore_x_pointer_control_set(int accel_num, int accel_denom, int threshold) { LOGFN(__FILE__, __LINE__, __FUNCTION__); return XChangePointerControl(_ecore_x_disp, 1, 1, - accel_num, accel_denom, threshold); + accel_num, accel_denom, threshold) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_pointer_control_set */ -EAPI int +EAPI Eina_Bool ecore_x_pointer_control_get(int *accel_num, int *accel_denom, int *threshold) { LOGFN(__FILE__, __LINE__, __FUNCTION__); return XGetPointerControl(_ecore_x_disp, - accel_num, accel_denom, threshold); + accel_num, accel_denom, threshold) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_pointer_control_get */ -EAPI int +EAPI Eina_Bool ecore_x_pointer_mapping_set(unsigned char *map, int nmap) { LOGFN(__FILE__, __LINE__, __FUNCTION__); - return XSetPointerMapping(_ecore_x_disp, map, nmap); + return XSetPointerMapping(_ecore_x_disp, map, nmap) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_pointer_mapping_set */ -EAPI int +EAPI Eina_Bool ecore_x_pointer_mapping_get(unsigned char *map, int nmap) { LOGFN(__FILE__, __LINE__, __FUNCTION__); - return XGetPointerMapping(_ecore_x_disp, map, nmap); + return XGetPointerMapping(_ecore_x_disp, map, nmap) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_pointer_mapping_get */ -EAPI int +EAPI Eina_Bool ecore_x_pointer_grab(Ecore_X_Window win) { LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -1381,12 +1385,12 @@ ecore_x_pointer_grab(Ecore_X_Window win) EnterWindowMask | LeaveWindowMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, None, None, CurrentTime) == GrabSuccess) - return 1; + return EINA_TRUE; - return 0; + return EINA_FALSE; } /* ecore_x_pointer_grab */ -EAPI int +EAPI Eina_Bool ecore_x_pointer_confine_grab(Ecore_X_Window win) { LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -1395,9 +1399,9 @@ ecore_x_pointer_confine_grab(Ecore_X_Window win) EnterWindowMask | LeaveWindowMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, win, None, CurrentTime) == GrabSuccess) - return 1; + return EINA_TRUE; - return 0; + return EINA_FALSE; } /* ecore_x_pointer_confine_grab */ EAPI void @@ -1407,23 +1411,23 @@ ecore_x_pointer_ungrab(void) XUngrabPointer(_ecore_x_disp, CurrentTime); } /* ecore_x_pointer_ungrab */ -EAPI int +EAPI Eina_Bool ecore_x_pointer_warp(Ecore_X_Window win, int x, int y) { LOGFN(__FILE__, __LINE__, __FUNCTION__); - return XWarpPointer(_ecore_x_disp, None, win, 0, 0, 0, 0, x, y); + return XWarpPointer(_ecore_x_disp, None, win, 0, 0, 0, 0, x, y) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_pointer_warp */ -EAPI int +EAPI Eina_Bool ecore_x_keyboard_grab(Ecore_X_Window win) { LOGFN(__FILE__, __LINE__, __FUNCTION__); if (XGrabKeyboard(_ecore_x_disp, win, False, GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess) - return 1; + return EINA_TRUE; - return 0; + return EINA_FALSE; } /* ecore_x_keyboard_grab */ EAPI void @@ -1707,9 +1711,9 @@ ecore_x_window_key_ungrab(Ecore_X_Window win, const char *key, * @param d3 The client message data item 4 * @param d4 The client message data item 5 * - * @return !0 on success. + * @return EINA_TRUE on success EINA_FALSE otherwise. */ -EAPI int +EAPI Eina_Bool ecore_x_client_message32_send(Ecore_X_Window win, Ecore_X_Atom type, Ecore_X_Event_Mask mask, long d0, long d1, long d2, long d3, long d4) @@ -1727,7 +1731,7 @@ ecore_x_client_message32_send(Ecore_X_Window win, Ecore_X_Atom type, xev.xclient.data.l[3] = d3; xev.xclient.data.l[4] = d4; - return XSendEvent(_ecore_x_disp, win, False, mask, &xev); + return XSendEvent(_ecore_x_disp, win, False, mask, &xev) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_client_message32_send */ /** @@ -1738,9 +1742,9 @@ ecore_x_client_message32_send(Ecore_X_Window win, Ecore_X_Atom type, * @param data Data to be sent. * @param len Number of data bytes, max 20. * - * @return !0 on success. + * @return EINA_TRUE on success EINA_FALSE otherwise. */ -EAPI int +EAPI Eina_Bool ecore_x_client_message8_send(Ecore_X_Window win, Ecore_X_Atom type, const void *data, int len) { @@ -1757,10 +1761,10 @@ ecore_x_client_message8_send(Ecore_X_Window win, Ecore_X_Atom type, memcpy(xev.xclient.data.b, data, len); memset(xev.xclient.data.b + len, 0, 20 - len); - return XSendEvent(_ecore_x_disp, win, False, NoEventMask, &xev); + return XSendEvent(_ecore_x_disp, win, False, NoEventMask, &xev) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_client_message8_send */ -EAPI int +EAPI Eina_Bool ecore_x_mouse_move_send(Ecore_X_Window win, int x, int y) { XEvent xev; @@ -1783,10 +1787,10 @@ ecore_x_mouse_move_send(Ecore_X_Window win, int x, int y) xev.xmotion.state = 0; xev.xmotion.is_hint = 0; xev.xmotion.same_screen = 1; - return XSendEvent(_ecore_x_disp, win, True, PointerMotionMask, &xev); + return XSendEvent(_ecore_x_disp, win, True, PointerMotionMask, &xev) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_mouse_move_send */ -EAPI int +EAPI Eina_Bool ecore_x_mouse_down_send(Ecore_X_Window win, int x, int y, int b) { XEvent xev; @@ -1809,10 +1813,10 @@ ecore_x_mouse_down_send(Ecore_X_Window win, int x, int y, int b) xev.xbutton.state = 1 << b; xev.xbutton.button = b; xev.xbutton.same_screen = 1; - return XSendEvent(_ecore_x_disp, win, True, ButtonPressMask, &xev); + return XSendEvent(_ecore_x_disp, win, True, ButtonPressMask, &xev) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_mouse_down_send */ -EAPI int +EAPI Eina_Bool ecore_x_mouse_up_send(Ecore_X_Window win, int x, int y, int b) { XEvent xev; @@ -1835,7 +1839,7 @@ ecore_x_mouse_up_send(Ecore_X_Window win, int x, int y, int b) xev.xbutton.state = 0; xev.xbutton.button = b; xev.xbutton.same_screen = 1; - return XSendEvent(_ecore_x_disp, win, True, ButtonReleaseMask, &xev); + return XSendEvent(_ecore_x_disp, win, True, ButtonReleaseMask, &xev) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_mouse_up_send */ EAPI void diff --git a/src/lib/ecore_x/xlib/ecore_x_atoms.c b/src/lib/ecore_x/xlib/ecore_x_atoms.c old mode 100755 new mode 100644 index 600322e..281d706 --- a/src/lib/ecore_x/xlib/ecore_x_atoms.c +++ b/src/lib/ecore_x/xlib/ecore_x_atoms.c @@ -281,7 +281,9 @@ _ecore_x_atoms_init(void) { "_E_COMP_FLUSH", &ECORE_X_ATOM_E_COMP_FLUSH }, { "_E_COMP_DUMP", &ECORE_X_ATOM_E_COMP_DUMP }, { "_E_COMP_PIXMAP", &ECORE_X_ATOM_E_COMP_PIXMAP }, - + + { "_E_USER_CREATED_WINDOW", &ECORE_X_ATOM_E_USER_CREATED_WINDOW }, + { "_E_PARENT_BORDER_WINDOW", &ECORE_X_ATOM_E_PARENT_BORDER_WINDOW }, { "_E_COMP_DRI_BUFF_FLIP_SUPPORTED", &ECORE_X_ATOM_E_COMP_DRI_BUFF_FLIP_SUPPORTED }, /* added by doyoun.kang 100218 - for rotation */ @@ -298,6 +300,10 @@ _ecore_x_atoms_init(void) /* added by doyoun.kang - for indicator's state */ { "_E_ILLUME_INDICATOR_STATE", &ECORE_X_ATOM_E_ILLUME_INDICATOR_STATE }, + { "_E_ILLUME_ROTATE_WINDOW_ANGLE", &ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_ANGLE }, + { "_E_ILLUME_ROTATE_WINDOW_AVAILABLE_ANGLES", &ECORE_X_ATOM_E_ILLUME_ROTATE_WINDOW_AVAILABLE_ANGLE }, + { "_E_ILLUME_ROTATE_OPERATOR", &ECORE_X_ATOM_E_ILLUME_ROTATE_OPERATOR }, + { "_E_ILLUME_ROTATE_ROOT_ANGLE", &ECORE_X_ATOM_E_ILLUME_ROTATE_ROOT_ANGLE }, /* added by doyoun.kang - for sliding window */ { "_E_ILLUME_SLIDING_WIN_STATE", &ECORE_X_ATOM_E_ILLUME_SLIDING_WIN_STATE }, diff --git a/src/lib/ecore_x/xlib/ecore_x_composite.c b/src/lib/ecore_x/xlib/ecore_x_composite.c index b36c74f..5205d5c 100644 --- a/src/lib/ecore_x/xlib/ecore_x_composite.c +++ b/src/lib/ecore_x/xlib/ecore_x_composite.c @@ -5,23 +5,34 @@ #include "ecore_x_private.h" #include "Ecore_X.h" -static int _composite_available; +static Eina_Bool _composite_available = EINA_FALSE; void _ecore_x_composite_init(void) { - _composite_available = 0; + _composite_available = EINA_FALSE; #ifdef ECORE_XCOMPOSITE int major, minor; if (XCompositeQueryVersion(_ecore_x_disp, &major, &minor)) - _composite_available = 1; - -#endif /* ifdef ECORE_XCOMPOSITE */ + { +# ifdef ECORE_XRENDER + if (XRenderQueryExtension(_ecore_x_disp, &major, &minor)) + { +# ifdef ECORE_XFIXES + if (XFixesQueryVersion(_ecore_x_disp, &major, &minor)) + { + _composite_available = EINA_TRUE; + } +# endif + } +# endif + } +#endif } /* _ecore_x_composite_init */ -EAPI int +EAPI Eina_Bool ecore_x_composite_query(void) { LOGFN(__FILE__, __LINE__, __FUNCTION__); diff --git a/src/lib/ecore_x/xlib/ecore_x_cursor.c b/src/lib/ecore_x/xlib/ecore_x_cursor.c index 7aeb9f9..d97b2f7 100644 --- a/src/lib/ecore_x/xlib/ecore_x_cursor.c +++ b/src/lib/ecore_x/xlib/ecore_x_cursor.c @@ -6,7 +6,7 @@ #include "ecore_x_private.h" -EAPI int +EAPI Eina_Bool ecore_x_cursor_color_supported_get(void) { return _ecore_x_xcursor; diff --git a/src/lib/ecore_x/xlib/ecore_x_damage.c b/src/lib/ecore_x/xlib/ecore_x_damage.c index 2c3b926..88d5f7d 100644 --- a/src/lib/ecore_x/xlib/ecore_x_damage.c +++ b/src/lib/ecore_x/xlib/ecore_x_damage.c @@ -5,7 +5,7 @@ #include "ecore_x_private.h" #include "Ecore_X.h" -static int _damage_available; +static Eina_Bool _damage_available = EINA_FALSE; #ifdef ECORE_XDAMAGE static int _damage_major, _damage_minor; #endif /* ifdef ECORE_XDAMAGE */ @@ -19,16 +19,16 @@ _ecore_x_damage_init(void) LOGFN(__FILE__, __LINE__, __FUNCTION__); if (XDamageQueryVersion(_ecore_x_disp, &_damage_major, &_damage_minor)) - _damage_available = 1; + _damage_available = EINA_TRUE; else - _damage_available = 0; + _damage_available = EINA_FALSE; #else /* ifdef ECORE_XDAMAGE */ - _damage_available = 0; + _damage_available = EINA_FALSE; #endif /* ifdef ECORE_XDAMAGE */ } /* _ecore_x_damage_init */ -EAPI int +EAPI Eina_Bool ecore_x_damage_query(void) { return _damage_available; diff --git a/src/lib/ecore_x/xlib/ecore_x_dnd.c b/src/lib/ecore_x/xlib/ecore_x_dnd.c index ddb48e8..74d5740 100644 --- a/src/lib/ecore_x/xlib/ecore_x_dnd.c +++ b/src/lib/ecore_x/xlib/ecore_x_dnd.c @@ -79,7 +79,7 @@ _ecore_x_dnd_shutdown(void) _ecore_x_dnd_init_count = 0; } /* _ecore_x_dnd_shutdown */ -static int +static Eina_Bool _ecore_x_dnd_converter_copy(char *target __UNUSED__, void *data, int size, @@ -93,11 +93,11 @@ _ecore_x_dnd_converter_copy(char *target __UNUSED__, XICCEncodingStyle style = XTextStyle; if (!data || !size) - return 0; + return EINA_FALSE; mystr = calloc(1, size + 1); if (!mystr) - return 0; + return EINA_FALSE; memcpy(mystr, data, size); @@ -110,17 +110,17 @@ _ecore_x_dnd_converter_copy(char *target __UNUSED__, *size_ret = bufsize; XFree(text_prop.value); free(mystr); - return 1; + return EINA_TRUE; } else { free(mystr); - return 0; + return EINA_FALSE; } } /* _ecore_x_dnd_converter_copy */ EAPI void -ecore_x_dnd_aware_set(Ecore_X_Window win, int on) +ecore_x_dnd_aware_set(Ecore_X_Window win, Eina_Bool on) { Ecore_X_Atom prop_data = ECORE_X_DND_VERSION; @@ -192,10 +192,10 @@ ecore_x_dnd_version_get(Ecore_X_Window win) return 0; } /* ecore_x_dnd_version_get */ -EAPI int +EAPI Eina_Bool ecore_x_dnd_type_isset(Ecore_X_Window win, const char *type) { - int num, i, ret = 0; + int num, i, ret = EINA_FALSE; unsigned char *data; Ecore_X_Atom *atoms, atom; @@ -211,7 +211,7 @@ ecore_x_dnd_type_isset(Ecore_X_Window win, const char *type) { if (atom == atoms[i]) { - ret = 1; + ret = EINA_TRUE; break; } } @@ -221,7 +221,7 @@ ecore_x_dnd_type_isset(Ecore_X_Window win, const char *type) } /* ecore_x_dnd_type_isset */ EAPI void -ecore_x_dnd_type_set(Ecore_X_Window win, const char *type, int on) +ecore_x_dnd_type_set(Ecore_X_Window win, const char *type, Eina_Bool on) { Ecore_X_Atom atom; Ecore_X_Atom *oldset = NULL, *newset = NULL; @@ -341,6 +341,29 @@ ecore_x_dnd_actions_set(Ecore_X_Window win, } } /* ecore_x_dnd_actions_set */ +/** + * The DND position update cb is called Ecore_X sends a DND position to a + * client. + * + * It essentially mirrors some of the data sent in the position message. + * Generally this cb should be set just before position update is called. + * Please note well you need to look after your own data pointer if someone + * trashes you position update cb set. + * + * It is considered good form to clear this when the dnd event finishes. + * + * @param cb Callback to updated each time ecore_x sends a position update. + * @param data User data. + */ +EAPI void +ecore_x_dnd_callback_pos_update_set( + void (*cb)(void *, Ecore_X_Xdnd_Position *data), + const void *data) +{ + _posupdatecb = cb; + _posupdatedata = (void *)data; /* Discard the const early */ +} + Ecore_X_DND_Source * _ecore_x_dnd_source_get(void) { @@ -353,16 +376,16 @@ _ecore_x_dnd_target_get(void) return _target; } /* _ecore_x_dnd_target_get */ -EAPI int +EAPI Eina_Bool ecore_x_dnd_begin(Ecore_X_Window source, unsigned char *data, int size) { LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!ecore_x_dnd_version_get(source)) - return 0; + return EINA_FALSE; /* Take ownership of XdndSelection */ if (!ecore_x_selection_xdnd_set(source, data, size)) - return 0; + return EINA_FALSE; if (_version_cache) { @@ -385,14 +408,14 @@ ecore_x_dnd_begin(Ecore_X_Window source, unsigned char *data, int size) _source->accepted_action = None; _source->dest = None; - return 1; + return EINA_TRUE; } /* ecore_x_dnd_begin */ -EAPI int +EAPI Eina_Bool ecore_x_dnd_drop(void) { XEvent xev; - int status = 0; + int status = EINA_FALSE; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (_source->dest) @@ -410,7 +433,7 @@ ecore_x_dnd_drop(void) xev.xclient.data.l[2] = _source->time; XSendEvent(_ecore_x_disp, _source->dest, False, 0, &xev); _source->state = ECORE_X_DND_SOURCE_DROPPED; - status = 1; + status = EINA_TRUE; } else { @@ -436,8 +459,8 @@ ecore_x_dnd_drop(void) } /* ecore_x_dnd_drop */ EAPI void -ecore_x_dnd_send_status(int will_accept, - int suppress, +ecore_x_dnd_send_status(Eina_Bool will_accept, + Eina_Bool suppress, Ecore_X_Rectangle rectangle, Ecore_X_Atom action) { @@ -530,30 +553,6 @@ ecore_x_dnd_source_action_get(void) return _source->action; } /* ecore_x_dnd_source_action_get */ -/** - * The DND position update cb is called Ecore_X sends a DND position to a - * client. - * - * It essentially mirrors some of the data sent in the position message. - * Generally this cb should be set just before position update is called. - * Please note well you need to look after your own data pointer if someone - * trashes you position update cb set. - * - * It is considered good form to clear this when the dnd event finishes. - * - * @param cb Callback to updated each time ecore_x sends a position update. - * @param data User data. - */ - -EAPI void -ecore_x_dnd_callback_pos_update_set( - void (*cb)(void *, Ecore_X_Xdnd_Position *data), - const void *data) -{ - _posupdatecb = cb; - _posupdatedata = (void *)data; /* Discard the const early */ -} - void _ecore_x_dnd_drag(Ecore_X_Window root, int x, int y) { @@ -664,18 +663,22 @@ _ecore_x_dnd_drag(Ecore_X_Window root, int x, int y) } if (_posupdatecb) - { - pos.position.x = x; - pos.position.y = y; - pos.win = win; - pos.prev = _source->dest; - _posupdatecb(_posupdatedata, &pos); - } - - + { + pos.position.x = x; + pos.position.y = y; + pos.win = win; + pos.prev = _source->dest; + _posupdatecb(_posupdatedata, &pos); + } + _source->prev.x = x; _source->prev.y = y; _source->prev.window = root; _source->dest = win; + + } /* _ecore_x_dnd_drag */ + + +/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/ diff --git a/src/lib/ecore_x/xlib/ecore_x_dpms.c b/src/lib/ecore_x/xlib/ecore_x_dpms.c index bc6869b..47ffcbf 100644 --- a/src/lib/ecore_x/xlib/ecore_x_dpms.c +++ b/src/lib/ecore_x/xlib/ecore_x_dpms.c @@ -4,7 +4,7 @@ #include "ecore_x_private.h" -static int _dpms_available; +static Eina_Bool _dpms_available = EINA_FALSE; void _ecore_x_dpms_init(void) @@ -16,12 +16,12 @@ _ecore_x_dpms_init(void) _dpms_minor = 0; if (DPMSGetVersion(_ecore_x_disp, &_dpms_major, &_dpms_minor)) - _dpms_available = 1; + _dpms_available = EINA_TRUE; else - _dpms_available = 0; + _dpms_available = EINA_FALSE; #else /* ifdef ECORE_XDPMS */ - _dpms_available = 0; + _dpms_available = EINA_FALSE; #endif /* ifdef ECORE_XDPMS */ } /* _ecore_x_dpms_init */ @@ -36,7 +36,7 @@ _ecore_x_dpms_init(void) * @return @c 1 if the X DPMS extension is available, @c 0 otherwise. * @ingroup Ecore_X_DPMS_Group */ -EAPI int +EAPI Eina_Bool ecore_x_dpms_query(void) { return _dpms_available; @@ -47,14 +47,14 @@ ecore_x_dpms_query(void) * @return @c 1 if the X server is capable of DPMS, @c 0 otherwise. * @ingroup Ecore_X_DPMS_Group */ -EAPI int +EAPI Eina_Bool ecore_x_dpms_capable_get(void) { #ifdef ECORE_XDPMS LOGFN(__FILE__, __LINE__, __FUNCTION__); - return DPMSCapable(_ecore_x_disp); + return DPMSCapable(_ecore_x_disp) ? EINA_TRUE : EINA_FALSE; #else /* ifdef ECORE_XDPMS */ - return 0; + return EINA_FALSE; #endif /* ifdef ECORE_XDPMS */ } /* ecore_x_dpms_capable_get */ @@ -63,7 +63,7 @@ ecore_x_dpms_capable_get(void) * @return @c 1 if DPMS is enabled, @c 0 otherwise. * @ingroup Ecore_X_DPMS_Group */ -EAPI int +EAPI Eina_Bool ecore_x_dpms_enabled_get(void) { #ifdef ECORE_XDPMS @@ -72,9 +72,9 @@ ecore_x_dpms_enabled_get(void) LOGFN(__FILE__, __LINE__, __FUNCTION__); DPMSInfo(_ecore_x_disp, &power_lvl, &state); - return state; + return state ? EINA_TRUE : EINA_FALSE; #else /* ifdef ECORE_XDPMS */ - return 0; + return EINA_FALSE; #endif /* ifdef ECORE_XDPMS */ } /* ecore_x_dpms_enabled_get */ @@ -122,16 +122,16 @@ ecore_x_dpms_timeouts_get(unsigned int *standby, * @param off Amount of time of inactivity before the monitor is shut off. * @ingroup Ecore_X_DPMS_Group */ -EAPI int +EAPI Eina_Bool ecore_x_dpms_timeouts_set(unsigned int standby, unsigned int suspend, unsigned int off) { #ifdef ECORE_XDPMS LOGFN(__FILE__, __LINE__, __FUNCTION__); - return DPMSSetTimeouts(_ecore_x_disp, standby, suspend, off); + return DPMSSetTimeouts(_ecore_x_disp, standby, suspend, off) ? EINA_TRUE : EINA_FALSE; #else /* ifdef ECORE_XDPMS */ - return 0; + return EINA_FALSE; #endif /* ifdef ECORE_XDPMS */ } /* ecore_x_dpms_timeouts_set */ diff --git a/src/lib/ecore_x/xlib/ecore_x_drawable.c b/src/lib/ecore_x/xlib/ecore_x_drawable.c index 00a53aa..90bda18 100644 --- a/src/lib/ecore_x/xlib/ecore_x_drawable.c +++ b/src/lib/ecore_x/xlib/ecore_x_drawable.c @@ -12,7 +12,7 @@ /** * Retrieves the geometry of the given drawable. - * @param d The given drawable. +* @param d The given drawable. * @param x Pointer to an integer into which the X position is to be stored. * @param y Pointer to an integer into which the Y position is to be stored. * @param w Pointer to an integer into which the width is to be stored. diff --git a/src/lib/ecore_x/xlib/ecore_x_e.c b/src/lib/ecore_x/xlib/ecore_x_e.c old mode 100755 new mode 100644 index 4b46f84..c5ca12a --- a/src/lib/ecore_x/xlib/ecore_x_e.c +++ b/src/lib/ecore_x/xlib/ecore_x_e.c @@ -37,7 +37,7 @@ ecore_x_e_virtual_keyboard_set(Ecore_X_Window win, unsigned int is_keyboard) &is_keyboard, 1); } /* ecore_x_e_virtual_keyboard_set */ -EAPI int +EAPI Eina_Bool ecore_x_e_virtual_keyboard_get(Ecore_X_Window win) { unsigned int val; @@ -45,9 +45,9 @@ ecore_x_e_virtual_keyboard_get(Ecore_X_Window win) LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_E_VIRTUAL_KEYBOARD, &val, 1)) - return 0; + return EINA_FALSE; - return val; + return val ? EINA_TRUE : EINA_FALSE; } /* ecore_x_e_virtual_keyboard_get */ static Ecore_X_Virtual_Keyboard_State @@ -266,7 +266,7 @@ ecore_x_e_illume_conformant_set(Ecore_X_Window win, unsigned int is_conformant) &is_conformant, 1); } /* ecore_x_e_illume_conformant_set */ -EAPI int +EAPI Eina_Bool ecore_x_e_illume_conformant_get(Ecore_X_Window win) { unsigned int val = 0; @@ -274,9 +274,9 @@ ecore_x_e_illume_conformant_get(Ecore_X_Window win) LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_E_ILLUME_CONFORMANT, &val, 1)) - return 0; + return EINA_FALSE; - return val; + return val ? EINA_TRUE : EINA_FALSE; } /* ecore_x_e_illume_conformant_get */ EAPI void @@ -373,16 +373,16 @@ ecore_x_e_illume_drag_set(Ecore_X_Window win, unsigned int drag) ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_E_ILLUME_DRAG, &drag, 1); } /* ecore_x_e_illume_drag_set */ -EAPI int +EAPI Eina_Bool ecore_x_e_illume_drag_get(Ecore_X_Window win) { unsigned int val = 0; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_E_ILLUME_DRAG, &val, 1)) - return 0; + return EINA_FALSE; - return val; + return val ? EINA_TRUE : EINA_FALSE; } /* ecore_x_e_illume_drag_get */ EAPI void @@ -393,7 +393,7 @@ ecore_x_e_illume_drag_locked_set(Ecore_X_Window win, unsigned int is_locked) &is_locked, 1); } /* ecore_x_e_illume_drag_locked_set */ -EAPI int +EAPI Eina_Bool ecore_x_e_illume_drag_locked_get(Ecore_X_Window win) { unsigned int val = 0; @@ -401,9 +401,9 @@ ecore_x_e_illume_drag_locked_get(Ecore_X_Window win) LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_E_ILLUME_DRAG_LOCKED, &val, 1)) - return 0; + return EINA_FALSE; - return val; + return val ? EINA_TRUE : EINA_FALSE; } /* ecore_x_e_illume_drag_locked_get */ EAPI void @@ -442,7 +442,7 @@ ecore_x_e_illume_indicator_geometry_set(Ecore_X_Window win, geom, 4); } /* ecore_x_e_illume_indicator_geometry_set */ -EAPI int +EAPI Eina_Bool ecore_x_e_illume_indicator_geometry_get(Ecore_X_Window win, int *x, int *y, @@ -458,7 +458,7 @@ ecore_x_e_illume_indicator_geometry_get(Ecore_X_Window win, ECORE_X_ATOM_E_ILLUME_INDICATOR_GEOMETRY, geom, 4); if (ret != 4) - return 0; + return EINA_FALSE; if (x) *x = geom[0]; @@ -472,7 +472,7 @@ ecore_x_e_illume_indicator_geometry_get(Ecore_X_Window win, if (h) *h = geom[3]; - return 1; + return EINA_TRUE; } /* ecore_x_e_illume_indicator_geometry_get */ EAPI void @@ -493,7 +493,7 @@ ecore_x_e_illume_softkey_geometry_set(Ecore_X_Window win, geom, 4); } /* ecore_x_e_illume_softkey_geometry_set */ -EAPI int +EAPI Eina_Bool ecore_x_e_illume_softkey_geometry_get(Ecore_X_Window win, int *x, int *y, @@ -509,7 +509,7 @@ ecore_x_e_illume_softkey_geometry_get(Ecore_X_Window win, ECORE_X_ATOM_E_ILLUME_SOFTKEY_GEOMETRY, geom, 4); if (ret != 4) - return 0; + return EINA_FALSE; if (x) *x = geom[0]; @@ -523,7 +523,7 @@ ecore_x_e_illume_softkey_geometry_get(Ecore_X_Window win, if (h) *h = geom[3]; - return 1; + return EINA_TRUE; } /* ecore_x_e_illume_softkey_geometry_get */ EAPI void @@ -544,7 +544,7 @@ ecore_x_e_illume_keyboard_geometry_set(Ecore_X_Window win, geom, 4); } /* ecore_x_e_illume_keyboard_geometry_set */ -EAPI int +EAPI Eina_Bool ecore_x_e_illume_keyboard_geometry_get(Ecore_X_Window win, int *x, int *y, @@ -560,7 +560,7 @@ ecore_x_e_illume_keyboard_geometry_get(Ecore_X_Window win, ECORE_X_ATOM_E_ILLUME_KEYBOARD_GEOMETRY, geom, 4); if (ret != 4) - return 0; + return EINA_FALSE; if (x) *x = geom[0]; @@ -574,7 +574,7 @@ ecore_x_e_illume_keyboard_geometry_get(Ecore_X_Window win, if (h) *h = geom[3]; - return 1; + return EINA_TRUE; } /* ecore_x_e_illume_keyboard_geometry_get */ static Ecore_X_Atom @@ -614,7 +614,7 @@ ecore_x_e_illume_quickpanel_set(Ecore_X_Window win, unsigned int is_quickpanel) &is_quickpanel, 1); } /* ecore_x_e_illume_quickpanel_set */ -EAPI int +EAPI Eina_Bool ecore_x_e_illume_quickpanel_get(Ecore_X_Window win) { unsigned int val = 0; @@ -622,9 +622,9 @@ ecore_x_e_illume_quickpanel_get(Ecore_X_Window win) LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_E_ILLUME_QUICKPANEL, &val, 1)) - return 0; + return EINA_FALSE; - return val; + return val ? EINA_TRUE : EINA_FALSE; } /* ecore_x_e_illume_quickpanel_get */ EAPI void @@ -679,14 +679,12 @@ ecore_x_e_illume_quickpanel_priority_major_set(Ecore_X_Window win, unsigned int priority) { LOGFN(__FILE__, __LINE__, __FUNCTION__); - ecore_x_window_prop_card32_set( - win, - ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MAJOR, - &priority, - 1); + ecore_x_window_prop_card32_set(win, + ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MAJOR, + &priority, 1); } /* ecore_x_e_illume_quickpanel_priority_major_set */ -EAPI int +EAPI int ecore_x_e_illume_quickpanel_priority_major_get(Ecore_X_Window win) { unsigned int val = 0; @@ -705,14 +703,12 @@ ecore_x_e_illume_quickpanel_priority_minor_set(Ecore_X_Window win, unsigned int priority) { LOGFN(__FILE__, __LINE__, __FUNCTION__); - ecore_x_window_prop_card32_set( - win, - ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MINOR, - &priority, - 1); + ecore_x_window_prop_card32_set(win, + ECORE_X_ATOM_E_ILLUME_QUICKPANEL_PRIORITY_MINOR, + &priority, 1); } /* ecore_x_e_illume_quickpanel_priority_minor_set */ -EAPI int +EAPI int ecore_x_e_illume_quickpanel_priority_minor_get(Ecore_X_Window win) { unsigned int val = 0; @@ -753,15 +749,10 @@ EAPI void ecore_x_e_illume_quickpanel_position_update_send(Ecore_X_Window win) { LOGFN(__FILE__, __LINE__, __FUNCTION__); - ecore_x_client_message32_send( - win, - ECORE_X_ATOM_E_ILLUME_QUICKPANEL_POSITION_UPDATE, - ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, - 1, - 0, - 0, - 0, - 0); + ecore_x_client_message32_send(win, + ECORE_X_ATOM_E_ILLUME_QUICKPANEL_POSITION_UPDATE, + ECORE_X_EVENT_MASK_WINDOW_CONFIGURE, + 1, 0, 0, 0, 0); } /* ecore_x_e_illume_quickpanel_position_update_send */ /* added by doyoun.kang - for sliding window */ @@ -1100,62 +1091,57 @@ ecore_x_e_comp_pixmap_get(Ecore_X_Window win) return pixmap; } /* ecore_x_e_comp_pixmap_get */ -/* added by gl77.lee 100704 - support for DRI buffer flipping */ EAPI void ecore_x_e_comp_dri_buff_flip_supported_set(Ecore_X_Window root, Eina_Bool enabled) { - Ecore_X_Window win; - - if (!root) root = DefaultRootWindow(_ecore_x_disp); - LOGFN(__FILE__, __LINE__, __FUNCTION__); - if (enabled) - { - win = ecore_x_window_new(root, 1, 2, 3, 4); - ecore_x_window_prop_xid_set(win, ECORE_X_ATOM_E_COMP_DRI_BUFF_FLIP_SUPPORTED, - ECORE_X_ATOM_WINDOW, &win, 1); - ecore_x_window_prop_xid_set(root, ECORE_X_ATOM_E_COMP_DRI_BUFF_FLIP_SUPPORTED, - ECORE_X_ATOM_WINDOW, &win, 1); - } - else - { - int ret; - ret = - ecore_x_window_prop_xid_get(root, - ECORE_X_ATOM_E_COMP_DRI_BUFF_FLIP_SUPPORTED, - ECORE_X_ATOM_WINDOW, - &win, 1); - if ((ret == 1) && (win)) - { - ecore_x_window_prop_property_del(root, ECORE_X_ATOM_E_COMP_DRI_BUFF_FLIP_SUPPORTED); - ecore_x_window_free(win); - } - } + Ecore_X_Window win; + + if (!root) root = DefaultRootWindow(_ecore_x_disp); + LOGFN(__FILE__, __LINE__, __FUNCTION__); + if (enabled) + { + win = ecore_x_window_new(root, 1, 2, 3, 4); + ecore_x_window_prop_xid_set(win, ECORE_X_ATOM_E_COMP_DRI_BUFF_FLIP_SUPPORTED, + ECORE_X_ATOM_WINDOW, &win, 1); + ecore_x_window_prop_xid_set(root, ECORE_X_ATOM_E_COMP_DRI_BUFF_FLIP_SUPPORTED, + ECORE_X_ATOM_WINDOW, &win, 1); + } + else + { + int ret = + ecore_x_window_prop_xid_get(root, + ECORE_X_ATOM_E_COMP_DRI_BUFF_FLIP_SUPPORTED, + ECORE_X_ATOM_WINDOW, + &win, 1); + if ((ret == 1) && (win)) + { + ecore_x_window_prop_property_del(root, ECORE_X_ATOM_E_COMP_DRI_BUFF_FLIP_SUPPORTED); + ecore_x_window_free(win); + } + } } EAPI Eina_Bool ecore_x_e_comp_dri_buff_flip_supported_get(Ecore_X_Window root) { - Ecore_X_Window win, win2; - int ret; - - LOGFN(__FILE__, __LINE__, __FUNCTION__); - if (!root) root = DefaultRootWindow(_ecore_x_disp); - ret = - ecore_x_window_prop_xid_get(root, - ECORE_X_ATOM_E_COMP_DRI_BUFF_FLIP_SUPPORTED, - ECORE_X_ATOM_WINDOW, - &win, 1); - if ((ret == 1) && (win)) - { - ret = - ecore_x_window_prop_xid_get(win, - ECORE_X_ATOM_E_COMP_DRI_BUFF_FLIP_SUPPORTED, - ECORE_X_ATOM_WINDOW, - &win2, 1); - if ((ret == 1) && (win2 == win)) - { - return 1; - } - } - return 0; + Ecore_X_Window win, win2; + int ret; + + LOGFN(__FILE__, __LINE__, __FUNCTION__); + if (!root) root = DefaultRootWindow(_ecore_x_disp); + ret = + ecore_x_window_prop_xid_get(root, + ECORE_X_ATOM_E_COMP_DRI_BUFF_FLIP_SUPPORTED, + ECORE_X_ATOM_WINDOW, + &win, 1); + if ((ret == 1) && (win)) + { + ret = + ecore_x_window_prop_xid_get(win, + ECORE_X_ATOM_E_COMP_DRI_BUFF_FLIP_SUPPORTED, + ECORE_X_ATOM_WINDOW, + &win2, 1); + if ((ret == 1) && (win2 == win)) return EINA_TRUE; + } + return EINA_FALSE; } diff --git a/src/lib/ecore_x/xlib/ecore_x_events.c b/src/lib/ecore_x/xlib/ecore_x_events.c index d877bcb..43421c4 100644 --- a/src/lib/ecore_x/xlib/ecore_x_events.c +++ b/src/lib/ecore_x/xlib/ecore_x_events.c @@ -325,7 +325,7 @@ _ecore_key_press(int event, XKeyEvent *xevent) sym = 0; key = NULL; compose = NULL; - if (_ecore_x_ic) + if ((_ecore_x_ic) && (event == ECORE_EVENT_KEY_DOWN)) { Status mbstatus; #ifdef X_HAVE_UTF8_STRING @@ -536,7 +536,7 @@ _ecore_mouse_button(int event, } } - + if (event == ECORE_EVENT_MOUSE_BUTTON_DOWN && !e->double_click && !e->triple_click) diff --git a/src/lib/ecore_x/xlib/ecore_x_icccm.c b/src/lib/ecore_x/xlib/ecore_x_icccm.c index 9837cdd..9a0acd0 100644 --- a/src/lib/ecore_x/xlib/ecore_x_icccm.c +++ b/src/lib/ecore_x/xlib/ecore_x_icccm.c @@ -125,12 +125,13 @@ ecore_x_icccm_move_resize_send(Ecore_X_Window win, int x, int y, int w, int h) EAPI void ecore_x_icccm_hints_set(Ecore_X_Window win, - int accepts_focus, + Eina_Bool accepts_focus, Ecore_X_Window_State_Hint initial_state, Ecore_X_Pixmap icon_pixmap, Ecore_X_Pixmap icon_mask, Ecore_X_Window icon_window, - Ecore_X_Window window_group, int is_urgent) + Ecore_X_Window window_group, + Eina_Bool is_urgent) { XWMHints *hints; @@ -179,20 +180,21 @@ ecore_x_icccm_hints_set(Ecore_X_Window win, XFree(hints); } /* ecore_x_icccm_hints_set */ -EAPI int +EAPI Eina_Bool ecore_x_icccm_hints_get(Ecore_X_Window win, - int *accepts_focus, + Eina_Bool *accepts_focus, Ecore_X_Window_State_Hint *initial_state, Ecore_X_Pixmap *icon_pixmap, Ecore_X_Pixmap *icon_mask, Ecore_X_Window *icon_window, - Ecore_X_Window *window_group, int *is_urgent) + Ecore_X_Window *window_group, + Eina_Bool *is_urgent) { XWMHints *hints; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (accepts_focus) - *accepts_focus = 1; + *accepts_focus = EINA_TRUE; if (initial_state) *initial_state = ECORE_X_WINDOW_STATE_HINT_NORMAL; @@ -210,7 +212,7 @@ ecore_x_icccm_hints_get(Ecore_X_Window win, *window_group = 0; if (is_urgent) - *is_urgent = 0; + *is_urgent = EINA_FALSE; hints = XGetWMHints(_ecore_x_disp, win); if (hints) @@ -218,9 +220,9 @@ ecore_x_icccm_hints_get(Ecore_X_Window win, if ((hints->flags & InputHint) && (accepts_focus)) { if (hints->input) - *accepts_focus = 1; + *accepts_focus = EINA_TRUE; else - *accepts_focus = 0; + *accepts_focus = EINA_FALSE; } if ((hints->flags & StateHint) && (initial_state)) @@ -246,18 +248,18 @@ ecore_x_icccm_hints_get(Ecore_X_Window win, *window_group = hints->window_group; if ((hints->flags & XUrgencyHint) && (is_urgent)) - *is_urgent = 1; + *is_urgent = EINA_TRUE; XFree(hints); - return 1; + return EINA_TRUE; } - return 0; + return EINA_FALSE; } /* ecore_x_icccm_hints_get */ EAPI void ecore_x_icccm_size_pos_hints_set(Ecore_X_Window win, - int request_pos, + Eina_Bool request_pos, Ecore_X_Gravity gravity, int min_w, int min_h, int max_w, int max_h, @@ -322,9 +324,9 @@ ecore_x_icccm_size_pos_hints_set(Ecore_X_Window win, XSetWMNormalHints(_ecore_x_disp, win, &hint); } /* ecore_x_icccm_size_pos_hints_set */ -EAPI int +EAPI Eina_Bool ecore_x_icccm_size_pos_hints_get(Ecore_X_Window win, - int *request_pos, + Eina_Bool *request_pos, Ecore_X_Gravity *gravity, int *min_w, int *min_h, int *max_w, int *max_h, @@ -343,15 +345,15 @@ ecore_x_icccm_size_pos_hints_get(Ecore_X_Window win, LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!XGetWMNormalHints(_ecore_x_disp, win, &hint, &mask)) - return 0; + return EINA_FALSE; if ((hint.flags & USPosition) || ((hint.flags & PPosition))) { if (request_pos) - *request_pos = 1; + *request_pos = EINA_TRUE; } else if (request_pos) - *request_pos = 0; + *request_pos = EINA_FALSE; if (hint.flags & PWinGravity) { @@ -439,7 +441,7 @@ ecore_x_icccm_size_pos_hints_get(Ecore_X_Window win, if (max_aspect) *max_aspect = maxa; - return 1; + return EINA_TRUE; } /* ecore_x_icccm_size_pos_hints_get */ EAPI void @@ -556,7 +558,8 @@ ecore_x_icccm_protocol_atoms_set(Ecore_X_Window win, */ EAPI void ecore_x_icccm_protocol_set(Ecore_X_Window win, - Ecore_X_WM_Protocol protocol, int on) + Ecore_X_WM_Protocol protocol, + Eina_Bool on) { Atom *protos = NULL; Atom proto; @@ -639,26 +642,27 @@ leave: * @param protocol The protocol to query * @return 1 if the protocol is set, else 0. */ -EAPI int +EAPI Eina_Bool ecore_x_icccm_protocol_isset(Ecore_X_Window win, Ecore_X_WM_Protocol protocol) { Atom proto, *protos = NULL; - int i, ret = 0, protos_count = 0; + int i, protos_count = 0; + Eina_Bool ret = EINA_FALSE; /* check for invalid values */ if (protocol >= ECORE_X_WM_PROTOCOL_NUM) - return 0; + return EINA_FALSE; LOGFN(__FILE__, __LINE__, __FUNCTION__); proto = _ecore_x_atoms_wm_protocols[protocol]; if (!XGetWMProtocols(_ecore_x_disp, win, &protos, &protos_count)) - return 0; + return EINA_FALSE; for (i = 0; i < protos_count; i++) if (protos[i] == proto) { - ret = 1; + ret = EINA_TRUE; break; } diff --git a/src/lib/ecore_x/xlib/ecore_x_image.c b/src/lib/ecore_x/xlib/ecore_x_image.c index ce36381..151a61e 100644 --- a/src/lib/ecore_x/xlib/ecore_x_image.c +++ b/src/lib/ecore_x/xlib/ecore_x_image.c @@ -215,9 +215,10 @@ ecore_x_image_get(Ecore_X_Image *im, Ecore_X_Drawable draw, im->data + (im->xim->bytes_per_line * sy) + (sx * im->bpp); im->xim->width = w; im->xim->height = h; + XGrabServer(_ecore_x_disp); if (!XShmGetImage(_ecore_x_disp, draw, im->xim, x, y, 0xffffffff)) ret = EINA_FALSE; - + XUngrabServer(_ecore_x_disp); ecore_x_sync(); } // unavoidable thanks to mit-shm get api - tmp shm buf + copy into it @@ -270,38 +271,295 @@ ecore_x_image_get(Ecore_X_Image *im, Ecore_X_Drawable draw, } /* ecore_x_image_get */ EAPI void -ecore_x_image_put(Ecore_X_Image *im __UNUSED__, - Ecore_X_Drawable draw __UNUSED__, - int x __UNUSED__, - int y __UNUSED__, - int sx __UNUSED__, - int sy __UNUSED__, - int w __UNUSED__, - int h __UNUSED__) +ecore_x_image_put(Ecore_X_Image *im, + Ecore_X_Drawable draw, + Ecore_X_GC gc, + int x, + int y, + int sx, + int sy, + int w, + int h) { - LOGFN(__FILE__, __LINE__, __FUNCTION__); - printf("ecore_x_image_put: unimplemented!\n"); + Ecore_X_GC tgc = 0; + + if (!gc) + { + XGCValues gcv; + memset(&gcv, 0, sizeof(gcv)); + gcv.subwindow_mode = IncludeInferiors; + tgc = XCreateGC(_ecore_x_disp, draw, GCSubwindowMode, &gcv); + gc = tgc; + } + if (!im->xim) _ecore_x_image_shm_create(im); + XShmPutImage(_ecore_x_disp, draw, gc, im->xim, sx, sy, x, y, w, h, False); + if (tgc) ecore_x_gc_free(tgc); } /* ecore_x_image_put */ EAPI void * ecore_x_image_data_get(Ecore_X_Image *im, int *bpl, int *rows, int *bpp) { LOGFN(__FILE__, __LINE__, __FUNCTION__); - if (!im->xim) - _ecore_x_image_shm_create(im); - - if (!im->xim) - return NULL; - - if (bpl) - *bpl = im->bpl; - - if (rows) - *rows = im->rows; - - if (bpp) - *bpp = im->bpp; - + if (!im->xim) _ecore_x_image_shm_create(im); + if (!im->xim) return NULL; + if (bpl) *bpl = im->bpl; + if (rows) *rows = im->rows; + if (bpp) *bpp = im->bpp; return im->data; } /* ecore_x_image_data_get */ +EAPI Eina_Bool +ecore_x_image_is_argb32_get(Ecore_X_Image *im) +{ + Visual *vis = im->vis; + if (!im->xim) _ecore_x_image_shm_create(im); + if (((vis->class == TrueColor) || + (vis->class == DirectColor)) && + (im->depth >= 24) && + (vis->red_mask == 0xff0000) && + (vis->green_mask == 0x00ff00) && + (vis->blue_mask == 0x0000ff)) + { +#ifdef WORDS_BIGENDIAN + if (im->xim->bitmap_bit_order == LSBFirst) return EINA_TRUE; +#else + if (im->xim->bitmap_bit_order == MSBFirst) return EINA_TRUE; +#endif + } + return EINA_FALSE; +} + +EAPI Eina_Bool +ecore_x_image_to_argb_convert(void *src, int sbpp, + int sbpl, + Ecore_X_Colormap c, + Ecore_X_Visual v, + int x, int y, int w, int h, + unsigned int *dst, + int dbpl, + int dx, int dy) +{ + Visual *vis = v; + XColor *cols = NULL; + int n = 0, nret = 0, i, row; + unsigned int pal[256], r, g, b; + enum + { + rgbnone = 0, + rgb565, + bgr565, + rgbx555, + argbx888, + abgrx888, + rgba888x, + bgra888x, + argbx666 + }; + int mode = 0; + + sbpp *= 8; + + n = vis->map_entries; + if ((n <= 256) && + ((vis->class == PseudoColor) || + (vis->class == StaticColor) || + (vis->class == GrayScale) || + (vis->class == StaticGray))) + { + if (!c) c = DefaultColormap(_ecore_x_disp, + DefaultScreen(_ecore_x_disp)); + cols = alloca(n * sizeof(XColor)); + for (i = 0; i < n; i++) + { + cols[i].pixel = i; + cols[i].flags = DoRed | DoGreen | DoBlue; + cols[i].red = 0; + cols[i].green = 0; + cols[i].blue = 0; + } + XQueryColors(_ecore_x_disp, c, cols, n); + for (i = 0; i < n; i++) + { + pal[i] = 0xff000000 | + ((cols[i].red >> 8) << 16) | + ((cols[i].green >> 8) << 8 ) | + ((cols[i].blue >> 8) ); + } + nret = n; + } + else if ((vis->class == TrueColor) || + (vis->class == DirectColor)) + { + if ((vis->red_mask == 0x00ff0000) && + (vis->green_mask == 0x0000ff00) && + (vis->blue_mask == 0x000000ff)) + mode = argbx888; + else if ((vis->red_mask == 0x000000ff) && + (vis->green_mask == 0x0000ff00) && + (vis->blue_mask == 0x00ff0000)) + mode = abgrx888; + else if ((vis->red_mask == 0xff000000) && + (vis->green_mask == 0x00ff0000) && + (vis->blue_mask == 0x0000ff00)) + mode = rgba888x; + else if ((vis->red_mask == 0x0000ff00) && + (vis->green_mask == 0x00ff0000) && + (vis->blue_mask == 0xff000000)) + mode = bgra888x; + else if ((vis->red_mask == 0x0003f000) && + (vis->green_mask == 0x00000fc0) && + (vis->blue_mask == 0x0000003f)) + mode = argbx666; + else if ((vis->red_mask == 0x0000f800) && + (vis->green_mask == 0x000007e0) && + (vis->blue_mask == 0x0000001f)) + mode = rgb565; + else if ((vis->red_mask == 0x0000001f) && + (vis->green_mask == 0x000007e0) && + (vis->blue_mask == 0x0000f800)) + mode = bgr565; + else if ((vis->red_mask == 0x00007c00) && + (vis->green_mask == 0x000003e0) && + (vis->blue_mask == 0x0000001f)) + mode = rgbx555; + else + return EINA_FALSE; + } + for (row = 0; row < h; row++) + { + unsigned char *s8; + unsigned short *s16; + unsigned int *s32; + unsigned int *dp, *de; + + dp = ((unsigned int *)(((unsigned char *)dst) + + ((dy + row) * dbpl))) + dx; + de = dp + w; + switch (sbpp) + { + case 8: + s8 = ((unsigned char *)(((unsigned char *)src) + ((y + row) * sbpl))) + x; + if (nret > 0) + { + while (dp < de) + { + *dp = pal[*s8]; + s8++; dp++; + } + } + else + return EINA_FALSE; + break; + case 16: + s16 = ((unsigned short *)(((unsigned char *)src) + ((y + row) * sbpl))) + x; + switch (mode) + { + case rgb565: + while (dp < de) + { + r = (*s16 & 0xf800) << 8; + g = (*s16 & 0x07e0) << 5; + b = (*s16 & 0x001f) << 3; + r |= (r >> 5) & 0xff0000; + g |= (g >> 6) & 0x00ff00; + b |= (b >> 5); + *dp = 0xff000000 | r | g | b; + s16++; dp++; + } + break; + case bgr565: + while (dp < de) + { + r = (*s16 & 0x001f) << 19; + g = (*s16 & 0x07e0) << 5; + b = (*s16 & 0xf800) >> 8; + r |= (r >> 5) & 0xff0000; + g |= (g >> 6) & 0x00ff00; + b |= (b >> 5); + *dp = 0xff000000 | r | g | b; + s16++; dp++; + } + break; + case rgbx555: + while (dp < de) + { + r = (*s16 & 0x7c00) << 9; + g = (*s16 & 0x03e0) << 6; + b = (*s16 & 0x001f) << 3; + r |= (r >> 5) & 0xff0000; + g |= (g >> 5) & 0x00ff00; + b |= (b >> 5); + *dp = 0xff000000 | r | g | b; + s16++; dp++; + } + break; + default: + return EINA_FALSE; + break; + } + break; + case 24: + case 32: + s32 = ((unsigned int *)(((unsigned char *)src) + ((y + row) * sbpl))) + x; + switch (mode) + { + case argbx888: + while (dp < de) + { + *dp = 0xff000000 | *s32; + s32++; dp++; + } + break; + case abgrx888: + while (dp < de) + { + r = *s32 & 0x000000ff; + g = *s32 & 0x0000ff00; + b = *s32 & 0x00ff0000; + *dp = 0xff000000 | (r << 16) | (g) | (b >> 16); + s32++; dp++; + } + break; + case rgba888x: + while (dp < de) + { + *dp = 0xff000000 | (*s32 >> 8); + s32++; dp++; + } + break; + case bgra888x: + while (dp < de) + { + r = *s32 & 0x0000ff00; + g = *s32 & 0x00ff0000; + b = *s32 & 0xff000000; + *dp = 0xff000000 | (r << 8) | (g >> 8) | (b >> 24); + s32++; dp++; + } + break; + case argbx666: + while (dp < de) + { + r = (*s32 & 0x3f000) << 6; + g = (*s32 & 0x00fc0) << 4; + b = (*s32 & 0x0003f) << 2; + r |= (r >> 6) & 0xff0000; + g |= (g >> 6) & 0x00ff00; + b |= (b >> 6); + *dp = 0xff000000 | r | g | b; + s32++; dp++; + } + break; + default: + return EINA_FALSE; + break; + } + break; + break; + default: + return EINA_FALSE; + break; + } + } + return EINA_TRUE; +} diff --git a/src/lib/ecore_x/xlib/ecore_x_mwm.c b/src/lib/ecore_x/xlib/ecore_x_mwm.c index 003bdf2..6de53dd 100644 --- a/src/lib/ecore_x/xlib/ecore_x_mwm.c +++ b/src/lib/ecore_x/xlib/ecore_x_mwm.c @@ -31,7 +31,7 @@ typedef struct _mwmhints } MWMHints; -EAPI int +EAPI Eina_Bool ecore_x_mwm_hints_get(Ecore_X_Window win, Ecore_X_MWM_Hint_Func *fhint, Ecore_X_MWM_Hint_Decor *dhint, @@ -40,15 +40,15 @@ ecore_x_mwm_hints_get(Ecore_X_Window win, unsigned char *p = NULL; MWMHints *mwmhints = NULL; int num; - int ret; + Eina_Bool ret; LOGFN(__FILE__, __LINE__, __FUNCTION__); - ret = 0; + ret = EINA_FALSE; if (!ecore_x_window_prop_property_get(win, ECORE_X_ATOM_MOTIF_WM_HINTS, ECORE_X_ATOM_MOTIF_WM_HINTS, 32, &p, &num)) - return 0; + return EINA_FALSE; mwmhints = (MWMHints *)p; if (mwmhints) @@ -79,7 +79,7 @@ ecore_x_mwm_hints_get(Ecore_X_Window win, *ihint = ECORE_X_MWM_HINT_INPUT_MODELESS; } - ret = 1; + ret = EINA_TRUE; } free(mwmhints); @@ -89,7 +89,7 @@ ecore_x_mwm_hints_get(Ecore_X_Window win, } /* ecore_x_mwm_hints_get */ EAPI void -ecore_x_mwm_borderless_set(Ecore_X_Window win, int borderless) +ecore_x_mwm_borderless_set(Ecore_X_Window win, Eina_Bool borderless) { unsigned int data[5] = {0, 0, 0, 0, 0}; diff --git a/src/lib/ecore_x/xlib/ecore_x_netwm.c b/src/lib/ecore_x/xlib/ecore_x_netwm.c index 1646ada..fa56135 100644 --- a/src/lib/ecore_x/xlib/ecore_x_netwm.c +++ b/src/lib/ecore_x/xlib/ecore_x_netwm.c @@ -128,7 +128,7 @@ ecore_x_netwm_supported_set(Ecore_X_Window root, num); } /* ecore_x_netwm_supported_set */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_supported_get(Ecore_X_Window root, Ecore_X_Atom **supported, int *num) @@ -145,12 +145,12 @@ ecore_x_netwm_supported_get(Ecore_X_Window root, num_ret = ecore_x_window_prop_atom_list_get(root, ECORE_X_ATOM_NET_SUPPORTED, supported); if (num_ret <= 0) - return 0; + return EINA_FALSE; if (num) *num = num_ret; - return 1; + return EINA_TRUE; } /* ecore_x_netwm_supported_get */ /* @@ -265,7 +265,7 @@ ecore_x_netwm_desk_current_set(Ecore_X_Window root, unsigned int desk) } /* ecore_x_netwm_desk_current_set */ EAPI void -ecore_x_netwm_showing_desktop_set(Ecore_X_Window root, int on) +ecore_x_netwm_showing_desktop_set(Ecore_X_Window root, Eina_Bool on) { unsigned int val; @@ -439,7 +439,7 @@ ecore_x_netwm_desktop_set(Ecore_X_Window win, unsigned int desk) ecore_x_window_prop_card32_set(win, ECORE_X_ATOM_NET_WM_DESKTOP, &desk, 1); } /* ecore_x_netwm_desktop_set */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_desktop_get(Ecore_X_Window win, unsigned int *desk) { int ret; @@ -452,7 +452,7 @@ ecore_x_netwm_desktop_get(Ecore_X_Window win, unsigned int *desk) if (desk) *desk = tmp; - return ret == 1 ? 1 : 0; + return ret == 1 ? EINA_TRUE : EINA_FALSE; } /* ecore_x_netwm_desktop_get */ /* @@ -475,7 +475,7 @@ ecore_x_netwm_strut_set(Ecore_X_Window win, int left, int right, /* * _NET_WM_STRUT is deprecated */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_strut_get(Ecore_X_Window win, int *left, int *right, int *top, int *bottom) { @@ -488,7 +488,7 @@ ecore_x_netwm_strut_get(Ecore_X_Window win, int *left, int *right, strut, 4); if (ret != 4) - return 0; + return EINA_FALSE; if (left) *left = strut[0]; @@ -502,7 +502,7 @@ ecore_x_netwm_strut_get(Ecore_X_Window win, int *left, int *right, if (bottom) *bottom = strut[3]; - return 1; + return EINA_TRUE; } /* ecore_x_netwm_strut_get */ EAPI void @@ -541,7 +541,7 @@ ecore_x_netwm_strut_partial_set(Ecore_X_Window win, 12); } /* ecore_x_netwm_strut_partial_set */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_strut_partial_get(Ecore_X_Window win, int *left, int *right, @@ -565,7 +565,7 @@ ecore_x_netwm_strut_partial_get(Ecore_X_Window win, strut, 12); if (ret != 12) - return 0; + return EINA_FALSE; if (left) *left = strut[0]; @@ -603,10 +603,10 @@ ecore_x_netwm_strut_partial_get(Ecore_X_Window win, if (bottom_end_x) *bottom_end_x = strut[11]; - return 1; + return EINA_TRUE; } /* ecore_x_netwm_strut_partial_get */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_icons_get(Ecore_X_Window win, Ecore_X_Icon **icon, int *num) { unsigned int *data, *p; @@ -624,15 +624,15 @@ ecore_x_netwm_icons_get(Ecore_X_Window win, Ecore_X_Icon **icon, int *num) num_ret = ecore_x_window_prop_card32_list_get(win, ECORE_X_ATOM_NET_WM_ICON, &data); if (num_ret <= 0) - return 0; + return EINA_FALSE; if (!data) - return 0; + return EINA_FALSE; if (num_ret < 2) { free(data); - return 0; + return EINA_FALSE; } /* Check how many icons there are */ @@ -645,7 +645,7 @@ ecore_x_netwm_icons_get(Ecore_X_Window win, Ecore_X_Icon **icon, int *num) if ((p - data) > num_ret) { free(data); - return 0; + return EINA_FALSE; } icons++; @@ -660,7 +660,7 @@ ecore_x_netwm_icons_get(Ecore_X_Window win, Ecore_X_Icon **icon, int *num) if (!icon) { free(data); - return 1; + return EINA_TRUE; } /* Allocate memory */ @@ -668,7 +668,7 @@ ecore_x_netwm_icons_get(Ecore_X_Window win, Ecore_X_Icon **icon, int *num) if (!(*icon)) { free(data); - return 0; + return EINA_FALSE; } /* Fetch the icons */ @@ -688,7 +688,7 @@ ecore_x_netwm_icons_get(Ecore_X_Window win, Ecore_X_Icon **icon, int *num) free(((*icon)[--i]).data); free(*icon); free(data); - return 0; + return EINA_FALSE; } pd = ((*icon)[i]).data; @@ -710,7 +710,7 @@ ecore_x_netwm_icons_get(Ecore_X_Window win, Ecore_X_Icon **icon, int *num) free(data); - return 1; + return EINA_TRUE; } /* ecore_x_netwm_icons_get */ EAPI void @@ -733,7 +733,7 @@ ecore_x_netwm_icon_geometry_set(Ecore_X_Window win, 4); } /* ecore_x_netwm_icon_geometry_set */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_icon_geometry_get(Ecore_X_Window win, int *x, int *y, @@ -749,7 +749,7 @@ ecore_x_netwm_icon_geometry_get(Ecore_X_Window win, geometry, 4); if (ret != 4) - return 0; + return EINA_FALSE; if (x) *x = geometry[0]; @@ -763,7 +763,7 @@ ecore_x_netwm_icon_geometry_get(Ecore_X_Window win, if (height) *height = geometry[3]; - return 1; + return EINA_TRUE; } /* ecore_x_netwm_icon_geometry_get */ EAPI void @@ -777,7 +777,7 @@ ecore_x_netwm_pid_set(Ecore_X_Window win, int pid) &tmp, 1); } /* ecore_x_netwm_pid_set */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_pid_get(Ecore_X_Window win, int *pid) { int ret; @@ -789,7 +789,7 @@ ecore_x_netwm_pid_get(Ecore_X_Window win, int *pid) if (pid) *pid = tmp; - return ret == 1 ? 1 : 0; + return ret == 1 ? EINA_TRUE : EINA_FALSE; } /* ecore_x_netwm_pid_get */ EAPI void @@ -800,14 +800,14 @@ ecore_x_netwm_handled_icons_set(Ecore_X_Window win) NULL, 0); } /* ecore_x_netwm_handled_icons_set */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_handled_icons_get(Ecore_X_Window win) { int ret = 0; LOGFN(__FILE__, __LINE__, __FUNCTION__); ret = ecore_x_window_prop_card32_get(win, ECORE_X_ATOM_NET_WM_HANDLED_ICONS, NULL, 0); - return ret == 0 ? 1 : 0; + return ret == 0 ? EINA_TRUE : EINA_FALSE; } /* ecore_x_netwm_handled_icons_get */ EAPI void @@ -818,7 +818,7 @@ ecore_x_netwm_user_time_set(Ecore_X_Window win, unsigned int time) &time, 1); } /* ecore_x_netwm_user_time_set */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_user_time_get(Ecore_X_Window win, unsigned int *time) { int ret; @@ -830,7 +830,7 @@ ecore_x_netwm_user_time_get(Ecore_X_Window win, unsigned int *time) if (time) *time = tmp; - return ret == 1 ? 1 : 0; + return ret == 1 ? EINA_TRUE : EINA_FALSE; } /* ecore_x_netwm_user_time_get */ Ecore_X_Window_State @@ -937,7 +937,7 @@ ecore_x_netwm_window_state_set(Ecore_X_Window win, free(set); } /* ecore_x_netwm_window_state_set */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_window_state_get(Ecore_X_Window win, Ecore_X_Window_State **state, unsigned int *num) @@ -955,7 +955,7 @@ ecore_x_netwm_window_state_get(Ecore_X_Window win, num_ret = ecore_x_window_prop_atom_list_get(win, ECORE_X_ATOM_NET_WM_STATE, &atoms); if (num_ret <= 0) - return 0; + return EINA_FALSE; if (state) { @@ -969,7 +969,7 @@ ecore_x_netwm_window_state_get(Ecore_X_Window win, } free(atoms); - return 1; + return EINA_TRUE; } /* ecore_x_netwm_window_state_get */ static Ecore_X_Window_Type @@ -1075,7 +1075,7 @@ ecore_x_netwm_window_type_set(Ecore_X_Window win, Ecore_X_Window_Type type) } /* ecore_x_netwm_window_type_set */ /* FIXME: Maybe return 0 on some conditions? */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_window_type_get(Ecore_X_Window win, Ecore_X_Window_Type *type) { int num; @@ -1093,9 +1093,9 @@ ecore_x_netwm_window_type_get(Ecore_X_Window win, Ecore_X_Window_Type *type) free(atoms); if (num >= 1) - return 1; + return EINA_TRUE; - return 0; + return EINA_FALSE; } /* ecore_x_netwm_window_type_get */ EAPI int @@ -1182,11 +1182,12 @@ _ecore_x_netwm_action_atom_get(Ecore_X_Action action) } /* _ecore_x_netwm_action_atom_get */ /* FIXME: Get complete list */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_allowed_action_isset(Ecore_X_Window win, Ecore_X_Action action) { - int num, i, ret = 0; + int num, i; Ecore_X_Atom *atoms, atom; + Eina_Bool ret = EINA_FALSE; LOGFN(__FILE__, __LINE__, __FUNCTION__); num = ecore_x_window_prop_atom_list_get(win, ECORE_X_ATOM_NET_WM_WINDOW_TYPE, @@ -1241,7 +1242,7 @@ ecore_x_netwm_allowed_action_set(Ecore_X_Window win, free(set); } /* ecore_x_netwm_allowed_action_set */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_allowed_action_get(Ecore_X_Window win, Ecore_X_Action **action, unsigned int *num) @@ -1261,7 +1262,7 @@ ecore_x_netwm_allowed_action_get(Ecore_X_Window win, ECORE_X_ATOM_NET_WM_ALLOWED_ACTIONS, &atoms); if (num_ret <= 0) - return 0; + return EINA_FALSE; if (action) { @@ -1275,7 +1276,7 @@ ecore_x_netwm_allowed_action_get(Ecore_X_Window win, } free(atoms); - return 1; + return EINA_TRUE; } /* ecore_x_netwm_allowed_action_get */ EAPI void @@ -1286,7 +1287,7 @@ ecore_x_netwm_opacity_set(Ecore_X_Window win, unsigned int opacity) &opacity, 1); } /* ecore_x_netwm_opacity_set */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_opacity_get(Ecore_X_Window win, unsigned int *opacity) { int ret; @@ -1298,7 +1299,7 @@ ecore_x_netwm_opacity_get(Ecore_X_Window win, unsigned int *opacity) if (opacity) *opacity = tmp; - return ret == 1 ? 1 : 0; + return ret == 1 ? EINA_TRUE : EINA_FALSE; } /* ecore_x_netwm_opacity_get */ EAPI void @@ -1317,7 +1318,7 @@ ecore_x_netwm_frame_size_set(Ecore_X_Window win, int fl, int fr, int ft, int fb) 4); } /* ecore_x_netwm_frame_size_set */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_frame_size_get(Ecore_X_Window win, int *fl, int *fr, @@ -1333,7 +1334,7 @@ ecore_x_netwm_frame_size_get(Ecore_X_Window win, frames, 4); if (ret != 4) - return 0; + return EINA_FALSE; if (fl) *fl = frames[0]; @@ -1347,10 +1348,10 @@ ecore_x_netwm_frame_size_get(Ecore_X_Window win, if (fb) *fb = frames[3]; - return 1; + return EINA_TRUE; } /* ecore_x_netwm_frame_size_get */ -EAPI int +EAPI Eina_Bool ecore_x_netwm_sync_counter_get(Ecore_X_Window win, Ecore_X_Sync_Counter *counter) { @@ -1367,7 +1368,7 @@ ecore_x_netwm_sync_counter_get(Ecore_X_Window win, if (counter) *counter = tmp; - return ret == 1 ? 1 : 0; + return ret == 1 ? EINA_TRUE : EINA_FALSE; } /* ecore_x_netwm_sync_counter_get */ EAPI void @@ -1424,7 +1425,7 @@ ecore_x_netwm_state_request_send(Ecore_X_Window win, Ecore_X_Window root, Ecore_X_Window_State s1, Ecore_X_Window_State s2, - int set) + Eina_Bool set) { XEvent xev; @@ -1888,7 +1889,7 @@ _ecore_x_netwm_startup_info_free(void *data) /* * Is screen composited? */ -EAPI int +EAPI Eina_Bool ecore_x_screen_is_composited(int screen) { Ecore_X_Window win; @@ -1901,11 +1902,11 @@ ecore_x_screen_is_composited(int screen) atom = XInternAtom(_ecore_x_disp, buf, False); if (atom == None) - return 0; + return EINA_FALSE; win = XGetSelectionOwner(_ecore_x_disp, atom); - return win != None; + return (win != None) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_screen_is_composited */ EAPI void diff --git a/src/lib/ecore_x/xlib/ecore_x_private.h b/src/lib/ecore_x/xlib/ecore_x_private.h index 537d42d..e3fc8d8 100644 --- a/src/lib/ecore_x/xlib/ecore_x_private.h +++ b/src/lib/ecore_x/xlib/ecore_x_private.h @@ -106,9 +106,9 @@ typedef struct _Ecore_X_Selection_Converter Ecore_X_Selection_Converter; struct _Ecore_X_Selection_Converter { Ecore_X_Atom target; - int (*convert)(char *target, void *data, int size, - void **data_ret, int *size_ret, - Ecore_X_Atom *type, int *typeseize); + Eina_Bool (*convert)(char *target, void *data, int size, + void **data_ret, int *size_ret, + Ecore_X_Atom *type, int *typeseize); Ecore_X_Selection_Converter *next; }; @@ -192,7 +192,7 @@ extern Time _ecore_x_event_last_time; extern Window _ecore_x_event_last_win; extern int _ecore_x_event_last_root_x; extern int _ecore_x_event_last_root_y; -extern int _ecore_x_xcursor; +extern Eina_Bool _ecore_x_xcursor; extern XIC _ecore_x_ic; extern Ecore_X_Atom _ecore_x_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_NUM]; @@ -268,7 +268,7 @@ Ecore_X_Atom char * _ecore_x_selection_target_get(Ecore_X_Atom target); Ecore_X_Selection_Intern * _ecore_x_selection_get(Ecore_X_Atom selection); -int _ecore_x_selection_set(Window w, +Eina_Bool _ecore_x_selection_set(Window w, const void *data, int len, Ecore_X_Atom selection); diff --git a/src/lib/ecore_x/xlib/ecore_x_randr.c b/src/lib/ecore_x/xlib/ecore_x_randr.c index 1da7cd1..aa935f7 100644 --- a/src/lib/ecore_x/xlib/ecore_x_randr.c +++ b/src/lib/ecore_x/xlib/ecore_x_randr.c @@ -81,8 +81,8 @@ ecore_x_randr_version_get(void) { return Ecore_X_Randr_Unset; } - #endif + return -1; } Eina_Bool diff --git a/src/lib/ecore_x/xlib/ecore_x_randr_12.c b/src/lib/ecore_x/xlib/ecore_x_randr_12.c index 27ef9c5..bd56228 100644 --- a/src/lib/ecore_x/xlib/ecore_x_randr_12.c +++ b/src/lib/ecore_x/xlib/ecore_x_randr_12.c @@ -9,8 +9,8 @@ #include "ecore_x_private.h" #include "ecore_x_randr.h" -#define Ecore_X_Randr_None 0 -#define Ecore_X_Randr_Unset -1 +#define Ecore_X_Randr_None (Ecore_X_Randr_Crtc)0 +#define Ecore_X_Randr_Unset (Ecore_X_Randr_Crtc)-1 #ifdef ECORE_XRANDR @@ -39,7 +39,7 @@ extern int _randr_version; #endif /** - * @Brief enable event selection. This enables basic interaction with + * @brief enable event selection. This enables basic interaction with * output/crtc events and requires RRandR >= 1.2. * @param win select this window's properties for RandRR events * @param on enable/disable selecting @@ -82,7 +82,8 @@ _ecore_x_randr_crtc_validate(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc) int i; Eina_Bool ret = EINA_FALSE; - if ((crtc == Ecore_X_Randr_None) || (crtc == Ecore_X_Randr_Unset)) + if ((crtc == Ecore_X_Randr_None) || + (crtc == Ecore_X_Randr_Unset)) return ret; if (_ecore_x_randr_root_validate(root) && crtc && @@ -385,7 +386,7 @@ ecore_x_randr_mode_info_get(Ecore_X_Window root, Ecore_X_Randr_Mode mode) int i; if (_ecore_x_randr_root_validate(root) && - (res = _ecore_x_randr_get_screen_resources (_ecore_x_disp, root))) + (res = _ecore_x_randr_get_screen_resources(_ecore_x_disp, root))) { for (i = 0; i < res->nmode; i++) { @@ -403,15 +404,14 @@ ecore_x_randr_mode_info_get(Ecore_X_Window root, Ecore_X_Randr_Mode mode) ret->vSyncStart = res->modes[i].vSyncStart; ret->vSyncEnd = res->modes[i].vSyncEnd; ret->vTotal = res->modes[i].vTotal; - if (!(ret->name = - strndup(res->modes[i].name, res->modes[i].nameLength))) + ret->name = NULL; + ret->nameLength = 0; + if (res->modes[i].nameLength > 0) { - ret->name = NULL; - ret->nameLength = 0; + ret->nameLength = res->modes[i].nameLength; + ret->name = strndup(res->modes[i].name, + res->modes[i].nameLength); } - else - ret->nameLength = res->modes[i].nameLength; - ret->modeFlags = res->modes[i].modeFlags; break; } @@ -436,12 +436,12 @@ ecore_x_randr_mode_info_free(Ecore_X_Randr_Mode_Info *mode_info) #ifdef ECORE_XRANDR RANDR_CHECK_1_2_RET(); if (!mode_info) - return; + return; if (mode_info->name) - free(mode_info->name); + free(mode_info->name); - free(mode_info); + free(mode_info); mode_info = NULL; #endif } @@ -635,7 +635,7 @@ ecore_x_randr_crtc_geometry_get(Ecore_X_Window root, } /* - * @Brief sets the position of given CRTC within root window's screen + * @brief sets the position of given CRTC within root window's screen * @param root the window's screen to be queried * @param crtc the CRTC which's position within the mentioned screen is to be altered * @param x position on the x-axis (0 == left) of the screen. if x < 0 current value will be kept. @@ -690,7 +690,7 @@ ecore_x_randr_crtc_pos_set(Ecore_X_Window root, } /** - * @Brief Get the current set mode of a given CRTC + * @brief Get the current set mode of a given CRTC * @param root the window's screen to be queried * @param crtc the CRTC which's should be queried * @return currently set mode or - in case parameters are invalid - @@ -724,16 +724,16 @@ ecore_x_randr_crtc_mode_get(Ecore_X_Window root, Ecore_X_Randr_Crtc crtc) } /** - * @Brief sets a mode for a CRTC and the outputs attached to it + * @brief sets a mode for a CRTC and the outputs attached to it * @param root the window's screen to be queried * @param crtc the CRTC which shall be set * @param outputs array of outputs which have to be compatible with the mode. If * NULL CRTC will be disabled. * @param noutputs number of outputs in array to be used. Use * Ecore_X_Randr_Unset (or -1) to use currently used outputs. - * @para mode XID of the mode to be set. If set to 0 the CRTC will be disabled. + * @param mode XID of the mode to be set. If set to 0 the CRTC will be disabled. * If set to -1 the call will fail. - * @return EINA_TRUE if mode setting was successfull. Else EINA_FALSE + * @return EINA_TRUE if mode setting was successful. Else EINA_FALSE */ EAPI Eina_Bool ecore_x_randr_crtc_mode_set(Ecore_X_Window root, @@ -1010,7 +1010,7 @@ ecore_x_randr_crtc_settings_set(Ecore_X_Window root, outputs = NULL; noutputs = 0; } - else if (noutputs == Ecore_X_Randr_Unset) + else if (noutputs == (int)Ecore_X_Randr_Unset) { outputs = (Ecore_X_Randr_Output *)crtc_info->outputs; noutputs = crtc_info->noutput; @@ -1047,10 +1047,10 @@ ecore_x_randr_crtc_settings_set(Ecore_X_Window root, /** * @brief sets a CRTC relative to another one. - * @crtc_r1 the CRTC to be positioned. - * @crtc_r2 the CRTC the position should be relative to - * @position the relation between the crtcs - * @aligment in case CRTCs size differ, aligns CRTC1 accordingly at CRTC2's + * @param crtc_r1 the CRTC to be positioned. + * @param crtc_r2 the CRTC the position should be relative to + * @param position the relation between the crtcs + * @param alignment in case CRTCs size differ, aligns CRTC1 accordingly at CRTC2's * borders * @return EINA_TRUE if crtc could be successfully positioned. EINA_FALSE if * repositioning failed or if position of new crtc would be out of given screen's min/max bounds. @@ -1425,9 +1425,9 @@ ecore_x_randr_output_possible_crtcs_get(Ecore_X_Window root, Ecore_X_Randr_Outpu /** * @brief gets the the outputs which might be used simultenously on the same * CRTC. - * @root window that this information should be queried for. - * @output the output which's clones we concern - * @num number of possible clones + * @param root window that this information should be queried for. + * @param output the output which's clones we concern + * @param num number of possible clones */ EAPI Ecore_X_Randr_Output * ecore_x_randr_output_clones_get(Ecore_X_Window root, Ecore_X_Randr_Output output, int *num) @@ -1491,7 +1491,7 @@ ecore_x_randr_output_crtc_get(Ecore_X_Window root, Ecore_X_Randr_Output output) /** * @brief gets the given output's name as reported by X * @param root the window which's screen will be queried - * @len length of returned c-string. + * @param len length of returned c-string. * @return name of the output as reported by X */ EAPI char * @@ -1512,9 +1512,8 @@ ecore_x_randr_output_name_get(Ecore_X_Window root, /* * Actually the bewow command is correct, but due to a bug in libXrandr * it doesn't work. Therefor we stick with strlen(). - * Replace the line below with the following once - * libXrandr >= git revision '25d793ab4ec111658e541c94eba4893a81d6a3b7'. - * is shipped and standard. + * Replace the line below with the following once this bug is + * fixed within libXrandr. * * *len = output_info->nameLen; * @@ -1537,8 +1536,8 @@ ecore_x_randr_output_name_get(Ecore_X_Window root, /** * @brief gets the width and hight of a given mode * @param mode the mode which's size is to be looked up - * @w width of given mode in px - * @h height of given mode in px + * @param w width of given mode in px + * @param h height of given mode in px */ EAPI void ecore_x_randr_mode_size_get(Ecore_X_Window root, @@ -1577,12 +1576,12 @@ ecore_x_randr_mode_size_get(Ecore_X_Window root, } /** - * @Brief gets the EDID information of an attached output if available. + * @brief gets the EDID information of an attached output if available. * Note that this information is not to be compared using ordinary string * comparison functions, since it includes 0-bytes. * @param root window this information should be queried from - * @output the XID of the output - * @length length of the byte-array. If NULL, request will fail. + * @param output the XID of the output + * @param length length of the byte-array. If NULL, request will fail. */ EAPI unsigned char * ecore_x_randr_output_edid_get(Ecore_X_Window root, @@ -1733,7 +1732,7 @@ ecore_x_randr_move_all_crtcs_but(Ecore_X_Window root, } /* - * @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 neccessary and possible. + * @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. * @param root window which's screen's resources are used * @param crtcs list of CRTCs to be moved * @param ncrtc number of CRTCs in array @@ -1769,14 +1768,14 @@ ecore_x_randr_move_crtcs(Ecore_X_Window root, i++) { if (((crtc_info[i]->x + dx) < 0) || - ((crtc_info[i]->x + crtc_info[i]->width + dx) > w_max) + ((int)(crtc_info[i]->x + crtc_info[i]->width + dx) > w_max) || ((crtc_info[i]->y + dy) < 0) || - ((crtc_info[i]->y + crtc_info[i]->height + dy) > h_max) + ((int)(crtc_info[i]->y + crtc_info[i]->height + dy) > h_max) ) goto _ecore_x_randr_move_crtcs_fail_free_crtc_info; - nw = MAX((crtc_info[i]->x + crtc_info[i]->width + dx), nw); - nh = MAX((crtc_info[i]->y + crtc_info[i]->height + dy), nh); + nw = MAX((int)(crtc_info[i]->x + crtc_info[i]->width + dx), nw); + nh = MAX((int)(crtc_info[i]->y + crtc_info[i]->height + dy), nh); } //not out of bounds @@ -1868,10 +1867,10 @@ ecore_x_randr_screen_reset(Ecore_X_Window root) enabled_crtcs[nenabled_crtcs++] = res->crtcs[i]; - if ((crtc_info->x + crtc_info->width) > w_n) + if ((int)(crtc_info->x + crtc_info->width) > w_n) w_n = (crtc_info->x + crtc_info->width); - if ((crtc_info->y + crtc_info->height) > h_n) + if ((int)(crtc_info->y + crtc_info->height) > h_n) h_n = (crtc_info->y + crtc_info->height); if (crtc_info->x < dx_min) diff --git a/src/lib/ecore_x/xlib/ecore_x_region.c b/src/lib/ecore_x/xlib/ecore_x_region.c index 4a11574..409ee89 100644 --- a/src/lib/ecore_x/xlib/ecore_x_region.c +++ b/src/lib/ecore_x/xlib/ecore_x_region.c @@ -44,11 +44,11 @@ ecore_x_xregion_free(Ecore_X_XRegion *region) XDestroyRegion((Region)region); } /* ecore_x_xregion_free */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_set(Ecore_X_XRegion *region, Ecore_X_GC gc) { LOGFN(__FILE__, __LINE__, __FUNCTION__); - return XSetRegion(_ecore_x_disp, gc, (Region)region); + return XSetRegion(_ecore_x_disp, gc, (Region)region) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_xregion_set */ EAPI void @@ -62,25 +62,25 @@ ecore_x_xregion_translate(Ecore_X_XRegion *region, int x, int y) XOffsetRegion((Region)region, x, y); } /* ecore_x_xregion_translate */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_intersect(Ecore_X_XRegion *dst, Ecore_X_XRegion *r1, Ecore_X_XRegion *r2) { LOGFN(__FILE__, __LINE__, __FUNCTION__); - return XIntersectRegion((Region)r1, (Region)r2, (Region)dst); + return XIntersectRegion((Region)r1, (Region)r2, (Region)dst) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_xregion_intersect */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_union(Ecore_X_XRegion *dst, Ecore_X_XRegion *r1, Ecore_X_XRegion *r2) { LOGFN(__FILE__, __LINE__, __FUNCTION__); - return XUnionRegion((Region)r1, (Region)r2, (Region)dst); + return XUnionRegion((Region)r1, (Region)r2, (Region)dst) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_xregion_union */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_union_rect(Ecore_X_XRegion *dst, Ecore_X_XRegion *src, Ecore_X_Rectangle *rect) @@ -93,59 +93,59 @@ ecore_x_xregion_union_rect(Ecore_X_XRegion *dst, xr.width = rect->width; xr.height = rect->height; - return XUnionRectWithRegion(&xr, (Region)src, (Region)dst); + return XUnionRectWithRegion(&xr, (Region)src, (Region)dst) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_xregion_union_rect */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_subtract(Ecore_X_XRegion *dst, Ecore_X_XRegion *rm, Ecore_X_XRegion *rs) { LOGFN(__FILE__, __LINE__, __FUNCTION__); - return XSubtractRegion((Region)rm, (Region)rs, (Region)dst); + return XSubtractRegion((Region)rm, (Region)rs, (Region)dst) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_xregion_subtract */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_is_empty(Ecore_X_XRegion *region) { if (!region) - return 1; + return EINA_TRUE; LOGFN(__FILE__, __LINE__, __FUNCTION__); - return !XEmptyRegion((Region)region); + return !XEmptyRegion((Region)region) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_xregion_is_empty */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_is_equal(Ecore_X_XRegion *r1, Ecore_X_XRegion *r2) { if (!r1 || !r2) - return 0; + return EINA_FALSE; LOGFN(__FILE__, __LINE__, __FUNCTION__); - return XEqualRegion((Region)r1, (Region)r1); + return XEqualRegion((Region)r1, (Region)r1) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_xregion_is_equal */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_point_contain(Ecore_X_XRegion *region, int x, int y) { if (!region) - return 0; + return EINA_FALSE; LOGFN(__FILE__, __LINE__, __FUNCTION__); - return XPointInRegion((Region)region, x, y); + return XPointInRegion((Region)region, x, y) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_xregion_point_contain */ -EAPI int +EAPI Eina_Bool ecore_x_xregion_rect_contain(Ecore_X_XRegion *region, Ecore_X_Rectangle *rect) { if (!region || !rect) - return 0; + return EINA_FALSE; LOGFN(__FILE__, __LINE__, __FUNCTION__); return XRectInRegion((Region)region, rect->x, rect->y, rect->width, - rect->height); + rect->height) ? EINA_TRUE : EINA_FALSE; } /* ecore_x_xregion_rect_contain */ diff --git a/src/lib/ecore_x/xlib/ecore_x_screensaver.c b/src/lib/ecore_x/xlib/ecore_x_screensaver.c index 2731d36..33f31af 100644 --- a/src/lib/ecore_x/xlib/ecore_x_screensaver.c +++ b/src/lib/ecore_x/xlib/ecore_x_screensaver.c @@ -13,7 +13,7 @@ static int _screensaver_available = -1; -EAPI int +EAPI Eina_Bool ecore_x_screensaver_event_available_get(void) { if (_screensaver_available >= 0) @@ -154,7 +154,7 @@ ecore_x_screensaver_interval_get(void) } /* ecore_x_screensaver_interval_get */ EAPI void -ecore_x_screensaver_event_listen_set(int on) +ecore_x_screensaver_event_listen_set(Eina_Bool on) { #ifdef ECORE_XSS Ecore_X_Window root; @@ -165,6 +165,9 @@ ecore_x_screensaver_event_listen_set(int on) XScreenSaverSelectInput(_ecore_x_disp, root, ScreenSaverNotifyMask); else XScreenSaverSelectInput(_ecore_x_disp, root, 0); +#else + return; + on = EINA_FALSE; #endif /* ifdef ECORE_XSS */ } /* ecore_x_screensaver_event_listen_set */ diff --git a/src/lib/ecore_x/xlib/ecore_x_selection.c b/src/lib/ecore_x/xlib/ecore_x_selection.c index cb09b55..f54ea93 100644 --- a/src/lib/ecore_x/xlib/ecore_x_selection.c +++ b/src/lib/ecore_x/xlib/ecore_x_selection.c @@ -15,7 +15,7 @@ static Ecore_X_Selection_Intern selections[4]; static Ecore_X_Selection_Converter *converters = NULL; static Ecore_X_Selection_Parser *parsers = NULL; -static int _ecore_x_selection_converter_text(char *target, +static Eina_Bool _ecore_x_selection_converter_text(char *target, void *data, int size, void **data_ret, @@ -119,7 +119,7 @@ _ecore_x_selection_get(Ecore_X_Atom selection) return NULL; } /* _ecore_x_selection_get */ -int +Eina_Bool _ecore_x_selection_set(Window w, const void *data, int size, @@ -130,7 +130,7 @@ _ecore_x_selection_set(Window w, XSetSelectionOwner(_ecore_x_disp, selection, w, _ecore_x_event_last_time); if (XGetSelectionOwner(_ecore_x_disp, selection) != w) - return 0; + return EINA_FALSE; if (selection == ECORE_X_ATOM_SELECTION_PRIMARY) in = 0; @@ -141,7 +141,7 @@ _ecore_x_selection_set(Window w, else if (selection == ECORE_X_ATOM_SELECTION_CLIPBOARD) in = 3; else - return 0; + return EINA_FALSE; if (data) { @@ -160,7 +160,7 @@ _ecore_x_selection_set(Window w, memset(&selections[in], 0, sizeof(Ecore_X_Selection_Data)); } - return 1; + return EINA_TRUE; } /* _ecore_x_selection_set */ /** @@ -171,7 +171,7 @@ _ecore_x_selection_set(Window w, * @return Returns 1 if the ownership of the selection was successfully * claimed, or 0 if unsuccessful. */ -EAPI int +EAPI Eina_Bool ecore_x_selection_primary_set(Ecore_X_Window w, const void *data, int size) { LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -184,7 +184,7 @@ ecore_x_selection_primary_set(Ecore_X_Window w, const void *data, int size) * or 0 if unsuccessful. * */ -EAPI int +EAPI Eina_Bool ecore_x_selection_primary_clear(void) { LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -199,7 +199,7 @@ ecore_x_selection_primary_clear(void) * @return Returns 1 if the ownership of the selection was successfully * claimed, or 0 if unsuccessful. */ -EAPI int +EAPI Eina_Bool ecore_x_selection_secondary_set(Ecore_X_Window w, const void *data, int size) { LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -215,7 +215,7 @@ ecore_x_selection_secondary_set(Ecore_X_Window w, const void *data, int size) * or 0 if unsuccessful. * */ -EAPI int +EAPI Eina_Bool ecore_x_selection_secondary_clear(void) { LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -233,7 +233,7 @@ ecore_x_selection_secondary_clear(void) * @return Returns 1 if the ownership of the selection was successfully * claimed, or 0 if unsuccessful. */ -EAPI int +EAPI Eina_Bool ecore_x_selection_xdnd_set(Ecore_X_Window w, const void *data, int size) { LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -246,7 +246,7 @@ ecore_x_selection_xdnd_set(Ecore_X_Window w, const void *data, int size) * or 0 if unsuccessful. * */ -EAPI int +EAPI Eina_Bool ecore_x_selection_xdnd_clear(void) { LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -264,7 +264,7 @@ ecore_x_selection_xdnd_clear(void) * Get the converted data from a previous CLIPBOARD selection * request. The buffer must be freed when done with. */ -EAPI int +EAPI Eina_Bool ecore_x_selection_clipboard_set(Ecore_X_Window w, const void *data, int size) { LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -280,7 +280,7 @@ ecore_x_selection_clipboard_set(Ecore_X_Window w, const void *data, int size) * or 0 if unsuccessful. * */ -EAPI int +EAPI Eina_Bool ecore_x_selection_clipboard_clear(void) { LOGFN(__FILE__, __LINE__, __FUNCTION__); @@ -386,14 +386,14 @@ ecore_x_selection_clipboard_request(Ecore_X_Window w, const char *target) } /* ecore_x_selection_clipboard_request */ EAPI void -ecore_x_selection_converter_atom_add(Ecore_X_Atom target, - int (*func)(char *target, - void *data, - int size, - void **data_ret, - int *size_ret, - Ecore_X_Atom *ttype, - int *tsize)) +ecore_x_selection_converter_atom_add(Ecore_X_Atom target, + Eina_Bool (*func)(char *target, + void *data, + int size, + void **data_ret, + int *size_ret, + Ecore_X_Atom *ttype, + int *tsize)) { Ecore_X_Selection_Converter *cnv; @@ -430,7 +430,7 @@ ecore_x_selection_converter_atom_add(Ecore_X_Atom EAPI void ecore_x_selection_converter_add(char *target, - int (*func)(char *target, + Eina_Bool (*func)(char *target, void *data, int size, void **data_ret, @@ -492,7 +492,7 @@ ecore_x_selection_converter_del(char *target) ecore_x_selection_converter_atom_del(x_target); } /* ecore_x_selection_converter_del */ -EAPI int +EAPI Eina_Bool ecore_x_selection_notify_send(Ecore_X_Window requestor, Ecore_X_Atom selection, Ecore_X_Atom target, @@ -514,11 +514,11 @@ ecore_x_selection_notify_send(Ecore_X_Window requestor, xnotify.serial = 0; xev.xselection = xnotify; - return ((XSendEvent(_ecore_x_disp, requestor, False, 0, &xev) > 0) ? 1 : 0); + return ((XSendEvent(_ecore_x_disp, requestor, False, 0, &xev) > 0) ? EINA_TRUE : EINA_FALSE); } /* ecore_x_selection_notify_send */ /* Locate and run conversion callback for specified selection target */ -EAPI int +EAPI Eina_Bool ecore_x_selection_convert(Ecore_X_Atom selection, Ecore_X_Atom target, void **data_ret, @@ -549,12 +549,12 @@ ecore_x_selection_convert(Ecore_X_Atom selection, return r; } else - return 0; + return EINA_FALSE; } } /* ICCCM says "If the selection cannot be converted into a form based on the target (and parameters, if any), the owner should refuse the SelectionRequest as previously described." */ - return 0; + return EINA_FALSE; /* Default, just return the data *data_ret = malloc(sel->length); @@ -567,7 +567,7 @@ ecore_x_selection_convert(Ecore_X_Atom selection, /* TODO: We need to work out a mechanism for automatic conversion to any requested * locale using Ecore_Txt functions */ /* Converter for standard non-utf8 text targets */ -static int +static Eina_Bool _ecore_x_selection_converter_text(char *target, void *data, int size, @@ -581,7 +581,7 @@ _ecore_x_selection_converter_text(char *target, XICCEncodingStyle style; if (!data || !size) - return 0; + return EINA_FALSE; LOGFN(__FILE__, __LINE__, __FUNCTION__); if (!strcmp(target, ECORE_X_SELECTION_TARGET_TEXT)) @@ -596,10 +596,9 @@ _ecore_x_selection_converter_text(char *target, style = XUTF8StringStyle; #endif /* ifdef X_HAVE_UTF8_STRING */ else - return 0; - + return EINA_FALSE; if (!(mystr = strdup(data))) - return 0; + return EINA_FALSE; #ifdef X_HAVE_UTF8_STRING if (Xutf8TextListToTextProperty(_ecore_x_disp, &mystr, 1, style, @@ -611,7 +610,7 @@ _ecore_x_selection_converter_text(char *target, *size_ret = bufsize; XFree(text_prop.value); free(mystr); - return 1; + return EINA_TRUE; } #else /* ifdef X_HAVE_UTF8_STRING */ @@ -624,17 +623,15 @@ _ecore_x_selection_converter_text(char *target, *size_ret = bufsize; XFree(text_prop.value); free(mystr); - return 1; + return EINA_TRUE; } #endif /* ifdef X_HAVE_UTF8_STRING */ else { free(mystr); - return 0; + return EINA_TRUE; } - - } /* _ecore_x_selection_converter_text */ EAPI void diff --git a/src/lib/ecore_x/xlib/ecore_x_sync.c b/src/lib/ecore_x/xlib/ecore_x_sync.c index 7ec2f9a..540ade4 100644 --- a/src/lib/ecore_x/xlib/ecore_x_sync.c +++ b/src/lib/ecore_x/xlib/ecore_x_sync.c @@ -44,14 +44,14 @@ ecore_x_sync_alarm_new(Ecore_X_Sync_Counter counter) return alarm; } /* ecore_x_sync_alarm_new */ -EAPI int +EAPI Eina_Bool ecore_x_sync_alarm_free(Ecore_X_Sync_Alarm alarm) { LOGFN(__FILE__, __LINE__, __FUNCTION__); return XSyncDestroyAlarm(_ecore_x_disp, alarm); } /* ecore_x_sync_alarm_free */ -EAPI int +EAPI Eina_Bool ecore_x_sync_counter_query(Ecore_X_Sync_Counter counter, unsigned int *val) { XSyncValue value; @@ -60,10 +60,10 @@ ecore_x_sync_counter_query(Ecore_X_Sync_Counter counter, unsigned int *val) if (XSyncQueryCounter(_ecore_x_disp, counter, &value)) { *val = (unsigned int)XSyncValueLow32(value); - return 1; + return EINA_TRUE; } - return 0; + return EINA_FALSE; } /* ecore_x_sync_counter_query */ EAPI Ecore_X_Sync_Counter diff --git a/src/lib/ecore_x/xlib/ecore_x_test.c b/src/lib/ecore_x/xlib/ecore_x_test.c index 3fb9b1a..b4335d1 100644 --- a/src/lib/ecore_x/xlib/ecore_x_test.c +++ b/src/lib/ecore_x/xlib/ecore_x_test.c @@ -12,7 +12,7 @@ #include "Ecore_X.h" #include -EAPI int +EAPI Eina_Bool ecore_x_test_fake_key_down(const char *key) { #ifdef ECORE_XTEST @@ -26,21 +26,21 @@ ecore_x_test_fake_key_down(const char *key) { keysym = XStringToKeysym(key); if (keysym == NoSymbol) - return 0; + return EINA_FALSE; keycode = XKeysymToKeycode(_ecore_x_disp, keysym); } if (keycode == 0) - return 0; + return EINA_FALSE; - return XTestFakeKeyEvent(_ecore_x_disp, keycode, 1, 0); + return XTestFakeKeyEvent(_ecore_x_disp, keycode, 1, 0) ? EINA_TRUE : EINA_FALSE; #else /* ifdef ECORE_XTEST */ - return 0; + return EINA_FALSE; #endif /* ifdef ECORE_XTEST */ } /* ecore_x_test_fake_key_down */ -EAPI int +EAPI Eina_Bool ecore_x_test_fake_key_up(const char *key) { #ifdef ECORE_XTEST @@ -54,21 +54,21 @@ ecore_x_test_fake_key_up(const char *key) { keysym = XStringToKeysym(key); if (keysym == NoSymbol) - return 0; + return EINA_FALSE; keycode = XKeysymToKeycode(_ecore_x_disp, keysym); } if (keycode == 0) - return 0; + return EINA_FALSE; - return XTestFakeKeyEvent(_ecore_x_disp, keycode, 0, 0); + return XTestFakeKeyEvent(_ecore_x_disp, keycode, 0, 0) ? EINA_TRUE : EINA_FALSE; #else /* ifdef ECORE_XTEST */ - return 0; + return EINA_FALSE; #endif /* ifdef ECORE_XTEST */ } /* ecore_x_test_fake_key_up */ -EAPI int +EAPI Eina_Bool ecore_x_test_fake_key_press(const char *key) { #ifdef ECORE_XTEST @@ -83,7 +83,7 @@ ecore_x_test_fake_key_press(const char *key) { keysym = XStringToKeysym(key); if (keysym == NoSymbol) - return 0; + return EINA_FALSE; keycode = XKeysymToKeycode(_ecore_x_disp, keysym); if (XKeycodeToKeysym(_ecore_x_disp, keycode, 0) != keysym) @@ -129,9 +129,9 @@ ecore_x_test_fake_key_press(const char *key) XTestFakeKeyEvent(_ecore_x_disp, XKeysymToKeycode(_ecore_x_disp, XK_Shift_L), 0, 0); - return 1; + return EINA_TRUE; #else /* ifdef ECORE_XTEST */ - return 0; + return EINA_FALSE; #endif /* ifdef ECORE_XTEST */ } /* ecore_x_test_fake_key_press */ diff --git a/src/lib/ecore_x/xlib/ecore_x_window.c b/src/lib/ecore_x/xlib/ecore_x_window.c index 8308c3f..34274a5 100644 --- a/src/lib/ecore_x/xlib/ecore_x_window.c +++ b/src/lib/ecore_x/xlib/ecore_x_window.c @@ -733,7 +733,7 @@ ecore_x_window_depth_get(Ecore_X_Window win) * FIXME: To be fixed. */ EAPI void -ecore_x_window_cursor_show(Ecore_X_Window win, int show) +ecore_x_window_cursor_show(Ecore_X_Window win, Eina_Bool show) { LOGFN(__FILE__, __LINE__, __FUNCTION__); if (win == 0) @@ -1389,7 +1389,7 @@ ecore_x_window_area_expose(Ecore_X_Window win, int x, int y, int w, int h) } /* ecore_x_window_area_expose */ EAPI void -ecore_x_window_override_set(Ecore_X_Window win, int override) +ecore_x_window_override_set(Ecore_X_Window win, Eina_Bool override) { XSetWindowAttributes att; @@ -1405,8 +1405,8 @@ _ecore_x_window_argb_internal_new(Ecore_X_Window parent, int y, int w, int h, - int override, - int saveunder) + Eina_Bool override, + Eina_Bool saveunder) { Window win; XSetWindowAttributes attr; diff --git a/src/lib/ecore_x/xlib/ecore_x_window_prop.c b/src/lib/ecore_x/xlib/ecore_x_window_prop.c index 7b447df..82e35a8 100644 --- a/src/lib/ecore_x/xlib/ecore_x_window_prop.c +++ b/src/lib/ecore_x/xlib/ecore_x_window_prop.c @@ -641,16 +641,17 @@ ecore_x_window_prop_string_get(Ecore_X_Window win, Ecore_X_Atom type) return str; } /* ecore_x_window_prop_string_get */ -EAPI int +EAPI Eina_Bool ecore_x_window_prop_protocol_isset(Ecore_X_Window win, Ecore_X_WM_Protocol protocol) { Atom proto, *protos = NULL; - int i, ret = 0, protos_count = 0; + int i, protos_count = 0; + Eina_Bool ret = EINA_FALSE; /* check for invalid values */ if (protocol >= ECORE_X_WM_PROTOCOL_NUM) - return 0; + return EINA_FALSE; LOGFN(__FILE__, __LINE__, __FUNCTION__); proto = _ecore_x_atoms_wm_protocols[protocol]; @@ -661,7 +662,7 @@ ecore_x_window_prop_protocol_isset(Ecore_X_Window win, for (i = 0; i < protos_count; i++) if (protos[i] == proto) { - ret = 1; + ret = EINA_TRUE; break; } diff --git a/src/lib/ecore_x/xlib/ecore_x_window_shape.c b/src/lib/ecore_x/xlib/ecore_x_window_shape.c index 2f56e72..f0362d3 100644 --- a/src/lib/ecore_x/xlib/ecore_x_window_shape.c +++ b/src/lib/ecore_x/xlib/ecore_x_window_shape.c @@ -271,7 +271,7 @@ ecore_x_window_shape_rectangles_get(Ecore_X_Window win, int *num_ret) } /* ecore_x_window_shape_rectangles_get */ EAPI void -ecore_x_window_shape_events_select(Ecore_X_Window win, int on) +ecore_x_window_shape_events_select(Ecore_X_Window win, Eina_Bool on) { LOGFN(__FILE__, __LINE__, __FUNCTION__); if (on) diff --git a/src/lib/ecore_x/xlib/ecore_x_xinerama.c b/src/lib/ecore_x/xlib/ecore_x_xinerama.c index 11f8e49..dcbd133 100644 --- a/src/lib/ecore_x/xlib/ecore_x_xinerama.c +++ b/src/lib/ecore_x/xlib/ecore_x_xinerama.c @@ -38,8 +38,8 @@ ecore_x_xinerama_screen_count_get(void) return 0; } /* ecore_x_xinerama_screen_count_get */ -EAPI int -ecore_x_xinerama_screen_geometry_get(int screen, int *x, int *y, int *w, int *h) +EAPI Eina_Bool +ecore_x_xinerama_screen_geometry_get(int screen __UNUSED__, int *x, int *y, int *w, int *h) { LOGFN(__FILE__, __LINE__, __FUNCTION__); #ifdef ECORE_XINERAMA @@ -63,7 +63,7 @@ ecore_x_xinerama_screen_geometry_get(int screen, int *x, int *y, int *w, int *h) if (h) *h = _xin_info[i].height; - return 1; + return EINA_TRUE; } } } @@ -81,6 +81,6 @@ ecore_x_xinerama_screen_geometry_get(int screen, int *x, int *y, int *w, int *h) if (h) *h = DisplayHeight(_ecore_x_disp, 0); - return 0; + return EINA_FALSE; } /* ecore_x_xinerama_screen_geometry_get */ -- 2.7.4