Skip to content

X11 mate clipboard #12002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jul 16, 2023
Merged

X11 mate clipboard #12002

merged 9 commits into from
Jul 16, 2023

Conversation

viordash
Copy link
Contributor

@viordash viordash commented Jul 2, 2023

What does the pull request do?

Fixes custom format data saving if CLIPBOARD_MANAGER is available.
Adds a wait for the data to be saved to CLIPBOARD_MANAGER to complete.

What is the current behavior?

Linux Mint 21.1 Mate 64.
Linux Ubuntu 18.04

Unstable use of custom data formats, such as the file copy format, even if the save (SetDataObjectAsync) succeeds and the subsequent read (GetDataAsync) returns the values written, the ability to paste the file is still not available on X11.
Code example:

      var dataObject = new DataObject();

      const string data = "copy\nfile:///tmp/X11Clipboard.cs";
      dataObject.Set("x-special/mate-copied-files", data);

      await clipboard.ClearAsync();
      await clipboard.SetDataObjectAsync(dataObject);

      var paste = await clipboard.GetDataAsync("x-special/mate-copied-files");
      if (paste is byte[] xbytes)
      {
          Debug.WriteLine("x-special :" + System.Text.Encoding.UTF8.GetString(xbytes));
      }

The current implementation of X11Clipboard.SetDataObjectAsync with the existing CLIPBOARD_MANAGER only stores text atoms, StoreAtomsInClipboardManager(_textAtoms). The required formats will be processed later, in OnEvent.
Also, saving with StoreAtomsInClipboardManager.CLIPBOARD_MANAGER does not wait for completion, which would sometimes confuse the X11 event stream because a new format/data request might arrive before the data was stored.

What is the updated/expected behavior with this PR?

Stable saving of data in various formats.
Added a TaskCompletionSource to asynchronously wait for the completion of the store in the StoreAtomsInClipboardManager.

How was the solution implemented (if it's not obvious)?

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0037324-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0037334-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 requested review from kekekeks and jmacato July 2, 2023 19:12
Copy link
Member

@jmacato jmacato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to add unit tests for this?

@viordash
Copy link
Contributor Author

viordash commented Jul 3, 2023

Would it be possible to add unit tests for this?

I'm ready to add the necessary unit tests for the x11 clipboard. But I couldn't find a test project with x11 support. Please indicate in which project I can add these tests

@maxkatz6
Copy link
Member

maxkatz6 commented Jul 4, 2023

Yeah, we don't have platform-specific tests for Linux @jmacato
At some point it would make sense to add integration tests for linux.

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0037376-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0037706-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 requested a review from jmacato July 14, 2023 00:44
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0037720-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 enabled auto-merge July 15, 2023 02:24
@avaloniaui-team
Copy link
Contributor

You can test this PR using the following package version. 11.0.999-cibuild0037757-beta. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 disabled auto-merge July 16, 2023 07:38
@maxkatz6 maxkatz6 merged commit fa0a534 into AvaloniaUI:master Jul 16, 2023
@viordash viordash deleted the x11-mate-clipboard branch July 16, 2023 09:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants