Skip to content
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

Clipboard / DnD changes #12600

Open
kekekeks opened this issue Aug 20, 2023 · 2 comments
Open

Clipboard / DnD changes #12600

kekekeks opened this issue Aug 20, 2023 · 2 comments

Comments

@kekekeks
Copy link
Member

Requirements

  1. Clipboard should be using only IDataObject APIs, existing methods should be thin wrappers over IDataObject (right now it's only possible to set a data object, but not get one)
  2. if IClipboard.GetDataObjectAsync is used when clipboard is owned by the current process, it should return the same object instance that was passed to IClipboard.SetDataObjectAsync, same with drag-n-drop
  3. We need to provide access to "generic" named platform-specific formats, those should always be represented as byte arrays or streams
  4. We need to provide access to known platform-independent formats (images, text, rich text, etc, see WPF format list), those should be always represented as relevant .NET types, it should not be possible to use byte arrays.
  5. Where possible, we should be consistent with WPF with platform-independent formats

Proposal (draft)

  1. platform-independent formats should be prefixed as "avalonia/"
  2. we should apply legacy emulation by treating pre-existing Text, Files, FileList formats formats as aliases
  3. if a platform-dependent format from a platform clipboard corresponds to a known platform-independent forma, it should not be listed and should be only reported as a platform-independent format
  4. platform-independent formats should be auto-converted into (multiple) platform-specific formats, e. g. when avalonia/Text is used with X11, we should be reporting UTF8_STRING, COMPOUND_TEXT, TEXT, STRING, text/plain;charset=utf-8, text/plain to the underlying system, when any of those exist in the platform clipboard, they should be removed from the reported format list and be represented by avalonia/Text
  5. if platform-independent format is not representable in the current platform, it should be serialized in some stable way and stored in net.avaloniaui.clipboard-formats/{name} platform format.

Questions

  • I'm not quite sure if hiding platform-specific formats is a good idea, need to check what WPF and Qt do
  • How would the API consumer specify if they want a Stream over a byte array for platform-specific formats? Should we always use streams?
  • What to do with platform-specific formats that can't be represented by a simple byte array? Win32 clipboard supports formats that are various win32 handles, macOS clipboard can have value dictionaries, can have multiple NSPasteboardItem instances in the same clipboard, etc
@maxkatz6
Copy link
Member

Also Share API

@kekekeks
Copy link
Member Author

Fix #12600

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

No branches or pull requests

2 participants