*
* i3 - an improved dynamic tiling window manager
*
- * © 2009 Michael Stapelberg and contributors
+ * © 2009-2010 Michael Stapelberg and contributors
*
* See file LICENSE for license information.
*
#include "table.h"
#include "layout.h"
#include "i3.h"
-#include "xinerama.h"
+#include "randr.h"
#include "client.h"
#include "floating.h"
#include "xcb.h"
* right/left/bottom/top and just switch to the workspace on
* the target screen. */
if (thing == THING_SCREEN) {
- i3Screen *cs = c_ws->screen;
+ Output *cs = c_ws->output;
assert(cs != NULL);
Rect bounds = cs->rect;
bounds.y -= bounds.height;
else bounds.y += bounds.height;
- i3Screen *target = get_screen_containing(bounds.x, bounds.y);
+ Output *target = get_screen_containing(bounds.x, bounds.y);
if (target == NULL) {
- DLOG("Target screen NULL\n");
+ DLOG("Target output NULL\n");
/* Wrap around if the target screen is out of bounds */
if (direction == D_RIGHT)
target = get_screen_most(D_LEFT, cs);
} else {
/* Let’s see if there is a screen down/up there to which we can switch */
DLOG("container is at %d with height %d\n", container->y, container->height);
- i3Screen *screen;
+ Output *output;
int destination_y = (direction == D_UP ? (container->y - 1) : (container->y + container->height + 1));
- if ((screen = get_screen_containing(container->x, destination_y)) == NULL) {
+ if ((output = get_screen_containing(container->x, destination_y)) == NULL) {
DLOG("Wrapping screen around vertically\n");
/* No screen found? Then wrap */
- screen = get_screen_most((direction == D_UP ? D_DOWN : D_UP), container->workspace->screen);
+ output = get_screen_most((direction == D_UP ? D_DOWN : D_UP), container->workspace->output);
}
- t_ws = screen->current_workspace;
+ t_ws = output->current_workspace;
new_row = (direction == D_UP ? (t_ws->rows - 1) : 0);
}
} else {
/* Let’s see if there is a screen left/right here to which we can switch */
DLOG("container is at %d with width %d\n", container->x, container->width);
- i3Screen *screen;
+ Output *output;
int destination_x = (direction == D_LEFT ? (container->x - 1) : (container->x + container->width + 1));
- if ((screen = get_screen_containing(destination_x, container->y)) == NULL) {
+ if ((output = get_screen_containing(destination_x, container->y)) == NULL) {
DLOG("Wrapping screen around horizontally\n");
- screen = get_screen_most((direction == D_LEFT ? D_RIGHT : D_LEFT), container->workspace->screen);
+ output = get_screen_most((direction == D_LEFT ? D_RIGHT : D_LEFT), container->workspace->output);
}
- t_ws = screen->current_workspace;
+ t_ws = output->current_workspace;
new_col = (direction == D_LEFT ? (t_ws->cols - 1) : 0);
}
/* Fix colspan/rowspan if it’d overlap */
fix_colrowspan(conn, workspace);
- render_workspace(conn, workspace->screen, workspace);
+ render_workspace(conn, workspace->output, workspace);
xcb_flush(conn);
set_focus(conn, current_client, true);
LOG("moving floating\n");
- workspace_initialize(t_ws, c_ws->screen, false);
+ workspace_initialize(t_ws, c_ws->output, false);
/* Check if there is already a fullscreen client on the destination workspace and
* stop moving if so. */
if (to_focus == NULL)
to_focus = CIRCLEQ_PREV_OR_NULL(&(container->clients), current_client, clients);
- workspace_initialize(t_ws, container->workspace->screen, false);
+ workspace_initialize(t_ws, container->workspace->output, false);
/* Check if there is already a fullscreen client on the destination workspace and
* stop moving if so. */
if (current_client->fullscreen && (t_ws->fullscreen_client != NULL)) {
render_layout(conn);
- if (workspace_is_visible(to_container->workspace))
+ if (workspace_is_visible(to_container->workspace)) {
+ client_warp_pointer_into(conn, current_client);
set_focus(conn, current_client, true);
+ }
}
/*
Workspace *ws = c_ws;
if (direction == 'n') {
- while ((ws = TAILQ_NEXT(ws, workspaces)) != TAILQ_END(workspaces_head)) {
- if (ws->screen == NULL)
+ while (1) {
+ ws = TAILQ_NEXT(ws, workspaces);
+
+ if (ws == TAILQ_END(workspaces))
+ ws = TAILQ_FIRST(workspaces);
+
+ if (ws == c_ws)
+ return;
+
+ if (ws->output == NULL)
continue;
workspace_show(conn, ws->num + 1);
return;
}
} else if (direction == 'p') {
- while ((ws = TAILQ_PREV(ws, workspaces_head, workspaces)) != TAILQ_END(workspaces)) {
- if (ws->screen == NULL)
+ while (1) {
+ ws = TAILQ_PREV(ws, workspaces_head, workspaces);
+
+ if (ws == TAILQ_END(workspaces))
+ ws = TAILQ_LAST(workspaces, workspaces_head);
+
+ if (ws == c_ws)
+ return;
+
+ if (ws->output == NULL)
continue;
workspace_show(conn, ws->num + 1);
int first, second;
resize_orientation_t orientation = O_VERTICAL;
Container *con = last_focused->container;
- Workspace *ws = con->workspace;
+ Workspace *ws = last_focused->workspace;
+
+ if (client_is_floating(last_focused)) {
+ DLOG("Resizing a floating client\n");
+ if (STARTS_WITH(command, "left")) {
+ command += strlen("left");
+ last_focused->rect.width += atoi(command);
+ last_focused->rect.x -= atoi(command);
+ } else if (STARTS_WITH(command, "right")) {
+ command += strlen("right");
+ last_focused->rect.width += atoi(command);
+ } else if (STARTS_WITH(command, "top")) {
+ command += strlen("top");
+ last_focused->rect.height += atoi(command);
+ last_focused->rect.y -= atoi(command);
+ } else if (STARTS_WITH(command, "bottom")) {
+ command += strlen("bottom");
+ last_focused->rect.height += atoi(command);
+ } else {
+ ELOG("Syntax: resize <left|right|top|bottom> [+|-]<pixels>\n");
+ return;
+ }
+
+ /* resize_client flushes */
+ resize_client(conn, last_focused);
+
+ return;
+ }
if (STARTS_WITH(command, "left")) {
if (con->col == 0)
/* Fix colspan/rowspan if it’d overlap */
fix_colrowspan(conn, ws);
- render_workspace(conn, ws->screen, ws);
+ render_workspace(conn, ws->output, ws);
/* Re-focus the client because cleanup_table sets the focus to the last
* focused client inside a container only. */