diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-09-09 23:28:29 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-09-09 23:28:29 +0200 |
commit | 01b9943e9cd886bcfd22ba58783137e554ef2a3c (patch) | |
tree | 8c49afa4cc4b9c8515813c89bf790ddba613248e /src/window | |
parent | b9892cbbeb217b45a593fe05d3f42245b70820db (diff) |
Support png,jpg and gif clipboard. Use callback for clipboard
Diffstat (limited to 'src/window')
-rw-r--r-- | src/window/Window.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/window/Window.cpp b/src/window/Window.cpp index 5174504..ec187e3 100644 --- a/src/window/Window.cpp +++ b/src/window/Window.cpp @@ -10,6 +10,11 @@ extern "C" { } namespace mgl { + static bool clipboard_callback_interface(const unsigned char *data, size_t size, mgl_clipboard_type clipboard_type, void *userdata) { + ClipboardCallback *clipboard_callback = (ClipboardCallback*)userdata; + return (*clipboard_callback)(data, size, clipboard_type); + } + Window::Window() { window.window = 0; } @@ -138,11 +143,15 @@ namespace mgl { mgl_window_set_clipboard(&window, str.c_str(), str.size()); } - std::string Window::get_clipboard() { + bool Window::get_clipboard(ClipboardCallback callback) { + return mgl_window_get_clipboard(&window, clipboard_callback_interface, &callback); + } + + std::string Window::get_clipboard_string() { std::string result; char *str = nullptr; size_t size = 0; - if(mgl_window_get_clipboard(&window, &str, &size)) { + if(mgl_window_get_clipboard_string(&window, &str, &size)) { result.assign(str, size); free(str); } |