mirror of
https://github.com/niri-wm/niri.git
synced 2026-06-21 02:01:55 +07:00
Migrate to new Rectangle functions
This commit is contained in:
@@ -5,7 +5,7 @@ use niri::render_helpers::border::BorderRenderElement;
|
||||
use niri_config::{Color, CornerRadius, GradientInterpolation};
|
||||
use smithay::backend::renderer::element::RenderElement;
|
||||
use smithay::backend::renderer::gles::GlesRenderer;
|
||||
use smithay::utils::{Physical, Rectangle, Size};
|
||||
use smithay::utils::{Physical, Point, Rectangle, Size};
|
||||
|
||||
use super::{Args, TestCase};
|
||||
|
||||
@@ -50,16 +50,16 @@ impl TestCase for GradientAngle {
|
||||
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
|
||||
let (a, b) = (size.w / 4, size.h / 4);
|
||||
let size = (size.w - a * 2, size.h - b * 2);
|
||||
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
|
||||
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
|
||||
|
||||
[BorderRenderElement::new(
|
||||
area.size,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
GradientInterpolation::default(),
|
||||
Color::new_unpremul(1., 0., 0., 1.),
|
||||
Color::new_unpremul(0., 1., 0., 1.),
|
||||
self.angle - FRAC_PI_2,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
0.,
|
||||
CornerRadius::default(),
|
||||
1.,
|
||||
|
||||
@@ -65,8 +65,8 @@ impl TestCase for GradientArea {
|
||||
let f = (self.progress.sin() + 1.) / 2.;
|
||||
|
||||
let (a, b) = (size.w / 4, size.h / 4);
|
||||
let rect_size = (size.w - a * 2, size.h - b * 2);
|
||||
let area = Rectangle::from_loc_and_size((a, b), rect_size).to_f64();
|
||||
let rect_size = Size::from((size.w - a * 2, size.h - b * 2));
|
||||
let area = Rectangle::new(Point::from((a, b)), rect_size).to_f64();
|
||||
|
||||
let g_size = Size::from((
|
||||
(size.w as f32 / 8. + size.w as f32 / 8. * 7. * f).round() as i32,
|
||||
@@ -74,7 +74,7 @@ impl TestCase for GradientArea {
|
||||
));
|
||||
let g_loc = Point::from(((size.w - g_size.w) / 2, (size.h - g_size.h) / 2)).to_f64();
|
||||
let g_size = g_size.to_f64();
|
||||
let mut g_area = Rectangle::from_loc_and_size(g_loc, g_size);
|
||||
let mut g_area = Rectangle::new(g_loc, g_size);
|
||||
g_area.loc -= area.loc;
|
||||
|
||||
self.border.update_render_elements(
|
||||
@@ -99,7 +99,7 @@ impl TestCase for GradientArea {
|
||||
Color::new_unpremul(1., 0., 0., 1.),
|
||||
Color::new_unpremul(0., 1., 0., 1.),
|
||||
FRAC_PI_4,
|
||||
Rectangle::from_loc_and_size((0, 0), rect_size).to_f64(),
|
||||
Rectangle::from_size(rect_size).to_f64(),
|
||||
0.,
|
||||
CornerRadius::default(),
|
||||
1.,
|
||||
|
||||
@@ -4,7 +4,7 @@ use niri_config::{
|
||||
};
|
||||
use smithay::backend::renderer::element::RenderElement;
|
||||
use smithay::backend::renderer::gles::GlesRenderer;
|
||||
use smithay::utils::{Physical, Rectangle, Size};
|
||||
use smithay::utils::{Physical, Point, Rectangle, Size};
|
||||
|
||||
use super::{Args, TestCase};
|
||||
|
||||
@@ -31,16 +31,16 @@ impl TestCase for GradientOklab {
|
||||
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
|
||||
let (a, b) = (size.w / 6, size.h / 3);
|
||||
let size = (size.w - a * 2, size.h - b * 2);
|
||||
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
|
||||
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
|
||||
|
||||
[BorderRenderElement::new(
|
||||
area.size,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
self.gradient_format,
|
||||
Color::new_unpremul(1., 0., 0., 1.),
|
||||
Color::new_unpremul(0., 1., 0., 1.),
|
||||
0.,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
0.,
|
||||
CornerRadius::default(),
|
||||
1.,
|
||||
|
||||
@@ -2,7 +2,7 @@ use niri::render_helpers::border::BorderRenderElement;
|
||||
use niri_config::{Color, CornerRadius, GradientColorSpace, GradientInterpolation};
|
||||
use smithay::backend::renderer::element::RenderElement;
|
||||
use smithay::backend::renderer::gles::GlesRenderer;
|
||||
use smithay::utils::{Physical, Rectangle, Size};
|
||||
use smithay::utils::{Physical, Point, Rectangle, Size};
|
||||
|
||||
use super::{Args, TestCase};
|
||||
|
||||
@@ -29,16 +29,16 @@ impl TestCase for GradientOklabAlpha {
|
||||
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
|
||||
let (a, b) = (size.w / 6, size.h / 3);
|
||||
let size = (size.w - a * 2, size.h - b * 2);
|
||||
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
|
||||
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
|
||||
|
||||
[BorderRenderElement::new(
|
||||
area.size,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
self.gradient_format,
|
||||
Color::new_unpremul(1., 0., 0., 1.),
|
||||
Color::new_unpremul(0., 1., 0., 0.),
|
||||
0.,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
0.,
|
||||
CornerRadius::default(),
|
||||
1.,
|
||||
|
||||
@@ -4,7 +4,7 @@ use niri_config::{
|
||||
};
|
||||
use smithay::backend::renderer::element::RenderElement;
|
||||
use smithay::backend::renderer::gles::GlesRenderer;
|
||||
use smithay::utils::{Physical, Rectangle, Size};
|
||||
use smithay::utils::{Physical, Point, Rectangle, Size};
|
||||
|
||||
use super::{Args, TestCase};
|
||||
|
||||
@@ -31,16 +31,16 @@ impl TestCase for GradientOklchAlpha {
|
||||
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
|
||||
let (a, b) = (size.w / 6, size.h / 3);
|
||||
let size = (size.w - a * 2, size.h - b * 2);
|
||||
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
|
||||
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
|
||||
|
||||
[BorderRenderElement::new(
|
||||
area.size,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
self.gradient_format,
|
||||
Color::new_unpremul(1., 0., 0., 1.),
|
||||
Color::new_unpremul(0., 1., 0., 0.),
|
||||
0.,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
0.,
|
||||
CornerRadius::default(),
|
||||
1.,
|
||||
|
||||
@@ -4,7 +4,7 @@ use niri_config::{
|
||||
};
|
||||
use smithay::backend::renderer::element::RenderElement;
|
||||
use smithay::backend::renderer::gles::GlesRenderer;
|
||||
use smithay::utils::{Physical, Rectangle, Size};
|
||||
use smithay::utils::{Physical, Point, Rectangle, Size};
|
||||
|
||||
use super::{Args, TestCase};
|
||||
|
||||
@@ -31,16 +31,16 @@ impl TestCase for GradientOklchDecreasing {
|
||||
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
|
||||
let (a, b) = (size.w / 6, size.h / 3);
|
||||
let size = (size.w - a * 2, size.h - b * 2);
|
||||
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
|
||||
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
|
||||
|
||||
[BorderRenderElement::new(
|
||||
area.size,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
self.gradient_format,
|
||||
Color::new_unpremul(1., 0., 0., 1.),
|
||||
Color::new_unpremul(0., 1., 0., 1.),
|
||||
0.,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
0.,
|
||||
CornerRadius::default(),
|
||||
1.,
|
||||
|
||||
@@ -4,7 +4,7 @@ use niri_config::{
|
||||
};
|
||||
use smithay::backend::renderer::element::RenderElement;
|
||||
use smithay::backend::renderer::gles::GlesRenderer;
|
||||
use smithay::utils::{Physical, Rectangle, Size};
|
||||
use smithay::utils::{Physical, Point, Rectangle, Size};
|
||||
|
||||
use super::{Args, TestCase};
|
||||
|
||||
@@ -31,16 +31,16 @@ impl TestCase for GradientOklchIncreasing {
|
||||
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
|
||||
let (a, b) = (size.w / 6, size.h / 3);
|
||||
let size = (size.w - a * 2, size.h - b * 2);
|
||||
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
|
||||
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
|
||||
|
||||
[BorderRenderElement::new(
|
||||
area.size,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
self.gradient_format,
|
||||
Color::new_unpremul(1., 0., 0., 1.),
|
||||
Color::new_unpremul(0., 1., 0., 1.),
|
||||
0.,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
0.,
|
||||
CornerRadius::default(),
|
||||
1.,
|
||||
|
||||
@@ -4,7 +4,7 @@ use niri_config::{
|
||||
};
|
||||
use smithay::backend::renderer::element::RenderElement;
|
||||
use smithay::backend::renderer::gles::GlesRenderer;
|
||||
use smithay::utils::{Physical, Rectangle, Size};
|
||||
use smithay::utils::{Physical, Point, Rectangle, Size};
|
||||
|
||||
use super::{Args, TestCase};
|
||||
|
||||
@@ -31,16 +31,16 @@ impl TestCase for GradientOklchLonger {
|
||||
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
|
||||
let (a, b) = (size.w / 6, size.h / 3);
|
||||
let size = (size.w - a * 2, size.h - b * 2);
|
||||
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
|
||||
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
|
||||
|
||||
[BorderRenderElement::new(
|
||||
area.size,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
self.gradient_format,
|
||||
Color::new_unpremul(1., 0., 0., 1.),
|
||||
Color::new_unpremul(0., 1., 0., 1.),
|
||||
0.,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
0.,
|
||||
CornerRadius::default(),
|
||||
1.,
|
||||
|
||||
@@ -4,7 +4,7 @@ use niri_config::{
|
||||
};
|
||||
use smithay::backend::renderer::element::RenderElement;
|
||||
use smithay::backend::renderer::gles::GlesRenderer;
|
||||
use smithay::utils::{Physical, Rectangle, Size};
|
||||
use smithay::utils::{Physical, Point, Rectangle, Size};
|
||||
|
||||
use super::{Args, TestCase};
|
||||
|
||||
@@ -31,16 +31,16 @@ impl TestCase for GradientOklchShorter {
|
||||
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
|
||||
let (a, b) = (size.w / 6, size.h / 3);
|
||||
let size = (size.w - a * 2, size.h - b * 2);
|
||||
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
|
||||
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
|
||||
|
||||
[BorderRenderElement::new(
|
||||
area.size,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
self.gradient_format,
|
||||
Color::new_unpremul(1., 0., 0., 1.),
|
||||
Color::new_unpremul(0., 1., 0., 1.),
|
||||
0.,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
0.,
|
||||
CornerRadius::default(),
|
||||
1.,
|
||||
|
||||
@@ -4,7 +4,7 @@ use niri_config::{
|
||||
};
|
||||
use smithay::backend::renderer::element::RenderElement;
|
||||
use smithay::backend::renderer::gles::GlesRenderer;
|
||||
use smithay::utils::{Physical, Rectangle, Size};
|
||||
use smithay::utils::{Physical, Point, Rectangle, Size};
|
||||
|
||||
use super::{Args, TestCase};
|
||||
|
||||
@@ -31,16 +31,16 @@ impl TestCase for GradientSrgb {
|
||||
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
|
||||
let (a, b) = (size.w / 6, size.h / 3);
|
||||
let size = (size.w - a * 2, size.h - b * 2);
|
||||
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
|
||||
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
|
||||
|
||||
[BorderRenderElement::new(
|
||||
area.size,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
self.gradient_format,
|
||||
Color::new_unpremul(1., 0., 0., 1.),
|
||||
Color::new_unpremul(0., 1., 0., 1.),
|
||||
0.,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
0.,
|
||||
CornerRadius::default(),
|
||||
1.,
|
||||
|
||||
@@ -2,7 +2,7 @@ use niri::render_helpers::border::BorderRenderElement;
|
||||
use niri_config::{Color, CornerRadius, GradientColorSpace, GradientInterpolation};
|
||||
use smithay::backend::renderer::element::RenderElement;
|
||||
use smithay::backend::renderer::gles::GlesRenderer;
|
||||
use smithay::utils::{Physical, Rectangle, Size};
|
||||
use smithay::utils::{Physical, Point, Rectangle, Size};
|
||||
|
||||
use super::{Args, TestCase};
|
||||
|
||||
@@ -29,16 +29,16 @@ impl TestCase for GradientSrgbAlpha {
|
||||
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
|
||||
let (a, b) = (size.w / 6, size.h / 3);
|
||||
let size = (size.w - a * 2, size.h - b * 2);
|
||||
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
|
||||
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
|
||||
|
||||
[BorderRenderElement::new(
|
||||
area.size,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
self.gradient_format,
|
||||
Color::new_unpremul(1., 0., 0., 1.),
|
||||
Color::new_unpremul(0., 1., 0., 0.),
|
||||
0.,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
0.,
|
||||
CornerRadius::default(),
|
||||
1.,
|
||||
|
||||
@@ -4,7 +4,7 @@ use niri_config::{
|
||||
};
|
||||
use smithay::backend::renderer::element::RenderElement;
|
||||
use smithay::backend::renderer::gles::GlesRenderer;
|
||||
use smithay::utils::{Physical, Rectangle, Size};
|
||||
use smithay::utils::{Physical, Point, Rectangle, Size};
|
||||
|
||||
use super::{Args, TestCase};
|
||||
|
||||
@@ -31,16 +31,16 @@ impl TestCase for GradientSrgbLinear {
|
||||
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
|
||||
let (a, b) = (size.w / 6, size.h / 3);
|
||||
let size = (size.w - a * 2, size.h - b * 2);
|
||||
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
|
||||
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
|
||||
|
||||
[BorderRenderElement::new(
|
||||
area.size,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
self.gradient_format,
|
||||
Color::new_unpremul(1., 0., 0., 1.),
|
||||
Color::new_unpremul(0., 1., 0., 1.),
|
||||
0.,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
0.,
|
||||
CornerRadius::default(),
|
||||
1.,
|
||||
|
||||
@@ -2,7 +2,7 @@ use niri::render_helpers::border::BorderRenderElement;
|
||||
use niri_config::{Color, CornerRadius, GradientColorSpace, GradientInterpolation};
|
||||
use smithay::backend::renderer::element::RenderElement;
|
||||
use smithay::backend::renderer::gles::GlesRenderer;
|
||||
use smithay::utils::{Physical, Rectangle, Size};
|
||||
use smithay::utils::{Physical, Point, Rectangle, Size};
|
||||
|
||||
use super::{Args, TestCase};
|
||||
|
||||
@@ -29,16 +29,16 @@ impl TestCase for GradientSrgbLinearAlpha {
|
||||
) -> Vec<Box<dyn RenderElement<GlesRenderer>>> {
|
||||
let (a, b) = (size.w / 6, size.h / 3);
|
||||
let size = (size.w - a * 2, size.h - b * 2);
|
||||
let area = Rectangle::from_loc_and_size((a, b), size).to_f64();
|
||||
let area = Rectangle::new(Point::from((a, b)), Size::from(size)).to_f64();
|
||||
|
||||
[BorderRenderElement::new(
|
||||
area.size,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
self.gradient_format,
|
||||
Color::new_unpremul(1., 0., 0., 1.),
|
||||
Color::new_unpremul(0., 1., 0., 0.),
|
||||
0.,
|
||||
Rectangle::from_loc_and_size((0., 0.), area.size),
|
||||
Rectangle::from_size(area.size),
|
||||
0.,
|
||||
CornerRadius::default(),
|
||||
1.,
|
||||
|
||||
@@ -114,7 +114,7 @@ impl TestCase for Tile {
|
||||
|
||||
self.tile.update(
|
||||
true,
|
||||
Rectangle::from_loc_and_size((-location.x, -location.y), size.to_logical(1.)),
|
||||
Rectangle::new(Point::from((-location.x, -location.y)), size.to_logical(1.)),
|
||||
);
|
||||
self.tile
|
||||
.render(
|
||||
|
||||
@@ -145,7 +145,7 @@ mod imp {
|
||||
|
||||
case.advance_animations(self.clock.borrow_mut().now());
|
||||
|
||||
let rect: Rectangle<i32, Physical> = Rectangle::from_loc_and_size((0, 0), size);
|
||||
let rect: Rectangle<i32, Physical> = Rectangle::from_size(Size::from(size));
|
||||
|
||||
let elements = unsafe {
|
||||
with_framebuffer_save_restore(renderer, |renderer| {
|
||||
|
||||
@@ -1050,7 +1050,7 @@ impl State {
|
||||
|
||||
// The target geometry for the positioner should be relative to its parent's geometry, so
|
||||
// we will compute that here.
|
||||
let mut target = Rectangle::from_loc_and_size((0, 0), output_geo.size);
|
||||
let mut target = Rectangle::from_size(output_geo.size);
|
||||
target.loc -= layer_geo.loc;
|
||||
target.loc -= get_popup_toplevel_coords(popup);
|
||||
|
||||
|
||||
@@ -330,7 +330,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
|
||||
let (tile, offset) = self.tiles_with_offsets().next()?;
|
||||
|
||||
let tile_size = tile.tile_size();
|
||||
let tile_rect = Rectangle::from_loc_and_size(offset, tile_size);
|
||||
let tile_rect = Rectangle::new(offset, tile_size);
|
||||
|
||||
self.working_area.intersection(tile_rect)
|
||||
}
|
||||
@@ -1105,7 +1105,7 @@ impl<W: LayoutElement> FloatingSpace<W> {
|
||||
pos: Point<f64, Logical>,
|
||||
size: Size<f64, Logical>,
|
||||
) -> Point<f64, Logical> {
|
||||
let mut rect = Rectangle::from_loc_and_size(pos, size);
|
||||
let mut rect = Rectangle::new(pos, size);
|
||||
clamp_preferring_top_left_in_area(self.working_area, &mut rect);
|
||||
rect.loc
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ impl FocusRing {
|
||||
in_: GradientInterpolation::default(),
|
||||
});
|
||||
|
||||
let full_rect = Rectangle::from_loc_and_size((-width, -width), self.full_size);
|
||||
let full_rect = Rectangle::new(Point::from((-width, -width)), self.full_size);
|
||||
let gradient_area = match gradient.relative_to {
|
||||
GradientRelativeTo::Window => full_rect,
|
||||
GradientRelativeTo::WorkspaceView => view_rect,
|
||||
@@ -178,12 +178,12 @@ impl FocusRing {
|
||||
for (border, (loc, size)) in zip(&mut self.borders, zip(self.locations, self.sizes)) {
|
||||
border.update(
|
||||
size,
|
||||
Rectangle::from_loc_and_size(gradient_area.loc - loc, gradient_area.size),
|
||||
Rectangle::new(gradient_area.loc - loc, gradient_area.size),
|
||||
gradient.in_,
|
||||
gradient.from,
|
||||
gradient.to,
|
||||
((gradient.angle as f32) - 90.).to_radians(),
|
||||
Rectangle::from_loc_and_size(full_rect.loc - loc, full_rect.size),
|
||||
Rectangle::new(full_rect.loc - loc, full_rect.size),
|
||||
rounded_corner_border_width,
|
||||
radius,
|
||||
scale as f32,
|
||||
@@ -196,15 +196,12 @@ impl FocusRing {
|
||||
|
||||
self.borders[0].update(
|
||||
self.sizes[0],
|
||||
Rectangle::from_loc_and_size(
|
||||
gradient_area.loc - self.locations[0],
|
||||
gradient_area.size,
|
||||
),
|
||||
Rectangle::new(gradient_area.loc - self.locations[0], gradient_area.size),
|
||||
gradient.in_,
|
||||
gradient.from,
|
||||
gradient.to,
|
||||
((gradient.angle as f32) - 90.).to_radians(),
|
||||
Rectangle::from_loc_and_size(full_rect.loc - self.locations[0], full_rect.size),
|
||||
Rectangle::new(full_rect.loc - self.locations[0], full_rect.size),
|
||||
rounded_corner_border_width,
|
||||
radius,
|
||||
scale as f32,
|
||||
|
||||
+6
-8
@@ -1289,7 +1289,7 @@ impl<W: LayoutElement> Layout<W> {
|
||||
// window geometry.
|
||||
let width = move_.tile.window_size().w;
|
||||
let height = output_size(&move_.output).h;
|
||||
let mut target = Rectangle::from_loc_and_size((0., 0.), (width, height));
|
||||
let mut target = Rectangle::from_size(Size::from((width, height)));
|
||||
// FIXME: ideally this shouldn't include the tile render offset, but the code
|
||||
// duplication would be a bit annoying for this edge case.
|
||||
target.loc.y -= move_.tile_render_location().y;
|
||||
@@ -2405,10 +2405,8 @@ impl<W: LayoutElement> Layout<W> {
|
||||
if let Some(InteractiveMoveState::Moving(move_)) = &mut self.interactive_move {
|
||||
if output.map_or(true, |output| move_.output == *output) {
|
||||
let pos_within_output = move_.tile_render_location();
|
||||
let view_rect = Rectangle::from_loc_and_size(
|
||||
pos_within_output.upscale(-1.),
|
||||
output_size(&move_.output),
|
||||
);
|
||||
let view_rect =
|
||||
Rectangle::new(pos_within_output.upscale(-1.), output_size(&move_.output));
|
||||
move_.tile.update(true, view_rect);
|
||||
}
|
||||
}
|
||||
@@ -4121,7 +4119,7 @@ mod tests {
|
||||
id,
|
||||
parent_id: None,
|
||||
is_floating: false,
|
||||
bbox: Rectangle::from_loc_and_size((0, 0), (100, 200)),
|
||||
bbox: Rectangle::from_size(Size::from((100, 200))),
|
||||
min_max_size: Default::default(),
|
||||
}
|
||||
}
|
||||
@@ -4295,7 +4293,7 @@ mod tests {
|
||||
any::<(i16, i16, u16, u16)>().prop_map(|(x, y, w, h)| {
|
||||
let loc: Point<i32, _> = Point::from((x.into(), y.into()));
|
||||
let size: Size<i32, _> = Size::from((w.max(1).into(), h.max(1).into()));
|
||||
Rectangle::from_loc_and_size(loc, size)
|
||||
Rectangle::new(loc, size)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -6078,7 +6076,7 @@ mod tests {
|
||||
|
||||
Op::AddWindow {
|
||||
params: TestWindowParams {
|
||||
bbox: Rectangle::from_loc_and_size((0, 0), (1280, 200)),
|
||||
bbox: Rectangle::from_size(Size::from((1280, 200))),
|
||||
..TestWindowParams::new(1)
|
||||
},
|
||||
}
|
||||
|
||||
+11
-5
@@ -7,7 +7,7 @@ use smithay::backend::renderer::element::utils::{
|
||||
CropRenderElement, Relocate, RelocateRenderElement,
|
||||
};
|
||||
use smithay::output::Output;
|
||||
use smithay::utils::{Logical, Point, Rectangle};
|
||||
use smithay::utils::{Logical, Point, Rectangle, Size};
|
||||
|
||||
use super::scrolling::{Column, ColumnWidth};
|
||||
use super::tile::Tile;
|
||||
@@ -871,7 +871,7 @@ impl<W: LayoutElement> Monitor<W> {
|
||||
let offset = switch.target_idx() - self.active_workspace_idx as f64;
|
||||
let offset = offset * size.h;
|
||||
|
||||
let clip_rect = Rectangle::from_loc_and_size((0., -offset), size);
|
||||
let clip_rect = Rectangle::new(Point::from((0., -offset)), size);
|
||||
rect = rect.intersection(clip_rect)?;
|
||||
}
|
||||
|
||||
@@ -930,7 +930,7 @@ impl<W: LayoutElement> Monitor<W> {
|
||||
let size = output_size(&self.output);
|
||||
let (ws, bounds) = self
|
||||
.workspaces_with_render_positions()
|
||||
.map(|(ws, offset)| (ws, Rectangle::from_loc_and_size(offset, size)))
|
||||
.map(|(ws, offset)| (ws, Rectangle::new(offset, size)))
|
||||
.find(|(_, bounds)| bounds.contains(pos_within_output))?;
|
||||
Some((ws, bounds.loc))
|
||||
}
|
||||
@@ -983,9 +983,15 @@ impl<W: LayoutElement> Monitor<W> {
|
||||
//
|
||||
// FIXME: use proper bounds after fixing the Crop element.
|
||||
let crop_bounds = if self.workspace_switch.is_some() {
|
||||
Rectangle::from_loc_and_size((-i32::MAX / 2, 0), (i32::MAX, height))
|
||||
Rectangle::new(
|
||||
Point::from((-i32::MAX / 2, 0)),
|
||||
Size::from((i32::MAX, height)),
|
||||
)
|
||||
} else {
|
||||
Rectangle::from_loc_and_size((-i32::MAX / 2, -i32::MAX / 2), (i32::MAX, i32::MAX))
|
||||
Rectangle::new(
|
||||
Point::from((-i32::MAX / 2, -i32::MAX / 2)),
|
||||
Size::from((i32::MAX, i32::MAX)),
|
||||
)
|
||||
};
|
||||
|
||||
self.workspaces_with_render_positions()
|
||||
|
||||
@@ -72,7 +72,7 @@ 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 + offset, texture_size);
|
||||
let mut area = Rectangle::new(location + offset, texture_size);
|
||||
|
||||
// Expand the area a bit to allow for more varied effects.
|
||||
let mut target_size = area.size.upscale(1.5);
|
||||
|
||||
+11
-11
@@ -335,13 +335,13 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
||||
let is_active = is_active && col_idx == active_idx;
|
||||
let col_off = Point::from((col_x, 0.));
|
||||
let col_pos = view_pos - col_off - col.render_offset();
|
||||
let view_rect = Rectangle::from_loc_and_size(col_pos, view_size);
|
||||
let view_rect = Rectangle::new(col_pos, view_size);
|
||||
col.update_render_elements(is_active, view_rect);
|
||||
}
|
||||
|
||||
if let Some(insert_hint) = &self.insert_hint {
|
||||
if let Some(area) = self.insert_hint_area(insert_hint) {
|
||||
let view_rect = Rectangle::from_loc_and_size(area.loc.upscale(-1.), view_size);
|
||||
let view_rect = Rectangle::new(area.loc.upscale(-1.), view_size);
|
||||
self.insert_hint_element.update_render_elements(
|
||||
area.size,
|
||||
view_rect,
|
||||
@@ -1919,7 +1919,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
||||
if column_index == 0 && !self.columns.is_empty() {
|
||||
loc.x -= size.w + self.options.gaps;
|
||||
}
|
||||
Rectangle::from_loc_and_size(loc, size)
|
||||
Rectangle::new(loc, size)
|
||||
} else if column_index > self.columns.len() {
|
||||
error!("insert hint column index is out of range");
|
||||
return None;
|
||||
@@ -1930,7 +1930,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
||||
self.column_x(column_index) - size.w / 2. - self.options.gaps / 2.,
|
||||
self.working_area.loc.y + self.options.gaps,
|
||||
));
|
||||
Rectangle::from_loc_and_size(loc, size)
|
||||
Rectangle::new(loc, size)
|
||||
}
|
||||
}
|
||||
InsertPosition::InColumn(column_index, tile_index) => {
|
||||
@@ -1963,7 +1963,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
||||
|
||||
let size = Size::from((self.data[column_index].width, height));
|
||||
let loc = Point::from((self.column_x(column_index), y));
|
||||
Rectangle::from_loc_and_size(loc, size)
|
||||
Rectangle::new(loc, size)
|
||||
}
|
||||
InsertPosition::Floating => return None,
|
||||
};
|
||||
@@ -2010,9 +2010,9 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
||||
|
||||
let tile_pos = view_off + tile_off;
|
||||
let tile_size = tile.tile_size();
|
||||
let tile_rect = Rectangle::from_loc_and_size(tile_pos, tile_size);
|
||||
let tile_rect = Rectangle::new(tile_pos, tile_size);
|
||||
|
||||
let view = Rectangle::from_loc_and_size((0., 0.), self.view_size);
|
||||
let view = Rectangle::from_size(self.view_size);
|
||||
view.intersection(tile_rect)
|
||||
}
|
||||
|
||||
@@ -2256,7 +2256,7 @@ impl<W: LayoutElement> ScrollingSpace<W> {
|
||||
}
|
||||
|
||||
// Draw the closing windows on top of the other windows.
|
||||
let view_rect = Rectangle::from_loc_and_size((self.view_pos(), 0.), self.view_size);
|
||||
let view_rect = Rectangle::new(Point::from((self.view_pos(), 0.)), self.view_size);
|
||||
for closing in self.closing_windows.iter().rev() {
|
||||
let elem = closing.render(renderer.as_gles_renderer(), view_rect, scale, target);
|
||||
rv.push(elem.into());
|
||||
@@ -3731,7 +3731,7 @@ impl<W: LayoutElement> Column<W> {
|
||||
let width = tile.window_size().w;
|
||||
let height = self.view_size.h;
|
||||
|
||||
let mut target = Rectangle::from_loc_and_size((0., 0.), (width, height));
|
||||
let mut target = Rectangle::from_size(Size::from((width, height)));
|
||||
target.loc.y -= pos.y;
|
||||
target.loc.y -= tile.window_loc().y;
|
||||
|
||||
@@ -4028,7 +4028,7 @@ mod tests {
|
||||
bottom: FloatOrInt(1.),
|
||||
};
|
||||
|
||||
let parent_area = Rectangle::from_loc_and_size((0., 0.), (1280., 720.));
|
||||
let parent_area = Rectangle::from_size(Size::from((1280., 720.)));
|
||||
let area = compute_working_area(parent_area, 1., struts);
|
||||
|
||||
assert_eq!(round_logical_in_physical(1., area.loc.x), area.loc.x);
|
||||
@@ -4044,7 +4044,7 @@ mod tests {
|
||||
bottom: FloatOrInt(0.),
|
||||
};
|
||||
|
||||
let parent_area = Rectangle::from_loc_and_size((0., 0.), (1280., 720.));
|
||||
let parent_area = Rectangle::from_size(Size::from((1280., 720.)));
|
||||
compute_working_area(parent_area, 1., struts);
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -318,7 +318,7 @@ impl<W: LayoutElement> Tile<W> {
|
||||
self.animated_window_size(),
|
||||
is_active,
|
||||
!draw_border_with_background,
|
||||
Rectangle::from_loc_and_size(
|
||||
Rectangle::new(
|
||||
view_rect.loc - Point::from((border_width, border_width)),
|
||||
view_rect.size,
|
||||
),
|
||||
@@ -590,7 +590,7 @@ impl<W: LayoutElement> Tile<W> {
|
||||
}
|
||||
|
||||
pub fn is_in_activation_region(&self, point: Point<f64, Logical>) -> bool {
|
||||
let activation_region = Rectangle::from_loc_and_size((0., 0.), self.tile_size());
|
||||
let activation_region = Rectangle::from_size(self.tile_size());
|
||||
activation_region.contains(point)
|
||||
}
|
||||
|
||||
@@ -711,7 +711,7 @@ impl<W: LayoutElement> Tile<W> {
|
||||
let window_size = self.window_size().to_f64();
|
||||
let animated_window_size = self.animated_window_size();
|
||||
let window_render_loc = location + window_loc;
|
||||
let area = Rectangle::from_loc_and_size(window_render_loc, animated_window_size);
|
||||
let area = Rectangle::new(window_render_loc, animated_window_size);
|
||||
|
||||
let rules = self.window.rules();
|
||||
let clip_to_geometry = !self.is_fullscreen && rules.clip_to_geometry == Some(true);
|
||||
@@ -810,7 +810,7 @@ impl<W: LayoutElement> Tile<W> {
|
||||
.window
|
||||
.render(renderer, window_render_loc, scale, alpha, target);
|
||||
|
||||
let geo = Rectangle::from_loc_and_size(window_render_loc, window_size);
|
||||
let geo = Rectangle::new(window_render_loc, window_size);
|
||||
let radius = radius.fit_to(window_size.w as f32, window_size.h as f32);
|
||||
|
||||
let clip_shader = ClippedSurfaceRenderElement::shader(renderer).cloned();
|
||||
@@ -852,12 +852,12 @@ impl<W: LayoutElement> Tile<W> {
|
||||
if radius != CornerRadius::default() && has_border_shader {
|
||||
return BorderRenderElement::new(
|
||||
geo.size,
|
||||
Rectangle::from_loc_and_size((0., 0.), geo.size),
|
||||
Rectangle::from_size(geo.size),
|
||||
GradientInterpolation::default(),
|
||||
Color::from_color32f(elem.color()),
|
||||
Color::from_color32f(elem.color()),
|
||||
0.,
|
||||
Rectangle::from_loc_and_size((0., 0.), geo.size),
|
||||
Rectangle::from_size(geo.size),
|
||||
0.,
|
||||
radius,
|
||||
scale.x as f32,
|
||||
|
||||
@@ -260,7 +260,7 @@ impl<W: LayoutElement> Workspace<W> {
|
||||
Rc::new(Options::clone(&base_options).adjusted_for_scale(scale.fractional_scale()));
|
||||
|
||||
let view_size = Size::from((1280., 720.));
|
||||
let working_area = Rectangle::from_loc_and_size((0., 0.), (1280., 720.));
|
||||
let working_area = Rectangle::from_size(Size::from((1280., 720.)));
|
||||
|
||||
let scrolling = ScrollingSpace::new(
|
||||
view_size,
|
||||
@@ -337,7 +337,7 @@ impl<W: LayoutElement> Workspace<W> {
|
||||
self.scrolling
|
||||
.update_render_elements(is_active && !self.floating_is_active.get());
|
||||
|
||||
let view_rect = Rectangle::from_loc_and_size((0., 0.), self.view_size);
|
||||
let view_rect = Rectangle::from_size(self.view_size);
|
||||
self.floating
|
||||
.update_render_elements(is_active && self.floating_is_active.get(), view_rect);
|
||||
}
|
||||
@@ -1332,7 +1332,7 @@ impl<W: LayoutElement> Workspace<W> {
|
||||
|
||||
let floating_focus_ring = focus_ring && self.floating_is_active();
|
||||
let floating = self.is_floating_visible().then(|| {
|
||||
let view_rect = Rectangle::from_loc_and_size((0., 0.), self.view_size);
|
||||
let view_rect = Rectangle::from_size(self.view_size);
|
||||
let floating = self.floating.render_elements(
|
||||
renderer,
|
||||
view_rect,
|
||||
@@ -1364,7 +1364,7 @@ impl<W: LayoutElement> Workspace<W> {
|
||||
for (tile, tile_pos) in self.tiles_with_render_positions_mut(false) {
|
||||
if tile.window().id() == window {
|
||||
let view_pos = Point::from((-tile_pos.x, -tile_pos.y));
|
||||
let view_rect = Rectangle::from_loc_and_size(view_pos, view_size);
|
||||
let view_rect = Rectangle::new(view_pos, view_size);
|
||||
tile.update(false, view_rect);
|
||||
tile.store_unmap_snapshot_if_empty(renderer, output_scale);
|
||||
return;
|
||||
|
||||
+13
-13
@@ -2169,7 +2169,7 @@ impl Niri {
|
||||
.map(|pos| Point::from((pos.x, pos.y)))
|
||||
.filter(|pos| {
|
||||
// Ensure that the requested position does not overlap any existing output.
|
||||
let target_geom = Rectangle::from_loc_and_size(*pos, size);
|
||||
let target_geom = Rectangle::new(*pos, size);
|
||||
|
||||
let overlap = self
|
||||
.global_space
|
||||
@@ -2651,9 +2651,9 @@ impl Niri {
|
||||
pub fn output_left(&self) -> Option<Output> {
|
||||
let active = self.layout.active_output()?;
|
||||
let active_geo = self.global_space.output_geometry(active).unwrap();
|
||||
let extended_geo = Rectangle::from_loc_and_size(
|
||||
(i32::MIN / 2, active_geo.loc.y),
|
||||
(i32::MAX, active_geo.size.h),
|
||||
let extended_geo = Rectangle::new(
|
||||
Point::from((i32::MIN / 2, active_geo.loc.y)),
|
||||
Size::from((i32::MAX, active_geo.size.h)),
|
||||
);
|
||||
|
||||
self.global_space
|
||||
@@ -2668,9 +2668,9 @@ impl Niri {
|
||||
pub fn output_right(&self) -> Option<Output> {
|
||||
let active = self.layout.active_output()?;
|
||||
let active_geo = self.global_space.output_geometry(active).unwrap();
|
||||
let extended_geo = Rectangle::from_loc_and_size(
|
||||
(i32::MIN / 2, active_geo.loc.y),
|
||||
(i32::MAX, active_geo.size.h),
|
||||
let extended_geo = Rectangle::new(
|
||||
Point::from((i32::MIN / 2, active_geo.loc.y)),
|
||||
Size::from((i32::MAX, active_geo.size.h)),
|
||||
);
|
||||
|
||||
self.global_space
|
||||
@@ -2685,9 +2685,9 @@ impl Niri {
|
||||
pub fn output_up(&self) -> Option<Output> {
|
||||
let active = self.layout.active_output()?;
|
||||
let active_geo = self.global_space.output_geometry(active).unwrap();
|
||||
let extended_geo = Rectangle::from_loc_and_size(
|
||||
(active_geo.loc.x, i32::MIN / 2),
|
||||
(active_geo.size.w, i32::MAX),
|
||||
let extended_geo = Rectangle::new(
|
||||
Point::from((active_geo.loc.x, i32::MIN / 2)),
|
||||
Size::from((active_geo.size.w, i32::MAX)),
|
||||
);
|
||||
|
||||
self.global_space
|
||||
@@ -2746,9 +2746,9 @@ impl Niri {
|
||||
pub fn output_down(&self) -> Option<Output> {
|
||||
let active = self.layout.active_output()?;
|
||||
let active_geo = self.global_space.output_geometry(active).unwrap();
|
||||
let extended_geo = Rectangle::from_loc_and_size(
|
||||
(active_geo.loc.x, i32::MIN / 2),
|
||||
(active_geo.size.w, i32::MAX),
|
||||
let extended_geo = Rectangle::new(
|
||||
Point::from((active_geo.loc.x, i32::MIN / 2)),
|
||||
Size::from((active_geo.size.w, i32::MAX)),
|
||||
);
|
||||
|
||||
self.global_space
|
||||
|
||||
@@ -206,9 +206,9 @@ where
|
||||
let output_transform = output.current_transform();
|
||||
let output_physical_size =
|
||||
output_transform.transform_size(output.current_mode().unwrap().size);
|
||||
let output_rect = Rectangle::from_loc_and_size((0, 0), output_physical_size);
|
||||
let output_rect = Rectangle::from_size(output_physical_size);
|
||||
|
||||
let rect = Rectangle::from_loc_and_size((x, y), (width, height));
|
||||
let rect = Rectangle::new(Point::from((x, y)), Size::from((width, height)));
|
||||
|
||||
let output_scale = output.current_scale().fractional_scale();
|
||||
let physical_rect = rect.to_physical_precise_round(output_scale);
|
||||
|
||||
@@ -6,7 +6,7 @@ use smithay::backend::renderer::gles::{
|
||||
GlesError, GlesFrame, GlesRenderer, GlesTexProgram, Uniform,
|
||||
};
|
||||
use smithay::backend::renderer::utils::{CommitCounter, DamageSet, OpaqueRegions};
|
||||
use smithay::utils::{Buffer, Logical, Physical, Rectangle, Scale, Size, Transform};
|
||||
use smithay::utils::{Buffer, Logical, Physical, Point, Rectangle, Scale, Size, Transform};
|
||||
|
||||
use super::damage::ExtraDamage;
|
||||
use super::renderer::{AsGlesFrame as _, NiriRenderer};
|
||||
@@ -117,21 +117,21 @@ impl<R: NiriRenderer> ClippedSurfaceRenderElement<R> {
|
||||
let bottom_left = corner_radius.bottom_left as f64;
|
||||
|
||||
[
|
||||
Rectangle::from_loc_and_size(geo.loc, (top_left, top_left)),
|
||||
Rectangle::from_loc_and_size(
|
||||
(geo.loc.x + geo.size.w - top_right, geo.loc.y),
|
||||
(top_right, top_right),
|
||||
Rectangle::new(geo.loc, Size::from((top_left, top_left))),
|
||||
Rectangle::new(
|
||||
Point::from((geo.loc.x + geo.size.w - top_right, geo.loc.y)),
|
||||
Size::from((top_right, top_right)),
|
||||
),
|
||||
Rectangle::from_loc_and_size(
|
||||
(
|
||||
Rectangle::new(
|
||||
Point::from((
|
||||
geo.loc.x + geo.size.w - bottom_right,
|
||||
geo.loc.y + geo.size.h - bottom_right,
|
||||
),
|
||||
(bottom_right, bottom_right),
|
||||
)),
|
||||
Size::from((bottom_right, bottom_right)),
|
||||
),
|
||||
Rectangle::from_loc_and_size(
|
||||
(geo.loc.x, geo.loc.y + geo.size.h - bottom_left),
|
||||
(bottom_left, bottom_left),
|
||||
Rectangle::new(
|
||||
Point::from((geo.loc.x, geo.loc.y + geo.size.h - bottom_left)),
|
||||
Size::from((bottom_left, bottom_left)),
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ impl Element for ExtraDamage {
|
||||
}
|
||||
|
||||
fn src(&self) -> Rectangle<f64, Buffer> {
|
||||
Rectangle::from_loc_and_size((0., 0.), (1., 1.))
|
||||
Rectangle::from_size(Size::from((1., 1.)))
|
||||
}
|
||||
|
||||
fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> {
|
||||
|
||||
@@ -216,7 +216,7 @@ pub fn render_and_download(
|
||||
|
||||
let buffer_size = size.to_logical(1).to_buffer(1, Transform::Normal);
|
||||
let mapping = renderer
|
||||
.copy_framebuffer(Rectangle::from_loc_and_size((0, 0), buffer_size), fourcc)
|
||||
.copy_framebuffer(Rectangle::from_size(buffer_size), fourcc)
|
||||
.context("error copying framebuffer")?;
|
||||
Ok(mapping)
|
||||
}
|
||||
@@ -300,7 +300,7 @@ fn render_elements(
|
||||
elements: impl Iterator<Item = impl RenderElement<GlesRenderer>>,
|
||||
) -> anyhow::Result<SyncPoint> {
|
||||
let transform = transform.invert();
|
||||
let output_rect = Rectangle::from_loc_and_size((0, 0), transform.transform_size(size));
|
||||
let output_rect = Rectangle::from_size(transform.transform_size(size));
|
||||
|
||||
let mut frame = renderer
|
||||
.render(size, transform)
|
||||
|
||||
@@ -43,7 +43,7 @@ impl ResizeRenderElement {
|
||||
let tex_next_geo_scaled = tex_next_geo.to_f64().upscale(scale_next);
|
||||
let combined_geo = tex_prev_geo_scaled.merge(tex_next_geo_scaled).to_i32_up();
|
||||
|
||||
let area = Rectangle::from_loc_and_size(
|
||||
let area = Rectangle::new(
|
||||
area.loc + combined_geo.loc.to_logical(scale),
|
||||
combined_geo.size.to_logical(scale),
|
||||
);
|
||||
|
||||
@@ -193,7 +193,7 @@ impl ShaderRenderElement {
|
||||
program,
|
||||
id: Id::new(),
|
||||
commit_counter: CommitCounter::default(),
|
||||
area: Rectangle::from_loc_and_size((0., 0.), size),
|
||||
area: Rectangle::from_size(size),
|
||||
opaque_regions: opaque_regions.unwrap_or_default(),
|
||||
scale,
|
||||
alpha,
|
||||
@@ -255,7 +255,7 @@ impl Element for ShaderRenderElement {
|
||||
}
|
||||
|
||||
fn src(&self) -> Rectangle<f64, Buffer> {
|
||||
Rectangle::from_loc_and_size((0., 0.), (1., 1.))
|
||||
Rectangle::from_size(Size::from((1., 1.)))
|
||||
}
|
||||
|
||||
fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> {
|
||||
@@ -314,7 +314,7 @@ impl RenderElement<GlesRenderer> for ShaderRenderElement {
|
||||
(dest_size.to_point() - rect_constrained_loc).to_size(),
|
||||
);
|
||||
|
||||
let rect = Rectangle::from_loc_and_size(rect_constrained_loc, rect_clamped_size);
|
||||
let rect = Rectangle::new(rect_constrained_loc, rect_clamped_size);
|
||||
[
|
||||
rect.loc.x as f32,
|
||||
rect.loc.y as f32,
|
||||
@@ -334,7 +334,7 @@ impl RenderElement<GlesRenderer> for ShaderRenderElement {
|
||||
(dest_size.to_point() - rect_constrained_loc).to_size(),
|
||||
);
|
||||
|
||||
let rect = Rectangle::from_loc_and_size(rect_constrained_loc, rect_clamped_size);
|
||||
let rect = Rectangle::new(rect_constrained_loc, rect_clamped_size);
|
||||
// Add the 4 f32s per damage rectangle for each of the 6 vertices.
|
||||
(0..6).flat_map(move |_| {
|
||||
[
|
||||
|
||||
@@ -85,7 +85,7 @@ impl SolidColorRenderElement {
|
||||
alpha: f32,
|
||||
kind: Kind,
|
||||
) -> Self {
|
||||
let geo = Rectangle::from_loc_and_size(location, buffer.size());
|
||||
let geo = Rectangle::new(location.into(), buffer.size());
|
||||
let color = buffer.color * alpha;
|
||||
Self::new(buffer.id.clone(), geo, buffer.commit, color, kind)
|
||||
}
|
||||
@@ -125,7 +125,7 @@ impl Element for SolidColorRenderElement {
|
||||
}
|
||||
|
||||
fn src(&self) -> Rectangle<f64, Buffer> {
|
||||
Rectangle::from_loc_and_size((0., 0.), (1., 1.))
|
||||
Rectangle::from_size(Size::from((1., 1.)))
|
||||
}
|
||||
|
||||
fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> {
|
||||
@@ -134,8 +134,7 @@ impl Element for SolidColorRenderElement {
|
||||
|
||||
fn opaque_regions(&self, scale: Scale<f64>) -> OpaqueRegions<i32, Physical> {
|
||||
if self.color.is_opaque() {
|
||||
let rect = Rectangle::from_loc_and_size((0., 0.), self.geometry.size)
|
||||
.to_physical_precise_down(scale);
|
||||
let rect = Rectangle::from_size(self.geometry.size).to_physical_precise_down(scale);
|
||||
OpaqueRegions::from_slice(&[rect])
|
||||
} else {
|
||||
OpaqueRegions::default()
|
||||
|
||||
@@ -157,7 +157,7 @@ impl<T: Texture> Element for TextureRenderElement<T> {
|
||||
}
|
||||
|
||||
fn geometry(&self, scale: Scale<f64>) -> Rectangle<i32, Physical> {
|
||||
let logical_geo = Rectangle::from_loc_and_size(self.location, self.logical_size());
|
||||
let logical_geo = Rectangle::new(self.location, self.logical_size());
|
||||
logical_geo.to_physical_precise_round(scale)
|
||||
}
|
||||
|
||||
@@ -174,9 +174,7 @@ impl<T: Texture> Element for TextureRenderElement<T> {
|
||||
&self.buffer.logical_size(),
|
||||
)
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
Rectangle::from_loc_and_size((0, 0), self.buffer.texture.size()).to_f64()
|
||||
})
|
||||
.unwrap_or_else(|| Rectangle::from_size(self.buffer.texture.size()).to_f64())
|
||||
}
|
||||
|
||||
fn opaque_regions(&self, scale: Scale<f64>) -> OpaqueRegions<i32, Physical> {
|
||||
|
||||
+14
-11
@@ -127,9 +127,9 @@ impl ScreenshotUi {
|
||||
let size = output_transform.transform_size(output_mode.size);
|
||||
(
|
||||
output,
|
||||
Rectangle::from_loc_and_size(
|
||||
(size.w / 4, size.h / 4),
|
||||
(size.w / 2, size.h / 2),
|
||||
Rectangle::new(
|
||||
Point::from((size.w / 4, size.h / 4)),
|
||||
Size::from((size.w / 2, size.h / 2)),
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -268,10 +268,10 @@ impl ScreenshotUi {
|
||||
|
||||
if output == selection_output {
|
||||
// Check if the selection is still valid. If not, reset it back to default.
|
||||
if !Rectangle::from_loc_and_size((0, 0), size).contains_rect(rect) {
|
||||
rect = Rectangle::from_loc_and_size(
|
||||
(size.w / 4, size.h / 4),
|
||||
(size.w / 2, size.h / 2),
|
||||
if !Rectangle::from_size(size).contains_rect(rect) {
|
||||
rect = Rectangle::new(
|
||||
Point::from((size.w / 4, size.h / 4)),
|
||||
Size::from((size.w / 2, size.h / 2)),
|
||||
);
|
||||
*a = rect.loc;
|
||||
*b = rect.loc + rect.size - Size::from((1, 1));
|
||||
@@ -446,7 +446,7 @@ impl ScreenshotUi {
|
||||
);
|
||||
match res {
|
||||
Ok((texture, _)) => {
|
||||
tex_rect = Some((texture, Rectangle::from_loc_and_size((0, 0), rect.size)));
|
||||
tex_rect = Some((texture, Rectangle::from_size(rect.size)));
|
||||
}
|
||||
Err(err) => {
|
||||
warn!("error compositing pointer onto screenshot: {err:?}");
|
||||
@@ -556,9 +556,12 @@ impl ScreenshotUi {
|
||||
let mut rect = rect_from_corner_points(*a, *b);
|
||||
if rect.size.is_empty() || rect.size == Size::from((1, 1)) {
|
||||
let data = &output_data[output];
|
||||
rect = Rectangle::from_loc_and_size((rect.loc.x - 16, rect.loc.y - 16), (32, 32))
|
||||
.intersection(Rectangle::from_loc_and_size((0, 0), data.size))
|
||||
.unwrap_or_default();
|
||||
rect = Rectangle::new(
|
||||
Point::from((rect.loc.x - 16, rect.loc.y - 16)),
|
||||
Size::from((32, 32)),
|
||||
)
|
||||
.intersection(Rectangle::from_size(data.size))
|
||||
.unwrap_or_default();
|
||||
*a = rect.loc;
|
||||
*b = rect.loc + rect.size - Size::from((1, 1));
|
||||
}
|
||||
|
||||
+2
-2
@@ -375,8 +375,8 @@ mod tests {
|
||||
(rx, ry, rw, rh): (i32, i32, i32, i32),
|
||||
(ex, ey): (i32, i32),
|
||||
) {
|
||||
let area = Rectangle::from_loc_and_size((ax, ay), (aw, ah)).to_f64();
|
||||
let mut rect = Rectangle::from_loc_and_size((rx, ry), (rw, rh)).to_f64();
|
||||
let area = Rectangle::new(Point::from((ax, ay)), Size::from((aw, ah))).to_f64();
|
||||
let mut rect = Rectangle::new(Point::from((rx, ry)), Size::from((rw, rh))).to_f64();
|
||||
clamp_preferring_top_left_in_area(area, &mut rect);
|
||||
assert_eq!(rect.loc, Point::from((ex, ey)).to_f64());
|
||||
}
|
||||
|
||||
@@ -365,12 +365,12 @@ impl Mapped {
|
||||
let geo = elem.geo();
|
||||
return BorderRenderElement::new(
|
||||
geo.size,
|
||||
Rectangle::from_loc_and_size((0., 0.), geo.size),
|
||||
Rectangle::from_size(geo.size),
|
||||
GradientInterpolation::default(),
|
||||
Color::from_color32f(elem.color()),
|
||||
Color::from_color32f(elem.color()),
|
||||
0.,
|
||||
Rectangle::from_loc_and_size((0., 0.), geo.size),
|
||||
Rectangle::from_size(geo.size),
|
||||
0.,
|
||||
radius,
|
||||
scale.x as f32,
|
||||
@@ -665,7 +665,7 @@ impl LayoutElement for Mapped {
|
||||
}
|
||||
|
||||
fn output_enter(&self, output: &Output) {
|
||||
let overlap = Rectangle::from_loc_and_size((0, 0), (i32::MAX, i32::MAX));
|
||||
let overlap = Rectangle::from_size(Size::from((i32::MAX, i32::MAX)));
|
||||
self.window.output_enter(output, overlap)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user