Fix windows closing eventhough they don't work
This commit is contained in:
parent
9ee852c0fd
commit
7bb5fddaa6
3 changed files with 12 additions and 6 deletions
|
@ -192,7 +192,7 @@ impl App {
|
||||||
|
|
||||||
fn close_window(&mut self, window_name: &String) -> Result<()> {
|
fn close_window(&mut self, window_name: &String) -> Result<()> {
|
||||||
for unused_var in self.variables_only_used_in(window_name) {
|
for unused_var in self.variables_only_used_in(window_name) {
|
||||||
log::info!("stopping for {}", &unused_var);
|
log::debug!("stopping for {}", &unused_var);
|
||||||
self.script_var_handler.stop_for_variable(unused_var.clone());
|
self.script_var_handler.stop_for_variable(unused_var.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,8 +213,6 @@ impl App {
|
||||||
monitor: Option<i32>,
|
monitor: Option<i32>,
|
||||||
anchor: Option<AnchorPoint>,
|
anchor: Option<AnchorPoint>,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
// remove and close existing window with the same name
|
|
||||||
let _ = self.close_window(window_name);
|
|
||||||
log::info!("Opening window {}", window_name);
|
log::info!("Opening window {}", window_name);
|
||||||
|
|
||||||
let mut window_def = self.eww_config.get_window(window_name)?.clone();
|
let mut window_def = self.eww_config.get_window(window_name)?.clone();
|
||||||
|
@ -222,6 +220,11 @@ impl App {
|
||||||
|
|
||||||
let root_widget =
|
let root_widget =
|
||||||
window_def.widget.render(&mut self.eww_state, window_name, &self.eww_config.get_widget_definitions())?;
|
window_def.widget.render(&mut self.eww_state, window_name, &self.eww_config.get_widget_definitions())?;
|
||||||
|
|
||||||
|
// once generating the root widget has succeeded
|
||||||
|
// remove and close existing window with the same name
|
||||||
|
let _ = self.close_window(window_name);
|
||||||
|
|
||||||
root_widget.get_style_context().add_class(&window_name.to_string());
|
root_widget.get_style_context().add_class(&window_name.to_string());
|
||||||
|
|
||||||
let monitor_geometry =
|
let monitor_geometry =
|
||||||
|
@ -240,7 +243,7 @@ impl App {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Load the given configuration, reloading all script-vars and reopening all windows that where opened.
|
/// Load the given configuration, reloading all script-vars and attempting to reopen all windows that where opened.
|
||||||
pub fn load_config(&mut self, config: config::EwwConfig) -> Result<()> {
|
pub fn load_config(&mut self, config: config::EwwConfig) -> Result<()> {
|
||||||
log::info!("Reloading windows");
|
log::info!("Reloading windows");
|
||||||
// refresh script-var poll stuff
|
// refresh script-var poll stuff
|
||||||
|
@ -250,8 +253,7 @@ impl App {
|
||||||
self.eww_state.clear_all_window_states();
|
self.eww_state.clear_all_window_states();
|
||||||
|
|
||||||
let windows = self.open_windows.clone();
|
let windows = self.open_windows.clone();
|
||||||
for (window_name, window) in windows {
|
for (window_name, _) in windows {
|
||||||
window.close();
|
|
||||||
self.open_window(&window_name, None, None, None, None)?;
|
self.open_window(&window_name, None, None, None, None)?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -67,7 +67,9 @@ fn main() {
|
||||||
handle_server_command(&paths, &ActionWithServer::KillServer, 1)?;
|
handle_server_command(&paths, &ActionWithServer::KillServer, 1)?;
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
// a running daemon is necessary for this command
|
||||||
opts::Action::WithServer(action) => {
|
opts::Action::WithServer(action) => {
|
||||||
|
// attempt to just send the command to a running daemon
|
||||||
if let Err(err) = handle_server_command(&paths, &action, 5) {
|
if let Err(err) = handle_server_command(&paths, &action, 5) {
|
||||||
// connecting to the daemon failed. Thus, start the daemon here!
|
// connecting to the daemon failed. Thus, start the daemon here!
|
||||||
log::warn!("Failed to connect to daemon: {}", err);
|
log::warn!("Failed to connect to daemon: {}", err);
|
||||||
|
@ -78,6 +80,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let (command, response_recv) = action.into_daemon_command();
|
let (command, response_recv) = action.into_daemon_command();
|
||||||
|
// start the daemon and give it the command
|
||||||
let fork_result = server::initialize_server(paths.clone(), Some(command))?;
|
let fork_result = server::initialize_server(paths.clone(), Some(command))?;
|
||||||
let is_parent = fork_result == ForkResult::Parent;
|
let is_parent = fork_result == ForkResult::Parent;
|
||||||
if let (Some(recv), true) = (response_recv, is_parent) {
|
if let (Some(recv), true) = (response_recv, is_parent) {
|
||||||
|
|
|
@ -76,6 +76,7 @@ pub fn initialize_server(paths: EwwPaths, action: Option<DaemonCommand>) -> Resu
|
||||||
init_async_part(app.paths.clone(), ui_send);
|
init_async_part(app.paths.clone(), ui_send);
|
||||||
|
|
||||||
glib::MainContext::default().spawn_local(async move {
|
glib::MainContext::default().spawn_local(async move {
|
||||||
|
// if an action was given to the daemon initially, execute it first.
|
||||||
if let Some(action) = action {
|
if let Some(action) = action {
|
||||||
app.handle_command(action);
|
app.handle_command(action);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue