Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,549 changes: 1,962 additions & 1,587 deletions Cargo.lock

Large diffs are not rendered by default.

17 changes: 13 additions & 4 deletions deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ allow = [
"Zlib",
"ISC",
"BSL-1.0",
"GPL-3.0",
"MPL-2.0",
"Unicode-DFS-2016",
"Unicode-3.0",
"OFL-1.1",
"LicenseRef-UFL-1.0",
"Unlicense",
"NCSA",
]
# List of explicitly disallowed licenses
# See https://spdx.org/licenses/ for list of possible licenses
Expand Down Expand Up @@ -123,6 +124,15 @@ exceptions = [
# Some crates don't have (easily) machine readable licensing information,
# adding a clarification entry for it allows you to manually specify the
# licensing information

# epaint_default_fonts uses "Ubuntu-font-1.0" which isn't a standard SPDX identifier
# The actual licenses are MIT OR Apache-2.0 for code, OFL-1.1 for fonts
[[licenses.clarify]]
name = "epaint_default_fonts"
version = "*"
expression = "(MIT OR Apache-2.0) AND OFL-1.1"
license-files = []

#[[licenses.clarify]]
# The name of the crate the clarification applies to
#name = "ring"
Expand Down Expand Up @@ -187,7 +197,6 @@ skip = [
# dependencies starting at the specified crate, up to a certain depth, which is
# by default infinite
skip-tree = [
{ name = "criterion", version = "=0.3.5" }
]

# This section is considered when running `cargo deny check sources`.
Expand All @@ -212,4 +221,4 @@ github = []
# 1 or more gitlab.com organizations to allow git sources for
gitlab = []
# 1 or more bitbucket.org organizations to allow git sources for
bitbucket = []
bitbucket = []
9 changes: 9 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
* feat(engine): Let default `Alt_R` hotkey accept `Alt` modifier [#719](https://github.com/Riey/kime/719)
* Add Opensuse Build Service repository and modify README
* fix(xim): handle None from from_hardware_code without panic [#721](https://github.com/Riey/kime/721)
* Update dependencies:
- bitflags 2.10, nix 0.30, strum 0.27
- x11rb 0.13, xim 0.5, image 0.25, imageproc 0.25
- mio 1.0 with timerfd-mio
- egui/eframe 0.33
- Replace rusttype with ab_glyph
- Replace ansi_term with owo-colors
- Replace daemonize with nix daemon
- Replace unic with unicode-properties

## 3.1.1

Expand Down
2 changes: 1 addition & 1 deletion src/engine/dict/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ serde = {version = "1.0.118", features = ["derive"]}
serde_json = "1.0"
itertools = "0.13.0"
quick-xml = { version = "0.27.1", features = ["encoding"] }
unic = "0.9.0"
unicode-properties = { version = "0.1", features = ["emoji"] }
4 changes: 2 additions & 2 deletions src/engine/dict/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::{
mem,
path::PathBuf,
};
use unic::emoji::char::is_emoji;
use unicode_properties::UnicodeEmoji;

#[derive(Default, Debug, Clone, Copy)]
struct HanjaEntry {
Expand Down Expand Up @@ -204,7 +204,7 @@ fn main() {
)
.unwrap();
for entry in load_unicode_annotations().unwrap() {
if !entry.cp.chars().any(|c| is_emoji(c)) {
if !entry.cp.chars().any(|c| c.is_emoji_char()) {
continue;
}

Expand Down
4 changes: 2 additions & 2 deletions src/frontends/wayland/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ xkbcommon = { version = "0.7.0", features = ["wayland"] }
libc = "0.2"
log = "0.4"
pico-args = "0.5"
mio = { version = "0.7", features = ["os-ext"] }
mio-timerfd = "0.2"
mio = { version = "1.0", features = ["os-ext"] }
timerfd-mio = "0.1"
20 changes: 11 additions & 9 deletions src/frontends/wayland/src/input_method_v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use wayland_protocols::unstable::input_method::v1::client::{
};

use mio::{unix::SourceFd, Events as MioEvents, Interest, Poll, Token};
use mio_timerfd::{ClockId, TimerFd};
use timerfd_mio::TimerFd;
use wayland_client::protocol::wl_keyboard::KeymapFormat;
use xkbcommon::xkb::{
Context, Keycode, Keymap, CONTEXT_NO_FLAGS, KEYMAP_COMPILE_NO_FLAGS, KEYMAP_FORMAT_TEXT_V1,
Expand Down Expand Up @@ -205,7 +205,7 @@ impl KimeContext {
if !press_state.is_pressing(key) =>
{
let duration = Duration::from_millis(info.delay as u64);
if let Err(e) = self.timer.set_timeout(&duration) {
if let Err(e) = self.timer.set_timeout_oneshot(duration) {
log::warn!("failed to set repeat timer: {}", e);
}
*press_state = PressState::Pressing {
Expand All @@ -228,9 +228,7 @@ impl KimeContext {
} else {
if let Some((.., ref mut press_state)) = self.repeat_state {
if press_state.is_pressing(key) {
if let Err(e) = self.timer.disarm() {
log::warn!("failed to disarm timer: {}", e);
}
let _ = self.timer.set_timeout_oneshot(Duration::ZERO);
*press_state = PressState::NotPressing;
}
}
Expand Down Expand Up @@ -287,6 +285,10 @@ impl KimeContext {
pub fn handle_timer_ev(&mut self) -> std::io::Result<()> {
// Read timer, this MUST be called or timer will be broken
let overrun_count = self.timer.read()?;
if overrun_count == 0 {
// Non-blocking read returned no expirations, skip processing
return Ok(());
}
if overrun_count != 1 {
log::warn!("Some timer events were not properly handled!");
}
Expand All @@ -309,8 +311,8 @@ impl KimeContext {
{
// Start repeat
log::trace!("Start repeating {}", key);
let interval = &Duration::from_secs_f64(1.0 / info.rate as f64);
self.timer.set_timeout_interval(interval)?;
let interval = Duration::from_secs_f64(1.0 / info.rate as f64);
self.timer.set_timeout_interval(interval, interval)?;
*is_repeating = true;
}
}
Expand Down Expand Up @@ -368,7 +370,7 @@ impl KimeContext {
self.grab_activate = false;

// Input deactivated, stop repeating
self.timer.disarm().unwrap();
let _ = self.timer.set_timeout_oneshot(Duration::ZERO);
if let Some((_, ref mut press_state)) = self.repeat_state {
*press_state = PressState::NotPressing
}
Expand Down Expand Up @@ -412,7 +414,7 @@ pub fn run(
let im = globals.instantiate_exact::<ZwpInputMethodV1>(1)?;
im.assign(im_filter);

let mut timer = TimerFd::new(ClockId::Monotonic).expect("Initialize timer");
let mut timer = TimerFd::new().expect("Initialize timer");

let mut poll = Poll::new().expect("Initialize epoll()");
let registry = poll.registry();
Expand Down
20 changes: 11 additions & 9 deletions src/frontends/wayland/src/input_method_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use zwp_virtual_keyboard::virtual_keyboard_unstable_v1::{
};

use mio::{unix::SourceFd, Events as MioEvents, Interest, Poll, Token};
use mio_timerfd::{ClockId, TimerFd};
use timerfd_mio::TimerFd;

use crate::{PressState, RepeatInfo};

Expand Down Expand Up @@ -192,7 +192,7 @@ impl KimeContext {
self.grab_activate = false;

// Input deactivated, stop repeating
self.timer.disarm().unwrap();
let _ = self.timer.set_timeout_oneshot(Duration::ZERO);
if let Some((_, ref mut press_state)) = self.repeat_state {
*press_state = PressState::NotPressing
}
Expand Down Expand Up @@ -241,7 +241,7 @@ impl KimeContext {
if !press_state.is_pressing(key) =>
{
let duration = Duration::from_millis(info.delay as u64);
if let Err(e) = self.timer.set_timeout(&duration) {
if let Err(e) = self.timer.set_timeout_oneshot(duration) {
log::warn!("failed to set repeat timer: {}", e);
}
*press_state = PressState::Pressing {
Expand All @@ -267,9 +267,7 @@ impl KimeContext {
// If user released the last pressed key, clear the timer and state
if let Some((.., ref mut press_state)) = self.repeat_state {
if press_state.is_pressing(key) {
if let Err(e) = self.timer.disarm() {
log::warn!("failed to disarm timer: {}", e);
}
let _ = self.timer.set_timeout_oneshot(Duration::ZERO);
*press_state = PressState::NotPressing;
}
}
Expand Down Expand Up @@ -323,6 +321,10 @@ impl KimeContext {
pub fn handle_timer_ev(&mut self) -> std::io::Result<()> {
// Read timer, this MUST be called or timer will be broken
let overrun_count = self.timer.read()?;
if overrun_count == 0 {
// Non-blocking read returned no expirations, skip processing
return Ok(());
}
if overrun_count != 1 {
log::warn!("Some timer events were not properly handled!");
}
Expand All @@ -340,8 +342,8 @@ impl KimeContext {
if !*is_repeating {
// Start repeat
log::trace!("Start repeating {}", key);
let interval = &Duration::from_secs_f64(1.0 / info.rate as f64);
self.timer.set_timeout_interval(interval)?;
let interval = Duration::from_secs_f64(1.0 / info.rate as f64);
self.timer.set_timeout_interval(interval, interval)?;
*is_repeating = true;
}

Expand Down Expand Up @@ -390,7 +392,7 @@ pub fn run(
im.assign(filter);

// Initialize timer
let mut timer = TimerFd::new(ClockId::Monotonic).expect("Initialize timer");
let mut timer = TimerFd::new().expect("Initialize timer");

// Initialize epoll() object
let mut poll = Poll::new().expect("Initialize epoll()");
Expand Down
3 changes: 2 additions & 1 deletion src/frontends/wayland/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ fn main() {

let result = kime_wayland::input_method_v2::run(&display, &mut event_queue, &globals);

if let Err(_) = result {
if let Err(e) = result {
log::warn!("input_method_v2 failed: {}, trying v1", e);
kime_wayland::input_method_v1::run(&display, &mut event_queue, &globals).unwrap();
}
}
10 changes: 5 additions & 5 deletions src/frontends/xim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ license = "GPL-3.0-or-later"
kime-engine-core = { path = "../../engine/core" }
kime-version = { path = "../../tools/version" }

xim = { version = "0.2", default-features = false, features = ["x11rb-server"] }
xim = { version = "0.5", default-features = false, features = ["x11rb-server"] }
# xim = { path = "../../../../xim-rs", default-features = false, features = ["x11rb-server", "x11rb-xcb"] }

ahash = "0.8"
log = "0.4"
x11rb = { version = "0.11.0", features = [
x11rb = { version = "0.13", features = [
"render",
"image",
], default-features = false }
pico-args = "0.5.0"
image = "0.24"
imageproc = "0.23"
rusttype = "0.9.2"
image = { version = "0.25", default-features = false, features = ["png"] }
imageproc = { version = "0.25", default-features = false }
ab_glyph = "0.2"
12 changes: 5 additions & 7 deletions src/frontends/xim/src/handler.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{num::NonZeroU32, sync::Arc};
use std::num::NonZeroU32;

use crate::pe_window::PeWindow;
use ab_glyph::{FontArc, FontVec};
use ahash::AHashMap;
use kime_engine_core::{Config, InputEngine, InputResult, Key, KeyCode, ModifierState};
use x11rb::{
Expand Down Expand Up @@ -32,19 +33,16 @@ impl KimeData {

pub struct KimeHandler {
preedit_windows: AHashMap<NonZeroU32, PeWindow>,
font: (Arc<rusttype::Font<'static>>, f32),
font: (FontArc, f32),
config: Config,
screen_num: usize,
}

impl KimeHandler {
pub fn new(screen_num: usize, config: Config) -> Self {
let (font_data, index, font_size) = &config.xim_preedit_font;
let font = Arc::new(
rusttype::Font::try_from_vec_and_index(font_data.clone(), *index)
.unwrap()
.to_owned(),
);
let font_vec = FontVec::try_from_vec_and_index(font_data.clone(), *index).unwrap();
let font = FontArc::from(font_vec);

Self {
preedit_windows: AHashMap::new(),
Expand Down
12 changes: 6 additions & 6 deletions src/frontends/xim/src/pe_window.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
mod bgra;

use bgra::Bgra;
use std::{num::NonZeroU32, sync::Arc};
use std::num::NonZeroU32;

use ab_glyph::{FontArc, PxScale};
use image::ImageBuffer;
use rusttype::Font;
use x11rb::{
connection::Connection,
protocol::xproto::{
Expand All @@ -19,15 +19,15 @@ pub struct PeWindow {
preedit: String,
gc: u32,
text_pos: (u32, u32),
text_scale: rusttype::Scale,
font: Arc<Font<'static>>,
text_scale: PxScale,
font: FontArc,
image_buffer: ImageBuffer<Bgra, Vec<u8>>,
}

impl PeWindow {
pub fn new(
conn: &impl Connection,
(font, font_size): (Arc<Font<'static>>, f32),
(font, font_size): (FontArc, f32),
app_win: Option<NonZeroU32>,
spot_location: xim::Point,
screen_num: usize,
Expand Down Expand Up @@ -102,7 +102,7 @@ impl PeWindow {
gc,
font,
text_pos: ((font_size * 0.36) as _, (font_size * 0.36) as _),
text_scale: rusttype::Scale::uniform(font_size as f32),
text_scale: PxScale::from(font_size),
image_buffer: ImageBuffer::new(size.0 as _, size.1 as _),
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/tools/candidate-window/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ license = "GPL-3.0-or-later"

[dependencies]
kime-engine-core = { path = "../../engine/core" }
eframe = "0.20.1"
egui = "0.20.1"
eframe = { version = "0.31", default-features = false, features = ["glow", "default_fonts", "wayland", "x11"] }
egui = "0.31"
Loading
Loading