ui: undoing 9e9b70005b
The ui-thread variable absolutely is needed to ensure that only one UI thread is running at the same time. If more than one UI thread runs, they will be competing for events which causes all sorts of problems.factor-shell
parent
9f1935c7f1
commit
f93da595f5
|
@ -6,10 +6,26 @@ vocabs.loader ;
|
||||||
|
|
||||||
IN: ui
|
IN: ui
|
||||||
|
|
||||||
|
HELP: close-window
|
||||||
|
{ $values { "gadget" gadget } }
|
||||||
|
{ $description "Close the native window containing " { $snippet "gadget" } "." } ;
|
||||||
|
|
||||||
HELP: open-window
|
HELP: open-window
|
||||||
{ $values { "gadget" gadget } { "title/attributes" { "a " { $link string } " or a " { $link world-attributes } " tuple" } } }
|
{ $values { "gadget" gadget } { "title/attributes" { "a " { $link string } " or a " { $link world-attributes } " tuple" } } }
|
||||||
{ $description "Opens a native window containing " { $snippet "gadget" } " with the specified attributes. If a string is provided, it is used as the window title; otherwise, the window attributes are specified in a " { $link world-attributes } " tuple." } ;
|
{ $description "Opens a native window containing " { $snippet "gadget" } " with the specified attributes. If a string is provided, it is used as the window title; otherwise, the window attributes are specified in a " { $link world-attributes } " tuple." } ;
|
||||||
|
|
||||||
|
HELP: set-fullscreen
|
||||||
|
{ $values { "gadget" gadget } { "?" boolean } }
|
||||||
|
{ $description "Sets and unsets fullscreen mode for the gadget's world." } ;
|
||||||
|
|
||||||
|
HELP: set-up-window
|
||||||
|
{ $values { "world" world } }
|
||||||
|
{ $description "Initializes the window that shows the world." } ;
|
||||||
|
|
||||||
|
HELP: ui-thread
|
||||||
|
{ $var-description "Holds a reference to the running UI thread. This variable is used to ensure that there can only be one UI thread running at the same time." }
|
||||||
|
{ $see-also start-ui-thread } ;
|
||||||
|
|
||||||
HELP: ui-running?
|
HELP: ui-running?
|
||||||
{ $values { "?" boolean } }
|
{ $values { "?" boolean } }
|
||||||
{ $description "Whether the UI is running or not." } ;
|
{ $description "Whether the UI is running or not." } ;
|
||||||
|
@ -19,10 +35,6 @@ HELP: ui-windows
|
||||||
|
|
||||||
{ ui-windows open-window find-window world-attributes } related-words
|
{ ui-windows open-window find-window world-attributes } related-words
|
||||||
|
|
||||||
HELP: close-window
|
|
||||||
{ $values { "gadget" gadget } }
|
|
||||||
{ $description "Close the native window containing " { $snippet "gadget" } "." } ;
|
|
||||||
|
|
||||||
HELP: world-attributes
|
HELP: world-attributes
|
||||||
{ $values { "world-class" class } { "title" string } { "status" gadget } { "gadgets" sequence } { "pixel-format-attributes" sequence } { "window-controls" sequence } }
|
{ $values { "world-class" class } { "title" string } { "status" gadget } { "gadgets" sequence } { "pixel-format-attributes" sequence } { "window-controls" sequence } }
|
||||||
{ $class-description "Tuples of this class can be passed to " { $link open-window } " to control attributes of the window opened. The following attributes can be set:" }
|
{ $class-description "Tuples of this class can be passed to " { $link open-window } " to control attributes of the window opened. The following attributes can be set:" }
|
||||||
|
@ -35,14 +47,6 @@ HELP: world-attributes
|
||||||
{ { $snippet "window-controls" } " is a sequence of " { $link "ui.gadgets.worlds-window-controls" } " that will be placed in the window." }
|
{ { $snippet "window-controls" } " is a sequence of " { $link "ui.gadgets.worlds-window-controls" } " that will be placed in the window." }
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
HELP: set-fullscreen
|
|
||||||
{ $values { "gadget" gadget } { "?" boolean } }
|
|
||||||
{ $description "Sets and unsets fullscreen mode for the gadget's world." } ;
|
|
||||||
|
|
||||||
HELP: set-up-window
|
|
||||||
{ $values { "world" world } }
|
|
||||||
{ $description "Initializes the window that shows the world." } ;
|
|
||||||
|
|
||||||
HELP: fullscreen?
|
HELP: fullscreen?
|
||||||
{ $values { "gadget" gadget } { "?" boolean } }
|
{ $values { "gadget" gadget } { "?" boolean } }
|
||||||
{ $description "Queries the gadget's world to see if it is running in fullscreen mode." } ;
|
{ $description "Queries the gadget's world to see if it is running in fullscreen mode." } ;
|
||||||
|
|
|
@ -150,12 +150,14 @@ PRIVATE>
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
|
SYMBOL: ui-thread
|
||||||
|
|
||||||
: update-ui-loop ( -- )
|
: update-ui-loop ( -- )
|
||||||
! Note the logic: if update-ui fails, we open an error window and
|
! Note the logic: if update-ui fails, we open an error window and
|
||||||
! run one iteration of update-ui. If that also fails, well, the
|
! run one iteration of update-ui. If that also fails, well, the
|
||||||
! whole UI subsystem is broken so we throw the error to terminate
|
! whole UI subsystem is broken so we throw the error to terminate
|
||||||
! the update-ui-loop.
|
! the update-ui-loop.
|
||||||
[ ui-running? ]
|
[ { [ ui-running? ] [ ui-thread get-global self eq? ] } 0&& ]
|
||||||
[
|
[
|
||||||
ui-notify-flag get lower-flag
|
ui-notify-flag get lower-flag
|
||||||
[ update-ui ] [
|
[ update-ui ] [
|
||||||
|
@ -166,7 +168,8 @@ PRIVATE>
|
||||||
] while ;
|
] while ;
|
||||||
|
|
||||||
: start-ui-thread ( -- )
|
: start-ui-thread ( -- )
|
||||||
[ update-ui-loop ] "UI update" spawn drop ;
|
[ self ui-thread set-global update-ui-loop ]
|
||||||
|
"UI update" spawn drop ;
|
||||||
|
|
||||||
: start-ui ( quot -- )
|
: start-ui ( quot -- )
|
||||||
call( -- ) notify-ui-thread start-ui-thread ;
|
call( -- ) notify-ui-thread start-ui-thread ;
|
||||||
|
|
Loading…
Reference in New Issue