summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/display.rs
diff options
context:
space:
mode:
authorKirill Chibisov <wchibisovkirill@gmail.com>2019-06-26 00:34:55 +0300
committerChristian Duerr <chrisduerr@users.noreply.github.com>2019-06-25 21:34:55 +0000
commit0815774cbfb9d1421b8077d5d9d641faf5f818c1 (patch)
tree218a7177650ef8fa92b6c1936de73a32d3396628 /alacritty_terminal/src/display.rs
parente2e25b3206ec6c99592ef9ee829426cad62e4d29 (diff)
downloadalacritty-0815774cbfb9d1421b8077d5d9d641faf5f818c1.tar.gz
alacritty-0815774cbfb9d1421b8077d5d9d641faf5f818c1.zip
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.
Diffstat (limited to 'alacritty_terminal/src/display.rs')
-rw-r--r--alacritty_terminal/src/display.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/alacritty_terminal/src/display.rs b/alacritty_terminal/src/display.rs
index 081625ac..4a2e57c4 100644
--- a/alacritty_terminal/src/display.rs
+++ b/alacritty_terminal/src/display.rs
@@ -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,