From cd997cbe48cfbd95e188d8c955684bb4795c0b6f Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sun, 27 Dec 2020 22:06:04 -0800 Subject: [PATCH] window+gui: migrate prefer_egl to WindowConfiguration --- wezterm-gui/src/gui/mod.rs | 4 ---- wezterm-gui/src/window_config.rs | 4 ++++ window/src/configuration.rs | 4 ++++ window/src/lib.rs | 9 --------- window/src/os/macos/window.rs | 9 ++++----- window/src/os/windows/window.rs | 2 +- 6 files changed, 13 insertions(+), 19 deletions(-) diff --git a/wezterm-gui/src/gui/mod.rs b/wezterm-gui/src/gui/mod.rs index 63bc28ca8..c0b55a38a 100644 --- a/wezterm-gui/src/gui/mod.rs +++ b/wezterm-gui/src/gui/mod.rs @@ -38,10 +38,6 @@ impl GuiFrontEnd { } pub fn try_new() -> anyhow::Result> { - let config = config::configuration(); - - prefer_egl(config.prefer_egl); - #[cfg(windows)] { if is_running_in_rdp_session() { diff --git a/wezterm-gui/src/window_config.rs b/wezterm-gui/src/window_config.rs index 607c5f8a7..fd284e5a7 100644 --- a/wezterm-gui/src/window_config.rs +++ b/wezterm-gui/src/window_config.rs @@ -15,4 +15,8 @@ impl WindowConfiguration for ConfigBridge { fn enable_wayland(&self) -> bool { configuration().enable_wayland } + + fn prefer_egl(&self) -> bool { + configuration().prefer_egl + } } diff --git a/window/src/configuration.rs b/window/src/configuration.rs index 487f654e5..26ed350d0 100644 --- a/window/src/configuration.rs +++ b/window/src/configuration.rs @@ -12,6 +12,10 @@ pub trait WindowConfiguration { fn enable_wayland(&self) -> bool { true } + + fn prefer_egl(&self) -> bool { + true + } } lazy_static::lazy_static! { diff --git a/window/src/lib.rs b/window/src/lib.rs index eef5e1278..c2abba9b7 100644 --- a/window/src/lib.rs +++ b/window/src/lib.rs @@ -301,7 +301,6 @@ pub trait WindowOpsMut { } static PREFER_SWRAST: AtomicBool = AtomicBool::new(false); -static PREFER_EGL: AtomicBool = AtomicBool::new(true); pub fn prefer_swrast() { PREFER_SWRAST.store(true, Ordering::Release); @@ -310,11 +309,3 @@ pub fn prefer_swrast() { pub fn is_swrast_preferred() -> bool { PREFER_SWRAST.load(Ordering::Acquire) } - -pub fn prefer_egl(value: bool) { - PREFER_EGL.store(value, Ordering::Release); -} - -pub fn is_egl_preferred() -> bool { - PREFER_EGL.load(Ordering::Acquire) -} diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs index e80f74039..f515596dc 100644 --- a/window/src/os/macos/window.rs +++ b/window/src/os/macos/window.rs @@ -6,10 +6,9 @@ use crate::bitmaps::Image; use crate::connection::ConnectionOps; use crate::os::macos::bitmap::BitmapRef; use crate::{ - config, is_egl_preferred, BitmapImage, Clipboard, Color, Connection, Dimensions, KeyCode, - KeyEvent, Modifiers, MouseButtons, MouseCursor, MouseEvent, MouseEventKind, MousePress, - Operator, PaintContext, Point, Rect, ScreenPoint, Size, WindowCallbacks, WindowOps, - WindowOpsMut, + config, BitmapImage, Clipboard, Color, Connection, Dimensions, KeyCode, KeyEvent, Modifiers, + MouseButtons, MouseCursor, MouseEvent, MouseEventKind, MousePress, Operator, PaintContext, + Point, Rect, ScreenPoint, Size, WindowCallbacks, WindowOps, WindowOpsMut, }; use anyhow::{anyhow, bail, ensure}; use cocoa::appkit::{ @@ -132,7 +131,7 @@ mod opengl { }; // Let's first try to initialize EGL... - let (context, backend) = match if is_egl_preferred() { + let (context, backend) = match if config().prefer_egl() { // ANGLE wants a layer, so tell the view to create one. // Importantly, we must set its scale to 1.0 prior to initializing // EGL to prevent undesirable scaling. diff --git a/window/src/os/windows/window.rs b/window/src/os/windows/window.rs index 98418bd9d..385af599d 100644 --- a/window/src/os/windows/window.rs +++ b/window/src/os/windows/window.rs @@ -128,7 +128,7 @@ impl WindowInner { let window = Window(self.hwnd); let conn = Connection::get().unwrap(); - let gl_state = if crate::is_egl_preferred() { + let gl_state = if config().prefer_egl() { match conn.gl_connection.borrow().as_ref() { None => crate::egl::GlState::create(None, self.hwnd.0), Some(glconn) => {