EAPI int
ecore_init(void)
{
- if (++_ecore_init_count == 1)
- {
+ if (++_ecore_init_count != 1)
+ return _ecore_init_count;
+
#ifdef HAVE_LOCALE_H
- setlocale(LC_CTYPE, "");
+ setlocale(LC_CTYPE, "");
#endif
- /*
- if (strcmp(nl_langinfo(CODESET), "UTF-8"))
- {
- printf("WARNING: not a utf8 locale!\n");
- }
- */
+ /*
+ if (strcmp(nl_langinfo(CODESET), "UTF-8"))
+ {
+ printf("WARNING: not a utf8 locale!\n");
+ }
+ */
#ifdef HAVE_EVIL
- evil_init();
+ if (!evil_init())
+ return --_ecore_init_count;
#endif
- eina_init();
- if (getenv("ECORE_FPS_DEBUG")) _ecore_fps_debug = 1;
- if (_ecore_fps_debug) _ecore_fps_debug_init();
- _ecore_signal_init();
- _ecore_exe_init();
- _ecore_thread_init();
- _ecore_glib_init();
- _ecore_loop_time = ecore_time_get();
- }
+ if (!eina_init())
+ goto shutdown_evil;
+ if (getenv("ECORE_FPS_DEBUG")) _ecore_fps_debug = 1;
+ if (_ecore_fps_debug) _ecore_fps_debug_init();
+ _ecore_signal_init();
+ _ecore_exe_init();
+ _ecore_thread_init();
+ _ecore_glib_init();
+ _ecore_loop_time = ecore_time_get();
return _ecore_init_count;
+
+ shutdown_evil:
+#ifdef HAVE_EVIL
+ evil_shutdown();
+#endif
+ return --_ecore_init_count;
}
/**
EAPI int
ecore_shutdown(void)
{
- if (--_ecore_init_count)
- return _ecore_init_count;
+ if (--_ecore_init_count != 0)
+ return _ecore_init_count;
if (_ecore_fps_debug) _ecore_fps_debug_shutdown();
_ecore_poller_shutdown();
EAPI int ECORE_CON_EVENT_SERVER_DATA = 0;
static Eina_List *servers = NULL;
-static int init_count = 0;
+static int _ecore_con_init_count = 0;
#define LENGTH_OF_SOCKADDR_UN(s) (strlen((s)->sun_path) + (size_t)(((struct sockaddr_un *)NULL)->sun_path))
#define LENGTH_OF_ABSTRACT_SOCKADDR_UN(s, path) (strlen(path) + 1 + (size_t)(((struct sockaddr_un *)NULL)->sun_path))
EAPI int
ecore_con_init(void)
{
- if (++init_count != 1) return init_count;
+ if (++_ecore_con_init_count != 1)
+ return _ecore_con_init_count;
+
+ if (!ecore_init())
+ return --_ecore_con_init_count;
- ecore_init();
ECORE_CON_EVENT_CLIENT_ADD = ecore_event_type_new();
ECORE_CON_EVENT_CLIENT_DEL = ecore_event_type_new();
ECORE_CON_EVENT_SERVER_ADD = ecore_event_type_new();
ecore_con_dns_init();
ecore_con_info_init();
- return init_count;
+ return _ecore_con_init_count;
}
/**
EAPI int
ecore_con_shutdown(void)
{
- if (--init_count != 0) return init_count;
+ if (--_ecore_con_init_count != 0)
+ return _ecore_con_init_count;
while (servers)
_ecore_con_server_free(eina_list_data_get(servers));
ecore_shutdown();
- return init_count;
+ return _ecore_con_init_count;
}
/**
#include "ecore_con_private.h"
#include "Ecore.h"
-static int _init_count = 0;
+static int _init_con_ssl_init_count = 0;
#if USE_GNUTLS
static int _client_connected = 0;
Ecore_Con_Ssl_Error
ecore_con_ssl_init(void)
{
- if (!_init_count++)
+ if (!_init_con_ssl_init_count++)
SSL_SUFFIX(_ecore_con_ssl_init)();
- return _init_count;
+ return _init_con_ssl_init_count;
}
Ecore_Con_Ssl_Error
ecore_con_ssl_shutdown(void)
{
- if (!--_init_count)
+ if (!--_init_con_ssl_init_count)
SSL_SUFFIX(_ecore_con_ssl_shutdown)();
- return _init_count;
+ return _init_con_ssl_init_count;
}
/**
{
int i = 0;
- _ecore_directfb_init_count++;
- if (_ecore_directfb_init_count > 1) return _ecore_directfb_init_count;
+ if (++_ecore_directfb_init_count != 1) return _ecore_directfb_init_count;
DFBCHECK(DirectFBInit(NULL,NULL));
DFBCHECK(DirectFBCreate(&_dfb));
EAPI int
ecore_directfb_shutdown(void)
{
- _ecore_directfb_init_count--;
- if (_ecore_directfb_init_count > 0) return _ecore_directfb_init_count;
- if (_ecore_directfb_init_count < 0)
- {
- _ecore_directfb_init_count = 0;
- return 0;
- }
+ if (--_ecore_directfb_init_count != 0) return _ecore_directfb_init_count;
+
ecore_main_fd_handler_del(_window_event_fd_handler_handle);
eina_hash_free(_ecore_directfb_key_symbols_hash);
DFBCHECK(_layer->Release(_layer));
DFBCHECK(_dfb->Release(_dfb));
- return 1;
+ return _ecore_directfb_init_count;
}
* Init the Evas system.
* @return greater than 0 on success, 0 on failure
*
- * Set up the Evas wrapper system.
+ * Set up the Evas wrapper system. Init Evas and Ecore libraries.
*/
EAPI int
ecore_evas_init(void)
{
- if (_ecore_evas_init_count == 0)
- {
- int fd;
+ int fd;
- evas_init();
- ecore_init();
+ if (++_ecore_evas_init_count != 1)
+ return _ecore_evas_init_count;
- _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.\n");
- ecore_shutdown();
- evas_shutdown();
- return 0;
- }
- 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);
+ if (!evas_init())
+ return --_ecore_evas_init_count;
+
+ 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)
+ {
+ EINA_LOG_ERR("Impossible to create a log domain for Ecore_Evas.\n");
+ goto shutdown_ecore;
}
- return ++_ecore_evas_init_count;
+
+ 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);
+ return _ecore_evas_init_count;
+
+ shutdown_ecore:
+ ecore_shutdown();
+ shutdown_evas:
+ evas_shutdown();
+
+ return --_ecore_evas_init_count;
}
/**
* Shut down the Evas system.
* @return 0 if ecore evas is fully shut down, or > 0 if it still needs to be shut down
*
- * This closes the Evas system down.
+ * This closes the Evas wrapper system down. Shut down Evas and Ecore libraries.
*/
EAPI int
ecore_evas_shutdown(void)
{
- _ecore_evas_init_count--;
- if (_ecore_evas_init_count == 0)
- {
+ if (--_ecore_evas_init_count != 0)
+ return _ecore_evas_init_count;
+
#ifdef BUILD_ECORE_EVAS_X11
- while (_ecore_evas_x_shutdown());
+ while (_ecore_evas_x_shutdown());
#endif
#ifdef BUILD_ECORE_EVAS_WIN32
- while (_ecore_evas_win32_shutdown());
+ while (_ecore_evas_win32_shutdown());
#endif
#ifdef BUILD_ECORE_EVAS_FB
- while (_ecore_evas_fb_shutdown());
+ while (_ecore_evas_fb_shutdown());
#endif
#ifdef BUILD_ECORE_EVAS_SOFTWARE_BUFFER
- while (_ecore_evas_buffer_shutdown());
+ while (_ecore_evas_buffer_shutdown());
#endif
#ifdef BUILD_ECORE_EVAS_DIRECTFB
- while (_ecore_evas_directfb_shutdown());
+ while (_ecore_evas_directfb_shutdown());
#endif
#ifdef BUILD_ECORE_EVAS_SOFTWARE_16_WINCE
- while (_ecore_evas_wince_shutdown());
+ while (_ecore_evas_wince_shutdown());
#endif
- if (_ecore_evas_async_events_fd)
- ecore_main_fd_handler_del(_ecore_evas_async_events_fd);
- eina_log_domain_unregister(_ecore_evas_log_dom);
- ecore_shutdown();
- evas_shutdown();
- }
- if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
+ if (_ecore_evas_async_events_fd)
+ ecore_main_fd_handler_del(_ecore_evas_async_events_fd);
+
+ eina_log_domain_unregister(_ecore_evas_log_dom);
+ ecore_shutdown();
+ evas_shutdown();
+
return _ecore_evas_init_count;
}
EAPI int
ecore_fb_init(const char *name __UNUSED__)
{
- if(!_ecore_fb_init_count)
- {
- if(!ecore_fb_vt_init()) return 0;
- 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();
- ECORE_FB_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new();
- ECORE_FB_EVENT_MOUSE_MOVE = ecore_event_type_new();
- ECORE_FB_EVENT_MOUSE_WHEEL = ecore_event_type_new();
- _ecore_fb_size_get(&_ecore_fb_console_w, &_ecore_fb_console_h);
- }
- return ++_ecore_fb_init_count;
+ if (++_ecore_fb_init_count != 1)
+ return _ecore_fb_init_count;
+
+ if (!ecore_fb_vt_init())
+ 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();
+ ECORE_FB_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new();
+ ECORE_FB_EVENT_MOUSE_MOVE = ecore_event_type_new();
+ ECORE_FB_EVENT_MOUSE_WHEEL = ecore_event_type_new();
+ _ecore_fb_size_get(&_ecore_fb_console_w, &_ecore_fb_console_h);
+
+ return _ecore_fb_init_count;
}
/**
EAPI int
ecore_fb_shutdown(void)
{
- _ecore_fb_init_count--;
- if(!_ecore_fb_init_count)
- {
- ecore_fb_vt_shutdown();
- return 0;
- }
- return _ecore_fb_init_count;
+ if (--_ecore_fb_init_count != 0)
+ return _ecore_fb_init_count;
+
+ ecore_fb_vt_shutdown();
+
+ return _ecore_fb_init_count;
}
#include "ecore_file_private.h"
-static int init = 0;
+static int _ecore_file_init_count = 0;
/* externally accessible functions */
/**
EAPI int
ecore_file_init()
{
- if (++init != 1) return init;
-
-// if (!
- ecore_file_monitor_init();
-// )
-// goto error;
-// if (!
- ecore_file_path_init();
-// )
-// goto error;
-// if (!
- ecore_file_download_init();
-// )
-// goto error;
- return init;
-
-//error:
+ if (++_ecore_file_init_count != 1)
+ return _ecore_file_init_count;
+ ecore_file_path_init();
+ ecore_file_monitor_init();
+ ecore_file_download_init();
+
+ /* FIXME: were the tests disabled for a good reason ? */
+
+ /*
+ if (!ecore_file_monitor_init())
+ goto shutdown_ecore_file_path;
+
+ if (!ecore_file_download_init())
+ goto shutdown_ecore_file_monitor;
+ */
+
+ return _ecore_file_init_count;
+
+ /*
+ shutdown_ecore_file_monitor:
ecore_file_monitor_shutdown();
+ shutdown_ecore_file_path:
ecore_file_path_shutdown();
- ecore_file_download_shutdown();
- return --init;
+ return --_ecore_file_init_count;
+ */
}
/**
EAPI int
ecore_file_shutdown()
{
- if (--init != 0) return init;
+ if (--_ecore_file_init_count != 0)
+ return _ecore_file_init_count;
+ ecore_file_download_shutdown();
ecore_file_monitor_shutdown();
ecore_file_path_shutdown();
- ecore_file_download_shutdown();
- return init;
+ return _ecore_file_init_count;
}
/**
#endif
static void _ecore_file_download_abort(Ecore_File_Download_Job *job);
-static int init = 0;
static Ecore_Event_Handler *_url_complete_handler = NULL;
static Ecore_Event_Handler *_url_progress_download = NULL;
static Eina_List *_job_list;
-EAPI int
+int
ecore_file_download_init(void)
{
#ifndef _WIN32
- ecore_con_url_init();
+ if (!ecore_con_url_init())
+ return 0;
- if (init++ == 0)
- {
#ifdef HAVE_CURL
- _url_complete_handler = ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _ecore_file_download_url_complete_cb, NULL);
- _url_progress_download = ecore_event_handler_add(ECORE_CON_EVENT_URL_PROGRESS, _ecore_file_download_url_progress_cb, NULL);
+ _url_complete_handler = ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _ecore_file_download_url_complete_cb, NULL);
+ _url_progress_download = ecore_event_handler_add(ECORE_CON_EVENT_URL_PROGRESS, _ecore_file_download_url_progress_cb, NULL);
#endif
- }
return 1;
#else
#endif
}
-EAPI int
+void
ecore_file_download_shutdown(void)
{
#ifndef _WIN32
- if (--init == 0)
- {
- if (_url_complete_handler)
- ecore_event_handler_del(_url_complete_handler);
- if (_url_progress_download)
- ecore_event_handler_del(_url_progress_download);
- _url_complete_handler = NULL;
- _url_progress_download = NULL;
- ecore_file_download_abort_all();
- }
-
- return ecore_con_url_shutdown();
-#else
- return 0;
+ if (_url_complete_handler)
+ ecore_event_handler_del(_url_complete_handler);
+ if (_url_progress_download)
+ ecore_event_handler_del(_url_progress_download);
+ _url_complete_handler = NULL;
+ _url_progress_download = NULL;
+ ecore_file_download_abort_all();
+
+ ecore_con_url_shutdown();
#endif
}
EAPI void
ecore_file_download_abort_all(void)
{
- Ecore_File_Download_Job *job;
+ Ecore_File_Download_Job *job;
EINA_LIST_FREE(_job_list, job)
_ecore_file_download_abort(job);
#include "ecore_file_private.h"
-static int init = 0;
-
typedef enum {
ECORE_FILE_MONITOR_TYPE_NONE,
#ifdef HAVE_INOTIFY
int
ecore_file_monitor_init(void)
{
- if (++init != 1) return init;
-
#ifdef HAVE_INOTIFY
monitor_type = ECORE_FILE_MONITOR_TYPE_INOTIFY;
if (ecore_file_monitor_inotify_init())
- return init;
+ return 1;
#endif
#ifdef HAVE_POLL
monitor_type = ECORE_FILE_MONITOR_TYPE_POLL;
if (ecore_file_monitor_poll_init())
- return init;
+ return 1;
#endif
monitor_type = ECORE_FILE_MONITOR_TYPE_NONE;
- return --init;
+ return 0;
}
-int
+void
ecore_file_monitor_shutdown(void)
{
- if (--init != 0) return init;
-
switch (monitor_type)
{
case ECORE_FILE_MONITOR_TYPE_NONE:
break;
#endif
}
- return init;
}
/**
#include "ecore_file_private.h"
-static int init = 0;
static Eina_List *__ecore_file_path_bin = NULL;
static Eina_List *_ecore_file_path_from_env(const char *env);
-int
+void
ecore_file_path_init(void)
{
- if (++init != 1) return init;
__ecore_file_path_bin = _ecore_file_path_from_env("PATH");
- return init;
}
-int
+void
ecore_file_path_shutdown(void)
{
char *dir;
- if (--init != 0) return init;
EINA_LIST_FREE(__ecore_file_path_bin, dir)
free(dir);
- return init;
}
Eina_List *
+#ifndef ECORE_FILE_PRIVATE_H_
+#define ECORE_FILE_PRIVATE_H_
+
#ifndef _FILE_OFFSET_BITS
# define _FILE_OFFSET_BITS 64
#endif
#include "Ecore_File.h"
/* ecore_file_monitor */
-int ecore_file_monitor_init(void);
-int ecore_file_monitor_shutdown(void);
+int ecore_file_monitor_init(void);
+void ecore_file_monitor_shutdown(void);
#define ECORE_FILE_MONITOR(x) ((Ecore_File_Monitor *)(x))
void *data);
void ecore_file_monitor_poll_del(Ecore_File_Monitor *ecore_file_monitor);
+#endif
+
/* ecore_file_path */
-int ecore_file_path_init(void);
-int ecore_file_path_shutdown(void);
+void ecore_file_path_init(void);
+void ecore_file_path_shutdown(void);
/* ecore_file_download */
-int ecore_file_download_init(void);
-int ecore_file_download_shutdown(void);
+int ecore_file_download_init(void);
+void ecore_file_download_shutdown(void);
#endif
EAPI int ECORE_IMF_EVENT_COMMIT = 0;
EAPI int ECORE_IMF_EVENT_DELETE_SURROUNDING = 0;
-static int init_count = 0;
+static int _ecore_imf_init_count = 0;
/**
* @defgroup Ecore_IMF_Lib_Group Ecore Input Method Library Functions
EAPI int
ecore_imf_init(void)
{
- if (++init_count != 1) return init_count;
+ if (++_ecore_imf_init_count != 1)
+ return _ecore_imf_init_count;
+
+ if (!ecore_init())
+ return --_ecore_imf_init_count;
- ecore_init();
ecore_imf_module_init();
ECORE_IMF_EVENT_PREEDIT_START = ecore_event_type_new();
ECORE_IMF_EVENT_COMMIT = ecore_event_type_new();
ECORE_IMF_EVENT_DELETE_SURROUNDING = ecore_event_type_new();
- return init_count;
+ return _ecore_imf_init_count;
}
/**
EAPI int
ecore_imf_shutdown(void)
{
- if (--init_count != 0) return init_count;
+ if (--_ecore_imf_init_count != 0)
+ return _ecore_imf_init_count;
ecore_shutdown();
ecore_imf_module_shutdown();
- return init_count;
+ return _ecore_imf_init_count;
}
EAPI int ECORE_EVENT_MOUSE_OUT = 0;
static int _ecore_event_init_count = 0;
+static int _ecore_event_evas_init_count = 0;
static Ecore_Event_Handler *ecore_event_evas_handlers[8];
static Eina_Hash *_window_hash = NULL;
-static int _ecore_event_evas_init_count = 0;
+EAPI int
+ecore_event_init(void)
+{
+ if (++_ecore_event_init_count != 1)
+ return _ecore_event_init_count;
+
+ ECORE_EVENT_KEY_DOWN = ecore_event_type_new();
+ ECORE_EVENT_KEY_UP = ecore_event_type_new();
+ ECORE_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new();
+ ECORE_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new();
+ ECORE_EVENT_MOUSE_MOVE = ecore_event_type_new();
+ ECORE_EVENT_MOUSE_WHEEL = ecore_event_type_new();
+ ECORE_EVENT_MOUSE_IN = ecore_event_type_new();
+ ECORE_EVENT_MOUSE_OUT = ecore_event_type_new();
+
+ return _ecore_event_init_count;
+}
+
+EAPI int
+ecore_event_shutdown(void)
+{
+ if (--_ecore_event_init_count != 0)
+ return _ecore_event_init_count;
+
+ ECORE_EVENT_KEY_DOWN = 0;
+ ECORE_EVENT_KEY_UP = 0;
+ ECORE_EVENT_MOUSE_BUTTON_DOWN = 0;
+ ECORE_EVENT_MOUSE_BUTTON_UP = 0;
+ ECORE_EVENT_MOUSE_MOVE = 0;
+ ECORE_EVENT_MOUSE_WHEEL = 0;
+ ECORE_EVENT_MOUSE_IN = 0;
+ ECORE_EVENT_MOUSE_OUT = 0;
+
+ return ++_ecore_event_init_count;
+}
EAPI void
ecore_event_evas_modifier_lock_update(Evas *e, unsigned int modifiers)
EAPI int
ecore_event_evas_init(void)
{
- if (!_ecore_event_evas_init_count)
+ if (++_ecore_event_evas_init_count != 1)
+ return _ecore_event_evas_init_count;
+
+ if (!ecore_init())
+ {
+ return --_ecore_event_evas_init_count;
+ }
+
+ if (!ecore_event_init())
{
- ecore_init();
- ecore_event_init();
-
- ecore_event_evas_handlers[0] = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
- 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_handlers[2] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,
- 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_handlers[4] = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE,
- 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_handlers[6] = ecore_event_handler_add(ECORE_EVENT_MOUSE_IN,
- 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);
-
- _window_hash = eina_hash_pointer_new(free);
+ goto shutdown_ecore;
}
- return ++_ecore_event_evas_init_count;
+
+ ecore_event_evas_handlers[0] = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
+ 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_handlers[2] = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN,
+ 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_handlers[4] = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE,
+ 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_handlers[6] = ecore_event_handler_add(ECORE_EVENT_MOUSE_IN,
+ 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);
+
+ _window_hash = eina_hash_pointer_new(free);
+
+ return _ecore_event_evas_init_count;
+
+ shutdown_ecore:
+ ecore_shutdown();
+
+ return --_ecore_event_evas_init_count;
}
EAPI int
ecore_event_evas_shutdown(void)
{
- if (_ecore_event_evas_init_count == 1)
+ int i;
+
+ if (--_ecore_event_evas_init_count != 0)
+ return _ecore_event_evas_init_count;
+
+
+ eina_hash_free(_window_hash);
+ _window_hash = NULL;
+ for (i = 0; i < sizeof(ecore_event_evas_handlers)/sizeof(Ecore_Event_Handler*); ++i)
{
- int i;
-
- eina_hash_free(_window_hash);
- _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_shutdown();
- ecore_shutdown();
+ ecore_event_handler_del(ecore_event_evas_handlers[i]);
+ ecore_event_evas_handlers[i] = NULL;
}
- return --_ecore_event_evas_init_count;
+
+ ecore_event_shutdown();
+ ecore_shutdown();
+
+ return _ecore_event_evas_init_count;
}
typedef struct _Ecore_Event_Modifier_Match Ecore_Event_Modifier_Match;
return ECORE_NONE;
}
-
-EAPI int
-ecore_event_init(void)
-{
- if (!_ecore_event_init_count)
- {
- ECORE_EVENT_KEY_DOWN = ecore_event_type_new();
- ECORE_EVENT_KEY_UP = ecore_event_type_new();
- ECORE_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new();
- ECORE_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new();
- ECORE_EVENT_MOUSE_MOVE = ecore_event_type_new();
- ECORE_EVENT_MOUSE_WHEEL = ecore_event_type_new();
- ECORE_EVENT_MOUSE_IN = ecore_event_type_new();
- ECORE_EVENT_MOUSE_OUT = ecore_event_type_new();
- }
- return ++_ecore_event_init_count;
-}
-
-EAPI int
-ecore_event_shutdown(void)
-{
- if (_ecore_event_init_count == 1)
- {
- ECORE_EVENT_KEY_DOWN = 0;
- ECORE_EVENT_KEY_UP = 0;
- ECORE_EVENT_MOUSE_BUTTON_DOWN = 0;
- ECORE_EVENT_MOUSE_BUTTON_UP = 0;
- ECORE_EVENT_MOUSE_MOVE = 0;
- ECORE_EVENT_MOUSE_WHEEL = 0;
- ECORE_EVENT_MOUSE_IN = 0;
- ECORE_EVENT_MOUSE_OUT = 0;
- }
- return ++_ecore_event_init_count;
-}
EAPI int ECORE_IPC_EVENT_CLIENT_DATA = 0;
EAPI int ECORE_IPC_EVENT_SERVER_DATA = 0;
-static int init_count = 0;
+static int _ecore_ipc_init_count = 0;
static Eina_List *servers = NULL;
static Ecore_Event_Handler *handler[6];
{
int i = 0;
- if (++init_count != 1) return init_count;
+ if (++_ecore_ipc_init_count != 1)
+ return _ecore_ipc_init_count;
- ecore_con_init();
+ if (!ecore_con_init())
+ return --_ecore_ipc_init_count;
ECORE_IPC_EVENT_CLIENT_ADD = ecore_event_type_new();
ECORE_IPC_EVENT_CLIENT_DEL = ecore_event_type_new();
_ecore_ipc_event_client_data, NULL);
handler[i++] = ecore_event_handler_add(ECORE_CON_EVENT_SERVER_DATA,
_ecore_ipc_event_server_data, NULL);
- return init_count;
+ return _ecore_ipc_init_count;
}
/**
{
int i;
- if (--init_count != 0) return init_count;
+ if (--_ecore_ipc_init_count != 0)
+ return _ecore_ipc_init_count;
while (servers) ecore_ipc_server_del(eina_list_data_get(servers));
ecore_con_shutdown();
- return init_count;
+ return _ecore_ipc_init_count;
}
/**
static void _ecore_job_event_free(void *data, void *ev);
static int ecore_event_job_type = 0;
-static int _ecore_init_job_count = 0;
+static int _ecore_job_init_count = 0;
static Ecore_Event_Handler* _ecore_job_handler = NULL;
EAPI int
ecore_job_init(void)
{
- if (++_ecore_init_job_count == 1)
- {
- ecore_init();
- ecore_event_job_type = ecore_event_type_new();
- _ecore_job_handler = ecore_event_handler_add(ecore_event_job_type, _ecore_job_event_handler, NULL);
- }
+ if (++_ecore_job_init_count != 1)
+ return _ecore_job_init_count;
+
+ if (!ecore_init())
+ return --_ecore_job_init_count;
+
+ ecore_event_job_type = ecore_event_type_new();
+ _ecore_job_handler = ecore_event_handler_add(ecore_event_job_type, _ecore_job_event_handler, NULL);
- return _ecore_init_job_count;
+ return _ecore_job_init_count;
}
EAPI int
ecore_job_shutdown(void)
{
- if (--_ecore_init_job_count)
- return _ecore_init_job_count;
+ if (--_ecore_job_init_count != 0)
+ return _ecore_job_init_count;
ecore_event_handler_del(_ecore_job_handler);
_ecore_job_handler = NULL;
ecore_shutdown();
- return _ecore_init_job_count;
+ return _ecore_job_init_count;
}
/**
EAPI int
ecore_quartz_init(const char *name __UNUSED__)
{
- if (!_ecore_quartz_init_count)
- {
- ECORE_QUARTZ_EVENT_GOT_FOCUS = ecore_event_type_new();
- ECORE_QUARTZ_EVENT_LOST_FOCUS = ecore_event_type_new();
- ECORE_QUARTZ_EVENT_RESIZE = ecore_event_type_new();
- ECORE_QUARTZ_EVENT_EXPOSE = ecore_event_type_new();
- }
+ if (++_ecore_quartz_init_count != 1)
+ return _ecore_quartz_init_count;
- ecore_event_init();
+ if (!ecore_event_init())
+ return --_ecore_quartz_init_count;
- return ++_ecore_quartz_init_count;
+ ECORE_QUARTZ_EVENT_GOT_FOCUS = ecore_event_type_new();
+ ECORE_QUARTZ_EVENT_LOST_FOCUS = ecore_event_type_new();
+ ECORE_QUARTZ_EVENT_RESIZE = ecore_event_type_new();
+ ECORE_QUARTZ_EVENT_EXPOSE = ecore_event_type_new();
+
+ return _ecore_quartz_init_count;
}
/**
EAPI int
ecore_quartz_shutdown(void)
{
- _ecore_quartz_init_count--;
+ if (--_ecore_quartz_init_count != 0)
+ return _ecore_quartz_init_count;
ecore_event_shutdown();
-I$(top_builddir)/src/lib/ecore_input \
@EFL_ECORE_SDL_BUILD@ \
@SDL_CFLAGS@ \
+@EVAS_CFLAGS@ \
@EINA_CFLAGS@
if BUILD_ECORE_SDL
EAPI int
ecore_sdl_init(const char *name __UNUSED__)
{
- if(!_ecore_sdl_init_count)
- {
- ECORE_SDL_EVENT_GOT_FOCUS = ecore_event_type_new();
- ECORE_SDL_EVENT_LOST_FOCUS = ecore_event_type_new();
- ECORE_SDL_EVENT_RESIZE = ecore_event_type_new();
- ECORE_SDL_EVENT_EXPOSE = ecore_event_type_new();
+ if(++_ecore_sdl_init_count != 1)
+ return _ecore_sdl_init_count;
- SDL_EnableKeyRepeat(200, 100);
- }
- ecore_event_init();
- return ++_ecore_sdl_init_count;
+ if (!ecore_event_init())
+ return --_ecore_sdl_init_count;
+
+ ECORE_SDL_EVENT_GOT_FOCUS = ecore_event_type_new();
+ ECORE_SDL_EVENT_LOST_FOCUS = ecore_event_type_new();
+ ECORE_SDL_EVENT_RESIZE = ecore_event_type_new();
+ ECORE_SDL_EVENT_EXPOSE = ecore_event_type_new();
+
+ SDL_EnableKeyRepeat(200, 100);
+
+ return _ecore_sdl_init_count;
}
/**
EAPI int
ecore_sdl_shutdown(void)
{
- _ecore_sdl_init_count--;
+ if (--_ecore_sdl_init_count != 0);
+ return _ecore_sdl_init_count;
+
ecore_event_shutdown();
+
return _ecore_sdl_init_count;
}
xcb_intern_atom_cookie_t atom_cookies[ECORE_X_ATOMS_COUNT];
- if (_ecore_xcb_init_count > 0)
- {
- _ecore_xcb_init_count++;
- return _ecore_xcb_init_count;
- }
+ if (--_ecore_xcb_init_count != 1)
+ return _ecore_xcb_init_count;
+
_ecore_xcb_conn = xcb_connect(name, &screen);
- if (!_ecore_xcb_conn) return 0;
+ if (!_ecore_xcb_conn)
+ return --_ecore_xcb_init_count;
/* FIXME: no error code right now */
/* _ecore_xcb_error_handler_init(); */
#endif /* ECORE_XCB_XPRINT */
/* We init some components (not related to XCB) */
- ecore_event_init();
+ if (!ecore_event_init())
+ goto close_connection;
+
_ecore_x_reply_init();
_ecore_x_dnd_init();
ecore_x_netwm_init();
_ecore_xcb_event_handlers = calloc(_ecore_xcb_event_handlers_num, sizeof(void *));
if (!_ecore_xcb_event_handlers)
- {
- /* We get the replies of the QueryVersion request because we leave */
-#ifdef ECORE_XCB_DAMAGE
- _ecore_x_damage_init_finalize();
-#endif /* ECORE_XCB_DAMAGE */
-#ifdef ECORE_XCB_COMPOSITE
- _ecore_x_composite_init_finalize();
-#endif /* ECORE_XCB_COMPOSITE */
-#ifdef ECORE_XCB_DPMS
- _ecore_x_dpms_init_finalize();
-#endif /* ECORE_XCB_DPMS */
-#ifdef ECORE_XCB_RANDR
- _ecore_x_randr_init_finalize();
-#endif /* ECORE_XCB_RANDR */
-#ifdef ECORE_XCB_SCREENSAVER
- _ecore_x_screensaver_init_finalize();
-#endif /* ECORE_XCB_SCREENSAVER */
-#ifdef ECORE_XCB_SHAPE
- _ecore_x_shape_init_finalize();
-#endif /* ECORE_XCB_SHAPE */
-#ifdef ECORE_XCB_SYNC
- _ecore_x_sync_init_finalize();
-#endif /* ECORE_XCB_SYNC */
-#ifdef ECORE_XCB_FIXES
- _ecore_x_xfixes_init_finalize();
-#endif /* ECORE_XCB_FIXES */
-#ifdef ECORE_XCB_XINERAMA
- _ecore_x_xinerama_init_finalize();
-#endif /* ECORE_XCB_XINERAMA */
-
- ecore_event_shutdown();
- xcb_disconnect(_ecore_xcb_conn);
- _ecore_xcb_fd_handler_handle = NULL;
- _ecore_xcb_conn = NULL;
- return 0;
- }
+ goto finalize_extensions;
#ifdef ECORE_XCB_CURSOR
_ecore_xcb_xcursor = XcursorSupportsARGB(_ecore_xcb_conn);
_ecore_xcb_fd_handler, _ecore_xcb_conn,
_ecore_xcb_fd_handler_buf, _ecore_xcb_conn);
if (!_ecore_xcb_fd_handler_handle)
- {
- /* We get the replies of the QueryVersion request because we leave */
+ goto free_event_handlers;
+
+ _ecore_xcb_filter_handler = ecore_event_filter_add(_ecore_xcb_event_filter_start, _ecore_xcb_event_filter_filter, _ecore_xcb_event_filter_end, NULL);
+
+ /* This is just to be anal about naming conventions */
+
+ _ecore_xcb_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_DELETE_REQUEST] = ECORE_X_ATOM_WM_DELETE_WINDOW;
+ _ecore_xcb_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_TAKE_FOCUS] = ECORE_X_ATOM_WM_TAKE_FOCUS;
+ _ecore_xcb_atoms_wm_protocols[ECORE_X_NET_WM_PROTOCOL_PING] = ECORE_X_ATOM_NET_WM_PING;
+ _ecore_xcb_atoms_wm_protocols[ECORE_X_NET_WM_PROTOCOL_SYNC_REQUEST] = ECORE_X_ATOM_NET_WM_SYNC_REQUEST;
+
+ _ecore_xcb_init_count++;
+
+ _ecore_xcb_private_window = ecore_x_window_override_new(0, -77, -777, 123, 456);
+
+ /* We finally get the replies of the QueryVersion request */
#ifdef ECORE_XCB_DAMAGE
- _ecore_x_damage_init_finalize();
+ _ecore_x_damage_init_finalize();
#endif /* ECORE_XCB_DAMAGE */
#ifdef ECORE_XCB_COMPOSITE
- _ecore_x_composite_init_finalize();
+ _ecore_x_composite_init_finalize();
#endif /* ECORE_XCB_COMPOSITE */
#ifdef ECORE_XCB_DPMS
- _ecore_x_dpms_init_finalize();
+ _ecore_x_dpms_init_finalize();
#endif /* ECORE_XCB_DPMS */
#ifdef ECORE_XCB_RANDR
- _ecore_x_randr_init_finalize();
+ _ecore_x_randr_init_finalize();
#endif /* ECORE_XCB_RANDR */
#ifdef ECORE_XCB_SCREENSAVER
- _ecore_x_screensaver_init_finalize();
+ _ecore_x_screensaver_init_finalize();
#endif /* ECORE_XCB_SCREENSAVER */
#ifdef ECORE_XCB_SHAPE
- _ecore_x_shape_init_finalize();
+ _ecore_x_shape_init_finalize();
#endif /* ECORE_XCB_SHAPE */
#ifdef ECORE_XCB_SYNC
- _ecore_x_sync_init_finalize();
+ _ecore_x_sync_init_finalize();
#endif /* ECORE_XCB_SYNC */
#ifdef ECORE_XCB_FIXES
- _ecore_x_xfixes_init_finalize();
+ _ecore_x_xfixes_init_finalize();
#endif /* ECORE_XCB_FIXES */
#ifdef ECORE_XCB_XINERAMA
- _ecore_x_xinerama_init_finalize();
+ _ecore_x_xinerama_init_finalize();
#endif /* ECORE_XCB_XINERAMA */
- ecore_event_shutdown();
- xcb_disconnect(_ecore_xcb_conn);
- free(_ecore_xcb_event_handlers);
- _ecore_xcb_fd_handler_handle = NULL;
- _ecore_xcb_conn = NULL;
- _ecore_xcb_event_handlers = NULL;
- return 0;
- }
- _ecore_xcb_filter_handler = ecore_event_filter_add(_ecore_xcb_event_filter_start, _ecore_xcb_event_filter_filter, _ecore_xcb_event_filter_end, NULL);
-
- /* This is just to be anal about naming conventions */
-
- _ecore_xcb_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_DELETE_REQUEST] = ECORE_X_ATOM_WM_DELETE_WINDOW;
- _ecore_xcb_atoms_wm_protocols[ECORE_X_WM_PROTOCOL_TAKE_FOCUS] = ECORE_X_ATOM_WM_TAKE_FOCUS;
- _ecore_xcb_atoms_wm_protocols[ECORE_X_NET_WM_PROTOCOL_PING] = ECORE_X_ATOM_NET_WM_PING;
- _ecore_xcb_atoms_wm_protocols[ECORE_X_NET_WM_PROTOCOL_SYNC_REQUEST] = ECORE_X_ATOM_NET_WM_SYNC_REQUEST;
-
- _ecore_xcb_init_count++;
-
- _ecore_xcb_private_window = ecore_x_window_override_new(0, -77, -777, 123, 456);
+ return _ecore_xcb_init_count;
- /* We finally get the replies of the QueryVersion request */
+ free_event_handlers:
+ free(_ecore_xcb_event_handlers);
+ _ecore_xcb_event_handlers = NULL;
+ finalize_extensions:
+ /* We get the replies of the QueryVersion request because we leave */
#ifdef ECORE_XCB_DAMAGE
_ecore_x_damage_init_finalize();
#endif /* ECORE_XCB_DAMAGE */
#ifdef ECORE_XCB_XINERAMA
_ecore_x_xinerama_init_finalize();
#endif /* ECORE_XCB_XINERAMA */
+ ecore_event_shutdown();
+ close_connection:
+ _ecore_x_atom_init_finalize(atom_cookies);
+ xcb_disconnect(_ecore_xcb_conn);
+ _ecore_xcb_fd_handler_handle = NULL;
+ _ecore_xcb_conn = NULL;
- return _ecore_xcb_init_count;
+ return --_ecore_xcb_init_count;
}
static int
_ecore_x_shutdown(int close_display)
{
- _ecore_xcb_init_count--;
- if (_ecore_xcb_init_count > 0) return _ecore_xcb_init_count;
+ if (--_ecore_xcb_init_count != 0)
+ return _ecore_xcb_init_count;
+
if (!_ecore_xcb_conn) return _ecore_xcb_init_count;
+
if (close_display)
xcb_disconnect(_ecore_xcb_conn);
else
_ecore_x_dnd_shutdown();
ecore_x_netwm_shutdown();
_ecore_x_reply_shutdown();
- if (_ecore_xcb_init_count < 0) _ecore_xcb_init_count = 0;
+
return _ecore_xcb_init_count;
}
int damage_err_base = 0;
#endif
- if (_ecore_x_init_count > 0)
- {
- _ecore_x_init_count++;
- return _ecore_x_init_count;
- }
- ecore_event_init();
+ if (++_ecore_x_init_count != 1)
+ return _ecore_x_init_count;
+
+ if (!ecore_event_init())
+ return --_ecore_x_init_count;
_ecore_x_disp = XOpenDisplay((char *)name);
- if (!_ecore_x_disp) return 0;
+ if (!_ecore_x_disp)
+ goto shutdown_ecore_event;
+
_ecore_x_error_handler_init();
_ecore_x_event_handlers_num = LASTEvent;
_ecore_x_event_handlers = calloc(_ecore_x_event_handlers_num, sizeof(void *));
if (!_ecore_x_event_handlers)
- {
- XCloseDisplay(_ecore_x_disp);
- _ecore_x_fd_handler_handle = NULL;
- _ecore_x_disp = NULL;
- return 0;
- }
+ goto close_display;
+
#ifdef ECORE_XCURSOR
_ecore_x_xcursor = XcursorSupportsARGB(_ecore_x_disp);
#endif
_ecore_x_fd_handler, _ecore_x_disp,
_ecore_x_fd_handler_buf, _ecore_x_disp);
if (!_ecore_x_fd_handler_handle)
- {
- XCloseDisplay(_ecore_x_disp);
- free(_ecore_x_event_handlers);
- _ecore_x_fd_handler_handle = NULL;
- _ecore_x_disp = NULL;
- _ecore_x_event_handlers = NULL;
- return 0;
- }
-
+ goto free_event_handlers;
_ecore_x_atoms_init();
_ecore_x_composite_init();
_ecore_x_dpms_init();
_ecore_x_randr_init();
-
- _ecore_x_init_count++;
_ecore_x_private_win = ecore_x_window_override_new(0, -77, -777, 123, 456);
_im_create_end:
#endif
return _ecore_x_init_count;
+
+ free_event_handlers:
+ free(_ecore_x_event_handlers);
+ _ecore_x_event_handlers = NULL;
+ close_display:
+ XCloseDisplay(_ecore_x_disp);
+ _ecore_x_fd_handler_handle = NULL;
+ _ecore_x_disp = NULL;
+ shutdown_ecore_event:
+ ecore_event_shutdown();
+
+ return --_ecore_x_init_count;
}
static int
_ecore_x_shutdown(int close_display)
{
- _ecore_x_init_count--;
- if (_ecore_x_init_count > 0) return _ecore_x_init_count;
+ if (--_ecore_x_init_count != 0)
+ return _ecore_x_init_count;
+
if (!_ecore_x_disp) return _ecore_x_init_count;
#ifdef ENABLE_XIM
_ecore_x_dnd_shutdown();
ecore_x_netwm_shutdown();
ecore_event_shutdown();
- if (_ecore_x_init_count < 0) _ecore_x_init_count = 0;
+
return _ecore_x_init_count;
}