Make command `move absolute position [position]` work with criteria
Patch status: superseded
Patch by Jesse Luehrs
Long description:
A container selected with criteria should be moved with the `move absolute position [position]` command, instead of this command always acting on the focused container.
To apply this patch, use:
curl http://cr.i3wm.org/patch/615/raw.patch | git am
b/src/commands.c
| 17 |
@@ -1811,31 +1811,42 @@ void cmd_move_window_to_position(I3_CMD, char *method, char *cx, char *cy) {
|
| 18 |
int x = atoi(cx); |
| 19 |
int y = atoi(cy); |
| 20 |
|
| 21 |
- if (!con_is_floating(focused)) {
|
| 22 |
- ELOG("Cannot change position. The window/container is not floating\n");
|
| 23 |
- yerror("Cannot change position. The window/container is not floating.");
|
| 24 |
- return; |
| 25 |
- } |
| 26 |
+ owindow *current; |
| 27 |
+ HANDLE_EMPTY_MATCH; |
| 28 |
|
| 29 |
- if (strcmp(method, "absolute") == 0) {
|
| 30 |
- focused->parent->rect.x = x; |
| 31 |
- focused->parent->rect.y = y; |
| 32 |
+ Con *initially_focused = focused; |
| 33 |
|
| 34 |
- DLOG("moving to absolute position %d %d\n", x, y);
|
| 35 |
- floating_maybe_reassign_ws(focused->parent); |
| 36 |
- cmd_output->needs_tree_render = true; |
| 37 |
- } |
| 38 |
+ TAILQ_FOREACH (current, &owindows, owindows) {
|
| 39 |
+ if (con_is_floating(current->con)) {
|
| 40 |
+ if (strcmp(method, "absolute") == 0) {
|
| 41 |
+ current->con->parent->rect.x = x; |
| 42 |
+ current->con->parent->rect.y = y; |
| 43 |
|
| 44 |
- if (strcmp(method, "position") == 0) {
|
| 45 |
- Rect newrect = focused->parent->rect; |
| 46 |
+ DLOG("moving to absolute position %d %d\n", x, y);
|
| 47 |
+ floating_maybe_reassign_ws(current->con->parent); |
| 48 |
+ cmd_output->needs_tree_render = true; |
| 49 |
+ } |
| 50 |
|
| 51 |
- DLOG("moving to position %d %d\n", x, y);
|
| 52 |
- newrect.x = x; |
| 53 |
- newrect.y = y; |
| 54 |
+ if (strcmp(method, "position") == 0) {
|
| 55 |
+ Rect newrect = current->con->parent->rect; |
| 56 |
|
| 57 |
- floating_reposition(focused->parent, newrect); |
| 58 |
+ DLOG("moving to position %d %d\n", x, y);
|
| 59 |
+ newrect.x = x; |
| 60 |
+ newrect.y = y; |
| 61 |
+ |
| 62 |
+ floating_reposition(current->con->parent, newrect); |
| 63 |
+ } |
| 64 |
+ } |
| 65 |
+ else {
|
| 66 |
+ ELOG("Cannot change position. The window/container is not floating\n");
|
| 67 |
+ yerror("Cannot change position. The window/container is not floating.");
|
| 68 |
+ return; |
| 69 |
+ } |
| 70 |
} |
| 71 |
|
| 72 |
+ if (focused != initially_focused) |
| 73 |
+ con_focus(initially_focused); |
| 74 |
+ |
| 75 |
// XXX: default reply for now, make this a better reply |
| 76 |
ysuccess(true); |
| 77 |
} |