* 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
bde71543f5
commit
7e344e2ac2
10 changed files with 882 additions and 949 deletions
|
@ -32,8 +32,8 @@ namespace OpenTK.Platform.MacOS
|
|||
GraphicsMode graphics_mode;
|
||||
CarbonWindowInfo carbonWindow;
|
||||
IntPtr shareContextRef;
|
||||
DisplayDevice device;
|
||||
bool mIsFullscreen = false;
|
||||
DisplayDevice device;
|
||||
bool mIsFullscreen = false;
|
||||
|
||||
public AglContext(GraphicsMode mode, IWindowInfo window, IGraphicsContext shareContext)
|
||||
{
|
||||
|
@ -45,18 +45,17 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
if (shareContext is AglContext)
|
||||
shareContextRef = ((AglContext)shareContext).Handle.Handle;
|
||||
if (shareContext is GraphicsContext)
|
||||
{
|
||||
ContextHandle shareHandle = shareContext != null ?
|
||||
(shareContext as IGraphicsContextInternal).Context : (ContextHandle)IntPtr.Zero;
|
||||
if (shareContext is GraphicsContext)
|
||||
{
|
||||
ContextHandle shareHandle = shareContext != null ? (shareContext as IGraphicsContextInternal).Context : (ContextHandle)IntPtr.Zero;
|
||||
|
||||
shareContextRef = shareHandle.Handle;
|
||||
}
|
||||
shareContextRef = shareHandle.Handle;
|
||||
}
|
||||
|
||||
if (shareContextRef == IntPtr.Zero)
|
||||
{
|
||||
Debug.Print("No context sharing will take place.");
|
||||
}
|
||||
if (shareContextRef == IntPtr.Zero)
|
||||
{
|
||||
Debug.Print("No context sharing will take place.");
|
||||
}
|
||||
|
||||
CreateContext(mode, carbonWindow, shareContextRef, true);
|
||||
}
|
||||
|
@ -86,10 +85,9 @@ 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>();
|
||||
List<int> aglAttributes = new List<int>();
|
||||
|
||||
Debug.Print("AGL pixel format attributes:");
|
||||
Debug.Indent();
|
||||
|
@ -139,21 +137,18 @@ namespace OpenTK.Platform.MacOS
|
|||
// Choose a pixel format with the attributes we specified.
|
||||
if (fullscreen)
|
||||
{
|
||||
IntPtr gdevice;
|
||||
IntPtr cgdevice = GetQuartzDevice(carbonWindow);
|
||||
IntPtr gdevice;
|
||||
IntPtr cgdevice = GetQuartzDevice(carbonWindow);
|
||||
|
||||
if (cgdevice == IntPtr.Zero)
|
||||
cgdevice = QuartzDisplayDeviceDriver.MainDisplay;
|
||||
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,20 +161,19 @@ namespace OpenTK.Platform.MacOS
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
myAGLPixelFormat = Agl.aglChoosePixelFormat(
|
||||
IntPtr.Zero, 0,
|
||||
aglAttributes.ToArray());
|
||||
myAGLPixelFormat = Agl.aglChoosePixelFormat(IntPtr.Zero, 0, aglAttributes.ToArray());
|
||||
|
||||
MyAGLReportError("aglChoosePixelFormat");
|
||||
}
|
||||
|
||||
|
||||
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.
|
||||
Handle = new ContextHandle( Agl.aglCreateContext(myAGLPixelFormat, shareContextRef));
|
||||
Handle = new ContextHandle(Agl.aglCreateContext(myAGLPixelFormat, shareContextRef));
|
||||
MyAGLReportError("aglCreateContext");
|
||||
|
||||
// Free the pixel format from memory.
|
||||
|
@ -197,25 +191,25 @@ namespace OpenTK.Platform.MacOS
|
|||
Debug.Print("context: {0}", Handle.Handle);
|
||||
}
|
||||
|
||||
private IntPtr GetQuartzDevice(CarbonWindowInfo carbonWindow)
|
||||
{
|
||||
IntPtr windowRef = carbonWindow.WindowRef;
|
||||
private IntPtr GetQuartzDevice(CarbonWindowInfo carbonWindow)
|
||||
{
|
||||
IntPtr windowRef = carbonWindow.WindowRef;
|
||||
|
||||
if (CarbonGLNative.WindowRefMap.ContainsKey(windowRef) == false)
|
||||
return IntPtr.Zero;
|
||||
if (CarbonGLNative.WindowRefMap.ContainsKey(windowRef) == false)
|
||||
return IntPtr.Zero;
|
||||
|
||||
WeakReference nativeRef = CarbonGLNative.WindowRefMap[windowRef];
|
||||
if (nativeRef.IsAlive == false)
|
||||
return IntPtr.Zero;
|
||||
WeakReference nativeRef = CarbonGLNative.WindowRefMap[windowRef];
|
||||
if (nativeRef.IsAlive == false)
|
||||
return IntPtr.Zero;
|
||||
|
||||
CarbonGLNative window = nativeRef.Target as CarbonGLNative;
|
||||
CarbonGLNative window = nativeRef.Target as CarbonGLNative;
|
||||
|
||||
if (window == null)
|
||||
return IntPtr.Zero;
|
||||
if (window == null)
|
||||
return IntPtr.Zero;
|
||||
|
||||
return QuartzDisplayDeviceDriver.HandleTo(window.TargetDisplayDevice);
|
||||
return QuartzDisplayDeviceDriver.HandleTo(window.TargetDisplayDevice);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void SetBufferRect(CarbonWindowInfo carbonWindow)
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -259,7 +252,7 @@ namespace OpenTK.Platform.MacOS
|
|||
void SetDrawable(CarbonWindowInfo carbonWindow)
|
||||
{
|
||||
IntPtr windowPort = GetWindowPortForWindowInfo(carbonWindow);
|
||||
//Debug.Print("Setting drawable for context {0} to window port: {1}", Handle.Handle, windowPort);
|
||||
//Debug.Print("Setting drawable for context {0} to window port: {1}", Handle.Handle, windowPort);
|
||||
|
||||
Agl.aglSetDrawable(Handle.Handle, windowPort);
|
||||
|
||||
|
@ -276,6 +269,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
windowPort = API.GetWindowPort(controlOwner);
|
||||
}
|
||||
|
||||
else
|
||||
windowPort = API.GetWindowPort(carbonWindow.WindowRef);
|
||||
|
||||
|
@ -285,32 +279,33 @@ namespace OpenTK.Platform.MacOS
|
|||
{
|
||||
CarbonWindowInfo carbonWindow = (CarbonWindowInfo)window;
|
||||
|
||||
if (carbonWindow.GoFullScreenHack)
|
||||
{
|
||||
carbonWindow.GoFullScreenHack = false;
|
||||
CarbonGLNative wind = GetCarbonWindow(carbonWindow);
|
||||
if (carbonWindow.GoFullScreenHack)
|
||||
{
|
||||
carbonWindow.GoFullScreenHack = false;
|
||||
CarbonGLNative wind = GetCarbonWindow(carbonWindow);
|
||||
|
||||
if (wind != null)
|
||||
wind.SetFullscreen(this);
|
||||
else
|
||||
Debug.Print("Could not find window!");
|
||||
if (wind != null)
|
||||
wind.SetFullscreen(this);
|
||||
else
|
||||
Debug.Print("Could not find window!");
|
||||
|
||||
return;
|
||||
}
|
||||
else if (carbonWindow.GoWindowedHack)
|
||||
{
|
||||
carbonWindow.GoWindowedHack = false;
|
||||
CarbonGLNative wind = GetCarbonWindow(carbonWindow);
|
||||
return;
|
||||
}
|
||||
|
||||
if (wind != null)
|
||||
wind.UnsetFullscreen(this);
|
||||
else
|
||||
Debug.Print("Could not find window!");
|
||||
else if (carbonWindow.GoWindowedHack)
|
||||
{
|
||||
carbonWindow.GoWindowedHack = false;
|
||||
CarbonGLNative wind = GetCarbonWindow(carbonWindow);
|
||||
|
||||
}
|
||||
if (wind != null)
|
||||
wind.UnsetFullscreen(this);
|
||||
else
|
||||
Debug.Print("Could not find window!");
|
||||
|
||||
if (mIsFullscreen)
|
||||
return;
|
||||
}
|
||||
|
||||
if (mIsFullscreen)
|
||||
return;
|
||||
|
||||
SetDrawable(carbonWindow);
|
||||
SetBufferRect(carbonWindow);
|
||||
|
@ -318,67 +313,65 @@ namespace OpenTK.Platform.MacOS
|
|||
Agl.aglUpdateContext(Handle.Handle);
|
||||
}
|
||||
|
||||
private CarbonGLNative GetCarbonWindow(CarbonWindowInfo carbonWindow)
|
||||
{
|
||||
WeakReference r = CarbonGLNative.WindowRefMap[carbonWindow.WindowRef];
|
||||
private CarbonGLNative GetCarbonWindow(CarbonWindowInfo carbonWindow)
|
||||
{
|
||||
WeakReference r = CarbonGLNative.WindowRefMap[carbonWindow.WindowRef];
|
||||
|
||||
if (r.IsAlive)
|
||||
{
|
||||
return (CarbonGLNative) r.Target;
|
||||
}
|
||||
else
|
||||
return null;
|
||||
}
|
||||
if (r.IsAlive)
|
||||
{
|
||||
return (CarbonGLNative)r.Target;
|
||||
}
|
||||
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
void MyAGLReportError(string function)
|
||||
{
|
||||
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;
|
||||
|
||||
internal void SetFullScreen(CarbonWindowInfo info, out int width, out int height)
|
||||
{
|
||||
CarbonGLNative wind = GetCarbonWindow(info);
|
||||
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);
|
||||
MakeCurrent(info);
|
||||
CG.DisplayCapture(GetQuartzDevice(info));
|
||||
Agl.aglSetFullScreen(Handle.Handle, wind.TargetDisplayDevice.Width, wind.TargetDisplayDevice.Height, 0, 0);
|
||||
MakeCurrent(info);
|
||||
|
||||
width = wind.TargetDisplayDevice.Width;
|
||||
height = wind.TargetDisplayDevice.Height;
|
||||
width = wind.TargetDisplayDevice.Width;
|
||||
height = wind.TargetDisplayDevice.Height;
|
||||
|
||||
// This is a weird hack to workaround a bug where the first time a context
|
||||
// is made fullscreen, we just end up with a blank screen. So we undo it as fullscreen
|
||||
// and redo it as fullscreen.
|
||||
if (firstFullScreen == false)
|
||||
{
|
||||
firstFullScreen = true;
|
||||
UnsetFullScreen(info);
|
||||
SetFullScreen(info, out width, out height);
|
||||
}
|
||||
if (firstFullScreen == false)
|
||||
{
|
||||
firstFullScreen = true;
|
||||
UnsetFullScreen(info);
|
||||
SetFullScreen(info, out width, out height);
|
||||
}
|
||||
|
||||
mIsFullscreen = true;
|
||||
mIsFullscreen = true;
|
||||
}
|
||||
internal void UnsetFullScreen(CarbonWindowInfo windowInfo)
|
||||
{
|
||||
Debug.Print("Unsetting AGL fullscreen.");
|
||||
Debug.Print("Unsetting AGL fullscreen.");
|
||||
Agl.aglSetDrawable(Handle.Handle, IntPtr.Zero);
|
||||
Agl.aglUpdateContext(Handle.Handle);
|
||||
Agl.aglUpdateContext(Handle.Handle);
|
||||
|
||||
CG.DisplayRelease(GetQuartzDevice(windowInfo));
|
||||
Debug.Print("Resetting drawable.");
|
||||
SetDrawable(windowInfo);
|
||||
CG.DisplayRelease(GetQuartzDevice(windowInfo));
|
||||
Debug.Print("Resetting drawable.");
|
||||
SetDrawable(windowInfo);
|
||||
|
||||
mIsFullscreen = false;
|
||||
mIsFullscreen = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -453,18 +440,18 @@ namespace OpenTK.Platform.MacOS
|
|||
Debug.Print("Disposing of AGL context.");
|
||||
Agl.aglSetCurrentContext(IntPtr.Zero);
|
||||
|
||||
//Debug.Print("Setting drawable to null for context {0}.", Handle.Handle);
|
||||
//Agl.aglSetDrawable(Handle.Handle, IntPtr.Zero);
|
||||
//Debug.Print("Setting drawable to null for context {0}.", Handle.Handle);
|
||||
//Agl.aglSetDrawable(Handle.Handle, IntPtr.Zero);
|
||||
|
||||
// I do not know MacOS allows us to destroy a context from a separate thread,
|
||||
// like the finalizer thread. It's untested, but worst case is probably
|
||||
// an exception on application exit, which would be logged to the console.
|
||||
Debug.Print("Destroying context");
|
||||
// I do not know MacOS allows us to destroy a context from a separate thread,
|
||||
// like the finalizer thread. It's untested, but worst case is probably
|
||||
// an exception on application exit, which would be logged to the console.
|
||||
Debug.Print("Destroying context");
|
||||
if (Agl.aglDestroyContext(Handle.Handle) == true)
|
||||
{
|
||||
Debug.Print("Context destruction completed successfully.");
|
||||
Handle = ContextHandle.Zero;
|
||||
return;
|
||||
Debug.Print("Context destruction completed successfully.");
|
||||
Handle = ContextHandle.Zero;
|
||||
return;
|
||||
}
|
||||
|
||||
// failed to destroy context.
|
||||
|
@ -484,7 +471,7 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
#region IGraphicsContextInternal Members
|
||||
|
||||
private const string Library = "libdl.dylib";
|
||||
private const string Library = "libdl.dylib";
|
||||
|
||||
[DllImport(Library, EntryPoint = "NSIsSymbolNameDefined")]
|
||||
private static extern bool NSIsSymbolNameDefined(string s);
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
@ -41,21 +42,21 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
|
||||
Debug.Print("Running on Mac OS X {0}.{1}.{2}.", osMajor, osMinor, osBugfix);
|
||||
|
||||
TransformProcessToForeground();
|
||||
TransformProcessToForeground();
|
||||
}
|
||||
|
||||
private static void TransformProcessToForeground()
|
||||
{
|
||||
Carbon.ProcessSerialNumber psn = new ProcessSerialNumber();
|
||||
private static void TransformProcessToForeground()
|
||||
{
|
||||
Carbon.ProcessSerialNumber psn = new ProcessSerialNumber();
|
||||
|
||||
Debug.Print("Setting process to be foreground application.");
|
||||
Debug.Print("Setting process to be foreground application.");
|
||||
|
||||
API.GetCurrentProcess(ref psn);
|
||||
API.TransformProcessType(ref psn, ProcessApplicationTransformState.kProcessTransformToForegroundApplication);
|
||||
API.SetFrontProcess(ref psn);
|
||||
}
|
||||
API.GetCurrentProcess(ref psn);
|
||||
API.TransformProcessType(ref psn, ProcessApplicationTransformState.kProcessTransformToForegroundApplication);
|
||||
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;
|
||||
}
|
||||
|
@ -100,26 +84,28 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
|
||||
switch (evt.EventClass)
|
||||
{
|
||||
case EventClass.Application:
|
||||
switch (evt.AppEventKind)
|
||||
{
|
||||
default:
|
||||
return OSStatus.EventNotHandled;
|
||||
}
|
||||
case EventClass.Application:
|
||||
switch (evt.AppEventKind)
|
||||
{
|
||||
default:
|
||||
return OSStatus.EventNotHandled;
|
||||
}
|
||||
|
||||
case EventClass.AppleEvent:
|
||||
// only event here is the apple event.
|
||||
Debug.Print("Processing apple event.");
|
||||
API.ProcessAppleEvent(inEvent);
|
||||
break;
|
||||
|
||||
case EventClass.Keyboard:
|
||||
case EventClass.Mouse:
|
||||
if (WindowEventHandler != null)
|
||||
{
|
||||
return WindowEventHandler.DispatchEvent(inCaller, inEvent, evt, userData);
|
||||
}
|
||||
break;
|
||||
case EventClass.AppleEvent:
|
||||
// only event here is the apple event.
|
||||
Debug.Print("Processing apple event.");
|
||||
API.ProcessAppleEvent(inEvent);
|
||||
break;
|
||||
|
||||
case EventClass.Keyboard:
|
||||
case EventClass.Mouse:
|
||||
if (WindowEventHandler != null)
|
||||
{
|
||||
return WindowEventHandler.DispatchEvent(inCaller, inEvent, evt, userData);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return OSStatus.EventNotHandled;
|
||||
|
@ -142,7 +128,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
}
|
||||
|
||||
|
||||
internal static void ProcessEvents()
|
||||
static internal void ProcessEvents()
|
||||
{
|
||||
API.ProcessEvents();
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ namespace OpenTK.Platform.MacOS
|
|||
bool ownHandle = false;
|
||||
bool disposed = false;
|
||||
bool isControl = false;
|
||||
bool goFullScreenHack = false;
|
||||
bool goWindowedHack = false;
|
||||
bool goFullScreenHack = false;
|
||||
bool goWindowedHack = false;
|
||||
|
||||
#region Constructors
|
||||
|
||||
|
@ -72,16 +72,16 @@ namespace OpenTK.Platform.MacOS
|
|||
get { return this.windowRef; }
|
||||
}
|
||||
|
||||
internal bool GoFullScreenHack
|
||||
{
|
||||
get { return goFullScreenHack; }
|
||||
set { goFullScreenHack = value; }
|
||||
}
|
||||
internal bool GoWindowedHack
|
||||
{
|
||||
get { return goWindowedHack; }
|
||||
set { goWindowedHack = value; }
|
||||
}
|
||||
internal bool GoFullScreenHack
|
||||
{
|
||||
get { return goFullScreenHack; }
|
||||
set { goFullScreenHack = value; }
|
||||
}
|
||||
internal bool GoWindowedHack
|
||||
{
|
||||
get { return goWindowedHack; }
|
||||
set { goWindowedHack = value; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -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,16 +74,16 @@ namespace OpenTK.Platform.MacOS.Carbon
|
|||
|
||||
public override string ToString()
|
||||
{
|
||||
switch(EventClass)
|
||||
switch (EventClass)
|
||||
{
|
||||
case EventClass.Application:
|
||||
return "Event: App " + AppEventKind.ToString();
|
||||
case EventClass.Keyboard:
|
||||
return "Event: Keyboard " + KeyboardEventKind.ToString();
|
||||
case EventClass.Mouse:
|
||||
return "Event: Mouse " + MouseEventKind.ToString();
|
||||
case EventClass.Window:
|
||||
return "Event: Window " + WindowEventKind.ToString();
|
||||
case EventClass.Application:
|
||||
return "Event: App " + AppEventKind.ToString();
|
||||
case EventClass.Keyboard:
|
||||
return "Event: Keyboard " + KeyboardEventKind.ToString();
|
||||
case EventClass.Mouse:
|
||||
return "Event: Mouse " + MouseEventKind.ToString();
|
||||
case EventClass.Window:
|
||||
return "Event: Window " + WindowEventKind.ToString();
|
||||
}
|
||||
|
||||
return "Event: Unknown Class " + EventClass.ToString() + " kind: " + _eventKind.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;
|
||||
|
||||
|
@ -90,14 +92,12 @@ 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);
|
||||
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);
|
||||
|
||||
Debug.Print("Display {0} bounds: {1}", i, newRect);
|
||||
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,13 +107,13 @@ namespace OpenTK.Platform.MacOS
|
|||
}
|
||||
|
||||
|
||||
internal static IntPtr HandleTo(DisplayDevice displayDevice)
|
||||
{
|
||||
if (displayMap.ContainsKey(displayDevice))
|
||||
return displayMap[displayDevice];
|
||||
else
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
static internal IntPtr HandleTo(DisplayDevice displayDevice)
|
||||
{
|
||||
if (displayMap.ContainsKey(displayDevice))
|
||||
return displayMap[displayDevice];
|
||||
else
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
#region IDisplayDeviceDriver Members
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -183,5 +180,5 @@ namespace OpenTK.Platform.MacOS
|
|||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue