Merge branch 'master' into next

This commit is contained in:
Michael Stapelberg 2012-01-21 15:08:36 +00:00
commit fabcd7d911
4 changed files with 39 additions and 17 deletions

View File

@ -146,4 +146,11 @@ void drag_pointer(Con *con, const xcb_button_press_event_t *event,
*/ */
void floating_reposition(Con *con, Rect newrect); void floating_reposition(Con *con, Rect newrect);
/**
* Fixes the coordinates of the floating window whenever the window gets
* reassigned to a different output (or when the outputs rect changes).
*
*/
void floating_fix_coordinates(Con *con, Rect *old_rect, Rect *new_rect);
#endif #endif

View File

@ -613,20 +613,7 @@ void con_move_to_workspace(Con *con, Con *workspace, bool fix_coordinates, bool
/* Take the relative coordinates of the current output, then add them /* Take the relative coordinates of the current output, then add them
* to the coordinate space of the correct output */ * to the coordinate space of the correct output */
if (fix_coordinates && con->type == CT_FLOATING_CON) { if (fix_coordinates && con->type == CT_FLOATING_CON) {
DLOG("Floating window, fixing coordinates\n"); floating_fix_coordinates(con, &(source_output->rect), &(dest_output->rect));
/* First we get the x/y coordinates relative to the x/y coordinates
* of the output on which the window is on */
uint32_t rel_x = (con->rect.x - source_output->rect.x);
uint32_t rel_y = (con->rect.y - source_output->rect.y);
/* Then we calculate a fraction, for example 0.63 for a window
* which is at y = 1212 of a 1920 px high output */
double fraction_x = ((double)rel_x / source_output->rect.width);
double fraction_y = ((double)rel_y / source_output->rect.height);
DLOG("rel_x = %d, rel_y = %d, fraction_x = %f, fraction_y = %f, output->w = %d, output->h = %d\n",
rel_x, rel_y, fraction_x, fraction_y, source_output->rect.width, source_output->rect.height);
con->rect.x = dest_output->rect.x + (fraction_x * dest_output->rect.width);
con->rect.y = dest_output->rect.y + (fraction_y * dest_output->rect.height);
DLOG("Resulting coordinates: x = %d, y = %d\n", con->rect.x, con->rect.y);
} else DLOG("Not fixing coordinates, fix_coordinates flag = %d\n", fix_coordinates); } else DLOG("Not fixing coordinates, fix_coordinates flag = %d\n", fix_coordinates);
/* If moving to a visible workspace, call show so it can be considered /* If moving to a visible workspace, call show so it can be considered

View File

@ -551,6 +551,28 @@ void floating_reposition(Con *con, Rect newrect) {
tree_render(); tree_render();
} }
/*
* Fixes the coordinates of the floating window whenever the window gets
* reassigned to a different output (or when the outputs rect changes).
*
*/
void floating_fix_coordinates(Con *con, Rect *old_rect, Rect *new_rect) {
DLOG("Fixing coordinates of floating window %p\n", con);
/* First we get the x/y coordinates relative to the x/y coordinates
* of the output on which the window is on */
uint32_t rel_x = (con->rect.x - old_rect->x);
uint32_t rel_y = (con->rect.y - old_rect->y);
/* Then we calculate a fraction, for example 0.63 for a window
* which is at y = 1212 of a 1920 px high output */
double fraction_x = ((double)rel_x / old_rect->width);
double fraction_y = ((double)rel_y / old_rect->height);
DLOG("rel_x = %d, rel_y = %d, fraction_x = %f, fraction_y = %f, output->w = %d, output->h = %d\n",
rel_x, rel_y, fraction_x, fraction_y, old_rect->width, old_rect->height);
con->rect.x = new_rect->x + (fraction_x * new_rect->width);
con->rect.y = new_rect->y + (fraction_y * new_rect->height);
DLOG("Resulting coordinates: x = %d, y = %d\n", con->rect.x, con->rect.y);
}
#if 0 #if 0
/* /*
* Moves the client 10px to the specified direction. * Moves the client 10px to the specified direction.

View File

@ -2,7 +2,7 @@
* vim:ts=4:sw=4:expandtab * vim:ts=4:sw=4:expandtab
* *
* i3 - an improved dynamic tiling window manager * i3 - an improved dynamic tiling window manager
* © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE) * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
* *
* For more information on RandR, please see the X.org RandR specification at * For more information on RandR, please see the X.org RandR specification at
* http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt * http://cgit.freedesktop.org/xorg/proto/randrproto/tree/randrproto.txt
@ -515,8 +515,6 @@ void init_ws_for_output(Output *output, Con *content) {
* *
*/ */
static void output_change_mode(xcb_connection_t *conn, Output *output) { static void output_change_mode(xcb_connection_t *conn, Output *output) {
//i3Font *font = load_font(conn, config.font);
DLOG("Output mode changed, updating rect\n"); DLOG("Output mode changed, updating rect\n");
assert(output->con != NULL); assert(output->con != NULL);
output->con->rect = output->rect; output->con->rect = output->rect;
@ -526,6 +524,14 @@ static void output_change_mode(xcb_connection_t *conn, Output *output) {
/* Point content to the container of the workspaces */ /* Point content to the container of the workspaces */
content = output_get_content(output->con); content = output_get_content(output->con);
/* Fix the position of all floating windows on this output.
* The 'rect' of each workspace will be updated in src/render.c. */
TAILQ_FOREACH(workspace, &(content->nodes_head), nodes) {
TAILQ_FOREACH(child, &(workspace->floating_head), floating_windows) {
floating_fix_coordinates(child, &(workspace->rect), &(output->con->rect));
}
}
/* If default_orientation is NO_ORIENTATION, we change the orientation of /* If default_orientation is NO_ORIENTATION, we change the orientation of
* the workspaces and their childs depending on output resolution. This is * the workspaces and their childs depending on output resolution. This is
* only done for workspaces with maximum one child. */ * only done for workspaces with maximum one child. */