mpv icon indicating copy to clipboard operation
mpv copied to clipboard

screenshot: add screenshot-to-clipboard command

Open rcombs opened this issue 1 year ago • 6 comments

Successor to #13837, post-#15355 and #15564.

Currently implemented only on macOS.

rcombs avatar Dec 25 '24 03:12 rcombs

Rebased with suggestions applied; split the function up to the extent that was possible without adding substantial duplication or major restructuring.

rcombs avatar Dec 28 '24 02:12 rcombs

I think there is no need for this to be a command. I designed the clipboard API with the ability for format conversion in mind: when the data formats in clipboard_access_params and clipboard_data are different, the backend can perform automatic format conversion if possible. This makes it possible to use the operating system's built-in data format conversion abilities.

In this specific case, it is possible to make the clipboard/image property writable, and a client can just set the clipboard content by writing a special token of MPV_FORMAT_STRING type like @screenshot window to the property.

Alternatively, writing a MPV_FORMAT_NODE nodemap containing information of the raw image data to that property should write that image to the clipboard, so a client can also use screenshot-raw command to acquire the image data and write the data to clipboard.

These approaches allow for more flexibility of setting image clipboard contents while not introducing a new command.

na-na-hi avatar Dec 28 '24 08:12 na-na-hi

I think supporting setting an MPV_FORMAT_NODE makes sense in the long term, but designing an API for it that's actually useful across a variety of pixel formats, colorspaces, etc. is going to be tricky, so I'd prefer to leave it out of this PR for now (see also the screenshot-raw command, which returns a node, but in a single hardcoded pixel format with no colorspace information).

I wouldn't object to having this be set clipboard/image "@screenshot window" or the like, though I do think the symmetry the current approach has with screenshot-to-file is probably a bit more intuitive for users?

Also, it probably makes most sense for any magic-string @screenshot support to happen up at the command/property level, rather than within each individual backend.

rcombs avatar Dec 28 '24 08:12 rcombs

tested the the mac parts and works as expected in programs that can handle those pastes. besides that one open point i am fine with he swift parts of the code.

would be nice if we could resolve the rest of the open points in a timely manner:

  • the user facing API
  • implementation on the mpv core side

Akemi avatar Dec 28 '24 14:12 Akemi

Rebased this a couple days ago; where are we on this now? Do we want to do set clipboard/image "@screenshot"?

rcombs avatar Feb 20 '25 15:02 rcombs