windows.factor KUSUMOTO Norio plan 2

bug fix for issue #1

Review of the structure of words

NUMPAD&OEM-keydown-codes

plugable keyboard info

keyboard auto detect

conflict

ToUnicode version

resolve conflicts

ui.backend.windows: fix whitespace
clean-macosx-x86-32
KUSUMOTO Norio 2019-04-03 22:00:45 +09:00 committed by Doug Coleman
parent 968fea56d0
commit 08aa27a112
2 changed files with 31 additions and 30 deletions

View File

@ -9,7 +9,7 @@ threads ui ui.backend ui.clipboards ui.event-loop ui.gadgets
ui.gadgets.private ui.gadgets.worlds ui.gestures ui.pixel-formats ui.gadgets.private ui.gadgets.worlds ui.gestures ui.pixel-formats
ui.private windows.dwmapi windows.errors windows.gdi32 ui.private windows.dwmapi windows.errors windows.gdi32
windows.kernel32 windows.messages windows.offscreen windows.opengl32 windows.kernel32 windows.messages windows.offscreen windows.opengl32
windows.types windows.user32 assocs.extras ; windows.types windows.user32 assocs.extras byte-arrays ;
SPECIALIZED-ARRAY: POINT SPECIALIZED-ARRAY: POINT
QUALIFIED-WITH: alien.c-types c QUALIFIED-WITH: alien.c-types c
IN: ui.backend.windows IN: ui.backend.windows
@ -321,40 +321,41 @@ CONSTANT: exclude-keys-wm-char
: send-key-up ( sym action? hWnd -- ) : send-key-up ( sym action? hWnd -- )
[ [ <key-up> ] ] dip send-key-gesture ; [ [ <key-up> ] ] dip send-key-gesture ;
: key-sym ( wParam -- string/f action? ) : key-sym ( wParam -- string/f )
{ wm-keydown-codes at ; inline
{
[ dup LETTER? ]
[ shift? caps-lock? xor [ CHAR: a + CHAR: A - ] unless 1string f ]
}
{ [ dup digit? ] [ 1string f ] }
[ wm-keydown-codes at t ]
} cond ;
:: handle-wm-keydown ( hWnd uMsg wParam lParam -- ) :: (handle-wm-keydown/up) ( hWnd uMsg wParam lParam send-key-down/up -- )
wParam exclude-key-wm-keydown? [ wParam exclude-key-wm-keydown? [
wParam key-sym over [ wParam key-sym [
dup ctrl? alt? xor or [ t hWnd send-key-down/up execute( sym action? hWnd -- )
hWnd send-key-down ] [
] [ 2drop ] if 256 <byte-array> :> keyboard-state
] [ 2drop ] if 4 <byte-array> :> chars
] unless ; lParam -16 shift 0xff bitand :> scan-code
keyboard-state GetKeyboardState win32-error<>0
VK_CONTROL VK_CAPITAL [ 0 swap keyboard-state set-nth ] bi@
wParam scan-code keyboard-state chars 2 0 ToUnicode dup win32-error=0/f
1 <= [
1 chars nth 8 shift 0 chars nth bitor
] [
3 chars nth 8 shift 2 chars nth bitor ! dead-key
] if
1string f hWnd send-key-down/up execute( sym action? hWnd -- )
] if*
] unless ; inline
: handle-wm-keydown ( hWnd uMsg wParam lParam -- )
\ send-key-down (handle-wm-keydown/up) ;
:: handle-wm-char ( hWnd uMsg wParam lParam -- ) :: handle-wm-char ( hWnd uMsg wParam lParam -- )
wParam exclude-key-wm-char? [ wParam exclude-key-wm-char? [
ctrl? alt? xor [ ctrl? alt? xor [ ! enable AltGr combination inputs
wParam 1string wParam 1string hWnd window user-input
[ f hWnd send-key-down ] ] unless
[ hWnd window user-input ] bi
] unless
] unless ; ] unless ;
:: handle-wm-keyup ( hWnd uMsg wParam lParam -- ) : handle-wm-keyup ( hWnd uMsg wParam lParam -- )
wParam exclude-key-wm-keydown? [ \ send-key-up (handle-wm-keydown/up) ;
wParam key-sym over [
hWnd send-key-up
] [ 2drop ] if
] unless ;
:: set-window-active ( hwnd uMsg wParam lParam ? -- n ) :: set-window-active ( hwnd uMsg wParam lParam ? -- n )
? hwnd window active?<< ? hwnd window active?<<

View File

@ -1643,7 +1643,7 @@ FUNCTION: HKL GetKeyboardLayout ( DWORD idThread )
! FUNCTION: GetKeyboardLayoutList ! FUNCTION: GetKeyboardLayoutList
! FUNCTION: GetKeyboardLayoutNameA ! FUNCTION: GetKeyboardLayoutNameA
! FUNCTION: GetKeyboardLayoutNameW ! FUNCTION: GetKeyboardLayoutNameW
! FUNCTION: GetKeyboardState FUNCTION: BOOL GetKeyboardState ( BYTE *lpKeyState )
FUNCTION: int GetKeyboardType ( int nTypeFlag ) FUNCTION: int GetKeyboardType ( int nTypeFlag )
! FUNCTION: GetKeyNameTextA ! FUNCTION: GetKeyNameTextA
! FUNCTION: GetKeyNameTextW ! FUNCTION: GetKeyNameTextW
@ -2129,7 +2129,7 @@ ALIAS: SystemParametersInfo SystemParametersInfoW
! FUNCTION: TileWindows ! FUNCTION: TileWindows
! FUNCTION: ToAscii ! FUNCTION: ToAscii
! FUNCTION: ToAsciiEx ! FUNCTION: ToAsciiEx
! FUNCTION: ToUnicode FUNCTION: int ToUnicode ( UINT wVirtKey, UINT wScanCode, BYTE *lpKeyState, LPWSTR pwszBuff, int cchBuff, UINT wFlags )
! FUNCTION: ToUnicodeEx ! FUNCTION: ToUnicodeEx
FUNCTION: BOOL TrackMouseEvent ( LPTRACKMOUSEEVENT lpEventTrack ) FUNCTION: BOOL TrackMouseEvent ( LPTRACKMOUSEEVENT lpEventTrack )
! FUNCTION: TrackPopupMenu ! FUNCTION: TrackPopupMenu