summaryrefslogtreecommitdiffstats
path: root/widget/gtk/nsClipboardX11.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /widget/gtk/nsClipboardX11.h
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'widget/gtk/nsClipboardX11.h')
-rw-r--r--widget/gtk/nsClipboardX11.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/widget/gtk/nsClipboardX11.h b/widget/gtk/nsClipboardX11.h
new file mode 100644
index 0000000000..2363111f74
--- /dev/null
+++ b/widget/gtk/nsClipboardX11.h
@@ -0,0 +1,73 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim:expandtab:shiftwidth=4:tabstop=4:
+ */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef __nsClipboardX11_h_
+#define __nsClipboardX11_h_
+
+#include <gtk/gtk.h>
+
+enum ClipboardDataType { CLIPBOARD_DATA, CLIPBOARD_TEXT, CLIPBOARD_TARGETS };
+
+class nsRetrievalContextX11 : public nsRetrievalContext {
+ public:
+ enum State { INITIAL, COMPLETED, TIMED_OUT };
+
+ virtual const char* GetClipboardData(const char* aMimeType,
+ int32_t aWhichClipboard,
+ uint32_t* aContentLength) override;
+ virtual const char* GetClipboardText(int32_t aWhichClipboard) override;
+ virtual void ReleaseClipboardData(const char* aClipboardData) override;
+
+ virtual GdkAtom* GetTargets(int32_t aWhichClipboard,
+ int* aTargetNums) override;
+
+ virtual bool HasSelectionSupport(void) override;
+
+ // Call this when data or text has been retrieved.
+ void Complete(ClipboardDataType aDataType, const void* aData,
+ int aDataRequestNumber);
+
+ nsRetrievalContextX11();
+
+ private:
+ bool WaitForClipboardData(ClipboardDataType aDataType,
+ GtkClipboard* clipboard,
+ const char* aMimeType = nullptr);
+
+ /**
+ * Spins X event loop until timing out or being completed. Returns
+ * null if we time out, otherwise returns the completed data (passing
+ * ownership to caller).
+ */
+ bool WaitForX11Content();
+
+ State mState;
+ int mClipboardRequestNumber;
+ void* mClipboardData;
+ uint32_t mClipboardDataLength;
+ GdkAtom mTargetMIMEType;
+};
+
+class ClipboardRequestHandler {
+ public:
+ ClipboardRequestHandler(nsRetrievalContextX11* aContext,
+ ClipboardDataType aDataType, int aDataRequestNumber)
+ : mContext(aContext),
+ mDataRequestNumber(aDataRequestNumber),
+ mDataType(aDataType) {}
+
+ void Complete(const void* aData) {
+ mContext->Complete(mDataType, aData, mDataRequestNumber);
+ }
+
+ private:
+ nsRetrievalContextX11* mContext;
+ int mDataRequestNumber;
+ ClipboardDataType mDataType;
+};
+
+#endif /* __nsClipboardX11_h_ */