diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-06-23 09:39:46 +0200 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2023-06-23 09:40:39 +0200 |
| commit | fc72ea11b7c3703fab19ba6ae6fd358851a8f467 (patch) | |
| tree | 03089560de613b6c3252b53b3546b0fad41979f5 | |
| parent | 20e95d917417e7b86eb602362e4c6d3bb17a0dcb (diff) | |
fix settitle crash
| -rw-r--r-- | swt.c | 31 | ||||
| -rw-r--r-- | term.c | 8 | ||||
| -rw-r--r-- | term.h | 8 |
3 files changed, 38 insertions, 9 deletions
@@ -13,6 +13,7 @@ #include <errno.h> #include <stdlib.h> #include <locale.h> +#include <ctype.h> char *argv0; #include "wayland.h" @@ -100,6 +101,7 @@ static void data_device_data_offer(void *data, struct wl_data_device *data_devic static void data_source_send(void *data, struct wl_data_source *source, const char *mime_type, int fd); static void data_source_cancelled(void *data, struct wl_data_source *source); static void dummy() {} +static int is_valid_title(const char *title); /* global variables */ @@ -413,9 +415,36 @@ wseticontitle(char *title) { } +int +is_valid_title(const char *title) +{ + int i = 0; + + if (!title) + return 0; + + fprintf(stderr, "HERE\n"); + for (; i < STR_BUF_SIZ; ++i) { + if (title[i] == 0) { + return 1; + } + } + + fprintf(stderr, "FALSE\n"); + + return 0; +} + + void wsettitle(char *title) { - xdg_toplevel_set_title(win.surface.toplevel, title); + if (is_valid_title(title)) { + fprintf(stderr, "TRUE\n"); + xdg_toplevel_set_title(win.surface.toplevel, title); + fprintf(stderr, "SET TITLE\n"); + } else { + xdg_toplevel_set_title(win.surface.toplevel, "swt"); + } } @@ -28,14 +28,6 @@ #include <libutil.h> #endif -/* Arbitrary sizes */ -#define UTF_INVALID 0xFFFD -#define UTF_SIZ 4 -#define ESC_BUF_SIZ (128*UTF_SIZ) -#define ESC_ARG_SIZ 16 -#define STR_BUF_SIZ ESC_BUF_SIZ -#define STR_ARG_SIZ ESC_ARG_SIZ - /* macros */ #define IS_SET(flag) ((term.mode & (flag)) != 0) #define ISCONTROLC0(c) (BETWEEN(c, 0, 0x1f) || (c) == 0x7f) @@ -20,6 +20,14 @@ #define TRUECOLOR(r,g,b) (1 << 24 | (r) << 16 | (g) << 8 | (b)) #define IS_TRUECOL(x) (1 << 24 & (x)) +/* Arbitrary sizes */ +#define UTF_INVALID 0xFFFD +#define UTF_SIZ 4 +#define ESC_BUF_SIZ (128*UTF_SIZ) +#define ESC_ARG_SIZ 16 +#define STR_BUF_SIZ ESC_BUF_SIZ +#define STR_ARG_SIZ ESC_ARG_SIZ + enum glyph_attribute { ATTR_NULL = 0, ATTR_BOLD = 1 << 0, |