diff --git a/crates/ui-contract/src/runtime/windows/native.rs b/crates/ui-contract/src/runtime/windows/native.rs index 78ecac850..6fa828cfb 100644 --- a/crates/ui-contract/src/runtime/windows/native.rs +++ b/crates/ui-contract/src/runtime/windows/native.rs @@ -8,13 +8,19 @@ use super::shell::{base_shell, os_of, window_info}; use super::spec::WindowLevel; use super::{HandOff, Record, SEARCH_EVERY, shared}; use crate::runtime::egui::{pass, viewports}; -use crate::runtime::frame::PerViewport; +use crate::runtime::frame::{PerViewport, Stored}; use craft_host::target::{Caps, DoubleClick, WindowState}; use craft_window::native::NativeWindow; use craft_window::policy::Frame; use egui::{Context, Pos2, Rect, Vec2, ViewportId}; use std::sync::Arc; +/// The last title the host set for a viewport. +#[derive(Default)] +struct SentTitle(Option); + +impl Stored for SentTitle {} + /// A window command `act` sends. #[derive(Clone, Debug, PartialEq)] #[non_exhaustive] @@ -137,7 +143,19 @@ pub fn act(ctx: &Context, viewport: ViewportId, action: WindowAction) -> bool { viewports::command(ctx, viewport, egui::ViewportCommand::WindowLevel(level.for_egui(active, os_of(ctx)))); } } - WindowAction::SetTitle(title) => viewports::command(ctx, viewport, egui::ViewportCommand::Title(title)), + WindowAction::SetTitle(title) => { + // `ViewportInfo::title` is empty on X11 and Wayland, so the host remembers what it set itself. + let fresh = PerViewport::::with(ctx, viewport, |sent| { + let fresh = sent.0.as_deref() != Some(title.as_str()); + if fresh { + sent.0 = Some(title.clone()); + } + fresh + }); + if fresh { + viewports::command(ctx, viewport, egui::ViewportCommand::Title(title)); + } + } WindowAction::SetOpacity(_) => {} } true diff --git a/crates/ui-panels/src/rails/flyout.rs b/crates/ui-panels/src/rails/flyout.rs index 3b30f20d9..7ed09ecff 100644 --- a/crates/ui-panels/src/rails/flyout.rs +++ b/crates/ui-panels/src/rails/flyout.rs @@ -283,7 +283,8 @@ impl Component for FlyoutButton<'_, T> { self.open = open; self.double = cx.press().double_pressed() && cx.press().mods.is_none(); if alt { - if let Some(at) = stepped { + // The release that ends a hold or a drag away fires nothing, with Alt held or not. + if let Some(at) = stepped.filter(|_| !held) { let tool = &self.tools[at]; cx.fire(tool.command.clone(), FireSource::Pointer); self.picked = Some(tool.id.clone()); diff --git a/crates/ui-panels/tests/it/rails/mod.rs b/crates/ui-panels/tests/it/rails/mod.rs index 10ddd9087..ce705a14b 100644 --- a/crates/ui-panels/tests/it/rails/mod.rs +++ b/crates/ui-panels/tests/it/rails/mod.rs @@ -135,7 +135,6 @@ fn a_click_command_cycles_and_a_hold_lists_the_tools_without_firing_it() { clicked.fixture.click(&target); clicked.fixture.idle(3); assert_eq!(fired(&clicked), 1, "a click fires the click command"); - clicked.fixture.key(Key::Tab, Modifiers::NONE); clicked.fixture.key(Key::Enter, Modifiers::NONE); assert_eq!(fired(&clicked), 1, "Enter fires it"); clicked.fixture.key(Key::Space, Modifiers::NONE); diff --git a/crates/ui-shell/src/shell/app_shell.rs b/crates/ui-shell/src/shell/app_shell.rs index d8052c753..03faacc3d 100644 --- a/crates/ui-shell/src/shell/app_shell.rs +++ b/crates/ui-shell/src/shell/app_shell.rs @@ -282,8 +282,8 @@ pub struct AppShell<'a, S> { /// The host's flag for the document tabs, read back through `ShellCx::tabs_visible`. #[prop] document_tabs: bool, - /// The window's title: the shell sends `WindowAction::SetTitle` when it differs from the title the viewport - /// reports. Not in an embedded shell. + /// The window's title: the shell sends `WindowAction::SetTitle` every pass and the window host drops a title equal + /// to the last one it set. Not in an embedded shell. #[prop(into)] window_title: Option, /// The name of the body region; the translated "Document" without it. @@ -433,10 +433,9 @@ impl<'a, S> AppShell<'a, S> { && !embedded && !ui.is_sizing_pass() { + // The window host skips a title equal to the one it last set for the viewport. let ctx = ui.ctx(); - if ctx.input(|input| input.viewport().title.clone()).as_deref() != Some(title.as_str()) { - WindowHost::of(ctx).act(pass::current_viewport(ctx), WindowAction::SetTitle(title)); - } + WindowHost::of(ctx).act(pass::current_viewport(ctx), WindowAction::SetTitle(title)); } let env = Env::of(ui); let outer = env.get::().0; diff --git a/crates/ui-shell/src/shell/mod.rs b/crates/ui-shell/src/shell/mod.rs index 1cedb638c..c5d93ebbf 100644 --- a/crates/ui-shell/src/shell/mod.rs +++ b/crates/ui-shell/src/shell/mod.rs @@ -23,7 +23,6 @@ mod opening; mod reveal; mod screen_mode; mod screen_mode_button; -mod screen_mode_button; pub use app_shell::{AppShell, AppShellOutput, ShellDialogsCx, ShellRegion, ShellRegionOutput, WindowDialogs}; pub use canvas_shell::{CanvasPanel, CanvasPanelOutput, slots};