11use std:: convert:: TryInto ;
22
3- use xim:: { AHashMap , Client , ClientError , ClientHandler } ;
3+ use xim:: { AHashMap , Client , ClientCore , ClientError , ClientHandler } ;
44use 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
0 commit comments