diff --git a/patches/core_editor.patch b/patches/core_editor.patch new file mode 100644 index 00000000..02400bd6 --- /dev/null +++ b/patches/core_editor.patch @@ -0,0 +1,13 @@ +--- iced-o/core/src/text/editor.rs 2025-04-23 13:38:47.083332287 +0200 ++++ iced/core/src/text/editor.rs 2025-04-23 13:49:57.361597749 +0200 +@@ -88,6 +88,10 @@ + /// The amount of lines to scroll. + lines: i32, + }, ++ /// Editor gained focus ++ Focus, ++ /// Editor lost focus ++ Blur, + } + + impl Action { diff --git a/patches/editor.patch b/patches/editor.patch new file mode 100644 index 00000000..cd9c0092 --- /dev/null +++ b/patches/editor.patch @@ -0,0 +1,67 @@ +--- iced-o/widget/src/text_editor.rs 2025-04-23 13:38:47.123616714 +0200 ++++ iced/widget/src/text_editor.rs 2025-04-23 13:59:09.467473938 +0200 +@@ -43,6 +43,7 @@ + use crate::core::text::highlighter::{self, Highlighter}; + use crate::core::text::{self, LineHeight, Text, Wrapping}; + use crate::core::time::{Duration, Instant}; ++use crate::core::touch; + use crate::core::widget::operation; + use crate::core::widget::{self, Widget}; + use crate::core::window; +@@ -719,6 +720,10 @@ + mouse::click::Kind::Triple => Action::SelectLine, + }; + ++ if !state.is_focused() { ++ shell.publish(on_edit(Action::Focus)); ++ } ++ + state.focus = Some(Focus::now()); + state.last_click = Some(click); + state.drag_click = Some(click.kind()); +@@ -789,6 +794,7 @@ + Binding::Unfocus => { + state.focus = None; + state.drag_click = None; ++ shell.publish(on_edit(Action::Blur)); + } + Binding::Copy => { + if let Some(selection) = content.selection() { +@@ -1294,6 +1300,37 @@ + Some(Update::InputMethod(Ime::Commit(content.clone()))) + } + _ => None, ++ }, ++ Event::Touch(event) => match event { ++ touch::Event::FingerPressed { .. } => { ++ if let Some(cursor_position) = cursor.position_in(bounds) { ++ let cursor_position = cursor_position ++ - Vector::new(padding.top, padding.left); ++ ++ let click = mouse::Click::new( ++ cursor_position, ++ mouse::Button::Left, ++ state.last_click, ++ ); ++ ++ Some(Update::Click(click)) ++ } else if state.focus.is_some() { ++ binding(Binding::Unfocus) ++ } else { ++ None ++ } ++ } ++ touch::Event::FingerLifted { .. } ++ | touch::Event::FingerLost { .. } => Some(Update::Release), ++ touch::Event::FingerMoved { .. } => match state.drag_click { ++ Some(mouse::click::Kind::Single) => { ++ let cursor_position = cursor.position_in(bounds)? ++ - Vector::new(padding.top, padding.left); ++ ++ Some(Update::Drag(cursor_position)) ++ } ++ _ => None, ++ }, + }, + Event::Keyboard(keyboard::Event::KeyPressed { + key, diff --git a/patches/graphics_editor.patch b/patches/graphics_editor.patch new file mode 100644 index 00000000..80ac2ecd --- /dev/null +++ b/patches/graphics_editor.patch @@ -0,0 +1,11 @@ +--- iced-o/graphics/src/text/editor.rs 2025-04-23 13:38:47.116236834 +0200 ++++ iced/graphics/src/text/editor.rs 2025-04-23 13:52:25.065135072 +0200 +@@ -438,6 +438,8 @@ + cosmic_text::Action::Scroll { lines }, + ); + } ++ // Do nothing, these are for user convenience only ++ Action::Focus | Action::Blur => {} + } + + self.0 = Some(Arc::new(internal)); diff --git a/patches/iced_winit.patch b/patches/iced_winit.patch new file mode 100644 index 00000000..2ddc0d12 --- /dev/null +++ b/patches/iced_winit.patch @@ -0,0 +1,55 @@ +--- iced-o/winit/src/conversion.rs 2025-04-23 13:38:47.125962653 +0200 ++++ iced/winit/src/conversion.rs 2025-04-23 13:42:51.660061924 +0200 +@@ -203,13 +203,19 @@ + WindowEvent::KeyboardInput { is_synthetic, .. } if is_synthetic => None, + WindowEvent::KeyboardInput { event, .. } => Some(Event::Keyboard({ + let key = { +- #[cfg(not(target_arch = "wasm32"))] ++ #[cfg(not(any( ++ target_arch = "wasm32", ++ target_os = "android", ++ )))] + { + use winit::platform::modifier_supplement::KeyEventExtModifierSupplement; + event.key_without_modifiers() + } + +- #[cfg(target_arch = "wasm32")] ++ #[cfg(any( ++ target_arch = "wasm32", ++ target_os = "android", ++ ))] + { + // TODO: Fix inconsistent API on Wasm + event.logical_key.clone() +@@ -217,7 +223,10 @@ + }; + + let text = { +- #[cfg(not(target_arch = "wasm32"))] ++ #[cfg(not(any( ++ target_arch = "wasm32", ++ target_os = "android", ++ )))] + { + use crate::core::SmolStr; + use winit::platform::modifier_supplement::KeyEventExtModifierSupplement; +@@ -225,6 +234,18 @@ + event.text_with_all_modifiers().map(SmolStr::new) + } + ++ #[cfg(target_os = "android")] ++ { ++ if event.text.is_some() { ++ event.text ++ } else { ++ match &key { ++ winit::keyboard::Key::Character(c) => Some(c.clone()), ++ _ => None, ++ } ++ } ++ } ++ + #[cfg(target_arch = "wasm32")] + { + // TODO: Fix inconsistent API on Wasm diff --git a/patches/text.patch b/patches/text.patch new file mode 100644 index 00000000..2df4da5d --- /dev/null +++ b/patches/text.patch @@ -0,0 +1,43 @@ +--- iced-o/graphics/src/text.rs 2025-04-23 13:38:47.115625021 +0200 ++++ iced/graphics/src/text.rs 2025-04-23 13:55:27.658385184 +0200 +@@ -159,16 +159,31 @@ + static FONT_SYSTEM: OnceLock> = OnceLock::new(); + + FONT_SYSTEM.get_or_init(|| { ++ #[allow(unused_mut)] ++ let mut raw = cosmic_text::FontSystem::new_with_fonts([ ++ cosmic_text::fontdb::Source::Binary(Arc::new( ++ include_bytes!("../fonts/Iced-Icons.ttf").as_slice(), ++ )), ++ #[cfg(all(target_arch = "wasm32", feature = "fira-sans"))] ++ cosmic_text::fontdb::Source::Binary(Arc::new( ++ include_bytes!("../fonts/FiraSans-Regular.ttf").as_slice(), ++ )), ++ ]); ++ ++ // Load system fonts for Android ++ // https://github.com/pop-os/cosmic-text/issues/243#issue-2189977938 ++ #[cfg(target_os = "android")] ++ { ++ raw.db_mut().load_fonts_dir("/system/fonts"); ++ raw.db_mut().set_sans_serif_family("Roboto"); ++ raw.db_mut().set_serif_family("Noto Serif"); ++ raw.db_mut().set_monospace_family("Droid Sans Mono"); // Cutive Mono looks more printer-like ++ raw.db_mut().set_cursive_family("Dancing Script"); ++ raw.db_mut().set_fantasy_family("Dancing Script"); ++ } ++ + RwLock::new(FontSystem { +- raw: cosmic_text::FontSystem::new_with_fonts([ +- cosmic_text::fontdb::Source::Binary(Arc::new( +- include_bytes!("../fonts/Iced-Icons.ttf").as_slice(), +- )), +- #[cfg(feature = "fira-sans")] +- cosmic_text::fontdb::Source::Binary(Arc::new( +- include_bytes!("../fonts/FiraSans-Regular.ttf").as_slice(), +- )), +- ]), ++ raw, + loaded_fonts: HashSet::new(), + version: Version::default(), + })