A full-window container's own window moves by its title row and resizes by its edges (photocraft#16905)

The fallback overlay of a full-window viewport mount covers the main window
and neither moves nor resizes; its own OS window took that rule, so a window
the app frames had no move band and no grips. In its own window the band
follows the window's own rule and every edge has a grip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
David Mann
2026-11-25 12:11:58 +01:00
co-authored by Claude Opus 5.5
parent 37c5317f1e
commit 60fcf6b1d9
3 changed files with 94 additions and 3 deletions
@@ -362,6 +362,58 @@ pub(crate) mod own_window {
assert!(!open.get(), "closing the dialog's window closes the dialog");
assert_eq!(closed.get(), Some((CloseReason::Requested, true)), "the close is a cancel");
}
/// photocraft#16905: in a window the app frames, a full-window dialog's own window moves by its title row. Its
/// fallback covers the main window and does not move, and the window took that rule, so RAW Develop's window could
/// not be moved.
#[trial]
fn a_full_window_dialogs_own_window_moves_by_its_title_row() {
use craft_host::target::{Backend, Os, ShellInfo, WindowKind};
use craft_ui::runtime::InstallSpec;
use craft_ui::testing::pointer::{moved, press, release};
use craft_ui::testing::windows::FakeSystem;
use craft_window::policy::{Desktop, DesktopKind, Runtime, TitleBarPref};
use egui::{Pos2, Rect, Vec2, ViewportCommand, pos2, vec2};
use std::sync::Arc;
let desktop = Desktop { kind: DesktopKind::Other, ssd: None, gtk_theme: None, icon_theme: None };
let integrated =
craft_window::policy::decide(Os::Linux, Runtime::Native, Backend::X11, &desktop, WindowKind::Main, TitleBarPref::Integrated, None);
let windows = Windows::with(InstallSpec::new(ShellInfo::default(), Arc::new(FakeSystem::new())).frame(integrated));
let open = Cell::new(true);
let frame = |events: Vec<egui::Event>| {
windows.frame(vec![], events, |ui| {
let mut is_open = open.get();
FullWindowDialog::new("Workspace").own_window(WindowSpec::dialog()).opened(Bind::bound(&mut is_open)).show(ui, |_, _| {});
open.set(is_open);
})
};
let rect = Rect::from_min_size(Pos2::new(100.0, 100.0), Vec2::new(900.0, 640.0));
windows.child_info(ViewportInfo {
inner_rect: Some(rect),
outer_rect: Some(rect),
native_pixels_per_point: Some(1.0),
..ViewportInfo::default()
});
for _ in 0..4 {
frame(vec![]);
}
// Clear of the top edge's grip and of the title row's own parts (the title at the start, the close action at
// the end).
let at = pos2(450.0, 14.0);
let mut sent = Vec::new();
for events in [
vec![moved(at)],
vec![press(at)],
vec![moved(at + vec2(20.0, 10.0))],
vec![moved(at + vec2(40.0, 20.0))],
vec![release(at + vec2(40.0, 20.0))],
] {
sent.extend(frame(events).commands.into_iter().map(|(_, command)| command));
}
assert!(open.get(), "the dialog stays open");
assert!(sent.contains(&ViewportCommand::StartDrag), "a drag of the title row moves the window: {sent:?}");
}
}
/// An overlay drawn through a frame.
@@ -795,11 +795,16 @@ impl BodyHooks<'_> {
};
let exclusive = |hit: WindowHit| os.is_some().then_some(hit);
let moves_window = matches!(&props.mount, Mount::Layer(overlay) | Mount::Viewport { fallback: overlay, .. } if overlay.moves_window);
// A full-window container in an OS window of its own: its fallback layer covers the main window, so neither
// moves nor resizes, but the window is one the user moves by its title row and sizes by its edges, as any
// window. Without them a window the app frames had no band and no grips (photocraft#16905).
let own_full_window = os.is_some() && matches!(&props.mount, Mount::Viewport { fallback, .. } if fallback.is_full_window());
// A layer moves when its overlay says so; other mounts follow the header's band.
let movable = match &props.mount {
// A band that moves the window below follows the rule of the window's own band (a title bar's); where the
// platform answers the hit test, the sink reads it from the exclusive list.
_ if moves_window => WindowParts::of(&ctx, pass::current_viewport(&ctx)).band,
_ if own_full_window => stands.band,
Mount::Layer(overlay) | Mount::Viewport { fallback: overlay, .. } => overlay.movable && stands.band,
_ => props.header.is_some_and(|header| header.band == crate::contract::DragBand::Move) && stands.band,
};
@@ -825,6 +830,7 @@ impl BodyHooks<'_> {
}
}
let edges = match &props.mount {
_ if own_full_window => ResizeEdges::ALL,
Mount::Layer(overlay) | Mount::Viewport { fallback: overlay, .. } => overlay.resize.edges,
Mount::Window { resize } => resize.edges,
_ => ResizeEdges::NONE,
@@ -4,12 +4,15 @@
//! move band is reported once.
use craft_behavior::{Cursor, CursorIcon};
use craft_host::target::{ShellInfo, WindowChrome, WindowInfo, WindowKind};
use craft_host::target::{Backend, Os, ShellInfo, WindowChrome, WindowInfo, WindowKind};
use craft_ui::contract::overlay::Resize;
use craft_ui::contract::{
BodyCx, Common, Component, Container, ContainerProps, Cx, DragBand, HeaderRegion, Mount, Props as _, Role, Show as _, ShowContainer as _, Sizing,
BodyCx, Common, Component, Container, ContainerProps, Cx, DragBand, HeaderRegion, Mount, Overlay, Props as _, Role, Show as _,
ShowContainer as _, Sizing,
};
use craft_ui::runtime::InstallSpec;
use craft_ui::runtime::focus::FocusPolicy;
use craft_ui::runtime::windows::WindowSpec;
use craft_ui::style::StyleCx;
use craft_ui::testing::layout::allocate;
use craft_ui::testing::pointer::{moved, press, release};
@@ -17,8 +20,9 @@ use craft_ui::testing::trial;
use craft_ui::testing::windows::FakeSystem;
use craft_ui_test_kit::contract::{PlainStyle, Probe, Seen};
use craft_ui_test_kit::windows::Windows;
use craft_window::policy::{Desktop, DesktopKind, Runtime, TitleBarPref};
use egui::viewport::ResizeDirection;
use egui::{Event, Pos2, Rect, Response, Ui, Vec2, ViewportCommand, pos2, vec2};
use egui::{Event, Pos2, Rect, Response, Ui, Vec2, ViewportCommand, ViewportInfo, pos2, vec2};
use std::cell::{Cell, RefCell};
use std::sync::Arc;
@@ -185,3 +189,32 @@ fn where_appkit_resizes_a_window_the_app_registers_no_grips_and_leaves_the_curso
let cursor = craft_ui::runtime::cursor::current(&windows.ctx);
assert!(matches!(cursor, None | Some(Cursor::System(CursorIcon::Default))), "over AppKit's edge the cursor is left to the OS: {cursor:?}");
}
/// photocraft#16905: a full-window container (RAW Develop, Vanishing Point) in an OS window of its own, in a window the
/// app frames, moves by its title row and resizes by its edges. Its fallback overlay covers the main window and neither
/// moves nor resizes, and the window took that rule: no move band and no grips, so the window could not be moved.
#[trial]
fn a_full_window_container_in_its_own_window_moves_and_resizes_it() {
const WINDOW: Vec2 = Vec2::new(900.0, 640.0);
let desktop = Desktop { kind: DesktopKind::Other, ssd: None, gtk_theme: None, icon_theme: None };
let integrated =
craft_window::policy::decide(Os::Linux, Runtime::Native, Backend::X11, &desktop, WindowKind::Main, TitleBarPref::Integrated, None);
let windows = Windows::with(InstallSpec::new(ShellInfo::default(), Arc::new(FakeSystem::new())).frame(integrated));
let rig = Rig::new(Mount::viewport_with(Overlay::full_window(FocusPolicy::DIALOG), WindowSpec::dialog()));
let rect = Rect::from_min_size(Pos2::new(100.0, 100.0), WINDOW);
windows.child_info(ViewportInfo {
inner_rect: Some(rect),
outer_rect: Some(rect),
native_pixels_per_point: Some(1.0),
..ViewportInfo::default()
});
for _ in 0..4 {
rig.frame(&windows, vec![], vec![]);
}
let title = rig.header.get();
assert!(title.is_positive(), "the title row showed");
let sent = drag(pos2(title.center().x + 30.0, title.center().y), vec2(40.0, 20.0), |events| rig.frame(&windows, vec![], events));
assert!(sent.contains(&ViewportCommand::StartDrag), "a drag of the title row moves the window: {sent:?}");
let sent = drag(pos2(WINDOW.x - 1.0, WINDOW.y / 2.0), vec2(-20.0, 0.0), |events| rig.frame(&windows, vec![], events));
assert_eq!(resizes(&sent), [ResizeDirection::East], "a drag of the right edge resizes the window: {sent:?}");
}