|
@@ -12,10 +12,19 @@
|
|
|
* the inactive one stays neutral. Windows have no visible frame. */
|
|
* the inactive one stays neutral. Windows have no visible frame. */
|
|
|
#define COL_TITLE_ON 0x365CA6u
|
|
#define COL_TITLE_ON 0x365CA6u
|
|
|
#define COL_TITLE_OFF 0x646464u
|
|
#define COL_TITLE_OFF 0x646464u
|
|
|
-#define COL_CLOSE 0xC64040u
|
|
|
|
|
|
|
+/* The close control is a bare window-close icon in the title bar: dimmed
|
|
|
|
|
+ * while idle, bright white while the pointer is over it. */
|
|
|
|
|
+#define COL_CLOSE_ICON 0xD3DAE6u
|
|
|
|
|
+#define COL_CLOSE_HOT 0xFFFFFFu
|
|
|
#define COL_WHITE 0xFFFFFFu
|
|
#define COL_WHITE 0xFFFFFFu
|
|
|
#define COL_BANNER 0x55FF55u
|
|
#define COL_BANNER 0x55FF55u
|
|
|
|
|
|
|
|
|
|
+/* Title-bar text inset from the window's left edge, and the close icon's
|
|
|
|
|
+ * inset from its right edge. The Adwaita symbolic icon mask is 16x16. */
|
|
|
|
|
+#define WM_TITLE_PAD 8
|
|
|
|
|
+#define WM_CLOSE_INSET 3
|
|
|
|
|
+#define WM_CLOSE_ICON_PX 16
|
|
|
|
|
+
|
|
|
struct uwin {
|
|
struct uwin {
|
|
|
struct wm_window_info info;
|
|
struct wm_window_info info;
|
|
|
struct wm_map_info map;
|
|
struct wm_map_info map;
|
|
@@ -89,6 +98,11 @@ static unsigned int resize_mx, resize_my, resize_ow, resize_oh;
|
|
|
static unsigned int resize_last_ms;
|
|
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;
|
|
|
|
|
+/* Window whose close icon is under the pointer (-1 for none); a change
|
|
|
|
|
+ * repaints only that button instead of the whole desktop. */
|
|
|
|
|
+static int close_hot = -1;
|
|
|
|
|
+static int close_hot_old = -1;
|
|
|
|
|
+static int close_dirty;
|
|
|
static unsigned int prev_buttons;
|
|
static unsigned int prev_buttons;
|
|
|
static int full_redraw = 1;
|
|
static int full_redraw = 1;
|
|
|
static int boot_term_spawned;
|
|
static int boot_term_spawned;
|
|
@@ -816,7 +830,7 @@ static void draw_window_clip(unsigned int idx, int cx, int cy,
|
|
|
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;
|
|
unsigned int pw = w->w;
|
|
|
- int bx = x + (int)pw - WM_BORDER_W - WM_CLOSE_W;
|
|
|
|
|
|
|
+ int bx = x + (int)pw - WM_BORDER_W - WM_CLOSE_W - WM_CLOSE_INSET;
|
|
|
int cony = y + WM_BORDER_W + WM_TITLE_H;
|
|
int cony = y + WM_BORDER_W + WM_TITLE_H;
|
|
|
int content_x = x + WM_BORDER_W;
|
|
int content_x = x + WM_BORDER_W;
|
|
|
unsigned int content_w = w->content_w;
|
|
unsigned int content_w = w->content_w;
|
|
@@ -827,14 +841,31 @@ static void draw_window_clip(unsigned int idx, int cx, int cy,
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /* Title bar and close button; windows have no visible frame. */
|
|
|
|
|
|
|
+ /* Title bar and close icon; windows have no visible frame. The title
|
|
|
|
|
+ * text is clipped where the icon starts, so a long title never runs
|
|
|
|
|
+ * under the button. */
|
|
|
fill_clip(x, y, pw, WM_TITLE_H,
|
|
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 + 3, y + 2, w->title, COL_WHITE,
|
|
|
|
|
- cx, cy, cw, ch);
|
|
|
|
|
- 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);
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ int tx0 = x + WM_TITLE_PAD, ty0 = y;
|
|
|
|
|
+ int tx1 = bx - 4, ty1 = y + WM_TITLE_H;
|
|
|
|
|
+
|
|
|
|
|
+ if (tx0 < cx) tx0 = cx;
|
|
|
|
|
+ if (ty0 < cy) ty0 = cy;
|
|
|
|
|
+ if (tx1 > cx + (int)cw) tx1 = cx + (int)cw;
|
|
|
|
|
+ if (ty1 > cy + (int)ch) ty1 = cy + (int)ch;
|
|
|
|
|
+ if (tx1 > tx0 && ty1 > ty0)
|
|
|
|
|
+ usurf_text(&screen, x + WM_TITLE_PAD, y + 2,
|
|
|
|
|
+ w->title, COL_WHITE, tx0, ty0,
|
|
|
|
|
+ (unsigned int)(tx1 - tx0),
|
|
|
|
|
+ (unsigned int)(ty1 - ty0));
|
|
|
|
|
+ }
|
|
|
|
|
+ (void)usurf_icon_clip(&screen, bx,
|
|
|
|
|
+ y + (WM_TITLE_H - WM_CLOSE_ICON_PX) / 2,
|
|
|
|
|
+ UWM_ICON_CLOSE,
|
|
|
|
|
+ close_hot == (int)idx ? COL_CLOSE_HOT :
|
|
|
|
|
+ COL_CLOSE_ICON,
|
|
|
|
|
+ cx, cy, cw, ch);
|
|
|
|
|
|
|
|
/* Content: every window presents an RGB565 canvas (the terminal
|
|
/* Content: every window presents an RGB565 canvas (the terminal
|
|
|
* renders its cells into one; gfx commands own theirs). A mapped
|
|
* renders its cells into one; gfx commands own theirs). A mapped
|
|
@@ -1270,13 +1301,28 @@ static int resize_cursor(int edges)
|
|
|
/* Close button hit area (the top-right WM_CLOSE_W columns of the title bar). */
|
|
/* 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)
|
|
static int close_hit(const struct wm_window_info *w, int mx, int my)
|
|
|
{
|
|
{
|
|
|
|
|
+ int bx;
|
|
|
|
|
+
|
|
|
if (w->popover)
|
|
if (w->popover)
|
|
|
return 0;
|
|
return 0;
|
|
|
- return mx >= w->x + (int)w->w - WM_CLOSE_W &&
|
|
|
|
|
- mx < w->x + (int)w->w &&
|
|
|
|
|
|
|
+ bx = w->x + (int)w->w - WM_BORDER_W - WM_CLOSE_W - WM_CLOSE_INSET;
|
|
|
|
|
+ return mx >= bx && mx < bx + WM_CLOSE_W &&
|
|
|
my >= w->y && my < w->y + WM_TITLE_H;
|
|
my >= w->y && my < w->y + WM_TITLE_H;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/* Window whose close icon is under the pointer, or -1. The topmost window
|
|
|
|
|
+ * decides, like a press does, so an icon covered by a popover or another
|
|
|
|
|
+ * window does not react. */
|
|
|
|
|
+static int close_window_at(int mx, int my)
|
|
|
|
|
+{
|
|
|
|
|
+ int edges = 0;
|
|
|
|
|
+ int idx = resize_hit(mx, my, &edges);
|
|
|
|
|
+
|
|
|
|
|
+ if (idx < 0 || !close_hit(&wins[idx].info, mx, my))
|
|
|
|
|
+ return -1;
|
|
|
|
|
+ return idx;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
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,
|
|
@@ -1330,6 +1376,20 @@ static void add_rect(struct wm_present_info *p, int x, int y,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/* Damage rectangle covering one window's close button, for a hover change. */
|
|
|
|
|
+static void close_add_damage(struct wm_present_info *p, int idx)
|
|
|
|
|
+{
|
|
|
|
|
+ struct wm_window_info *w;
|
|
|
|
|
+
|
|
|
|
|
+ if (idx < 0 || idx >= WM_MAX_WINDOWS)
|
|
|
|
|
+ return;
|
|
|
|
|
+ w = &wins[idx].info;
|
|
|
|
|
+ if (!w->used || w->popover)
|
|
|
|
|
+ return;
|
|
|
|
|
+ add_rect(p, w->x + (int)w->w - WM_BORDER_W - WM_CLOSE_W -
|
|
|
|
|
+ WM_CLOSE_INSET, w->y, WM_CLOSE_W, WM_TITLE_H);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/* Center the brightness bubble in the work area, clamped on small screens. */
|
|
/* Center the brightness bubble in the work area, clamped on small screens. */
|
|
|
static void osd_geom(void)
|
|
static void osd_geom(void)
|
|
|
{
|
|
{
|
|
@@ -2103,6 +2163,23 @@ static void do_update(struct wm_status *st)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+ /* Close-icon hover: only the topmost window under a free pointer
|
|
|
|
|
+ * reacts; an open menu, the dock and the top bar own the pointer when
|
|
|
|
|
+ * they are under it. A change repaints just the two button rects. */
|
|
|
|
|
+ {
|
|
|
|
|
+ int hot = -1;
|
|
|
|
|
+
|
|
|
|
|
+ if (resize_id < 0 && drag_id < 0 && !sm_open &&
|
|
|
|
|
+ !dock_pointer_inside(st->mouse.x, st->mouse.y) &&
|
|
|
|
|
+ st->mouse.y >= WM_BAR_H)
|
|
|
|
|
+ hot = close_window_at((int)st->mouse.x,
|
|
|
|
|
+ (int)st->mouse.y);
|
|
|
|
|
+ if (hot != close_hot) {
|
|
|
|
|
+ close_hot_old = close_hot;
|
|
|
|
|
+ close_hot = hot;
|
|
|
|
|
+ close_dirty = 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
/* Popovers are WM-anchored overlays, flush against the bottom of the
|
|
/* Popovers are WM-anchored overlays, flush against the bottom of the
|
|
|
* bar and the right screen edge. The WM owns the geometry, so the app
|
|
* bar and the right screen edge. The WM owns the geometry, so the app
|
|
|
* does not need a placement ABI. */
|
|
* does not need a placement ABI. */
|
|
@@ -2232,6 +2309,13 @@ static void do_update(struct wm_status *st)
|
|
|
/* Partial cell/canvas updates and the bar clock. */
|
|
/* Partial cell/canvas updates and the bar clock. */
|
|
|
present.count = 0;
|
|
present.count = 0;
|
|
|
present.immediate = 0;
|
|
present.immediate = 0;
|
|
|
|
|
+ if (close_dirty) {
|
|
|
|
|
+ close_dirty = 0;
|
|
|
|
|
+ close_add_damage(&present, close_hot);
|
|
|
|
|
+ close_add_damage(&present, close_hot_old);
|
|
|
|
|
+ close_hot_old = -1;
|
|
|
|
|
+ need = 1;
|
|
|
|
|
+ }
|
|
|
if (osd_repaint) {
|
|
if (osd_repaint) {
|
|
|
add_rect(&present, osd_x, osd_y, osd_w, osd_h);
|
|
add_rect(&present, osd_x, osd_y, osd_w, osd_h);
|
|
|
need = 1;
|
|
need = 1;
|
|
@@ -2962,8 +3046,8 @@ static void begin_resize(unsigned int idx, int edges, unsigned int mx,
|
|
|
/* The WM's cursor override (SYS_WM_SET_CURSOR): resize arrows on the
|
|
/* The WM's cursor override (SYS_WM_SET_CURSOR): resize arrows on the
|
|
|
* invisible resize border and while resizing, the move cross while a
|
|
* invisible resize border and while resizing, the move cross while a
|
|
|
* title-bar drag is under way, a hand over the start button, the open start
|
|
* title-bar drag is under way, a hand over the start button, the open start
|
|
|
- * menu and the status area. Everywhere else the kernel picks the window's
|
|
|
|
|
- * own content cursor (or the arrow). */
|
|
|
|
|
|
|
+ * menu, the status area, the dock or a window's close icon. 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;
|
|
@@ -2991,8 +3075,9 @@ static void update_cursor(unsigned int mx, unsigned int my)
|
|
|
int edges = 0;
|
|
int edges = 0;
|
|
|
int idx = resize_hit((int)mx, (int)my, &edges);
|
|
int idx = resize_hit((int)mx, (int)my, &edges);
|
|
|
|
|
|
|
|
- if (idx >= 0 && edges &&
|
|
|
|
|
- !close_hit(&wins[idx].info, (int)mx, (int)my))
|
|
|
|
|
|
|
+ if (idx >= 0 && close_hit(&wins[idx].info, (int)mx, (int)my))
|
|
|
|
|
+ want = CURSOR_POINTER;
|
|
|
|
|
+ else if (idx >= 0 && edges)
|
|
|
want = resize_cursor(edges);
|
|
want = resize_cursor(edges);
|
|
|
}
|
|
}
|
|
|
if (want != current && u_wm_set_cursor(want) == 0)
|
|
if (want != current && u_wm_set_cursor(want) == 0)
|