xwayland: add clipboard support for images, RTF, and HTML#160
Open
Iweisc wants to merge 3 commits intomicrosoft:workingfrom
Open
xwayland: add clipboard support for images, RTF, and HTML#160Iweisc wants to merge 3 commits intomicrosoft:workingfrom
Iweisc wants to merge 3 commits intomicrosoft:workingfrom
Conversation
The XWayland selection bridge only forwarded text (UTF8_STRING/TEXT), silently dropping all other formats. This meant X11 apps could not paste images, rich text, or HTML copied from Windows via the RDP clipboard backend, even though native Wayland apps could. Add a format mapping table that bridges additional X11 atoms to their Wayland MIME types: image/bmp, image/png, text/rtf, and text/html. Rewrite the target advertisement, selection request handling, and data source send paths to use this table instead of hardcoded checks. Additionally, implement BMP-to-PNG conversion using Cairo so that image/png is advertised to X11 apps when the source only provides image/bmp, since most Linux applications expect PNG for clipboard images. Fixes: microsoft/wslg#236
Author
|
@microsoft-github-policy-service agree |
The BMP-to-PNG conversion branch in weston_wm_handle_selection_request was unreachable because the generic format table lookup always matched image_png first. This caused X11 apps to receive empty data when requesting image/png from a Wayland source that only offered image/bmp. Move the conversion check before the format table lookup, guarded by source_offers_mime_type to verify the source actually has image/bmp but not image/png. Also fix an integer overflow in the BMP row size calculation by using size_t.
6ffeb40 to
22eeac6
Compare
…version Premultiply RGB by alpha for Cairo ARGB32 format in the 32-bit BMP path. Use INCR incremental transfer for converted PNGs exceeding 64KB instead of writing the entire buffer in a single xcb_change_property call which could exceed X11 max request size.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The xwayland selection bridge hardcodes UTF8_STRING and TEXT as the only supported clipboard targets, so X11 apps can't paste images, RTF, or HTML that come through the RDP backend — even though Wayland apps can.
This patch replaces the hardcoded target handling with a format mapping table (similar to the one in rdpclip.c) that maps X11 atoms to Wayland MIME types. Supported formats: image/bmp, image/png, text/rtf, text/html, plus the existing text types.
Since Windows clipboard provides images as BMP (CF_DIB) but most Linux apps expect image/png, this also adds a BMP-to-PNG conversion path using Cairo. When the source only offers image/bmp, the bridge advertises image/png and converts on the fly.
Tested on WSLg with xclip — TARGETS correctly lists the new formats after copying from Windows.
Fixes microsoft/wslg#236