aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2022-05-22 18:26:35 -0400
committerDavid Robillard <d@drobilla.net>2023-11-11 09:54:18 -0500
commit91051e9059b67b8d633e385afb48a36d4f9467ba (patch)
tree0d221ea736e27dec7f405acfe2b866b4f81398e3 /src
parentc59e88aa6fa60c6f7424da737fcaf0496a0bf3d6 (diff)
downloadpugl-91051e9059b67b8d633e385afb48a36d4f9467ba.tar.gz
pugl-91051e9059b67b8d633e385afb48a36d4f9467ba.tar.bz2
pugl-91051e9059b67b8d633e385afb48a36d4f9467ba.zip
Add action parameter to puglAcceptOffer()
Diffstat (limited to 'src')
-rw-r--r--src/mac.m20
-rw-r--r--src/win.c1
-rw-r--r--src/x11.c3
-rw-r--r--src/x11.h1
4 files changed, 24 insertions, 1 deletions
diff --git a/src/mac.m b/src/mac.m
index 6da3cf7..107cadb 100644
--- a/src/mac.m
+++ b/src/mac.m
@@ -1926,10 +1926,28 @@ puglGetClipboardType(const PuglView* const view,
return mimeType ? [mimeType UTF8String] : [uti UTF8String];
}
+static NSDragOperation
+getDragOperation(const PuglAction action)
+{
+ switch (action) {
+ case PUGL_ACTION_COPY:
+ return NSDragOperationCopy;
+ case PUGL_ACTION_LINK:
+ return NSDragOperationLink;
+ case PUGL_ACTION_MOVE:
+ return NSDragOperationMove;
+ case PUGL_ACTION_PRIVATE:
+ break;
+ }
+
+ return NSDragOperationPrivate;
+}
+
PuglStatus
puglAcceptOffer(PuglView* const view,
const PuglDataOfferEvent* const offer,
const uint32_t typeIndex,
+ const PuglAction action,
const PuglRect region)
{
PuglWrapperView* const wrapper = view->impl->wrapperView;
@@ -1943,7 +1961,7 @@ puglAcceptOffer(PuglView* const view,
return PUGL_BAD_PARAMETER;
}
- wrapper->dragOperation = NSDragOperationCopy;
+ wrapper->dragOperation = getDragOperation(action);
wrapper->dragTypeIndex = typeIndex;
const PuglDataEvent data = {PUGL_DATA,
diff --git a/src/win.c b/src/win.c
index d118b36..0b850ef 100644
--- a/src/win.c
+++ b/src/win.c
@@ -1372,6 +1372,7 @@ PuglStatus
puglAcceptOffer(PuglView* const view,
const PuglDataOfferEvent* const PUGL_UNUSED(offer),
const uint32_t typeIndex,
+ PuglAction PUGL_UNUSED(action),
const PuglRect region)
{
if (typeIndex != 0) {
diff --git a/src/x11.c b/src/x11.c
index 5bdbbed..a66ac30 100644
--- a/src/x11.c
+++ b/src/x11.c
@@ -508,6 +508,7 @@ clearX11Clipboard(PuglX11Clipboard* const board)
board->source = None;
board->numFormats = 0;
+ board->acceptedAction = PUGL_ACTION_PRIVATE;
board->acceptedFormatIndex = UINT32_MAX;
board->acceptedFormat = None;
board->data.len = 0;
@@ -2116,6 +2117,7 @@ PuglStatus
puglAcceptOffer(PuglView* const view,
const PuglDataOfferEvent* const offer,
const uint32_t typeIndex,
+ PuglAction action,
const PuglRect region)
{
(void)region;
@@ -2124,6 +2126,7 @@ puglAcceptOffer(PuglView* const view,
Display* const display = view->world->impl->display;
PuglX11Clipboard* const board = getX11Clipboard(view, offer->clipboard);
+ board->acceptedAction = action;
board->acceptedFormatIndex = typeIndex;
board->acceptedFormat = board->formats[typeIndex];
diff --git a/src/x11.h b/src/x11.h
index 58073e5..2e14ae2 100644
--- a/src/x11.h
+++ b/src/x11.h
@@ -61,6 +61,7 @@ typedef struct {
Atom* formats;
char** formatStrings;
unsigned long numFormats;
+ PuglAction acceptedAction;
uint32_t acceptedFormatIndex;
Atom acceptedFormat;
PuglBlob data;