1
1
mirror of https://github.com/wez/wezterm.git synced 2024-12-23 21:32:13 +03:00

window: make opengl always required

This commit is contained in:
Wez Furlong 2020-12-29 12:13:23 -08:00
parent cf2dcff362
commit 4c22de9f6d
16 changed files with 155 additions and 228 deletions

View File

@ -65,7 +65,7 @@ wezterm-font = { path = "../wezterm-font" }
wezterm-gui-subcommands = { path = "../wezterm-gui-subcommands" } wezterm-gui-subcommands = { path = "../wezterm-gui-subcommands" }
wezterm-term = { path = "../term", features=["use_serde"] } wezterm-term = { path = "../term", features=["use_serde"] }
wezterm-toast-notification = { path = "../wezterm-toast-notification" } wezterm-toast-notification = { path = "../wezterm-toast-notification" }
window = { path = "../window", features=["opengl", "wayland"]} window = { path = "../window", features=["wayland"]}
[target."cfg(windows)".dependencies] [target."cfg(windows)".dependencies]
shared_library = "0.1" shared_library = "0.1"

View File

@ -12,7 +12,7 @@ build = "build.rs"
pretty_env_logger = "0.4" pretty_env_logger = "0.4"
[build-dependencies] [build-dependencies]
gl_generator = {version="0.14", optional=true} gl_generator = "0.14"
[dependencies] [dependencies]
async-task = "4.0" async-task = "4.0"
@ -22,7 +22,7 @@ bitflags = "1.0"
euclid = "0.22" euclid = "0.22"
guillotiere = "0.6" guillotiere = "0.6"
lazy_static = "1.4" lazy_static = "1.4"
libloading = { version = "0.6", optional=true } libloading = "0.6"
line_drawing = "0.8" line_drawing = "0.8"
log = "0.4" log = "0.4"
metrics = { version="0.12", features=["std"]} metrics = { version="0.12", features=["std"]}
@ -30,11 +30,10 @@ palette = "0.5"
promise = { path = "../promise" } promise = { path = "../promise" }
resize = "0.5" resize = "0.5"
serde = {version="1.0", features = ["rc", "derive"]} serde = {version="1.0", features = ["rc", "derive"]}
glium = { version = "0.29", optional=true, default-features = false} glium = { version = "0.29", default-features = false}
wezterm-input-types = { path = "../wezterm-input-types" } wezterm-input-types = { path = "../wezterm-input-types" }
[features] [features]
opengl = ["cgl", "glium", "gl_generator", "libloading"]
wayland = ["smithay-client-toolkit", "memmap", "wayland-client", "wayland-egl"] wayland = ["smithay-client-toolkit", "memmap", "wayland-client", "wayland-egl"]
[target."cfg(windows)".dependencies] [target."cfg(windows)".dependencies]
@ -70,4 +69,4 @@ objc = "0.2"
clipboard = "0.5" clipboard = "0.5"
core-foundation = "0.7" core-foundation = "0.7"
core-graphics = "0.19" core-graphics = "0.19"
cgl = { version = "0.3", optional = true } cgl = "0.3"

View File

@ -1,8 +1,6 @@
fn main() { fn main() {
println!("cargo:rerun-if-changed=build.rs"); println!("cargo:rerun-if-changed=build.rs");
#[cfg(feature = "opengl")]
{
use gl_generator::{Api, Fallbacks, Profile, Registry}; use gl_generator::{Api, Fallbacks, Profile, Registry};
use std::env; use std::env;
use std::fs::File; use std::fs::File;
@ -74,5 +72,4 @@ fn main() {
.write_bindings(gl_generator::StructGenerator, &mut file) .write_bindings(gl_generator::StructGenerator, &mut file)
.unwrap(); .unwrap();
} }
}
} }

View File

@ -16,14 +16,12 @@ impl WindowCallbacks for MyWindow {
context.clear(Color::rgb(0x0, 0x0, 0x0)); context.clear(Color::rgb(0x0, 0x0, 0x0));
} }
#[cfg(feature = "opengl")]
fn paint_opengl(&mut self, frame: &mut glium::Frame) { fn paint_opengl(&mut self, frame: &mut glium::Frame) {
// Window contents are gray in opengl mode // Window contents are gray in opengl mode
use glium::Surface; use glium::Surface;
frame.clear_color_srgb(0.15, 0.15, 0.15, 1.0); frame.clear_color_srgb(0.15, 0.15, 0.15, 1.0);
} }
#[cfg(feature = "opengl")]
fn opengl_initialize( fn opengl_initialize(
&mut self, &mut self,
_window: &dyn WindowOps, _window: &dyn WindowOps,
@ -53,14 +51,7 @@ fn spawn_window() -> anyhow::Result<()> {
}), }),
)?; )?;
#[cfg(feature = "opengl")]
win.enable_opengl(); win.enable_opengl();
#[cfg(not(feature = "opengl"))]
eprintln!(
"opengl not enabled at compile time: cargo run --feature opengl --example basic_opengl"
);
win.show(); win.show();
win.apply(|myself, _win| { win.apply(|myself, _win| {
if let Some(myself) = myself.downcast_ref::<MyWindow>() { if let Some(myself) = myself.downcast_ref::<MyWindow>() {

View File

@ -1,6 +1,5 @@
use crate::color::Color; use crate::color::Color;
use crate::{Operator, Point, Rect, Size}; use crate::{Operator, Point, Rect, Size};
#[cfg(feature = "opengl")]
use glium::texture::SrgbTexture2d; use glium::texture::SrgbTexture2d;
use palette::LinSrgba; use palette::LinSrgba;
use std::cell::RefCell; use std::cell::RefCell;
@ -43,7 +42,6 @@ pub trait Texture2d {
} }
} }
#[cfg(feature = "opengl")]
impl Texture2d for SrgbTexture2d { impl Texture2d for SrgbTexture2d {
fn write(&self, rect: Rect, im: &dyn BitmapImage) { fn write(&self, rect: Rect, im: &dyn BitmapImage) {
let (im_width, im_height) = im.image_dimensions(); let (im_width, im_height) = im.image_dimensions();

View File

@ -16,15 +16,12 @@ pub const DEFAULT_DPI: f64 = 72.0;
#[cfg(not(target_os = "macos"))] #[cfg(not(target_os = "macos"))]
pub const DEFAULT_DPI: f64 = 96.0; pub const DEFAULT_DPI: f64 = 96.0;
#[cfg(feature = "opengl")]
mod egl; mod egl;
#[cfg(feature = "opengl")]
pub use glium;
pub use bitmaps::{BitmapImage, Image}; pub use bitmaps::{BitmapImage, Image};
pub use color::Color; pub use color::Color;
pub use connection::*; pub use connection::*;
pub use glium;
pub use os::*; pub use os::*;
pub use wezterm_input_types::*; pub use wezterm_input_types::*;
@ -139,7 +136,6 @@ pub trait WindowCallbacks: Any {
/// Called when the window has opengl mode enabled and the window /// Called when the window has opengl mode enabled and the window
/// contents need painting. /// contents need painting.
#[cfg(feature = "opengl")]
fn paint_opengl(&mut self, frame: &mut glium::Frame) { fn paint_opengl(&mut self, frame: &mut glium::Frame) {
use glium::Surface; use glium::Surface;
frame.clear_color_srgb(0.25, 0.125, 0.375, 1.0); frame.clear_color_srgb(0.25, 0.125, 0.375, 1.0);
@ -147,7 +143,6 @@ pub trait WindowCallbacks: Any {
/// Called when opengl is initialized by enable_opengl(), /// Called when opengl is initialized by enable_opengl(),
/// and also prior to calling opengl_context_lost with and Err value. /// and also prior to calling opengl_context_lost with and Err value.
#[cfg(feature = "opengl")]
fn opengl_initialize( fn opengl_initialize(
&mut self, &mut self,
_window: &dyn WindowOps, _window: &dyn WindowOps,
@ -157,7 +152,6 @@ pub trait WindowCallbacks: Any {
} }
/// Called if the opengl context is lost /// Called if the opengl context is lost
#[cfg(feature = "opengl")]
fn opengl_context_lost(&mut self, _window: &dyn WindowOps) -> anyhow::Result<()> { fn opengl_context_lost(&mut self, _window: &dyn WindowOps) -> anyhow::Result<()> {
Ok(()) Ok(())
} }
@ -238,7 +232,6 @@ pub trait WindowOps {
/// Attempt to set up opengl based painting. /// Attempt to set up opengl based painting.
/// Will call opengl_initialize() in your WindowCallbacks impl to /// Will call opengl_initialize() in your WindowCallbacks impl to
/// inform it of the gl context. /// inform it of the gl context.
#[cfg(feature = "opengl")]
fn enable_opengl(&self) -> promise::Future<()>; fn enable_opengl(&self) -> promise::Future<()>;
/// Initiate textual transfer from the clipboard /// Initiate textual transfer from the clipboard

View File

@ -18,7 +18,6 @@ pub struct Connection {
ns_app: id, ns_app: id,
pub(crate) windows: RefCell<HashMap<usize, Rc<RefCell<WindowInner>>>>, pub(crate) windows: RefCell<HashMap<usize, Rc<RefCell<WindowInner>>>>,
pub(crate) next_window_id: AtomicUsize, pub(crate) next_window_id: AtomicUsize,
#[cfg(feature = "opengl")]
pub(crate) gl_connection: RefCell<Option<Rc<crate::egl::GlConnection>>>, pub(crate) gl_connection: RefCell<Option<Rc<crate::egl::GlConnection>>>,
} }
@ -35,7 +34,6 @@ impl Connection {
ns_app, ns_app,
windows: RefCell::new(HashMap::new()), windows: RefCell::new(HashMap::new()),
next_window_id: AtomicUsize::new(1), next_window_id: AtomicUsize::new(1),
#[cfg(feature = "opengl")]
gl_connection: RefCell::new(None), gl_connection: RefCell::new(None),
}; };
Ok(conn) Ok(conn)

View File

@ -85,7 +85,6 @@ impl NSRange {
} }
} }
#[cfg(feature = "opengl")]
mod opengl { mod opengl {
use super::*; use super::*;
use cocoa::appkit::{self, NSOpenGLContext, NSOpenGLPixelFormat}; use cocoa::appkit::{self, NSOpenGLContext, NSOpenGLPixelFormat};
@ -389,7 +388,6 @@ impl Window {
view_id: None, view_id: None,
window_id, window_id,
screen_changed: false, screen_changed: false,
#[cfg(feature = "opengl")]
gl_context_pair: None, gl_context_pair: None,
text_cursor_position: Rect::new(Point::new(0, 0), Size::new(0, 0)), text_cursor_position: Rect::new(Point::new(0, 0), Size::new(0, 0)),
hscroll_remainder: 0., hscroll_remainder: 0.,
@ -570,7 +568,6 @@ impl WindowOps for Window {
}) })
} }
#[cfg(feature = "opengl")]
fn enable_opengl(&self) -> promise::Future<()> { fn enable_opengl(&self) -> promise::Future<()> {
Connection::with_window_inner(self.0, move |inner| { Connection::with_window_inner(self.0, move |inner| {
if let Some(window_view) = WindowView::get_this(unsafe { &**inner.view }) { if let Some(window_view) = WindowView::get_this(unsafe { &**inner.view }) {
@ -843,7 +840,6 @@ struct Inner {
view_id: Option<WeakPtr>, view_id: Option<WeakPtr>,
window_id: usize, window_id: usize,
screen_changed: bool, screen_changed: bool,
#[cfg(feature = "opengl")]
gl_context_pair: Option<opengl::GlContextPair>, gl_context_pair: Option<opengl::GlContextPair>,
text_cursor_position: Rect, text_cursor_position: Rect,
hscroll_remainder: f64, hscroll_remainder: f64,
@ -859,7 +855,6 @@ struct Inner {
} }
impl Inner { impl Inner {
#[cfg(feature = "opengl")]
fn enable_opengl(&mut self) -> anyhow::Result<()> { fn enable_opengl(&mut self) -> anyhow::Result<()> {
let window = Window(self.window_id); let window = Window(self.window_id);
@ -1517,8 +1512,6 @@ impl WindowView {
} }
extern "C" fn did_resize(this: &mut Object, _sel: Sel, _notification: id) { extern "C" fn did_resize(this: &mut Object, _sel: Sel, _notification: id) {
#[cfg(feature = "opengl")]
{
if let Some(this) = Self::get_this(this) { if let Some(this) = Self::get_this(this) {
let inner = this.inner.borrow_mut(); let inner = this.inner.borrow_mut();
@ -1526,7 +1519,6 @@ impl WindowView {
gl_context_pair.backend.update(); gl_context_pair.backend.update();
} }
} }
}
let frame = unsafe { NSView::frame(this as *mut _) }; let frame = unsafe { NSView::frame(this as *mut _) };
let backing_frame = unsafe { NSView::convertRectToBacking(this as *mut _, frame) }; let backing_frame = unsafe { NSView::convertRectToBacking(this as *mut _, frame) };
@ -1563,8 +1555,6 @@ impl WindowView {
return; return;
} }
#[cfg(feature = "opengl")]
{
if let Some(gl_context_pair) = inner.gl_context_pair.as_ref() { if let Some(gl_context_pair) = inner.gl_context_pair.as_ref() {
if gl_context_pair.context.is_context_lost() { if gl_context_pair.context.is_context_lost() {
log::error!("opengl context was lost; should reinit"); log::error!("opengl context was lost; should reinit");
@ -1591,7 +1581,6 @@ impl WindowView {
.expect("frame.finish failed and we don't know how to recover"); .expect("frame.finish failed and we don't know how to recover");
return; return;
} }
}
let mut buffer = this.buffer.borrow_mut(); let mut buffer = this.buffer.borrow_mut();
let (pixel_width, pixel_height) = buffer.image_dimensions(); let (pixel_width, pixel_height) = buffer.image_dimensions();

View File

@ -34,7 +34,6 @@ pub struct WaylandConnection {
// they appear in the struct, so the Display must be at the // they appear in the struct, so the Display must be at the
// bottom of this list, and opengl, which depends on everything // bottom of this list, and opengl, which depends on everything
// must be ahead of the rest. // must be ahead of the rest.
#[cfg(feature = "opengl")]
pub(crate) gl_connection: RefCell<Option<Rc<crate::egl::GlConnection>>>, pub(crate) gl_connection: RefCell<Option<Rc<crate::egl::GlConnection>>>,
pub(crate) pointer: PointerDispatcher, pub(crate) pointer: PointerDispatcher,
pub(crate) keyboard: KeyboardDispatcher, pub(crate) keyboard: KeyboardDispatcher,
@ -87,7 +86,6 @@ impl WaylandConnection {
windows: RefCell::new(HashMap::new()), windows: RefCell::new(HashMap::new()),
keyboard, keyboard,
pointer: pointer.unwrap(), pointer: pointer.unwrap(),
#[cfg(feature = "opengl")]
gl_connection: RefCell::new(None), gl_connection: RefCell::new(None),
}) })
} }

View File

@ -27,7 +27,6 @@ use toolkit::reexports::client::protocol::wl_surface::WlSurface;
use toolkit::shm::MemPool; use toolkit::shm::MemPool;
use toolkit::window::{ButtonColorSpec, ColorSpec, ConceptConfig, ConceptFrame, Event}; use toolkit::window::{ButtonColorSpec, ColorSpec, ConceptConfig, ConceptFrame, Event};
use wayland_client::protocol::wl_data_device_manager::WlDataDeviceManager; use wayland_client::protocol::wl_data_device_manager::WlDataDeviceManager;
#[cfg(feature = "opengl")]
use wayland_egl::{is_available as egl_is_available, WlEglSurface}; use wayland_egl::{is_available as egl_is_available, WlEglSurface};
use wezterm_input_types::*; use wezterm_input_types::*;
@ -98,9 +97,7 @@ pub struct WaylandWindowInner {
// wegl_surface is listed before gl_state because it // wegl_surface is listed before gl_state because it
// must be dropped before gl_state otherwise the underlying // must be dropped before gl_state otherwise the underlying
// libraries will segfault on shutdown // libraries will segfault on shutdown
#[cfg(feature = "opengl")]
wegl_surface: Option<WlEglSurface>, wegl_surface: Option<WlEglSurface>,
#[cfg(feature = "opengl")]
gl_state: Option<Rc<glium::backend::Context>>, gl_state: Option<Rc<glium::backend::Context>>,
} }
@ -245,9 +242,7 @@ impl WaylandWindow {
modifiers: Modifiers::NONE, modifiers: Modifiers::NONE,
pending_event, pending_event,
pending_mouse, pending_mouse,
#[cfg(feature = "opengl")]
gl_state: None, gl_state: None,
#[cfg(feature = "opengl")]
wegl_surface: None, wegl_surface: None,
})); }));
@ -489,13 +484,10 @@ impl WaylandWindowInner {
self.dimensions = new_dimensions; self.dimensions = new_dimensions;
self.callbacks.resize(self.dimensions); self.callbacks.resize(self.dimensions);
#[cfg(feature = "opengl")]
{
if let Some(wegl_surface) = self.wegl_surface.as_mut() { if let Some(wegl_surface) = self.wegl_surface.as_mut() {
wegl_surface.resize(pixel_width, pixel_height, 0, 0); wegl_surface.resize(pixel_width, pixel_height, 0, 0);
} }
} }
}
self.refresh_frame(); self.refresh_frame();
self.need_paint = true; self.need_paint = true;
@ -514,7 +506,6 @@ impl WaylandWindowInner {
} }
} }
#[cfg(feature = "opengl")]
fn enable_opengl(&mut self) -> anyhow::Result<()> { fn enable_opengl(&mut self) -> anyhow::Result<()> {
let window = Window::Wayland(WaylandWindow(self.window_id)); let window = Window::Wayland(WaylandWindow(self.window_id));
let wayland_conn = Connection::get().unwrap().wayland(); let wayland_conn = Connection::get().unwrap().wayland();
@ -563,8 +554,6 @@ impl WaylandWindowInner {
} }
fn do_paint(&mut self) -> anyhow::Result<()> { fn do_paint(&mut self) -> anyhow::Result<()> {
#[cfg(feature = "opengl")]
{
if let Some(gl_context) = self.gl_state.as_ref() { if let Some(gl_context) = self.gl_state.as_ref() {
if gl_context.is_context_lost() { if gl_context.is_context_lost() {
log::error!("opengl context was lost; should reinit"); log::error!("opengl context was lost; should reinit");
@ -588,7 +577,6 @@ impl WaylandWindowInner {
self.need_paint = false; self.need_paint = false;
return Ok(()); return Ok(());
} }
}
if self.pool.is_used() { if self.pool.is_used() {
// Buffer still in use by server; retry later // Buffer still in use by server; retry later
@ -777,7 +765,6 @@ impl WindowOps for WaylandWindow {
}) })
} }
#[cfg(feature = "opengl")]
fn enable_opengl(&self) -> promise::Future<()> { fn enable_opengl(&self) -> promise::Future<()> {
WaylandConnection::with_window_inner(self.0, move |inner| inner.enable_opengl()) WaylandConnection::with_window_inner(self.0, move |inner| inner.enable_opengl())
} }

View File

@ -18,7 +18,6 @@ pub struct Connection {
event_handle: HANDLE, event_handle: HANDLE,
pub(crate) windows: RefCell<HashMap<HWindow, Rc<RefCell<WindowInner>>>>, pub(crate) windows: RefCell<HashMap<HWindow, Rc<RefCell<WindowInner>>>>,
timers: RefCell<HashMap<UINT_PTR, UINT_PTR>>, timers: RefCell<HashMap<UINT_PTR, UINT_PTR>>,
#[cfg(feature = "opengl")]
pub(crate) gl_connection: RefCell<Option<Rc<crate::egl::GlConnection>>>, pub(crate) gl_connection: RefCell<Option<Rc<crate::egl::GlConnection>>>,
} }
@ -99,7 +98,6 @@ impl Connection {
event_handle, event_handle,
windows: RefCell::new(HashMap::new()), windows: RefCell::new(HashMap::new()),
timers: RefCell::new(HashMap::new()), timers: RefCell::new(HashMap::new()),
#[cfg(feature = "opengl")]
gl_connection: RefCell::new(None), gl_connection: RefCell::new(None),
}) })
} }

View File

@ -1,5 +1,3 @@
#![cfg(feature = "opengl")]
use super::*; use super::*;
use crate::is_swrast_preferred; use crate::is_swrast_preferred;
use glium::backend::Backend; use glium::backend::Backend;

View File

@ -45,7 +45,6 @@ pub(crate) struct WindowInner {
hwnd: HWindow, hwnd: HWindow,
callbacks: RefCell<Box<dyn WindowCallbacks>>, callbacks: RefCell<Box<dyn WindowCallbacks>>,
bitmap: RefCell<GdiBitmap>, bitmap: RefCell<GdiBitmap>,
#[cfg(feature = "opengl")]
gl_state: Option<Rc<glium::backend::Context>>, gl_state: Option<Rc<glium::backend::Context>>,
/// Fraction of mouse scroll /// Fraction of mouse scroll
hscroll_remainder: i16, hscroll_remainder: i16,
@ -111,7 +110,6 @@ fn take_rc_from_pointer(lparam: LPVOID) -> Rc<RefCell<WindowInner>> {
unsafe { Rc::from_raw(std::mem::transmute(lparam)) } unsafe { Rc::from_raw(std::mem::transmute(lparam)) }
} }
#[cfg(feature = "opengl")]
fn callback_behavior() -> glium::debug::DebugCallbackBehavior { fn callback_behavior() -> glium::debug::DebugCallbackBehavior {
if cfg!(debug_assertions) && false if cfg!(debug_assertions) && false
/* https://github.com/glium/glium/issues/1885 */ /* https://github.com/glium/glium/issues/1885 */
@ -123,7 +121,6 @@ fn callback_behavior() -> glium::debug::DebugCallbackBehavior {
} }
impl WindowInner { impl WindowInner {
#[cfg(feature = "opengl")]
fn enable_opengl(&mut self) -> anyhow::Result<()> { fn enable_opengl(&mut self) -> anyhow::Result<()> {
let window = Window(self.hwnd); let window = Window(self.hwnd);
let conn = Connection::get().unwrap(); let conn = Connection::get().unwrap();
@ -299,7 +296,6 @@ impl Window {
hwnd: HWindow(null_mut()), hwnd: HWindow(null_mut()),
callbacks: RefCell::new(callbacks), callbacks: RefCell::new(callbacks),
bitmap: RefCell::new(GdiBitmap::new_empty()), bitmap: RefCell::new(GdiBitmap::new_empty()),
#[cfg(feature = "opengl")]
gl_state: None, gl_state: None,
vscroll_remainder: 0, vscroll_remainder: 0,
hscroll_remainder: 0, hscroll_remainder: 0,
@ -512,7 +508,6 @@ impl WindowOps for Window {
}) })
} }
#[cfg(feature = "opengl")]
fn enable_opengl(&self) -> promise::Future<()> { fn enable_opengl(&self) -> promise::Future<()> {
Connection::with_window_inner(self.0, move |inner| inner.enable_opengl()) Connection::with_window_inner(self.0, move |inner| inner.enable_opengl())
} }
@ -784,8 +779,6 @@ unsafe fn wm_paint(hwnd: HWND, _msg: UINT, _wparam: WPARAM, _lparam: LPARAM) ->
let width = rect_width(&rect) as usize; let width = rect_width(&rect) as usize;
let height = rect_height(&rect) as usize; let height = rect_height(&rect) as usize;
#[cfg(feature = "opengl")]
{
if let Some(gl_context) = inner.gl_state.as_ref() { if let Some(gl_context) = inner.gl_state.as_ref() {
if gl_context.is_context_lost() { if gl_context.is_context_lost() {
log::error!("opengl context was lost; should reinit"); log::error!("opengl context was lost; should reinit");
@ -804,7 +797,6 @@ unsafe fn wm_paint(hwnd: HWND, _msg: UINT, _wparam: WPARAM, _lparam: LPARAM) ->
EndPaint(hwnd, &mut ps); EndPaint(hwnd, &mut ps);
return Some(0); return Some(0);
} }
}
if width > 0 && height > 0 { if width > 0 && height > 0 {
let mut bitmap = inner.bitmap.borrow_mut(); let mut bitmap = inner.bitmap.borrow_mut();

View File

@ -10,7 +10,6 @@ use mio::{Evented, Events, Poll, PollOpt, Ready, Token};
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::HashMap; use std::collections::HashMap;
use std::os::unix::io::AsRawFd; use std::os::unix::io::AsRawFd;
#[cfg(feature = "opengl")]
use std::rc::Rc; use std::rc::Rc;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant}; use std::time::{Duration, Instant};
@ -36,7 +35,6 @@ pub struct XConnection {
timers: RefCell<TimerList>, timers: RefCell<TimerList>,
pub(crate) visual: xcb::xproto::Visualtype, pub(crate) visual: xcb::xproto::Visualtype,
pub(crate) depth: u8, pub(crate) depth: u8,
#[cfg(feature = "opengl")]
pub(crate) gl_connection: RefCell<Option<Rc<crate::egl::GlConnection>>>, pub(crate) gl_connection: RefCell<Option<Rc<crate::egl::GlConnection>>>,
} }
@ -413,7 +411,6 @@ impl XConnection {
timers: RefCell::new(TimerList::new()), timers: RefCell::new(TimerList::new()),
depth, depth,
visual, visual,
#[cfg(feature = "opengl")]
gl_connection: RefCell::new(None), gl_connection: RefCell::new(None),
}; };

View File

@ -50,7 +50,6 @@ pub(crate) struct XWindowInner {
cursor: Option<MouseCursor>, cursor: Option<MouseCursor>,
cursors: HashMap<Option<MouseCursor>, XcbCursor>, cursors: HashMap<Option<MouseCursor>, XcbCursor>,
copy_and_paste: CopyAndPaste, copy_and_paste: CopyAndPaste,
#[cfg(feature = "opengl")]
gl_state: Option<Rc<glium::backend::Context>>, gl_state: Option<Rc<glium::backend::Context>>,
} }
@ -111,7 +110,6 @@ impl<'a> PaintContext for X11GraphicsContext<'a> {
} }
impl XWindowInner { impl XWindowInner {
#[cfg(feature = "opengl")]
fn enable_opengl(&mut self) -> anyhow::Result<()> { fn enable_opengl(&mut self) -> anyhow::Result<()> {
let window = XWindow(self.window_id); let window = XWindow(self.window_id);
let conn = self.conn(); let conn = self.conn();
@ -159,8 +157,6 @@ impl XWindowInner {
return Ok(()); return Ok(());
} }
#[cfg(feature = "opengl")]
{
if let Some(gl_context) = self.gl_state.as_ref() { if let Some(gl_context) = self.gl_state.as_ref() {
if gl_context.is_context_lost() { if gl_context.is_context_lost() {
log::error!("opengl context was lost; should reinit"); log::error!("opengl context was lost; should reinit");
@ -180,7 +176,6 @@ impl XWindowInner {
frame.finish()?; frame.finish()?;
return Ok(()); return Ok(());
} }
}
let (buf_width, buf_height) = self.buffer_image.image_dimensions(); let (buf_width, buf_height) = self.buffer_image.image_dimensions();
if buf_width != self.width.into() || buf_height != self.height.into() { if buf_width != self.width.into() || buf_height != self.height.into() {
@ -848,7 +843,6 @@ impl XWindow {
buffer_image, buffer_image,
cursor: None, cursor: None,
cursors: HashMap::new(), cursors: HashMap::new(),
#[cfg(feature = "opengl")]
gl_state: None, gl_state: None,
})) }))
}; };
@ -1061,7 +1055,6 @@ impl WindowOps for XWindow {
}) })
} }
#[cfg(feature = "opengl")]
fn enable_opengl(&self) -> promise::Future<()> { fn enable_opengl(&self) -> promise::Future<()> {
XConnection::with_window_inner(self.0, move |inner| inner.enable_opengl()) XConnection::with_window_inner(self.0, move |inner| inner.enable_opengl())
} }

View File

@ -213,7 +213,6 @@ impl WindowOps for Window {
} }
} }
#[cfg(feature = "opengl")]
fn enable_opengl(&self) -> promise::Future<()> { fn enable_opengl(&self) -> promise::Future<()> {
match self { match self {
Self::X11(x) => x.enable_opengl(), Self::X11(x) => x.enable_opengl(),