11use crate :: WindowError ;
2- use libc:: c_ulong;
32use raw_window_handle:: XlibDisplayHandle ;
43use std:: {
54 cell:: RefCell ,
65 collections:: HashMap ,
76 ffi:: CStr ,
87 marker:: PhantomData ,
98 mem:: zeroed,
10- os:: raw:: c_int,
9+ os:: raw:: { c_char , c_int, c_ulong } ,
1110 ptr:: { NonNull , null, null_mut} ,
1211 str:: FromStr ,
1312 sync:: { LazyLock , Mutex } ,
@@ -28,8 +27,6 @@ use x11::{
2827 } ,
2928} ;
3029
31- pub const ATOM_PICOVIEW_WAKEUP : & CStr = c"PICOVIEW_WAKEUP" ;
32-
3330unsafe impl Send for Connection { }
3431pub struct Connection {
3532 display : * mut Display ,
@@ -39,7 +36,7 @@ pub struct Connection {
3936 cursor_cache : RefCell < HashMap < usize , c_ulong > > ,
4037 atom_cache : RefCell < HashMap < usize , c_ulong > > ,
4138
42- unsync : PhantomData < * mut ( ) > ,
39+ not_sync : PhantomData < * mut ( ) > ,
4340}
4441
4542impl Connection {
@@ -51,7 +48,6 @@ impl Connection {
5148 }
5249
5350 XSetErrorHandler ( Some ( error_handler) ) ;
54- XInternAtom ( display, ATOM_PICOVIEW_WAKEUP . as_ptr ( ) as _ , 1 ) ;
5551
5652 let screen = XDefaultScreen ( display) ;
5753 let connection = Self {
@@ -62,7 +58,7 @@ impl Connection {
6258 cursor_cache : RefCell :: new ( HashMap :: new ( ) ) ,
6359 atom_cache : RefCell :: new ( HashMap :: new ( ) ) ,
6460
65- unsync : PhantomData ,
61+ not_sync : PhantomData ,
6662 } ;
6763
6864 ERRORS_FOR_EACH_DISPLAY
@@ -74,7 +70,7 @@ impl Connection {
7470 }
7571 }
7672
77- pub fn check_error ( & self ) -> Result < ( ) , String > {
73+ pub fn last_error ( & self ) -> Result < ( ) , String > {
7874 let err = ERRORS_FOR_EACH_DISPLAY
7975 . lock ( )
8076 . expect ( "poisoned" )
@@ -240,7 +236,7 @@ impl Connection {
240236 let mut event = XEvent { type_ : 0 } ;
241237 if XNextEvent ( self . display , & mut event) != 0 {
242238 return Err ( WindowError :: Platform (
243- self . check_error ( )
239+ self . last_error ( )
244240 . err ( )
245241 . unwrap_or_else ( || "unknown error" . to_owned ( ) ) ,
246242 ) ) ;
@@ -309,19 +305,15 @@ unsafe extern "C" fn error_handler(dpy: *mut Display, err: *mut XErrorEvent) ->
309305 }
310306
311307 unsafe {
312- let mut buf = [ 0 ; 255 ] ;
308+ let mut buf = [ 0 as c_char ; 255 ] ;
313309 XGetErrorText (
314310 ( * err) . display ,
315311 ( * err) . error_code . into ( ) ,
316- buf. as_mut_ptr ( ) . cast ( ) ,
312+ buf. as_mut_ptr ( ) ,
317313 ( buf. len ( ) - 1 ) as i32 ,
318314 ) ;
319315 buf[ 254 ] = 0 ;
320- conn. replace (
321- CStr :: from_ptr ( buf. as_mut_ptr ( ) . cast ( ) )
322- . to_string_lossy ( )
323- . into ( ) ,
324- ) ;
316+ conn. replace ( CStr :: from_ptr ( buf. as_mut_ptr ( ) ) . to_string_lossy ( ) . into ( ) ) ;
325317 }
326318
327319 0
0 commit comments