add patches

This commit is contained in:
Your Name 2025-05-15 01:55:02 +02:00
parent a6f4b5ac0a
commit 0ee56eecfb
5 changed files with 189 additions and 0 deletions

13
patches/core_editor.patch Normal file
View file

@ -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 {

67
patches/editor.patch Normal file
View file

@ -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,

View file

@ -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));

55
patches/iced_winit.patch Normal file
View file

@ -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

43
patches/text.patch Normal file
View file

@ -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<RwLock<FontSystem>> = 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(),
})