Skip to content

Commit

Permalink
Fix issue with polybar not handling events
Browse files Browse the repository at this point in the history
  • Loading branch information
lex148 committed Jan 29, 2021
1 parent d913ba8 commit 8f19cad
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/bin/leftwm-worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ fn get_events<T: DisplayServer>(ds: &mut T) -> Vec<DisplayEvent> {
use slog::{o, Drain};

fn main() {
//let _log_guard = setup_logfile();
let _log_guard = setup_logging();
log::info!("leftwm-worker booted!");

Expand Down Expand Up @@ -148,6 +149,36 @@ async fn event_loop(
}
}

// Very basic logging used when developing.
// outputs to /tmp/leftwm/leftwm-XXXXXXXXXXXX.log
//fn setup_logfile() -> slog_scope::GlobalLoggerGuard {
// use chrono::Local;
// use std::fs;
// use std::fs::OpenOptions;
// let date = Local::now();
// let path = "/tmp/leftwm";
// let _ = fs::create_dir_all(path);
// let log_path = format!("{}/leftwm-{}.log", path, date.format("%Y%m%d%H%M"));
// let file = OpenOptions::new()
// .create(true)
// .write(true)
// .truncate(true)
// .open(log_path)
// .unwrap();
// let decorator = slog_term::PlainDecorator::new(file);
// let drain = slog_term::FullFormat::new(decorator).build().fuse();
// let drain = slog_async::Async::new(drain).build().fuse();
// let envlogger = slog_envlogger::LogBuilder::new(drain)
// .parse(&std::env::var("RUST_LOG").unwrap_or_else(|_| "trace".into()))
// .build()
// .ignore_res();
// let logger = slog::Logger::root(slog_async::Async::default(envlogger).ignore_res(), o!());
// slog_stdlog::init().unwrap_or_else(|err| {
// eprintln!("failed to setup logging: {}", err);
// });
// slog_scope::set_global_logger(logger)
//}

/// Log to both stdout and journald.
fn setup_logging() -> slog_scope::GlobalLoggerGuard {
#[cfg(feature = "slog-journald")]
Expand Down
5 changes: 5 additions & 0 deletions src/handlers/focus_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ pub fn focus_window_by_handle(
}

pub fn focus_window(manager: &mut Manager, window: &Window, x: i32, y: i32) -> bool {
//Docks don't want to get focus. If they do weird things happen. They don't get events...
if window.type_ == WindowType::Dock {
return false;
}

let result = _focus_window_work(manager, window);
if !result {
return false;
Expand Down

0 comments on commit 8f19cad

Please sign in to comment.