Esempio n. 1
0
File: move.c Progetto: Chr1stoph/i3
/*
 * Moves the given container to the closest output in the given direction if
 * such an output exists.
 *
 */
static void move_to_output_directed(Con *con, direction_t direction) {
    Con *old_ws = con_get_workspace(con);
    Con *current_output_con = con_get_output(con);
    Output *current_output = get_output_by_name(current_output_con->name);
    Output *output = get_output_next(direction, current_output, CLOSEST_OUTPUT);

    if (!output) {
        DLOG("No output in this direction found. Not moving.\n");
        return;
    }

    Con *ws = NULL;
    GREP_FIRST(ws, output_get_content(output->con), workspace_is_visible(child));

    if (!ws) {
        DLOG("No workspace on output in this direction found. Not moving.\n");
        return;
    }

    attach_to_workspace(con, ws, direction);

    /* fix the focus stack */
    con_focus(con);

    /* force re-painting the indicators */
    FREE(con->deco_render_params);

    tree_flatten(croot);

    ipc_send_workspace_event("focus", ws, old_ws);
}
Esempio n. 2
0
/*
 * Creates outputs according to the given specification.
 * The specification must be in the format wxh+x+y, for example 1024x768+0+0,
 * with multiple outputs separated by commas:
 *   1900x1200+0+0,1280x1024+1900+0
 *
 */
void fake_outputs_init(const char *output_spec) {
    char useless_buffer[1024];
    const char *walk = output_spec;
    unsigned int x, y, width, height;
    while (sscanf(walk, "%ux%u+%u+%u", &width, &height, &x, &y) == 4) {
        DLOG("Parsed output as width = %u, height = %u at (%u, %u)\n",
             width, height, x, y);
        Output *new_output = get_screen_at(x, y);
        if (new_output != NULL) {
            DLOG("Re-used old output %p\n", new_output);
            /* This screen already exists. We use the littlest screen so that the user
               can always see the complete workspace */
            new_output->rect.width = min(new_output->rect.width, width);
            new_output->rect.height = min(new_output->rect.height, height);
        } else {
            new_output = scalloc(sizeof(Output));
            sasprintf(&(new_output->name), "fake-%d", num_screens);
            DLOG("Created new fake output %s (%p)\n", new_output->name, new_output);
            new_output->active = true;
            new_output->rect.x = x;
            new_output->rect.y = y;
            new_output->rect.width = width;
            new_output->rect.height = height;
            /* We always treat the screen at 0x0 as the primary screen */
            if (new_output->rect.x == 0 && new_output->rect.y == 0)
                TAILQ_INSERT_HEAD(&outputs, new_output, outputs);
            else
                TAILQ_INSERT_TAIL(&outputs, new_output, outputs);
            output_init_con(new_output);
            init_ws_for_output(new_output, output_get_content(new_output->con));
            num_screens++;
        }

        /* Figure out how long the input was to skip it */
        walk += sprintf(useless_buffer, "%ux%u+%u+%u", width, height, x, y) + 1;
    }

    if (num_screens == 0) {
        ELOG("No screens found. Please fix your setup. i3 will exit now.\n");
        exit(0);
    }
}