forked from enlightenment/enlightenment
shave 0.2s off xsettings init with aggressive use of timers and idlers
SVN revision: 74422
This commit is contained in:
parent
bd6e61c6c8
commit
a72afa83fc
|
@ -51,18 +51,18 @@ static Eina_Bool running = EINA_FALSE;
|
|||
static Eio_File *eio_op = NULL;
|
||||
static Eina_Bool setting = EINA_FALSE;
|
||||
static Eina_Bool reset = EINA_FALSE;
|
||||
static Ecore_Idle_Enterer *xsettings_idler = NULL;
|
||||
static const char *_setting_icon_theme_name = NULL;
|
||||
static const char *_setting_theme_name = NULL;
|
||||
static const char *_setting_font_name = NULL;
|
||||
static const char *_setting_xft_dpi = NULL;
|
||||
static const char *_setting_theme = NULL;
|
||||
|
||||
static void _e_xsettings_done_cb(void *data, Eio_File *handler, const Eina_Stat *stat);
|
||||
|
||||
static Ecore_X_Atom
|
||||
_e_xsettings_atom_screen_get(int screen_num)
|
||||
{
|
||||
char buf[32];
|
||||
char buf[64];
|
||||
snprintf(buf, sizeof(buf), "_XSETTINGS_S%d", screen_num);
|
||||
return ecore_x_atom_get(buf);
|
||||
}
|
||||
|
@ -128,9 +128,6 @@ _e_xsettings_activate(Settings_Manager *sm)
|
|||
ECORE_X_EVENT_MASK_WINDOW_CONFIGURE,
|
||||
ecore_x_current_time_get(), atom,
|
||||
sm->selection, 0, 0);
|
||||
|
||||
_e_xsettings_apply(sm);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -435,6 +432,7 @@ _e_xsettings_done_cb(void *data __UNUSED__, Eio_File *handler __UNUSED__, const
|
|||
_setting_theme = NULL;
|
||||
eio_op = NULL;
|
||||
setting = EINA_FALSE;
|
||||
if (xsettings_idler) return;
|
||||
EINA_LIST_FOREACH(managers, l, sm)
|
||||
_e_xsettings_apply(sm);
|
||||
}
|
||||
|
@ -514,23 +512,64 @@ _e_xsettings_xft_set(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
static Eina_Bool
|
||||
_e_xsettings_idler_cb(void *d)
|
||||
{
|
||||
static int type;
|
||||
double loop, frame;
|
||||
|
||||
if (d)
|
||||
{
|
||||
/* reset */
|
||||
type = 0;
|
||||
return ECORE_CALLBACK_RENEW;
|
||||
}
|
||||
frame = ecore_animator_frametime_get();
|
||||
loop = ecore_loop_time_get();
|
||||
for (; (type < 4) && (ecore_loop_time_get() - loop < frame); type++)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
_e_xsettings_theme_set();
|
||||
break;
|
||||
case 1:
|
||||
_e_xsettings_icon_theme_set();
|
||||
break;
|
||||
case 2:
|
||||
_e_xsettings_font_set();
|
||||
break;
|
||||
case 3:
|
||||
_e_xsettings_update();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (type < 4) return ECORE_CALLBACK_RENEW;
|
||||
xsettings_idler = NULL;
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_e_xsettings_idler_start(void *d __UNUSED__)
|
||||
{
|
||||
if (xsettings_idler)
|
||||
_e_xsettings_idler_cb((void*)1);
|
||||
else
|
||||
xsettings_idler = ecore_idle_enterer_add(_e_xsettings_idler_cb, NULL);
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_xsettings_start(void)
|
||||
{
|
||||
Eina_List *l;
|
||||
E_Manager *man;
|
||||
|
||||
if (running) return;
|
||||
|
||||
_e_xsettings_theme_set();
|
||||
_e_xsettings_icon_theme_set();
|
||||
_e_xsettings_font_set();
|
||||
|
||||
EINA_LIST_FOREACH(e_manager_list(), l, man)
|
||||
{
|
||||
Settings_Manager *sm = E_NEW(Settings_Manager, 1);
|
||||
sm->man = man;
|
||||
|
||||
if (!_e_xsettings_activate(sm))
|
||||
_e_xsettings_retry(sm);
|
||||
|
||||
|
@ -538,8 +577,8 @@ _e_xsettings_start(void)
|
|||
}
|
||||
|
||||
handlers = eina_list_append(handlers, ecore_event_handler_add(E_EVENT_CONFIG_ICON_THEME,
|
||||
_cb_icon_theme_change, NULL));
|
||||
|
||||
_cb_icon_theme_change, NULL));
|
||||
ecore_timer_add(2, _e_xsettings_idler_start, NULL);
|
||||
running = EINA_TRUE;
|
||||
}
|
||||
|
||||
|
@ -577,6 +616,7 @@ _e_xsettings_stop(void)
|
|||
EINTERN int
|
||||
e_xsettings_init(void)
|
||||
{
|
||||
|
||||
_atom_manager = ecore_x_atom_get("MANAGER");
|
||||
_atom_xsettings = ecore_x_atom_get("_XSETTINGS_SETTINGS");
|
||||
|
||||
|
@ -597,7 +637,9 @@ e_xsettings_shutdown(void)
|
|||
_e_xsettings_stop();
|
||||
if (eio_op) eio_file_cancel(eio_op);
|
||||
eio_op = NULL;
|
||||
setting = EINA_FALSE;
|
||||
if (xsettings_idler) ecore_idle_enterer_del(xsettings_idler);
|
||||
xsettings_idler = NULL;
|
||||
reset = setting = EINA_FALSE;
|
||||
|
||||
eina_stringshare_replace(&_setting_icon_theme_name, NULL);
|
||||
eina_stringshare_replace(&_setting_theme_name, NULL);
|
||||
|
@ -619,15 +661,10 @@ e_xsettings_config_update(void)
|
|||
}
|
||||
|
||||
if (!running)
|
||||
{
|
||||
_e_xsettings_start();
|
||||
}
|
||||
_e_xsettings_start();
|
||||
else
|
||||
{
|
||||
_e_xsettings_theme_set();
|
||||
_e_xsettings_icon_theme_set();
|
||||
_e_xsettings_font_set();
|
||||
_e_xsettings_update();
|
||||
_e_xsettings_idler_start(NULL);
|
||||
reset = EINA_TRUE;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue