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

android: Hold NativeWindow lock until after notifying the user with Event::Suspended #2307

Merged
merged 1 commit into from
Jul 14, 2022

Conversation

MarijnS95
Copy link
Member

@MarijnS95 MarijnS95 commented May 28, 2022

This applies rust-mobile/ndk#117 on the winit side: Android destroys its window/surface as soon as the user returns from onNativeWindowDestroyed, and we "fixed" this on the ndk-glue side by sending the WindowDestroyed event before locking the window and removing it: this lock has to wait for any user of ndk-glue - ie. winit - to give up its readlock on the window, which is what we utilize here to give users of winit "time" to destroy any resource created on top of a RawWindowHandle.

since we can't pass the user a RawWindowHandle through the HasRawWindowHandle trait we have to document this case explicitly and keep the lock alive on the winit side instead.

  • Tested on all platforms changed
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality
  • Updated feature matrix, if new features were added or implemented

I'm creating this as draft because there are different things to consider: for one I've constantly commented that we should probably pass the RawWindowHandle and/or Android NativeWindow inside the Resumed event somehow across every platform for consistency, and it'd be great if this includes the lock to make the user responsible for holding it instead of implicitly unlocking after Event::Suspended. Then someone recently created a whole bunch of very long issues mentioning similar (concurrency) issues and longevity of the Android backend in general - sorry I've yet to catch up to those but there are too many and they're way too long 😁

@rib
Copy link
Contributor

rib commented May 29, 2022

then someone recently created a whole bunch of very long issues mentioning similar (concurrency) issues and longevity of the Android backend in general - sorry I've yet to catch up to those but there are too many and they're way too long

hehe, yeah that'll be me, sorry :)

TL;DR = I don't think ndk-glue handles native <-> Java synchronization robustly at the moment.

Ideally I think it could be good for ndk-glue to provide a callback based API for polling + dispatching events which can handle synchronization in a way that's similar to the original android_native_app_glue that's ships with the Android NDK where the glue can insert "pre" and "post" code around callbacks that let ndk-glue encapsulate this kind of synchronization so downstream users don't have to follow this kind of convention to get correct synchronization.

I feel like this is an error-prone design at the moment, that pushes the fiddly burden of handling synchronization to downstream users (winit) while also exposing implementation details that could ideally be encapsulated in the glue layer (now winit will depend on parking_lot because that's how ndk_glue internally locks the window state, and ndk_glue now can't change how it handles synchronization without breaking it's API)

I've tried to solve this with how I designed these native-activity and game-activity glue crates, including also handling synchronization for saving app state.

Those concerns aside for a moment though; the changes in this draft look good for being able to address the main synchronization issue I've seen with ndk-glue for window surface destruction.

@MarijnS95
Copy link
Member Author

TL;DR = I don't think ndk-glue handles native <-> Java synchronization robustly at the moment.

TL;DR: I can't but agree.

In principle NDK glue looks like a straightforward, concise wrapper. Using a pipe to tie into looper, and using locks to synchronize objects created and destroyed in its callbacks. Consumers of ndk-glue - in particular winit which lives under the same orga - are probably designed to tightly work with/around the design of ndk-glue, and hide its implementation details. That didn't really seem to have happened, and the Android backend in winit feels like it works "just good enough" and the missing features are only slowly trickling in when users finally need it (ie. it doesn't seem to be used often).

In the end ndk-glue could have also provided a (callback) layer on top of the looper, pipe, and locks, instead of having this implemented inside winit and any other possible consumer of ndk-glue. Combine that with winits "poor" (because desktop differs here) handling of "dynamic" windows that "randomly" (dis)appear and require platform-specific Suspended and Resumed events and the oddities of the Android API trickle down all the way into user code. But that's a discussion better left for #2185/#2293.

so downstream users don't have to follow this kind of convention to get correct synchronization.

For the record I have yet to find a primitive that helps users be aware that they must handle a WindowDestroyed/Suspended event in terms of destroying their Vulkan/OpenGL surfaces, before returning/continuing from the handling of this event.

now winit will depend on parking_lot because that's how ndk_glue internally locks the window state, and ndk_glue now can't change how it handles synchronization without breaking it's API

parking_lot is not necessary for this change. It simply makes the API more convenient by not having an Option inside the ReadLock that you know will never be None after initially checking it (fwiw many other platform backends have a parking_lot dependency as well, this locking crate appears to be widely accepted).

Those concerns aside for a moment though; the changes in this draft look good for being able to address the main synchronization issue I've seen with ndk-glue for window surface destruction.

Yes, I'm surprised we fixed this in ndk-glue but the change wasn't yet applied to winit... Priorities I guess.

What's your thought: get this in now, and keep discussing the future with your game/native-activity wrappers and see where we end up time-wise? There are currently some tricky issues with ndk-glue which'll take time to resolve that I don't have; at the same time your crate may solve a bunch of those implicitly but will also take quite some time/effort to discuss and migrate to? Most importantly updating the user-facing winit part to better suit Android instead of feeling and behaving like an afterthought.

@MarijnS95
Copy link
Member Author

Addendum: It's funny that I just now started reading #2293 and addressed your main concern with this PR, while I was really doing that after noticing that it needed to be done in glutin because winit didn't do it yet. The comment you quoted came from another ndk-glue - but not winit - user who saw the same concerns and I just forgot to update winit after fixing it there.

However.

I may have done that "on purpose".

In certain cases the caller may invoke ndk_glue::native_window(), and themselves be responsible for storing the lock next to their handle on a Vulkan/OpenGL surface, instead of winit.

At least this is what I initially thought when voicing these concerns in rust-windowing/glutin#1411 (comment), where this thought is valid.

But then.

It is more common for applications to use the HasRawWindowHandle trait on a winit::Window, perhaps even the glutin implementation should use that without ever depending on the ndk_glue crate directly.


Summing that up, this PR is probably the right thing to do after all given that users of winit don't use ndk_glue hence don't see the lock as that's now hidden behind the Suspended/Resumed events. Otherwise there's no harm in holding the readlock twice.

@rib
Copy link
Contributor

rib commented May 30, 2022

For the record I have yet to find a primitive that helps users be aware that they must handle a WindowDestroyed/Suspended event in terms of destroying their Vulkan/OpenGL surfaces, before returning/continuing from the handling of this event.

Right, I think this is a big enough portability hazard that I think it needs to be addressed at a higher level than just the Android backend. I don't tend to think there's a simple primitive we can find to solve this within the Android backend.

With issue #2182 and #2293 I think I'd currently like to advocate for Winit supporting resume events consistently across all platforms, and then either just updating all examples and potentially introducing some impediments on other platforms that strongly encourage following a pattern where GPU resources like your context and first window + surface are only lazily allocated once you reach your first resume event.

I recently worked on two downstream projects to investigate the feasibility of this and I was able to get both egui and Bevy running based on this model, in such a way that it also worked to run on Windows following the same model.

E.g. this Egui example, based on Winit, runs on Android and Windows: https://github.com/rib/agdk-rust/blob/main/examples/agdk-egui/src/lib.rs
and here's a proof of concept for Bevy too: https://github.com/rib/bevy/tree/android-deferred-render-init (I had a local Winit branch that generates Resumed events on Windows so the same approach ran on Windows)
I'd say that Bevy was by far the more complex architecture to adapt, but in the end it wasn't too big of a change.

@rib
Copy link
Contributor

rib commented May 30, 2022

parking_lot is not necessary for this change. It simply makes the API more convenient by not having an Option inside the ReadLock that you know will never be None after initially checking it (fwiw many other platform backends have a parking_lot dependency as well, this locking crate appears to be widely accepted).

Yep, and to be clear, I'm not making any kind of value judgement on parking lot here which is definitely widely used and yeah it makes sense that other backends are also using it. I'm more just concerned with the leaky ndk-glue abstraction. The choice of locking and synchronization primitives can ideally be encapsulated within a library. In this case ndk-glue now has a public API that imposes a parking_lot dependency on its downstream users and it also means ndk_glue can't simply switch to a different synchronization strategy without breaking its public API, which doesn't seem ideal to me.

@rib
Copy link
Contributor

rib commented May 30, 2022

What's your thought: get this in now, and keep discussing the future with your game/native-activity wrappers and see where we end up time-wise? There are currently some tricky issues with ndk-glue which'll take time to resolve that I don't have; at the same time your crate may solve a bunch of those implicitly but will also take quite some time/effort to discuss and migrate to? Most importantly updating the user-facing winit part to better suit Android instead of feeling and behaving like an afterthought.

My gut instinct atm is that there's no reason to block a fix like this on any other proposal to potentially swap out ndk_glue; this should hopefully fix a legitimate synchronization issue that exists now, and the concerns around leaky API etc don't extend outside of the Android backend so they don't affect users of the Winit API.

Thinking ahead; I'm currently thinking of creating a shim android_activity crate (I was considering renaming my agdk-rust repo to android-activity) that would provide a single place that can allow Rust applications to configure their Activity glue layer. For starters the crate would optionally depend on the native-activity and game-activity crates and let you pick a glue layer based on a feature. Additional glue layers could be implemented to support different Activity base classes (E.g. there were some ideas to create a RustActivity crate suggested here: rust-mobile/ndk#266 (comment)).

This would result in a single crate + API for Winit to use for Android glue while giving applications the ability to choose different Activity base classes. Right now my experimental Winit backend conditionally switches between native-activity and game-activity based on a feature in Winit (since the APIs are compatible it just needs a #[cfg()] test around the use *-activity as ndk_glue currently), but I was thinking it might be beneficial to push that out to a separate crate in case there are opportunities to share code for different activity classes and to allow for non-winit use cases that could also benefit from a common API.

Also just for reference, I'm not expecting that android_activity would have to be a fully encapsulated, lowest-common-denominator API for different activity base classes (since otherwise we wouldn't be able to support any additional Android features in Winit beyond what NativeActivity allows). I was thinking there would be a core API that's common across activity classes (such as poll_events() and the input API and APIs for saving state + querying data_dirs) and then the features for selecting the implementation would also be able to expose APIs that may be specific to that activity class.

For the more general challenge with Android being a kind of second-class platform atm then I mainly thinking about trying to normalize lazy graphics state initialization via resumed events across platforms as a starting point, re: #2307 (comment)

@rib
Copy link
Contributor

rib commented May 30, 2022

But then.

It is more common for applications to use the HasRawWindowHandle trait on a winit::Window, perhaps even the glutin implementation should use that without ever depending on the ndk_glue crate directly.

Summing that up, this PR is probably the right thing to do after all given that users of winit don't use ndk_glue hence don't see the lock as that's now hidden behind the Suspended/Resumed events. Otherwise there's no harm in holding the readlock twice.

hmm, yeah, I didn't realize glutin was currently dependent on ndk_glue directly. Especially considering this kind of locking design in ndk_glue I would think it's probably for the best to at least aim to keep the synchronization responsibilities encapsulated inside Winit, and would guess it'd be best for glutin to be getting it's raw window handles via Winit.

@MarijnS95
Copy link
Member Author

For the record I have yet to find a primitive that helps users be aware that they must handle a WindowDestroyed/Suspended event in terms of destroying their Vulkan/OpenGL surfaces, before returning/continuing from the handling of this event.

Right, I think this is a big enough portability hazard that I think it needs to be addressed at a higher level than just the Android backend. I don't tend to think there's a simple primitive we can find to solve this within the Android backend.

In case it wasn't entirely clear I'm specifically looking for a solution that forces the API to be consistent across all platforms, to replace the Android-specific after-thought that we have now. In addition something that more clearly pushes the burden of managing the implicit dependency between Vulkan/GL surfaces and a window.

However, I initially limited my thoughts to RawWindowHandle in Resumed (and removing the getter/trait from Window), because Window is pretty much an empty shell on Android that I don't look at much. But for true platform agnostic behaviour things presumably need to change across the board.

For one I remember some getter functions on Window not behaving correctly prior to Resumed (IIRC it was the window size, which isn't surprising) but will need to recheck that before commenting further.

With issue #2182 and #2293 I think I'd currently like to advocate for Winit supporting resume events consistently across all platforms, and then either just updating all examples and potentially introducing some impediments on other platforms that strongly encourage following a pattern where GPU resources like your context and first window + surface are only lazily allocated once you reach your first resume event.

Exactly this. Slightly more burden for "desktop app" writers, but they'll "thank us" when their app runs flawless on mobile, instead of finding out through obscure errors that they need to handle this differently.


Yep, and to be clear, I'm not making any kind of value judgement on parking lot here which is definitely widely used and yeah it makes sense that other backends are also using it. I'm more just concerned with the leaky ndk-glue abstraction. The choice of locking and synchronization primitives can ideally be encapsulated within a library. In this case ndk-glue now has a public API that imposes a parking_lot dependency on its downstream users and it also means ndk_glue can't simply switch to a different synchronization strategy without breaking its public API, which doesn't seem ideal to me.

I guess we could newtype-wrap it just to get this issue done and over with, at which point we're free to implement whatever locking abstraction we want.


My gut instinct atm is that there's no reason to block a fix like this on any other proposal to potentially swap out ndk_glue; this should hopefully fix a legitimate synchronization issue that exists now, and the concerns around leaky API etc don't extend outside of the Android backend so they don't affect users of the Winit API.

...

For the more general challenge with Android being a kind of second-class platform atm then I mainly thinking about trying to normalize lazy graphics state initialization via resumed events across platforms as a starting point, re: #2307 (comment)

I guess we should talk to the winit maintainers for a timeline on the next release. Specifically I'd like to get these changes merged but without a git dependency - though at the same time that forces the next winit release to coordinate with an NDK/ndk_glue breaking release as requested in #1995.

On the side, in separate issues that don't fill up this PR, we should discuss how to proceed on making Android a first-class citizen, how to lay out the underlying crates and architecture, etc.


hmm, yeah, I didn't realize glutin was currently dependent on ndk_glue directly. Especially considering this kind of locking design in ndk_glue I would think it's probably for the best to at least aim to keep the synchronization responsibilities encapsulated inside Winit, and would guess it'd be best for glutin to be getting it's raw window handles via Winit.

We've already shoved ndk_glue out as soon as it came in, since this should be handled through raw-window-handle instead: rust-windowing/glutin#1418

Over time (I don't use glutin, so progress only happens in down-time) I'm pushing towards working winit out the door too: raw-window-handle was specifically designed for this, allows for a more generic implementation (just a match block) across all platforms, and will allow arbitrary Android Surfaces (NativeWindows...) to be used as render target (rust-mobile/ndk#274).

@MarijnS95
Copy link
Member Author

@rib I like the newtype suggestion, see rust-mobile/ndk#288. This is now all ready from my side, and probably the last change we can do before pushing out 0.27. I wish we could do a larger Suspended/Resumed refactor, but that'll probably be a larger endeavour requiring precise API design.

@MarijnS95 MarijnS95 added the I - BLOCKING RELEASE Prevents a new release label Jun 10, 2022
rib added a commit to rib/winit that referenced this pull request Jul 4, 2022
This updates the Android backend to use the android_activity create instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Jul 4, 2022
This updates the Android backend to use the android_activity create instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
@MarijnS95
Copy link
Member Author

MarijnS95 commented Jul 5, 2022

This applies rust-windowing/android-ndk-rs#117 on the winit side

It is thanks to @rib's commit above that links to these PRs, that I found #1892 again which did end up applying rust-mobile/ndk#117 to winit. It wasn't forgotten about, I just forgot about that PR being open and ending up stale...

@MarijnS95 MarijnS95 requested a review from msiglreith July 6, 2022 10:38
@MarijnS95 MarijnS95 force-pushed the android-hold-window-lock branch 2 times, most recently from 3284770 to 5dabb1e Compare July 8, 2022 13:37
… `Event::Suspended`

This applies rust-mobile/ndk#117
on the `winit` side: Android destroys its window/surface as soon as the
user returns from [`onNativeWindowDestroyed`], and we "fixed" this on
the `ndk-glue` side by sending the `WindowDestroyed` event before
locking the window and removing it: this lock has to wait for any user
of `ndk-glue` - ie. `winit` - to give up its readlock on the window,
which is what we utilize here to give users of `winit` "time" to destroy
any resource created on top of a `RawWindowHandle`.

since we can't pass the user a `RawWindowHandle` through the
`HasRawWindowHandle` trait we have to document this case explicitly and
keep the lock alive on the `winit` side instead.

[`onNativeWindowDestroyed`]: https://developer.android.com/ndk/reference/struct/a-native-activity-callbacks#onnativewindowdestroyed
@MarijnS95 MarijnS95 merged commit 472d7b9 into rust-windowing:master Jul 14, 2022
@MarijnS95 MarijnS95 deleted the android-hold-window-lock branch July 14, 2022 10:35
rib added a commit to rib/winit that referenced this pull request Aug 11, 2022
This updates the Android backend to use the android_activity create instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Aug 14, 2022
This updates the Android backend to use the android_activity create instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Aug 20, 2022
This updates the Android backend to use the android_activity create instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Aug 20, 2022
This updates the Android backend to use the android_activity create instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Aug 24, 2022
This updates the Android backend to use the android_activity create instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
a-llie pushed a commit to a-llie/winit that referenced this pull request Aug 24, 2022
Unify `with_app_id` and `with_class` methods

Both APIs are used to set application name. This commit unifies the API
between Wayland and X11, so downstream applications can remove platform
specific code when using `WindowBuilderExtUnix`.

Fixes rust-windowing#1739.

Unify behavior of `resizable` across platforms

This makes X11 and Wayland follow Windows and macOS, so the size of the
window could be set even though it has resizable attribute set to false.

Fixes rust-windowing#2242.

Fix assigning the wrong monitor when receiving Windows move events (rust-windowing#2266)

Fix embedded NULs in C wide strings returned from Windows API (rust-windowing#2264)

On Wayland, fix hiding cursors on GNOME

`wl_pointer::set_cursor` expects a serial number of the last
`wl_pointer::enter` event. However other calls expect latest
observed pointer serial, so this commit tracks both and
use them as required by specification.

Fixes rust-windowing#2273.

Bump windows-sys version to 0.36 (rust-windowing#2277)

Add new `Ime` event for desktop platforms

This commit brings new Ime event to account for preedit state of input
method, also adding `Window::set_ime_allowed` to toggle IME input on
the particular window.

This commit implements API as designed in rust-windowing#1497 for desktop platforms.

On Wayland, provide option for better CSD

While most compositors provide server side decorations, the GNOME
does not, and won't provide them. Also Wayland clients must render
client side decorations.

Winit was already drawing some decorations, however they were bad
looking and provided no text rendering, so the title was missing.
However this commit makes use of the SCTK external frame similar to
GTK's Adwaita theme supporting text rendering and looking similar to
other GTK applications.

Fixes rust-windowing#1967.

Fix warnings on nightly rust (rust-windowing#2295)

This was causing CI to fail: https://github.com/rust-windowing/winit/runs/6506026326

On macOS, emit resize event on `frame_did_change`

When the window switches mode from normal to tabbed one, it doesn't
get resized, however the frame gets resized. This commit makes
winit to track resizes when frame changes instead of window.

Fixes rust-windowing#2191.

Reorganize `EventLoopBuilder::build()` platform documentation

Since there's a "Platform-specific" header, it makes sense to put the
Linux-specific part under it. On the other hand, "Can only be called on
the main thread." is true for all platforms, not just iOS, so there is
no reason to call it out for iOS specifically.

[Windows] Avoid GetModuleHandle(NULL) (rust-windowing#2301)

Use get_instance_handle() over GetModuleHandle(NULL)

On Windows, fix reported cursor position. (rust-windowing#2311)

When clicking and moving the cursor out of the window negative coordinates were not handled correctly.

Revert "On Wayland, fix resize not propagating properly"

This reverts commit 78e5a39.

It was discovered that in some cases mesa will lock the back
buffer, e.g. when making context current, leading to resize
missing. Given that applications can restructure their rendering
to account for that, and that winit isn't limited to playing
nice with mesa reverting the original commit.

Set `WindowBuilder` to must_use

Add X11 opt-in function for device events

Previously on X11, by default all global events were broadcasted to
every winit application. This unnecessarily drains battery due to
excessive CPU usage when moving the mouse.

To resolve this, device events are now ignored by default and users must
manually opt into it using
`EventLoopWindowTarget::set_filter_device_events`.

Fixes (rust-windowing#1634) on Linux.

Prevent null dereference on X11 with bad locale

Remove old dialog fix that is superseded by rust-windowing#2027 (rust-windowing#2292)

This fixes the run_return loop never returning on macos when using multiple windows

Migrate from lazy_static to once_cell

macOS: Emit LoopDestroyed on CMD+Q (rust-windowing#2073)

override applicationWillTerminate:

On Android, use `HasRawWindowHandle` directly from the `ndk` crate (rust-windowing#2318)

The `ndk` crate now implements [`HasRawWindowHandle` directly on
`NativeWindow`], relieving the burden to reimplement it on `winit`.

[`HasRawWindowHandle` directly on `NativeWindow`]: rust-mobile/ndk#274

Run clippy on CI

Fixes rust-windowing#1402.

Make `set_device_event_filter` non-mut

Commit f10a984 added `EventLoopWindowTarget::set_device_event_filter`
with for a mutable reference, however most winit APIs work with
immutable references, so altering API to play nicely with existing APIs.

This also disables device event filtering on debug example.

Make `WindowAttributes` private (rust-windowing#2134)

* Make `WindowAttributes` private, and move its documentation

* Reorder WindowAttributes title and fullscreen to match method order

Build docs on `docs.rs` for iOS and Android as well (rust-windowing#2324)

Remove core-video-sys dependency (rust-windowing#2326)

Hasn't been updated in over 2 years - many open PRs, seems abandoned. Is the cause of several duplicate dependencies in our dependency tree!

Fix macOS 32bit (rust-windowing#2327)

Documentation cleanup (rust-windowing#2328)

* Remove redundant documentation links

* Add note to README about windows not showing up on Wayland

* Fix documentation links

* Small documentation fixes

* Add note about doing stuff after StartCause::Init on macOS

Add `WindowBuilder::transparent`

This is required to help hardware accelerated libraries like glutin
that accept WindowBuilder instead of RawWindowHandle, since the api
to access builder properties directly was removed.

Follow up to 44288f6.

Refine `Window::set_cursor_grab` API

This commit renames `Window::set_cursor_grab` to
`Window::set_cursor_grab_mode`. The new API now accepts enumeration
to control the way cursor grab is performed. The value could be: `lock`,
`confine`, or `none`.

This commit also implements `Window::set_cursor_position` for Wayland,
since it's tied to locked cursor.

Implements API from rust-windowing#1677.

examples/window_run_return: Enable on Android (rust-windowing#2321)

Android also supports `EventLoopExtRunReturn`.  The user will still have
to follow the README to turn this example into a `cdylib` and add the
`ndk_glue::main()` initialization attribute, though.

Fix doubled device events on X11

Fixes rust-windowing#2332

macOS: disallow_highdpi will set explicity the value to avoid the SO value by default (rust-windowing#2339)

ci: Disallow warnings in rustdoc and test private items (rust-windowing#2341)

Make sure `cargo doc` runs cleanly without any warnings in the CI - some
recently introduced but still allowing a PR to get merged.

In case someone wishes to add docs on private items, make sure those
adhere to the same standards.

Bump smithay-client-toolkit to v0.16.0

Disallow multiple EventLoop creation

Fix conflict in `WindowFlags` on Windows

Map XK_Caps_Lock to VirtualKeyCode::Capital (rust-windowing#1864)

This allows applications to handle events for the caps lock key under X11

Less redundancy and improve fullscreen in examples

Remove examples/minimize which is redundant

Implement From<u64> for WindowId and vise-versa

This should help downstream applications to expose WindowId to the end
users via e.g. IPC to control particular windows in multi window
systems.

examples/multiwindow.rs: ignore synthetic key press events

Fix infinite recursion in `WindowId` conversion methods

Add 'WindowEvent::Occluded(bool)'

This commits and an event to track window occlusion state,
which could help optimize rendering downstream.

Add `refresh_rate_millihertz` for `MonitorHandle`

This also alters `VideoMode::refresh_rate` to
`VideoMode::refresh_rate_millihertz` which now returns monitor refresh rate in
mHz.

On Wayland send Focused(false) for new window

On Wayland winit will always get an explicit focused event from the
system and will transfer it downstream. So send focused false to enforce
it.

On Wayland, drop wl_surface on window close

web: Manually emit focused event on mouse click (rust-windowing#2202)

* Manually emit focused event on mouse click

* Update CHANGELOG.md

Co-authored-by: Markus Røyset <maroider@protonmail.com>

web: Add `EventLoop::spawn` (rust-windowing#2208)

* web: Add `EventLoop::spawn`

This is the same as `EventLoop::run`, but doesn't throw an exception in order to return `!`.

I decided to name it `spawn` rather than `run_web` because I think that's more descriptive, but I'm happy to change it to `run_web`.

Resolves rust-windowing#1714

* Update src/platform/web.rs

* Fix outdated names

Co-authored-by: Markus Røyset <maroider@protonmail.com>

Fix changelog entry for `EventLoopExtWebSys` (rust-windowing#2372)

android: Hold `NativeWindow` lock until after notifying the user with `Event::Suspended` (rust-windowing#2307)

This applies rust-mobile/ndk#117
on the `winit` side: Android destroys its window/surface as soon as the
user returns from [`onNativeWindowDestroyed`], and we "fixed" this on
the `ndk-glue` side by sending the `WindowDestroyed` event before
locking the window and removing it: this lock has to wait for any user
of `ndk-glue` - ie. `winit` - to give up its readlock on the window,
which is what we utilize here to give users of `winit` "time" to destroy
any resource created on top of a `RawWindowHandle`.

since we can't pass the user a `RawWindowHandle` through the
`HasRawWindowHandle` trait we have to document this case explicitly and
keep the lock alive on the `winit` side instead.

[`onNativeWindowDestroyed`]: https://developer.android.com/ndk/reference/struct/a-native-activity-callbacks#onnativewindowdestroyed

web: add `with_prevent_default`, `with_focusable` (rust-windowing#2365)

* web: add `with_prevent_default`, `with_focusable`

`with_prevent_default` controls whether `event.preventDefault` is called

`with_focusable` controls whether `tabindex` is added

Fixes rust-windowing#1768

* Remove extra space from CHANGELOG

windows: Use correct value for mouse wheel delta (rust-windowing#2374)

Make winit focus take activity into account on Windows (rust-windowing#2159)

winit's notion of "focus" is very simple; you're either focused or not.
However, Windows has both notions of focused window and active window
and paying attention only to WM_SETFOCUS/WM_KILLFOCUS can cause a window
to believe the user is interacting with it when they're not. (this
manifests when a user switches to another application between when a
winit application starts and it creates its first window)

Fix typos (rust-windowing#2375)

Bump sctk-adwaita to 0.4.1

This should force the use of system libraries for Fontconfig
and freetype instead of building them with cmake if missing.

This also fixes compilation failures on nightly.

Fixes rust-windowing#2373.

Tidy up "platform-specifc" doc sections (rust-windowing#2356)

* Tidy up "platform-specific" doc sections

* Unrelated grammatical fix

* Subjective improvements

Android: avoid deadlocks while handling UserEvent (rust-windowing#2343)

Replace `Arc<Mutex<VecDeque<T>>` by `mpsc`

Update raw-window-handle to v0.5.0

This updates raw-window-handle to v0.5.0.

On macOS, fix confirmed character inserted

When confirming input in e.g. Korean IME or using characters like
`+` winit was sending those twice, once via `Ime::Commit` and the
other one via `ReceivedCharacter`, since those events weren't generating
any `Ime::Preedit` and were forwarded due to `do_command_by_selector`.

Add method to hook xlib error handler

This should help glutin to handle errors coming from GLX
and offer multithreading support in a safe way.

Fixes rust-windowing#2378.

Windows: apply skip taskbar state when taskbar is restarted (rust-windowing#2380)

Fix hiding a maximized window On Windows (rust-windowing#2336)

Bump `ndk` and `ndk-glue` dependencies to stable `0.7.0` release (rust-windowing#2392)

Fix type hint reference for xlib hook

Consistently deliver a Resumed event on all platforms

To be more consistent with mobile platforms this updates the Windows,
macOS, Wayland, X11 and Web backends to all emit a Resumed event
immediately after the initial `NewEvents(StartCause::Init)` event.

The documentation for Suspended and Resumed has also been updated
to provide general recommendations for how to handle Suspended and
Resumed events in portable applications as well as providing
Android and iOS specific details.

This consistency makes it possible to write applications that lazily
initialize their graphics state when the application resumes without
any platform-specific knowledge. Previously, applications that wanted
to run on Android and other systems would have to maintain two,
mutually-exclusive, initialization paths.

Note: This patch does nothing to guarantee that Suspended events will
be delivered. It's still reasonable to say that most OSs without a
formal lifecycle for applications will simply never "suspend" your
application. There are currently no known portability issues caused
by not delivering `Suspended` events consistently and technically
it's not possible to guarantee the delivery of `Suspended` events if
the OS doesn't define an application lifecycle. (app can always be
terminated without any kind of clean up notification on most
non-mobile OSs)

Fixes rust-windowing#2185.

ci: manually point ANDROID_NDK_ROOT to latest supplied version

It seems the symlink to `ndk-bundle` and this environment variable
pointing to it have been removed to prevent the sdkmanager from failing,
when finding the SDK setup to be in an "indeterminate" state.  It is now
up to the users themselves to install an NDK through that tool or point
the right variables to a preinstalled "latest" NDK.

actions/runner-images#2689
actions/runner-images#5926

Fix changelog entry wrt scrolling

The breaking change was put into the wrong release section.

Release 0.27.0 version

Explicitly specify minimum supported rust version

This should help with distributing apps using winit.

Fixes rust-windowing#1075.

On X11, fix crash when can't disable IME

Fixes rust-windowing#2402.

Release 0.27.1 version

Windows: respect min/max sizes when creating the window (rust-windowing#2393)

On X11, fix window hints not persisting

This commit fixes the issue with min, max, and resize increments
not persisting across the dpi changes.

Fix tracking of phase changes for mousewheel on trackpad (rust-windowing#2158)

On Windows, add opt-in function for device events (rust-windowing#2409)

Add CODEOWNERS file (rust-windowing#2420)

* Add CODEOWNERS file

This makes it very clear when you're stepping down from the post as a maintainer, and makes it clear for users who is expected to review their PR

* Fix grammar

* Make @kchibisov receive pings for the X11 platform

* Fix typo

Implement version 0.4 of the HasRawWindowHandle trait

This makes Winit 0.27 compatible with crates like Wgpu 0.13 that are
using the raw_window_handle v0.4 crate and aren't able to upgrade to 0.5
until they do a new release (since it requires a semver change).

The change is intended to be self-contained (instead of pushing
the details into all the platform_impl backends) since this is only
intended to be a temporary trait implementation for backwards
compatibility that will likely be removed before the next Winit release.

Fixes rust-windowing#2415.

Fix missleading breaking change on Windows

The applications should not rely on not-implemented behavior and
should use the right functions for that.

Remove redundant steps from CI

Tests are already building the entire crate, so no need for a
separate builds slowing down the CI.

On Wayland, fix `Window::request_redraw` being delayed

On Waylnad when asking for redraw before `MainEventsCleared`
would result for redraw being send on the next event loop tick,
which is not expectable given that it must be delivered on the same
event loop tick.

Release 0.27.2 version

On Windows, improve support for undecorated windows (rust-windowing#2419)

Add touchpad magnify and rotate gestures support for macOS (rust-windowing#2157)

* Add touchpad magnify support for macOS

* Add touchpad rotate support for macOS

* Add macOS rotate and magnify gesture cancelled phases

* Correct docs for TouchpadRotate event

* Fix tracing macros

Document `WindowEvent::Moved` as unsupported on Wayland

Update `sctk-adwaita` to use `ab_glyph`

The crossfont will still be available under the option.

Mark new events as breaking change

Adding a new enum variant is a breaking change in winit.

Co-Authored-By: kas <exactly-one-kas@users.noreply.github.com>
Co-Authored-By: Artur Kovacs <kovacs.artur.barnabas@gmail.com>
Co-Authored-By: Markus Siglreithmaier <m.siglreith@gmail.com>
Co-Authored-By: Murarth <murarth@gmail.com>
Co-Authored-By: Yusuke Kominami <yukke.konan@gmail.com>
Co-Authored-By: moko256 <koutaro.mo@gmail.com>
Co-Authored-By: Mads Marquart <mads@marquart.dk>
Co-Authored-By: Markus Røyset <maroider@protonmail.com>
Co-Authored-By: Marijn Suijten <marijns95@gmail.com>
Co-Authored-By: Kirill Chibisov <contact@kchibisov.com>
rib added a commit to rib/winit that referenced this pull request Aug 26, 2022
This updates the Android backend to use the android_activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Aug 31, 2022
This updates the Android backend to use the android_activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Aug 31, 2022
This updates the Android backend to use the android_activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Sep 17, 2022
This updates the Android backend to use the android_activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Sep 17, 2022
This updates the Android backend to use the android_activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Sep 18, 2022
This updates the Android backend to use the android_activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Sep 20, 2022
This updates the Android backend to use the android_activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Sep 20, 2022
This updates the Android backend to use the android_activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Oct 19, 2022
This updates the Android backend to use the android_activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Oct 19, 2022
This updates the Android backend to use the android_activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Oct 19, 2022
This updates the Android backend to use the android-activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

To make it possible for application crates to avoid explicitly
depending on the `android-activity` crate (and avoid version conflicts)
this re-exports the android-activity crate under:

  `winit::platform::android::activity::*`

This also adds `android-native-activity` and `android-game-activity`
features that set the corresponding android-activity features.

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Oct 22, 2022
This updates the Android backend to use the android-activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

To make it possible for application crates to avoid explicitly
depending on the `android-activity` crate (and avoid version conflicts)
this re-exports the android-activity crate under:

  `winit::platform::android::activity::*`

This also adds `android-native-activity` and `android-game-activity`
features that set the corresponding android-activity features.

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Oct 26, 2022
This updates the Android backend to use the android-activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

To make it possible for application crates to avoid explicitly
depending on the `android-activity` crate (and avoid version conflicts)
this re-exports the android-activity crate under:

  `winit::platform::android::activity::*`

This also adds `android-native-activity` and `android-game-activity`
features that set the corresponding android-activity features.

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Oct 28, 2022
This updates the Android backend to use the android-activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

To make it possible for application crates to avoid explicitly
depending on the `android-activity` crate (and avoid version conflicts)
this re-exports the android-activity crate under:

  `winit::platform::android::activity::*`

This also adds `android-native-activity` and `android-game-activity`
features that set the corresponding android-activity features.

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Nov 7, 2022
This updates the Android backend to use the android-activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

To make it possible for application crates to avoid explicitly
depending on the `android-activity` crate (and avoid version conflicts)
this re-exports the android-activity crate under:

  `winit::platform::android::activity::*`

This also adds `android-native-activity` and `android-game-activity`
features that set the corresponding android-activity features.

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299

Co-authored-by: Markus Siglreithmaier <m.siglreith@gmail.com>
msiglreith added a commit that referenced this pull request Nov 10, 2022
This updates the Android backend to use the android-activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves #2299)

To make it possible for application crates to avoid explicitly
depending on the `android-activity` crate (and avoid version conflicts)
this re-exports the android-activity crate under:

  `winit::platform::android::activity::*`

This also adds `android-native-activity` and `android-game-activity`
features that set the corresponding android-activity features.

Addresses: PR #1892
Addresses: PR #2307
Addresses: PR #2343

Addresses: #2293
Resolves: #2299

Co-authored-by: Markus Siglreithmaier <m.siglreith@gmail.com>

Co-authored-by: Markus Siglreithmaier <m.siglreith@gmail.com>
rib added a commit to rib/winit that referenced this pull request Nov 29, 2022
This updates the Android backend to use the android_activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299
rib added a commit to rib/winit that referenced this pull request Nov 29, 2022
This updates the Android backend to use the android-activity crate instead
of ndk-glue. This solves a few issues:
1. The backend is agnostic of the application's choice of Activity base
   class
2. Winit is no longer responsible for handling any Java synchronization
   details, since these are encapsulated by the design of
   android_activity
3. The backend no longer depends on global / static getters for state
   such as the native_window() which puts it in a better position to
   support running multiple activities within a single Android process.
4. Redraw requests are flagged, not queued, in a way that avoids taking
   priority over user events (resolves rust-windowing#2299)

To make it possible for application crates to avoid explicitly
depending on the `android-activity` crate (and avoid version conflicts)
this re-exports the android-activity crate under:

  `winit::platform::android::activity::*`

This also adds `android-native-activity` and `android-game-activity`
features that set the corresponding android-activity features.

Addresses: PR rust-windowing#1892
Addresses: PR rust-windowing#2307
Addresses: PR rust-windowing#2343

Addresses: rust-windowing#2293
Resolves: rust-windowing#2299

Co-authored-by: Markus Siglreithmaier <m.siglreith@gmail.com>
@maciejgodek
Copy link

#1892 author here, glad this got fixed eventually! Apologies for abandoning the PR, my priorities changed for a while. :)

@MarijnS95
Copy link
Member Author

@maciejgodek no worries, I think this code even ended up being replaced with a completely different android-activity backend now. Feel free to close the PR to that effect though, as there's nothing actionable anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C - needs discussion Direction must be ironed out D - hard Likely harder than most tasks here DS - android I - BLOCKING RELEASE Prevents a new release
Development

Successfully merging this pull request may close these issues.

None yet

4 participants