fix(display): adjust size of output based on scale
This commit is contained in:
parent
91862918f9
commit
1d41792700
2 changed files with 12 additions and 20 deletions
|
|
@ -89,7 +89,7 @@ impl<'a, Message: Clone> Widget<Message, cosmic::Theme, Renderer> for Arrangemen
|
||||||
let mut max_dimensions = (0, 0);
|
let mut max_dimensions = (0, 0);
|
||||||
let mut display_area = (0, 0);
|
let mut display_area = (0, 0);
|
||||||
|
|
||||||
for (_key, output) in self.list.outputs.iter() {
|
for output in self.list.outputs.values() {
|
||||||
if !output.enabled {
|
if !output.enabled {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -102,12 +102,16 @@ impl<'a, Message: Clone> Widget<Message, cosmic::Theme, Renderer> for Arrangemen
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
let (width, height) = if output.transform.map_or(true, is_landscape) {
|
let (mut width, mut height) = if output.transform.map_or(true, is_landscape) {
|
||||||
(mode.size.0, mode.size.1)
|
(mode.size.0, mode.size.1)
|
||||||
} else {
|
} else {
|
||||||
(mode.size.1, mode.size.0)
|
(mode.size.1, mode.size.0)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Scale dimensions of the display with the output scale.
|
||||||
|
width = (width as f64 / output.scale) as u32;
|
||||||
|
height = (height as f64 / output.scale) as u32;
|
||||||
|
|
||||||
max_dimensions.0 = max_dimensions.0.max(width);
|
max_dimensions.0 = max_dimensions.0.max(width);
|
||||||
max_dimensions.1 = max_dimensions.1.max(height);
|
max_dimensions.1 = max_dimensions.1.max(height);
|
||||||
|
|
||||||
|
|
@ -115,8 +119,8 @@ impl<'a, Message: Clone> Widget<Message, cosmic::Theme, Renderer> for Arrangemen
|
||||||
display_area.1 = display_area.1.max(height as i32 + output.position.1);
|
display_area.1 = display_area.1.max(height as i32 + output.position.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
let width = (max_dimensions.0 as i32 * 3 + display_area.0) as f32 / UNIT_PIXELS;
|
let width = (max_dimensions.0 as i32 * 2 + display_area.0) as f32 / UNIT_PIXELS;
|
||||||
let height = (max_dimensions.1 as i32 * 3 + display_area.1) as f32 / UNIT_PIXELS;
|
let height = (max_dimensions.1 as i32 * 2 + display_area.1) as f32 / UNIT_PIXELS;
|
||||||
|
|
||||||
let state = tree.state.downcast_mut::<State>();
|
let state = tree.state.downcast_mut::<State>();
|
||||||
state.max_dimensions = (
|
state.max_dimensions = (
|
||||||
|
|
@ -382,8 +386,8 @@ fn display_regions<'a>(
|
||||||
};
|
};
|
||||||
|
|
||||||
let (mut width, mut height) = (
|
let (mut width, mut height) = (
|
||||||
(mode.size.0 as f32) / UNIT_PIXELS,
|
(mode.size.0 as f32 / output.scale as f32) / UNIT_PIXELS,
|
||||||
(mode.size.1 as f32) / UNIT_PIXELS,
|
(mode.size.1 as f32 / output.scale as f32) / UNIT_PIXELS,
|
||||||
);
|
);
|
||||||
|
|
||||||
(width, height) = if output.transform.map_or(true, is_landscape) {
|
(width, height) = if output.transform.map_or(true, is_landscape) {
|
||||||
|
|
@ -432,11 +436,6 @@ fn update_dragged_region(
|
||||||
) {
|
) {
|
||||||
let mut dragged_region = Rectangle { x, y, ..*region };
|
let mut dragged_region = Rectangle { x, y, ..*region };
|
||||||
|
|
||||||
// Prevent display from exceeding boundaries.
|
|
||||||
if !dragged_region.is_within_strict(bounds) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut nearest = f32::MAX;
|
let mut nearest = f32::MAX;
|
||||||
let mut nearest_region = Rectangle::default();
|
let mut nearest_region = Rectangle::default();
|
||||||
let mut nearest_side = NearestSide::East;
|
let mut nearest_side = NearestSide::East;
|
||||||
|
|
@ -537,11 +536,6 @@ fn update_dragged_region(
|
||||||
dragged_region.y = nearest_region.y + nearest_region.height - dragged_region.height;
|
dragged_region.y = nearest_region.y + nearest_region.height - dragged_region.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent display from exceeding boundaries.
|
|
||||||
if !dragged_region.is_within_strict(bounds) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prevent display from overlapping with other displays.
|
// Prevent display from overlapping with other displays.
|
||||||
for (other_output, other_region) in display_regions(model, list, bounds, max_dimensions) {
|
for (other_output, other_region) in display_regions(model, list, bounds, max_dimensions) {
|
||||||
if other_output == output {
|
if other_output == output {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use crate::{app, pages};
|
||||||
use apply::Apply;
|
use apply::Apply;
|
||||||
use arrangement::Arrangement;
|
use arrangement::Arrangement;
|
||||||
use cosmic::iced::Length;
|
use cosmic::iced::Length;
|
||||||
|
use cosmic::iced_core::Alignment;
|
||||||
use cosmic::iced_widget::scrollable::{Direction, Properties};
|
use cosmic::iced_widget::scrollable::{Direction, Properties};
|
||||||
use cosmic::widget::{
|
use cosmic::widget::{
|
||||||
column, container, dropdown, list_column, segmented_button, toggler, view_switcher,
|
column, container, dropdown, list_column, segmented_button, toggler, view_switcher,
|
||||||
|
|
@ -371,10 +372,7 @@ impl Page {
|
||||||
.on_placement(|id, x, y| pages::Message::Displays(Message::Position(id, x, y)))
|
.on_placement(|id, x, y| pages::Message::Displays(Message::Position(id, x, y)))
|
||||||
.apply(cosmic::widget::scrollable)
|
.apply(cosmic::widget::scrollable)
|
||||||
.width(Length::Shrink)
|
.width(Length::Shrink)
|
||||||
.direction(Direction::Both {
|
.direction(Direction::Horizontal(Properties::new()))
|
||||||
horizontal: Properties::new(),
|
|
||||||
vertical: Properties::new(),
|
|
||||||
})
|
|
||||||
.apply(container)
|
.apply(container)
|
||||||
.center_x()
|
.center_x()
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue