Skip to content

Commit af9adda

Browse files
committed
cocoa: try to fix bug where my ui hangs under arm64
1 parent 3912c21 commit af9adda

4 files changed

Lines changed: 18 additions & 8 deletions

File tree

basis/cocoa/runtime/runtime.factor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ FUNCTION: Protocol objc_getProtocol ( c-string class )
4343
FUNCTION: Class objc_allocateClassPair ( Class superclass, c-string name, size_t extraBytes )
4444
FUNCTION: void objc_registerClassPair ( Class cls )
4545

46-
FUNCTION: void* objc_getAssociatedObject ( void* obj, c-string key )
46+
FUNCTION: void* objc_getAssociatedObject ( void* obj, void* key )
4747

4848
FUNCTION: id class_createInstance ( Class class, uint additionalByteCount )
4949

basis/cocoa/statusbar/statusbar.factor

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ TUPLE: platform-menu-item title { quot callable } key-equivalent selector target
8585
: hide-statusbar-item ( statusbar-item-alien -- )
8686
[ get-system-statusbar ] dip -> removeStatusItem: ;
8787

88-
: hide-statusbar* ( platform-menu -- )
89-
[ get-system-statusbar ] dip -> removeStatusItem: ;
88+
: hide-statusbar* ( statusbar-item-alien -- )
89+
[ [ get-system-statusbar ] dip -> removeStatusItem: ] keep
90+
-> release ;
9091

9192
: hide-statusbar ( platform-menu -- platform-menu )
9293
[ statusbar-alien>> hide-statusbar* ] keep ;

basis/core-graphics/core-graphics.factor

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ FUNCTION: CGLError CGLSetParameter ( CGLContextObj ctx, CGLContextParameter pnam
151151

152152
FUNCTION: CGDirectDisplayID CGMainDisplayID ( )
153153

154+
FUNCTION: boolean_t CGDisplayIsAsleep ( CGDirectDisplayID display )
155+
154156
FUNCTION: CGError CGDisplayHideCursor ( CGDirectDisplayID display )
155157
FUNCTION: CGError CGDisplayShowCursor ( CGDirectDisplayID display )
156158

basis/ui/backend/cocoa/cocoa.factor

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
USING: accessors alien.c-types alien.data cocoa
44
cocoa.application cocoa.classes cocoa.nibs cocoa.pasteboard
55
cocoa.runtime cocoa.subclassing cocoa.views cocoa.windows
6-
combinators core-foundation.run-loop core-foundation.strings
7-
core-graphics core-graphics.types io.thread kernel literals math
8-
math.bitwise math.rectangles namespaces sequences threads ui
6+
combinators continuations core-foundation.run-loop
7+
core-foundation.strings core-graphics core-graphics.types debugger
8+
io.thread kernel
9+
literals math math.bitwise math.rectangles namespaces sequences
10+
threads ui
911
ui.backend ui.backend.cocoa.views ui.clipboards
1012
ui.gadgets.worlds ui.pixel-formats ui.private ui.render ui.theme
1113
ui.theme.switching ;
@@ -181,8 +183,12 @@ M: cocoa-ui-backend raise-window*
181183
M: window-handle select-gl-context
182184
view>> -> openGLContext -> makeCurrentContext ;
183185

186+
: display-asleep? ( -- ? )
187+
CGMainDisplayID CGDisplayIsAsleep c-bool> ;
188+
184189
M: window-handle flush-gl-context
185-
view>> -> openGLContext -> flushBuffer ;
190+
display-asleep?
191+
[ drop ] [ view>> -> openGLContext -> flushBuffer ] if ;
186192

187193
M: cocoa-ui-backend beep
188194
NSBeep ;
@@ -202,7 +208,8 @@ M: cocoa-ui-backend system-alert
202208

203209
<CLASS: FactorApplicationDelegate < NSObject
204210

205-
METHOD: void applicationDidUpdate: id obj [ reset-thread-timer ] ;
211+
METHOD: void applicationDidUpdate: id obj
212+
[ [ reset-thread-timer ] [ print-error ] recover ] ;
206213

207214
METHOD: char applicationShouldTerminateAfterLastWindowClosed: id app [
208215
ui-stop-after-last-window? get 1 0 ?

0 commit comments

Comments
 (0)