diff --git a/src/main.rs b/src/main.rs index 31d71b9..1da0ab5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -86,7 +86,7 @@ fn build_ui(application: >k::Application) { }), ); let (key, modifier) = gtk::accelerator_parse("F11"); - let w_state = WindowState::new_arc(WindowPos::Up, FullScreenState::NotFull); + let w_state = WindowState::new_arc(WindowPos::Hidden, FullScreenState::NotFull); let w_state0 = w_state.clone(); let w_state1 = w_state.clone(); let w_state2 = w_state.clone(); @@ -134,6 +134,7 @@ fn build_ui(application: >k::Application) { window.set_skip_taskbar_hint(true); window.set_skip_pager_hint(true); window.show_all(); + window.hide(); /*unsafe { gdk_sys::gdk_window_set_skip_pager_hint( window.get_window().unwrap().to_glib_none().0, @@ -174,7 +175,7 @@ fn build_ui(application: >k::Application) { }); let (tx, rx) = glib::MainContext::channel(glib::PRIORITY_DEFAULT); - window_state::bring_up(&window, &w_state4, gtk::get_current_event_time()); + //window_state::bring_up(&window, &w_state4, gtk::get_current_event_time()); //tabs::focus_tab_corrente(&nb); rx.attach(None, move |cmd| { let tira_su = || { diff --git a/src/window_state.rs b/src/window_state.rs index c359e1f..2d3050f 100644 --- a/src/window_state.rs +++ b/src/window_state.rs @@ -7,7 +7,7 @@ use std::time::{Duration, Instant}; #[derive(Eq, PartialEq, Debug, Copy, Clone)] pub enum WindowPos { Up, - BringingUp, + // BringingUp, Hiding, Hidden, UpWithoutFocus, @@ -26,6 +26,7 @@ pub struct WindowState { position: WindowPos, full: FullScreenState, last_toggle: Option, + focus_lost: Option, } impl WindowState { pub fn new_arc(p: WindowPos, f: FullScreenState) -> Rc> { @@ -33,6 +34,7 @@ impl WindowState { full: f, position: p, last_toggle: None, + focus_lost: None })) } } @@ -43,11 +45,15 @@ pub trait StateOperations { fn get_full(&self) -> FullScreenState; fn set_last_toggle(&self, instant: Option); fn get_last_toggle(&self) -> Option; + fn set_focus_lost(&self, instant: Option); + fn get_focus_lost(&self) -> Option; } impl StateOperations for Rc> { fn set_pos(&self, p: WindowPos) { if let Ok(mut w_lock) = self.write() { w_lock.position = p; + } else { + eprintln!("Can't acquire lock"); } } fn get_pos(&self) -> WindowPos { @@ -60,6 +66,8 @@ impl StateOperations for Rc> { fn set_full(&self, full: FullScreenState) { if let Ok(mut w_lock) = self.write() { w_lock.full = full; + } else { + eprintln!("Can't acquire lock"); } } fn get_full(&self) -> FullScreenState { @@ -79,6 +87,22 @@ impl StateOperations for Rc> { fn set_last_toggle(&self, instant: Option) { if let Ok(mut w_lock) = self.write() { w_lock.last_toggle = instant; + } else { + eprintln!("Can't acquire lock"); + } + } + fn get_focus_lost(&self) -> Option { + if let Ok(r_lock) = self.read() { + r_lock.focus_lost + } else { + None + } + } + fn set_focus_lost(&self, instant: Option) { + if let Ok(mut w_lock) = self.write() { + w_lock.focus_lost = instant; + } else { + eprintln!("Can't acquire lock"); } } } @@ -90,24 +114,26 @@ pub fn bring_up(window: >k::ApplicationWindow, w_state: &Rc