Add space drag support

parent f9564861
......@@ -7,3 +7,67 @@ hs.hotkey.bind(hyper, "return", function()
local win = hs.window.frontmostWindow()
win:setFullscreen(not win:isFullscreen())
end)
-- Move windows around spaces
-- https://github.com/Hammerspoon/hammerspoon/issues/235
local hotkey = require "hs.hotkey"
local window = require "hs.window"
local spaces = require "hs._asm.undocumented.spaces"
function getGoodFocusedWindow(nofull)
local win = window.focusedWindow()
if not win or not win:isStandard() then return end
if nofull and win:isFullScreen() then return end
return win
end
function flashScreen(screen)
local flash=hs.canvas.new(screen:fullFrame()):appendElements({
action = "fill",
fillColor = { alpha = 0.25, red=1},
type = "rectangle"})
flash:show()
hs.timer.doAfter(.15,function () flash:delete() end)
end
function switchSpace(skip,dir)
for i=1,skip do
hs.eventtap.keyStroke({"ctrl"},dir)
end
end
function moveWindowOneSpace(dir)
local win = getGoodFocusedWindow(true)
if not win then return end
local screen=win:screen()
local uuid=screen:spacesUUID()
local userSpaces=spaces.layout()[uuid]
local thisSpace=win:spaces() -- first space win appears on
if not thisSpace then return else thisSpace=thisSpace[1] end
local last=nil
local skipSpaces=0
for _, spc in ipairs(userSpaces) do
if spaces.spaceType(spc)~=spaces.types.user then -- skippable space
skipSpaces=skipSpaces+1
else -- A good user space, check it
if last and
(dir=="left" and spc==thisSpace) or
(dir=="right" and last==thisSpace)
then
win:spacesMoveTo(dir=="left" and last or spc)
switchSpace(skipSpaces+1,dir)
win:focus()
return
end
last=spc -- Haven't found it yet...
skipSpaces=0
end
end
flashScreen(screen) -- Shouldn't get here, so no space found
end
hotkey.bind(hyper, "L",nil,
function() moveWindowOneSpace("right",true) end)
hotkey.bind(hyper, "H",nil,
function() moveWindowOneSpace("left",true) end)
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.internal.so</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
......@@ -12,11 +12,11 @@ placid = {'ctrl', 'cmd'}
hs.loadSpoon('MiroWindowsManager')
hs.window.animationDuration = 0.3
spoon.MiroWindowsManager:bindHotkeys({
up = {hyper, 'K'},
right = {hyper, 'L'},
down = {hyper, 'J'},
left = {hyper, 'H'},
fullscreen = {hyper, 'g'}
up = {placid, 'K'},
right = {placid, 'L'},
down = {placid, 'J'},
left = {placid, 'H'},
fullscreen = {placid, 'g'}
})
-- Some Ad-ons for the window manager
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment