-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[RFC] Add Window.CanMinimize/CanMaximize #18117
base: master
Are you sure you want to change the base?
Conversation
You can test this PR using the following package version. |
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.
Is the linked issue really resolved? CaptionButtons are still visible.
We're just supporting what the various platforms are exposing here. On Windows, if Maximize and Minimize are both disabled, the system automatically hides both buttons. To do more, it's always possible for users to use a custom chrome. |
style &= ~WindowStyles.WS_MINIMIZEBOX; | ||
|
||
if (newProperties.IsMaximizable || (newProperties.WindowState == WindowState.Maximized && newProperties.IsResizable)) | ||
style |= WindowStyles.WS_MAXIMIZEBOX; |
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 know it's annoying, but we need integration tests for win/mac :)
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 completely agree that we need more tests overall!
However, in this case, I don't really see a good way to test this with the current infrastructure.
Should we find the position of the maximize/minimize buttons and try to click them? (Can we even access the non-client area buttons via Appium?) Did you have another approach in mind?
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 wrote these extension methods before for window-decoration tests: https://github.com/AvaloniaUI/Avalonia/blob/master/tests/Avalonia.IntegrationTests.Appium/ElementExtensions.cs#L40
It might be enough to check enabled/visible state of these elements via appium apis.
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.
GetSystemChromeButtons
for system titlebar. And GetClientChromeButtons
for client titlebar (which also is properly recognized as an accessible titlebar, at least on windows).
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.
Thanks for the pointers! I really need to familiarize myself with the integration tests infrastructure.
You can test this PR using the following package version. |
I think hint in the name makes more sense and follows the existing pattern of things that may or may not work. |
Couple thoughts:
|
What does the pull request do?
This PR adds two new properties to
Window
to enable or disable the minimize (CanMinimize
) and maximize (CanMaximize
) buttons of a window.They're implemented on all three desktop platforms: Windows, macOS and X11.
Notes
General
true
by default.CanMaximize
is automatically coerced tofalse
whenCanResize
isfalse
.CanMaximize
is false, the restore button stays enabled if the window is somehow already maximized (and is resizable).Both Qt and Wine have been used as reference implementations for X11 and macOS.
Windows
On Windows, the two properties work exactly as one would expect. They map to the
WS_MINIMIZEBOX
andWS_MAXIMIZEBOX
window styles.Linux
On X11, the two properties are effectively hints (
_MOTIF_WM_HINTS
).Maybe we should prefer names such as
CanMinimizeHint
andCanMaximizeHint
?In my tests, GNOME respects them, and while the buttons aren't visually disabled (at least on Ubuntu 24.04 with the default theme), they aren't clickable.
KDE (KWin) completely ignores them.
macOS
CanMinimize
disables the minimize button, as expected.CanMaximize
disables both the zoom/maximize gesture (titlebar double click) and the green full screen button.I went this route because I believe that's what most users would expect: that each property effectively corresponds to one traffic light button. Plus, clicking the green button with ⌥ pressed effectively zooms so the two behaviors aren't easily dissociated.
If that isn't acceptable, we could easily split that into
CanMaximize
andCanSwitchToFullScreen
(naming TBD).New API
Fixed issues