WindowStartupLocation DPI-awareness#1979
WindowStartupLocation DPI-awareness#1979OronDF343 wants to merge 7 commits intoAvaloniaUI:masterfrom OronDF343:wsldpifix
Conversation
Uses ITopLevelImpl.Scaling to calculate screen coordinates
|
|
||
| if (screen != null) | ||
| Position = screen.WorkingArea.CenterRect(new Rect(ClientSize)).Position; | ||
| Position = screen.WorkingArea.CenterRect(new Rect(ClientSize * scaling)).Position; |
There was a problem hiding this comment.
I believe this is because the ClientSize is being treated as screen pixels somewhere and isn't being scaled. This is probably a backend-specific bug as I'm not getting it on Win32.
Which backend are you running on?
|
I notitce that window position does not seem to use scaling on win32 |
|
Correct, this is why the original issue exists. The question is, is the
same true for the other platforms? Is Windows the exception rather than the
norm, or vice versa?
…On Wed, 16 Jan 2019, 14:51 ahopper ***@***.*** wrote:
I notitce that window position does not seem to use scaling on win32
https://github.com/AvaloniaUI/Avalonia/blob/3d4fb2c54b38873bc57d343f3505c376967738b6/src/Windows/Avalonia.Win32/WindowImpl.cs#L360
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1979 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AE5SjCvuCLHf-IspQIi81kUE-AtKzJpXks5vDyA6gaJpZM4XvQva>
.
|
|
Yes, it is not clear what should be scaled and what should allow for window chrome and where the transitions should happen. |
|
Yes, I think the problem here is that we're not specific as to whether a window's position is in device co-ordinates or in device independent co-ordinates. This SO answer suggests that win32's window position will be in device coordinates if you have a DPI-aware app (we do):
My feeling is that this makes sense, and that we should specify that |
|
It makes perfect sense to have Window.Position in device pixels. There would be a problem with GTK which scales everything, but we are going to get rid of it anyway. We should also make Position to use PixelPoint instead of Point and make screens API to use PixelSize. Also, we need to fix |
|
Thanks for this @OronDF343: the changes @kekekeks suggested made sense, but they were a bit more involved so we merged #2250 which incorporates your changes there. |

Fixes #1961
Window.SetWindowStartupLocation()will now respect the display scaling when positioning the window. I am using ITopLevelImpl.Scaling to do this.CenterScreen works for me at 150% on desktop Win 7. CenterOwner should also work in theory - only limited testing was done as I have no more time to work on this today. The code is pretty simple anyways.