diff --git a/src/x11/window.rs b/src/x11/window.rs index 6c5d5b6..55caf88 100644 --- a/src/x11/window.rs +++ b/src/x11/window.rs @@ -188,13 +188,13 @@ impl<'a> Window<'a> { let xcb_connection = XcbConnection::new()?; // Get screen information (?) - let setup = xcb_connection.conn2.setup(); + let setup = xcb_connection.conn.setup(); let screen = &setup.roots[xcb_connection.screen]; let parent_id = parent.unwrap_or_else(|| screen.root); - let gc_id = xcb_connection.conn2.generate_id()?; - xcb_connection.conn2.create_gc( + let gc_id = xcb_connection.conn.generate_id()?; + xcb_connection.conn.create_gc( gc_id, parent_id, &CreateGCAux::new().foreground(screen.black_pixel).graphics_exposures(0), @@ -234,11 +234,11 @@ impl<'a> Window<'a> { // For this 32-bith depth to work, you also need to define a color map and set a border // pixel: https://cgit.freedesktop.org/xorg/xserver/tree/dix/window.c#n818 - let colormap = xcb_connection.conn2.generate_id()?; - xcb_connection.conn2.create_colormap(ColormapAlloc::NONE, colormap, screen.root, visual)?; + let colormap = xcb_connection.conn.generate_id()?; + xcb_connection.conn.create_colormap(ColormapAlloc::NONE, colormap, screen.root, visual)?; - let window_id = xcb_connection.conn2.generate_id()?; - xcb_connection.conn2.create_window( + let window_id = xcb_connection.conn.generate_id()?; + xcb_connection.conn.create_window( depth, window_id, parent_id, @@ -266,11 +266,11 @@ impl<'a> Window<'a> { .colormap(colormap) .border_pixel(0), )?; - xcb_connection.conn2.map_window(window_id)?; + xcb_connection.conn.map_window(window_id)?; // Change window title let title = options.title; - xcb_connection.conn2.change_property8( + xcb_connection.conn.change_property8( PropMode::REPLACE, window_id, AtomEnum::WM_NAME, @@ -278,15 +278,15 @@ impl<'a> Window<'a> { title.as_bytes(), )?; - xcb_connection.conn2.change_property32( + xcb_connection.conn.change_property32( PropMode::REPLACE, window_id, - xcb_connection.atoms2.WM_PROTOCOLS, + xcb_connection.atoms.WM_PROTOCOLS, AtomEnum::ATOM, - &[xcb_connection.atoms2.WM_DELETE_WINDOW], + &[xcb_connection.atoms.WM_DELETE_WINDOW], )?; - xcb_connection.conn2.flush()?; + xcb_connection.conn.flush()?; // TODO: These APIs could use a couple tweaks now that everything is internal and there is // no error handling anymore at this point. Everything is more or less unchanged @@ -345,11 +345,11 @@ impl<'a> Window<'a> { let xid = self.inner.xcb_connection.get_cursor(mouse_cursor).unwrap(); if xid != 0 { - let _ = self.inner.xcb_connection.conn2.change_window_attributes( + let _ = self.inner.xcb_connection.conn.change_window_attributes( self.inner.window_id, &ChangeWindowAttributesAux::new().cursor(xid), ); - let _ = self.inner.xcb_connection.conn2.flush(); + let _ = self.inner.xcb_connection.conn.flush(); } self.inner.mouse_cursor = mouse_cursor; @@ -371,13 +371,13 @@ impl<'a> Window<'a> { let scaling = self.inner.window_info.scale(); let new_window_info = WindowInfo::from_logical_size(size, scaling); - let _ = self.inner.xcb_connection.conn2.configure_window( + let _ = self.inner.xcb_connection.conn.configure_window( self.inner.window_id, &ConfigureWindowAux::new() .width(new_window_info.physical_size().width) .height(new_window_info.physical_size().height), ); - let _ = self.inner.xcb_connection.conn2.flush(); + let _ = self.inner.xcb_connection.conn.flush(); // This will trigger a `ConfigureNotify` event which will in turn change `self.window_info` // and notify the window handler about it @@ -413,7 +413,7 @@ impl WindowInner { // when they've all been coalesced. self.new_physical_size = None; - while let Some(event) = self.xcb_connection.conn2.poll_for_event()? { + while let Some(event) = self.xcb_connection.conn.poll_for_event()? { self.handle_xcb_event(handler, event); } @@ -438,7 +438,7 @@ impl WindowInner { fn run_event_loop(&mut self, handler: &mut dyn WindowHandler) -> Result<(), Box> { use nix::poll::*; - let xcb_fd = self.xcb_connection.conn2.as_raw_fd(); + let xcb_fd = self.xcb_connection.conn.as_raw_fd(); let mut last_frame = Instant::now(); self.event_loop_running = true; @@ -545,7 +545,7 @@ impl WindowInner { //// XEvent::ClientMessage(event) => { if event.format == 32 - && event.data.as_data32()[0] == self.xcb_connection.atoms2.WM_DELETE_WINDOW + && event.data.as_data32()[0] == self.xcb_connection.atoms.WM_DELETE_WINDOW { self.handle_close_requested(handler); } diff --git a/src/x11/xcb_connection.rs b/src/x11/xcb_connection.rs index 34b400a..4f17a59 100644 --- a/src/x11/xcb_connection.rs +++ b/src/x11/xcb_connection.rs @@ -14,7 +14,7 @@ use crate::MouseCursor; use super::cursor; x11rb::atom_manager! { - pub Atoms2: AtomsCookie { + pub Atoms: AtomsCookie { WM_PROTOCOLS, WM_DELETE_WINDOW, } @@ -25,9 +25,9 @@ x11rb::atom_manager! { /// Keeps track of the xcb connection itself and the xlib display ID that was used to connect. pub struct XcbConnection { pub(crate) dpy: *mut Display, - pub(crate) conn2: XCBConnection, + pub(crate) conn: XCBConnection, pub(crate) screen: usize, - pub(crate) atoms2: Atoms2, + pub(crate) atoms: Atoms, pub(crate) resources: resource_manager::Database, pub(crate) cursor_handle: CursorHandle, pub(super) cursor_cache: HashMap, @@ -40,20 +40,20 @@ impl XcbConnection { let xcb_connection = unsafe { xlib_xcb::XGetXCBConnection(dpy) }; assert!(!xcb_connection.is_null()); let screen = unsafe { xlib::XDefaultScreen(dpy) } as usize; - let conn2 = unsafe { XCBConnection::from_raw_xcb_connection(xcb_connection, true)? }; + let conn = unsafe { XCBConnection::from_raw_xcb_connection(xcb_connection, true)? }; unsafe { xlib_xcb::XSetEventQueueOwner(dpy, xlib_xcb::XEventQueueOwner::XCBOwnsEventQueue) }; - let atoms2 = Atoms2::new(&conn2)?.reply()?; - let resources = resource_manager::new_from_default(&conn2)?; - let cursor_handle = CursorHandle::new(&conn2, screen, &resources)?.reply()?; + let atoms = Atoms::new(&conn)?.reply()?; + let resources = resource_manager::new_from_default(&conn)?; + let cursor_handle = CursorHandle::new(&conn, screen, &resources)?.reply()?; Ok(Self { dpy, - conn2, + conn, screen, - atoms2, + atoms, resources, cursor_handle, cursor_cache: HashMap::new(), @@ -76,7 +76,7 @@ impl XcbConnection { // If neither work, I guess just assume 96.0 and don't do any scaling. fn get_scaling_screen_dimensions(&self) -> f64 { // Figure out screen information - let setup = self.conn2.setup(); + let setup = self.conn.setup(); let screen = &setup.roots[self.screen]; // Get the DPI from the screen struct @@ -109,7 +109,7 @@ impl XcbConnection { Entry::Occupied(entry) => Ok(*entry.get()), Entry::Vacant(entry) => { let cursor = - cursor::get_xcursor(&self.conn2, self.screen, &self.cursor_handle, cursor)?; + cursor::get_xcursor(&self.conn, self.screen, &self.cursor_handle, cursor)?; entry.insert(cursor); Ok(cursor) }