diff options
author | Chris Michael <cp.michael@samsung.com> | 2014-08-23 10:30:56 -0400 |
---|---|---|
committer | Chris Michael <cp.michael@samsung.com> | 2014-09-16 09:15:43 -0400 |
commit | 2791add2e1f9d6b45461cff097f852492d98daf4 (patch) | |
tree | 1a5afb2fb0d1253b490a4d7b185658e697fce0e1 | |
parent | 4c555026764883ee29bafbbf4f069104c76fe83a (diff) | |
download | efl-2791add2e1f9d6b45461cff097f852492d98daf4.tar.gz |
ecore-input: Cleanup ecore_input_init function and add
session_init/shutdown API functions
This cleans up ecore_input_init to not init dbus/udev/etc Every time.
As ecore_input_init is used in various places to setup old deprecated
ecore_event stuff, we need to not init dbus/udev/etc all the time.
This also adds & implements API functions to handle initializing the
systemd session and setup of udev/dbus.
@fix
Signed-off-by: Chris Michael <cp.michael@samsung.com>
-rw-r--r-- | src/lib/ecore_input/ecore_input.c | 84 |
1 files changed, 58 insertions, 26 deletions
diff --git a/src/lib/ecore_input/ecore_input.c b/src/lib/ecore_input/ecore_input.c index cdc917db13..6489585a66 100644 --- a/src/lib/ecore_input/ecore_input.c +++ b/src/lib/ecore_input/ecore_input.c @@ -75,20 +75,58 @@ ecore_input_init(void) ECORE_EVENT_MOUSE_IN = ecore_event_type_new(); ECORE_EVENT_MOUSE_OUT = ecore_event_type_new(); + return _ecore_input_init_count; +} + +EAPI int +ecore_input_shutdown(void) +{ + if (--_ecore_input_init_count != 0) + return _ecore_input_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; + + eina_log_domain_unregister(_ecore_input_log_dom); + _ecore_input_log_dom = -1; + + ecore_shutdown(); + + return _ecore_input_init_count; +} + +EAPI Eina_Bool +ecore_input_session_init(void) +{ #ifdef HAVE_SYSTEMD_LOGIN /* try to get the systemd session id */ if (sd_pid_get_session(getpid(), &_ecore_input_session_id) < 0) - ERR("Could not get systemd session id: %m"); + { + ERR("Could not get systemd session id: %m"); + return EINA_FALSE; + } #endif #ifdef HAVE_LIBINPUT /* try to init dbus */ if (!_ecore_input_dbus_init()) - ERR("Could not initialize dbus"); + { + ERR("Could not initialize dbus"); + goto dbus_err; + } /* try to init udev */ if (!(_ecore_input_udev = udev_new())) - ERR("Could not initialize udev: %m"); + { + ERR("Could not initialize udev: %m"); + goto udev_err; + } else { /* try to init libinput seat */ @@ -97,46 +135,40 @@ ecore_input_init(void) } #endif - return _ecore_input_init_count; + return EINA_TRUE; + +#ifdef HAVE_LIBINPUT +udev_err: + _ecore_input_dbus_shutdown(); +dbus_err: +# ifdef HAVE_SYSTEMD_LOGIN + /* free the stored systemd session id */ + free(_ecore_input_session_id); +# endif + return EINA_FALSE; +#endif } -EAPI int -ecore_input_shutdown(void) +EAPI Eina_Bool +ecore_input_session_shutdown(void) { - if (--_ecore_input_init_count != 0) - return _ecore_input_init_count; - #ifdef HAVE_LIBINPUT /* shutdown libinput seat */ ecore_input_seat_shutdown(NULL); /* free udev */ if (_ecore_input_udev) udev_unref(_ecore_input_udev); -#endif -#ifdef HAVE_SYSTEMD_LOGIN /* shutdown dbus */ _ecore_input_dbus_shutdown(); +#endif +#ifdef HAVE_SYSTEMD_LOGIN /* free the stored systemd session id */ free(_ecore_input_session_id); #endif - 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; - - eina_log_domain_unregister(_ecore_input_log_dom); - _ecore_input_log_dom = -1; - - ecore_shutdown(); - - return _ecore_input_init_count; + return EINA_TRUE; } EAPI unsigned int |