From e29412321530aece770b38997c2c111d6649a9e3 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 23 Mar 2021 22:11:41 -0700 Subject: [PATCH] window: remove ConfigBridge on x11/wayland --- window/src/os/wayland/window.rs | 4 ++-- window/src/os/x11/connection.rs | 2 +- window/src/os/x11/window.rs | 26 +++++++++++++------------- window/src/os/x_and_wayland.rs | 10 +++++----- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/window/src/os/wayland/window.rs b/window/src/os/wayland/window.rs index 1b944b1b9..0db4c1b22 100644 --- a/window/src/os/wayland/window.rs +++ b/window/src/os/wayland/window.rs @@ -4,12 +4,12 @@ use super::pointer::*; use crate::connection::ConnectionOps; use crate::os::wayland::connection::WaylandConnection; use crate::os::xkeysyms::keysym_to_keycode; -use crate::WindowConfigHandle; use crate::{ Clipboard, Connection, Dimensions, MouseCursor, Point, ScreenPoint, Window, WindowCallbacks, WindowOps, WindowOpsMut, }; use anyhow::{anyhow, bail, Context}; +use config::ConfigHandle; use filedescriptor::FileDescriptor; use promise::{Future, Promise}; use smithay_client_toolkit as toolkit; @@ -167,7 +167,7 @@ impl WaylandWindow { width: usize, height: usize, callbacks: Box, - _config: Option<&WindowConfigHandle>, + _config: Option<&ConfigHandle>, ) -> anyhow::Result { let conn = WaylandConnection::get() .ok_or_else(|| { diff --git a/window/src/os/x11/connection.rs b/window/src/os/x11/connection.rs index 7d90cb929..532366037 100644 --- a/window/src/os/x11/connection.rs +++ b/window/src/os/x11/connection.rs @@ -329,7 +329,7 @@ impl XConnection { let depth_bpp = depth.depth(); if depth_bpp == 24 || depth_bpp == 32 { for vis in depth.visuals() { - if vis.class() == xcb::xproto::VISUAL_CLASS_TRUE_COLOR as _ + if vis.class() == xcb::xproto::VISUAL_CLASS_TRUE_COLOR as u8 && vis.bits_per_rgb_value() == 8 { visuals.push((depth_bpp, vis)); diff --git a/window/src/os/x11/window.rs b/window/src/os/x11/window.rs index 4129f8ca6..0544c629f 100644 --- a/window/src/os/x11/window.rs +++ b/window/src/os/x11/window.rs @@ -3,12 +3,12 @@ use crate::bitmaps::*; use crate::connection::ConnectionOps; use crate::os::xkeysyms; use crate::os::{Connection, Window}; -use crate::WindowConfigHandle; use crate::{ Clipboard, Dimensions, MouseButtons, MouseCursor, MouseEvent, MouseEventKind, MousePress, Point, Rect, ScreenPoint, Size, WindowCallbacks, WindowDecorations, WindowOps, WindowOpsMut, }; use anyhow::{anyhow, Context as _}; +use config::ConfigHandle; use promise::{Future, Promise}; use std::any::Any; use std::collections::VecDeque; @@ -58,7 +58,7 @@ pub(crate) struct XWindowInner { paint_all: bool, cursors: CursorInfo, copy_and_paste: CopyAndPaste, - config: WindowConfigHandle, + config: ConfigHandle, gl_state: Option>, } @@ -546,7 +546,7 @@ impl XWindowInner { xcb::ClientMessageData::from_data32(data), ), ); - self.adjust_decorations(self.config.decorations())?; + self.adjust_decorations(self.config.window_decorations)?; Ok(()) } @@ -635,11 +635,11 @@ impl XWindow { width: usize, height: usize, callbacks: Box, - config: Option<&WindowConfigHandle>, + config: Option<&ConfigHandle>, ) -> anyhow::Result { let config = match config { - Some(c) => Arc::clone(c), - None => crate::config(), + Some(c) => c.clone(), + None => config::configuration(), }; let conn = Connection::get() .ok_or_else(|| { @@ -720,7 +720,7 @@ impl XWindow { copy_and_paste: CopyAndPaste::default(), cursors: CursorInfo::new(&conn), gl_state: None, - config: Arc::clone(&config), + config: config.clone(), })) }; @@ -742,7 +742,7 @@ impl XWindow { window .lock() .unwrap() - .adjust_decorations(config.decorations())?; + .adjust_decorations(config.window_decorations)?; let window_handle = Window::X11(XWindow::from_id(window_id)); @@ -783,9 +783,9 @@ impl WindowOpsMut for XWindowInner { self.set_fullscreen_hint(!fullscreen).ok(); } - fn config_did_change(&mut self, config: &WindowConfigHandle) { - self.config = Arc::clone(config); - let _ = self.adjust_decorations(config.decorations()); + fn config_did_change(&mut self, config: &ConfigHandle) { + self.config = config.clone(); + let _ = self.adjust_decorations(config.window_decorations); } fn set_inner_size(&mut self, width: usize, height: usize) { @@ -870,8 +870,8 @@ impl WindowOps for XWindow { }) } - fn config_did_change(&self, config: &WindowConfigHandle) -> Future<()> { - let config = Arc::clone(config); + fn config_did_change(&self, config: &ConfigHandle) -> Future<()> { + let config = config.clone(); XConnection::with_window_inner(self.0, move |inner| { inner.config_did_change(&config); Ok(()) diff --git a/window/src/os/x_and_wayland.rs b/window/src/os/x_and_wayland.rs index 46ddd997d..27125cc97 100644 --- a/window/src/os/x_and_wayland.rs +++ b/window/src/os/x_and_wayland.rs @@ -7,8 +7,8 @@ use crate::os::wayland::connection::WaylandConnection; use crate::os::wayland::window::WaylandWindow; use crate::os::x11::connection::XConnection; use crate::os::x11::window::XWindow; -use crate::WindowConfigHandle; use crate::{Clipboard, MouseCursor, ScreenPoint, WindowCallbacks, WindowOps}; +use config::ConfigHandle; use promise::*; use std::any::Any; use std::rc::Rc; @@ -30,7 +30,7 @@ impl Connection { pub(crate) fn create_new() -> anyhow::Result { #[cfg(feature = "wayland")] { - if crate::config().enable_wayland() { + if config::configuration().enable_wayland { match WaylandConnection::create_new() { Ok(w) => { log::debug!("Using wayland connection!"); @@ -52,7 +52,7 @@ impl Connection { width: usize, height: usize, callbacks: Box, - config: Option<&WindowConfigHandle>, + config: Option<&ConfigHandle>, ) -> anyhow::Result { match self { Self::X11(_) => XWindow::new_window(class_name, name, width, height, callbacks, config), @@ -112,7 +112,7 @@ impl Window { width: usize, height: usize, callbacks: Box, - config: Option<&WindowConfigHandle>, + config: Option<&ConfigHandle>, ) -> anyhow::Result { Connection::get() .unwrap() @@ -145,7 +145,7 @@ impl WindowOps for Window { } } - fn config_did_change(&self, config: &WindowConfigHandle) -> Future<()> { + fn config_did_change(&self, config: &ConfigHandle) -> Future<()> { match self { Self::X11(x) => x.config_did_change(config), #[cfg(feature = "wayland")]