Skip to content

Commit

Permalink
Fix window actions for individual windows (#65)
Browse files Browse the repository at this point in the history
Fixes an issue in which "window minimize" was minimizing all the windows
in an app.
  • Loading branch information
nriley authored Oct 28, 2023
1 parent 9af22c0 commit 3c0ccc0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions window_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def action_window(window: Window, action: str = "close"):
def action_windows_app(
app: App, action: str = "close", on_current: bool = True, on_others: bool = True
):
"""Actions windows for the given application
"""Performs actions on window(s) of the given application
`on_current`: whether to affect the current window
`on_others`: whether to affect the non-current window
Expand All @@ -78,14 +78,20 @@ def action_windows_app(
if close_windows_via_appscript(app):
return

current_window = app.active_window

if on_current and not on_others:
actions.user.action_window(current_window, action)
return

for window in app.windows():
if window == app.active_window and not on_current:
if window == current_window and not on_current:
continue

if window != app.active_window and not on_others:
if window != current_window and not on_others:
continue

# NOTE(pcohen): I used to have a cron() here but it doesn't seem to speed it up
# NOTE(pcohen): I used to have a cron() here but it doesn't seem to it up
# (at least not with any single application)
actions.user.action_window(window, action)

Expand Down

0 comments on commit 3c0ccc0

Please sign in to comment.