Files
mono/mcs/class/Managed.Windows.Forms/System.Windows.Forms/XEventQueue.cs
T
Jackson Harper 2841a73b10 * XEventQueue.cs: Increase the default queue size (very simple
apps needed to grow the queue).
	* Hwnd.cs: No finalizer so we don't need to suppress
	finalization. Compute the invalid area manually so a new rectangle
	does not newto be created.
	* ScrollableControl.cs: Don't set any params (otherwise visibility
	isn't set correctly).
	* MdiChildContext.cs: New constructor takes the mdi parent so it
	doesn't have to be computed and avoids a crash on windows. Draw
	the window icon properly, and allow the text to be seen.
	* Form.cs: Use new MdiChildContext constructor. Make sure the
	child context isn't null in wndproc.
	* TabControl.cs: Don't set focus, this is muddling keyboard
	behavoir. Expand the tab rows when a window size increase will
	allow extra tabs to be seen. Don't allow tabs smaller than the
	width of a window to be scrolled out of view.
	* TreeNode.cs:
	* TreeView.cs: Use measure string to calculate a nodes width, the
	width is cached and only updated when the text or the font is
	changed. Don't check for expand/collapse clicks on the first level
	nodes if root lines are disabled.


svn path=/trunk/mcs/; revision=51769
2005-10-16 18:26:11 +00:00

110 lines
1.9 KiB
C#

//
// System.Windows.Forms.XEventQueue
//
// Author(s):
// Jackson Harper ([email protected])
//
// Copyright (C) Novell, Inc (http://www.novell.com)
//
using System;
using System.Threading;
using System.Collections;
namespace System.Windows.Forms {
internal class XEventQueue {
private XQueue xqueue;
private XQueue lqueue; // Events inserted from threads other then the main X thread
private static readonly int InitialXEventSize = 100;
private static readonly int InitialLXEventSize = 10;
public XEventQueue ()
{
xqueue = new XQueue (InitialXEventSize);
lqueue = new XQueue (InitialLXEventSize);
}
public int Count {
get {
lock (lqueue) {
return xqueue.Count + lqueue.Count;
}
}
}
public void Enqueue (XEvent xevent)
{
xqueue.Enqueue (xevent);
}
public void EnqueueLocked (XEvent xevent)
{
lock (lqueue) {
lqueue.Enqueue (xevent);
}
}
public XEvent Dequeue ()
{
if (xqueue.Count == 0) {
lock (lqueue) {
return lqueue.Dequeue ();
}
}
return xqueue.Dequeue ();
}
private class XQueue {
private XEvent [] xevents;
private int head;
private int tail;
private int size;
public XQueue (int size)
{
xevents = new XEvent [size];
}
public int Count {
get { return size; }
}
public void Enqueue (XEvent xevent)
{
if (size == xevents.Length)
Grow ();
xevents [tail] = xevent;
tail = (tail + 1) % xevents.Length;
size++;
}
public XEvent Dequeue ()
{
if (size < 1)
throw new Exception ("Attempt to dequeue empty queue.");
XEvent res = xevents [head];
head = (head + 1) % xevents.Length;
size--;
return res;
}
private void Grow ()
{
int newcap = (xevents.Length * 2);
XEvent [] na = new XEvent [newcap];
xevents.CopyTo (na, 0);
xevents = na;
head = 0;
tail = head + size;
}
}
}
}