-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[Mac Catalyst] Set window dimensions #24001
[Mac Catalyst] Set window dimensions #24001
Conversation
3862e00
to
72401f9
Compare
protected override void ConnectHandler(UIWindow platformView) | ||
{ | ||
base.ConnectHandler(platformView); | ||
|
||
UpdateVirtualViewFrame(platformView); | ||
|
||
_effectiveGeometryObserver = platformView.WindowScene?.AddObserver("effectiveGeometry", NSKeyValueObservingOptions.OldNew, HandleEffectiveGeometryObserved); |
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.
Referencing the handler directly from the native view - the observer now holds a reference to the handler - will most certainly cause a leak.
Please use our amazing and totally not verbose way to do events: https://github.com/dotnet/maui/blob/main/src/Core/src/Handlers/Switch/SwitchHandler.iOS.cs#L57-L79
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 attempted to update it.
I think all this looks good, just had a nit about collapsing and reducing the if block complexity. Then you are going to have to use the proxy event system as anything referencing maui from the native world will leak the entire universe as they are all linked. Although now with @PureWeen magic in net9 this may not be the case. But, for net8 we are going to have to proxy all the things. |
251d4fa
to
cb0eae4
Compare
I noticed an issue when initial window dimension was not correctly handled (window was placed always to X=0 and Y=0). I'm not sure how else to fix it than to do: 3e17515 (where I basically wait until the new API sends an event with proper window dimensions, at first, some values are NaNs.) |
tl;dr: The controls sample app I use for testing appears to work correctly with the latest commit (3e17515). But I guess there are more scenarios which should be tested, hopefully tests cover some of those scenarios. |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
This comment was marked as outdated.
This comment was marked as outdated.
@mattleibow Could you take a look please? |
@MartyIX to run the failing test you need to set this in your vs code after a successful build, you should see the following screen: then to run this particular test do as I did in this video: Screen.Recording.2024-10-16.at.20.12.08.mov |
Yeah, I figured it out in the meanwhile. Sorry for not updating the post. However, I'm very much unsure how to fix the test. |
This comment was marked as outdated.
This comment was marked as outdated.
3e49f32
to
89976d9
Compare
Azure Pipelines successfully started running 3 pipeline(s). |
89976d9
to
9449842
Compare
9449842
to
e3bc904
Compare
Azure Pipelines successfully started running 3 pipeline(s). |
@mattleibow Could you take a look please? |
Would this also fix the window positioning error? |
Could you explain more in detail what you mean? |
If I understand right from the video (I haven't cloned and ran this), your changes would fix the error of being unable to change window dimensions programmatically on mac. If that's right, does your change also address moving the location of the app's window itself? (App.X / App.Y) |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
It appears that
fails on iOS. |
d98c564
to
1650bee
Compare
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
src/Core/src/Hosting/LifecycleEvents/AppHostBuilderExtensions.iOS.cs
Outdated
Show resolved
Hide resolved
PR looks ok, not sure about the observers @PureWeen? Are we allowed to do that? My review is a bit nitty, but I think adding the logging will help future us and customers when things break. |
@mattleibow I have addressed your feedback. Hopefully, it's OK. |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
@mattleibow Tests seem to be green. |
Description of Change
This PR demonstrates that Mac Catalyst applications can change window dimensions.
Demo
Screen.Recording.2024-08-14.at.15.00.53.mov
Issues Fixed
Fixes #9704
Resources