X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Foutput.c;h=571c01cfa49e7f19f98f0da23adc31aea8b8b10c;hb=0b5a2092a08f7e4463b5d52e11d84750af84e73c;hp=62b146a74150fa65e094e09a6b4e4570552700b1;hpb=71afed725a95d12c5e12661d87f503e6b24f6247;p=i3%2Fi3 diff --git a/src/output.c b/src/output.c index 62b146a7..571c01cf 100644 --- a/src/output.c +++ b/src/output.c @@ -1,5 +1,3 @@ -#undef I3__FILE__ -#define I3__FILE__ "output.c" /* * vim:ts=4:sw=4:expandtab * @@ -31,18 +29,41 @@ Con *output_get_content(Con *output) { * */ Output *get_output_from_string(Output *current_output, const char *output_str) { - Output *output; + if (strcasecmp(output_str, "current") == 0) { + return get_output_for_con(focused); + } else if (strcasecmp(output_str, "left") == 0) { + return get_output_next_wrap(D_LEFT, current_output); + } else if (strcasecmp(output_str, "right") == 0) { + return get_output_next_wrap(D_RIGHT, current_output); + } else if (strcasecmp(output_str, "up") == 0) { + return get_output_next_wrap(D_UP, current_output); + } else if (strcasecmp(output_str, "down") == 0) { + return get_output_next_wrap(D_DOWN, current_output); + } + + return get_output_by_name(output_str, true); +} - if (strcasecmp(output_str, "left") == 0) - output = get_output_next_wrap(D_LEFT, current_output); - else if (strcasecmp(output_str, "right") == 0) - output = get_output_next_wrap(D_RIGHT, current_output); - else if (strcasecmp(output_str, "up") == 0) - output = get_output_next_wrap(D_UP, current_output); - else if (strcasecmp(output_str, "down") == 0) - output = get_output_next_wrap(D_DOWN, current_output); - else - output = get_output_by_name(output_str); +/* + * Retrieves the primary name of an output. + * + */ +char *output_primary_name(Output *output) { + return SLIST_FIRST(&output->names_head)->name; +} + +Output *get_output_for_con(Con *con) { + Con *output_con = con_get_output(con); + if (output_con == NULL) { + ELOG("Could not get the output container for con = %p.\n", con); + return NULL; + } + + Output *output = get_output_by_name(output_con->name, true); + if (output == NULL) { + ELOG("Could not get output from name \"%s\".\n", output_con->name); + return NULL; + } return output; } @@ -78,7 +99,14 @@ void output_push_sticky_windows(Con *to_focus) { continue; if (con_is_sticky(current)) { - con_move_to_workspace(current, visible_ws, true, false, current != to_focus->parent); + bool ignore_focus = (to_focus == NULL) || (current != to_focus->parent); + con_move_to_workspace(current, visible_ws, true, false, ignore_focus); + if (!ignore_focus) { + Con *current_ws = con_get_workspace(focused); + con_activate(con_descend_focused(current)); + /* Pushing sticky windows shouldn't change the focused workspace. */ + con_activate(con_descend_focused(current_ws)); + } } } }