Honor pre-refactor window preferences and preserve Hand placement clicks

This commit is contained in:
Codex committed 2026-11-30 12:16:43 +01:00
1 parent fbf3a28cac
commit f4e2f5f4c6
3 files changed
+26 -6

No files matched your search

+11 -4
View File
@@ -114,8 +114,8 @@ const MIN_SIZE: [f32; 2] = [800.0, 500.0];
/// Apply the saved main-window placement before the first frame. On a first launch the
/// framework maximizes the window when its default size would not fit the current screen.
fn restore_main_window(window: &winit::window::Window, store: &Store, wayland: bool) {
use craft::behavior::placement::{Defaults, place};
fn restore_main_window(window: &winit::window::Window, store: &Store, legacy: Option<vectorcraft_ui_egui::state::LegacyWindow>, wayland: bool) {
use craft::behavior::placement::{Defaults, Placement, place};
use craft::behavior::{Monitor, MonitorKey};
use winit::dpi::{LogicalSize, PhysicalPosition};
@@ -131,7 +131,14 @@ fn restore_main_window(window: &winit::window::Window, store: &Store, wayland: b
.collect();
let home = window.current_monitor().or_else(|| window.primary_monitor()).and_then(|monitor| handles.iter().position(|m| *m == monitor));
let defaults = Defaults::new(DEFAULT_SIZE, MIN_SIZE).with_no_position(wayland);
let placement = place(store.get(craft::window::restore::MAIN).as_ref(), &monitors, home, &defaults);
let saved = store.get(craft::window::restore::MAIN).or_else(|| {
let old = legacy?;
let mut placement = Placement::new(old.size, window.scale_factor() as f32);
placement.position_px = old.pos;
placement.maximized = old.maximized;
placement.repaired()
});
let placement = place(saved.as_ref(), &monitors, home, &defaults);
if let Some([x, y]) = placement.position_px {
window.set_outer_position(PhysicalPosition::new(x, y));
}
@@ -819,7 +826,7 @@ fn main() -> std::process::ExitCode {
let winit_window = cc.winit_window().cloned();
let placement = placement_store();
if let Some(window) = &winit_window {
restore_main_window(window, &placement, wayland);
restore_main_window(window, &placement, settings.lock().get().ui.legacy_window, wayland);
}
let spec = InstallSpec::new(shell_info, Arc::new(SystemWindows))
.app_id(vectorcraft_ui_egui::os_window::app_id())
+2 -2
View File
@@ -650,12 +650,12 @@ pub(crate) fn run(app: &mut VectorcraftApp, ui: &mut Ui, pass: &ToolPass) -> Too
let mut picked = ToolHostResponse::default();
let mut response = if crate::dialogs::recolor::edit_tab::with_theme_pick(app, |app, tool| picked = host_run(app, ui, pass, tool)) {
picked
} else if app.session.tool_id() == "hand" && app.ui.screen_mode != 3 {
} else if app.session.tool_id() == "hand" && app.ui.screen_mode != 3 && app.ui.rearrange_placement.is_none() {
let options = crate::app::view::navigation(&app.session.prefs);
let mut hand = app.canvas.hand.take().unwrap_or_else(|| craft::ui::canvas::HandTool::new(options));
hand.options = options;
let response = host_run(app, ui, pass, &mut hand);
if response.gesture.is_some() && !view_tool_held(app) && ui.input(|i| i.pointer.primary_down()) {
if response.gesture.is_some() && !view_tool_held(app) && ui.input(|i| i.pointer.primary_down() || i.pointer.primary_pressed()) {
crate::shortcuts::note_tool_use(app);
}
app.canvas.hand = Some(hand);
+13
View File
@@ -490,6 +490,15 @@ pub struct ContextSpelling {
pub suggestions: Vec<String>,
}
/// The main window as saved in the UI preferences through 0.24.1. Positions are desktop pixels.
#[derive(Clone, Copy, Debug, Deserialize)]
pub struct LegacyWindow {
pub pos: Option<[i32; 2]>,
pub size: [f32; 2],
#[serde(default)]
pub maximized: bool,
}
/// Two states are equal when they save the same: the settings store writes only a changed saved form,
/// and the panels' session state is no change to save.
#[derive(Clone, Debug, Serialize, Deserialize)]
@@ -500,6 +509,9 @@ pub struct UiState {
/// it is never written back.
#[serde(rename = "language", skip_serializing)]
pub legacy_language: Option<String>,
/// Used until the shared window store has recorded the main window.
#[serde(rename = "window", skip_serializing)]
pub legacy_window: Option<LegacyWindow>,
pub brightness: Brightness,
/// The panel arrangement: docks, floating windows, closed panels and where each goes back. One
/// `Arc` the dock area keeps across frames; writers change it through `Arc::make_mut`.
@@ -1448,6 +1460,7 @@ impl Default for UiState {
fn default() -> Self {
Self {
legacy_language: None,
legacy_window: None,
brightness: Brightness::MediumDark,
dock_workspace: std::sync::Arc::new(crate::panel_docking::default_workspace(&[])),
tools_last_used: Default::default(),