We can now spawn additional windows
However, https://github.com/tomaka/winit/issues/414 makes this unsafe.
This commit is contained in:
1 parent
4089649d8c
commit
6623e1ff86
3 files changed
+34
-18
No files matched your search
+28
-2
@@ -1,9 +1,12 @@
|
||||
//! Generic system dependent windows via glium+glutin
|
||||
#![allow(dead_code)]
|
||||
|
||||
use super::{spawn_window, GuiEventLoop};
|
||||
use clipboard::{Clipboard, ClipboardImpl, Paste};
|
||||
use config::Config;
|
||||
use failure::Error;
|
||||
use font::FontConfiguration;
|
||||
use futures;
|
||||
use glium::{self, glutin};
|
||||
use glium::glutin::{ElementState, MouseCursor};
|
||||
use opengl::render::Renderer;
|
||||
@@ -64,6 +67,8 @@ impl term::TerminalHost for Host {
|
||||
|
||||
pub struct TerminalWindow {
|
||||
host: Host,
|
||||
event_loop: Rc<GuiEventLoop>,
|
||||
config: Rc<Config>,
|
||||
renderer: Renderer,
|
||||
width: u16,
|
||||
height: u16,
|
||||
@@ -81,13 +86,19 @@ pub struct TerminalWindow {
|
||||
|
||||
impl TerminalWindow {
|
||||
pub fn new(
|
||||
event_loop: &super::GuiEventLoop,
|
||||
event_loop: &Rc<GuiEventLoop>,
|
||||
terminal: Terminal,
|
||||
pty: MasterPty,
|
||||
process: Child,
|
||||
fonts: &Rc<FontConfiguration>,
|
||||
palette: term::color::ColorPalette,
|
||||
config: &Rc<Config>,
|
||||
) -> Result<TerminalWindow, Error> {
|
||||
let palette = config
|
||||
.colors
|
||||
.as_ref()
|
||||
.map(|p| p.clone().into())
|
||||
.unwrap_or_else(term::color::ColorPalette::default);
|
||||
|
||||
let (cell_height, cell_width) = {
|
||||
// Urgh, this is a bit repeaty, but we need to satisfy the borrow checker
|
||||
let font = fonts.default_font()?;
|
||||
@@ -126,6 +137,8 @@ impl TerminalWindow {
|
||||
|
||||
Ok(TerminalWindow {
|
||||
host,
|
||||
event_loop: Rc::clone(event_loop),
|
||||
config: Rc::clone(config),
|
||||
renderer,
|
||||
width,
|
||||
height,
|
||||
@@ -518,6 +531,19 @@ impl TerminalWindow {
|
||||
self.is_fullscreen = self.window_position.take();
|
||||
window.set_fullscreen(Some(window.get_current_monitor()));
|
||||
}
|
||||
} else if c == 'y' && self.last_modifiers.contains(KeyModifiers::SUPER) {
|
||||
// CMD-y to open a new window
|
||||
println!("open a new one!");
|
||||
let event_loop = Rc::clone(&self.event_loop);
|
||||
let config = Rc::clone(&self.config);
|
||||
let fonts = Rc::clone(&self.renderer.fonts);
|
||||
self.event_loop
|
||||
.core
|
||||
.spawn(futures::future::poll_fn(move || {
|
||||
spawn_window(&event_loop, None, &config, &fonts)
|
||||
.map(futures::Async::Ready)
|
||||
.map_err(|_| ())
|
||||
}));
|
||||
} else {
|
||||
self.terminal
|
||||
.key_down(KeyCode::Char(c), self.last_modifiers, &mut self.host)?;
|
||||
|
||||
+5
-15
@@ -103,7 +103,7 @@ struct Windows {
|
||||
pub struct GuiEventLoop {
|
||||
event_loop: RefCell<glium::glutin::EventsLoop>,
|
||||
windows: Rc<RefCell<Windows>>,
|
||||
core: futurecore::Core,
|
||||
pub core: futurecore::Core,
|
||||
poll: remotemio::IOMgr,
|
||||
poll_rx: Receiver<remotemio::Notification>,
|
||||
paster: GuiSender<WindowId>,
|
||||
@@ -403,7 +403,7 @@ fn run() -> Result<(), Error> {
|
||||
None
|
||||
};
|
||||
|
||||
let event_loop = GuiEventLoop::new()?;
|
||||
let event_loop = Rc::new(GuiEventLoop::new()?);
|
||||
|
||||
spawn_window(&event_loop, cmd, &config, &fontconfig)?;
|
||||
|
||||
@@ -412,7 +412,7 @@ fn run() -> Result<(), Error> {
|
||||
}
|
||||
|
||||
fn spawn_window(
|
||||
event_loop: &GuiEventLoop,
|
||||
event_loop: &Rc<GuiEventLoop>,
|
||||
cmd: Option<Vec<&std::ffi::OsStr>>,
|
||||
config: &Rc<config::Config>,
|
||||
fontconfig: &Rc<FontConfiguration>,
|
||||
@@ -458,18 +458,8 @@ fn spawn_window(
|
||||
config.hyperlink_rules.clone(),
|
||||
);
|
||||
|
||||
let window = gliumwindows::TerminalWindow::new(
|
||||
event_loop,
|
||||
terminal,
|
||||
master,
|
||||
child,
|
||||
fontconfig,
|
||||
config
|
||||
.colors
|
||||
.as_ref()
|
||||
.map(|p| p.clone().into())
|
||||
.unwrap_or_else(term::color::ColorPalette::default),
|
||||
)?;
|
||||
let window =
|
||||
gliumwindows::TerminalWindow::new(event_loop, terminal, master, child, fontconfig, config)?;
|
||||
|
||||
event_loop.add_window(window)
|
||||
}
|
||||
|
||||
@@ -248,7 +248,7 @@ void main() {
|
||||
pub struct Renderer {
|
||||
width: u16,
|
||||
height: u16,
|
||||
fonts: Rc<FontConfiguration>,
|
||||
pub fonts: Rc<FontConfiguration>,
|
||||
cell_height: usize,
|
||||
cell_width: usize,
|
||||
descender: isize,
|
||||
|
||||
Reference in new issue
Block a user