MacOS: Detect display boundaries so created windows are placed in the right spot.

This commit is contained in:
kanato 2009-11-09 07:39:38 +00:00
parent dad798d41d
commit 049d339643
2 changed files with 11 additions and 2 deletions

View file

@ -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);

View file

@ -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);
}