@@ -17,7 +17,7 @@ import AndroidLooper
1717/// AInputQueue is an opaque handle for the native input queue associated with a window.
1818///
1919/// [See Also](https://developer.android.com/ndk/reference/group/input#ainputqueue)
20- public struct InputQueue : ~ Copyable, Sendable {
20+ public struct InputQueue : ~ Copyable {
2121
2222 // MARK: - Properties
2323
@@ -39,12 +39,14 @@ public struct InputQueue: ~Copyable, Sendable {
3939 /// - callback: The function to call when an event is available.
4040 /// - data: A private data pointer to supply to the callback.
4141 public func attachLooper(
42- _ looper: Looper ,
42+ _ looper: borrowing Looper ,
4343 identifier: Int32 ,
4444 callback: ALooper_callbackFunc ? ,
4545 data: UnsafeMutableRawPointer ?
4646 ) {
47- AInputQueue_attachLooper ( pointer, looper. pointer, identifier, callback, data)
47+ looper. withUnsafePointer { looperPointer in
48+ AInputQueue_attachLooper ( self . pointer, looperPointer, identifier, callback, data)
49+ }
4850 }
4951
5052 /// Remove the input queue from the looper it is currently attached to.
@@ -84,7 +86,7 @@ public struct InputQueue: ~Copyable, Sendable {
8486 /// - Parameter event: The input event to pre-dispatch.
8587 /// - Returns: The result code.
8688 @discardableResult
87- public func preDispatchEvent( _ event: InputEvent ) -> Int32 {
89+ public func preDispatchEvent( _ event: borrowing InputEvent ) -> Int32 {
8890 AInputQueue_preDispatchEvent ( pointer, event. pointer)
8991 }
9092
@@ -95,16 +97,7 @@ public struct InputQueue: ~Copyable, Sendable {
9597 /// - Parameters:
9698 /// - event: The event that was handled.
9799 /// - handled: Whether the event was handled (1) or not (0).
98- public func finishEvent( _ event: InputEvent , handled: Bool ) {
100+ public func finishEvent( _ event: borrowing InputEvent , handled: Bool ) {
99101 AInputQueue_finishEvent ( pointer, event. pointer, handled ? 1 : 0 )
100102 }
101103}
102-
103- #if !os(Android)
104- private func AInputQueue_attachLooper( _ queue: OpaquePointer , _ looper: OpaquePointer , _ ident: Int32 , _ callback: ALooper_callbackFunc ? , _ data: UnsafeMutableRawPointer ? ) { fatalError ( " stub " ) }
105- private func AInputQueue_detachLooper( _ queue: OpaquePointer ) { fatalError ( " stub " ) }
106- private func AInputQueue_hasEvents( _ queue: OpaquePointer ) -> Int32 { fatalError ( " stub " ) }
107- private func AInputQueue_getEvent( _ queue: OpaquePointer , _ outEvent: UnsafeMutablePointer < OpaquePointer ? > ? ) -> Int32 { fatalError ( " stub " ) }
108- private func AInputQueue_preDispatchEvent( _ queue: OpaquePointer , _ event: OpaquePointer ) -> Int32 { fatalError ( " stub " ) }
109- private func AInputQueue_finishEvent( _ queue: OpaquePointer , _ event: OpaquePointer , _ handled: Int32 ) { fatalError ( " stub " ) }
110- #endif
0 commit comments