Update Smithay (apply state in post commit)
Browse files at this commit618fa08aa5649e867c24db5ae941ca7f5064eecaParent: a40e7b48 changed files +32 -29
- Cargo.lock +2 -2
- niri-config/src/lib.rs +5 -0
- niri-visual-tests/src/smithay_view.rs +2 -2
- src/layout/tile.rs +2 -2
- src/niri.rs +2 -1
- src/render_helpers/mod.rs +2 -2
- src/render_helpers/solid_color.rs +15 -18
- src/window/mapped.rs +2 -2
Cargo.lockmodified+2 -2
| @@ -3479,7 +3479,7 @@ checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" | |||
| 3479 | [[package]] | 3479 | [[package]] |
| 3480 | name = "smithay" | 3480 | name = "smithay" |
| 3481 | version = "0.3.0" | 3481 | version = "0.3.0" |
| 3482 | -source = "git+https://github.com/Smithay/smithay.git#c4844428f8de024222a44cd906060f2af77f4ba1" | 3482 | +source = "git+https://github.com/Smithay/smithay.git#e97bff13dd404bf350f3872de726803d7aed8b85" |
| 3483 | dependencies = [ | 3483 | dependencies = [ |
| 3484 | "appendlist", | 3484 | "appendlist", |
| 3485 | "bitflags 2.6.0", | 3485 | "bitflags 2.6.0", |
| @@ -3553,7 +3553,7 @@ dependencies = [ | |||
| 3553 | [[package]] | 3553 | [[package]] |
| 3554 | name = "smithay-drm-extras" | 3554 | name = "smithay-drm-extras" |
| 3555 | version = "0.1.0" | 3555 | version = "0.1.0" |
| 3556 | -source = "git+https://github.com/Smithay/smithay.git#c4844428f8de024222a44cd906060f2af77f4ba1" | 3556 | +source = "git+https://github.com/Smithay/smithay.git#e97bff13dd404bf350f3872de726803d7aed8b85" |
| 3557 | dependencies = [ | 3557 | dependencies = [ |
| 3558 | "drm", | 3558 | "drm", |
| 3559 | "edid-rs", | 3559 | "edid-rs", |
niri-config/src/lib.rsmodified+5 -0
| @@ -13,6 +13,7 @@ use knuffel::Decode as _; | |||
| 13 | use miette::{miette, Context, IntoDiagnostic, NarratableReportHandler}; | 13 | use miette::{miette, Context, IntoDiagnostic, NarratableReportHandler}; |
| 14 | use niri_ipc::{ConfiguredMode, LayoutSwitchTarget, SizeChange, Transform, WorkspaceReferenceArg}; | 14 | use niri_ipc::{ConfiguredMode, LayoutSwitchTarget, SizeChange, Transform, WorkspaceReferenceArg}; |
| 15 | use regex::Regex; | 15 | use regex::Regex; |
| 16 | +use smithay::backend::renderer::Color32F; | ||
| 16 | use smithay::input::keyboard::keysyms::KEY_NoSymbol; | 17 | use smithay::input::keyboard::keysyms::KEY_NoSymbol; |
| 17 | use smithay::input::keyboard::xkb::{keysym_from_name, KEYSYM_CASE_INSENSITIVE}; | 18 | use smithay::input::keyboard::xkb::{keysym_from_name, KEYSYM_CASE_INSENSITIVE}; |
| 18 | use smithay::input::keyboard::{Keysym, XkbConfig}; | 19 | use smithay::input::keyboard::{Keysym, XkbConfig}; |
| @@ -580,6 +581,10 @@ impl Color { | |||
| 580 | Self { r, g, b, a } | 581 | Self { r, g, b, a } |
| 581 | } | 582 | } |
| 582 | 583 | ||
| 584 | + pub fn from_color32f(color: Color32F) -> Self { | ||
| 585 | + Self::from_array_premul(color.components()) | ||
| 586 | + } | ||
| 587 | + | ||
| 583 | pub fn to_array_unpremul(self) -> [f32; 4] { | 588 | pub fn to_array_unpremul(self) -> [f32; 4] { |
| 584 | [self.r, self.g, self.b, self.a] | 589 | [self.r, self.g, self.b, self.a] |
| 585 | } | 590 | } |
niri-visual-tests/src/smithay_view.rsmodified+2 -2
| @@ -16,7 +16,7 @@ mod imp { | |||
| 16 | use smithay::backend::egl::ffi::egl; | 16 | use smithay::backend::egl::ffi::egl; |
| 17 | use smithay::backend::egl::EGLContext; | 17 | use smithay::backend::egl::EGLContext; |
| 18 | use smithay::backend::renderer::gles::GlesRenderer; | 18 | use smithay::backend::renderer::gles::GlesRenderer; |
| 19 | - use smithay::backend::renderer::{Frame, Renderer, Unbind}; | 19 | + use smithay::backend::renderer::{Color32F, Frame, Renderer, Unbind}; |
| 20 | use smithay::utils::{Physical, Rectangle, Scale, Transform}; | 20 | use smithay::utils::{Physical, Rectangle, Scale, Transform}; |
| 21 | 21 | ||
| 22 | use super::*; | 22 | use super::*; |
| @@ -147,7 +147,7 @@ mod imp { | |||
| 147 | .context("error creating frame")?; | 147 | .context("error creating frame")?; |
| 148 | 148 | ||
| 149 | frame | 149 | frame |
| 150 | - .clear([0.3, 0.3, 0.3, 1.], &[rect]) | 150 | + .clear(Color32F::from([0.3, 0.3, 0.3, 1.]), &[rect]) |
| 151 | .context("error clearing")?; | 151 | .context("error clearing")?; |
| 152 | 152 | ||
| 153 | for element in elements.iter().rev() { | 153 | for element in elements.iter().rev() { |
src/layout/tile.rsmodified+2 -2
| @@ -758,8 +758,8 @@ impl<W: LayoutElement> Tile<W> { | |||
| 758 | geo.size, | 758 | geo.size, |
| 759 | Rectangle::from_loc_and_size((0., 0.), geo.size), | 759 | Rectangle::from_loc_and_size((0., 0.), geo.size), |
| 760 | GradientInterpolation::default(), | 760 | GradientInterpolation::default(), |
| 761 | - Color::from_array_premul(elem.color()), | 761 | + Color::from_color32f(elem.color()), |
| 762 | - Color::from_array_premul(elem.color()), | 762 | + Color::from_color32f(elem.color()), |
| 763 | 0., | 763 | 0., |
| 764 | Rectangle::from_loc_and_size((0., 0.), geo.size), | 764 | Rectangle::from_loc_and_size((0., 0.), geo.size), |
| 765 | 0., | 765 | 0., |
src/niri.rsmodified+2 -1
| @@ -32,7 +32,7 @@ use smithay::backend::renderer::element::{ | |||
| 32 | }; | 32 | }; |
| 33 | use smithay::backend::renderer::gles::GlesRenderer; | 33 | use smithay::backend::renderer::gles::GlesRenderer; |
| 34 | use smithay::backend::renderer::sync::SyncPoint; | 34 | use smithay::backend::renderer::sync::SyncPoint; |
| 35 | -use smithay::backend::renderer::Unbind; | 35 | +use smithay::backend::renderer::{Color32F, Unbind}; |
| 36 | use smithay::desktop::utils::{ | 36 | use smithay::desktop::utils::{ |
| 37 | bbox_from_surface_tree, output_update, send_dmabuf_feedback_surface_tree, | 37 | bbox_from_surface_tree, output_update, send_dmabuf_feedback_surface_tree, |
| 38 | send_frames_surface_tree, surface_presentation_feedback_flags_from_states, | 38 | send_frames_surface_tree, surface_presentation_feedback_flags_from_states, |
| @@ -1137,6 +1137,7 @@ impl State { | |||
| 1137 | .unwrap_or(DEFAULT_BACKGROUND_COLOR) | 1137 | .unwrap_or(DEFAULT_BACKGROUND_COLOR) |
| 1138 | .to_array_unpremul(); | 1138 | .to_array_unpremul(); |
| 1139 | background_color[3] = 1.; | 1139 | background_color[3] = 1.; |
| 1140 | + let background_color = Color32F::from(background_color); | ||
| 1140 | 1141 | ||
| 1141 | if let Some(state) = self.niri.output_state.get_mut(output) { | 1142 | if let Some(state) = self.niri.output_state.get_mut(output) { |
| 1142 | if state.background_buffer.color() != background_color { | 1143 | if state.background_buffer.color() != background_color { |
src/render_helpers/mod.rsmodified+2 -2
| @@ -8,7 +8,7 @@ use smithay::backend::renderer::element::utils::{Relocate, RelocateRenderElement | |||
| 8 | use smithay::backend::renderer::element::{Kind, RenderElement}; | 8 | use smithay::backend::renderer::element::{Kind, RenderElement}; |
| 9 | use smithay::backend::renderer::gles::{GlesMapping, GlesRenderer, GlesTexture}; | 9 | use smithay::backend::renderer::gles::{GlesMapping, GlesRenderer, GlesTexture}; |
| 10 | use smithay::backend::renderer::sync::SyncPoint; | 10 | use smithay::backend::renderer::sync::SyncPoint; |
| 11 | -use smithay::backend::renderer::{Bind, ExportMem, Frame, Offscreen, Renderer}; | 11 | +use smithay::backend::renderer::{Bind, Color32F, ExportMem, Frame, Offscreen, Renderer}; |
| 12 | use smithay::reexports::wayland_server::protocol::wl_buffer::WlBuffer; | 12 | use smithay::reexports::wayland_server::protocol::wl_buffer::WlBuffer; |
| 13 | use smithay::reexports::wayland_server::protocol::wl_shm; | 13 | use smithay::reexports::wayland_server::protocol::wl_shm; |
| 14 | use smithay::utils::{Logical, Physical, Point, Rectangle, Scale, Size, Transform}; | 14 | use smithay::utils::{Logical, Physical, Point, Rectangle, Scale, Size, Transform}; |
| @@ -302,7 +302,7 @@ fn render_elements( | |||
| 302 | .context("error starting frame")?; | 302 | .context("error starting frame")?; |
| 303 | 303 | ||
| 304 | frame | 304 | frame |
| 305 | - .clear([0., 0., 0., 0.], &[output_rect]) | 305 | + .clear(Color32F::TRANSPARENT, &[output_rect]) |
| 306 | .context("error clearing")?; | 306 | .context("error clearing")?; |
| 307 | 307 | ||
| 308 | for element in elements { | 308 | for element in elements { |
src/render_helpers/solid_color.rsmodified+15 -18
| @@ -1,6 +1,6 @@ | |||
| 1 | use smithay::backend::renderer::element::{Element, Id, Kind, RenderElement, UnderlyingStorage}; | 1 | use smithay::backend::renderer::element::{Element, Id, Kind, RenderElement, UnderlyingStorage}; |
| 2 | use smithay::backend::renderer::utils::{CommitCounter, OpaqueRegions}; | 2 | use smithay::backend::renderer::utils::{CommitCounter, OpaqueRegions}; |
| 3 | -use smithay::backend::renderer::{Frame as _, Renderer}; | 3 | +use smithay::backend::renderer::{Color32F, Frame as _, Renderer}; |
| 4 | use smithay::utils::{Buffer, Logical, Physical, Point, Rectangle, Scale, Size}; | 4 | use smithay::utils::{Buffer, Logical, Physical, Point, Rectangle, Scale, Size}; |
| 5 | 5 | ||
| 6 | /// Smithay's solid color buffer, but with fractional scale. | 6 | /// Smithay's solid color buffer, but with fractional scale. |
| @@ -9,7 +9,7 @@ pub struct SolidColorBuffer { | |||
| 9 | id: Id, | 9 | id: Id, |
| 10 | size: Size<f64, Logical>, | 10 | size: Size<f64, Logical>, |
| 11 | commit: CommitCounter, | 11 | commit: CommitCounter, |
| 12 | - color: [f32; 4], | 12 | + color: Color32F, |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | /// Render element for a [`SolidColorBuffer`]. | 15 | /// Render element for a [`SolidColorBuffer`]. |
| @@ -18,7 +18,7 @@ pub struct SolidColorRenderElement { | |||
| 18 | id: Id, | 18 | id: Id, |
| 19 | geometry: Rectangle<f64, Logical>, | 19 | geometry: Rectangle<f64, Logical>, |
| 20 | commit: CommitCounter, | 20 | commit: CommitCounter, |
| 21 | - color: [f32; 4], | 21 | + color: Color32F, |
| 22 | kind: Kind, | 22 | kind: Kind, |
| 23 | } | 23 | } |
| 24 | 24 | ||
| @@ -34,10 +34,10 @@ impl Default for SolidColorBuffer { | |||
| 34 | } | 34 | } |
| 35 | 35 | ||
| 36 | impl SolidColorBuffer { | 36 | impl SolidColorBuffer { |
| 37 | - pub fn new(size: impl Into<Size<f64, Logical>>, color: [f32; 4]) -> Self { | 37 | + pub fn new(size: impl Into<Size<f64, Logical>>, color: impl Into<Color32F>) -> Self { |
| 38 | SolidColorBuffer { | 38 | SolidColorBuffer { |
| 39 | id: Id::new(), | 39 | id: Id::new(), |
| 40 | - color, | 40 | + color: color.into(), |
| 41 | commit: CommitCounter::default(), | 41 | commit: CommitCounter::default(), |
| 42 | size: size.into(), | 42 | size: size.into(), |
| 43 | } | 43 | } |
| @@ -51,15 +51,17 @@ impl SolidColorBuffer { | |||
| 51 | } | 51 | } |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | - pub fn set_color(&mut self, color: [f32; 4]) { | 54 | + pub fn set_color(&mut self, color: impl Into<Color32F>) { |
| 55 | + let color = color.into(); | ||
| 55 | if color != self.color { | 56 | if color != self.color { |
| 56 | self.color = color; | 57 | self.color = color; |
| 57 | self.commit.increment(); | 58 | self.commit.increment(); |
| 58 | } | 59 | } |
| 59 | } | 60 | } |
| 60 | 61 | ||
| 61 | - pub fn update(&mut self, size: impl Into<Size<f64, Logical>>, color: [f32; 4]) { | 62 | + pub fn update(&mut self, size: impl Into<Size<f64, Logical>>, color: impl Into<Color32F>) { |
| 62 | let size = size.into(); | 63 | let size = size.into(); |
| 64 | + let color = color.into(); | ||
| 63 | if size != self.size || color != self.color { | 65 | if size != self.size || color != self.color { |
| 64 | self.size = size; | 66 | self.size = size; |
| 65 | self.color = color; | 67 | self.color = color; |
| @@ -67,7 +69,7 @@ impl SolidColorBuffer { | |||
| 67 | } | 69 | } |
| 68 | } | 70 | } |
| 69 | 71 | ||
| 70 | - pub fn color(&self) -> [f32; 4] { | 72 | + pub fn color(&self) -> Color32F { |
| 71 | self.color | 73 | self.color |
| 72 | } | 74 | } |
| 73 | 75 | ||
| @@ -84,12 +86,7 @@ impl SolidColorRenderElement { | |||
| 84 | kind: Kind, | 86 | kind: Kind, |
| 85 | ) -> Self { | 87 | ) -> Self { |
| 86 | let geo = Rectangle::from_loc_and_size(location, buffer.size()); | 88 | let geo = Rectangle::from_loc_and_size(location, buffer.size()); |
| 87 | - let color = [ | 89 | + let color = buffer.color * alpha; |
| 88 | - buffer.color[0] * alpha, | ||
| 89 | - buffer.color[1] * alpha, | ||
| 90 | - buffer.color[2] * alpha, | ||
| 91 | - buffer.color[3] * alpha, | ||
| 92 | - ]; | ||
| 93 | Self::new(buffer.id.clone(), geo, buffer.commit, color, kind) | 90 | Self::new(buffer.id.clone(), geo, buffer.commit, color, kind) |
| 94 | } | 91 | } |
| 95 | 92 | ||
| @@ -97,7 +94,7 @@ impl SolidColorRenderElement { | |||
| 97 | id: Id, | 94 | id: Id, |
| 98 | geometry: Rectangle<f64, Logical>, | 95 | geometry: Rectangle<f64, Logical>, |
| 99 | commit: CommitCounter, | 96 | commit: CommitCounter, |
| 100 | - color: [f32; 4], | 97 | + color: Color32F, |
| 101 | kind: Kind, | 98 | kind: Kind, |
| 102 | ) -> Self { | 99 | ) -> Self { |
| 103 | SolidColorRenderElement { | 100 | SolidColorRenderElement { |
| @@ -109,7 +106,7 @@ impl SolidColorRenderElement { | |||
| 109 | } | 106 | } |
| 110 | } | 107 | } |
| 111 | 108 | ||
| 112 | - pub fn color(&self) -> [f32; 4] { | 109 | + pub fn color(&self) -> Color32F { |
| 113 | self.color | 110 | self.color |
| 114 | } | 111 | } |
| 115 | 112 | ||
| @@ -136,7 +133,7 @@ impl Element for SolidColorRenderElement { | |||
| 136 | } | 133 | } |
| 137 | 134 | ||
| 138 | fn opaque_regions(&self, scale: Scale<f64>) -> OpaqueRegions<i32, Physical> { | 135 | fn opaque_regions(&self, scale: Scale<f64>) -> OpaqueRegions<i32, Physical> { |
| 139 | - if self.color[3] == 1f32 { | 136 | + if self.color.is_opaque() { |
| 140 | let rect = Rectangle::from_loc_and_size((0., 0.), self.geometry.size) | 137 | let rect = Rectangle::from_loc_and_size((0., 0.), self.geometry.size) |
| 141 | .to_physical_precise_down(scale); | 138 | .to_physical_precise_down(scale); |
| 142 | OpaqueRegions::from_slice(&[rect]) | 139 | OpaqueRegions::from_slice(&[rect]) |
| @@ -146,7 +143,7 @@ impl Element for SolidColorRenderElement { | |||
| 146 | } | 143 | } |
| 147 | 144 | ||
| 148 | fn alpha(&self) -> f32 { | 145 | fn alpha(&self) -> f32 { |
| 149 | - self.color[3] | 146 | + self.color.a() |
| 150 | } | 147 | } |
| 151 | 148 | ||
| 152 | fn kind(&self) -> Kind { | 149 | fn kind(&self) -> Kind { |
src/window/mapped.rsmodified+2 -2
| @@ -290,8 +290,8 @@ impl Mapped { | |||
| 290 | geo.size, | 290 | geo.size, |
| 291 | Rectangle::from_loc_and_size((0., 0.), geo.size), | 291 | Rectangle::from_loc_and_size((0., 0.), geo.size), |
| 292 | GradientInterpolation::default(), | 292 | GradientInterpolation::default(), |
| 293 | - Color::from_array_premul(elem.color()), | 293 | + Color::from_color32f(elem.color()), |
| 294 | - Color::from_array_premul(elem.color()), | 294 | + Color::from_color32f(elem.color()), |
| 295 | 0., | 295 | 0., |
| 296 | Rectangle::from_loc_and_size((0., 0.), geo.size), | 296 | Rectangle::from_loc_and_size((0., 0.), geo.size), |
| 297 | 0., | 297 | 0., |