@@ -69,8 +69,18 @@ export const WindowGeometry = GObject.registerClass({
6969 Meta . MaximizeFlags ,
7070 Meta . MaximizeFlags . VERTICAL
7171 ) ,
72- 'window-size' : GObject . ParamSpec . double (
73- 'window-size' ,
72+ 'window-size-x' : GObject . ParamSpec . double (
73+ 'window-size-x' ,
74+ null ,
75+ null ,
76+ GObject . ParamFlags . READWRITE | GObject . ParamFlags . EXPLICIT_NOTIFY ,
77+ 0 ,
78+ 1 ,
79+ 1
80+ ) ,
81+
82+ 'window-size-y' : GObject . ParamSpec . double (
83+ 'window-size-y' ,
7484 null ,
7585 null ,
7686 GObject . ParamFlags . READWRITE | GObject . ParamFlags . EXPLICIT_NOTIFY ,
@@ -86,6 +96,24 @@ export const WindowGeometry = GObject.registerClass({
8696 Meta . Side ,
8797 Meta . Side . TOP
8898 ) ,
99+ 'pos-x-offset' : GObject . ParamSpec . double (
100+ 'pos-x-offset' ,
101+ null ,
102+ null ,
103+ GObject . ParamFlags . READWRITE | GObject . ParamFlags . EXPLICIT_NOTIFY ,
104+ - 10000 ,
105+ 10000 ,
106+ 0
107+ ) ,
108+ 'pos-y-offset' : GObject . ParamSpec . double (
109+ 'pos-y-offset' ,
110+ null ,
111+ null ,
112+ GObject . ParamFlags . READWRITE | GObject . ParamFlags . EXPLICIT_NOTIFY ,
113+ - 10000 ,
114+ 10000 ,
115+ 0
116+ ) ,
89117 'window-monitor' : GObject . ParamSpec . string (
90118 'window-monitor' ,
91119 null ,
@@ -123,7 +151,10 @@ export const WindowGeometry = GObject.registerClass({
123151 this . #update_workarea. bind ( this )
124152 ) ;
125153
126- this . connect ( 'notify::window-size' , this . #update_target_rect. bind ( this ) ) ;
154+ this . connect ( 'notify::window-size-x' , this . #update_target_rect. bind ( this ) ) ;
155+ this . connect ( 'notify::window-size-y' , this . #update_target_rect. bind ( this ) ) ;
156+ this . connect ( 'notify::pos-x-offset' , this . #update_target_rect. bind ( this ) ) ;
157+ this . connect ( 'notify::pos-y-offset' , this . #update_target_rect. bind ( this ) ) ;
127158 this . connect ( 'notify::window-position' , this . #update_window_position. bind ( this ) ) ;
128159 this . connect ( 'notify::window-monitor' , this . update_monitor . bind ( this ) ) ;
129160 this . connect ( 'notify::window-monitor-connector' , this . update_monitor . bind ( this ) ) ;
@@ -139,33 +170,54 @@ export const WindowGeometry = GObject.registerClass({
139170 }
140171 }
141172
142- static get_target_rect ( workarea , monitor_scale , size , window_pos ) {
143- const target_rect = workarea . copy ( ) ;
173+ static get_target_rect ( workarea , monitor_scale , size_x , size_y , window_pos , pos_x_offset , pos_y_offset ) {
174+ if ( size_x === 1 && size_y === 1 && pos_x_offset === 0 && pos_y_offset === 0 )
175+ return workarea . copy ( ) ;
144176
145- if ( size === 1 )
146- return target_rect ;
177+ const target_rect = workarea . copy ( ) ;
147178
148179 if ( window_pos === Meta . Side . LEFT || window_pos === Meta . Side . RIGHT ) {
149- target_rect . width *= size ;
150- target_rect . width -= target_rect . width % monitor_scale ;
180+ target_rect . height *= size_y ;
181+ target_rect . height -= target_rect . height % monitor_scale ;
151182
152183 if ( window_pos === Meta . Side . RIGHT )
153184 target_rect . x += workarea . width - target_rect . width ;
154185 } else {
155- target_rect . height *= size ;
186+ target_rect . height *= size_y ;
156187 target_rect . height -= target_rect . height % monitor_scale ;
157188
189+ target_rect . width *= size_x ;
190+ target_rect . width -= target_rect . width % monitor_scale ;
191+
192+ target_rect . x += Math . floor ( ( workarea . width - target_rect . width ) / 2 ) ;
193+
158194 if ( window_pos === Meta . Side . BOTTOM )
159195 target_rect . y += workarea . height - target_rect . height ;
160196 }
161197
198+ target_rect . x -= pos_x_offset * workarea . width ;
199+ target_rect . y -= pos_y_offset * workarea . height ;
200+
201+ target_rect . x = Math . min (
202+ Math . max ( target_rect . x , workarea . x ) ,
203+ workarea . x + workarea . width - target_rect . width
204+ ) ;
205+
206+ target_rect . y = Math . min (
207+ Math . max ( target_rect . y , workarea . y ) ,
208+ workarea . y + workarea . height - target_rect . height
209+ ) ;
210+
162211 return target_rect ;
163212 }
164213
165214 bind_settings ( settings ) {
166215 [
167- 'window-size' ,
216+ 'window-size-x' ,
217+ 'window-size-y' ,
168218 'window-position' ,
219+ 'pos-x-offset' ,
220+ 'pos-y-offset' ,
169221 'window-monitor' ,
170222 'window-monitor-connector' ,
171223 ] . forEach ( key => {
@@ -355,8 +407,11 @@ export const WindowGeometry = GObject.registerClass({
355407 const target_rect = WindowGeometry . get_target_rect (
356408 this . #workarea,
357409 Math . floor ( this . #monitor_scale) ,
358- this . window_size ,
359- this . window_position
410+ this . window_size_x ,
411+ this . window_size_y ,
412+ this . window_position ,
413+ this . pos_x_offset ,
414+ this . pos_y_offset ,
360415 ) ;
361416
362417 this . #set_target_rect( target_rect ) ;
0 commit comments