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. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
74f4d02944
commit
7f3a4b2428
1 changed files with 40 additions and 0 deletions
|
|
@ -283,6 +283,46 @@ pub fn attach_shell<R: Runtime>(shell: &Webview<R>) {
|
|||
|
||||
/// 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<R: Runtime>(shell: &Webview<R>, 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<R: Runtime>(webview: &Webview<R>) -> Option<(f64, f64, f64, f64)> {
|
||||
linux::placed(webview.label())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue