@@ -46,6 +46,9 @@ var Me = Extension.imports.tiling;
4646
4747var prefs = Settings . prefs ;
4848
49+ var columns = 1 ;
50+ var autoWidth = true ;
51+
4952var backgroundSettings = new Gio . Settings ( {
5053 schema_id : 'org.gnome.desktop.background'
5154} )
@@ -147,6 +150,7 @@ var Space = class Space extends Array {
147150
148151 // default focusMode (can be overriden by saved user pref in Space.init method)
149152 this . focusMode = FocusModes . DEFAULT ;
153+
150154 this . focusModeIcon = new TopBar . FocusIcon ( {
151155 name : 'panel' ,
152156 style_class : 'space-focus-mode-icon' ,
@@ -158,6 +162,9 @@ var Space = class Space extends Array {
158162 this . showFocusModeIcon ( ) ;
159163 this . unfocusXPosition = null ; // init
160164
165+ this . columns = columns ;
166+ this . autoWidth = autoWidth ;
167+
161168 let clip = new Clutter . Actor ( { name : "clip" } ) ;
162169 this . clip = clip ;
163170 let actor = new Clutter . Actor ( { name : "space-actor" } ) ;
@@ -265,6 +272,7 @@ var Space = class Space extends Array {
265272
266273 this . getWindows ( ) . forEach ( w => {
267274 animateWindow ( w ) ;
275+ if ( this . autoWidth ) setAutoWidth ( w )
268276 } ) ;
269277
270278 let selected = this . selectedWindow ;
@@ -705,6 +713,7 @@ var Space = class Space extends Array {
705713 this . targetX = workArea . x + Math . round ( ( workArea . width - this . cloneContainer . width ) / 2 ) ;
706714 }
707715 this . emit ( 'window-added' , metaWindow , index , row ) ;
716+ if ( autoWidth ) setAutoWidth ( metaWindow )
708717 return true ;
709718 }
710719
@@ -882,6 +891,7 @@ var Space = class Space extends Array {
882891
883892 let metaWindow = space . getWindow ( index , row ) ;
884893 ensureViewport ( metaWindow , space ) ;
894+ if ( autoWidth ) setAutoWidth ( metaWindow )
885895 }
886896
887897 /**
@@ -3365,6 +3375,25 @@ function toggleMaximizeHorizontally(metaWindow) {
33653375 }
33663376}
33673377
3378+ function setAutoWidth ( metaWindow ) {
3379+ metaWindow = metaWindow || display . focus_window ;
3380+
3381+ if ( metaWindow . get_maximized ( ) === Meta . MaximizeFlags . BOTH ) {
3382+ metaWindow . unmaximize ( Meta . MaximizeFlags . BOTH ) ;
3383+ metaWindow . unmaximizedRect = null ;
3384+ return ;
3385+ }
3386+
3387+ let space = spaces . spaceOfWindow ( metaWindow ) ;
3388+ let workArea = space . workArea ( ) ;
3389+ let frame = metaWindow . get_frame_rect ( ) ;
3390+ let reqWidth = ( workArea . width - prefs . minimum_margin ) / space . columns - prefs . minimum_margin ;
3391+
3392+ let x = workArea . x + space . monitor . x + prefs . minimum_margin ;
3393+ metaWindow . unmaximizedRect = frame ;
3394+ metaWindow . move_resize_frame ( true , x , frame . y , reqWidth , frame . height ) ;
3395+ }
3396+
33683397function resizeHInc ( metaWindow ) {
33693398 let frame = metaWindow . get_frame_rect ( ) ;
33703399 let monitor = Main . layoutManager . monitors [ metaWindow . get_monitor ( ) ] ;
@@ -3654,6 +3683,16 @@ function switchToNextFocusMode(space) {
36543683 setFocusMode ( nextMode , space ) ;
36553684}
36563685
3686+ function switchColumnsLayout ( space ) {
3687+ space = space ?? spaces . getActiveSpace ( ) ;
3688+ space . columns = space . columns == 1 ? 2 : 1
3689+
3690+ space . getWindows ( ) . forEach ( w => {
3691+ setAutoWidth ( w )
3692+ ensureViewport ( w , space ) ;
3693+ } ) ;
3694+ }
3695+
36573696/**
36583697 * "Fit" values such that they sum to `targetSum`
36593698 */
0 commit comments