From: Orestis Floros Date: Sun, 18 Mar 2018 00:41:12 +0000 (+0200) Subject: cmd_move_window_to_position: improve error message X-Git-Tag: 4.16~123^2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5e8a3f3f0cd2a986b721e1480831ca5ff80713c5;p=i3%2Fi3 cmd_move_window_to_position: improve error message --- diff --git a/include/floating.h b/include/floating.h index babfafc9..4382437b 100644 --- a/include/floating.h +++ b/include/floating.h @@ -143,7 +143,7 @@ drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event, * outputs. * */ -void floating_reposition(Con *con, Rect newrect); +bool floating_reposition(Con *con, Rect newrect); /** * Sets size of the CT_FLOATING_CON to specified dimensions. Might limit the diff --git a/src/commands.c b/src/commands.c index b62daad9..98625a91 100644 --- a/src/commands.c +++ b/src/commands.c @@ -1718,10 +1718,12 @@ void cmd_move_window_to_position(I3_CMD, long x, long y) { newrect.x = x; newrect.y = y; - floating_reposition(current->con->parent, newrect); + if (!floating_reposition(current->con->parent, newrect)) { + yerror("Cannot move window/container out of bounds."); + has_error = true; + } } - // XXX: default reply for now, make this a better reply if (!has_error) ysuccess(true); } diff --git a/src/floating.c b/src/floating.c index e958153d..2130d673 100644 --- a/src/floating.c +++ b/src/floating.c @@ -864,12 +864,12 @@ drag_result_t drag_pointer(Con *con, const xcb_button_press_event_t *event, xcb_ * outputs. * */ -void floating_reposition(Con *con, Rect newrect) { +bool floating_reposition(Con *con, Rect newrect) { /* Sanity check: Are the new coordinates on any output? If not, we * ignore that request. */ if (!contained_by_output(newrect)) { ELOG("No output found at destination coordinates. Not repositioning.\n"); - return; + return false; } con->rect = newrect; @@ -881,6 +881,7 @@ void floating_reposition(Con *con, Rect newrect) { con->scratchpad_state = SCRATCHPAD_CHANGED; tree_render(); + return true; } /*