ltk

Socket-based GUI for X11 (WIP)
git clone git://lumidify.org/ltk.git (fast, but not encrypted)
git clone https://lumidify.org/git/ltk.git (encrypted, but very slow)
Log | Files | Refs | README | LICENSE

commit 5aff106f8dd7610fe450e26880243949481ba5af
parent 63762ef33368a564ca5f630cde74981c63d32cd7
Author: lumidify <nobody@lumidify.org>
Date:   Sun,  7 Jun 2020 17:28:01 +0200

Add quit command

Diffstat:
Mltk.c | 10++++++----
Mtext_common.h | 5++++-
Mtext_line.h | 8++++----
3 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/ltk.c b/ltk.c @@ -44,6 +44,7 @@ static void ltk_load_theme(ltk_window *window, const char *path); static void ltk_destroy_theme(ltk_theme *theme); +static ltk_rect ltk_rect_union(ltk_rect r1, ltk_rect r2); static int running = 1; static char *cmd_input = NULL; @@ -91,7 +92,6 @@ ltk_window_invalidate_rect(ltk_window *window, ltk_rect rect) { void ltk_clean_up(ltk_window *window) { - XCloseDisplay(window->dpy); ltk_destroy_theme(window->theme); ltk_destroy_window(window); if (tokens) free(tokens); @@ -230,6 +230,8 @@ proc_cmds(ltk_window *window) { ltk_set_root_widget_cmd(window, tokens, tokens_len); } else if (strcmp(tokens[0], "draw") == 0) { ltk_draw_cmd(window, tokens, tokens_len); + } else if (strcmp(tokens[0], "quit") == 0) { + ltk_quit(window); } else { (void)fprintf(stderr, "Invalid command.\n"); } @@ -270,7 +272,7 @@ ltk_mainloop(ltk_window *window) { window->dirty_rect.w = 0; window->dirty_rect.h = 0; } - if (window->last_event) { + if (window->last_event && running) { struct ltk_event_queue *cur = window->last_event; struct ltk_event_queue *last; do { @@ -359,8 +361,7 @@ ltk_create_window(const char *theme_path, const char *title, int x, int y, unsig void ltk_destroy_window(ltk_window *window) { khint_t k; - ltk_widget *ptr = window->root_widget; - if (ptr) ptr->destroy(ptr, 0); + ltk_widget *ptr; XDestroyWindow(window->dpy, window->xwindow); for (k = kh_begin(window->widget_hash); k != kh_end(window->widget_hash); k++) { if (kh_exist(window->widget_hash, k)) { @@ -370,6 +371,7 @@ ltk_destroy_window(ltk_window *window) { } kh_destroy(widget, window->widget_hash); ltk_cleanup_text(); + XCloseDisplay(window->dpy); free(window); } diff --git a/text_common.h b/text_common.h @@ -24,8 +24,11 @@ #ifndef _TEXT_COMMON_H_ #define _TEXT_COMMON_H_ +/* +Requires: <stdint.h> +*/ + typedef struct ltk_font ltk_font; -typedef struct ltk_text ltk_text; /* Contains general info on glyphs that doesn't change regardless of the context */ typedef struct { diff --git a/text_line.h b/text_line.h @@ -21,12 +21,12 @@ * SOFTWARE. */ -#ifndef _TEXT_BUFFER_H_ -#define _TEXT_BUFFER_H_ +#ifndef _TEXT_LINE_H_ +#define _TEXT_LINE_H_ /* Requires the following includes: -<X11/Xlib.h>, <X11/Xutil.h>, "text_common.h", +<X11/Xlib.h>, <X11/Xutil.h>, <stdint.h>, "text_common.h", */ struct ltk_text_line { @@ -45,4 +45,4 @@ XImage *ltk_text_line_render(struct ltk_text_line *tl, Display *dpy, struct ltk_text_line *ltk_text_line_create(uint16_t font_size, char *text); void ltk_text_line_destroy(struct ltk_text_line *tl); -#endif /* _TEXT_BUFFER_H_ */ +#endif /* _TEXT_LINE_H_ */