mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-05 04:27:51 +00:00
Merge pull request #1682 from ftphikari/master
sys/windows: add intrinsics.constant_utf16_cstring
This commit is contained in:
@@ -96,6 +96,7 @@ LPPROCESS_INFORMATION :: ^PROCESS_INFORMATION
|
||||
PSECURITY_ATTRIBUTES :: ^SECURITY_ATTRIBUTES
|
||||
LPSECURITY_ATTRIBUTES :: ^SECURITY_ATTRIBUTES
|
||||
LPSTARTUPINFO :: ^STARTUPINFO
|
||||
LPTRACKMOUSEEVENT :: ^TRACKMOUSEEVENT
|
||||
VOID :: rawptr
|
||||
PVOID :: rawptr
|
||||
LPVOID :: rawptr
|
||||
@@ -272,6 +273,13 @@ PAINTSTRUCT :: struct {
|
||||
rgbReserved: [32]BYTE,
|
||||
}
|
||||
|
||||
TRACKMOUSEEVENT :: struct {
|
||||
cbSize: DWORD,
|
||||
dwFlags: DWORD,
|
||||
hwndTrack: HWND,
|
||||
dwHoverTime: DWORD,
|
||||
}
|
||||
|
||||
WIN32_FIND_DATAW :: struct {
|
||||
dwFileAttributes: DWORD,
|
||||
ftCreationTime: FILETIME,
|
||||
@@ -387,13 +395,6 @@ CS_BYTEALIGNWINDOW : UINT : 0x2000
|
||||
CS_GLOBALCLASS : UINT : 0x4000
|
||||
CS_DROPSHADOW : UINT : 0x0002_0000
|
||||
|
||||
GWL_EXSTYLE : c_int : -20
|
||||
GWLP_HINSTANCE : c_int : -6
|
||||
GWLP_ID : c_int : -12
|
||||
GWL_STYLE : c_int : -16
|
||||
GWLP_USERDATA : c_int : -21
|
||||
GWLP_WNDPROC : c_int : -4
|
||||
|
||||
WS_BORDER : UINT : 0x0080_0000
|
||||
WS_CAPTION : UINT : 0x00C0_0000
|
||||
WS_CHILD : UINT : 0x4000_0000
|
||||
@@ -485,6 +486,48 @@ HWND_BOTTOM :: HWND( uintptr(1)) // 1
|
||||
HWND_TOPMOST :: HWND(~uintptr(0)) // -1
|
||||
HWND_NOTOPMOST :: HWND(~uintptr(0) - 1) // -2
|
||||
|
||||
// Window field offsets for GetWindowLong()
|
||||
GWL_STYLE :: -16
|
||||
GWL_EXSTYLE :: -20
|
||||
GWL_ID :: -12
|
||||
|
||||
when ODIN_ARCH == .i386 {
|
||||
GWL_WNDPROC :: -4
|
||||
GWL_HINSTANCE :: -6
|
||||
GWL_HWNDPARENT :: -8
|
||||
GWL_USERDATA :: -21
|
||||
}
|
||||
|
||||
GWLP_WNDPROC :: -4
|
||||
GWLP_HINSTANCE :: -6
|
||||
GWLP_HWNDPARENT :: -8
|
||||
GWLP_USERDATA :: -21
|
||||
GWLP_ID :: -12
|
||||
|
||||
// Class field offsets for GetClassLong()
|
||||
GCL_CBWNDEXTRA :: -18
|
||||
GCL_CBCLSEXTRA :: -20
|
||||
GCL_STYLE :: -26
|
||||
GCW_ATOM :: -32
|
||||
|
||||
when ODIN_ARCH == .i386 {
|
||||
GCL_MENUNAME :: -8
|
||||
GCL_HBRBACKGROUND :: -10
|
||||
GCL_HCURSOR :: -12
|
||||
GCL_HICON :: -14
|
||||
GCL_HMODULE :: -16
|
||||
GCL_WNDPROC :: -24
|
||||
GCL_HICONSM :: -34
|
||||
}
|
||||
|
||||
GCLP_MENUNAME :: -8
|
||||
GCLP_HBRBACKGROUND :: -10
|
||||
GCLP_HCURSOR :: -12
|
||||
GCLP_HICON :: -14
|
||||
GCLP_HMODULE :: -16
|
||||
GCLP_WNDPROC :: -24
|
||||
GCLP_HICONSM :: -34
|
||||
|
||||
// GetSystemMetrics() codes
|
||||
SM_CXSCREEN :: 0
|
||||
SM_CYSCREEN :: 1
|
||||
@@ -645,6 +688,13 @@ MK_MBUTTON :: 0x0010
|
||||
MK_XBUTTON1 :: 0x0020
|
||||
MK_XBUTTON2 :: 0x0040
|
||||
|
||||
TME_HOVER :: 0x00000001
|
||||
TME_LEAVE :: 0x00000002
|
||||
TME_NONCLIENT :: 0x00000010
|
||||
TME_QUERY :: 0x40000000
|
||||
TME_CANCEL :: 0x80000000
|
||||
HOVER_DEFAULT :: 0xFFFFFFFF
|
||||
|
||||
USER_TIMER_MAXIMUM :: 0x7FFFFFFF
|
||||
USER_TIMER_MINIMUM :: 0x0000000A
|
||||
|
||||
|
||||
@@ -10,19 +10,19 @@ foreign user32 {
|
||||
GetClassInfoExA :: proc(hInsatnce: HINSTANCE, lpszClass: LPCSTR, lpwcx: ^WNDCLASSEXA) -> BOOL ---
|
||||
GetClassInfoExW :: proc(hInsatnce: HINSTANCE, lpszClass: LPCWSTR, lpwcx: ^WNDCLASSEXW) -> BOOL ---
|
||||
|
||||
GetClassLongPtrA :: proc(hWnd: HWND, nIndex: c_int) -> DWORD ---
|
||||
GetClassLongPtrW :: proc(hWnd: HWND, nIndex: c_int) -> DWORD ---
|
||||
SetClassLongPtrA :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> ULONG_PTR ---
|
||||
SetClassLongPtrW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> ULONG_PTR ---
|
||||
GetClassLongA :: proc(hWnd: HWND, nIndex: c_int) -> DWORD ---
|
||||
GetClassLongW :: proc(hWnd: HWND, nIndex: c_int) -> DWORD ---
|
||||
SetClassLongA :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG) -> DWORD ---
|
||||
SetClassLongW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG) -> DWORD ---
|
||||
|
||||
GetWindowLongA :: proc(hWnd: HWND, nIndex: c_int) -> LONG ---
|
||||
GetWindowLongW :: proc(hWnd: HWND, nIndex: c_int) -> LONG ---
|
||||
SetWindowLongA :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG) -> LONG ---
|
||||
SetWindowLongW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG) -> LONG ---
|
||||
|
||||
GetClassNameA :: proc(hWnd: HWND, lpClassName: LPSTR, nMaxCount: c_int) -> c_int ---
|
||||
GetClassNameW :: proc(hWnd: HWND, lpClassName: LPWSTR, nMaxCount: c_int) -> c_int ---
|
||||
|
||||
GetWindowLongPtrA :: proc(hWnd: HWND, nIndex: c_int) -> LONG_PTR ---
|
||||
GetWindowLongPtrW :: proc(hWnd: HWND, nIndex: c_int) -> LONG_PTR ---
|
||||
SetWindowLongPtrA :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> LONG_PTR ---
|
||||
SetWindowLongPtrW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> LONG_PTR ---
|
||||
|
||||
RegisterClassA :: proc(lpWndClass: ^WNDCLASSA) -> ATOM ---
|
||||
RegisterClassW :: proc(lpWndClass: ^WNDCLASSW) -> ATOM ---
|
||||
RegisterClassExA :: proc(^WNDCLASSEXA) -> ATOM ---
|
||||
@@ -123,6 +123,11 @@ foreign user32 {
|
||||
BeginPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> HDC ---
|
||||
EndPaint :: proc(hWnd: HWND, lpPaint: ^PAINTSTRUCT) -> BOOL ---
|
||||
|
||||
GetCapture :: proc() -> HWND ---
|
||||
SetCapture :: proc(hWnd: HWND) -> HWND ---
|
||||
ReleaseCapture :: proc() -> BOOL ---
|
||||
TrackMouseEvent :: proc(lpEventTrack: LPTRACKMOUSEEVENT) -> BOOL ---
|
||||
|
||||
GetKeyState :: proc(nVirtKey: c_int) -> SHORT ---
|
||||
GetAsyncKeyState :: proc(vKey: c_int) -> SHORT ---
|
||||
|
||||
@@ -193,6 +198,31 @@ CreateWindowW :: #force_inline proc "stdcall" (
|
||||
)
|
||||
}
|
||||
|
||||
when ODIN_ARCH == .amd64 {
|
||||
@(default_calling_convention="stdcall")
|
||||
foreign user32 {
|
||||
GetClassLongPtrA :: proc(hWnd: HWND, nIndex: c_int) -> ULONG_PTR ---
|
||||
GetClassLongPtrW :: proc(hWnd: HWND, nIndex: c_int) -> ULONG_PTR ---
|
||||
SetClassLongPtrA :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> ULONG_PTR ---
|
||||
SetClassLongPtrW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> ULONG_PTR ---
|
||||
|
||||
GetWindowLongPtrA :: proc(hWnd: HWND, nIndex: c_int) -> LONG_PTR ---
|
||||
GetWindowLongPtrW :: proc(hWnd: HWND, nIndex: c_int) -> LONG_PTR ---
|
||||
SetWindowLongPtrA :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> LONG_PTR ---
|
||||
SetWindowLongPtrW :: proc(hWnd: HWND, nIndex: c_int, dwNewLong: LONG_PTR) -> LONG_PTR ---
|
||||
}
|
||||
} else when ODIN_ARCH == .i386 {
|
||||
GetClassLongPtrA :: GetClassLongA
|
||||
GetClassLongPtrW :: GetClassLongW
|
||||
SetClassLongPtrA :: SetClassLongA
|
||||
SetClassLongPtrW :: SetClassLongW
|
||||
|
||||
GetWindowLongPtrA :: GetWindowLongA
|
||||
GetWindowLongPtrW :: GetWindowLongW
|
||||
SetWindowLongPtrA :: GetWindowLongA
|
||||
SetWindowLongPtrW :: GetWindowLongW
|
||||
}
|
||||
|
||||
GET_SC_WPARAM :: #force_inline proc(wparam: WPARAM) -> i32 {
|
||||
return i32(wparam) & 0xFFF0
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@ package sys_windows
|
||||
|
||||
import "core:strings"
|
||||
import "core:sys/win32"
|
||||
import "core:intrinsics"
|
||||
|
||||
L :: intrinsics.constant_utf16_cstring
|
||||
|
||||
LOWORD :: #force_inline proc "contextless" (x: DWORD) -> WORD {
|
||||
return WORD(x & 0xffff)
|
||||
@@ -456,4 +459,4 @@ run_as_user :: proc(username, password, application, commandline: string, pi: ^P
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user