After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 775099 - Shell search provider doesn't work with Wayland
Shell search provider doesn't work with Wayland
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: search
unspecified
Other Linux
: Normal major
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2016-11-25 16:58 UTC by Alexandre Franke
Modified: 2017-05-11 09:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch to gnome-characters (2.28 KB, patch)
2017-05-02 15:04 UTC, Daiki Ueno
none Details | Review
remoteSearch: respect "CopyResult" in desktop file (2.08 KB, patch)
2017-05-03 09:23 UTC, Daiki Ueno
none Details | Review
search: copy result to clipboard if requested (2.08 KB, patch)
2017-05-11 02:33 UTC, Daiki Ueno
committed Details | Review

Description Alexandre Franke 2016-11-25 16:58:43 UTC
With the search provider enabled in a Wayland session, open the shell and type something that brings a character result ("thumbs" brings "thumbs up" and a few others for instance), select the character you want and press enter.

The character should be copied to clipboard and ctrl + V should paste it. This does not do it and previous content of the clipboard is still in the clipboard.
Comment 1 khatar 2017-04-11 13:52:11 UTC
hello,

i can't reproduce this bug with the same workflow on a 
date debian stretch (gnome 3.22.2).
Comment 2 Bastien Nocera 2017-04-11 14:12:04 UTC
(In reply to khatar from comment #1)
> hello,
> 
> i can't reproduce this bug with the same workflow on a 
> date debian stretch (gnome 3.22.2).

Because you're using X11 I'm guessing.

I can reproduce as well on GNOME 3.24 (gnome-characters 3.22.0).
Comment 3 Daiki Ueno 2017-04-11 14:35:55 UTC
I am on Wayland, and it happens only sporadically.  Interestingly, it doesn't work if I select a Unicode symbol (e.g. "Thumbs Up Sign") at first, while it starts working once I select an ASCII symbol (e.g. "Asterisk").
Comment 4 Juraj Fiala 2017-04-22 12:38:19 UTC
I use Characters quite often so this bug is very annoying for me. I can reproduce this everytime, I have to open the app to copy the characters I want. Also, when clicking the Characters icon in the search results nothing happens. Before it opened the Characters app with more search results (I think).
Comment 5 Daiki Ueno 2017-04-24 11:05:45 UTC
I have no idea how to fix this; the application and the search provider simply call GtkClipboard#set_text() as follows:

GtkClipboard *clipboard;
clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
clipboard.set_text(text, -1);

https://git.gnome.org/browse/gnome-characters/tree/lib/gc.c#n1132
https://git.gnome.org/browse/gnome-characters/tree/src/searchProvider.js#n117
https://git.gnome.org/browse/gnome-characters/tree/src/character.js#n183

Reassigning to gtk+ for feedback from experts.
Comment 6 Alexandre Franke 2017-04-24 11:43:09 UTC
Could it be linked to bug 759626 ?
Comment 7 Carlos Garnacho 2017-04-24 12:26:15 UTC
It's not just that. On wayland a surface from the application must be focused before the application can modify/peek the clipboard or any other selection.

In this case there's no application windows at all, thus there's no surface, thus there's no clipboard.
Comment 8 Matthias Clasen 2017-04-27 23:10:13 UTC
Maybe the copy-to-clipboard feature has to move to the shell side ?
Comment 9 Daiki Ueno 2017-05-02 15:04:08 UTC
Created attachment 350888 [details] [review]
patch to gnome-characters

So maybe like this?  It seems to work, though quite hacky.
Comment 10 Bastien Nocera 2017-05-02 15:10:06 UTC
*very* hacky. And it wouldn't work with gnome-characters sandboxed. I think that the search provider needs to tell gnome-shell, through an extension of the protocol, that it's supposed to copy "this" when the search result is activated.

Tangentially, Florian, won't this particular call be a security problem if applications can talk to the shell for their search providers?
Comment 11 Daiki Ueno 2017-05-03 09:22:06 UTC
(In reply to Bastien Nocera from comment #10)
> *very* hacky. And it wouldn't work with gnome-characters sandboxed. I think
> that the search provider needs to tell gnome-shell, through an extension of
> the protocol, that it's supposed to copy "this" when the search result is
> activated.

That sounds like a cleaner approach, but changing the protocol just for this particular issue seems overkill to me, as I don't see any other use-case of this feature.

Perhaps gnome-shell could simply copy the search result to the clipboard depending on the name or configuration of the search provider?
Comment 12 Daiki Ueno 2017-05-03 09:23:41 UTC
Created attachment 350958 [details] [review]
remoteSearch: respect "CopyResult" in desktop file

Some search providers such as GNOME Characters want to copy the search
results to a clipboard.  However, on Wayland, GtkClipboard is functional
only if the app has any visible surface.

This patch adds a new keyword "CopyResult" in seach providers' .ini
file.  If the keyword is set to true, the shell by itself copies the
result to the clipboard.
Comment 13 Florian Müllner 2017-05-09 16:53:58 UTC
(In reply to Bastien Nocera from comment #10)
> Tangentially, Florian, won't this particular call be a security problem if
> applications can talk to the shell for their search providers?

Yeah, it's an issue when apps are allowed to talk to any name owned by the shell. It's not something apps are expected to do (including for search providers, which actually work the other way round, i.e. the shell talking to the app)), in particular when sandboxed.

Still, we may want to consider turning it off by default ('development-tools' in org.gnome.shell) ...
Comment 14 Florian Müllner 2017-05-09 17:18:36 UTC
Review of attachment 350958 [details] [review]:

The commit message is poorly worded - "respect foo property" sounds like there was a well-established field that we failed to support, rather than something newly made-up. And of course a search provider keyfile is not a .desktop file ...

::: js/ui/search.js
@@ +184,2 @@
     _activateResult: function(result, id) {
         this.provider.activateResult(id, this._terms);

Does this make sense, or should we assume that if copyResult is set, then the app uses the activate-copies pattern?

@@ +185,3 @@
         this.provider.activateResult(id, this._terms);
+        if (this.provider.copyResult)
+            this._clipboard.set_text(St.ClipboardType.CLIPBOARD, id);

Of course this doesn't copy the result, but its ID. While I don't know about any other search provider that uses the activate-copies pattern, this looks needlessly restrictive.

Maybe something like:

  activateResult: function(id, terms) {
      if (this.copyResult)
          this.proxy.GetResultClipboardTextRemote(id, (text, error) => {
              this._clipboard.set_text(St.ClipboardType.CLIPBOARD, text);
          });
      else
          this.proxy.ActivateResultRemote(id, terms, global.get_current_time());
  },
Comment 15 Daiki Ueno 2017-05-11 02:33:49 UTC
Created attachment 351592 [details] [review]
search: copy result to clipboard if requested

Some search providers such as GNOME Characters want to copy search
results to clipboard.  However, on Wayland, clipboards are only
accessible from applications that have a visible surface on display.

This patch allows a search provider to request the shell to copy a
search result to clipboard when 'clipboardText' is included in the meta
of the result.
Comment 16 Daiki Ueno 2017-05-11 02:48:10 UTC
(In reply to Florian Müllner from comment #14)
> Review of attachment 350958 [details] [review] [review]:
> 
> The commit message is poorly worded - "respect foo property" sounds like
> there was a well-established field that we failed to support, rather than
> something newly made-up. And of course a search provider keyfile is not a
> .desktop file ...

Thank you for the review.

> ::: js/ui/search.js
> @@ +184,2 @@
>      _activateResult: function(result, id) {
>          this.provider.activateResult(id, this._terms);
> 
> Does this make sense, or should we assume that if copyResult is set, then
> the app uses the activate-copies pattern?

I think it still makes sense to call activateResult, even if a search provider wants to copy the result to clipboard, because it allows the search provider to track the activated result as "recently used".

> @@ +185,3 @@
>          this.provider.activateResult(id, this._terms);
> +        if (this.provider.copyResult)
> +            this._clipboard.set_text(St.ClipboardType.CLIPBOARD, id);
> 
> Of course this doesn't copy the result, but its ID. While I don't know about
> any other search provider that uses the activate-copies pattern, this looks
> needlessly restrictive.
> 
> Maybe something like:
> 
>   activateResult: function(id, terms) {
>       if (this.copyResult)
>           this.proxy.GetResultClipboardTextRemote(id, (text, error) => {
>               this._clipboard.set_text(St.ClipboardType.CLIPBOARD, text);
>           });
>       else
>           this.proxy.ActivateResultRemote(id, terms,
> global.get_current_time());
>   },

I guess it could reuse GetResultMetas, which is already called before ActivateResult, instead of adding a new method.  And in that case, we don't even need CopyResult keyword in .ini file anymore, because we can simply check a certain property ("clipboardText" in the patch in comment 15) is set in the result meta.
Comment 17 Florian Müllner 2017-05-11 08:25:12 UTC
Review of attachment 351592 [details] [review]:

This looks like a better approach indeed, thanks. Feel free to push to gnome-3-24 as well.
Comment 18 Daiki Ueno 2017-05-11 09:13:09 UTC
Attachment 351592 [details] pushed as 0142fae - search: copy result to clipboard if requested