Window Position in XAML not honored on startup
Experimenting in 0.9 and setting position of the window with something like Position="500,600" is not working on Linux but does work on Windows and Mac. At first I thought it was an out of bounds issue by setting it to 0,0, which the upper left corner of the deskop is not on my Linux (I get 1,23 for that on Mint MATE and 0,57 on Ubuntu 18.04 not counting the dock and 67,57 when not going past it). However even setting it to something close to but not the default location.
The behavior is manifesting differently on MATE and on Ubuntu 18.04 GNOME. On MATE it simply does nothing. If I capture the PositionChanged event after setting the Position to 500,500 (so no bounds problems) I can see it still draws it at 1130,570 just like if I didn't set it at all. On GNOME 3 I end up getting two position changed events. The first moves it to the requested 500,500 but then it seems to get some sort of default position from GNOME to throw it to wherever it decides to. Sometimes that's the next offset stacked window position. Sometimes it's aligned with the bottom of the terminal window I used to launch it. etc.
Repro on 0.10.15 on Debian
We found a workaround. You can't change Position before the window is shown. So, in our method where we were setting Position = new PixelPoint(newX, newY), we instead save the new PixelPoint to a class variable, then override OnOpened to actually set Position:
public MyWindow()
{
...
newPosition = new(newX, newY);
}
private PixelPoint newPosition = default;
protected override void OnOpened(EventArgs e)
{
Position = newPosition;
base.OnOpened(e);
}
@maxkatz6 Why is this not planned? Is it not possible to fix in X11 or Wayland?
@colejohnson66 in case you know a reliable way to solve it for Avalonia, a PR is welcome. Until today, we think that not all Windowmanager support it by design and thus we cannot really solve it.