mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-17 11:35:08 -04:00
eliminate ClientRectangle, ClientSize is good enough
This commit is contained in:
parent
f69308c7dd
commit
8cf88a138c
@ -74,11 +74,8 @@ namespace OpenTK {
|
|||||||
/// <summary> Gets or sets a <see cref="System.Drawing.Size"/> structure that contains the external size of this window. </summary>
|
/// <summary> Gets or sets a <see cref="System.Drawing.Size"/> structure that contains the external size of this window. </summary>
|
||||||
public abstract Size Size { get; set; }
|
public abstract Size Size { get; set; }
|
||||||
|
|
||||||
/// <summary> Gets or sets a <see cref="System.Drawing.Rectangle"/> structure that contains the internal bounds of this window, in client coordinates.
|
/// <summary> Gets or sets a <see cref="System.Drawing.Size"/> structure that contains the internal size of this window;
|
||||||
/// The internal bounds include the drawing area of the window, but exclude the titlebar and window borders. </summary>
|
/// The internal size include the drawing area of the window, but exclude the titlebar and window borders. </summary>
|
||||||
public abstract Rectangle ClientRectangle { get; set; }
|
|
||||||
|
|
||||||
/// <summary> Gets or sets a <see cref="System.Drawing.Size"/> structure that contains the internal size this window. </summary>
|
|
||||||
public abstract Size ClientSize { get; set; }
|
public abstract Size ClientSize { get; set; }
|
||||||
|
|
||||||
/// <summary> Closes this window. </summary>
|
/// <summary> Closes this window. </summary>
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
|
||||||
|
|
||||||
namespace OpenTK.Input {
|
namespace OpenTK.Input {
|
||||||
|
|
||||||
|
@ -3,15 +3,11 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using AGLContext = System.IntPtr;
|
|
||||||
using AGLDevice = System.IntPtr;
|
|
||||||
using AGLDrawable = System.IntPtr;
|
|
||||||
using AGLPixelFormat = System.IntPtr;
|
|
||||||
|
|
||||||
namespace OpenTK.Platform.MacOS {
|
namespace OpenTK.Platform.MacOS {
|
||||||
|
|
||||||
public unsafe static class Agl {
|
public unsafe static class Agl {
|
||||||
const string agl = "/System/Library/Frameworks/AGL.framework/Versions/Current/AGL";
|
const string lib = "/System/Library/Frameworks/AGL.framework/Versions/Current/AGL";
|
||||||
|
|
||||||
// Attribute names for aglChoosePixelFormat and aglDescribePixelFormat.
|
// Attribute names for aglChoosePixelFormat and aglDescribePixelFormat.
|
||||||
internal enum PixelFormatAttribute {
|
internal enum PixelFormatAttribute {
|
||||||
@ -30,38 +26,38 @@ namespace OpenTK.Platform.MacOS {
|
|||||||
internal const int AGL_SWAP_INTERVAL = 222; /* 0 -> Don't sync, n -> Sync every n retrace */
|
internal const int AGL_SWAP_INTERVAL = 222; /* 0 -> Don't sync, n -> Sync every n retrace */
|
||||||
internal const int AGL_BAD_PIXEL_FORMAT = 0002; /* invalid pixel format */
|
internal const int AGL_BAD_PIXEL_FORMAT = 0002; /* invalid pixel format */
|
||||||
|
|
||||||
[DllImport(agl)]
|
[DllImport(lib)]
|
||||||
internal static extern IntPtr aglChoosePixelFormat(ref IntPtr gdevs, int ndev, int[] attribs);
|
internal static extern IntPtr aglChoosePixelFormat(ref IntPtr gdevs, int ndev, int[] attribs);
|
||||||
[DllImport(agl)]
|
[DllImport(lib)]
|
||||||
internal static extern IntPtr aglChoosePixelFormat(IntPtr gdevs, int ndev, int[] attribs);
|
internal static extern IntPtr aglChoosePixelFormat(IntPtr gdevs, int ndev, int[] attribs);
|
||||||
[DllImport(agl)]
|
[DllImport(lib)]
|
||||||
internal static extern void aglDestroyPixelFormat(IntPtr pix);
|
internal static extern void aglDestroyPixelFormat(IntPtr pix);
|
||||||
|
|
||||||
[DllImport(agl)]
|
[DllImport(lib)]
|
||||||
internal static extern IntPtr aglCreateContext(IntPtr pix, IntPtr share);
|
internal static extern IntPtr aglCreateContext(IntPtr pix, IntPtr share);
|
||||||
[DllImport(agl)]
|
[DllImport(lib)]
|
||||||
internal static extern byte aglDestroyContext(IntPtr ctx);
|
internal static extern byte aglDestroyContext(IntPtr ctx);
|
||||||
[DllImport(agl)]
|
[DllImport(lib)]
|
||||||
internal static extern byte aglUpdateContext(IntPtr ctx);
|
internal static extern byte aglUpdateContext(IntPtr ctx);
|
||||||
|
|
||||||
[DllImport(agl)]
|
[DllImport(lib)]
|
||||||
internal static extern byte aglSetCurrentContext(IntPtr ctx);
|
internal static extern byte aglSetCurrentContext(IntPtr ctx);
|
||||||
[DllImport(agl)]
|
[DllImport(lib)]
|
||||||
internal static extern IntPtr aglGetCurrentContext();
|
internal static extern IntPtr aglGetCurrentContext();
|
||||||
|
|
||||||
[DllImport(agl)]
|
[DllImport(lib)]
|
||||||
internal static extern byte aglSetDrawable(IntPtr ctx, IntPtr draw);
|
internal static extern byte aglSetDrawable(IntPtr ctx, IntPtr draw);
|
||||||
[DllImport(agl)]
|
[DllImport(lib)]
|
||||||
internal static extern byte aglSetFullScreen(IntPtr ctx, int width, int height, int freq, int device);
|
internal static extern byte aglSetFullScreen(IntPtr ctx, int width, int height, int freq, int device);
|
||||||
|
|
||||||
[DllImport(agl)]
|
[DllImport(lib)]
|
||||||
internal static extern void aglSwapBuffers(IntPtr ctx);
|
internal static extern void aglSwapBuffers(IntPtr ctx);
|
||||||
[DllImport(agl)]
|
[DllImport(lib)]
|
||||||
internal static extern byte aglSetInteger(IntPtr ctx, int pname, ref int @params);
|
internal static extern byte aglSetInteger(IntPtr ctx, int pname, ref int @params);
|
||||||
|
|
||||||
[DllImport(agl)]
|
[DllImport(lib)]
|
||||||
internal static extern int aglGetError();
|
internal static extern int aglGetError();
|
||||||
[DllImport(agl)]
|
[DllImport(lib)]
|
||||||
static extern IntPtr aglErrorString(int code);
|
static extern IntPtr aglErrorString(int code);
|
||||||
|
|
||||||
internal static void CheckReturnValue(byte code, string function) {
|
internal static void CheckReturnValue(byte code, string function) {
|
||||||
|
@ -337,38 +337,15 @@ namespace OpenTK.Platform.MacOS {
|
|||||||
StandardFloating = (CloseBox | CollapseBox)
|
StandardFloating = (CloseBox | CollapseBox)
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum WindowPositionMethod : uint
|
public enum WindowPositionMethod : uint {
|
||||||
{
|
|
||||||
CenterOnMainScreen = 1,
|
CenterOnMainScreen = 1,
|
||||||
CenterOnParentWindow = 2,
|
|
||||||
CenterOnParentWindowScreen = 3,
|
|
||||||
CascadeOnMainScreen = 4,
|
|
||||||
CascadeOnParentWindow = 5,
|
|
||||||
CascadeOnParentWindowScreen = 6,
|
|
||||||
CascadeStartAtParentWindowScreen = 10,
|
|
||||||
AlertPositionOnMainScreen = 7,
|
|
||||||
AlertPositionOnParentWindow = 8,
|
|
||||||
AlertPositionOnParentWindowScreen = 9
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public delegate OSStatus MacOSEventHandler(IntPtr inCaller, IntPtr inEvent, IntPtr userData);
|
public delegate OSStatus MacOSEventHandler(IntPtr inCaller, IntPtr inEvent, IntPtr userData);
|
||||||
|
|
||||||
public enum WindowPartCode : short
|
public enum WindowPartCode : short {
|
||||||
{
|
|
||||||
inDesk = 0,
|
|
||||||
inNoWindow = 0,
|
|
||||||
inMenuBar = 1,
|
|
||||||
inSysWindow = 2,
|
|
||||||
inContent = 3,
|
|
||||||
inDrag = 4,
|
|
||||||
inGrow = 5,
|
|
||||||
inGoAway = 6,
|
|
||||||
inZoomIn = 7,
|
inZoomIn = 7,
|
||||||
inZoomOut = 8,
|
inZoomOut = 8,
|
||||||
inCollapseBox = 11,
|
|
||||||
inProxyIcon = 12,
|
|
||||||
inToolbarButton = 13,
|
|
||||||
inStructure = 15,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -38,7 +38,8 @@ namespace OpenTK.Platform.MacOS {
|
|||||||
internal bool goFullScreenHack, goWindowedHack;
|
internal bool goFullScreenHack, goWindowedHack;
|
||||||
|
|
||||||
string title = "OpenTK Window";
|
string title = "OpenTK Window";
|
||||||
Rectangle bounds, clientRectangle;
|
Rectangle bounds;
|
||||||
|
Size clientSize;
|
||||||
Rectangle windowedBounds;
|
Rectangle windowedBounds;
|
||||||
bool mIsDisposed = false;
|
bool mIsDisposed = false;
|
||||||
bool mExists = true;
|
bool mExists = true;
|
||||||
@ -141,9 +142,9 @@ namespace OpenTK.Platform.MacOS {
|
|||||||
int width, height;
|
int width, height;
|
||||||
context.SetFullScreen(this, out width, out height);
|
context.SetFullScreen(this, out width, out height);
|
||||||
|
|
||||||
Debug.Print("Prev Size: {0}, {1}", ClientRectangle.Width, ClientRectangle.Height);
|
Debug.Print("Prev Size: {0}, {1}", clientSize.Width, clientSize.Height);
|
||||||
clientRectangle.Size = new Size(width, height);
|
clientSize = new Size(width, height);
|
||||||
Debug.Print("New Size: {0}, {1}", ClientRectangle.Width, ClientRectangle.Height);
|
Debug.Print("New Size: {0}, {1}", clientSize.Width, clientSize.Height);
|
||||||
|
|
||||||
// TODO: if we go full screen we need to make this use the device specified.
|
// TODO: if we go full screen we need to make this use the device specified.
|
||||||
bounds = Display.Bounds;
|
bounds = Display.Bounds;
|
||||||
@ -230,11 +231,11 @@ namespace OpenTK.Platform.MacOS {
|
|||||||
return OSStatus.NoError;
|
return OSStatus.NoError;
|
||||||
|
|
||||||
case WindowEventKind.WindowBoundsChanged:
|
case WindowEventKind.WindowBoundsChanged:
|
||||||
int curWidth = ClientRectangle.Width;
|
int curWidth = clientSize.Width;
|
||||||
int curHeight = ClientRectangle.Height;
|
int curHeight = clientSize.Height;
|
||||||
LoadSize();
|
LoadSize();
|
||||||
|
|
||||||
if (curWidth != ClientRectangle.Width || curHeight != ClientRectangle.Height)
|
if (curWidth != clientSize.Width || curHeight != clientSize.Height)
|
||||||
OnResize();
|
OnResize();
|
||||||
return OSStatus.EventNotHandled;
|
return OSStatus.EventNotHandled;
|
||||||
|
|
||||||
@ -362,8 +363,8 @@ namespace OpenTK.Platform.MacOS {
|
|||||||
// The bounds of the window should be the size specified, but
|
// The bounds of the window should be the size specified, but
|
||||||
// API.SizeWindow sets the content region size. So
|
// API.SizeWindow sets the content region size. So
|
||||||
// we reduce the size to get the correct bounds.
|
// we reduce the size to get the correct bounds.
|
||||||
width -= (short)(bounds.Width - clientRectangle.Width);
|
width -= (short)(bounds.Width - clientSize.Width);
|
||||||
height -= (short)(bounds.Height - clientRectangle.Height);
|
height -= (short)(bounds.Height - clientSize.Height);
|
||||||
|
|
||||||
API.SizeWindow(WinHandle, width, height, true);
|
API.SizeWindow(WinHandle, width, height, true);
|
||||||
}
|
}
|
||||||
@ -385,7 +386,7 @@ namespace OpenTK.Platform.MacOS {
|
|||||||
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(WinHandle, WindowRegionCode.GlobalPortRegion);
|
r = API.GetWindowBounds(WinHandle, WindowRegionCode.GlobalPortRegion);
|
||||||
clientRectangle = new Rectangle(0, 0, r.Width, r.Height);
|
clientSize = new Size(r.Width, r.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
IntPtr pbStr, utf16, utf8;
|
IntPtr pbStr, utf16, utf8;
|
||||||
@ -589,17 +590,8 @@ namespace OpenTK.Platform.MacOS {
|
|||||||
set { SetSize((short)value.Width, (short)value.Height); }
|
set { SetSize((short)value.Width, (short)value.Height); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Rectangle ClientRectangle {
|
|
||||||
get { return clientRectangle; }
|
|
||||||
set {
|
|
||||||
// just set the size, and ignore the location value.
|
|
||||||
// this is the behavior of the Windows WinGLNative.
|
|
||||||
ClientSize = value.Size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Size ClientSize {
|
public override Size ClientSize {
|
||||||
get { return clientRectangle.Size; }
|
get { return clientSize; }
|
||||||
set {
|
set {
|
||||||
API.SizeWindow(WinHandle, (short)value.Width, (short)value.Height, true);
|
API.SizeWindow(WinHandle, (short)value.Width, (short)value.Height, true);
|
||||||
OnResize();
|
OnResize();
|
||||||
|
@ -43,8 +43,8 @@ namespace OpenTK.Platform.Windows {
|
|||||||
bool invisible_since_creation; // Set by WindowsMessage.CREATE and consumed by Visible = true (calls BringWindowToFront).
|
bool invisible_since_creation; // Set by WindowsMessage.CREATE and consumed by Visible = true (calls BringWindowToFront).
|
||||||
int suppress_resize; // Used in WindowBorder and WindowState in order to avoid rapid, consecutive resize events.
|
int suppress_resize; // Used in WindowBorder and WindowState in order to avoid rapid, consecutive resize events.
|
||||||
|
|
||||||
Rectangle bounds = new Rectangle(), client_rectangle = new Rectangle(),
|
Rectangle bounds, previous_bounds; // Used to restore previous size when leaving fullscreen mode.
|
||||||
previous_bounds = new Rectangle(); // Used to restore previous size when leaving fullscreen mode.
|
Size clientSize;
|
||||||
Icon icon;
|
Icon icon;
|
||||||
|
|
||||||
static readonly WinKeyMap KeyMap = new WinKeyMap();
|
static readonly WinKeyMap KeyMap = new WinKeyMap();
|
||||||
@ -73,6 +73,13 @@ namespace OpenTK.Platform.Windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UpdateClientSize(IntPtr handle) {
|
||||||
|
Win32Rectangle rect;
|
||||||
|
API.GetClientRect(handle, out rect);
|
||||||
|
clientSize.Width = rect.Width;
|
||||||
|
clientSize.Height = rect.Height;
|
||||||
|
}
|
||||||
|
|
||||||
unsafe IntPtr WindowProcedure(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam) {
|
unsafe IntPtr WindowProcedure(IntPtr handle, WindowMessage message, IntPtr wParam, IntPtr lParam) {
|
||||||
switch (message) {
|
switch (message) {
|
||||||
|
|
||||||
@ -111,10 +118,7 @@ namespace OpenTK.Platform.Windows {
|
|||||||
if (Size != new_size) {
|
if (Size != new_size) {
|
||||||
bounds.Width = pos->cx;
|
bounds.Width = pos->cx;
|
||||||
bounds.Height = pos->cy;
|
bounds.Height = pos->cy;
|
||||||
|
UpdateClientSize(handle);
|
||||||
Win32Rectangle rect;
|
|
||||||
API.GetClientRect(handle, out rect);
|
|
||||||
client_rectangle = rect.ToRectangle();
|
|
||||||
|
|
||||||
API.SetWindowPos(WinHandle, IntPtr.Zero,
|
API.SetWindowPos(WinHandle, IntPtr.Zero,
|
||||||
bounds.X, bounds.Y, bounds.Width, bounds.Height,
|
bounds.X, bounds.Y, bounds.Width, bounds.Height,
|
||||||
@ -288,17 +292,12 @@ namespace OpenTK.Platform.Windows {
|
|||||||
|
|
||||||
case WindowMessage.CREATE:
|
case WindowMessage.CREATE:
|
||||||
CreateStruct cs = (CreateStruct)Marshal.PtrToStructure(lParam, typeof(CreateStruct));
|
CreateStruct cs = (CreateStruct)Marshal.PtrToStructure(lParam, typeof(CreateStruct));
|
||||||
if (cs.hwndParent == IntPtr.Zero)
|
if (cs.hwndParent == IntPtr.Zero) {
|
||||||
{
|
|
||||||
bounds.X = cs.x;
|
bounds.X = cs.x;
|
||||||
bounds.Y = cs.y;
|
bounds.Y = cs.y;
|
||||||
bounds.Width = cs.cx;
|
bounds.Width = cs.cx;
|
||||||
bounds.Height = cs.cy;
|
bounds.Height = cs.cy;
|
||||||
|
UpdateClientSize(handle);
|
||||||
Win32Rectangle rect;
|
|
||||||
API.GetClientRect(handle, out rect);
|
|
||||||
client_rectangle = rect.ToRectangle();
|
|
||||||
|
|
||||||
invisible_since_creation = true;
|
invisible_since_creation = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -473,20 +472,12 @@ namespace OpenTK.Platform.Windows {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override 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 {
|
|
||||||
ClientSize = value.Size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Size ClientSize {
|
public override Size ClientSize {
|
||||||
get { return ClientRectangle.Size; }
|
get {
|
||||||
|
if (clientSize.Width == 0) clientSize.Width = 1;
|
||||||
|
if (clientSize.Height == 0) clientSize.Height = 1;
|
||||||
|
return clientSize;
|
||||||
|
}
|
||||||
set {
|
set {
|
||||||
WindowStyle style = (WindowStyle)API.GetWindowLong(WinHandle, GetWindowLongOffsets.STYLE);
|
WindowStyle style = (WindowStyle)API.GetWindowLong(WinHandle, GetWindowLongOffsets.STYLE);
|
||||||
Win32Rectangle rect = Win32Rectangle.From(value);
|
Win32Rectangle rect = Win32Rectangle.From(value);
|
||||||
|
@ -98,17 +98,6 @@ namespace OpenTK.Platform.X11 {
|
|||||||
}
|
}
|
||||||
ContextHandle = IntPtr.Zero;
|
ContextHandle = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
internal static GraphicsMode SelectGraphicsMode(GraphicsMode template, out XVisualInfo info) {
|
|
||||||
int[] attribs = GetVisualAttribs(template.ColorFormat, template.Depth, template.Stencil, template.Buffers);
|
|
||||||
IntPtr visual = SelectVisual(attribs);
|
|
||||||
if (visual == IntPtr.Zero)
|
|
||||||
throw new GraphicsModeException("Requested GraphicsMode not available.");
|
|
||||||
|
|
||||||
info = (XVisualInfo)Marshal.PtrToStructure(visual, typeof(XVisualInfo));
|
|
||||||
API.XFree(visual);
|
|
||||||
return GetGraphicsMode(info);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static GraphicsMode GetGraphicsMode(XVisualInfo info) {
|
internal static GraphicsMode GetGraphicsMode(XVisualInfo info) {
|
||||||
// See what we *really* got:
|
// See what we *really* got:
|
||||||
@ -125,6 +114,17 @@ namespace OpenTK.Platform.X11 {
|
|||||||
// the above lines returns 0 - false and 1 - true.
|
// the above lines returns 0 - false and 1 - true.
|
||||||
return new GraphicsMode(new ColorFormat(r, g, b, a), depth, stencil, buffers);
|
return new GraphicsMode(new ColorFormat(r, g, b, a), depth, stencil, buffers);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
internal static XVisualInfo SelectGraphicsMode(GraphicsMode template) {
|
||||||
|
int[] attribs = GetVisualAttribs(template.ColorFormat, template.Depth, template.Stencil, template.Buffers);
|
||||||
|
IntPtr visual = SelectVisual(attribs);
|
||||||
|
if (visual == IntPtr.Zero)
|
||||||
|
throw new GraphicsModeException("Requested GraphicsMode not available.");
|
||||||
|
|
||||||
|
XVisualInfo info = (XVisualInfo)Marshal.PtrToStructure(visual, typeof(XVisualInfo));
|
||||||
|
API.XFree(visual);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
// See http://www-01.ibm.com/support/knowledgecenter/ssw_aix_61/com.ibm.aix.opengl/doc/openglrf/glXChooseFBConfig.htm%23glxchoosefbconfig
|
// See http://www-01.ibm.com/support/knowledgecenter/ssw_aix_61/com.ibm.aix.opengl/doc/openglrf/glXChooseFBConfig.htm%23glxchoosefbconfig
|
||||||
// See http://www-01.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.opengl/doc/openglrf/glXChooseVisual.htm%23b5c84be452rree
|
// See http://www-01.ibm.com/support/knowledgecenter/ssw_aix_71/com.ibm.aix.opengl/doc/openglrf/glXChooseVisual.htm%23b5c84be452rree
|
||||||
|
@ -58,7 +58,8 @@ namespace OpenTK.Platform.X11 {
|
|||||||
static readonly IntPtr _add = (IntPtr)1;
|
static readonly IntPtr _add = (IntPtr)1;
|
||||||
static readonly IntPtr _toggle = (IntPtr)2;
|
static readonly IntPtr _toggle = (IntPtr)2;
|
||||||
|
|
||||||
Rectangle bounds, client_rectangle;
|
Rectangle bounds;
|
||||||
|
Size clientSize;
|
||||||
int borderLeft, borderRight, borderTop, borderBottom;
|
int borderLeft, borderRight, borderTop, borderBottom;
|
||||||
Icon icon;
|
Icon icon;
|
||||||
bool has_focus, visible;
|
bool has_focus, visible;
|
||||||
@ -85,9 +86,7 @@ namespace OpenTK.Platform.X11 {
|
|||||||
API.DefaultDisplay, API.DefaultScreen, API.RootWindow);
|
API.DefaultDisplay, API.DefaultScreen, API.RootWindow);
|
||||||
|
|
||||||
RegisterAtoms();
|
RegisterAtoms();
|
||||||
XVisualInfo info = new XVisualInfo();
|
VisualInfo = X11GLContext.SelectGraphicsMode(mode);
|
||||||
mode = X11GLContext.SelectGraphicsMode(mode, out info);
|
|
||||||
VisualInfo = info;
|
|
||||||
// Create a window on this display using the visual above
|
// Create a window on this display using the visual above
|
||||||
Debug.Print("Opening render window... ");
|
Debug.Print("Opening render window... ");
|
||||||
|
|
||||||
@ -282,7 +281,7 @@ namespace OpenTK.Platform.X11 {
|
|||||||
|
|
||||||
if (bounds.Size != newSize) {
|
if (bounds.Size != newSize) {
|
||||||
bounds.Size = newSize;
|
bounds.Size = newSize;
|
||||||
client_rectangle.Size = new Size(e.ConfigureEvent.width, e.ConfigureEvent.height);
|
clientSize = new Size(e.ConfigureEvent.width, e.ConfigureEvent.height);
|
||||||
RaiseResize();
|
RaiseResize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -521,13 +520,11 @@ namespace OpenTK.Platform.X11 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Rectangle ClientRectangle {
|
public override Size ClientSize {
|
||||||
get {
|
get {
|
||||||
if (client_rectangle.Width == 0)
|
if (clientSize.Width == 0) clientSize.Width = 1;
|
||||||
client_rectangle.Width = 1;
|
if (clientSize.Height == 0) clientSize.Height = 1;
|
||||||
if (client_rectangle.Height == 0)
|
return clientSize;
|
||||||
client_rectangle.Height = 1;
|
|
||||||
return client_rectangle;
|
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
API.XResizeWindow(API.DefaultDisplay, WinHandle, value.Width, value.Height);
|
API.XResizeWindow(API.DefaultDisplay, WinHandle, value.Width, value.Height);
|
||||||
@ -535,16 +532,10 @@ namespace OpenTK.Platform.X11 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Size ClientSize {
|
|
||||||
get { return ClientRectangle.Size; }
|
|
||||||
set { ClientRectangle = new Rectangle(Point.Empty, value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Icon Icon {
|
public override Icon Icon {
|
||||||
get { return icon; }
|
get { return icon; }
|
||||||
set {
|
set {
|
||||||
if (value == icon)
|
if (value == icon) return;
|
||||||
return;
|
|
||||||
|
|
||||||
// Note: it seems that Gnome/Metacity does not respect the _NET_WM_ICON hint.
|
// Note: it seems that Gnome/Metacity does not respect the _NET_WM_ICON hint.
|
||||||
// For this reason, we'll also set the icon using XSetWMHints.
|
// For this reason, we'll also set the icon using XSetWMHints.
|
||||||
|
@ -24,7 +24,7 @@ bool invisible_since_creation; // Set by WindowsMessage.CREATE and consumed by V
|
|||||||
Int32 suppress_resize; // Used in WindowBorder and WindowState in order to avoid rapid, consecutive resize events.
|
Int32 suppress_resize; // Used in WindowBorder and WindowState in order to avoid rapid, consecutive resize events.
|
||||||
|
|
||||||
Rectangle2D win_Bounds;
|
Rectangle2D win_Bounds;
|
||||||
Rectangle2D win_ClientRect;
|
Size2D win_ClientSize;
|
||||||
Rectangle2D previous_bounds; // Used to restore previous size when leaving fullscreen mode.
|
Rectangle2D previous_bounds; // Used to restore previous size when leaving fullscreen mode.
|
||||||
|
|
||||||
static Rectangle2D Window_FromRect(RECT rect) {
|
static Rectangle2D Window_FromRect(RECT rect) {
|
||||||
@ -165,6 +165,13 @@ static Key Window_MapKey(WPARAM key) {
|
|||||||
return Key_None;
|
return Key_None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Window_UpdateClientSize(HWND handle) {
|
||||||
|
RECT rect;
|
||||||
|
GetClientRect(handle, &rect);
|
||||||
|
win_ClientSize.Width = RECT_WIDTH(rect);
|
||||||
|
win_ClientSize.Height = RECT_HEIGHT(rect);
|
||||||
|
}
|
||||||
|
|
||||||
static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wParam, LPARAM lParam) {
|
static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wParam, LPARAM lParam) {
|
||||||
bool new_focused_state;
|
bool new_focused_state;
|
||||||
Real32 wheel_delta;
|
Real32 wheel_delta;
|
||||||
@ -207,10 +214,7 @@ static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wPara
|
|||||||
Size2D size = Window_GetSize();
|
Size2D size = Window_GetSize();
|
||||||
if (size.Width != pos->cx || size.Height != pos->cy) {
|
if (size.Width != pos->cx || size.Height != pos->cy) {
|
||||||
win_Bounds.Width = pos->cx; win_Bounds.Height = pos->cy;
|
win_Bounds.Width = pos->cx; win_Bounds.Height = pos->cy;
|
||||||
|
Window_UpdateClientSize(handle);
|
||||||
RECT rect;
|
|
||||||
GetClientRect(handle, &rect);
|
|
||||||
win_ClientRect = Window_FromRect(rect);
|
|
||||||
|
|
||||||
SetWindowPos(win_Handle, NULL,
|
SetWindowPos(win_Handle, NULL,
|
||||||
win_Bounds.X, win_Bounds.Y, win_Bounds.Width, win_Bounds.Height,
|
win_Bounds.X, win_Bounds.Y, win_Bounds.Width, win_Bounds.Height,
|
||||||
@ -372,10 +376,7 @@ static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wPara
|
|||||||
if (cs->hwndParent == NULL) {
|
if (cs->hwndParent == NULL) {
|
||||||
win_Bounds.X = cs->x; win_Bounds.Y = cs->y;
|
win_Bounds.X = cs->x; win_Bounds.Y = cs->y;
|
||||||
win_Bounds.Width = cs->cx; win_Bounds.Height = cs->cy;
|
win_Bounds.Width = cs->cx; win_Bounds.Height = cs->cy;
|
||||||
|
Window_UpdateClientSize(handle);
|
||||||
RECT rect;
|
|
||||||
GetClientRect(handle, &rect);
|
|
||||||
win_ClientRect = Window_FromRect(rect);
|
|
||||||
invisible_since_creation = true;
|
invisible_since_creation = true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -401,7 +402,8 @@ void Window_Create(Int32 x, Int32 y, Int32 width, Int32 height, STRING_REF Strin
|
|||||||
/* TODO: UngroupFromTaskbar(); */
|
/* TODO: UngroupFromTaskbar(); */
|
||||||
|
|
||||||
/* Find out the final window rectangle, after the WM has added its chrome (titlebar, sidebars etc). */
|
/* Find out the final window rectangle, after the WM has added its chrome (titlebar, sidebars etc). */
|
||||||
RECT rect; rect.left = x; rect.top = y; rect.right = x + width; rect.bottom = y + height;
|
RECT rect; rect.left = x; rect.top = y;
|
||||||
|
rect.right = x + width; rect.bottom = y + height;
|
||||||
AdjustWindowRect(&rect, win_Style, false);
|
AdjustWindowRect(&rect, win_Style, false);
|
||||||
|
|
||||||
WNDCLASSEXA wc = { 0 };
|
WNDCLASSEXA wc = { 0 };
|
||||||
@ -518,19 +520,10 @@ void Window_SetSize(Size2D size) {
|
|||||||
SetWindowPos(win_Handle, NULL, 0, 0, size.Width, size.Height, SWP_NOMOVE);
|
SetWindowPos(win_Handle, NULL, 0, 0, size.Width, size.Height, SWP_NOMOVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle2D Window_GetClientRectangle(void) { return win_ClientRect; }
|
Size2D Window_GetClientSize(void) { return win_ClientSize; }
|
||||||
void Window_SetClientRectangle(Rectangle2D rect) {
|
|
||||||
Size2D size = { rect.Width, rect.Height };
|
|
||||||
Window_SetClientSize(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
Size2D Window_GetClientSize(void) {
|
|
||||||
Size2D size = { win_ClientRect.Width, win_ClientRect.Height }; return size;
|
|
||||||
}
|
|
||||||
void Window_SetClientSize(Size2D size) {
|
void Window_SetClientSize(Size2D size) {
|
||||||
DWORD style = GetWindowLongA(win_Handle, GWL_STYLE);
|
DWORD style = GetWindowLongA(win_Handle, GWL_STYLE);
|
||||||
RECT rect;
|
RECT rect; rect.left = 0; rect.top = 0;
|
||||||
rect.left = 0; rect.top = 0;
|
|
||||||
rect.right = size.Width; rect.bottom = size.Height;
|
rect.right = size.Width; rect.bottom = size.Height;
|
||||||
|
|
||||||
AdjustWindowRect(&rect, style, false);
|
AdjustWindowRect(&rect, style, false);
|
||||||
|
@ -57,8 +57,6 @@ Point2D Window_GetLocation(void);
|
|||||||
void Window_SetLocation(Point2D point);
|
void Window_SetLocation(Point2D point);
|
||||||
Size2D Window_GetSize(void);
|
Size2D Window_GetSize(void);
|
||||||
void Window_SetSize(Size2D size);
|
void Window_SetSize(Size2D size);
|
||||||
Rectangle2D Window_GetClientRectangle(void);
|
|
||||||
void Window_SetClientRectangle(Rectangle2D rect);
|
|
||||||
Size2D Window_GetClientSize(void);
|
Size2D Window_GetClientSize(void);
|
||||||
void Window_SetClientSize(Size2D size);
|
void Window_SetClientSize(Size2D size);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user