+2008-10-15 Ivan N. Zlatev <contact@i-nz.net>
+
+ * XplatUIX11.cs, XplatUICarbon.cs: Do not Timer.Tick before
+ MainForm.OnLoad has completed unless DoEvents is forced.
+ [Fixes bug #412536]
+
2008-10-15 Jonathan Pobst <monkey@jpobst.com>
* ToolTip.cs: Ensure that Timer.Internal cannot be set to 0.
// Timers
private ArrayList TimerList;
+ private static bool in_doevents;
static readonly object instancelock = new object ();
static readonly object queuelock = new object ();
RefCount = 0;
TimerList = new ArrayList ();
+ in_doevents = false;
MessageQueue = new Queue ();
Initialize ();
for (int i = 0; i < TimerList.Count; i++) {
Timer timer = (Timer) TimerList [i];
if (timer.Enabled && timer.Expires <= now) {
- // Prevent the Timer from ticking before MainForm.OnLoad has
- // completed. This seems to be the case with Win32.
+ // Timer ticks:
+ // - Before MainForm.OnLoad if DoEvents () is called.
+ // - After MainForm.OnLoad if not.
//
- if (Application.MWFThread.Current.Context != null &&
- Application.MWFThread.Current.Context.MainForm != null &&
- Application.MWFThread.Current.Context.MainForm.IsLoaded) {
+ if (in_doevents ||
+ (Application.MWFThread.Current.Context != null &&
+ Application.MWFThread.Current.Context.MainForm != null &&
+ Application.MWFThread.Current.Context.MainForm.IsLoaded)) {
timer.FireTick ();
timer.Update (now);
}
internal override void DoEvents() {
MSG msg = new MSG ();
+ in_doevents = true;
while (PeekMessage (null, ref msg, IntPtr.Zero, 0, 0, (uint)PeekMessageFlags.PM_REMOVE)) {
TranslateMessage (ref msg);
DispatchMessage (ref msg);
}
+ in_doevents = false;
}
// State
Point mouse_position; // Last position of mouse, in screen coords
internal static MouseButtons MouseState; // Last state of mouse buttons
-
+ internal static bool in_doevents;
// 'Constants'
private static int DoubleClickInterval; // msec; max interval between clicks to count as double click
private XplatUIX11() {
// Handle singleton stuff first
RefCount = 0;
+ in_doevents = false;
// Now regular initialization
XlibLock = new object ();
timer = (Timer) timers [i];
if (timer.Enabled && timer.Expires <= now && !timer.Busy) {
- // Prevent the Timer from ticking before MainForm.OnLoad has
- // completed. This seems to be the case with Win32.
+ // Timer ticks:
+ // - Before MainForm.OnLoad if DoEvents () is called.
+ // - After MainForm.OnLoad if not.
//
- if (Application.MWFThread.Current.Context != null &&
- Application.MWFThread.Current.Context.MainForm != null &&
- Application.MWFThread.Current.Context.MainForm.IsLoaded) {
+ if (in_doevents ||
+ (Application.MWFThread.Current.Context != null &&
+ Application.MWFThread.Current.Context.MainForm != null &&
+ Application.MWFThread.Current.Context.MainForm.IsLoaded)) {
timer.Busy = true;
timer.Update (now);
timer.FireTick ();
queue = ThreadQueue(Thread.CurrentThread);
queue.DispatchIdle = false;
+ in_doevents = true;
while (PeekMessage(queue, ref msg, IntPtr.Zero, 0, 0, (uint)PeekMessageFlags.PM_REMOVE)) {
TranslateMessage (ref msg);
DispatchMessage (ref msg);
}
+ in_doevents = false;
queue.DispatchIdle = true;
}