mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-01-12 23:05:26 +00:00
Fixed MacOS initialization by returning IntPtr from CoreGraphics methods
instead of structures wrapping CoreFoundation types.
This commit is contained in:
parent
e66d796bdb
commit
6e327798a3
|
@ -72,6 +72,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
||||||
else if (evt.EventClass == EventClass.AppleEvent)
|
else if (evt.EventClass == EventClass.AppleEvent)
|
||||||
{
|
{
|
||||||
// only event here is the apple event.
|
// only event here is the apple event.
|
||||||
|
Debug.Print("Processing apple event.");
|
||||||
API.ProcessAppleEvent(inEvent);
|
API.ProcessAppleEvent(inEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +91,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
||||||
|
|
||||||
static void MainWindowClosed(object sender, EventArgs e)
|
static void MainWindowClosed(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
Debug.Print("Quitting application event loop.");
|
||||||
API.QuitApplicationEventLoop();
|
API.QuitApplicationEventLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
||||||
// CGRect -> HIRect
|
// CGRect -> HIRect
|
||||||
|
|
||||||
[DllImport(appServices,EntryPoint="CGGetActiveDisplayList")]
|
[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")]
|
[DllImport(appServices,EntryPoint="CGMainDisplayID")]
|
||||||
internal static extern IntPtr MainDisplayID();
|
internal static extern IntPtr MainDisplayID();
|
||||||
|
@ -33,7 +33,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
||||||
internal static extern int DisplayPixelsHigh(IntPtr display);
|
internal static extern int DisplayPixelsHigh(IntPtr display);
|
||||||
|
|
||||||
[DllImport(appServices,EntryPoint="CGDisplayCurrentMode")]
|
[DllImport(appServices,EntryPoint="CGDisplayCurrentMode")]
|
||||||
internal static extern CFDictionary DisplayCurrentMode(IntPtr display);
|
internal static extern IntPtr DisplayCurrentMode(IntPtr display);
|
||||||
|
|
||||||
[DllImport(appServices,EntryPoint="CGDisplayCapture")]
|
[DllImport(appServices,EntryPoint="CGDisplayCapture")]
|
||||||
internal static extern CGDisplayErr DisplayCapture(IntPtr display);
|
internal static extern CGDisplayErr DisplayCapture(IntPtr display);
|
||||||
|
@ -42,7 +42,7 @@ namespace OpenTK.Platform.MacOS.Carbon
|
||||||
internal static extern CGDisplayErr DisplayRelease(IntPtr display);
|
internal static extern CGDisplayErr DisplayRelease(IntPtr display);
|
||||||
|
|
||||||
[DllImport(appServices, EntryPoint = "CGDisplayAvailableModes")]
|
[DllImport(appServices, EntryPoint = "CGDisplayAvailableModes")]
|
||||||
internal static extern CFArray DisplayAvailableModes(IntPtr display);
|
internal static extern IntPtr DisplayAvailableModes(IntPtr display);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
static MacOSKeyMap Keymap = new MacOSKeyMap();
|
static MacOSKeyMap Keymap = new MacOSKeyMap();
|
||||||
|
|
||||||
IntPtr uppHandler;
|
IntPtr uppHandler;
|
||||||
string title = "New Window";
|
string title = "OpenTK Window";
|
||||||
short mWidth, mHeight;
|
short mWidth, mHeight;
|
||||||
bool mIsDisposed = false;
|
bool mIsDisposed = false;
|
||||||
|
|
||||||
|
@ -81,9 +81,9 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
mWindows.Remove(window.WindowRef);
|
mWindows.Remove(window.WindowRef);
|
||||||
|
|
||||||
window.Dispose();
|
window.Dispose();
|
||||||
window = null;
|
window = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,8 +94,8 @@ namespace OpenTK.Platform.MacOS
|
||||||
{
|
{
|
||||||
if (uppHandler != IntPtr.Zero)
|
if (uppHandler != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
// API.RemoveEventHandler(uppHandler);
|
//API.RemoveEventHandler(uppHandler);
|
||||||
// API.DisposeEventHandlerUPP(uppHandler);
|
//API.DisposeEventHandlerUPP(uppHandler);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
Debug.Indent();
|
Debug.Indent();
|
||||||
|
|
||||||
IntPtr windowRef = API.CreateNewWindow(@class, attrib, r);
|
IntPtr windowRef = API.CreateNewWindow(@class, attrib, r);
|
||||||
//API.SetWindowTitle(windowRef, title);
|
API.SetWindowTitle(windowRef, title);
|
||||||
|
|
||||||
window = new CarbonWindowInfo(windowRef, true, false);
|
window = new CarbonWindowInfo(windowRef, true, false);
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
ConnectEvents();
|
ConnectEvents();
|
||||||
|
|
||||||
System.Diagnostics.Debug.Print("Attached events.");
|
System.Diagnostics.Debug.Print("Attached window events.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Activate()
|
public void Activate()
|
||||||
|
@ -187,7 +187,6 @@ namespace OpenTK.Platform.MacOS
|
||||||
API.ShowWindow(window.WindowRef);
|
API.ShowWindow(window.WindowRef);
|
||||||
API.RepositionWindow(window.WindowRef, parent, WindowPositionMethod);
|
API.RepositionWindow(window.WindowRef, parent, WindowPositionMethod);
|
||||||
API.SelectWindow(window.WindowRef);
|
API.SelectWindow(window.WindowRef);
|
||||||
|
|
||||||
}
|
}
|
||||||
public void Hide()
|
public void Hide()
|
||||||
{
|
{
|
||||||
|
@ -222,6 +221,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
WeakReference reference = mWindows[userData];
|
WeakReference reference = mWindows[userData];
|
||||||
CarbonGLNative window = (CarbonGLNative)reference.Target;
|
CarbonGLNative window = (CarbonGLNative)reference.Target;
|
||||||
|
|
||||||
|
Debug.Print("Processing {0} event for {1}.", evt, window.window);
|
||||||
|
|
||||||
if (window == null)
|
if (window == null)
|
||||||
{
|
{
|
||||||
|
@ -591,7 +591,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return windowState;
|
return windowState;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace OpenTK.Platform.MacOS
|
namespace OpenTK.Platform.MacOS
|
||||||
|
@ -59,6 +60,7 @@ namespace OpenTK.Platform.MacOS
|
||||||
|
|
||||||
if (ownHandle)
|
if (ownHandle)
|
||||||
{
|
{
|
||||||
|
Debug.Print("Disposing window {0}.", windowRef);
|
||||||
Carbon.API.DisposeWindow(this.windowRef);
|
Carbon.API.DisposeWindow(this.windowRef);
|
||||||
windowRef = IntPtr.Zero;
|
windowRef = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,13 @@ namespace OpenTK.Platform.MacOS
|
||||||
IntPtr[] displays = new IntPtr[maxDisplayCount];
|
IntPtr[] displays = new IntPtr[maxDisplayCount];
|
||||||
int displayCount;
|
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.Print("CoreGraphics reported {0} displays.", displayCount);
|
||||||
Debug.Indent();
|
Debug.Indent();
|
||||||
|
@ -54,12 +60,14 @@ namespace OpenTK.Platform.MacOS
|
||||||
int currentHeight = CG.DisplayPixelsHigh(currentDisplay);
|
int currentHeight = CG.DisplayPixelsHigh(currentDisplay);
|
||||||
Debug.Print("Display {0} is at {1}x{2}", i, currentWidth, currentHeight);
|
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);
|
Debug.Print("Supports {0} display modes.", displayModes.Count);
|
||||||
|
|
||||||
DisplayResolution opentk_dev_current_res = null;
|
DisplayResolution opentk_dev_current_res = null;
|
||||||
List<DisplayResolution> opentk_dev_available_res = new List<DisplayResolution>();
|
List<DisplayResolution> opentk_dev_available_res = new List<DisplayResolution>();
|
||||||
CFDictionary currentMode = CG.DisplayCurrentMode(currentDisplay);
|
IntPtr currentModePtr = CG.DisplayCurrentMode(currentDisplay);
|
||||||
|
CFDictionary currentMode = new CFDictionary(currentModePtr);
|
||||||
|
|
||||||
for (int j = 0; j < displayModes.Count; j++)
|
for (int j = 0; j < displayModes.Count; j++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue