From 537c303ee524193db6a5f867d0773e953a627f4d Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Thu, 1 Dec 2022 18:21:25 +0100 Subject: [PATCH] Only send resize event on Windows on actual change To be in line with the Linux implementation. --- src/win/window.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/win/window.rs b/src/win/window.rs index ef784c9..58b924d 100644 --- a/src/win/window.rs +++ b/src/win/window.rs @@ -315,18 +315,25 @@ unsafe fn wnd_proc_inner( let width = (lparam & 0xFFFF) as u16 as u32; let height = ((lparam >> 16) & 0xFFFF) as u16 as u32; - let window_info = { + let new_window_info = { let mut window_info = window_state.window_info.borrow_mut(); - *window_info = + let new_window_info = WindowInfo::from_physical_size(PhySize { width, height }, window_info.scale()); - *window_info + // Only send the event if anything changed + if window_info.physical_size() == new_window_info.physical_size() { + return None; + } + + *window_info = new_window_info; + + new_window_info }; window_state .handler .borrow_mut() - .on_event(&mut window, Event::Window(WindowEvent::Resized(window_info))); + .on_event(&mut window, Event::Window(WindowEvent::Resized(new_window_info))); } WM_DPICHANGED => { // To avoid weirdness with the realtime borrow checker.