Last active
October 6, 2015 19:03
-
-
Save ashaffer/1328a3f182a17115bf7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getRectCenter(rect) { | |
return { | |
x: rect.x + rect.width/2, | |
y: rect.y + rect.height/2 | |
}; | |
} | |
function getScreenForegroundWindow(id) { | |
var center = getRectCenter(slate.screenForRef(id).rect()); | |
return slate.windowUnderPoint(center); | |
} | |
slate.bind('up:ctrl', function(win) { | |
win.doOperation('focus', { | |
direction: 'behind' | |
}); | |
}); | |
slate.bind('down:ctrl', function(win) { | |
win.doOperation('focus', { | |
direction: 'behind' | |
}); | |
}); | |
slate.bind('left:ctrl', function() { | |
var wnd = getScreenForegroundWindow('0'); | |
wnd && wnd.focus(); | |
}); | |
slate.bind('right:ctrl', function() { | |
var wnd = getScreenForegroundWindow('1'); | |
wnd && wnd.focus(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment