From 3c4deef40ccb57e46e3da30c76dee1e5011d7fd7 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 5 Nov 2022 11:18:03 +0100 Subject: Only allow text in mgl_window_get_clipboard_string --- include/mgl/window/window.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/mgl/window/window.h b/include/mgl/window/window.h index 34f8cbb..ed50dcb 100644 --- a/include/mgl/window/window.h +++ b/include/mgl/window/window.h @@ -56,12 +56,15 @@ typedef struct { } mgl_window_create_params; typedef enum { - MGL_CLIPBOARD_TYPE_STRING, - MGL_CLIPBOARD_TYPE_IMAGE_PNG, - MGL_CLIPBOARD_TYPE_IMAGE_JPG, - MGL_CLIPBOARD_TYPE_IMAGE_GIF, + MGL_CLIPBOARD_TYPE_STRING = 1 << 0, + MGL_CLIPBOARD_TYPE_IMAGE_PNG = 1 << 1, + MGL_CLIPBOARD_TYPE_IMAGE_JPG = 1 << 2, + MGL_CLIPBOARD_TYPE_IMAGE_GIF = 1 << 3, } mgl_clipboard_type; +#define MGL_CLIPBOARD_TYPE_ALL 0xFFFFFFFF +#define MGL_CLIPBOARD_TYPE_IMAGE (MGL_CLIPBOARD_TYPE_IMAGE_PNG | MGL_CLIPBOARD_TYPE_IMAGE_JPG | MGL_CLIPBOARD_TYPE_IMAGE_GIF) + /* Return true to continue. |mgl_window_get_clipboard| returns false if this returns false. Note: |size| is the size of the current data, not the total data (if the callback only contains a part of the data). @@ -115,7 +118,8 @@ void mgl_window_set_size(mgl_window *self, mgl_vec2i size); void mgl_window_set_size_limits(mgl_window *self, mgl_vec2i minimum, mgl_vec2i maximum); void mgl_window_set_clipboard(mgl_window *self, const char *str, size_t size); -bool mgl_window_get_clipboard(mgl_window *self, mgl_clipboard_callback callback, void *userdata); +/* clipboard_types should be a bit-or of mgl_clipboard_type */ +bool mgl_window_get_clipboard(mgl_window *self, mgl_clipboard_callback callback, void *userdata, uint32_t clipboard_types); /* A new string is allocated and the pointer is copied to |str| with the size returned in |size|. |str| should be deallocated with |free| by the user. -- cgit v1.2.3