Skip to content

Conversation

jonahgraham
Copy link
Contributor

The pre-existing implementation of Clipboard for GTK4 only allowed copying and pasting within the application.

Fixes #2126

@jonahgraham jonahgraham added the gtk4 GTK4 issues label Oct 3, 2025
Copy link
Contributor

github-actions bot commented Oct 3, 2025

Test Results

   88 files   - 27     88 suites   - 27   8m 11s ⏱️ - 3m 53s
4 556 tests  -  4  4 538 ✅  -  6  18 💤 +2  0 ❌ ±0 
  261 runs   - 50    258 ✅  - 50   3 💤 ±0  0 ❌ ±0 

Results for commit 28f4799. ± Comparison against base commit dfd19fc.

This pull request removes 5 and adds 1 tests. Note that renamed tests count towards both.
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_dnd_Clipboard ‑ test_LocalClipboard(int)[2]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_dnd_Clipboard ‑ test_Remote(int)[2]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_dnd_Clipboard ‑ test_getContents(int)[2]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_dnd_Clipboard ‑ test_setContents(int)[2]
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_graphics_GC ‑ test_drawImageLorg_eclipse_swt_graphics_ImageIIII_ImageDataAtSizeProvider(int)
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_dnd_Clipboard ‑ test_getContentsAsync(int)[1]
This pull request skips 3 tests.
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_dnd_Clipboard ‑ test_getContentsBothClipboards
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_dnd_Clipboard ‑ test_setContentsBothClipboards
org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Shell ‑ test_activateEventSend

♻️ This comment has been updated with latest results.

@jonahgraham jonahgraham self-assigned this Oct 6, 2025
@jonahgraham jonahgraham force-pushed the clipboard branch 3 times, most recently from 929cde3 to 374db73 Compare October 21, 2025 18:52
Obtaining data from the clipboard is fundamentally an asynchronous
operation, the event loop, at least at the OS level, needs to run
for the data to become available.

This PR proposes new API that provides asynchronous equivalents of
getContents methods called getContentsAsync that return
CompleteableFutures.

This new API will allow SWT API consumers to interact better with the
clipboard when the OS (window system) API is actually implemented in an
asynchronous manner.

GTK3 and cocoa provides API that spins the event loop as needed so
that a synchronous looking API can be provided to the user of the API.
For example, in SWT we use gtk_clipboard_wait_for_contents which
spins the loop in the GTK library itself
[here](https://gitlab.gnome.org/GNOME/gtk/-/blob/716458e86a222f43e64f7a4feda37749f3469ee4/gtk/gtkclipboard.c#L1436)

GTK4 does not provide such an API and leaves it to the user
of the API to spin the event loop.

Win32 is somewhat of a hybrid. The API appears synchronous, but SWT
needs to spin in a couple of places, such as
[getData](https://github.com/eclipse-platform/eclipse.platform.swt/blob/63e8925dc77db3b93ef521dc6cf2bd6ded7bab64/bundles/org.eclipse.swt/Eclipse%20SWT%20Drag%20and%20Drop/win32/org/eclipse/swt/dnd/Transfer.java#L46)

Part of eclipse-platform#2598 and eclipse-platform#2126
…cations

The pre-existing implementation of Clipboard for GTK4 only allowed
copying and pasting within the application.

Add 'clipboard' Tag to all tests that use it, and mark all suites
as `failIfNoTests` = `false` so that tags are useful

Fixes eclipse-platform#2126
@jonahgraham
Copy link
Contributor Author

In addition the automated tests contained within this change the other ways to test this change involves manually running multiple instances of ClipboardExample (in SWT examples), in both GTK3 and GTK4 and ensuring that all types can be copied between instances. Using gtk4-demo is also useful.

Testing has been done in GNOME, KDE and Xfce, both with clipboard managers disabled and enabled.

Note: the parent commit of this PR is #2650 which is also waiting for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gtk4 GTK4 issues

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

[GTK4] Implement Full Clipboard support for GTK4

1 participant