aboutsummaryrefslogtreecommitdiff
path: root/src/layout/opening_window.rs
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2024-06-17 09:16:28 +0300
committerIvan Molodetskikh <yalterz@gmail.com>2024-06-18 14:01:28 +0300
commit1dae45c58d7eabeda21ef490d712915890bf6cff (patch)
tree62c473ab1662a1161ed522517ea57b7bd8db340c /src/layout/opening_window.rs
parent997119c44338ad96a40b4a1d6e958f77062a37ef (diff)
downloadniri-1dae45c58d7eabeda21ef490d712915890bf6cff.tar.gz
niri-1dae45c58d7eabeda21ef490d712915890bf6cff.tar.bz2
niri-1dae45c58d7eabeda21ef490d712915890bf6cff.zip
Refactor layout to fractional-logical
Lets borders, gaps, and everything else stay pixel-perfect even with fractional scale. Allows setting fractional border widths, gaps, struts. See the new wiki .md for more details.
Diffstat (limited to 'src/layout/opening_window.rs')
-rw-r--r--src/layout/opening_window.rs18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/layout/opening_window.rs b/src/layout/opening_window.rs
index 38eb89ab..d265c463 100644
--- a/src/layout/opening_window.rs
+++ b/src/layout/opening_window.rs
@@ -55,8 +55,8 @@ impl OpenAnimation {
&self,
renderer: &mut GlesRenderer,
elements: &[impl RenderElement<GlesRenderer>],
- geo_size: Size<i32, Logical>,
- location: Point<i32, Logical>,
+ geo_size: Size<f64, Logical>,
+ location: Point<f64, Logical>,
scale: Scale<f64>,
) -> anyhow::Result<OpeningWindowRenderElement> {
let progress = self.anim.value();
@@ -75,17 +75,17 @@ impl OpenAnimation {
let texture_size = geo.size.to_f64().to_logical(scale);
if Shaders::get(renderer).program(ProgramType::Open).is_some() {
- let mut area = Rectangle::from_loc_and_size(location.to_f64() + offset, texture_size);
+ let mut area = Rectangle::from_loc_and_size(location + offset, texture_size);
// Expand the area a bit to allow for more varied effects.
let mut target_size = area.size.upscale(1.5);
target_size.w = f64::max(area.size.w + 1000., target_size.w);
target_size.h = f64::max(area.size.h + 1000., target_size.h);
- let diff = target_size.to_point() - area.size.to_point();
- area.loc -= diff.downscale(2.);
- area.size += diff.to_size();
+ let diff = (target_size.to_point() - area.size.to_point()).downscale(2.);
+ let diff = diff.to_physical_precise_round(scale).to_logical(scale);
+ area.loc -= diff;
+ area.size += diff.upscale(2.).to_size();
- let area = area.to_i32_up();
let area_loc = Vec2::new(area.loc.x as f32, area.loc.y as f32);
let area_size = Vec2::new(area.size.w as f32, area.size.h as f32);
@@ -135,7 +135,7 @@ impl OpenAnimation {
let elem = PrimaryGpuTextureRenderElement(elem);
- let center = geo_size.to_point().to_f64().downscale(2.);
+ let center = geo_size.to_point().downscale(2.);
let elem = RescaleRenderElement::from_element(
elem,
(center - offset).to_physical_precise_round(scale),
@@ -144,7 +144,7 @@ impl OpenAnimation {
let elem = RelocateRenderElement::from_element(
elem,
- (location.to_f64() + offset).to_physical_precise_round(scale),
+ (location + offset).to_physical_precise_round(scale),
Relocate::Relative,
);