diff --git a/include/floating.h b/include/floating.h index e97029f5..b6c7c6e3 100644 --- a/include/floating.h +++ b/include/floating.h @@ -137,4 +137,13 @@ void drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_window_t confine_to, border_t border, callback_t callback, const void *extra); +/** + * Repositions the CT_FLOATING_CON to have the coordinates specified by + * newrect, but only if the coordinates are not out-of-bounds. Also reassigns + * the floating con to a different workspace if this move was across different + * outputs. + * + */ +void floating_reposition(Con *con, Rect newrect); + #endif diff --git a/src/cmdparse.y b/src/cmdparse.y index 652f6adc..7f86c8db 100644 --- a/src/cmdparse.y +++ b/src/cmdparse.y @@ -780,20 +780,21 @@ move: printf("moving in direction %d\n", direction); if (con_is_floating(focused)) { printf("floating move with %d pixels\n", px); + Rect newrect = focused->parent->rect; if (direction == TOK_LEFT) { - focused->parent->rect.x -= px; + newrect.x -= px; } else if (direction == TOK_RIGHT) { - focused->parent->rect.x += px; + newrect.x += px; } else if (direction == TOK_UP) { - focused->parent->rect.y -= px; + newrect.y -= px; } else if (direction == TOK_DOWN) { - focused->parent->rect.y += px; + newrect.y += px; } + floating_reposition(focused->parent, newrect); } else { tree_move(direction); + tree_render(); } - - tree_render(); } | TOK_MOVE TOK_WORKSPACE STR { diff --git a/src/floating.c b/src/floating.c index 90e5024e..d86ee2c0 100644 --- a/src/floating.c +++ b/src/floating.c @@ -514,6 +514,31 @@ void drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_window_t xcb_flush(conn); } +/* + * Repositions the CT_FLOATING_CON to have the coordinates specified by + * newrect, but only if the coordinates are not out-of-bounds. Also reassigns + * the floating con to a different workspace if this move was across different + * outputs. + * + */ +void floating_reposition(Con *con, Rect newrect) { + /* Sanity check: Are the new coordinates on any output? If not, we + * ignore that request. */ + Output *output = get_output_containing( + newrect.x + (newrect.width / 2), + newrect.y + (newrect.height / 2)); + + if (!output) { + ELOG("No output found at destination coordinates. Not repositioning.\n"); + return; + } + + con->rect = newrect; + + floating_maybe_reassign_ws(con); + tree_render(); +} + #if 0 /* * Moves the client 10px to the specified direction. diff --git a/src/handlers.c b/src/handlers.c index 61a2e175..69c1831d 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -400,23 +400,9 @@ static int handle_configure_request(xcb_configure_request_event_t *event) { event->height, newrect.height, con->border_width); } - /* Sanity check: Are the new coordinates on any output? If not, we - * ignore that request. */ - Output *output = get_output_containing( - newrect.x + (newrect.width / 2), - newrect.y + (newrect.height / 2)); - - if (!output) { - ELOG("No output found at destination coordinates. Ignoring this ConfigureRequest.\n"); - fake_absolute_configure_notify(con); - return 0; - } - DLOG("Container is a floating leaf node, will do that.\n"); - floatingcon->rect = newrect; - - floating_maybe_reassign_ws(floatingcon); - tree_render(); + floating_reposition(floatingcon, newrect); + return 1; } /* Dock windows can be reconfigured in their height */