Implement drag cancel for resizing floating windows
Patch status: needinfo
Patch by Tony Crisci
Long description:
Hi, I am a new developer and this is my first code submission to a project. If I do anything wrong, please let me know. The patches I've submitted implement #1074 "Add ability to escape out of a mouse-resize operation".
To apply this patch, use:
curl http://cr.i3wm.org/patch/235/raw.patch | git am
b/src/floating.c
18 |
@@ -554,7 +554,15 @@ void floating_resize_window(Con *con, const bool proportional, |
19 |
|
20 |
struct resize_window_callback_params params = { corner, proportional, event }; |
21 |
|
22 |
- drag_pointer(con, event, XCB_NONE, BORDER_TOP /* irrelevant */, cursor, resize_window_callback, ¶ms); |
23 |
+ /* get the initial rect in case of cancel */ |
24 |
+ struct Rect initial_rect = con->rect; |
25 |
+ |
26 |
+ int drag_result = drag_pointer(con, event, XCB_NONE, BORDER_TOP /* irrelevant */, cursor, resize_window_callback, ¶ms); |
27 |
+ |
28 |
+ /* If the user cancels, undo the resize */ |
29 |
+ if (drag_result == 1) { |
30 |
+ floating_reposition(con, initial_rect); |
31 |
+ } |
32 |
|
33 |
/* If this is a scratchpad window, don't auto center it from now on. */ |
34 |
if (con->scratchpad_state == SCRATCHPAD_FRESH) |