1
0
Fork 0

Fix temporary names left over from x11rb migration (#179)

This commit is contained in:
Micah Johnston 2024-03-26 22:43:27 -05:00 committed by GitHub
parent ea0cd5367d
commit f7d83a561e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 31 deletions

View file

@ -188,13 +188,13 @@ impl<'a> Window<'a> {
let xcb_connection = XcbConnection::new()?; let xcb_connection = XcbConnection::new()?;
// Get screen information (?) // Get screen information (?)
let setup = xcb_connection.conn2.setup(); let setup = xcb_connection.conn.setup();
let screen = &setup.roots[xcb_connection.screen]; let screen = &setup.roots[xcb_connection.screen];
let parent_id = parent.unwrap_or_else(|| screen.root); let parent_id = parent.unwrap_or_else(|| screen.root);
let gc_id = xcb_connection.conn2.generate_id()?; let gc_id = xcb_connection.conn.generate_id()?;
xcb_connection.conn2.create_gc( xcb_connection.conn.create_gc(
gc_id, gc_id,
parent_id, parent_id,
&CreateGCAux::new().foreground(screen.black_pixel).graphics_exposures(0), &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 // 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 // pixel: https://cgit.freedesktop.org/xorg/xserver/tree/dix/window.c#n818
let colormap = xcb_connection.conn2.generate_id()?; let colormap = xcb_connection.conn.generate_id()?;
xcb_connection.conn2.create_colormap(ColormapAlloc::NONE, colormap, screen.root, visual)?; xcb_connection.conn.create_colormap(ColormapAlloc::NONE, colormap, screen.root, visual)?;
let window_id = xcb_connection.conn2.generate_id()?; let window_id = xcb_connection.conn.generate_id()?;
xcb_connection.conn2.create_window( xcb_connection.conn.create_window(
depth, depth,
window_id, window_id,
parent_id, parent_id,
@ -266,11 +266,11 @@ impl<'a> Window<'a> {
.colormap(colormap) .colormap(colormap)
.border_pixel(0), .border_pixel(0),
)?; )?;
xcb_connection.conn2.map_window(window_id)?; xcb_connection.conn.map_window(window_id)?;
// Change window title // Change window title
let title = options.title; let title = options.title;
xcb_connection.conn2.change_property8( xcb_connection.conn.change_property8(
PropMode::REPLACE, PropMode::REPLACE,
window_id, window_id,
AtomEnum::WM_NAME, AtomEnum::WM_NAME,
@ -278,15 +278,15 @@ impl<'a> Window<'a> {
title.as_bytes(), title.as_bytes(),
)?; )?;
xcb_connection.conn2.change_property32( xcb_connection.conn.change_property32(
PropMode::REPLACE, PropMode::REPLACE,
window_id, window_id,
xcb_connection.atoms2.WM_PROTOCOLS, xcb_connection.atoms.WM_PROTOCOLS,
AtomEnum::ATOM, 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 // 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 // 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(); let xid = self.inner.xcb_connection.get_cursor(mouse_cursor).unwrap();
if xid != 0 { 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, self.inner.window_id,
&ChangeWindowAttributesAux::new().cursor(xid), &ChangeWindowAttributesAux::new().cursor(xid),
); );
let _ = self.inner.xcb_connection.conn2.flush(); let _ = self.inner.xcb_connection.conn.flush();
} }
self.inner.mouse_cursor = mouse_cursor; self.inner.mouse_cursor = mouse_cursor;
@ -371,13 +371,13 @@ impl<'a> Window<'a> {
let scaling = self.inner.window_info.scale(); let scaling = self.inner.window_info.scale();
let new_window_info = WindowInfo::from_logical_size(size, scaling); 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, self.inner.window_id,
&ConfigureWindowAux::new() &ConfigureWindowAux::new()
.width(new_window_info.physical_size().width) .width(new_window_info.physical_size().width)
.height(new_window_info.physical_size().height), .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` // This will trigger a `ConfigureNotify` event which will in turn change `self.window_info`
// and notify the window handler about it // and notify the window handler about it
@ -413,7 +413,7 @@ impl WindowInner {
// when they've all been coalesced. // when they've all been coalesced.
self.new_physical_size = None; 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); self.handle_xcb_event(handler, event);
} }
@ -438,7 +438,7 @@ impl WindowInner {
fn run_event_loop(&mut self, handler: &mut dyn WindowHandler) -> Result<(), Box<dyn Error>> { fn run_event_loop(&mut self, handler: &mut dyn WindowHandler) -> Result<(), Box<dyn Error>> {
use nix::poll::*; 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(); let mut last_frame = Instant::now();
self.event_loop_running = true; self.event_loop_running = true;
@ -545,7 +545,7 @@ impl WindowInner {
//// ////
XEvent::ClientMessage(event) => { XEvent::ClientMessage(event) => {
if event.format == 32 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); self.handle_close_requested(handler);
} }

View file

@ -14,7 +14,7 @@ use crate::MouseCursor;
use super::cursor; use super::cursor;
x11rb::atom_manager! { x11rb::atom_manager! {
pub Atoms2: AtomsCookie { pub Atoms: AtomsCookie {
WM_PROTOCOLS, WM_PROTOCOLS,
WM_DELETE_WINDOW, 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. /// Keeps track of the xcb connection itself and the xlib display ID that was used to connect.
pub struct XcbConnection { pub struct XcbConnection {
pub(crate) dpy: *mut Display, pub(crate) dpy: *mut Display,
pub(crate) conn2: XCBConnection, pub(crate) conn: XCBConnection,
pub(crate) screen: usize, pub(crate) screen: usize,
pub(crate) atoms2: Atoms2, pub(crate) atoms: Atoms,
pub(crate) resources: resource_manager::Database, pub(crate) resources: resource_manager::Database,
pub(crate) cursor_handle: CursorHandle, pub(crate) cursor_handle: CursorHandle,
pub(super) cursor_cache: HashMap<MouseCursor, u32>, pub(super) cursor_cache: HashMap<MouseCursor, u32>,
@ -40,20 +40,20 @@ impl XcbConnection {
let xcb_connection = unsafe { xlib_xcb::XGetXCBConnection(dpy) }; let xcb_connection = unsafe { xlib_xcb::XGetXCBConnection(dpy) };
assert!(!xcb_connection.is_null()); assert!(!xcb_connection.is_null());
let screen = unsafe { xlib::XDefaultScreen(dpy) } as usize; 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 { unsafe {
xlib_xcb::XSetEventQueueOwner(dpy, xlib_xcb::XEventQueueOwner::XCBOwnsEventQueue) xlib_xcb::XSetEventQueueOwner(dpy, xlib_xcb::XEventQueueOwner::XCBOwnsEventQueue)
}; };
let atoms2 = Atoms2::new(&conn2)?.reply()?; let atoms = Atoms::new(&conn)?.reply()?;
let resources = resource_manager::new_from_default(&conn2)?; let resources = resource_manager::new_from_default(&conn)?;
let cursor_handle = CursorHandle::new(&conn2, screen, &resources)?.reply()?; let cursor_handle = CursorHandle::new(&conn, screen, &resources)?.reply()?;
Ok(Self { Ok(Self {
dpy, dpy,
conn2, conn,
screen, screen,
atoms2, atoms,
resources, resources,
cursor_handle, cursor_handle,
cursor_cache: HashMap::new(), 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. // If neither work, I guess just assume 96.0 and don't do any scaling.
fn get_scaling_screen_dimensions(&self) -> f64 { fn get_scaling_screen_dimensions(&self) -> f64 {
// Figure out screen information // Figure out screen information
let setup = self.conn2.setup(); let setup = self.conn.setup();
let screen = &setup.roots[self.screen]; let screen = &setup.roots[self.screen];
// Get the DPI from the screen struct // Get the DPI from the screen struct
@ -109,7 +109,7 @@ impl XcbConnection {
Entry::Occupied(entry) => Ok(*entry.get()), Entry::Occupied(entry) => Ok(*entry.get()),
Entry::Vacant(entry) => { Entry::Vacant(entry) => {
let cursor = 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); entry.insert(cursor);
Ok(cursor) Ok(cursor)
} }