From 380b00e083bfbfca05c7aa15039c4c233a2be63c Mon Sep 17 00:00:00 2001 From: Victoria Brekenfeld Date: Thu, 31 Aug 2023 18:17:37 +0200 Subject: [PATCH] render: Respect scale for indicator thickness --- src/backend/render/mod.rs | 5 +++++ src/shell/grabs/moving.rs | 5 +++-- src/shell/layout/floating/mod.rs | 1 + src/shell/layout/tiling/mod.rs | 9 +++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/backend/render/mod.rs b/src/backend/render/mod.rs index f4a2d6dd..d5dafe0f 100644 --- a/src/backend/render/mod.rs +++ b/src/backend/render/mod.rs @@ -155,6 +155,7 @@ impl IndicatorShader { key: impl Into, mut element_geo: Rectangle, thickness: u8, + scale: f64, alpha: f32, ) -> PixelShaderElement { let t = thickness as i32; @@ -168,6 +169,7 @@ impl IndicatorShader { thickness, thickness * 2, alpha, + scale, FOCUS_INDICATOR_COLOR, ) } @@ -179,8 +181,11 @@ impl IndicatorShader { thickness: u8, radius: u8, alpha: f32, + scale: f64, color: [f32; 3], ) -> PixelShaderElement { + let thickness = (thickness as f64 * scale).round() as u8; + let settings = IndicatorSettings { thickness, radius, diff --git a/src/shell/grabs/moving.rs b/src/shell/grabs/moving.rs index f486c992..6d277fc6 100644 --- a/src/shell/grabs/moving.rs +++ b/src/shell/grabs/moving.rs @@ -32,7 +32,7 @@ use smithay::{ }, output::Output, reexports::wayland_server::protocol::wl_surface::WlSurface, - utils::{IsAlive, Logical, Point, Rectangle, Serial}, + utils::{IsAlive, Logical, Point, Rectangle, Scale, Serial}, wayland::compositor::SurfaceData, }; use std::{ @@ -83,7 +83,7 @@ impl MoveGrabState { return Vec::new(); } - let output_scale = output.current_scale().fractional_scale().into(); + let output_scale: Scale = output.current_scale().fractional_scale().into(); let scaling_offset = self.window_offset - self.window_offset.to_f64().upscale(scale).to_i32_round(); let render_location = @@ -104,6 +104,7 @@ impl MoveGrabState { .to_i32_round(), ), self.indicator_thickness, + output_scale.x, 1.0, )) .into(), diff --git a/src/shell/layout/floating/mod.rs b/src/shell/layout/floating/mod.rs index 6560a4eb..d3171198 100644 --- a/src/shell/layout/floating/mod.rs +++ b/src/shell/layout/floating/mod.rs @@ -517,6 +517,7 @@ impl FloatingLayout { elem.clone(), indicator_geometry, indicator_thickness, + output_scale, alpha, ); window_elements.push(element.into()); diff --git a/src/shell/layout/tiling/mod.rs b/src/shell/layout/tiling/mod.rs index f8caf792..7f03e87d 100644 --- a/src/shell/layout/tiling/mod.rs +++ b/src/shell/layout/tiling/mod.rs @@ -2319,6 +2319,7 @@ impl TilingLayout { None, 1.0, overview.alpha().unwrap(), + 1.0, placeholder_id, Some(None), ) @@ -2984,6 +2985,7 @@ impl TilingLayout { // but for that we have to associate focus with a tree (and animate focus changes properly) 1.0 - transition, transition, + output_scale, &self.placeholder_id, is_mouse_tiling, ) @@ -3017,6 +3019,7 @@ impl TilingLayout { seat, transition, transition, + output_scale, &self.placeholder_id, is_mouse_tiling, ) @@ -3072,6 +3075,7 @@ fn geometries_for_groupview<'a, R>( seat: Option<&Seat>, alpha: f32, transition: f32, + output_scale: f64, placeholder_id: &Id, mouse_tiling: Option>, ) -> Option<( @@ -3238,6 +3242,7 @@ where 4, if render_active_child { 16 } else { 8 }, alpha * if render_potential_group { 0.40 } else { 1.0 }, + output_scale, GROUP_COLOR, ) .into(), @@ -3255,6 +3260,7 @@ where 4, 8, alpha * 0.40, + output_scale, GROUP_COLOR, ) .into(), @@ -3321,6 +3327,7 @@ where 4, 8, alpha * 0.15, + output_scale, GROUP_COLOR, ) .into(), @@ -3520,6 +3527,7 @@ where 4, 8, alpha * 0.40, + output_scale, GROUP_COLOR, ) .into(), @@ -3913,6 +3921,7 @@ where } else { indicator_thickness }, + output_scale, 1.0, )); }