@@ -340,21 +340,11 @@ impl GlfwContext {
340340 self . window . focus ( ) ;
341341 }
342342
343- #[ cfg( all( target_os = "linux" , feature = "wayland" ) ) ]
344- let frame_pos: Option < IVec2 > = None ;
345- #[ cfg( not( all( target_os = "linux" , feature = "wayland" ) ) ) ]
346- let frame_pos = {
347- let ( cx, cy) = self . window . get_pos ( ) ;
348- let ( inset_l, inset_t, _, _) = self . window . get_frame_size ( ) ;
349- Some ( IVec2 :: new ( cx - inset_l, cy - inset_t) )
350- } ;
351-
343+ let frame_pos = self . frame_pos ( ) ;
352344 let _ = app_mut ( |app| {
353345 let world = app. world_mut ( ) ;
354- if let Some ( pos) = frame_pos
355- && let Some ( mut window) = world. get_mut :: < BevyWindow > ( surface)
356- {
357- window. position = WindowPosition :: At ( pos) ;
346+ if let Some ( mut window) = world. get_mut :: < BevyWindow > ( surface) {
347+ window. position = WindowPosition :: At ( frame_pos) ;
358348 }
359349 if let Some ( mut controls) = world. get_mut :: < WindowControls > ( surface) {
360350 controls. pending_iconify = false ;
@@ -364,9 +354,19 @@ impl GlfwContext {
364354 }
365355 Ok ( ( ) )
366356 } ) ;
367- if let Some ( pos) = frame_pos {
368- self . last_applied . position = pos;
369- }
357+ self . last_applied . position = frame_pos;
358+ }
359+
360+ #[ cfg( not( feature = "wayland" ) ) ]
361+ fn frame_pos ( & self ) -> IVec2 {
362+ let ( cx, cy) = self . window . get_pos ( ) ;
363+ let ( inset_l, inset_t, _, _) = self . window . get_frame_size ( ) ;
364+ IVec2 :: new ( cx - inset_l, cy - inset_t)
365+ }
366+
367+ #[ cfg( feature = "wayland" ) ]
368+ fn frame_pos ( & self ) -> IVec2 {
369+ self . last_applied . position
370370 }
371371
372372 fn apply_window ( & mut self , desired : & DesiredWindow ) {
@@ -376,14 +376,12 @@ impl GlfwContext {
376376 self . window . set_title ( & desired. title ) ;
377377 last. title . clone_from ( & desired. title ) ;
378378 }
379+ #[ cfg( not( feature = "wayland" ) ) ]
379380 if let Some ( pos) = desired. position
380381 && pos != last. position
381382 {
382- #[ cfg( not( all( target_os = "linux" , feature = "wayland" ) ) ) ]
383- {
384- let ( inset_l, inset_t, _, _) = self . window . get_frame_size ( ) ;
385- self . window . set_pos ( pos. x + inset_l, pos. y + inset_t) ;
386- }
383+ let ( inset_l, inset_t, _, _) = self . window . get_frame_size ( ) ;
384+ self . window . set_pos ( pos. x + inset_l, pos. y + inset_t) ;
387385 last. position = pos;
388386 }
389387 if desired. size != last. size && desired. size . x > 0 && desired. size . y > 0 {
@@ -429,12 +427,9 @@ impl GlfwContext {
429427 match target {
430428 Some ( monitor_entity) => {
431429 if self . last_applied . fullscreen_on . is_none ( ) {
432- #[ cfg( all( target_os = "linux" , feature = "wayland" ) ) ]
433- let ( x, y) = ( 0 , 0 ) ;
434- #[ cfg( not( all( target_os = "linux" , feature = "wayland" ) ) ) ]
435- let ( x, y) = self . window . get_pos ( ) ;
436430 let ( w, h) = self . window . get_size ( ) ;
437- self . windowed_geometry = Some ( ( x, y, w as u32 , h as u32 ) ) ;
431+ let pos = self . frame_pos ( ) ;
432+ self . windowed_geometry = Some ( ( pos. x , pos. y , w as u32 , h as u32 ) ) ;
438433 }
439434 let target_name = monitor_name ( monitor_entity) ;
440435 let window = & mut self . window ;
@@ -457,12 +452,9 @@ impl GlfwContext {
457452 }
458453 None => {
459454 let ( x, y, w, h) = self . windowed_geometry . take ( ) . unwrap_or_else ( || {
460- #[ cfg( all( target_os = "linux" , feature = "wayland" ) ) ]
461- let ( x, y) = ( 0 , 0 ) ;
462- #[ cfg( not( all( target_os = "linux" , feature = "wayland" ) ) ) ]
463- let ( x, y) = self . window . get_pos ( ) ;
464455 let ( w, h) = self . window . get_size ( ) ;
465- ( x, y, w as u32 , h as u32 )
456+ let pos = self . frame_pos ( ) ;
457+ ( pos. x , pos. y , w as u32 , h as u32 )
466458 } ) ;
467459 self . window
468460 . set_monitor ( WindowMode :: Windowed , x, y, w, h, None ) ;
@@ -497,6 +489,7 @@ impl GlfwContext {
497489#[ derive( Clone , Debug ) ]
498490struct DesiredWindow {
499491 title : String ,
492+ #[ cfg( not( feature = "wayland" ) ) ]
500493 position : Option < IVec2 > ,
501494 size : bevy:: math:: UVec2 ,
502495 visible : bool ,
@@ -530,6 +523,7 @@ fn read_desired_window(surface: Entity) -> Option<DesiredWindow> {
530523 } ;
531524 Ok ( Some ( DesiredWindow {
532525 title : window. title . clone ( ) ,
526+ #[ cfg( not( feature = "wayland" ) ) ]
533527 position : match window. position {
534528 WindowPosition :: At ( p) => Some ( p) ,
535529 _ => None ,
0 commit comments