Migrate to new Rectangle functions
Browse files at this commita2f9d132a088e399fb1f292d84d3d3862127f02eParent: 1973b9736 changed files +160 -159
- niri-visual-tests/src/cases/gradient_angle.rs +4 -4
- niri-visual-tests/src/cases/gradient_area.rs +4 -4
- niri-visual-tests/src/cases/gradient_oklab.rs +4 -4
- niri-visual-tests/src/cases/gradient_oklab_alpha.rs +4 -4
- niri-visual-tests/src/cases/gradient_oklch_alpha.rs +4 -4
- niri-visual-tests/src/cases/gradient_oklch_decreasing.rs +4 -4
- niri-visual-tests/src/cases/gradient_oklch_increasing.rs +4 -4
- niri-visual-tests/src/cases/gradient_oklch_longer.rs +4 -4
- niri-visual-tests/src/cases/gradient_oklch_shorter.rs +4 -4
- niri-visual-tests/src/cases/gradient_srgb.rs +4 -4
- niri-visual-tests/src/cases/gradient_srgb_alpha.rs +4 -4
- niri-visual-tests/src/cases/gradient_srgblinear.rs +4 -4
- niri-visual-tests/src/cases/gradient_srgblinear_alpha.rs +4 -4
- niri-visual-tests/src/cases/tile.rs +1 -1
- niri-visual-tests/src/smithay_view.rs +1 -1
- src/handlers/xdg_shell.rs +1 -1
- src/layout/floating.rs +2 -2
- src/layout/focus_ring.rs +5 -8
- src/layout/mod.rs +6 -8
- src/layout/monitor.rs +11 -5
- src/layout/opening_window.rs +1 -1
- src/layout/scrolling.rs +11 -11
- src/layout/tile.rs +6 -6
- src/layout/workspace.rs +4 -4
- src/niri.rs +13 -13
- src/protocols/screencopy.rs +2 -2
- src/render_helpers/clipped_surface.rs +12 -12
- src/render_helpers/damage.rs +1 -1
- src/render_helpers/mod.rs +2 -2
- src/render_helpers/resize.rs +1 -1
- src/render_helpers/shader_element.rs +4 -4
- src/render_helpers/solid_color.rs +3 -4
- src/render_helpers/texture.rs +2 -4
- src/ui/screenshot_ui.rs +14 -11
- src/utils/mod.rs +2 -2
- src/window/mapped.rs +3 -3
niri-visual-tests/src/cases/gradient_angle.rsmodified+4 -4
| @@ -5,7 +5,7 @@ use niri::render_helpers::border::BorderRenderElement; | |||
| 5 | use niri_config::{Color, CornerRadius, GradientInterpolation}; | 5 | use niri_config::{Color, CornerRadius, GradientInterpolation}; |
| 6 | use smithay::backend::renderer::element::RenderElement; | 6 | use smithay::backend::renderer::element::RenderElement; |
| 7 | use smithay::backend::renderer::gles::GlesRenderer; | 7 | use smithay::backend::renderer::gles::GlesRenderer; |
| 8 | -use smithay::utils::{Physical, Rectangle, Size}; | 8 | +use smithay::utils::{Physical, Point, Rectangle, Size}; |
| 9 | 9 | ||
| 10 | use super::{Args, TestCase}; | 10 | use super::{Args, TestCase}; |
| 11 | 11 | ||
| @@ -50,16 +50,16 @@ impl TestCase for GradientAngle { | |||
| 50 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { | 50 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { |
| 51 | let (a, b) = (size.w / 4, size.h / 4); | 51 | let (a, b) = (size.w / 4, size.h / 4); |
| 52 | let size = (size.w - a * 2, size.h - b * 2); | 52 | let size = (size.w - a * 2, size.h - b * 2); |
| 53 | - let area = Rectangle::from_loc_and_size((a, b), size).to_f64(); | 53 | + let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64(); |
| 54 | 54 | ||
| 55 | [BorderRenderElement::new( | 55 | [BorderRenderElement::new( |
| 56 | area.size, | 56 | area.size, |
| 57 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 57 | + Rectangle::from_size(area.size), |
| 58 | GradientInterpolation::default(), | 58 | GradientInterpolation::default(), |
| 59 | Color::new_unpremul(1., 0., 0., 1.), | 59 | Color::new_unpremul(1., 0., 0., 1.), |
| 60 | Color::new_unpremul(0., 1., 0., 1.), | 60 | Color::new_unpremul(0., 1., 0., 1.), |
| 61 | self.angle - FRAC_PI_2, | 61 | self.angle - FRAC_PI_2, |
| 62 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 62 | + Rectangle::from_size(area.size), |
| 63 | 0., | 63 | 0., |
| 64 | CornerRadius::default(), | 64 | CornerRadius::default(), |
| 65 | 1., | 65 | 1., |
niri-visual-tests/src/cases/gradient_area.rsmodified+4 -4
| @@ -65,8 +65,8 @@ impl TestCase for GradientArea { | |||
| 65 | let f = (self.progress.sin() + 1.) / 2.; | 65 | let f = (self.progress.sin() + 1.) / 2.; |
| 66 | 66 | ||
| 67 | let (a, b) = (size.w / 4, size.h / 4); | 67 | let (a, b) = (size.w / 4, size.h / 4); |
| 68 | - let rect_size = (size.w - a * 2, size.h - b * 2); | 68 | + let rect_size = Size::from((size.w - a * 2, size.h - b * 2)); |
| 69 | - let area = Rectangle::from_loc_and_size((a, b), rect_size).to_f64(); | 69 | + let area = Rectangle::new(Point::from((a, b)), rect_size).to_f64(); |
| 70 | 70 | ||
| 71 | let g_size = Size::from(( | 71 | let g_size = Size::from(( |
| 72 | (size.w as f32 / 8. + size.w as f32 / 8. * 7. * f).round() as i32, | 72 | (size.w as f32 / 8. + size.w as f32 / 8. * 7. * f).round() as i32, |
| @@ -74,7 +74,7 @@ impl TestCase for GradientArea { | |||
| 74 | )); | 74 | )); |
| 75 | let g_loc = Point::from(((size.w - g_size.w) / 2, (size.h - g_size.h) / 2)).to_f64(); | 75 | let g_loc = Point::from(((size.w - g_size.w) / 2, (size.h - g_size.h) / 2)).to_f64(); |
| 76 | let g_size = g_size.to_f64(); | 76 | let g_size = g_size.to_f64(); |
| 77 | - let mut g_area = Rectangle::from_loc_and_size(g_loc, g_size); | 77 | + let mut g_area = Rectangle::new(g_loc, g_size); |
| 78 | g_area.loc -= area.loc; | 78 | g_area.loc -= area.loc; |
| 79 | 79 | ||
| 80 | self.border.update_render_elements( | 80 | self.border.update_render_elements( |
| @@ -99,7 +99,7 @@ impl TestCase for GradientArea { | |||
| 99 | Color::new_unpremul(1., 0., 0., 1.), | 99 | Color::new_unpremul(1., 0., 0., 1.), |
| 100 | Color::new_unpremul(0., 1., 0., 1.), | 100 | Color::new_unpremul(0., 1., 0., 1.), |
| 101 | FRAC_PI_4, | 101 | FRAC_PI_4, |
| 102 | - Rectangle::from_loc_and_size((0, 0), rect_size).to_f64(), | 102 | + Rectangle::from_size(rect_size).to_f64(), |
| 103 | 0., | 103 | 0., |
| 104 | CornerRadius::default(), | 104 | CornerRadius::default(), |
| 105 | 1., | 105 | 1., |
niri-visual-tests/src/cases/gradient_oklab.rsmodified+4 -4
| @@ -4,7 +4,7 @@ use niri_config::{ | |||
| 4 | }; | 4 | }; |
| 5 | use smithay::backend::renderer::element::RenderElement; | 5 | use smithay::backend::renderer::element::RenderElement; |
| 6 | use smithay::backend::renderer::gles::GlesRenderer; | 6 | use smithay::backend::renderer::gles::GlesRenderer; |
| 7 | -use smithay::utils::{Physical, Rectangle, Size}; | 7 | +use smithay::utils::{Physical, Point, Rectangle, Size}; |
| 8 | 8 | ||
| 9 | use super::{Args, TestCase}; | 9 | use super::{Args, TestCase}; |
| 10 | 10 | ||
| @@ -31,16 +31,16 @@ impl TestCase for GradientOklab { | |||
| 31 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { | 31 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { |
| 32 | let (a, b) = (size.w / 6, size.h / 3); | 32 | let (a, b) = (size.w / 6, size.h / 3); |
| 33 | let size = (size.w - a * 2, size.h - b * 2); | 33 | let size = (size.w - a * 2, size.h - b * 2); |
| 34 | - let area = Rectangle::from_loc_and_size((a, b), size).to_f64(); | 34 | + let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64(); |
| 35 | 35 | ||
| 36 | [BorderRenderElement::new( | 36 | [BorderRenderElement::new( |
| 37 | area.size, | 37 | area.size, |
| 38 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 38 | + Rectangle::from_size(area.size), |
| 39 | self.gradient_format, | 39 | self.gradient_format, |
| 40 | Color::new_unpremul(1., 0., 0., 1.), | 40 | Color::new_unpremul(1., 0., 0., 1.), |
| 41 | Color::new_unpremul(0., 1., 0., 1.), | 41 | Color::new_unpremul(0., 1., 0., 1.), |
| 42 | 0., | 42 | 0., |
| 43 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 43 | + Rectangle::from_size(area.size), |
| 44 | 0., | 44 | 0., |
| 45 | CornerRadius::default(), | 45 | CornerRadius::default(), |
| 46 | 1., | 46 | 1., |
niri-visual-tests/src/cases/gradient_oklab_alpha.rsmodified+4 -4
| @@ -2,7 +2,7 @@ use niri::render_helpers::border::BorderRenderElement; | |||
| 2 | use niri_config::{Color, CornerRadius, GradientColorSpace, GradientInterpolation}; | 2 | use niri_config::{Color, CornerRadius, GradientColorSpace, GradientInterpolation}; |
| 3 | use smithay::backend::renderer::element::RenderElement; | 3 | use smithay::backend::renderer::element::RenderElement; |
| 4 | use smithay::backend::renderer::gles::GlesRenderer; | 4 | use smithay::backend::renderer::gles::GlesRenderer; |
| 5 | -use smithay::utils::{Physical, Rectangle, Size}; | 5 | +use smithay::utils::{Physical, Point, Rectangle, Size}; |
| 6 | 6 | ||
| 7 | use super::{Args, TestCase}; | 7 | use super::{Args, TestCase}; |
| 8 | 8 | ||
| @@ -29,16 +29,16 @@ impl TestCase for GradientOklabAlpha { | |||
| 29 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { | 29 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { |
| 30 | let (a, b) = (size.w / 6, size.h / 3); | 30 | let (a, b) = (size.w / 6, size.h / 3); |
| 31 | let size = (size.w - a * 2, size.h - b * 2); | 31 | let size = (size.w - a * 2, size.h - b * 2); |
| 32 | - let area = Rectangle::from_loc_and_size((a, b), size).to_f64(); | 32 | + let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64(); |
| 33 | 33 | ||
| 34 | [BorderRenderElement::new( | 34 | [BorderRenderElement::new( |
| 35 | area.size, | 35 | area.size, |
| 36 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 36 | + Rectangle::from_size(area.size), |
| 37 | self.gradient_format, | 37 | self.gradient_format, |
| 38 | Color::new_unpremul(1., 0., 0., 1.), | 38 | Color::new_unpremul(1., 0., 0., 1.), |
| 39 | Color::new_unpremul(0., 1., 0., 0.), | 39 | Color::new_unpremul(0., 1., 0., 0.), |
| 40 | 0., | 40 | 0., |
| 41 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 41 | + Rectangle::from_size(area.size), |
| 42 | 0., | 42 | 0., |
| 43 | CornerRadius::default(), | 43 | CornerRadius::default(), |
| 44 | 1., | 44 | 1., |
niri-visual-tests/src/cases/gradient_oklch_alpha.rsmodified+4 -4
| @@ -4,7 +4,7 @@ use niri_config::{ | |||
| 4 | }; | 4 | }; |
| 5 | use smithay::backend::renderer::element::RenderElement; | 5 | use smithay::backend::renderer::element::RenderElement; |
| 6 | use smithay::backend::renderer::gles::GlesRenderer; | 6 | use smithay::backend::renderer::gles::GlesRenderer; |
| 7 | -use smithay::utils::{Physical, Rectangle, Size}; | 7 | +use smithay::utils::{Physical, Point, Rectangle, Size}; |
| 8 | 8 | ||
| 9 | use super::{Args, TestCase}; | 9 | use super::{Args, TestCase}; |
| 10 | 10 | ||
| @@ -31,16 +31,16 @@ impl TestCase for GradientOklchAlpha { | |||
| 31 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { | 31 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { |
| 32 | let (a, b) = (size.w / 6, size.h / 3); | 32 | let (a, b) = (size.w / 6, size.h / 3); |
| 33 | let size = (size.w - a * 2, size.h - b * 2); | 33 | let size = (size.w - a * 2, size.h - b * 2); |
| 34 | - let area = Rectangle::from_loc_and_size((a, b), size).to_f64(); | 34 | + let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64(); |
| 35 | 35 | ||
| 36 | [BorderRenderElement::new( | 36 | [BorderRenderElement::new( |
| 37 | area.size, | 37 | area.size, |
| 38 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 38 | + Rectangle::from_size(area.size), |
| 39 | self.gradient_format, | 39 | self.gradient_format, |
| 40 | Color::new_unpremul(1., 0., 0., 1.), | 40 | Color::new_unpremul(1., 0., 0., 1.), |
| 41 | Color::new_unpremul(0., 1., 0., 0.), | 41 | Color::new_unpremul(0., 1., 0., 0.), |
| 42 | 0., | 42 | 0., |
| 43 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 43 | + Rectangle::from_size(area.size), |
| 44 | 0., | 44 | 0., |
| 45 | CornerRadius::default(), | 45 | CornerRadius::default(), |
| 46 | 1., | 46 | 1., |
niri-visual-tests/src/cases/gradient_oklch_decreasing.rsmodified+4 -4
| @@ -4,7 +4,7 @@ use niri_config::{ | |||
| 4 | }; | 4 | }; |
| 5 | use smithay::backend::renderer::element::RenderElement; | 5 | use smithay::backend::renderer::element::RenderElement; |
| 6 | use smithay::backend::renderer::gles::GlesRenderer; | 6 | use smithay::backend::renderer::gles::GlesRenderer; |
| 7 | -use smithay::utils::{Physical, Rectangle, Size}; | 7 | +use smithay::utils::{Physical, Point, Rectangle, Size}; |
| 8 | 8 | ||
| 9 | use super::{Args, TestCase}; | 9 | use super::{Args, TestCase}; |
| 10 | 10 | ||
| @@ -31,16 +31,16 @@ impl TestCase for GradientOklchDecreasing { | |||
| 31 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { | 31 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { |
| 32 | let (a, b) = (size.w / 6, size.h / 3); | 32 | let (a, b) = (size.w / 6, size.h / 3); |
| 33 | let size = (size.w - a * 2, size.h - b * 2); | 33 | let size = (size.w - a * 2, size.h - b * 2); |
| 34 | - let area = Rectangle::from_loc_and_size((a, b), size).to_f64(); | 34 | + let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64(); |
| 35 | 35 | ||
| 36 | [BorderRenderElement::new( | 36 | [BorderRenderElement::new( |
| 37 | area.size, | 37 | area.size, |
| 38 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 38 | + Rectangle::from_size(area.size), |
| 39 | self.gradient_format, | 39 | self.gradient_format, |
| 40 | Color::new_unpremul(1., 0., 0., 1.), | 40 | Color::new_unpremul(1., 0., 0., 1.), |
| 41 | Color::new_unpremul(0., 1., 0., 1.), | 41 | Color::new_unpremul(0., 1., 0., 1.), |
| 42 | 0., | 42 | 0., |
| 43 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 43 | + Rectangle::from_size(area.size), |
| 44 | 0., | 44 | 0., |
| 45 | CornerRadius::default(), | 45 | CornerRadius::default(), |
| 46 | 1., | 46 | 1., |
niri-visual-tests/src/cases/gradient_oklch_increasing.rsmodified+4 -4
| @@ -4,7 +4,7 @@ use niri_config::{ | |||
| 4 | }; | 4 | }; |
| 5 | use smithay::backend::renderer::element::RenderElement; | 5 | use smithay::backend::renderer::element::RenderElement; |
| 6 | use smithay::backend::renderer::gles::GlesRenderer; | 6 | use smithay::backend::renderer::gles::GlesRenderer; |
| 7 | -use smithay::utils::{Physical, Rectangle, Size}; | 7 | +use smithay::utils::{Physical, Point, Rectangle, Size}; |
| 8 | 8 | ||
| 9 | use super::{Args, TestCase}; | 9 | use super::{Args, TestCase}; |
| 10 | 10 | ||
| @@ -31,16 +31,16 @@ impl TestCase for GradientOklchIncreasing { | |||
| 31 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { | 31 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { |
| 32 | let (a, b) = (size.w / 6, size.h / 3); | 32 | let (a, b) = (size.w / 6, size.h / 3); |
| 33 | let size = (size.w - a * 2, size.h - b * 2); | 33 | let size = (size.w - a * 2, size.h - b * 2); |
| 34 | - let area = Rectangle::from_loc_and_size((a, b), size).to_f64(); | 34 | + let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64(); |
| 35 | 35 | ||
| 36 | [BorderRenderElement::new( | 36 | [BorderRenderElement::new( |
| 37 | area.size, | 37 | area.size, |
| 38 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 38 | + Rectangle::from_size(area.size), |
| 39 | self.gradient_format, | 39 | self.gradient_format, |
| 40 | Color::new_unpremul(1., 0., 0., 1.), | 40 | Color::new_unpremul(1., 0., 0., 1.), |
| 41 | Color::new_unpremul(0., 1., 0., 1.), | 41 | Color::new_unpremul(0., 1., 0., 1.), |
| 42 | 0., | 42 | 0., |
| 43 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 43 | + Rectangle::from_size(area.size), |
| 44 | 0., | 44 | 0., |
| 45 | CornerRadius::default(), | 45 | CornerRadius::default(), |
| 46 | 1., | 46 | 1., |
niri-visual-tests/src/cases/gradient_oklch_longer.rsmodified+4 -4
| @@ -4,7 +4,7 @@ use niri_config::{ | |||
| 4 | }; | 4 | }; |
| 5 | use smithay::backend::renderer::element::RenderElement; | 5 | use smithay::backend::renderer::element::RenderElement; |
| 6 | use smithay::backend::renderer::gles::GlesRenderer; | 6 | use smithay::backend::renderer::gles::GlesRenderer; |
| 7 | -use smithay::utils::{Physical, Rectangle, Size}; | 7 | +use smithay::utils::{Physical, Point, Rectangle, Size}; |
| 8 | 8 | ||
| 9 | use super::{Args, TestCase}; | 9 | use super::{Args, TestCase}; |
| 10 | 10 | ||
| @@ -31,16 +31,16 @@ impl TestCase for GradientOklchLonger { | |||
| 31 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { | 31 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { |
| 32 | let (a, b) = (size.w / 6, size.h / 3); | 32 | let (a, b) = (size.w / 6, size.h / 3); |
| 33 | let size = (size.w - a * 2, size.h - b * 2); | 33 | let size = (size.w - a * 2, size.h - b * 2); |
| 34 | - let area = Rectangle::from_loc_and_size((a, b), size).to_f64(); | 34 | + let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64(); |
| 35 | 35 | ||
| 36 | [BorderRenderElement::new( | 36 | [BorderRenderElement::new( |
| 37 | area.size, | 37 | area.size, |
| 38 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 38 | + Rectangle::from_size(area.size), |
| 39 | self.gradient_format, | 39 | self.gradient_format, |
| 40 | Color::new_unpremul(1., 0., 0., 1.), | 40 | Color::new_unpremul(1., 0., 0., 1.), |
| 41 | Color::new_unpremul(0., 1., 0., 1.), | 41 | Color::new_unpremul(0., 1., 0., 1.), |
| 42 | 0., | 42 | 0., |
| 43 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 43 | + Rectangle::from_size(area.size), |
| 44 | 0., | 44 | 0., |
| 45 | CornerRadius::default(), | 45 | CornerRadius::default(), |
| 46 | 1., | 46 | 1., |
niri-visual-tests/src/cases/gradient_oklch_shorter.rsmodified+4 -4
| @@ -4,7 +4,7 @@ use niri_config::{ | |||
| 4 | }; | 4 | }; |
| 5 | use smithay::backend::renderer::element::RenderElement; | 5 | use smithay::backend::renderer::element::RenderElement; |
| 6 | use smithay::backend::renderer::gles::GlesRenderer; | 6 | use smithay::backend::renderer::gles::GlesRenderer; |
| 7 | -use smithay::utils::{Physical, Rectangle, Size}; | 7 | +use smithay::utils::{Physical, Point, Rectangle, Size}; |
| 8 | 8 | ||
| 9 | use super::{Args, TestCase}; | 9 | use super::{Args, TestCase}; |
| 10 | 10 | ||
| @@ -31,16 +31,16 @@ impl TestCase for GradientOklchShorter { | |||
| 31 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { | 31 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { |
| 32 | let (a, b) = (size.w / 6, size.h / 3); | 32 | let (a, b) = (size.w / 6, size.h / 3); |
| 33 | let size = (size.w - a * 2, size.h - b * 2); | 33 | let size = (size.w - a * 2, size.h - b * 2); |
| 34 | - let area = Rectangle::from_loc_and_size((a, b), size).to_f64(); | 34 | + let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64(); |
| 35 | 35 | ||
| 36 | [BorderRenderElement::new( | 36 | [BorderRenderElement::new( |
| 37 | area.size, | 37 | area.size, |
| 38 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 38 | + Rectangle::from_size(area.size), |
| 39 | self.gradient_format, | 39 | self.gradient_format, |
| 40 | Color::new_unpremul(1., 0., 0., 1.), | 40 | Color::new_unpremul(1., 0., 0., 1.), |
| 41 | Color::new_unpremul(0., 1., 0., 1.), | 41 | Color::new_unpremul(0., 1., 0., 1.), |
| 42 | 0., | 42 | 0., |
| 43 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 43 | + Rectangle::from_size(area.size), |
| 44 | 0., | 44 | 0., |
| 45 | CornerRadius::default(), | 45 | CornerRadius::default(), |
| 46 | 1., | 46 | 1., |
niri-visual-tests/src/cases/gradient_srgb.rsmodified+4 -4
| @@ -4,7 +4,7 @@ use niri_config::{ | |||
| 4 | }; | 4 | }; |
| 5 | use smithay::backend::renderer::element::RenderElement; | 5 | use smithay::backend::renderer::element::RenderElement; |
| 6 | use smithay::backend::renderer::gles::GlesRenderer; | 6 | use smithay::backend::renderer::gles::GlesRenderer; |
| 7 | -use smithay::utils::{Physical, Rectangle, Size}; | 7 | +use smithay::utils::{Physical, Point, Rectangle, Size}; |
| 8 | 8 | ||
| 9 | use super::{Args, TestCase}; | 9 | use super::{Args, TestCase}; |
| 10 | 10 | ||
| @@ -31,16 +31,16 @@ impl TestCase for GradientSrgb { | |||
| 31 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { | 31 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { |
| 32 | let (a, b) = (size.w / 6, size.h / 3); | 32 | let (a, b) = (size.w / 6, size.h / 3); |
| 33 | let size = (size.w - a * 2, size.h - b * 2); | 33 | let size = (size.w - a * 2, size.h - b * 2); |
| 34 | - let area = Rectangle::from_loc_and_size((a, b), size).to_f64(); | 34 | + let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64(); |
| 35 | 35 | ||
| 36 | [BorderRenderElement::new( | 36 | [BorderRenderElement::new( |
| 37 | area.size, | 37 | area.size, |
| 38 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 38 | + Rectangle::from_size(area.size), |
| 39 | self.gradient_format, | 39 | self.gradient_format, |
| 40 | Color::new_unpremul(1., 0., 0., 1.), | 40 | Color::new_unpremul(1., 0., 0., 1.), |
| 41 | Color::new_unpremul(0., 1., 0., 1.), | 41 | Color::new_unpremul(0., 1., 0., 1.), |
| 42 | 0., | 42 | 0., |
| 43 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 43 | + Rectangle::from_size(area.size), |
| 44 | 0., | 44 | 0., |
| 45 | CornerRadius::default(), | 45 | CornerRadius::default(), |
| 46 | 1., | 46 | 1., |
niri-visual-tests/src/cases/gradient_srgb_alpha.rsmodified+4 -4
| @@ -2,7 +2,7 @@ use niri::render_helpers::border::BorderRenderElement; | |||
| 2 | use niri_config::{Color, CornerRadius, GradientColorSpace, GradientInterpolation}; | 2 | use niri_config::{Color, CornerRadius, GradientColorSpace, GradientInterpolation}; |
| 3 | use smithay::backend::renderer::element::RenderElement; | 3 | use smithay::backend::renderer::element::RenderElement; |
| 4 | use smithay::backend::renderer::gles::GlesRenderer; | 4 | use smithay::backend::renderer::gles::GlesRenderer; |
| 5 | -use smithay::utils::{Physical, Rectangle, Size}; | 5 | +use smithay::utils::{Physical, Point, Rectangle, Size}; |
| 6 | 6 | ||
| 7 | use super::{Args, TestCase}; | 7 | use super::{Args, TestCase}; |
| 8 | 8 | ||
| @@ -29,16 +29,16 @@ impl TestCase for GradientSrgbAlpha { | |||
| 29 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { | 29 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { |
| 30 | let (a, b) = (size.w / 6, size.h / 3); | 30 | let (a, b) = (size.w / 6, size.h / 3); |
| 31 | let size = (size.w - a * 2, size.h - b * 2); | 31 | let size = (size.w - a * 2, size.h - b * 2); |
| 32 | - let area = Rectangle::from_loc_and_size((a, b), size).to_f64(); | 32 | + let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64(); |
| 33 | 33 | ||
| 34 | [BorderRenderElement::new( | 34 | [BorderRenderElement::new( |
| 35 | area.size, | 35 | area.size, |
| 36 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 36 | + Rectangle::from_size(area.size), |
| 37 | self.gradient_format, | 37 | self.gradient_format, |
| 38 | Color::new_unpremul(1., 0., 0., 1.), | 38 | Color::new_unpremul(1., 0., 0., 1.), |
| 39 | Color::new_unpremul(0., 1., 0., 0.), | 39 | Color::new_unpremul(0., 1., 0., 0.), |
| 40 | 0., | 40 | 0., |
| 41 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 41 | + Rectangle::from_size(area.size), |
| 42 | 0., | 42 | 0., |
| 43 | CornerRadius::default(), | 43 | CornerRadius::default(), |
| 44 | 1., | 44 | 1., |
niri-visual-tests/src/cases/gradient_srgblinear.rsmodified+4 -4
| @@ -4,7 +4,7 @@ use niri_config::{ | |||
| 4 | }; | 4 | }; |
| 5 | use smithay::backend::renderer::element::RenderElement; | 5 | use smithay::backend::renderer::element::RenderElement; |
| 6 | use smithay::backend::renderer::gles::GlesRenderer; | 6 | use smithay::backend::renderer::gles::GlesRenderer; |
| 7 | -use smithay::utils::{Physical, Rectangle, Size}; | 7 | +use smithay::utils::{Physical, Point, Rectangle, Size}; |
| 8 | 8 | ||
| 9 | use super::{Args, TestCase}; | 9 | use super::{Args, TestCase}; |
| 10 | 10 | ||
| @@ -31,16 +31,16 @@ impl TestCase for GradientSrgbLinear { | |||
| 31 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { | 31 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { |
| 32 | let (a, b) = (size.w / 6, size.h / 3); | 32 | let (a, b) = (size.w / 6, size.h / 3); |
| 33 | let size = (size.w - a * 2, size.h - b * 2); | 33 | let size = (size.w - a * 2, size.h - b * 2); |
| 34 | - let area = Rectangle::from_loc_and_size((a, b), size).to_f64(); | 34 | + let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64(); |
| 35 | 35 | ||
| 36 | [BorderRenderElement::new( | 36 | [BorderRenderElement::new( |
| 37 | area.size, | 37 | area.size, |
| 38 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 38 | + Rectangle::from_size(area.size), |
| 39 | self.gradient_format, | 39 | self.gradient_format, |
| 40 | Color::new_unpremul(1., 0., 0., 1.), | 40 | Color::new_unpremul(1., 0., 0., 1.), |
| 41 | Color::new_unpremul(0., 1., 0., 1.), | 41 | Color::new_unpremul(0., 1., 0., 1.), |
| 42 | 0., | 42 | 0., |
| 43 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 43 | + Rectangle::from_size(area.size), |
| 44 | 0., | 44 | 0., |
| 45 | CornerRadius::default(), | 45 | CornerRadius::default(), |
| 46 | 1., | 46 | 1., |
niri-visual-tests/src/cases/gradient_srgblinear_alpha.rsmodified+4 -4
| @@ -2,7 +2,7 @@ use niri::render_helpers::border::BorderRenderElement; | |||
| 2 | use niri_config::{Color, CornerRadius, GradientColorSpace, GradientInterpolation}; | 2 | use niri_config::{Color, CornerRadius, GradientColorSpace, GradientInterpolation}; |
| 3 | use smithay::backend::renderer::element::RenderElement; | 3 | use smithay::backend::renderer::element::RenderElement; |
| 4 | use smithay::backend::renderer::gles::GlesRenderer; | 4 | use smithay::backend::renderer::gles::GlesRenderer; |
| 5 | -use smithay::utils::{Physical, Rectangle, Size}; | 5 | +use smithay::utils::{Physical, Point, Rectangle, Size}; |
| 6 | 6 | ||
| 7 | use super::{Args, TestCase}; | 7 | use super::{Args, TestCase}; |
| 8 | 8 | ||
| @@ -29,16 +29,16 @@ impl TestCase for GradientSrgbLinearAlpha { | |||
| 29 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { | 29 | ) -> Vec<Box<dyn RenderElement<GlesRenderer>>> { |
| 30 | let (a, b) = (size.w / 6, size.h / 3); | 30 | let (a, b) = (size.w / 6, size.h / 3); |
| 31 | let size = (size.w - a * 2, size.h - b * 2); | 31 | let size = (size.w - a * 2, size.h - b * 2); |
| 32 | - let area = Rectangle::from_loc_and_size((a, b), size).to_f64(); | 32 | + let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64(); |
| 33 | 33 | ||
| 34 | [BorderRenderElement::new( | 34 | [BorderRenderElement::new( |
| 35 | area.size, | 35 | area.size, |
| 36 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 36 | + Rectangle::from_size(area.size), |
| 37 | self.gradient_format, | 37 | self.gradient_format, |
| 38 | Color::new_unpremul(1., 0., 0., 1.), | 38 | Color::new_unpremul(1., 0., 0., 1.), |
| 39 | Color::new_unpremul(0., 1., 0., 0.), | 39 | Color::new_unpremul(0., 1., 0., 0.), |
| 40 | 0., | 40 | 0., |
| 41 | - Rectangle::from_loc_and_size((0., 0.), area.size), | 41 | + Rectangle::from_size(area.size), |
| 42 | 0., | 42 | 0., |
| 43 | CornerRadius::default(), | 43 | CornerRadius::default(), |
| 44 | 1., | 44 | 1., |
niri-visual-tests/src/cases/tile.rsmodified+1 -1
| @@ -114,7 +114,7 @@ impl TestCase for Tile { | |||
| 114 | 114 | ||
| 115 | self.tile.update( | 115 | self.tile.update( |
| 116 | true, | 116 | true, |
| 117 | - Rectangle::from_loc_and_size((-location.x, -location.y), size.to_logical(1.)), | 117 | + Rectangle::new(Point::from((-location.x, -location.y)), size.to_logical(1.)), |
| 118 | ); | 118 | ); |
| 119 | self.tile | 119 | self.tile |
| 120 | .render( | 120 | .render( |
niri-visual-tests/src/smithay_view.rsmodified+1 -1
| @@ -145,7 +145,7 @@ mod imp { | |||
| 145 | 145 | ||
| 146 | case.advance_animations(self.clock.borrow_mut().now()); | 146 | case.advance_animations(self.clock.borrow_mut().now()); |
| 147 | 147 | ||
| 148 | - let rect: Rectangle<i32, Physical> = Rectangle::from_loc_and_size((0, 0), size); | 148 | + let rect: Rectangle<i32, Physical> = Rectangle::from_size(Size::from(size)); |
| 149 | 149 | ||
| 150 | let elements = unsafe { | 150 | let elements = unsafe { |
| 151 | with_framebuffer_save_restore(renderer, |renderer| { | 151 | with_framebuffer_save_restore(renderer, |renderer| { |
src/handlers/xdg_shell.rsmodified+1 -1
| @@ -1050,7 +1050,7 @@ impl State { | |||
| 1050 | 1050 | ||
| 1051 | // The target geometry for the positioner should be relative to its parent's geometry, so | 1051 | // The target geometry for the positioner should be relative to its parent's geometry, so |
| 1052 | // we will compute that here. | 1052 | // we will compute that here. |
| 1053 | - let mut target = Rectangle::from_loc_and_size((0, 0), output_geo.size); | 1053 | + let mut target = Rectangle::from_size(output_geo.size); |
| 1054 | target.loc -= layer_geo.loc; | 1054 | target.loc -= layer_geo.loc; |
| 1055 | target.loc -= get_popup_toplevel_coords(popup); | 1055 | target.loc -= get_popup_toplevel_coords(popup); |
| 1056 | 1056 | ||
src/layout/floating.rsmodified+2 -2
| @@ -330,7 +330,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 330 | let (tile, offset) = self.tiles_with_offsets().next()?; | 330 | let (tile, offset) = self.tiles_with_offsets().next()?; |
| 331 | 331 | ||
| 332 | let tile_size = tile.tile_size(); | 332 | let tile_size = tile.tile_size(); |
| 333 | - let tile_rect = Rectangle::from_loc_and_size(offset, tile_size); | 333 | + let tile_rect = Rectangle::new(offset, tile_size); |
| 334 | 334 | ||
| 335 | self.working_area.intersection(tile_rect) | 335 | self.working_area.intersection(tile_rect) |
| 336 | } | 336 | } |
| @@ -1105,7 +1105,7 @@ impl<W: LayoutElement> FloatingSpace<W> { | |||
| 1105 | pos: Point<f64, Logical>, | 1105 | pos: Point<f64, Logical>, |
| 1106 | size: Size<f64, Logical>, | 1106 | size: Size<f64, Logical>, |
| 1107 | ) -> Point<f64, Logical> { | 1107 | ) -> Point<f64, Logical> { |
| 1108 | - let mut rect = Rectangle::from_loc_and_size(pos, size); | 1108 | + let mut rect = Rectangle::new(pos, size); |
| 1109 | clamp_preferring_top_left_in_area(self.working_area, &mut rect); | 1109 | clamp_preferring_top_left_in_area(self.working_area, &mut rect); |
| 1110 | rect.loc | 1110 | rect.loc |
| 1111 | } | 1111 | } |
src/layout/focus_ring.rsmodified+5 -8
| @@ -94,7 +94,7 @@ impl FocusRing { | |||
| 94 | in_: GradientInterpolation::default(), | 94 | in_: GradientInterpolation::default(), |
| 95 | }); | 95 | }); |
| 96 | 96 | ||
| 97 | - let full_rect = Rectangle::from_loc_and_size((-width, -width), self.full_size); | 97 | + let full_rect = Rectangle::new(Point::from((-width, -width)), self.full_size); |
| 98 | let gradient_area = match gradient.relative_to { | 98 | let gradient_area = match gradient.relative_to { |
| 99 | GradientRelativeTo::Window => full_rect, | 99 | GradientRelativeTo::Window => full_rect, |
| 100 | GradientRelativeTo::WorkspaceView => view_rect, | 100 | GradientRelativeTo::WorkspaceView => view_rect, |
| @@ -178,12 +178,12 @@ impl FocusRing { | |||
| 178 | for (border, (loc, size)) in zip(&mut self.borders, zip(self.locations, self.sizes)) { | 178 | for (border, (loc, size)) in zip(&mut self.borders, zip(self.locations, self.sizes)) { |
| 179 | border.update( | 179 | border.update( |
| 180 | size, | 180 | size, |
| 181 | - Rectangle::from_loc_and_size(gradient_area.loc - loc, gradient_area.size), | 181 | + Rectangle::new(gradient_area.loc - loc, gradient_area.size), |
| 182 | gradient.in_, | 182 | gradient.in_, |
| 183 | gradient.from, | 183 | gradient.from, |
| 184 | gradient.to, | 184 | gradient.to, |
| 185 | ((gradient.angle as f32) - 90.).to_radians(), | 185 | ((gradient.angle as f32) - 90.).to_radians(), |
| 186 | - Rectangle::from_loc_and_size(full_rect.loc - loc, full_rect.size), | 186 | + Rectangle::new(full_rect.loc - loc, full_rect.size), |
| 187 | rounded_corner_border_width, | 187 | rounded_corner_border_width, |
| 188 | radius, | 188 | radius, |
| 189 | scale as f32, | 189 | scale as f32, |
| @@ -196,15 +196,12 @@ impl FocusRing { | |||
| 196 | 196 | ||
| 197 | self.borders[0].update( | 197 | self.borders[0].update( |
| 198 | self.sizes[0], | 198 | self.sizes[0], |
| 199 | - Rectangle::from_loc_and_size( | 199 | + Rectangle::new(gradient_area.loc - self.locations[0], gradient_area.size), |
| 200 | - gradient_area.loc - self.locations[0], | ||
| 201 | - gradient_area.size, | ||
| 202 | - ), | ||
| 203 | gradient.in_, | 200 | gradient.in_, |
| 204 | gradient.from, | 201 | gradient.from, |
| 205 | gradient.to, | 202 | gradient.to, |
| 206 | ((gradient.angle as f32) - 90.).to_radians(), | 203 | ((gradient.angle as f32) - 90.).to_radians(), |
| 207 | - Rectangle::from_loc_and_size(full_rect.loc - self.locations[0], full_rect.size), | 204 | + Rectangle::new(full_rect.loc - self.locations[0], full_rect.size), |
| 208 | rounded_corner_border_width, | 205 | rounded_corner_border_width, |
| 209 | radius, | 206 | radius, |
| 210 | scale as f32, | 207 | scale as f32, |
src/layout/mod.rsmodified+6 -8
| @@ -1289,7 +1289,7 @@ impl<W: LayoutElement> Layout<W> { | |||
| 1289 | // window geometry. | 1289 | // window geometry. |
| 1290 | let width = move_.tile.window_size().w; | 1290 | let width = move_.tile.window_size().w; |
| 1291 | let height = output_size(&move_.output).h; | 1291 | let height = output_size(&move_.output).h; |
| 1292 | - let mut target = Rectangle::from_loc_and_size((0., 0.), (width, height)); | 1292 | + let mut target = Rectangle::from_size(Size::from((width, height))); |
| 1293 | // FIXME: ideally this shouldn't include the tile render offset, but the code | 1293 | // FIXME: ideally this shouldn't include the tile render offset, but the code |
| 1294 | // duplication would be a bit annoying for this edge case. | 1294 | // duplication would be a bit annoying for this edge case. |
| 1295 | target.loc.y -= move_.tile_render_location().y; | 1295 | target.loc.y -= move_.tile_render_location().y; |
| @@ -2405,10 +2405,8 @@ impl<W: LayoutElement> Layout<W> { | |||
| 2405 | if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move { | 2405 | if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move { |
| 2406 | if output.map_or(true, |output| move_.output == *output) { | 2406 | if output.map_or(true, |output| move_.output == *output) { |
| 2407 | let pos_within_output = move_.tile_render_location(); | 2407 | let pos_within_output = move_.tile_render_location(); |
| 2408 | - let view_rect = Rectangle::from_loc_and_size( | 2408 | + let view_rect = |
| 2409 | - pos_within_output.upscale(-1.), | 2409 | + Rectangle::new(pos_within_output.upscale(-1.), output_size(&move_.output)); |
| 2410 | - output_size(&move_.output), | ||
| 2411 | - ); | ||
| 2412 | move_.tile.update(true, view_rect); | 2410 | move_.tile.update(true, view_rect); |
| 2413 | } | 2411 | } |
| 2414 | } | 2412 | } |
| @@ -4121,7 +4119,7 @@ mod tests { | |||
| 4121 | id, | 4119 | id, |
| 4122 | parent_id: None, | 4120 | parent_id: None, |
| 4123 | is_floating: false, | 4121 | is_floating: false, |
| 4124 | - bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)), | 4122 | + bbox: Rectangle::from_size(Size::from((100, 200))), |
| 4125 | min_max_size: Default::default(), | 4123 | min_max_size: Default::default(), |
| 4126 | } | 4124 | } |
| 4127 | } | 4125 | } |
| @@ -4295,7 +4293,7 @@ mod tests { | |||
| 4295 | any::<(i16, i16, u16, u16)>().prop_map(|(x, y, w, h)| { | 4293 | any::<(i16, i16, u16, u16)>().prop_map(|(x, y, w, h)| { |
| 4296 | let loc: Point<i32, _> = Point::from((x.into(), y.into())); | 4294 | let loc: Point<i32, _> = Point::from((x.into(), y.into())); |
| 4297 | let size: Size<i32, _> = Size::from((w.max(1).into(), h.max(1).into())); | 4295 | let size: Size<i32, _> = Size::from((w.max(1).into(), h.max(1).into())); |
| 4298 | - Rectangle::from_loc_and_size(loc, size) | 4296 | + Rectangle::new(loc, size) |
| 4299 | }) | 4297 | }) |
| 4300 | } | 4298 | } |
| 4301 | 4299 | ||
| @@ -6078,7 +6076,7 @@ mod tests { | |||
| 6078 | 6076 | ||
| 6079 | Op::AddWindow { | 6077 | Op::AddWindow { |
| 6080 | params: TestWindowParams { | 6078 | params: TestWindowParams { |
| 6081 | - bbox: Rectangle::from_loc_and_size((0, 0), (1280, 200)), | 6079 | + bbox: Rectangle::from_size(Size::from((1280, 200))), |
| 6082 | ..TestWindowParams::new(1) | 6080 | ..TestWindowParams::new(1) |
| 6083 | }, | 6081 | }, |
| 6084 | } | 6082 | } |
src/layout/monitor.rsmodified+11 -5
| @@ -7,7 +7,7 @@ use smithay::backend::renderer::element::utils::{ | |||
| 7 | CropRenderElement, Relocate, RelocateRenderElement, | 7 | CropRenderElement, Relocate, RelocateRenderElement, |
| 8 | }; | 8 | }; |
| 9 | use smithay::output::Output; | 9 | use smithay::output::Output; |
| 10 | -use smithay::utils::{Logical, Point, Rectangle}; | 10 | +use smithay::utils::{Logical, Point, Rectangle, Size}; |
| 11 | 11 | ||
| 12 | use super::scrolling::{Column, ColumnWidth}; | 12 | use super::scrolling::{Column, ColumnWidth}; |
| 13 | use super::tile::Tile; | 13 | use super::tile::Tile; |
| @@ -871,7 +871,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 871 | let offset = switch.target_idx() - self.active_workspace_idx as f64; | 871 | let offset = switch.target_idx() - self.active_workspace_idx as f64; |
| 872 | let offset = offset * size.h; | 872 | let offset = offset * size.h; |
| 873 | 873 | ||
| 874 | - let clip_rect = Rectangle::from_loc_and_size((0., -offset), size); | 874 | + let clip_rect = Rectangle::new(Point::from((0., -offset)), size); |
| 875 | rect = rect.intersection(clip_rect)?; | 875 | rect = rect.intersection(clip_rect)?; |
| 876 | } | 876 | } |
| 877 | 877 | ||
| @@ -930,7 +930,7 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 930 | let size = output_size(&self.output); | 930 | let size = output_size(&self.output); |
| 931 | let (ws, bounds) = self | 931 | let (ws, bounds) = self |
| 932 | .workspaces_with_render_positions() | 932 | .workspaces_with_render_positions() |
| 933 | - .map(|(ws, offset)| (ws, Rectangle::from_loc_and_size(offset, size))) | 933 | + .map(|(ws, offset)| (ws, Rectangle::new(offset, size))) |
| 934 | .find(|(_, bounds)| bounds.contains(pos_within_output))?; | 934 | .find(|(_, bounds)| bounds.contains(pos_within_output))?; |
| 935 | Some((ws, bounds.loc)) | 935 | Some((ws, bounds.loc)) |
| 936 | } | 936 | } |
| @@ -983,9 +983,15 @@ impl<W: LayoutElement> Monitor<W> { | |||
| 983 | // | 983 | // |
| 984 | // FIXME: use proper bounds after fixing the Crop element. | 984 | // FIXME: use proper bounds after fixing the Crop element. |
| 985 | let crop_bounds = if self.workspace_switch.is_some() { | 985 | let crop_bounds = if self.workspace_switch.is_some() { |
| 986 | - Rectangle::from_loc_and_size((-i32::MAX / 2, 0), (i32::MAX, height)) | 986 | + Rectangle::new( |
| 987 | + Point::from((-i32::MAX / 2, 0)), | ||
| 988 | + Size::from((i32::MAX, height)), | ||
| 989 | + ) | ||
| 987 | } else { | 990 | } else { |
| 988 | - Rectangle::from_loc_and_size((-i32::MAX / 2, -i32::MAX / 2), (i32::MAX, i32::MAX)) | 991 | + Rectangle::new( |
| 992 | + Point::from((-i32::MAX / 2, -i32::MAX / 2)), | ||
| 993 | + Size::from((i32::MAX, i32::MAX)), | ||
| 994 | + ) | ||
| 989 | }; | 995 | }; |
| 990 | 996 | ||
| 991 | self.workspaces_with_render_positions() | 997 | self.workspaces_with_render_positions() |
src/layout/opening_window.rsmodified+1 -1
| @@ -72,7 +72,7 @@ impl OpenAnimation { | |||
| 72 | let texture_size = geo.size.to_f64().to_logical(scale); | 72 | let texture_size = geo.size.to_f64().to_logical(scale); |
| 73 | 73 | ||
| 74 | if Shaders::get(renderer).program(ProgramType::Open).is_some() { | 74 | if Shaders::get(renderer).program(ProgramType::Open).is_some() { |
| 75 | - let mut area = Rectangle::from_loc_and_size(location + offset, texture_size); | 75 | + let mut area = Rectangle::new(location + offset, texture_size); |
| 76 | 76 | ||
| 77 | // Expand the area a bit to allow for more varied effects. | 77 | // Expand the area a bit to allow for more varied effects. |
| 78 | let mut target_size = area.size.upscale(1.5); | 78 | let mut target_size = area.size.upscale(1.5); |
src/layout/scrolling.rsmodified+11 -11
| @@ -335,13 +335,13 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 335 | let is_active = is_active && col_idx == active_idx; | 335 | let is_active = is_active && col_idx == active_idx; |
| 336 | let col_off = Point::from((col_x, 0.)); | 336 | let col_off = Point::from((col_x, 0.)); |
| 337 | let col_pos = view_pos - col_off - col.render_offset(); | 337 | let col_pos = view_pos - col_off - col.render_offset(); |
| 338 | - let view_rect = Rectangle::from_loc_and_size(col_pos, view_size); | 338 | + let view_rect = Rectangle::new(col_pos, view_size); |
| 339 | col.update_render_elements(is_active, view_rect); | 339 | col.update_render_elements(is_active, view_rect); |
| 340 | } | 340 | } |
| 341 | 341 | ||
| 342 | if let Some(insert_hint) = &self.insert_hint { | 342 | if let Some(insert_hint) = &self.insert_hint { |
| 343 | if let Some(area) = self.insert_hint_area(insert_hint) { | 343 | if let Some(area) = self.insert_hint_area(insert_hint) { |
| 344 | - let view_rect = Rectangle::from_loc_and_size(area.loc.upscale(-1.), view_size); | 344 | + let view_rect = Rectangle::new(area.loc.upscale(-1.), view_size); |
| 345 | self.insert_hint_element.update_render_elements( | 345 | self.insert_hint_element.update_render_elements( |
| 346 | area.size, | 346 | area.size, |
| 347 | view_rect, | 347 | view_rect, |
| @@ -1919,7 +1919,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 1919 | if column_index == 0 && !self.columns.is_empty() { | 1919 | if column_index == 0 && !self.columns.is_empty() { |
| 1920 | loc.x -= size.w + self.options.gaps; | 1920 | loc.x -= size.w + self.options.gaps; |
| 1921 | } | 1921 | } |
| 1922 | - Rectangle::from_loc_and_size(loc, size) | 1922 | + Rectangle::new(loc, size) |
| 1923 | } else if column_index > self.columns.len() { | 1923 | } else if column_index > self.columns.len() { |
| 1924 | error!("insert hint column index is out of range"); | 1924 | error!("insert hint column index is out of range"); |
| 1925 | return None; | 1925 | return None; |
| @@ -1930,7 +1930,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 1930 | self.column_x(column_index) - size.w / 2. - self.options.gaps / 2., | 1930 | self.column_x(column_index) - size.w / 2. - self.options.gaps / 2., |
| 1931 | self.working_area.loc.y + self.options.gaps, | 1931 | self.working_area.loc.y + self.options.gaps, |
| 1932 | )); | 1932 | )); |
| 1933 | - Rectangle::from_loc_and_size(loc, size) | 1933 | + Rectangle::new(loc, size) |
| 1934 | } | 1934 | } |
| 1935 | } | 1935 | } |
| 1936 | InsertPosition::InColumn(column_index, tile_index) => { | 1936 | InsertPosition::InColumn(column_index, tile_index) => { |
| @@ -1963,7 +1963,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 1963 | 1963 | ||
| 1964 | let size = Size::from((self.data[column_index].width, height)); | 1964 | let size = Size::from((self.data[column_index].width, height)); |
| 1965 | let loc = Point::from((self.column_x(column_index), y)); | 1965 | let loc = Point::from((self.column_x(column_index), y)); |
| 1966 | - Rectangle::from_loc_and_size(loc, size) | 1966 | + Rectangle::new(loc, size) |
| 1967 | } | 1967 | } |
| 1968 | InsertPosition::Floating => return None, | 1968 | InsertPosition::Floating => return None, |
| 1969 | }; | 1969 | }; |
| @@ -2010,9 +2010,9 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 2010 | 2010 | ||
| 2011 | let tile_pos = view_off + tile_off; | 2011 | let tile_pos = view_off + tile_off; |
| 2012 | let tile_size = tile.tile_size(); | 2012 | let tile_size = tile.tile_size(); |
| 2013 | - let tile_rect = Rectangle::from_loc_and_size(tile_pos, tile_size); | 2013 | + let tile_rect = Rectangle::new(tile_pos, tile_size); |
| 2014 | 2014 | ||
| 2015 | - let view = Rectangle::from_loc_and_size((0., 0.), self.view_size); | 2015 | + let view = Rectangle::from_size(self.view_size); |
| 2016 | view.intersection(tile_rect) | 2016 | view.intersection(tile_rect) |
| 2017 | } | 2017 | } |
| 2018 | 2018 | ||
| @@ -2256,7 +2256,7 @@ impl<W: LayoutElement> ScrollingSpace<W> { | |||
| 2256 | } | 2256 | } |
| 2257 | 2257 | ||
| 2258 | // Draw the closing windows on top of the other windows. | 2258 | // Draw the closing windows on top of the other windows. |
| 2259 | - let view_rect = Rectangle::from_loc_and_size((self.view_pos(), 0.), self.view_size); | 2259 | + let view_rect = Rectangle::new(Point::from((self.view_pos(), 0.)), self.view_size); |
| 2260 | for closing in self.closing_windows.iter().rev() { | 2260 | for closing in self.closing_windows.iter().rev() { |
| 2261 | let elem = closing.render(renderer.as_gles_renderer(), view_rect, scale, target); | 2261 | let elem = closing.render(renderer.as_gles_renderer(), view_rect, scale, target); |
| 2262 | rv.push(elem.into()); | 2262 | rv.push(elem.into()); |
| @@ -3731,7 +3731,7 @@ impl<W: LayoutElement> Column<W> { | |||
| 3731 | let width = tile.window_size().w; | 3731 | let width = tile.window_size().w; |
| 3732 | let height = self.view_size.h; | 3732 | let height = self.view_size.h; |
| 3733 | 3733 | ||
| 3734 | - let mut target = Rectangle::from_loc_and_size((0., 0.), (width, height)); | 3734 | + let mut target = Rectangle::from_size(Size::from((width, height))); |
| 3735 | target.loc.y -= pos.y; | 3735 | target.loc.y -= pos.y; |
| 3736 | target.loc.y -= tile.window_loc().y; | 3736 | target.loc.y -= tile.window_loc().y; |
| 3737 | 3737 | ||
| @@ -4028,7 +4028,7 @@ mod tests { | |||
| 4028 | bottom: FloatOrInt(1.), | 4028 | bottom: FloatOrInt(1.), |
| 4029 | }; | 4029 | }; |
| 4030 | 4030 | ||
| 4031 | - let parent_area = Rectangle::from_loc_and_size((0., 0.), (1280., 720.)); | 4031 | + let parent_area = Rectangle::from_size(Size::from((1280., 720.))); |
| 4032 | let area = compute_working_area(parent_area, 1., struts); | 4032 | let area = compute_working_area(parent_area, 1., struts); |
| 4033 | 4033 | ||
| 4034 | assert_eq!(round_logical_in_physical(1., area.loc.x), area.loc.x); | 4034 | assert_eq!(round_logical_in_physical(1., area.loc.x), area.loc.x); |
| @@ -4044,7 +4044,7 @@ mod tests { | |||
| 4044 | bottom: FloatOrInt(0.), | 4044 | bottom: FloatOrInt(0.), |
| 4045 | }; | 4045 | }; |
| 4046 | 4046 | ||
| 4047 | - let parent_area = Rectangle::from_loc_and_size((0., 0.), (1280., 720.)); | 4047 | + let parent_area = Rectangle::from_size(Size::from((1280., 720.))); |
| 4048 | compute_working_area(parent_area, 1., struts); | 4048 | compute_working_area(parent_area, 1., struts); |
| 4049 | } | 4049 | } |
| 4050 | } | 4050 | } |
src/layout/tile.rsmodified+6 -6
| @@ -318,7 +318,7 @@ impl<W: LayoutElement> Tile<W> { | |||
| 318 | self.animated_window_size(), | 318 | self.animated_window_size(), |
| 319 | is_active, | 319 | is_active, |
| 320 | !draw_border_with_background, | 320 | !draw_border_with_background, |
| 321 | - Rectangle::from_loc_and_size( | 321 | + Rectangle::new( |
| 322 | view_rect.loc - Point::from((border_width, border_width)), | 322 | view_rect.loc - Point::from((border_width, border_width)), |
| 323 | view_rect.size, | 323 | view_rect.size, |
| 324 | ), | 324 | ), |
| @@ -590,7 +590,7 @@ impl<W: LayoutElement> Tile<W> { | |||
| 590 | } | 590 | } |
| 591 | 591 | ||
| 592 | pub fn is_in_activation_region(&self, point: Point<f64, Logical>) -> bool { | 592 | pub fn is_in_activation_region(&self, point: Point<f64, Logical>) -> bool { |
| 593 | - let activation_region = Rectangle::from_loc_and_size((0., 0.), self.tile_size()); | 593 | + let activation_region = Rectangle::from_size(self.tile_size()); |
| 594 | activation_region.contains(point) | 594 | activation_region.contains(point) |
| 595 | } | 595 | } |
| 596 | 596 | ||
| @@ -711,7 +711,7 @@ impl<W: LayoutElement> Tile<W> { | |||
| 711 | let window_size = self.window_size().to_f64(); | 711 | let window_size = self.window_size().to_f64(); |
| 712 | let animated_window_size = self.animated_window_size(); | 712 | let animated_window_size = self.animated_window_size(); |
| 713 | let window_render_loc = location + window_loc; | 713 | let window_render_loc = location + window_loc; |
| 714 | - let area = Rectangle::from_loc_and_size(window_render_loc, animated_window_size); | 714 | + let area = Rectangle::new(window_render_loc, animated_window_size); |
| 715 | 715 | ||
| 716 | let rules = self.window.rules(); | 716 | let rules = self.window.rules(); |
| 717 | let clip_to_geometry = !self.is_fullscreen && rules.clip_to_geometry == Some(true); | 717 | let clip_to_geometry = !self.is_fullscreen && rules.clip_to_geometry == Some(true); |
| @@ -810,7 +810,7 @@ impl<W: LayoutElement> Tile<W> { | |||
| 810 | .window | 810 | .window |
| 811 | .render(renderer, window_render_loc, scale, alpha, target); | 811 | .render(renderer, window_render_loc, scale, alpha, target); |
| 812 | 812 | ||
| 813 | - let geo = Rectangle::from_loc_and_size(window_render_loc, window_size); | 813 | + let geo = Rectangle::new(window_render_loc, window_size); |
| 814 | let radius = radius.fit_to(window_size.w as f32, window_size.h as f32); | 814 | let radius = radius.fit_to(window_size.w as f32, window_size.h as f32); |
| 815 | 815 | ||
| 816 | let clip_shader = ClippedSurfaceRenderElement::shader(renderer).cloned(); | 816 | let clip_shader = ClippedSurfaceRenderElement::shader(renderer).cloned(); |
| @@ -852,12 +852,12 @@ impl<W: LayoutElement> Tile<W> { | |||
| 852 | if radius != CornerRadius::default() && has_border_shader { | 852 | if radius != CornerRadius::default() && has_border_shader { |
| 853 | return BorderRenderElement::new( | 853 | return BorderRenderElement::new( |
| 854 | geo.size, | 854 | geo.size, |
| 855 | - Rectangle::from_loc_and_size((0., 0.), geo.size), | 855 | + Rectangle::from_size(geo.size), |
| 856 | GradientInterpolation::default(), | 856 | GradientInterpolation::default(), |
| 857 | Color::from_color32f(elem.color()), | 857 | Color::from_color32f(elem.color()), |
| 858 | Color::from_color32f(elem.color()), | 858 | Color::from_color32f(elem.color()), |
| 859 | 0., | 859 | 0., |
| 860 | - Rectangle::from_loc_and_size((0., 0.), geo.size), | 860 | + Rectangle::from_size(geo.size), |
| 861 | 0., | 861 | 0., |
| 862 | radius, | 862 | radius, |
| 863 | scale.x as f32, | 863 | scale.x as f32, |
src/layout/workspace.rsmodified+4 -4
| @@ -260,7 +260,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 260 | Rc::new(Options::clone(&base_options).adjusted_for_scale(scale.fractional_scale())); | 260 | Rc::new(Options::clone(&base_options).adjusted_for_scale(scale.fractional_scale())); |
| 261 | 261 | ||
| 262 | let view_size = Size::from((1280., 720.)); | 262 | let view_size = Size::from((1280., 720.)); |
| 263 | - let working_area = Rectangle::from_loc_and_size((0., 0.), (1280., 720.)); | 263 | + let working_area = Rectangle::from_size(Size::from((1280., 720.))); |
| 264 | 264 | ||
| 265 | let scrolling = ScrollingSpace::new( | 265 | let scrolling = ScrollingSpace::new( |
| 266 | view_size, | 266 | view_size, |
| @@ -337,7 +337,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 337 | self.scrolling | 337 | self.scrolling |
| 338 | .update_render_elements(is_active && !self.floating_is_active.get()); | 338 | .update_render_elements(is_active && !self.floating_is_active.get()); |
| 339 | 339 | ||
| 340 | - let view_rect = Rectangle::from_loc_and_size((0., 0.), self.view_size); | 340 | + let view_rect = Rectangle::from_size(self.view_size); |
| 341 | self.floating | 341 | self.floating |
| 342 | .update_render_elements(is_active && self.floating_is_active.get(), view_rect); | 342 | .update_render_elements(is_active && self.floating_is_active.get(), view_rect); |
| 343 | } | 343 | } |
| @@ -1332,7 +1332,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1332 | 1332 | ||
| 1333 | let floating_focus_ring = focus_ring && self.floating_is_active(); | 1333 | let floating_focus_ring = focus_ring && self.floating_is_active(); |
| 1334 | let floating = self.is_floating_visible().then(|| { | 1334 | let floating = self.is_floating_visible().then(|| { |
| 1335 | - let view_rect = Rectangle::from_loc_and_size((0., 0.), self.view_size); | 1335 | + let view_rect = Rectangle::from_size(self.view_size); |
| 1336 | let floating = self.floating.render_elements( | 1336 | let floating = self.floating.render_elements( |
| 1337 | renderer, | 1337 | renderer, |
| 1338 | view_rect, | 1338 | view_rect, |
| @@ -1364,7 +1364,7 @@ impl<W: LayoutElement> Workspace<W> { | |||
| 1364 | for (tile, tile_pos) in self.tiles_with_render_positions_mut(false) { | 1364 | for (tile, tile_pos) in self.tiles_with_render_positions_mut(false) { |
| 1365 | if tile.window().id() == window { | 1365 | if tile.window().id() == window { |
| 1366 | let view_pos = Point::from((-tile_pos.x, -tile_pos.y)); | 1366 | let view_pos = Point::from((-tile_pos.x, -tile_pos.y)); |
| 1367 | - let view_rect = Rectangle::from_loc_and_size(view_pos, view_size); | 1367 | + let view_rect = Rectangle::new(view_pos, view_size); |
| 1368 | tile.update(false, view_rect); | 1368 | tile.update(false, view_rect); |
| 1369 | tile.store_unmap_snapshot_if_empty(renderer, output_scale); | 1369 | tile.store_unmap_snapshot_if_empty(renderer, output_scale); |
| 1370 | return; | 1370 | return; |
src/niri.rsmodified+13 -13
| @@ -2169,7 +2169,7 @@ impl Niri { | |||
| 2169 | .map(|pos| Point::from((pos.x, pos.y))) | 2169 | .map(|pos| Point::from((pos.x, pos.y))) |
| 2170 | .filter(|pos| { | 2170 | .filter(|pos| { |
| 2171 | // Ensure that the requested position does not overlap any existing output. | 2171 | // Ensure that the requested position does not overlap any existing output. |
| 2172 | - let target_geom = Rectangle::from_loc_and_size(*pos, size); | 2172 | + let target_geom = Rectangle::new(*pos, size); |
| 2173 | 2173 | ||
| 2174 | let overlap = self | 2174 | let overlap = self |
| 2175 | .global_space | 2175 | .global_space |
| @@ -2651,9 +2651,9 @@ impl Niri { | |||
| 2651 | pub fn output_left(&self) -> Option<Output> { | 2651 | pub fn output_left(&self) -> Option<Output> { |
| 2652 | let active = self.layout.active_output()?; | 2652 | let active = self.layout.active_output()?; |
| 2653 | let active_geo = self.global_space.output_geometry(active).unwrap(); | 2653 | let active_geo = self.global_space.output_geometry(active).unwrap(); |
| 2654 | - let extended_geo = Rectangle::from_loc_and_size( | 2654 | + let extended_geo = Rectangle::new( |
| 2655 | - (i32::MIN / 2, active_geo.loc.y), | 2655 | + Point::from((i32::MIN / 2, active_geo.loc.y)), |
| 2656 | - (i32::MAX, active_geo.size.h), | 2656 | + Size::from((i32::MAX, active_geo.size.h)), |
| 2657 | ); | 2657 | ); |
| 2658 | 2658 | ||
| 2659 | self.global_space | 2659 | self.global_space |
| @@ -2668,9 +2668,9 @@ impl Niri { | |||
| 2668 | pub fn output_right(&self) -> Option<Output> { | 2668 | pub fn output_right(&self) -> Option<Output> { |
| 2669 | let active = self.layout.active_output()?; | 2669 | let active = self.layout.active_output()?; |
| 2670 | let active_geo = self.global_space.output_geometry(active).unwrap(); | 2670 | let active_geo = self.global_space.output_geometry(active).unwrap(); |
| 2671 | - let extended_geo = Rectangle::from_loc_and_size( | 2671 | + let extended_geo = Rectangle::new( |
| 2672 | - (i32::MIN / 2, active_geo.loc.y), | 2672 | + Point::from((i32::MIN / 2, active_geo.loc.y)), |
| 2673 | - (i32::MAX, active_geo.size.h), | 2673 | + Size::from((i32::MAX, active_geo.size.h)), |
| 2674 | ); | 2674 | ); |
| 2675 | 2675 | ||
| 2676 | self.global_space | 2676 | self.global_space |
| @@ -2685,9 +2685,9 @@ impl Niri { | |||
| 2685 | pub fn output_up(&self) -> Option<Output> { | 2685 | pub fn output_up(&self) -> Option<Output> { |
| 2686 | let active = self.layout.active_output()?; | 2686 | let active = self.layout.active_output()?; |
| 2687 | let active_geo = self.global_space.output_geometry(active).unwrap(); | 2687 | let active_geo = self.global_space.output_geometry(active).unwrap(); |
| 2688 | - let extended_geo = Rectangle::from_loc_and_size( | 2688 | + let extended_geo = Rectangle::new( |
| 2689 | - (active_geo.loc.x, i32::MIN / 2), | 2689 | + Point::from((active_geo.loc.x, i32::MIN / 2)), |
| 2690 | - (active_geo.size.w, i32::MAX), | 2690 | + Size::from((active_geo.size.w, i32::MAX)), |
| 2691 | ); | 2691 | ); |
| 2692 | 2692 | ||
| 2693 | self.global_space | 2693 | self.global_space |
| @@ -2746,9 +2746,9 @@ impl Niri { | |||
| 2746 | pub fn output_down(&self) -> Option<Output> { | 2746 | pub fn output_down(&self) -> Option<Output> { |
| 2747 | let active = self.layout.active_output()?; | 2747 | let active = self.layout.active_output()?; |
| 2748 | let active_geo = self.global_space.output_geometry(active).unwrap(); | 2748 | let active_geo = self.global_space.output_geometry(active).unwrap(); |
| 2749 | - let extended_geo = Rectangle::from_loc_and_size( | 2749 | + let extended_geo = Rectangle::new( |
| 2750 | - (active_geo.loc.x, i32::MIN / 2), | 2750 | + Point::from((active_geo.loc.x, i32::MIN / 2)), |
| 2751 | - (active_geo.size.w, i32::MAX), | 2751 | + Size::from((active_geo.size.w, i32::MAX)), |
| 2752 | ); | 2752 | ); |
| 2753 | 2753 | ||
| 2754 | self.global_space | 2754 | self.global_space |
src/protocols/screencopy.rsmodified+2 -2
| @@ -206,9 +206,9 @@ where | |||
| 206 | let output_transform = output.current_transform(); | 206 | let output_transform = output.current_transform(); |
| 207 | let output_physical_size = | 207 | let output_physical_size = |
| 208 | output_transform.transform_size(output.current_mode().unwrap().size); | 208 | output_transform.transform_size(output.current_mode().unwrap().size); |
| 209 | - let output_rect = Rectangle::from_loc_and_size((0, 0), output_physical_size); | 209 | + let output_rect = Rectangle::from_size(output_physical_size); |
| 210 | 210 | ||
| 211 | - let rect = Rectangle::from_loc_and_size((x, y), (width, height)); | 211 | + let rect = Rectangle::new(Point::from((x, y)), Size::from((width, height))); |
| 212 | 212 | ||
| 213 | let output_scale = output.current_scale().fractional_scale(); | 213 | let output_scale = output.current_scale().fractional_scale(); |
| 214 | let physical_rect = rect.to_physical_precise_round(output_scale); | 214 | let physical_rect = rect.to_physical_precise_round(output_scale); |
src/render_helpers/clipped_surface.rsmodified+12 -12
| @@ -6,7 +6,7 @@ use smithay::backend::renderer::gles::{ | |||
| 6 | GlesError, GlesFrame, GlesRenderer, GlesTexProgram, Uniform, | 6 | GlesError, GlesFrame, GlesRenderer, GlesTexProgram, Uniform, |
| 7 | }; | 7 | }; |
| 8 | use smithay::backend::renderer::utils::{CommitCounter, DamageSet, OpaqueRegions}; | 8 | use smithay::backend::renderer::utils::{CommitCounter, DamageSet, OpaqueRegions}; |
| 9 | -use smithay::utils::{Buffer, Logical, Physical, Rectangle, Scale, Size, Transform}; | 9 | +use smithay::utils::{Buffer, Logical, Physical, Point, Rectangle, Scale, Size, Transform}; |
| 10 | 10 | ||
| 11 | use super::damage::ExtraDamage; | 11 | use super::damage::ExtraDamage; |
| 12 | use super::renderer::{AsGlesFrame as _, NiriRenderer}; | 12 | use super::renderer::{AsGlesFrame as _, NiriRenderer}; |
| @@ -117,21 +117,21 @@ impl<R: NiriRenderer> ClippedSurfaceRenderElement<R> { | |||
| 117 | let bottom_left = corner_radius.bottom_left as f64; | 117 | let bottom_left = corner_radius.bottom_left as f64; |
| 118 | 118 | ||
| 119 | [ | 119 | [ |
| 120 | - Rectangle::from_loc_and_size(geo.loc, (top_left, top_left)), | 120 | + Rectangle::new(geo.loc, Size::from((top_left, top_left))), |
| 121 | - Rectangle::from_loc_and_size( | 121 | + Rectangle::new( |
| 122 | - (geo.loc.x + geo.size.w - top_right, geo.loc.y), | 122 | + Point::from((geo.loc.x + geo.size.w - top_right, geo.loc.y)), |
| 123 | - (top_right, top_right), | 123 | + Size::from((top_right, top_right)), |
| 124 | ), | 124 | ), |
| 125 | - Rectangle::from_loc_and_size( | 125 | + Rectangle::new( |
| 126 | - ( | 126 | + Point::from(( |
| 127 | geo.loc.x + geo.size.w - bottom_right, | 127 | geo.loc.x + geo.size.w - bottom_right, |
| 128 | geo.loc.y + geo.size.h - bottom_right, | 128 | geo.loc.y + geo.size.h - bottom_right, |
| 129 | - ), | 129 | + )), |
| 130 | - (bottom_right, bottom_right), | 130 | + Size::from((bottom_right, bottom_right)), |
| 131 | ), | 131 | ), |
| 132 | - Rectangle::from_loc_and_size( | 132 | + Rectangle::new( |
| 133 | - (geo.loc.x, geo.loc.y + geo.size.h - bottom_left), | 133 | + Point::from((geo.loc.x, geo.loc.y + geo.size.h - bottom_left)), |
| 134 | - (bottom_left, bottom_left), | 134 | + Size::from((bottom_left, bottom_left)), |
| 135 | ), | 135 | ), |
| 136 | ] | 136 | ] |
| 137 | } | 137 | } |
src/render_helpers/damage.rsmodified+1 -1
| @@ -54,7 +54,7 @@ impl Element for ExtraDamage { | |||
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | fn src(&self) -> Rectangle<f64, Buffer> { | 56 | fn src(&self) -> Rectangle<f64, Buffer> { |
| 57 | - Rectangle::from_loc_and_size((0., 0.), (1., 1.)) | 57 | + Rectangle::from_size(Size::from((1., 1.))) |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> { | 60 | fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> { |
src/render_helpers/mod.rsmodified+2 -2
| @@ -216,7 +216,7 @@ pub fn render_and_download( | |||
| 216 | 216 | ||
| 217 | let buffer_size = size.to_logical(1).to_buffer(1, Transform::Normal); | 217 | let buffer_size = size.to_logical(1).to_buffer(1, Transform::Normal); |
| 218 | let mapping = renderer | 218 | let mapping = renderer |
| 219 | - .copy_framebuffer(Rectangle::from_loc_and_size((0, 0), buffer_size), fourcc) | 219 | + .copy_framebuffer(Rectangle::from_size(buffer_size), fourcc) |
| 220 | .context("error copying framebuffer")?; | 220 | .context("error copying framebuffer")?; |
| 221 | Ok(mapping) | 221 | Ok(mapping) |
| 222 | } | 222 | } |
| @@ -300,7 +300,7 @@ fn render_elements( | |||
| 300 | elements: impl Iterator<Item = impl RenderElement<GlesRenderer>>, | 300 | elements: impl Iterator<Item = impl RenderElement<GlesRenderer>>, |
| 301 | ) -> anyhow::Result<SyncPoint> { | 301 | ) -> anyhow::Result<SyncPoint> { |
| 302 | let transform = transform.invert(); | 302 | let transform = transform.invert(); |
| 303 | - let output_rect = Rectangle::from_loc_and_size((0, 0), transform.transform_size(size)); | 303 | + let output_rect = Rectangle::from_size(transform.transform_size(size)); |
| 304 | 304 | ||
| 305 | let mut frame = renderer | 305 | let mut frame = renderer |
| 306 | .render(size, transform) | 306 | .render(size, transform) |
src/render_helpers/resize.rsmodified+1 -1
| @@ -43,7 +43,7 @@ impl ResizeRenderElement { | |||
| 43 | let tex_next_geo_scaled = tex_next_geo.to_f64().upscale(scale_next); | 43 | let tex_next_geo_scaled = tex_next_geo.to_f64().upscale(scale_next); |
| 44 | let combined_geo = tex_prev_geo_scaled.merge(tex_next_geo_scaled).to_i32_up(); | 44 | let combined_geo = tex_prev_geo_scaled.merge(tex_next_geo_scaled).to_i32_up(); |
| 45 | 45 | ||
| 46 | - let area = Rectangle::from_loc_and_size( | 46 | + let area = Rectangle::new( |
| 47 | area.loc + combined_geo.loc.to_logical(scale), | 47 | area.loc + combined_geo.loc.to_logical(scale), |
| 48 | combined_geo.size.to_logical(scale), | 48 | combined_geo.size.to_logical(scale), |
| 49 | ); | 49 | ); |
src/render_helpers/shader_element.rsmodified+4 -4
| @@ -193,7 +193,7 @@ impl ShaderRenderElement { | |||
| 193 | program, | 193 | program, |
| 194 | id: Id::new(), | 194 | id: Id::new(), |
| 195 | commit_counter: CommitCounter::default(), | 195 | commit_counter: CommitCounter::default(), |
| 196 | - area: Rectangle::from_loc_and_size((0., 0.), size), | 196 | + area: Rectangle::from_size(size), |
| 197 | opaque_regions: opaque_regions.unwrap_or_default(), | 197 | opaque_regions: opaque_regions.unwrap_or_default(), |
| 198 | scale, | 198 | scale, |
| 199 | alpha, | 199 | alpha, |
| @@ -255,7 +255,7 @@ impl Element for ShaderRenderElement { | |||
| 255 | } | 255 | } |
| 256 | 256 | ||
| 257 | fn src(&self) -> Rectangle<f64, Buffer> { | 257 | fn src(&self) -> Rectangle<f64, Buffer> { |
| 258 | - Rectangle::from_loc_and_size((0., 0.), (1., 1.)) | 258 | + Rectangle::from_size(Size::from((1., 1.))) |
| 259 | } | 259 | } |
| 260 | 260 | ||
| 261 | fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> { | 261 | fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> { |
| @@ -314,7 +314,7 @@ impl RenderElement<GlesRenderer> for ShaderRenderElement { | |||
| 314 | (dest_size.to_point() - rect_constrained_loc).to_size(), | 314 | (dest_size.to_point() - rect_constrained_loc).to_size(), |
| 315 | ); | 315 | ); |
| 316 | 316 | ||
| 317 | - let rect = Rectangle::from_loc_and_size(rect_constrained_loc, rect_clamped_size); | 317 | + let rect = Rectangle::new(rect_constrained_loc, rect_clamped_size); |
| 318 | [ | 318 | [ |
| 319 | rect.loc.x as f32, | 319 | rect.loc.x as f32, |
| 320 | rect.loc.y as f32, | 320 | rect.loc.y as f32, |
| @@ -334,7 +334,7 @@ impl RenderElement<GlesRenderer> for ShaderRenderElement { | |||
| 334 | (dest_size.to_point() - rect_constrained_loc).to_size(), | 334 | (dest_size.to_point() - rect_constrained_loc).to_size(), |
| 335 | ); | 335 | ); |
| 336 | 336 | ||
| 337 | - let rect = Rectangle::from_loc_and_size(rect_constrained_loc, rect_clamped_size); | 337 | + let rect = Rectangle::new(rect_constrained_loc, rect_clamped_size); |
| 338 | // Add the 4 f32s per damage rectangle for each of the 6 vertices. | 338 | // Add the 4 f32s per damage rectangle for each of the 6 vertices. |
| 339 | (0..6).flat_map(move |_| { | 339 | (0..6).flat_map(move |_| { |
| 340 | [ | 340 | [ |
src/render_helpers/solid_color.rsmodified+3 -4
| @@ -85,7 +85,7 @@ impl SolidColorRenderElement { | |||
| 85 | alpha: f32, | 85 | alpha: f32, |
| 86 | kind: Kind, | 86 | kind: Kind, |
| 87 | ) -> Self { | 87 | ) -> Self { |
| 88 | - let geo = Rectangle::from_loc_and_size(location, buffer.size()); | 88 | + let geo = Rectangle::new(location.into(), buffer.size()); |
| 89 | let color = buffer.color * alpha; | 89 | let color = buffer.color * alpha; |
| 90 | Self::new(buffer.id.clone(), geo, buffer.commit, color, kind) | 90 | Self::new(buffer.id.clone(), geo, buffer.commit, color, kind) |
| 91 | } | 91 | } |
| @@ -125,7 +125,7 @@ impl Element for SolidColorRenderElement { | |||
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | fn src(&self) -> Rectangle<f64, Buffer> { | 127 | fn src(&self) -> Rectangle<f64, Buffer> { |
| 128 | - Rectangle::from_loc_and_size((0., 0.), (1., 1.)) | 128 | + Rectangle::from_size(Size::from((1., 1.))) |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> { | 131 | fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> { |
| @@ -134,8 +134,7 @@ impl Element for SolidColorRenderElement { | |||
| 134 | 134 | ||
| 135 | fn opaque_regions(&self, scale: Scale<f64>) -> OpaqueRegions<i32, Physical> { | 135 | fn opaque_regions(&self, scale: Scale<f64>) -> OpaqueRegions<i32, Physical> { |
| 136 | if self.color.is_opaque() { | 136 | if self.color.is_opaque() { |
| 137 | - let rect = Rectangle::from_loc_and_size((0., 0.), self.geometry.size) | 137 | + let rect = Rectangle::from_size(self.geometry.size).to_physical_precise_down(scale); |
| 138 | - .to_physical_precise_down(scale); | ||
| 139 | OpaqueRegions::from_slice(&[rect]) | 138 | OpaqueRegions::from_slice(&[rect]) |
| 140 | } else { | 139 | } else { |
| 141 | OpaqueRegions::default() | 140 | OpaqueRegions::default() |
src/render_helpers/texture.rsmodified+2 -4
| @@ -157,7 +157,7 @@ impl<T: Texture> Element for TextureRenderElement<T> { | |||
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> { | 159 | fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> { |
| 160 | - let logical_geo = Rectangle::from_loc_and_size(self.location, self.logical_size()); | 160 | + let logical_geo = Rectangle::new(self.location, self.logical_size()); |
| 161 | logical_geo.to_physical_precise_round(scale) | 161 | logical_geo.to_physical_precise_round(scale) |
| 162 | } | 162 | } |
| 163 | 163 | ||
| @@ -174,9 +174,7 @@ impl<T: Texture> Element for TextureRenderElement<T> { | |||
| 174 | &self.buffer.logical_size(), | 174 | &self.buffer.logical_size(), |
| 175 | ) | 175 | ) |
| 176 | }) | 176 | }) |
| 177 | - .unwrap_or_else(|| { | 177 | + .unwrap_or_else(|| Rectangle::from_size(self.buffer.texture.size()).to_f64()) |
| 178 | - Rectangle::from_loc_and_size((0, 0), self.buffer.texture.size()).to_f64() | ||
| 179 | - }) | ||
| 180 | } | 178 | } |
| 181 | 179 | ||
| 182 | fn opaque_regions(&self, scale: Scale<f64>) -> OpaqueRegions<i32, Physical> { | 180 | fn opaque_regions(&self, scale: Scale<f64>) -> OpaqueRegions<i32, Physical> { |
src/ui/screenshot_ui.rsmodified+14 -11
| @@ -127,9 +127,9 @@ impl ScreenshotUi { | |||
| 127 | let size = output_transform.transform_size(output_mode.size); | 127 | let size = output_transform.transform_size(output_mode.size); |
| 128 | ( | 128 | ( |
| 129 | output, | 129 | output, |
| 130 | - Rectangle::from_loc_and_size( | 130 | + Rectangle::new( |
| 131 | - (size.w / 4, size.h / 4), | 131 | + Point::from((size.w / 4, size.h / 4)), |
| 132 | - (size.w / 2, size.h / 2), | 132 | + Size::from((size.w / 2, size.h / 2)), |
| 133 | ), | 133 | ), |
| 134 | ) | 134 | ) |
| 135 | } | 135 | } |
| @@ -268,10 +268,10 @@ impl ScreenshotUi { | |||
| 268 | 268 | ||
| 269 | if output == selection_output { | 269 | if output == selection_output { |
| 270 | // Check if the selection is still valid. If not, reset it back to default. | 270 | // Check if the selection is still valid. If not, reset it back to default. |
| 271 | - if !Rectangle::from_loc_and_size((0, 0), size).contains_rect(rect) { | 271 | + if !Rectangle::from_size(size).contains_rect(rect) { |
| 272 | - rect = Rectangle::from_loc_and_size( | 272 | + rect = Rectangle::new( |
| 273 | - (size.w / 4, size.h / 4), | 273 | + Point::from((size.w / 4, size.h / 4)), |
| 274 | - (size.w / 2, size.h / 2), | 274 | + Size::from((size.w / 2, size.h / 2)), |
| 275 | ); | 275 | ); |
| 276 | *a = rect.loc; | 276 | *a = rect.loc; |
| 277 | *b = rect.loc + rect.size - Size::from((1, 1)); | 277 | *b = rect.loc + rect.size - Size::from((1, 1)); |
| @@ -446,7 +446,7 @@ impl ScreenshotUi { | |||
| 446 | ); | 446 | ); |
| 447 | match res { | 447 | match res { |
| 448 | Ok((texture, _)) => { | 448 | Ok((texture, _)) => { |
| 449 | - tex_rect = Some((texture, Rectangle::from_loc_and_size((0, 0), rect.size))); | 449 | + tex_rect = Some((texture, Rectangle::from_size(rect.size))); |
| 450 | } | 450 | } |
| 451 | Err(err) => { | 451 | Err(err) => { |
| 452 | warn!("error compositing pointer onto screenshot: {err:?}"); | 452 | warn!("error compositing pointer onto screenshot: {err:?}"); |
| @@ -556,9 +556,12 @@ impl ScreenshotUi { | |||
| 556 | let mut rect = rect_from_corner_points(*a, *b); | 556 | let mut rect = rect_from_corner_points(*a, *b); |
| 557 | if rect.size.is_empty() || rect.size == Size::from((1, 1)) { | 557 | if rect.size.is_empty() || rect.size == Size::from((1, 1)) { |
| 558 | let data = &output_data[output]; | 558 | let data = &output_data[output]; |
| 559 | - rect = Rectangle::from_loc_and_size((rect.loc.x - 16, rect.loc.y - 16), (32, 32)) | 559 | + rect = Rectangle::new( |
| 560 | - .intersection(Rectangle::from_loc_and_size((0, 0), data.size)) | 560 | + Point::from((rect.loc.x - 16, rect.loc.y - 16)), |
| 561 | - .unwrap_or_default(); | 561 | + Size::from((32, 32)), |
| 562 | + ) | ||
| 563 | + .intersection(Rectangle::from_size(data.size)) | ||
| 564 | + .unwrap_or_default(); | ||
| 562 | *a = rect.loc; | 565 | *a = rect.loc; |
| 563 | *b = rect.loc + rect.size - Size::from((1, 1)); | 566 | *b = rect.loc + rect.size - Size::from((1, 1)); |
| 564 | } | 567 | } |
src/utils/mod.rsmodified+2 -2
| @@ -375,8 +375,8 @@ mod tests { | |||
| 375 | (rx, ry, rw, rh): (i32, i32, i32, i32), | 375 | (rx, ry, rw, rh): (i32, i32, i32, i32), |
| 376 | (ex, ey): (i32, i32), | 376 | (ex, ey): (i32, i32), |
| 377 | ) { | 377 | ) { |
| 378 | - let area = Rectangle::from_loc_and_size((ax, ay), (aw, ah)).to_f64(); | 378 | + let area = Rectangle::new(Point::from((ax, ay)), Size::from((aw, ah))).to_f64(); |
| 379 | - let mut rect = Rectangle::from_loc_and_size((rx, ry), (rw, rh)).to_f64(); | 379 | + let mut rect = Rectangle::new(Point::from((rx, ry)), Size::from((rw, rh))).to_f64(); |
| 380 | clamp_preferring_top_left_in_area(area, &mut rect); | 380 | clamp_preferring_top_left_in_area(area, &mut rect); |
| 381 | assert_eq!(rect.loc, Point::from((ex, ey)).to_f64()); | 381 | assert_eq!(rect.loc, Point::from((ex, ey)).to_f64()); |
| 382 | } | 382 | } |
src/window/mapped.rsmodified+3 -3
| @@ -365,12 +365,12 @@ impl Mapped { | |||
| 365 | let geo = elem.geo(); | 365 | let geo = elem.geo(); |
| 366 | return BorderRenderElement::new( | 366 | return BorderRenderElement::new( |
| 367 | geo.size, | 367 | geo.size, |
| 368 | - Rectangle::from_loc_and_size((0., 0.), geo.size), | 368 | + Rectangle::from_size(geo.size), |
| 369 | GradientInterpolation::default(), | 369 | GradientInterpolation::default(), |
| 370 | Color::from_color32f(elem.color()), | 370 | Color::from_color32f(elem.color()), |
| 371 | Color::from_color32f(elem.color()), | 371 | Color::from_color32f(elem.color()), |
| 372 | 0., | 372 | 0., |
| 373 | - Rectangle::from_loc_and_size((0., 0.), geo.size), | 373 | + Rectangle::from_size(geo.size), |
| 374 | 0., | 374 | 0., |
| 375 | radius, | 375 | radius, |
| 376 | scale.x as f32, | 376 | scale.x as f32, |
| @@ -665,7 +665,7 @@ impl LayoutElement for Mapped { | |||
| 665 | } | 665 | } |
| 666 | 666 | ||
| 667 | fn output_enter(&self, output: &Output) { | 667 | fn output_enter(&self, output: &Output) { |
| 668 | - let overlap = Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX)); | 668 | + let overlap = Rectangle::from_size(Size::from((i32::MAX, i32::MAX))); |
| 669 | self.window.output_enter(output, overlap) | 669 | self.window.output_enter(output, overlap) |
| 670 | } | 670 | } |
| 671 | 671 | ||