]> gitweb.factorcode.org Git - factor.git/commitdiff
Windoows: Add some more bindings.
authorDoug Coleman <doug.coleman@gmail.com>
Sun, 7 Mar 2021 19:02:45 +0000 (13:02 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Sun, 7 Mar 2021 19:03:00 +0000 (13:03 -0600)
basis/windows/hardware/authors.txt [new file with mode: 0644]
basis/windows/hardware/hardware.factor [new file with mode: 0644]
basis/windows/hardware/platforms.txt [new file with mode: 0644]
basis/windows/processes/platforms.txt [new file with mode: 0644]
basis/windows/user32/user32.factor

diff --git a/basis/windows/hardware/authors.txt b/basis/windows/hardware/authors.txt
new file mode 100644 (file)
index 0000000..7c1b2f2
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
diff --git a/basis/windows/hardware/hardware.factor b/basis/windows/hardware/hardware.factor
new file mode 100644 (file)
index 0000000..b7d7e45
--- /dev/null
@@ -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 <struct> 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 (file)
index 0000000..d493d34
--- /dev/null
@@ -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 (file)
index 0000000..d493d34
--- /dev/null
@@ -0,0 +1 @@
+windows
\ No newline at end of file
index 166cfc50c2b071857dec2faeb2b12b36d72697ea..fb14d7e106cc5ecaf24961964c03cdf9d9e03176 100644 (file)
@@ -978,31 +978,41 @@ CONSTANT: DISP_CHANGE_NOTUPDATED -3
 CONSTANT: DISP_CHANGE_BADFLAGS   -4
 CONSTANT: DISP_CHANGE_BADPARAM   -5
 
 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
 
 STRUCT: DEVMODE
-    { dmDeviceName TCHAR[CCHDEVICENAME] }
+    { dmDeviceName WCHAR[CCHDEVICENAME] }
     { dmSpecVersion WORD }
     { dmDriverVersion WORD }
     { dmSize WORD }
     { dmDriverExtra WORD }
     { dmFields DWORD }
 
     { 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 }
 
     { dmColor short }
     { dmDuplex short }
     { dmYResolution short }
     { dmTTOption short }
     { dmCollate short }
-    { dmFormName TCHAR[CCHFORMNAME] }
+    { dmFormName WCHAR[CCHFORMNAME] }
     { dmLogPixels WORD }
     { dmBitsPerPel DWORD }
     { dmPelsWidth DWORD }
     { dmLogPixels WORD }
     { dmBitsPerPel DWORD }
     { dmPelsWidth DWORD }
@@ -1011,35 +1021,29 @@ STRUCT: DEVMODE
     { dmDisplayFrequency DWORD }
     { dmiCMMethod DWORD }
     { dmICMIntent DWORD }
     { dmDisplayFrequency DWORD }
     { dmiCMMethod DWORD }
     { dmICMIntent DWORD }
-
     { dmMediaType DWORD }
     { dmDitherType DWORD }
     { dmReserved1 DWORD }
     { dmReserved2 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
 
 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
 
 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: 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: 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: 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
 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: 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
 
 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: HWND GetParent ( HWND hWnd )
 FUNCTION: int GetPriorityClipboardFormat ( UINT* paFormatPriorityList, int cFormats )
 ! FUNCTION: GetProcessDefaultLayout
-! FUNCTION: GetProcessWindowStation
+FUNCTION: HWINSTA GetProcessWindowStation ( )
 ! FUNCTION: GetProgmanWindow
 ! FUNCTION: GetPropA
 ! FUNCTION: GetPropW
 ! FUNCTION: GetProgmanWindow
 ! FUNCTION: GetPropA
 ! FUNCTION: GetPropW