{"record":{"id":"53aedf3c80cbd87a","repo":"AprilNEA/OpenLogi","slug":"ring-window-has-no-win32-handle","errorCode":null,"errorMessage":"ring window has no Win32 handle","messagePattern":"ring window has no Win32 handle","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/openlogi-overlay/src/platform/windows/native.rs","lineNumber":76,"sourceCode":"                point(DevicePixels(cursor.x), DevicePixels(cursor.y))\n            } else {\n                display.center()\n            },\n            display,\n        })\n    }\n\n    #[expect(\n        unsafe_code,\n        reason = \"borrow the live GPUI HWND on its owning UI thread\"\n    )]\n    pub(crate) fn show(self, window: &mut Window) -> Result<()> {\n        let RawWindowHandle::Win32(handle) = window\n            .window_handle()\n            .map_err(|error| anyhow::anyhow!(\"get ring HWND: {error}\"))?\n            .as_raw()\n        else {\n            anyhow::bail!(\"ring window has no Win32 handle\");\n        };\n        let hwnd = handle.hwnd.get() as HWND;\n        // Bootstrap a tiny hidden window well inside the selected monitor.\n        // SetWindowPos synchronously delivers WM_DPICHANGED; GPUI applies its\n        // suggested rectangle and updates rendering scale before this returns.\n        // Final geometry is applied only AFTER that transition, so the suggested\n        // rectangle cannot move a cursor-centred ring away from its anchor.\n        let anchor = Bounds::new(\n            self.display.center(),\n            size(DevicePixels(1), DevicePixels(1)),\n        );\n        set_bounds(hwnd, anchor, SWP_NOACTIVATE | SWP_NOZORDER)?;\n        // SAFETY: hwnd belongs to the still-borrowed window.\n        let dpi = unsafe { GetDpiForWindow(hwnd) };\n        ensure!(dpi != 0, \"could not read ring window DPI\");\n        // SAFETY: read-only query on the still-borrowed window.\n        let monitor = unsafe { MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST) };\n        ensure!(","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/AprilNEA/OpenLogi/blob/e846e6f4b4405e33bd6a9aaf949a482ce34cb6d8/crates/openlogi-overlay/src/platform/windows/native.rs#L58-L94","documentation":"The Windows overlay's `show` obtains the ring window's raw handle via the windowing crate and requires the `RawWindowHandle::Win32` variant, since the DPI-bootstrap trick needs a real HWND. If GPUI hands back any other raw-handle variant, the code cannot proceed on Windows and bails with this error.","triggerScenarios":"Calling `show` on a ring window whose `window_handle().as_raw()` is not `RawWindowHandle::Win32` — i.e. the window is not backed by Win32 (wrong platform build, headless/mock window, or a GPUI backend change).","commonSituations":"Running or testing the Windows overlay path with a window created by a non-Win32 backend; a GPUI version change altering the raw-handle variant; mixing platform code so the overlay runs off-Windows where Win32 handles don't exist.","solutions":["Ensure the overlay only runs on Windows with GPUI's Win32 (winit/Win32) backend and a real, visible window.","Check that the window passed to `show` was created by the platform window path, not a mock or test stub.","Upgrade/align GPUI versions so `window_handle()` returns the Win32 variant on Windows.","If supporting other platforms in this file, cfg-gate the Win32 path as the codebase does elsewhere."],"exampleFix":"// before\nlet RawWindowHandle::Win32(handle) = window.window_handle()?.as_raw() else {\n    anyhow::bail!(\"ring window has no Win32 handle\");\n};\n// after (guard the platform before showing)\n#[cfg(target_os = \"windows\")]\nlet handle = match window.window_handle()?.as_raw() {\n    RawWindowHandle::Win32(h) => h,\n    other => anyhow::bail!(\"ring window has no Win32 handle, got {other:?}\"),\n};","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"fn is_win32_handle(handle: &RawWindowHandle) -> bool {\n    matches!(handle, RawWindowHandle::Win32(_))\n}","tryCatchPattern":"match show(&mut window) {\n    Err(e) if e.to_string().contains(\"no Win32 handle\") => {\n        log::error!(\"overlay requires a Win32-backed window on Windows: {e}\");\n    }\n    Err(e) => log::error!(\"overlay show failed: {e}\"),\n    Ok(()) => {}\n}","preventionTips":["Only invoke the Windows overlay path on real Win32-backed GPUI windows","Cfg-gate platform-native window manipulation as the codebase does elsewhere","Keep GPUI versions aligned across workspace crates so raw-handle variants match expectations"],"tags":["windows","overlay","win32","gpui"],"backgroundTag":"internal-invariant-violation","analyzedSha":"e846e6f4b4405e33bd6a9aaf949a482ce34cb6d8","analyzedAt":"2026-09-13T03:07:16.451Z","contentChangedAt":"2026-09-13T03:07:16.451Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}