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

Support Window.Frame on all platforms #10028

Merged
merged 6 commits into from
Sep 16, 2022
Merged

Support Window.Frame on all platforms #10028

merged 6 commits into from
Sep 16, 2022

Conversation

mattleibow
Copy link
Member

@mattleibow mattleibow commented Sep 9, 2022

Description

This PR fixes a few more Window issues:

Tasks

  • Write code
    • Android
    • iOS
    • Windows
    • Mac Catalyst
    • Tizen (pending review by @rookiejava)
  • Write unit tests
  • Write device tests

Known Issues

  • iOS/Mac Catalyst do not report X/Y, so they are always 0,0

Screenshots

Android iOS Windows Mac Catalyst
Screenshot_1663003046 Simulator Screen Shot - iPhone 13 Pro Max - 2022-09-12 at 19 42 33 image maccat

@mattleibow mattleibow added the do-not-merge Don't merge this PR label Sep 9, 2022
@mattleibow mattleibow changed the title Make window.frame work Support Window.Frame on all platforms Sep 11, 2022
@mattleibow mattleibow removed the do-not-merge Don't merge this PR label Sep 11, 2022
@mattleibow mattleibow added this to the 7.0-rc2 milestone Sep 11, 2022
@@ -16,7 +16,8 @@ protected override void ConnectHandler(UI.Xaml.Window platformView)
if (platformView.Content is null)
platformView.Content = new WindowRootViewContainer();

// update the platform window with the user size
// update the platform window with the user size/position
platformView.UpdatePosition(VirtualView);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The real fix for #9703

@mattleibow
Copy link
Member Author

@rookiejava are you or your team able to confirm that Tizen works as expected?

Comment on lines +116 to +129
internal static void UpdateX(this Window platformWindow, IWindow window) =>
platformWindow.UpdateUnsupportedCoordinate(window);

internal static void UpdateY(this Window platformWindow, IWindow window) =>
platformWindow.UpdateUnsupportedCoordinate(window);

internal static void UpdateWidth(this Window platformWindow, IWindow window) =>
platformWindow.UpdateUnsupportedCoordinate(window);

internal static void UpdateHeight(this Window platformWindow, IWindow window) =>
platformWindow.UpdateUnsupportedCoordinate(window);

internal static void UpdateUnsupportedCoordinate(this Window platformWindow, IWindow window) =>
window.FrameChanged(platformWindow.WindowPositionSize.ToDP());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rookiejava are you or your team able to confirm that Tizen works as expected?

No problems with current tizen implementation at the moment. However, we need more investigation for supporing multi window and window resizing on tizen (with NUI), hopefully it should be supported. If we find a way, I will submit separate PR the actual tizen implementation. 🤙

{
internal static partial class ActivityExtensions
{
internal static IWindow? GetWindowFromActivity(this Android.App.Activity? activity)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deleting this and moving this code to ContextExtensions.GetWindow which we are already using

image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful. Less code is good code.

if (e.MessageId == PlatformMethods.MessageIds.WM_SETTINGCHANGE ||
e.MessageId == PlatformMethods.MessageIds.WM_THEMECHANGE)
{
var mauiApp = MauiWinUIApplication.Current;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced this with

if (IPlatformApplication.Current is IPlatformApplication platformApplication)

var density = newConfig.DensityDpi / DeviceDisplay.BaseLogicalDpi;
mauiWindow.DisplayDensityChanged(density);
}
MauiApplication.Current?.Services?.InvokeLifecycleEvents<AndroidLifecycle.OnConfigurationChanged>(del => del(this, newConfig));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3


return null;
}
=> view?.Context?.GetWindow();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha you were already consolidating.

XF: yea it's really hard to get the window
MAUI: here's like 7 extensions you can use with slightly different names :-p

@PureWeen PureWeen marked this pull request as ready for review September 15, 2022 22:23
@PureWeen PureWeen enabled auto-merge (squash) September 16, 2022 00:20
@PureWeen PureWeen merged commit 2ec5abe into main Sep 16, 2022
@PureWeen PureWeen deleted the dev/window-fixes branch September 16, 2022 01:29
@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants