-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WindowStartupLocation DPI-awareness #1979
Conversation
Uses ITopLevelImpl.Scaling to calculate screen coordinates
if (WindowStartupLocation == WindowStartupLocation.CenterScreen) | ||
{ | ||
var screen = Screens.ScreenFromPoint(Bounds.Position); | ||
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@danwalmsley any further info here?
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.