Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CoreGraphics] Add support for xcode13 beta 5. #12589

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Constants.maccatalyst.cs.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ namespace ObjCRuntime {

// iOS 9.0
public const string libcompressionLibrary = "/usr/lib/libcompression.dylib";

// xcode 13
public const string ApplicationServicesCoreGraphicsLibrary = "/System/Library/Frameworks/ApplicationServices.framework/Frameworks/CoreGraphics.framework/CoreGraphics";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is it used ?

https://developer.apple.com/documentation/colorsync/colorsyncprofileref?changes=_4&language=objc hints to it, but no DllImport uses that constant

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the constant string ApplicationServicesCoreGraphicsLibrary used there ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes github links to a line number of a file in a PR SUCK, better link: https://github.com/xamarin/xamarin-macios/blob/main/src/CoreGraphics/CGEvent.cs#L80

[DllImport (Constants.ApplicationServicesCoreGraphicsLibrary)]
		extern static IntPtr CGEventCreateMouseEvent(IntPtr source, CGEventType mouseType, CGPoint mouseCursorPosition, CGMouseButton mouseButton);
			
		public CGEvent (CGEventSource source, CGEventType mouseType, CGPoint mouseCursorPosition, CGMouseButton mouseButton)
		{
			handle = CGEventCreateMouseEvent (source == null ? IntPtr.Zero : source.Handle, mouseType, mouseCursorPosition, mouseButton);
		}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I see it now 👓 thanks!

}
}
34 changes: 34 additions & 0 deletions src/CoreGraphics/CGColorSpace.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;

using CoreFoundation;
using ObjCRuntime;
Expand Down Expand Up @@ -655,6 +656,39 @@ public bool UsesExtendedRange {
[MacCatalyst (14,0)]
public CGColorSpace CreateExtendedLinearized () => Runtime.GetINativeObject<CGColorSpace> (CGColorSpaceCreateExtendedLinearized (handle), owns: true);

#if !NET
[Mac (12,0), iOS (15,0), TV (15,0), MacCatalyst (15,0), Watch (8,0)]
#else
[SupportedOSPlatform ("ios15.0"), SupportedOSPlatform ("tvos15.0"), SupportedOSPlatform ("macos12.0"), SupportedOSPlatform ("maccatalyst15.0")]
#endif
[return: MarshalAs (UnmanagedType.I1)]
[DllImport (Constants.CoreGraphicsLibrary)]
static extern bool CGColorSpaceIsHLGBased (/* CGColorSpace */ IntPtr space);

#if !NET
[Mac (12,0), iOS (15,0), TV (15,0), MacCatalyst (15,0), Watch (8,0)]
#else
[SupportedOSPlatform ("ios15.0"), SupportedOSPlatform ("tvos15.0"), SupportedOSPlatform ("macos12.0"), SupportedOSPlatform ("maccatalyst15.0")]
#endif
public bool IsHlgBased => CGColorSpaceIsHLGBased (handle);

#if !NET
[Mac (12,0), iOS (15,0), TV (15,0), MacCatalyst (15,0), Watch (8,0)]
#else
[SupportedOSPlatform ("ios15.0"), SupportedOSPlatform ("tvos15.0"), SupportedOSPlatform ("macos12.0"), SupportedOSPlatform ("maccatalyst15.0")]
#endif
[return: MarshalAs (UnmanagedType.I1)]
[DllImport (Constants.CoreGraphicsLibrary)]
static extern bool CGColorSpaceIsPQBased (/* CGColorSpace */ IntPtr space);

#if !NET
[Mac (12,0), iOS (15,0), TV (15,0), MacCatalyst (15,0), Watch (8,0)]
#else
[SupportedOSPlatform ("ios15.0"), SupportedOSPlatform ("tvos15.0"), SupportedOSPlatform ("macos12.0"), SupportedOSPlatform ("maccatalyst15.0")]
#endif
public bool IsPQBased => CGColorSpaceIsPQBased (handle);


#endif // !COREBUILD
}
}
14 changes: 13 additions & 1 deletion src/CoreGraphics/CGDisplay.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
#if MONOMAC
#if MONOMAC || __MACCATALYST__
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using ObjCRuntime;
using Foundation;

namespace CoreGraphics
{

#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
public enum CGCaptureOptions : uint
{
None = 0,
NoFill = 1 << 0
}

#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
public static class CGDisplay
{
#if !COREBUILD
Expand Down
9 changes: 8 additions & 1 deletion src/CoreGraphics/CGEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
* Miguel de Icaza
*/

#if MONOMAC
#if MONOMAC || __MACCATALYST__

using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
#if !NO_SYSTEM_DRAWING
using System.Drawing;
#endif
Expand All @@ -20,6 +21,12 @@
using Foundation;

namespace CoreGraphics {

#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
public sealed class CGEvent : IDisposable, INativeObject {
public delegate IntPtr CGEventTapCallback (IntPtr tapProxyEvent, CGEventType eventType, IntPtr eventRef, IntPtr userInfo);

Expand Down
8 changes: 7 additions & 1 deletion src/CoreGraphics/CGEventSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
* Miguel de Icaza
*/

#if MONOMAC
#if MONOMAC || __MACCATALYST__

using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
#if !NO_SYSTEM_DRAWING
using System.Drawing;
#endif
Expand All @@ -20,6 +21,11 @@
using Foundation;

namespace CoreGraphics {
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
public sealed class CGEventSource : IDisposable, INativeObject {
IntPtr handle;

Expand Down
68 changes: 67 additions & 1 deletion src/CoreGraphics/CGEventTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
* Miguel de Icaza
*/

#if MONOMAC
#if MONOMAC || __MACCATALYST__

using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
#if !NO_SYSTEM_DRAWING
using System.Drawing;
#endif
Expand All @@ -22,35 +23,65 @@
namespace CoreGraphics {

// CGEventTypes.h:typedef uint32_t CGEventTapLocation;
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
public enum CGEventTapLocation : int {
HID,
Session,
AnnotatedSession
}

// CGEventTypes.h:typedef uint32_t CGEventTapPlacement;
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
public enum CGEventTapPlacement : uint {
HeadInsert,
TailAppend
}

// CGEventTypes.h:typedef uint32_t CGEventTapOptions;
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
public enum CGEventTapOptions : uint {
Default,
ListenOnly
}

// CGEventTypes.h:typedef uint32_t CGMouseButton;
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
public enum CGMouseButton : uint {
Left, Right, Center
}

// CGEventTypes.h:typedef uint32_t CGScrollEventUnit;
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
public enum CGScrollEventUnit : uint {
Pixel, Line
}

// CGEventTypes.h:typedef uint64_t CGEventMask;
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
[Flags]
public enum CGEventMask : ulong {
Null = 0x00000001,
Expand All @@ -73,6 +104,11 @@ public enum CGEventMask : ulong {
}

// CGEventTypes.h:typedef uint64_t CGEventFlags;
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
[Flags]
public enum CGEventFlags : ulong {
NonCoalesced = 0x00000100,
Expand All @@ -87,6 +123,11 @@ public enum CGEventFlags : ulong {
}

// CGEventTypes.h:typedef uint32_t CGEventField;
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
internal enum CGEventField : int {
MouseEventNumber = 0,
MouseEventClickState = 1,
Expand Down Expand Up @@ -151,6 +192,11 @@ internal enum CGEventField : int {
}

// CGEventTypes.h:typedef uint32_t CGEventType;
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
public enum CGEventType : uint {
Null = 0x0,
LeftMouseDown = 0x1,
Expand All @@ -174,16 +220,31 @@ public enum CGEventType : uint {
}

// CGEventTypes.h:typedef uint32_t CGEventMouseSubtype;
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
public enum CGEventMouseSubtype : uint {
Default, TabletPoint, TabletProximity
}

// CGEventTypes.h:typedef uint32_t CGEventSourceStateID;
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
public enum CGEventSourceStateID : int {
Private = -1, CombinedSession = 0, HidSystem = 1
}

// CGRemoteOperation.h:typedef uint32_t CGEventFilterMask;
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
[Flags]
public enum CGEventFilterMask : uint {
PermitLocalMouseEvents = 1,
Expand All @@ -192,6 +253,11 @@ public enum CGEventFilterMask : uint {
}

// CGRemoteOperation.h:typedef uint32_t CGEventSuppressionState;
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
public enum CGEventSuppressionState : int {
SuppressionInterval,
RemoteMouseDrag,
Expand Down
30 changes: 28 additions & 2 deletions src/CoreGraphics/CGImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,20 @@
//
using System;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;

using ObjCRuntime;
using Foundation;

namespace CoreGraphics {

#if MONOMAC
#if MONOMAC || __MACCATALYST__
// uint32_t -> CGWindow.h (OSX SDK only)
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
[Flags]
public enum CGWindowImageOption : uint {
Default = 0,
Expand All @@ -46,6 +52,11 @@ public enum CGWindowImageOption : uint {
}

// uint32_t -> CGWindow.h (OSX SDK only)
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
[Flags]
public enum CGWindowListOption : uint {
All = 0,
Expand Down Expand Up @@ -213,15 +224,30 @@ public CGImage (int width, int height, int bitsPerComponent, int bitsPerPixel, i
shouldInterpolate, intent);
}

#if MONOMAC
#if MONOMAC || __MACCATALYST__
#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
[DllImport (Constants.CoreGraphicsLibrary)]
static extern IntPtr CGWindowListCreateImage(CGRect screenBounds, CGWindowListOption windowOption, uint windowID, CGWindowImageOption imageOption);

#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
public static CGImage ScreenImage (int windownumber, CGRect bounds)
{
return ScreenImage (windownumber, bounds, CGWindowListOption.IncludingWindow, CGWindowImageOption.Default);
}

#if !NET
[MacCatalyst (15,0)]
#else
[SupportedOSPlatform ("maccatalyst15.0")]
#endif
public static CGImage ScreenImage (int windownumber, CGRect bounds, CGWindowListOption windowOption,
CGWindowImageOption imageOption)
{
Expand Down
12 changes: 12 additions & 0 deletions src/coregraphics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,18 @@ interface CGColorSpaceNames {
[MacCatalyst (14,0)]
[Field ("kCGColorSpaceITUR_2100_PQ")]
NSString Itur_2100_PQ { get; }

[Mac (12,0), iOS (15,0), TV (15,0), Watch (8,0), MacCatalyst (15,0)]
[Field ("kCGColorSpaceExtendedRange")]
NSString ExtendedRange { get; }

[Mac (12, 0), iOS (15, 0), TV (15,0), Watch (8,0), MacCatalyst (15,0)]
[Field ("kCGColorSpaceLinearDisplayP3")]
NSString LinearDisplayP3 { get; }

[Mac (12, 0), iOS (15, 0), TV (15,0), Watch (8,0), MacCatalyst (15,0)]
[Field ("kCGColorSpaceLinearITUR_2020")]
NSString LinearItur_2020 { get; }
}

[Partial]
Expand Down
Loading