From 05e7471a1a354751f25eb1f762f759299b61a9db Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Sun, 9 Apr 2006 10:18:34 +0000 Subject: [PATCH] Introduce idlers. SVN revision: 21980 --- src/E.h | 5 +++++ src/desktops.c | 11 +++++++---- src/dialog.c | 10 ++++++++-- src/dialog.h | 2 +- src/ecompmgr.c | 21 +++++++++++++-------- src/emodule.h | 1 - src/events.c | 4 +--- src/focus.c | 17 ++++++++++------- src/main.c | 2 ++ src/moveresize.c | 2 +- src/pager.c | 12 +++++++----- src/timers.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 102 insertions(+), 32 deletions(-) diff --git a/src/E.h b/src/E.h index 40f3ee20..7bfc9da1 100644 --- a/src/E.h +++ b/src/E.h @@ -971,6 +971,11 @@ Qentry *GetHeadTimerQueue(void); void HandleTimerEvent(void); int RemoveTimerEvent(const char *name); +struct _idler; +void IdlerAdd(int order, void (*func) (void *data), void *data); +void IdlerDel(struct _idler *id); +void IdlersRun(void); + /* warp.c */ void WarpFocus(int delta); diff --git a/src/desktops.c b/src/desktops.c index 7ce9f8f1..7619170a 100644 --- a/src/desktops.c +++ b/src/desktops.c @@ -1047,6 +1047,12 @@ DesksStackingCheck(void) } } +static void +_DesksIdler(void *data __UNUSED__) +{ + DesksStackingCheck(); +} + static void DeskMove(Desk * dsk, int x, int y) { @@ -2198,10 +2204,7 @@ DesksSighan(int sig, void *prm __UNUSED__) case ESIGNAL_START: /* Draw all the buttons that belong on the desktop */ DeskShowButtons(); - break; - - case ESIGNAL_IDLE: - DesksStackingCheck(); + IdlerAdd(50, _DesksIdler, NULL); break; } } diff --git a/src/dialog.c b/src/dialog.c index 55fd2965..d7600685 100644 --- a/src/dialog.c +++ b/src/dialog.c @@ -1725,8 +1725,8 @@ DialogUpdate(Dialog * d) d->xu2 = d->yu2 = 0; } -void -DialogsCheckUpdate(void) +static void +_DialogsCheckUpdate(void *data __UNUSED__) { Dialog *d; @@ -1742,6 +1742,12 @@ DialogsCheckUpdate(void) } } +void +DialogsInit(void) +{ + IdlerAdd(50, _DialogsCheckUpdate, NULL); +} + static void DialogItemsRealize(Dialog * d) { diff --git a/src/dialog.h b/src/dialog.h index ecd3e69a..1cc19ce4 100644 --- a/src/dialog.h +++ b/src/dialog.h @@ -127,7 +127,7 @@ void DialogItemAreaSetEventFunc(DItem * di, void DialogCallbackClose(Dialog * d, int val, void *data); -void DialogsCheckUpdate(void); +void DialogsInit(void); EWin *FindEwinByDialog(Dialog * d); diff --git a/src/ecompmgr.c b/src/ecompmgr.c index 20d56bd3..dd92362d 100644 --- a/src/ecompmgr.c +++ b/src/ecompmgr.c @@ -2136,6 +2136,18 @@ ECompMgrRepaint(void) allDamage = None; } +static void +_ECompMgrIdler(void *data __UNUSED__) +{ + /* Do we get here on auto? */ + if (!allDamage /* || Conf_compmgr.mode == ECM_MODE_AUTO */ ) + return; + ECompMgrRepaint(); +#if 0 /* FIXME - Was here - Why? */ + XSync(disp, False); +#endif +} + static void ECompMgrRootConfigure(void *prm __UNUSED__, XEvent * ev) { @@ -2622,14 +2634,7 @@ ECompMgrSighan(int sig, void *prm __UNUSED__) ECompMgrInit(); if (Conf_compmgr.enable) ECompMgrStart(); - break; - - case ESIGNAL_IDLE: - /* Do we get here on auto? */ - if (!allDamage /* || Conf_compmgr.mode == ECM_MODE_AUTO */ ) - return; - ECompMgrRepaint(); - XSync(disp, False); + IdlerAdd(50, _ECompMgrIdler, NULL); break; } } diff --git a/src/emodule.h b/src/emodule.h index 558734dd..57b0dd9c 100644 --- a/src/emodule.h +++ b/src/emodule.h @@ -49,7 +49,6 @@ typedef enum ESIGNAL_CONFIGURE, ESIGNAL_START, ESIGNAL_EXIT, - ESIGNAL_IDLE, ESIGNAL_AREA_CONFIGURED, ESIGNAL_AREA_SWITCH_START, ESIGNAL_AREA_SWITCH_DONE, diff --git a/src/events.c b/src/events.c index 8201de6a..d7208ac4 100644 --- a/src/events.c +++ b/src/events.c @@ -23,7 +23,6 @@ */ #include "E.h" #include "aclass.h" -#include "dialog.h" /* FIXME - Should not be here */ #include "emodule.h" #include "xwin.h" #include @@ -626,8 +625,7 @@ EventsMain(void) if (EventDebug(EDBUG_TYPE_EVENTS)) Eprintf("EventsMain - Idlers\n"); - DialogsCheckUpdate(); /* FIXME - Shouldn't be here */ - ModulesSignal(ESIGNAL_IDLE, NULL); + IdlersRun(); if (pfetch) { diff --git a/src/focus.c b/src/focus.c index f118a471..12469332 100644 --- a/src/focus.c +++ b/src/focus.c @@ -863,6 +863,15 @@ FocusInitTimeout(int val __UNUSED__, void *data __UNUSED__) FocusInit(); } +static void +_FocusIdler(void *data __UNUSED__) +{ + if (!focus_inhibit && focus_pending_why) + FocusSet(); + if (focus_pending_update_grabs) + doFocusGrabsUpdate(); +} + static void FocusSighan(int sig, void *prm __UNUSED__) { @@ -870,19 +879,13 @@ FocusSighan(int sig, void *prm __UNUSED__) { case ESIGNAL_START: /* Delay focusing a bit to allow things to settle down */ + IdlerAdd(50, _FocusIdler, NULL); DoIn("FOCUS_INIT_TIMEOUT", 0.5, FocusInitTimeout, 0, NULL); break; case ESIGNAL_EXIT: FocusExit(); break; - - case ESIGNAL_IDLE: - if (!focus_inhibit && focus_pending_why) - FocusSet(); - if (focus_pending_update_grabs) - doFocusGrabsUpdate(); - break; } } diff --git a/src/main.c b/src/main.c index a10dfefa..fba9f364 100644 --- a/src/main.c +++ b/src/main.c @@ -23,6 +23,7 @@ */ #include "E.h" #include "desktops.h" +#include "dialog.h" #include "emodule.h" #include "hints.h" #include "snaps.h" @@ -286,6 +287,7 @@ main(int argc, char **argv) #endif ModulesSignal(ESIGNAL_START, NULL); + DialogsInit(); /* Map the clients */ MapUnmap(1); diff --git a/src/moveresize.c b/src/moveresize.c index 9c3d53d3..cd1106e6 100644 --- a/src/moveresize.c +++ b/src/moveresize.c @@ -282,7 +282,7 @@ ActionResizeStart(EWin * ewin, int grab, int hv) EGrabServer(); ModulesSignal(ESIGNAL_ANIMATION_SUSPEND, NULL); /* Run idlers (stacking, border updates, ...) before drawing lines */ - ModulesSignal(ESIGNAL_IDLE, NULL); + IdlersRun(); } else { diff --git a/src/pager.c b/src/pager.c index 524e1fb9..cf552212 100644 --- a/src/pager.c +++ b/src/pager.c @@ -775,6 +775,12 @@ PagerUpdateTimeout(int val __UNUSED__, void *data __UNUSED__) PagersCheckUpdate(); } +static void +_PagersIdler(void *data __UNUSED__) +{ + PagersCheckUpdate(); +} + static void PagerEwinUpdateFromPager(Pager * p, EWin * ewin) { @@ -1904,11 +1910,7 @@ PagersSighan(int sig, void *prm) break; Conf_pagers.enable = 0; PagersShow(1); - PagersCheckUpdate(); - break; - - case ESIGNAL_IDLE: - PagersCheckUpdate(); + IdlerAdd(50, _PagersIdler, NULL); break; case ESIGNAL_AREA_CONFIGURED: diff --git a/src/timers.c b/src/timers.c index 8f6beaf4..01192116 100644 --- a/src/timers.c +++ b/src/timers.c @@ -21,6 +21,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "E.h" +#include "e16-ecore_list.h" #include double @@ -132,3 +133,49 @@ RemoveTimerEvent(const char *name) return 0; } + +static Ecore_List *idler_list = NULL; + +typedef struct _idler Idler; +typedef void (IdlerFunc) (void *data); + +struct _idler +{ + int order; + IdlerFunc *func; + void *data; +}; + +void +IdlerAdd(int order, IdlerFunc * func, void *data) +{ + Idler *id; + + id = Emalloc(sizeof(Idler)); + if (!id) + return; + + id->order = order; /* Not used atm. */ + id->func = func; + id->data = data; + + if (!idler_list) + idler_list = ecore_list_new(); + + ecore_list_append(idler_list, id); +} + +void +IdlerDel(Idler * id) +{ + ecore_list_remove_node(idler_list, id); + Efree(id); +} + +void +IdlersRun(void) +{ + Idler *id; + + ECORE_LIST_FOR_EACH(idler_list, id) id->func(id->data); +}