aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/event.rs
diff options
context:
space:
mode:
Diffstat (limited to 'alacritty/src/event.rs')
-rw-r--r--alacritty/src/event.rs50
1 files changed, 31 insertions, 19 deletions
diff --git a/alacritty/src/event.rs b/alacritty/src/event.rs
index 23575e21..f0159060 100644
--- a/alacritty/src/event.rs
+++ b/alacritty/src/event.rs
@@ -1,6 +1,7 @@
//! Process window events.
use crate::ConfigMonitor;
+use glutin::config::GetGlConfig;
use std::borrow::Cow;
use std::cmp::min;
use std::collections::{HashMap, HashSet, VecDeque};
@@ -16,7 +17,8 @@ use std::{env, f32, mem};
use ahash::RandomState;
use crossfont::Size as FontSize;
-use glutin::display::{Display as GlutinDisplay, GetGlDisplay};
+use glutin::config::Config as GlutinConfig;
+use glutin::display::GetGlDisplay;
use log::{debug, error, info, warn};
use winit::application::ApplicationHandler;
use winit::event::{
@@ -80,7 +82,7 @@ pub struct Processor {
initial_window_error: Option<Box<dyn Error>>,
windows: HashMap<WindowId, WindowContext, RandomState>,
proxy: EventLoopProxy<Event>,
- gl_display: Option<GlutinDisplay>,
+ gl_config: Option<GlutinConfig>,
#[cfg(unix)]
global_ipc_options: ParsedOptions,
cli_options: CliOptions,
@@ -121,7 +123,7 @@ impl Processor {
cli_options,
proxy,
scheduler,
- gl_display: None,
+ gl_config: None,
config: Rc::new(config),
clipboard,
windows: Default::default(),
@@ -138,12 +140,16 @@ impl Processor {
pub fn create_initial_window(
&mut self,
event_loop: &ActiveEventLoop,
- options: WindowOptions,
) -> Result<(), Box<dyn Error>> {
+ let options = match self.initial_window_options.take() {
+ Some(options) => options,
+ None => return Ok(()),
+ };
+
let window_context =
WindowContext::initial(event_loop, self.proxy.clone(), self.config.clone(), options)?;
- self.gl_display = Some(window_context.display.gl_context().display());
+ self.gl_config = Some(window_context.display.gl_context().config());
self.windows.insert(window_context.id(), window_context);
Ok(())
@@ -155,7 +161,7 @@ impl Processor {
event_loop: &ActiveEventLoop,
options: WindowOptions,
) -> Result<(), Box<dyn Error>> {
- let window = self.windows.iter().next().as_ref().unwrap().1;
+ let gl_config = self.gl_config.as_ref().unwrap();
// Override config with CLI/IPC options.
let mut config_overrides = options.config_overrides();
@@ -164,9 +170,14 @@ impl Processor {
let mut config = self.config.clone();
config = config_overrides.override_config_rc(config);
- #[allow(unused_mut)]
- let mut window_context =
- window.additional(event_loop, self.proxy.clone(), config, options, config_overrides)?;
+ let window_context = WindowContext::additional(
+ gl_config,
+ event_loop,
+ self.proxy.clone(),
+ config,
+ options,
+ config_overrides,
+ )?;
self.windows.insert(window_context.id(), window_context);
Ok(())
@@ -210,16 +221,11 @@ impl ApplicationHandler<Event> for Processor {
fn resumed(&mut self, _event_loop: &ActiveEventLoop) {}
fn new_events(&mut self, event_loop: &ActiveEventLoop, cause: StartCause) {
- if cause != StartCause::Init {
+ if cause != StartCause::Init || self.cli_options.daemon {
return;
}
- let initial_window_options = match self.initial_window_options.take() {
- Some(initial_window_options) => initial_window_options,
- None => return,
- };
-
- if let Err(err) = self.create_initial_window(event_loop, initial_window_options) {
+ if let Err(err) = self.create_initial_window(event_loop) {
self.initial_window_error = Some(err);
event_loop.exit();
return;
@@ -338,7 +344,13 @@ impl ApplicationHandler<Event> for Processor {
window_context.display.make_not_current();
}
- if let Err(err) = self.create_window(event_loop, options.clone()) {
+ if self.gl_config.is_none() {
+ // Handle initial window creation in daemon mode.
+ if let Err(err) = self.create_initial_window(event_loop) {
+ self.initial_window_error = Some(err);
+ event_loop.exit();
+ }
+ } else if let Err(err) = self.create_window(event_loop, options.clone()) {
error!("Could not open window: {:?}", err);
}
},
@@ -375,7 +387,7 @@ impl ApplicationHandler<Event> for Processor {
self.scheduler.unschedule_window(window_context.id());
// Shutdown if no more terminals are open.
- if self.windows.is_empty() {
+ if self.windows.is_empty() && !self.cli_options.daemon {
// Write ref tests of last window to disk.
if self.config.debug.ref_test {
window_context.write_ref_test_results();
@@ -439,7 +451,7 @@ impl ApplicationHandler<Event> for Processor {
info!("Exiting the event loop");
}
- match self.gl_display.take() {
+ match self.gl_config.take().map(|config| config.display()) {
#[cfg(not(target_os = "macos"))]
Some(glutin::display::Display::Egl(display)) => {
// Ensure that all the windows are dropped, so the destructors for