From: Doug Coleman Date: Fri, 28 Aug 2009 02:43:29 +0000 (-0500) Subject: more struct changes X-Git-Tag: 0.97~5635^2~11^2~29 X-Git-Url: https://gitweb.factorcode.org/gitweb.cgi?p=factor.git;a=commitdiff_plain;h=111c0f6b895f02cacbe56a198fea22d17f5681f8 more struct changes --- diff --git a/basis/game-input/dinput/dinput.factor b/basis/game-input/dinput/dinput.factor index 6cd161bd28..26d57871d7 100755 --- a/basis/game-input/dinput/dinput.factor +++ b/basis/game-input/dinput/dinput.factor @@ -6,7 +6,7 @@ math.rectangles namespaces parser sequences shuffle struct-arrays ui.backend.windows vectors windows.com windows.dinput windows.dinput.constants windows.errors windows.kernel32 windows.messages windows.ole32 -windows.user32 ; +windows.user32 classes.struct ; IN: game-input.dinput CONSTANT: MOUSE-BUFFER-SIZE 16 @@ -162,7 +162,7 @@ SYMBOLS: +dinput+ +keyboard-device+ +keyboard-state+ [ remove-controller ] each ; : device-interface? ( dbt-broadcast-hdr -- ? ) - DEV_BROADCAST_HDR-dbch_devicetype DBT_DEVTYP_DEVICEINTERFACE = ; + dbch_devicetype>> DBT_DEVTYP_DEVICEINTERFACE = ; : device-arrived ( dbt-broadcast-hdr -- ) device-interface? [ find-controllers ] when ; @@ -185,9 +185,9 @@ TUPLE: window-rect < rect window-loc ; { 0 0 } >>dim ; : (device-notification-filter) ( -- DEV_BROADCAST_DEVICEW ) - "DEV_BROADCAST_DEVICEW" - "DEV_BROADCAST_DEVICEW" heap-size over set-DEV_BROADCAST_DEVICEW-dbcc_size - DBT_DEVTYP_DEVICEINTERFACE over set-DEV_BROADCAST_DEVICEW-dbcc_devicetype ; + DEV_BROADCAST_DEVICEW + DEV_BROADCAST_DEVICEW heap-size >>dbcc_size + DBT_DEVTYP_DEVICEINTERFACE >>dbcc_devicetype ; : create-device-change-window ( -- ) WS_OVERLAPPEDWINDOW 0 create-window @@ -239,11 +239,13 @@ M: dinput-game-input-backend (close-game-input) delete-dinput ; M: dinput-game-input-backend (reset-game-input) - { - +dinput+ +keyboard-device+ +keyboard-state+ - +controller-devices+ +controller-guids+ - +device-change-window+ +device-change-handle+ - } [ f swap set-global ] each ; + global [ + { + +dinput+ +keyboard-device+ +keyboard-state+ + +controller-devices+ +controller-guids+ + +device-change-window+ +device-change-handle+ + } [ off ] each + ] bind ; M: dinput-game-input-backend get-controllers +controller-devices+ get diff --git a/basis/ui/backend/windows/windows.factor b/basis/ui/backend/windows/windows.factor index 5ff33c65d6..cf4966b756 100755 --- a/basis/ui/backend/windows/windows.factor +++ b/basis/ui/backend/windows/windows.factor @@ -751,17 +751,18 @@ M: windows-ui-backend beep ( -- ) : fullscreen-RECT ( hwnd -- RECT ) MONITOR_DEFAULTTONEAREST MonitorFromWindow - "MONITORINFOEX" dup length over set-MONITORINFOEX-cbSize - [ GetMonitorInfo win32-error=0/f ] keep MONITORINFOEX-rcMonitor ; + MONITORINFOEX + MONITORINFOEX heap-size >>cbSize + [ GetMonitorInfo win32-error=0/f ] keep rcMonitor>> ; : client-area>RECT ( hwnd -- RECT ) - "RECT" + RECT [ GetClientRect win32-error=0/f ] [ "POINT" byte-array>struct-array [ ClientToScreen drop ] with each ] [ nip ] 2tri ; : hwnd>RECT ( hwnd -- RECT ) - "RECT" [ GetWindowRect win32-error=0/f ] keep ; + RECT [ GetWindowRect win32-error=0/f ] keep ; M: windows-ui-backend (grab-input) ( handle -- ) 0 ShowCursor drop diff --git a/basis/windows/types/types.factor b/basis/windows/types/types.factor index 081e03f292..59192bb3b6 100755 --- a/basis/windows/types/types.factor +++ b/basis/windows/types/types.factor @@ -216,17 +216,17 @@ CONSTANT: TRUE 1 ! typedef LRESULT (CALLBACK* WNDPROC)(HWND, UINT, WPARAM, LPARAM); -C-STRUCT: WNDCLASS - { "UINT" "style" } - { "WNDPROC" "lpfnWndProc" } - { "int" "cbClsExtra" } - { "int" "cbWndExtra" } - { "HINSTANCE" "hInstance" } - { "HICON" "hIcon" } - { "HCURSOR" "hCursor" } - { "HBRUSH" "hbrBackground" } - { "LPCTSTR" "lpszMenuName" } - { "LPCTSTR" "lpszClassName" } ; +STRUCT: WNDCLASS + { style UINT } + { lpfnWndProc WNDPROC } + { cbClsExtra int } + { cbWndExtra int } + { hInstance HINSTANCE } + { hIcon HICON } + { hCursor HCURSOR } + { hbrBackground HBRUSH } + { lpszMenuName LPCTSTR } + { lpszClassName LPCTSTR } ; STRUCT: WNDCLASSEX { cbSize UINT } @@ -329,12 +329,6 @@ STRUCT: PIXELFORMATDESCRIPTOR { dwVisibleMask DWORD } { dwDamageMask DWORD } ; -C-STRUCT: RECT - { "LONG" "left" } - { "LONG" "top" } - { "LONG" "right" } - { "LONG" "bottom" } ; - : ( loc dim -- RECT ) [ RECT ] 2dip [ drop [ first >>left ] [ second >>top ] bi ] diff --git a/basis/windows/user32/user32.factor b/basis/windows/user32/user32.factor index 543ce6e292..4c39385ce5 100755 --- a/basis/windows/user32/user32.factor +++ b/basis/windows/user32/user32.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2005, 2006 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: alien alien.syntax parser namespaces kernel math -windows.types generalizations math.bitwise classes.struct ; +windows.types generalizations math.bitwise classes.struct +literals ; IN: windows.user32 ! HKL for ActivateKeyboardLayout @@ -74,8 +75,10 @@ CONSTANT: WS_EX_RIGHTSCROLLBAR HEX: 00000000 CONSTANT: WS_EX_CONTROLPARENT HEX: 00010000 CONSTANT: WS_EX_STATICEDGE HEX: 00020000 CONSTANT: WS_EX_APPWINDOW HEX: 00040000 + : WS_EX_OVERLAPPEDWINDOW ( -- n ) WS_EX_WINDOWEDGE WS_EX_CLIENTEDGE bitor ; foldable + : WS_EX_PALETTEWINDOW ( -- n ) { WS_EX_WINDOWEDGE WS_EX_TOOLWINDOW WS_EX_TOPMOST } flags ; foldable @@ -538,26 +541,26 @@ CONSTANT: DEVICE_NOTIFY_SERVICE_HANDLE 1 CONSTANT: DEVICE_NOTIFY_ALL_INTERFACE_CLASSES 4 -C-STRUCT: DEV_BROADCAST_HDR - { "DWORD" "dbch_size" } - { "DWORD" "dbch_devicetype" } - { "DWORD" "dbch_reserved" } ; +STRUCT: DEV_BROADCAST_HDR + { dbch_size DWORD } + { dbch_devicetype DWORD } + { dbch_reserved DWORD } ; -C-STRUCT: DEV_BROADCAST_DEVICEW - { "DWORD" "dbcc_size" } - { "DWORD" "dbcc_devicetype" } - { "DWORD" "dbcc_reserved" } - { "GUID" "dbcc_classguid" } - { { "WCHAR" 1 } "dbcc_name" } ; +STRUCT: DEV_BROADCAST_DEVICEW + { dbcc_size DWORD } + { dbcc_devicetype DWORD } + { dbcc_reserved DWORD } + { dbcc_classguid GUID } + { dbcc_name WCHAR[1] } ; CONSTANT: CCHDEVICENAME 32 -C-STRUCT: MONITORINFOEX - { "DWORD" "cbSize" } - { "RECT" "rcMonitor" } - { "RECT" "rcWork" } - { "DWORD" "dwFlags" } - { { "TCHAR" CCHDEVICENAME } "szDevice" } ; +STRUCT: MONITORINFOEX + { cbSize DWORD } + { rcMonitor RECT } + { rcWork RECT } + { dwFlags DWORD } + { szDevice { "TCHAR" $ CCHDEVICENAME } } ; TYPEDEF: MONITORINFOEX* LPMONITORINFOEX TYPEDEF: MONITORINFOEX* LPMONITORINFO