feat: wi-fi - expand support and fix issues, add GUI components
This commit is contained in:
@@ -276,6 +276,7 @@ void gui::desktop_init(DesktopState* ds) {
|
||||
ds->icon_folder = svg_load("0:/icons/folder.svg", 16, 16, defColor);
|
||||
ds->icon_file = svg_load("0:/icons/text-x-generic.svg", 16, 16, defColor);
|
||||
ds->icon_network = svg_load("0:/icons/network-wired-symbolic.svg", 16, 16, colors::PANEL_TEXT);
|
||||
ds->icon_wifi = svg_load("0:/icons/network-wireless-symbolic.svg", 16, 16, colors::PANEL_TEXT);
|
||||
ds->icon_go_up = svg_load("0:/icons/go-up-symbolic.svg", 16, 16, defColor);
|
||||
ds->icon_go_back = svg_load("0:/icons/go-previous-symbolic.svg", 16, 16, defColor);
|
||||
ds->icon_go_forward = svg_load("0:/icons/go-next-symbolic.svg", 16, 16, defColor);
|
||||
@@ -392,6 +393,9 @@ void gui::desktop_init(DesktopState* ds) {
|
||||
ds->net_cfg_last_poll = montauk::get_milliseconds();
|
||||
ds->net_icon_rect = {0, 0, 0, 0};
|
||||
|
||||
desktop_refresh_netifs(ds);
|
||||
desktop_wifi_init(ds);
|
||||
|
||||
ds->vol_popup_open = false;
|
||||
ds->vol_icon_rect = {0, 0, 0, 0};
|
||||
int vol = montauk::audio_get_master_volume();
|
||||
@@ -465,6 +469,30 @@ static bool desktop_netcfg_equal(const montauk::abi::NetCfg& a, const montauk::a
|
||||
return true;
|
||||
}
|
||||
|
||||
// Re-read the interface registry. Cheap, and it is the only way to tell the
|
||||
// wired and wireless halves of the panel apart.
|
||||
void desktop_refresh_netifs(DesktopState* ds) {
|
||||
int n = montauk::net_interfaces(ds->netifs, DesktopState::MAX_NETIFS);
|
||||
ds->netif_count = n > 0 ? n : 0;
|
||||
ds->eth_present = false;
|
||||
for (int i = 0; i < ds->netif_count; i++) {
|
||||
if (ds->netifs[i].kind == montauk::abi::NETIF_KIND_ETHERNET)
|
||||
ds->eth_present = true;
|
||||
}
|
||||
}
|
||||
|
||||
static bool desktop_netifs_equal(const montauk::abi::NetIfInfo* a, int an,
|
||||
const montauk::abi::NetIfInfo* b, int bn) {
|
||||
if (an != bn) return false;
|
||||
for (int i = 0; i < an; i++) {
|
||||
if (a[i].linkUp != b[i].linkUp || a[i].active != b[i].active ||
|
||||
a[i].kind != b[i].kind) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool desktop_refresh_panel_state(DesktopState* ds, uint64_t now) {
|
||||
if (ds->screen_locked) return false;
|
||||
|
||||
@@ -476,9 +504,20 @@ static bool desktop_refresh_panel_state(DesktopState* ds, uint64_t now) {
|
||||
ds->cached_net_cfg = next;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
montauk::abi::NetIfInfo ifaces[DesktopState::MAX_NETIFS];
|
||||
int count = montauk::net_interfaces(ifaces, DesktopState::MAX_NETIFS);
|
||||
if (count < 0) count = 0;
|
||||
if (!desktop_netifs_equal(ifaces, count, ds->netifs, ds->netif_count)) {
|
||||
desktop_refresh_netifs(ds);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
ds->net_cfg_last_poll = now;
|
||||
}
|
||||
|
||||
if (desktop_wifi_poll(ds, now)) changed = true;
|
||||
|
||||
// Event-driven sync: the kernel mixer bumps a serial on every state
|
||||
// change. Reading it is one cheap syscall; refresh only when the serial
|
||||
// moved since we last looked. The audio app (and any other client) will
|
||||
|
||||
Reference in New Issue
Block a user