summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/yasl/yasl.h9
-rw-r--r--src/common/utf8.c11
-rw-r--r--src/wayland/clipboard.c9
3 files changed, 20 insertions, 9 deletions
diff --git a/include/yasl/yasl.h b/include/yasl/yasl.h
index 081e1f0..c211a0b 100644
--- a/include/yasl/yasl.h
+++ b/include/yasl/yasl.h
@@ -208,12 +208,12 @@ struct yasl_key_event {
struct yasl_mouse_event {
struct yasl_vector2i pos;
- int button;
+ int16_t button;
+ int16_t scroll_lines;
enum yasl_pointer_kind kind;
+ enum yasl_pointer_device device;
uint32_t mods;
- int scroll_lines;
float scroll_delta;
- enum yasl_pointer_device device;
struct yasl_pointer_pen pen;
};
@@ -227,8 +227,9 @@ enum yasl_input_kind {
};
struct yasl_input_event {
- enum yasl_input_kind kind;
struct yasl_surface *surface;
+ enum yasl_input_kind kind;
+ uint32_t reserved;
union {
struct yasl_key_event key;
struct yasl_mouse_event mouse;
diff --git a/src/common/utf8.c b/src/common/utf8.c
index 7f2e6f1..1d4cf13 100644
--- a/src/common/utf8.c
+++ b/src/common/utf8.c
@@ -54,10 +54,17 @@ bool yasl_utf8_validate(const char *str, size_t len)
char *yasl_utf8_sanitize_dup(const char *str)
{
- if (!str) return NULL;
+ if (unlikely(!str)) return NULL;
size_t len = strlen(str);
+ if (likely(yasl_utf8_validate(str, len))) {
+ char *out = malloc(len + 1);
+ if (unlikely(!out)) return NULL;
+ memcpy(out, str, len + 1);
+ return out;
+ }
+
char *out = malloc(len + 1);
- if (!out) return NULL;
+ if (unlikely(!out)) return NULL;
const unsigned char *p = (const unsigned char *)str;
size_t o = 0;
diff --git a/src/wayland/clipboard.c b/src/wayland/clipboard.c
index 324644f..0e6ce33 100644
--- a/src/wayland/clipboard.c
+++ b/src/wayland/clipboard.c
@@ -170,9 +170,12 @@ static struct transfer *start_transfer(struct clipboard *c, int fd, bool sending
static const char *match_text_mime(const char *mime)
{
- if (!strcasecmp(mime, "text/plain;charset=utf-8")) return "text/plain;charset=utf-8";
- if (!strcasecmp(mime, "text/plain;charset=utf8")) return "text/plain;charset=utf8";
- if (!strcasecmp(mime, "text/plain")) return "text/plain";
+ if (unlikely(!mime)) return NULL;
+ if (likely(!strncasecmp(mime, "text/plain", 10))) {
+ if (!strcasecmp(mime, "text/plain;charset=utf-8")) return "text/plain;charset=utf-8";
+ if (!strcasecmp(mime, "text/plain;charset=utf8")) return "text/plain;charset=utf8";
+ if (!strcasecmp(mime, "text/plain")) return "text/plain";
+ }
if (!strcasecmp(mime, "UTF8_STRING")) return "UTF8_STRING";
if (!strcasecmp(mime, "STRING")) return "STRING";
if (!strcasecmp(mime, "TEXT")) return "TEXT";