scratchpad: add support for scaled monitors

Closes #9
This commit is contained in:
fdev31 2023-07-26 22:22:34 +02:00
parent 8b17403e8a
commit 03d6e26c11

View file

@ -23,20 +23,23 @@ async def get_client_props_by_address(addr: str):
class Animations: class Animations:
@classmethod @classmethod
async def fromtop(cls, monitor, client, client_uid, margin): async def fromtop(cls, monitor, client, client_uid, margin):
scale = float(monitor["scale"])
mon_x = monitor["x"] mon_x = monitor["x"]
mon_y = monitor["y"] mon_y = monitor["y"]
mon_width = monitor["width"] mon_width = int(monitor["width"] / scale)
client_width = client["size"][0] client_width = client["size"][0]
margin_x = int((mon_width - client_width) / 2) + mon_x margin_x = int((mon_width - client_width) / 2) + mon_x
await hyprctl(f"movewindowpixel exact {margin_x} {mon_y + margin},{client_uid}") await hyprctl(f"movewindowpixel exact {margin_x} {mon_y + margin},{client_uid}")
@classmethod @classmethod
async def frombottom(cls, monitor, client, client_uid, margin): async def frombottom(cls, monitor, client, client_uid, margin):
scale = float(monitor["scale"])
mon_x = monitor["x"] mon_x = monitor["x"]
mon_y = monitor["y"] mon_y = monitor["y"]
mon_width = monitor["width"] mon_width = int(monitor["width"] / scale)
mon_height = monitor["height"] mon_height = int(monitor["height"] / scale)
client_width = client["size"][0] client_width = client["size"][0]
client_height = client["size"][1] client_height = client["size"][1]
@ -47,9 +50,10 @@ class Animations:
@classmethod @classmethod
async def fromleft(cls, monitor, client, client_uid, margin): async def fromleft(cls, monitor, client, client_uid, margin):
scale = float(monitor["scale"])
mon_x = monitor["x"] mon_x = monitor["x"]
mon_y = monitor["y"] mon_y = monitor["y"]
mon_height = monitor["height"] mon_height = int(monitor["height"] / scale)
client_height = client["size"][1] client_height = client["size"][1]
margin_y = int((mon_height - client_height) / 2) + mon_y margin_y = int((mon_height - client_height) / 2) + mon_y
@ -58,10 +62,11 @@ class Animations:
@classmethod @classmethod
async def fromright(cls, monitor, client, client_uid, margin): async def fromright(cls, monitor, client, client_uid, margin):
scale = float(monitor["scale"])
mon_x = monitor["x"] mon_x = monitor["x"]
mon_y = monitor["y"] mon_y = monitor["y"]
mon_width = monitor["width"] mon_width = int(monitor["width"] / scale)
mon_height = monitor["height"] mon_height = int(monitor["height"] / scale)
client_width = client["size"][0] client_width = client["size"][0]
client_height = client["size"][1] client_height = client["size"][1]