From be7e74fe9b51123dec29f9ed9c0441dc8725dd1a Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 9 Sep 2022 22:59:06 +0200 Subject: Support png,jpg and gif clipboard. Use callback for clipboard --- tests/main.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/main.c b/tests/main.c index df68dd5..7d94461 100644 --- a/tests/main.c +++ b/tests/main.c @@ -215,6 +215,11 @@ static void test_utf8() { require_equals(mgl_utf8_get_start_of_codepoint("abö", 3, 4), 2); } +static bool clipboard_callback(const unsigned char *data, size_t size, mgl_clipboard_type clipboard_type, void *userdata) { + fprintf(stderr, "clipboard type: %d, size: %zu, data: %s\n", clipboard_type, size, data); + return true; +} + int main(int argc, char **argv) { test_hash_map(); test_utf8(); @@ -287,11 +292,10 @@ int main(int argc, char **argv) { mgl_window_set_clipboard(&window, str, strlen(str)); fprintf(stderr, "Copied '%s' to the clipboard\n", str); } else if(event.key.code == MGL_KEY_V) { - char *str; - size_t size; - if(mgl_window_get_clipboard(&window, &str, &size)) { - fprintf(stderr, "Copied '%s' from the clipboard\n", str); - free(str); + if(mgl_window_get_clipboard(&window, clipboard_callback, NULL)) { + fprintf(stderr, "Successfully copied clipboard!\n"); + } else { + fprintf(stderr, "Failed to copy clipboard!\n"); } } fprintf(stderr, "key press event, code: %u\n", event.key.code); -- cgit v1.2.3