@@ -24,7 +24,7 @@ use crate::platform_impl::EventLoopWindowTarget as PlatformEventLoopWindowTarget
24
24
use super :: env:: { WindowingFeatures , WinitEnv } ;
25
25
use super :: output:: OutputManager ;
26
26
use super :: seat:: SeatManager ;
27
- use super :: window:: shim:: { self , WindowUpdate } ;
27
+ use super :: window:: shim:: { self , WindowRequest , WindowUpdate } ;
28
28
use super :: { DeviceId , WindowId } ;
29
29
30
30
mod proxy;
@@ -249,7 +249,8 @@ impl<T: 'static> EventLoop<T> {
249
249
}
250
250
251
251
// Process 'new' pending updates.
252
- self . with_state ( |state| {
252
+ self . with_window_target ( |window_target| {
253
+ let state = window_target. state . get_mut ( ) ;
253
254
window_updates. clear ( ) ;
254
255
window_updates. extend (
255
256
state
@@ -261,7 +262,8 @@ impl<T: 'static> EventLoop<T> {
261
262
262
263
for ( window_id, window_update) in window_updates. iter_mut ( ) {
263
264
if let Some ( scale_factor) = window_update. scale_factor . map ( |f| f as f64 ) {
264
- let mut physical_size = self . with_state ( |state| {
265
+ let mut physical_size = self . with_window_target ( |window_target| {
266
+ let state = window_target. state . get_mut ( ) ;
265
267
let window_handle = state. window_map . get ( window_id) . unwrap ( ) ;
266
268
let mut size = window_handle. size . lock ( ) . unwrap ( ) ;
267
269
@@ -294,7 +296,8 @@ impl<T: 'static> EventLoop<T> {
294
296
}
295
297
296
298
if let Some ( size) = window_update. size . take ( ) {
297
- let physical_size = self . with_state ( |state| {
299
+ let physical_size = self . with_window_target ( |window_target| {
300
+ let state = window_target. state . get_mut ( ) ;
298
301
let window_handle = state. window_map . get_mut ( window_id) . unwrap ( ) ;
299
302
let mut window_size = window_handle. size . lock ( ) . unwrap ( ) ;
300
303
@@ -320,6 +323,15 @@ impl<T: 'static> EventLoop<T> {
320
323
// Mark that refresh isn't required, since we've done it right now.
321
324
window_update. refresh_frame = false ;
322
325
326
+ // Queue request for redraw into the next iteration of the loop, since
327
+ // resize and scale factor changes are double buffered.
328
+ window_handle
329
+ . pending_window_requests
330
+ . lock ( )
331
+ . unwrap ( )
332
+ . push ( WindowRequest :: Redraw ) ;
333
+ window_target. event_loop_awakener . ping ( ) ;
334
+
323
335
physical_size
324
336
} ) ;
325
337
@@ -356,7 +368,8 @@ impl<T: 'static> EventLoop<T> {
356
368
// The purpose of the back buffer and that swap is to not hold borrow_mut when
357
369
// we're doing callback to the user, since we can double borrow if the user decides
358
370
// to create a window in one of those callbacks.
359
- self . with_state ( |state| {
371
+ self . with_window_target ( |window_target| {
372
+ let state = window_target. state . get_mut ( ) ;
360
373
std:: mem:: swap (
361
374
& mut event_sink_back_buffer,
362
375
& mut state. event_sink . window_events ,
@@ -381,7 +394,8 @@ impl<T: 'static> EventLoop<T> {
381
394
for ( window_id, window_update) in window_updates. iter ( ) {
382
395
// Handle refresh of the frame.
383
396
if window_update. refresh_frame {
384
- self . with_state ( |state| {
397
+ self . with_window_target ( |window_target| {
398
+ let state = window_target. state . get_mut ( ) ;
385
399
let window_handle = state. window_map . get_mut ( window_id) . unwrap ( ) ;
386
400
window_handle. window . refresh ( ) ;
387
401
if !window_update. redraw_requested {
@@ -526,9 +540,9 @@ impl<T: 'static> EventLoop<T> {
526
540
& self . window_target
527
541
}
528
542
529
- fn with_state < U , F : FnOnce ( & mut WinitState ) -> U > ( & mut self , f : F ) -> U {
543
+ fn with_window_target < U , F : FnOnce ( & mut EventLoopWindowTarget < T > ) -> U > ( & mut self , f : F ) -> U {
530
544
let state = match & mut self . window_target . p {
531
- PlatformEventLoopWindowTarget :: Wayland ( window_target) => window_target. state . get_mut ( ) ,
545
+ PlatformEventLoopWindowTarget :: Wayland ( window_target) => window_target,
532
546
#[ cfg( feature = "x11" ) ]
533
547
_ => unreachable ! ( ) ,
534
548
} ;
0 commit comments