Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ashaffer
Last active October 6, 2015 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashaffer/1328a3f182a17115bf7f to your computer and use it in GitHub Desktop.
Save ashaffer/1328a3f182a17115bf7f to your computer and use it in GitHub Desktop.
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