From 26510ba65a0ca8091ebfa82e909b6022ba0bb8ff Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 7 Mar 2021 13:02:45 -0600 Subject: [PATCH] Windoows: Add some more bindings. --- basis/windows/hardware/authors.txt | 1 + basis/windows/hardware/hardware.factor | 33 +++++++++ basis/windows/hardware/platforms.txt | 1 + basis/windows/processes/platforms.txt | 1 + basis/windows/user32/user32.factor | 96 ++++++++++++++++---------- 5 files changed, 94 insertions(+), 38 deletions(-) create mode 100644 basis/windows/hardware/authors.txt create mode 100644 basis/windows/hardware/hardware.factor create mode 100644 basis/windows/hardware/platforms.txt create mode 100644 basis/windows/processes/platforms.txt diff --git a/basis/windows/hardware/authors.txt b/basis/windows/hardware/authors.txt new file mode 100644 index 0000000000..7c1b2f2279 --- /dev/null +++ b/basis/windows/hardware/authors.txt @@ -0,0 +1 @@ +Doug Coleman diff --git a/basis/windows/hardware/hardware.factor b/basis/windows/hardware/hardware.factor new file mode 100644 index 0000000000..b7d7e45167 --- /dev/null +++ b/basis/windows/hardware/hardware.factor @@ -0,0 +1,33 @@ +! Copyright (C) 2021 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: accessors alien alien.data arrays classes.struct io +kernel namespaces prettyprint ui.backend.windows +ui.gadgets.worlds windows.errors windows.types windows.user32 ; +IN: windows.hardware + +: monitor-enum-proc ( -- callback ) + BOOL { HMONITOR HDC LPRECT LPARAM } stdcall [ + 4dup 4array . + 3drop + MONITORINFOEX dup byte-length >>cbSize + [ GetMonitorInfo win32-error=0/f ] keep ... flush + TRUE + ] alien-callback ; + +: enum-monitors ( -- ) + world get + [ handle>> hDC>> ] + [ make-RECT ] bi + monitor-enum-proc + 0 + EnumDisplayMonitors win32-error=0/f ; + + +: desktop-enum-proc ( -- callback ) + BOOL { LPWSTR LPARAM } stdcall [ + 2array . + TRUE + ] alien-callback ; + +: enum-desktops ( -- ) + f desktop-enum-proc 0 EnumDesktopsW win32-error=0/f ; diff --git a/basis/windows/hardware/platforms.txt b/basis/windows/hardware/platforms.txt new file mode 100644 index 0000000000..d493d3459b --- /dev/null +++ b/basis/windows/hardware/platforms.txt @@ -0,0 +1 @@ +windows \ No newline at end of file diff --git a/basis/windows/processes/platforms.txt b/basis/windows/processes/platforms.txt new file mode 100644 index 0000000000..d493d3459b --- /dev/null +++ b/basis/windows/processes/platforms.txt @@ -0,0 +1 @@ +windows \ No newline at end of file diff --git a/basis/windows/user32/user32.factor b/basis/windows/user32/user32.factor index 166cfc50c2..fb14d7e106 100644 --- a/basis/windows/user32/user32.factor +++ b/basis/windows/user32/user32.factor @@ -978,31 +978,41 @@ CONSTANT: DISP_CHANGE_NOTUPDATED -3 CONSTANT: DISP_CHANGE_BADFLAGS -4 CONSTANT: DISP_CHANGE_BADPARAM -5 +STRUCT: DEVMODE_PROPS1 + { dmOrientation short } + { dmPaperSize short } + { dmPaperLength short } + { dmPaperWidth short } + { dmScale short } + { dmCopies short } + { dmDefaultSource short } + { dmPrintQuality short } ; +STRUCT: DEVMODE_PROPS2 + { dmPosition POINTL } + { dmDisplayOrientation DWORD } + { dmDisplayFixedOutput DWORD } ; + +UNION-STRUCT: DEVMODE_UNION_1 + { props1 DEVMODE_PROPS1 } + { props2 DEVMODE_PROPS2 } ; STRUCT: DEVMODE - { dmDeviceName TCHAR[CCHDEVICENAME] } + { dmDeviceName WCHAR[CCHDEVICENAME] } { dmSpecVersion WORD } { dmDriverVersion WORD } { dmSize WORD } { dmDriverExtra WORD } { dmFields DWORD } - { dmOrientation short } - { dmPaperSize short } - { dmPaperLength short } - { dmPaperWidth short } - { dmScale short } - { dmCopies short } - { dmDefaultSource short } - { dmPrintQuality short } + { props DEVMODE_UNION_1 } { dmColor short } { dmDuplex short } { dmYResolution short } { dmTTOption short } { dmCollate short } - { dmFormName TCHAR[CCHFORMNAME] } + { dmFormName WCHAR[CCHFORMNAME] } { dmLogPixels WORD } { dmBitsPerPel DWORD } { dmPelsWidth DWORD } @@ -1011,35 +1021,29 @@ STRUCT: DEVMODE { dmDisplayFrequency DWORD } { dmiCMMethod DWORD } { dmICMIntent DWORD } - { dmMediaType DWORD } { dmDitherType DWORD } { dmReserved1 DWORD } { dmReserved2 DWORD } - { dmPanningWidth DWORD } ; - -! union { DWORD dmDisplayFlags; DWORD dmNup; } ; - ! union { - ! struct { - ! short dmOrientation; - ! short dmPaperSize; - ! short dmPaperLength; - ! short dmPaperWidth; - ! short dmScale; - ! short dmCopies; - ! short dmDefaultSource; - ! short dmPrintQuality; - ! } ; - ! struct { - ! POINTL dmPosition; - ! DWORD dmDisplayOrientation; - ! DWORD dmDisplayFixedOutput; - ! } ; - ! } ; + { dmPanningWidth DWORD } + { dmPanningHeight DWORD } ; +TYPEDEF: DEVMODE DEVMODEW TYPEDEF: DEVMODE* PDEVMODE TYPEDEF: DEVMODE* LPDEVMODE +STRUCT: DISPLAY_DEVICEW + { cb DWORD } + { DeviceName CHAR[32] } + { DeviceString CHAR[128] } + { StateFlags DWORD } + { DeviceID CHAR[128] } + { DeviceKey CHAR[128] } ; +TYPEDEF: DISPLAY_DEVICEW* PDISPLAY_DEVICEW +TYPEDEF: DISPLAY_DEVICEW* LPDISPLAY_DEVICEW + +CALLBACK: BOOL DESKTOPENUMPROCW ( LPWSTR arg1, LPARAM arg2 ) + CONSTANT: MSGFLT_ADD 1 CONSTANT: MSGFLT_REMOVE 2 @@ -1546,14 +1550,31 @@ FUNCTION: BOOL EndPaint ( HWND hWnd, PAINTSTRUCT* lpPaint ) ! FUNCTION: EnumChildWindows FUNCTION: UINT EnumClipboardFormats ( UINT format ) ! FUNCTION: EnumDesktopsA -! FUNCTION: EnumDesktopsW + +FUNCTION: BOOL EnumDesktopsW ( + HWINSTA hwinsta, + DESKTOPENUMPROCW lpEnumFunc, + LPARAM lParam +) + FUNCTION: BOOL EnumDesktopWindows ( HDESK hDesktop, WNDENUMPROC lpFn, LPARAM lParam ) ! FUNCTION: EnumDisplayDevicesA -! FUNCTION: EnumDisplayDevicesW -! FUNCTION: BOOL EnumDisplayMonitors ( HDC hdc, LPCRECT lprcClip, MONITORENUMPROC lpfnEnum, LPARAM dwData ) +FUNCTION: BOOL EnumDisplayDevicesW ( + LPCWSTR lpDevice, + DWORD iDevNum, + PDISPLAY_DEVICEW lpDisplayDevice, + DWORD dwFlags +) +CALLBACK: BOOL MONITORENUMPROC ( HMONITOR arg1, HDC arg2, LPRECT arg3, LPARAM arg4 ) +FUNCTION: BOOL EnumDisplayMonitors ( HDC hdc, LPRECT lprcClip, MONITORENUMPROC lpfnEnum, LPARAM dwData ) ! FUNCTION: EnumDisplaySettingsA ! FUNCTION: EnumDisplaySettingsExA -! FUNCTION: EnumDisplaySettingsExW +FUNCTION: BOOL EnumDisplaySettingsExW ( LPCWSTR lpszDeviceName, + DWORD iModeNum, + DEVMODEW *lpDevMode, + DWORD dwFlags +) + FUNCTION: BOOL EnumDisplaySettingsW ( LPCTSTR lpszDeviceName, DWORD iModeNum, DEVMODE *lpDevMode ) ALIAS: EnumDisplaySettings EnumDisplaySettingsW ! FUNCTION: EnumPropsA @@ -1673,8 +1694,7 @@ ALIAS: GetMessage GetMessageW FUNCTION: LPARAM GetMessageExtraInfo ( ) ! FUNCTION: GetMessagePos ! FUNCTION: GetMessageTime -! FUNCTION: GetMonitorInfoA - +! FUNCTION: BOOL GetMonitorInfoA ( HMONITOR hMonitor, LPMONITORINFO lpmi ) FUNCTION: BOOL GetMonitorInfoW ( HMONITOR hMonitor, LPMONITORINFO lpmi ) ALIAS: GetMonitorInfo GetMonitorInfoW @@ -1685,7 +1705,7 @@ ALIAS: GetMonitorInfo GetMonitorInfoW FUNCTION: HWND GetParent ( HWND hWnd ) FUNCTION: int GetPriorityClipboardFormat ( UINT* paFormatPriorityList, int cFormats ) ! FUNCTION: GetProcessDefaultLayout -! FUNCTION: GetProcessWindowStation +FUNCTION: HWINSTA GetProcessWindowStation ( ) ! FUNCTION: GetProgmanWindow ! FUNCTION: GetPropA ! FUNCTION: GetPropW -- 2.34.1