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