Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: setWindowState when target_space is empty #2

Open
wants to merge 6 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# Default temp files
.DS_*
*.log
logs
**/*.backup.*
*.bak

# Folder `downloads`
/downloads

Expand Down Expand Up @@ -42,3 +49,12 @@ luac.out
*.x86_64
*.hex

### VisualStudioCode ###
shailesh17 marked this conversation as resolved.
Show resolved Hide resolved
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
.history
.ionide
26 changes: 14 additions & 12 deletions restore_spaces/rs/plumbing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,21 @@ return function(rs,hs)
else
target_space = space
end
--target_space = tonumber(target_space)
if target_space then
shailesh17 marked this conversation as resolved.
Show resolved Hide resolved
--target_space = tonumber(target_space)

if rs.spaces_fixed_after_macOS14_5 then
hs.spaces.moveWindowToSpace(window, target_space)
else
-- solution by `cunha`
-- (see: https://github.com/Hammerspoon/hammerspoon/pull/3638#issuecomment-2252826567)
local target_screen, _ = hs.spaces.spaceDisplay(target_space)
hs.spaces.moveWindowToSpace(window, target_space)
window:focus()
rs.delayExecution(0.4)
window:moveToScreen(target_screen)
window:focus()
if rs.spaces_fixed_after_macOS14_5 then
hs.spaces.moveWindowToSpace(window, target_space)
else
-- solution by `cunha`
-- (see: https://github.com/Hammerspoon/hammerspoon/pull/3638#issuecomment-2252826567)
local target_screen, _ = hs.spaces.spaceDisplay(target_space)
hs.spaces.moveWindowToSpace(window, target_space)
window:focus()
rs.delayExecution(0.4)
window:moveToScreen(target_screen)
window:focus()
end
end

rs.setFrameState(window, frame_state, fullscreen_state)
Copy link
Owner

@tplobo tplobo Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this does not comply with the modifications...
both setFrameState and issueVerbose("set window"...) should only be called if target_space was identified, so they should be moved into the if statement (or maybe using a return)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're at it, can you also try to change the "target space undefined..." line to keep it under 72 characters?

In this code I have been using something like the following:

local msg = "target space undefined; "
msg = msg .. "unable to set window "
rs.issueVerbose(msg .. window:id(), rs.verbose)

Expand Down