-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f1c353a
Showing
6 changed files
with
327 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[target.i686-pc-windows-msvc] | ||
rustflags="-C target-feature=+crt-static" | ||
|
||
[target.x86-64-pc-windows-msvc] | ||
rustflags="-C target-feature=+crt-static" | ||
|
||
[target.i686-pc-windows-gnu] | ||
rustflags="-C target-feature=+crt-static" | ||
|
||
[target.x86-64-pc-windows-gnu] | ||
rustflags="-C target-feature=+crt-static" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
build: | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
with: | ||
target: i686-pc-windows-msvc | ||
- name: Build x64 | ||
run: cargo build --verbose --release --target x86_64-pc-windows-msvc | ||
- name: Build x86 | ||
run: cargo build --verbose --release --target i686-pc-windows-msvc | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
path: target/*/release/*.exe | ||
|
||
fmt: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions-rust-lang/setup-rust-toolchain@v1 | ||
with: | ||
components: rustfmt | ||
- uses: actions-rust-lang/rustfmt@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "aerotest" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
windows = { version = "0.58.0", features = ["Win32_UI_WindowsAndMessaging", "Win32_Graphics_Dwm", "Win32_Graphics_Gdi", "Win32_UI_Controls", "Win32_System_LibraryLoader"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#![windows_subsystem = "windows"] | ||
|
||
use std::ffi::c_void; | ||
use std::mem::size_of; | ||
|
||
use windows::core::*; | ||
use windows::Win32::Foundation::*; | ||
use windows::Win32::Graphics::Dwm::*; | ||
use windows::Win32::Graphics::Gdi::*; | ||
use windows::Win32::System::LibraryLoader::*; | ||
use windows::Win32::UI::Controls::*; | ||
use windows::Win32::UI::WindowsAndMessaging::*; | ||
|
||
const AERO_WINDOW_CLASS_NAME: PCSTR = s!("AeroWindow"); | ||
|
||
fn main() -> Result<()> { | ||
unsafe { | ||
let instance = GetModuleHandleA(None)?; | ||
let black_brush = HBRUSH(GetStockObject(BLACK_BRUSH).0); // Don't ask me why | ||
|
||
let class = WNDCLASSA { | ||
lpfnWndProc: Some(wndproc), | ||
hInstance: instance.into(), | ||
lpszClassName: AERO_WINDOW_CLASS_NAME, | ||
hbrBackground: black_brush, | ||
..Default::default() | ||
}; | ||
|
||
if RegisterClassA(&class) == 0 { | ||
return Err(Error::from_win32()); | ||
} | ||
|
||
let hwnd = CreateWindowExA( | ||
WS_EX_OVERLAPPEDWINDOW, | ||
AERO_WINDOW_CLASS_NAME, | ||
s!("Aero Window"), | ||
WS_OVERLAPPEDWINDOW, | ||
0, | ||
0, | ||
600, | ||
400, | ||
None, | ||
None, | ||
instance, | ||
None, | ||
)?; | ||
|
||
let margins = MARGINS { | ||
cxLeftWidth: -1, | ||
cxRightWidth: -1, | ||
cyTopHeight: -1, | ||
cyBottomHeight: -1, | ||
}; | ||
|
||
DwmExtendFrameIntoClientArea(hwnd, &margins)?; | ||
|
||
// Enable dark mode and Mica on Windows 11+ | ||
_ = DwmSetWindowAttribute( | ||
hwnd, | ||
DWMWA_USE_IMMERSIVE_DARK_MODE, | ||
(&TRUE) as *const _ as *const c_void, | ||
size_of::<BOOL>().try_into()?, | ||
); | ||
_ = DwmSetWindowAttribute( | ||
hwnd, | ||
DWMWA_SYSTEMBACKDROP_TYPE, | ||
(&DWMSBT_MAINWINDOW) as *const _ as *const c_void, | ||
size_of::<DWM_SYSTEMBACKDROP_TYPE>().try_into()?, | ||
); | ||
|
||
_ = ShowWindow(hwnd, SW_NORMAL); | ||
|
||
let mut msg = Default::default(); | ||
|
||
while GetMessageA(&mut msg, None, 0, 0).into() { | ||
_ = TranslateMessage(&msg); | ||
DispatchMessageA(&msg); | ||
} | ||
|
||
Ok(()) | ||
} | ||
} | ||
|
||
unsafe extern "system" fn wndproc(hwnd: HWND, msg: u32, wparam: WPARAM, lparam: LPARAM) -> LRESULT { | ||
match msg { | ||
WM_CLOSE => { | ||
DestroyWindow(hwnd).unwrap(); | ||
LRESULT(0) | ||
} | ||
WM_DESTROY => { | ||
PostQuitMessage(0); | ||
LRESULT(0) | ||
} | ||
_ => DefWindowProcA(hwnd, msg, wparam, lparam), | ||
} | ||
} |