Skip to content

Commit

Permalink
fix: cursor position
Browse files Browse the repository at this point in the history
in this way, the real scale will always be 1.0
  • Loading branch information
Decodetalkers committed Oct 7, 2024
1 parent ffebb0e commit ffd11ad
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 22 deletions.
6 changes: 3 additions & 3 deletions iced_examples/counter_muti/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,12 @@ impl MultiApplication for Counter {
let center = column![
button("Increment").on_press(Message::IncrementPressed),
button("Decrement").on_press(Message::DecrementPressed),
text(self.value).size(30),
text(self.value).size(50),
button("newwindowLeft").on_press(Message::NewWindowLeft),
button("newwindowRight").on_press(Message::NewWindowRight),
]
.align_x(Alignment::Center)
.padding(10)
.padding(20)
.width(Length::Fill)
.height(Length::Fill);
row![
Expand All @@ -253,7 +253,7 @@ impl MultiApplication for Counter {
.on_press(Message::Direction(WindowDirection::Right(id)))
.height(Length::Fill),
]
.padding(10)
.padding(20)
.spacing(10)
//.align_items(Alignment::Center)
.width(Length::Fill)
Expand Down
6 changes: 1 addition & 5 deletions iced_layershell/src/application/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,10 @@ where
&self.theme
}
pub fn application_scale_factor(&self) -> f64 {
self.application_scale_factor
1.
}
pub fn cursor(&self) -> IcedMouse::Cursor {
self.mouse_position
.map(|point| Point {
x: point.x / self.application_scale_factor() as f32,
y: point.y / self.application_scale_factor() as f32,
})
.map(IcedMouse::Cursor::Available)
.unwrap_or(IcedMouse::Cursor::Unavailable)
}
Expand Down
2 changes: 1 addition & 1 deletion iced_layershell/src/multi_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ async fn run_instance<A, E, C>(
window.state.update(&event);
if let Some(event) = conversion::window_event(
&event,
window.state.application_scale_factor(),
window.state.scale_factor(),
window.state.modifiers(),
) {
events.push((Some(id), event));
Expand Down
8 changes: 2 additions & 6 deletions iced_layershell/src/multi_window/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ where
self.viewport.logical_size()
}

pub fn application_scale_factor(&self) -> f64 {
self.application_scale_factor
pub fn scale_factor(&self) -> f64 {
1.
}

pub fn text_color(&self) -> Color {
Expand All @@ -129,10 +129,6 @@ where

pub fn cursor(&self) -> IcedMouse::Cursor {
self.mouse_position
.map(|point| Point {
x: point.x / self.application_scale_factor() as f32,
y: point.y / self.application_scale_factor() as f32,
})
.map(IcedMouse::Cursor::Available)
.unwrap_or(IcedMouse::Cursor::Unavailable)
}
Expand Down
2 changes: 1 addition & 1 deletion iced_sessionlock/src/multi_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ async fn run_instance<A, E, C>(
window.state.update(&event);
if let Some(event) = conversion::window_event(
&event,
window.state.application_scale_factor(),
window.state.scale_factor(),
window.state.modifiers(),
) {
events.push((Some(id), event));
Expand Down
8 changes: 2 additions & 6 deletions iced_sessionlock/src/multi_window/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ where
self.viewport.logical_size()
}

pub fn application_scale_factor(&self) -> f64 {
self.application_scale_factor
pub fn scale_factor(&self) -> f64 {
1.
}

pub fn text_color(&self) -> Color {
Expand All @@ -124,10 +124,6 @@ where

pub fn cursor(&self) -> IcedMouse::Cursor {
self.mouse_position
.map(|point| Point {
x: point.x / self.application_scale_factor() as f32,
y: point.y / self.application_scale_factor() as f32,
})
.map(IcedMouse::Cursor::Available)
.unwrap_or(IcedMouse::Cursor::Unavailable)
}
Expand Down

0 comments on commit ffd11ad

Please sign in to comment.