feat: various power and thermal optimizations, fix Printers app regression
This commit is contained in:
@@ -267,6 +267,36 @@ static void text_fit(const char* src, char* out, int out_len, int max_w) {
|
||||
montauk::strncpy(out, ell, out_len - 1);
|
||||
}
|
||||
|
||||
static void format_resolved_transport_line(const IppUri& uri, char* out, int out_len) {
|
||||
if (!out || out_len <= 0) return;
|
||||
out[0] = '\0';
|
||||
|
||||
const char* transport = uri.use_tls ? "TLS" : "Plain TCP";
|
||||
uint32_t ip = 0;
|
||||
if (!parse_ipv4_literal(uri.host, &ip))
|
||||
ip = g_app.probe_caps.resolved_ip;
|
||||
|
||||
if (ip != 0) {
|
||||
char ip_text[20];
|
||||
format_ipv4(ip_text, sizeof(ip_text), ip);
|
||||
snprintf(out, out_len, "Resolved: %s Transport: %s", ip_text, transport);
|
||||
return;
|
||||
}
|
||||
|
||||
if (host_looks_like_mdns(uri.host)) {
|
||||
snprintf(out, out_len,
|
||||
"Resolved: unavailable (.local/mDNS not supported yet) Transport: %s",
|
||||
transport);
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_app.probe_valid)
|
||||
snprintf(out, out_len, "Resolved: unavailable Transport: %s", transport);
|
||||
else
|
||||
snprintf(out, out_len, "Resolved: run Probe to resolve current printer Transport: %s",
|
||||
transport);
|
||||
}
|
||||
|
||||
static bool main_mouse_in_rect(const Rect& rect) {
|
||||
return rect.contains(g_app.mouse_x, g_app.mouse_y);
|
||||
}
|
||||
@@ -807,17 +837,7 @@ static void render_details(Canvas& c, const Layout& lo, const mtk::Theme& theme)
|
||||
c.text(x, y, line, dim);
|
||||
y += sfh + 4;
|
||||
|
||||
uint32_t ip = 0;
|
||||
if (resolve_host(normalized.host, &ip)) {
|
||||
char ip_text[20];
|
||||
format_ipv4(ip_text, sizeof(ip_text), ip);
|
||||
snprintf(line, sizeof(line), "Resolved: %s Transport: %s", ip_text,
|
||||
normalized.use_tls ? "TLS" : "Plain TCP");
|
||||
} else if (host_looks_like_mdns(normalized.host)) {
|
||||
safe_copy(line, sizeof(line), "Resolved: unavailable (.local/mDNS not supported yet)");
|
||||
} else {
|
||||
safe_copy(line, sizeof(line), "Resolved: unavailable");
|
||||
}
|
||||
format_resolved_transport_line(normalized, line, sizeof(line));
|
||||
text_fit(line, line, sizeof(line), w);
|
||||
c.text(x, y, line, dim);
|
||||
y += sfh + 4;
|
||||
@@ -943,8 +963,6 @@ static void render_details(Canvas& c, const Layout& lo, const mtk::Theme& theme)
|
||||
}
|
||||
|
||||
static void render() {
|
||||
refresh_state();
|
||||
|
||||
mtk::StandaloneHost host(&g_win);
|
||||
Canvas c = host.canvas();
|
||||
mtk::Theme theme = printers_theme();
|
||||
|
||||
Reference in New Issue
Block a user