forked from enlightenment/enlightenment
clock now uses timerfd_create() to receive updates when the system clock has changed to ensure proper sync
SVN revision: 76946
This commit is contained in:
parent
17f3ddae83
commit
546d83c6ba
|
@ -79,6 +79,8 @@ AC_CHECK_FUNCS(unsetenv)
|
||||||
|
|
||||||
efl_version="1.7.0"
|
efl_version="1.7.0"
|
||||||
|
|
||||||
|
AC_CHECK_HEADERS([sys/timerfd.h])
|
||||||
|
|
||||||
dnl AC_CHECK_HEADERS(X11/extensions/shape.h,, AC_MSG_ERROR([Cannot find X11/extensions/shape.h. Make sure your CFLAGS environment variable contains include lines for the location of this file]))
|
dnl AC_CHECK_HEADERS(X11/extensions/shape.h,, AC_MSG_ERROR([Cannot find X11/extensions/shape.h. Make sure your CFLAGS environment variable contains include lines for the location of this file]))
|
||||||
|
|
||||||
AC_CHECK_HEADERS(fnmatch.h,, AC_MSG_ERROR([Cannot find fnmatch.h. Make sure your CFLAGS environment variable contains include lines for the location of this file]))
|
AC_CHECK_HEADERS(fnmatch.h,, AC_MSG_ERROR([Cannot find fnmatch.h. Make sure your CFLAGS environment variable contains include lines for the location of this file]))
|
||||||
|
|
|
@ -3,6 +3,9 @@
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#ifdef HAVE_SYS_TIMERFD_H
|
||||||
|
# include <sys/timerfd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* actual module specifics */
|
/* actual module specifics */
|
||||||
typedef struct _Instance Instance;
|
typedef struct _Instance Instance;
|
||||||
|
@ -50,6 +53,9 @@ static E_Config_DD *conf_item_edd = NULL;
|
||||||
static Eina_List *clock_instances = NULL;
|
static Eina_List *clock_instances = NULL;
|
||||||
static E_Action *act = NULL;
|
static E_Action *act = NULL;
|
||||||
static Ecore_Timer *update_today = NULL;
|
static Ecore_Timer *update_today = NULL;
|
||||||
|
#ifdef HAVE_SYS_TIMERFD_H
|
||||||
|
static Ecore_Fd_Handler *timerfd_handler = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* and actually define the gadcon class that this module provides (just 1) */
|
/* and actually define the gadcon class that this module provides (just 1) */
|
||||||
static const E_Gadcon_Client_Class _gadcon_class =
|
static const E_Gadcon_Client_Class _gadcon_class =
|
||||||
|
@ -810,6 +816,16 @@ _clock_eio_error(void *d __UNUSED__, int type __UNUSED__, void *event __UNUSED__
|
||||||
return ECORE_CALLBACK_RENEW;
|
return ECORE_CALLBACK_RENEW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
_clock_fd_update(void *d __UNUSED__, Ecore_Fd_Handler *fdh)
|
||||||
|
{
|
||||||
|
char buf[64];
|
||||||
|
|
||||||
|
read(ecore_main_fd_handler_fd_get(fdh), buf, sizeof(buf));
|
||||||
|
e_int_clock_instances_redo();
|
||||||
|
return EINA_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* module setup */
|
/* module setup */
|
||||||
EAPI E_Module_Api e_modapi =
|
EAPI E_Module_Api e_modapi =
|
||||||
{
|
{
|
||||||
|
@ -866,6 +882,16 @@ e_modapi_init(E_Module *m)
|
||||||
E_LIST_HANDLERS_APPEND(clock_eio_handlers, EIO_MONITOR_SELF_RENAME, _clock_eio_update, NULL);
|
E_LIST_HANDLERS_APPEND(clock_eio_handlers, EIO_MONITOR_SELF_RENAME, _clock_eio_update, NULL);
|
||||||
|
|
||||||
e_gadcon_provider_register(&_gadcon_class);
|
e_gadcon_provider_register(&_gadcon_class);
|
||||||
|
|
||||||
|
#ifdef HAVE_SYS_TIMERFD_H
|
||||||
|
int timer_fd;
|
||||||
|
|
||||||
|
/* on old systems, flags must be 0, so we'll play nice and do it always */
|
||||||
|
timer_fd = timerfd_create(CLOCK_REALTIME, 0);
|
||||||
|
if (timer_fd < 0) return m;
|
||||||
|
fcntl(timer_fd, F_SETFL, O_NONBLOCK | FD_CLOEXEC);
|
||||||
|
timerfd_handler = ecore_main_fd_handler_add(timer_fd, ECORE_FD_READ, _clock_fd_update, NULL, NULL, NULL);
|
||||||
|
#endif
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -908,6 +934,9 @@ e_modapi_shutdown(E_Module *m __UNUSED__)
|
||||||
}
|
}
|
||||||
eio_monitor_del(clock_tz_monitor);
|
eio_monitor_del(clock_tz_monitor);
|
||||||
clock_tz_monitor = NULL;
|
clock_tz_monitor = NULL;
|
||||||
|
#ifdef HAVE_SYS_TIMERFD_H
|
||||||
|
timerfd_handler = ecore_main_fd_handler_del(timerfd_handler);
|
||||||
|
#endif
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue