updated shortcut functions on wayland/kde to stop showing shortcuts setting window on every launch
This commit is contained in:
1 parent
abbca0e411
commit
485cbf4c18
2 files changed
+95
-39
No files matched your search
+42
@@ -1697,6 +1697,9 @@ struct Moorly {
|
||||
/// Wayland cannot hide or restore a toplevel, so the window is destroyed
|
||||
/// while hidden and recreated from this state on show.
|
||||
hidden_main_window: Option<WindowState>,
|
||||
/// Set when the palette shortcut is used while the window is being
|
||||
/// recreated, so focus can be requested after the new window exists.
|
||||
pending_command_palette: bool,
|
||||
tray_available: bool,
|
||||
close_to_tray: bool,
|
||||
close_to_tray_draft: bool,
|
||||
@@ -4668,6 +4671,7 @@ impl Default for Moorly {
|
||||
focused_window: None,
|
||||
main_window_hidden: false,
|
||||
hidden_main_window: None,
|
||||
pending_command_palette: false,
|
||||
tray_available: false,
|
||||
close_to_tray,
|
||||
close_to_tray_draft: close_to_tray,
|
||||
@@ -6421,7 +6425,16 @@ fn handle_tray_event(state: &mut Moorly, event: tray::Event) -> Task<Message> {
|
||||
}
|
||||
|
||||
fn open_palette_from_hotkey(state: &mut Moorly) -> Task<Message> {
|
||||
let reopening = state.hidden_main_window.is_some();
|
||||
let show = show_main_window(state);
|
||||
|
||||
if reopening {
|
||||
// The new window does not exist yet, so focusing the palette now
|
||||
// would act on nothing. Open it once the window reports `Opened`.
|
||||
state.pending_command_palette = true;
|
||||
return show;
|
||||
}
|
||||
|
||||
let Some(window) = main_window_id(state) else {
|
||||
return show;
|
||||
};
|
||||
@@ -6523,6 +6536,11 @@ fn window_event(state: &mut Moorly, window: window::Id, event: window::Event) ->
|
||||
window_state.position = position;
|
||||
}
|
||||
}
|
||||
|
||||
if state.pending_command_palette && state.main_window == Some(window) {
|
||||
state.pending_command_palette = false;
|
||||
return update(state, Message::ToggleCommandPalette(window));
|
||||
}
|
||||
}
|
||||
window::Event::Moved(position) => {
|
||||
if let Some(window_state) = state.windows.get_mut(&window) {
|
||||
@@ -8143,8 +8161,12 @@ fn shortcut_row(
|
||||
.on_press(Message::OpenShortcutCapture(action))
|
||||
.style(theme::outlined_option),
|
||||
]
|
||||
// Let the buttons drop to the next line in a narrow window instead of
|
||||
// pushing the "..." button outside the pane.
|
||||
.spacing(8)
|
||||
.align_y(Alignment::Center)
|
||||
.wrap()
|
||||
.vertical_spacing(8)
|
||||
.into()
|
||||
}
|
||||
|
||||
@@ -11261,6 +11283,7 @@ mod tests {
|
||||
focused_window: Some(window),
|
||||
main_window_hidden: false,
|
||||
hidden_main_window: None,
|
||||
pending_command_palette: false,
|
||||
tray_available: false,
|
||||
close_to_tray: false,
|
||||
close_to_tray_draft: false,
|
||||
@@ -14085,6 +14108,25 @@ start_path = "/tmp"
|
||||
std::fs::remove_dir_all(&root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn palette_waits_for_the_reopened_window() {
|
||||
let window = test_window();
|
||||
let mut state = self::state();
|
||||
state.pending_command_palette = true;
|
||||
|
||||
let _ = super::window_event(
|
||||
&mut state,
|
||||
window,
|
||||
super::window::Event::Opened {
|
||||
position: None,
|
||||
size: iced::Size::new(800.0, 600.0),
|
||||
},
|
||||
);
|
||||
|
||||
assert!(!state.pending_command_palette);
|
||||
assert!(window_state(&state).command_palette_open);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn closing_the_window_only_hides_it_when_a_tray_is_available() {
|
||||
let window = test_window();
|
||||
|
||||
Reference in new issue
Block a user