From e07eabb856da1ccc18dda1c5a5fea45e5554cfc2 Mon Sep 17 00:00:00 2001 From: CRT Date: Mon, 28 Sep 2026 19:00:34 +0000 Subject: [PATCH] host: raise_shell puts the shell webview above or below the tab webviews (Windows, SetWindowPos on its WebView2 container) Shell overlays can then draw over the panes while they stay on screen. Returns false elsewhere, where the caller hides the tabs instead. --- crates/waybetter-host/src/host.rs | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/crates/waybetter-host/src/host.rs b/crates/waybetter-host/src/host.rs index 68bfe3c..6a8b4d7 100644 --- a/crates/waybetter-host/src/host.rs +++ b/crates/waybetter-host/src/host.rs @@ -283,6 +283,46 @@ pub fn attach_shell(shell: &Webview) { /// Where [`place_child`] last put a child webview, in logical px (x, y, width, height). Linux /// only: there `Webview::position` is not the placement (always 0,0 outside X11 child windows). +/// Puts the shell webview above every tab webview (`on_top`), so shell menus, dialogs and drag +/// zones draw over the panes while the panes stay on screen (the shell page must then be +/// transparent where the panes are), or back below them. Returns whether this platform can: +/// Windows only (WebView2 hosts each webview in its own child window, re-ordered with +/// `SetWindowPos`; no activation or focus change). Elsewhere the caller hides the tabs instead. +pub fn raise_shell(shell: &Webview, on_top: bool) -> bool { + #[cfg(windows)] + { + let _ = shell.with_webview(move |platform| { + use windows::Win32::Foundation::HWND; + use windows::Win32::UI::WindowsAndMessaging::{ + SetWindowPos, HWND_BOTTOM, HWND_TOP, SWP_NOACTIVATE, SWP_NOMOVE, SWP_NOOWNERZORDER, SWP_NOSIZE, + }; + let mut container = HWND::default(); + // SAFETY: the shell's own live controller and its container window, on the main + // thread (with_webview runs the closure there). + unsafe { + if platform.controller().ParentWindow(&mut container).is_ok() && !container.is_invalid() { + let after = if on_top { HWND_TOP } else { HWND_BOTTOM }; + let _ = SetWindowPos( + container, + Some(after), + 0, + 0, + 0, + 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOOWNERZORDER, + ); + } + } + }); + true + } + #[cfg(not(windows))] + { + let _ = (shell, on_top); + false + } +} + #[cfg(target_os = "linux")] pub fn placed_rect(webview: &Webview) -> Option<(f64, f64, f64, f64)> { linux::placed(webview.label())