aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/mgl/window/window.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/include/mgl/window/window.h b/include/mgl/window/window.h
index f42d592..7dd85b4 100644
--- a/include/mgl/window/window.h
+++ b/include/mgl/window/window.h
@@ -54,6 +54,19 @@ typedef struct {
bool override_redirect; /* false by default */
} 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;
+
+/*
+ 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).
+*/
+typedef bool (*mgl_clipboard_callback)(const unsigned char *data, size_t size, mgl_clipboard_type clipboard_type, void *userdata);
+
/* |params| can be NULL */
int mgl_window_create(mgl_window *self, const char *title, const mgl_window_create_params *params);
int mgl_window_init_from_existing_window(mgl_window *self, mgl_window_handle existing_window);
@@ -101,8 +114,15 @@ 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);
-/* A malloc'ed and null terminated string is returned in |str|, it should be deallocated with free */
-bool mgl_window_get_clipboard(mgl_window *self, char **str, size_t *size);
+bool mgl_window_get_clipboard(mgl_window *self, mgl_clipboard_callback callback, void *userdata);
+/*
+ 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.
+ This function returns false if there is nothing to copy, or if the clipboard
+ contains clipboard data that is not a string or if it fails to copy the data
+ for any other reason.
+*/
+bool mgl_window_get_clipboard_string(mgl_window *self, char **str, size_t *size);
void mgl_window_set_key_repeat_enabled(mgl_window *self, bool enabled);
#endif /* MGL_WINDOW_H */