Last active
April 22, 2017 02:41
-
-
Save jakemayeux/67ef8e0e4c886f2f39ec63dfd1180ebe to your computer and use it in GitHub Desktop.
This file contains 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
var sh = Screen.main().frame().height; | |
var sw = Screen.main().frame().width; | |
var menuBarHeight = 23; | |
var lastWindow = { | |
position: 'left or right', | |
hash: 'the window hash' | |
} | |
Key.on('left', [ 'ctrl', 'shift' ], function(){ | |
setLeft(); | |
}) | |
Key.on('h', [ 'ctrl', 'shift' ], function(){ | |
setLeft(); | |
}) | |
Key.on('right', [ 'ctrl', 'shift' ], function(){ | |
setRight(); | |
}) | |
Key.on('l', [ 'ctrl', 'shift' ], function(){ | |
setRight(); | |
}) | |
Key.on('right', [ 'alt', 'shift' ], function(){ | |
Window.focused().setTopLeft({x:sw/2, y:0}); | |
Window.focused().setSize({ | |
width: sw/2, | |
height: sh | |
}) | |
}) | |
Key.on('l', [ 'alt', 'shift' ], function(){ | |
Window.focused().setTopLeft({x:sw/2, y:0}); | |
Window.focused().setSize({ | |
width: sw/2, | |
height: sh | |
}) | |
}) | |
Key.on('left', [ 'alt', 'shift' ], function(){ | |
Window.focused().setTopLeft({x:0, y:0}); | |
Window.focused().setSize({ | |
width: sw/2, | |
height: sh | |
}) | |
}) | |
Key.on('h', [ 'alt', 'shift' ], function(){ | |
Window.focused().setTopLeft({x:0, y:0}); | |
Window.focused().setSize({ | |
width: sw/2, | |
height: sh | |
}) | |
}) | |
Key.on('up', [ 'alt', 'shift' ], function(){ | |
Window.focused().setTopLeft({x:0, y:0}); | |
Window.focused().setSize({ | |
width: sw, | |
height: sh | |
}) | |
}) | |
Key.on('k', [ 'alt', 'shift' ], function(){ | |
Window.focused().setTopLeft({x:0, y:0}); | |
Window.focused().setSize({ | |
width: sw, | |
height: sh | |
}) | |
}) | |
Key.on('down', [ 'alt', 'shift' ], function(){ | |
// Window.focused().minimise() | |
Window.focused().setTopLeft({ | |
x:0, | |
y:sh-sh/4 | |
}) | |
Window.focused().setSize({ | |
width: sw, | |
height: sh/4 | |
}) | |
}) | |
Key.on('j', [ 'alt', 'shift' ], function(){ | |
// Window.focused().minimise() | |
Window.focused().setTopLeft({ | |
x:0, | |
y:sh-sh/4 | |
}) | |
Window.focused().setSize({ | |
width: sw, | |
height: sh/4 | |
}) | |
}) | |
// Key.on('a', [ 'alt', 'shift' ], function(){ | |
// Window. | |
// }) | |
function setLeft(){ | |
if(!Window.focused()){ | |
return | |
} | |
var win = Window.focused() | |
if(true){ | |
var spaceIndex, x; | |
for(i in Screen.main().spaces()){ | |
if(Screen.main().spaces()[i].hash() == Space.active().hash()){ | |
spaceIndex = i; | |
break | |
} | |
} | |
if(Screen.main().spaces()[spaceIndex-1]){ | |
Screen.main().spaces()[spaceIndex-1].addWindows([Window.focused()]) | |
Screen.main().spaces()[spaceIndex].removeWindows([Window.focused()]) | |
Window.focused().focus() | |
} | |
return | |
} | |
lastWindow = { | |
position: 'left', | |
hash: Window.focused().hash() | |
} | |
Window.focused().setTopLeft({x:0, y:0}); | |
Window.focused().setSize({ | |
width: sw/2, | |
height: sh | |
}) | |
} | |
function setRight(){ | |
if(!Window.focused()){ | |
return | |
} | |
var win = Window.focused() | |
if(true){ | |
var spaceIndex, x; | |
for(i in Screen.main().spaces()){ | |
Phoenix.log(i) | |
if(Screen.main().spaces()[i].hash() == Space.active().hash()){ | |
spaceIndex = i; | |
// break | |
} | |
} | |
Phoenix.log(spaceIndex-(-1)) | |
if(Screen.main().spaces()[spaceIndex-(-1)]){ | |
Phoenix.log('asdf') | |
Screen.main().spaces()[spaceIndex-(-1)].addWindows([Window.focused()]) | |
Screen.main().spaces()[spaceIndex].removeWindows([Window.focused()]) | |
Window.focused().focus() | |
// setLeft() | |
} | |
return | |
} | |
lastWindow = { | |
position: 'right', | |
hash: Window.focused().hash() | |
} | |
Window.focused().setTopLeft({x: sw/2, y:0}); | |
Window.focused().setSize({width: sw/2, height: sh}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment