mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-27 13:15:12 +00:00
Revert "Fix floating document raise after Presentation Mode"
This reverts commit 77a12e40bb.
This commit is contained in:
@@ -335,7 +335,6 @@ fn show_windows(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
|
||||
// Presentation Mode fits each floating window it shows to the main window: back in their
|
||||
// floating windows, those views fit their windows again.
|
||||
let presenting = presenting(app);
|
||||
let restoring = !presenting && app.canvas.windows.presented.is_some();
|
||||
if presenting {
|
||||
let is_floating = current.is_some_and(|k| floating(app, &k));
|
||||
let shown = app.canvas.windows.presented.get_or_insert_default();
|
||||
@@ -366,15 +365,9 @@ fn show_windows(app: &mut VectorcraftApp, ui: &mut egui::Ui) {
|
||||
return;
|
||||
}
|
||||
let raise = current.filter(|u| app.canvas.windows.current != Some(*u));
|
||||
app.canvas.windows.current = current;
|
||||
let ctx = ui.ctx().clone();
|
||||
let os_windows = WindowHost::of(&ctx).viewports_available();
|
||||
if restoring && !os_windows && raise.is_some() {
|
||||
// egui raises every reappearing area in this pass, preserving their old order. Repeat
|
||||
// the current window's raise next frame, when the other windows no longer request it.
|
||||
ctx.request_repaint();
|
||||
} else {
|
||||
app.canvas.windows.current = current;
|
||||
}
|
||||
// An OS window's place is in desktop points: the main window's own origin shifts it.
|
||||
let origin = if os_windows {
|
||||
ctx.input(|i| i.viewport().inner_rect.map(|r| r.min)).filter(|p| p.is_finite()).unwrap_or(egui::Pos2::ZERO).to_vec2()
|
||||
|
||||
@@ -417,36 +417,23 @@ fn presentation_mode_shows_the_floating_current_document_in_the_main_window() {
|
||||
|
||||
#[test]
|
||||
fn a_document_made_current_in_presentation_mode_comes_to_the_front_after_it() {
|
||||
for change_during_presentation in [false, true] {
|
||||
let mut app = app_with(2);
|
||||
let ctx = crate::testing::ui_context();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
app.run("window.arrange.floatAllInWindows", json!({})).unwrap();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
// Where the two windows overlap: document 1's title bar, over document 0's body.
|
||||
let overlap = app.ui.floating[1].place.min + vec2(60.0, 10.0);
|
||||
// Cover both an unchanged current document and one chosen while the windows are hidden.
|
||||
if !change_during_presentation {
|
||||
app.run("document.activate", json!({"index": 0})).unwrap();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
}
|
||||
app.run("view.presentation", json!({})).unwrap();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
if change_during_presentation {
|
||||
app.run("document.activate", json!({"index": 0})).unwrap();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
}
|
||||
app.run("view.presentation", json!({})).unwrap();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
click(&mut app, &ctx, overlap);
|
||||
assert_eq!(
|
||||
app.session.active_index(),
|
||||
Some(0),
|
||||
"document 0's window is in front (changed during presentation: {change_during_presentation})"
|
||||
);
|
||||
}
|
||||
let mut app = app_with(2);
|
||||
let ctx = crate::testing::ui_context();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
app.run("window.arrange.floatAllInWindows", json!({})).unwrap();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
// Where the two windows overlap: document 1's title bar, over document 0's body.
|
||||
let overlap = app.ui.floating[1].place.min + vec2(60.0, 10.0);
|
||||
app.run("view.presentation", json!({})).unwrap();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
app.run("document.activate", json!({"index": 0})).unwrap();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
app.run("view.presentation", json!({})).unwrap();
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
frame(&mut app, &ctx, vec![]);
|
||||
click(&mut app, &ctx, overlap);
|
||||
assert_eq!(app.session.active_index(), Some(0), "document 0's window is in front where they overlap");
|
||||
}
|
||||
|
||||
/// A stand-in for the window system of the documents' OS windows: it runs each one's frame and asks
|
||||
|
||||
Reference in New Issue
Block a user