diff --git a/Source/OpenTK/Platform/MacOS/Application.cs b/Source/OpenTK/Platform/MacOS/Application.cs index c33e8f0e..a7f43e16 100644 --- a/Source/OpenTK/Platform/MacOS/Application.cs +++ b/Source/OpenTK/Platform/MacOS/Application.cs @@ -72,6 +72,7 @@ namespace OpenTK.Platform.MacOS.Carbon else if (evt.EventClass == EventClass.AppleEvent) { // only event here is the apple event. + Debug.Print("Processing apple event."); API.ProcessAppleEvent(inEvent); } @@ -90,6 +91,7 @@ namespace OpenTK.Platform.MacOS.Carbon static void MainWindowClosed(object sender, EventArgs e) { + Debug.Print("Quitting application event loop."); API.QuitApplicationEventLoop(); } diff --git a/Source/OpenTK/Platform/MacOS/CarbonBindings/QuartzDisplayServicesAPI.cs b/Source/OpenTK/Platform/MacOS/CarbonBindings/QuartzDisplayServicesAPI.cs index 4b8c0ece..45c48e92 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonBindings/QuartzDisplayServicesAPI.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonBindings/QuartzDisplayServicesAPI.cs @@ -21,7 +21,7 @@ namespace OpenTK.Platform.MacOS.Carbon // CGRect -> HIRect [DllImport(appServices,EntryPoint="CGGetActiveDisplayList")] - internal static extern CGDisplayErr GetActiveDisplayList(int maxDisplays, IntPtr[] activeDspys, out int dspyCnt); + internal unsafe static extern CGDisplayErr GetActiveDisplayList(int maxDisplays, IntPtr* activeDspys, out int dspyCnt); [DllImport(appServices,EntryPoint="CGMainDisplayID")] internal static extern IntPtr MainDisplayID(); @@ -33,7 +33,7 @@ namespace OpenTK.Platform.MacOS.Carbon internal static extern int DisplayPixelsHigh(IntPtr display); [DllImport(appServices,EntryPoint="CGDisplayCurrentMode")] - internal static extern CFDictionary DisplayCurrentMode(IntPtr display); + internal static extern IntPtr DisplayCurrentMode(IntPtr display); [DllImport(appServices,EntryPoint="CGDisplayCapture")] internal static extern CGDisplayErr DisplayCapture(IntPtr display); @@ -42,7 +42,7 @@ namespace OpenTK.Platform.MacOS.Carbon internal static extern CGDisplayErr DisplayRelease(IntPtr display); [DllImport(appServices, EntryPoint = "CGDisplayAvailableModes")] - internal static extern CFArray DisplayAvailableModes(IntPtr display); + internal static extern IntPtr DisplayAvailableModes(IntPtr display); } } diff --git a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs index 6d53ca4b..56edc872 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonGLNative.cs @@ -27,7 +27,7 @@ namespace OpenTK.Platform.MacOS static MacOSKeyMap Keymap = new MacOSKeyMap(); IntPtr uppHandler; - string title = "New Window"; + string title = "OpenTK Window"; short mWidth, mHeight; bool mIsDisposed = false; @@ -81,9 +81,9 @@ namespace OpenTK.Platform.MacOS if (disposing) { - mWindows.Remove(window.WindowRef); + mWindows.Remove(window.WindowRef); - window.Dispose(); + window.Dispose(); window = null; } @@ -94,8 +94,8 @@ namespace OpenTK.Platform.MacOS { if (uppHandler != IntPtr.Zero) { - // API.RemoveEventHandler(uppHandler); - // API.DisposeEventHandlerUPP(uppHandler); + //API.RemoveEventHandler(uppHandler); + //API.DisposeEventHandlerUPP(uppHandler); } @@ -109,7 +109,7 @@ namespace OpenTK.Platform.MacOS Debug.Indent(); IntPtr windowRef = API.CreateNewWindow(@class, attrib, r); - //API.SetWindowTitle(windowRef, title); + API.SetWindowTitle(windowRef, title); window = new CarbonWindowInfo(windowRef, true, false); @@ -129,7 +129,7 @@ namespace OpenTK.Platform.MacOS ConnectEvents(); - System.Diagnostics.Debug.Print("Attached events."); + System.Diagnostics.Debug.Print("Attached window events."); } public void Activate() @@ -187,7 +187,6 @@ namespace OpenTK.Platform.MacOS API.ShowWindow(window.WindowRef); API.RepositionWindow(window.WindowRef, parent, WindowPositionMethod); API.SelectWindow(window.WindowRef); - } public void Hide() { @@ -222,6 +221,7 @@ namespace OpenTK.Platform.MacOS WeakReference reference = mWindows[userData]; CarbonGLNative window = (CarbonGLNative)reference.Target; + Debug.Print("Processing {0} event for {1}.", evt, window.window); if (window == null) { @@ -591,7 +591,7 @@ namespace OpenTK.Platform.MacOS { get { - return windowState; + return windowState; } set { diff --git a/Source/OpenTK/Platform/MacOS/CarbonWindowInfo.cs b/Source/OpenTK/Platform/MacOS/CarbonWindowInfo.cs index a46b3603..f86b5133 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonWindowInfo.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonWindowInfo.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Text; namespace OpenTK.Platform.MacOS @@ -59,6 +60,7 @@ namespace OpenTK.Platform.MacOS if (ownHandle) { + Debug.Print("Disposing window {0}.", windowRef); Carbon.API.DisposeWindow(this.windowRef); windowRef = IntPtr.Zero; } diff --git a/Source/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs b/Source/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs index 4eb21c02..3ce26174 100644 --- a/Source/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs +++ b/Source/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs @@ -36,7 +36,13 @@ namespace OpenTK.Platform.MacOS IntPtr[] displays = new IntPtr[maxDisplayCount]; int displayCount; - CG.GetActiveDisplayList(maxDisplayCount, displays, out displayCount); + unsafe + { + fixed(IntPtr* displayPtr = displays) + { + CG.GetActiveDisplayList(maxDisplayCount, displayPtr, out displayCount); + } + } Debug.Print("CoreGraphics reported {0} displays.", displayCount); Debug.Indent(); @@ -54,12 +60,14 @@ namespace OpenTK.Platform.MacOS int currentHeight = CG.DisplayPixelsHigh(currentDisplay); Debug.Print("Display {0} is at {1}x{2}", i, currentWidth, currentHeight); - CFArray displayModes = CG.DisplayAvailableModes(currentDisplay); + IntPtr displayModesPtr = CG.DisplayAvailableModes(currentDisplay); + CFArray displayModes = new CFArray(displayModesPtr); Debug.Print("Supports {0} display modes.", displayModes.Count); DisplayResolution opentk_dev_current_res = null; List opentk_dev_available_res = new List(); - CFDictionary currentMode = CG.DisplayCurrentMode(currentDisplay); + IntPtr currentModePtr = CG.DisplayCurrentMode(currentDisplay); + CFDictionary currentMode = new CFDictionary(currentModePtr); for (int j = 0; j < displayModes.Count; j++) {