|
@@ -8,8 +8,9 @@
|
|
|
#include "version.h"
|
|
#include "version.h"
|
|
|
|
|
|
|
|
#define COL_BG 0x202030u
|
|
#define COL_BG 0x202030u
|
|
|
-#define COL_BORDER 0xC8C8C8u
|
|
|
|
|
-#define COL_TITLE_ON 0x465A96u
|
|
|
|
|
|
|
+/* The active title bar uses the toolkit highlight (ngui_theme_dark.selection);
|
|
|
|
|
+ * the inactive one stays neutral. Windows have no visible frame. */
|
|
|
|
|
+#define COL_TITLE_ON 0x365CA6u
|
|
|
#define COL_TITLE_OFF 0x646464u
|
|
#define COL_TITLE_OFF 0x646464u
|
|
|
#define COL_CLOSE 0xC64040u
|
|
#define COL_CLOSE 0xC64040u
|
|
|
#define COL_WHITE 0xFFFFFFu
|
|
#define COL_WHITE 0xFFFFFFu
|
|
@@ -57,6 +58,8 @@ static int drag_dx, drag_dy;
|
|
|
static int drag_mx, drag_my; /* press position, for restore-on-drag */
|
|
static int drag_mx, drag_my; /* press position, for restore-on-drag */
|
|
|
static int drag_moved; /* the pointer passed WM_DRAG_START */
|
|
static int drag_moved; /* the pointer passed WM_DRAG_START */
|
|
|
static int resize_id = -1;
|
|
static int resize_id = -1;
|
|
|
|
|
+static int resize_edges; /* WM_EDGE_* bits captured at the press */
|
|
|
|
|
+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;
|
|
|
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;
|
|
@@ -621,10 +624,10 @@ static void draw_window_clip(unsigned int idx, int cx, int cy,
|
|
|
struct uwin *u = &wins[idx];
|
|
struct uwin *u = &wins[idx];
|
|
|
struct wm_window_info *w = &u->info;
|
|
struct wm_window_info *w = &u->info;
|
|
|
int x = w->x, y = w->y;
|
|
int x = w->x, y = w->y;
|
|
|
- unsigned int pw = w->w, ph = w->h;
|
|
|
|
|
- int bx = x + (int)pw - 1 - WM_CLOSE_W;
|
|
|
|
|
- int cony = y + 1 + WM_TITLE_H;
|
|
|
|
|
- int content_x = x + 1;
|
|
|
|
|
|
|
+ unsigned int pw = w->w;
|
|
|
|
|
+ int bx = x + (int)pw - WM_BORDER_W - WM_CLOSE_W;
|
|
|
|
|
+ int cony = y + WM_BORDER_W + WM_TITLE_H;
|
|
|
|
|
+ int content_x = x + WM_BORDER_W;
|
|
|
unsigned int content_w = w->content_w;
|
|
unsigned int content_w = w->content_w;
|
|
|
unsigned int content_h = w->content_h;
|
|
unsigned int content_h = w->content_h;
|
|
|
|
|
|
|
@@ -633,15 +636,13 @@ static void draw_window_clip(unsigned int idx, int cx, int cy,
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /* Border, title bar, close button. */
|
|
|
|
|
- fill_clip(x, y, pw, ph, COL_BORDER, cx, cy, cw, ch);
|
|
|
|
|
- fill_clip(x + 1, y + 1, pw - 2, WM_TITLE_H,
|
|
|
|
|
|
|
+ /* Title bar and close button; windows have no visible frame. */
|
|
|
|
|
+ fill_clip(x, y, pw, WM_TITLE_H,
|
|
|
w->focused ? COL_TITLE_ON : COL_TITLE_OFF, cx, cy, cw, ch);
|
|
w->focused ? COL_TITLE_ON : COL_TITLE_OFF, cx, cy, cw, ch);
|
|
|
- usurf_text(&screen, x + 4, y + 3, w->title, COL_WHITE,
|
|
|
|
|
|
|
+ usurf_text(&screen, x + 3, y + 2, w->title, COL_WHITE,
|
|
|
cx, cy, cw, ch);
|
|
cx, cy, cw, ch);
|
|
|
- fill_clip(bx, y + 1, WM_CLOSE_W, WM_TITLE_H, COL_CLOSE,
|
|
|
|
|
- cx, cy, cw, ch);
|
|
|
|
|
- usurf_text(&screen, bx + 4, y + 3, "x", COL_WHITE,
|
|
|
|
|
|
|
+ fill_clip(bx, y, WM_CLOSE_W, WM_TITLE_H, COL_CLOSE, cx, cy, cw, ch);
|
|
|
|
|
+ usurf_text(&screen, bx + 4, y + 2, "x", COL_WHITE,
|
|
|
cx, cy, cw, ch);
|
|
cx, cy, cw, ch);
|
|
|
|
|
|
|
|
/* Content: every window presents an RGB565 canvas (the terminal
|
|
/* Content: every window presents an RGB565 canvas (the terminal
|
|
@@ -663,20 +664,6 @@ static void draw_window_clip(unsigned int idx, int cx, int cy,
|
|
|
fill_clip(content_x, cony, content_w, content_h,
|
|
fill_clip(content_x, cony, content_w, content_h,
|
|
|
0x000000u, cx, cy, cw, ch);
|
|
0x000000u, cx, cy, cw, ch);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- /* Resize grip (bottom-right corner). */
|
|
|
|
|
- if (w->focused) {
|
|
|
|
|
- unsigned int i;
|
|
|
|
|
-
|
|
|
|
|
- for (i = 0; i < 10; i++) {
|
|
|
|
|
- fill_clip(x + (int)pw - 3 - (int)i,
|
|
|
|
|
- y + (int)ph - 4, 1, 1, 0xD2D2D2u,
|
|
|
|
|
- cx, cy, cw, ch);
|
|
|
|
|
- fill_clip(x + (int)pw - 4,
|
|
|
|
|
- y + (int)ph - 3 - (int)i, 1, 1, 0xD2D2D2u,
|
|
|
|
|
- cx, cy, cw, ch);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* Front-to-back window order: popovers float above everything, then the
|
|
/* Front-to-back window order: popovers float above everything, then the
|
|
@@ -860,34 +847,95 @@ static void draw_rect(int x, int y, unsigned int w, unsigned int h)
|
|
|
draw_rect_naive(dmg.x, dmg.y, dmg.w, dmg.h);
|
|
draw_rect_naive(dmg.x, dmg.y, dmg.w, dmg.h);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static int window_at(int mx, int my)
|
|
|
|
|
|
|
+/* Invisible resize border: edge bits for a point in the band around the
|
|
|
|
|
+ * window's outer edge (WM_RESIZE_IN px inside and WM_RESIZE_OUT px outside).
|
|
|
|
|
+ * Popovers have no chrome and never resize. */
|
|
|
|
|
+#define WM_EDGE_LEFT 1
|
|
|
|
|
+#define WM_EDGE_RIGHT 2
|
|
|
|
|
+#define WM_EDGE_TOP 4
|
|
|
|
|
+#define WM_EDGE_BOTTOM 8
|
|
|
|
|
+
|
|
|
|
|
+static int resize_edges_at(const struct uwin *u, int mx, int my)
|
|
|
|
|
+{
|
|
|
|
|
+ const struct wm_window_info *w = &u->info;
|
|
|
|
|
+ int l = w->x, t = w->y;
|
|
|
|
|
+ int r = l + (int)w->w, b = t + (int)w->h;
|
|
|
|
|
+ int near_x, near_y, e = 0;
|
|
|
|
|
+
|
|
|
|
|
+ if (w->popover)
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ near_x = mx >= l - WM_RESIZE_OUT && mx < r + WM_RESIZE_OUT;
|
|
|
|
|
+ near_y = my >= t - WM_RESIZE_OUT && my < b + WM_RESIZE_OUT;
|
|
|
|
|
+ if (near_y && mx >= l - WM_RESIZE_OUT && mx < l + WM_RESIZE_IN)
|
|
|
|
|
+ e |= WM_EDGE_LEFT;
|
|
|
|
|
+ if (near_y && mx >= r - WM_RESIZE_IN && mx < r + WM_RESIZE_OUT)
|
|
|
|
|
+ e |= WM_EDGE_RIGHT;
|
|
|
|
|
+ if (near_x && my >= t - WM_RESIZE_OUT && my < t + WM_RESIZE_IN)
|
|
|
|
|
+ e |= WM_EDGE_TOP;
|
|
|
|
|
+ if (near_x && my >= b - WM_RESIZE_IN && my < b + WM_RESIZE_OUT)
|
|
|
|
|
+ e |= WM_EDGE_BOTTOM;
|
|
|
|
|
+ return e;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* Topmost window at (mx,my): its resize band when the point is inside one,
|
|
|
|
|
+ * otherwise the window rectangle. *edges is 0 for a plain rectangle hit.
|
|
|
|
|
+ * Bands are not considered inside the top bar, which the WM owns. */
|
|
|
|
|
+static int resize_hit(int mx, int my, int *edges)
|
|
|
{
|
|
{
|
|
|
int order[WM_MAX_WINDOWS];
|
|
int order[WM_MAX_WINDOWS];
|
|
|
unsigned int n = build_order(order), i;
|
|
unsigned int n = build_order(order), i;
|
|
|
|
|
|
|
|
|
|
+ *edges = 0;
|
|
|
for (i = 0; i < n; i++) {
|
|
for (i = 0; i < n; i++) {
|
|
|
- struct wm_window_info *w = &wins[order[i]].info;
|
|
|
|
|
|
|
+ struct uwin *u = &wins[order[i]];
|
|
|
|
|
+ int e = 0;
|
|
|
|
|
|
|
|
- if (!w->popover)
|
|
|
|
|
|
|
+ if (!u->info.used)
|
|
|
continue;
|
|
continue;
|
|
|
- if (mx >= w->x && my >= w->y &&
|
|
|
|
|
- mx < w->x + (int)w->w &&
|
|
|
|
|
- my < w->y + (int)w->h)
|
|
|
|
|
|
|
+ if (my >= WM_BAR_H)
|
|
|
|
|
+ e = resize_edges_at(u, mx, my);
|
|
|
|
|
+ if (e) {
|
|
|
|
|
+ *edges = e;
|
|
|
return order[i];
|
|
return order[i];
|
|
|
- }
|
|
|
|
|
- for (i = 0; i < n; i++) {
|
|
|
|
|
- struct wm_window_info *w = &wins[order[i]].info;
|
|
|
|
|
-
|
|
|
|
|
- if (w->popover)
|
|
|
|
|
- continue;
|
|
|
|
|
- if (mx >= w->x && my >= w->y &&
|
|
|
|
|
- mx < w->x + (int)w->w &&
|
|
|
|
|
- my < w->y + (int)w->h)
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ if (mx >= u->info.x && my >= u->info.y &&
|
|
|
|
|
+ mx < u->info.x + (int)u->info.w &&
|
|
|
|
|
+ my < u->info.y + (int)u->info.h)
|
|
|
return order[i];
|
|
return order[i];
|
|
|
}
|
|
}
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static int resize_cursor(int edges)
|
|
|
|
|
+{
|
|
|
|
|
+ switch (edges) {
|
|
|
|
|
+ case WM_EDGE_LEFT:
|
|
|
|
|
+ case WM_EDGE_RIGHT:
|
|
|
|
|
+ return CURSOR_EW_RESIZE;
|
|
|
|
|
+ case WM_EDGE_TOP:
|
|
|
|
|
+ case WM_EDGE_BOTTOM:
|
|
|
|
|
+ return CURSOR_NS_RESIZE;
|
|
|
|
|
+ case WM_EDGE_LEFT | WM_EDGE_TOP:
|
|
|
|
|
+ case WM_EDGE_RIGHT | WM_EDGE_BOTTOM:
|
|
|
|
|
+ return CURSOR_NWSE_RESIZE;
|
|
|
|
|
+ case WM_EDGE_RIGHT | WM_EDGE_TOP:
|
|
|
|
|
+ case WM_EDGE_LEFT | WM_EDGE_BOTTOM:
|
|
|
|
|
+ return CURSOR_NESW_RESIZE;
|
|
|
|
|
+ default:
|
|
|
|
|
+ return CURSOR_DEFAULT;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* Close button hit area (the top-right WM_CLOSE_W columns of the title bar). */
|
|
|
|
|
+static int close_hit(const struct wm_window_info *w, int mx, int my)
|
|
|
|
|
+{
|
|
|
|
|
+ if (w->popover)
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ return mx >= w->x + (int)w->w - WM_CLOSE_W &&
|
|
|
|
|
+ mx < w->x + (int)w->w &&
|
|
|
|
|
+ my >= w->y && my < w->y + WM_TITLE_H;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
static void clamp_geom(struct uwin *u, int *x, int *y)
|
|
static void clamp_geom(struct uwin *u, int *x, int *y)
|
|
|
{
|
|
{
|
|
|
/* Match wm_clamp_window(): allow the window to hang off the left,
|
|
/* Match wm_clamp_window(): allow the window to hang off the left,
|
|
@@ -896,7 +944,7 @@ static void clamp_geom(struct uwin *u, int *x, int *y)
|
|
|
int minx = WM_DRAG_VISIBLE - (int)u->info.w;
|
|
int minx = WM_DRAG_VISIBLE - (int)u->info.w;
|
|
|
int maxx = (int)fbw - WM_DRAG_VISIBLE;
|
|
int maxx = (int)fbw - WM_DRAG_VISIBLE;
|
|
|
int miny = WM_BAR_H;
|
|
int miny = WM_BAR_H;
|
|
|
- int maxy = (int)fbh - WM_TITLE_H;
|
|
|
|
|
|
|
+ int maxy = (int)fbh - WM_BORDER_W - WM_TITLE_H;
|
|
|
|
|
|
|
|
if (minx > maxx)
|
|
if (minx > maxx)
|
|
|
minx = maxx = 0;
|
|
minx = maxx = 0;
|
|
@@ -1120,7 +1168,8 @@ static int set_window_geometry(struct uwin *u, unsigned int idx,
|
|
|
unsigned int ow = u->info.w, oh = u->info.h;
|
|
unsigned int ow = u->info.w, oh = u->info.h;
|
|
|
|
|
|
|
|
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, nh - WM_TITLE_H - 2) != 0)
|
|
|
|
|
|
|
+ if (u_wm_resize(idx, nw - 2 * WM_BORDER_W,
|
|
|
|
|
+ nh - WM_TITLE_H - 2 * WM_BORDER_W) != 0)
|
|
|
return -1;
|
|
return -1;
|
|
|
}
|
|
}
|
|
|
if (nx != ox || ny != oy)
|
|
if (nx != ox || ny != oy)
|
|
@@ -1572,8 +1621,8 @@ static void do_update(struct wm_status *st)
|
|
|
continue;
|
|
continue;
|
|
|
if (!w->dmg_w || !w->dmg_h)
|
|
if (!w->dmg_w || !w->dmg_h)
|
|
|
continue;
|
|
continue;
|
|
|
- rx = w->x + (w->popover ? 0 : 1) + (int)w->dmg_x;
|
|
|
|
|
- ry = w->y + (w->popover ? 0 : 1 + WM_TITLE_H) +
|
|
|
|
|
|
|
+ rx = w->x + (w->popover ? 0 : WM_BORDER_W) + (int)w->dmg_x;
|
|
|
|
|
+ ry = w->y + (w->popover ? 0 : WM_BORDER_W + WM_TITLE_H) +
|
|
|
(int)w->dmg_y;
|
|
(int)w->dmg_y;
|
|
|
rw = w->dmg_w;
|
|
rw = w->dmg_w;
|
|
|
rh = w->dmg_h;
|
|
rh = w->dmg_h;
|
|
@@ -1750,17 +1799,100 @@ static int bar_launcher_hit(unsigned int mx, unsigned int my)
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/* The WM's cursor override (SYS_WM_SET_CURSOR): resize arrows on the grip
|
|
|
|
|
- * and while resizing, the move cross while a title-bar drag is under way,
|
|
|
|
|
- * a hand over the launchers and the status area. Everywhere else the
|
|
|
|
|
- * kernel picks the window's own content cursor (or the arrow). */
|
|
|
|
|
|
|
+/* Apply one edge-drag step. The grabbed edges follow the pointer while the
|
|
|
|
|
+ * opposite edges stay put; the work area clamps the active edges. */
|
|
|
|
|
+static void resize_window_drag(struct uwin *u, unsigned int idx,
|
|
|
|
|
+ unsigned int mx, unsigned int my)
|
|
|
|
|
+{
|
|
|
|
|
+ int dx = (int)mx - (int)resize_mx;
|
|
|
|
|
+ int dy = (int)my - (int)resize_my;
|
|
|
|
|
+ int left = resize_ox;
|
|
|
|
|
+ int right = resize_ox + (int)resize_ow;
|
|
|
|
|
+ int top = resize_oy;
|
|
|
|
|
+ int bottom = resize_oy + (int)resize_oh;
|
|
|
|
|
+ int nx, ny, nw, nh;
|
|
|
|
|
+
|
|
|
|
|
+ if (resize_edges & WM_EDGE_LEFT) {
|
|
|
|
|
+ left = resize_ox + dx;
|
|
|
|
|
+ if (left < 0)
|
|
|
|
|
+ left = 0;
|
|
|
|
|
+ } else if (resize_edges & WM_EDGE_RIGHT) {
|
|
|
|
|
+ right = resize_ox + (int)resize_ow + dx;
|
|
|
|
|
+ if (right > (int)fbw)
|
|
|
|
|
+ right = (int)fbw;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (resize_edges & WM_EDGE_TOP) {
|
|
|
|
|
+ top = resize_oy + dy;
|
|
|
|
|
+ if (top < WM_BAR_H)
|
|
|
|
|
+ top = WM_BAR_H;
|
|
|
|
|
+ } else if (resize_edges & WM_EDGE_BOTTOM) {
|
|
|
|
|
+ bottom = resize_oy + (int)resize_oh + dy;
|
|
|
|
|
+ if (bottom > (int)fbh)
|
|
|
|
|
+ bottom = (int)fbh;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ((resize_edges & (WM_EDGE_LEFT | WM_EDGE_RIGHT)) &&
|
|
|
|
|
+ right - left < 200) {
|
|
|
|
|
+ if (resize_edges & WM_EDGE_LEFT)
|
|
|
|
|
+ left = right - 200;
|
|
|
|
|
+ else
|
|
|
|
|
+ right = left + 200;
|
|
|
|
|
+ }
|
|
|
|
|
+ if ((resize_edges & (WM_EDGE_TOP | WM_EDGE_BOTTOM)) &&
|
|
|
|
|
+ bottom - top < 140) {
|
|
|
|
|
+ if (resize_edges & WM_EDGE_TOP)
|
|
|
|
|
+ top = bottom - 140;
|
|
|
|
|
+ else
|
|
|
|
|
+ bottom = top + 140;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (left < 0)
|
|
|
|
|
+ left = 0;
|
|
|
|
|
+ if (top < WM_BAR_H)
|
|
|
|
|
+ top = WM_BAR_H;
|
|
|
|
|
+ nx = left;
|
|
|
|
|
+ ny = top;
|
|
|
|
|
+ nw = right - left;
|
|
|
|
|
+ nh = bottom - top;
|
|
|
|
|
+ if (nw > (int)fbw)
|
|
|
|
|
+ nw = (int)fbw;
|
|
|
|
|
+ if (nh > (int)fbh - WM_BAR_H)
|
|
|
|
|
+ nh = (int)fbh - WM_BAR_H;
|
|
|
|
|
+ if (nx == u->info.x && ny == u->info.y &&
|
|
|
|
|
+ nw == (int)u->info.w && nh == (int)u->info.h)
|
|
|
|
|
+ return;
|
|
|
|
|
+ if (set_window_geometry(u, idx, nx, ny, (unsigned int)nw,
|
|
|
|
|
+ (unsigned int)nh) == 0)
|
|
|
|
|
+ u->state = WIN_NORMAL;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* Capture the pointer for an edge resize that started at (mx,my). */
|
|
|
|
|
+static void begin_resize(unsigned int idx, int edges, unsigned int mx,
|
|
|
|
|
+ unsigned int my)
|
|
|
|
|
+{
|
|
|
|
|
+ struct uwin *u = &wins[idx];
|
|
|
|
|
+
|
|
|
|
|
+ resize_id = (int)idx;
|
|
|
|
|
+ resize_edges = edges;
|
|
|
|
|
+ resize_mx = mx;
|
|
|
|
|
+ resize_my = my;
|
|
|
|
|
+ resize_ox = u->info.x;
|
|
|
|
|
+ resize_oy = u->info.y;
|
|
|
|
|
+ resize_ow = u->info.w;
|
|
|
|
|
+ resize_oh = u->info.h;
|
|
|
|
|
+ u_wm_mouse_capture(1);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* The WM's cursor override (SYS_WM_SET_CURSOR): resize arrows on the
|
|
|
|
|
+ * invisible resize border and while resizing, the move cross while a
|
|
|
|
|
+ * title-bar drag is under way, a hand over the launchers and the status
|
|
|
|
|
+ * area. Everywhere else the kernel picks the window's own content cursor
|
|
|
|
|
+ * (or the arrow). */
|
|
|
static void update_cursor(unsigned int mx, unsigned int my)
|
|
static void update_cursor(unsigned int mx, unsigned int my)
|
|
|
{
|
|
{
|
|
|
static int current = CURSOR_NO_OVERRIDE;
|
|
static int current = CURSOR_NO_OVERRIDE;
|
|
|
int want = CURSOR_NO_OVERRIDE;
|
|
int want = CURSOR_NO_OVERRIDE;
|
|
|
|
|
|
|
|
if (resize_id >= 0) {
|
|
if (resize_id >= 0) {
|
|
|
- want = CURSOR_NWSE_RESIZE;
|
|
|
|
|
|
|
+ want = resize_cursor(resize_edges);
|
|
|
} else if (drag_id >= 0) {
|
|
} else if (drag_id >= 0) {
|
|
|
if (drag_moved)
|
|
if (drag_moved)
|
|
|
want = CURSOR_MOVE;
|
|
want = CURSOR_MOVE;
|
|
@@ -1768,12 +1900,12 @@ static void update_cursor(unsigned int mx, unsigned int my)
|
|
|
if (bar_launcher_hit(mx, my) || bar_status_hit(mx, my))
|
|
if (bar_launcher_hit(mx, my) || bar_status_hit(mx, my))
|
|
|
want = CURSOR_POINTER;
|
|
want = CURSOR_POINTER;
|
|
|
} else {
|
|
} else {
|
|
|
- int idx = window_at((int)mx, (int)my);
|
|
|
|
|
|
|
+ int edges = 0;
|
|
|
|
|
+ int idx = resize_hit((int)mx, (int)my, &edges);
|
|
|
|
|
|
|
|
- if (idx >= 0 && !wins[idx].info.popover &&
|
|
|
|
|
- (int)mx >= wins[idx].info.x + (int)wins[idx].info.w - 16 &&
|
|
|
|
|
- (int)my >= wins[idx].info.y + (int)wins[idx].info.h - 16)
|
|
|
|
|
- want = CURSOR_NWSE_RESIZE;
|
|
|
|
|
|
|
+ if (idx >= 0 && edges &&
|
|
|
|
|
+ !close_hit(&wins[idx].info, (int)mx, (int)my))
|
|
|
|
|
+ want = resize_cursor(edges);
|
|
|
}
|
|
}
|
|
|
if (want != current && u_wm_set_cursor(want) == 0)
|
|
if (want != current && u_wm_set_cursor(want) == 0)
|
|
|
current = want;
|
|
current = want;
|
|
@@ -1843,32 +1975,24 @@ static void handle_mouse(struct wm_status *st)
|
|
|
my < WM_BTN_DISKS_Y + WM_BTN_DISKS_H) {
|
|
my < WM_BTN_DISKS_Y + WM_BTN_DISKS_H) {
|
|
|
spawn_app_checked("/ramfs/bin/disks");
|
|
spawn_app_checked("/ramfs/bin/disks");
|
|
|
} else {
|
|
} else {
|
|
|
- int idx = window_at((int)mx, (int)my);
|
|
|
|
|
|
|
+ int edges = 0;
|
|
|
|
|
+ int idx = resize_hit((int)mx, (int)my, &edges);
|
|
|
|
|
|
|
|
if (idx >= 0) {
|
|
if (idx >= 0) {
|
|
|
struct uwin *u = &wins[idx];
|
|
struct uwin *u = &wins[idx];
|
|
|
int pmx = (int)mx, pmy = (int)my;
|
|
int pmx = (int)mx, pmy = (int)my;
|
|
|
- int rx = u->info.x + (int)u->info.w - 1 -
|
|
|
|
|
- WM_CLOSE_W;
|
|
|
|
|
- int ry = u->info.y + 1;
|
|
|
|
|
|
|
|
|
|
u_wm_focus((unsigned int)idx);
|
|
u_wm_focus((unsigned int)idx);
|
|
|
if (u->info.popover) {
|
|
if (u->info.popover) {
|
|
|
/* A popover has no title bar, close
|
|
/* A popover has no title bar, close
|
|
|
- * button or resize grip; the app owns
|
|
|
|
|
|
|
+ * button or resize border; the app owns
|
|
|
* its content. */
|
|
* its content. */
|
|
|
- } else if (pmx >= rx &&
|
|
|
|
|
- pmx < u->info.x + (int)u->info.w &&
|
|
|
|
|
- pmy >= ry && pmy < ry + WM_TITLE_H) {
|
|
|
|
|
|
|
+ } else if (close_hit(&u->info, pmx, pmy)) {
|
|
|
u_wm_close((unsigned int)idx);
|
|
u_wm_close((unsigned int)idx);
|
|
|
full_redraw = 1;
|
|
full_redraw = 1;
|
|
|
- } else if (pmx >= u->info.x + (int)u->info.w - 16 &&
|
|
|
|
|
- pmy >= u->info.y + (int)u->info.h - 16) {
|
|
|
|
|
- resize_id = idx;
|
|
|
|
|
- resize_mx = mx;
|
|
|
|
|
- resize_my = my;
|
|
|
|
|
- resize_ow = u->info.w;
|
|
|
|
|
- resize_oh = u->info.h;
|
|
|
|
|
|
|
+ } else if (edges) {
|
|
|
|
|
+ begin_resize((unsigned int)idx, edges,
|
|
|
|
|
+ mx, my);
|
|
|
} else if (pmy < u->info.y + WM_TITLE_H) {
|
|
} else if (pmy < u->info.y + WM_TITLE_H) {
|
|
|
if (prev_title_id == idx &&
|
|
if (prev_title_id == idx &&
|
|
|
now - last_title_ms <= WM_DBLCLICK_MS &&
|
|
now - last_title_ms <= WM_DBLCLICK_MS &&
|
|
@@ -1889,6 +2013,7 @@ static void handle_mouse(struct wm_status *st)
|
|
|
drag_dx = pmx - u->info.x;
|
|
drag_dx = pmx - u->info.x;
|
|
|
drag_dy = pmy - u->info.y;
|
|
drag_dy = pmy - u->info.y;
|
|
|
drag_moved = 0;
|
|
drag_moved = 0;
|
|
|
|
|
+ u_wm_mouse_capture(1);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1896,32 +2021,11 @@ static void handle_mouse(struct wm_status *st)
|
|
|
} else if (down && was && resize_id >= 0) {
|
|
} else if (down && was && resize_id >= 0) {
|
|
|
struct uwin *u = &wins[resize_id];
|
|
struct uwin *u = &wins[resize_id];
|
|
|
|
|
|
|
|
- if (u->info.used) {
|
|
|
|
|
- int nw = (int)resize_ow + (int)mx - (int)resize_mx;
|
|
|
|
|
- int nh = (int)resize_oh + (int)my - (int)resize_my;
|
|
|
|
|
- int maxw = (int)fbw;
|
|
|
|
|
- int maxh = (int)fbh - WM_BAR_H;
|
|
|
|
|
-
|
|
|
|
|
- if (nw < 200) nw = 200;
|
|
|
|
|
- if (nh < 140) nh = 140;
|
|
|
|
|
- if (nw > maxw) nw = maxw;
|
|
|
|
|
- if (nh > maxh) nh = maxh;
|
|
|
|
|
- /* Dragging the grip into the screen corner means "as
|
|
|
|
|
- * large as the work area", even though the grip starts
|
|
|
|
|
- * 16 px inside the window edge. */
|
|
|
|
|
- if ((int)mx >= (int)fbw - 1)
|
|
|
|
|
- nw = maxw;
|
|
|
|
|
- if ((int)my >= (int)fbh - 1)
|
|
|
|
|
- nh = maxh;
|
|
|
|
|
- if (nw != (int)u->info.w || nh != (int)u->info.h) {
|
|
|
|
|
- if (set_window_geometry(u,
|
|
|
|
|
- (unsigned int)resize_id, u->info.x,
|
|
|
|
|
- u->info.y, (unsigned int)nw,
|
|
|
|
|
- (unsigned int)nh) == 0)
|
|
|
|
|
- u->state = WIN_NORMAL;
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
|
|
+ if (u->info.used)
|
|
|
|
|
+ resize_window_drag(u, (unsigned int)resize_id, mx, my);
|
|
|
|
|
+ else {
|
|
|
resize_id = -1;
|
|
resize_id = -1;
|
|
|
|
|
+ u_wm_mouse_capture(0);
|
|
|
}
|
|
}
|
|
|
} else if (down && was && drag_id >= 0) {
|
|
} else if (down && was && drag_id >= 0) {
|
|
|
struct uwin *u = &wins[drag_id];
|
|
struct uwin *u = &wins[drag_id];
|
|
@@ -1993,6 +2097,7 @@ static void handle_mouse(struct wm_status *st)
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
drag_id = -1;
|
|
drag_id = -1;
|
|
|
|
|
+ u_wm_mouse_capture(0);
|
|
|
}
|
|
}
|
|
|
} else if (!down && was) {
|
|
} else if (!down && was) {
|
|
|
/* Dropping a window with the pointer on the left/right screen
|
|
/* Dropping a window with the pointer on the left/right screen
|
|
@@ -2014,6 +2119,7 @@ static void handle_mouse(struct wm_status *st)
|
|
|
}
|
|
}
|
|
|
drag_id = -1;
|
|
drag_id = -1;
|
|
|
resize_id = -1;
|
|
resize_id = -1;
|
|
|
|
|
+ u_wm_mouse_capture(0);
|
|
|
}
|
|
}
|
|
|
prev_buttons = buttons;
|
|
prev_buttons = buttons;
|
|
|
update_cursor(mx, my);
|
|
update_cursor(mx, my);
|