From 0815774cbfb9d1421b8077d5d9d641faf5f818c1 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Wed, 26 Jun 2019 00:34:55 +0300 Subject: 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. --- alacritty_terminal/src/display.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'alacritty_terminal/src/display.rs') 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, -- cgit v1.2.3-54-g00ecf