mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-25 16:52:29 +00:00
fix(gui): Adapt the desktop to the active resolution and restore the console on exit
The launcher table is authored against an 800x600 work area, so at 1280x720 every window kept its original size and left the desktop looking sparse, while still overlapping the icon column the way it did at the design resolution. Launch geometry now scales with the work area, capped so a window cannot swallow the screen, and offset clear of the icon strip so launcher labels stay readable. The wallpaper grid was a single fixed colour, which is darker than the top of the gradient but lighter than the bottom, so the grid faded out across the lower half of the screen. It is blended now and reads the whole way down. Leaving the desktop hands the screen to the framebuffer console, and entering it takes the screen back, so Esc drops to a working TTY inside the emulator and `gui` returns to the desktop. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01L5yKJT4Wo2cV3rfPrwY5MP
This commit is contained in:
1 parent
2d01fd629e
commit
65b7a709cc
2 files changed
+68
-7
No files matched your search
@@ -47,6 +47,11 @@
|
|||||||
- **Animated progress bar** tied to the real boot stages, held for a minimum duration (`splashtime=<ms>`) so a sub-second boot still shows it; `nosplash`, `nogui` or `text` skip it.
|
- **Animated progress bar** tied to the real boot stages, held for a minimum duration (`splashtime=<ms>`) so a sub-second boot still shows it; `nosplash`, `nogui` or `text` skip it.
|
||||||
- **Regenerable**: `python3 scripts/mklogo.py path/to/logo.png` rewrites `init/logo_data.c` from source artwork.
|
- **Regenerable**: `python3 scripts/mklogo.py path/to/logo.png` rewrites `init/logo_data.c` from source artwork.
|
||||||
- 🔤 **Shared 8x8 Console Font (`lib/font8x8.c`)**: one glyph table behind the framebuffer console, the 2D canvas rasterizer and the desktop compositor, replacing three divergent private copies.
|
- 🔤 **Shared 8x8 Console Font (`lib/font8x8.c`)**: one glyph table behind the framebuffer console, the 2D canvas rasterizer and the desktop compositor, replacing three divergent private copies.
|
||||||
|
- 🖵 **Framebuffer Console (`drivers/video/fbcon.c`)**:
|
||||||
|
- Once the VBE adapter is in graphics mode the VGA text buffer stops being scanned out, so anything printed afterwards is invisible on the display even though it still reaches serial. fbcon renders the console into the framebuffer instead, the way Linux fbcon does.
|
||||||
|
- **VT100 subset**: SGR colours, cursor addressing (`H`/`f`), relative moves, erase-display and erase-line, save/restore — enough for full-screen curses-style programs such as the **nano** editor to render correctly.
|
||||||
|
- Presents a fixed **80x25** grid (matching `TTY_WIDTH`/`TTY_HEIGHT`, which the userland assumes) with the glyph cell scaled to fill whatever resolution is active.
|
||||||
|
- The TTY driver dispatches `tty_write`, `tty_clear` and `tty_set_cursor` to it, so leaving the desktop with `Esc` drops to a working console **inside the emulator**, not just on the host serial line.
|
||||||
- 🖥️ **SUB-OS Graphical Desktop Environment (`gui/`)**:
|
- 🖥️ **SUB-OS Graphical Desktop Environment (`gui/`)**:
|
||||||
- **SUB-WM Compositor**: 800x600 TrueColor double-buffered window manager with drag, corner resize, minimize/maximize/restore, edge snapping (left/right/maximize), tile and cascade layouts, and z-ordered painter's-algorithm compositing.
|
- **SUB-WM Compositor**: 800x600 TrueColor double-buffered window manager with drag, corner resize, minimize/maximize/restore, edge snapping (left/right/maximize), tile and cascade layouts, and z-ordered painter's-algorithm compositing.
|
||||||
- **SUB-WT Widget Toolkit (`gui/gui_widgets.c`)**: Immediate-mode controls -- buttons, labels, checkboxes, radios, sliders, list boxes, text fields, tab bars, scrollbars, progress bars, sparklines and badges -- so an app rebuilds its interface from state each frame instead of maintaining a retained widget tree.
|
- **SUB-WT Widget Toolkit (`gui/gui_widgets.c`)**: Immediate-mode controls -- buttons, labels, checkboxes, radios, sliders, list boxes, text fields, tab bars, scrollbars, progress bars, sparklines and badges -- so an app rebuilds its interface from state each frame instead of maintaining a retained widget tree.
|
||||||
@@ -231,9 +236,14 @@ SUB-OS boots straight into the desktop. Pass `nogui`, `text`, `emergency` or
|
|||||||
from inside the desktop, `Esc` (or Start -> Exit to Kernel TTY) drops to the
|
from inside the desktop, `Esc` (or Start -> Exit to Kernel TTY) drops to the
|
||||||
same shell.
|
same shell.
|
||||||
|
|
||||||
|
The display mode is set with `video=WIDTHxHEIGHT` on the kernel command line
|
||||||
|
(default `1280x720`, 16:9). Both the desktop and the framebuffer console adapt
|
||||||
|
to whatever mode is active.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make run-gui # Local SDL/GTK window
|
make run-gui # Windowed, aspect-preserving scaling
|
||||||
make run-vnc # Headless: VNC server on localhost:5900
|
make run-fullscreen # Fullscreen without stretching
|
||||||
|
make run-vnc # Headless: VNC server on localhost:5900
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
+56
-5
@@ -17,6 +17,9 @@
|
|||||||
#include <gui/gui_dialog.h>
|
#include <gui/gui_dialog.h>
|
||||||
#include <gui/gui_theme.h>
|
#include <gui/gui_theme.h>
|
||||||
#include <drivers/fb.h>
|
#include <drivers/fb.h>
|
||||||
|
#include <drivers/bochs.h>
|
||||||
|
#include <drivers/fbcon.h>
|
||||||
|
#include <drivers/tty.h>
|
||||||
#include <drivers/mouse.h>
|
#include <drivers/mouse.h>
|
||||||
#include <drivers/keyboard.h>
|
#include <drivers/keyboard.h>
|
||||||
#include <drivers/rtc.h>
|
#include <drivers/rtc.h>
|
||||||
@@ -74,10 +77,44 @@ static int g_hover_menu_item = -1;
|
|||||||
static uint64_t g_frames = 0;
|
static uint64_t g_frames = 0;
|
||||||
static uint8_t g_cpu_history[48];
|
static uint8_t g_cpu_history[48];
|
||||||
|
|
||||||
|
// The launcher geometry below is authored against an 800x600 work area.
|
||||||
|
#define DESIGN_W 800
|
||||||
|
#define DESIGN_H 568
|
||||||
|
|
||||||
static void launch_app(int index) {
|
static void launch_app(int index) {
|
||||||
if (index < 0 || index >= APP_COUNT) return;
|
if (index < 0 || index >= APP_COUNT) return;
|
||||||
|
|
||||||
const desktop_app_t* a = &g_apps[index];
|
const desktop_app_t* a = &g_apps[index];
|
||||||
if (a->launch) a->launch(a->x, a->y, a->w, a->h);
|
if (!a->launch) return;
|
||||||
|
|
||||||
|
int sw = gui_gfx_get_width();
|
||||||
|
int wh = gui_desktop_workarea_height();
|
||||||
|
|
||||||
|
// Scale the design geometry to the live resolution, but never shrink below
|
||||||
|
// it: a window sized for 800x600 is already at its comfortable minimum.
|
||||||
|
int x = (a->x * sw) / DESIGN_W;
|
||||||
|
int y = (a->y * wh) / DESIGN_H;
|
||||||
|
int w = (a->w * sw) / DESIGN_W;
|
||||||
|
int h = (a->h * wh) / DESIGN_H;
|
||||||
|
|
||||||
|
if (w < a->w) w = a->w;
|
||||||
|
if (h < a->h) h = a->h;
|
||||||
|
|
||||||
|
// Leave the desktop breathing room: a window scaled straight from the
|
||||||
|
// design size swallows most of a 1280x720 screen and buries the wallpaper.
|
||||||
|
int max_w = (sw * 62) / 100;
|
||||||
|
int max_h = (wh * 72) / 100;
|
||||||
|
if (w > max_w) w = max_w;
|
||||||
|
if (h > max_h) h = max_h;
|
||||||
|
|
||||||
|
// Keep clear of the icon column so launcher labels stay readable.
|
||||||
|
int icon_strip = GUI_DESKTOP_ICON_W + 28;
|
||||||
|
if (x < icon_strip) x = icon_strip;
|
||||||
|
if (x + w > sw - 8) x = sw - 8 - w;
|
||||||
|
if (y + h > wh - 8) y = wh - 8 - h;
|
||||||
|
if (y < 8) y = 8;
|
||||||
|
|
||||||
|
a->launch(x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
int gui_desktop_workarea_height(void) {
|
int gui_desktop_workarea_height(void) {
|
||||||
@@ -119,8 +156,15 @@ void gui_desktop_render_background(void) {
|
|||||||
gui_gfx_draw_gradient_v(0, 0, sw, wh, 0xFF0B132B, 0xFF1C2541);
|
gui_gfx_draw_gradient_v(0, 0, sw, wh, 0xFF0B132B, 0xFF1C2541);
|
||||||
|
|
||||||
if (g_show_grid) {
|
if (g_show_grid) {
|
||||||
for (int y = 0; y < wh; y += 40) gui_gfx_draw_line(0, y, sw - 1, y, 0xFF141F36);
|
// Blend rather than stamp a fixed colour: the gradient's lower half is
|
||||||
for (int x = 0; x < sw; x += 40) gui_gfx_draw_line(x, 0, x, wh - 1, 0xFF141F36);
|
// lighter than any single grid tone, so a constant colour disappears
|
||||||
|
// there and only shows near the top of the screen.
|
||||||
|
for (int y = 0; y < wh; y += 40) {
|
||||||
|
gui_gfx_fill_rect_blend(0, y, sw, 1, GUI_COLOR_BLACK, 40);
|
||||||
|
}
|
||||||
|
for (int x = 0; x < sw; x += 40) {
|
||||||
|
gui_gfx_fill_rect_blend(x, 0, 1, wh, GUI_COLOR_BLACK, 40);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Branding, offset to the right so it clears the icon column.
|
// Branding, offset to the right so it clears the icon column.
|
||||||
@@ -546,11 +590,12 @@ static void sample_cpu_history(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int gui_desktop_run(void) {
|
int gui_desktop_run(void) {
|
||||||
|
fbcon_enable(false);
|
||||||
gui_desktop_init();
|
gui_desktop_init();
|
||||||
|
|
||||||
// Open a default session so the desktop is not empty on first boot.
|
// Open a default session so the desktop is not empty on first boot.
|
||||||
gui_app_sysmon_launch(430, 30, 340, 240);
|
launch_app(2); // System Monitor
|
||||||
gui_app_terminal_launch(30, 40, 560, 340);
|
launch_app(0); // Terminal
|
||||||
|
|
||||||
// Discard anything the console left in the keyboard queue; a stale key
|
// Discard anything the console left in the keyboard queue; a stale key
|
||||||
// arriving on frame 0 would otherwise act as a desktop shortcut.
|
// arriving on frame 0 would otherwise act as a desktop shortcut.
|
||||||
@@ -633,6 +678,12 @@ int gui_desktop_run(void) {
|
|||||||
g_frames++;
|
g_frames++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hand the screen to the framebuffer console. Without this the shell writes
|
||||||
|
// into the VGA text buffer while the adapter is still scanning out the
|
||||||
|
// framebuffer, so the TTY is visible only on the serial line -- which is
|
||||||
|
// the host terminal, not the emulator window.
|
||||||
|
fbcon_enable(true);
|
||||||
|
|
||||||
printk(KERN_INFO "GUI: Desktop session ended after %llu frames, TTY restored\n",
|
printk(KERN_INFO "GUI: Desktop session ended after %llu frames, TTY restored\n",
|
||||||
(unsigned long long)g_frames);
|
(unsigned long long)g_frames);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in new issue
Block a user