ui: change active? back to a boolean.

locals-and-roots
John Benediktsson 2016-03-30 07:31:13 -07:00
parent 8e59246a8b
commit 1b71efb748
5 changed files with 19 additions and 22 deletions

View File

@ -13,8 +13,7 @@ ui.gadgets.worlds ui.pixel-formats ui.pixel-formats.private
ui.private words.symbol ; ui.private words.symbol ;
IN: ui.backend.cocoa IN: ui.backend.cocoa
TUPLE: handle ; TUPLE: window-handle view window ;
TUPLE: window-handle < handle view window ;
C: <window-handle> window-handle C: <window-handle> window-handle
@ -144,7 +143,7 @@ M:: cocoa-ui-backend (open-window) ( world -- )
window install-window-delegate window install-window-delegate
view window <window-handle> world handle<< view window <window-handle> world handle<<
window f -> makeKeyAndOrderFront: window f -> makeKeyAndOrderFront:
100 world active?<< ; t world active?<< ;
M: cocoa-ui-backend (close-window) ( handle -- ) M: cocoa-ui-backend (close-window) ( handle -- )
[ [
@ -180,19 +179,17 @@ M: cocoa-ui-backend raise-window* ( world -- )
NSApp 1 -> activateIgnoringOtherApps: NSApp 1 -> activateIgnoringOtherApps:
] when* ; ] when* ;
GENERIC: (gl-context) ( handle -- context ) M: window-handle select-gl-context ( handle -- )
M: window-handle (gl-context) view>> -> openGLContext ; view>> -> openGLContext -> makeCurrentContext ;
M: handle select-gl-context ( handle -- ) M: window-handle flush-gl-context ( handle -- )
(gl-context) -> makeCurrentContext ; view>> -> openGLContext -> flushBuffer ;
M: handle flush-gl-context ( handle -- )
(gl-context) -> flushBuffer ;
M: cocoa-ui-backend beep ( -- ) M: cocoa-ui-backend beep ( -- )
NSBeep ; NSBeep ;
M: cocoa-ui-backend resize-window [ handle>> window>> ] [ first2 ] bi* <CGSize> -> setContentSize: ; M: cocoa-ui-backend resize-window
[ handle>> window>> ] [ first2 ] bi* <CGSize> -> setContentSize: ;
M: cocoa-ui-backend system-alert M: cocoa-ui-backend system-alert
NSAlert -> alloc -> init -> autorelease [ NSAlert -> alloc -> init -> autorelease [

View File

@ -229,14 +229,14 @@ CONSTANT: action-key-codes
2drop window relayout t ; 2drop window relayout t ;
: on-configure ( win event user-data -- ? ) : on-configure ( win event user-data -- ? )
drop swap window dup active?>> 100 = [ drop swap window dup active?>> [
swap GdkEventConfigure memory>struct swap GdkEventConfigure memory>struct
[ event-loc >>window-loc ] [ event-dim >>dim ] bi [ event-loc >>window-loc ] [ event-dim >>dim ] bi
relayout-1 relayout-1
] [ 2drop ] if f ; ] [ 2drop ] if f ;
: on-map ( win event user-data -- ? ) : on-map ( win event user-data -- ? )
2drop window 100 >>active? drop t ; 2drop window t >>active? drop t ;
: on-delete ( win event user-data -- ? ) : on-delete ( win event user-data -- ? )
2drop window ungraft t ; 2drop window ungraft t ;

View File

@ -271,7 +271,7 @@ CONSTANT: window-control>ex-style
: handle-wm-paint ( hWnd uMsg wParam lParam -- ) : handle-wm-paint ( hWnd uMsg wParam lParam -- )
! wParam and lParam are unused ! wParam and lParam are unused
! only paint if width/height both > 0 ! only paint if width/height both > 0
3drop window 100 >>active? relayout-1 yield ; 3drop window t >>active? relayout-1 yield ;
: handle-wm-size ( hWnd uMsg wParam lParam -- ) : handle-wm-size ( hWnd uMsg wParam lParam -- )
2nip 2nip
@ -411,9 +411,9 @@ CONSTANT: exclude-keys-wm-char
: handle-wm-syscommand ( hWnd uMsg wParam lParam -- n ) : handle-wm-syscommand ( hWnd uMsg wParam lParam -- n )
{ {
{ [ over SC_MINIMIZE = ] [ 0 set-window-active ] } { [ over SC_MINIMIZE = ] [ f set-window-active ] }
{ [ over SC_RESTORE = ] [ 100 set-window-active ] } { [ over SC_RESTORE = ] [ t set-window-active ] }
{ [ over SC_MAXIMIZE = ] [ 100 set-window-active ] } { [ over SC_MAXIMIZE = ] [ t set-window-active ] }
{ [ dup alpha? ] [ 4drop 0 ] } { [ dup alpha? ] [ 4drop 0 ] }
{ [ t ] [ DefWindowProc ] } { [ t ] [ DefWindowProc ] }
} cond ; } cond ;

View File

@ -57,7 +57,7 @@ M: world expose-event nip relayout ;
M: world configure-event M: world configure-event
swap [ event-loc >>window-loc ] [ event-dim >>dim ] bi swap [ event-loc >>window-loc ] [ event-dim >>dim ] bi
100 >>active? t >>active?
! In case dimensions didn't change ! In case dimensions didn't change
relayout-1 ; relayout-1 ;

View File

@ -118,7 +118,7 @@ M: world request-focus-on ( child gadget -- )
: new-world ( class -- world ) : new-world ( class -- world )
vertical swap new-track vertical swap new-track
t >>root? t >>root?
0 >>active? f >>active?
{ 0 0 } >>window-loc { 0 0 } >>window-loc
f >>grab-input? f >>grab-input?
V{ } clone >>window-resources V{ } clone >>window-resources
@ -177,7 +177,7 @@ M: world resize-world drop ;
M: world dim<< M: world dim<<
[ call-next-method ] [ call-next-method ]
[ [
dup active?>> 100 = [ dup active?>> [
dup handle>> dup handle>>
[ [ set-gl-context ] [ resize-world ] bi ] [ [ set-gl-context ] [ resize-world ] bi ]
[ drop ] if [ drop ] if
@ -197,7 +197,7 @@ M: world draw-world*
: draw-world? ( world -- ? ) : draw-world? ( world -- ? )
! We don't draw deactivated worlds, or those with 0 size. ! We don't draw deactivated worlds, or those with 0 size.
! On Windows, the latter case results in GL errors. ! On Windows, the latter case results in GL errors.
{ [ active?>> 100 = ] [ handle>> ] [ dim>> [ 0 > ] all? ] } 1&& ; { [ active?>> ] [ handle>> ] [ dim>> [ 0 > ] all? ] } 1&& ;
TUPLE: world-error error world ; TUPLE: world-error error world ;
@ -217,7 +217,7 @@ ui-error-hook [ [ rethrow ] ] initialize
dup [ draw-world* ] with-gl-context dup [ draw-world* ] with-gl-context
flush-layout-cache-hook get call( -- ) flush-layout-cache-hook get call( -- )
] [ ] [
swap 0 >>active? <world-error> ui-error swap f >>active? <world-error> ui-error
] recover ] recover
] with-variable ] with-variable
] [ drop ] if ; ] [ drop ] if ;