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

[SR-4073] CGEventMask & CGEventMaskBit bridging situation is poor #46656

Closed
jtbandes opened this issue Feb 25, 2017 · 8 comments
Closed

[SR-4073] CGEventMask & CGEventMaskBit bridging situation is poor #46656

jtbandes opened this issue Feb 25, 2017 · 8 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. SDKOverlay

Comments

@jtbandes
Copy link
Collaborator

Previous ID SR-4073
Radar rdar://problem/30712185
Original Reporter @jtbandes
Type Bug
Status Resolved
Resolution Invalid
Additional Detail from JIRA
Votes 0
Component/s
Labels Bug, CoreGraphics, SDKOverlay
Assignee None
Priority Medium

md5: b015d70c4497d7d58830c2d2327b6438

Issue Description:

CGEventMask is imported as a typealias. The macro #define CGEventMaskBit(eventType) ((CGEventMask)1 << (eventType)) is not imported at all.

I think an optimal solution would import CGEventMask as an OptionSet with members mirroring the CGEventType members.

@jtbandes
Copy link
Collaborator Author

I'd be happy to implement this, but I imagine it's more appropriate to hand off to the CoreGraphics team internally... Who's the right person to ask about this? (@parkera?)

@jtbandes
Copy link
Collaborator Author

Here's an example implementation (as a separate type, not replacing the CGEventMask typealias):

struct CGEventSet: OptionSet {
  let rawValue: CGEventMask
  static let allEvents = ~CGEventMask.allZeros
  
  static let leftMouseDown = CGEventSet(rawValue: UInt64(1 << CGEventType.leftMouseDown.rawValue))
  static let leftMouseUp = CGEventSet(rawValue: UInt64(1 << CGEventType.leftMouseUp.rawValue))
  static let rightMouseDown = CGEventSet(rawValue: UInt64(1 << CGEventType.rightMouseDown.rawValue))
  static let rightMouseUp = CGEventSet(rawValue: UInt64(1 << CGEventType.rightMouseUp.rawValue))
  static let mouseMoved = CGEventSet(rawValue: UInt64(1 << CGEventType.mouseMoved.rawValue))
  static let leftMouseDragged = CGEventSet(rawValue: UInt64(1 << CGEventType.leftMouseDragged.rawValue))
  static let rightMouseDragged = CGEventSet(rawValue: UInt64(1 << CGEventType.rightMouseDragged.rawValue))
  static let keyDown = CGEventSet(rawValue: UInt64(1 << CGEventType.keyDown.rawValue))
  static let keyUp = CGEventSet(rawValue: UInt64(1 << CGEventType.keyUp.rawValue))
  static let flagsChanged = CGEventSet(rawValue: UInt64(1 << CGEventType.flagsChanged.rawValue))
  static let scrollWheel = CGEventSet(rawValue: UInt64(1 << CGEventType.scrollWheel.rawValue))
  static let tabletPointer = CGEventSet(rawValue: UInt64(1 << CGEventType.tabletPointer.rawValue))
  static let tabletProximity = CGEventSet(rawValue: UInt64(1 << CGEventType.tabletProximity.rawValue))
  static let otherMouseDown = CGEventSet(rawValue: UInt64(1 << CGEventType.otherMouseDown.rawValue))
  static let otherMouseUp = CGEventSet(rawValue: UInt64(1 << CGEventType.otherMouseUp.rawValue))
  static let otherMouseDragged = CGEventSet(rawValue: UInt64(1 << CGEventType.otherMouseDragged.rawValue))
  static let tapDisabledByTimeout = CGEventSet(rawValue: UInt64(1 << CGEventType.tapDisabledByTimeout.rawValue))
  static let tapDisabledByUserInput = CGEventSet(rawValue: UInt64(1 << CGEventType.tapDisabledByUserInput.rawValue))
}

@parkera
Copy link
Member

parkera commented Feb 25, 2017

I'll make sure your radar gets sent to the right place. Thanks for filing it.

@parkera
Copy link
Member

parkera commented Feb 25, 2017

(you're right that it should be the CG team which looks at this - each framework owner is responsible for their overlay)

@jtbandes
Copy link
Collaborator Author

Thanks, I appreciate it. On a separate note, I also noticed all the CGEventTap APIs are bizarrely imported as CGEvent.tapCreate, CGEvent.tapEnable, etc. rather than their original names CGEventTapCreate.

@belkadan
Copy link
Contributor

Closing since CoreGraphics is not part of the Swift Open Source project. Thanks for filing the Radar!

@jtbandes
Copy link
Collaborator Author

CG itself isn't part of the open source project, but the overlay is: https://github.com/apple/swift/blob/master/stdlib/public/SDK/CoreGraphics/CoreGraphics.swift

Does that still fall completely under the internal team's purview?

@belkadan
Copy link
Contributor

The overlay is also not part of the open source project from a process perspective. Think of it as a build dependency.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. SDKOverlay
Projects
None yet
Development

No branches or pull requests

3 participants