Switch full screen with F11 or Alt+Enter while the title runs #1

Merged
TaynanGT merged 1 commit from upstream-pr/1 into main 2026-11-26 08:35:27 +00:00
TaynanGT commented 2026-11-26 08:34:56 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-26T08:34:56Z.


Full screen was fixed when the window was made. Now F11, or Alt+Enter, on the title's window switches between full screen (a frameless popup over the monitor the window is on) and the window it was made as, fitted to the screen. The swap chain stretches to either. DXGI's own Alt+Enter, which would switch the swap chain to exclusive full screen with buffers nothing resizes, is turned off with MakeWindowAssociation.

The README already describes the keys (How to run it).

Tested:

  • Local CI (clippy both ways, workspace tests, xtask): 936 passed, 0 failed.
  • New tests: a_full_screen_window_is_a_frameless_popup_over_the_screen, full_screen_switches_both_ways_on_the_window_s_monitor.

Not played live with this exact tree yet: the next measured session will check both keys.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:issue:5506662553 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/1). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-26T08:34:56Z. --- Full screen was fixed when the window was made. Now **F11**, or **Alt+Enter**, on the title's window switches between full screen (a frameless popup over the monitor the window is on) and the window it was made as, fitted to the screen. The swap chain stretches to either. DXGI's own Alt+Enter, which would switch the swap chain to exclusive full screen with buffers nothing resizes, is turned off with `MakeWindowAssociation`. The README already describes the keys (How to run it). Tested: - Local CI (clippy both ways, workspace tests, xtask): 936 passed, 0 failed. - New tests: `a_full_screen_window_is_a_frameless_popup_over_the_screen`, `full_screen_switches_both_ways_on_the_window_s_monitor`. Not played live with this exact tree yet: the next measured session will check both keys.
chatgpt-codex-connector[bot] commented 2026-11-26 08:35:10 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T08:35:10Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T08:37:01.074997Z 3981f71 PR opened
🔒 Security Review ✅ Completed 2026-11-26T08:38:30.452295Z 3981f71 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7186773592 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/1#issuecomment-7186773592). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T08:35:10Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"3981f716f3f9f2f49b5b0dc84ef23fbcacacae0c","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":"3981f716f3f9f2f49b5b0dc84ef23fbcacacae0c","has_any_findings":null,"has_unresolved_findings":null,"status":"completed"}} --> <!-- codex-security-review:v1 {"blockingSeverityThreshold":"P0","headSha":"3981f716f3f9f2f49b5b0dc84ef23fbcacacae0c","mergeGateEnabled":false,"pullRequestNumber":1,"repository":"TaynanGT/Vice-Tay","status":"completed"} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-26T08:37:01.074997Z">2026-11-26T08:37:01.074997Z</relative-time> | `3981f71` | PR opened | | 🔒 **Security Review** | ✅ **Completed** <relative-time datetime="2026-11-26T08:38:30.452295Z">2026-11-26T08:38:30.452295Z</relative-time> | `3981f71` | PR opened | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
chatgpt-codex-connector[bot] commented 2026-11-26 08:36:57 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T08:36:57Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3981f716f3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review:6070810102 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/1#pullrequestreview-6070810102). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T08:36:57Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `3981f716f3` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
chatgpt-codex-connector[bot] commented 2026-11-26 08:36:58 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T08:36:58Z.

Code review location: crates/victory-hle/src/modules/lifecycle.rs; line 170

@@ -160,15 +160,77 @@ fn place(
     width: i32,
     height: i32,
 ) -> (u32, u32, (i32, i32, i32, i32)) {
-    if full_screen_on() {
-        // SAFETY: plain queries of the primary monitor's size.
-        let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) };
-        if let Some(full) = full_screen(ex_style, style, !parent.is_null(), screen) {
-            tracing::info!(width = screen.0, height = screen.1, "title window made full screen");
-            return full;
-        }
+    let fitted = fit(parent, x, y, width, height);
+    // SAFETY: plain queries of the primary monitor's size.
+    let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) };
+    let full = full_screen(ex_style, style, !parent.is_null(), screen);
+    if full.is_some() {
+        // A window that could go full screen: how it goes back to a window
+        // ([`toggle_full_screen`]).
+        *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) = Some((ex_style, style, fitted));

P2 Badge Associate saved window state with the title's HWND

If the title creates another unowned, non-tool top-level window after its main window, this assignment overwrites WINDOWED with that other window's styles and geometry, even if it is hidden or creation subsequently fails. window_proc still restricts toggling to TITLE_WINDOW, so switching the main window back to windowed mode applies the helper's dimensions and styles to it. Save the state per HWND after successful creation, or retain only the state belonging to the selected title window.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review-comment:4705693135 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/1#discussion_r4705693135). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T08:36:58Z. **Code review location:** `crates/victory-hle/src/modules/lifecycle.rs`; line 170 ~~~~diff @@ -160,15 +160,77 @@ fn place( width: i32, height: i32, ) -> (u32, u32, (i32, i32, i32, i32)) { - if full_screen_on() { - // SAFETY: plain queries of the primary monitor's size. - let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) }; - if let Some(full) = full_screen(ex_style, style, !parent.is_null(), screen) { - tracing::info!(width = screen.0, height = screen.1, "title window made full screen"); - return full; - } + let fitted = fit(parent, x, y, width, height); + // SAFETY: plain queries of the primary monitor's size. + let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) }; + let full = full_screen(ex_style, style, !parent.is_null(), screen); + if full.is_some() { + // A window that could go full screen: how it goes back to a window + // ([`toggle_full_screen`]). + *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) = Some((ex_style, style, fitted)); ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Associate saved window state with the title's HWND** If the title creates another unowned, non-tool top-level window after its main window, this assignment overwrites `WINDOWED` with that other window's styles and geometry, even if it is hidden or creation subsequently fails. `window_proc` still restricts toggling to `TITLE_WINDOW`, so switching the main window back to windowed mode applies the helper's dimensions and styles to it. Save the state per HWND after successful creation, or retain only the state belonging to the selected title window. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot] commented 2026-11-26 08:36:58 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T08:36:58Z.

Code review location: crates/victory-hle/src/modules/lifecycle.rs; line 208

@@ -160,15 +160,77 @@ fn place(
     width: i32,
     height: i32,
 ) -> (u32, u32, (i32, i32, i32, i32)) {
-    if full_screen_on() {
-        // SAFETY: plain queries of the primary monitor's size.
-        let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) };
-        if let Some(full) = full_screen(ex_style, style, !parent.is_null(), screen) {
-            tracing::info!(width = screen.0, height = screen.1, "title window made full screen");
-            return full;
-        }
+    let fitted = fit(parent, x, y, width, height);
+    // SAFETY: plain queries of the primary monitor's size.
+    let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) };
+    let full = full_screen(ex_style, style, !parent.is_null(), screen);
+    if full.is_some() {
+        // A window that could go full screen: how it goes back to a window
+        // ([`toggle_full_screen`]).
+        *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) = Some((ex_style, style, fitted));
+    }
+    if full_screen_on()
+        && let Some(full) = full
+    {
+        tracing::info!(width = screen.0, height = screen.1, "title window made full screen");
+        FULL_SCREEN.store(true, std::sync::atomic::Ordering::Relaxed);
+        return full;
+    }
+    (ex_style, style, fitted)
+}
+
+/// The styles and place the title's top-level window had (or would have
+/// had) as a window, for going back from full screen.
+type Windowed = (u32, u32, (i32, i32, i32, i32));
+static WINDOWED: Mutex<Option<Windowed>> = Mutex::new(None);
+/// Whether the title's window is full screen now.
+static FULL_SCREEN: AtomicBool = AtomicBool::new(false);
+
+/// F11 or Alt+Enter on the title's window: full screen (frameless, over the
+/// monitor it is on) or back to the window it was made as, whichever it is
+/// not now. The swap chain stretches to either.
+fn toggle_full_screen(hwnd: HWND) {
+    let Some(windowed) = *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) else { return };
+    let full = FULL_SCREEN.load(std::sync::atomic::Ordering::Relaxed);
+    // SAFETY: queries of the title's window and the monitor it is on.
+    let monitor = unsafe {
+        let mut info: windows_sys::Win32::Graphics::Gdi::MONITORINFO = std::mem::zeroed();
+        info.cbSize = std::mem::size_of_val(&info) as u32;
+        let on = windows_sys::Win32::Graphics::Gdi::MonitorFromWindow(hwnd, windows_sys::Win32::Graphics::Gdi::MONITOR_DEFAULTTONEAREST);
+        (windows_sys::Win32::Graphics::Gdi::GetMonitorInfoW(on, &mut info) != 0).then_some(info.rcMonitor)
+    };
+    let Some(monitor) = monitor else { return };
+    let (ex_style, style, (x, y, w, h)) = toggled(full, windowed, monitor);
+    // SAFETY: the title's own window, on its own thread (this procedure).
+    unsafe {
+        wm::SetWindowLongPtrW(hwnd, wm::GWL_STYLE, style as isize);
+        wm::SetWindowLongPtrW(hwnd, wm::GWL_EXSTYLE, ex_style as isize);
+        wm::SetWindowPos(hwnd, std::ptr::null_mut(), x, y, w, h, wm::SWP_FRAMECHANGED | wm::SWP_NOZORDER | wm::SWP_SHOWWINDOW);

P2 Badge Resolve default window geometry before saving it for restoration

For a title that passes CW_USEDEFAULT to CreateWindowEx, fit deliberately preserves that sentinel, so the saved rectangle is not necessarily usable geometry. Returning from full screen later passes it directly to SetWindowPos, which does not interpret CW_USEDEFAULT as a default-placement request. Default coordinates can therefore move the window off-screen, and default dimensions can leave it incorrectly sized. Resolve the windowed rectangle to actual coordinates and positive dimensions before using it for restoration.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review-comment:4705693144 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/1#discussion_r4705693144). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T08:36:58Z. **Code review location:** `crates/victory-hle/src/modules/lifecycle.rs`; line 208 ~~~~diff @@ -160,15 +160,77 @@ fn place( width: i32, height: i32, ) -> (u32, u32, (i32, i32, i32, i32)) { - if full_screen_on() { - // SAFETY: plain queries of the primary monitor's size. - let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) }; - if let Some(full) = full_screen(ex_style, style, !parent.is_null(), screen) { - tracing::info!(width = screen.0, height = screen.1, "title window made full screen"); - return full; - } + let fitted = fit(parent, x, y, width, height); + // SAFETY: plain queries of the primary monitor's size. + let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) }; + let full = full_screen(ex_style, style, !parent.is_null(), screen); + if full.is_some() { + // A window that could go full screen: how it goes back to a window + // ([`toggle_full_screen`]). + *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) = Some((ex_style, style, fitted)); + } + if full_screen_on() + && let Some(full) = full + { + tracing::info!(width = screen.0, height = screen.1, "title window made full screen"); + FULL_SCREEN.store(true, std::sync::atomic::Ordering::Relaxed); + return full; + } + (ex_style, style, fitted) +} + +/// The styles and place the title's top-level window had (or would have +/// had) as a window, for going back from full screen. +type Windowed = (u32, u32, (i32, i32, i32, i32)); +static WINDOWED: Mutex<Option<Windowed>> = Mutex::new(None); +/// Whether the title's window is full screen now. +static FULL_SCREEN: AtomicBool = AtomicBool::new(false); + +/// F11 or Alt+Enter on the title's window: full screen (frameless, over the +/// monitor it is on) or back to the window it was made as, whichever it is +/// not now. The swap chain stretches to either. +fn toggle_full_screen(hwnd: HWND) { + let Some(windowed) = *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) else { return }; + let full = FULL_SCREEN.load(std::sync::atomic::Ordering::Relaxed); + // SAFETY: queries of the title's window and the monitor it is on. + let monitor = unsafe { + let mut info: windows_sys::Win32::Graphics::Gdi::MONITORINFO = std::mem::zeroed(); + info.cbSize = std::mem::size_of_val(&info) as u32; + let on = windows_sys::Win32::Graphics::Gdi::MonitorFromWindow(hwnd, windows_sys::Win32::Graphics::Gdi::MONITOR_DEFAULTTONEAREST); + (windows_sys::Win32::Graphics::Gdi::GetMonitorInfoW(on, &mut info) != 0).then_some(info.rcMonitor) + }; + let Some(monitor) = monitor else { return }; + let (ex_style, style, (x, y, w, h)) = toggled(full, windowed, monitor); + // SAFETY: the title's own window, on its own thread (this procedure). + unsafe { + wm::SetWindowLongPtrW(hwnd, wm::GWL_STYLE, style as isize); + wm::SetWindowLongPtrW(hwnd, wm::GWL_EXSTYLE, ex_style as isize); + wm::SetWindowPos(hwnd, std::ptr::null_mut(), x, y, w, h, wm::SWP_FRAMECHANGED | wm::SWP_NOZORDER | wm::SWP_SHOWWINDOW); ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Resolve default window geometry before saving it for restoration** For a title that passes `CW_USEDEFAULT` to `CreateWindowEx`, `fit` deliberately preserves that sentinel, so the saved rectangle is not necessarily usable geometry. Returning from full screen later passes it directly to `SetWindowPos`, which does not interpret `CW_USEDEFAULT` as a default-placement request. Default coordinates can therefore move the window off-screen, and default dimensions can leave it incorrectly sized. Resolve the windowed rectangle to actual coordinates and positive dimensions before using it for restoration. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot] commented 2026-11-26 08:36:58 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T08:36:58Z.

Code review location: crates/victory-hle/src/modules/lifecycle.rs; line 233

@@ -160,15 +160,77 @@ fn place(
     width: i32,
     height: i32,
 ) -> (u32, u32, (i32, i32, i32, i32)) {
-    if full_screen_on() {
-        // SAFETY: plain queries of the primary monitor's size.
-        let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) };
-        if let Some(full) = full_screen(ex_style, style, !parent.is_null(), screen) {
-            tracing::info!(width = screen.0, height = screen.1, "title window made full screen");
-            return full;
-        }
+    let fitted = fit(parent, x, y, width, height);
+    // SAFETY: plain queries of the primary monitor's size.
+    let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) };
+    let full = full_screen(ex_style, style, !parent.is_null(), screen);
+    if full.is_some() {
+        // A window that could go full screen: how it goes back to a window
+        // ([`toggle_full_screen`]).
+        *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) = Some((ex_style, style, fitted));
+    }
+    if full_screen_on()
+        && let Some(full) = full
+    {
+        tracing::info!(width = screen.0, height = screen.1, "title window made full screen");
+        FULL_SCREEN.store(true, std::sync::atomic::Ordering::Relaxed);
+        return full;
+    }
+    (ex_style, style, fitted)
+}
+
+/// The styles and place the title's top-level window had (or would have
+/// had) as a window, for going back from full screen.
+type Windowed = (u32, u32, (i32, i32, i32, i32));
+static WINDOWED: Mutex<Option<Windowed>> = Mutex::new(None);
+/// Whether the title's window is full screen now.
+static FULL_SCREEN: AtomicBool = AtomicBool::new(false);
+
+/// F11 or Alt+Enter on the title's window: full screen (frameless, over the
+/// monitor it is on) or back to the window it was made as, whichever it is
+/// not now. The swap chain stretches to either.
+fn toggle_full_screen(hwnd: HWND) {
+    let Some(windowed) = *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) else { return };
+    let full = FULL_SCREEN.load(std::sync::atomic::Ordering::Relaxed);
+    // SAFETY: queries of the title's window and the monitor it is on.
+    let monitor = unsafe {
+        let mut info: windows_sys::Win32::Graphics::Gdi::MONITORINFO = std::mem::zeroed();
+        info.cbSize = std::mem::size_of_val(&info) as u32;
+        let on = windows_sys::Win32::Graphics::Gdi::MonitorFromWindow(hwnd, windows_sys::Win32::Graphics::Gdi::MONITOR_DEFAULTTONEAREST);
+        (windows_sys::Win32::Graphics::Gdi::GetMonitorInfoW(on, &mut info) != 0).then_some(info.rcMonitor)
+    };
+    let Some(monitor) = monitor else { return };
+    let (ex_style, style, (x, y, w, h)) = toggled(full, windowed, monitor);
+    // SAFETY: the title's own window, on its own thread (this procedure).
+    unsafe {
+        wm::SetWindowLongPtrW(hwnd, wm::GWL_STYLE, style as isize);
+        wm::SetWindowLongPtrW(hwnd, wm::GWL_EXSTYLE, ex_style as isize);
+        wm::SetWindowPos(hwnd, std::ptr::null_mut(), x, y, w, h, wm::SWP_FRAMECHANGED | wm::SWP_NOZORDER | wm::SWP_SHOWWINDOW);
     }
-    (ex_style, style, fit(parent, x, y, width, height))
+    FULL_SCREEN.store(!full, std::sync::atomic::Ordering::Relaxed);
+    tracing::info!(full_screen = !full, "the title's window switched");
+}
+
+/// The styles and place after a switch from full screen (`full`) or to it:
+/// back to `windowed`, or a frameless popup over `monitor`. Visible either way.
+fn toggled(full: bool, windowed: Windowed, monitor: RECT) -> Windowed {
+    if full {
+        let (ex_style, style, place) = windowed;
+        return (ex_style, style | wm::WS_VISIBLE, place);
+    }
+    let (ex_style, style, _) = windowed;
+    let (w, h) = (monitor.right - monitor.left, monitor.bottom - monitor.top);
+    let (ex_style, style, _) =
+        full_screen(ex_style, style | wm::WS_VISIBLE, false, (w, h)).unwrap_or((ex_style, style, (0, 0, w, h)));
+    (ex_style, style, (monitor.left, monitor.top, w, h))
+}
+
+/// A key that switches full screen: F11, or Enter with Alt.
+fn switches_full_screen(message: u32, wparam: WPARAM, lparam: LPARAM) -> bool {
+    const VK_RETURN: usize = 0x0D;
+    const VK_F11: usize = 0x7A;
+    let alt = (lparam >> 29) & 1 != 0;
+    (message == wm::WM_KEYDOWN && wparam == VK_F11) || (message == wm::WM_SYSKEYDOWN && wparam == VK_RETURN && alt)

P2 Badge Ignore auto-repeat messages for full-screen shortcuts

Holding F11 or Alt+Enter beyond the keyboard repeat delay generates repeated key-down messages, and every one currently triggers another full-screen transition. The window consequently alternates modes until release, with the final mode depending on the repeat count. Check the previous-key-state bit in lparam and toggle only on the initial key-down.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review-comment:4705693147 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/1#discussion_r4705693147). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T08:36:58Z. **Code review location:** `crates/victory-hle/src/modules/lifecycle.rs`; line 233 ~~~~diff @@ -160,15 +160,77 @@ fn place( width: i32, height: i32, ) -> (u32, u32, (i32, i32, i32, i32)) { - if full_screen_on() { - // SAFETY: plain queries of the primary monitor's size. - let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) }; - if let Some(full) = full_screen(ex_style, style, !parent.is_null(), screen) { - tracing::info!(width = screen.0, height = screen.1, "title window made full screen"); - return full; - } + let fitted = fit(parent, x, y, width, height); + // SAFETY: plain queries of the primary monitor's size. + let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) }; + let full = full_screen(ex_style, style, !parent.is_null(), screen); + if full.is_some() { + // A window that could go full screen: how it goes back to a window + // ([`toggle_full_screen`]). + *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) = Some((ex_style, style, fitted)); + } + if full_screen_on() + && let Some(full) = full + { + tracing::info!(width = screen.0, height = screen.1, "title window made full screen"); + FULL_SCREEN.store(true, std::sync::atomic::Ordering::Relaxed); + return full; + } + (ex_style, style, fitted) +} + +/// The styles and place the title's top-level window had (or would have +/// had) as a window, for going back from full screen. +type Windowed = (u32, u32, (i32, i32, i32, i32)); +static WINDOWED: Mutex<Option<Windowed>> = Mutex::new(None); +/// Whether the title's window is full screen now. +static FULL_SCREEN: AtomicBool = AtomicBool::new(false); + +/// F11 or Alt+Enter on the title's window: full screen (frameless, over the +/// monitor it is on) or back to the window it was made as, whichever it is +/// not now. The swap chain stretches to either. +fn toggle_full_screen(hwnd: HWND) { + let Some(windowed) = *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) else { return }; + let full = FULL_SCREEN.load(std::sync::atomic::Ordering::Relaxed); + // SAFETY: queries of the title's window and the monitor it is on. + let monitor = unsafe { + let mut info: windows_sys::Win32::Graphics::Gdi::MONITORINFO = std::mem::zeroed(); + info.cbSize = std::mem::size_of_val(&info) as u32; + let on = windows_sys::Win32::Graphics::Gdi::MonitorFromWindow(hwnd, windows_sys::Win32::Graphics::Gdi::MONITOR_DEFAULTTONEAREST); + (windows_sys::Win32::Graphics::Gdi::GetMonitorInfoW(on, &mut info) != 0).then_some(info.rcMonitor) + }; + let Some(monitor) = monitor else { return }; + let (ex_style, style, (x, y, w, h)) = toggled(full, windowed, monitor); + // SAFETY: the title's own window, on its own thread (this procedure). + unsafe { + wm::SetWindowLongPtrW(hwnd, wm::GWL_STYLE, style as isize); + wm::SetWindowLongPtrW(hwnd, wm::GWL_EXSTYLE, ex_style as isize); + wm::SetWindowPos(hwnd, std::ptr::null_mut(), x, y, w, h, wm::SWP_FRAMECHANGED | wm::SWP_NOZORDER | wm::SWP_SHOWWINDOW); } - (ex_style, style, fit(parent, x, y, width, height)) + FULL_SCREEN.store(!full, std::sync::atomic::Ordering::Relaxed); + tracing::info!(full_screen = !full, "the title's window switched"); +} + +/// The styles and place after a switch from full screen (`full`) or to it: +/// back to `windowed`, or a frameless popup over `monitor`. Visible either way. +fn toggled(full: bool, windowed: Windowed, monitor: RECT) -> Windowed { + if full { + let (ex_style, style, place) = windowed; + return (ex_style, style | wm::WS_VISIBLE, place); + } + let (ex_style, style, _) = windowed; + let (w, h) = (monitor.right - monitor.left, monitor.bottom - monitor.top); + let (ex_style, style, _) = + full_screen(ex_style, style | wm::WS_VISIBLE, false, (w, h)).unwrap_or((ex_style, style, (0, 0, w, h))); + (ex_style, style, (monitor.left, monitor.top, w, h)) +} + +/// A key that switches full screen: F11, or Enter with Alt. +fn switches_full_screen(message: u32, wparam: WPARAM, lparam: LPARAM) -> bool { + const VK_RETURN: usize = 0x0D; + const VK_F11: usize = 0x7A; + let alt = (lparam >> 29) & 1 != 0; + (message == wm::WM_KEYDOWN && wparam == VK_F11) || (message == wm::WM_SYSKEYDOWN && wparam == VK_RETURN && alt) ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Ignore auto-repeat messages for full-screen shortcuts** Holding F11 or Alt+Enter beyond the keyboard repeat delay generates repeated key-down messages, and every one currently triggers another full-screen transition. The window consequently alternates modes until release, with the final mode depending on the repeat count. Check the previous-key-state bit in `lparam` and toggle only on the initial key-down. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
chatgpt-codex-connector[bot] commented 2026-11-26 08:36:58 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T08:36:58Z.

Code review location: crates/victory-gpu/src/host.rs; line 9308

@@ -9302,6 +9302,10 @@ impl Host {
             let swap_chain = factory
                 .CreateSwapChainForHwnd(&self.queue, hwnd, &desc, None, None)?
                 .cast::<IDXGISwapChain3>()?;
+            // Alt+Enter is the title window's own switch to and from full
+            // screen (frameless, the swap chain stretched); DXGI's would make
+            // it exclusive full screen, whose buffers nothing resizes.
+            let _ = factory.MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER);

P2 Badge Provide a replacement shortcut for the GPU fallback window

When presenter() finds no title-created window, it calls window(width, height) to create the GPU fallback window. That window is created directly through Win32 in make_window(), and its window_proc() only calls DefWindowProcW; it never receives the lifecycle module's new shortcut handler. Disabling DXGI's Alt+Enter unconditionally therefore removes the fallback window's existing full-screen shortcut without providing a replacement. Add the borderless toggle handler to this window too, or restrict this association change to windows with the replacement handler.

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review-comment:4705693170 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/1#discussion_r4705693170). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/apps/chatgpt-codex-connector) on 2026-11-26T08:36:58Z. **Code review location:** `crates/victory-gpu/src/host.rs`; line 9308 ~~~~diff @@ -9302,6 +9302,10 @@ impl Host { let swap_chain = factory .CreateSwapChainForHwnd(&self.queue, hwnd, &desc, None, None)? .cast::<IDXGISwapChain3>()?; + // Alt+Enter is the title window's own switch to and from full + // screen (frameless, the swap chain stretched); DXGI's would make + // it exclusive full screen, whose buffers nothing resizes. + let _ = factory.MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER); ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Provide a replacement shortcut for the GPU fallback window** When `presenter()` finds no title-created window, it calls `window(width, height)` to create the GPU fallback window. That window is created directly through Win32 in `make_window()`, and its `window_proc()` only calls `DefWindowProcW`; it never receives the lifecycle module's new shortcut handler. Disabling DXGI's Alt+Enter unconditionally therefore removes the fallback window's existing full-screen shortcut without providing a replacement. Add the borderless toggle handler to this window too, or restrict this association change to windows with the replacement handler. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
TaynanGT commented 2026-11-27 01:33:54 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-27T01:33:54Z.


I opened #104 to address the four findings above. Window placement now belongs to the window that created it, the restore path resolves default coordinates before calling SetWindowPos, and held F11 or Alt+Enter only toggles once. The fallback window keeps DXGI's Alt+Enter. The draft includes regression tests and is waiting for CI and an in-game toggle check.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:comment:7207390781 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/1#issuecomment-7207390781). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-27T01:33:54Z. --- I opened #104 to address the four findings above. Window placement now belongs to the window that created it, the restore path resolves default coordinates before calling `SetWindowPos`, and held F11 or Alt+Enter only toggles once. The fallback window keeps DXGI's Alt+Enter. The draft includes regression tests and is waiting for CI and an in-game toggle check.
TaynanGT commented 2026-11-29 19:11:24 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-29T19:11:24Z.

Code review location: crates/victory-hle/src/modules/lifecycle.rs; line 170

@@ -160,15 +160,77 @@ fn place(
     width: i32,
     height: i32,
 ) -> (u32, u32, (i32, i32, i32, i32)) {
-    if full_screen_on() {
-        // SAFETY: plain queries of the primary monitor's size.
-        let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) };
-        if let Some(full) = full_screen(ex_style, style, !parent.is_null(), screen) {
-            tracing::info!(width = screen.0, height = screen.1, "title window made full screen");
-            return full;
-        }
+    let fitted = fit(parent, x, y, width, height);
+    // SAFETY: plain queries of the primary monitor's size.
+    let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) };
+    let full = full_screen(ex_style, style, !parent.is_null(), screen);
+    if full.is_some() {
+        // A window that could go full screen: how it goes back to a window
+        // ([`toggle_full_screen`]).
+        *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) = Some((ex_style, style, fitted));

The current local lifecycle implementation stores window state per HWND in WINDOWS and removes it on WM_NCDESTROY. The selected title window looks up its own state, so a helper window no longer overwrites it. Native fullscreen testing remains separate.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review-comment:4732760213 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/1#discussion_r4732760213). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-29T19:11:24Z. **Code review location:** `crates/victory-hle/src/modules/lifecycle.rs`; line 170 ~~~~diff @@ -160,15 +160,77 @@ fn place( width: i32, height: i32, ) -> (u32, u32, (i32, i32, i32, i32)) { - if full_screen_on() { - // SAFETY: plain queries of the primary monitor's size. - let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) }; - if let Some(full) = full_screen(ex_style, style, !parent.is_null(), screen) { - tracing::info!(width = screen.0, height = screen.1, "title window made full screen"); - return full; - } + let fitted = fit(parent, x, y, width, height); + // SAFETY: plain queries of the primary monitor's size. + let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) }; + let full = full_screen(ex_style, style, !parent.is_null(), screen); + if full.is_some() { + // A window that could go full screen: how it goes back to a window + // ([`toggle_full_screen`]). + *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) = Some((ex_style, style, fitted)); ~~~~ --- The current local lifecycle implementation stores window state per HWND in WINDOWS and removes it on WM_NCDESTROY. The selected title window looks up its own state, so a helper window no longer overwrites it. Native fullscreen testing remains separate.
TaynanGT commented 2026-11-29 19:11:26 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-29T19:11:26Z.

Code review location: crates/victory-hle/src/modules/lifecycle.rs; line 208

@@ -160,15 +160,77 @@ fn place(
     width: i32,
     height: i32,
 ) -> (u32, u32, (i32, i32, i32, i32)) {
-    if full_screen_on() {
-        // SAFETY: plain queries of the primary monitor's size.
-        let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) };
-        if let Some(full) = full_screen(ex_style, style, !parent.is_null(), screen) {
-            tracing::info!(width = screen.0, height = screen.1, "title window made full screen");
-            return full;
-        }
+    let fitted = fit(parent, x, y, width, height);
+    // SAFETY: plain queries of the primary monitor's size.
+    let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) };
+    let full = full_screen(ex_style, style, !parent.is_null(), screen);
+    if full.is_some() {
+        // A window that could go full screen: how it goes back to a window
+        // ([`toggle_full_screen`]).
+        *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) = Some((ex_style, style, fitted));
+    }
+    if full_screen_on()
+        && let Some(full) = full
+    {
+        tracing::info!(width = screen.0, height = screen.1, "title window made full screen");
+        FULL_SCREEN.store(true, std::sync::atomic::Ordering::Relaxed);
+        return full;
+    }
+    (ex_style, style, fitted)
+}
+
+/// The styles and place the title's top-level window had (or would have
+/// had) as a window, for going back from full screen.
+type Windowed = (u32, u32, (i32, i32, i32, i32));
+static WINDOWED: Mutex<Option<Windowed>> = Mutex::new(None);
+/// Whether the title's window is full screen now.
+static FULL_SCREEN: AtomicBool = AtomicBool::new(false);
+
+/// F11 or Alt+Enter on the title's window: full screen (frameless, over the
+/// monitor it is on) or back to the window it was made as, whichever it is
+/// not now. The swap chain stretches to either.
+fn toggle_full_screen(hwnd: HWND) {
+    let Some(windowed) = *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) else { return };
+    let full = FULL_SCREEN.load(std::sync::atomic::Ordering::Relaxed);
+    // SAFETY: queries of the title's window and the monitor it is on.
+    let monitor = unsafe {
+        let mut info: windows_sys::Win32::Graphics::Gdi::MONITORINFO = std::mem::zeroed();
+        info.cbSize = std::mem::size_of_val(&info) as u32;
+        let on = windows_sys::Win32::Graphics::Gdi::MonitorFromWindow(hwnd, windows_sys::Win32::Graphics::Gdi::MONITOR_DEFAULTTONEAREST);
+        (windows_sys::Win32::Graphics::Gdi::GetMonitorInfoW(on, &mut info) != 0).then_some(info.rcMonitor)
+    };
+    let Some(monitor) = monitor else { return };
+    let (ex_style, style, (x, y, w, h)) = toggled(full, windowed, monitor);
+    // SAFETY: the title's own window, on its own thread (this procedure).
+    unsafe {
+        wm::SetWindowLongPtrW(hwnd, wm::GWL_STYLE, style as isize);
+        wm::SetWindowLongPtrW(hwnd, wm::GWL_EXSTYLE, ex_style as isize);
+        wm::SetWindowPos(hwnd, std::ptr::null_mut(), x, y, w, h, wm::SWP_FRAMECHANGED | wm::SWP_NOZORDER | wm::SWP_SHOWWINDOW);

The current local lifecycle path resolves CW_USEDEFAULT into monitor-relative coordinates and positive dimensions for restoration. The regression coverage includes a monitor with negative coordinates.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review-comment:4732760312 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/1#discussion_r4732760312). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-29T19:11:26Z. **Code review location:** `crates/victory-hle/src/modules/lifecycle.rs`; line 208 ~~~~diff @@ -160,15 +160,77 @@ fn place( width: i32, height: i32, ) -> (u32, u32, (i32, i32, i32, i32)) { - if full_screen_on() { - // SAFETY: plain queries of the primary monitor's size. - let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) }; - if let Some(full) = full_screen(ex_style, style, !parent.is_null(), screen) { - tracing::info!(width = screen.0, height = screen.1, "title window made full screen"); - return full; - } + let fitted = fit(parent, x, y, width, height); + // SAFETY: plain queries of the primary monitor's size. + let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) }; + let full = full_screen(ex_style, style, !parent.is_null(), screen); + if full.is_some() { + // A window that could go full screen: how it goes back to a window + // ([`toggle_full_screen`]). + *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) = Some((ex_style, style, fitted)); + } + if full_screen_on() + && let Some(full) = full + { + tracing::info!(width = screen.0, height = screen.1, "title window made full screen"); + FULL_SCREEN.store(true, std::sync::atomic::Ordering::Relaxed); + return full; + } + (ex_style, style, fitted) +} + +/// The styles and place the title's top-level window had (or would have +/// had) as a window, for going back from full screen. +type Windowed = (u32, u32, (i32, i32, i32, i32)); +static WINDOWED: Mutex<Option<Windowed>> = Mutex::new(None); +/// Whether the title's window is full screen now. +static FULL_SCREEN: AtomicBool = AtomicBool::new(false); + +/// F11 or Alt+Enter on the title's window: full screen (frameless, over the +/// monitor it is on) or back to the window it was made as, whichever it is +/// not now. The swap chain stretches to either. +fn toggle_full_screen(hwnd: HWND) { + let Some(windowed) = *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) else { return }; + let full = FULL_SCREEN.load(std::sync::atomic::Ordering::Relaxed); + // SAFETY: queries of the title's window and the monitor it is on. + let monitor = unsafe { + let mut info: windows_sys::Win32::Graphics::Gdi::MONITORINFO = std::mem::zeroed(); + info.cbSize = std::mem::size_of_val(&info) as u32; + let on = windows_sys::Win32::Graphics::Gdi::MonitorFromWindow(hwnd, windows_sys::Win32::Graphics::Gdi::MONITOR_DEFAULTTONEAREST); + (windows_sys::Win32::Graphics::Gdi::GetMonitorInfoW(on, &mut info) != 0).then_some(info.rcMonitor) + }; + let Some(monitor) = monitor else { return }; + let (ex_style, style, (x, y, w, h)) = toggled(full, windowed, monitor); + // SAFETY: the title's own window, on its own thread (this procedure). + unsafe { + wm::SetWindowLongPtrW(hwnd, wm::GWL_STYLE, style as isize); + wm::SetWindowLongPtrW(hwnd, wm::GWL_EXSTYLE, ex_style as isize); + wm::SetWindowPos(hwnd, std::ptr::null_mut(), x, y, w, h, wm::SWP_FRAMECHANGED | wm::SWP_NOZORDER | wm::SWP_SHOWWINDOW); ~~~~ --- The current local lifecycle path resolves CW_USEDEFAULT into monitor-relative coordinates and positive dimensions for restoration. The regression coverage includes a monitor with negative coordinates.
TaynanGT commented 2026-11-29 19:11:27 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-29T19:11:27Z.

Code review location: crates/victory-hle/src/modules/lifecycle.rs; line 233

@@ -160,15 +160,77 @@ fn place(
     width: i32,
     height: i32,
 ) -> (u32, u32, (i32, i32, i32, i32)) {
-    if full_screen_on() {
-        // SAFETY: plain queries of the primary monitor's size.
-        let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) };
-        if let Some(full) = full_screen(ex_style, style, !parent.is_null(), screen) {
-            tracing::info!(width = screen.0, height = screen.1, "title window made full screen");
-            return full;
-        }
+    let fitted = fit(parent, x, y, width, height);
+    // SAFETY: plain queries of the primary monitor's size.
+    let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) };
+    let full = full_screen(ex_style, style, !parent.is_null(), screen);
+    if full.is_some() {
+        // A window that could go full screen: how it goes back to a window
+        // ([`toggle_full_screen`]).
+        *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) = Some((ex_style, style, fitted));
+    }
+    if full_screen_on()
+        && let Some(full) = full
+    {
+        tracing::info!(width = screen.0, height = screen.1, "title window made full screen");
+        FULL_SCREEN.store(true, std::sync::atomic::Ordering::Relaxed);
+        return full;
+    }
+    (ex_style, style, fitted)
+}
+
+/// The styles and place the title's top-level window had (or would have
+/// had) as a window, for going back from full screen.
+type Windowed = (u32, u32, (i32, i32, i32, i32));
+static WINDOWED: Mutex<Option<Windowed>> = Mutex::new(None);
+/// Whether the title's window is full screen now.
+static FULL_SCREEN: AtomicBool = AtomicBool::new(false);
+
+/// F11 or Alt+Enter on the title's window: full screen (frameless, over the
+/// monitor it is on) or back to the window it was made as, whichever it is
+/// not now. The swap chain stretches to either.
+fn toggle_full_screen(hwnd: HWND) {
+    let Some(windowed) = *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) else { return };
+    let full = FULL_SCREEN.load(std::sync::atomic::Ordering::Relaxed);
+    // SAFETY: queries of the title's window and the monitor it is on.
+    let monitor = unsafe {
+        let mut info: windows_sys::Win32::Graphics::Gdi::MONITORINFO = std::mem::zeroed();
+        info.cbSize = std::mem::size_of_val(&info) as u32;
+        let on = windows_sys::Win32::Graphics::Gdi::MonitorFromWindow(hwnd, windows_sys::Win32::Graphics::Gdi::MONITOR_DEFAULTTONEAREST);
+        (windows_sys::Win32::Graphics::Gdi::GetMonitorInfoW(on, &mut info) != 0).then_some(info.rcMonitor)
+    };
+    let Some(monitor) = monitor else { return };
+    let (ex_style, style, (x, y, w, h)) = toggled(full, windowed, monitor);
+    // SAFETY: the title's own window, on its own thread (this procedure).
+    unsafe {
+        wm::SetWindowLongPtrW(hwnd, wm::GWL_STYLE, style as isize);
+        wm::SetWindowLongPtrW(hwnd, wm::GWL_EXSTYLE, ex_style as isize);
+        wm::SetWindowPos(hwnd, std::ptr::null_mut(), x, y, w, h, wm::SWP_FRAMECHANGED | wm::SWP_NOZORDER | wm::SWP_SHOWWINDOW);
     }
-    (ex_style, style, fit(parent, x, y, width, height))
+    FULL_SCREEN.store(!full, std::sync::atomic::Ordering::Relaxed);
+    tracing::info!(full_screen = !full, "the title's window switched");
+}
+
+/// The styles and place after a switch from full screen (`full`) or to it:
+/// back to `windowed`, or a frameless popup over `monitor`. Visible either way.
+fn toggled(full: bool, windowed: Windowed, monitor: RECT) -> Windowed {
+    if full {
+        let (ex_style, style, place) = windowed;
+        return (ex_style, style | wm::WS_VISIBLE, place);
+    }
+    let (ex_style, style, _) = windowed;
+    let (w, h) = (monitor.right - monitor.left, monitor.bottom - monitor.top);
+    let (ex_style, style, _) =
+        full_screen(ex_style, style | wm::WS_VISIBLE, false, (w, h)).unwrap_or((ex_style, style, (0, 0, w, h)));
+    (ex_style, style, (monitor.left, monitor.top, w, h))
+}
+
+/// A key that switches full screen: F11, or Enter with Alt.
+fn switches_full_screen(message: u32, wparam: WPARAM, lparam: LPARAM) -> bool {
+    const VK_RETURN: usize = 0x0D;
+    const VK_F11: usize = 0x7A;
+    let alt = (lparam >> 29) & 1 != 0;
+    (message == wm::WM_KEYDOWN && wparam == VK_F11) || (message == wm::WM_SYSKEYDOWN && wparam == VK_RETURN && alt)

The current switches_full_screen predicate checks bit 30 of lparam and ignores repeated key-down messages. The repeat case is covered by a regression test in lifecycle.rs.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review-comment:4732760414 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/1#discussion_r4732760414). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-29T19:11:27Z. **Code review location:** `crates/victory-hle/src/modules/lifecycle.rs`; line 233 ~~~~diff @@ -160,15 +160,77 @@ fn place( width: i32, height: i32, ) -> (u32, u32, (i32, i32, i32, i32)) { - if full_screen_on() { - // SAFETY: plain queries of the primary monitor's size. - let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) }; - if let Some(full) = full_screen(ex_style, style, !parent.is_null(), screen) { - tracing::info!(width = screen.0, height = screen.1, "title window made full screen"); - return full; - } + let fitted = fit(parent, x, y, width, height); + // SAFETY: plain queries of the primary monitor's size. + let screen = unsafe { (wm::GetSystemMetrics(wm::SM_CXSCREEN), wm::GetSystemMetrics(wm::SM_CYSCREEN)) }; + let full = full_screen(ex_style, style, !parent.is_null(), screen); + if full.is_some() { + // A window that could go full screen: how it goes back to a window + // ([`toggle_full_screen`]). + *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) = Some((ex_style, style, fitted)); + } + if full_screen_on() + && let Some(full) = full + { + tracing::info!(width = screen.0, height = screen.1, "title window made full screen"); + FULL_SCREEN.store(true, std::sync::atomic::Ordering::Relaxed); + return full; + } + (ex_style, style, fitted) +} + +/// The styles and place the title's top-level window had (or would have +/// had) as a window, for going back from full screen. +type Windowed = (u32, u32, (i32, i32, i32, i32)); +static WINDOWED: Mutex<Option<Windowed>> = Mutex::new(None); +/// Whether the title's window is full screen now. +static FULL_SCREEN: AtomicBool = AtomicBool::new(false); + +/// F11 or Alt+Enter on the title's window: full screen (frameless, over the +/// monitor it is on) or back to the window it was made as, whichever it is +/// not now. The swap chain stretches to either. +fn toggle_full_screen(hwnd: HWND) { + let Some(windowed) = *WINDOWED.lock().unwrap_or_else(|e| e.into_inner()) else { return }; + let full = FULL_SCREEN.load(std::sync::atomic::Ordering::Relaxed); + // SAFETY: queries of the title's window and the monitor it is on. + let monitor = unsafe { + let mut info: windows_sys::Win32::Graphics::Gdi::MONITORINFO = std::mem::zeroed(); + info.cbSize = std::mem::size_of_val(&info) as u32; + let on = windows_sys::Win32::Graphics::Gdi::MonitorFromWindow(hwnd, windows_sys::Win32::Graphics::Gdi::MONITOR_DEFAULTTONEAREST); + (windows_sys::Win32::Graphics::Gdi::GetMonitorInfoW(on, &mut info) != 0).then_some(info.rcMonitor) + }; + let Some(monitor) = monitor else { return }; + let (ex_style, style, (x, y, w, h)) = toggled(full, windowed, monitor); + // SAFETY: the title's own window, on its own thread (this procedure). + unsafe { + wm::SetWindowLongPtrW(hwnd, wm::GWL_STYLE, style as isize); + wm::SetWindowLongPtrW(hwnd, wm::GWL_EXSTYLE, ex_style as isize); + wm::SetWindowPos(hwnd, std::ptr::null_mut(), x, y, w, h, wm::SWP_FRAMECHANGED | wm::SWP_NOZORDER | wm::SWP_SHOWWINDOW); } - (ex_style, style, fit(parent, x, y, width, height)) + FULL_SCREEN.store(!full, std::sync::atomic::Ordering::Relaxed); + tracing::info!(full_screen = !full, "the title's window switched"); +} + +/// The styles and place after a switch from full screen (`full`) or to it: +/// back to `windowed`, or a frameless popup over `monitor`. Visible either way. +fn toggled(full: bool, windowed: Windowed, monitor: RECT) -> Windowed { + if full { + let (ex_style, style, place) = windowed; + return (ex_style, style | wm::WS_VISIBLE, place); + } + let (ex_style, style, _) = windowed; + let (w, h) = (monitor.right - monitor.left, monitor.bottom - monitor.top); + let (ex_style, style, _) = + full_screen(ex_style, style | wm::WS_VISIBLE, false, (w, h)).unwrap_or((ex_style, style, (0, 0, w, h))); + (ex_style, style, (monitor.left, monitor.top, w, h)) +} + +/// A key that switches full screen: F11, or Enter with Alt. +fn switches_full_screen(message: u32, wparam: WPARAM, lparam: LPARAM) -> bool { + const VK_RETURN: usize = 0x0D; + const VK_F11: usize = 0x7A; + let alt = (lparam >> 29) & 1 != 0; + (message == wm::WM_KEYDOWN && wparam == VK_F11) || (message == wm::WM_SYSKEYDOWN && wparam == VK_RETURN && alt) ~~~~ --- The current switches_full_screen predicate checks bit 30 of lparam and ignores repeated key-down messages. The repeat case is covered by a regression test in lifecycle.rs.
TaynanGT commented 2026-11-29 19:11:29 +00:00 (Migrated from github.com)

Imported from TaynanGT/Vice-Tay. Originally posted by TaynanGT on 2026-11-29T19:11:29Z.

Code review location: crates/victory-gpu/src/host.rs; line 9308

@@ -9302,6 +9302,10 @@ impl Host {
             let swap_chain = factory
                 .CreateSwapChainForHwnd(&self.queue, hwnd, &desc, None, None)?
                 .cast::<IDXGISwapChain3>()?;
+            // Alt+Enter is the title window's own switch to and from full
+            // screen (frameless, the swap chain stretched); DXGI's would make
+            // it exclusive full screen, whose buffers nothing resizes.
+            let _ = factory.MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER);

The current local presenter only disables DXGI Alt+Enter when a title window exists. The fallback window retains DXGI's shortcut rather than losing it unconditionally.

<!-- greyfinch-sync:TaynanGT/Vice-Tay:review-comment:4732760506 --> Imported from [TaynanGT/Vice-Tay](https://github.com/TaynanGT/Vice-Tay/pull/1#discussion_r4732760506). Originally posted by [TaynanGT](https://github.com/TaynanGT) on 2026-11-29T19:11:29Z. **Code review location:** `crates/victory-gpu/src/host.rs`; line 9308 ~~~~diff @@ -9302,6 +9302,10 @@ impl Host { let swap_chain = factory .CreateSwapChainForHwnd(&self.queue, hwnd, &desc, None, None)? .cast::<IDXGISwapChain3>()?; + // Alt+Enter is the title window's own switch to and from full + // screen (frameless, the swap chain stretched); DXGI's would make + // it exclusive full screen, whose buffers nothing resizes. + let _ = factory.MakeWindowAssociation(hwnd, DXGI_MWA_NO_ALT_ENTER); ~~~~ --- The current local presenter only disables DXGI Alt+Enter when a title window exists. The fallback window retains DXGI's shortcut rather than losing it unconditionally.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
TaynanGT/Vice-Tay!1
No description provided.