Merge pull request #3080 from orestisf1993/cmd_move_con_to_workspace
Reduce repetition in cmd_move_con_to_workspace*
This commit is contained in:
commit
9610dc29b8
|
@ -261,14 +261,20 @@ void cmd_criteria_add(I3_CMD, const char *ctype, const char *cvalue) {
|
||||||
match_parse_property(current_match, ctype, cvalue);
|
match_parse_property(current_match, ctype, cvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void move_matches_to_workspace(Con *ws) {
|
||||||
|
owindow *current;
|
||||||
|
TAILQ_FOREACH(current, &owindows, owindows) {
|
||||||
|
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
||||||
|
con_move_to_workspace(current->con, ws, true, false, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implementation of 'move [window|container] [to] workspace
|
* Implementation of 'move [window|container] [to] workspace
|
||||||
* next|prev|next_on_output|prev_on_output|current'.
|
* next|prev|next_on_output|prev_on_output|current'.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void cmd_move_con_to_workspace(I3_CMD, const char *which) {
|
void cmd_move_con_to_workspace(I3_CMD, const char *which) {
|
||||||
owindow *current;
|
|
||||||
|
|
||||||
DLOG("which=%s\n", which);
|
DLOG("which=%s\n", which);
|
||||||
|
|
||||||
/* We have nothing to move:
|
/* We have nothing to move:
|
||||||
|
@ -301,10 +307,7 @@ void cmd_move_con_to_workspace(I3_CMD, const char *which) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH(current, &owindows, owindows) {
|
move_matches_to_workspace(ws);
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
|
||||||
con_move_to_workspace(current->con, ws, true, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd_output->needs_tree_render = true;
|
cmd_output->needs_tree_render = true;
|
||||||
// XXX: default reply for now, make this a better reply
|
// XXX: default reply for now, make this a better reply
|
||||||
|
@ -316,11 +319,7 @@ void cmd_move_con_to_workspace(I3_CMD, const char *which) {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void cmd_move_con_to_workspace_back_and_forth(I3_CMD) {
|
void cmd_move_con_to_workspace_back_and_forth(I3_CMD) {
|
||||||
owindow *current;
|
Con *ws = workspace_back_and_forth_get();
|
||||||
Con *ws;
|
|
||||||
|
|
||||||
ws = workspace_back_and_forth_get();
|
|
||||||
|
|
||||||
if (ws == NULL) {
|
if (ws == NULL) {
|
||||||
yerror("No workspace was previously active.");
|
yerror("No workspace was previously active.");
|
||||||
return;
|
return;
|
||||||
|
@ -328,10 +327,7 @@ void cmd_move_con_to_workspace_back_and_forth(I3_CMD) {
|
||||||
|
|
||||||
HANDLE_EMPTY_MATCH;
|
HANDLE_EMPTY_MATCH;
|
||||||
|
|
||||||
TAILQ_FOREACH(current, &owindows, owindows) {
|
move_matches_to_workspace(ws);
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
|
||||||
con_move_to_workspace(current->con, ws, true, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd_output->needs_tree_render = true;
|
cmd_output->needs_tree_render = true;
|
||||||
// XXX: default reply for now, make this a better reply
|
// XXX: default reply for now, make this a better reply
|
||||||
|
@ -350,7 +346,6 @@ void cmd_move_con_to_workspace_name(I3_CMD, const char *name, const char *_no_au
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
|
const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
|
||||||
owindow *current;
|
|
||||||
|
|
||||||
/* We have nothing to move:
|
/* We have nothing to move:
|
||||||
* when criteria was specified but didn't match any window or
|
* when criteria was specified but didn't match any window or
|
||||||
|
@ -374,10 +369,7 @@ void cmd_move_con_to_workspace_name(I3_CMD, const char *name, const char *_no_au
|
||||||
|
|
||||||
HANDLE_EMPTY_MATCH;
|
HANDLE_EMPTY_MATCH;
|
||||||
|
|
||||||
TAILQ_FOREACH(current, &owindows, owindows) {
|
move_matches_to_workspace(ws);
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
|
||||||
con_move_to_workspace(current->con, ws, true, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd_output->needs_tree_render = true;
|
cmd_output->needs_tree_render = true;
|
||||||
// XXX: default reply for now, make this a better reply
|
// XXX: default reply for now, make this a better reply
|
||||||
|
@ -390,7 +382,6 @@ void cmd_move_con_to_workspace_name(I3_CMD, const char *name, const char *_no_au
|
||||||
*/
|
*/
|
||||||
void cmd_move_con_to_workspace_number(I3_CMD, const char *which, const char *_no_auto_back_and_forth) {
|
void cmd_move_con_to_workspace_number(I3_CMD, const char *which, const char *_no_auto_back_and_forth) {
|
||||||
const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
|
const bool no_auto_back_and_forth = (_no_auto_back_and_forth != NULL);
|
||||||
owindow *current;
|
|
||||||
|
|
||||||
/* We have nothing to move:
|
/* We have nothing to move:
|
||||||
* when criteria was specified but didn't match any window or
|
* when criteria was specified but didn't match any window or
|
||||||
|
@ -404,7 +395,7 @@ void cmd_move_con_to_workspace_number(I3_CMD, const char *which, const char *_no
|
||||||
|
|
||||||
LOG("should move window to workspace %s\n", which);
|
LOG("should move window to workspace %s\n", which);
|
||||||
/* get the workspace */
|
/* get the workspace */
|
||||||
Con *output, *workspace = NULL;
|
Con *output, *ws = NULL;
|
||||||
|
|
||||||
long parsed_num = ws_name_to_number(which);
|
long parsed_num = ws_name_to_number(which);
|
||||||
|
|
||||||
|
@ -415,22 +406,19 @@ void cmd_move_con_to_workspace_number(I3_CMD, const char *which, const char *_no
|
||||||
}
|
}
|
||||||
|
|
||||||
TAILQ_FOREACH(output, &(croot->nodes_head), nodes)
|
TAILQ_FOREACH(output, &(croot->nodes_head), nodes)
|
||||||
GREP_FIRST(workspace, output_get_content(output),
|
GREP_FIRST(ws, output_get_content(output),
|
||||||
child->num == parsed_num);
|
child->num == parsed_num);
|
||||||
|
|
||||||
if (!workspace) {
|
if (!ws) {
|
||||||
workspace = workspace_get(which, NULL);
|
ws = workspace_get(which, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!no_auto_back_and_forth)
|
if (!no_auto_back_and_forth)
|
||||||
workspace = maybe_auto_back_and_forth_workspace(workspace);
|
ws = maybe_auto_back_and_forth_workspace(ws);
|
||||||
|
|
||||||
HANDLE_EMPTY_MATCH;
|
HANDLE_EMPTY_MATCH;
|
||||||
|
|
||||||
TAILQ_FOREACH(current, &owindows, owindows) {
|
move_matches_to_workspace(ws);
|
||||||
DLOG("matching: %p / %s\n", current->con, current->con->name);
|
|
||||||
con_move_to_workspace(current->con, workspace, true, false, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd_output->needs_tree_render = true;
|
cmd_output->needs_tree_render = true;
|
||||||
// XXX: default reply for now, make this a better reply
|
// XXX: default reply for now, make this a better reply
|
||||||
|
|
Loading…
Reference in New Issue