Skip to content
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

Window with extendedclientarea incorrectly sized on fullscreen #17497

Open
giacarrea opened this issue Nov 13, 2024 · 6 comments
Open

Window with extendedclientarea incorrectly sized on fullscreen #17497

giacarrea opened this issue Nov 13, 2024 · 6 comments

Comments

@giacarrea
Copy link

Describe the bug

I have a simple window with a customized titlebar.

When not maximized, the elements are fully displayed.
image

When maximized, the window seem larger than the screen.
image

This behavior can be mitigated by adding a maximized specific styling:
<Window.Styles> <Style Selector="Window[WindowState=Maximized]"> <Setter Property="Padding" Value="8" /> </Style> </Window.Styles>

Here's a solution embedding the issue, derived from the avalonia sample repository:
schlorping.zip

To Reproduce

Compare the elements' edges when the window is maximized VS when it's not. (seem to only occur on windows)

Expected behavior

No response

Avalonia version

11.2.0

OS

Windows

Additional context

No response

@mgarstenauer
Copy link
Contributor

Instead of using a Style with a hardcoded Padding, you can use:

<Panel Padding="{Binding $parent[Window].OffScreenMargin}">
    ...
</Panel>

See also:
https://github.com/AvaloniaUI/Avalonia/blob/master/samples/ControlCatalog/MainWindow.xaml#L59

Maybe this should be built into the default Window control theme. I think that could solve the problem for everyone – but it would mess up the style for users that already apply OffScreenMargin to their content.

@pavelovcharov
Copy link
Contributor

It looks like the OffScreenMargin is not calculated correctly. The MainView doesn't fit the screen (tested on Windows 11)

image

@mgarstenauer
Copy link
Contributor

mgarstenauer commented Nov 16, 2024

@pavelovcharov The screenshot looks fine. The custom title "Content in Title Bar" is fully visible. I don't see a problem.

Let me explain:

  • I assume you have enabled "Extend Client Area to Decorations". That means the client area also includes the window border (+1px on all sides).
  • The desktop minus the taskbar is 2560×1392.
  • The window is maximized. In this case Windows hides the window border. 1 px on each side of the window is outside the visible area. That's how you end up with MainView.Bounds.Width == 2562.

If you select "MainWindow" in DevTools and look for OffScreenMargin you should see a value like 7,7,7,7.

(Tested with Avalonia 11.1.3)

@pavelovcharov
Copy link
Contributor

pavelovcharov commented Nov 16, 2024

@mgarstenauer Yes, I have enabled the ExtendClientAreaToDecorationsHint option.
The MainView is the user content. Its width is 2562px while the screen width is 2560px. As a result, the user content is not completely visible on the screen.

I'm using v11.2.0

@pavelovcharov
Copy link
Contributor

Or should we add this 1pixel margin manually?

@mgarstenauer
Copy link
Contributor

I am not sure how the 1 pixel margin is supposed to be handled – or whether it is actually a bug. It is discussed here as well: #17202

I think the authors of the Win32 window implementation need to clarify the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants