mirror of
https://github.com/BoredDevNL/BoredOS.git
synced 2026-05-15 10:48:38 +00:00
tweak: increased cursor size and improved design
This commit is contained in:
parent
af5eda1647
commit
f8ca9d9d91
1 changed files with 41 additions and 27 deletions
68
src/wm/wm.c
68
src/wm/wm.c
|
|
@ -246,6 +246,9 @@ static uint32_t timer_ticks = 0;
|
||||||
static int last_cursor_x = 400;
|
static int last_cursor_x = 400;
|
||||||
static int last_cursor_y = 300;
|
static int last_cursor_y = 300;
|
||||||
|
|
||||||
|
#define CURSOR_W 18
|
||||||
|
#define CURSOR_H 18
|
||||||
|
|
||||||
static bool periodic_refresh_pending = false;
|
static bool periodic_refresh_pending = false;
|
||||||
|
|
||||||
// --- Desktop State ---
|
// --- Desktop State ---
|
||||||
|
|
@ -1344,27 +1347,38 @@ void draw_window(Window *win) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw Mouse Cursor (Simple Arrow)
|
// Draw Mouse Cursor (classic outlined arrow)
|
||||||
void draw_cursor(int x, int y) {
|
void draw_cursor(int x, int y) {
|
||||||
// 0 = Transparent (skip), 1 = Black, 2 = White
|
// '.' transparent, 'w' white outline, 'b' black fill
|
||||||
static const uint8_t cursor_bitmap[10][10] = {
|
static const char cursor_bitmap[CURSOR_H][CURSOR_W + 1] = {
|
||||||
{1,1,0,0,0,0,0,0,0,0},
|
"w.................",
|
||||||
{1,2,1,0,0,0,0,0,0,0},
|
"ww................",
|
||||||
{1,2,2,1,0,0,0,0,0,0},
|
"wbw...............",
|
||||||
{1,2,2,2,1,0,0,0,0,0},
|
"wbbw..............",
|
||||||
{1,2,2,2,2,1,0,0,0,0},
|
"wbbbw.............",
|
||||||
{1,2,2,2,2,2,1,0,0,0},
|
"wbbbbw............",
|
||||||
{1,2,2,1,1,1,1,0,0,0},
|
"wbbbbbw...........",
|
||||||
{1,1,1,0,1,2,1,0,0,0},
|
"wbbbbbbw..........",
|
||||||
{0,0,0,0,0,1,2,1,0,0},
|
"wbbbbbbbw.........",
|
||||||
{0,0,0,0,0,0,1,0,0,0}
|
"wbbbbbbbbw........",
|
||||||
|
"wbbbbbbbbw........",
|
||||||
|
"wbbbbbbbw.........",
|
||||||
|
"wbbbbbbbw.........",
|
||||||
|
"wbbbbbbw..........",
|
||||||
|
"wwwwbbbw..........",
|
||||||
|
"....wbbw..........",
|
||||||
|
".....wbw..........",
|
||||||
|
"......ww..........."
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int r = 0; r < 10; r++) {
|
for (int r = 0; r < CURSOR_H; r++) {
|
||||||
for (int c = 0; c < 10; c++) {
|
for (int c = 0; c < CURSOR_W; c++) {
|
||||||
uint8_t p = cursor_bitmap[r][c];
|
char p = cursor_bitmap[r][c];
|
||||||
if (p == 1) put_pixel(x + c, y + r, COLOR_BLACK);
|
if (p == 'w') {
|
||||||
else if (p == 2) put_pixel(x + c, y + r, COLOR_WHITE);
|
put_pixel(x + c, y + r, COLOR_WHITE);
|
||||||
|
} else if (p == 'b') {
|
||||||
|
put_pixel(x + c, y + r, COLOR_BLACK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1377,8 +1391,8 @@ static void erase_cursor(int x, int y) {
|
||||||
// Clamp to screen
|
// Clamp to screen
|
||||||
int x1 = x < 0 ? 0 : x;
|
int x1 = x < 0 ? 0 : x;
|
||||||
int y1 = y < 0 ? 0 : y;
|
int y1 = y < 0 ? 0 : y;
|
||||||
int x2 = x + 10 > sw ? sw : x + 10;
|
int x2 = x + CURSOR_W > sw ? sw : x + CURSOR_W;
|
||||||
int y2 = y + 10 > sh ? sh : y + 10;
|
int y2 = y + CURSOR_H > sh ? sh : y + CURSOR_H;
|
||||||
int w = x2 - x1;
|
int w = x2 - x1;
|
||||||
int h = y2 - y1;
|
int h = y2 - y1;
|
||||||
|
|
||||||
|
|
@ -1750,8 +1764,8 @@ void wm_paint(void) {
|
||||||
int sh = get_screen_height();
|
int sh = get_screen_height();
|
||||||
uint64_t rflags;
|
uint64_t rflags;
|
||||||
rflags = wm_lock_acquire();
|
rflags = wm_lock_acquire();
|
||||||
wm_mark_dirty(last_cursor_x, last_cursor_y, 12, 12);
|
wm_mark_dirty(last_cursor_x, last_cursor_y, CURSOR_W, CURSOR_H);
|
||||||
wm_mark_dirty(mx, my, 12, 12);
|
wm_mark_dirty(mx, my, CURSOR_W, CURSOR_H);
|
||||||
|
|
||||||
DirtyRect dirty = graphics_get_dirty_rect();
|
DirtyRect dirty = graphics_get_dirty_rect();
|
||||||
if (menubar_dirty_pending) {
|
if (menubar_dirty_pending) {
|
||||||
|
|
@ -2294,8 +2308,8 @@ static void wm_handle_mouse_internal(int dx, int dy, uint8_t buttons, int dz) {
|
||||||
if (my >= sh) my = sh - 1;
|
if (my >= sh) my = sh - 1;
|
||||||
|
|
||||||
if (move_x != 0 || move_y != 0) {
|
if (move_x != 0 || move_y != 0) {
|
||||||
wm_mark_dirty(prev_mx, prev_my, 12, 12); // Extra padding for safety
|
wm_mark_dirty(prev_mx, prev_my, CURSOR_W, CURSOR_H);
|
||||||
wm_mark_dirty(mx, my, 12, 12);
|
wm_mark_dirty(mx, my, CURSOR_W, CURSOR_H);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dz != 0) {
|
if (dz != 0) {
|
||||||
|
|
@ -2897,8 +2911,8 @@ static void wm_handle_mouse_internal(int dx, int dy, uint8_t buttons, int dz) {
|
||||||
|
|
||||||
if (prev_mx != mx || prev_my != my) {
|
if (prev_mx != mx || prev_my != my) {
|
||||||
// Cursor moved - just mark dirty cursor areas
|
// Cursor moved - just mark dirty cursor areas
|
||||||
wm_mark_dirty(prev_mx, prev_my, 10, 10);
|
wm_mark_dirty(prev_mx, prev_my, CURSOR_W, CURSOR_H);
|
||||||
wm_mark_dirty(mx, my, 10, 10);
|
wm_mark_dirty(mx, my, CURSOR_W, CURSOR_H);
|
||||||
}
|
}
|
||||||
|
|
||||||
prev_left = left;
|
prev_left = left;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue