diff options
author | YuutaW <17158086+Trumeet@users.noreply.github.com> | 2019-07-01 14:43:07 -0700 |
---|---|---|
committer | Trumeet <17158086+Trumeet@users.noreply.github.com> | 2019-07-01 14:43:07 -0700 |
commit | 3c3c4841312262c73c5d973d590f541f8445962d (patch) | |
tree | c0e39367c1b60344182bdaf5e66c4acff114335a /src/mingwMain/kotlin/moe/yuuta/aero/Aero.kt | |
parent | 41b0c65a084619330db2ead75cffe7fbe6db9ad8 (diff) | |
download | Aero-3c3c4841312262c73c5d973d590f541f8445962d.tar Aero-3c3c4841312262c73c5d973d590f541f8445962d.tar.gz Aero-3c3c4841312262c73c5d973d590f541f8445962d.tar.bz2 Aero-3c3c4841312262c73c5d973d590f541f8445962d.zip |
feat: add support for Windows 7 Aero APIHEADuntagged-edcb449b8928f4456e7cmaster
Breaking changes: To test on the Windows 7 x86 virtual machine, the build had been changed from mingwX64 to mingwX86. Therefore the binary path will be changed, INT_PTR will represent Int and some Gradle tasks disappeared and changed. Due to the change of INT_PTR and some unknown reasons, the dialog cannot be shown so I removed the dialog mode.
Signed-off-by: Trumeet <17158086+Trumeet@users.noreply.github.com>
Diffstat (limited to 'src/mingwMain/kotlin/moe/yuuta/aero/Aero.kt')
-rw-r--r-- | src/mingwMain/kotlin/moe/yuuta/aero/Aero.kt | 73 |
1 files changed, 20 insertions, 53 deletions
diff --git a/src/mingwMain/kotlin/moe/yuuta/aero/Aero.kt b/src/mingwMain/kotlin/moe/yuuta/aero/Aero.kt index 44c184e..e9f47b4 100644 --- a/src/mingwMain/kotlin/moe/yuuta/aero/Aero.kt +++ b/src/mingwMain/kotlin/moe/yuuta/aero/Aero.kt @@ -29,38 +29,23 @@ fun main() { null ) - val forceDialogEnv = WinApi.getenv("AERO_DEMO_FORCE_DIALOG") + if (hwnd == null) { + MessageBoxA(null, + "The system returns an empty dialog (${GetLastError()})", + "Aero", + (MB_OK or MB_ICONERROR).convert()) + return + } - if (hwnd == null || (forceDialogEnv == "true")) { - if (hwnd == null) { - MessageBoxA(null, - "The system returns an empty dialog (${GetLastError()})", - "Aero", - (MB_OK or MB_ICONERROR).convert()) - } - memScoped { - // Fallback - val dlgImpl = cValue<DLGTEMPLATE> { - style = (WS_OVERLAPPEDWINDOW or - DS_CENTER or - DS_MODALFRAME).convert() - dwExtendedStyle = 0.convert() - cdit = 0.convert() - x = 0 - y = 0 - cx = 400 - cy = 200 - } - return@memScoped DialogBoxIndirectParamW(WinCompat.hInstance, - dlgImpl.ptr, - null, - staticCFunction(::dlgProc), - 0) - } - } else { - ShowWindow(hwnd, WinCompat.nCmdShow) - WinApi.msgLoop() + val result = DwmEnableComposition(DWM_EC_ENABLECOMPOSITION) and 0xFFFF + if (result != 0) { + MessageBoxA(hwnd, + "DwmEnableComposition() fail (0x${result.toString(16)})", + "Aero", + (MB_OK or MB_ICONERROR).convert()) } + ShowWindow(hwnd, WinCompat.nCmdShow) + WinApi.msgLoop() } fun windowProc(hwnd: HWND?, @@ -69,13 +54,17 @@ fun windowProc(hwnd: HWND?, lParam: LPARAM): LRESULT { return when (uMsg.convert<Int>()) { WM_CREATE -> { - WinApi.setAero(hwnd) + WinApi.setAero10(hwnd) 1 } WM_DESTROY -> { PostQuitMessage(0) 1 } + WM_ACTIVATE -> { + WinApi.setAero7(hwnd) + 1 + } WM_PAINT -> { val ps = nativeHeap.alloc<PAINTSTRUCT>() val hdc = BeginPaint(hwnd, ps.ptr) @@ -90,26 +79,4 @@ fun windowProc(hwnd: HWND?, DefWindowProcA(hwnd, uMsg, wParam, lParam) } } -} - -fun dlgProc(hDlg: HWND?, - message: UINT, - wParam: WPARAM, - lParam: LPARAM): INT_PTR { - when (message.convert<Int>()) { - WM_INITDIALOG -> { - WinApi.setAero(hDlg) - return true.toByte().toLong() - } - WM_COMMAND -> { - EndDialog(hDlg, wParam.convert()) - return true.toByte().toLong() - } - WM_CTLCOLORDLG -> { - return GetStockObject(BLACK_BRUSH).rawValue.toLong() - } - else -> { - return false.toByte().toLong() - } - } }
\ No newline at end of file |