canonical / mir

The Mir compositor
GNU General Public License v2.0
621 stars 99 forks source link

Can't paste when copied from Firefox address bar or Thunderbird "copy link" #2583

Closed Saviq closed 1 year ago

Saviq commented 2 years ago

Steps:

  1. select the URL in Firefox address bar
  2. press Ctrl+C or choose "Copy" in context menu
  3. try pasting in another app
$ WAYLAND_DEBUG=1 firefox 2>&1 | grep wl_data
[572093,203] wl_registry@2.global(6, "wl_data_device_manager", 3)   
[572093,217]  -> wl_registry@2.bind(6, "wl_data_device_manager", 3, new id [unknown]@6)
[572202,094]  -> wl_data_device_manager@6.get_data_device(new id wl_data_device@14, wl_seat@12)
[573324,009] wl_registry@18.global(6, "wl_data_device_manager", 3)       
[573808,473] wl_registry@22.global(6, "wl_data_device_manager", 3)
[573808,774] wl_registry@24.global(6, "wl_data_device_manager", 3)       
[573820,752] wl_registry@25.global(6, "wl_data_device_manager", 3)
[573916,169] wl_registry@27.global(6, "wl_data_device_manager", 3)
[573935,010] wl_registry@33.global(6, "wl_data_device_manager", 3)        
[574598,892] wl_registry@36.global(6, "wl_data_device_manager", 3)
[574598,906]  -> wl_registry@36.bind(6, "wl_data_device_manager", 3, new id [unknown]@42)

# copy from address bar
[585807,780]  -> wl_data_device_manager@6.create_data_source(new id wl_data_source@52)
[585807,812]  -> wl_data_source@52.offer("UTF8_STRING")
[585807,823]  -> wl_data_source@52.offer("COMPOUND_TEXT")
[585807,833]  -> wl_data_source@52.offer("TEXT")
[585807,843]  -> wl_data_source@52.offer("STRING")
[585807,853]  -> wl_data_source@52.offer("text/plain;charset=utf-8")
[585807,863]  -> wl_data_source@52.offer("text/plain")
[585807,874]  -> wl_data_device@14.set_selection(wl_data_source@52, 5463)
[585807,918]  -> wl_data_source@52.offer("SAVE_TARGETS")
[585807,932]  -> wl_data_device@14.set_selection(wl_data_source@52, 5463)
[585847,265] wl_data_device@14.data_offer(new id wl_data_offer@2843147248)
[585847,280] wl_data_offer@4278190081.offer("UTF8_STRING")
[585847,291] wl_data_offer@4278190081.offer("COMPOUND_TEXT")
[585847,334] wl_data_offer@4278190081.offer("TEXT")
[585847,346] wl_data_offer@4278190081.offer("STRING")
[585847,355] wl_data_offer@4278190081.offer("text/plain;charset=utf-8")
[585847,364] wl_data_offer@4278190081.offer("text/plain")
[585847,373] wl_data_device@14.selection(wl_data_offer@4278190081)
[585847,385]  -> wl_data_offer@4278190080.destroy()

# broken paste
[591214,517] wl_data_source@52.send("text/plain;charset=utf-8", fd 53)

# copy from website
[610971,188]  -> wl_data_source@52.destroy()
[610971,253]  -> wl_data_device_manager@6.create_data_source(new id wl_data_source@62)
[610971,272]  -> wl_data_source@62.offer("text/html")
[610971,285]  -> wl_data_source@62.offer("text/_moz_htmlcontext")
[610971,295]  -> wl_data_source@62.offer("text/_moz_htmlinfo")
[610971,369]  -> wl_data_source@62.offer("UTF8_STRING")
[610971,387]  -> wl_data_source@62.offer("COMPOUND_TEXT")
[610971,403]  -> wl_data_source@62.offer("TEXT")
[610971,419]  -> wl_data_source@62.offer("STRING")
[610971,433]  -> wl_data_source@62.offer("text/plain;charset=utf-8")
[610971,448]  -> wl_data_source@62.offer("text/plain")
[610971,464]  -> wl_data_source@62.offer("text/x-moz-url-priv")
[610971,482]  -> wl_data_device@14.set_selection(wl_data_source@62, 5561)
[610971,517]  -> wl_data_source@62.offer("SAVE_TARGETS")
[610971,542]  -> wl_data_device@14.set_selection(wl_data_source@62, 5561)
[610972,461] wl_data_device@14.selection(nil)
[610972,481]  -> wl_data_offer@4278190081.destroy()
[610972,525] wl_data_device@14.data_offer(new id wl_data_offer@2817448864)
[610972,559] wl_data_offer@4278190080.offer("text/html")
[610972,578] wl_data_offer@4278190080.offer("text/_moz_htmlcontext")
[610972,595] wl_data_offer@4278190080.offer("text/_moz_htmlinfo")
[610972,611] wl_data_offer@4278190080.offer("UTF8_STRING")
[610972,627] wl_data_offer@4278190080.offer("COMPOUND_TEXT")
[610972,652] wl_data_offer@4278190080.offer("TEXT")
[610972,666] wl_data_offer@4278190080.offer("STRING")
[610972,678] wl_data_offer@4278190080.offer("text/plain;charset=utf-8")
[610972,691] wl_data_offer@4278190080.offer("text/plain")
[610972,703] wl_data_offer@4278190080.offer("text/x-moz-url-priv")
[610972,715] wl_data_device@14.selection(wl_data_offer@4278190080)

# working paste
[618606,602] wl_data_source@62.send("text/plain;charset=utf-8", fd 62)
AlanGriffiths commented 2 years ago

Just for confirmation: this is the lack of "primary select" (select & paste), which we don't implement for security reasons?

I.e. not a problem with copy and paste?

Saviq commented 2 years ago

No, this is actual copy paste, as in Ctrl+C / Ctrl+V. Fixed the steps.

Saviq commented 2 years ago

It must be related to the copy mime type or so. I now found that if I right-click a link in Thunderbird and "copy link", I can't paste that either. If I select the link and just Ctrl+C that, it works.

AlanGriffiths commented 2 years ago

related to the copy mime type or so

That would be weird: Mir only sees that as a string to pass on

AlanGriffiths commented 2 years ago

Probably related to this: I've found that in CLion cut & paste only works up to the last \n in the source text. Also seen pasting from CLion into Firefox. (I.e. cut & paste a few words fails, cut & paste several lines drops the last line unless I carefully select the EOL.)

wmww commented 2 years ago

Are all of these issues involving at least one XWayland app? Copy/paste code paths for Wayland/XWayland are very different, so that's likely relevant.

AlanGriffiths commented 2 years ago

Are all of these issues involving at least one XWayland app

No, cutting from Firefox address bar and pasting into Gnome Console doesn't work

graysonguarino commented 1 year ago

I noticed something interesting on Miriway. When I:

  1. Open Miriway
  2. Open a recently-viewed link on Firefox (snap) via the address bar
  3. Copy it via right click->Copy

I can paste the URL into Gnome Terminal and Gedit. Once I try to repeat this in the same Miriway session, I am no longer able to copy the link. Closing the Miriway session and restarting it allows for one copy to happen.

EDIT: This behavior is repeatable using the Firefox snap. When running Firefox installed from Mozilla's apt repository, I cannot even copy a link properly once.

Saviq commented 1 year ago

I can paste the URL into Gnome Terminal and Gedit. Once I try to repeat this in the same Miriway session, I am no longer able to copy the link. Closing the Miriway session and restarting it allows for one copy to happen.

FWIW I can't even paste the once.

graysonguarino commented 1 year ago

Firefox is successfully copy/pasting again after disabling the call to multiplexer.paste_source_set(nullptr) in ms::BasicClipboard::clear_paste_source(ClipboardSource const& source).

I'm not too sure of the inner workings of all of this, but it seems like something @wmww is familiar with.

EDIT: I was accidentally running Firefox on XWayland.

wmww commented 1 year ago

@graysonguarino that had no effect for me running Firefox on Wayland. It sounded like you're running Firefox on XWayland, which is likely a different issue.

Notably, I just discovered that copy/paste from address bar in FF on Wayland is also broken under Weston. Perhaps FFs logic relies on primary selection or some other protocol Mir and Weston don't support but Sway and Mir do?

graysonguarino commented 1 year ago

Bug reported to Mozilla https://bugzilla.mozilla.org/show_bug.cgi?id=1791417

wmww commented 1 year ago

I have confirmed that adding and enabling a stubbed out implementation of the primary selection protocol fixes the problem.

wmww commented 1 year ago

I've added that info to the FF bug, you can see it working on this branch