mirror of
https://github.com/alacritty/alacritty.git
synced 2024-11-18 13:55:23 -05:00
Perform clear and buffer swap before showing window
This should fill window with background color while it is offscreen instead of showing it with uninitilized surface and then performing `clear`. So, the new behavior should prevent glitches during startup. e.g. content of the windows below, garbage from drivers and so on.
This commit is contained in:
parent
e2e25b3206
commit
0815774cbf
3 changed files with 47 additions and 33 deletions
|
@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
- Text Cursor position when scrolling
|
||||
- Performance issues while resizing Alacritty
|
||||
- First unfullscreen action ignored on window launched in fullscreen mode
|
||||
- The window is now filled with the background color before displaying
|
||||
|
||||
## 0.3.3
|
||||
|
||||
|
|
|
@ -224,6 +224,32 @@ impl Display {
|
|||
api.clear(background_color);
|
||||
});
|
||||
|
||||
// We should call `clear` when window is offscreen, so when `window.show()` happens it
|
||||
// would be with background color instead of uninitialized surface.
|
||||
window.swap_buffers()?;
|
||||
|
||||
window.show();
|
||||
|
||||
// Set window position
|
||||
//
|
||||
// TODO: replace `set_position` with `with_position` once available
|
||||
// Upstream issue: https://github.com/tomaka/winit/issues/806
|
||||
if let Some(position) = config.window.position {
|
||||
let physical = PhysicalPosition::from((position.x, position.y));
|
||||
let logical = physical.to_logical(window.hidpi_factor());
|
||||
window.set_position(logical);
|
||||
}
|
||||
|
||||
#[allow(clippy::single_match)]
|
||||
match config.window.startup_mode() {
|
||||
StartupMode::Fullscreen => window.set_fullscreen(true),
|
||||
#[cfg(target_os = "macos")]
|
||||
StartupMode::SimpleFullscreen => window.set_simple_fullscreen(true),
|
||||
#[cfg(not(any(target_os = "macos", windows)))]
|
||||
StartupMode::Maximized if window.is_x11() => window.set_maximized(true),
|
||||
_ => (),
|
||||
}
|
||||
|
||||
Ok(Display {
|
||||
window,
|
||||
renderer,
|
||||
|
|
|
@ -17,7 +17,7 @@ use std::ffi::c_void;
|
|||
use std::fmt::Display;
|
||||
|
||||
use crate::gl;
|
||||
use glutin::dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize};
|
||||
use glutin::dpi::{LogicalPosition, LogicalSize, PhysicalSize};
|
||||
#[cfg(target_os = "macos")]
|
||||
use glutin::os::macos::WindowExt;
|
||||
#[cfg(not(any(target_os = "macos", windows)))]
|
||||
|
@ -158,38 +158,6 @@ impl Window {
|
|||
create_gl_window(window_builder.clone(), &event_loop, false, dimensions)
|
||||
.or_else(|_| create_gl_window(window_builder, &event_loop, true, dimensions))?;
|
||||
let window = windowed_context.window();
|
||||
window.show();
|
||||
|
||||
// Maximize window after mapping in X11
|
||||
#[cfg(not(any(target_os = "macos", windows)))]
|
||||
{
|
||||
if event_loop.is_x11() && config.window.startup_mode() == StartupMode::Maximized {
|
||||
window.set_maximized(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Set window position
|
||||
//
|
||||
// TODO: replace `set_position` with `with_position` once available
|
||||
// Upstream issue: https://github.com/tomaka/winit/issues/806
|
||||
if let Some(position) = config.window.position {
|
||||
let physical = PhysicalPosition::from((position.x, position.y));
|
||||
let logical = physical.to_logical(window.get_hidpi_factor());
|
||||
window.set_position(logical);
|
||||
}
|
||||
|
||||
if let StartupMode::Fullscreen = config.window.startup_mode() {
|
||||
let current_monitor = window.get_current_monitor();
|
||||
window.set_fullscreen(Some(current_monitor));
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
{
|
||||
if let StartupMode::SimpleFullscreen = config.window.startup_mode() {
|
||||
use glutin::os::macos::WindowExt;
|
||||
window.set_simple_fullscreen(true);
|
||||
}
|
||||
}
|
||||
|
||||
// Text cursor
|
||||
window.set_cursor(MouseCursor::Text);
|
||||
|
@ -250,6 +218,12 @@ impl Window {
|
|||
self.windowed_context.resize(size);
|
||||
}
|
||||
|
||||
/// Show window
|
||||
#[inline]
|
||||
pub fn show(&self) {
|
||||
self.window().show();
|
||||
}
|
||||
|
||||
/// Block waiting for events
|
||||
#[inline]
|
||||
pub fn wait_events<F>(&mut self, func: F)
|
||||
|
@ -379,6 +353,10 @@ impl Window {
|
|||
self.window().set_ime_spot(pos);
|
||||
}
|
||||
|
||||
pub fn set_position(&self, pos: LogicalPosition) {
|
||||
self.window().set_position(pos);
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
pub fn get_window_id(&self) -> Option<usize> {
|
||||
match self.window().get_xlib_window() {
|
||||
|
@ -387,6 +365,11 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "windows")))]
|
||||
pub fn is_x11(&self) -> bool {
|
||||
self.event_loop.is_x11()
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "windows"))]
|
||||
pub fn get_window_id(&self) -> Option<usize> {
|
||||
None
|
||||
|
@ -408,6 +391,10 @@ impl Window {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn set_maximized(&self, maximized: bool) {
|
||||
self.window().set_maximized(maximized);
|
||||
}
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn set_simple_fullscreen(&self, fullscreen: bool) {
|
||||
use glutin::os::macos::WindowExt;
|
||||
|
|
Loading…
Reference in a new issue