Skip to content

Commit

Permalink
Don't clear search bar if window is closed using global shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalin8900 authored and Exidex committed Feb 15, 2025
1 parent 047e0c3 commit f50a9ae
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ For changes in `@project-gauntlet/tools` see [separate CHANGELOG.md](https://git

## [Unreleased]

- Pressing global shortcut while window is open now preserves search bar value when window is opened next time (contributed by @Kalin8900)
- Added localization support for macOS application names (contributed by @BennoCrafter)
- Added plugin preference `Bundle Name Lang` of enum type
- `localized` option - use localized name of bundle if available - this is the default
Expand Down
20 changes: 12 additions & 8 deletions rust/client/src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -789,14 +789,14 @@ fn update(state: &mut AppModel, message: AppMsg) -> Task<AppMsg> {
AppMsg::RunCommand {
plugin_id,
entrypoint_id,
} => Task::batch([state.hide_window(), state.run_command(plugin_id, entrypoint_id)]),
} => Task::batch([state.hide_window(true), state.run_command(plugin_id, entrypoint_id)]),
AppMsg::RunGeneratedEntrypoint {
plugin_id,
entrypoint_id,
action_index,
} => {
Task::batch([
state.hide_window(),
state.hide_window(true),
state.run_generated_entrypoint(plugin_id, entrypoint_id, action_index),
])
}
Expand All @@ -811,7 +811,7 @@ fn update(state: &mut AppModel, message: AppMsg) -> Task<AppMsg> {
match render_location {
UiRenderLocation::InlineView => {
Task::batch([
state.hide_window(),
state.hide_window(true),
Task::done(AppMsg::WidgetEvent {
widget_event,
plugin_id,
Expand Down Expand Up @@ -1158,7 +1158,7 @@ fn update(state: &mut AppModel, message: AppMsg) -> Task<AppMsg> {
}
AppMsg::ToggleWindow => state.toggle_window(),
AppMsg::ShowWindow => state.show_window(),
AppMsg::HideWindow => state.hide_window(),
AppMsg::HideWindow => state.hide_window(true),
AppMsg::ShowPreferenceRequiredView {
plugin_id,
entrypoint_id,
Expand Down Expand Up @@ -2254,29 +2254,33 @@ impl AppModel {
fn on_unfocused(&mut self) -> Task<AppMsg> {
// for some reason (on both macOS and linux x11 but x11 now uses separate impl) duplicate Unfocused fires right before Focus event
if self.focused {
self.hide_window()
self.hide_window(true)
} else {
Task::none()
}
}

fn toggle_window(&mut self) -> Task<AppMsg> {
if self.opened {
self.hide_window()
self.hide_window(false)
} else {
self.show_window()
}
}

fn hide_window(&mut self) -> Task<AppMsg> {
fn hide_window(&mut self, reset_state: bool) -> Task<AppMsg> {
if !self.opened {
return Task::none();
}

self.focused = false;
self.opened = false;

let mut commands = vec![self.reset_window_state()];
let mut commands = vec![];

if reset_state {
commands.push(self.reset_window_state());
}

#[cfg(target_os = "linux")]
if self.wayland {
Expand Down

0 comments on commit f50a9ae

Please sign in to comment.