88import net .notcoded .wayfix .WayFix ;
99import net .notcoded .wayfix .config .ModConfig ;
1010import net .notcoded .wayfix .util .DesktopFileInjector ;
11+ import net .notcoded .wayfix .util .WindowHelper ;
1112import org .lwjgl .glfw .GLFW ;
13+ import org .spongepowered .asm .mixin .Final ;
1214import org .spongepowered .asm .mixin .Mixin ;
15+ import org .spongepowered .asm .mixin .Shadow ;
1316import org .spongepowered .asm .mixin .Unique ;
1417import org .spongepowered .asm .mixin .injection .At ;
1518import org .spongepowered .asm .mixin .injection .Inject ;
3942*/
4043
4144@ Mixin (Window .class )
42- public class WindowMixin {
45+ public abstract class WindowMixin {
46+ @ Shadow protected abstract void onWindowPosChanged (long window , int x , int y );
47+
48+ @ Shadow @ Final private long handle ;
49+
4350 @ Inject (method = "<init>" , at = @ At (value = "INVOKE" , target = "Lorg/lwjgl/glfw/GLFW;glfwDefaultWindowHints()V" , shift = At .Shift .AFTER , remap = false ))
4451 private void onWindowHints (WindowEventHandler windowEventHandler , MonitorTracker monitorTracker , WindowSettings windowSettings , String string , String string2 , CallbackInfo ci ) {
4552 if (isWayland ()) {
4653 GLFW .glfwWindowHint (GLFW .GLFW_FOCUS_ON_SHOW , GLFW .GLFW_FALSE );
4754
48- if (!WayFix .config .injectIcon ) return ; // assuming that user wants wayland icon and not broken icon (mc launcher)
49- DesktopFileInjector .inject ();
55+ if (WayFix .config .injectIcon ) DesktopFileInjector .inject ();
5056 GLFW .glfwWindowHintString (GLFW .GLFW_WAYLAND_APP_ID , DesktopFileInjector .APP_ID );
5157 }
5258 }
5359
5460 @ Redirect (method = "updateWindowRegion" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/util/MonitorTracker;getMonitor(Lnet/minecraft/client/util/Window;)Lnet/minecraft/client/util/Monitor;" ))
5561 private Monitor fixWrongMonitor (MonitorTracker instance , Window window ) {
56- return WayFix .config .fullscreen .useMonitorName ? getMonitor (instance ) : instance .getMonitor (window );
62+ return WayFix .config .fullscreen .useMonitorName && ! WindowHelper . canUseWindowHelper ? getMonitor (instance ) : instance .getMonitor (window );
5763 }
5864
5965 @ Unique
@@ -69,6 +75,18 @@ private Monitor getMonitor(MonitorTracker instance) {
6975
7076 return instance .getMonitor (monitorID );
7177 }
78+
79+
80+ // KDE Plasma ONLY
81+ @ Inject (method = "updateWindowRegion" , at = @ At ("HEAD" ))
82+ private void fixWrongMonitor (CallbackInfo ci ) {
83+ if (!WindowHelper .canUseWindowHelper ) return ;
84+
85+ int [] pos = WindowHelper .getWindowPos ();
86+ if (pos == null ) return ;
87+
88+ onWindowPosChanged (this .handle , pos [0 ], pos [1 ]);
89+ }
7290
7391 @ Inject (method = "setIcon" , at = @ At ("HEAD" ), cancellable = true )
7492 //? if >=1.20 {
0 commit comments