Skip to content

Expose underlying mobile support from winit via cfg changes #2952

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

markkimsal
Copy link

I understand mobile support is not a priority, and possibly even a detriment if it attracts more spurious bug reports. But, with just 6 lines of code changes iced can expose underling winit android support. This goes a long way to closing #302 with no ongoing maintenance from iced core team.

4 lines are cfg changes that more closely align with the underlying winit library

--- a/winit/src/conversion.rs
+++ b/winit/src/conversion.rs
@@ -203,13 +203,25 @@ pub fn window_event(
         WindowEvent::KeyboardInput { is_synthetic, .. } if is_synthetic => None,
         WindowEvent::KeyboardInput { event, .. } => Some(Event::Keyboard({
             let key = {
-                #[cfg(not(target_arch = "wasm32"))]
+                #[cfg(any(
+                    target_os="windows",
+                    target_os="macos",
+                    all(feature = "x11", all(unix, not(any(target_os = "ios", target_os = "macos")), not(target_os = "android"), not(target_os = "emscripten")), not(target_os = "redox")),
+                    all(feature = "wayland", all(unix, not(any(target_os = "ios", target_os = "macos")), not(target_os = "android"), not(target_os = "emscripten")), not(target_os = "redox")),
+                    target_os="redox",
+                ))]

Checking only for wasm32 let's unsupported platforms slip through the feature gate of KeyEventExtModifierSupplement, because the underlying core winit library uses a different set of platform checks.

This will allow more platform support transparently by matching the cfg of the underlying winit library.

winit 0.31 plans to remove config aliases in favor of raw cfg macros. rust-windowing/winit#3539

Lastly, re-exporting 2 winit features into the iced_winit workspace Cargo allows the underlying winit + android-activity to build when targeting aarch64-linux-android

--- a/winit/Cargo.toml
+++ b/winit/Cargo.toml
@@ -22,6 +22,8 @@ x11 = ["winit/x11"]
 wayland = ["winit/wayland"]
 wayland-dlopen = ["winit/wayland-dlopen"]
 wayland-csd-adwaita = ["winit/wayland-csd-adwaita"]
+android-native-activity = ["winit/android-native-activity"]
+android-game-activity = ["winit/android-game-activity"]
 unconditional-rendering = []

There are all the changes to allow successful building on android - fonts don't work, but that is another small pr.

Checking only for wasm32 let's unsupported platforms slip through the
feature gate of KeyEventExtModifierSupplement, because the underlying
core winit library uses a different set of platform checks.

This will allow more platform support transparently by matching the
cfg of the underlying winit librayr.

winit 0.31 plans to remove config aliases in favor of raw cfg macros.
Core winit allows for android-native-activity and android-game-activity
via the android-activity library.  This change exposes those features
already present in winit to the iced_winit workspace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant