mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
app/internal/window: [iOS] move main thread dispatch to Go
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -200,14 +200,19 @@ func onTouch(last C.int, view, touchRef C.CFTypeRef, phase C.NSInteger, x, y C.C
|
||||
}
|
||||
|
||||
func (w *window) SetAnimating(anim bool) {
|
||||
if w.view == 0 {
|
||||
v := w.view
|
||||
if v == 0 {
|
||||
return
|
||||
}
|
||||
var animi C.int
|
||||
if anim {
|
||||
animi = 1
|
||||
}
|
||||
C.gio_setAnimating(w.view, animi)
|
||||
C.CFRetain(v)
|
||||
runOnMain(func() {
|
||||
defer C.CFRelease(v)
|
||||
C.gio_setAnimating(v, animi)
|
||||
})
|
||||
}
|
||||
|
||||
func (w *window) onKeyCommand(name string) {
|
||||
@@ -245,14 +250,19 @@ func (w *window) isVisible() bool {
|
||||
}
|
||||
|
||||
func (w *window) ShowTextInput(show bool) {
|
||||
if w.view == 0 {
|
||||
v := w.view
|
||||
if v == 0 {
|
||||
return
|
||||
}
|
||||
if show {
|
||||
C.gio_showTextInput(w.view)
|
||||
} else {
|
||||
C.gio_hideTextInput(w.view)
|
||||
}
|
||||
C.CFRetain(v)
|
||||
runOnMain(func() {
|
||||
defer C.CFRelease(v)
|
||||
if show {
|
||||
C.gio_showTextInput(w.view)
|
||||
} else {
|
||||
C.gio_hideTextInput(w.view)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func NewWindow(win Callbacks, opts *Options) error {
|
||||
|
||||
@@ -281,23 +281,17 @@ NSArray<UIKeyCommand *> *_keyCommands;
|
||||
|
||||
void gio_setAnimating(CFTypeRef viewRef, int anim) {
|
||||
GioView *view = (__bridge GioView *)viewRef;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[view setAnimating:(anim ? YES : NO)];
|
||||
});
|
||||
[view setAnimating:(anim ? YES : NO)];
|
||||
}
|
||||
|
||||
void gio_showTextInput(CFTypeRef viewRef) {
|
||||
UIView *view = (__bridge UIView *)viewRef;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[view becomeFirstResponder];
|
||||
});
|
||||
[view becomeFirstResponder];
|
||||
}
|
||||
|
||||
void gio_hideTextInput(CFTypeRef viewRef) {
|
||||
UIView *view = (__bridge UIView *)viewRef;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[view resignFirstResponder];
|
||||
});
|
||||
[view resignFirstResponder];
|
||||
}
|
||||
|
||||
void gio_addLayerToView(CFTypeRef viewRef, CFTypeRef layerRef) {
|
||||
|
||||
Reference in New Issue
Block a user