forked from kgrossjo/phoenix-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
move-window-prefix-key.js
35 lines (31 loc) · 1.24 KB
/
move-window-prefix-key.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"use strict";
/* For licensing information, refer to LICENSE.md. */
function MoveWindowPrefixKey(key, modifiers, description) {
PrefixKey.call(this, key, modifiers, description);
}
MoveWindowPrefixKey.prototype = Object.create(PrefixKey.prototype);
MoveWindowPrefixKey.prototype.moveWindow = function (rect, screen) {
screen = screen || Screen.main();
var scr = screen.visibleFrameInRectangle();
var r = {
x: Math.round(scr.x + rect.x*scr.width),
y: Math.round(scr.y + rect.y*scr.height),
width: Math.round(scr.width * rect.width),
height: Math.round(scr.height * rect.height),
};
Window.focused().setFrame(r);
};
MoveWindowPrefixKey.prototype.moveWindowToNextScreen = function () {
var currW = Window.focused();
var cwFrame = currW.frame();
var currScreen = currW.screen();
var nextScreen = currScreen.next();
var currScreenSize = currScreen.visibleFrameInRectangle();
var relative = {
x: (cwFrame.x - currScreenSize.x) / currScreenSize.width,
y: (cwFrame.y - currScreenSize.y) / currScreenSize.height,
width: cwFrame.width / currScreenSize.width,
height: cwFrame.height / currScreenSize.height,
};
this.moveWindow(relative, nextScreen);
};