Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force Recreating Windows on Config Reload #1284

Merged
merged 1 commit into from
Feb 10, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Force recreating windows on config change
Fixes the regression from #1236 preventing hot reload.
This can be made granular, e.g. for changes that don't
effect all windows or css chnages not requiring a full
window restart
bbb651 committed Feb 10, 2025
commit 18d8ba0ee73eaac203603e912c1ad96b2d586473
34 changes: 20 additions & 14 deletions crates/eww/src/app.rs
Original file line number Diff line number Diff line change
@@ -217,7 +217,10 @@ impl<B: DisplayBackend> App<B> {
.filter(|(win_id, ..)| win_id.is_empty() || win_id == id)
.map(|(_, n, v)| (n.clone(), v.clone()))
.collect();
self.open_window(&WindowArguments::new_from_args(id.to_string(), config_name.clone(), window_args)?)
self.open_window(
&WindowArguments::new_from_args(id.to_string(), config_name.clone(), window_args)?,
false,
)
}
})
.filter_map(Result::err);
@@ -242,16 +245,19 @@ impl<B: DisplayBackend> App<B> {
let result = if should_toggle && is_open {
self.close_window(&instance_id)
} else {
self.open_window(&WindowArguments {
instance_id,
window_name,
pos,
size,
monitor,
anchor,
duration,
args: args.unwrap_or_default().into_iter().collect(),
})
self.open_window(
&WindowArguments {
instance_id,
window_name,
pos,
size,
monitor,
anchor,
duration,
args: args.unwrap_or_default().into_iter().collect(),
},
false,
)
};

sender.respond_with_result(result)?;
@@ -385,13 +391,13 @@ impl<B: DisplayBackend> App<B> {
Ok(())
}

fn open_window(&mut self, window_args: &WindowArguments) -> Result<()> {
fn open_window(&mut self, window_args: &WindowArguments, dirty: bool) -> Result<()> {
let instance_id = &window_args.instance_id;
self.failed_windows.remove(instance_id);
log::info!("Opening window {} as '{}'", window_args.window_name, instance_id);

// if an instance of this is already running and arguments haven't change, only update duration
let reuse_window = if self.open_windows.contains_key(instance_id) {
let reuse_window = if !dirty && self.open_windows.contains_key(instance_id) {
if self.instance_id_to_args.get(instance_id).is_some_and(|args| window_args.can_reuse_window_with_args(args)) {
true
} else {
@@ -530,7 +536,7 @@ impl<B: DisplayBackend> App<B> {
let window_arguments = self.instance_id_to_args.get(instance_id).with_context(|| {
format!("Cannot reopen window, initial parameters were not saved correctly for {instance_id}")
})?;
self.open_window(&window_arguments.clone())?;
self.open_window(&window_arguments.clone(), true)?;
}
Ok(())
}

Unchanged files with check annotations Beta

/// via combining information from the [`WindowDefinition`] and the [`WindowInitiator`]
#[derive(Debug, Clone)]
pub struct WindowInitiator {
pub backend_options: BackendWindowOptions,

Check warning on line 18 in crates/eww/src/window_initiator.rs

GitHub Actions / build

fields `backend_options`, `resizable`, and `stacking` are never read
pub geometry: Option<WindowGeometry>,
pub local_variables: HashMap<VarName, DynVal>,
pub monitor: Option<MonitorIdentifier>,