mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-04-18 04:51:49 +00:00
* EventInfo.cs:
* AglContext.cs: * MacOSKeyMap.cs: * CarbonInput.cs: * Application.cs: * MacOSFactory.cs: * CarbonGLNative.cs: * CarbonWindowInfo.cs: * MacOSGraphicsMode.cs: * QuartzDisplayDeviceDriver.cs: Normalized code formatting.
This commit is contained in:
parent
b30ec15167
commit
64210383de
|
@ -47,8 +47,7 @@ namespace OpenTK.Platform.MacOS
|
|||
shareContextRef = ((AglContext)shareContext).Handle.Handle;
|
||||
if (shareContext is GraphicsContext)
|
||||
{
|
||||
ContextHandle shareHandle = shareContext != null ?
|
||||
(shareContext as IGraphicsContextInternal).Context : (ContextHandle)IntPtr.Zero;
|
||||
ContextHandle shareHandle = shareContext != null ? (shareContext as IGraphicsContextInternal).Context : (ContextHandle)IntPtr.Zero;
|
||||
|
||||
shareContextRef = shareHandle.Handle;
|
||||
}
|
||||
|
@ -86,8 +85,7 @@ namespace OpenTK.Platform.MacOS
|
|||
aglAttributes.Add((int)pixelFormatAttribute);
|
||||
aglAttributes.Add(value);
|
||||
}
|
||||
void CreateContext(GraphicsMode mode, CarbonWindowInfo carbonWindow,
|
||||
IntPtr shareContextRef, bool fullscreen)
|
||||
void CreateContext(GraphicsMode mode, CarbonWindowInfo carbonWindow, IntPtr shareContextRef, bool fullscreen)
|
||||
{
|
||||
List<int> aglAttributes = new List<int>();
|
||||
|
||||
|
@ -145,15 +143,12 @@ namespace OpenTK.Platform.MacOS
|
|||
if (cgdevice == IntPtr.Zero)
|
||||
cgdevice = QuartzDisplayDeviceDriver.MainDisplay;
|
||||
|
||||
OSStatus status = Carbon.API.DMGetGDeviceByDisplayID(
|
||||
cgdevice, out gdevice, false);
|
||||
OSStatus status = Carbon.API.DMGetGDeviceByDisplayID(cgdevice, out gdevice, false);
|
||||
|
||||
if (status != OSStatus.NoError)
|
||||
throw new MacOSException(status, "DMGetGDeviceByDisplayID failed.");
|
||||
|
||||
myAGLPixelFormat = Agl.aglChoosePixelFormat(
|
||||
ref gdevice, 1,
|
||||
aglAttributes.ToArray());
|
||||
myAGLPixelFormat = Agl.aglChoosePixelFormat(ref gdevice, 1, aglAttributes.ToArray());
|
||||
|
||||
Agl.AglError err = Agl.GetError();
|
||||
|
||||
|
@ -166,11 +161,10 @@ namespace OpenTK.Platform.MacOS
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
myAGLPixelFormat = Agl.aglChoosePixelFormat(
|
||||
IntPtr.Zero, 0,
|
||||
aglAttributes.ToArray());
|
||||
myAGLPixelFormat = Agl.aglChoosePixelFormat(IntPtr.Zero, 0, aglAttributes.ToArray());
|
||||
|
||||
MyAGLReportError("aglChoosePixelFormat");
|
||||
}
|
||||
|
@ -179,7 +173,7 @@ namespace OpenTK.Platform.MacOS
|
|||
Debug.Print("Creating AGL context. Sharing with {0}", shareContextRef);
|
||||
|
||||
// create the context and share it with the share reference.
|
||||
Handle = new ContextHandle( Agl.aglCreateContext(myAGLPixelFormat, shareContextRef));
|
||||
Handle = new ContextHandle(Agl.aglCreateContext(myAGLPixelFormat, shareContextRef));
|
||||
MyAGLReportError("aglCreateContext");
|
||||
|
||||
// Free the pixel format from memory.
|
||||
|
@ -228,10 +222,9 @@ namespace OpenTK.Platform.MacOS
|
|||
return;
|
||||
|
||||
Rect rect = API.GetControlBounds(carbonWindow.WindowRef);
|
||||
System.Windows.Forms.Form frm = (System.Windows.Forms.Form) ctrl.TopLevelControl;
|
||||
System.Windows.Forms.Form frm = (System.Windows.Forms.Form)ctrl.TopLevelControl;
|
||||
|
||||
System.Drawing.Point loc =
|
||||
frm.PointToClient(ctrl.PointToScreen(System.Drawing.Point.Empty));
|
||||
System.Drawing.Point loc = frm.PointToClient(ctrl.PointToScreen(System.Drawing.Point.Empty));
|
||||
|
||||
rect.X = (short)loc.X;
|
||||
rect.Y = (short)loc.Y;
|
||||
|
@ -276,6 +269,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
windowPort = API.GetWindowPort(controlOwner);
|
||||
}
|
||||
|
||||
else
|
||||
windowPort = API.GetWindowPort(carbonWindow.WindowRef);
|
||||
|
||||
|
@ -297,6 +291,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
else if (carbonWindow.GoWindowedHack)
|
||||
{
|
||||
carbonWindow.GoWindowedHack = false;
|
||||
|
@ -324,8 +319,9 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
if (r.IsAlive)
|
||||
{
|
||||
return (CarbonGLNative) r.Target;
|
||||
return (CarbonGLNative)r.Target;
|
||||
}
|
||||
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
@ -335,9 +331,7 @@ namespace OpenTK.Platform.MacOS
|
|||
Agl.AglError err = Agl.GetError();
|
||||
|
||||
if (err != Agl.AglError.NoError)
|
||||
throw new MacOSException((OSStatus)err, string.Format(
|
||||
"AGL Error from function {0}: {1} {2}",
|
||||
function, err, Agl.ErrorString(err)));
|
||||
throw new MacOSException((OSStatus)err, string.Format("AGL Error from function {0}: {1} {2}", function, err, Agl.ErrorString(err)));
|
||||
}
|
||||
|
||||
bool firstFullScreen = false;
|
||||
|
@ -346,8 +340,7 @@ namespace OpenTK.Platform.MacOS
|
|||
{
|
||||
CarbonGLNative wind = GetCarbonWindow(info);
|
||||
|
||||
Debug.Print("Switching to full screen {0}x{1} on context {2}",
|
||||
wind.TargetDisplayDevice.Width, wind.TargetDisplayDevice.Height, Handle.Handle);
|
||||
Debug.Print("Switching to full screen {0}x{1} on context {2}", wind.TargetDisplayDevice.Width, wind.TargetDisplayDevice.Height, Handle.Handle);
|
||||
|
||||
CG.DisplayCapture(GetQuartzDevice(info));
|
||||
Agl.aglSetFullScreen(Handle.Handle, wind.TargetDisplayDevice.Width, wind.TargetDisplayDevice.Height, 0, 0);
|
||||
|
@ -409,18 +402,12 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
public override bool IsCurrent
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Handle.Handle == Agl.aglGetCurrentContext());
|
||||
}
|
||||
get { return (Handle.Handle == Agl.aglGetCurrentContext()); }
|
||||
}
|
||||
|
||||
public override bool VSync
|
||||
{
|
||||
get
|
||||
{
|
||||
return mVSync;
|
||||
}
|
||||
get { return mVSync; }
|
||||
set
|
||||
{
|
||||
int intVal = value ? 1 : 0;
|
||||
|
|
|
@ -27,9 +27,10 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
Initialize();
|
||||
}
|
||||
|
||||
internal static void Initialize()
|
||||
static internal void Initialize()
|
||||
{
|
||||
if (mInitialized) return;
|
||||
if (mInitialized)
|
||||
return;
|
||||
|
||||
API.AcquireRootMenu();
|
||||
|
||||
|
@ -55,7 +56,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
API.SetFrontProcess(ref psn);
|
||||
}
|
||||
|
||||
internal static CarbonGLNative WindowEventHandler
|
||||
static internal CarbonGLNative WindowEventHandler
|
||||
{
|
||||
get { return eventHandler; }
|
||||
set { eventHandler = value; }
|
||||
|
@ -63,33 +64,16 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
|
||||
static void ConnectEvents()
|
||||
{
|
||||
EventTypeSpec[] eventTypes = new EventTypeSpec[]
|
||||
{
|
||||
new EventTypeSpec(EventClass.Application, AppEventKind.AppActivated),
|
||||
new EventTypeSpec(EventClass.Application, AppEventKind.AppDeactivated),
|
||||
new EventTypeSpec(EventClass.Application, AppEventKind.AppQuit),
|
||||
|
||||
new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseDown),
|
||||
new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseUp),
|
||||
new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseMoved),
|
||||
new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseDragged),
|
||||
new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseEntered),
|
||||
new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseExited),
|
||||
new EventTypeSpec(EventClass.Mouse, MouseEventKind.WheelMoved),
|
||||
EventTypeSpec[] eventTypes = new EventTypeSpec[] { new EventTypeSpec(EventClass.Application, AppEventKind.AppActivated), new EventTypeSpec(EventClass.Application, AppEventKind.AppDeactivated), new EventTypeSpec(EventClass.Application, AppEventKind.AppQuit), new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseDown), new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseUp), new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseMoved), new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseDragged), new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseEntered), new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseExited), new EventTypeSpec(EventClass.Mouse, MouseEventKind.WheelMoved),
|
||||
|
||||
new EventTypeSpec(EventClass.Keyboard, KeyboardEventKind.RawKeyDown),
|
||||
new EventTypeSpec(EventClass.Keyboard, KeyboardEventKind.RawKeyRepeat),
|
||||
new EventTypeSpec(EventClass.Keyboard, KeyboardEventKind.RawKeyUp),
|
||||
new EventTypeSpec(EventClass.Keyboard, KeyboardEventKind.RawKeyModifiersChanged),
|
||||
|
||||
new EventTypeSpec(EventClass.AppleEvent, AppleEventKind.AppleEvent),
|
||||
};
|
||||
new EventTypeSpec(EventClass.Keyboard, KeyboardEventKind.RawKeyDown), new EventTypeSpec(EventClass.Keyboard, KeyboardEventKind.RawKeyRepeat), new EventTypeSpec(EventClass.Keyboard, KeyboardEventKind.RawKeyUp), new EventTypeSpec(EventClass.Keyboard, KeyboardEventKind.RawKeyModifiersChanged), new EventTypeSpec(EventClass.AppleEvent, AppleEventKind.AppleEvent) };
|
||||
|
||||
MacOSEventHandler handler = EventHandler;
|
||||
uppHandler = API.NewEventHandlerUPP(handler);
|
||||
|
||||
API.InstallApplicationEventHandler(
|
||||
uppHandler, eventTypes, IntPtr.Zero, IntPtr.Zero);
|
||||
API.InstallApplicationEventHandler(uppHandler, eventTypes, IntPtr.Zero, IntPtr.Zero);
|
||||
|
||||
mInitialized = true;
|
||||
}
|
||||
|
@ -107,6 +91,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
return OSStatus.EventNotHandled;
|
||||
}
|
||||
|
||||
|
||||
case EventClass.AppleEvent:
|
||||
// only event here is the apple event.
|
||||
Debug.Print("Processing apple event.");
|
||||
|
@ -119,6 +104,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
{
|
||||
return WindowEventHandler.DispatchEvent(inCaller, inEvent, evt, userData);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -142,7 +128,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
}
|
||||
|
||||
|
||||
internal static void ProcessEvents()
|
||||
static internal void ProcessEvents()
|
||||
{
|
||||
API.ProcessEvents();
|
||||
}
|
||||
|
|
|
@ -75,8 +75,14 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
#region AGL Device Hack
|
||||
|
||||
static internal Dictionary<IntPtr, WeakReference> WindowRefMap { get { return mWindows; } }
|
||||
internal DisplayDevice TargetDisplayDevice { get { return mDisplayDevice; } }
|
||||
static internal Dictionary<IntPtr, WeakReference> WindowRefMap
|
||||
{
|
||||
get { return mWindows; }
|
||||
}
|
||||
internal DisplayDevice TargetDisplayDevice
|
||||
{
|
||||
get { return mDisplayDevice; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -87,13 +93,9 @@ namespace OpenTK.Platform.MacOS
|
|||
Application.Initialize();
|
||||
}
|
||||
|
||||
CarbonGLNative()
|
||||
: this(WindowClass.Document,
|
||||
WindowAttributes.StandardDocument |
|
||||
WindowAttributes.StandardHandler |
|
||||
WindowAttributes.InWindowMenu |
|
||||
WindowAttributes.LiveResize)
|
||||
{ }
|
||||
CarbonGLNative() : this(WindowClass.Document, WindowAttributes.StandardDocument | WindowAttributes.StandardHandler | WindowAttributes.InWindowMenu | WindowAttributes.LiveResize)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
CarbonGLNative(WindowClass @class, WindowAttributes attrib)
|
||||
|
@ -104,10 +106,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
public CarbonGLNative(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
|
||||
{
|
||||
CreateNativeWindow(WindowClass.Document,
|
||||
WindowAttributes.StandardDocument | WindowAttributes.StandardHandler |
|
||||
WindowAttributes.InWindowMenu | WindowAttributes.LiveResize,
|
||||
new Rect((short)x, (short)y, (short)width, (short)height));
|
||||
CreateNativeWindow(WindowClass.Document, WindowAttributes.StandardDocument | WindowAttributes.StandardHandler | WindowAttributes.InWindowMenu | WindowAttributes.LiveResize, new Rect((short)x, (short)y, (short)width, (short)height));
|
||||
|
||||
mDisplayDevice = device;
|
||||
}
|
||||
|
@ -201,13 +200,6 @@ namespace OpenTK.Platform.MacOS
|
|||
{
|
||||
mInputDriver = new CarbonInput();
|
||||
|
||||
EventTypeSpec[] eventTypes = new EventTypeSpec[]
|
||||
{
|
||||
new EventTypeSpec(EventClass.Window, WindowEventKind.WindowClose),
|
||||
new EventTypeSpec(EventClass.Window, WindowEventKind.WindowClosed),
|
||||
new EventTypeSpec(EventClass.Window, WindowEventKind.WindowBoundsChanged),
|
||||
new EventTypeSpec(EventClass.Window, WindowEventKind.WindowActivate),
|
||||
new EventTypeSpec(EventClass.Window, WindowEventKind.WindowDeactivate),
|
||||
|
||||
//new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseDown),
|
||||
//new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseUp),
|
||||
|
@ -221,7 +213,7 @@ namespace OpenTK.Platform.MacOS
|
|||
//new EventTypeSpec(EventClass.Keyboard, KeyboardEventKind.RawKeyRepeat),
|
||||
//new EventTypeSpec(EventClass.Keyboard, KeyboardEventKind.RawKeyUp),
|
||||
//new EventTypeSpec(EventClass.Keyboard, KeyboardEventKind.RawKeyModifiersChanged),
|
||||
};
|
||||
EventTypeSpec[] eventTypes = new EventTypeSpec[] { new EventTypeSpec(EventClass.Window, WindowEventKind.WindowClose), new EventTypeSpec(EventClass.Window, WindowEventKind.WindowClosed), new EventTypeSpec(EventClass.Window, WindowEventKind.WindowBoundsChanged), new EventTypeSpec(EventClass.Window, WindowEventKind.WindowActivate), new EventTypeSpec(EventClass.Window, WindowEventKind.WindowDeactivate) };
|
||||
|
||||
MacOSEventHandler handler = EventHandler;
|
||||
uppHandler = API.NewEventHandlerUPP(handler);
|
||||
|
@ -302,8 +294,8 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
case EventClass.Keyboard:
|
||||
return ProcessKeyboardEvent(inCaller, inEvent, evt, userData);
|
||||
|
||||
default:
|
||||
|
||||
return OSStatus.EventNotHandled;
|
||||
}
|
||||
}
|
||||
|
@ -345,8 +337,8 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
case EventClass.Keyboard:
|
||||
return window.ProcessKeyboardEvent(inCaller, inEvent, evt, userData);
|
||||
|
||||
default:
|
||||
|
||||
return OSStatus.EventNotHandled;
|
||||
}
|
||||
}
|
||||
|
@ -388,8 +380,8 @@ namespace OpenTK.Platform.MacOS
|
|||
case KeyboardEventKind.RawKeyModifiersChanged:
|
||||
ProcessModifierKey(inEvent);
|
||||
return OSStatus.NoError;
|
||||
|
||||
default:
|
||||
|
||||
return OSStatus.EventNotHandled;
|
||||
}
|
||||
|
||||
|
@ -440,8 +432,8 @@ namespace OpenTK.Platform.MacOS
|
|||
case WindowEventKind.WindowDeactivate:
|
||||
OnDeactivate();
|
||||
return OSStatus.EventNotHandled;
|
||||
|
||||
default:
|
||||
|
||||
Debug.Print("{0}", evt);
|
||||
|
||||
return OSStatus.EventNotHandled;
|
||||
|
@ -460,6 +452,7 @@ namespace OpenTK.Platform.MacOS
|
|||
{
|
||||
pt = screenLoc;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
err = API.GetEventWindowMouseLocation(inEvent, out pt);
|
||||
|
@ -506,6 +499,7 @@ namespace OpenTK.Platform.MacOS
|
|||
}
|
||||
|
||||
|
||||
|
||||
return OSStatus.NoError;
|
||||
|
||||
case MouseEventKind.MouseUp:
|
||||
|
@ -526,6 +520,7 @@ namespace OpenTK.Platform.MacOS
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
button = API.GetEventMouseButton(inEvent);
|
||||
|
||||
return OSStatus.NoError;
|
||||
|
@ -545,28 +540,28 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
if (this.windowState == WindowState.Fullscreen)
|
||||
{
|
||||
if (mousePosInClient.X != InputDriver.Mouse[0].X ||
|
||||
mousePosInClient.Y != InputDriver.Mouse[0].Y)
|
||||
if (mousePosInClient.X != InputDriver.Mouse[0].X || mousePosInClient.Y != InputDriver.Mouse[0].Y)
|
||||
{
|
||||
InputDriver.Mouse[0].Position = mousePosInClient;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// ignore clicks in the title bar
|
||||
if (pt.Y < 0)
|
||||
return OSStatus.EventNotHandled;
|
||||
|
||||
if (mousePosInClient.X != InputDriver.Mouse[0].X ||
|
||||
mousePosInClient.Y != InputDriver.Mouse[0].Y)
|
||||
if (mousePosInClient.X != InputDriver.Mouse[0].X || mousePosInClient.Y != InputDriver.Mouse[0].Y)
|
||||
{
|
||||
InputDriver.Mouse[0].Position = mousePosInClient;
|
||||
}
|
||||
}
|
||||
|
||||
return OSStatus.EventNotHandled;
|
||||
|
||||
return OSStatus.EventNotHandled;
|
||||
default:
|
||||
|
||||
Debug.Print("{0}", evt);
|
||||
|
||||
return OSStatus.EventNotHandled;
|
||||
|
@ -721,10 +716,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
public OpenTK.Input.IInputDriver InputDriver
|
||||
{
|
||||
get
|
||||
{
|
||||
return mInputDriver;
|
||||
}
|
||||
get { return mInputDriver; }
|
||||
}
|
||||
|
||||
|
||||
|
@ -751,6 +743,7 @@ namespace OpenTK.Platform.MacOS
|
|||
{
|
||||
API.RestoreApplicationDockTileImage();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
Bitmap bitmap;
|
||||
|
@ -780,6 +773,7 @@ namespace OpenTK.Platform.MacOS
|
|||
byte b = (byte)(pixel & 0xFF);
|
||||
data[index++] = (IntPtr)(a + (r << 8) + (g << 16) + (b << 24));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
data[index++] = (IntPtr)pixel;
|
||||
|
@ -788,17 +782,15 @@ namespace OpenTK.Platform.MacOS
|
|||
}
|
||||
|
||||
IntPtr provider = API.CGDataProviderCreateWithData(IntPtr.Zero, data, size * 4, IntPtr.Zero);
|
||||
IntPtr image = API.CGImageCreate(128, 128, 8, 32, 4 * 128, API.CGColorSpaceCreateDeviceRGB(), 4, provider, IntPtr.Zero, 0, 0);
|
||||
IntPtr image = API.CGImageCreate(128, 128, 8, 32, 4 * 128, API.CGColorSpaceCreateDeviceRGB(), 4, provider, IntPtr.Zero, 0,
|
||||
0);
|
||||
API.SetApplicationDockTileImage(image);
|
||||
}
|
||||
}
|
||||
|
||||
public string Title
|
||||
{
|
||||
get
|
||||
{
|
||||
return title;
|
||||
}
|
||||
get { return title; }
|
||||
set
|
||||
{
|
||||
if (value != Title)
|
||||
|
@ -833,12 +825,9 @@ namespace OpenTK.Platform.MacOS
|
|||
}
|
||||
|
||||
public Rectangle Bounds
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return bounds;
|
||||
}
|
||||
get { return bounds; }
|
||||
set
|
||||
{
|
||||
Location = value.Location;
|
||||
|
@ -848,26 +837,14 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
public Point Location
|
||||
{
|
||||
get
|
||||
{
|
||||
return Bounds.Location;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetLocation((short)value.X, (short)value.Y);
|
||||
}
|
||||
get { return Bounds.Location; }
|
||||
set { SetLocation((short)value.X, (short)value.Y); }
|
||||
}
|
||||
|
||||
public Size Size
|
||||
{
|
||||
get
|
||||
{
|
||||
return bounds.Size;
|
||||
}
|
||||
set
|
||||
{
|
||||
SetSize((short)value.Width, (short)value.Height);
|
||||
}
|
||||
get { return bounds.Size; }
|
||||
set { SetSize((short)value.Width, (short)value.Height); }
|
||||
}
|
||||
|
||||
public int Width
|
||||
|
@ -884,48 +861,27 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
public int X
|
||||
{
|
||||
get
|
||||
{
|
||||
return ClientRectangle.X;
|
||||
}
|
||||
set
|
||||
{
|
||||
Location = new Point(value, Y);
|
||||
}
|
||||
get { return ClientRectangle.X; }
|
||||
set { Location = new Point(value, Y); }
|
||||
}
|
||||
|
||||
public int Y
|
||||
{
|
||||
get
|
||||
{
|
||||
return ClientRectangle.Y;
|
||||
}
|
||||
set
|
||||
{
|
||||
Location = new Point(X, value);
|
||||
}
|
||||
get { return ClientRectangle.Y; }
|
||||
set { Location = new Point(X, value); }
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
get { return clientRectangle; }
|
||||
// just set the size, and ignore the location value.
|
||||
// this is the behavior of the Windows WinGLNative.
|
||||
set { ClientSize = value.Size; }
|
||||
}
|
||||
|
||||
public Size ClientSize
|
||||
{
|
||||
get
|
||||
{
|
||||
return clientRectangle.Size;
|
||||
}
|
||||
get { return clientRectangle.Size; }
|
||||
set
|
||||
{
|
||||
API.SizeWindow(window.WindowRef, (short)value.Width, (short)value.Height, true);
|
||||
|
@ -1023,6 +979,7 @@ namespace OpenTK.Platform.MacOS
|
|||
idealSize = new CarbonPoint();
|
||||
API.ZoomWindowIdeal(window.WindowRef, WindowPartCode.inZoomIn, ref idealSize);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case WindowState.Minimized:
|
||||
|
@ -1039,10 +996,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
public WindowBorder WindowBorder
|
||||
{
|
||||
get
|
||||
{
|
||||
return windowBorder;
|
||||
}
|
||||
get { return windowBorder; }
|
||||
set
|
||||
{
|
||||
if (windowBorder == value)
|
||||
|
@ -1052,13 +1006,12 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
if (windowBorder == WindowBorder.Resizable)
|
||||
{
|
||||
API.ChangeWindowAttributes(window.WindowRef, WindowAttributes.Resizable | WindowAttributes.FullZoom,
|
||||
WindowAttributes.NoAttributes);
|
||||
API.ChangeWindowAttributes(window.WindowRef, WindowAttributes.Resizable | WindowAttributes.FullZoom, WindowAttributes.NoAttributes);
|
||||
}
|
||||
|
||||
else if (windowBorder == WindowBorder.Fixed)
|
||||
{
|
||||
API.ChangeWindowAttributes(window.WindowRef, WindowAttributes.NoAttributes,
|
||||
WindowAttributes.Resizable | WindowAttributes.FullZoom);
|
||||
API.ChangeWindowAttributes(window.WindowRef, WindowAttributes.NoAttributes, WindowAttributes.Resizable | WindowAttributes.FullZoom);
|
||||
}
|
||||
|
||||
WindowBorderChanged(this, EventArgs.Empty);
|
||||
|
|
|
@ -65,17 +65,26 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
public IMouseDriver2 MouseDriver
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public IKeyboardDriver2 KeyboardDriver
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public IGamePadDriver GamePadDriver
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
get
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,8 +96,7 @@ namespace OpenTK.Platform.MacOS
|
|||
/// <returns>A System.String that represents the current window.</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
return String.Format("MacOS.CarbonWindowInfo: Handle {0}",
|
||||
this.WindowRef);
|
||||
return String.Format("MacOS.CarbonWindowInfo: Handle {0}", this.WindowRef);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -25,14 +25,17 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
uint _eventKind;
|
||||
EventClass _eventClass;
|
||||
|
||||
public EventClass EventClass { get { return _eventClass; }}
|
||||
public EventClass EventClass
|
||||
{
|
||||
get { return _eventClass; }
|
||||
}
|
||||
|
||||
public WindowEventKind WindowEventKind
|
||||
{
|
||||
get
|
||||
{
|
||||
if (EventClass == EventClass.Window)
|
||||
return (WindowEventKind) _eventKind;
|
||||
return (WindowEventKind)_eventKind;
|
||||
else
|
||||
throw new InvalidCastException("Event is not a Window event.");
|
||||
}
|
||||
|
@ -42,7 +45,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
get
|
||||
{
|
||||
if (EventClass == EventClass.Keyboard)
|
||||
return (KeyboardEventKind) _eventKind;
|
||||
return (KeyboardEventKind)_eventKind;
|
||||
else
|
||||
throw new InvalidCastException("Event is not a Keyboard event.");
|
||||
}
|
||||
|
@ -52,7 +55,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
get
|
||||
{
|
||||
if (EventClass == EventClass.Mouse)
|
||||
return (MouseEventKind) _eventKind;
|
||||
return (MouseEventKind)_eventKind;
|
||||
else
|
||||
throw new InvalidCastException("Event is not an Mouse event.");
|
||||
}
|
||||
|
@ -62,7 +65,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
get
|
||||
{
|
||||
if (EventClass == EventClass.Application)
|
||||
return (AppEventKind) _eventKind;
|
||||
return (AppEventKind)_eventKind;
|
||||
else
|
||||
throw new InvalidCastException("Event is not an Application event.");
|
||||
}
|
||||
|
@ -71,7 +74,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
|
||||
public override string ToString()
|
||||
{
|
||||
switch(EventClass)
|
||||
switch (EventClass)
|
||||
{
|
||||
case EventClass.Application:
|
||||
return "Event: App " + AppEventKind.ToString();
|
||||
|
|
|
@ -12,8 +12,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
public GraphicsMode SelectGraphicsMode(ColorFormat color, int depth, int stencil, int samples, ColorFormat accum, int buffers, bool stereo)
|
||||
{
|
||||
GraphicsMode gfx = new GraphicsMode((IntPtr)1, color, depth, stencil, samples,
|
||||
accum, buffers, stereo);
|
||||
GraphicsMode gfx = new GraphicsMode((IntPtr)1, color, depth, stencil, samples, accum, buffers, stereo);
|
||||
|
||||
System.Diagnostics.Debug.Print("Created dummy graphics mode.");
|
||||
|
||||
|
|
|
@ -11,11 +11,13 @@ namespace OpenTK.Platform.MacOS
|
|||
{
|
||||
static object display_lock = new object();
|
||||
|
||||
static Dictionary<DisplayDevice, IntPtr> displayMap =
|
||||
new Dictionary<DisplayDevice, IntPtr>();
|
||||
static Dictionary<DisplayDevice, IntPtr> displayMap = new Dictionary<DisplayDevice, IntPtr>();
|
||||
|
||||
static IntPtr mainDisplay;
|
||||
internal static IntPtr MainDisplay { get { return mainDisplay; } }
|
||||
static internal IntPtr MainDisplay
|
||||
{
|
||||
get { return mainDisplay; }
|
||||
}
|
||||
|
||||
static QuartzDisplayDeviceDriver()
|
||||
{
|
||||
|
@ -33,7 +35,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
unsafe
|
||||
{
|
||||
fixed(IntPtr* displayPtr = displays)
|
||||
fixed (IntPtr* displayPtr = displays)
|
||||
{
|
||||
CG.GetActiveDisplayList(maxDisplayCount, displayPtr, out displayCount);
|
||||
}
|
||||
|
@ -71,9 +73,9 @@ namespace OpenTK.Platform.MacOS
|
|||
{
|
||||
CFDictionary dict = new CFDictionary(displayModes[j]);
|
||||
|
||||
int width = (int) dict.GetNumberValue("Width");
|
||||
int height = (int) dict.GetNumberValue("Height");
|
||||
int bpp = (int) dict.GetNumberValue("BitsPerPixel");
|
||||
int width = (int)dict.GetNumberValue("Width");
|
||||
int height = (int)dict.GetNumberValue("Height");
|
||||
int bpp = (int)dict.GetNumberValue("BitsPerPixel");
|
||||
double freq = dict.GetNumberValue("RefreshRate");
|
||||
bool current = currentMode.Ref == dict.Ref;
|
||||
|
||||
|
@ -91,13 +93,11 @@ namespace OpenTK.Platform.MacOS
|
|||
}
|
||||
|
||||
HIRect bounds = CG.DisplayBounds(currentDisplay);
|
||||
Rectangle newRect = new Rectangle(
|
||||
(int)bounds.Origin.X, (int)bounds.Origin.Y, (int)bounds.Size.Width, (int)bounds.Size.Height);
|
||||
Rectangle newRect = new Rectangle((int)bounds.Origin.X, (int)bounds.Origin.Y, (int)bounds.Size.Width, (int)bounds.Size.Height);
|
||||
|
||||
Debug.Print("Display {0} bounds: {1}", i, newRect);
|
||||
|
||||
DisplayDevice opentk_dev =
|
||||
new DisplayDevice(opentk_dev_current_res, primary, opentk_dev_available_res, newRect);
|
||||
DisplayDevice opentk_dev = new DisplayDevice(opentk_dev_current_res, primary, opentk_dev_available_res, newRect);
|
||||
|
||||
displayMap.Add(opentk_dev, currentDisplay);
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ namespace OpenTK.Platform.MacOS
|
|||
}
|
||||
|
||||
|
||||
internal static IntPtr HandleTo(DisplayDevice displayDevice)
|
||||
static internal IntPtr HandleTo(DisplayDevice displayDevice)
|
||||
{
|
||||
if (displayMap.ContainsKey(displayDevice))
|
||||
return displayMap[displayDevice];
|
||||
|
@ -142,10 +142,7 @@ namespace OpenTK.Platform.MacOS
|
|||
int bpp = (int)dict.GetNumberValue("BitsPerPixel");
|
||||
double freq = dict.GetNumberValue("RefreshRate");
|
||||
|
||||
if (width == resolution.Width &&
|
||||
height == resolution.Height &&
|
||||
bpp == resolution.BitsPerPixel &&
|
||||
System.Math.Abs(freq - resolution.RefreshRate) < 1e-6)
|
||||
if (width == resolution.Width && height == resolution.Height && bpp == resolution.BitsPerPixel && System.Math.Abs(freq - resolution.RefreshRate) < 1e-6)
|
||||
{
|
||||
if (displaysCaptured.Contains(display) == false)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue