if (Location != new_location)
{
bounds.Location = new_location;
- Move(this, EventArgs.Empty);
+ OnMove(EventArgs.Empty);
}
// Note: width and height denote the internal (client) size.
if (Bounds.Size != new_size)
{
bounds.Size = new_size;
- client_rectangle.Size = new Size(e.ConfigureEvent.width, e.ConfigureEvent.height);
- Resize(this, EventArgs.Empty);
+ // X11 sets the client width/height to 0
+ // when the window is minimized. Many apps
+ // do not expect this and crash, so clamp
+ // minimum width/height to 1 instead.
+ client_rectangle.Size = new Size(
+ Math.Max(e.ConfigureEvent.width, 1),
+ Math.Max(e.ConfigureEvent.height, 1));
+ OnResize(EventArgs.Empty);
}
//Debug.Print("[X11] Window bounds changed: {0}", bounds);
bool previous_visible = visible;
visible = true;
if (visible != previous_visible)
- VisibleChanged(this, EventArgs.Empty);
+ OnVisibleChanged(EventArgs.Empty);
}
return;
bool previous_visible = visible;
visible = false;
if (visible != previous_visible)
- VisibleChanged(this, EventArgs.Empty);
+ OnVisibleChanged(EventArgs.Empty);
}
break;
{
Debug.WriteLine("Exit message received.");
CancelEventArgs ce = new CancelEventArgs();
- Closing(this, ce);
+ OnClosing(ce);
if (!ce.Cancel)
{
Debug.WriteLine("Window destroyed");
exists = false;
- Closed(this, EventArgs.Empty);
+ OnClosed(EventArgs.Empty);
return;
bool previous_focus = has_focus;
has_focus = true;
if (has_focus != previous_focus)
- FocusedChanged(this, EventArgs.Empty);
+ OnFocusedChanged(EventArgs.Empty);
}
break;
bool previous_focus = has_focus;
has_focus = false;
if (has_focus != previous_focus)
- FocusedChanged(this, EventArgs.Empty);
+ OnFocusedChanged(EventArgs.Empty);
}
break;
case XEventName.LeaveNotify:
if (CursorVisible)
{
- MouseLeave(this, EventArgs.Empty);
+ OnMouseLeave(EventArgs.Empty);
}
break;
case XEventName.EnterNotify:
- MouseEnter(this, EventArgs.Empty);
+ OnMouseEnter(EventArgs.Empty);
break;
case XEventName.MappingNotify:
case XEventName.PropertyNotify:
if (e.PropertyEvent.atom == _atom_net_wm_state)
{
- WindowStateChanged(this, EventArgs.Empty);
+ OnWindowStateChanged(EventArgs.Empty);
}
//if (e.PropertyEvent.atom == _atom_net_frame_extents)
#endregion
- #region Location
-
- public Point Location
- {
- get { return Bounds.Location; }
- set
- {
- Bounds = new Rectangle(value, Bounds.Size);
- }
- }
-
- #endregion
-
- #region Size
-
- public Size Size
- {
- get { return Bounds.Size; }
- set
- {
- Bounds = new Rectangle(Bounds.Location, value);
- }
- }
-
- #endregion
-
- #region ClientRectangle
+ #region ClientSize
- public Rectangle ClientRectangle
+ public override Size ClientSize
{
get
{
- if (client_rectangle.Width == 0)
- client_rectangle.Width = 1;
- if (client_rectangle.Height == 0)
- client_rectangle.Height = 1;
- return client_rectangle;
+ return client_rectangle.Size;
}
set
{
using (new XLock(window.Display))
{
- Functions.XMoveWindow(window.Display, window.Handle,
- value.X, value.Y);
Functions.XResizeWindow(window.Display, window.Handle,
value.Width, value.Height);
}
#endregion
- #region ClientSize
-
- public override Size ClientSize
- {
- get
- {
- return ClientRectangle.Size;
- }
- set
- {
- ClientRectangle = new Rectangle(Point.Empty, value);
- }
- }
-
- #endregion
-
- #region Width
-
- public int Width
- {
- get { return ClientSize.Width; }
- set { ClientSize = new Size(value, Height); }
- }
-
- #endregion
-
- #region Height
-
- public int Height
- {
- get { return ClientSize.Height; }
- set { ClientSize = new Size(Width, value); }
- }
-
- #endregion
-
- #region X
-
- public int X
- {
- get { return Location.X; }
- set { Location = new Point(value, Y); }
- }
-
- #endregion
-
- #region Y
-
- public int Y
- {
- get { return Location.Y; }
- set { Location = new Point(X, value); }
- }
-
- #endregion
-
#region Icon
public override Icon Icon
}
icon = value;
- IconChanged(this, EventArgs.Empty);
+ OnIconChanged(EventArgs.Empty);
}
}
break;
}
- WindowBorderChanged(this, EventArgs.Empty);
+ OnWindowBorderChanged(EventArgs.Empty);
}
}
#endregion
- #region Events
-
- public event EventHandler<EventArgs> Move = delegate { };
- public event EventHandler<EventArgs> Resize = delegate { };
- public event EventHandler<System.ComponentModel.CancelEventArgs> Closing = delegate { };
- public event EventHandler<EventArgs> Closed = delegate { };
- public event EventHandler<EventArgs> Disposed = delegate { };
- public event EventHandler<EventArgs> IconChanged = delegate { };
- public event EventHandler<EventArgs> TitleChanged = delegate { };
- public event EventHandler<EventArgs> VisibleChanged = delegate { };
- public event EventHandler<EventArgs> FocusedChanged = delegate { };
- public event EventHandler<EventArgs> WindowBorderChanged = delegate { };
- public event EventHandler<EventArgs> WindowStateChanged = delegate { };
- public event EventHandler<KeyboardKeyEventArgs> KeyDown = delegate { };
- public event EventHandler<KeyPressEventArgs> KeyPress = delegate { };
- public event EventHandler<KeyboardKeyEventArgs> KeyUp = delegate { };
- public event EventHandler<EventArgs> MouseEnter = delegate { };
- public event EventHandler<EventArgs> MouseLeave = delegate { };
-
- #endregion
-
#region Cursor
public override MouseCursor Cursor
}
}
- TitleChanged(this, EventArgs.Empty);
+ OnTitleChanged(EventArgs.Empty);
}
}