Snap pointer to resize bar on drag resize

When the user initiates a drag resize, draw the resize bar on the border
of the two involved containers and snap the pointer.

This solution produces cleaner code than the former approach where the
caller obfuscated the click coordinates of the event. This may confuse
someone expecting a true button press event.

Fixes an issue where the resize cursor is not shown when the resize bar
is clicked until the user begins to drag the mouse.

Fixes an issue where focus is not properly updated after the drag is
complete when `focus_follows_mouse' option is set, leaving the pointer
in an unfocused window in some cases.

Fixes an issue where the resize bar may jump a few pixels when the mouse
is first moved.

(Thanks to pbos for suggesting this fix and providing an example
implementation)
This commit is contained in:
Tony Crisci
2013-12-21 14:29:22 -05:00
committed by Michael Stapelberg
parent e2ebe3e2ae
commit 69ce33d06d
2 changed files with 19 additions and 15 deletions

View File

@ -62,12 +62,7 @@ static bool tiling_resize_for_border(Con *con, border_t border, xcb_button_press
second = tmp;
}
/* We modify the X/Y position in the event so that the divider line is at
* the actual position of the border, not at the position of the click. */
const orientation_t orientation = ((border == BORDER_LEFT || border == BORDER_RIGHT) ? HORIZ : VERT);
if (orientation == HORIZ)
event->root_x = second->rect.x;
else event->root_y = second->rect.y;
resize_graphical_handler(first, second, orientation, event);