Skip to content

Commit

Permalink
feat: move active window using a hotkey #80
Browse files Browse the repository at this point in the history
  • Loading branch information
leukipp committed Nov 5, 2024
1 parent 96a0edd commit 279c5cc
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 35 deletions.
60 changes: 31 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,35 +92,37 @@ Additional information about individual entries can be found in the comments sec
### Shortcuts
The default keyboard shortcuts are assigned as shown below.
If some of them are already in use by your system, update the default values in the `[keys]` section of the configuration file:
| Keys | Description |
| ------------------------------------------------------- | --------------------------------------------- |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Home</kbd> | Enable tiling on the current screen |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>End</kbd> | Disable tiling on the current screen |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd> | Toggle between enable and disable |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>D</kbd> | Toggle window decoration on and off |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>R</kbd> | Disable tiling and restore windows |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>BackSpace</kbd> | Reset layouts to default proportions |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Next</kbd> | Cycle through next layouts |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Prior</kbd> | Cycle through previous layouts |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Left</kbd> | Activate vertical-left layout |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Right</kbd> | Activate vertical-right layout |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Up</kbd> | Activate horizontal-top layout |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Down</kbd> | Activate horizontal-bottom layout |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Space</kbd> | Activate maximized layout |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Return</kbd> | Activate fullscreen layout |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Plus</kbd> | Increase number of maximum slave windows |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Minus</kbd> | Decrease number of maximum slave windows |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_Add</kbd> | Increase number of master windows |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_Subtract</kbd> | Decrease number of master windows |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_2</kbd> | Move focus to the next window |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_8</kbd> | Move focus to the previous window |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_9</kbd> | Move the active window to the next screen |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_7</kbd> | Move the active window to the previous screen |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_5</kbd> | Make the active window master |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_6</kbd> | Make the next window master |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_4</kbd> | Make the previous window master |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_3</kbd> | Increase proportion of master-slave area |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_1</kbd> | Decrease proportion of master-slave area |
| Keys | Description |
| ------------------------------------------------------- | ----------------------------------------------- |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Home</kbd> | Enable tiling on the current screen |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>End</kbd> | Disable tiling on the current screen |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd> | Toggle between enable and disable |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>D</kbd> | Toggle window decoration on and off |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>R</kbd> | Disable tiling and restore windows |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>BackSpace</kbd> | Reset layouts to default proportions |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Next</kbd> | Cycle through next layouts |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Prior</kbd> | Cycle through previous layouts |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Left</kbd> | Activate vertical-left layout |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Right</kbd> | Activate vertical-right layout |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Up</kbd> | Activate horizontal-top layout |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Down</kbd> | Activate horizontal-bottom layout |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Space</kbd> | Activate maximized layout |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Return</kbd> | Activate fullscreen layout |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Plus</kbd> | Increase number of maximum slave windows |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Minus</kbd> | Decrease number of maximum slave windows |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_Add</kbd> | Increase number of master windows |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_Subtract</kbd> | Decrease number of master windows |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_2</kbd> | Move focus to the next window |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_8</kbd> | Move focus to the previous window |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_3</kbd> | Move the active window to the next position |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_1</kbd> | Move the active window to the previous position |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_9</kbd> | Move the active window to the next screen |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_7</kbd> | Move the active window to the previous screen |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_5</kbd> | Make the active window master |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_6</kbd> | Make the next window master |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>KP_4</kbd> | Make the previous window master |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Insert</kbd> | Increase proportion of master-slave area |
| <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Delete</kbd> | Decrease proportion of master-slave area |

Hot corner events are defined under the `[corners]` section and are triggered when the pointer enters one of the target areas:
| Corners | Description |
Expand Down
14 changes: 10 additions & 4 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ window_next = "Control-Shift-KP_2"
# Move focus to the previous window (KP_8 = Num_8).
window_previous = "Control-Shift-KP_8"

# Move the active window to the next position (KP_3 = Num_3).
position_next = "Control-Shift-KP_3"

# Move the active window to the previous position (KP_1 = Num_1).
position_previous = "Control-Shift-KP_1"

# Move the active window to the next screen (KP_9 = Num_9).
screen_next = "Control-Shift-KP_9"

Expand All @@ -198,11 +204,11 @@ master_make_next = "Control-Shift-KP_6"
# Make the previous window a master (KP_4 = Num_4).
master_make_previous = "Control-Shift-KP_4"

# Increase the proportion of master-slave area (KP_3 = Num_3).
proportion_increase = "Control-Shift-KP_3"
# Increase the proportion of master-slave area (Insert = Ins).
proportion_increase = "Control-Shift-Insert"

# Decrease the proportion of master-slave area (KP_1 = Num_1).
proportion_decrease = "Control-Shift-KP_1"
# Decrease the proportion of master-slave area (Delete = Del).
proportion_decrease = "Control-Shift-Delete"

# Some commands above will affect all screens if this key is pressed in addition (Mod1 = Alt_L).
mod_screens = "Mod1"
Expand Down
44 changes: 42 additions & 2 deletions input/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ func ExecuteAction(action string, tr *desktop.Tracker, ws *desktop.Workspace) bo
success = NextWindow(tr, ws)
case "window_previous":
success = PreviousWindow(tr, ws)
case "position_next":
success = NextPosition(tr, ws)
case "position_previous":
success = PreviousPosition(tr, ws)
case "screen_next":
success = NextScreen(tr, ws)
case "screen_previous":
Expand Down Expand Up @@ -445,12 +449,49 @@ func PreviousWindow(tr *desktop.Tracker, ws *desktop.Workspace) bool {
return true
}

func NextPosition(tr *desktop.Tracker, ws *desktop.Workspace) bool {
if ws.TilingDisabled() {
return false
}
c1 := ws.ActiveLayout().ActiveClient()
if c1 == nil {
return false
}
c2 := ws.ActiveLayout().NextClient()
if c2 == nil {
return false
}

ws.ActiveLayout().SwapClient(c1, c2)
tr.Tile(ws)

return true
}

func PreviousPosition(tr *desktop.Tracker, ws *desktop.Workspace) bool {
if ws.TilingDisabled() {
return false
}
c1 := ws.ActiveLayout().ActiveClient()
if c1 == nil {
return false
}
c2 := ws.ActiveLayout().PreviousClient()
if c2 == nil {
return false
}

ws.ActiveLayout().SwapClient(c1, c2)
tr.Tile(ws)

return true
}

func NextScreen(tr *desktop.Tracker, ws *desktop.Workspace) bool {
c := tr.ActiveClient()
if c == nil {
return false
}

screen := int(c.Latest.Location.Screen) + 1
if screen > int(store.Workplace.ScreenCount)-1 {
return false
Expand All @@ -464,7 +505,6 @@ func PreviousScreen(tr *desktop.Tracker, ws *desktop.Workspace) bool {
if c == nil {
return false
}

screen := int(c.Latest.Location.Screen) - 1
if screen < 0 {
return false
Expand Down

0 comments on commit 279c5cc

Please sign in to comment.