diff options
author | YOSHIOKA Takuma <lo48576@hard-wi.red> | 2018-03-13 20:16:01 +0900 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2018-03-13 16:43:15 -0700 |
commit | 6debc4f3351446417d0c4e38173cd9ef0faa71d5 (patch) | |
tree | fd9b0d497170e42efec5354179048f8c204e5109 | |
parent | 196e60238758a473043ef5df5798c7da25e923d1 (diff) | |
download | alacritty-6debc4f3351446417d0c4e38173cd9ef0faa71d5.tar.gz alacritty-6debc4f3351446417d0c4e38173cd9ef0faa71d5.zip |
Try to create window with different SRGB config when failed
This may truly solve #921 (and issue caused by #1178)
<https://github.com/jwilm/alacritty/issues/921#issuecomment-372619121>.
-rw-r--r-- | src/window.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/window.rs b/src/window.rs index 0f527a4f..42a1785e 100644 --- a/src/window.rs +++ b/src/window.rs @@ -183,6 +183,17 @@ impl From<glutin::ContextError> for Error { } } +fn create_gl_window( + window: WindowBuilder, + event_loop: &EventsLoop, + srgb: bool, +) -> ::std::result::Result<glutin::GlWindow, glutin::CreationError> { + let context = ContextBuilder::new() + .with_srgb(srgb) + .with_vsync(true); + ::glutin::GlWindow::new(window, context, event_loop) +} + impl Window { /// Create a new window /// @@ -199,10 +210,8 @@ impl Window { .with_visibility(false) .with_transparency(true) .with_decorations(window_config.decorations()); - let context = ContextBuilder::new() - .with_srgb(true) - .with_vsync(true); - let window = ::glutin::GlWindow::new(window, context, &event_loop)?; + let window = create_gl_window(window.clone(), &event_loop, false) + .or_else(|_| create_gl_window(window, &event_loop, true))?; window.show(); // Text cursor |