@@ -335,17 +335,26 @@ impl GlfwContext {
335335 if desired. maximize {
336336 self . window . maximize ( ) ;
337337 }
338+ #[ cfg( not( all( target_os = "linux" , feature = "wayland" ) ) ) ]
338339 if desired. focus {
339340 self . window . focus ( ) ;
340341 }
341342
342- let ( cx, cy) = self . window . get_pos ( ) ;
343- let ( inset_l, inset_t, _, _) = self . window . get_frame_size ( ) ;
344- let frame_pos = IVec2 :: new ( cx - inset_l, cy - inset_t) ;
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+
345352 let _ = app_mut ( |app| {
346353 let world = app. world_mut ( ) ;
347- if let Some ( mut window) = world. get_mut :: < BevyWindow > ( surface) {
348- window. position = WindowPosition :: At ( frame_pos) ;
354+ if let Some ( pos) = frame_pos
355+ && let Some ( mut window) = world. get_mut :: < BevyWindow > ( surface)
356+ {
357+ window. position = WindowPosition :: At ( pos) ;
349358 }
350359 if let Some ( mut controls) = world. get_mut :: < WindowControls > ( surface) {
351360 controls. pending_iconify = false ;
@@ -355,7 +364,9 @@ impl GlfwContext {
355364 }
356365 Ok ( ( ) )
357366 } ) ;
358- self . last_applied . position = frame_pos;
367+ if let Some ( pos) = frame_pos {
368+ self . last_applied . position = pos;
369+ }
359370 }
360371
361372 fn apply_window ( & mut self , desired : & DesiredWindow ) {
@@ -368,8 +379,11 @@ impl GlfwContext {
368379 if let Some ( pos) = desired. position
369380 && pos != last. position
370381 {
371- let ( inset_l, inset_t, _, _) = self . window . get_frame_size ( ) ;
372- self . window . set_pos ( pos. x + inset_l, pos. y + inset_t) ;
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+ }
373387 last. position = pos;
374388 }
375389 if desired. size != last. size && desired. size . x > 0 && desired. size . y > 0 {
@@ -394,13 +408,15 @@ impl GlfwContext {
394408 last. decorations = desired. decorations ;
395409 }
396410 if desired. window_level != last. window_level {
411+ #[ cfg( not( all( target_os = "linux" , feature = "wayland" ) ) ) ]
397412 self . window
398413 . set_floating ( matches ! ( desired. window_level, BevyWindowLevel :: AlwaysOnTop ) ) ;
399414 last. window_level = desired. window_level ;
400415 }
401416 if let Some ( opacity) = desired. opacity
402417 && ( opacity - last. opacity ) . abs ( ) > f32:: EPSILON
403418 {
419+ #[ cfg( not( all( target_os = "linux" , feature = "wayland" ) ) ) ]
404420 self . window . set_opacity ( opacity) ;
405421 last. opacity = opacity;
406422 }
@@ -413,6 +429,9 @@ impl GlfwContext {
413429 match target {
414430 Some ( monitor_entity) => {
415431 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" ) ) ) ]
416435 let ( x, y) = self . window . get_pos ( ) ;
417436 let ( w, h) = self . window . get_size ( ) ;
418437 self . windowed_geometry = Some ( ( x, y, w as u32 , h as u32 ) ) ;
@@ -438,6 +457,9 @@ impl GlfwContext {
438457 }
439458 None => {
440459 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" ) ) ) ]
441463 let ( x, y) = self . window . get_pos ( ) ;
442464 let ( w, h) = self . window . get_size ( ) ;
443465 ( x, y, w as u32 , h as u32 )
@@ -486,6 +508,7 @@ struct DesiredWindow {
486508 iconify : bool ,
487509 restore : bool ,
488510 maximize : bool ,
511+ #[ cfg( not( all( target_os = "linux" , feature = "wayland" ) ) ) ]
489512 focus : bool ,
490513}
491514
@@ -524,6 +547,7 @@ fn read_desired_window(surface: Entity) -> Option<DesiredWindow> {
524547 iconify : controls. pending_iconify ,
525548 restore : controls. pending_restore ,
526549 maximize : controls. pending_maximize ,
550+ #[ cfg( not( all( target_os = "linux" , feature = "wayland" ) ) ) ]
527551 focus : controls. pending_focus ,
528552 } ) )
529553 } )
0 commit comments