input grabbing support
parent
ba213bdc34
commit
9992817c65
|
@ -105,6 +105,15 @@ CONSTANT: kCGLRendererGenericFloatID HEX: 00020400
|
|||
|
||||
FUNCTION: CGLError CGLSetParameter ( CGLContextObj ctx, CGLContextParameter pname, GLint* params ) ;
|
||||
|
||||
FUNCTION: CGDirectDisplayID CGMainDisplayID ( ) ;
|
||||
|
||||
FUNCTION: CGError CGDisplayHideCursor ( CGDirectDisplayID display ) ;
|
||||
FUNCTION: CGError CGDisplayShowCursor ( CGDirectDisplayID display ) ;
|
||||
|
||||
FUNCTION: CGError CGAssociateMouseAndMouseCursorPosition ( boolean_t connected ) ;
|
||||
|
||||
FUNCTION: CGError CGWarpMouseCursorPosition ( CGPoint newCursorPosition ) ;
|
||||
|
||||
<PRIVATE
|
||||
|
||||
: bitmap-flags ( -- flags )
|
||||
|
|
|
@ -90,5 +90,8 @@ TYPEDEF: void* CGContextRef
|
|||
TYPEDEF: uint CGBitmapInfo
|
||||
|
||||
TYPEDEF: int CGLError
|
||||
TYPEDEF: int CGError
|
||||
TYPEDEF: uint CGDirectDisplayID
|
||||
TYPEDEF: int boolean_t
|
||||
TYPEDEF: void* CGLContextObj
|
||||
TYPEDEF: int CGLContextParameter
|
|
@ -21,6 +21,8 @@ M: rect pprint*
|
|||
|
||||
: rect-extent ( rect -- loc ext ) rect-bounds over v+ ;
|
||||
|
||||
: rect-center ( rect -- center ) rect-bounds 2 v/n v+ ;
|
||||
|
||||
: with-rect-extents ( rect1 rect2 loc-quot: ( loc1 loc2 -- ) ext-quot: ( ext1 ext2 -- ) -- )
|
||||
[ [ rect-extent ] bi@ ] 2dip bi-curry* bi* ; inline
|
||||
|
||||
|
|
|
@ -32,3 +32,7 @@ HOOK: offscreen-pixels ui-backend ( world -- alien w h )
|
|||
[ flush-gl-context gl-error ] bi ; inline
|
||||
|
||||
HOOK: (with-ui) ui-backend ( quot -- )
|
||||
|
||||
HOOK: (grab-input) ui-backend ( handle -- )
|
||||
|
||||
HOOK: (ungrab-input) ui-backend ( handle -- )
|
||||
|
|
|
@ -122,6 +122,17 @@ M:: cocoa-ui-backend (open-window) ( world -- )
|
|||
M: cocoa-ui-backend (close-window) ( handle -- )
|
||||
window>> -> release ;
|
||||
|
||||
M: cocoa-ui-backend (grab-input) ( handle -- )
|
||||
0 CGAssociateMouseAndMouseCursorPosition drop
|
||||
CGMainDisplayID CGDisplayHideCursor drop
|
||||
window>> -> frame CGRect>rect rect-center
|
||||
first2 <CGPoint> CGWarpMouseCursorPosition drop ;
|
||||
|
||||
M: cocoa-ui-backend (ungrab-input) ( handle -- )
|
||||
drop
|
||||
CGMainDisplayID CGDisplayShowCursor drop
|
||||
1 CGAssociateMouseAndMouseCursorPosition drop ;
|
||||
|
||||
M: cocoa-ui-backend close-window ( gadget -- )
|
||||
find-world [
|
||||
handle>> [
|
||||
|
|
|
@ -706,6 +706,14 @@ M: windows-ui-backend beep ( -- )
|
|||
: hwnd>RECT ( hwnd -- RECT )
|
||||
"RECT" <c-object> [ GetWindowRect win32-error=0/f ] keep ;
|
||||
|
||||
M: windows-ui-backend (grab-input) ( handle -- )
|
||||
0 ShowCursor drop
|
||||
hWnd>> hwnd>RECT ClipCursor drop ;
|
||||
M: windows-ui-backend (ungrab-input) ( handle -- )
|
||||
drop
|
||||
f ClipCursor drop
|
||||
1 ShowCursor drop ;
|
||||
|
||||
: fullscreen-flags ( -- n )
|
||||
{ WS_CAPTION WS_BORDER WS_THICKFRAME } flags ; inline
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ CONSTANT: default-world-pixel-format-attributes
|
|||
{ windowed double-buffered T{ depth-bits { value 16 } } }
|
||||
|
||||
TUPLE: world < track
|
||||
active? focused?
|
||||
active? focused? grab-input?
|
||||
layers
|
||||
title status status-owner
|
||||
text-handle handle images
|
||||
|
@ -20,6 +20,7 @@ TUPLE: world < track
|
|||
|
||||
TUPLE: world-attributes
|
||||
{ world-class initial: world }
|
||||
grab-input?
|
||||
title
|
||||
status
|
||||
gadgets
|
||||
|
@ -63,13 +64,15 @@ M: world request-focus-on ( child gadget -- )
|
|||
vertical swap new-track
|
||||
t >>root?
|
||||
t >>active?
|
||||
{ 0 0 } >>window-loc ;
|
||||
{ 0 0 } >>window-loc
|
||||
f >>grab-input? ;
|
||||
|
||||
: apply-world-attributes ( world attributes -- world )
|
||||
{
|
||||
[ title>> >>title ]
|
||||
[ status>> >>status ]
|
||||
[ pixel-format-attributes>> >>pixel-format-attributes ]
|
||||
[ grab-input?>> >>grab-input? ]
|
||||
[ gadgets>> [ 1 track-add ] each ]
|
||||
} cleave ;
|
||||
|
||||
|
|
|
@ -41,14 +41,23 @@ SYMBOL: windows
|
|||
lose-focus swap each-gesture
|
||||
gain-focus swap each-gesture ;
|
||||
|
||||
: ?grab-input ( world -- )
|
||||
dup grab-input?>> [ handle>> (grab-input) ] [ drop ] if ;
|
||||
|
||||
: ?ungrab-input ( world -- )
|
||||
dup grab-input?>> [ handle>> (ungrab-input) ] [ drop ] if ;
|
||||
|
||||
: focus-world ( world -- )
|
||||
t >>focused?
|
||||
dup raised-window
|
||||
focus-path f focus-gestures ;
|
||||
[ ?grab-input ] [
|
||||
dup raised-window
|
||||
focus-path f focus-gestures
|
||||
] bi ;
|
||||
|
||||
: unfocus-world ( world -- )
|
||||
f >>focused?
|
||||
focus-path f swap focus-gestures ;
|
||||
[ ?ungrab-input ]
|
||||
[ focus-path f swap focus-gestures ] bi ;
|
||||
|
||||
: try-to-open-window ( world -- )
|
||||
{
|
||||
|
|
|
@ -654,7 +654,7 @@ FUNCTION: HWND ChildWindowFromPoint ( HWND hWndParent, POINT point ) ;
|
|||
! FUNCTION: ClientThreadSetup
|
||||
! FUNCTION: ClientToScreen
|
||||
! FUNCTION: CliImmSetHotKey
|
||||
! FUNCTION: ClipCursor
|
||||
FUNCTION: int ClipCursor ( RECT* clipRect ) ;
|
||||
FUNCTION: BOOL CloseClipboard ( ) ;
|
||||
! FUNCTION: CloseDesktop
|
||||
! FUNCTION: CloseWindow
|
||||
|
@ -1363,7 +1363,7 @@ CONSTANT: HWND_TOP f
|
|||
! FUNCTION: SetWindowWord
|
||||
! FUNCTION: SetWinEventHook
|
||||
! FUNCTION: ShowCaret
|
||||
! FUNCTION: ShowCursor
|
||||
FUNCTION: int ShowCursor ( BOOL show ) ;
|
||||
! FUNCTION: ShowOwnedPopups
|
||||
! FUNCTION: ShowScrollBar
|
||||
! FUNCTION: ShowStartGlass
|
||||
|
|
|
@ -186,5 +186,6 @@ M: terrain-world pref-dim* drop { 640 480 } ;
|
|||
double-buffered
|
||||
T{ depth-bits { value 24 } }
|
||||
} }
|
||||
{ grab-input? t }
|
||||
} open-window
|
||||
] with-ui ;
|
||||
|
|
Loading…
Reference in New Issue