Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Alle nennenswerten Änderungen an SyncDrive. Format nach [Keep a Changelog](http
Korrekturen heben PATCH. Die Version steht an einer Stelle (`04-umsetzung/Directory.Build.props`); ein Test prüft, dass sie mit dem obersten
Eintrag hier übereinstimmt. Jede Version bekommt ein Git-Tag `vX.Y.Z`. Die Versionen 0.1.0 bis 0.11.0 wurden nachträglich vergeben.

## [0.41.1] – 2026-10-23 – Mac: Panel genau unter dem Symbol

### Geändert
- Mac: Das Panel öffnet **mittig direkt unter dem Menüleisten-Symbol** (Lage des Symbols von AppKit erfragt), nicht mehr am rechten
Bildschirmrand; am Rand bleibt es ganz sichtbar.

## [0.41.0] – 2026-10-23 – Mac: Klick aufs Symbol öffnet das Panel wie unter Windows

### Geändert
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<!-- Einzige Quelle der Produktversion (Semantic Versioning, siehe ../CHANGELOG.md). Vor 1.0.0 darf sich das Protokoll noch ändern.
Jeder Meilenstein hebt MINOR, reine Korrekturen PATCH; dazu ein Eintrag im CHANGELOG und ein Git-Tag vX.Y.Z. -->
<Version>0.41.0</Version>
<Version>0.41.1</Version>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
Expand Down
1 change: 1 addition & 0 deletions src/SyncDrive.Client.Tray/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ private static (Action<int> ShowIcon, Action RefreshTexts) MacTray(ShellViewMode
{
var item = new MacStatusItem();
item.Clicked += () => Dispatcher.UIThread.Post(windows.TogglePanel);
windows.TrayAnchor = item.Frame;
return (s => item.SetImage(TrayArt.MacImage(shell, s)), () => item.SetToolTip(shell.Tooltip));
}

Expand Down
28 changes: 28 additions & 0 deletions src/SyncDrive.Client.Tray/MacStatusItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@ public void SetImage(byte[] png)

public void SetToolTip(string text) => SendPtr(_button, Selector("setToolTip:"), NsString(text));

/// <summary>
/// Wo das Symbol steht, in Punkten mit Ursprung oben links auf dem Hauptbildschirm (wie Avalonia rechnet); null, solange es kein Fenster
/// hat. AppKit zählt von unten links, daher die Umrechnung über die Höhe des Hauptbildschirms.
/// </summary>
public (double X, double Y, double Width, double Height)? Frame()
{
var window = Send(_button, "window");
var screens = Send(Class("NSScreen"), "screens");
if (window == IntPtr.Zero || screens == IntPtr.Zero)
{
return null;
}

var frame = SendRect(window, Selector("frame"));
var main = SendRect(SendULongRet(screens, Selector("objectAtIndex:"), 0), Selector("frame"));
return (frame.X, main.Height - frame.Y - frame.Height, frame.Width, frame.Height);
}

private static IntPtr TargetClass()
{
var existing = Class("SyncDriveStatusTarget");
Expand Down Expand Up @@ -122,6 +140,16 @@ private static IntPtr NsString(string text)
[DllImport(ObjC, EntryPoint = "objc_msgSend")]
private static extern void SendSize(IntPtr receiver, IntPtr selector, CGSize argument);

// arm64: Strukturen aus vier double kommen in Registern zurück, objc_msgSend genügt (kein _stret)
[DllImport(ObjC, EntryPoint = "objc_msgSend")]
private static extern CGRect SendRect(IntPtr receiver, IntPtr selector);

[DllImport(ObjC, EntryPoint = "objc_msgSend")]
private static extern IntPtr SendULongRet(IntPtr receiver, IntPtr selector, ulong argument);

[StructLayout(LayoutKind.Sequential)]
private readonly record struct CGRect(double X, double Y, double Width, double Height);

[DllImport(ObjC)]
private static extern IntPtr objc_getClass(byte[] name);

Expand Down
24 changes: 19 additions & 5 deletions src/SyncDrive.Client.Tray/Views/PanelWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,31 @@ public PanelWindow()
/// <summary>Wann das Panel zuletzt durch Fokusverlust zuging (ein Klick aufs Symbol soll es dann nicht sofort neu öffnen).</summary>
public DateTimeOffset HiddenAt { get; private set; } = DateTimeOffset.MinValue;

public void ShowNearTray(PanelViewModel viewModel)
/// <param name="anchor">macOS: Lage des Menüleisten-Symbols in Punkten (oben links); das Panel öffnet mittig darunter.</param>
public void ShowNearTray(PanelViewModel viewModel, (double X, double Y, double Width, double Height)? anchor = null)
{
DataContext = viewModel;
if (Screens.Primary is { } screen)
{
var area = screen.WorkingArea;
var scale = screen.Scaling;
// Windows: über der Taskleiste unten rechts; macOS: unter der Menüleiste oben rechts, dort sitzt das Symbol
Position = new PixelPoint(
area.Right - (int)(Width * scale) - (int)(12 * scale),
OperatingSystem.IsMacOS() ? area.Y + (int)(6 * scale) : area.Bottom - (int)(Height * scale) - (int)(12 * scale));
if (anchor is { } icon)
{
// Mittig unter dem Symbol, 4 Punkte Abstand; nicht über den Bildschirmrand hinaus
var x = (int)((icon.X + (icon.Width / 2) - (Width / 2)) * scale);
var y = (int)((icon.Y + icon.Height + 4) * scale);
var margin = (int)(8 * scale);
Position = new PixelPoint(
Math.Clamp(x, area.X + margin, area.Right - (int)(Width * scale) - margin),
Math.Max(y, area.Y));
}
else
{
// Windows: über der Taskleiste unten rechts (dort sitzt der Infobereich)
Position = new PixelPoint(
area.Right - (int)(Width * scale) - (int)(12 * scale),
area.Bottom - (int)(Height * scale) - (int)(12 * scale));
}
}

Show();
Expand Down
5 changes: 4 additions & 1 deletion src/SyncDrive.Client.Tray/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public void Post(Action action)
}
}

/// <summary>macOS: liefert die Lage des Menüleisten-Symbols, damit das Panel genau darunter aufgeht.</summary>
public Func<(double X, double Y, double Width, double Height)?>? TrayAnchor { get; set; }

public void TogglePanel()
{
if (_shell is null)
Expand All @@ -48,7 +51,7 @@ public void TogglePanel()
else if (DateTimeOffset.UtcNow - _panel.HiddenAt > TimeSpan.FromMilliseconds(400))
{
// Der Klick aufs Symbol nimmt dem offenen Panel zuerst den Fokus (es schließt sich); er soll es nicht gleich wieder öffnen
_panel.ShowNearTray(_shell.Panel);
_panel.ShowNearTray(_shell.Panel, TrayAnchor?.Invoke());
}
}

Expand Down
Loading