1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
4 * Moonlight List (moonlight-list@lists.ximian.com)
6 * Copyright 2007 Novell, Inc. (http://www.novell.com)
8 * See the LICENSE file included with the distribution for details.
12 #ifndef MOON_TIMEMANAGER_H
13 #define MOON_TIMEMANAGER_H
18 #include "timesource.h"
19 #include "dependencyobject.h"
21 // our root level time manager (basically the object that registers
22 // the gtk_timeout and drives all Clock objects
23 class TimeManager
: public EventObject
{
32 TimeSource
*GetSource() { return source
; }
34 void AddClock (Clock
*clock
);
36 virtual TimeSpan
GetCurrentTime () { return current_global_time
- start_time
; }
37 virtual TimeSpan
GetLastTime () { return last_global_time
- start_time
; }
38 TimeSpan
GetCurrentTimeUsec () { return current_global_time_usec
- start_time_usec
; }
40 /* @GenerateCBinding,GeneratePInvoke */
41 void AddTickCall (TickCallHandler handler
, EventObject
*tick_data
);
42 /* @GenerateCBinding,GeneratePInvoke */
43 void RemoveTickCall (TickCallHandler handler
, EventObject
*tick_data
);
44 /* @GenerateCBinding,GeneratePInvoke */
45 void AddDispatcherCall (TickCallHandler handler
, EventObject
*tick_data
);
48 void NeedClockTick ();
50 void InvokeTickCalls ();
52 /* @GenerateCBinding, GeneratePInvoke */
53 guint
AddTimeout (gint priority
, guint ms_interval
, GSourceFunc func
, gpointer timeout_data
);
54 /* @GenerateCBinding, GeneratePInvoke */
55 void RemoveTimeout (guint timeout_id
);
57 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Internal,Version=2 */
58 void SetMaximumRefreshRate (int hz
);
59 /* @GenerateCBinding,GeneratePInvoke,ManagedAccess=Internal,Version=2 */
60 int GetMaximumRefreshRate () { return max_fps
; }
62 // Events you can AddHandler to
63 const static int UpdateInputEvent
;
64 const static int RenderEvent
;
67 Applier
* GetApplier () { return applier
; }
70 virtual ~TimeManager ();
74 TimelineGroup
*timeline
;
75 ClockGroup
*root_clock
;
80 void RemoveAllRegisteredTimeouts ();
82 TimeSpan current_global_time
;
83 TimeSpan last_global_time
;
86 TimeSpan current_global_time_usec
;
87 TimeSpan start_time_usec
;
89 static void source_tick_callback (EventObject
*sender
, EventArgs
*calldata
, gpointer closure
);
90 bool source_tick_pending
;
96 TimeSpan previous_smoothed
;
99 TIME_MANAGER_UPDATE_CLOCKS
= 0x01,
100 TIME_MANAGER_RENDER
= 0x02,
101 TIME_MANAGER_TICK_CALL
= 0x04,
102 TIME_MANAGER_UPDATE_INPUT
= 0x08
110 Queue dispatcher_calls
;
112 GList
*registered_timeouts
;
117 bool find_tick_call (List::Node
*node
, void *data
);
121 #endif /* MOON_TIMEMANAGER_H */