Skip to content

Commit

Permalink
Implement conflict-free movement in 2x2 grid
Browse files Browse the repository at this point in the history
  • Loading branch information
lucmos committed Nov 26, 2018
1 parent 41b6cf3 commit 5ef20a4
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 12 deletions.
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,26 @@ My suggestion is to use the following configuration:
| <kbd>Meta</kbd> + <kbd>Numpad5</kbd> | <kbd>Ultrawide: Move Window to center-height (3x2)</kbd> |
| <kbd>Meta</kbd> + <kbd>Numpad6</kbd> | <kbd>Ultrawide: Move Window to right-height (3x2)</kbd> |

| Shortcuts | Commands in 2x2 grid |
| ----------------------------------------------------- | ------------------------------------ |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad7</kbd> | <kbd>Move Window to Up Left</kbd> |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad8</kbd> | <kbd>Move Window Up</kbd> |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad9</kbd> | <kbd>Move Window to Up Right</kbd> |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad1</kbd> | <kbd>Move Window to Down Left</kbd> |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad2</kbd> | <kbd>Move Window to Down</kbd> |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad3</kbd> | <kbd>Move Window to Down Right</kbd> |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad4</kbd> | <kbd>Move Window to Left</kbd> |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad6</kbd> | <kbd>Move Window to Right</kbd> |
| Shortcuts | Commands in 2x2 grid |
| ----------------------------------------------------- | -------------------------------------------------------------- |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad7</kbd> | <kbd>UltrawideWindows: Move Window to up-left (2x2)</kbd> |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad8</kbd> | <kbd>UltrawideWindows: Move Window to up-width (2x2)</kbd> |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad9</kbd> | <kbd>UltrawideWindows: Move Window to up-right (2x2)</kbd> |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad1</kbd> | <kbd>UltrawideWindows: Move Window to down-left (2x2)</kbd> |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad2</kbd> | <kbd>UltrawideWindows: Move Window to down-width (2x2)</kbd> |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad3</kbd> | <kbd>UltrawideWindows: Move Window to down-right (2x2)</kbd> |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad4</kbd> | <kbd>UltrawideWindows: Move Window to left-height (2x2)</kbd> |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad6</kbd> | <kbd>UltrawideWindows: Move Window to right-height (2x2)</kbd> |

| Shortcuts | General commands |
| ----------------------------------------------------- | -------------------------- |
| <kbd>Meta</kbd> + <kbd>Numpad0</kbd> | <kbd>Maximize window</kbd> |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad5</kbd> | <kbd>Maximize window</kbd> |
| <kbd>Meta</kbd> + <kbd>Alt</kbd> + <kbd>Numpad0</kbd> | <kbd>Maximize window</kbd> |

##### Notes
* Using only `Ultrawide` shortcuts, even for 2x2 movements, avoids conflicts. They are caused by the standard behaviour of going to the previous position if the window is already in the correct position. I found that the only default one useful is the `maximize windows`, that even if it may work unexpectedly, is convenient to use. If the unexpected bothers you, there is a `Ultrawide` implementation, that doesn't have the _go to the previous position_ feature.
* The animations are lost.
* The default shortcuts works only if the combinations contains even the <kbd>ald</kbd> modifier, probably a KWin problem.

# Update
```bash
Expand Down
40 changes: 39 additions & 1 deletion contents/code/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function move(workspace, numberXslots, numberYslots, x, y) {
}
}


// GRID 3x2
registerShortcut("MoveWindowToUpLeft3x2", "UltrawideWindows: Move Window to up-left (3x2)", "Meta+Num+7", function () {
move(workspace, 3, 2, 0, 0)
});
Expand Down Expand Up @@ -61,3 +61,41 @@ registerShortcut("MoveWindowToCenterHeight3x2", "UltrawideWindows: Move Window t
registerShortcut("MoveWindowToRightHeight3x2", "UltrawideWindows: Move Window to right-height (3x2)", "Meta+Num+6", function () {
move(workspace, 3, 1, 2, 0)
});

// GRID 2x2
registerShortcut("MoveWindowToUpLeft2x2", "UltrawideWindows: Move Window to up-left (2x2)", "Meta+alt+Num+7", function () {
move(workspace, 2, 2, 0, 0)
});

registerShortcut("MoveWindowToUpCenter2x2", "UltrawideWindows: Move Window to up-width (2x2)", "Meta+alt+Num+8", function () {
move(workspace, 1, 2, 0, 0)
});

registerShortcut("MoveWindowToUpRight2x2", "UltrawideWindows: Move Window to up-right (2x2)", "Meta+alt+Num+9", function () {
move(workspace, 2, 2, 1, 0)
});

registerShortcut("MoveWindowToDownLeft2x2", "UltrawideWindows: Move Window to down-left (2x2)", "Meta+alt+Num+1", function () {
move(workspace, 2, 2, 0, 1)
});

registerShortcut("MoveWindowToDownCenter2x2", "UltrawideWindows: Move Window to down-width (2x2)", "Meta+alt+Num+2", function () {
move(workspace, 1, 2, 0, 1)
});

registerShortcut("MoveWindowToDownRight2x2", "UltrawideWindows: Move Window to down-right (2x2)", "Meta+alt+Num+3", function () {
move(workspace, 2, 2, 1, 1)
});

registerShortcut("MoveWindowToLeftHeight2x2", "UltrawideWindows: Move Window to left-height (2x2)", "Meta+alt+Num+4", function () {
move(workspace, 2, 1, 0, 0)
});

registerShortcut("MoveWindowToRightHeight2x2", "UltrawideWindows: Move Window to right-height (2x2)", "Meta+alt+Num+6", function () {
move(workspace, 2, 1, 1, 0)
});

// General
registerShortcut("MoveWindowToCenterHeight2x2", "UltrawideWindows: Maximize Window", "Meta+alt+Num+5", function () {
move(workspace, 1, 1, 0, 0)
});
Binary file modified movewindowtocenter.kwinscript
Binary file not shown.

0 comments on commit 5ef20a4

Please sign in to comment.