summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-12 23:28:33 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-12 23:28:33 +0300
commitf6a42623ec1e3bc718ae685ddbb0be118364121e (patch)
treed1fdc33c0b433b2c1dffaffeac56be814f100b2b /examples
parent4ab6c6924f08fe64d594d099509924576d0f7ea2 (diff)
fix: prevent close stall on Wayland and ensure clean immediate shutdown on close
Diffstat (limited to 'examples')
-rw-r--r--examples/notepad.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/examples/notepad.c b/examples/notepad.c
index 2d20039..beb7051 100644
--- a/examples/notepad.c
+++ b/examples/notepad.c
@@ -354,6 +354,9 @@ static void *worker_thread(void *arg)
}
}
+ if (!ed->worker_running)
+ break;
+
struct doc_stats *s = malloc(sizeof(*s));
if (s) {
s->words = word_count;
@@ -1087,6 +1090,8 @@ static int on_event(void *ud, const struct yasl_event *ev)
/* Shortcuts */
if (ctrl) {
switch (ev->key.key) {
+ case YASL_KEY_Q:
+ return YASL_APP_QUIT;
case YASL_KEY_N:
editor_new_file(ed);
yasl_surface_request_frame(ed->surface);
@@ -1394,14 +1399,6 @@ static int on_event(void *ud, const struct yasl_event *ev)
break;
case YASL_EVENT_WINDOW_CLOSE_REQUEST:
- if (ed->is_modified && ed->prompt != PROMPT_CONFIRM_QUIT) {
- ed->prompt = PROMPT_CONFIRM_QUIT;
- ed->prompt_len = 0;
- ed->prompt_buf[0] = '\0';
- editor_set_status(ed, "Save changes before exit? (y/n/esc)");
- yasl_surface_request_frame(ed->surface);
- return YASL_APP_CONTINUE;
- }
return YASL_APP_QUIT;
default:
@@ -1562,7 +1559,7 @@ static void on_quit(void *ud, struct yasl_display *d)
struct editor *ed = ud;
ed->worker_running = false;
pthread_mutex_lock(&ed->worker_mutex);
- pthread_cond_signal(&ed->worker_cond);
+ pthread_cond_broadcast(&ed->worker_cond);
pthread_mutex_unlock(&ed->worker_mutex);
pthread_join(ed->worker_tid, NULL);
pthread_mutex_destroy(&ed->worker_mutex);