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

[RNW] GetForCurrentView API alternatives for islands #114

Closed
asklar opened this issue Jul 17, 2020 · 9 comments
Closed

[RNW] GetForCurrentView API alternatives for islands #114

asklar opened this issue Jul 17, 2020 · 9 comments

Comments

@asklar
Copy link
Member

asklar commented Jul 17, 2020

React Native for Windows doesn't currently officially support islands today (on system xaml nor winui3) but I’m doing work to bring up islands support.

We have usages of a few WinRT types via GetForCurrentView which won't work in island scenarios, this tracks pursuing alternatives in Reunion that allow us to have a unified calling pattern for both win32 and UWP.

Members of DisplayInformation we use (after doing a GetForCurrentView):

  • DpiChanged
  • ResolutionScale
  • LogicalDpi
  • ScreenWidthInRawPixels, ScreenHeightInRawPixels
    These last 2 are used to expose them to the JS side of apps and libraries.

There are a couple of other places where we do things like GetForCurrentView that we’ll need to figure out how to achieve with islands:

  • CoreInputView -> GetCoreInputViewOcclusions -> OcclusionsChanged
    We do that to know when the on screen keyboard shows/hides and raise JS events to that effect so that the UI can re-layout.
  • SystemNavigationManager -> BackRequested and AppViewBackButtonVisibility
    This might be ok to not hook up in island scenarios if we never have a device with back buttons that can also run Win32 apps
  • ApplicationModel.Resources.Core.ResourceContext.GetForCurrentView() -> QualifierValues -> Lookup(“LayoutDirection”)
    This is used to determine whether we should display in RTL or LTR. I’m assuming the alternative is to do GetLayout(hwnd) == LAYOUT_RTL instead?
@jonwis
Copy link
Member

jonwis commented Jul 17, 2020

Thanks - I see a bunch of APIs for this already available to your needs. You could potentially add the layer of indirection now, then help us make that indirection functionality part of Project Reunion. For example:

  • DPI Change - Recheck the DPI on a window change message
  • Resolution Scale - Use MonitorFromWindow then GetScaleFactorForMonitor
  • Logical DPI - Use GetDpiForWindow
  • Screen physical size - Use MonitorFromWindow then GetMonitorInfo

@asklar
Copy link
Member Author

asklar commented Aug 13, 2020

@jonwis any ideas for the other scenarios? e.g. detecting when the software keyboard shows/hides, etc.?

@ghost ghost added the needs-attention 👋 label Sep 1, 2020
@stevewri
Copy link
Contributor

@asklar - anything left (see Jon's question above)?

@asklar
Copy link
Member Author

asklar commented Sep 21, 2020

@stevewri @jonwis I was hoping Reunion would be this magic box I could call an API on and it would just work regardless of context (uwp/island/...).
So maybe I should step back and ask...what is Reunion/how does it help me write converged uwp/win32 code? :)
(happy to have this discussion offline too)

@michael-hawker
Copy link

@marb2000 @azchohfi these are the similar transitions needed for XAML Islands, those were all documented somewhere on docs.microsoft.com, right? Any insights here you can provide?

@imbushuo
Copy link
Member

imbushuo commented May 4, 2021

+1 for case in DisplayInformation. In this specifically case, a lot of Win32 applications do not have CoreWindow presence, for easier display information retrieval, something like DisplayInformation.GetForHwnd(hwnd) should be added. This will make querying HDR information on Win32 apps easier.

@marb2000
Copy link

marb2000 commented May 4, 2021

@asklar, @imbushuo I wrote several samples using the Win32 APIs that cover the majority of the gaps that there are in the platform. You can take a look at https://github.com/marb2000/DesktopWindow. Per the current engineering plan, these functionalities are not in Reunion v1.

@jeffstall
Copy link

Currently, it is recommended to use the various I*Interop APIs using HWNDs. See
IPrintManagerInterop for an example. We are tracking this feature request to make improvements in the future.

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

9 participants