Kaynağa Gözat

In .:
2008-01-21 Geoff Norton <[email protected]>

* Graphics.cs: Support Graphics.FromHwnd (IntPtr.Zero) on X11
* carbonFunctions.cs: Support for Graphics.FromHwnd (IntPtr.Zero)
on Carbon
* gdipFunctions.cs: Add XDefaultScreen overload.


svn path=/trunk/mcs/; revision=93419

Geoff Norton 18 yıl önce
ebeveyn
işleme
6d7fb7da31

+ 7 - 0
mcs/class/System.Drawing/System.Drawing/ChangeLog

@@ -1,3 +1,10 @@
+2008-01-21  Geoff Norton  <[email protected]>
+
+	* Graphics.cs: Support Graphics.FromHwnd (IntPtr.Zero) on X11
+	* carbonFunctions.cs: Support for Graphics.FromHwnd (IntPtr.Zero)
+	on Carbon
+	* gdipFunctions.cs: Add XDefaultScreen overload.
+
 2008-01-13  Sebastien Pouliot  <[email protected]>
 
 	* gdipEnums.cs: Remove Unit enum since there's a public version

+ 3 - 0
mcs/class/System.Drawing/System.Drawing/Graphics.cs

@@ -1723,6 +1723,9 @@ namespace System.Drawing
 				if (GDIPlus.Display == IntPtr.Zero) {
 					GDIPlus.Display = GDIPlus.XOpenDisplay (IntPtr.Zero);
 				}
+				if (hwnd == IntPtr.Zero) {
+					hwnd = GDIPlus.XRootWindow (GDIPlus.Display, GDIPlus.XDefaultScreen (GDIPlus.Display));
+				}
 
 				return FromXDrawable (hwnd, GDIPlus.Display);
 

+ 17 - 0
mcs/class/System.Drawing/System.Drawing/carbonFunctions.cs

@@ -65,6 +65,16 @@ namespace System.Drawing {
 			IntPtr port = IntPtr.Zero;
 			IntPtr window = IntPtr.Zero;
 
+			if (handle == IntPtr.Zero) {
+				// FIXME: Can we actually get a CGContextRef for the desktop?  this makes context IntPtr.Zero
+				port = GetQDGlobalsThePort ();
+				CreateCGContextForPort (port, ref context);
+
+				Rect desktop_bounds = CGDisplayBounds (CGMainDisplayID ());
+
+				return new CarbonContext (port, context, (int)desktop_bounds.size.width, (int)desktop_bounds.size.height);
+			}
+
 			QDRect window_bounds = new QDRect ();
 			Rect view_bounds = new Rect ();
 
@@ -146,6 +156,11 @@ namespace System.Drawing {
 		public static extern IntPtr sel_registerName(string selectorName);         
 		#endregion
 
+		[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+		internal static extern IntPtr CGMainDisplayID ();
+		[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+		internal static extern Rect CGDisplayBounds (IntPtr display);
+
 		[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
 		internal static extern int HIViewGetBounds (IntPtr vHnd, ref Rect r);
 		[DllImport("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
@@ -159,6 +174,8 @@ namespace System.Drawing {
 		[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
 		internal static extern IntPtr GetWindowPort (IntPtr hWnd);
 		[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
+		internal static extern IntPtr GetQDGlobalsThePort ();
+		[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
 		internal static extern void CreateCGContextForPort (IntPtr port, ref IntPtr context);
 		[DllImport ("/System/Library/Frameworks/Carbon.framework/Versions/Current/Carbon")]
 		internal static extern void CFRelease (IntPtr context);

+ 3 - 0
mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs

@@ -1477,6 +1477,9 @@ namespace System.Drawing
 		[DllImport ("libX11", EntryPoint="XRootWindow")]
 		internal extern static IntPtr XRootWindow(IntPtr display, int screen);
 			
+		[DllImport ("libX11", EntryPoint="XDefaultScreen")]
+		internal extern static int XDefaultScreen(IntPtr display);
+
 		[DllImport ("libX11", EntryPoint="XDefaultDepth")]
 		internal extern static uint XDefaultDepth(IntPtr display, int screen);