mirror of
https://github.com/storytold/figcraft.git
synced 2026-12-05 22:58:51 +00:00
Revert "Merge upstream PR #2556: fix(present): close the active tab with Cmd/Ctrl+W"
This reverts commit8f5c9c2e2e, reversing changes made tod05c13e44b.
This commit is contained in:
@@ -36,7 +36,7 @@ pub struct PresentTab {
|
||||
pub page_name: String,
|
||||
}
|
||||
|
||||
/// The full-window presenter (while `app.ui.present` is set). Escape, Cmd/Ctrl+W or Close ends it.
|
||||
/// The full-window presenter (while `app.ui.present` is set). Escape or Close ends it.
|
||||
pub fn show(app: &mut FigApp, ui: &mut Ui) {
|
||||
let ctx = ui.ctx().clone();
|
||||
let now = ctx.input(|i| i.time);
|
||||
@@ -48,15 +48,6 @@ pub fn show(app: &mut FigApp, ui: &mut Ui) {
|
||||
pres.sync(&ds.doc, now);
|
||||
}
|
||||
poll_pads(app, &mut pres, &ctx);
|
||||
// Reserve Cmd/Ctrl+W before the prototype handles key bindings.
|
||||
let close_shortcut = ctx.input_mut(|i| {
|
||||
let count = i.events.len();
|
||||
i.events.retain(|event| {
|
||||
!matches!(event, egui::Event::Key { key: egui::Key::W, pressed: true, modifiers, .. }
|
||||
if modifiers.matches_exact(egui::Modifiers::COMMAND))
|
||||
});
|
||||
i.events.len() != count
|
||||
});
|
||||
let mut action = None;
|
||||
// Typing a reply to a comment keeps the keys from the prototype, and so does the link notice
|
||||
// while it shows; Shift+C shows the comments.
|
||||
@@ -134,7 +125,7 @@ pub fn show(app: &mut FigApp, ui: &mut Ui) {
|
||||
choose_device(app, &mut pres, &device);
|
||||
}
|
||||
app.ui.present = Some(pres);
|
||||
if action == Some(BarAction::Close) || close_shortcut || ctx.input(|i| i.key_pressed(egui::Key::Escape)) {
|
||||
if action == Some(BarAction::Close) || ctx.input(|i| i.key_pressed(egui::Key::Escape)) {
|
||||
if let Some(id) = app.ui.present_active {
|
||||
crate::tabs::close_present(app, id);
|
||||
} else {
|
||||
|
||||
@@ -86,21 +86,6 @@ fn the_tab_is_named_after_the_file_and_page_and_its_x_closes_it() {
|
||||
assert!(!u.app.ui.home, "back to its file");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn command_w_closes_the_present_tab() {
|
||||
let (mut u, a, ..) = setup();
|
||||
u.run("proto.present", json!({"start": a}));
|
||||
assert!(presenting(&u));
|
||||
let key = |pressed, modifiers| egui::Event::Key { key: Key::W, physical_key: None, pressed, repeat: false, modifiers };
|
||||
let shifted = egui::Modifiers::COMMAND | egui::Modifiers::SHIFT;
|
||||
u.frame(vec![key(true, shifted), key(false, shifted)]);
|
||||
assert!(presenting(&u));
|
||||
let command = egui::Modifiers::COMMAND;
|
||||
u.frame(vec![key(true, command), key(false, command)]);
|
||||
assert_eq!((presenting(&u), tabs(&u)), (false, json!([])));
|
||||
assert!(!u.app.ui.home, "back to its file");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn play_again_shows_the_tab_as_it_was_and_another_page_opens_a_new_one() {
|
||||
let (mut u, a, b, _) = setup();
|
||||
|
||||
Reference in New Issue
Block a user