mirror of
https://github.com/JannisHeydemann/BoredOS.git
synced 2026-05-30 10:26:59 +00:00
FIX: Fixed framebuffer freeze upon screenshot
This commit is contained in:
@@ -374,7 +374,7 @@ static void cmd_init_config_defaults(void) {
|
||||
shell_config.default_text_color = 0xFFFFFFFF; // White
|
||||
shell_config.bg_color = 0xFF1E1E1E; // Dark background
|
||||
shell_config.cursor_color = 0xFFFFFFFF;
|
||||
shell_config.show_drive = true;
|
||||
shell_config.show_drive = false;
|
||||
shell_config.show_dir = true;
|
||||
shell_config.dir_color = 0xFF569CD6;
|
||||
shell_config.file_color = 0xFFFFFFFF;
|
||||
|
||||
@@ -842,19 +842,22 @@ void graphics_flip_buffer(void) {
|
||||
void graphics_copy_screenbuffer(uint32_t *dest) {
|
||||
if (!g_fb || !dest) return;
|
||||
|
||||
uint64_t rflags;
|
||||
asm volatile("pushfq; pop %0; cli" : "=r"(rflags));
|
||||
int sw = g_fb->width;
|
||||
int sh = g_fb->height;
|
||||
extern uint64_t wm_lock_acquire(void);
|
||||
extern void wm_lock_release(uint64_t);
|
||||
uint64_t rflags = wm_lock_acquire();
|
||||
|
||||
int sw = (int)g_fb->width;
|
||||
int sh = (int)g_fb->height;
|
||||
|
||||
// Copy the internal back object to the dest directly
|
||||
// Copy from the composition back buffer
|
||||
for (int y = 0; y < sh; y++) {
|
||||
uint32_t *src_row = &g_back_buffer[y * sw];
|
||||
for (int x = 0; x < sw; x++) {
|
||||
dest[y * sw + x] = src_row[x];
|
||||
}
|
||||
}
|
||||
asm volatile("push %0; popfq" : : "r"(rflags));
|
||||
|
||||
wm_lock_release(rflags);
|
||||
}
|
||||
|
||||
void graphics_set_clipping(int x, int y, int w, int h) {
|
||||
|
||||
@@ -14,10 +14,11 @@
|
||||
#define GUI_CMD_GET_STRING_WIDTH 8
|
||||
#define GUI_CMD_GET_FONT_HEIGHT 9
|
||||
#define GUI_CMD_WINDOW_SET_RESIZABLE 14
|
||||
#define GUI_CMD_GET_SCREEN_SIZE 17
|
||||
#define GUI_CMD_GET_SCREENBUFFER 18
|
||||
#define GUI_CMD_SHOW_NOTIFICATION 19
|
||||
#define GUI_CMD_GET_DATETIME 20
|
||||
// Remapped Screenshot API Commands to avoid collisions (Originals 17, 18, 19 conflicted with magic numbers)
|
||||
#define GUI_CMD_GET_SCREEN_SIZE 50
|
||||
#define GUI_CMD_GET_SCREENBUFFER 51
|
||||
#define GUI_CMD_SHOW_NOTIFICATION 52
|
||||
#define GUI_CMD_GET_DATETIME 53
|
||||
|
||||
#define GUI_EVENT_NONE 0
|
||||
#define GUI_EVENT_PAINT 1
|
||||
|
||||
16
src/wm/wm.c
16
src/wm/wm.c
@@ -81,7 +81,7 @@ void (*wm_custom_paint_hook)(void) = NULL;
|
||||
// Notification state
|
||||
static char notif_text[256] = {0};
|
||||
static int notif_timer = 0;
|
||||
static int notif_x_offset = 300; // Starts offscreen
|
||||
static int notif_x_offset = 420; // Starts offscreen
|
||||
static bool notif_active = false;
|
||||
extern bool ps2_ctrl_pressed;
|
||||
|
||||
@@ -1502,9 +1502,9 @@ void wm_paint(void) {
|
||||
|
||||
// Notification (dark mode)
|
||||
if (notif_active) {
|
||||
int nx = sw - 280 + notif_x_offset;
|
||||
int nx = sw - 400 + notif_x_offset;
|
||||
int ny = 40;
|
||||
int nw = 260;
|
||||
int nw = 380;
|
||||
int nh = 50;
|
||||
|
||||
draw_rounded_rect_filled(nx, ny, nw, nh, 8, COLOR_DARK_PANEL);
|
||||
@@ -2679,7 +2679,7 @@ void wm_show_notification(const char *msg) {
|
||||
notif_text[i] = 0;
|
||||
|
||||
notif_timer = 180; // ~3 seconds at 60Hz
|
||||
notif_x_offset = 300;
|
||||
notif_x_offset = 420;
|
||||
notif_active = true;
|
||||
force_redraw = true;
|
||||
}
|
||||
@@ -2811,19 +2811,19 @@ void wm_timer_tick(void) {
|
||||
notif_timer--;
|
||||
// Slide in
|
||||
if (notif_timer > 165 && notif_x_offset > 0) { // First 15 ticks (1/4 sec) slide in
|
||||
notif_x_offset -= 20;
|
||||
notif_x_offset -= 28; // Slightly faster slide for larger distance
|
||||
if (notif_x_offset < 0) notif_x_offset = 0;
|
||||
}
|
||||
// Slide out
|
||||
else if (notif_timer < 15 && notif_x_offset < 300) { // Last 15 ticks slide out
|
||||
notif_x_offset += 20;
|
||||
else if (notif_timer < 15 && notif_x_offset < 420) { // Last 15 ticks slide out
|
||||
notif_x_offset += 28;
|
||||
}
|
||||
} else {
|
||||
notif_active = false;
|
||||
}
|
||||
|
||||
int sw = get_screen_width();
|
||||
wm_mark_dirty(sw - 280, 40, 275, 60);
|
||||
wm_mark_dirty(sw - 420, 40, 415, 60);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user