fix: fix rare page faults caused by Window Server apps, change default wallpaper path
This commit is contained in:
@@ -562,8 +562,8 @@ static inline void terminal_resize(TerminalState* t, int new_cols, int new_rows)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t->cells) montauk::mfree(t->cells);
|
if (t->cells) montauk::free(t->cells);
|
||||||
if (t->alt_cells) montauk::mfree(t->alt_cells);
|
if (t->alt_cells) montauk::free(t->alt_cells);
|
||||||
|
|
||||||
t->cells = new_cells;
|
t->cells = new_cells;
|
||||||
t->alt_cells = new_alt;
|
t->alt_cells = new_alt;
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ static void klog_on_poll(Window* win) {
|
|||||||
static void klog_on_close(Window* win) {
|
static void klog_on_close(Window* win) {
|
||||||
KlogState* klog = (KlogState*)win->app_data;
|
KlogState* klog = (KlogState*)win->app_data;
|
||||||
if (klog) {
|
if (klog) {
|
||||||
if (klog->term.cells) montauk::mfree(klog->term.cells);
|
if (klog->term.cells) montauk::free(klog->term.cells);
|
||||||
if (klog->term.alt_cells) montauk::mfree(klog->term.alt_cells);
|
if (klog->term.alt_cells) montauk::free(klog->term.alt_cells);
|
||||||
if (klog->klog_buf) montauk::mfree(klog->klog_buf);
|
if (klog->klog_buf) montauk::mfree(klog->klog_buf);
|
||||||
montauk::mfree(klog);
|
montauk::mfree(klog);
|
||||||
win->app_data = nullptr;
|
win->app_data = nullptr;
|
||||||
|
|||||||
@@ -39,7 +39,8 @@ static void terminal_on_key(Window* win, const Montauk::KeyEvent& key) {
|
|||||||
static void terminal_on_close(Window* win) {
|
static void terminal_on_close(Window* win) {
|
||||||
TerminalState* ts = (TerminalState*)win->app_data;
|
TerminalState* ts = (TerminalState*)win->app_data;
|
||||||
if (ts) {
|
if (ts) {
|
||||||
if (ts->cells) montauk::mfree(ts->cells);
|
if (ts->cells) montauk::free(ts->cells);
|
||||||
|
if (ts->alt_cells) montauk::free(ts->alt_cells);
|
||||||
montauk::mfree(ts);
|
montauk::mfree(ts);
|
||||||
win->app_data = nullptr;
|
win->app_data = nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ void gui::desktop_init(DesktopState* ds) {
|
|||||||
ds->settings.ui_scale = 1;
|
ds->settings.ui_scale = 1;
|
||||||
|
|
||||||
// Try to load default wallpaper
|
// Try to load default wallpaper
|
||||||
wallpaper_load(&ds->settings, "0:/home/gustav-gullstrand-d6kSvT2xZQo-unsplash.jpg",
|
wallpaper_load(&ds->settings, "0:/home/stephen-walker-DaC8D3USffk-unsplash.jpg",
|
||||||
ds->screen_w, ds->screen_h);
|
ds->screen_w, ds->screen_h);
|
||||||
montauk::win_setscale(1);
|
montauk::win_setscale(1);
|
||||||
|
|
||||||
|
|||||||
@@ -283,7 +283,8 @@ static void add_empty_line() {
|
|||||||
// Word-wrap a text segment into display lines using pixel-width measurement.
|
// Word-wrap a text segment into display lines using pixel-width measurement.
|
||||||
static void wrap_text(TrueTypeFont* font, int size, const char* text, int textLen,
|
static void wrap_text(TrueTypeFont* font, int size, const char* text, int textLen,
|
||||||
int max_px, Color color) {
|
int max_px, Color color) {
|
||||||
char cur[256];
|
static constexpr int MAX_LINE = 255;
|
||||||
|
char cur[MAX_LINE + 1];
|
||||||
int cur_len = 0;
|
int cur_len = 0;
|
||||||
const char* p = text;
|
const char* p = text;
|
||||||
const char* end = text + textLen;
|
const char* end = text + textLen;
|
||||||
@@ -298,14 +299,16 @@ static void wrap_text(TrueTypeFont* font, int size, const char* text, int textLe
|
|||||||
if (word_len <= 0) continue;
|
if (word_len <= 0) continue;
|
||||||
|
|
||||||
// Build candidate: current line + space + word
|
// Build candidate: current line + space + word
|
||||||
char test[260];
|
char test[MAX_LINE + 1];
|
||||||
int test_len = cur_len;
|
int test_len = cur_len;
|
||||||
memcpy(test, cur, cur_len);
|
memcpy(test, cur, cur_len);
|
||||||
if (cur_len > 0) test[test_len++] = ' ';
|
if (cur_len > 0 && test_len < MAX_LINE) test[test_len++] = ' ';
|
||||||
int copy = word_len < (int)(sizeof(test) - test_len - 1)
|
int avail = MAX_LINE - test_len;
|
||||||
? word_len : (int)(sizeof(test) - test_len - 1);
|
int copy = word_len < avail ? word_len : avail;
|
||||||
memcpy(test + test_len, word_start, copy);
|
if (copy > 0) {
|
||||||
test_len += copy;
|
memcpy(test + test_len, word_start, copy);
|
||||||
|
test_len += copy;
|
||||||
|
}
|
||||||
test[test_len] = '\0';
|
test[test_len] = '\0';
|
||||||
|
|
||||||
int test_w = font->measure_text(test, size);
|
int test_w = font->measure_text(test, size);
|
||||||
@@ -316,7 +319,7 @@ static void wrap_text(TrueTypeFont* font, int size, const char* text, int textLe
|
|||||||
} else {
|
} else {
|
||||||
// Emit current line and start fresh
|
// Emit current line and start fresh
|
||||||
if (cur_len > 0) add_line(cur, cur_len, color, size, font);
|
if (cur_len > 0) add_line(cur, cur_len, color, size, font);
|
||||||
int wl = word_len < 254 ? word_len : 254;
|
int wl = word_len < MAX_LINE ? word_len : MAX_LINE;
|
||||||
memcpy(cur, word_start, wl);
|
memcpy(cur, word_start, wl);
|
||||||
cur_len = wl;
|
cur_len = wl;
|
||||||
cur[cur_len] = '\0';
|
cur[cur_len] = '\0';
|
||||||
|
|||||||
Reference in New Issue
Block a user