aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2025-01-12 22:30:27 +0300
committerGitHub <noreply@github.com>2025-01-12 22:30:27 +0300
commit2290afff02bc8470fb4abeb2a2ffc1c22dc2ede7 (patch)
tree24b43ebabc38133cabfe36dc07b815bf5c1695e4
parentcd884c984bbd6a7c65965681083da61e091ff7e5 (diff)
downloadr-alacritty-2290afff02bc8470fb4abeb2a2ffc1c22dc2ede7.tar.gz
r-alacritty-2290afff02bc8470fb4abeb2a2ffc1c22dc2ede7.tar.bz2
r-alacritty-2290afff02bc8470fb4abeb2a2ffc1c22dc2ede7.zip
Bump glutin to 0.32.2
This cleans up context managing.
-rw-r--r--Cargo.lock16
-rw-r--r--alacritty/Cargo.toml2
-rw-r--r--alacritty/src/display/mod.rs64
3 files changed, 18 insertions, 64 deletions
diff --git a/Cargo.lock b/Cargo.lock
index c55d1fc1..9f294793 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -814,9 +814,9 @@ dependencies = [
[[package]]
name = "glutin"
-version = "0.32.1"
+version = "0.32.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ec69412a0bf07ea7607e638b415447857a808846c2b685a43c8aa18bc6d5e499"
+checksum = "03642b8b0cce622392deb0ee3e88511f75df2daac806102597905c3ea1974848"
dependencies = [
"bitflags 2.6.0",
"cfg_aliases",
@@ -839,9 +839,9 @@ dependencies = [
[[package]]
name = "glutin_egl_sys"
-version = "0.7.0"
+version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cae99fff4d2850dbe6fb8c1fa8e4fead5525bab715beaacfccf3fb994e01c827"
+checksum = "4c4680ba6195f424febdc3ba46e7a42a0e58743f2edb115297b86d7f8ecc02d2"
dependencies = [
"gl_generator",
"windows-sys 0.52.0",
@@ -849,9 +849,9 @@ dependencies = [
[[package]]
name = "glutin_glx_sys"
-version = "0.6.0"
+version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9c2b2d3918e76e18e08796b55eb64e8fe6ec67d5a6b2e2a7e2edce224ad24c63"
+checksum = "8a7bb2938045a88b612499fbcba375a77198e01306f52272e692f8c1f3751185"
dependencies = [
"gl_generator",
"x11-dl",
@@ -859,9 +859,9 @@ dependencies = [
[[package]]
name = "glutin_wgl_sys"
-version = "0.6.0"
+version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0a4e1951bbd9434a81aa496fe59ccc2235af3820d27b85f9314e279609211e2c"
+checksum = "2c4ee00b289aba7a9e5306d57c2d05499b2e5dc427f84ac708bd2c090212cf3e"
dependencies = [
"gl_generator",
]
diff --git a/alacritty/Cargo.toml b/alacritty/Cargo.toml
index 6fb2ee2b..fb961d8f 100644
--- a/alacritty/Cargo.toml
+++ b/alacritty/Cargo.toml
@@ -28,7 +28,7 @@ bitflags = "2.2.1"
clap = { version = "4.2.7", features = ["derive", "env"] }
copypasta = { version = "0.10.1", default-features = false }
crossfont = "0.8.0"
-glutin = { version = "0.32.0", default-features = false, features = ["egl", "wgl"] }
+glutin = { version = "0.32.2", default-features = false, features = ["egl", "wgl"] }
home = "0.5.5"
libc = "0.2"
log = { version = "0.4", features = ["std", "serde"] }
diff --git a/alacritty/src/display/mod.rs b/alacritty/src/display/mod.rs
index 9f11ccf6..6a84bf0f 100644
--- a/alacritty/src/display/mod.rs
+++ b/alacritty/src/display/mod.rs
@@ -5,7 +5,7 @@ use std::cmp;
use std::fmt::{self, Formatter};
use std::mem::{self, ManuallyDrop};
use std::num::NonZeroU32;
-use std::ops::{Deref, DerefMut};
+use std::ops::Deref;
use std::time::{Duration, Instant};
use glutin::config::GetGlConfig;
@@ -393,7 +393,7 @@ pub struct Display {
surface: ManuallyDrop<Surface<WindowSurface>>,
- context: ManuallyDrop<Replaceable<PossiblyCurrentContext>>,
+ context: ManuallyDrop<PossiblyCurrentContext>,
glyph_cache: GlyphCache,
meter: Meter,
@@ -515,7 +515,7 @@ impl Display {
}
Ok(Self {
- context: ManuallyDrop::new(Replaceable::new(context)),
+ context: ManuallyDrop::new(context),
visual_bell: VisualBell::from(&config.bell),
renderer: ManuallyDrop::new(renderer),
renderer_preference: config.debug.renderer,
@@ -544,22 +544,17 @@ impl Display {
#[inline]
pub fn gl_context(&self) -> &PossiblyCurrentContext {
- self.context.get()
+ &self.context
}
pub fn make_not_current(&mut self) {
- if self.context.get().is_current() {
- self.context.replace_with(|context| {
- context
- .make_not_current()
- .expect("failed to disable context")
- .treat_as_possibly_current()
- });
+ if self.context.is_current() {
+ self.context.make_not_current_in_place().expect("failed to disable context");
}
}
pub fn make_current(&mut self) {
- let is_current = self.context.get().is_current();
+ let is_current = self.context.is_current();
// Attempt to make the context current if it's not.
let context_loss = if is_current {
@@ -592,7 +587,7 @@ impl Display {
// Activate new context.
let context = context.treat_as_possibly_current();
- self.context = ManuallyDrop::new(Replaceable::new(context));
+ self.context = ManuallyDrop::new(context);
self.context.make_current(&self.surface).expect("failed to reativate context after reset.");
// Recreate renderer.
@@ -611,7 +606,7 @@ impl Display {
fn swap_buffers(&self) {
#[allow(clippy::single_match)]
- let res = match (self.surface.deref(), &self.context.get()) {
+ let res = match (self.surface.deref(), &self.context.deref()) {
#[cfg(not(any(target_os = "macos", windows)))]
(Surface::Egl(surface), PossiblyCurrentContext::Egl(context))
if matches!(self.raw_window_handle, RawWindowHandle::Wayland(_))
@@ -1555,47 +1550,6 @@ pub struct RendererUpdate {
clear_font_cache: bool,
}
-/// Struct for safe in-place replacement.
-///
-/// This struct allows easily replacing struct fields that provide `self -> Self` methods in-place,
-/// without having to deal with constantly unwrapping the underlying [`Option`].
-struct Replaceable<T>(Option<T>);
-
-impl<T> Replaceable<T> {
- pub fn new(inner: T) -> Self {
- Self(Some(inner))
- }
-
- /// Replace the contents of the container.
- pub fn replace_with<F: FnMut(T) -> T>(&mut self, f: F) {
- self.0 = self.0.take().map(f);
- }
-
- /// Get immutable access to the wrapped value.
- pub fn get(&self) -> &T {
- self.0.as_ref().unwrap()
- }
-
- /// Get mutable access to the wrapped value.
- pub fn get_mut(&mut self) -> &mut T {
- self.0.as_mut().unwrap()
- }
-}
-
-impl<T> Deref for Replaceable<T> {
- type Target = T;
-
- fn deref(&self) -> &Self::Target {
- self.get()
- }
-}
-
-impl<T> DerefMut for Replaceable<T> {
- fn deref_mut(&mut self) -> &mut Self::Target {
- self.get_mut()
- }
-}
-
/// The frame timer state.
pub struct FrameTimer {
/// Base timestamp used to compute sync points.