|
|
@@ -71,10 +71,11 @@ static int bar_temp_c = -1;
|
|
|
static int bar_batt_pct = -1;
|
|
|
static int bar_batt_charging;
|
|
|
static int bar_ac_online = -1;
|
|
|
-/* Battery/AC status icon: a plug on AC, a level-filled battery otherwise.
|
|
|
- * The rightmost bar item; hovering it shows a percentage tooltip below it. */
|
|
|
+/* 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. */
|
|
|
#define BAR_PWR_W 24
|
|
|
-#define BAR_PWR_Y 6
|
|
|
+#define BAR_PWR_Y 7
|
|
|
#define BAR_TIP_H 20
|
|
|
static int bar_pwr_x = -1;
|
|
|
static int bar_pwr_hot;
|
|
|
@@ -110,7 +111,7 @@ static unsigned int stat_frames, stat_ms, stat_px, stat_max, stat_last;
|
|
|
|
|
|
/* Network status icon (right side of the bar). */
|
|
|
#define BAR_NET_W 24
|
|
|
-#define BAR_NET_Y 6
|
|
|
+#define BAR_NET_Y 7
|
|
|
#define BAR_NET_NONE 0
|
|
|
#define BAR_NET_WIRED 1
|
|
|
#define BAR_NET_WIFI 2
|
|
|
@@ -216,60 +217,28 @@ static int net_rssi_bars(int rssi)
|
|
|
return 1;
|
|
|
}
|
|
|
|
|
|
-/* Small top-bar pictograms, drawn directly into the shadow. */
|
|
|
-static void bar_icon_cable(int x, int y, unsigned int c)
|
|
|
-{
|
|
|
- usurf_fill(&screen, x + 1, y + 6, 9, 8, c);
|
|
|
- usurf_fill(&screen, x + 3, y + 8, 2, 2, COL_BG);
|
|
|
- usurf_fill(&screen, x + 6, y + 8, 2, 2, COL_BG);
|
|
|
- usurf_fill(&screen, x + 10, y + 9, 7, 2, c);
|
|
|
- usurf_fill(&screen, x + 17, y + 5, 5, 10, c);
|
|
|
- usurf_fill(&screen, x + 19, y + 7, 2, 3, COL_BG);
|
|
|
-}
|
|
|
-
|
|
|
-static void bar_icon_wifi(int x, int y, unsigned int c, int bars)
|
|
|
-{
|
|
|
- int i;
|
|
|
-
|
|
|
- for (i = 0; i < 4; i++) {
|
|
|
- int h = 3 + i * 3;
|
|
|
-
|
|
|
- usurf_fill(&screen, x + 3 + i * 5, y + 16 - h, 3, h,
|
|
|
- i < bars ? c : 0x4A4A5Au);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-static void bar_icon_x(int x, int y, unsigned int c)
|
|
|
-{
|
|
|
- int i;
|
|
|
-
|
|
|
- for (i = 0; i < 12; i++) {
|
|
|
- usurf_fill(&screen, x + 6 + i, y + 4 + i, 2, 2, c);
|
|
|
- usurf_fill(&screen, x + 17 - i, y + 4 + i, 2, 2, c);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-static void bar_icon_usb(int x, int y, unsigned int c)
|
|
|
-{
|
|
|
- usurf_text(&screen, x + 1, y + 1, "USB", c, 0, 0, fbw, WM_BAR_H);
|
|
|
-}
|
|
|
-
|
|
|
+/* Small top-bar pictograms: Adwaita symbolic masks from the pack, centered
|
|
|
+ * in their 24 px hit slots. */
|
|
|
static void bar_draw_net_icon(int x, int y)
|
|
|
{
|
|
|
+ enum uwm_icon ic;
|
|
|
+
|
|
|
switch (bar_net_kind) {
|
|
|
case BAR_NET_WIRED:
|
|
|
- bar_icon_cable(x, y, bar_net_color);
|
|
|
+ ic = UWM_ICON_NET_WIRED;
|
|
|
break;
|
|
|
case BAR_NET_WIFI:
|
|
|
- bar_icon_wifi(x, y, bar_net_color, bar_net_bars);
|
|
|
+ ic = bar_net_bars > 0 ? UWM_ICON_NET_WIFI_0 + bar_net_bars :
|
|
|
+ UWM_ICON_NET_WIFI_OFF;
|
|
|
break;
|
|
|
case BAR_NET_USB:
|
|
|
- bar_icon_usb(x, y, bar_net_color);
|
|
|
+ ic = UWM_ICON_NET_USB;
|
|
|
break;
|
|
|
default:
|
|
|
- bar_icon_x(x, y, bar_net_color);
|
|
|
+ ic = UWM_ICON_NET_WIRED_OFF;
|
|
|
break;
|
|
|
}
|
|
|
+ (void)usurf_icon(&screen, x + 4, y, ic, bar_net_color);
|
|
|
}
|
|
|
|
|
|
/* 1 Hz poll: cached state -> the bar's network icon. The WiFi status call is
|
|
|
@@ -291,11 +260,18 @@ static int poll_net_status(void)
|
|
|
struct sys_wifi_status ws;
|
|
|
|
|
|
if (u_wifi(SYS_WIFI_STATUS, (int)&ws, 0) == 0 &&
|
|
|
- ws.present && ws.state >= SYS_WIFI_ST_ASSOC) {
|
|
|
+ ws.present) {
|
|
|
kind = BAR_NET_WIFI;
|
|
|
- bars = net_rssi_bars(ws.rssi);
|
|
|
- color = (ws.state >= SYS_WIFI_ST_LINK && have_ip) ?
|
|
|
- 0x55FF55u : 0xFFD250u;
|
|
|
+ if (ws.state >= SYS_WIFI_ST_ASSOC) {
|
|
|
+ bars = net_rssi_bars(ws.rssi);
|
|
|
+ color = (ws.state >= SYS_WIFI_ST_LINK &&
|
|
|
+ have_ip) ?
|
|
|
+ 0x55FF55u : 0xFFD250u;
|
|
|
+ } else {
|
|
|
+ /* Card present, not associated. */
|
|
|
+ bars = 0;
|
|
|
+ color = 0xFF5050u;
|
|
|
+ }
|
|
|
}
|
|
|
} else if (name_is(ni.name, "rndis")) {
|
|
|
kind = BAR_NET_USB;
|
|
|
@@ -360,31 +336,35 @@ static unsigned int batt_color(int pct)
|
|
|
return 0x55FF55u;
|
|
|
}
|
|
|
|
|
|
-/* Battery pictogram: outline, terminal and a fill proportional to the
|
|
|
- * percentage. A critical charge turns the outline red as well. */
|
|
|
+/* Battery: the Adwaita outline with our own level fill over the lower
|
|
|
+ * interior. The symbol's body is striped, so the interior is cleared to a
|
|
|
+ * dim shade of the state colour first; the level then reads as a bright
|
|
|
+ * block inside the outline. A critical charge turns the outline red too.
|
|
|
+ * Geometry of battery-symbolic at 16 px: body x2..13, cavity x4..11 and
|
|
|
+ * y4..13. */
|
|
|
+static unsigned int batt_dim(unsigned int c)
|
|
|
+{
|
|
|
+ return (c >> 2) & 0x3F3F3F;
|
|
|
+}
|
|
|
+
|
|
|
static void bar_icon_battery(int x, int y, int pct, unsigned int c)
|
|
|
{
|
|
|
- unsigned int frame = c;
|
|
|
- unsigned int fill = (unsigned int)((14 * pct + 99) / 100);
|
|
|
+ unsigned int fill = (unsigned int)((10 * pct + 99) / 100);
|
|
|
+ int ix = x + 4;
|
|
|
|
|
|
- usurf_fill(&screen, x + 1, y + 2, 18, 2, frame);
|
|
|
- usurf_fill(&screen, x + 1, y + 14, 18, 2, frame);
|
|
|
- usurf_fill(&screen, x + 1, y + 2, 2, 14, frame);
|
|
|
- usurf_fill(&screen, x + 17, y + 2, 2, 14, frame);
|
|
|
- usurf_fill(&screen, x + 19, y + 6, 3, 6, frame);
|
|
|
- if (fill > 14)
|
|
|
- fill = 14;
|
|
|
+ if (fill > 10)
|
|
|
+ fill = 10;
|
|
|
+ if (!usurf_icon(&screen, ix, y, UWM_ICON_BATTERY, c))
|
|
|
+ return;
|
|
|
+ usurf_fill(&screen, ix + 4, y + 4, 8, 10, batt_dim(c));
|
|
|
if (fill)
|
|
|
- usurf_fill(&screen, x + 3, y + 4, fill, 10, c);
|
|
|
+ usurf_fill(&screen, ix + 4, y + 14 - (int)fill, 8, fill, c);
|
|
|
}
|
|
|
|
|
|
-/* AC plug pictogram: two prongs and the body, kept compact in height. */
|
|
|
-static void bar_icon_plug(int x, int y, unsigned int c)
|
|
|
+/* AC adapter: the Adwaita plug symbol. */
|
|
|
+static void bar_icon_ac(int x, int y, unsigned int c)
|
|
|
{
|
|
|
- usurf_fill(&screen, x + 7, y + 2, 3, 5, c);
|
|
|
- usurf_fill(&screen, x + 14, y + 2, 3, 5, c);
|
|
|
- usurf_fill(&screen, x + 5, y + 7, 14, 7, c);
|
|
|
- usurf_fill(&screen, x + 7, y + 9, 10, 3, COL_BG);
|
|
|
+ (void)usurf_icon(&screen, x + 4, y, UWM_ICON_AC, c);
|
|
|
}
|
|
|
|
|
|
/* Percentage tooltip: a small box below the status icon. It is drawn after
|
|
|
@@ -515,7 +495,7 @@ static void draw_bar(void)
|
|
|
BAR_PWR_W + 6,
|
|
|
WM_BAR_H - 7, 0x3A3A55u);
|
|
|
if (bar_ac_online > 0)
|
|
|
- bar_icon_plug(px, BAR_PWR_Y, 0x55FF55u);
|
|
|
+ bar_icon_ac(px, BAR_PWR_Y, 0x55FF55u);
|
|
|
else
|
|
|
bar_icon_battery(px, BAR_PWR_Y,
|
|
|
bar_batt_pct,
|