start making it possible not to build winit+glutin

This commit is contained in:
Wez Furlong committed 2019-10-26 09:51:29 -07:00
1 parent ba56a86201
commit 95d3fb7aeb
5 files changed
+27 -3

No files matched your search

+4 -2
View File
@@ -26,7 +26,7 @@ failure = "0.1"
failure_derive = "0.1"
foreign-types = "0.3"
freetype = { path = "deps/freetype" }
glium = { version = "0.24", default-features = false, features = ["glutin", "icon_loading"]}
glium = { optional=true, version = "0.24", default-features = false, features = ["glutin", "icon_loading"]}
harfbuzz = { path = "deps/harfbuzz" }
lazy_static = "1.3"
leb128 = "0.2"
@@ -52,7 +52,7 @@ toml = "0.4"
unicode-normalization = "0.1"
unicode-width = "0.1"
varbincode = "0.1"
winit = "0.19"
winit = {version="0.19",optional=true}
window = { path = "window", features=["opengl"]}
zstd = "0.4"
@@ -101,7 +101,9 @@ core-graphics = "0.17"
core-text = "13.2"
[features]
default = ["enable-winit"]
force-fontconfig = ["fontconfig"]
enable-winit = ["winit", "glium"]
[workspace]
+10
View File
@@ -1,3 +1,4 @@
#[cfg(feature = "enable-winit")]
use super::window::TerminalWindow;
use crate::font::{FontConfiguration, FontSystemSelection};
use crate::frontend::guicommon::clipboard::SystemClipboard;
@@ -37,6 +38,7 @@ pub enum KeyAssignment {
CloseCurrentTab,
}
#[cfg(feature = "enable-winit")]
pub trait HostHelper {
fn with_window<F: Send + 'static + Fn(&mut dyn TerminalWindow) -> Result<(), Error>>(
&self,
@@ -45,6 +47,7 @@ pub trait HostHelper {
fn toggle_full_screen(&mut self);
}
#[cfg(feature = "enable-winit")]
pub struct HostImpl<H: HostHelper> {
helper: H,
clipboard: Arc<dyn Clipboard>,
@@ -142,6 +145,7 @@ impl KeyMap {
}
}
#[cfg(feature = "enable-winit")]
impl<H: HostHelper> HostImpl<H> {
pub fn new(helper: H) -> Self {
Self {
@@ -280,12 +284,15 @@ impl<H: HostHelper> HostImpl<H> {
}
}
#[cfg(feature = "enable-winit")]
impl<H: HostHelper> Deref for HostImpl<H> {
type Target = H;
fn deref(&self) -> &H {
&self.helper
}
}
#[cfg(feature = "enable-winit")]
impl<H: HostHelper> DerefMut for HostImpl<H> {
fn deref_mut(&mut self) -> &mut H {
&mut self.helper
@@ -295,17 +302,20 @@ impl<H: HostHelper> DerefMut for HostImpl<H> {
/// Implements `TerminalHost` for a Tab.
/// `TabHost` instances are short lived and borrow references to
/// other state.
#[cfg(feature = "enable-winit")]
pub struct TabHost<'a, H: HostHelper> {
writer: &'a mut dyn std::io::Write,
host: &'a mut HostImpl<H>,
}
#[cfg(feature = "enable-winit")]
impl<'a, H: HostHelper> TabHost<'a, H> {
pub fn new(writer: &'a mut dyn std::io::Write, host: &'a mut HostImpl<H>) -> Self {
Self { writer, host }
}
}
#[cfg(feature = "enable-winit")]
impl<'a, H: HostHelper> term::TerminalHost for TabHost<'a, H> {
fn writer(&mut self) -> &mut dyn std::io::Write {
&mut self.writer
+4
View File
@@ -4,9 +4,12 @@ use crate::mux::domain::DomainId;
use crate::mux::tab::{Tab, TabId};
use crate::mux::window::WindowId;
use crate::mux::Mux;
#[cfg(feature = "enable-winit")]
use crate::opengl::render::Renderer;
#[cfg(feature = "enable-winit")]
use crate::opengl::textureatlas::OutOfTextureSpace;
use failure::{bail, ensure, format_err, Error};
#[cfg(feature = "enable-winit")]
use glium;
use log::{debug, error};
use portable_pty::PtySize;
@@ -41,6 +44,7 @@ pub struct Dimensions {
/// the different GUI systems.
/// A number of methods need to be provided by the window in order to
/// unlock the use of the provided methods towards the bottom of the trait.
#[cfg(feature = "enable-winit")]
pub trait TerminalWindow {
fn set_window_title(&mut self, title: &str) -> Result<(), Error>;
fn get_mux_window_id(&self) -> WindowId;
+7 -1
View File
@@ -12,6 +12,7 @@ use std::cell::RefCell;
use std::rc::Rc;
use std::sync::{Arc, Mutex};
#[cfg(feature = "enable-winit")]
pub mod glium;
pub mod guicommon;
pub mod muxserver;
@@ -33,8 +34,10 @@ impl Default for FrontEndSelection {
fn default() -> Self {
if cfg!(all(unix, not(target_os = "macos"))) {
FrontEndSelection::X11
} else {
} else if cfg!(feature = "enable-winit") {
FrontEndSelection::Glutin
} else {
FrontEndSelection::OpenGL
}
}
}
@@ -67,7 +70,10 @@ pub fn front_end() -> Option<Rc<dyn FrontEnd>> {
impl FrontEndSelection {
pub fn try_new(self, mux: &Rc<Mux>) -> Result<Rc<dyn FrontEnd>, Error> {
let front_end = match self {
#[cfg(feature = "enable-winit")]
FrontEndSelection::Glutin => glium::glutinloop::GlutinFrontEnd::try_new(mux),
#[cfg(not(feature = "enable-winit"))]
FrontEndSelection::Glutin => failure::bail!("Glutin not compiled in"),
#[cfg(all(unix, not(target_os = "macos")))]
FrontEndSelection::X11 => xwindows::x11loop::X11FrontEnd::try_new(mux),
#[cfg(not(all(unix, not(target_os = "macos"))))]
+2
View File
@@ -17,6 +17,8 @@ use std::sync::Arc;
mod config;
mod frontend;
mod mux;
#[cfg(feature = "enable-winit")]
mod opengl;
mod ratelim;
mod server;