From: Michael Stapelberg Date: Wed, 24 Aug 2011 20:59:46 +0000 (+0200) Subject: Bugfix: Correctly warp floating windows when using the 'move' command X-Git-Tag: 4.0.2~25^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=698d97cd02e3b50e0e62add0bf82b2404bba40ef;p=i3%2Fi3 Bugfix: Correctly warp floating windows when using the 'move' command --- diff --git a/include/con.h b/include/con.h index 7d828408..d8bad7de 100644 --- a/include/con.h +++ b/include/con.h @@ -131,10 +131,14 @@ void con_toggle_fullscreen(Con *con, int fullscreen_mode); /** * Moves the given container to the currently focused container on the given * workspace. + * + * The dont_warp flag disables pointer warping and will be set when this + * function is called while dragging a floating window. + * * TODO: is there a better place for this function? * */ -void con_move_to_workspace(Con *con, Con *workspace); +void con_move_to_workspace(Con *con, Con *workspace, bool dont_warp); /** * Returns the orientation of the given container (for stacked containers, diff --git a/src/cmdparse.y b/src/cmdparse.y index c9e9fc7c..021b0b83 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -699,7 +699,7 @@ move: TAILQ_FOREACH(current, &owindows, owindows) { printf("matching: %p / %s\n", current->con, current->con->name); - con_move_to_workspace(current->con, ws); + con_move_to_workspace(current->con, ws, false); } tree_render(); diff --git a/src/con.c b/src/con.c index 497cb1d3..a115ad7b 100644 --- a/src/con.c +++ b/src/con.c @@ -540,10 +540,14 @@ update_netwm_state: /* * Moves the given container to the currently focused container on the given * workspace. + * + * The dont_warp flag disables pointer warping and will be set when this + * function is called while dragging a floating window. + * * TODO: is there a better place for this function? * */ -void con_move_to_workspace(Con *con, Con *workspace) { +void con_move_to_workspace(Con *con, Con *workspace, bool dont_warp) { if (con->type == CT_WORKSPACE) { DLOG("Moving workspaces is not yet implemented.\n"); return; @@ -602,9 +606,9 @@ void con_move_to_workspace(Con *con, Con *workspace) { con->rect.y = dest_output->rect.y + rel_y; } - /* Unset warp_to if target con is floating. Otherwise, set warp_to to - * current target container. */ - if (con->type == CT_FLOATING_CON) + /* Don’t warp if told so (when dragging floating windows with the + * mouse for example) */ + if (dont_warp) x_set_warp_to(NULL); else x_set_warp_to(&(con->rect)); diff --git a/src/floating.c b/src/floating.c index a5ce1841..8718ee01 100644 --- a/src/floating.c +++ b/src/floating.c @@ -282,7 +282,7 @@ bool floating_maybe_reassign_ws(Con *con) { Con *content = output_get_content(output->con); Con *ws = TAILQ_FIRST(&(content->focus_head)); DLOG("Moving con %p / %s to workspace %p / %s\n", con, con->name, ws, ws->name); - con_move_to_workspace(con, ws); + con_move_to_workspace(con, ws, true); con_focus(con_descend_focused(con)); return true; }