From 049d3396430dbf60278ebe0cb563b9a62b670578 Mon Sep 17 00:00:00 2001 From: kanato Date: Mon, 9 Nov 2009 07:39:38 +0000 Subject: [PATCH] MacOS: Detect display boundaries so created windows are placed in the right spot. --- .../MacOS/CarbonBindings/QuartzDisplayServicesAPI.cs | 3 +++ .../OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Source/OpenTK/Platform/MacOS/CarbonBindings/QuartzDisplayServicesAPI.cs b/Source/OpenTK/Platform/MacOS/CarbonBindings/QuartzDisplayServicesAPI.cs index 6c523358..d241a3d6 100644 --- a/Source/OpenTK/Platform/MacOS/CarbonBindings/QuartzDisplayServicesAPI.cs +++ b/Source/OpenTK/Platform/MacOS/CarbonBindings/QuartzDisplayServicesAPI.cs @@ -26,6 +26,9 @@ namespace OpenTK.Platform.MacOS.Carbon [DllImport(appServices,EntryPoint="CGMainDisplayID")] internal static extern IntPtr MainDisplayID(); + [DllImport(appServices, EntryPoint = "CGDisplayBounds")] + internal unsafe static extern HIRect DisplayBounds(IntPtr display); + [DllImport(appServices,EntryPoint="CGDisplayPixelsWide")] internal static extern int DisplayPixelsWide(IntPtr display); diff --git a/Source/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs b/Source/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs index dc9f4ac9..26f873cd 100644 --- a/Source/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs +++ b/Source/OpenTK/Platform/MacOS/QuartzDisplayDeviceDriver.cs @@ -39,7 +39,7 @@ namespace OpenTK.Platform.MacOS } } - Debug.Print("CoreGraphics reported {0} displays.", displayCount); + Debug.Print("CoreGraphics reported {0} display(s).", displayCount); Debug.Indent(); for (int i = 0; i < displayCount; i++) @@ -90,8 +90,14 @@ 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); + + Debug.Print("Display {0} bounds: {1}", i, newRect); + DisplayDevice opentk_dev = - new DisplayDevice(opentk_dev_current_res, primary, opentk_dev_available_res, Rectangle.Empty); + new DisplayDevice(opentk_dev_current_res, primary, opentk_dev_available_res, newRect); displayMap.Add(opentk_dev, currentDisplay); }