Added extra handling for linux screens
This commit is contained in:
+17
-2
@@ -1,11 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
|
using Avalonia.Platform;
|
||||||
|
|
||||||
namespace SimpleNote;
|
namespace SimpleNote;
|
||||||
|
|
||||||
@@ -15,7 +17,19 @@ public partial class MainWindow : Window
|
|||||||
private PixelRect? screen;
|
private PixelRect? screen;
|
||||||
public MainWindow()
|
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)
|
if (screen == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine("No screen available.");
|
Console.WriteLine("No screen available.");
|
||||||
@@ -80,7 +94,8 @@ public partial class MainWindow : Window
|
|||||||
if (width == 55) width -= 5;
|
if (width == 55) width -= 5;
|
||||||
|
|
||||||
this.Width = width;
|
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)
|
private void InputElement_OnKeyDown(object? sender, KeyEventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user