ui.backend: refactor the UI `main-vocab-hook` to use a backend-specific `ui-backend-available?` word, so that loading other backends doesn't change the `main-vocab-hook` out of sync with the backend; fixes #131

db4
Joe Groff 2011-09-15 11:27:16 -07:00
parent 4726757d95
commit 9bd84e73f4
5 changed files with 19 additions and 6 deletions

View File

@ -1,6 +1,6 @@
! Copyright (C) 2006, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel namespaces opengl opengl.gl fry ;
USING: command-line kernel namespaces opengl opengl.gl fry ;
IN: ui.backend
SYMBOL: ui-backend
@ -32,3 +32,10 @@ HOOK: (with-ui) ui-backend ( quot -- )
HOOK: (grab-input) ui-backend ( handle -- )
HOOK: (ungrab-input) ui-backend ( handle -- )
HOOK: ui-backend-available? ui-backend ( -- ? )
M: object ui-backend-available?
f ;
[ ui-backend-available? "ui.tools" "listener" ? ] main-vocab-hook set-global

View File

@ -256,4 +256,6 @@ M: cocoa-ui-backend (with-ui)
cocoa-ui-backend ui-backend set-global
[ running.app? "ui.tools" "listener" ? ] main-vocab-hook set-global
M: cocoa-ui-backend ui-backend-available?
running.app? ;

View File

@ -539,4 +539,6 @@ os unix? os macosx? not and [
{ "ui.backend.gtk" "ui.gadgets.editors" }
"ui.backend.gtk.input-methods.editors" require-when
[ "DISPLAY" os-env "ui.tools" "listener" ? ] main-vocab-hook set-global
M: gtk-ui-backend ui-backend-available?
"DISPLAY" os-env >boolean ;

View File

@ -861,6 +861,8 @@ M: windows-ui-backend (fullscreen?) ( world -- ? )
[ hwnd>RECT ] [ fullscreen-RECT ] bi
[ get-RECT-dimensions 2array 2nip ] bi@ = ;
M: windows-ui-backend ui-backend-available?
t ;
windows-ui-backend ui-backend set-global
[ "ui.tools" ] main-vocab-hook set-global

View File

@ -414,5 +414,5 @@ M: x11-ui-backend (ungrab-input)
x11-ui-backend ui-backend set-global
[ "DISPLAY" os-env "ui.tools" "listener" ? ]
main-vocab-hook set-global
M: x11-ui-backend ui-backend-available?
"DISPLAY" os-env >boolean ;