From 344b02e097721103c2f53d3678f2b9353861f7c1 Mon Sep 17 00:00:00 2001 From: Ano-sys Date: Fri, 14 Feb 2025 20:15:21 +0100 Subject: [PATCH] Added extra handling for linux screens --- MainWindow.axaml.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/MainWindow.axaml.cs b/MainWindow.axaml.cs index c1c479d..b5e7021 100644 --- a/MainWindow.axaml.cs +++ b/MainWindow.axaml.cs @@ -1,11 +1,13 @@ using System; using System.ComponentModel; +using System.Linq; using Avalonia; using Avalonia.Controls; using System.Reactive.Linq; using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.Media; +using Avalonia.Platform; namespace SimpleNote; @@ -15,7 +17,19 @@ public partial class MainWindow : Window private PixelRect? screen; public MainWindow() { - screen = Screens.Primary?.WorkingArea; + if (Screens.Primary == null) + { + Screen max = Screens.All[0]; + for (int i = 0; i < Screens.ScreenCount; i++) + { + if (Screens.All[i].Bounds.Width > max.Bounds.Width) max = Screens.All[i]; + } + + screen = max.WorkingArea; + } + else + screen = Screens.Primary?.WorkingArea; + if (screen == null) { Console.WriteLine("No screen available."); @@ -80,7 +94,8 @@ public partial class MainWindow : Window if (width == 55) width -= 5; this.Width = width; - this.Position = new PixelPoint((int)((screen.Value.Width - width) / 2), 10); + if(!System.OperatingSystem.IsLinux()) // Screenpositionhandling on Hyprland/Wayland/X11 is different + this.Position = new PixelPoint((int)((screen.Value.Width - width) / 2), 10); } private void InputElement_OnKeyDown(object? sender, KeyEventArgs e)