in --watch mode, expose the MIME type that wl-paste resolved for the paste to the spawned command via the CLIPBOARD_TYPE env var
$ ./build/src/wl-paste --watch sh -c 'echo "state=$CLIPBOARD_STATE type=$CLIPBOARD_TYPE bytes=$(wc -c)"'
state=data type=text/plain;charset=utf-8 bytes=226
state=data type=image/png bytes=671
closes#296
The ext-data-control protocol is identical to the wlr-data-control
protocol, except that it is governed by the wayland-protocols now.
This change was tested in Plasma Wayland with and without the
ext_data_control_manager_v1 global.
Closes#242
Signed-off-by: Vlad Zahorodnii <vlad.zahorodnii@kde.org>
This currently sets the x-kde-passwordManagerHint, which is also set by
"some password managers", notably KWallet, and respected by Klipper.
Should a proper way to indicate a data source as sensitive appear, this
same option should be setting that, too.
See https://github.com/bugaevc/wl-clipboard/pull/214
Closes https://github.com/bugaevc/wl-clipboard/issues/177
Co-authored-by: Puck Meerburg <puck@puckipedia.com>
If we try to paste when there is an offer that has no MIME types offered,
we'd fail when trying to report it to the user. Make sure to handle this
case explicitly, and report it the same way as there no being any offer
at all.
We ignore SIGHUP and SIGPIPE in wl-copy itself, yet we want our child
processes, notably cat, to still get terminated if it receives SIGPIPE.
Signal handlers set to SIG_IGN unfortunately get inherited over exec, so
reset them before execing.
Fixes https://github.com/bugaevc/wl-clipboard/issues/190
Good things about this:
1. It should now be possible to build wl-clipboard without any system
dependencies (other than Meson and the compiler toolchain), with
everything coming from subprojects. Yet, this does not hurt the
normal case of using system-provided dependencies for everything.
2. New enough Wayland (1.22.0, as opposed to 1.20.0 in the Meson WrapDB
at the time of writing) now ships with a call to
override_find_program('wayland-scanner'), so finding wayland-scanner
works transparently.
Less than ideal things about this:
1. This requires us to specify default options (to disable Wayland
tests, docs, and importantly DTD validation, which depends on
libxml2) in our buildscript, not in the wrap file.
2. Wayland still doesn't ship expat and libffi as its own subprojects,
so we have to ship the wraps in wl-clipboard alongside with Wayland
itself.
3. If libwayland-client is found but wayland-scanner is not, the
subproject gets built to get wayland-scanner, but our default options
specified at dependency('wayland-client') call time are not respected
and this throws an error about missing libxml2. This would be fixed
if Meson allowed specifying default options in the wrap file.
Closes https://github.com/bugaevc/wl-clipboard/issues/182
The most probable reason for this is wl-clipboard being built without
xdg-shell support, which is something we're trying to discourage, and
something that typically happens with self-built wl-clipboard binaries,
as opposed to distro-provided ones.
Instead of just adding a note (which would only be helpful if you're
actively aware of the decision to build wl-clipboard without xdg-shell),
print a specialized message explicitly pointing at missing xdg-shell at
build time as the root issue, and ask the user to rebuild wl-clipboard.
It is possible that the compositor gives our popup surface focus before
we ever commit a buffer. In that case, we run the rest of our logic
immediately, and popup_surface_init() knows not to proceed with creating
a buffer. However, that has regressed in commit
d66fb03313, where we started setting
popup_surface to NULL, but still checking for wl_surface being NULL to
detect that case. Fix this by also resetting self->wl_surface to NULL.
Fixes https://github.com/bugaevc/wl-clipboard/issues/174
When the compositor supports it, wl-clipboard will use gtk-shell, the
semi-private protocol used by GTK, Mutter, and phoc, to ask the
compositor to raise the popup surface.
https://github.com/bugaevc/wl-clipboard/issues/169
When the Wayland connection fails, let's print some useful info that may
help the user diagnose why it is failing. For instance, in case of
https://github.com/bugaevc/wl-clipboard/issues/114, this would print:
Failed to connect to a Wayland server: No such file or directory
Note: WAYLAND_DISPLAY is unset (using wayland-0)
Note: XDG_RUNTIME_DIR is set to /tmp/
Please check whether /tmp//wayland-0 socket exists and is accessible.
While this approach obviously doesn't scale and we should probably
switch to a better one, adding these two lines is easy and it scratches
the particular itch.
Closes https://github.com/bugaevc/wl-clipboard/issues/73
We only need the temp file to be present on the file system to run
xdg-mime on it. Once we have done that, we can unlink it and simply use
an fd to refer to it, seeking to the beginning each time.
This makes us more robust against wl-copy crashing (or getting killed),
in which case the file would be kept on the file system; this should no
longer be the case with this patch.
Related to https://github.com/bugaevc/wl-clipboard/pull/155
It could happen that new offer comes in while we're in the middle of
trying to receive the previous one. This leads to issues and hangs,
since the logic is not prepared to handle reentrancy at all.
Commit 89cd9f9e43 has prevented this from
happening by immediately rejecting all but the very first offer, unless
the --watch mode is used. This makes sense, because unless the --watch
mode is used, we are indeed only interested in pasting once.
But this issue still manifested itself in the --watch mode. Fix that one
too, by not using wl_display_roundtrip() and thus not dispatching any
events in the middle of processing an offer.
Related to https://github.com/bugaevc/wl-clipboard/pull/133
Fixes https://github.com/bugaevc/wl-clipboard/issues/137
This is a more correct thing to do, considering that there could
potentially be other child processes that wl-copy itself does not know
about, due to the current process spawning them before exec'ing the
wl-copy executable. In particular, it makes some sense to spawn a
process that produces clipboard contents (piped to stdin of wl-copy) as
a child of the process that becomes wl-copy.
Fixes#156
In `selection_callback`, if wl-paste uses a popup window,
`wl_display_roundtrip` is called. This can cause `selection_callback` to
be called again with a NULL offer since wl-paste has lost the keyboard
focus. Before this change this would cause wl-paste to abort the ongoing
paste by calling `exit(1)`.
Instead ignore all but the first selection_callback call except in watch
mode.
During the wl_display_roundtrip() call, the popup surface could gain
focus a second time, which would cause do_set_selection() to be invoked
again. It would destroy the popup surface, which would cause the outer
do_set_selection() call to crash.
Fix this in two ways:
* Unset the callback before we perform roundtrip, to prevent any
reentrancy.
* Check whether we (still) have a popup_surface instead of whether we
need it; this way even if we end up without a popup surface for some
other mysterious reason, we still won't segfault here.
Fixes https://github.com/bugaevc/wl-clipboard/issues/117
2021-07-20 21:06:21 +03:00
47 changed files with 1318 additions and 406 deletions