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

add "native" wayland clipboard backend and several related properties #15704

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions DOCS/interface-changes/clipboard.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
add `--clipboard-enable` and `--clipboard-monitor` options
add `clipboard` property
add `current-clipboard-backend` property
30 changes: 28 additions & 2 deletions DOCS/man/input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3968,10 +3968,36 @@ Property list
The text content in the clipboard (Windows, Wayland and macOS only).
Writing to this property sets the text clipboard content (Windows only).

``clipboard/text-primary``
The text content in the primary selection (Wayland only).

.. note::

On Wayland, the clipboard content is only updated when the compositor
sends a selection data offer (typically when VO window is focused).
On Wayland with the ``vo`` clipboard backend, the clipboard content is
only updated when the compositor sends a selection data offer
(typically when VO window is focused). The ``wayland`` backend typically
does not have this limitation.
See ``current-clipboard-backend`` property for more details.

``current-clipboard-backend``
A string containing the currently active clipboard backend.
The following clipboard backends are implemented:

``win32``
Windows backend.

``mac``
macOS backend.

``wayland``
Wayland backend. This backend is only available if the compositor
supports the ``zwlr_data_control_manager_v1`` protocol.

``vo``
VO backend. Requires an active VO window, and support differs across
platforms. Currently, this is used as a fallback for Wayland
compositors without support for the ``zwlr_data_control_manager_v1``
protocol.

Inconsistencies between options and properties
----------------------------------------------
Expand Down
6 changes: 5 additions & 1 deletion DOCS/man/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7860,10 +7860,14 @@ Miscellaneous
writing to the ``clipboard`` property to get and set clipboard contents.

``--clipboard-monitor=<yes|no>``
(Windows and macOS only)
(Windows, Wayland and macOS only)

Enable clipboard monitoring so that the ``clipboard`` property can be
observed for content changes (default: no). This only affects clipboard
implementations which use polling to monitor clipboard updates.
Other platforms currently ignore this option and always/never notify
changes.

On Wayland, this option only has effect on the ``wayland`` backend, and
not for the ``vo`` backend. See ``current-clipboard-backend`` property for
more details.
9 changes: 9 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,15 @@ if features['wayland']
subdir(join_paths('video', 'out'))
endif

foreach v: ['1.39']
features += {'wayland-protocols-' + v.replace('.', '-'):
wayland['deps'][2].version().version_compare('>=' + v)}
endforeach

if features['wayland-protocols-1-39']
sources += files('player/clipboard/clipboard-wayland.c')
endif

features += {'memfd-create': false}
if features['wayland']
features += {'memfd-create': cc.has_function('memfd_create',
Expand Down
10 changes: 6 additions & 4 deletions player/clipboard/clipboard-vo.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@

struct clipboard_vo_priv {
struct MPContext *mpctx;
struct mp_log *log;
};

static int init(struct clipboard_ctx *cl, struct clipboard_init_params *params)
{
struct clipboard_vo_priv *priv = talloc_ptrtype(cl, priv);
priv->mpctx = params->mpctx;
priv->log = mp_log_new(priv, cl->log, "vo"),
cl->priv = priv;
return CLIPBOARD_SUCCESS;
}
Expand All @@ -52,10 +54,10 @@ static int get_data(struct clipboard_ctx *cl, struct clipboard_access_params *pa
return CLIPBOARD_SUCCESS;
case VO_NOTAVAIL:
case VO_NOTIMPL:
MP_VERBOSE(cl, "VO does not support getting clipboard in the requested format.\n");
MP_VERBOSE(priv, "VO does not support getting clipboard in the requested format.\n");
return CLIPBOARD_UNAVAILABLE;
default:
MP_WARN(cl, "Failed getting VO clipboard.\n");
MP_WARN(priv, "Failed getting VO clipboard.\n");
return CLIPBOARD_FAILED;
}
}
Expand All @@ -78,10 +80,10 @@ static int set_data(struct clipboard_ctx *cl, struct clipboard_access_params *pa
return CLIPBOARD_SUCCESS;
case VO_NOTAVAIL:
case VO_NOTIMPL:
MP_VERBOSE(cl, "VO does not support setting clipboard in the requested format.\n");
MP_VERBOSE(priv, "VO does not support setting clipboard in the requested format.\n");
return CLIPBOARD_UNAVAILABLE;
default:
MP_WARN(cl, "Failed setting VO clipboard.\n");
MP_WARN(priv, "Failed setting VO clipboard.\n");
return CLIPBOARD_FAILED;
}
}
Expand Down
Loading
Loading