From 4572731b1a8e855cee2467a609a383801ba0e930 Mon Sep 17 00:00:00 2001 From: fdev31 Date: Sat, 29 Apr 2023 23:28:07 +0200 Subject: [PATCH] scratchpad: Fix lost focus when animating --- pyprland/plugins/scratchpads.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pyprland/plugins/scratchpads.py b/pyprland/plugins/scratchpads.py index 0930d4d..ea25e60 100644 --- a/pyprland/plugins/scratchpads.py +++ b/pyprland/plugins/scratchpads.py @@ -114,6 +114,7 @@ class Extension(Plugin): self._respawned_scratches: set[str] = set() self.scratches_by_address: dict[str, Scratch] = {} self.scratches_by_pid: dict[int, Scratch] = {} + self.focused_window_tracking = dict() async def exit(self) -> None: async def die_in_piece(scratch: Scratch): @@ -260,14 +261,22 @@ class Extension(Plugin): if uid in self.transitioning_scratches: return # abort sequence await asyncio.sleep(0.2) # await for animation to finish + if uid not in self.transitioning_scratches: await hyprctl(f"movetoworkspacesilent special:scratch,{pid}") + if ( + animation_type and uid in self.focused_window_tracking + ): # focus got lost when animating + await hyprctl(f"focuswindow pid:{self.focused_window_tracking[uid]['pid']}") + async def run_show(self, uid, force=False) -> None: """ shows scratchpad "name" """ uid = uid.strip() item = self.scratches.get(uid) + self.focused_window_tracking[uid] = await hyprctlJSON("activewindow") + if not item: print(f"{uid} is not configured") return