mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-07 02:15:34 +00:00
app: replace C-to-Go handle maps with cgo.Handle
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+17
-6
@@ -123,10 +123,6 @@ static void handleTouches(int last, UIView *view, NSSet<UITouch *> *touches, UIE
|
||||
|
||||
@implementation GioView
|
||||
NSArray<UIKeyCommand *> *_keyCommands;
|
||||
+ (void)onFrameCallback:(CADisplayLink *)link {
|
||||
gio_onFrameCallback((__bridge CFTypeRef)link);
|
||||
}
|
||||
|
||||
+ (Class)layerClass {
|
||||
return gio_layerClass();
|
||||
}
|
||||
@@ -231,8 +227,23 @@ NSArray<UIKeyCommand *> *_keyCommands;
|
||||
}
|
||||
@end
|
||||
|
||||
CFTypeRef gio_createDisplayLink(void) {
|
||||
CADisplayLink *dl = [CADisplayLink displayLinkWithTarget:[GioView class] selector:@selector(onFrameCallback:)];
|
||||
@interface DisplayLinkHandle : NSObject {
|
||||
}
|
||||
@property uintptr_t handle;
|
||||
@end
|
||||
|
||||
@implementation DisplayLinkHandle {
|
||||
}
|
||||
|
||||
- (void)onFrameCallback:(CADisplayLink *)link {
|
||||
gio_onFrameCallback((__bridge CFTypeRef)link, _handle);
|
||||
}
|
||||
@end
|
||||
|
||||
CFTypeRef gio_createDisplayLink(uintptr_t handle) {
|
||||
DisplayLinkHandle *h = [DisplayLinkHandle alloc];
|
||||
h.handle = handle;
|
||||
CADisplayLink *dl = [CADisplayLink displayLinkWithTarget:h selector:@selector(onFrameCallback:)];
|
||||
dl.paused = YES;
|
||||
NSRunLoop *runLoop = [NSRunLoop mainRunLoop];
|
||||
[dl addToRunLoop:runLoop forMode:[runLoop currentMode]];
|
||||
|
||||
Reference in New Issue
Block a user