@@ -509,6 +509,10 @@ export class Space extends Array {
509509 let resizable = ! mw . fullscreen &&
510510 mw . get_maximized ( ) !== Meta . MaximizeFlags . BOTH ;
511511
512+ if ( mw . _fullscreen_width ) {
513+ targetWidth = mw . _fullscreen_width ;
514+ }
515+
512516 if ( mw . preferredWidth ) {
513517 let prop = mw . preferredWidth ;
514518 if ( prop . value <= 0 ) {
@@ -590,8 +594,9 @@ export class Space extends Array {
590594 return ;
591595
592596 // option properties
593- let ensure = options ?. ensure ?? true ;
594- let allocators = options ?. customAllocators ;
597+ const ensure = options ?. ensure ?? true ;
598+ const allocators = options ?. customAllocators ;
599+ const callback = options ?. callback ;
595600
596601 this . _inLayout = true ;
597602 this . startAnimate ( ) ;
@@ -709,24 +714,34 @@ export class Space extends Array {
709714 console . log ( `with idle clear fullscreenOnLayout: ${ global . get_current_time ( ) } ` ) ;
710715 this . getWindows ( ) . forEach ( w => {
711716 if ( w . fullscreenOnLayout ) {
712- resizeHandler ( w ) ;
713717 delete w . fullscreenOnLayout ;
714718 }
715719 } ) ;
716720 } ) ;
717721
718722 console . log ( `emit layout: ${ global . get_current_time ( ) } ` ) ;
723+ if ( callback ) {
724+ callback ( ) ;
725+ }
719726 this . emit ( 'layout' , this ) ;
720727 }
721728
722- queueLayout ( animate = true ) {
729+ queueLayout ( animate = true , options = { } ) {
723730 if ( this . _layoutQueued )
724731 return ;
725732
733+ const callback = options ?. callback ;
734+
726735 this . _layoutQueued = true ;
727736 Utils . later_add ( Meta . LaterType . RESIZE , ( ) => {
728737 this . _layoutQueued = false ;
729- this . layout ( animate ) ;
738+
739+ if ( callback ) {
740+ this . layout ( animate , { callback } ) ;
741+ }
742+ else {
743+ this . layout ( ) ;
744+ }
730745 } ) ;
731746 }
732747
@@ -1910,6 +1925,7 @@ export const Spaces = class Spaces extends Map {
19101925 // Fixup allocations on reload
19111926 allocateClone ( w ) ;
19121927 this . signals . connect ( w , 'size-changed' , resizeHandler ) ;
1928+ this . signals . connect ( w , 'position-changed' , positionChangeHandler ) ;
19131929 } ) ;
19141930 this . _initDone = true ;
19151931
@@ -3011,7 +3027,14 @@ export function registerWindow(metaWindow) {
30113027 } ) ;
30123028 signals . connect ( metaWindow , 'size-changed' , allocateClone ) ;
30133029 // Note: runs before gnome-shell's minimize handling code
3014- signals . connect ( metaWindow , 'notify::fullscreen' , Topbar . fixTopBar ) ;
3030+ signals . connect ( metaWindow , 'notify::fullscreen' , ( ) => {
3031+ /**
3032+ * Run resizeHandler here since relying only on window resizing
3033+ * to pick-up fullscreen change is trouble (e.g. windows that start as fullscreen).
3034+ */
3035+ resizeHandler ( metaWindow ) ;
3036+ Topbar . fixTopBar ( ) ;
3037+ } ) ;
30153038 signals . connect ( metaWindow , 'notify::minimized' , metaWindow => {
30163039 minimizeHandler ( metaWindow ) ;
30173040 } ) ;
@@ -3055,8 +3078,19 @@ export function destroyHandler(actor) {
30553078 signals . disconnect ( actor ) ;
30563079}
30573080
3081+ export function positionChangeHandler ( metaWindow ) {
3082+ // don't update saved position if fullscreen
3083+ if ( metaWindow . fullscreen || metaWindow ?. _fullscreen_lock ) {
3084+ return ;
3085+ }
3086+
3087+ const f = metaWindow . get_frame_rect ( ) ;
3088+ metaWindow . _fullscreen_x = f . x ;
3089+ console . log ( `_fullscreen_x changed: ${ f . x } ` ) ;
3090+ }
3091+
30583092export function resizeHandler ( metaWindow ) {
3059- console . log ( `resize handler called on ${ metaWindow ?. title } ` ) ;
3093+ console . error ( new Error ( `resize handler called on ${ metaWindow ?. title } ` ) ) ;
30603094
30613095 // if navigator is showing, reset/refresh it after a window has resized
30623096 if ( Navigator . navigating ) {
@@ -3067,10 +3101,6 @@ export function resizeHandler(metaWindow) {
30673101 return ;
30683102
30693103 const f = metaWindow . get_frame_rect ( ) ;
3070- let needLayout = false ;
3071- if ( metaWindow . _targetWidth !== f . width || metaWindow . _targetHeight !== f . height ) {
3072- needLayout = true ;
3073- }
30743104 metaWindow . _targetWidth = null ;
30753105 metaWindow . _targetHeight = null ;
30763106
@@ -3079,28 +3109,48 @@ export function resizeHandler(metaWindow) {
30793109 return ;
30803110
30813111 const selected = metaWindow === space . selectedWindow ;
3112+ let addCallback = false ;
30823113 let animate = true ;
30833114 let x ;
30843115
30853116 // if window is fullscreened, then don't animate background space.container animation etc.
3086- if ( metaWindow ?. fullscreen ) {
3117+ if ( metaWindow . fullscreen ) {
3118+ metaWindow . _fullscreen_lock = true ;
3119+ addCallback = true ;
30873120 animate = false ;
30883121 x = 0 ;
3089- } else {
3090- x = metaWindow . get_frame_rect ( ) . x - space . monitor . x ;
3122+ }
3123+ else {
3124+ x = metaWindow . _fullscreen_x ?? f . x - space . monitor . x ;
3125+ x = Math . max ( x , Settings . prefs . horizontal_margin ) ;
3126+
3127+ // if pwm fullscreen previously
3128+ if ( metaWindow . _fullscreen_lock ) {
3129+ addCallback = true ;
3130+ delete metaWindow . _fullscreen_lock ;
3131+ }
3132+ else {
3133+ console . error ( new Error ( '_fullscreen_width saved' ) ) ;
3134+ metaWindow . _fullscreen_width = f . width ;
3135+ console . log ( `save _fullscreen_width ${ metaWindow ?. title } : ${ metaWindow ?. _fullscreen_width } ` ) ;
3136+ }
30913137 }
30923138
3093- if ( ! space . _inLayout && needLayout ) {
3139+ if ( ! space . _inLayout ) {
30943140 // Restore window position when eg. exiting fullscreen
3095- if ( ! Navigator . navigating && selected ) {
3096- move_to ( space , metaWindow , {
3097- x,
3098- animate,
3099- } ) ;
3141+ let callback = ( ) => { } ;
3142+ if ( addCallback && ! Navigator . navigating && selected ) {
3143+ callback = ( ) => {
3144+ console . log ( `callback! x:${ x } ` ) ;
3145+ move_to ( space , metaWindow , {
3146+ x,
3147+ animate,
3148+ } ) ;
3149+ } ;
31003150 }
31013151
31023152 // Resizing from within a size-changed signal is troube (#73). Queue instead.
3103- space . queueLayout ( animate ) ;
3153+ space . queueLayout ( animate , { callback } ) ;
31043154 }
31053155}
31063156
@@ -3287,7 +3337,10 @@ export function insertWindow(metaWindow, { existing }) {
32873337 if ( tiled ) {
32883338 animateWindow ( metaWindow ) ;
32893339 }
3290- metaWindow . unmapped && signals . connect ( metaWindow , 'size-changed' , resizeHandler ) ;
3340+ if ( metaWindow . unmapped ) {
3341+ signals . connect ( metaWindow , 'size-changed' , resizeHandler ) ;
3342+ signals . connect ( metaWindow , 'position-changed' , positionChangeHandler ) ;
3343+ }
32913344 delete metaWindow . unmapped ;
32923345 } ;
32933346
0 commit comments