parent
7ee40a7968
commit
1dad1ef28f
|
@ -64,6 +64,7 @@ struct _background {
|
|||
};
|
||||
|
||||
static Ecore_List *bg_list = NULL;
|
||||
static Timer *bg_timer = NULL;
|
||||
static unsigned int bg_seq_no = 0;
|
||||
|
||||
#define N_BG_ASSIGNED 32
|
||||
|
@ -1415,16 +1416,17 @@ BackgroundsAccounting(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
BackgroundsTimeout(int val __UNUSED__, void *data __UNUSED__)
|
||||
static int
|
||||
BackgroundsTimeout(void *data __UNUSED__)
|
||||
{
|
||||
if (Conf.backgrounds.timeout <= 0)
|
||||
Conf.backgrounds.timeout = 1;
|
||||
|
||||
BackgroundsAccounting();
|
||||
|
||||
DoIn("BACKGROUND_ACCOUNTING_TIMEOUT", 1.0 * Conf.backgrounds.timeout,
|
||||
BackgroundsTimeout, 0, NULL);
|
||||
TimerSetInterval(bg_timer, 1.0 * Conf.backgrounds.timeout);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1446,8 +1448,7 @@ BackgroundsSighan(int sig, void *prm __UNUSED__)
|
|||
break;
|
||||
|
||||
case ESIGNAL_START:
|
||||
DoIn("BACKGROUND_ACCOUNTING_TIMEOUT", 30.0, BackgroundsTimeout, 0,
|
||||
NULL);
|
||||
TIMER_ADD(bg_timer, 30.0, BackgroundsTimeout, NULL);
|
||||
break;
|
||||
|
||||
case ESIGNAL_EXIT:
|
||||
|
|
34
src/edge.c
34
src/edge.c
|
@ -30,29 +30,32 @@
|
|||
#include "xwin.h"
|
||||
|
||||
static EObj *w1 = NULL, *w2 = NULL, *w3 = NULL, *w4 = NULL;
|
||||
static Timer *edge_timer = NULL;
|
||||
|
||||
static void
|
||||
EdgeTimeout(int val, void *data __UNUSED__)
|
||||
static int
|
||||
EdgeTimeout(void *data)
|
||||
{
|
||||
int val;
|
||||
int ax, ay, aw, ah, dx, dy, dax, day;
|
||||
EWin *ewin;
|
||||
|
||||
if (MenusActive())
|
||||
return;
|
||||
goto done;
|
||||
if (Conf.desks.edge_flip_mode == EDGE_FLIP_OFF)
|
||||
return;
|
||||
goto done;
|
||||
|
||||
/* Quit if pointer has left screen */
|
||||
if (!EQueryPointer(NULL, NULL, NULL, NULL, NULL))
|
||||
return;
|
||||
goto done;
|
||||
|
||||
/* Quit if in fullscreen window */
|
||||
ewin = GetEwinPointerInClient();
|
||||
if (ewin && ewin->state.fullscreen)
|
||||
return;
|
||||
goto done;
|
||||
|
||||
DeskCurrentGetArea(&ax, &ay);
|
||||
DesksGetAreaSize(&aw, &ah);
|
||||
val = PTR2INT(data);
|
||||
dx = 0;
|
||||
dy = 0;
|
||||
dax = 0;
|
||||
|
@ -61,25 +64,25 @@ EdgeTimeout(int val, void *data __UNUSED__)
|
|||
{
|
||||
case 0:
|
||||
if (ax == 0 && !Conf.desks.areas_wraparound)
|
||||
return;
|
||||
goto done;
|
||||
dx = WinGetW(VROOT) - 2;
|
||||
dax = -1;
|
||||
break;
|
||||
case 1:
|
||||
if (ax == (aw - 1) && !Conf.desks.areas_wraparound)
|
||||
return;
|
||||
goto done;
|
||||
dx = -(WinGetW(VROOT) - 2);
|
||||
dax = 1;
|
||||
break;
|
||||
case 2:
|
||||
if (ay == 0 && !Conf.desks.areas_wraparound)
|
||||
return;
|
||||
goto done;
|
||||
dy = WinGetH(VROOT) - 2;
|
||||
day = -1;
|
||||
break;
|
||||
case 3:
|
||||
if (ay == (ah - 1) && !Conf.desks.areas_wraparound)
|
||||
return;
|
||||
goto done;
|
||||
dy = -(WinGetH(VROOT) - 2);
|
||||
day = 1;
|
||||
break;
|
||||
|
@ -98,6 +101,10 @@ EdgeTimeout(int val, void *data __UNUSED__)
|
|||
DeskCurrentMoveAreaBy(dax, day);
|
||||
Mode.events.px = Mode.events.mx;
|
||||
Mode.events.py = Mode.events.my;
|
||||
|
||||
done:
|
||||
edge_timer = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -114,14 +121,13 @@ EdgeEvent(int dir)
|
|||
if (Conf.desks.edge_flip_mode == EDGE_FLIP_MOVE && Mode.mode != MODE_MOVE)
|
||||
return;
|
||||
|
||||
RemoveTimerEvent("EDGE_TIMEOUT");
|
||||
TIMER_DEL(edge_timer);
|
||||
if (dir >= 0)
|
||||
{
|
||||
if (Conf.desks.edge_flip_resistance <= 0)
|
||||
Conf.desks.edge_flip_resistance = 1;
|
||||
DoIn("EDGE_TIMEOUT",
|
||||
((double)Conf.desks.edge_flip_resistance) / 100.0, EdgeTimeout,
|
||||
dir, NULL);
|
||||
TIMER_ADD(edge_timer, ((double)Conf.desks.edge_flip_resistance) / 100.0,
|
||||
EdgeTimeout, INT2PTR(dir));
|
||||
}
|
||||
lastdir = dir;
|
||||
}
|
||||
|
|
12
src/ewins.c
12
src/ewins.c
|
@ -53,7 +53,7 @@
|
|||
/* StructureNotifyMask | */ ResizeRedirectMask | \
|
||||
PropertyChangeMask | ColormapChangeMask | VisibilityChangeMask)
|
||||
|
||||
static void EwinSlideIn(int val __UNUSED__, void *data);
|
||||
static int EwinSlideIn(void *data);
|
||||
|
||||
static void EwinChangesStart(EWin * ewin);
|
||||
static void EwinChangesProcess(EWin * ewin);
|
||||
|
@ -886,6 +886,8 @@ AddToFamily(EWin * ewin, Window xwin)
|
|||
}
|
||||
else if (doslide)
|
||||
{
|
||||
Timer *slide_timer;
|
||||
|
||||
k = rand() % 4;
|
||||
if (k == 0)
|
||||
{
|
||||
|
@ -915,7 +917,7 @@ AddToFamily(EWin * ewin, Window xwin)
|
|||
EwinShow(ewin);
|
||||
ewin->req_x = x;
|
||||
ewin->req_y = y;
|
||||
DoIn("Slide", 0.05, EwinSlideIn, 0, ewin);
|
||||
TIMER_ADD(slide_timer, 0.05, EwinSlideIn, ewin);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1876,8 +1878,8 @@ EwinUpdateOpacity(EWin * ewin)
|
|||
/*
|
||||
* Slidein
|
||||
*/
|
||||
static void
|
||||
EwinSlideIn(int val __UNUSED__, void *data)
|
||||
static int
|
||||
EwinSlideIn(void *data)
|
||||
{
|
||||
EWin *ewin = (EWin *) data;
|
||||
|
||||
|
@ -1891,6 +1893,8 @@ EwinSlideIn(int val __UNUSED__, void *data)
|
|||
done:
|
||||
Mode.place.doing_slide = 0;
|
||||
FocusEnable(1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
49
src/focus.c
49
src/focus.c
|
@ -42,6 +42,8 @@ static char click_pending_update_grabs = 0;
|
|||
static int focus_pending_why = 0;
|
||||
static EWin *focus_pending_ewin = NULL;
|
||||
static EWin *focus_pending_new = NULL;
|
||||
static Timer *focus_timer_autoraise = NULL;
|
||||
static Timer *focus_timer_reverse = NULL;
|
||||
|
||||
void
|
||||
FocusEnable(int on)
|
||||
|
@ -135,27 +137,32 @@ FocusEwinSelect(void)
|
|||
return ewin;
|
||||
}
|
||||
|
||||
static void
|
||||
AutoraiseTimeout(int val, void *data __UNUSED__)
|
||||
static int
|
||||
AutoraiseTimeout(void *data)
|
||||
{
|
||||
EWin *ewin;
|
||||
EWin *ewin = (EWin *) data;
|
||||
|
||||
if (Conf.focus.mode == MODE_FOCUS_CLICK)
|
||||
return;
|
||||
goto done;
|
||||
|
||||
ewin = EwinFindByClient(val);
|
||||
if (ewin)
|
||||
if (EwinFindByPtr(ewin)) /* May be gone */
|
||||
EwinRaise(ewin);
|
||||
|
||||
done:
|
||||
focus_timer_autoraise = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ReverseTimeout(int val, void *data __UNUSED__)
|
||||
static int
|
||||
ReverseTimeout(void *data)
|
||||
{
|
||||
EWin *ewin;
|
||||
EWin *ewin = (EWin *) data;
|
||||
|
||||
ewin = EwinFindByClient(val);
|
||||
if (ewin)
|
||||
if (EwinFindByPtr(ewin)) /* May be gone */
|
||||
EwinListFocusRaise(ewin);
|
||||
|
||||
focus_timer_reverse = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -386,11 +393,11 @@ doFocusToEwin(EWin * ewin, int why)
|
|||
|
||||
if (Conf.autoraise.enable)
|
||||
{
|
||||
RemoveTimerEvent("AUTORAISE_TIMEOUT");
|
||||
TIMER_DEL(focus_timer_autoraise);
|
||||
|
||||
if (Conf.focus.mode != MODE_FOCUS_CLICK)
|
||||
DoIn("AUTORAISE_TIMEOUT", 0.001 * Conf.autoraise.delay,
|
||||
AutoraiseTimeout, EwinGetClientXwin(ewin), NULL);
|
||||
TIMER_ADD(focus_timer_autoraise, 0.001 * Conf.autoraise.delay,
|
||||
AutoraiseTimeout, ewin);
|
||||
}
|
||||
|
||||
if (do_raise)
|
||||
|
@ -401,12 +408,11 @@ doFocusToEwin(EWin * ewin, int why)
|
|||
if (do_warp)
|
||||
EwinWarpTo(ewin);
|
||||
|
||||
RemoveTimerEvent("REVERSE_FOCUS_TIMEOUT");
|
||||
TIMER_DEL(focus_timer_reverse);
|
||||
switch (why)
|
||||
{
|
||||
case FOCUS_PREV:
|
||||
DoIn("REVERSE_FOCUS_TIMEOUT", 0.5, ReverseTimeout,
|
||||
EwinGetClientXwin(ewin), NULL);
|
||||
TIMER_ADD(focus_timer_reverse, 0.5, ReverseTimeout, ewin);
|
||||
break;
|
||||
case FOCUS_DESK_ENTER:
|
||||
if (Conf.focus.mode == MODE_FOCUS_CLICK)
|
||||
|
@ -853,10 +859,11 @@ const DialogDef DlgFocus = {
|
|||
* Focus Module
|
||||
*/
|
||||
|
||||
static void
|
||||
FocusInitTimeout(int val __UNUSED__, void *data __UNUSED__)
|
||||
static int
|
||||
FocusInitTimeout(void *data __UNUSED__)
|
||||
{
|
||||
FocusInit();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -871,12 +878,14 @@ _FocusIdler(void *data __UNUSED__)
|
|||
static void
|
||||
FocusSighan(int sig, void *prm __UNUSED__)
|
||||
{
|
||||
Timer *focus_init_timer;
|
||||
|
||||
switch (sig)
|
||||
{
|
||||
case ESIGNAL_START:
|
||||
/* Delay focusing a bit to allow things to settle down */
|
||||
IdlerAdd(_FocusIdler, NULL);
|
||||
DoIn("FOCUS_INIT_TIMEOUT", 0.5, FocusInitTimeout, 0, NULL);
|
||||
TIMER_ADD(focus_init_timer, 0.5, FocusInitTimeout, NULL);
|
||||
break;
|
||||
|
||||
case ESIGNAL_EXIT:
|
||||
|
|
51
src/fx.c
51
src/fx.c
|
@ -59,9 +59,10 @@ typedef struct {
|
|||
static Pixmap fx_ripple_above = None;
|
||||
static Win fx_ripple_win = NULL;
|
||||
static int fx_ripple_count = 0;
|
||||
static Timer *fx_ripple_timer = NULL;
|
||||
|
||||
static void
|
||||
FX_ripple_timeout(int val __UNUSED__, void *data __UNUSED__)
|
||||
static int
|
||||
FX_ripple_timeout(void *data __UNUSED__)
|
||||
{
|
||||
static double incv = 0, inch = 0;
|
||||
static GC gc1 = 0, gc = 0;
|
||||
|
@ -118,14 +119,15 @@ FX_ripple_timeout(int val __UNUSED__, void *data __UNUSED__)
|
|||
WinGetW(VROOT), 1, off,
|
||||
WinGetH(VROOT) - fx_ripple_waterh + y);
|
||||
}
|
||||
DoIn("FX_RIPPLE_TIMEOUT", 0.066, FX_ripple_timeout, 0, NULL);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
FX_Ripple_Init(const char *name __UNUSED__)
|
||||
{
|
||||
fx_ripple_count = 0;
|
||||
DoIn("FX_RIPPLE_TIMEOUT", 0.066, FX_ripple_timeout, 0, NULL);
|
||||
TIMER_ADD(fx_ripple_timer, 0.066, FX_ripple_timeout, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -140,7 +142,7 @@ FX_Ripple_Desk(void)
|
|||
static void
|
||||
FX_Ripple_Quit(void)
|
||||
{
|
||||
RemoveTimerEvent("FX_RIPPLE_TIMEOUT");
|
||||
TIMER_DEL(fx_ripple_timer);
|
||||
EClearArea(fx_ripple_win, 0, WinGetH(VROOT) - fx_ripple_waterh,
|
||||
WinGetW(VROOT), fx_ripple_waterh);
|
||||
}
|
||||
|
@ -175,6 +177,7 @@ FX_Ripple_Pause(void)
|
|||
static Win fx_raindrops_win = NULL;
|
||||
static int fx_raindrops_number = 4;
|
||||
static PixImg *fx_raindrops_draw = NULL;
|
||||
static Timer *fx_raindrops_timer = NULL;
|
||||
|
||||
typedef struct {
|
||||
int x, y;
|
||||
|
@ -184,8 +187,8 @@ typedef struct {
|
|||
|
||||
static DropContext fx_raindrops[4];
|
||||
|
||||
static void
|
||||
FX_raindrops_timeout(int val __UNUSED__, void *data __UNUSED__)
|
||||
static int
|
||||
FX_raindrops_timeout(void *data __UNUSED__)
|
||||
{
|
||||
static GC gc1 = 0, gc = 0;
|
||||
int i, x, y, xx, yy;
|
||||
|
@ -233,7 +236,7 @@ FX_raindrops_timeout(int val __UNUSED__, void *data __UNUSED__)
|
|||
ECreatePixImg(WinGetXwin(fx_raindrops_win), fx_raindrop_size,
|
||||
fx_raindrop_size);
|
||||
if (!fx_raindrops_draw)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < fx_raindrops_number; i++)
|
||||
{
|
||||
|
@ -245,7 +248,7 @@ FX_raindrops_timeout(int val __UNUSED__, void *data __UNUSED__)
|
|||
fx_raindrops[i].buf->xim, fx_raindrops[i].x,
|
||||
fx_raindrops[i].y, 0xffffffff);
|
||||
if (!fx_raindrops[i].buf)
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -380,8 +383,7 @@ FX_raindrops_timeout(int val __UNUSED__, void *data __UNUSED__)
|
|||
ESync(0);
|
||||
}
|
||||
|
||||
DoIn("FX_RAINDROPS_TIMEOUT", (0.066 /*/ (float)fx_raindrops_number */ ),
|
||||
FX_raindrops_timeout, 0, NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -396,7 +398,7 @@ FX_Raindrops_Init(const char *name __UNUSED__)
|
|||
fx_raindrops[i].x = rand() % (WinGetW(VROOT) - fx_raindrop_size);
|
||||
fx_raindrops[i].y = rand() % (WinGetH(VROOT) - fx_raindrop_size);
|
||||
}
|
||||
DoIn("FX_RAINDROPS_TIMEOUT", 0.066, FX_raindrops_timeout, 0, NULL);
|
||||
TIMER_ADD(fx_raindrops_timer, 0.066, FX_raindrops_timeout, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -410,7 +412,7 @@ FX_Raindrops_Quit(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
RemoveTimerEvent("FX_RAINDROPS_TIMEOUT");
|
||||
TIMER_DEL(fx_raindrops_timer);
|
||||
for (i = 0; i < fx_raindrops_number; i++)
|
||||
{
|
||||
EClearArea(fx_raindrops_win, fx_raindrops[i].x, fx_raindrops[i].y,
|
||||
|
@ -456,9 +458,10 @@ FX_Raindrops_Pause(void)
|
|||
static Pixmap fx_wave_above = None;
|
||||
static Win fx_wave_win = NULL;
|
||||
static int fx_wave_count = 0;
|
||||
static Timer *fx_wave_timer = NULL;
|
||||
|
||||
static void
|
||||
FX_Wave_timeout(int val __UNUSED__, void *data __UNUSED__)
|
||||
static int
|
||||
FX_Wave_timeout(void *data __UNUSED__)
|
||||
{
|
||||
/* Variables */
|
||||
static double incv = 0, inch = 0;
|
||||
|
@ -561,15 +564,14 @@ FX_Wave_timeout(int val __UNUSED__, void *data __UNUSED__)
|
|||
}
|
||||
}
|
||||
|
||||
/* Make noise */
|
||||
DoIn("FX_WAVE_TIMEOUT", 0.066, FX_Wave_timeout, 0, NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
FX_Waves_Init(const char *name __UNUSED__)
|
||||
{
|
||||
fx_wave_count = 0;
|
||||
DoIn("FX_WAVE_TIMEOUT", 0.066, FX_Wave_timeout, 0, NULL);
|
||||
TIMER_ADD(fx_wave_timer, 0.066, FX_Wave_timeout, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -583,7 +585,7 @@ FX_Waves_Desk(void)
|
|||
static void
|
||||
FX_Waves_Quit(void)
|
||||
{
|
||||
RemoveTimerEvent("FX_WAVE_TIMEOUT");
|
||||
TIMER_DEL(fx_wave_timer);
|
||||
EClearArea(fx_wave_win, 0, WinGetH(VROOT) - FX_WAVE_WATERH,
|
||||
WinGetW(VROOT), FX_WAVE_WATERH);
|
||||
}
|
||||
|
@ -612,9 +614,10 @@ FX_Waves_Pause(void)
|
|||
static Win fx_imagespinner_win = NULL;
|
||||
static int fx_imagespinner_count = 3;
|
||||
static char *fx_imagespinner_params = NULL;
|
||||
static Timer *fx_imagespinner_timer = NULL;
|
||||
|
||||
static void
|
||||
FX_imagespinner_timeout(int val __UNUSED__, void *data __UNUSED__)
|
||||
static int
|
||||
FX_imagespinner_timeout(void *data __UNUSED__)
|
||||
{
|
||||
char *string = NULL;
|
||||
|
||||
|
@ -654,14 +657,14 @@ FX_imagespinner_timeout(int val __UNUSED__, void *data __UNUSED__)
|
|||
Efree(string);
|
||||
}
|
||||
|
||||
DoIn("FX_IMAGESPINNER_TIMEOUT", 0.066, FX_imagespinner_timeout, 0, NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
FX_ImageSpinner_Init(const char *name)
|
||||
{
|
||||
fx_imagespinner_count = 3;
|
||||
DoIn("FX_IMAGESPINNER_TIMEOUT", 0.066, FX_imagespinner_timeout, 0, NULL);
|
||||
TIMER_ADD(fx_imagespinner_timer, 0.066, FX_imagespinner_timeout, NULL);
|
||||
fx_imagespinner_params = Estrdup(name);
|
||||
}
|
||||
|
||||
|
@ -674,7 +677,7 @@ FX_ImageSpinner_Desk(void)
|
|||
static void
|
||||
FX_ImageSpinner_Quit(void)
|
||||
{
|
||||
RemoveTimerEvent("FX_IMAGESPINNER_TIMEOUT");
|
||||
TIMER_DEL(fx_imagespinner_timer);
|
||||
EClearArea(fx_imagespinner_win, 0, 0, WinGetW(VROOT), WinGetH(VROOT));
|
||||
Efree(fx_imagespinner_params);
|
||||
fx_imagespinner_params = NULL;
|
||||
|
|
36
src/ipc.c
36
src/ipc.c
|
@ -402,15 +402,18 @@ doMoveConstrainedNoGroup(EWin * ewin, const char *params)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
OpacityTimeout(int val, void *data __UNUSED__)
|
||||
static int
|
||||
OpacityTimeout(void *data)
|
||||
{
|
||||
EWin *ewin;
|
||||
EWin *ewin = (EWin *) data;
|
||||
|
||||
ewin = EwinFindByClient(val);
|
||||
if (ewin)
|
||||
if (ewin->state.active)
|
||||
EoChangeOpacity(ewin, ewin->props.focused_opacity);
|
||||
if (!EwinFindByPtr(ewin)) /* May be gone */
|
||||
return 0;
|
||||
|
||||
if (ewin->state.active)
|
||||
EoChangeOpacity(ewin, ewin->props.focused_opacity);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -686,10 +689,11 @@ IpcWinop(const WinOp * wop, EWin * ewin, const char *prm)
|
|||
EwinOpSetOpacity(ewin, OPSRC_USER, a);
|
||||
if (ewin->state.active)
|
||||
{
|
||||
Timer *op_timer;
|
||||
|
||||
EoChangeOpacity(ewin, OpacityFromPercent(a));
|
||||
if (ewin->props.focused_opacity)
|
||||
DoIn("OPACITY_TIMEOUT", 0.001 * 700, OpacityTimeout,
|
||||
EwinGetClientXwin(ewin), NULL);
|
||||
TIMER_ADD(op_timer, 0.001 * 700, OpacityTimeout, ewin);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1713,28 +1717,29 @@ EFunc(EWin * ewin, const char *params)
|
|||
return ok;
|
||||
}
|
||||
|
||||
static void
|
||||
doEFuncDeferred(int val __UNUSED__, void *data)
|
||||
static int
|
||||
doEFuncDeferred(void *data)
|
||||
{
|
||||
void **prm = (void **)data;
|
||||
EWin *ewin;
|
||||
|
||||
ewin = (EWin *) prm[0];
|
||||
if (ewin && !EwinFindByPtr(ewin))
|
||||
return;
|
||||
return 0;
|
||||
|
||||
EFunc(ewin, (const char *)prm[1]);
|
||||
|
||||
Efree(prm[1]);
|
||||
Efree(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
EFuncDefer(EWin * ewin, const char *cmd)
|
||||
{
|
||||
static int seqn = 0;
|
||||
char s[32];
|
||||
void **prm;
|
||||
Timer *defer_timer;
|
||||
|
||||
prm = EMALLOC(void *, 2);
|
||||
|
||||
|
@ -1743,8 +1748,7 @@ EFuncDefer(EWin * ewin, const char *cmd)
|
|||
prm[0] = ewin;
|
||||
prm[1] = Estrdup(cmd);
|
||||
|
||||
Esnprintf(s, sizeof(s), "EFunc-%d", seqn++);
|
||||
DoIn(s, 0.0, doEFuncDeferred, 0, prm);
|
||||
TIMER_ADD(defer_timer, 0.0, doEFuncDeferred, prm);
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
16
src/magwin.c
16
src/magwin.c
|
@ -46,6 +46,9 @@
|
|||
typedef struct {
|
||||
EWin *ewin;
|
||||
const char *title;
|
||||
#if USE_TIMER
|
||||
Timer *timer;
|
||||
#endif
|
||||
int cx, cy; /* Center */
|
||||
int scale; /* Zoom level */
|
||||
int sx, sy; /* Scene x,y */
|
||||
|
@ -200,17 +203,18 @@ _MagwinUpdate(MagWindow * mw)
|
|||
}
|
||||
|
||||
#if USE_TIMER
|
||||
static void
|
||||
static int
|
||||
_MagwinTimeout(int val __UNUSED__, void *data)
|
||||
{
|
||||
MagWindow *mw = (MagWindow *) data;
|
||||
int again;
|
||||
|
||||
again = _MagwinUpdate(mw);
|
||||
if (!again)
|
||||
return;
|
||||
if (again)
|
||||
return 1;
|
||||
|
||||
DoIn("magwin", .050, _MagwinTimeout, 0, data);
|
||||
mw->timer = NULL;
|
||||
return 0;
|
||||
}
|
||||
#elif USE_ANIMATOR
|
||||
static int
|
||||
|
@ -353,7 +357,7 @@ MagwinEvent(Win win __UNUSED__, XEvent * ev, void *prm)
|
|||
case MapNotify:
|
||||
MagwinKeyPress(mw, XK_g);
|
||||
#if USE_TIMER
|
||||
_MagwinTimeout(1, mw);
|
||||
TIMER_ADD(mw->timer, .050, _MagwinTimeout, 0, mw);
|
||||
#elif USE_ANIMATOR
|
||||
AnimatorAdd(_MagwinAnimator, mw);
|
||||
#endif
|
||||
|
@ -443,7 +447,7 @@ static void
|
|||
MagwinDestroy(MagWindow * mw)
|
||||
{
|
||||
#if USE_TIMER
|
||||
RemoveTimerEvent("magwin");
|
||||
TIMER_DEL(mw->timer);
|
||||
#endif
|
||||
EventCallbackUnregister(EwinGetClientWin(mw->ewin), 0, MagwinEvent, mw);
|
||||
EDestroyWindow(EwinGetClientWin(mw->ewin));
|
||||
|
|
49
src/menus.c
49
src/menus.c
|
@ -46,7 +46,7 @@
|
|||
|
||||
#define DEBUG_MENU_EVENTS 0
|
||||
|
||||
#define MENU_UNLOAD_CHECK_IMTERVAL 300 /* Seconds */
|
||||
#define MENU_UNLOAD_CHECK_INTERVAL 300 /* Seconds */
|
||||
|
||||
static struct {
|
||||
Menu *first;
|
||||
|
@ -135,6 +135,7 @@ static void MenusHide(void);
|
|||
|
||||
static Ecore_List *menu_list = NULL;
|
||||
static Ecore_List *menu_style_list = NULL;
|
||||
static Timer *menu_timer_submenu = NULL;
|
||||
|
||||
static MenuItem *
|
||||
MenuFindItemByChild(Menu * m, Menu * mc)
|
||||
|
@ -1154,7 +1155,7 @@ MenusActive(void)
|
|||
static void
|
||||
MenusHide(void)
|
||||
{
|
||||
RemoveTimerEvent("SUBMENU_SHOW");
|
||||
TIMER_DEL(menu_timer_submenu);
|
||||
|
||||
MenuHide(Mode_menus.first);
|
||||
Mode_menus.first = NULL;
|
||||
|
@ -1549,8 +1550,8 @@ MenuSelectItemByChild(Menu * m, Menu * mc)
|
|||
MenuSelectItem(m, mi, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
SubmenuShowTimeout(int val __UNUSED__, void *dat)
|
||||
static int
|
||||
SubmenuShowTimeout(void *dat)
|
||||
{
|
||||
int mx, my, my2, xo, yo, mw;
|
||||
Menu *m;
|
||||
|
@ -1561,35 +1562,33 @@ SubmenuShowTimeout(int val __UNUSED__, void *dat)
|
|||
int bl2, br2, bt2, bb2;
|
||||
|
||||
data = (struct _mdata *)dat;
|
||||
if (!data)
|
||||
return;
|
||||
if (!data->m)
|
||||
return;
|
||||
if (!data || !data->m)
|
||||
goto done;
|
||||
|
||||
m = data->m;
|
||||
if (!ecore_list_goto(menu_list, m))
|
||||
return;
|
||||
goto done;
|
||||
ewin = m->ewin;
|
||||
if (!ewin || !EwinFindByPtr(ewin))
|
||||
return;
|
||||
goto done;
|
||||
if (!EoIsShown(ewin))
|
||||
return;
|
||||
goto done;
|
||||
|
||||
mi = data->mi;
|
||||
if (!mi)
|
||||
return;
|
||||
goto done;
|
||||
|
||||
if (mi->child != m->child)
|
||||
MenuHide(m->child);
|
||||
m->child = mi->child;
|
||||
if (!mi->child)
|
||||
return;
|
||||
goto done;
|
||||
|
||||
mi->child->parent = m;
|
||||
MenuShow(mi->child, 1);
|
||||
ewin2 = mi->child->ewin;
|
||||
if (!ewin2 || !EwinFindByPtr(ewin2))
|
||||
return;
|
||||
goto done;
|
||||
|
||||
EGetGeometry(mi->win, NULL, &mx, &my, &mw, NULL, NULL, NULL);
|
||||
my2 = 0;
|
||||
|
@ -1664,6 +1663,10 @@ SubmenuShowTimeout(int val __UNUSED__, void *dat)
|
|||
|
||||
if (Conf.menus.animate)
|
||||
EwinUnShade(ewin2);
|
||||
|
||||
done:
|
||||
menu_timer_submenu = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1686,13 +1689,13 @@ MenuActivateItem(Menu * m, MenuItem * mi)
|
|||
if (mi && !mi->child && mi_prev && !mi_prev->child)
|
||||
return;
|
||||
|
||||
RemoveTimerEvent("SUBMENU_SHOW");
|
||||
TIMER_DEL(menu_timer_submenu);
|
||||
|
||||
if ((mi && mi->child && !mi->child->shown) || (mi && mi->child != m->child))
|
||||
{
|
||||
mdata.m = m;
|
||||
mdata.mi = mi;
|
||||
DoIn("SUBMENU_SHOW", 0.2, SubmenuShowTimeout, 0, &mdata);
|
||||
TIMER_ADD(menu_timer_submenu, 0.2, SubmenuShowTimeout, &mdata);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1945,8 +1948,8 @@ MenuConfigLoad(FILE * fs)
|
|||
return err;
|
||||
}
|
||||
|
||||
static void
|
||||
MenusTimeout(int val __UNUSED__, void *data __UNUSED__)
|
||||
static int
|
||||
MenusTimeout(void *data __UNUSED__)
|
||||
{
|
||||
Menu *m;
|
||||
time_t ts;
|
||||
|
@ -1956,7 +1959,7 @@ MenusTimeout(int val __UNUSED__, void *data __UNUSED__)
|
|||
ECORE_LIST_FOR_EACH(menu_list, m)
|
||||
{
|
||||
if (m->shown || !m->filled ||
|
||||
ts - m->last_access < MENU_UNLOAD_CHECK_IMTERVAL)
|
||||
ts - m->last_access < MENU_UNLOAD_CHECK_INTERVAL)
|
||||
continue;
|
||||
|
||||
m->last_change = 0;
|
||||
|
@ -1968,7 +1971,7 @@ MenusTimeout(int val __UNUSED__, void *data __UNUSED__)
|
|||
MenuDestroy(m);
|
||||
}
|
||||
|
||||
DoIn("MenusCheck", 1. * MENU_UNLOAD_CHECK_IMTERVAL, MenusTimeout, 0, NULL);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1978,6 +1981,8 @@ MenusTimeout(int val __UNUSED__, void *data __UNUSED__)
|
|||
static void
|
||||
MenusSighan(int sig, void *prm __UNUSED__)
|
||||
{
|
||||
Timer *menu_unload_timer;
|
||||
|
||||
switch (sig)
|
||||
{
|
||||
case ESIGNAL_CONFIGURE:
|
||||
|
@ -1985,8 +1990,8 @@ MenusSighan(int sig, void *prm __UNUSED__)
|
|||
break;
|
||||
|
||||
case ESIGNAL_START:
|
||||
DoIn("MenusCheck", 1. * MENU_UNLOAD_CHECK_IMTERVAL, MenusTimeout, 0,
|
||||
NULL);
|
||||
TIMER_ADD(menu_unload_timer, 1. * MENU_UNLOAD_CHECK_INTERVAL,
|
||||
MenusTimeout, NULL);
|
||||
break;
|
||||
|
||||
case ESIGNAL_AREA_SWITCH_START:
|
||||
|
|
|
@ -291,7 +291,7 @@ autosave(void)
|
|||
if (EDebug(EDBUG_TYPE_SESSION))
|
||||
Eprintf("autosave\n");
|
||||
|
||||
Real_SaveSnapInfo(0, NULL);
|
||||
Real_SaveSnapInfo(NULL);
|
||||
|
||||
/* Save the configuration parameters */
|
||||
ConfigurationSave();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (C) 2004-2007 Jaron Omega
|
||||
* Copyright (C) 2004-2007 Kim Woelders
|
||||
* Copyright (C) 2004-2008 Kim Woelders
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
|
@ -41,16 +41,22 @@ static int tmp_st_menu;
|
|||
static int tmp_st_tooltip;
|
||||
static int tmp_st_hilight;
|
||||
|
||||
static void
|
||||
TransparencyChangeTimeout(int val, void *data __UNUSED__)
|
||||
static Timer *st_timer = NULL;
|
||||
|
||||
static int
|
||||
TransparencyChangeTimeout(void *data)
|
||||
{
|
||||
TransparencySet(val);
|
||||
TransparencySet(PTR2INT(data));
|
||||
|
||||
st_timer = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
TransparencyChange(int val)
|
||||
{
|
||||
DoIn("PT-Change", .01, TransparencyChangeTimeout, val, NULL);
|
||||
TIMER_DEL(st_timer);
|
||||
TIMER_ADD(st_timer, .01, TransparencyChangeTimeout, INT2PTR(val));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
74
src/pager.c
74
src/pager.c
|
@ -93,9 +93,9 @@ typedef struct {
|
|||
int screen_w, screen_h;
|
||||
int update_phase;
|
||||
Win sel_win;
|
||||
Timer *scan_timer;
|
||||
|
||||
/* State flags */
|
||||
char scan_pending;
|
||||
char do_newbg;
|
||||
char do_update;
|
||||
int x1, y1, x2, y2;
|
||||
|
@ -105,7 +105,7 @@ typedef struct {
|
|||
} Pager;
|
||||
|
||||
static void PagerScanCancel(Pager * p);
|
||||
static void PagerScanTimeout(int val, void *data);
|
||||
static int PagerScanTimeout(void *data);
|
||||
static void PagerCheckUpdate(Pager * p, void *prm);
|
||||
static void PagerUpdateEwinsFromPager(Pager * p);
|
||||
static void PagerHiwinHide(void);
|
||||
|
@ -169,31 +169,21 @@ PagerDestroy(Pager * p)
|
|||
static void
|
||||
PagerScanTrig(Pager * p)
|
||||
{
|
||||
char s[128];
|
||||
|
||||
if (p->scan_pending || Conf_pagers.scanspeed <= 0)
|
||||
if (p->scan_timer || Conf_pagers.scanspeed <= 0)
|
||||
return;
|
||||
|
||||
Esnprintf(s, sizeof(s), "pg-scan.%x", (unsigned)WinGetXwin(p->win));
|
||||
DoIn(s, 1 / ((double)Conf_pagers.scanspeed), PagerScanTimeout, 0, p);
|
||||
p->scan_pending = 1;
|
||||
TIMER_ADD(p->scan_timer, 1 / ((double)Conf_pagers.scanspeed),
|
||||
PagerScanTimeout, p);
|
||||
}
|
||||
|
||||
static void
|
||||
PagerScanCancel(Pager * p)
|
||||
{
|
||||
char s[128];
|
||||
|
||||
if (!p->scan_pending)
|
||||
return;
|
||||
p->scan_pending = 0;
|
||||
|
||||
Esnprintf(s, sizeof(s), "pg-scan.%x", (unsigned)WinGetXwin(p->win));
|
||||
RemoveTimerEvent(s);
|
||||
TIMER_DEL(p->scan_timer);
|
||||
}
|
||||
|
||||
static void
|
||||
PagerScanTimeout(int val __UNUSED__, void *data)
|
||||
static int
|
||||
PagerScanTimeout(void *data)
|
||||
{
|
||||
Pager *p;
|
||||
EWin *ewin;
|
||||
|
@ -201,25 +191,24 @@ PagerScanTimeout(int val __UNUSED__, void *data)
|
|||
static int offsets[8] = { 0, 4, 2, 6, 1, 5, 3, 7 };
|
||||
int pager_mode = PagersGetMode();
|
||||
|
||||
if (pager_mode != PAGER_MODE_SNAP)
|
||||
return;
|
||||
|
||||
p = (Pager *) data;
|
||||
p->scan_pending = 0;
|
||||
|
||||
if (pager_mode != PAGER_MODE_SNAP)
|
||||
goto nomore;
|
||||
|
||||
ewin = p->ewin;
|
||||
if (!ewin || !EoIsShown(ewin))
|
||||
return;
|
||||
goto nomore;
|
||||
if (p->dsk != DesksGetCurrent())
|
||||
return;
|
||||
goto nomore;
|
||||
if (ewin->state.visibility == VisibilityFullyObscured)
|
||||
return;
|
||||
goto nomore;
|
||||
|
||||
if (Conf_pagers.scanspeed > 0)
|
||||
PagerScanTrig(p);
|
||||
if (Conf_pagers.scanspeed <= 0)
|
||||
goto nomore;
|
||||
|
||||
if (Mode.mode != MODE_NONE)
|
||||
return;
|
||||
goto nomore;
|
||||
|
||||
DeskCurrentGetArea(&cx, &cy);
|
||||
ww = p->dw;
|
||||
|
@ -228,7 +217,7 @@ PagerScanTimeout(int val __UNUSED__, void *data)
|
|||
yy = cy * hh;
|
||||
phase = p->update_phase;
|
||||
if (ww <= 0 || hh <= 0)
|
||||
return;
|
||||
goto nomore;
|
||||
|
||||
#if 0
|
||||
/* Due to a bug in imlib2 <= 1.2.0 we have to scan left->right in stead
|
||||
|
@ -255,6 +244,13 @@ PagerScanTimeout(int val __UNUSED__, void *data)
|
|||
PagerUpdateEwinsFromPager(p);
|
||||
p->update_phase = 0;
|
||||
}
|
||||
|
||||
TimerSetInterval(p->scan_timer, 1 / ((double)Conf_pagers.scanspeed));
|
||||
return 1;
|
||||
|
||||
nomore:
|
||||
p->scan_timer = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if 0 /* FIXME - Remove? */
|
||||
|
@ -821,10 +817,12 @@ PagerCheckUpdate(Pager * p, void *prm __UNUSED__)
|
|||
p->do_newbg = p->do_update = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_PagersUpdateTimeout(int val __UNUSED__, void *data __UNUSED__)
|
||||
static int
|
||||
_PagersUpdateTimeout(void *data __UNUSED__)
|
||||
{
|
||||
Mode_pagers.timer_pending = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -832,6 +830,7 @@ PagersCheckUpdate(void)
|
|||
{
|
||||
static double tlast = 0.;
|
||||
double t, dt;
|
||||
Timer *pager_update_timer;
|
||||
|
||||
if (!Mode_pagers.update_pending || !Conf_pagers.enable)
|
||||
return;
|
||||
|
@ -844,7 +843,7 @@ PagersCheckUpdate(void)
|
|||
{
|
||||
/* The purpose of this timer is to trigger the idler */
|
||||
if (!Mode_pagers.timer_pending)
|
||||
DoIn("pg-upd", dt, _PagersUpdateTimeout, 0, NULL);
|
||||
TIMER_ADD(pager_update_timer, dt, _PagersUpdateTimeout, NULL);
|
||||
Mode_pagers.timer_pending = 1;
|
||||
return;
|
||||
}
|
||||
|
@ -1284,7 +1283,6 @@ PagerSetHiQ(char onoff)
|
|||
static void
|
||||
_PagerSetSnap(Pager * p, void *prm __UNUSED__)
|
||||
{
|
||||
p->scan_pending = 0;
|
||||
PagerScanTrig(p);
|
||||
}
|
||||
|
||||
|
@ -1747,19 +1745,23 @@ _PagerReconfigure(Pager * p, void *prm __UNUSED__)
|
|||
PagerReconfigure(p, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
_PagersReconfigureTimeout(int val __UNUSED__, void *data __UNUSED__)
|
||||
static int
|
||||
_PagersReconfigureTimeout(void *data __UNUSED__)
|
||||
{
|
||||
PagersForeach(NULL, _PagerReconfigure, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
PagersReconfigure(void)
|
||||
{
|
||||
Timer *pg_timer_cfg;
|
||||
|
||||
if (!Conf_pagers.enable)
|
||||
return;
|
||||
|
||||
DoIn("pg-cfg", .5, _PagersReconfigureTimeout, 0, NULL);
|
||||
TIMER_ADD(pg_timer_cfg, .5, _PagersReconfigureTimeout, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -473,7 +473,7 @@ SessionSave(int shutdown)
|
|||
if (EDebug(EDBUG_TYPE_SESSION))
|
||||
Eprintf("SessionSave(%d)\n", shutdown);
|
||||
|
||||
Real_SaveSnapInfo(0, NULL);
|
||||
Real_SaveSnapInfo(NULL);
|
||||
|
||||
#if USE_SM
|
||||
if (shutdown && sm_conn)
|
||||
|
|
17
src/snaps.c
17
src/snaps.c
|
@ -71,6 +71,7 @@ struct _snapshot {
|
|||
};
|
||||
|
||||
static Ecore_List *ss_list = NULL;
|
||||
static Timer *ss_timer = NULL;
|
||||
|
||||
static Snapshot *
|
||||
SnapshotCreate(const char *name)
|
||||
|
@ -1077,16 +1078,16 @@ const DialogDef DlgRemember = {
|
|||
};
|
||||
|
||||
/* ... combine writes, only save after a timeout */
|
||||
|
||||
void
|
||||
SaveSnapInfo(void)
|
||||
{
|
||||
DoIn("SAVESNAP_TIMEOUT", 5.0, Real_SaveSnapInfo, 0, NULL);
|
||||
TIMER_DEL(ss_timer);
|
||||
TIMER_ADD(ss_timer, 5.0, Real_SaveSnapInfo, NULL);
|
||||
}
|
||||
|
||||
/* save out all snapped info to disk */
|
||||
void
|
||||
Real_SaveSnapInfo(int dumval __UNUSED__, void *dumdat __UNUSED__)
|
||||
int
|
||||
Real_SaveSnapInfo(void *data __UNUSED__)
|
||||
{
|
||||
Snapshot *sn;
|
||||
int j;
|
||||
|
@ -1094,12 +1095,12 @@ Real_SaveSnapInfo(int dumval __UNUSED__, void *dumdat __UNUSED__)
|
|||
FILE *f;
|
||||
|
||||
if (!Mode.wm.save_ok)
|
||||
return;
|
||||
goto done;
|
||||
|
||||
Etmp(s);
|
||||
f = fopen(s, "w");
|
||||
if (!f)
|
||||
return;
|
||||
goto done;
|
||||
|
||||
ECORE_LIST_FOR_EACH(ss_list, sn)
|
||||
{
|
||||
|
@ -1167,6 +1168,10 @@ Real_SaveSnapInfo(int dumval __UNUSED__, void *dumdat __UNUSED__)
|
|||
Alert(_("Error saving snaps file\n"));
|
||||
|
||||
SaveGroups();
|
||||
|
||||
done:
|
||||
TIMER_DEL(ss_timer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2005-2007 Kim Woelders
|
||||
* Copyright (C) 2005-2008 Kim Woelders
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
|
@ -51,7 +51,7 @@
|
|||
|
||||
#define SNAP_USE_ALL (~1)
|
||||
|
||||
void Real_SaveSnapInfo(int dumval, void *dumdat);
|
||||
int Real_SaveSnapInfo(void *data);
|
||||
void LoadSnapInfo(void);
|
||||
void SaveSnapInfo(void);
|
||||
void SpawnSnappedCmds(void);
|
||||
|
|
197
src/timers.c
197
src/timers.c
|
@ -26,14 +26,15 @@
|
|||
#include "timers.h"
|
||||
#include <sys/time.h>
|
||||
|
||||
typedef struct _qentry Qentry;
|
||||
struct _qentry {
|
||||
char *name;
|
||||
#define DEBUG_TIMERS 0
|
||||
|
||||
struct _timer {
|
||||
double in_time;
|
||||
double at_time;
|
||||
void (*func) (int val, void *data);
|
||||
struct _qentry *next;
|
||||
int runtime_val;
|
||||
void *runtime_data;
|
||||
struct _timer *next;
|
||||
int (*func) (void *data);
|
||||
void *data;
|
||||
char again;
|
||||
};
|
||||
|
||||
double
|
||||
|
@ -45,98 +46,155 @@ GetTime(void)
|
|||
return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
|
||||
}
|
||||
|
||||
static Qentry *q_first = NULL;
|
||||
static Timer *q_first = NULL;
|
||||
|
||||
void
|
||||
DoIn(const char *name, double in_time, void (*func) (int val, void *data),
|
||||
int runtime_val, void *runtime_data)
|
||||
static void
|
||||
_TimerSet(Timer * timer)
|
||||
{
|
||||
Qentry *qe, *ptr, *pptr;
|
||||
|
||||
RemoveTimerEvent(name);
|
||||
qe = EMALLOC(Qentry, 1);
|
||||
if (!qe)
|
||||
return;
|
||||
|
||||
if (in_time < 0.) /* No negative in-times */
|
||||
in_time = 0.;
|
||||
Timer *ptr, *pptr;
|
||||
|
||||
#if DEBUG_TIMERS
|
||||
if (EDebug(EDBUG_TYPE_TIMERS))
|
||||
Eprintf("DoIn %8.3f: %s\n", in_time, name);
|
||||
|
||||
qe->name = Estrdup(name);
|
||||
qe->func = func;
|
||||
qe->at_time = GetTime() + in_time;
|
||||
qe->runtime_val = runtime_val;
|
||||
qe->runtime_data = runtime_data;
|
||||
Eprintf("_TimerSet %p: func=%p data=%p\n", timer, timer->func,
|
||||
timer->data);
|
||||
#endif
|
||||
|
||||
/* if there is no queue it becomes the queue */
|
||||
if (!q_first)
|
||||
{
|
||||
q_first = qe;
|
||||
qe->next = NULL;
|
||||
q_first = timer;
|
||||
timer->next = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
pptr = NULL;
|
||||
for (ptr = q_first; ptr; pptr = ptr, ptr = ptr->next)
|
||||
{
|
||||
if (ptr->at_time > qe->at_time)
|
||||
if (ptr->at_time > timer->at_time)
|
||||
break;
|
||||
}
|
||||
if (pptr)
|
||||
pptr->next = qe;
|
||||
pptr->next = timer;
|
||||
else
|
||||
q_first = qe;
|
||||
qe->next = ptr;
|
||||
q_first = timer;
|
||||
timer->next = ptr;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_TimerDel(Timer * timer)
|
||||
{
|
||||
#if DEBUG_TIMERS
|
||||
if (EDebug(EDBUG_TYPE_TIMERS))
|
||||
Eprintf("_TimerDel %p: func=%p data=%p\n", timer, timer->func,
|
||||
timer->data);
|
||||
#endif
|
||||
Efree(timer);
|
||||
}
|
||||
|
||||
Timer *
|
||||
TimerAdd(double in_time, int (*func) (void *data), void *data)
|
||||
{
|
||||
Timer *timer;
|
||||
|
||||
timer = EMALLOC(Timer, 1);
|
||||
if (!timer)
|
||||
return NULL;
|
||||
|
||||
if (in_time < 0.) /* No negative in-times */
|
||||
in_time = 0.;
|
||||
|
||||
if (EDebug(EDBUG_TYPE_TIMERS))
|
||||
Eprintf("TimerAdd %p: func=%p data=%p: %8.3f\n", timer,
|
||||
timer->func, timer->data, in_time);
|
||||
|
||||
timer->func = func;
|
||||
timer->in_time = in_time;
|
||||
timer->at_time = GetTime() + in_time;
|
||||
timer->data = data;
|
||||
|
||||
_TimerSet(timer); /* Add to timer queue */
|
||||
|
||||
return timer;
|
||||
}
|
||||
|
||||
double
|
||||
TimersRun(double tt)
|
||||
{
|
||||
Qentry *qe;
|
||||
Timer *timer, *q_old, *q_run;
|
||||
double t;
|
||||
|
||||
qe = q_first;
|
||||
timer = q_first;
|
||||
if (!q_first)
|
||||
return 0.; /* No timers pending */
|
||||
|
||||
t = tt;
|
||||
if (t <= 0.)
|
||||
t = qe->at_time;
|
||||
t = timer->at_time;
|
||||
|
||||
for (; qe; qe = q_first)
|
||||
q_run = NULL;
|
||||
q_old = q_first;
|
||||
for (; timer; timer = q_first)
|
||||
{
|
||||
if (qe->at_time > t + 200e-6) /* Within 200 us is close enough */
|
||||
if (timer->at_time > t + 200e-6) /* Within 200 us is close enough */
|
||||
break;
|
||||
|
||||
if (EDebug(EDBUG_TYPE_TIMERS))
|
||||
Eprintf("TimersRun - run %8.3lf: %s\n", qe->at_time - t, qe->name);
|
||||
Eprintf("TimersRun - run %p: func=%p data=%p: %8.3lf\n", timer,
|
||||
timer->func, timer->data, timer->at_time - t);
|
||||
|
||||
/* remove it */
|
||||
q_first = qe->next;
|
||||
q_first = timer->next;
|
||||
|
||||
/* run this callback */
|
||||
qe->func(qe->runtime_val, qe->runtime_data);
|
||||
/* Run this callback */
|
||||
timer->again = timer->func(timer->data);
|
||||
q_run = timer;
|
||||
}
|
||||
|
||||
/* free the timer */
|
||||
Efree(qe->name);
|
||||
Efree(qe);
|
||||
if (q_old != q_first)
|
||||
{
|
||||
/* At least one timer has run */
|
||||
q_run->next = NULL; /* Terminate expired timer list */
|
||||
|
||||
/* Re-schedule/remove timers that have run */
|
||||
for (timer = q_old; timer; timer = q_old)
|
||||
{
|
||||
q_old = timer->next;
|
||||
if (timer->again)
|
||||
{
|
||||
timer->at_time += timer->in_time;
|
||||
_TimerSet(timer); /* Add to timer queue */
|
||||
}
|
||||
else
|
||||
{
|
||||
_TimerDel(timer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (tt <= 0.) /* Avoid some redundant debug output */
|
||||
return tt;
|
||||
|
||||
timer = q_first;
|
||||
|
||||
if (EDebug(EDBUG_TYPE_TIMERS) > 1)
|
||||
{
|
||||
Qentry *qp;
|
||||
Timer *qp;
|
||||
|
||||
for (qp = qe; qp; qp = qp->next)
|
||||
Eprintf("TimersRun - pend %8.3lf: %s\n", qp->at_time - t, qp->name);
|
||||
for (qp = timer; qp; qp = qp->next)
|
||||
Eprintf("TimersRun - pend %p: func=%p data=%p: %8.3lf\n", timer,
|
||||
timer->func, timer->data, timer->at_time - t);
|
||||
}
|
||||
|
||||
t = (qe) ? qe->at_time - t : 0.;
|
||||
if (timer)
|
||||
{
|
||||
t = timer->at_time - t;
|
||||
if (t <= 0.)
|
||||
t = 1e-6;
|
||||
}
|
||||
else
|
||||
{
|
||||
t = 0.;
|
||||
}
|
||||
|
||||
if (EDebug(EDBUG_TYPE_TIMERS))
|
||||
Eprintf("TimersRun - next in %8.3lf\n", t);
|
||||
|
@ -145,15 +203,15 @@ TimersRun(double tt)
|
|||
}
|
||||
|
||||
int
|
||||
RemoveTimerEvent(const char *name)
|
||||
TimerDel(Timer * timer)
|
||||
{
|
||||
Qentry *qe, *ptr, *pptr;
|
||||
Timer *qe, *ptr, *pptr;
|
||||
|
||||
pptr = NULL;
|
||||
for (ptr = q_first; ptr; pptr = ptr, ptr = ptr->next)
|
||||
{
|
||||
qe = ptr;
|
||||
if (strcmp(qe->name, name))
|
||||
if (qe != timer)
|
||||
continue;
|
||||
|
||||
/* Match - remove it from the queue */
|
||||
|
@ -161,9 +219,10 @@ RemoveTimerEvent(const char *name)
|
|||
pptr->next = qe->next;
|
||||
else
|
||||
q_first = qe->next;
|
||||
|
||||
/* free it */
|
||||
Efree(qe->name);
|
||||
Efree(qe);
|
||||
_TimerDel(timer);
|
||||
|
||||
/* done */
|
||||
return 1;
|
||||
}
|
||||
|
@ -171,6 +230,12 @@ RemoveTimerEvent(const char *name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
TimerSetInterval(Timer * timer, double dt)
|
||||
{
|
||||
timer->in_time = dt;
|
||||
}
|
||||
|
||||
/*
|
||||
* Idlers
|
||||
*/
|
||||
|
@ -232,6 +297,7 @@ IdlersRun(void)
|
|||
*/
|
||||
#define DEBUG_ANIMATORS 0
|
||||
static Ecore_List *animator_list = NULL;
|
||||
static Timer *animator_timer = NULL;
|
||||
|
||||
typedef int (AnimatorFunc) (void *data);
|
||||
|
||||
|
@ -254,13 +320,21 @@ _AnimatorRun(void *_an, void *prm __UNUSED__)
|
|||
AnimatorDel(an);
|
||||
}
|
||||
|
||||
static void
|
||||
AnimatorsRun(int val __UNUSED__, void *data __UNUSED__)
|
||||
static int
|
||||
AnimatorsRun(void *data __UNUSED__)
|
||||
{
|
||||
ecore_list_for_each(animator_list, _AnimatorRun, NULL);
|
||||
|
||||
if (ecore_list_count(animator_list))
|
||||
DoIn("Anim", 1e-3 * Conf.animation.step, AnimatorsRun, 0, NULL);
|
||||
{
|
||||
TimerSetInterval(animator_timer, 1e-3 * Conf.animation.step);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
animator_timer = NULL;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Animator *
|
||||
|
@ -288,7 +362,8 @@ AnimatorAdd(AnimatorFunc * func, void *data)
|
|||
if (Conf.animation.step <= 0)
|
||||
Conf.animation.step = 1;
|
||||
/* Animator list was empty - Add to timer qeueue */
|
||||
DoIn("Anim", 1e-3 * Conf.animation.step, AnimatorsRun, 0, NULL);
|
||||
TIMER_ADD(animator_timer, 1e-3 * Conf.animation.step,
|
||||
AnimatorsRun, NULL);
|
||||
}
|
||||
|
||||
return an;
|
||||
|
@ -306,7 +381,7 @@ AnimatorDel(Animator * an)
|
|||
|
||||
if (ecore_list_count(animator_list) == 0)
|
||||
{
|
||||
/* Animator list was empty - Add to timer qeueue */
|
||||
RemoveTimerEvent("Anim");
|
||||
/* Animator list is empty - Remove from timer qeueue */
|
||||
TIMER_DEL(animator_timer);
|
||||
}
|
||||
}
|
||||
|
|
16
src/timers.h
16
src/timers.h
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Copyright (C) 2000-2007 Carsten Haitzler, Geoff Harrison and various contributors
|
||||
* Copyright (C) 2004-2007 Kim Woelders
|
||||
* Copyright (C) 2004-2008 Kim Woelders
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
|
@ -27,12 +27,18 @@
|
|||
/* timers.c */
|
||||
double GetTime(void);
|
||||
|
||||
void DoIn(const char *name, double in_time,
|
||||
void (*func) (int val, void *data),
|
||||
int runtime_val, void *runtime_data);
|
||||
int RemoveTimerEvent(const char *name);
|
||||
typedef struct _timer Timer;
|
||||
Timer *TimerAdd(double in_time,
|
||||
int (*func) (void *data), void *data);
|
||||
int TimerDel(Timer * timer);
|
||||
void TimerSetInterval(Timer * timer, double dt);
|
||||
double TimersRun(double t);
|
||||
|
||||
#define TIMER_ADD(timer, in, func, prm) \
|
||||
timer = TimerAdd(in, func, prm)
|
||||
#define TIMER_DEL(timer) \
|
||||
if (timer) { TimerDel(timer); timer = NULL; }
|
||||
|
||||
typedef struct _idler Idler;
|
||||
Idler *IdlerAdd(void (*func) (void *data), void *data);
|
||||
void IdlerDel(Idler * id);
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "xwin.h"
|
||||
|
||||
static Ecore_List *tt_list = NULL;
|
||||
static Timer *tt_timer = NULL;
|
||||
|
||||
static struct {
|
||||
char enable;
|
||||
|
@ -714,8 +715,8 @@ TooltipsEnable(int enable)
|
|||
|
||||
static ToolTip *ttip = NULL;
|
||||
|
||||
static void
|
||||
ToolTipTimeout(int val __UNUSED__, void *data __UNUSED__)
|
||||
static int
|
||||
ToolTipTimeout(void *data __UNUSED__)
|
||||
{
|
||||
int x, y;
|
||||
unsigned int mask;
|
||||
|
@ -725,33 +726,37 @@ ToolTipTimeout(int val __UNUSED__, void *data __UNUSED__)
|
|||
if (!ttip)
|
||||
ttip = TooltipFind("DEFAULT");
|
||||
if (!ttip)
|
||||
return;
|
||||
goto done;
|
||||
|
||||
/* In the case of multiple screens, check to make sure
|
||||
* the root window is still where the mouse is... */
|
||||
if (!EQueryPointer(NULL, &x, &y, NULL, &mask))
|
||||
return;
|
||||
goto done;
|
||||
|
||||
/* In case this is a virtual root */
|
||||
if (x < 0 || y < 0 || x >= WinGetW(VROOT) || y >= WinGetH(VROOT))
|
||||
return;
|
||||
goto done;
|
||||
|
||||
/* dont pop up tooltip is mouse button down */
|
||||
if (mask &
|
||||
(Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask))
|
||||
return;
|
||||
goto done;
|
||||
|
||||
if (!Mode_tooltips.ac_func)
|
||||
return;
|
||||
goto done;
|
||||
ac = Mode_tooltips.ac_func(Mode_tooltips.ac_data);
|
||||
if (!ac)
|
||||
return;
|
||||
goto done;
|
||||
|
||||
tts = ActionclassGetTooltipString(ac);
|
||||
if (!tts)
|
||||
return;
|
||||
goto done;
|
||||
|
||||
TooltipShow(ttip, _(tts), ac, x, y);
|
||||
|
||||
done:
|
||||
tt_timer = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -769,7 +774,7 @@ TooltipsSetPending(int type, CB_GetAclass * func, void *data)
|
|||
|
||||
TooltipHide(ttip);
|
||||
|
||||
RemoveTimerEvent("TOOLTIP_TIMEOUT");
|
||||
TIMER_DEL(tt_timer);
|
||||
|
||||
if (Conf_tooltips.showroottooltip)
|
||||
{
|
||||
|
@ -795,8 +800,7 @@ TooltipsSetPending(int type, CB_GetAclass * func, void *data)
|
|||
if (type && !Conf_tooltips.showroottooltip)
|
||||
return;
|
||||
|
||||
DoIn("TOOLTIP_TIMEOUT", 0.001 * Conf_tooltips.delay, ToolTipTimeout, 0,
|
||||
NULL);
|
||||
TIMER_ADD(tt_timer, 0.001 * Conf_tooltips.delay, ToolTipTimeout, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
#include "config.h"
|
||||
#include <stdarg.h>
|
||||
|
||||
#define INT2PTR(i) ((void*)(long)(i))
|
||||
#define PTR2INT(p) ((int)(long)(p))
|
||||
|
||||
/* Inspired by Xfuncproto.h */
|
||||
#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 303)
|
||||
# define __EXPORT__ __attribute__((visibility("default")))
|
||||
|
|
Loading…
Reference in New Issue