WinJitsu 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- winjitsu/__init__.py +5 -0
- winjitsu/actions.py +169 -0
- winjitsu/cache.py +68 -0
- winjitsu/cli.py +127 -0
- winjitsu/config.py +65 -0
- winjitsu/daemon.py +129 -0
- winjitsu/screen.py +73 -0
- winjitsu/window.py +53 -0
- winjitsu-0.2.0.dist-info/METADATA +888 -0
- winjitsu-0.2.0.dist-info/RECORD +14 -0
- winjitsu-0.2.0.dist-info/WHEEL +5 -0
- winjitsu-0.2.0.dist-info/entry_points.txt +2 -0
- winjitsu-0.2.0.dist-info/licenses/LICENSE +674 -0
- winjitsu-0.2.0.dist-info/top_level.txt +1 -0
winjitsu/window.py
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
|
|
3
|
+
from .config import _CFG
|
|
4
|
+
from .screen import _get_display
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def get_window_position():
|
|
8
|
+
try:
|
|
9
|
+
window_id = subprocess.check_output(["xdotool", "getactivewindow"]).decode().strip()
|
|
10
|
+
geometry_output = subprocess.check_output(["xdotool", "getwindowgeometry", "--shell", window_id]).decode()
|
|
11
|
+
window_geometry = {}
|
|
12
|
+
for line in geometry_output.splitlines():
|
|
13
|
+
key, value = line.split("=", 1)
|
|
14
|
+
window_geometry[key] = int(value)
|
|
15
|
+
return window_geometry
|
|
16
|
+
except subprocess.CalledProcessError:
|
|
17
|
+
raise RuntimeError("Could not get window position. Is xdotool installed?")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_wm_class(window_id):
|
|
21
|
+
try:
|
|
22
|
+
return subprocess.check_output(
|
|
23
|
+
["xdotool", "getwindowclassname", str(window_id)]
|
|
24
|
+
).decode().strip()
|
|
25
|
+
except subprocess.CalledProcessError:
|
|
26
|
+
return None
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def move_window(target_width, target_height, window_id, current_w, current_h, current_x, current_y, target_x, target_y):
|
|
30
|
+
def _ease(t):
|
|
31
|
+
# smoothstep: eases in and out, producing natural-feeling animation
|
|
32
|
+
return t * t * (3.0 - 2.0 * t)
|
|
33
|
+
|
|
34
|
+
display_screen = _get_display().screen()
|
|
35
|
+
display_width, display_height = display_screen.width_in_pixels, display_screen.height_in_pixels
|
|
36
|
+
target_width = min(target_width, display_width)
|
|
37
|
+
target_height = min(target_height, display_height)
|
|
38
|
+
# Clamp to display bounds so the window never moves off-screen
|
|
39
|
+
target_x = max(0, min(target_x, display_width - target_width))
|
|
40
|
+
target_y = max(0, min(target_y, display_height - target_height))
|
|
41
|
+
|
|
42
|
+
window_id_str = str(window_id)
|
|
43
|
+
for step in range(1, _CFG.steps + 1):
|
|
44
|
+
ease_factor = _ease(step / _CFG.steps)
|
|
45
|
+
interp_width = current_w + (target_width - current_w) * ease_factor
|
|
46
|
+
interp_height = current_h + (target_height - current_h) * ease_factor
|
|
47
|
+
interp_x = current_x + (target_x - current_x) * ease_factor
|
|
48
|
+
interp_y = current_y + (target_y - current_y) * ease_factor
|
|
49
|
+
subprocess.run([
|
|
50
|
+
"xdotool",
|
|
51
|
+
"windowsize", window_id_str, str(round(interp_width)), str(round(interp_height)),
|
|
52
|
+
"windowmove", window_id_str, str(round(interp_x)), str(round(interp_y)),
|
|
53
|
+
])
|