Skip to content

Commit da91f4b

Browse files
committed
Minor cleanup
Use the new winit_handle() function to remove one level of indentation.
1 parent 5e0c5a1 commit da91f4b

File tree

1 file changed

+27
-31
lines changed

1 file changed

+27
-31
lines changed

internal/backends/winit/glwindow.rs

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -291,50 +291,46 @@ impl<Renderer: WinitCompatibleRenderer + 'static> WindowAdapterSealed for GLWind
291291
}
292292

293293
fn apply_window_properties(&self, window_item: Pin<&i_slint_core::items::WindowItem>) {
294-
// Make the unwrap() calls on self.borrow_mapped_window*() safe
295-
if !self.is_mapped() {
296-
return;
297-
}
294+
let winit_window = match self.winit_window() {
295+
Some(handle) => handle,
296+
None => return,
297+
};
298298

299299
let mut width = window_item.width().get() as f32;
300300
let mut height = window_item.height().get() as f32;
301301

302302
let mut must_resize = false;
303303

304-
self.with_window_handle(&mut |winit_window| {
305-
winit_window.set_window_icon(icon_to_winit(window_item.icon()));
306-
winit_window.set_title(&window_item.title());
307-
winit_window
308-
.set_decorations(!window_item.no_frame() || winit_window.fullscreen().is_some());
304+
winit_window.set_window_icon(icon_to_winit(window_item.icon()));
305+
winit_window.set_title(&window_item.title());
306+
winit_window
307+
.set_decorations(!window_item.no_frame() || winit_window.fullscreen().is_some());
309308

310-
if width <= 0. || height <= 0. {
311-
must_resize = true;
309+
if width <= 0. || height <= 0. {
310+
must_resize = true;
312311

313-
let winit_size =
314-
winit_window.inner_size().to_logical(self.window.scale_factor() as f64);
312+
let winit_size =
313+
winit_window.inner_size().to_logical(self.window.scale_factor() as f64);
315314

316-
if width <= 0. {
317-
width = winit_size.width;
318-
}
319-
if height <= 0. {
320-
height = winit_size.height;
321-
}
315+
if width <= 0. {
316+
width = winit_size.width;
322317
}
318+
if height <= 0. {
319+
height = winit_size.height;
320+
}
321+
}
323322

324-
let existing_size: winit::dpi::LogicalSize<f32> =
325-
winit_window.inner_size().to_logical(self.window.scale_factor().into());
323+
let existing_size: winit::dpi::LogicalSize<f32> =
324+
winit_window.inner_size().to_logical(self.window.scale_factor().into());
326325

327-
if (existing_size.width - width).abs() > 1.
328-
|| (existing_size.height - height).abs() > 1.
329-
{
330-
// If we're in fullscreen state, don't try to resize the window but maintain the surface
331-
// size we've been assigned to from the windowing system. Weston/Wayland don't like it
332-
// when we create a surface that's bigger than the screen due to constraints (#532).
333-
if winit_window.fullscreen().is_none() {
334-
winit_window.set_inner_size(winit::dpi::LogicalSize::new(width, height));
335-
}
326+
if (existing_size.width - width).abs() > 1. || (existing_size.height - height).abs() > 1. {
327+
// If we're in fullscreen state, don't try to resize the window but maintain the surface
328+
// size we've been assigned to from the windowing system. Weston/Wayland don't like it
329+
// when we create a surface that's bigger than the screen due to constraints (#532).
330+
if winit_window.fullscreen().is_none() {
331+
winit_window.set_inner_size(winit::dpi::LogicalSize::new(width, height));
336332
}
337-
});
333+
}
338334

339335
if must_resize {
340336
self.window.set_size(i_slint_core::api::LogicalSize::new(width, height));

0 commit comments

Comments
 (0)