1
0
Fork 0

Fix clippy lints

This commit is contained in:
Robbert van der Helm 2022-04-06 13:33:01 +02:00
parent 0cf8bdfed6
commit af44796056

View file

@ -97,42 +97,37 @@ impl Model for ParamModel {
impl Model for WindowModel {
fn event(&mut self, cx: &mut vizia::Context, event: &mut vizia::Event) {
if let Some(window_event) = event.message.downcast() {
match *window_event {
// This gets fired whenever the inner window gets resized
WindowEvent::WindowResize => {
let logical_size = (cx.window_size.width, cx.window_size.height);
let old_logical_size @ (old_logical_width, old_logical_height) =
self.vizia_state.size.load();
let scale_factor = cx.user_scale_factor;
let old_user_scale_factor = self.vizia_state.scale_factor.load();
// This gets fired whenever the inner window gets resized
if let Some(WindowEvent::WindowResize) = event.message.downcast() {
let logical_size = (cx.window_size.width, cx.window_size.height);
let old_logical_size @ (old_logical_width, old_logical_height) =
self.vizia_state.size.load();
let scale_factor = cx.user_scale_factor;
let old_user_scale_factor = self.vizia_state.scale_factor.load();
// Don't do anything if the current size already matches the new size, this
// could otherwise also cause a feedback loop on resize failure
if logical_size == old_logical_size && scale_factor == old_user_scale_factor {
return;
}
// Don't do anything if the current size already matches the new size, this
// could otherwise also cause a feedback loop on resize failure
if logical_size == old_logical_size && scale_factor == old_user_scale_factor {
return;
}
// Our embedded baseview window will have already been resized. If the host does
// not accept our new size, then we'll try to undo that
self.vizia_state.size.store(logical_size);
self.vizia_state.scale_factor.store(scale_factor);
if !self.context.request_resize() {
self.vizia_state.size.store(old_logical_size);
self.vizia_state.scale_factor.store(old_user_scale_factor);
// Our embedded baseview window will have already been resized. If the host does
// not accept our new size, then we'll try to undo that
self.vizia_state.size.store(logical_size);
self.vizia_state.scale_factor.store(scale_factor);
if !self.context.request_resize() {
self.vizia_state.size.store(old_logical_size);
self.vizia_state.scale_factor.store(old_user_scale_factor);
// This will cause the window's size to be reverted on the next event loop
cx.window_size.width = old_logical_width;
cx.window_size.height = old_logical_height;
cx.user_scale_factor = old_user_scale_factor;
}
}
_ => (),
// This will cause the window's size to be reverted on the next event loop
cx.window_size.width = old_logical_width;
cx.window_size.height = old_logical_height;
cx.user_scale_factor = old_user_scale_factor;
}
}
}
}
impl<P: Param> From<ParamEvent<'_, P>> for RawParamEvent {
fn from(event: ParamEvent<'_, P>) -> Self {
match event {