Skip to content

Commit

Permalink
Completely disable daemon mode for i3 as it gets stuck with an old hi…
Browse files Browse the repository at this point in the history
…ghlight and spams the CPU
  • Loading branch information
Alex Saveau committed Nov 18, 2024
1 parent 25b2a0b commit b897f53
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions egui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,6 @@ fn main() -> Result<(), eframe::Error> {
thread::spawn({
let ctx = cc.egui_ctx.clone();
let stop = stop.clone();
let command_sender = option_env!("XDG_CURRENT_DESKTOP")
.is_some_and(|de| de.eq_ignore_ascii_case("i3"))
.then(|| command_sender.clone());
move || {
ctx.send_viewport_cmd(ViewportCommand::Icon(Some(
eframe::icon_data::from_png_bytes(include_bytes!("../logo.jpeg"))
Expand All @@ -144,12 +141,6 @@ fn main() -> Result<(), eframe::Error> {
)));

if let Err(e) = maintain_single_instance(&stop, || {
// Hack to work around i3 thinking the closed window is focused if it moves
// monitors.
if let Some(command_sender) = &command_sender {
let _ = command_sender.send(Command::LoadFirstPage);
}

ctx.send_viewport_cmd(ViewportCommand::Visible(true));
ctx.send_viewport_cmd(ViewportCommand::Focus);
}) {
Expand Down Expand Up @@ -346,7 +337,11 @@ impl eframe::App for App {
});

#[cfg(not(feature = "wayland"))]
if ctx.input(|i| i.viewport().close_requested()) {
if {
// i3 thinks the closed window is focused if it moves monitors.
option_env!("XDG_CURRENT_DESKTOP").is_none_or(|de| !de.eq_ignore_ascii_case("i3"))
} && ctx.input(|i| i.viewport().close_requested())
{
ctx.send_viewport_cmd(ViewportCommand::CancelClose);
ctx.send_viewport_cmd(ViewportCommand::Visible(false));

Expand Down

0 comments on commit b897f53

Please sign in to comment.