Rc<Config> -> Arc<Config>
This commit is contained in:
1 parent
1d37e44b62
commit
2ece60b45c
8 files changed
+31
-27
No files matched your search
+3
-2
@@ -8,6 +8,7 @@ use self::hbwrap as harfbuzz;
|
||||
use std::cell::RefCell;
|
||||
use std::collections::HashMap;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub mod system;
|
||||
pub use self::system::*;
|
||||
@@ -34,7 +35,7 @@ type FontPtr = Rc<RefCell<Box<NamedFont>>>;
|
||||
|
||||
/// Matches and loads fonts for a given input style
|
||||
pub struct FontConfiguration {
|
||||
config: Rc<Config>,
|
||||
config: Arc<Config>,
|
||||
fonts: RefCell<HashMap<TextStyle, FontPtr>>,
|
||||
system: Rc<FontSystem>,
|
||||
metrics: RefCell<Option<FontMetrics>>,
|
||||
@@ -120,7 +121,7 @@ impl std::str::FromStr for FontSystemSelection {
|
||||
|
||||
impl FontConfiguration {
|
||||
/// Create a new empty configuration
|
||||
pub fn new(config: Rc<Config>, system: FontSystemSelection) -> Self {
|
||||
pub fn new(config: Arc<Config>, system: FontSystemSelection) -> Self {
|
||||
Self {
|
||||
config,
|
||||
fonts: RefCell::new(HashMap::new()),
|
||||
|
||||
+7
-6
@@ -14,6 +14,7 @@ use glium;
|
||||
use glium::glutin::dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize};
|
||||
use glium::glutin::{self, ElementState, MouseCursor};
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
use term;
|
||||
use term::KeyCode;
|
||||
use term::KeyModifiers;
|
||||
@@ -28,7 +29,7 @@ struct Host {
|
||||
/// if is_some, holds position to be restored after exiting
|
||||
/// fullscreen mode.
|
||||
is_fullscreen: Option<LogicalPosition>,
|
||||
config: Rc<Config>,
|
||||
config: Arc<Config>,
|
||||
fonts: Rc<FontConfiguration>,
|
||||
}
|
||||
|
||||
@@ -71,7 +72,7 @@ impl HostHelper for Host {
|
||||
pub struct GliumTerminalWindow {
|
||||
host: HostImpl<Host>,
|
||||
event_loop: Rc<GuiEventLoop>,
|
||||
config: Rc<Config>,
|
||||
config: Arc<Config>,
|
||||
fonts: Rc<FontConfiguration>,
|
||||
renderer: Renderer,
|
||||
width: u16,
|
||||
@@ -92,7 +93,7 @@ impl TerminalWindow for GliumTerminalWindow {
|
||||
fn get_tabs_mut(&mut self) -> &mut Tabs {
|
||||
&mut self.tabs
|
||||
}
|
||||
fn config(&self) -> &Rc<Config> {
|
||||
fn config(&self) -> &Arc<Config> {
|
||||
&self.config
|
||||
}
|
||||
fn fonts(&self) -> &Rc<FontConfiguration> {
|
||||
@@ -189,7 +190,7 @@ impl GliumTerminalWindow {
|
||||
pub fn new(
|
||||
event_loop: &Rc<GuiEventLoop>,
|
||||
fonts: &Rc<FontConfiguration>,
|
||||
config: &Rc<Config>,
|
||||
config: &Arc<Config>,
|
||||
tab: &Rc<Tab>,
|
||||
) -> Result<GliumTerminalWindow, Error> {
|
||||
let palette = config
|
||||
@@ -232,7 +233,7 @@ impl GliumTerminalWindow {
|
||||
display,
|
||||
window_position,
|
||||
is_fullscreen: None,
|
||||
config: Rc::clone(config),
|
||||
config: Arc::clone(config),
|
||||
fonts: Rc::clone(fonts),
|
||||
});
|
||||
|
||||
@@ -245,7 +246,7 @@ impl GliumTerminalWindow {
|
||||
Ok(GliumTerminalWindow {
|
||||
host,
|
||||
event_loop: Rc::clone(event_loop),
|
||||
config: Rc::clone(config),
|
||||
config: Arc::clone(config),
|
||||
fonts: Rc::clone(fonts),
|
||||
renderer,
|
||||
width,
|
||||
|
||||
@@ -8,6 +8,7 @@ use crate::openpty;
|
||||
use failure::Error;
|
||||
use glium;
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Reports the currently configured physical size of the display
|
||||
/// surface (physical pixels, not adjusted for dpi) and the current
|
||||
@@ -39,7 +40,7 @@ pub trait TerminalWindow {
|
||||
fn advise_renderer_of_resize(&mut self, width: u16, height: u16) -> Result<(), Error>;
|
||||
fn tab_was_created(&mut self, tab: &Rc<Tab>) -> Result<(), Error>;
|
||||
fn deregister_tab(&mut self, tab_id: TabId) -> Result<(), Error>;
|
||||
fn config(&self) -> &Rc<Config>;
|
||||
fn config(&self) -> &Arc<Config>;
|
||||
fn fonts(&self) -> &Rc<FontConfiguration>;
|
||||
fn get_dimensions(&self) -> Dimensions;
|
||||
fn resize_if_not_full_screen(&mut self, width: u16, height: u16) -> Result<bool, Error>;
|
||||
|
||||
@@ -168,8 +168,8 @@ impl GuiSystem for GlutinGuiSystem {
|
||||
|
||||
fn spawn_new_window(
|
||||
&self,
|
||||
config: &Rc<crate::config::Config>,
|
||||
fontconfig: &Rc<crate::font::FontConfiguration>,
|
||||
config: &Arc<Config>,
|
||||
fontconfig: &Rc<FontConfiguration>,
|
||||
tab: &Rc<Tab>,
|
||||
) -> Result<(), Error> {
|
||||
let window = GliumTerminalWindow::new(&self.event_loop, fontconfig, config, tab)?;
|
||||
@@ -228,7 +228,7 @@ impl GuiEventLoop {
|
||||
|
||||
fn do_spawn_new_window(
|
||||
events: &Rc<Self>,
|
||||
config: &Rc<Config>,
|
||||
config: &Arc<Config>,
|
||||
fonts: &Rc<FontConfiguration>,
|
||||
) -> Result<(), Error> {
|
||||
let tab = spawn_tab(&config, None)?;
|
||||
@@ -241,11 +241,11 @@ impl GuiEventLoop {
|
||||
|
||||
pub fn schedule_spawn_new_window(
|
||||
events: &Rc<Self>,
|
||||
config: &Rc<Config>,
|
||||
config: &Arc<Config>,
|
||||
fonts: &Rc<FontConfiguration>,
|
||||
) {
|
||||
let myself = Rc::clone(events);
|
||||
let config = Rc::clone(config);
|
||||
let config = Arc::clone(config);
|
||||
let fonts = Rc::clone(fonts);
|
||||
events.core.spawn(futures::future::poll_fn(move || {
|
||||
Self::do_spawn_new_window(&myself, &config, &fonts)
|
||||
|
||||
+1
-1
@@ -90,7 +90,7 @@ pub trait GuiSystem {
|
||||
|
||||
fn spawn_new_window(
|
||||
&self,
|
||||
config: &Rc<Config>,
|
||||
config: &Arc<Config>,
|
||||
fontconfig: &Rc<FontConfiguration>,
|
||||
tab: &Rc<Tab>,
|
||||
) -> Result<(), Error>;
|
||||
|
||||
+4
-4
@@ -102,7 +102,7 @@ impl super::GuiSystem for X11GuiSystem {
|
||||
}
|
||||
fn spawn_new_window(
|
||||
&self,
|
||||
config: &Rc<Config>,
|
||||
config: &Arc<Config>,
|
||||
fontconfig: &Rc<FontConfiguration>,
|
||||
tab: &Rc<Tab>,
|
||||
) -> Result<(), Error> {
|
||||
@@ -231,7 +231,7 @@ impl GuiEventLoop {
|
||||
|
||||
fn do_spawn_new_window(
|
||||
events: &Rc<Self>,
|
||||
config: &Rc<Config>,
|
||||
config: &Arc<Config>,
|
||||
fonts: &Rc<FontConfiguration>,
|
||||
) -> Result<(), Error> {
|
||||
let tab = spawn_tab(&config, None)?;
|
||||
@@ -244,11 +244,11 @@ impl GuiEventLoop {
|
||||
|
||||
pub fn schedule_spawn_new_window(
|
||||
events: &Rc<Self>,
|
||||
config: &Rc<Config>,
|
||||
config: &Arc<Config>,
|
||||
fonts: &Rc<FontConfiguration>,
|
||||
) {
|
||||
let myself = Rc::clone(events);
|
||||
let config = Rc::clone(config);
|
||||
let config = Arc::clone(config);
|
||||
let fonts = Rc::clone(fonts);
|
||||
events.core.spawn(futures::future::poll_fn(move || {
|
||||
Self::do_spawn_new_window(&myself, &config, &fonts)
|
||||
|
||||
+5
-4
@@ -14,6 +14,7 @@ use structopt::StructOpt;
|
||||
mod xwindows;
|
||||
|
||||
use std::rc::Rc;
|
||||
use std::sync::Arc;
|
||||
|
||||
mod config;
|
||||
mod futurecore;
|
||||
@@ -105,7 +106,7 @@ struct Opt {
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
let opts = Opt::from_args();
|
||||
let config = Rc::new(if opts.skip_config {
|
||||
let config = Arc::new(if opts.skip_config {
|
||||
config::Config::default_config()
|
||||
} else {
|
||||
config::Config::load()?
|
||||
@@ -113,7 +114,7 @@ fn main() -> Result<(), Error> {
|
||||
println!("Using configuration: {:#?}\nopts: {:#?}", config, opts);
|
||||
|
||||
let font_system = opts.font_system.unwrap_or(config.font_system);
|
||||
let fontconfig = Rc::new(FontConfiguration::new(Rc::clone(&config), font_system));
|
||||
let fontconfig = Rc::new(FontConfiguration::new(Arc::clone(&config), font_system));
|
||||
|
||||
let cmd = if !opts.prog.is_empty() {
|
||||
Some(opts.prog.iter().map(|x| x.as_os_str()).collect())
|
||||
@@ -131,7 +132,7 @@ fn main() -> Result<(), Error> {
|
||||
}
|
||||
|
||||
fn spawn_tab(
|
||||
config: &Rc<config::Config>,
|
||||
config: &Arc<config::Config>,
|
||||
cmd: Option<Vec<&std::ffi::OsStr>>,
|
||||
) -> Result<Rc<Tab>, Error> {
|
||||
let cmd = config.build_prog(cmd)?;
|
||||
@@ -165,7 +166,7 @@ fn spawn_window(
|
||||
mux: &Rc<Mux>,
|
||||
gui: &GuiSystem,
|
||||
cmd: Option<Vec<&std::ffi::OsStr>>,
|
||||
config: &Rc<config::Config>,
|
||||
config: &Arc<config::Config>,
|
||||
fontconfig: &Rc<FontConfiguration>,
|
||||
) -> Result<(), Error> {
|
||||
let tab = spawn_tab(config, cmd)?;
|
||||
|
||||
@@ -20,7 +20,7 @@ struct Host {
|
||||
window: Window,
|
||||
event_loop: Rc<GuiEventLoop>,
|
||||
fonts: Rc<FontConfiguration>,
|
||||
config: Rc<Config>,
|
||||
config: Arc<Config>,
|
||||
}
|
||||
|
||||
impl HostHelper for Host {
|
||||
@@ -60,7 +60,7 @@ impl TerminalWindow for X11TerminalWindow {
|
||||
fn get_tabs_mut(&mut self) -> &mut Tabs {
|
||||
&mut self.tabs
|
||||
}
|
||||
fn config(&self) -> &Rc<Config> {
|
||||
fn config(&self) -> &Arc<Config> {
|
||||
&self.host.config
|
||||
}
|
||||
fn fonts(&self) -> &Rc<FontConfiguration> {
|
||||
@@ -131,7 +131,7 @@ impl X11TerminalWindow {
|
||||
pub fn new(
|
||||
event_loop: &Rc<GuiEventLoop>,
|
||||
fonts: &Rc<FontConfiguration>,
|
||||
config: &Rc<Config>,
|
||||
config: &Arc<Config>,
|
||||
tab: &Rc<Tab>,
|
||||
) -> Result<X11TerminalWindow, Error> {
|
||||
let palette = config
|
||||
@@ -159,7 +159,7 @@ impl X11TerminalWindow {
|
||||
let host = HostImpl::new(Host {
|
||||
window,
|
||||
event_loop: Rc::clone(event_loop),
|
||||
config: Rc::clone(config),
|
||||
config: Arc::clone(config),
|
||||
fonts: Rc::clone(fonts),
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user