From ec7d5117500187da209767181896b667a27856ea Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Tue, 29 Dec 2020 12:31:25 -0800 Subject: [PATCH] window: implicitly enable_opengl at new_window creation --- wezterm-gui/src/gui/termwindow.rs | 3 --- window/examples/basic_opengl.rs | 1 - window/src/lib.rs | 5 ----- window/src/os/macos/window.rs | 11 +---------- window/src/os/wayland/window.rs | 5 +---- window/src/os/windows/window.rs | 5 +---- window/src/os/x11/window.rs | 5 +---- window/src/os/x_and_wayland.rs | 8 -------- 8 files changed, 4 insertions(+), 39 deletions(-) diff --git a/wezterm-gui/src/gui/termwindow.rs b/wezterm-gui/src/gui/termwindow.rs index 05c745913..029f55c28 100644 --- a/wezterm-gui/src/gui/termwindow.rs +++ b/wezterm-gui/src/gui/termwindow.rs @@ -749,7 +749,6 @@ impl WindowCallbacks for TermWindow { Self::start_periodic_maintenance(window.clone()); Self::setup_clipboard(&window, mux_window_id, clipboard_contents); - window.enable_opengl(); drop(activity); // Keep the activity outstanding until we get here Ok::<(), anyhow::Error>(()) }) @@ -1012,8 +1011,6 @@ impl TermWindow { Self::start_periodic_maintenance(window.clone()); Self::setup_clipboard(&window, mux_window_id, clipboard_contents); - window.enable_opengl(); - crate::update::start_update_checker(); Ok(()) } diff --git a/window/examples/basic_opengl.rs b/window/examples/basic_opengl.rs index f5dee03df..d12c81857 100644 --- a/window/examples/basic_opengl.rs +++ b/window/examples/basic_opengl.rs @@ -51,7 +51,6 @@ fn spawn_window() -> anyhow::Result<()> { }), )?; - win.enable_opengl(); win.show(); win.apply(|myself, _win| { if let Some(myself) = myself.downcast_ref::() { diff --git a/window/src/lib.rs b/window/src/lib.rs index 5a4876947..6305aef2b 100644 --- a/window/src/lib.rs +++ b/window/src/lib.rs @@ -229,11 +229,6 @@ pub trait WindowOps { Self: Sized, R: Send + 'static; - /// Attempt to set up opengl based painting. - /// Will call opengl_initialize() in your WindowCallbacks impl to - /// inform it of the gl context. - fn enable_opengl(&self) -> promise::Future<()>; - /// Initiate textual transfer from the clipboard fn get_clipboard(&self, clipboard: Clipboard) -> Future; diff --git a/window/src/os/macos/window.rs b/window/src/os/macos/window.rs index 65f332471..b0eed878d 100644 --- a/window/src/os/macos/window.rs +++ b/window/src/os/macos/window.rs @@ -469,6 +469,7 @@ impl Window { let window = Window(window_id); + inner.borrow_mut().enable_opengl()?; inner.borrow_mut().callbacks.created(&window); // Synthesize a resize event immediately; this allows // the embedding application an opportunity to discover @@ -568,16 +569,6 @@ impl WindowOps for Window { }) } - fn enable_opengl(&self) -> promise::Future<()> { - Connection::with_window_inner(self.0, move |inner| { - if let Some(window_view) = WindowView::get_this(unsafe { &**inner.view }) { - window_view.inner.borrow_mut().enable_opengl() - } else { - bail!("apply: window is invalid"); - } - }) - } - fn get_clipboard(&self, _clipboard: Clipboard) -> Future { use clipboard::ClipboardProvider; Future::result( diff --git a/window/src/os/wayland/window.rs b/window/src/os/wayland/window.rs index c0f975ee0..77c23f11a 100644 --- a/window/src/os/wayland/window.rs +++ b/window/src/os/wayland/window.rs @@ -251,6 +251,7 @@ impl WaylandWindow { conn.windows.borrow_mut().insert(window_id, inner.clone()); inner.borrow_mut().callbacks.created(&window_handle); + inner.borrow_mut().enable_opengl()?; Ok(window_handle) } @@ -765,10 +766,6 @@ impl WindowOps for WaylandWindow { }) } - fn enable_opengl(&self) -> promise::Future<()> { - WaylandConnection::with_window_inner(self.0, move |inner| inner.enable_opengl()) - } - fn get_clipboard(&self, _clipboard: Clipboard) -> Future { let mut promise = Promise::new(); let future = promise.get_future().unwrap(); diff --git a/window/src/os/windows/window.rs b/window/src/os/windows/window.rs index ed9e0fab4..308b35d37 100644 --- a/window/src/os/windows/window.rs +++ b/window/src/os/windows/window.rs @@ -328,6 +328,7 @@ impl Window { let window = Window(hwnd); inner.borrow_mut().callbacks.borrow_mut().created(&window); + inner.borrow_mut().enable_opengl()?; Ok(window) } @@ -508,10 +509,6 @@ impl WindowOps for Window { }) } - fn enable_opengl(&self) -> promise::Future<()> { - Connection::with_window_inner(self.0, move |inner| inner.enable_opengl()) - } - fn get_clipboard(&self, _clipboard: Clipboard) -> Future { Future::result( clipboard_win::get_clipboard_string() diff --git a/window/src/os/x11/window.rs b/window/src/os/x11/window.rs index c1802afdb..d9a4e58cb 100644 --- a/window/src/os/x11/window.rs +++ b/window/src/os/x11/window.rs @@ -867,6 +867,7 @@ impl XWindow { let window_handle = Window::X11(XWindow::from_id(window_id)); window.lock().unwrap().callbacks.created(&window_handle); + window.lock().unwrap().enable_opengl()?; conn.windows.borrow_mut().insert(window_id, window); @@ -1055,10 +1056,6 @@ impl WindowOps for XWindow { }) } - fn enable_opengl(&self) -> promise::Future<()> { - XConnection::with_window_inner(self.0, move |inner| inner.enable_opengl()) - } - /// Initiate textual transfer from the clipboard fn get_clipboard(&self, clipboard: Clipboard) -> Future { let mut promise = Promise::new(); diff --git a/window/src/os/x_and_wayland.rs b/window/src/os/x_and_wayland.rs index 3beab44a3..cac7c45fc 100644 --- a/window/src/os/x_and_wayland.rs +++ b/window/src/os/x_and_wayland.rs @@ -213,14 +213,6 @@ impl WindowOps for Window { } } - fn enable_opengl(&self) -> promise::Future<()> { - match self { - Self::X11(x) => x.enable_opengl(), - #[cfg(feature = "wayland")] - Self::Wayland(w) => w.enable_opengl(), - } - } - fn get_clipboard(&self, clipboard: Clipboard) -> Future { match self { Self::X11(x) => x.get_clipboard(clipboard),