Skip to content

Commit

Permalink
add feature to force building with glutin on linux
Browse files Browse the repository at this point in the history
this helps me verify from WSL that I didn't break compilation in
the refactoring to follow
  • Loading branch information
wez committed Feb 16, 2019
1 parent 9bc99f5 commit d95da9c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 28 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@ core-text = "~9.2"

[features]
debug-escape-sequences = ["term/debug-escape-sequences"]
force-glutin = []

[workspace]
10 changes: 5 additions & 5 deletions src/gliumwindows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use font::FontConfiguration;
use futures;
use glium;
use glium::glutin::{self, ElementState, MouseCursor};
use guiloop::GuiEventLoop;
use guiloop::{GuiEventLoop, SessionTerminated};
use opengl::render::Renderer;
use opengl::textureatlas::OutOfTextureSpace;
use pty::MasterPty;
Expand All @@ -18,11 +18,11 @@ use std::io::{Read, Write};
use std::os::unix::io::{AsRawFd, RawFd};
use std::process::{Child, Command, ExitStatus};
use std::rc::Rc;
use term::hyperlink::Hyperlink;
use term::KeyCode;
use term::KeyModifiers;
use term::{self, Terminal};
use term::{MouseButton, MouseEventKind};
use termwiz::hyperlink::Hyperlink;

struct Host {
display: glium::Display,
Expand All @@ -41,10 +41,10 @@ impl term::TerminalHost for Host {
fn click_link(&mut self, link: &Rc<Hyperlink>) {
// TODO: make this configurable
let mut cmd = Command::new("xdg-open");
cmd.arg(&link.url);
cmd.arg(link.uri());
match cmd.spawn() {
Ok(_) => {}
Err(err) => eprintln!("failed to spawn xdg-open {}: {:?}", link.url, err),
Err(err) => eprintln!("failed to spawn xdg-open {}: {:?}", link.uri(), err),
}
}

Expand Down Expand Up @@ -533,7 +533,7 @@ impl TerminalWindow {
event: WindowEvent::Moved(x, y),
..
} => {
self.window_position = Some((x, y));
self.host.window_position = Some((x, y));
}
Event::WindowEvent {
event: WindowEvent::ReceivedCharacter(c),
Expand Down
12 changes: 6 additions & 6 deletions src/guiloop/glutinloop.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use failure::Error;
use futures::{future, Future};
use glium;
use glium::glutin::{EventsLoopProxy, WindowId};
use glium::glutin::EventsLoopProxy;
use mio;
use mio::{PollOpt, Ready, Token};
use std::cell::RefCell;
Expand All @@ -12,6 +12,9 @@ use std::rc::Rc;
use std::sync::mpsc::{self, Receiver, Sender, TryRecvError};
use std::time::Duration;

pub use glium::glutin::WindowId;
pub use gliumwindows::TerminalWindow;

use futurecore;
use gliumwindows;
use remotemio;
Expand Down Expand Up @@ -115,7 +118,7 @@ impl GuiEventLoop {
let dead = match self.windows.borrow_mut().by_id.get_mut(&window_id) {
Some(window) => match window.dispatch_event(event) {
Ok(_) => None,
Err(err) => match err.downcast_ref::<gliumwindows::SessionTerminated>() {
Err(err) => match err.downcast_ref::<super::SessionTerminated>() {
Some(_) => Some(window_id),
_ => return Err(err),
},
Expand Down Expand Up @@ -187,10 +190,7 @@ impl GuiEventLoop {
};

if let Err(err) = result {
if err
.downcast_ref::<gliumwindows::SessionTerminated>()
.is_some()
{
if err.downcast_ref::<super::SessionTerminated>().is_some() {
self.schedule_window_close(window_id)?;
} else {
bail!("{:?}", err);
Expand Down
22 changes: 8 additions & 14 deletions src/guiloop/mod.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
use failure::Error;
use std::process::ExitStatus;

#[cfg(any(windows, target_os = "macos"))]
#[cfg(any(windows, feature = "force-glutin", target_os = "macos"))]
mod glutinloop;

#[cfg(any(windows, target_os = "macos"))]
pub use glutinloop::{GuiEventLoop, GuiSender};
#[cfg(any(windows, feature = "force-glutin", target_os = "macos"))]
pub use self::glutinloop::{GuiEventLoop, GuiSender, TerminalWindow, WindowId};

#[cfg(any(windows, target_os = "macos"))]
pub use gliumwindows::TerminalWindow;
#[cfg(any(windows, feature = "force-glutin", target_os = "macos"))]
pub use std::sync::mpsc::Receiver as GuiReceiver;

#[cfg(any(windows, target_os = "macos"))]
pub use mpsc::Receiver as GuiReceiver;

#[cfg(any(windows, target_os = "macos"))]
pub use glium::glutin::WindowId;

#[cfg(all(unix, not(target_os = "macos")))]
#[cfg(all(unix, not(feature = "force-glutin"), not(target_os = "macos")))]
pub use xwindows::xwin::TerminalWindow;

#[cfg(all(unix, not(target_os = "macos")))]
#[cfg(all(unix, not(feature = "force-glutin"), not(target_os = "macos")))]
mod x11;

#[cfg(all(unix, not(target_os = "macos")))]
#[cfg(all(unix, not(feature = "force-glutin"), not(target_os = "macos")))]
pub use self::x11::*;

#[derive(Debug, Fail)]
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extern crate x11;
extern crate xcb;
#[cfg(all(unix, not(target_os = "macos")))]
extern crate xcb_util;
#[cfg(all(unix, not(target_os = "macos")))]
#[cfg(all(unix, not(feature = "force-glutin"), not(target_os = "macos")))]
mod xwindows;

use std::process::Command;
Expand All @@ -51,11 +51,11 @@ mod config;

mod futurecore;
mod opengl;
#[cfg(any(windows,target_os = "macos"))]
#[cfg(any(windows, feature = "force-glutin", target_os = "macos"))]
mod remotemio;

mod clipboard;
#[cfg(any(windows,target_os = "macos"))]
#[cfg(any(windows, feature = "force-glutin", target_os = "macos"))]
mod gliumwindows;
mod guiloop;

Expand Down

0 comments on commit d95da9c

Please sign in to comment.