aboutsummaryrefslogtreecommitdiffstats
path: root/include/pugl
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-05-22 17:48:16 -0400
committerDavid Robillard <d@drobilla.net>2023-11-11 09:49:51 -0500
commitc59e88aa6fa60c6f7424da737fcaf0496a0bf3d6 (patch)
treeca5e6f85207f3f51bd3015a67c23d9dd0c917846 /include/pugl
parent32733abab8546b708cab59a4df09f92eb3214f73 (diff)
downloadpugl-c59e88aa6fa60c6f7424da737fcaf0496a0bf3d6.tar.gz
pugl-c59e88aa6fa60c6f7424da737fcaf0496a0bf3d6.tar.bz2
pugl-c59e88aa6fa60c6f7424da737fcaf0496a0bf3d6.zip
Add API support for multiple clipboards
Adds a PuglClipboard enum, and uses it everywhere necessary to "structurally" support multiple clipboards. Towards re-using this API to support DnD.
Diffstat (limited to 'include/pugl')
-rw-r--r--include/pugl/pugl.h44
1 files changed, 32 insertions, 12 deletions
diff --git a/include/pugl/pugl.h b/include/pugl/pugl.h
index 329acba..852003f 100644
--- a/include/pugl/pugl.h
+++ b/include/pugl/pugl.h
@@ -148,6 +148,16 @@ typedef enum {
PUGL_CROSSING_UNGRAB ///< Crossing due to a grab release
} PuglCrossingMode;
+/**
+ A system clipboard.
+
+ A clipboard provides a mechanism for transferring data between views,
+ including views in different processes.
+*/
+typedef enum {
+ PUGL_CLIPBOARD_GENERAL, ///< General clipboard for copy/pasted data
+} PuglClipboard;
+
/// Common header for all event structs
typedef struct {
PuglEventType type; ///< Event type
@@ -649,11 +659,12 @@ typedef struct {
puglAcceptOffer().
*/
typedef struct {
- PuglEventType type; ///< #PUGL_DATA_OFFER
- PuglEventFlags flags; ///< Bitwise OR of #PuglEventFlag values
- double time; ///< Time in seconds
- double x; ///< View-relative X coordinate
- double y; ///< View-relative Y coordinate
+ PuglEventType type; ///< #PUGL_DATA_OFFER
+ PuglEventFlags flags; ///< Bitwise OR of #PuglEventFlag values
+ double time; ///< Time in seconds
+ double x; ///< View-relative X coordinate
+ double y; ///< View-relative Y coordinate
+ PuglClipboard clipboard; ///< Clipboard with available data
} PuglDataOfferEvent;
/**
@@ -669,6 +680,7 @@ typedef struct {
double time; ///< Time in seconds
double x; ///< View-relative X coordinate
double y; ///< View-relative Y coordinate
+ PuglClipboard clipboard; ///< Clipboard with available data
uint32_t typeIndex; ///< Index of datatype
} PuglDataEvent;
@@ -1495,7 +1507,7 @@ puglPaste(PuglView* view);
*/
PUGL_API
uint32_t
-puglGetNumClipboardTypes(const PuglView* view);
+puglGetNumClipboardTypes(const PuglView* view, PuglClipboard clipboard);
/**
Return the identifier of a type available in a clipboard.
@@ -1508,7 +1520,9 @@ puglGetNumClipboardTypes(const PuglView* view);
*/
PUGL_API
const char*
-puglGetClipboardType(const PuglView* view, uint32_t typeIndex);
+puglGetClipboardType(const PuglView* view,
+ PuglClipboard clipboard,
+ uint32_t typeIndex);
/**
Accept data offered from a clipboard.
@@ -1543,16 +1557,18 @@ puglAcceptOffer(PuglView* view,
puglGetClipboard() or pasted into other applications.
@param view The view.
+ @param clipboard Clipboard to set data for.
@param type The MIME type of the data, "text/plain" is assumed if `NULL`.
@param data The data to copy to the clipboard.
@param len The length of data in bytes (including terminator if necessary).
*/
PUGL_API
PuglStatus
-puglSetClipboard(PuglView* view,
- const char* type,
- const void* data,
- size_t len);
+puglSetClipboard(PuglView* view,
+ PuglClipboard clipboard,
+ const char* type,
+ const void* data,
+ size_t len);
/**
Get the clipboard contents.
@@ -1561,13 +1577,17 @@ puglSetClipboard(PuglView* view,
puglSetClipboard() or copied from another application.
@param view The view.
+ @param clipboard Clipboard to get data from.
@param typeIndex Index of the data type to get the item as.
@param[out] len Set to the length of the data in bytes.
@return The clipboard contents, or null.
*/
PUGL_API
const void*
-puglGetClipboard(PuglView* view, uint32_t typeIndex, size_t* len);
+puglGetClipboard(PuglView* view,
+ PuglClipboard clipboard,
+ uint32_t typeIndex,
+ size_t* len);
/**
Set the mouse cursor.