|
@@ -80,6 +80,13 @@ static int resize_id = -1;
|
|
|
static int resize_edges; /* WM_EDGE_* bits captured at the press */
|
|
static int resize_edges; /* WM_EDGE_* bits captured at the press */
|
|
|
static int resize_ox, resize_oy;
|
|
static int resize_ox, resize_oy;
|
|
|
static unsigned int resize_mx, resize_my, resize_ow, resize_oh;
|
|
static unsigned int resize_mx, resize_my, resize_ow, resize_oh;
|
|
|
|
|
+/* A live resize step reallocates both canvases and wakes the client to
|
|
|
|
|
+ * reflow, so pointer-rate commits starve it (and make the content blink).
|
|
|
|
|
+ * Commit when the edge moved at least WM_RESIZE_MIN_STEP pixels, else at
|
|
|
|
|
+ * most every WM_RESIZE_COMMIT_MS; the button release forces the final one. */
|
|
|
|
|
+#define WM_RESIZE_COMMIT_MS 30
|
|
|
|
|
+#define WM_RESIZE_MIN_STEP 8
|
|
|
|
|
+static unsigned int resize_last_ms;
|
|
|
static unsigned int last_title_ms;
|
|
static unsigned int last_title_ms;
|
|
|
static int last_title_id = -1, last_title_x, last_title_y;
|
|
static int last_title_id = -1, last_title_x, last_title_y;
|
|
|
static unsigned int prev_buttons;
|
|
static unsigned int prev_buttons;
|
|
@@ -1518,7 +1525,8 @@ static int set_window_geometry(struct uwin *u, unsigned int idx,
|
|
|
|
|
|
|
|
if ((int)nw != (int)ow || (int)nh != (int)oh) {
|
|
if ((int)nw != (int)ow || (int)nh != (int)oh) {
|
|
|
if (u_wm_resize(idx, nw - 2 * WM_BORDER_W,
|
|
if (u_wm_resize(idx, nw - 2 * WM_BORDER_W,
|
|
|
- nh - WM_TITLE_H - 2 * WM_BORDER_W) != 0)
|
|
|
|
|
|
|
+ nh - WM_TITLE_H - 2 * WM_BORDER_W,
|
|
|
|
|
+ nx - ox, ny - oy) != 0)
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
if (nx != ox || ny != oy)
|
|
if (nx != ox || ny != oy)
|
|
@@ -2845,9 +2853,11 @@ static void dock_capture_update(unsigned int mx, unsigned int my,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* Apply one edge-drag step. The grabbed edges follow the pointer while the
|
|
/* Apply one edge-drag step. The grabbed edges follow the pointer while the
|
|
|
- * opposite edges stay put; the work area clamps the active edges. */
|
|
|
|
|
|
|
+ * opposite edges stay put; the work area clamps the active edges. `force`
|
|
|
|
|
+ * commits the geometry even when the throttle would still defer it (button
|
|
|
|
|
+ * release). */
|
|
|
static void resize_window_drag(struct uwin *u, unsigned int idx,
|
|
static void resize_window_drag(struct uwin *u, unsigned int idx,
|
|
|
- unsigned int mx, unsigned int my)
|
|
|
|
|
|
|
+ unsigned int mx, unsigned int my, int force)
|
|
|
{
|
|
{
|
|
|
int dx = (int)mx - (int)resize_mx;
|
|
int dx = (int)mx - (int)resize_mx;
|
|
|
int dy = (int)my - (int)resize_my;
|
|
int dy = (int)my - (int)resize_my;
|
|
@@ -2856,6 +2866,7 @@ static void resize_window_drag(struct uwin *u, unsigned int idx,
|
|
|
int top = resize_oy;
|
|
int top = resize_oy;
|
|
|
int bottom = resize_oy + (int)resize_oh;
|
|
int bottom = resize_oy + (int)resize_oh;
|
|
|
int nx, ny, nw, nh;
|
|
int nx, ny, nw, nh;
|
|
|
|
|
+ unsigned int now;
|
|
|
|
|
|
|
|
if (resize_edges & WM_EDGE_LEFT) {
|
|
if (resize_edges & WM_EDGE_LEFT) {
|
|
|
left = resize_ox + dx;
|
|
left = resize_ox + dx;
|
|
@@ -2904,6 +2915,13 @@ static void resize_window_drag(struct uwin *u, unsigned int idx,
|
|
|
if (nx == u->info.x && ny == u->info.y &&
|
|
if (nx == u->info.x && ny == u->info.y &&
|
|
|
nw == (int)u->info.w && nh == (int)u->info.h)
|
|
nw == (int)u->info.w && nh == (int)u->info.h)
|
|
|
return;
|
|
return;
|
|
|
|
|
+ now = u_ticks_ms();
|
|
|
|
|
+ if (!force &&
|
|
|
|
|
+ (unsigned int)(now - resize_last_ms) < WM_RESIZE_COMMIT_MS &&
|
|
|
|
|
+ iabs(nw - (int)u->info.w) < WM_RESIZE_MIN_STEP &&
|
|
|
|
|
+ iabs(nh - (int)u->info.h) < WM_RESIZE_MIN_STEP)
|
|
|
|
|
+ return;
|
|
|
|
|
+ resize_last_ms = now;
|
|
|
if (set_window_geometry(u, idx, nx, ny, (unsigned int)nw,
|
|
if (set_window_geometry(u, idx, nx, ny, (unsigned int)nw,
|
|
|
(unsigned int)nh) == 0)
|
|
(unsigned int)nh) == 0)
|
|
|
u->state = WIN_NORMAL;
|
|
u->state = WIN_NORMAL;
|
|
@@ -2923,6 +2941,7 @@ static void begin_resize(unsigned int idx, int edges, unsigned int mx,
|
|
|
resize_oy = u->info.y;
|
|
resize_oy = u->info.y;
|
|
|
resize_ow = u->info.w;
|
|
resize_ow = u->info.w;
|
|
|
resize_oh = u->info.h;
|
|
resize_oh = u->info.h;
|
|
|
|
|
+ resize_last_ms = u_ticks_ms() - WM_RESIZE_COMMIT_MS;
|
|
|
u_wm_mouse_capture(1);
|
|
u_wm_mouse_capture(1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -3080,7 +3099,7 @@ static void handle_mouse(struct wm_status *st)
|
|
|
struct uwin *u = &wins[resize_id];
|
|
struct uwin *u = &wins[resize_id];
|
|
|
|
|
|
|
|
if (u->info.used)
|
|
if (u->info.used)
|
|
|
- resize_window_drag(u, (unsigned int)resize_id, mx, my);
|
|
|
|
|
|
|
+ resize_window_drag(u, (unsigned int)resize_id, mx, my, 0);
|
|
|
else {
|
|
else {
|
|
|
resize_id = -1;
|
|
resize_id = -1;
|
|
|
u_wm_mouse_capture(0);
|
|
u_wm_mouse_capture(0);
|
|
@@ -3159,6 +3178,11 @@ static void handle_mouse(struct wm_status *st)
|
|
|
u_wm_mouse_capture(0);
|
|
u_wm_mouse_capture(0);
|
|
|
}
|
|
}
|
|
|
} else if (!down && was) {
|
|
} else if (!down && was) {
|
|
|
|
|
+ /* A throttled resize may still be behind the last pointer
|
|
|
|
|
+ * position; commit the final geometry before dropping it. */
|
|
|
|
|
+ if (resize_id >= 0 && wins[resize_id].info.used)
|
|
|
|
|
+ resize_window_drag(&wins[resize_id],
|
|
|
|
|
+ (unsigned int)resize_id, mx, my, 1);
|
|
|
/* Dropping a window with the pointer on the left/right screen
|
|
/* Dropping a window with the pointer on the left/right screen
|
|
|
* edge snaps it to that half; on the top edge it maximizes. */
|
|
* edge snaps it to that half; on the top edge it maximizes. */
|
|
|
if (drag_id >= 0 && drag_moved && wins[drag_id].info.used &&
|
|
if (drag_id >= 0 && drag_moved && wins[drag_id].info.used &&
|