Skip to content

Conversation

jonahgraham
Copy link
Contributor

This is my "its sort of working" Clipboard for GTK4.

This PR is a draft and contains a bunch of TODOs, some are questions for myself, some are questions for others. There are a number of items in here I plan to pull into separate PRs, so this PR may not be so interesting to review yet. But if someone want to, they should be able to run the new test class Test_org_eclipse_swt_dnd_Clipboard to see basic functionality working. This test seems reliable on my machine on GTK3, but not so much on GTK4 yet.

Once complete this will:

Fixes #2126

Copy link
Contributor

github-actions bot commented Sep 24, 2025

Test Results

   88 files   - 30     88 suites   - 30   7m 44s ⏱️ - 2m 32s
4 403 tests  - 37  4 388 ✅  - 32  15 💤  - 2  0 ❌  - 3 
  237 runs   - 61    234 ✅  - 57   3 💤  - 1  0 ❌  - 3 

Results for commit b300e03. ± Comparison against base commit 810cbcc.

This pull request removes 37 tests.
AllGTKTests Test_GtkConverter ‑ test_HeuristicASCII_dollarSign
AllGTKTests Test_GtkConverter ‑ test_HeuristicASCII_emptyString
AllGTKTests Test_GtkConverter ‑ test_HeuristicASCII_letterA
AllGTKTests Test_GtkConverter ‑ test_HeuristicASCII_letters
AllGTKTests Test_GtkConverter ‑ test_HeuristicUTF16LE_null
AllGTKTests Test_GtkConverter ‑ test_HeuristicUTF16_AsciiLetters
AllGTKTests Test_GtkConverter ‑ test_HeuristicUTF16_Asciiletter
AllGTKTests Test_GtkConverter ‑ test_HeuristicUTF16_LotsOfLetters
AllGTKTests Test_GtkConverter ‑ test_HeuristicUTF16_letter
AllGTKTests Test_GtkConverter ‑ test_HeuristicUTF16_letters
…

♻️ This comment has been updated with latest results.

@jonahgraham
Copy link
Contributor Author

I have split out some foundational work into the following PRs that can be reviewed now:

A number of places in the GTK4 API there is the possibility of passing
in arrays of Strings, i.e. Java String[] -> char ** as input argument
to C side.

This change adds better support to the JNI generator for this use case
by converting the jobjectArray (String[]) to char ** on the C side.

Part of #2126
Split out of #2538
akurtakov pushed a commit that referenced this pull request Sep 25, 2025
A number of places in the GTK4 API there is the possibility of passing
in arrays of Strings, i.e. Java String[] -> char ** as input argument
to C side.

This change adds better support to the JNI generator for this use case
by converting the jobjectArray (String[]) to char ** on the C side.

Part of #2126
Split out of #2538
jonahgraham added a commit that referenced this pull request Sep 25, 2025
Testing the Clipboard can be difficult because there are a lot of system
issues that can interfere, but of particular concern are:

1. System clipboard managers which may take ownership of the clipboard
at unexpected times.
2. Limitations as to when processes can access clipboard, such as on Wayland
where only active window can access clipboard.
3. Different behaviour when copying within a single process than between
processes.

These tests aim to resolve these issues.

For the system clipboard manager there are a lot of extra sleep calls
to allow clipboard manager to complete operations before continuing tests.
In addition, we run all the tests multiple times by default to ensure
stability.

For the process limitations, we carefully control when the shell is created
because we often cannot get focus back when shell ends up in the background.
See the openAndFocusShell and openAndFocusRemote methods.

For the different behaviours, we spin up a simple Swing app in a new
process (the "remote" in openAndFocusRemote above). This app can be
directed, over RMI, to access the clipboard. This allows our test to
place data on the clipboard and ensure that the remote app can read the
data successfully.

For now this test only covers basic text (and a little of RTF). Adding
Image and other transfers is part of the future work as such functionality
is added in GTK4 while working on #2126

For the changes to SwtTestUtil that we required:

1. isGTK4 moved from Test_org_eclipse_swt_widgets_Shell.java to the Utils
2. processEvents was limited to 20 readAndDispatch calls per second due
to the ordering of the targetTimestamp check. This change allows full speed
readAndDispatching.
3. getPath was refactored to allow better control of source and destination
of files extracted. See extracting of class files for remote Swing app
in startRemoteClipboardCommands method

Part of #2126
Split out of #2538
@jonahgraham jonahgraham closed this by deleting the head repository Oct 2, 2025
@jonahgraham
Copy link
Contributor Author

This was closed and will be replaced by a new PR - it was closed because I deleted my fork while trying to track down a git lfs issue I was having.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gtk4 GTK4 issues
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

[GTK4] Implement Full Clipboard support for GTK4
1 participant