diff options
| author | Jack Jamison <jackqjamison@gmail.com> | 2025-10-18 01:40:58 -0400 |
|---|---|---|
| committer | Jack Jamison <jackqjamison@gmail.com> | 2025-10-18 01:41:33 -0400 |
| commit | 24fb6ee3b2d6e3c68410e439c7395f5058dabce5 (patch) | |
| tree | 7defb2460e92b0019c26004110ed4f82d70466db | |
| parent | 4ec95c0bc1223aee10449bf831d29f4f683faff7 (diff) | |
exit codes
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | input_field.c | 2 | ||||
| -rw-r--r-- | keyboard.c | 9 | ||||
| -rw-r--r-- | layer_surface.c | 2 | ||||
| -rw-r--r-- | main.c | 7 | ||||
| -rw-r--r-- | state.h | 1 |
6 files changed, 20 insertions, 3 deletions
@@ -5,7 +5,7 @@ To build: `make` ## Todo - - [x] "selection" -- [ ] figure out whats going on with stderr and exit code +- [x] figure out whats going on with stderr and exit code - [ ] cursor - [ ] fuzzy filter and sort filtering by match % - [ ] fancy highlights diff --git a/input_field.c b/input_field.c index 46f0791..31ae627 100644 --- a/input_field.c +++ b/input_field.c @@ -41,6 +41,7 @@ bool type_key(client_state* state, xkb_keysym_t keysym) { (keysym == XKB_KEY_Escape)) { state->running = false; + state->exit_code = EXIT_FAILURE; return false; } @@ -114,4 +115,5 @@ void submit_line(client_state* state) { printf("%s\n", state->items[state->filtered_items[state->selected_filtered_item]].text); } state->running = false; + state->exit_code = EXIT_SUCCESS; } @@ -23,6 +23,7 @@ void wl_keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard, if (format != WL_KEYBOARD_KEYMAP_FORMAT_XKB_V1) { fprintf(stderr, "unknown keyboard format"); state->running = false; + state->exit_code = EXIT_FAILURE; return; } @@ -30,6 +31,7 @@ void wl_keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard, if (buffer == MAP_FAILED) { fprintf(stderr, "Failed to mmap keymap"); state->running = false; + state->exit_code = EXIT_FAILURE; return; } @@ -37,6 +39,7 @@ void wl_keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard, if (!state->xkb_context) { fprintf(stderr, "Failed to create xkb context\n"); state->running = false; + state->exit_code = EXIT_FAILURE; return; } @@ -49,6 +52,9 @@ void wl_keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard, state->xkb_state = xkb_state_new(state->xkb_keymap); if (!state->xkb_state) { fprintf(stderr, "Failed to create state"); + state->running = false; + state->exit_code = EXIT_FAILURE; + return; } struct xkb_compose_table* xkb_compose_table = xkb_compose_table_new_from_locale( @@ -56,6 +62,8 @@ void wl_keyboard_keymap(void *data, struct wl_keyboard *wl_keyboard, if (!xkb_compose_table) { fprintf(stderr, "Failed to create xkb compose table"); + state->running = false; + state->exit_code = EXIT_FAILURE; return; } @@ -73,6 +81,7 @@ void wl_keyboard_leave(void *data, struct wl_keyboard *wl_keyboard, // close on focus lost state->running = false; + state->exit_code = EXIT_FAILURE; } void wl_keyboard_key(void *data, struct wl_keyboard *wl_keyboard, diff --git a/layer_surface.c b/layer_surface.c index 7758dde..936e1ab 100644 --- a/layer_surface.c +++ b/layer_surface.c @@ -45,7 +45,9 @@ void configure(void *data, struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, void closed(void *data, struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1) { client_state* state = data; + state->running = false; + state->exit_code = EXIT_FAILURE; } struct zwlr_layer_surface_v1_listener layer_surface_listener = { @@ -57,7 +57,7 @@ int main(int argc, char* argv[]) { state.display = wl_display_connect(NULL); if (!state.display) { fprintf(stderr, "Failed to Connect to wayland display\n"); - return 0; + return EXIT_FAILURE; } // bind globals and roundtrip @@ -72,7 +72,7 @@ int main(int argc, char* argv[]) { // set up graphics if (!init_gl(&state)) { fprintf(stderr, "Failed to Initalize EGL/OpenGL\n"); - return 1; + return EXIT_FAILURE; } // create font altas textures @@ -90,9 +90,12 @@ int main(int argc, char* argv[]) { render_frame(&state); } + // cleanup (of course) if (state.items) { array_free(state.items); } + + return state.exit_code; } void poll_events(client_state* state) { @@ -103,6 +103,7 @@ typedef struct { item_t* items; uint32_t* filtered_items; bool running; + int exit_code; } client_state; |
