aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-03-15 22:02:29 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2024-03-15 22:02:29 +0400
commit0c57815fbf47c69af9ed11fa8ebc1b52158a3ba2 (patch)
treede651e37c50254f62a5ce8296547208c6b61353f /src
parentcf89c789c3a09a470eba7b9b0d899f38c661af7c (diff)
downloadniri-0c57815fbf47c69af9ed11fa8ebc1b52158a3ba2.tar.gz
niri-0c57815fbf47c69af9ed11fa8ebc1b52158a3ba2.tar.bz2
niri-0c57815fbf47c69af9ed11fa8ebc1b52158a3ba2.zip
Restore gamma on TTY switch back
Diffstat (limited to 'src')
-rw-r--r--src/backend/tty.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/backend/tty.rs b/src/backend/tty.rs
index e7b60900..7d80c251 100644
--- a/src/backend/tty.rs
+++ b/src/backend/tty.rs
@@ -397,7 +397,7 @@ impl Tty {
// Refresh the connectors.
self.device_changed(node.dev_id(), niri);
- // Apply pending gamma changes.
+ // Apply pending gamma changes and restore our existing gamma.
let device = self.devices.get_mut(&node).unwrap();
for (crtc, surface) in device.surfaces.iter_mut() {
if let Some(ramp) = surface.pending_gamma_change.take() {
@@ -410,6 +410,10 @@ impl Tty {
if let Err(err) = res {
warn!("error applying pending gamma change: {err:?}");
}
+ } else if let Some(gamma_props) = &surface.gamma_props {
+ if let Err(err) = gamma_props.restore_gamma(&device.drm) {
+ warn!("error restoring gamma: {err:?}");
+ }
}
}
}
@@ -1708,6 +1712,21 @@ impl GammaProps {
Ok(())
}
+
+ fn restore_gamma(&self, device: &DrmDevice) -> anyhow::Result<()> {
+ let _span = tracy_client::span!("GammaProps::restore_gamma");
+
+ let blob = self.previous_blob.map(NonZeroU64::get).unwrap_or(0);
+ device
+ .set_property(
+ self.crtc,
+ self.gamma_lut,
+ property::Value::Blob(blob).into(),
+ )
+ .context("error setting GAMMA_LUT")?;
+
+ Ok(())
+ }
}
fn primary_node_from_config(config: &Config) -> Option<(DrmNode, DrmNode)> {