Desktop: Fix resize helper window Z-order and attach to parent console on Windows (#3572)

* Desktop: Fix helper window zorder on Windows

* Attach to parent console if launched from a terminal

* Workaround for a Windows-specific exception that occurs when `app` is dropped
This commit is contained in:
Timon
2026-01-05 23:02:41 +00:00
committed by GitHub
parent fafc687d84
commit bd1f7eefdb
4 changed files with 25 additions and 9 deletions
+7
View File
@@ -1,4 +1,5 @@
use windows::Win32::System::Com::{COINIT_APARTMENTTHREADED, CoInitializeEx};
use windows::Win32::System::Console::{ATTACH_PARENT_PROCESS, AttachConsole};
use windows::Win32::UI::Shell::SetCurrentProcessExplicitAppUserModelID;
use windows::core::HSTRING;
use winit::event_loop::ActiveEventLoop;
@@ -13,6 +14,12 @@ pub(super) struct NativeWindowImpl {
impl super::NativeWindow for NativeWindowImpl {
fn init() {
// Attach to parent console if launched from a terminal (no-op otherwise)
unsafe {
let _ = AttachConsole(ATTACH_PARENT_PROCESS);
}
// Set stable app ID
let app_id = HSTRING::from(APP_ID);
unsafe {
let _ = CoInitializeEx(None, COINIT_APARTMENTTHREADED).ok();