Fix race condition with opening windows which affected get-workspace

release
Slava Pestov 2007-11-24 22:09:40 -05:00
parent 30541ec78a
commit 4b92d10d64
5 changed files with 23 additions and 23 deletions

View File

@ -19,7 +19,7 @@ SYMBOL: stop-after-last-window?
: event-loop ( -- )
event-loop? [
[
[ NSApp do-events ui-step ] ui-try
[ NSApp do-events ui-step 10 sleep ] ui-try
] with-autorelease-pool event-loop
] when ;

View File

@ -2,11 +2,10 @@
! See http://factorcode.org/license.txt for BSD license.
USING: classes continuations help help.topics kernel models
sequences ui ui.backend ui.tools.debugger ui.gadgets
ui.gadgets.books ui.gadgets.buttons
ui.gadgets.labelled ui.gadgets.panes ui.gadgets.scrollers
ui.gadgets.tracks ui.gadgets.worlds ui.gadgets.presentations
ui.gadgets.status-bar ui.commands ui.gestures assocs arrays
namespaces ;
ui.gadgets.books ui.gadgets.buttons ui.gadgets.labelled
ui.gadgets.panes ui.gadgets.scrollers ui.gadgets.tracks
ui.gadgets.worlds ui.gadgets.presentations ui.gadgets.status-bar
ui.commands ui.gestures assocs arrays namespaces ;
IN: ui.tools.workspace
TUPLE: workspace book listener popup ;

View File

@ -65,18 +65,6 @@ M: world ungraft*
dup world-handle (close-window)
reset-world ;
: open-world-window ( world -- )
dup pref-dim over set-gadget-dim dup relayout graft ;
: open-window ( gadget title -- )
>r [ 1 track, ] { 0 1 } make-track r>
f <world> open-world-window ;
HOOK: close-window ui-backend ( gadget -- )
M: object close-window
find-world [ ungraft ] when* ;
: find-window ( quot -- world )
windows get values
[ gadget-child swap call ] curry* find-last nip ; inline
@ -148,9 +136,20 @@ SYMBOL: ui-hook
notify-queued
layout-queued
redraw-worlds
10 sleep
] assert-depth ;
: open-world-window ( world -- )
dup pref-dim over set-gadget-dim dup relayout graft ui-step ;
: open-window ( gadget title -- )
>r [ 1 track, ] { 0 1 } make-track r>
f <world> open-world-window ;
HOOK: close-window ui-backend ( gadget -- )
M: object close-window
find-world [ ungraft ] when* ;
: start-ui ( -- )
init-timers
restore-windows? [

View File

@ -94,8 +94,7 @@ SYMBOL: mouse-captured
3drop window draw-world ;
: handle-wm-size ( hWnd uMsg wParam lParam -- )
[ lo-word ] keep hi-word make-RECT get-RECT-dimensions 2array
2nip
[ lo-word ] keep hi-word make-RECT get-RECT-dimensions 2array 2nip
dup { 0 0 } = [ 2drop ] [ swap window set-gadget-dim ui-step ] if ;
: wm-keydown-codes ( -- key )
@ -348,7 +347,10 @@ M: windows-ui-backend (close-window)
: event-loop ( msg -- )
{
{ [ windows get empty? ] [ drop ] }
{ [ dup peek-message? ] [ >r [ ui-step ] ui-try r> event-loop ] }
{ [ dup peek-message? ] [
>r [ ui-step 10 sleep ] ui-try
r> event-loop
] }
{ [ dup MSG-message WM_QUIT = ] [ drop ] }
{ [ t ] [
dup TranslateMessage drop

View File

@ -178,7 +178,7 @@ M: world client-event
next-event dup
None XFilterEvent zero? [ drop wait-event ] unless
] [
ui-step wait-event
ui-step 10 sleep wait-event
] if ;
: do-events ( -- )