allow ppt values in move direction and move position commands
make ppt values clear in userguide
chore: move is_ppt and DLOG out of TAILQ_FOREACH loop
acheronfail
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 | ------------------------------ |
2139 | 2139 | # Moves the container into the given direction. |
2140 | 2140 | # The optional pixel argument specifies how far the |
2141 | 2141 | # container should be moved if it is floating and |
2142 | # defaults to 10 pixels. | |
2143 | move <left|right|down|up> [<px> px] | |
2142 | # defaults to 10 pixels. The optional ppt argument | |
2143 | # means "percentage points", and if specified it indicates | |
2144 | # how many points the container should be moved if it is | |
2145 | # floating rather than by a pixel value. | |
2146 | move <left|right|down|up> [<amount> [px|ppt]] | |
2144 | 2147 | |
2145 | 2148 | # Moves the container to the specified pos_x and pos_y |
2146 | 2149 | # coordinates on the screen. |
2147 | move position <pos_x> [px] <pos_y> [px] | |
2150 | move position <pos_x> [px|ppt] <pos_y> [px|ppt] | |
2148 | 2151 | |
2149 | 2152 | # Moves the container to the center of the screen. |
2150 | 2153 | # 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 |
130 | 130 | -> call cmd_workspace_back_and_forth() |
131 | 131 | 'number' |
132 | 132 | -> WORKSPACE_NUMBER |
133 | workspace = string | |
133 | workspace = string | |
134 | 134 | -> call cmd_workspace_name($workspace, $no_auto_back_and_forth) |
135 | 135 | |
136 | 136 | state WORKSPACE_NUMBER: |
320 | 320 | new_name = string |
321 | 321 | -> call cmd_rename_workspace($old_name, $new_name) |
322 | 322 | |
323 | # move <direction> [<pixels> [px]] | |
323 | ||
324 | # move <direction> [<amount> [px|ppt]] | |
324 | 325 | # move [window|container] [to] workspace [<str>|next|prev|next_on_output|prev_on_output|current] |
325 | 326 | # move [window|container] [to] output <str> |
326 | 327 | # move [window|container] [to] mark <str> |
327 | 328 | # move [window|container] [to] scratchpad |
328 | 329 | # move workspace to [output] <str> |
329 | 330 | # move scratchpad |
330 | # move [window|container] [to] [absolute] position [ [<pixels> [px] <pixels> [px]] | center ] | |
331 | # move [window|container] [to] [absolute] position [ [<pos_x> [px|ppt] <pos_y> [px|ppt] ] | center ] | |
331 | 332 | # move [window|container] [to] position mouse|cursor|pointer |
332 | 333 | state MOVE: |
333 | 334 | 'window' |
354 | 355 | -> MOVE_TO_ABSOLUTE_POSITION |
355 | 356 | |
356 | 357 | state MOVE_DIRECTION: |
357 | pixels = number | |
358 | -> MOVE_DIRECTION_PX | |
359 | end | |
360 | -> call cmd_move_direction($direction, 10) | |
361 | ||
362 | state MOVE_DIRECTION_PX: | |
363 | 'px' | |
364 | -> call cmd_move_direction($direction, &pixels) | |
365 | end | |
366 | -> call cmd_move_direction($direction, &pixels) | |
358 | amount = number | |
359 | -> MOVE_DIRECTION_NUMBER | |
360 | end | |
361 | -> call cmd_move_direction($direction, 10, "px") | |
362 | ||
363 | state MOVE_DIRECTION_NUMBER: | |
364 | mode = 'px', 'ppt' | |
365 | -> call cmd_move_direction($direction, &amount, $mode) | |
366 | end | |
367 | -> call cmd_move_direction($direction, &amount, "px") | |
367 | 368 | |
368 | 369 | state MOVE_WORKSPACE: |
369 | 370 | 'to ' |
408 | 409 | -> MOVE_TO_POSITION_X |
409 | 410 | |
410 | 411 | state MOVE_TO_POSITION_X: |
411 | 'px' | |
412 | mode_x = 'px', 'ppt' | |
412 | 413 | -> |
413 | 414 | coord_y = number |
414 | 415 | -> MOVE_TO_POSITION_Y |
415 | 416 | |
416 | 417 | state MOVE_TO_POSITION_Y: |
417 | 'px', end | |
418 | -> call cmd_move_window_to_position(&coord_x, &coord_y) | |
418 | mode_y = 'px', 'ppt' | |
419 | -> call cmd_move_window_to_position(&coord_x, $mode_x, &coord_y, $mode_y) | |
420 | end | |
421 | -> call cmd_move_window_to_position(&coord_x, $mode_x, &coord_y, 0) | |
419 | 422 | |
420 | 423 | # mode <string> |
421 | 424 | 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}}; |