mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-11-15 21:32:26 +01:00
feat(nix): the KWin helpers several KDE extras use
This commit is contained in:
1 parent
227e1e0e89
commit
d5eff2c445
2 files changed
+45
-17
No files matched your search
@@ -12,29 +12,15 @@ import re
|
||||
|
||||
from komorebi_vm import daemon
|
||||
from komorebi_vm.core.checks import Checks
|
||||
from komorebi_vm.core.geometry import Rect
|
||||
from komorebi_vm.core.platform import Client
|
||||
from komorebi_vm.kde_platform import CELL, PARK, KdePlatform
|
||||
from komorebi_vm.kde_platform import PARK, KdePlatform
|
||||
from komorebi_vm.platforms.kde.support import where_asked
|
||||
|
||||
OUTPUT_WIDTH = 1920
|
||||
|
||||
|
||||
def _asked(platform: KdePlatform, title: str) -> Rect | None:
|
||||
return daemon.asked(platform.kde.komorebi_log(), title)
|
||||
|
||||
|
||||
def _where_asked(platform: KdePlatform, title: str) -> bool:
|
||||
"""KWin has the window where the daemon asked: the same place, and the size up to a cell."""
|
||||
kde = platform.kde
|
||||
want, wid = _asked(platform, title), kde.wid(title)
|
||||
if want is None or wid == "":
|
||||
return False
|
||||
have = kde.rect(wid)
|
||||
return (
|
||||
(have.x, have.y) == (want.x, want.y)
|
||||
and 0 <= want.w - have.w < CELL
|
||||
and 0 <= want.h - have.h < CELL
|
||||
)
|
||||
return where_asked(platform, title)
|
||||
|
||||
|
||||
def _focus_agrees(platform: KdePlatform) -> bool:
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
"""What several KDE suites and extras ask of KWin and the daemon's log, once.
|
||||
|
||||
Each function takes a `KdePlatform`, so a suite or an extra that needs one of them imports it from
|
||||
here and does not write it again.
|
||||
"""
|
||||
|
||||
from komorebi_vm import daemon
|
||||
from komorebi_vm.core.geometry import Rect
|
||||
from komorebi_vm.kde_platform import CELL, PARK, KdePlatform
|
||||
|
||||
|
||||
def asked(platform: KdePlatform, title: str) -> Rect | None:
|
||||
"""The frame the daemon last asked KWin for, for the window with this title, from its log."""
|
||||
return daemon.asked(platform.kde.komorebi_log(), title)
|
||||
|
||||
|
||||
def where_asked(platform: KdePlatform, title: str) -> bool:
|
||||
"""KWin has the window where the daemon asked: the same place, and the size up to a cell."""
|
||||
kde = platform.kde
|
||||
want, wid = asked(platform, title), kde.wid(title)
|
||||
if want is None or wid == "":
|
||||
return False
|
||||
have = kde.rect(wid)
|
||||
return (
|
||||
(have.x, have.y) == (want.x, want.y)
|
||||
and 0 <= want.w - have.w < CELL
|
||||
and 0 <= want.h - have.h < CELL
|
||||
)
|
||||
|
||||
|
||||
def park_desktop(platform: KdePlatform) -> int:
|
||||
"""The number of the parking desktop, counted from 1 as kdotool counts, or 0 for none."""
|
||||
names = platform.kde.desktop_names()
|
||||
return names.index(PARK) + 1 if PARK in names else 0
|
||||
|
||||
|
||||
def parked(platform: KdePlatform, title: str) -> bool:
|
||||
"""Whether the window is on the parking desktop, out of sight."""
|
||||
kde = platform.kde
|
||||
desk = park_desktop(platform)
|
||||
wid = kde.wid(title)
|
||||
return desk != 0 and wid != "" and kde.desk(wid) == desk
|
||||
Reference in new issue
Block a user