From ea15c978ba0853bac5d6272ff1ead62211a9e0a0 Mon Sep 17 00:00:00 2001 From: Albert Armea Date: Sat, 27 Dec 2025 21:16:58 -0500 Subject: [PATCH] Fix Minecraft window focus --- crates/shepherd-host-linux/src/process.rs | 5 +++++ sway.conf | 12 ++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/crates/shepherd-host-linux/src/process.rs b/crates/shepherd-host-linux/src/process.rs index d3c75c1..6f7303b 100644 --- a/crates/shepherd-host-linux/src/process.rs +++ b/crates/shepherd-host-linux/src/process.rs @@ -218,6 +218,11 @@ impl ManagedProcess { } } + // Java AWT/Swing applications (like Minecraft) need this to work properly + // on non-reparenting window managers like Sway. Without this, Java apps may + // have focus issues or render incorrectly. + cmd.env("_JAVA_AWT_WM_NONREPARENTING", "1"); + // Special handling for WAYLAND_DISPLAY: // If SHEPHERD_WAYLAND_DISPLAY is set, use that instead of the inherited value. // This allows apps to be launched on a nested compositor while the daemon diff --git a/sway.conf b/sway.conf index dfe0aed..e18681e 100644 --- a/sway.conf +++ b/sway.conf @@ -58,10 +58,14 @@ for_window [app_id="shepherd-launcher"] fullscreen enable for_window [class=".*"] fullscreen enable, border none, title_format "" for_window [app_id=".*"] fullscreen enable, border none, title_format "" -# Minecraft-specific rules (XWayland Electron app) -for_window [class="Minecraft.*"] fullscreen enable, border none -for_window [class="minecraft-launcher"] fullscreen enable, border none -for_window [title="Minecraft.*"] fullscreen enable, border none +# Minecraft Launcher (Electron app) and Minecraft Java Edition (game) +# Launcher: class="Minecraft Launcher" instance="minecraft-launcher" +# Game: class="Minecraft 1.21.11" instance="Minecraft 1.21.11" (version varies) +# We add "focus" to ensure the window gets focus when it appears +for_window [class="^Minecraft [0-9]"] fullscreen enable, border none, focus +for_window [instance="^Minecraft [0-9]"] fullscreen enable, border none, focus +for_window [class="^Minecraft Launcher$"] fullscreen enable, border none +for_window [instance="^minecraft-launcher$"] fullscreen enable, border none # Disable window decorations (no title bars) - for all windows default_border none