mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-03-29 18:06:52 +00:00
[X11] Corrected size events
This commit is contained in:
parent
e3fd9e1374
commit
d430b462fe
|
@ -739,7 +739,7 @@ namespace OpenTK.Platform.X11
|
||||||
if (Location != new_location)
|
if (Location != new_location)
|
||||||
{
|
{
|
||||||
bounds.Location = new_location;
|
bounds.Location = new_location;
|
||||||
Move(this, EventArgs.Empty);
|
OnMove(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: width and height denote the internal (client) size.
|
// Note: width and height denote the internal (client) size.
|
||||||
|
@ -750,9 +750,15 @@ namespace OpenTK.Platform.X11
|
||||||
if (Bounds.Size != new_size)
|
if (Bounds.Size != new_size)
|
||||||
{
|
{
|
||||||
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);
|
//Debug.Print("[X11] Window bounds changed: {0}", bounds);
|
||||||
|
@ -800,7 +806,7 @@ namespace OpenTK.Platform.X11
|
||||||
bool previous_visible = visible;
|
bool previous_visible = visible;
|
||||||
visible = true;
|
visible = true;
|
||||||
if (visible != previous_visible)
|
if (visible != previous_visible)
|
||||||
VisibleChanged(this, EventArgs.Empty);
|
OnVisibleChanged(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -809,7 +815,7 @@ namespace OpenTK.Platform.X11
|
||||||
bool previous_visible = visible;
|
bool previous_visible = visible;
|
||||||
visible = false;
|
visible = false;
|
||||||
if (visible != previous_visible)
|
if (visible != previous_visible)
|
||||||
VisibleChanged(this, EventArgs.Empty);
|
OnVisibleChanged(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -822,7 +828,7 @@ namespace OpenTK.Platform.X11
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Exit message received.");
|
Debug.WriteLine("Exit message received.");
|
||||||
CancelEventArgs ce = new CancelEventArgs();
|
CancelEventArgs ce = new CancelEventArgs();
|
||||||
Closing(this, ce);
|
OnClosing(ce);
|
||||||
|
|
||||||
if (!ce.Cancel)
|
if (!ce.Cancel)
|
||||||
{
|
{
|
||||||
|
@ -843,7 +849,7 @@ namespace OpenTK.Platform.X11
|
||||||
Debug.WriteLine("Window destroyed");
|
Debug.WriteLine("Window destroyed");
|
||||||
exists = false;
|
exists = false;
|
||||||
|
|
||||||
Closed(this, EventArgs.Empty);
|
OnClosed(EventArgs.Empty);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1002,7 +1008,7 @@ namespace OpenTK.Platform.X11
|
||||||
bool previous_focus = has_focus;
|
bool previous_focus = has_focus;
|
||||||
has_focus = true;
|
has_focus = true;
|
||||||
if (has_focus != previous_focus)
|
if (has_focus != previous_focus)
|
||||||
FocusedChanged(this, EventArgs.Empty);
|
OnFocusedChanged(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1011,19 +1017,19 @@ namespace OpenTK.Platform.X11
|
||||||
bool previous_focus = has_focus;
|
bool previous_focus = has_focus;
|
||||||
has_focus = false;
|
has_focus = false;
|
||||||
if (has_focus != previous_focus)
|
if (has_focus != previous_focus)
|
||||||
FocusedChanged(this, EventArgs.Empty);
|
OnFocusedChanged(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XEventName.LeaveNotify:
|
case XEventName.LeaveNotify:
|
||||||
if (CursorVisible)
|
if (CursorVisible)
|
||||||
{
|
{
|
||||||
MouseLeave(this, EventArgs.Empty);
|
OnMouseLeave(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XEventName.EnterNotify:
|
case XEventName.EnterNotify:
|
||||||
MouseEnter(this, EventArgs.Empty);
|
OnMouseEnter(EventArgs.Empty);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XEventName.MappingNotify:
|
case XEventName.MappingNotify:
|
||||||
|
@ -1038,7 +1044,7 @@ namespace OpenTK.Platform.X11
|
||||||
case XEventName.PropertyNotify:
|
case XEventName.PropertyNotify:
|
||||||
if (e.PropertyEvent.atom == _atom_net_wm_state)
|
if (e.PropertyEvent.atom == _atom_net_wm_state)
|
||||||
{
|
{
|
||||||
WindowStateChanged(this, EventArgs.Empty);
|
OnWindowStateChanged(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
//if (e.PropertyEvent.atom == _atom_net_frame_extents)
|
//if (e.PropertyEvent.atom == _atom_net_frame_extents)
|
||||||
|
@ -1122,115 +1128,27 @@ namespace OpenTK.Platform.X11
|
||||||
|
|
||||||
#endregion
|
#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
|
|
||||||
|
|
||||||
public Rectangle ClientRectangle
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (client_rectangle.Width == 0)
|
|
||||||
client_rectangle.Width = 1;
|
|
||||||
if (client_rectangle.Height == 0)
|
|
||||||
client_rectangle.Height = 1;
|
|
||||||
return client_rectangle;
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
ProcessEvents();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region ClientSize
|
#region ClientSize
|
||||||
|
|
||||||
public override Size ClientSize
|
public override Size ClientSize
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return ClientRectangle.Size;
|
return client_rectangle.Size;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
ClientRectangle = new Rectangle(Point.Empty, value);
|
using (new XLock(window.Display))
|
||||||
|
{
|
||||||
|
Functions.XResizeWindow(window.Display, window.Handle,
|
||||||
|
value.Width, value.Height);
|
||||||
|
}
|
||||||
|
ProcessEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#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
|
#region Icon
|
||||||
|
|
||||||
public override Icon Icon
|
public override Icon Icon
|
||||||
|
@ -1299,7 +1217,7 @@ namespace OpenTK.Platform.X11
|
||||||
}
|
}
|
||||||
|
|
||||||
icon = value;
|
icon = value;
|
||||||
IconChanged(this, EventArgs.Empty);
|
OnIconChanged(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1497,33 +1415,12 @@ namespace OpenTK.Platform.X11
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
WindowBorderChanged(this, EventArgs.Empty);
|
OnWindowBorderChanged(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#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
|
#region Cursor
|
||||||
|
|
||||||
public override MouseCursor Cursor
|
public override MouseCursor Cursor
|
||||||
|
@ -1659,7 +1556,7 @@ namespace OpenTK.Platform.X11
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TitleChanged(this, EventArgs.Empty);
|
OnTitleChanged(EventArgs.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue