fix some hot-reloading issues
This commit is contained in:
parent
7bb5fddaa6
commit
eb11c29e6a
2 changed files with 19 additions and 13 deletions
|
@ -1,7 +1,4 @@
|
||||||
use crate::{
|
use crate::{EwwPaths, config, daemon_response::DaemonResponseSender, display_backend, error_handling_ctx, eww_state::{self, EwwState}, script_var_handler::*};
|
||||||
config, daemon_response::DaemonResponseSender, display_backend, error_handling_ctx, eww_state, script_var_handler::*,
|
|
||||||
EwwPaths,
|
|
||||||
};
|
|
||||||
use anyhow::*;
|
use anyhow::*;
|
||||||
use debug_stub_derive::*;
|
use debug_stub_derive::*;
|
||||||
use eww_shared_util::VarName;
|
use eww_shared_util::VarName;
|
||||||
|
@ -32,7 +29,7 @@ pub enum DaemonCommand {
|
||||||
pos: Option<Coords>,
|
pos: Option<Coords>,
|
||||||
size: Option<Coords>,
|
size: Option<Coords>,
|
||||||
anchor: Option<AnchorPoint>,
|
anchor: Option<AnchorPoint>,
|
||||||
monitor: Option<i32>,
|
screen: Option<i32>,
|
||||||
should_toggle: bool,
|
should_toggle: bool,
|
||||||
sender: DaemonResponseSender,
|
sender: DaemonResponseSender,
|
||||||
},
|
},
|
||||||
|
@ -133,7 +130,7 @@ impl App {
|
||||||
let result = windows.iter().try_for_each(|w| self.open_window(w, None, None, None, None));
|
let result = windows.iter().try_for_each(|w| self.open_window(w, None, None, None, None));
|
||||||
respond_with_error(sender, result)?;
|
respond_with_error(sender, result)?;
|
||||||
}
|
}
|
||||||
DaemonCommand::OpenWindow { window_name, pos, size, anchor, monitor, should_toggle, sender } => {
|
DaemonCommand::OpenWindow { window_name, pos, size, anchor, screen: monitor, should_toggle, sender } => {
|
||||||
let result = if should_toggle && self.open_windows.contains_key(&window_name) {
|
let result = if should_toggle && self.open_windows.contains_key(&window_name) {
|
||||||
self.close_window(&window_name)
|
self.close_window(&window_name)
|
||||||
} else {
|
} else {
|
||||||
|
@ -196,8 +193,10 @@ impl App {
|
||||||
self.script_var_handler.stop_for_variable(unused_var.clone());
|
self.script_var_handler.stop_for_variable(unused_var.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
let window =
|
let window = self
|
||||||
self.open_windows.remove(window_name).context(format!("No window with name '{}' is running.", window_name))?;
|
.open_windows
|
||||||
|
.remove(window_name)
|
||||||
|
.with_context(|| format!("Tried to close window named '{}', but no such window was open", window_name))?;
|
||||||
|
|
||||||
window.close();
|
window.close();
|
||||||
self.eww_state.clear_window_state(window_name);
|
self.eww_state.clear_window_state(window_name);
|
||||||
|
@ -250,7 +249,14 @@ impl App {
|
||||||
self.script_var_handler.stop_all();
|
self.script_var_handler.stop_all();
|
||||||
|
|
||||||
self.eww_config = config;
|
self.eww_config = config;
|
||||||
self.eww_state.clear_all_window_states();
|
|
||||||
|
let new_state = EwwState::from_default_vars(self.eww_config.generate_initial_state()?);
|
||||||
|
let old_state = std::mem::replace(&mut self.eww_state, new_state);
|
||||||
|
for (key, value) in old_state.get_variables() {
|
||||||
|
if self.eww_state.get_variables().contains_key(key) {
|
||||||
|
self.eww_state.update_variable(key.clone(), value.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let windows = self.open_windows.clone();
|
let windows = self.open_windows.clone();
|
||||||
for (window_name, _) in windows {
|
for (window_name, _) in windows {
|
||||||
|
|
|
@ -78,8 +78,8 @@ pub enum ActionWithServer {
|
||||||
window_name: String,
|
window_name: String,
|
||||||
|
|
||||||
/// Monitor-index the window should open on
|
/// Monitor-index the window should open on
|
||||||
#[structopt(short, long)]
|
#[structopt(long)]
|
||||||
monitor: Option<i32>,
|
screen: Option<i32>,
|
||||||
|
|
||||||
/// The position of the window, where it should open.
|
/// The position of the window, where it should open.
|
||||||
#[structopt(short, long)]
|
#[structopt(short, long)]
|
||||||
|
@ -175,13 +175,13 @@ impl ActionWithServer {
|
||||||
ActionWithServer::OpenMany { windows } => {
|
ActionWithServer::OpenMany { windows } => {
|
||||||
return with_response_channel(|sender| app::DaemonCommand::OpenMany { windows, sender });
|
return with_response_channel(|sender| app::DaemonCommand::OpenMany { windows, sender });
|
||||||
}
|
}
|
||||||
ActionWithServer::OpenWindow { window_name, pos, size, monitor, anchor, should_toggle } => {
|
ActionWithServer::OpenWindow { window_name, pos, size, screen, anchor, should_toggle } => {
|
||||||
return with_response_channel(|sender| app::DaemonCommand::OpenWindow {
|
return with_response_channel(|sender| app::DaemonCommand::OpenWindow {
|
||||||
window_name,
|
window_name,
|
||||||
pos,
|
pos,
|
||||||
size,
|
size,
|
||||||
anchor,
|
anchor,
|
||||||
monitor,
|
screen,
|
||||||
should_toggle,
|
should_toggle,
|
||||||
sender,
|
sender,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Reference in a new issue