Merge remote-tracking branch 'vanilla/next' into gaps-next
Ingo Bürk
3 years ago
26 | 26 | • update i3bar config when necessary (reduces redraws on bar mode changes) |
27 | 27 | • mention rofi in default config file |
28 | 28 | • i3-input: add different exit codes for when i3-input fails |
29 | • allow ppt values in move direction and move position commands | |
29 | 30 | |
30 | 31 | ┌────────────────────────────┐ |
31 | 32 | │ Bugfixes │ |
244 | 244 | |
245 | 245 | So, how can you open a new terminal window to the *right* of the current one? |
246 | 246 | The solution is to use +focus parent+, which will focus the +Parent Container+ of |
247 | the current +Container+. In default configuration, use +$mod+a+ to navigate one | |
247 | the current +Container+. In default configuration, use +$mod+a+ to navigate one | |
248 | 248 | +Container+ up the tree (you can repeat this multiple times until you get to the |
249 | 249 | +Workspace Container+). In this case, you would focus the +Vertical Split Container+ |
250 | 250 | which is *inside* the horizontally oriented workspace. Thus, now new windows will be |
1414 | 1414 | Scroll wheel right. |
1415 | 1415 | button7:: |
1416 | 1416 | Scroll wheel left. |
1417 | ||
1417 | ||
1418 | 1418 | |
1419 | 1419 | Please note that the old +wheel_up_cmd+ and +wheel_down_cmd+ commands are deprecated |
1420 | 1420 | and will be removed in a future release. We strongly recommend using the more general |
1681 | 1681 | the form "[n][:][NAME]" will display only the number. |
1682 | 1682 | |
1683 | 1683 | The default is to display the full name within the workspace button. Be aware |
1684 | that the colon in the workspace name is optional, so `[n][NAME]` will also | |
1685 | have the workspace name and number stripped correctly. | |
1684 | that the colon in the workspace name is optional, so `[n][NAME]` will also | |
1685 | have the workspace name and number stripped correctly. | |
1686 | 1686 | |
1687 | 1687 | *Syntax*: |
1688 | 1688 | ------------------------------ |
2156 | 2156 | # Moves the container into the given direction. |
2157 | 2157 | # The optional pixel argument specifies how far the |
2158 | 2158 | # container should be moved if it is floating and |
2159 | # defaults to 10 pixels. | |
2160 | move <left|right|down|up> [<px> px] | |
2159 | # defaults to 10 pixels. The optional ppt argument | |
2160 | # means "percentage points", and if specified it indicates | |
2161 | # how many points the container should be moved if it is | |
2162 | # floating rather than by a pixel value. | |
2163 | move <left|right|down|up> [<amount> [px|ppt]] | |
2161 | 2164 | |
2162 | 2165 | # Moves the container to the specified pos_x and pos_y |
2163 | 2166 | # coordinates on the screen. |
2164 | move position <pos_x> [px] <pos_y> [px] | |
2167 | move position <pos_x> [px|ppt] <pos_y> [px|ppt] | |
2165 | 2168 | |
2166 | 2169 | # Moves the container to the center of the screen. |
2167 | 2170 | # If 'absolute' is used, it is moved to the center of |
218 | 218 | void cmd_sticky(I3_CMD, const char *action); |
219 | 219 | |
220 | 220 | /** |
221 | * Implementation of 'move <direction> [<pixels> [px]]'. | |
222 | * | |
223 | */ | |
224 | void cmd_move_direction(I3_CMD, const char *direction_str, long move_px); | |
221 | * Implementation of 'move <direction> [<amount> [px|ppt]]'. | |
222 | * | |
223 | */ | |
224 | void cmd_move_direction(I3_CMD, const char *direction_str, long amount, const char *mode); | |
225 | 225 | |
226 | 226 | /** |
227 | 227 | * Implementation of 'layout default|stacked|stacking|tabbed|splitv|splith'. |
266 | 266 | void cmd_focus_output(I3_CMD, const char *name); |
267 | 267 | |
268 | 268 | /** |
269 | * Implementation of 'move [window|container] [to] [absolute] position <px> [px] <px> [px] | |
270 | * | |
271 | */ | |
272 | void cmd_move_window_to_position(I3_CMD, long x, long y); | |
269 | * Implementation of 'move [window|container] [to] [absolute] position [<pos_x> [px|ppt] <pos_y> [px|ppt]] | |
270 | * | |
271 | */ | |
272 | void cmd_move_window_to_position(I3_CMD, long x, const char *mode_x, long y, const char *mode_y); | |
273 | 273 | |
274 | 274 | /** |
275 | 275 | * Implementation of 'move [window|container] [to] [absolute] position center |
148 | 148 | -> call cmd_workspace_back_and_forth() |
149 | 149 | 'number' |
150 | 150 | -> WORKSPACE_NUMBER |
151 | workspace = string | |
151 | workspace = string | |
152 | 152 | -> call cmd_workspace_name($workspace, $no_auto_back_and_forth) |
153 | 153 | |
154 | 154 | state WORKSPACE_NUMBER: |
338 | 338 | new_name = string |
339 | 339 | -> call cmd_rename_workspace($old_name, $new_name) |
340 | 340 | |
341 | # move <direction> [<pixels> [px]] | |
341 | ||
342 | # move <direction> [<amount> [px|ppt]] | |
342 | 343 | # move [window|container] [to] workspace [<str>|next|prev|next_on_output|prev_on_output|current] |
343 | 344 | # move [window|container] [to] output <str> |
344 | 345 | # move [window|container] [to] mark <str> |
345 | 346 | # move [window|container] [to] scratchpad |
346 | 347 | # move workspace to [output] <str> |
347 | 348 | # move scratchpad |
348 | # move [window|container] [to] [absolute] position [ [<pixels> [px] <pixels> [px]] | center ] | |
349 | # move [window|container] [to] [absolute] position [ [<pos_x> [px|ppt] <pos_y> [px|ppt] ] | center ] | |
349 | 350 | # move [window|container] [to] position mouse|cursor|pointer |
350 | 351 | state MOVE: |
351 | 352 | 'window' |
372 | 373 | -> MOVE_TO_ABSOLUTE_POSITION |
373 | 374 | |
374 | 375 | state MOVE_DIRECTION: |
375 | pixels = number | |
376 | -> MOVE_DIRECTION_PX | |
377 | end | |
378 | -> call cmd_move_direction($direction, 10) | |
379 | ||
380 | state MOVE_DIRECTION_PX: | |
381 | 'px' | |
382 | -> call cmd_move_direction($direction, &pixels) | |
383 | end | |
384 | -> call cmd_move_direction($direction, &pixels) | |
376 | amount = number | |
377 | -> MOVE_DIRECTION_NUMBER | |
378 | end | |
379 | -> call cmd_move_direction($direction, 10, "px") | |
380 | ||
381 | state MOVE_DIRECTION_NUMBER: | |
382 | mode = 'px', 'ppt' | |
383 | -> call cmd_move_direction($direction, &amount, $mode) | |
384 | end | |
385 | -> call cmd_move_direction($direction, &amount, "px") | |
385 | 386 | |
386 | 387 | state MOVE_WORKSPACE: |
387 | 388 | 'to ' |
426 | 427 | -> MOVE_TO_POSITION_X |
427 | 428 | |
428 | 429 | state MOVE_TO_POSITION_X: |
429 | 'px' | |
430 | mode_x = 'px', 'ppt' | |
430 | 431 | -> |
431 | 432 | coord_y = number |
432 | 433 | -> MOVE_TO_POSITION_Y |
433 | 434 | |
434 | 435 | state MOVE_TO_POSITION_Y: |
435 | 'px', end | |
436 | -> call cmd_move_window_to_position(&coord_x, &coord_y) | |
436 | mode_y = 'px', 'ppt' | |
437 | -> call cmd_move_window_to_position(&coord_x, $mode_x, &coord_y, $mode_y) | |
438 | end | |
439 | -> call cmd_move_window_to_position(&coord_x, $mode_x, &coord_y, 0) | |
437 | 440 | |
438 | 441 | # mode <string> |
439 | 442 | state MODE: |
1489 | 1489 | } |
1490 | 1490 | |
1491 | 1491 | /* |
1492 | * Implementation of 'move <direction> [<pixels> [px]]'. | |
1493 | * | |
1494 | */ | |
1495 | void cmd_move_direction(I3_CMD, const char *direction_str, long move_px) { | |
1492 | * Implementation of 'move <direction> [<amount> [px|ppt]]'. | |
1493 | * | |
1494 | */ | |
1495 | void cmd_move_direction(I3_CMD, const char *direction_str, long amount, const char *mode) { | |
1496 | 1496 | owindow *current; |
1497 | 1497 | HANDLE_EMPTY_MATCH; |
1498 | 1498 | |
1499 | 1499 | Con *initially_focused = focused; |
1500 | 1500 | direction_t direction = parse_direction(direction_str); |
1501 | 1501 | |
1502 | TAILQ_FOREACH (current, &owindows, owindows) { | |
1503 | DLOG("moving in direction %s, px %ld\n", direction_str, move_px); | |
1502 | const bool is_ppt = mode && strcmp(mode, "ppt") == 0; | |
1503 | ||
1504 | DLOG("moving in direction %s, %ld %s\n", direction_str, amount, mode); | |
1505 | TAILQ_FOREACH (current, &owindows, owindows) { | |
1504 | 1506 | if (con_is_floating(current->con)) { |
1505 | DLOG("floating move with %ld pixels\n", move_px); | |
1507 | DLOG("floating move with %ld %s\n", amount, mode); | |
1506 | 1508 | Rect newrect = current->con->parent->rect; |
1509 | Con *output = con_get_output(current->con); | |
1507 | 1510 | |
1508 | 1511 | switch (direction) { |
1509 | 1512 | case D_LEFT: |
1510 | newrect.x -= move_px; | |
1513 | newrect.x -= is_ppt ? output->rect.width * ((double)amount / 100.0) : amount; | |
1511 | 1514 | break; |
1512 | 1515 | case D_RIGHT: |
1513 | newrect.x += move_px; | |
1516 | newrect.x += is_ppt ? output->rect.width * ((double)amount / 100.0) : amount; | |
1514 | 1517 | break; |
1515 | 1518 | case D_UP: |
1516 | newrect.y -= move_px; | |
1519 | newrect.y -= is_ppt ? output->rect.height * ((double)amount / 100.0) : amount; | |
1517 | 1520 | break; |
1518 | 1521 | case D_DOWN: |
1519 | newrect.y += move_px; | |
1522 | newrect.y += is_ppt ? output->rect.height * ((double)amount / 100.0) : amount; | |
1520 | 1523 | break; |
1521 | 1524 | } |
1522 | 1525 | |
1720 | 1723 | } |
1721 | 1724 | |
1722 | 1725 | /* |
1723 | * Implementation of 'move [window|container] [to] [absolute] position <px> [px] <px> [px] | |
1724 | * | |
1725 | */ | |
1726 | void cmd_move_window_to_position(I3_CMD, long x, long y) { | |
1726 | * Implementation of 'move [window|container] [to] [absolute] position [<pos_x> [px|ppt] <pos_y> [px|ppt]] | |
1727 | * | |
1728 | */ | |
1729 | void cmd_move_window_to_position(I3_CMD, long x, const char *mode_x, long y, const char *mode_y) { | |
1727 | 1730 | bool has_error = false; |
1728 | 1731 | |
1729 | 1732 | owindow *current; |
1742 | 1745 | } |
1743 | 1746 | |
1744 | 1747 | Rect newrect = current->con->parent->rect; |
1745 | ||
1746 | DLOG("moving to position %ld %ld\n", x, y); | |
1747 | newrect.x = x; | |
1748 | newrect.y = y; | |
1748 | Con *output = con_get_output(current->con); | |
1749 | ||
1750 | newrect.x = mode_x && strcmp(mode_x, "ppt") == 0 ? output->rect.width * ((double)x / 100.0) : x; | |
1751 | newrect.y = mode_y && strcmp(mode_y, "ppt") == 0 ? output->rect.height * ((double)y / 100.0) : y; | |
1752 | DLOG("moving to position %d %s %d %s\n", newrect.x, mode_x, newrect.y, mode_y); | |
1749 | 1753 | |
1750 | 1754 | if (!floating_reposition(current->con->parent, newrect)) { |
1751 | 1755 | yerror("Cannot move window/container out of bounds."); |
219 | 219 | is($absolute->width, $absolute_before->width, 'width not changed'); |
220 | 220 | is($absolute->height, $absolute_before->height, 'height not changed'); |
221 | 221 | |
222 | ###################################################################### | |
223 | # 6) test moving floating window to a specified position | |
222 | $absolute_before = $absolute; | |
223 | $top_before = $top; | |
224 | ||
225 | ###################################################################### | |
226 | # 7) test moving floating containers with a specific amount of ppt | |
227 | ###################################################################### | |
228 | ||
229 | cmd 'move right 25 ppt'; | |
230 | ||
231 | sync_with_i3; | |
232 | ||
233 | ($absolute, $top) = $floatwin->rect; | |
234 | ||
235 | is($absolute->x, int($x->root->rect->width * 0.25) + $absolute_before->x, 'moved 25 ppt to the right'); | |
236 | is($absolute->y, $absolute_before->y, 'y not changed'); | |
237 | is($absolute->width, $absolute_before->width, 'width not changed'); | |
238 | is($absolute->height, $absolute_before->height, 'height not changed'); | |
239 | ||
240 | ###################################################################### | |
241 | # 8) test moving floating window to a specified position | |
224 | 242 | # and to absolute center |
225 | 243 | ###################################################################### |
226 | 244 | |
227 | 245 | $tmp = fresh_workspace; |
228 | 246 | open_floating_window; my @floatcon; |
229 | 247 | |
248 | # Move to specified position with px | |
230 | 249 | cmd 'move position 5 px 15 px'; |
231 | 250 | |
232 | 251 | @floatcon = @{get_ws($tmp)->{floating_nodes}}; |
233 | 252 | |
234 | is($floatcon[0]->{rect}->{x}, 5, 'moved to position 5 x'); | |
235 | is($floatcon[0]->{rect}->{y}, 15, 'moved to position 15 y'); | |
236 | ||
253 | is($floatcon[0]->{rect}->{x}, 5, 'moved to position 5 (px) x'); | |
254 | is($floatcon[0]->{rect}->{y}, 15, 'moved to position 15 (px) y'); | |
255 | ||
256 | # Move to specified position with ppt | |
257 | cmd 'move position 20 ppt 20 ppt'; | |
258 | ||
259 | @floatcon = @{get_ws($tmp)->{floating_nodes}}; | |
260 | ||
261 | is($floatcon[0]->{rect}->{x}, int($x->root->rect->width * 0.20), "moved to position 20 (ppt) x"); | |
262 | is($floatcon[0]->{rect}->{y}, int($x->root->rect->height * 0.20), "moved to position 20 (ppt) y"); | |
263 | ||
264 | # Move to absolute center | |
237 | 265 | cmd 'move absolute position center'; |
238 | 266 | |
239 | 267 | @floatcon = @{get_ws($tmp)->{floating_nodes}}; |