|
@@ -75,21 +75,22 @@ static int bar_temp_c = -1;
|
|
|
static int bar_batt_pct = -1;
|
|
static int bar_batt_pct = -1;
|
|
|
static int bar_batt_charging;
|
|
static int bar_batt_charging;
|
|
|
static int bar_ac_online = -1;
|
|
static int bar_ac_online = -1;
|
|
|
|
|
+/* Both top-bar buttons share this geometry: one rounded pill that stops one
|
|
|
|
|
+ * pixel above the rainbow separator (which starts at WM_BAR_H - 5). */
|
|
|
|
|
+#define BAR_BTN_Y 2
|
|
|
|
|
+#define BAR_BTN_H 22
|
|
|
|
|
+#define BAR_BTN_RADIUS 6
|
|
|
|
|
+
|
|
|
/* Battery/AC status icon: the Adwaita AC adapter on AC, the battery outline
|
|
/* Battery/AC status icon: the Adwaita AC adapter on AC, the battery outline
|
|
|
- * with our own level fill otherwise. The rightmost bar item; hovering it
|
|
|
|
|
- * shows a percentage tooltip below it. */
|
|
|
|
|
|
|
+ * with our own level fill otherwise. The rightmost bar item. */
|
|
|
#define BAR_PWR_W 24
|
|
#define BAR_PWR_W 24
|
|
|
#define BAR_PWR_Y 7
|
|
#define BAR_PWR_Y 7
|
|
|
-#define BAR_TIP_H 20
|
|
|
|
|
-static int bar_pwr_x = -1;
|
|
|
|
|
-static int bar_pwr_hot;
|
|
|
|
|
-static int bar_pwr_tip_x = -1;
|
|
|
|
|
-static int bar_pwr_tip_y;
|
|
|
|
|
-static unsigned int bar_pwr_tip_w, bar_pwr_tip_h;
|
|
|
|
|
-static int bar_pwr_tip_want; /* tooltip computed for this frame */
|
|
|
|
|
-static int bar_pwr_tip_on; /* tooltip pixels currently on screen */
|
|
|
|
|
-static int bar_pwr_tip_on_x, bar_pwr_tip_on_y;
|
|
|
|
|
-static unsigned int bar_pwr_tip_on_w, bar_pwr_tip_on_h;
|
|
|
|
|
|
|
+/* The clock, temperature, network and AC/battery labels are one status
|
|
|
|
|
+ * button. draw_bar() records their bounding rectangle; only that rectangle
|
|
|
|
|
+ * opens the control panel, so the empty part of the bar is not clickable. */
|
|
|
|
|
+static int bar_status_x = -1;
|
|
|
|
|
+static unsigned int bar_status_w;
|
|
|
|
|
+static int bar_status_hot;
|
|
|
/* Brightness OSD: a centered bubble shown after the kernel's backlight
|
|
/* Brightness OSD: a centered bubble shown after the kernel's backlight
|
|
|
* seq changes, then hidden after OSD_MS. */
|
|
* seq changes, then hidden after OSD_MS. */
|
|
|
#define OSD_MS 3000
|
|
#define OSD_MS 3000
|
|
@@ -106,11 +107,6 @@ static unsigned int osd_w, osd_h;
|
|
|
static char bar_msg[24];
|
|
static char bar_msg[24];
|
|
|
static unsigned int bar_msg_until;
|
|
static unsigned int bar_msg_until;
|
|
|
static int bar_msg_dirty;
|
|
static int bar_msg_dirty;
|
|
|
-/* Rectangle of the right-aligned date/time text, so a click there can open
|
|
|
|
|
- * the Date & Time app. w == 0 means "not drawn" (e.g. kexec banner). */
|
|
|
|
|
-static int bar_clock_x = -1;
|
|
|
|
|
-static unsigned int bar_clock_w;
|
|
|
|
|
-static int bar_clock_hot;
|
|
|
|
|
static unsigned int stat_frames, stat_ms, stat_px, stat_max, stat_last;
|
|
static unsigned int stat_frames, stat_ms, stat_px, stat_max, stat_last;
|
|
|
|
|
|
|
|
/* ---- Start menu --------------------------------------------------------
|
|
/* ---- Start menu --------------------------------------------------------
|
|
@@ -120,12 +116,28 @@ static unsigned int stat_frames, stat_ms, stat_px, stat_max, stat_last;
|
|
|
* lists every GUI app in the pack and ends with a Power row whose submenu
|
|
* lists every GUI app in the pack and ends with a Power row whose submenu
|
|
|
* reboots or powers off the machine through the privileged kernel command
|
|
* reboots or powers off the machine through the privileged kernel command
|
|
|
* registry (SYS_SPAWN_KCMD). */
|
|
* registry (SYS_SPAWN_KCMD). */
|
|
|
-#define SM_W 236
|
|
|
|
|
-#define SM_ROW_H 30
|
|
|
|
|
-#define SM_MIN_ROW 18
|
|
|
|
|
-#define SM_HDR_H 44
|
|
|
|
|
-#define SM_SEP_H 7
|
|
|
|
|
-#define SM_SUB_W 152
|
|
|
|
|
|
|
+/* The panel mirrors ngui_theme_dark and the netmenu popover: a flat
|
|
|
|
|
+ * theme.bg surface without a rim, rounded theme.panel summary cards,
|
|
|
|
|
+ * theme.panel_alt hover rows and the selection colour for an active item. */
|
|
|
|
|
+#define SM_BG 0x181C28u
|
|
|
|
|
+#define SM_PANEL 0x262B3Au
|
|
|
|
|
+#define SM_PANEL_ALT 0x32384Au
|
|
|
|
|
+#define SM_TEXT 0xE4E6F0u
|
|
|
|
|
+#define SM_TEXT_DIM 0x9197AAu
|
|
|
|
|
+#define SM_SEL 0x365CA6u
|
|
|
|
|
+#define SM_BTN_HOT 0x46516Cu
|
|
|
|
|
+#define SM_ERROR 0xEE7474u
|
|
|
|
|
+
|
|
|
|
|
+#define SM_W 252
|
|
|
|
|
+#define SM_PAD 12
|
|
|
|
|
+#define SM_TOP 10
|
|
|
|
|
+#define SM_GAP 6
|
|
|
|
|
+#define SM_SECT_H 22
|
|
|
|
|
+#define SM_ROW_H 26
|
|
|
|
|
+#define SM_MIN_ROW 20
|
|
|
|
|
+#define SM_BOTTOM 10
|
|
|
|
|
+#define SM_RADIUS 6
|
|
|
|
|
+#define SM_SUB_W 160
|
|
|
#define SM_TILE 18
|
|
#define SM_TILE 18
|
|
|
|
|
|
|
|
#define SM_HIT_NONE (-1)
|
|
#define SM_HIT_NONE (-1)
|
|
@@ -133,6 +145,7 @@ static unsigned int stat_frames, stat_ms, stat_px, stat_max, stat_last;
|
|
|
#define SM_HIT_POWER (-3)
|
|
#define SM_HIT_POWER (-3)
|
|
|
#define SM_HIT_REBOOT (-4)
|
|
#define SM_HIT_REBOOT (-4)
|
|
|
#define SM_HIT_POWEROFF (-5)
|
|
#define SM_HIT_POWEROFF (-5)
|
|
|
|
|
+#define SM_HIT_MENU (-6) /* inside the panel but not on an entry */
|
|
|
|
|
|
|
|
#define SM_ACT_SPAWN 0
|
|
#define SM_ACT_SPAWN 0
|
|
|
#define SM_ACT_TERM 1
|
|
#define SM_ACT_TERM 1
|
|
@@ -171,6 +184,8 @@ static const struct sm_app sm_apps[] = {
|
|
|
struct sm_layout {
|
|
struct sm_layout {
|
|
|
int x, y, w, h;
|
|
int x, y, w, h;
|
|
|
int row_h;
|
|
int row_h;
|
|
|
|
|
+ int sect_y;
|
|
|
|
|
+ int row_x, row_w;
|
|
|
int list_y;
|
|
int list_y;
|
|
|
int power_y;
|
|
int power_y;
|
|
|
int sub_x, sub_y, sub_w, sub_h;
|
|
int sub_x, sub_y, sub_w, sub_h;
|
|
@@ -196,9 +211,6 @@ static void sm_launch(int idx);
|
|
|
#define BAR_NET_WIRED 1
|
|
#define BAR_NET_WIRED 1
|
|
|
#define BAR_NET_WIFI 2
|
|
#define BAR_NET_WIFI 2
|
|
|
#define BAR_NET_USB 3
|
|
#define BAR_NET_USB 3
|
|
|
-static int bar_net_x = -1;
|
|
|
|
|
-static unsigned int bar_net_w;
|
|
|
|
|
-static int bar_net_hot;
|
|
|
|
|
static int bar_net_kind;
|
|
static int bar_net_kind;
|
|
|
static int bar_net_bars;
|
|
static int bar_net_bars;
|
|
|
static unsigned int bar_net_color = 0xFF5050u;
|
|
static unsigned int bar_net_color = 0xFF5050u;
|
|
@@ -284,14 +296,102 @@ static void fill_clip(int x, int y, unsigned int w, unsigned int h,
|
|
|
(unsigned int)(y1 - y0), rgb);
|
|
(unsigned int)(y1 - y0), rgb);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/* Rounded rectangle fill, matching ngui_fill_round_rect()'s pixel-centre
|
|
|
|
|
+ * corner sampling (the popover's cards and tiles use a 6 px radius). */
|
|
|
|
|
+static int sm_isqrt(int v)
|
|
|
|
|
+{
|
|
|
|
|
+ int r = 0, bit = 1 << 30;
|
|
|
|
|
+
|
|
|
|
|
+ if (v <= 0)
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ while (bit > v)
|
|
|
|
|
+ bit >>= 2;
|
|
|
|
|
+ while (bit) {
|
|
|
|
|
+ if (v >= r + bit) {
|
|
|
|
|
+ v -= r + bit;
|
|
|
|
|
+ r = (r >> 1) + bit;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ r >>= 1;
|
|
|
|
|
+ }
|
|
|
|
|
+ bit >>= 2;
|
|
|
|
|
+ }
|
|
|
|
|
+ return r;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static int sm_round_inset(int y, int h, int r)
|
|
|
|
|
+{
|
|
|
|
|
+ int dy2, d2;
|
|
|
|
|
+
|
|
|
|
|
+ if (r <= 0)
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ if (y < r)
|
|
|
|
|
+ dy2 = 2 * r - 2 * y - 1;
|
|
|
|
|
+ else if (y >= h - r)
|
|
|
|
|
+ dy2 = 2 * (y - (h - r)) + 1;
|
|
|
|
|
+ else
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ d2 = 4 * r * r - dy2 * dy2;
|
|
|
|
|
+ if (d2 < 0)
|
|
|
|
|
+ d2 = 0;
|
|
|
|
|
+ return r - (sm_isqrt(d2) + 1) / 2;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+static void sm_fill_round(int x, int y, int w, int h, int r,
|
|
|
|
|
+ unsigned int rgb)
|
|
|
|
|
+{
|
|
|
|
|
+ int yy, half;
|
|
|
|
|
+
|
|
|
|
|
+ if (w <= 0 || h <= 0)
|
|
|
|
|
+ return;
|
|
|
|
|
+ half = w < h ? w / 2 : h / 2;
|
|
|
|
|
+ if (r > half)
|
|
|
|
|
+ r = half;
|
|
|
|
|
+ if (r <= 0) {
|
|
|
|
|
+ usurf_fill(&screen, x, y, (unsigned int)w, (unsigned int)h,
|
|
|
|
|
+ rgb);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (yy = 0; yy < h; yy++) {
|
|
|
|
|
+ int li = 0, ri = 0;
|
|
|
|
|
+
|
|
|
|
|
+ if (yy < r) {
|
|
|
|
|
+ li = sm_round_inset(yy, h, r);
|
|
|
|
|
+ ri = li;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (yy >= h - r) {
|
|
|
|
|
+ int i = sm_round_inset(yy, h, r);
|
|
|
|
|
+
|
|
|
|
|
+ if (i > li)
|
|
|
|
|
+ li = i;
|
|
|
|
|
+ if (i > ri)
|
|
|
|
|
+ ri = i;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (w - li - ri > 0)
|
|
|
|
|
+ usurf_fill(&screen, x + li, y + yy,
|
|
|
|
|
+ (unsigned int)(w - li - ri), 1, rgb);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+/* One shared renderer for the start and status buttons: the same height,
|
|
|
|
|
+ * corner radius and hover/active colours. */
|
|
|
|
|
+static void bar_button_bg(int x, int w, int active, int hot)
|
|
|
|
|
+{
|
|
|
|
|
+ if (active)
|
|
|
|
|
+ sm_fill_round(x, BAR_BTN_Y, w, BAR_BTN_H, BAR_BTN_RADIUS,
|
|
|
|
|
+ SM_SEL);
|
|
|
|
|
+ else if (hot)
|
|
|
|
|
+ sm_fill_round(x, BAR_BTN_Y, w, BAR_BTN_H, BAR_BTN_RADIUS,
|
|
|
|
|
+ SM_PANEL_ALT);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/* The NebOS banner doubles as the start button. Its width follows the
|
|
/* The NebOS banner doubles as the start button. Its width follows the
|
|
|
* proportional font, so the hit area and the highlight use the same
|
|
* proportional font, so the hit area and the highlight use the same
|
|
|
* geometry. */
|
|
* geometry. */
|
|
|
static void bar_start_geom(int *x, int *y, int *w, int *h)
|
|
static void bar_start_geom(int *x, int *y, int *w, int *h)
|
|
|
{
|
|
{
|
|
|
*x = 2;
|
|
*x = 2;
|
|
|
- *y = 2;
|
|
|
|
|
- *h = WM_BAR_H - 6;
|
|
|
|
|
|
|
+ *y = BAR_BTN_Y;
|
|
|
|
|
+ *h = BAR_BTN_H;
|
|
|
*w = (int)usurf_text_width(&screen, OS_NAME " v" OS_VERSION) + 20;
|
|
*w = (int)usurf_text_width(&screen, OS_NAME " v" OS_VERSION) + 20;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -309,13 +409,9 @@ static void bar_start_button(void)
|
|
|
int x, y, w, h;
|
|
int x, y, w, h;
|
|
|
|
|
|
|
|
bar_start_geom(&x, &y, &w, &h);
|
|
bar_start_geom(&x, &y, &w, &h);
|
|
|
- if (sm_open || sm_start_hot) {
|
|
|
|
|
- usurf_fill(&screen, x, y, w, h,
|
|
|
|
|
- sm_open ? 0x365CA6u : 0x3A3A55u);
|
|
|
|
|
- usurf_fill(&screen, x + 2, y + h - 2, w - 4, 2,
|
|
|
|
|
- sm_open ? 0x55FF55u : 0x70709Au);
|
|
|
|
|
- }
|
|
|
|
|
- usurf_text(&screen, x + 10, y + 4, OS_NAME " v" OS_VERSION,
|
|
|
|
|
|
|
+ bar_button_bg(x, w, sm_open, sm_start_hot);
|
|
|
|
|
+ usurf_text(&screen, x + 10, y + (h - 16) / 2,
|
|
|
|
|
+ OS_NAME " v" OS_VERSION,
|
|
|
sm_open ? COL_WHITE : COL_BANNER, 0, 0, fbw, WM_BAR_H);
|
|
sm_open ? COL_WHITE : COL_BANNER, 0, 0, fbw, WM_BAR_H);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -438,21 +534,6 @@ static unsigned int temp_text(char *b, int c)
|
|
|
return n;
|
|
return n;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/* "87%" (no libc printf here). */
|
|
|
|
|
-static unsigned int pct_text(char *b, int pct)
|
|
|
|
|
-{
|
|
|
|
|
- unsigned int n = 0, v = (unsigned int)pct;
|
|
|
|
|
-
|
|
|
|
|
- if (v >= 100)
|
|
|
|
|
- b[n++] = (char)('0' + (v / 100) % 10);
|
|
|
|
|
- if (v >= 10)
|
|
|
|
|
- b[n++] = (char)('0' + (v / 10) % 10);
|
|
|
|
|
- b[n++] = (char)('0' + v % 10);
|
|
|
|
|
- b[n++] = '%';
|
|
|
|
|
- b[n] = '\0';
|
|
|
|
|
- return n;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
static unsigned int batt_color(int pct)
|
|
static unsigned int batt_color(int pct)
|
|
|
{
|
|
{
|
|
|
if (pct <= 10)
|
|
if (pct <= 10)
|
|
@@ -491,49 +572,6 @@ static void bar_icon_ac(int x, int y, unsigned int c)
|
|
|
(void)usurf_icon(&screen, x + 4, y, UWM_ICON_AC, c);
|
|
(void)usurf_icon(&screen, x + 4, y, UWM_ICON_AC, c);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/* Percentage tooltip: a small box below the status icon. It is drawn after
|
|
|
|
|
- * the windows (see bar_tooltip_overlay), so it always sits on top. */
|
|
|
|
|
-static void bar_draw_tooltip(void)
|
|
|
|
|
-{
|
|
|
|
|
- char lb[8];
|
|
|
|
|
- unsigned int lw;
|
|
|
|
|
- int tx;
|
|
|
|
|
-
|
|
|
|
|
- if (!bar_pwr_tip_want || bar_pwr_tip_x < 0)
|
|
|
|
|
- return;
|
|
|
|
|
- usurf_fill(&screen, bar_pwr_tip_x, bar_pwr_tip_y,
|
|
|
|
|
- bar_pwr_tip_w, bar_pwr_tip_h, 0x161622u);
|
|
|
|
|
- usurf_fill(&screen, bar_pwr_tip_x, bar_pwr_tip_y,
|
|
|
|
|
- bar_pwr_tip_w, 1, 0x646464u);
|
|
|
|
|
- usurf_fill(&screen, bar_pwr_tip_x,
|
|
|
|
|
- bar_pwr_tip_y + (int)bar_pwr_tip_h - 1,
|
|
|
|
|
- bar_pwr_tip_w, 1, 0x646464u);
|
|
|
|
|
- usurf_fill(&screen, bar_pwr_tip_x, bar_pwr_tip_y,
|
|
|
|
|
- 1, bar_pwr_tip_h, 0x646464u);
|
|
|
|
|
- usurf_fill(&screen, bar_pwr_tip_x + (int)bar_pwr_tip_w - 1,
|
|
|
|
|
- bar_pwr_tip_y, 1, bar_pwr_tip_h, 0x646464u);
|
|
|
|
|
- (void)pct_text(lb, bar_batt_pct);
|
|
|
|
|
- lw = usurf_text_width(&screen, lb);
|
|
|
|
|
- tx = bar_pwr_tip_x + ((int)bar_pwr_tip_w - (int)lw) / 2;
|
|
|
|
|
- usurf_text(&screen, tx, bar_pwr_tip_y + 3, lb,
|
|
|
|
|
- batt_color(bar_batt_pct), 0, 0, fbw, fbh);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-/* Publish the geometry computed by draw_bar() and redraw the tooltip. */
|
|
|
|
|
-static void bar_tooltip_commit(void)
|
|
|
|
|
-{
|
|
|
|
|
- if (bar_pwr_tip_want) {
|
|
|
|
|
- bar_draw_tooltip();
|
|
|
|
|
- bar_pwr_tip_on = 1;
|
|
|
|
|
- bar_pwr_tip_on_x = bar_pwr_tip_x;
|
|
|
|
|
- bar_pwr_tip_on_y = bar_pwr_tip_y;
|
|
|
|
|
- bar_pwr_tip_on_w = bar_pwr_tip_w;
|
|
|
|
|
- bar_pwr_tip_on_h = bar_pwr_tip_h;
|
|
|
|
|
- } else {
|
|
|
|
|
- bar_pwr_tip_on = 0;
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
static void draw_bar(void)
|
|
static void draw_bar(void)
|
|
|
{
|
|
{
|
|
|
char dt[48];
|
|
char dt[48];
|
|
@@ -559,14 +597,8 @@ static void draw_bar(void)
|
|
|
unsigned int dots = bar_kexec_total ?
|
|
unsigned int dots = bar_kexec_total ?
|
|
|
(bar_kexec_progress * 12 / bar_kexec_total) : 0;
|
|
(bar_kexec_progress * 12 / bar_kexec_total) : 0;
|
|
|
|
|
|
|
|
- bar_clock_x = -1;
|
|
|
|
|
- bar_clock_w = 0;
|
|
|
|
|
- bar_clock_hot = 0;
|
|
|
|
|
- bar_net_x = -1;
|
|
|
|
|
- bar_net_w = 0;
|
|
|
|
|
- bar_pwr_x = -1;
|
|
|
|
|
- bar_pwr_tip_x = -1;
|
|
|
|
|
- bar_pwr_tip_want = 0;
|
|
|
|
|
|
|
+ bar_status_x = -1;
|
|
|
|
|
+ bar_status_w = 0;
|
|
|
n = 0;
|
|
n = 0;
|
|
|
while (msg[n])
|
|
while (msg[n])
|
|
|
dt[n] = msg[n], n++;
|
|
dt[n] = msg[n], n++;
|
|
@@ -578,117 +610,96 @@ static void draw_bar(void)
|
|
|
(int)fbw - (int)usurf_text_width(&screen, dt) - 4,
|
|
(int)fbw - (int)usurf_text_width(&screen, dt) - 4,
|
|
|
5, dt, 0xFFC864u, 0, 0, fbw, WM_BAR_H);
|
|
5, dt, 0xFFC864u, 0, 0, fbw, WM_BAR_H);
|
|
|
} else {
|
|
} else {
|
|
|
- unsigned int clock_chars = 0;
|
|
|
|
|
int right = (int)fbw - 4;
|
|
int right = (int)fbw - 4;
|
|
|
int min_x = (int)WM_BAR_LEFT_END + 4;
|
|
int min_x = (int)WM_BAR_LEFT_END + 4;
|
|
|
-
|
|
|
|
|
- bar_clock_x = -1;
|
|
|
|
|
- bar_clock_w = 0;
|
|
|
|
|
- bar_net_x = -1;
|
|
|
|
|
- bar_net_w = 0;
|
|
|
|
|
- bar_pwr_x = -1;
|
|
|
|
|
- bar_pwr_tip_x = -1;
|
|
|
|
|
- bar_pwr_tip_want = 0;
|
|
|
|
|
- /* The AC/battery status icon is the rightmost item. */
|
|
|
|
|
|
|
+ int pwr_px = -1, net_nx = -1, clock_tx = -1, temp_tx = -1;
|
|
|
|
|
+ int temp_tw;
|
|
|
|
|
+ int left;
|
|
|
|
|
+ char cdt[12], tb[12];
|
|
|
|
|
+ const char *clock_txt = dt;
|
|
|
|
|
+
|
|
|
|
|
+ /* Lay the cluster out right to left: AC/battery, network, the
|
|
|
|
|
+ * date/time and the CPU temperature. */
|
|
|
if (bar_batt_pct >= 0 || bar_ac_online > 0) {
|
|
if (bar_batt_pct >= 0 || bar_ac_online > 0) {
|
|
|
- int px = right - BAR_PWR_W;
|
|
|
|
|
-
|
|
|
|
|
- if (px >= min_x) {
|
|
|
|
|
- if (bar_pwr_hot)
|
|
|
|
|
- usurf_fill(&screen, px - 3, 2,
|
|
|
|
|
- BAR_PWR_W + 6,
|
|
|
|
|
- WM_BAR_H - 7, 0x3A3A55u);
|
|
|
|
|
- if (bar_ac_online > 0)
|
|
|
|
|
- bar_icon_ac(px, BAR_PWR_Y, 0x55FF55u);
|
|
|
|
|
- else
|
|
|
|
|
- bar_icon_battery(px, BAR_PWR_Y,
|
|
|
|
|
- bar_batt_pct,
|
|
|
|
|
- batt_color(bar_batt_pct));
|
|
|
|
|
- bar_pwr_x = px;
|
|
|
|
|
- right = px - 8;
|
|
|
|
|
- if (bar_pwr_hot && bar_batt_pct >= 0) {
|
|
|
|
|
- char lb[8];
|
|
|
|
|
- unsigned int lw, bw;
|
|
|
|
|
- int bx;
|
|
|
|
|
-
|
|
|
|
|
- (void)pct_text(lb, bar_batt_pct);
|
|
|
|
|
- lw = usurf_text_width(&screen, lb);
|
|
|
|
|
- bw = lw + 10;
|
|
|
|
|
- bx = px + BAR_PWR_W - (int)bw;
|
|
|
|
|
- if (bx < 4)
|
|
|
|
|
- bx = 4;
|
|
|
|
|
- if (bx + (int)bw > (int)fbw - 4)
|
|
|
|
|
- bx = (int)fbw - 4 - (int)bw;
|
|
|
|
|
- bar_pwr_tip_x = bx;
|
|
|
|
|
- bar_pwr_tip_y = WM_BAR_H + 2;
|
|
|
|
|
- bar_pwr_tip_w = bw;
|
|
|
|
|
- bar_pwr_tip_h = BAR_TIP_H;
|
|
|
|
|
- bar_pwr_tip_want = 1;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- /* The network status sits to the left of the power icon, so it
|
|
|
|
|
- * survives narrow screens and a full temperature cluster. */
|
|
|
|
|
- {
|
|
|
|
|
- int nx = right - BAR_NET_W;
|
|
|
|
|
-
|
|
|
|
|
- if (nx >= min_x) {
|
|
|
|
|
- if (bar_net_hot)
|
|
|
|
|
- usurf_fill(&screen, nx - 3, 2,
|
|
|
|
|
- BAR_NET_W + 6,
|
|
|
|
|
- WM_BAR_H - 7, 0x3A3A55u);
|
|
|
|
|
- bar_draw_net_icon(nx, BAR_NET_Y);
|
|
|
|
|
- bar_net_x = nx;
|
|
|
|
|
- bar_net_w = BAR_NET_W;
|
|
|
|
|
- right = nx - 8;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ pwr_px = right - BAR_PWR_W;
|
|
|
|
|
+ if (pwr_px >= min_x)
|
|
|
|
|
+ right = pwr_px - 8;
|
|
|
|
|
+ else
|
|
|
|
|
+ pwr_px = -1;
|
|
|
}
|
|
}
|
|
|
|
|
+ net_nx = right - BAR_NET_W;
|
|
|
|
|
+ if (net_nx >= min_x)
|
|
|
|
|
+ right = net_nx - 8;
|
|
|
|
|
+ else
|
|
|
|
|
+ net_nx = -1;
|
|
|
if (u_rtc_datetime(dt, sizeof(dt)) == 0) {
|
|
if (u_rtc_datetime(dt, sizeof(dt)) == 0) {
|
|
|
- char cdt[12];
|
|
|
|
|
- const char *txt = dt;
|
|
|
|
|
int tw = (int)usurf_text_width(&screen, dt);
|
|
int tw = (int)usurf_text_width(&screen, dt);
|
|
|
int tx = right - tw;
|
|
int tx = right - tw;
|
|
|
- unsigned int i;
|
|
|
|
|
|
|
+ unsigned int k;
|
|
|
|
|
|
|
|
if (tx < min_x) {
|
|
if (tx < min_x) {
|
|
|
/* Compact form "MM-DD HH:MM" from
|
|
/* Compact form "MM-DD HH:MM" from
|
|
|
- * "YYYY-MM-DD HH:MM:SS" when the launcher row is
|
|
|
|
|
- * too wide for the full date. */
|
|
|
|
|
- for (i = 0; i < 11 && dt[5 + i]; i++)
|
|
|
|
|
- cdt[i] = dt[5 + i];
|
|
|
|
|
- cdt[i] = '\0';
|
|
|
|
|
- txt = cdt;
|
|
|
|
|
|
|
+ * "YYYY-MM-DD HH:MM:SS" when the status
|
|
|
|
|
+ * cluster is too wide for the full date. */
|
|
|
|
|
+ for (k = 0; k < 11 && dt[5 + k]; k++)
|
|
|
|
|
+ cdt[k] = dt[5 + k];
|
|
|
|
|
+ cdt[k] = '\0';
|
|
|
|
|
+ clock_txt = cdt;
|
|
|
tw = (int)usurf_text_width(&screen, cdt);
|
|
tw = (int)usurf_text_width(&screen, cdt);
|
|
|
tx = right - tw;
|
|
tx = right - tw;
|
|
|
}
|
|
}
|
|
|
if (tx >= min_x) {
|
|
if (tx >= min_x) {
|
|
|
- bar_clock_x = tx;
|
|
|
|
|
- bar_clock_w = (unsigned int)tw;
|
|
|
|
|
- if (bar_clock_hot)
|
|
|
|
|
- usurf_fill(&screen, tx - 5, 2,
|
|
|
|
|
- (unsigned int)tw + 10,
|
|
|
|
|
- WM_BAR_H - 7, 0x3A3A55u);
|
|
|
|
|
- usurf_text(&screen, tx, 5, txt, COL_BANNER, 0, 0,
|
|
|
|
|
- fbw, WM_BAR_H);
|
|
|
|
|
- clock_chars = (unsigned int)tw;
|
|
|
|
|
|
|
+ clock_tx = tx;
|
|
|
|
|
+ right = tx - 8;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- if (clock_chars)
|
|
|
|
|
- right -= (int)clock_chars + 8;
|
|
|
|
|
if (bar_temp_c >= 0) {
|
|
if (bar_temp_c >= 0) {
|
|
|
- char tb[12];
|
|
|
|
|
- int tx;
|
|
|
|
|
-
|
|
|
|
|
(void)temp_text(tb, bar_temp_c);
|
|
(void)temp_text(tb, bar_temp_c);
|
|
|
- tx = right - (int)usurf_text_width(&screen, tb);
|
|
|
|
|
|
|
+ temp_tw = (int)usurf_text_width(&screen, tb);
|
|
|
|
|
+ temp_tx = right - temp_tw;
|
|
|
|
|
+ if (temp_tx < min_x)
|
|
|
|
|
+ temp_tx = -1;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (tx >= min_x) {
|
|
|
|
|
- usurf_text(&screen, tx, 5, tb,
|
|
|
|
|
- temp_color(bar_temp_c), 0, 0,
|
|
|
|
|
- fbw, WM_BAR_H);
|
|
|
|
|
- right = tx - 8;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ /* The status labels form one click target: record the whole
|
|
|
|
|
+ * cluster and paint one rounded hover pill behind it. */
|
|
|
|
|
+ left = pwr_px;
|
|
|
|
|
+ if (net_nx >= 0)
|
|
|
|
|
+ left = net_nx;
|
|
|
|
|
+ if (clock_tx >= 0)
|
|
|
|
|
+ left = clock_tx;
|
|
|
|
|
+ if (temp_tx >= 0)
|
|
|
|
|
+ left = temp_tx;
|
|
|
|
|
+ if (left >= 0) {
|
|
|
|
|
+ bar_status_x = left - 4;
|
|
|
|
|
+ if (bar_status_x < 0)
|
|
|
|
|
+ bar_status_x = 0;
|
|
|
|
|
+ bar_status_w = (unsigned int)((int)fbw - 2 -
|
|
|
|
|
+ bar_status_x);
|
|
|
|
|
+ bar_button_bg(bar_status_x, (int)bar_status_w,
|
|
|
|
|
+ control_pid > 0, bar_status_hot);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ bar_status_x = -1;
|
|
|
|
|
+ bar_status_w = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (pwr_px >= 0) {
|
|
|
|
|
+ if (bar_ac_online > 0)
|
|
|
|
|
+ bar_icon_ac(pwr_px, BAR_PWR_Y, 0x55FF55u);
|
|
|
|
|
+ else
|
|
|
|
|
+ bar_icon_battery(pwr_px, BAR_PWR_Y,
|
|
|
|
|
+ bar_batt_pct,
|
|
|
|
|
+ batt_color(bar_batt_pct));
|
|
|
}
|
|
}
|
|
|
|
|
+ if (net_nx >= 0)
|
|
|
|
|
+ bar_draw_net_icon(net_nx, BAR_NET_Y);
|
|
|
|
|
+ if (clock_tx >= 0)
|
|
|
|
|
+ usurf_text(&screen, clock_tx, 5, clock_txt, COL_BANNER,
|
|
|
|
|
+ 0, 0, fbw, WM_BAR_H);
|
|
|
|
|
+ if (temp_tx >= 0)
|
|
|
|
|
+ usurf_text(&screen, temp_tx, 5, tb,
|
|
|
|
|
+ temp_color(bar_temp_c), 0, 0, fbw,
|
|
|
|
|
+ WM_BAR_H);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -1086,16 +1097,6 @@ static void add_rect(struct wm_present_info *p, int x, int y,
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/* Redraw the power tooltip above whatever a render pass just painted. */
|
|
|
|
|
-static void bar_tooltip_overlay(struct wm_present_info *p)
|
|
|
|
|
-{
|
|
|
|
|
- if (!bar_pwr_tip_on || !bar_pwr_tip_want)
|
|
|
|
|
- return;
|
|
|
|
|
- bar_draw_tooltip();
|
|
|
|
|
- add_rect(p, bar_pwr_tip_on_x, bar_pwr_tip_on_y,
|
|
|
|
|
- bar_pwr_tip_on_w, bar_pwr_tip_on_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)
|
|
|
{
|
|
{
|
|
@@ -1177,11 +1178,10 @@ static void osd_draw(void)
|
|
|
0xFFD250u);
|
|
0xFFD250u);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-/* Put the power tooltip and the brightness OSD back on top after a render
|
|
|
|
|
- * pass that may have overwritten them. */
|
|
|
|
|
|
|
+/* Put the brightness OSD and the start menu back on top after a render pass
|
|
|
|
|
+ * that may have overwritten them. */
|
|
|
static void wm_overlays(struct wm_present_info *p)
|
|
static void wm_overlays(struct wm_present_info *p)
|
|
|
{
|
|
{
|
|
|
- bar_tooltip_overlay(p);
|
|
|
|
|
if (osd_show) {
|
|
if (osd_show) {
|
|
|
osd_draw();
|
|
osd_draw();
|
|
|
add_rect(p, osd_x, osd_y, osd_w, osd_h);
|
|
add_rect(p, osd_x, osd_y, osd_w, osd_h);
|
|
@@ -1410,70 +1410,49 @@ static void resist_geom(struct uwin *u, int idx, int *nx, int *ny)
|
|
|
|
|
|
|
|
/* The top-bar date/time text is also a button: it opens the Date & Time
|
|
/* The top-bar date/time text is also a button: it opens the Date & Time
|
|
|
* editor. The rectangle is recorded by draw_bar(). */
|
|
* editor. The rectangle is recorded by draw_bar(). */
|
|
|
-static int bar_clock_hit(unsigned int mx, unsigned int my)
|
|
|
|
|
-{
|
|
|
|
|
- return bar_clock_w && bar_clock_x >= 0 && my < WM_BAR_H &&
|
|
|
|
|
- (int)mx >= bar_clock_x - 5 &&
|
|
|
|
|
- (int)mx < bar_clock_x + (int)bar_clock_w + 5;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-static int bar_net_hit(unsigned int mx, unsigned int my)
|
|
|
|
|
-{
|
|
|
|
|
- return bar_net_w && bar_net_x >= 0 && my < WM_BAR_H &&
|
|
|
|
|
- (int)mx >= bar_net_x - 3 &&
|
|
|
|
|
- (int)mx < bar_net_x + (int)bar_net_w + 3;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-/* The AC/battery icon opens the control panel on a click; hovering it also
|
|
|
|
|
- * reveals the percentage tooltip below it. The tooltip area keeps the hover
|
|
|
|
|
- * alive but is not a click target. */
|
|
|
|
|
-static int bar_pwr_hit(unsigned int mx, unsigned int my)
|
|
|
|
|
-{
|
|
|
|
|
- if (my >= WM_BAR_H)
|
|
|
|
|
- return bar_pwr_tip_on &&
|
|
|
|
|
- (int)mx >= bar_pwr_tip_on_x &&
|
|
|
|
|
- (int)mx < bar_pwr_tip_on_x + (int)bar_pwr_tip_on_w &&
|
|
|
|
|
- (int)my >= bar_pwr_tip_on_y &&
|
|
|
|
|
- (int)my < bar_pwr_tip_on_y + (int)bar_pwr_tip_on_h;
|
|
|
|
|
- return bar_pwr_x >= 0 &&
|
|
|
|
|
- (int)mx >= bar_pwr_x - 3 &&
|
|
|
|
|
- (int)mx < bar_pwr_x + BAR_PWR_W + 3;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-/* The whole right status area is one button: the clock, temperature, network
|
|
|
|
|
- * and power items plus the gaps between them. The start button ends well
|
|
|
|
|
- * before WM_BAR_LEFT_END, so this never overlaps it. */
|
|
|
|
|
|
|
+/* The whole right status cluster is one button: the clock, temperature,
|
|
|
|
|
+ * network and power items plus the gaps between them. Only the rectangle
|
|
|
|
|
+ * draw_bar() recorded is clickable, so the empty bar between the start
|
|
|
|
|
+ * button and the cluster does nothing. */
|
|
|
static int bar_status_hit(unsigned int mx, unsigned int my)
|
|
static int bar_status_hit(unsigned int mx, unsigned int my)
|
|
|
{
|
|
{
|
|
|
- return my < WM_BAR_H && (int)mx >= WM_BAR_LEFT_END + 4;
|
|
|
|
|
|
|
+ return bar_status_w && bar_status_x >= 0 &&
|
|
|
|
|
+ (int)my >= BAR_BTN_Y && (int)my < BAR_BTN_Y + BAR_BTN_H &&
|
|
|
|
|
+ (int)mx >= bar_status_x &&
|
|
|
|
|
+ (int)mx < bar_status_x + (int)bar_status_w;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void sm_layout_get(struct sm_layout *l)
|
|
static void sm_layout_get(struct sm_layout *l)
|
|
|
{
|
|
{
|
|
|
int avail = (int)fbh - WM_BAR_H - 8;
|
|
int avail = (int)fbh - WM_BAR_H - 8;
|
|
|
int row = SM_ROW_H;
|
|
int row = SM_ROW_H;
|
|
|
- int total = SM_HDR_H + SM_NAPP * row + SM_SEP_H + row;
|
|
|
|
|
|
|
+ int total = SM_TOP + SM_SECT_H + SM_NAPP * row + SM_GAP + row +
|
|
|
|
|
+ SM_BOTTOM;
|
|
|
|
|
|
|
|
/* Shrink the rows to the work area, so a 540-600 px panel still fits
|
|
/* Shrink the rows to the work area, so a 540-600 px panel still fits
|
|
|
* the whole list. The low bound is the smallest legible row. */
|
|
* the whole list. The low bound is the smallest legible row. */
|
|
|
while (row > SM_MIN_ROW && total > avail) {
|
|
while (row > SM_MIN_ROW && total > avail) {
|
|
|
row--;
|
|
row--;
|
|
|
- total = SM_HDR_H + SM_NAPP * row + SM_SEP_H + row;
|
|
|
|
|
|
|
+ total = SM_TOP + SM_SECT_H + SM_NAPP * row + SM_GAP + row +
|
|
|
|
|
+ SM_BOTTOM;
|
|
|
}
|
|
}
|
|
|
l->x = 4;
|
|
l->x = 4;
|
|
|
l->y = WM_BAR_H + 2;
|
|
l->y = WM_BAR_H + 2;
|
|
|
l->w = SM_W;
|
|
l->w = SM_W;
|
|
|
l->h = total;
|
|
l->h = total;
|
|
|
l->row_h = row;
|
|
l->row_h = row;
|
|
|
- l->list_y = l->y + SM_HDR_H;
|
|
|
|
|
- l->power_y = l->list_y + SM_NAPP * row + SM_SEP_H;
|
|
|
|
|
|
|
+ l->sect_y = l->y + SM_TOP;
|
|
|
|
|
+ l->row_x = l->x + SM_PAD;
|
|
|
|
|
+ l->row_w = l->w - 2 * SM_PAD;
|
|
|
|
|
+ l->list_y = l->sect_y + SM_SECT_H;
|
|
|
|
|
+ l->power_y = l->list_y + SM_NAPP * row + SM_GAP;
|
|
|
|
|
|
|
|
l->sub_w = SM_SUB_W;
|
|
l->sub_w = SM_SUB_W;
|
|
|
- l->sub_h = 2 * row + 4;
|
|
|
|
|
- l->sub_x = l->x + l->w + 2;
|
|
|
|
|
|
|
+ l->sub_h = 2 * row + 8;
|
|
|
|
|
+ l->sub_x = l->x + l->w + 4;
|
|
|
if (l->sub_x + l->sub_w > (int)fbw - 2) {
|
|
if (l->sub_x + l->sub_w > (int)fbw - 2) {
|
|
|
- if (l->x - l->sub_w - 2 >= 0)
|
|
|
|
|
- l->sub_x = l->x - l->sub_w - 2;
|
|
|
|
|
|
|
+ if (l->x - l->sub_w - 4 >= 0)
|
|
|
|
|
+ l->sub_x = l->x - l->sub_w - 4;
|
|
|
else
|
|
else
|
|
|
l->sub_x = (int)fbw - 2 - l->sub_w;
|
|
l->sub_x = (int)fbw - 2 - l->sub_w;
|
|
|
}
|
|
}
|
|
@@ -1488,15 +1467,6 @@ static void sm_layout_get(struct sm_layout *l)
|
|
|
l->sub_y = 0;
|
|
l->sub_y = 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-static void sm_frame(int x, int y, int w, int h)
|
|
|
|
|
-{
|
|
|
|
|
- usurf_fill(&screen, x, y, (unsigned int)w, (unsigned int)h, 0x161622u);
|
|
|
|
|
- usurf_fill(&screen, x, y, (unsigned int)w, 1, 0x5A5A7Au);
|
|
|
|
|
- usurf_fill(&screen, x, y + h - 1, (unsigned int)w, 1, 0x5A5A7Au);
|
|
|
|
|
- usurf_fill(&screen, x, y, 1, (unsigned int)h, 0x5A5A7Au);
|
|
|
|
|
- usurf_fill(&screen, x + w - 1, y, 1, (unsigned int)h, 0x5A5A7Au);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
static void sm_tile(int x, int y, int size, unsigned int rgb, char letter)
|
|
static void sm_tile(int x, int y, int size, unsigned int rgb, char letter)
|
|
|
{
|
|
{
|
|
|
char s[2];
|
|
char s[2];
|
|
@@ -1506,7 +1476,7 @@ static void sm_tile(int x, int y, int size, unsigned int rgb, char letter)
|
|
|
size = 12;
|
|
size = 12;
|
|
|
s[0] = letter;
|
|
s[0] = letter;
|
|
|
s[1] = '\0';
|
|
s[1] = '\0';
|
|
|
- usurf_fill(&screen, x, y, (unsigned int)size, (unsigned int)size, rgb);
|
|
|
|
|
|
|
+ sm_fill_round(x, y, size, size, 4, rgb);
|
|
|
tw = (int)usurf_text_width(&screen, s);
|
|
tw = (int)usurf_text_width(&screen, s);
|
|
|
tx = x + (size - tw) / 2;
|
|
tx = x + (size - tw) / 2;
|
|
|
ty = y + (size - 16) / 2;
|
|
ty = y + (size - 16) / 2;
|
|
@@ -1519,77 +1489,76 @@ static void sm_draw_app(int i, const struct sm_layout *l)
|
|
|
const struct sm_app *a = &sm_apps[i];
|
|
const struct sm_app *a = &sm_apps[i];
|
|
|
int ry = l->list_y + i * l->row_h;
|
|
int ry = l->list_y + i * l->row_h;
|
|
|
int ty = ry + (l->row_h - 16) / 2;
|
|
int ty = ry + (l->row_h - 16) / 2;
|
|
|
- int tile = l->row_h - 4;
|
|
|
|
|
|
|
+ int tile = l->row_h - 8;
|
|
|
|
|
|
|
|
if (tile > SM_TILE)
|
|
if (tile > SM_TILE)
|
|
|
tile = SM_TILE;
|
|
tile = SM_TILE;
|
|
|
if (sm_hot == i)
|
|
if (sm_hot == i)
|
|
|
- usurf_fill(&screen, l->x + 4, ry + 1, l->w - 8,
|
|
|
|
|
- (unsigned int)(l->row_h - 2), 0x365CA6u);
|
|
|
|
|
- sm_tile(l->x + 10, ry + (l->row_h - tile) / 2, tile,
|
|
|
|
|
|
|
+ sm_fill_round(l->row_x, ry + 1, l->row_w,
|
|
|
|
|
+ l->row_h - 2, SM_RADIUS, SM_PANEL_ALT);
|
|
|
|
|
+ sm_tile(l->row_x + 10, ry + (l->row_h - tile) / 2, tile,
|
|
|
a->tile, a->letter);
|
|
a->tile, a->letter);
|
|
|
- usurf_text(&screen, l->x + 36, ty, a->label,
|
|
|
|
|
- sm_hot == i ? COL_WHITE : 0xE8E8F6u,
|
|
|
|
|
- l->x, l->y, l->w, l->h);
|
|
|
|
|
|
|
+ usurf_text(&screen, l->row_x + 36, ty, a->label, SM_TEXT,
|
|
|
|
|
+ l->x, l->y, (unsigned int)l->w, (unsigned int)l->h);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static void sm_draw(void)
|
|
static void sm_draw(void)
|
|
|
{
|
|
{
|
|
|
struct sm_layout l;
|
|
struct sm_layout l;
|
|
|
- unsigned int ver_w;
|
|
|
|
|
int i, ty;
|
|
int i, ty;
|
|
|
|
|
|
|
|
if (!sm_open)
|
|
if (!sm_open)
|
|
|
return;
|
|
return;
|
|
|
sm_layout_get(&l);
|
|
sm_layout_get(&l);
|
|
|
- sm_frame(l.x, l.y, l.w, l.h);
|
|
|
|
|
|
|
|
|
|
- ver_w = usurf_text_width(&screen, "v" OS_VERSION);
|
|
|
|
|
- usurf_text(&screen, l.x + 12, l.y + 6, OS_NAME, COL_WHITE,
|
|
|
|
|
- l.x, l.y, (unsigned int)l.w, (unsigned int)l.h);
|
|
|
|
|
- usurf_text(&screen, l.x + l.w - 12 - (int)ver_w, l.y + 6,
|
|
|
|
|
- "v" OS_VERSION, 0x9A9AAEu,
|
|
|
|
|
- l.x, l.y, (unsigned int)l.w, (unsigned int)l.h);
|
|
|
|
|
- usurf_text(&screen, l.x + 12, l.y + 25, "All apps", 0x9A9AAEu,
|
|
|
|
|
- l.x, l.y, (unsigned int)l.w, (unsigned int)l.h);
|
|
|
|
|
- usurf_fill(&screen, l.x + 8, l.list_y - 1, l.w - 16, 1, 0x3A3A55u);
|
|
|
|
|
|
|
+ /* Flat theme.bg panel with no rim, exactly like the netmenu popover.
|
|
|
|
|
+ * The Applications caption is the first item: there is no separate
|
|
|
|
|
+ * banner card. */
|
|
|
|
|
+ usurf_fill(&screen, l.x, l.y, (unsigned int)l.w, (unsigned int)l.h,
|
|
|
|
|
+ SM_BG);
|
|
|
|
|
+ usurf_text(&screen, l.x + SM_PAD, l.sect_y + 3, "Applications",
|
|
|
|
|
+ SM_TEXT_DIM, l.x, l.y, (unsigned int)l.w,
|
|
|
|
|
+ (unsigned int)l.h);
|
|
|
|
|
|
|
|
for (i = 0; i < SM_NAPP; i++)
|
|
for (i = 0; i < SM_NAPP; i++)
|
|
|
sm_draw_app(i, &l);
|
|
sm_draw_app(i, &l);
|
|
|
|
|
|
|
|
- /* Power row and the separator above it. */
|
|
|
|
|
- usurf_fill(&screen, l.x + 8, l.power_y - 4, l.w - 16, 1, 0x3A3A55u);
|
|
|
|
|
- if (sm_power_hot == 1 || sm_power_open)
|
|
|
|
|
- usurf_fill(&screen, l.x + 4, l.power_y + 1, l.w - 8,
|
|
|
|
|
- (unsigned int)(l.row_h - 2), 0x365CA6u);
|
|
|
|
|
|
|
+ /* The Power row is a quick-settings tile rather than a plain list
|
|
|
|
|
+ * row, so the submenu entry reads as the panel's last action. */
|
|
|
|
|
+ sm_fill_round(l.row_x, l.power_y, l.row_w, l.row_h, SM_RADIUS,
|
|
|
|
|
+ sm_power_open ? SM_SEL :
|
|
|
|
|
+ (sm_power_hot == 1 ? SM_BTN_HOT : SM_PANEL_ALT));
|
|
|
ty = l.power_y + (l.row_h - 16) / 2;
|
|
ty = l.power_y + (l.row_h - 16) / 2;
|
|
|
- usurf_text(&screen, l.x + 12, ty, "Power",
|
|
|
|
|
- sm_power_hot == 1 || sm_power_open ? COL_WHITE : 0xE8E8F6u,
|
|
|
|
|
|
|
+ usurf_text(&screen, l.row_x + 12, ty, "Power",
|
|
|
|
|
+ sm_power_open || sm_power_hot == 1 ? COL_WHITE : SM_TEXT,
|
|
|
l.x, l.y, (unsigned int)l.w, (unsigned int)l.h);
|
|
l.x, l.y, (unsigned int)l.w, (unsigned int)l.h);
|
|
|
{
|
|
{
|
|
|
const char *arrow = sm_power_open ? "v" : ">";
|
|
const char *arrow = sm_power_open ? "v" : ">";
|
|
|
int aw = (int)usurf_text_width(&screen, arrow);
|
|
int aw = (int)usurf_text_width(&screen, arrow);
|
|
|
|
|
|
|
|
- usurf_text(&screen, l.x + l.w - 12 - aw, ty, arrow,
|
|
|
|
|
- 0x9A9AAEu, l.x, l.y, (unsigned int)l.w,
|
|
|
|
|
- (unsigned int)l.h);
|
|
|
|
|
|
|
+ usurf_text(&screen, l.row_x + l.row_w - 12 - aw, ty, arrow,
|
|
|
|
|
+ sm_power_open || sm_power_hot == 1 ? COL_WHITE :
|
|
|
|
|
+ SM_TEXT_DIM,
|
|
|
|
|
+ l.x, l.y, (unsigned int)l.w, (unsigned int)l.h);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (!sm_power_open)
|
|
if (!sm_power_open)
|
|
|
return;
|
|
return;
|
|
|
- sm_frame(l.sub_x, l.sub_y, l.sub_w, l.sub_h);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /* Submenu: a rounded panel card with two rounded selection rows. */
|
|
|
|
|
+ sm_fill_round(l.sub_x, l.sub_y, l.sub_w, l.sub_h, SM_RADIUS,
|
|
|
|
|
+ SM_PANEL);
|
|
|
for (i = 0; i < 2; i++) {
|
|
for (i = 0; i < 2; i++) {
|
|
|
- int sy = l.sub_y + 2 + i * l.row_h;
|
|
|
|
|
|
|
+ int sy = l.sub_y + 4 + i * l.row_h;
|
|
|
int sty = sy + (l.row_h - 16) / 2;
|
|
int sty = sy + (l.row_h - 16) / 2;
|
|
|
|
|
|
|
|
if (sm_power_hot == i + 2)
|
|
if (sm_power_hot == i + 2)
|
|
|
- usurf_fill(&screen, l.sub_x + 3, sy + 1, l.sub_w - 6,
|
|
|
|
|
- (unsigned int)(l.row_h - 2), 0x365CA6u);
|
|
|
|
|
|
|
+ sm_fill_round(l.sub_x + 4, sy + 1, l.sub_w - 8,
|
|
|
|
|
+ l.row_h - 2, 4, SM_SEL);
|
|
|
usurf_text(&screen, l.sub_x + 12, sty,
|
|
usurf_text(&screen, l.sub_x + 12, sty,
|
|
|
i == 0 ? "Reboot" : "Power off",
|
|
i == 0 ? "Reboot" : "Power off",
|
|
|
- i == 1 ? (sm_power_hot == 3 ? COL_WHITE : 0xFF9090u)
|
|
|
|
|
- : (sm_power_hot == 2 ? COL_WHITE
|
|
|
|
|
- : 0xE8E8F6u),
|
|
|
|
|
|
|
+ i == 1 ? (sm_power_hot == 3 ? COL_WHITE : SM_ERROR)
|
|
|
|
|
+ : (sm_power_hot == 2 ? COL_WHITE : SM_TEXT),
|
|
|
l.sub_x, l.sub_y, (unsigned int)l.sub_w,
|
|
l.sub_x, l.sub_y, (unsigned int)l.sub_w,
|
|
|
(unsigned int)l.sub_h);
|
|
(unsigned int)l.sub_h);
|
|
|
}
|
|
}
|
|
@@ -1607,16 +1576,19 @@ static int sm_hit(unsigned int mx, unsigned int my)
|
|
|
sm_layout_get(&l);
|
|
sm_layout_get(&l);
|
|
|
if (sm_power_open &&
|
|
if (sm_power_open &&
|
|
|
x >= l.sub_x && x < l.sub_x + l.sub_w &&
|
|
x >= l.sub_x && x < l.sub_x + l.sub_w &&
|
|
|
- y >= l.sub_y + 2 && y < l.sub_y + 2 + 2 * l.row_h)
|
|
|
|
|
- return (y - (l.sub_y + 2)) / l.row_h == 0 ?
|
|
|
|
|
- SM_HIT_REBOOT : SM_HIT_POWEROFF;
|
|
|
|
|
- if (x < l.x || x >= l.x + l.w)
|
|
|
|
|
|
|
+ y >= l.sub_y && y < l.sub_y + l.sub_h) {
|
|
|
|
|
+ if (y >= l.sub_y + 4 && y < l.sub_y + 4 + 2 * l.row_h)
|
|
|
|
|
+ return (y - (l.sub_y + 4)) / l.row_h == 0 ?
|
|
|
|
|
+ SM_HIT_REBOOT : SM_HIT_POWEROFF;
|
|
|
|
|
+ return SM_HIT_MENU;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (x < l.x || x >= l.x + l.w || y < l.y || y >= l.y + l.h)
|
|
|
return SM_HIT_NONE;
|
|
return SM_HIT_NONE;
|
|
|
if (y >= l.list_y && y < l.list_y + SM_NAPP * l.row_h)
|
|
if (y >= l.list_y && y < l.list_y + SM_NAPP * l.row_h)
|
|
|
return (y - l.list_y) / l.row_h;
|
|
return (y - l.list_y) / l.row_h;
|
|
|
if (y >= l.power_y && y < l.power_y + l.row_h)
|
|
if (y >= l.power_y && y < l.power_y + l.row_h)
|
|
|
return SM_HIT_POWER;
|
|
return SM_HIT_POWER;
|
|
|
- return SM_HIT_NONE;
|
|
|
|
|
|
|
+ return SM_HIT_MENU;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static int sm_update_hover(unsigned int mx, unsigned int my)
|
|
static int sm_update_hover(unsigned int mx, unsigned int my)
|
|
@@ -1778,26 +1750,10 @@ static void do_update(struct wm_status *st)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
{
|
|
{
|
|
|
- int hot = bar_clock_hit(st->mouse.x, st->mouse.y);
|
|
|
|
|
-
|
|
|
|
|
- if (hot != bar_clock_hot) {
|
|
|
|
|
- bar_clock_hot = hot;
|
|
|
|
|
- bar_dirty = 1;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- {
|
|
|
|
|
- int hot = bar_net_hit(st->mouse.x, st->mouse.y);
|
|
|
|
|
|
|
+ int hot = bar_status_hit(st->mouse.x, st->mouse.y);
|
|
|
|
|
|
|
|
- if (hot != bar_net_hot) {
|
|
|
|
|
- bar_net_hot = hot;
|
|
|
|
|
- bar_dirty = 1;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- {
|
|
|
|
|
- int hot = bar_pwr_hit(st->mouse.x, st->mouse.y);
|
|
|
|
|
-
|
|
|
|
|
- if (hot != bar_pwr_hot) {
|
|
|
|
|
- bar_pwr_hot = hot;
|
|
|
|
|
|
|
+ if (hot != bar_status_hot) {
|
|
|
|
|
+ bar_status_hot = hot;
|
|
|
bar_dirty = 1;
|
|
bar_dirty = 1;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -1866,8 +1822,10 @@ static void do_update(struct wm_status *st)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if (!control_found && control_pid > 0 &&
|
|
if (!control_found && control_pid > 0 &&
|
|
|
- !u_alive((unsigned int)control_pid))
|
|
|
|
|
|
|
+ !u_alive((unsigned int)control_pid)) {
|
|
|
control_pid = 0;
|
|
control_pid = 0;
|
|
|
|
|
+ bar_dirty = 1;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
/* The RTC is slow (CMOS polling) and the temperature/battery state only
|
|
/* The RTC is slow (CMOS polling) and the temperature/battery state only
|
|
|
* changes once a second; query them at 1 Hz instead of every 10 ms. */
|
|
* changes once a second; query them at 1 Hz instead of every 10 ms. */
|
|
@@ -1943,7 +1901,6 @@ static void do_update(struct wm_status *st)
|
|
|
{
|
|
{
|
|
|
draw_rect(0, 0, fbw, fbh);
|
|
draw_rect(0, 0, fbw, fbh);
|
|
|
draw_bar();
|
|
draw_bar();
|
|
|
- bar_tooltip_commit();
|
|
|
|
|
if (osd_show)
|
|
if (osd_show)
|
|
|
osd_draw();
|
|
osd_draw();
|
|
|
osd_visible = osd_show;
|
|
osd_visible = osd_show;
|
|
@@ -1995,14 +1952,6 @@ static void do_update(struct wm_status *st)
|
|
|
need = 1;
|
|
need = 1;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /* Repaint the previous tooltip area so hiding or moving it restores
|
|
|
|
|
- * the window/desktop underneath; the new one is drawn after the
|
|
|
|
|
- * windows below. */
|
|
|
|
|
- if (bar_pwr_tip_on) {
|
|
|
|
|
- need = 1;
|
|
|
|
|
- add_rect(&present, bar_pwr_tip_on_x, bar_pwr_tip_on_y,
|
|
|
|
|
- bar_pwr_tip_on_w, bar_pwr_tip_on_h);
|
|
|
|
|
- }
|
|
|
|
|
if (sm_dirty && sm_open)
|
|
if (sm_dirty && sm_open)
|
|
|
need = 1;
|
|
need = 1;
|
|
|
|
|
|
|
@@ -2021,13 +1970,6 @@ static void do_update(struct wm_status *st)
|
|
|
present.rect[i].w, present.rect[i].h);
|
|
present.rect[i].w, present.rect[i].h);
|
|
|
if (bar_dirty)
|
|
if (bar_dirty)
|
|
|
draw_bar();
|
|
draw_bar();
|
|
|
- if (bar_pwr_tip_want) {
|
|
|
|
|
- bar_tooltip_commit();
|
|
|
|
|
- add_rect(&present, bar_pwr_tip_on_x, bar_pwr_tip_on_y,
|
|
|
|
|
- bar_pwr_tip_on_w, bar_pwr_tip_on_h);
|
|
|
|
|
- } else {
|
|
|
|
|
- bar_pwr_tip_on = 0;
|
|
|
|
|
- }
|
|
|
|
|
if (osd_show) {
|
|
if (osd_show) {
|
|
|
osd_draw();
|
|
osd_draw();
|
|
|
add_rect(&present, osd_x, osd_y, osd_w, osd_h);
|
|
add_rect(&present, osd_x, osd_y, osd_w, osd_h);
|
|
@@ -2266,7 +2208,9 @@ static void update_cursor(unsigned int mx, unsigned int my)
|
|
|
} else if (sm_open) {
|
|
} else if (sm_open) {
|
|
|
/* The menu is modal: a hand over its items, the arrow
|
|
/* The menu is modal: a hand over its items, the arrow
|
|
|
* elsewhere, never a window's content cursor underneath. */
|
|
* elsewhere, never a window's content cursor underneath. */
|
|
|
- want = sm_hit(mx, my) == SM_HIT_NONE ?
|
|
|
|
|
|
|
+ int hit = sm_hit(mx, my);
|
|
|
|
|
+
|
|
|
|
|
+ want = (hit == SM_HIT_NONE || hit == SM_HIT_MENU) ?
|
|
|
CURSOR_DEFAULT : CURSOR_POINTER;
|
|
CURSOR_DEFAULT : CURSOR_POINTER;
|
|
|
} else if (my < WM_BAR_H) {
|
|
} else if (my < WM_BAR_H) {
|
|
|
if (bar_start_hit(mx, my) || bar_status_hit(mx, my))
|
|
if (bar_start_hit(mx, my) || bar_status_hit(mx, my))
|
|
@@ -2316,7 +2260,7 @@ static void handle_mouse(struct wm_status *st)
|
|
|
bar_notice("poweroff failed");
|
|
bar_notice("poweroff failed");
|
|
|
} else if (hit >= 0) {
|
|
} else if (hit >= 0) {
|
|
|
sm_launch(hit);
|
|
sm_launch(hit);
|
|
|
- } else {
|
|
|
|
|
|
|
+ } else if (hit != SM_HIT_MENU) {
|
|
|
sm_close();
|
|
sm_close();
|
|
|
}
|
|
}
|
|
|
goto mouse_done;
|
|
goto mouse_done;
|