mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-25 20:11:10 +00:00
Fixed GameWindow.{Bounds, Location, Size, X, Y} setters on OpenTK/Carbon
This commit is contained in:
parent
c6a21a2239
commit
c13d80d6d8
|
@ -64,6 +64,11 @@ namespace OpenTK.Platform.MacOS.Carbon
|
||||||
short bottom;
|
short bottom;
|
||||||
short right;
|
short right;
|
||||||
|
|
||||||
|
internal Rect(int left, int top, int width, int height)
|
||||||
|
: this((short)left, (short)top, (short)width, (short)height)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
internal Rect(short _left, short _top, short _width, short _height)
|
internal Rect(short _left, short _top, short _width, short _height)
|
||||||
{
|
{
|
||||||
top = _top;
|
top = _top;
|
||||||
|
@ -530,6 +535,9 @@ namespace OpenTK.Platform.MacOS.Carbon
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DllImport(carbon)]
|
||||||
|
internal static extern OSStatus SetWindowBounds(IntPtr Windows, WindowRegionCode WindowRegionCode, ref Rect globalBounds);
|
||||||
|
|
||||||
//[DllImport(carbon)]
|
//[DllImport(carbon)]
|
||||||
//internal static extern void MoveWindow(IntPtr window, short hGlobal, short vGlobal, bool front);
|
//internal static extern void MoveWindow(IntPtr window, short hGlobal, short vGlobal, bool front);
|
||||||
|
|
||||||
|
|
|
@ -660,41 +660,40 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Rect GetRegion()
|
Rect GetClientSize()
|
||||||
{
|
{
|
||||||
Rect retval = API.GetWindowBounds(window.Handle, WindowRegionCode.ContentRegion);
|
Rect retval = API.GetWindowBounds(window.Handle, WindowRegionCode.ContentRegion);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetLocation(short x, short y)
|
|
||||||
{
|
|
||||||
if (windowState == WindowState.Fullscreen)
|
|
||||||
return;
|
|
||||||
|
|
||||||
API.MoveWindow(window.Handle, x, y, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetSize(short width, short height)
|
|
||||||
{
|
|
||||||
if (WindowState == WindowState.Fullscreen)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// The bounds of the window should be the size specified, but
|
|
||||||
// API.SizeWindow sets the content region size. So
|
|
||||||
// we reduce the size to get the correct bounds.
|
|
||||||
width -= (short)(bounds.Width - clientRectangle.Width);
|
|
||||||
height -= (short)(bounds.Height - clientRectangle.Height);
|
|
||||||
|
|
||||||
API.SizeWindow(window.Handle, width, height, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetClientSize(short width, short height)
|
void SetClientSize(short width, short height)
|
||||||
{
|
{
|
||||||
if (WindowState == WindowState.Fullscreen)
|
if (WindowState == WindowState.Fullscreen)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
API.SizeWindow(window.Handle, width, height, true);
|
Rect new_bounds = new Rect(Bounds.X, Bounds.Y, width, height);
|
||||||
|
API.SetWindowBounds(window.Handle, WindowRegionCode.ContentRegion, ref new_bounds);
|
||||||
|
LoadSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetLocation(short x, short y)
|
||||||
|
{
|
||||||
|
if (windowState == WindowState.Fullscreen)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Rect new_bounds = new Rect(x, y, Bounds.Width, Bounds.Height);
|
||||||
|
API.SetWindowBounds(window.Handle, WindowRegionCode.StructureRegion, ref new_bounds);
|
||||||
|
LoadSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetSize(short width, short height)
|
||||||
|
{
|
||||||
|
if (WindowState == WindowState.Fullscreen)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Rect new_bounds = new Rect(Bounds.X, Bounds.Y, width, height);
|
||||||
|
API.SetWindowBounds(window.Handle, WindowRegionCode.StructureRegion, ref new_bounds);
|
||||||
|
LoadSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadSize()
|
private void LoadSize()
|
||||||
|
@ -705,7 +704,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
Rect r = API.GetWindowBounds(window.Handle, WindowRegionCode.StructureRegion);
|
Rect r = API.GetWindowBounds(window.Handle, WindowRegionCode.StructureRegion);
|
||||||
bounds = new Rectangle(r.X, r.Y, r.Width, r.Height);
|
bounds = new Rectangle(r.X, r.Y, r.Width, r.Height);
|
||||||
|
|
||||||
r = API.GetWindowBounds(window.Handle, WindowRegionCode.GlobalPortRegion);
|
r = API.GetWindowBounds(window.Handle, WindowRegionCode.ContentRegion);
|
||||||
clientRectangle = new Rectangle(0, 0, r.Width, r.Height);
|
clientRectangle = new Rectangle(0, 0, r.Width, r.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -891,13 +890,13 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
public int X
|
public int X
|
||||||
{
|
{
|
||||||
get { return ClientRectangle.X; }
|
get { return Bounds.X; }
|
||||||
set { Location = new Point(value, Y); }
|
set { Location = new Point(value, Y); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Y
|
public int Y
|
||||||
{
|
{
|
||||||
get { return ClientRectangle.Y; }
|
get { return Bounds.Y; }
|
||||||
set { Location = new Point(X, value); }
|
set { Location = new Point(X, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue