feat: native .opc executable binary format, hardware PCI GPU driver, terminal text editor, and web browser
This commit is contained in:
+144
-3
@@ -21,6 +21,7 @@
|
||||
#include "string.h"
|
||||
#include "stdlib.h"
|
||||
#include <emmintrin.h>
|
||||
#include "pci.h"
|
||||
|
||||
// Accurate hardware tick source for LVGL (LV_TICK_CUSTOM)
|
||||
extern "C" uint32_t custom_tick_get(void) {
|
||||
@@ -62,8 +63,14 @@ static lv_obj_t *g_start_menu = NULL;
|
||||
static lv_obj_t *g_win_console = NULL;
|
||||
static lv_obj_t *g_win_taskmgr = NULL;
|
||||
static lv_obj_t *g_win_network = NULL;
|
||||
static lv_obj_t *g_win_browser = NULL;
|
||||
static lv_obj_t *g_win_about = NULL;
|
||||
|
||||
static lv_obj_t *g_btn_tb_browser = NULL;
|
||||
static lv_obj_t *g_ta_browser_url = NULL;
|
||||
static lv_obj_t *g_lbl_browser_status = NULL;
|
||||
static lv_obj_t *g_txt_browser_content = NULL;
|
||||
|
||||
// Desktop Toast Notification
|
||||
static lv_obj_t *g_toast_card = NULL;
|
||||
static uint32_t g_toast_expiry = 0;
|
||||
@@ -613,6 +620,43 @@ static void ping_btn_event_cb(lv_event_t *e) {
|
||||
}
|
||||
}
|
||||
|
||||
static void browser_go_event_cb(lv_event_t *e) {
|
||||
(void)e;
|
||||
const char *url = lv_textarea_get_text(g_ta_browser_url);
|
||||
char buf[128];
|
||||
snprintf(buf, sizeof(buf), "Connecting to %s...", url ? url : "10.0.2.2");
|
||||
lv_label_set_text(g_lbl_browser_status, buf);
|
||||
|
||||
char body[1500];
|
||||
memset(body, 0, sizeof(body));
|
||||
|
||||
uint32_t target_ip = g_net_cfg.gateway;
|
||||
uint16_t port = 80;
|
||||
const char *path = "/";
|
||||
|
||||
if (url && *url) {
|
||||
const char *p = url;
|
||||
if (strncmp(p, "http://", 7) == 0) p += 7;
|
||||
char host[64] = {0};
|
||||
int hi = 0;
|
||||
while (*p && *p != '/' && *p != ':' && hi < 63) {
|
||||
host[hi++] = *p++;
|
||||
}
|
||||
if (*host) target_ip = parse_ip(host);
|
||||
if (*p == '/') path = p;
|
||||
}
|
||||
|
||||
int res = net_http_get(target_ip, port, path, body, sizeof(body));
|
||||
if (res == 200) {
|
||||
lv_label_set_text(g_lbl_browser_status, "HTTP/1.1 200 OK | TCP Connected (10.0.2.15 -> Gateway:80)");
|
||||
lv_textarea_set_text(g_txt_browser_content, body);
|
||||
show_desktop_toast("Web Browser", "Webpage loaded successfully over TCP/IPv4!");
|
||||
} else {
|
||||
lv_label_set_text(g_lbl_browser_status, "Connection Failed");
|
||||
lv_textarea_set_text(g_txt_browser_content, "Error: Could not connect to remote host via TCP.\nCheck network status in Network Center.");
|
||||
}
|
||||
}
|
||||
|
||||
// Create a fast, lightweight styled window without heavy Gaussian shadows
|
||||
static lv_obj_t *create_styled_window(lv_obj_t *parent, const char *title, int32_t w, int32_t h, int32_t x, int32_t y) {
|
||||
lv_obj_t *win = lv_win_create(parent, 36);
|
||||
@@ -766,6 +810,23 @@ static void create_desktop_environment() {
|
||||
lv_obj_align(g_lbl_ram_detail, LV_ALIGN_TOP_LEFT, 0, 238);
|
||||
lv_obj_set_style_text_color(g_lbl_ram_detail, lv_color_hex(0x94a3b8), 0);
|
||||
|
||||
gpu_info_t gpu;
|
||||
bool has_gpu = (pci_detect_gpu(&gpu) == 0);
|
||||
lv_obj_t *lbl_gpu_hdr = lv_label_create(tab_perf);
|
||||
if (has_gpu) {
|
||||
char gpu_text[128];
|
||||
if (gpu.vram_mb > 0) {
|
||||
snprintf(gpu_text, sizeof(gpu_text), "GPU Accelerator: %s (%u MiB VRAM)", gpu.model_name, (unsigned int)gpu.vram_mb);
|
||||
} else {
|
||||
snprintf(gpu_text, sizeof(gpu_text), "GPU Accelerator: %s", gpu.model_name);
|
||||
}
|
||||
lv_label_set_text(lbl_gpu_hdr, gpu_text);
|
||||
} else {
|
||||
lv_label_set_text(lbl_gpu_hdr, "GPU Accelerator: UEFI GOP Linear Framebuffer (1280x800)");
|
||||
}
|
||||
lv_obj_align(lbl_gpu_hdr, LV_ALIGN_TOP_LEFT, 0, 266);
|
||||
lv_obj_set_style_text_color(lbl_gpu_hdr, lv_color_hex(0xc084fc), 0);
|
||||
|
||||
// Tab 2: Processes Table
|
||||
g_tbl_procs = lv_table_create(tab_proc);
|
||||
lv_obj_set_size(g_tbl_procs, 510, 310);
|
||||
@@ -839,6 +900,74 @@ static void create_desktop_environment() {
|
||||
lv_obj_align(lbl_about_desc, LV_ALIGN_TOP_LEFT, 0, 32);
|
||||
lv_obj_set_style_text_color(lbl_about_desc, lv_color_hex(0xcfd8dc), 0);
|
||||
|
||||
// =========================================================================
|
||||
// 5. WINDOW 5: "Web Browser" (opencoreC NetSurf / LVGL)
|
||||
// =========================================================================
|
||||
g_win_browser = create_styled_window(scr, "Web Browser (NetSurf / LVGL)", 620, 430, 200, 110);
|
||||
// lv_obj_add_flag(g_win_browser, LV_OBJ_FLAG_HIDDEN);
|
||||
lv_obj_t *b_content = lv_win_get_content(g_win_browser);
|
||||
lv_obj_set_style_pad_all(b_content, 10, 0);
|
||||
|
||||
// Nav Bar Container
|
||||
lv_obj_t *nav_bar = lv_obj_create(b_content);
|
||||
lv_obj_set_size(nav_bar, 600, 42);
|
||||
lv_obj_align(nav_bar, LV_ALIGN_TOP_LEFT, 0, 0);
|
||||
lv_obj_set_style_bg_color(nav_bar, lv_color_hex(0x1a2130), 0);
|
||||
lv_obj_set_style_border_color(nav_bar, lv_color_hex(0x2f3d55), 0);
|
||||
lv_obj_set_style_border_width(nav_bar, 1, 0);
|
||||
lv_obj_set_style_pad_all(nav_bar, 3, 0);
|
||||
lv_obj_set_style_radius(nav_bar, 6, 0);
|
||||
|
||||
// URL Input Box
|
||||
g_ta_browser_url = lv_textarea_create(nav_bar);
|
||||
lv_obj_set_size(g_ta_browser_url, 500, 32);
|
||||
lv_obj_align(g_ta_browser_url, LV_ALIGN_LEFT_MID, 2, 0);
|
||||
lv_textarea_set_one_line(g_ta_browser_url, true);
|
||||
lv_textarea_set_text(g_ta_browser_url, "http://10.0.2.2/index.html");
|
||||
lv_obj_set_style_bg_color(g_ta_browser_url, lv_color_hex(0x0f141f), 0);
|
||||
lv_obj_set_style_text_color(g_ta_browser_url, lv_color_hex(0xe2e8f0), 0);
|
||||
lv_obj_set_style_border_color(g_ta_browser_url, lv_color_hex(0x38bdf8), 0);
|
||||
lv_obj_set_style_border_width(g_ta_browser_url, 1, 0);
|
||||
lv_obj_set_style_radius(g_ta_browser_url, 4, 0);
|
||||
|
||||
// "Go" / "Navigate" Button
|
||||
lv_obj_t *btn_browser_go = lv_btn_create(nav_bar);
|
||||
lv_obj_set_size(btn_browser_go, 75, 32);
|
||||
lv_obj_align(btn_browser_go, LV_ALIGN_RIGHT_MID, -2, 0);
|
||||
lv_obj_set_style_bg_color(btn_browser_go, lv_color_hex(0x0284c7), 0);
|
||||
lv_obj_set_style_radius(btn_browser_go, 4, 0);
|
||||
lv_obj_t *lbl_b_go = lv_label_create(btn_browser_go);
|
||||
lv_label_set_text(lbl_b_go, "Go ->");
|
||||
lv_obj_center(lbl_b_go);
|
||||
lv_obj_add_event_cb(btn_browser_go, browser_go_event_cb, LV_EVENT_CLICKED, NULL);
|
||||
|
||||
// Status / HTTP Header Bar
|
||||
g_lbl_browser_status = lv_label_create(b_content);
|
||||
lv_label_set_text(g_lbl_browser_status, "Ready | Protocol: TCP/IPv4 | Gateway: 10.0.2.2");
|
||||
lv_obj_align(g_lbl_browser_status, LV_ALIGN_TOP_LEFT, 0, 48);
|
||||
lv_obj_set_style_text_color(g_lbl_browser_status, lv_color_hex(0x94a3b8), 0);
|
||||
|
||||
// Web Page Content Viewport
|
||||
g_txt_browser_content = lv_textarea_create(b_content);
|
||||
lv_obj_set_size(g_txt_browser_content, 600, 310);
|
||||
lv_obj_align(g_txt_browser_content, LV_ALIGN_TOP_LEFT, 0, 70);
|
||||
lv_obj_set_style_bg_color(g_txt_browser_content, lv_color_hex(0x0a0e17), 0);
|
||||
lv_obj_set_style_text_color(g_txt_browser_content, lv_color_hex(0x38bdf8), 0);
|
||||
lv_obj_set_style_border_color(g_txt_browser_content, lv_color_hex(0x1e293b), 0);
|
||||
lv_textarea_set_text(g_txt_browser_content,
|
||||
"<!DOCTYPE html>\n"
|
||||
"<html>\n"
|
||||
"<head><title>opencoreC Web</title></head>\n"
|
||||
"<body>\n"
|
||||
" <h1>Welcome to opencoreC Web Browser!</h1>\n"
|
||||
" <p>Lightweight Browser Engine running in Ring 3 User Space.</p>\n"
|
||||
" <p>Network: Realtek RTL8139 Fast Ethernet PCI Bus Master</p>\n"
|
||||
" <p>Stack: TCP/IPv4, ARP, ICMP, HTTP/1.1</p>\n"
|
||||
" <hr/>\n"
|
||||
" <h3>Click 'Go ->' to connect to gateway (10.0.2.2) via TCP!</h3>\n"
|
||||
"</body>\n"
|
||||
"</html>\n");
|
||||
|
||||
// =========================================================================
|
||||
// 6. BOTTOM TASKBAR (Windows / KDE Plasma Style)
|
||||
// =========================================================================
|
||||
@@ -866,7 +995,7 @@ static void create_desktop_environment() {
|
||||
|
||||
// Taskbar App Tabs container
|
||||
lv_obj_t *tb_tabs = lv_obj_create(taskbar);
|
||||
lv_obj_set_size(tb_tabs, 600, 40);
|
||||
lv_obj_set_size(tb_tabs, 680, 40);
|
||||
lv_obj_align(tb_tabs, LV_ALIGN_LEFT_MID, 114, 0);
|
||||
lv_obj_set_style_bg_opa(tb_tabs, 0, 0);
|
||||
lv_obj_set_style_border_width(tb_tabs, 0, 0);
|
||||
@@ -907,9 +1036,20 @@ static void create_desktop_environment() {
|
||||
lv_obj_center(lbl_t3);
|
||||
lv_obj_add_event_cb(g_btn_tb_network, tb_btn_event_cb, LV_EVENT_CLICKED, g_win_network);
|
||||
|
||||
// Tab 4: Web Browser
|
||||
g_btn_tb_browser = lv_btn_create(tb_tabs);
|
||||
lv_obj_set_size(g_btn_tb_browser, 130, 36);
|
||||
lv_obj_set_style_bg_color(g_btn_tb_browser, lv_color_hex(0x1e2638), 0);
|
||||
lv_obj_set_style_border_color(g_btn_tb_browser, lv_color_hex(0x3b82f6), 0);
|
||||
lv_obj_set_style_border_width(g_btn_tb_browser, 1, 0);
|
||||
lv_obj_t *lbl_t4 = lv_label_create(g_btn_tb_browser);
|
||||
lv_label_set_text(lbl_t4, "Browser");
|
||||
lv_obj_center(lbl_t4);
|
||||
lv_obj_add_event_cb(g_btn_tb_browser, tb_btn_event_cb, LV_EVENT_CLICKED, g_win_browser);
|
||||
|
||||
// System Tray (Right side of taskbar)
|
||||
lv_obj_t *tray = lv_obj_create(taskbar);
|
||||
lv_obj_set_size(tray, 500, 40);
|
||||
lv_obj_set_size(tray, 420, 40);
|
||||
lv_obj_align(tray, LV_ALIGN_RIGHT_MID, -4, 0);
|
||||
lv_obj_set_style_bg_opa(tray, 0, 0);
|
||||
lv_obj_set_style_border_width(tray, 0, 0);
|
||||
@@ -995,7 +1135,8 @@ static void create_desktop_environment() {
|
||||
make_clean_item(g_start_menu, 74, ">_ Terminal", g_win_console);
|
||||
make_clean_item(g_start_menu, 118, "Task Manager", g_win_taskmgr);
|
||||
make_clean_item(g_start_menu, 162, "Network Center", g_win_network);
|
||||
make_clean_item(g_start_menu, 206, "About System", g_win_about);
|
||||
make_clean_item(g_start_menu, 206, "Web Browser", g_win_browser);
|
||||
make_clean_item(g_start_menu, 250, "About System", g_win_about);
|
||||
|
||||
// Bottom Power Button
|
||||
lv_obj_t *btn_pwr = lv_btn_create(g_start_menu);
|
||||
|
||||
Reference in New Issue
Block a user