Skip to content

Commit ba99514

Browse files
committed
added #154
1 parent 0b64057 commit ba99514

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

pyprland/plugins/scratchpads/__init__.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ async def run_toggle(self, uid_or_uids: str) -> None:
507507
await asyncio.gather(*(asyncio.create_task(t()) for t in tasks))
508508

509509
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."""
511511
offset = scratch.conf.get("offset")
512512
if monitor is None:
513513
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
517517
if offset:
518518
return cast(tuple[int, int], (convert_monitor_dimension(offset, ref, monitor) for ref in aspect))
519519

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 = []
522526

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)]
524532

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)])
527533
return cast(tuple[int, int], scaled)
528534

529535
async def _hide_transition(self, scratch: Scratch, monitor: MonitorInfo) -> bool:

pyprland/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""Package version."""
22

3-
VERSION = "2.4.3-11"
3+
VERSION = "2.4.3-13"

0 commit comments

Comments
 (0)