@@ -507,7 +507,7 @@ async def run_toggle(self, uid_or_uids: str) -> None:
507
507
await asyncio .gather (* (asyncio .create_task (t ()) for t in tasks ))
508
508
509
509
async def get_offsets (self , scratch : Scratch , monitor : MonitorInfo | None = None ) -> tuple [int , int ]:
510
- """Return offset from config or use margin as a ref ."""
510
+ """Return offset from config or computed from window & screen positions ."""
511
511
offset = scratch .conf .get ("offset" )
512
512
if monitor is None :
513
513
monitor = await get_focused_monitor_props (self .log , name = scratch .forced_monitor )
@@ -517,13 +517,19 @@ async def get_offsets(self, scratch: Scratch, monitor: MonitorInfo | None = None
517
517
if offset :
518
518
return cast (tuple [int , int ], (convert_monitor_dimension (offset , ref , monitor ) for ref in aspect ))
519
519
520
- # compute from client size & margin
521
- margin = scratch .conf .get ("margin" , DEFAULT_MARGIN )
520
+ mon_size = tuple (
521
+ int (m / monitor ["scale" ]) for m in ([monitor ["height" ], monitor ["width" ]] if rotated else [monitor ["width" ], monitor ["height" ]])
522
+ )
523
+ win_position = apply_offset ((monitor ["x" ], monitor ["y" ]), scratch .meta .extra_positions [scratch .address ])
524
+ win_size = convert_coords (scratch .conf .get ("size" ), monitor )
525
+ scaled = []
522
526
523
- mon_size = [monitor ["height" ], monitor ["width" ]] if rotated else [monitor ["width" ], monitor ["height" ]]
527
+ if get_animation_type (scratch ) in ("fromtop" , "fromleft" ):
528
+ for v1 , v2 in zip (win_position , win_size , strict = True ):
529
+ scaled .append (v1 + v2 )
530
+ else :
531
+ scaled = [m - w for m , w in zip (mon_size , win_position , strict = True )]
524
532
525
- margins = [convert_monitor_dimension (margin , dim , monitor ) for dim in mon_size ]
526
- scaled = map (int , [(a + m ) / monitor ["scale" ] for a , m in zip (aspect , margins , strict = False )])
527
533
return cast (tuple [int , int ], scaled )
528
534
529
535
async def _hide_transition (self , scratch : Scratch , monitor : MonitorInfo ) -> bool :
0 commit comments