* 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:
the_fiddler 2010-11-02 19:49:24 +00:00
parent bde71543f5
commit 7e344e2ac2
10 changed files with 882 additions and 949 deletions

View file

@ -47,8 +47,7 @@ namespace OpenTK.Platform.MacOS
shareContextRef = ((AglContext)shareContext).Handle.Handle; shareContextRef = ((AglContext)shareContext).Handle.Handle;
if (shareContext is GraphicsContext) if (shareContext is GraphicsContext)
{ {
ContextHandle shareHandle = shareContext != null ? ContextHandle shareHandle = shareContext != null ? (shareContext as IGraphicsContextInternal).Context : (ContextHandle)IntPtr.Zero;
(shareContext as IGraphicsContextInternal).Context : (ContextHandle)IntPtr.Zero;
shareContextRef = shareHandle.Handle; shareContextRef = shareHandle.Handle;
} }
@ -86,8 +85,7 @@ namespace OpenTK.Platform.MacOS
aglAttributes.Add((int)pixelFormatAttribute); aglAttributes.Add((int)pixelFormatAttribute);
aglAttributes.Add(value); aglAttributes.Add(value);
} }
void CreateContext(GraphicsMode mode, CarbonWindowInfo carbonWindow, void CreateContext(GraphicsMode mode, CarbonWindowInfo carbonWindow, IntPtr shareContextRef, bool fullscreen)
IntPtr shareContextRef, bool fullscreen)
{ {
List<int> aglAttributes = new List<int>(); List<int> aglAttributes = new List<int>();
@ -145,15 +143,12 @@ namespace OpenTK.Platform.MacOS
if (cgdevice == IntPtr.Zero) if (cgdevice == IntPtr.Zero)
cgdevice = QuartzDisplayDeviceDriver.MainDisplay; cgdevice = QuartzDisplayDeviceDriver.MainDisplay;
OSStatus status = Carbon.API.DMGetGDeviceByDisplayID( OSStatus status = Carbon.API.DMGetGDeviceByDisplayID(cgdevice, out gdevice, false);
cgdevice, out gdevice, false);
if (status != OSStatus.NoError) if (status != OSStatus.NoError)
throw new MacOSException(status, "DMGetGDeviceByDisplayID failed."); throw new MacOSException(status, "DMGetGDeviceByDisplayID failed.");
myAGLPixelFormat = Agl.aglChoosePixelFormat( myAGLPixelFormat = Agl.aglChoosePixelFormat(ref gdevice, 1, aglAttributes.ToArray());
ref gdevice, 1,
aglAttributes.ToArray());
Agl.AglError err = Agl.GetError(); Agl.AglError err = Agl.GetError();
@ -166,11 +161,10 @@ namespace OpenTK.Platform.MacOS
return; return;
} }
} }
else else
{ {
myAGLPixelFormat = Agl.aglChoosePixelFormat( myAGLPixelFormat = Agl.aglChoosePixelFormat(IntPtr.Zero, 0, aglAttributes.ToArray());
IntPtr.Zero, 0,
aglAttributes.ToArray());
MyAGLReportError("aglChoosePixelFormat"); MyAGLReportError("aglChoosePixelFormat");
} }
@ -179,7 +173,7 @@ namespace OpenTK.Platform.MacOS
Debug.Print("Creating AGL context. Sharing with {0}", shareContextRef); Debug.Print("Creating AGL context. Sharing with {0}", shareContextRef);
// create the context and share it with the share reference. // 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"); MyAGLReportError("aglCreateContext");
// Free the pixel format from memory. // Free the pixel format from memory.
@ -228,10 +222,9 @@ namespace OpenTK.Platform.MacOS
return; return;
Rect rect = API.GetControlBounds(carbonWindow.WindowRef); 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 = System.Drawing.Point loc = frm.PointToClient(ctrl.PointToScreen(System.Drawing.Point.Empty));
frm.PointToClient(ctrl.PointToScreen(System.Drawing.Point.Empty));
rect.X = (short)loc.X; rect.X = (short)loc.X;
rect.Y = (short)loc.Y; rect.Y = (short)loc.Y;
@ -276,6 +269,7 @@ namespace OpenTK.Platform.MacOS
windowPort = API.GetWindowPort(controlOwner); windowPort = API.GetWindowPort(controlOwner);
} }
else else
windowPort = API.GetWindowPort(carbonWindow.WindowRef); windowPort = API.GetWindowPort(carbonWindow.WindowRef);
@ -297,6 +291,7 @@ namespace OpenTK.Platform.MacOS
return; return;
} }
else if (carbonWindow.GoWindowedHack) else if (carbonWindow.GoWindowedHack)
{ {
carbonWindow.GoWindowedHack = false; carbonWindow.GoWindowedHack = false;
@ -324,8 +319,9 @@ namespace OpenTK.Platform.MacOS
if (r.IsAlive) if (r.IsAlive)
{ {
return (CarbonGLNative) r.Target; return (CarbonGLNative)r.Target;
} }
else else
return null; return null;
} }
@ -335,9 +331,7 @@ namespace OpenTK.Platform.MacOS
Agl.AglError err = Agl.GetError(); Agl.AglError err = Agl.GetError();
if (err != Agl.AglError.NoError) if (err != Agl.AglError.NoError)
throw new MacOSException((OSStatus)err, string.Format( throw new MacOSException((OSStatus)err, string.Format("AGL Error from function {0}: {1} {2}", function, err, Agl.ErrorString(err)));
"AGL Error from function {0}: {1} {2}",
function, err, Agl.ErrorString(err)));
} }
bool firstFullScreen = false; bool firstFullScreen = false;
@ -346,8 +340,7 @@ namespace OpenTK.Platform.MacOS
{ {
CarbonGLNative wind = GetCarbonWindow(info); CarbonGLNative wind = GetCarbonWindow(info);
Debug.Print("Switching to full screen {0}x{1} on context {2}", Debug.Print("Switching to full screen {0}x{1} on context {2}", wind.TargetDisplayDevice.Width, wind.TargetDisplayDevice.Height, Handle.Handle);
wind.TargetDisplayDevice.Width, wind.TargetDisplayDevice.Height, Handle.Handle);
CG.DisplayCapture(GetQuartzDevice(info)); CG.DisplayCapture(GetQuartzDevice(info));
Agl.aglSetFullScreen(Handle.Handle, wind.TargetDisplayDevice.Width, wind.TargetDisplayDevice.Height, 0, 0); Agl.aglSetFullScreen(Handle.Handle, wind.TargetDisplayDevice.Width, wind.TargetDisplayDevice.Height, 0, 0);
@ -409,18 +402,12 @@ namespace OpenTK.Platform.MacOS
public override bool IsCurrent public override bool IsCurrent
{ {
get get { return (Handle.Handle == Agl.aglGetCurrentContext()); }
{
return (Handle.Handle == Agl.aglGetCurrentContext());
}
} }
public override bool VSync public override bool VSync
{ {
get get { return mVSync; }
{
return mVSync;
}
set set
{ {
int intVal = value ? 1 : 0; int intVal = value ? 1 : 0;

View file

@ -27,9 +27,10 @@ namespace OpenTK.Platform.MacOS.Carbon
Initialize(); Initialize();
} }
internal static void Initialize() static internal void Initialize()
{ {
if (mInitialized) return; if (mInitialized)
return;
API.AcquireRootMenu(); API.AcquireRootMenu();
@ -55,7 +56,7 @@ namespace OpenTK.Platform.MacOS.Carbon
API.SetFrontProcess(ref psn); API.SetFrontProcess(ref psn);
} }
internal static CarbonGLNative WindowEventHandler static internal CarbonGLNative WindowEventHandler
{ {
get { return eventHandler; } get { return eventHandler; }
set { eventHandler = value; } set { eventHandler = value; }
@ -63,33 +64,16 @@ namespace OpenTK.Platform.MacOS.Carbon
static void ConnectEvents() 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), 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.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; MacOSEventHandler handler = EventHandler;
uppHandler = API.NewEventHandlerUPP(handler); uppHandler = API.NewEventHandlerUPP(handler);
API.InstallApplicationEventHandler( API.InstallApplicationEventHandler(uppHandler, eventTypes, IntPtr.Zero, IntPtr.Zero);
uppHandler, eventTypes, IntPtr.Zero, IntPtr.Zero);
mInitialized = true; mInitialized = true;
} }
@ -107,6 +91,7 @@ namespace OpenTK.Platform.MacOS.Carbon
return OSStatus.EventNotHandled; return OSStatus.EventNotHandled;
} }
case EventClass.AppleEvent: case EventClass.AppleEvent:
// only event here is the apple event. // only event here is the apple event.
Debug.Print("Processing apple event."); Debug.Print("Processing apple event.");
@ -119,6 +104,7 @@ namespace OpenTK.Platform.MacOS.Carbon
{ {
return WindowEventHandler.DispatchEvent(inCaller, inEvent, evt, userData); return WindowEventHandler.DispatchEvent(inCaller, inEvent, evt, userData);
} }
break; break;
} }
@ -142,7 +128,7 @@ namespace OpenTK.Platform.MacOS.Carbon
} }
internal static void ProcessEvents() static internal void ProcessEvents()
{ {
API.ProcessEvents(); API.ProcessEvents();
} }

View file

@ -75,8 +75,14 @@ namespace OpenTK.Platform.MacOS
#region AGL Device Hack #region AGL Device Hack
static internal Dictionary<IntPtr, WeakReference> WindowRefMap { get { return mWindows; } } static internal Dictionary<IntPtr, WeakReference> WindowRefMap
internal DisplayDevice TargetDisplayDevice { get { return mDisplayDevice; } } {
get { return mWindows; }
}
internal DisplayDevice TargetDisplayDevice
{
get { return mDisplayDevice; }
}
#endregion #endregion
@ -87,13 +93,9 @@ namespace OpenTK.Platform.MacOS
Application.Initialize(); Application.Initialize();
} }
CarbonGLNative() CarbonGLNative() : this(WindowClass.Document, WindowAttributes.StandardDocument | WindowAttributes.StandardHandler | WindowAttributes.InWindowMenu | WindowAttributes.LiveResize)
: this(WindowClass.Document, {
WindowAttributes.StandardDocument | }
WindowAttributes.StandardHandler |
WindowAttributes.InWindowMenu |
WindowAttributes.LiveResize)
{ }
CarbonGLNative(WindowClass @class, WindowAttributes attrib) 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) public CarbonGLNative(int x, int y, int width, int height, string title, GraphicsMode mode, GameWindowFlags options, DisplayDevice device)
{ {
CreateNativeWindow(WindowClass.Document, CreateNativeWindow(WindowClass.Document, WindowAttributes.StandardDocument | WindowAttributes.StandardHandler | WindowAttributes.InWindowMenu | WindowAttributes.LiveResize, new Rect((short)x, (short)y, (short)width, (short)height));
WindowAttributes.StandardDocument | WindowAttributes.StandardHandler |
WindowAttributes.InWindowMenu | WindowAttributes.LiveResize,
new Rect((short)x, (short)y, (short)width, (short)height));
mDisplayDevice = device; mDisplayDevice = device;
} }
@ -201,13 +200,6 @@ namespace OpenTK.Platform.MacOS
{ {
mInputDriver = new CarbonInput(); 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.MouseDown),
//new EventTypeSpec(EventClass.Mouse, MouseEventKind.MouseUp), //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.RawKeyRepeat),
//new EventTypeSpec(EventClass.Keyboard, KeyboardEventKind.RawKeyUp), //new EventTypeSpec(EventClass.Keyboard, KeyboardEventKind.RawKeyUp),
//new EventTypeSpec(EventClass.Keyboard, KeyboardEventKind.RawKeyModifiersChanged), //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; MacOSEventHandler handler = EventHandler;
uppHandler = API.NewEventHandlerUPP(handler); uppHandler = API.NewEventHandlerUPP(handler);
@ -302,8 +294,8 @@ namespace OpenTK.Platform.MacOS
case EventClass.Keyboard: case EventClass.Keyboard:
return ProcessKeyboardEvent(inCaller, inEvent, evt, userData); return ProcessKeyboardEvent(inCaller, inEvent, evt, userData);
default: default:
return OSStatus.EventNotHandled; return OSStatus.EventNotHandled;
} }
} }
@ -345,8 +337,8 @@ namespace OpenTK.Platform.MacOS
case EventClass.Keyboard: case EventClass.Keyboard:
return window.ProcessKeyboardEvent(inCaller, inEvent, evt, userData); return window.ProcessKeyboardEvent(inCaller, inEvent, evt, userData);
default: default:
return OSStatus.EventNotHandled; return OSStatus.EventNotHandled;
} }
} }
@ -388,8 +380,8 @@ namespace OpenTK.Platform.MacOS
case KeyboardEventKind.RawKeyModifiersChanged: case KeyboardEventKind.RawKeyModifiersChanged:
ProcessModifierKey(inEvent); ProcessModifierKey(inEvent);
return OSStatus.NoError; return OSStatus.NoError;
default: default:
return OSStatus.EventNotHandled; return OSStatus.EventNotHandled;
} }
@ -440,8 +432,8 @@ namespace OpenTK.Platform.MacOS
case WindowEventKind.WindowDeactivate: case WindowEventKind.WindowDeactivate:
OnDeactivate(); OnDeactivate();
return OSStatus.EventNotHandled; return OSStatus.EventNotHandled;
default: default:
Debug.Print("{0}", evt); Debug.Print("{0}", evt);
return OSStatus.EventNotHandled; return OSStatus.EventNotHandled;
@ -460,6 +452,7 @@ namespace OpenTK.Platform.MacOS
{ {
pt = screenLoc; pt = screenLoc;
} }
else else
{ {
err = API.GetEventWindowMouseLocation(inEvent, out pt); err = API.GetEventWindowMouseLocation(inEvent, out pt);
@ -506,6 +499,7 @@ namespace OpenTK.Platform.MacOS
} }
return OSStatus.NoError; return OSStatus.NoError;
case MouseEventKind.MouseUp: case MouseEventKind.MouseUp:
@ -526,6 +520,7 @@ namespace OpenTK.Platform.MacOS
break; break;
} }
button = API.GetEventMouseButton(inEvent); button = API.GetEventMouseButton(inEvent);
return OSStatus.NoError; return OSStatus.NoError;
@ -545,28 +540,28 @@ namespace OpenTK.Platform.MacOS
if (this.windowState == WindowState.Fullscreen) if (this.windowState == WindowState.Fullscreen)
{ {
if (mousePosInClient.X != InputDriver.Mouse[0].X || if (mousePosInClient.X != InputDriver.Mouse[0].X || mousePosInClient.Y != InputDriver.Mouse[0].Y)
mousePosInClient.Y != InputDriver.Mouse[0].Y)
{ {
InputDriver.Mouse[0].Position = mousePosInClient; InputDriver.Mouse[0].Position = mousePosInClient;
} }
} }
else else
{ {
// ignore clicks in the title bar // ignore clicks in the title bar
if (pt.Y < 0) if (pt.Y < 0)
return OSStatus.EventNotHandled; return OSStatus.EventNotHandled;
if (mousePosInClient.X != InputDriver.Mouse[0].X || if (mousePosInClient.X != InputDriver.Mouse[0].X || mousePosInClient.Y != InputDriver.Mouse[0].Y)
mousePosInClient.Y != InputDriver.Mouse[0].Y)
{ {
InputDriver.Mouse[0].Position = mousePosInClient; InputDriver.Mouse[0].Position = mousePosInClient;
} }
} }
return OSStatus.EventNotHandled;
return OSStatus.EventNotHandled;
default: default:
Debug.Print("{0}", evt); Debug.Print("{0}", evt);
return OSStatus.EventNotHandled; return OSStatus.EventNotHandled;
@ -721,10 +716,7 @@ namespace OpenTK.Platform.MacOS
public OpenTK.Input.IInputDriver InputDriver public OpenTK.Input.IInputDriver InputDriver
{ {
get get { return mInputDriver; }
{
return mInputDriver;
}
} }
@ -751,6 +743,7 @@ namespace OpenTK.Platform.MacOS
{ {
API.RestoreApplicationDockTileImage(); API.RestoreApplicationDockTileImage();
} }
else else
{ {
Bitmap bitmap; Bitmap bitmap;
@ -780,6 +773,7 @@ namespace OpenTK.Platform.MacOS
byte b = (byte)(pixel & 0xFF); byte b = (byte)(pixel & 0xFF);
data[index++] = (IntPtr)(a + (r << 8) + (g << 16) + (b << 24)); data[index++] = (IntPtr)(a + (r << 8) + (g << 16) + (b << 24));
} }
else else
{ {
data[index++] = (IntPtr)pixel; data[index++] = (IntPtr)pixel;
@ -788,17 +782,15 @@ namespace OpenTK.Platform.MacOS
} }
IntPtr provider = API.CGDataProviderCreateWithData(IntPtr.Zero, data, size * 4, IntPtr.Zero); 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); API.SetApplicationDockTileImage(image);
} }
} }
public string Title public string Title
{ {
get get { return title; }
{
return title;
}
set set
{ {
if (value != Title) if (value != Title)
@ -833,12 +825,9 @@ namespace OpenTK.Platform.MacOS
} }
public Rectangle Bounds public Rectangle Bounds
{
get
{ {
return bounds; get { return bounds; }
}
set set
{ {
Location = value.Location; Location = value.Location;
@ -848,26 +837,14 @@ namespace OpenTK.Platform.MacOS
public Point Location public Point Location
{ {
get get { return Bounds.Location; }
{ set { SetLocation((short)value.X, (short)value.Y); }
return Bounds.Location;
}
set
{
SetLocation((short)value.X, (short)value.Y);
}
} }
public Size Size public Size Size
{ {
get get { return bounds.Size; }
{ set { SetSize((short)value.Width, (short)value.Height); }
return bounds.Size;
}
set
{
SetSize((short)value.Width, (short)value.Height);
}
} }
public int Width public int Width
@ -884,48 +861,27 @@ namespace OpenTK.Platform.MacOS
public int X public int X
{ {
get get { return ClientRectangle.X; }
{ set { Location = new Point(value, Y); }
return ClientRectangle.X;
}
set
{
Location = new Point(value, Y);
}
} }
public int Y public int Y
{ {
get get { return ClientRectangle.Y; }
{ set { Location = new Point(X, value); }
return ClientRectangle.Y;
}
set
{
Location = new Point(X, value);
}
} }
public Rectangle ClientRectangle public Rectangle ClientRectangle
{ {
get get { return clientRectangle; }
{ // just set the size, and ignore the location value.
return clientRectangle; // this is the behavior of the Windows WinGLNative.
} set { ClientSize = value.Size; }
set
{
// just set the size, and ignore the location value.
// this is the behavior of the Windows WinGLNative.
ClientSize = value.Size;
}
} }
public Size ClientSize public Size ClientSize
{ {
get get { return clientRectangle.Size; }
{
return clientRectangle.Size;
}
set set
{ {
API.SizeWindow(window.WindowRef, (short)value.Width, (short)value.Height, true); API.SizeWindow(window.WindowRef, (short)value.Width, (short)value.Height, true);
@ -1023,6 +979,7 @@ namespace OpenTK.Platform.MacOS
idealSize = new CarbonPoint(); idealSize = new CarbonPoint();
API.ZoomWindowIdeal(window.WindowRef, WindowPartCode.inZoomIn, ref idealSize); API.ZoomWindowIdeal(window.WindowRef, WindowPartCode.inZoomIn, ref idealSize);
} }
break; break;
case WindowState.Minimized: case WindowState.Minimized:
@ -1039,10 +996,7 @@ namespace OpenTK.Platform.MacOS
public WindowBorder WindowBorder public WindowBorder WindowBorder
{ {
get get { return windowBorder; }
{
return windowBorder;
}
set set
{ {
if (windowBorder == value) if (windowBorder == value)
@ -1052,13 +1006,12 @@ namespace OpenTK.Platform.MacOS
if (windowBorder == WindowBorder.Resizable) if (windowBorder == WindowBorder.Resizable)
{ {
API.ChangeWindowAttributes(window.WindowRef, WindowAttributes.Resizable | WindowAttributes.FullZoom, API.ChangeWindowAttributes(window.WindowRef, WindowAttributes.Resizable | WindowAttributes.FullZoom, WindowAttributes.NoAttributes);
WindowAttributes.NoAttributes);
} }
else if (windowBorder == WindowBorder.Fixed) else if (windowBorder == WindowBorder.Fixed)
{ {
API.ChangeWindowAttributes(window.WindowRef, WindowAttributes.NoAttributes, API.ChangeWindowAttributes(window.WindowRef, WindowAttributes.NoAttributes, WindowAttributes.Resizable | WindowAttributes.FullZoom);
WindowAttributes.Resizable | WindowAttributes.FullZoom);
} }
WindowBorderChanged(this, EventArgs.Empty); WindowBorderChanged(this, EventArgs.Empty);

View file

@ -65,17 +65,26 @@ namespace OpenTK.Platform.MacOS
public IMouseDriver2 MouseDriver public IMouseDriver2 MouseDriver
{ {
get { throw new NotImplementedException(); } get
{
throw new NotImplementedException();
}
} }
public IKeyboardDriver2 KeyboardDriver public IKeyboardDriver2 KeyboardDriver
{ {
get { throw new NotImplementedException(); } get
{
throw new NotImplementedException();
}
} }
public IGamePadDriver GamePadDriver public IGamePadDriver GamePadDriver
{ {
get { throw new NotImplementedException(); } get
{
throw new NotImplementedException();
}
} }
} }
} }

View file

@ -96,8 +96,7 @@ namespace OpenTK.Platform.MacOS
/// <returns>A System.String that represents the current window.</returns> /// <returns>A System.String that represents the current window.</returns>
public override string ToString() public override string ToString()
{ {
return String.Format("MacOS.CarbonWindowInfo: Handle {0}", return String.Format("MacOS.CarbonWindowInfo: Handle {0}", this.WindowRef);
this.WindowRef);
} }
#endregion #endregion

View file

@ -25,14 +25,17 @@ namespace OpenTK.Platform.MacOS.Carbon
uint _eventKind; uint _eventKind;
EventClass _eventClass; EventClass _eventClass;
public EventClass EventClass { get { return _eventClass; }} public EventClass EventClass
{
get { return _eventClass; }
}
public WindowEventKind WindowEventKind public WindowEventKind WindowEventKind
{ {
get get
{ {
if (EventClass == EventClass.Window) if (EventClass == EventClass.Window)
return (WindowEventKind) _eventKind; return (WindowEventKind)_eventKind;
else else
throw new InvalidCastException("Event is not a Window event."); throw new InvalidCastException("Event is not a Window event.");
} }
@ -42,7 +45,7 @@ namespace OpenTK.Platform.MacOS.Carbon
get get
{ {
if (EventClass == EventClass.Keyboard) if (EventClass == EventClass.Keyboard)
return (KeyboardEventKind) _eventKind; return (KeyboardEventKind)_eventKind;
else else
throw new InvalidCastException("Event is not a Keyboard event."); throw new InvalidCastException("Event is not a Keyboard event.");
} }
@ -52,7 +55,7 @@ namespace OpenTK.Platform.MacOS.Carbon
get get
{ {
if (EventClass == EventClass.Mouse) if (EventClass == EventClass.Mouse)
return (MouseEventKind) _eventKind; return (MouseEventKind)_eventKind;
else else
throw new InvalidCastException("Event is not an Mouse event."); throw new InvalidCastException("Event is not an Mouse event.");
} }
@ -62,7 +65,7 @@ namespace OpenTK.Platform.MacOS.Carbon
get get
{ {
if (EventClass == EventClass.Application) if (EventClass == EventClass.Application)
return (AppEventKind) _eventKind; return (AppEventKind)_eventKind;
else else
throw new InvalidCastException("Event is not an Application event."); throw new InvalidCastException("Event is not an Application event.");
} }
@ -71,7 +74,7 @@ namespace OpenTK.Platform.MacOS.Carbon
public override string ToString() public override string ToString()
{ {
switch(EventClass) switch (EventClass)
{ {
case EventClass.Application: case EventClass.Application:
return "Event: App " + AppEventKind.ToString(); return "Event: App " + AppEventKind.ToString();

View file

@ -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) 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, GraphicsMode gfx = new GraphicsMode((IntPtr)1, color, depth, stencil, samples, accum, buffers, stereo);
accum, buffers, stereo);
System.Diagnostics.Debug.Print("Created dummy graphics mode."); System.Diagnostics.Debug.Print("Created dummy graphics mode.");

View file

@ -11,11 +11,13 @@ namespace OpenTK.Platform.MacOS
{ {
static object display_lock = new object(); static object display_lock = new object();
static Dictionary<DisplayDevice, IntPtr> displayMap = static Dictionary<DisplayDevice, IntPtr> displayMap = new Dictionary<DisplayDevice, IntPtr>();
new Dictionary<DisplayDevice, IntPtr>();
static IntPtr mainDisplay; static IntPtr mainDisplay;
internal static IntPtr MainDisplay { get { return mainDisplay; } } static internal IntPtr MainDisplay
{
get { return mainDisplay; }
}
static QuartzDisplayDeviceDriver() static QuartzDisplayDeviceDriver()
{ {
@ -33,7 +35,7 @@ namespace OpenTK.Platform.MacOS
unsafe unsafe
{ {
fixed(IntPtr* displayPtr = displays) fixed (IntPtr* displayPtr = displays)
{ {
CG.GetActiveDisplayList(maxDisplayCount, displayPtr, out displayCount); CG.GetActiveDisplayList(maxDisplayCount, displayPtr, out displayCount);
} }
@ -71,9 +73,9 @@ namespace OpenTK.Platform.MacOS
{ {
CFDictionary dict = new CFDictionary(displayModes[j]); CFDictionary dict = new CFDictionary(displayModes[j]);
int width = (int) dict.GetNumberValue("Width"); int width = (int)dict.GetNumberValue("Width");
int height = (int) dict.GetNumberValue("Height"); int height = (int)dict.GetNumberValue("Height");
int bpp = (int) dict.GetNumberValue("BitsPerPixel"); int bpp = (int)dict.GetNumberValue("BitsPerPixel");
double freq = dict.GetNumberValue("RefreshRate"); double freq = dict.GetNumberValue("RefreshRate");
bool current = currentMode.Ref == dict.Ref; bool current = currentMode.Ref == dict.Ref;
@ -91,13 +93,11 @@ namespace OpenTK.Platform.MacOS
} }
HIRect bounds = CG.DisplayBounds(currentDisplay); HIRect bounds = CG.DisplayBounds(currentDisplay);
Rectangle newRect = new Rectangle( Rectangle newRect = new Rectangle((int)bounds.Origin.X, (int)bounds.Origin.Y, (int)bounds.Size.Width, (int)bounds.Size.Height);
(int)bounds.Origin.X, (int)bounds.Origin.Y, (int)bounds.Size.Width, (int)bounds.Size.Height);
Debug.Print("Display {0} bounds: {1}", i, newRect); Debug.Print("Display {0} bounds: {1}", i, newRect);
DisplayDevice opentk_dev = DisplayDevice opentk_dev = new DisplayDevice(opentk_dev_current_res, primary, opentk_dev_available_res, newRect);
new DisplayDevice(opentk_dev_current_res, primary, opentk_dev_available_res, newRect);
displayMap.Add(opentk_dev, currentDisplay); 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)) if (displayMap.ContainsKey(displayDevice))
return displayMap[displayDevice]; return displayMap[displayDevice];
@ -142,10 +142,7 @@ namespace OpenTK.Platform.MacOS
int bpp = (int)dict.GetNumberValue("BitsPerPixel"); int bpp = (int)dict.GetNumberValue("BitsPerPixel");
double freq = dict.GetNumberValue("RefreshRate"); double freq = dict.GetNumberValue("RefreshRate");
if (width == resolution.Width && if (width == resolution.Width && height == resolution.Height && bpp == resolution.BitsPerPixel && System.Math.Abs(freq - resolution.RefreshRate) < 1e-6)
height == resolution.Height &&
bpp == resolution.BitsPerPixel &&
System.Math.Abs(freq - resolution.RefreshRate) < 1e-6)
{ {
if (displaysCaptured.Contains(display) == false) if (displaysCaptured.Contains(display) == false)
{ {