Skip to content

Commit a75d1ca

Browse files
committed
fix: Don't use trait-alias
1 parent f0e4f12 commit a75d1ca

File tree

6 files changed

+16
-40
lines changed

6 files changed

+16
-40
lines changed

Cargo.toml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
[workspace]
2-
members = [
3-
".",
4-
"xim-ctext",
5-
"xim-gen",
6-
"xim-parser",
7-
]
2+
members = [".", "xim-ctext", "xim-gen", "xim-parser"]
83

94
[package]
105
name = "xim"
@@ -42,11 +37,13 @@ server = []
4237
xim-parser = { path = "./xim-parser", version = "0.2.0", default-features = false }
4338
xim-ctext = { path = "./xim-ctext", version = "0.3.0", default-features = false }
4439
log = { version = "0.4", default-features = false }
45-
ahash = { version = "0.8", default-features = false, features = ["compile-time-rng"] }
40+
ahash = { version = "0.8", default-features = false, features = [
41+
"compile-time-rng",
42+
] }
4643

4744
x11rb = { version = "0.13", optional = true }
4845
x11-dl = { version = "2.18.5", optional = true }
49-
hashbrown = { version = "0.14.0", default-features = false }
46+
hashbrown = { version = "0.16.0", default-features = false }
5047

5148
[[example]]
5249
name = "x11rb_client"

examples/util/handler.rs

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::convert::TryInto;
22

3-
use xim::{AHashMap, Client, ClientError, ClientHandler};
3+
use xim::{AHashMap, Client, ClientCore, ClientError, ClientHandler};
44
use xim_parser::{AttributeName, InputStyle, Point};
55

66
#[derive(Default)]
@@ -11,16 +11,7 @@ pub struct ExampleHandler {
1111
pub window: u32,
1212
}
1313

14-
#[cfg(all(feature = "x11rb-client", not(feature = "xlib-client")))]
15-
trait ClientAlias = Client<XEvent = x11rb::protocol::xproto::KeyPressEvent>;
16-
17-
#[cfg(all(feature = "xlib-client", not(feature = "x11rb-client")))]
18-
trait ClientAlias = Client<XEvent = x11_dl::xlib::XKeyPressedEvent>;
19-
20-
#[cfg(all(feature = "xlib-client", feature = "x11rb-client"))]
21-
trait ClientAlias = Client;
22-
23-
impl<C: ClientAlias> ClientHandler<C> for ExampleHandler {
14+
impl<T, C: Client<XEvent = T> + ClientCore<XEvent = T>> ClientHandler<C> for ExampleHandler {
2415
fn handle_connect(&mut self, client: &mut C) -> Result<(), ClientError> {
2516
log::trace!("Connected");
2617
client.open("en_US")
@@ -68,23 +59,15 @@ impl<C: ClientAlias> ClientHandler<C> for ExampleHandler {
6859

6960
fn handle_forward_event(
7061
&mut self,
71-
_client: &mut C,
62+
client: &mut C,
7263
_input_method_id: u16,
7364
_input_context_id: u16,
7465
flag: xim::ForwardEventFlag,
75-
xev: C::XEvent,
66+
xev: T,
7667
) -> Result<(), ClientError> {
77-
#[cfg(all(feature = "x11rb-client", not(feature = "xlib-client")))]
78-
let keycode = xev.detail;
79-
#[cfg(all(feature = "xlib-client", not(feature = "x11rb-client")))]
80-
let keycode = xev.keycode;
81-
82-
// When both feature are enabled, emit flag only.
83-
#[cfg(all(feature = "xlib-client", feature = "x11rb-client"))]
84-
log::info!("Handle forward event {:?}", flag);
68+
let xev = client.serialize_event(&xev);
69+
log::info!("Handle forward event {:?}, {}", flag, xev.detail);
8570

86-
#[cfg(not(all(feature = "xlib-client", feature = "x11rb-client")))]
87-
log::info!("Handle forward event {:?}, {}", flag, keycode);
8871
Ok(())
8972
}
9073

examples/x11rb_client.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(trait_alias)]
2-
31
use x11rb::connection::Connection;
42
use x11rb::protocol::{xproto::*, Event};
53
use xim::{x11rb::X11rbClient, Client};

examples/xlib_client.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(trait_alias)]
2-
31
use std::{mem::MaybeUninit, ptr};
42
use x11_dl::xlib;
53
use xim::{xlib::XlibClient, Client};

src/client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,8 @@ pub trait ClientCore {
277277
pub trait Client {
278278
type XEvent;
279279

280-
fn build_ic_attributes(&self) -> AttributeBuilder;
281-
fn build_im_attributes(&self) -> AttributeBuilder;
280+
fn build_ic_attributes(&'_ self) -> AttributeBuilder<'_>;
281+
fn build_im_attributes(&'_ self) -> AttributeBuilder<'_>;
282282

283283
fn disconnect(&mut self) -> Result<(), ClientError>;
284284
fn open(&mut self, locale: &str) -> Result<(), ClientError>;
@@ -331,11 +331,11 @@ where
331331
{
332332
type XEvent = C::XEvent;
333333

334-
fn build_ic_attributes(&self) -> AttributeBuilder {
334+
fn build_ic_attributes(&'_ self) -> AttributeBuilder<'_> {
335335
AttributeBuilder::new(self.ic_attributes())
336336
}
337337

338-
fn build_im_attributes(&self) -> AttributeBuilder {
338+
fn build_im_attributes(&'_ self) -> AttributeBuilder<'_> {
339339
AttributeBuilder::new(self.im_attributes())
340340
}
341341

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub mod x11rb;
4141
pub mod xlib;
4242

4343
#[cfg(feature = "client")]
44-
pub use crate::client::{Client, ClientError, ClientHandler};
44+
pub use crate::client::{Client, ClientCore, ClientError, ClientHandler};
4545

4646
#[cfg(feature = "server")]
4747
pub const ALL_LOCALES: &str = include_str!("./all_locales.txt");

0 commit comments

Comments
 (0)