Fix Windows. Only redraw when systray is closed.
#[cfg(target_os = "macos")]
pub type StatusBar = osx::OSXStatusBar;
#[cfg(target_os = "windows")]
-pub type StatusBar = windows::WindowsStatusBar;
+pub type StatusBar = win::WindowsStatusBar;
pub type MenuItem = *mut Object;
pub trait TStatusBar {
type S: TStatusBar;
fn new(tx: Sender<String>) -> Self::S;
+ fn can_redraw(&mut self) -> bool;
fn clear_items(&mut self);
fn add_separator(&mut self);
fn add_label(&mut self, label: &str);
impl TStatusBar for DummyStatusBar {
type S = DummyStatusBar;
fn new(_: Sender<String>) -> Self::S { DummyStatusBar {} }
+ fn can_redraw(&mut self) -> bool { true }
fn clear_items(&mut self) {}
fn add_separator(&mut self) {}
fn add_label(&mut self, _: &str) {}
while running.load(Ordering::SeqCst) {
let now = time::now_utc().to_timespec().sec as i64;
- if now > refresh_time_utc {
+ if now > refresh_time_utc && status.can_redraw() {
// Redraw the whole menu once every 60 seconds, or sooner if a
// command is processed later.
clear_menu(&mut app, &mut spotify, &mut status);
}
bar
}
+ fn can_redraw(&mut self) -> bool {
+ true
+ }
fn clear_items(&mut self) {
unsafe {
let old_menu = self.menu_bar;
{
let ref mut win = &mut bar.app.window;
win.set_icon_from_file(&"spotify.ico".to_string());
- win.add_menu_separator();
- win.add_menu_item(&"Menu Item1".to_string(), true, |window| {println!("hello")});
- win.add_menu_item(&"Menu Item2".to_string(), false, |window| {println!("hello")});
- let idx = win.add_menu_item(&"Menu Item3".to_string(), false, |window| {println!("hello")});
- let idx = idx.unwrap();
- win.select_menu_item(idx);
- win.unselect_menu_item(idx);
- win.clear_menu();
- win.add_menu_item(&"Menu Item4".to_string(), false, |window| {println!("hello")});
}
bar
}
+ fn can_redraw(&mut self) -> bool {
+ let ref mut win = &mut self.app.window;
+ !win.menu_displayed()
+ }
fn clear_items(&mut self) {
+ let ref mut win = &mut self.app.window;
+ win.clear_menu();
}
fn set_tooltip(&mut self, text: &str) {
let ref mut win = &mut self.app.window;