mirror of
https://github.com/wez/wezterm.git
synced 2024-12-25 22:33:52 +03:00
GuiSystem -> FrontEnd
This commit is contained in:
parent
943fd74d5e
commit
c6acc36ee5
@ -2,7 +2,7 @@ use crate::config::Config;
|
||||
use crate::font::{FontConfiguration, FontSystemSelection};
|
||||
use crate::frontend::glium::window::GliumTerminalWindow;
|
||||
use crate::frontend::guicommon::window::TerminalWindow;
|
||||
use crate::frontend::guiloop::GuiSystem;
|
||||
use crate::frontend::FrontEnd;
|
||||
use crate::mux::tab::Tab;
|
||||
use crate::mux::{Mux, SessionTerminated};
|
||||
use crate::spawn_tab;
|
||||
@ -82,7 +82,7 @@ pub struct GuiEventLoop {
|
||||
const TICK_INTERVAL: Duration = Duration::from_millis(50);
|
||||
const MAX_POLL_LOOP_DURATION: Duration = Duration::from_millis(500);
|
||||
|
||||
pub struct GlutinGuiSystem {
|
||||
pub struct GlutinFrontEnd {
|
||||
event_loop: Rc<GuiEventLoop>,
|
||||
}
|
||||
|
||||
@ -90,15 +90,15 @@ thread_local! {
|
||||
static GLUTIN_EVENT_LOOP: RefCell<Option<Rc<GuiEventLoop>>> = RefCell::new(None);
|
||||
}
|
||||
|
||||
impl GlutinGuiSystem {
|
||||
pub fn try_new(mux: &Rc<Mux>) -> Result<Rc<GuiSystem>, Error> {
|
||||
impl GlutinFrontEnd {
|
||||
pub fn try_new(mux: &Rc<Mux>) -> Result<Rc<FrontEnd>, Error> {
|
||||
let event_loop = Rc::new(GuiEventLoop::new(mux)?);
|
||||
GLUTIN_EVENT_LOOP.with(|f| *f.borrow_mut() = Some(Rc::clone(&event_loop)));
|
||||
Ok(Rc::new(Self { event_loop }))
|
||||
}
|
||||
}
|
||||
|
||||
impl GuiSystem for GlutinGuiSystem {
|
||||
impl FrontEnd for GlutinFrontEnd {
|
||||
fn gui_executor(&self) -> Box<Executor> {
|
||||
self.event_loop.gui_executor()
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
use crate::config::Config;
|
||||
use crate::font::FontConfiguration;
|
||||
use crate::mux::tab::Tab;
|
||||
use failure::Error;
|
||||
use promise::Executor;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub trait GuiSystem {
|
||||
/// Run the event loop. Does not return until there is either a fatal
|
||||
/// error, or until there are no more windows left to manage.
|
||||
fn run_forever(&self) -> Result<(), Error>;
|
||||
|
||||
fn spawn_new_window(
|
||||
&self,
|
||||
config: &Arc<Config>,
|
||||
fontconfig: &Rc<FontConfiguration>,
|
||||
tab: &Rc<Tab>,
|
||||
) -> Result<(), Error>;
|
||||
|
||||
fn gui_executor(&self) -> Box<Executor>;
|
||||
}
|
@ -1,10 +1,13 @@
|
||||
use crate::config::Config;
|
||||
use crate::font::FontConfiguration;
|
||||
use crate::mux::tab::Tab;
|
||||
use crate::mux::Mux;
|
||||
use failure::Error;
|
||||
use guiloop::GuiSystem;
|
||||
use promise::Executor;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub mod guicommon;
|
||||
pub mod guiloop;
|
||||
|
||||
pub mod glium;
|
||||
#[cfg(all(unix, not(feature = "force-glutin"), not(target_os = "macos")))]
|
||||
@ -29,11 +32,11 @@ impl Default for FrontEndSelection {
|
||||
}
|
||||
|
||||
impl FrontEndSelection {
|
||||
pub fn try_new(self, mux: &Rc<Mux>) -> Result<Rc<GuiSystem>, Error> {
|
||||
pub fn try_new(self, mux: &Rc<Mux>) -> Result<Rc<FrontEnd>, Error> {
|
||||
let system = match self {
|
||||
FrontEndSelection::Glutin => glium::glutinloop::GlutinGuiSystem::try_new(mux),
|
||||
FrontEndSelection::Glutin => glium::glutinloop::GlutinFrontEnd::try_new(mux),
|
||||
#[cfg(all(unix, not(target_os = "macos")))]
|
||||
FrontEndSelection::X11 => xwindows::x11loop::X11GuiSystem::try_new(mux),
|
||||
FrontEndSelection::X11 => xwindows::x11loop::X11FrontEnd::try_new(mux),
|
||||
#[cfg(not(all(unix, not(target_os = "macos"))))]
|
||||
FrontEndSelection::X11 => bail!("X11 not compiled in"),
|
||||
};
|
||||
@ -60,3 +63,18 @@ impl std::str::FromStr for FrontEndSelection {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait FrontEnd {
|
||||
/// Run the event loop. Does not return until there is either a fatal
|
||||
/// error, or until there are no more windows left to manage.
|
||||
fn run_forever(&self) -> Result<(), Error>;
|
||||
|
||||
fn spawn_new_window(
|
||||
&self,
|
||||
config: &Arc<Config>,
|
||||
fontconfig: &Rc<FontConfiguration>,
|
||||
tab: &Rc<Tab>,
|
||||
) -> Result<(), Error>;
|
||||
|
||||
fn gui_executor(&self) -> Box<Executor>;
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
use crate::config::Config;
|
||||
use crate::font::{FontConfiguration, FontSystemSelection};
|
||||
use crate::frontend::guicommon::window::TerminalWindow;
|
||||
use crate::frontend::guiloop::GuiSystem;
|
||||
use crate::frontend::xwindows::xwin::X11TerminalWindow;
|
||||
use crate::frontend::xwindows::Connection;
|
||||
use crate::frontend::FrontEnd;
|
||||
use crate::mux::tab::Tab;
|
||||
use crate::mux::Mux;
|
||||
use crate::spawn_tab;
|
||||
@ -55,11 +55,11 @@ pub struct GuiEventLoop {
|
||||
const TOK_XCB: usize = 0xffff_fffc;
|
||||
const TOK_GUI_EXEC: usize = 0xffff_fffd;
|
||||
|
||||
pub struct X11GuiSystem {
|
||||
pub struct X11FrontEnd {
|
||||
event_loop: Rc<GuiEventLoop>,
|
||||
}
|
||||
impl X11GuiSystem {
|
||||
pub fn try_new(mux: &Rc<Mux>) -> Result<Rc<GuiSystem>, Error> {
|
||||
impl X11FrontEnd {
|
||||
pub fn try_new(mux: &Rc<Mux>) -> Result<Rc<FrontEnd>, Error> {
|
||||
let event_loop = Rc::new(GuiEventLoop::new(mux)?);
|
||||
X11_EVENT_LOOP.with(|f| *f.borrow_mut() = Some(Rc::clone(&event_loop)));
|
||||
Ok(Rc::new(Self { event_loop }))
|
||||
@ -70,7 +70,7 @@ thread_local! {
|
||||
static X11_EVENT_LOOP: RefCell<Option<Rc<GuiEventLoop>>> = RefCell::new(None);
|
||||
}
|
||||
|
||||
impl GuiSystem for X11GuiSystem {
|
||||
impl FrontEnd for X11FrontEnd {
|
||||
fn gui_executor(&self) -> Box<Executor> {
|
||||
self.event_loop.gui_executor()
|
||||
}
|
||||
|
@ -19,8 +19,7 @@ mod mux;
|
||||
mod opengl;
|
||||
mod server;
|
||||
use crate::frontend::guicommon::localtab::LocalTab;
|
||||
use crate::frontend::guiloop::GuiSystem;
|
||||
use crate::frontend::FrontEndSelection;
|
||||
use crate::frontend::{FrontEnd, FrontEndSelection};
|
||||
use crate::mux::tab::Tab;
|
||||
use crate::mux::Mux;
|
||||
|
||||
@ -175,7 +174,7 @@ fn spawn_tab(
|
||||
|
||||
fn spawn_window(
|
||||
mux: &Rc<Mux>,
|
||||
gui: &GuiSystem,
|
||||
gui: &FrontEnd,
|
||||
cmd: Option<Vec<&std::ffi::OsStr>>,
|
||||
config: &Arc<config::Config>,
|
||||
fontconfig: &Rc<FontConfiguration>,
|
||||
|
Loading…
Reference in New Issue
Block a user