Menu

#2361 Cannot paste to a Qt app under KDE on Wayland

Bug
closed-fixed
nobody
5
2023-02-08
2022-10-24
Alexander
No

I am using KDE Plasma 5.26 under Wayland. If I try to copy some text from Scintilla widget and paste it into a KDE app, then nothing is pasted. Though, pasting into XWayland or GTK apps works fine.

The bug is reproducible both with Geany 1.38 ( https://github.com/geany/geany/issues/3320 ) and SciTE 5.3.1.

Discussion

1 2 > >> (Page 1 of 2)
  • Neil Hodgson

    Neil Hodgson - 2022-10-25
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,3 +1,3 @@
     I am using KDE Plasma 5.26 under Wayland. If I try to copy some text from Scintilla widget and paste it into a KDE app, then nothing is pasted. Though, pasting into XWayland or GTK apps works fine.
    
    -The bug is reproducible both with  Geany 1.38 (https://github.com/geany/geany/issues/3320) and SciTE 5.3.1.
    +The bug is reproducible both with  Geany 1.38 ( https://github.com/geany/geany/issues/3320 ) and SciTE 5.3.1.
    
     
  • Neil Hodgson

    Neil Hodgson - 2022-10-25

    Here is a screenshot after successfully pasting from SciTE 5.3.1 on Ubuntu 22.10 with Wayland into Qt Creator, KWrite, and Calligra Words.
    KDE apps

    The about boxes from GNOME and KWrite show that it is using Wayland and other versions are KDE Frameworks 5.98.0 and Qt 5.15.6.

    This bug report is non-specific: say which operating system, distribution, and version are being used along with the KDE app and its version.

     
  • Neil Hodgson

    Neil Hodgson - 2022-10-25
    • status: open --> open-works-for-me
     
  • Alexander

    Alexander - 2022-10-25

    This bug report is non-specific: say which operating system, distribution, and version are being used along with the KDE app and its version.

    I am using the most recent Debian GNU/Linux Testing with a KDE Plasma 5.26 session under Wayland. The bug happens with many different KDE and Qt apps, moreover, the clipboard history in the KDE Plasma itself is not populated with the copied text.

    Maybe the main difference which triggers the bug is using KDE session instead of GNOME session.

    Copying from other GTK+ apps, or, considering Geany, copying from anywhere except the Scintilla widget, works.

     
  • Neil Hodgson

    Neil Hodgson - 2022-11-01

    Reproduced with copying from SciTE to Kate on Debian Wayland. On this system, it still copies from SciTE to gedit.

    Copying the path with the File | Copy Path command does copy to Kate. That is using the simpler gtk_clipboard_set_text API instead of gtk_clipboard_set_with_data which is called in Scintilla to allow multiple formats and asynchronous access. Its likely that the current KDE implementation on Wayland has a problem with this API or its use. Since it works with GTK applications on Debian + Wayland and also with KDE applications on Ubuntu + Wayland, I'd hope that it gets fixed with updates to KDE's Wayland support.

    If anyone is sufficiently motivated, it may be possible to provide an optional alternative code path in Scintilla, possibly with decreased functionality by not supporting multiple clipboard formats. However, supporting multiple clipboard formats is important to future extensibility to allow better provision of columnar and line-oriented copies as is done on Win32.

     
    👍
    1
  • Neil Hodgson

    Neil Hodgson - 2022-11-01
    • labels: paste, wayland --> paste, wayland, kde
    • status: open-works-for-me --> open-accepted
     
  • Alexander

    Alexander - 2022-11-01

    Also reported the bug to the KDE side: https://bugs.kde.org/show_bug.cgi?id=461301

     
  • Alexander

    Alexander - 2022-11-02

    The bug is definitely on the Scintilla side.

    The code sets "UTF8_STRING" and "STRING" as MIME types when copying the text:
    https://sourceforge.net/p/scintilla/code/ci/default/tree/gtk/ScintillaGTK.cxx#l123

    At the same time, Qt under Wayland doesn't understand such MIMEs and accepts only "text/plain;charset=utf8" or "text/plain":
    https://github.com/qt/qtwayland/blob/dev/src/client/qwaylanddataoffer.cpp#L18-L21
    https://github.com/qt/qtwayland/blob/dev/src/client/qwaylanddataoffer.cpp#L126-L127

    GTK apps, as well as GNOME under Wayland seem to understand these MIME types, but KDE doesn't (and AFAIK doesn't have to).

    The attached patch seems to fix the original issue. There are also issues with drag&drop and middle button copying between GTK and Qt apps, however I hope that the issue there is basically the same and can be fixed by using the right MIME types.

     
    • Neil Hodgson

      Neil Hodgson - 2022-11-06

      The bug is definitely on the Scintilla side.

      This is definitely a KDE bug as it works with GTK.

      The code sets "UTF8_STRING" and "STRING" as MIME types when copying the text

      These are target atoms, not MIME types and are defined by the Inter-Client Communication Conventions Manual https://www.x.org/releases/X11R7.7/doc/xorg-docs/icccm/icccm.pdf and subsequent documents https://www.irif.fr/~jch//software/UTF8_STRING/

      This code works with KDE applications in other circumstances so would be best fixed upstream.

      GTK apps, as well as GNOME under Wayland seem to understand these MIME types, but KDE doesn't (and AFAIK doesn't have to).

      KDE may choose to be incompatible with older software but that makes it less useful.

       
  • Alexander

    Alexander - 2022-11-06

    These are target atoms, not MIME types and are defined by the Inter-Client Communication Conventions Manual

    Are they specific to X.org or are the same target atoms also specified for Wayland?

     

    Last edit: Alexander 2022-11-06
    • Neil Hodgson

      Neil Hodgson - 2022-11-08

      freedesktop.org is the organisation that is supposed to harmonize different windowing systems and toolkits. Wayland (https://wayland.freedesktop.org/) is a freedesktop.org project. While they have documents about some aspects of clipboard handling, I haven't found one that defines mime-types and target atoms and their relationship.

      https://www.freedesktop.org/wiki/Specifications/

       
      • Alexander

        Alexander - 2022-11-08

        Anyway, ICCCM is only related to X.org, not Wayland. Relying on the X.org conventions under Wayland is not a good idea.

        By the way, GTK4 has removed the support for UTF8_STRING and STRING atoms under Wayland.

        Also, the concerns related to usage of text/plain;encoding=utf8 alongside with UTF8_STRING were risen before, see https://sourceforge.net/p/scintilla/bugs/2175/, for example.

         

        Last edit: Alexander 2022-11-08
        • Neil Hodgson

          Neil Hodgson - 2022-11-10

          Relying on the X.org conventions under Wayland is not a good idea.

          Where are the Wayland conventions documented?

           
          • Alexander

            Alexander - 2022-11-10

            I am unsure if they are currently documented anywhere, unfortunately.

             
            • Neil Hodgson

              Neil Hodgson - 2022-11-10

              Scintilla's GTK platform layer is written to the GTK API which covers multiple underlying platforms: X, Wayland, Win32, macOS, and potentially others. On Win32 and macOS, UTF8_STRING and STRING are not the literal clipboard types since they are from X and the clipboard code needs to interoperate with native applications.

              On Win32 the normal text type identifier is CF_UNICODETEXT (a CLIPFORMAT) and on macOS it is public.text (a Uniform Type Identifier). Both of these place UTF-16 on the clipboard instead of UTF-8. Thus, there is interpretation of clipboard actions occurring.

              If some MIME types have become the way to specify clipboard types on Wayland then we need to know the scope and history of this - Scintilla still works with GTK 2. What happens when text/plain;charset=utf-8 is used on macOS or Win32? Does this depend on GTK version?

               
              • Alexander

                Alexander - 2022-11-10

                If some MIME types have become the way to specify clipboard types on Wayland then we need to know the scope and history of this - Scintilla still works with GTK 2. What happens when text/plain;charset=utf-8 is used on macOS or Win32? Does this depend on GTK version?

                Do you mean GTK under Windows and macOS here, right?

                 
                • Neil Hodgson

                  Neil Hodgson - 2022-11-12

                  Do you mean GTK under Windows and macOS here, right?

                  Yes, GTK on Windows and macOS which are supported by Geany.

                   
  • Alexander

    Alexander - 2022-11-06

    By the way, pasting into GTK4 applications doesn't work either. Seems that GTK has dropped the support for compatibility atoms on the toolkit level, but I don't know how it works in the recent GNOME.

     
  • Chris Mayo

    Chris Mayo - 2022-11-26

    There is a change in GTK 3.24.35:

    wayland: Translate STRING/UTF8_STRING selection atoms to mimetypes
    https://gitlab.gnome.org/GNOME/gtk/-/commit/0c1ea9221976b838101d2593754b658808fdc542

    Got included in Debian Testing gtk+3.0 (3.24.34-4)
    https://metadata.ftp-master.debian.org/changelogs//main/g/gtk+3.0/gtk+3.0_3.24.34-5_changelog

    as:
    wayland-Translate-STRING-UTF8_STRING-selection-atoms-to-m.patch

    I've seen the same problem with SciTE 5.3.1 on GNOME 43, i.e. pasting to Wayland programs, but not XWayland after updating to gtk+-3.24.3.

    After reverting the above GTK commit pasting worked again.

     
    • Chris Mayo

      Chris Mayo - 2022-11-26

      Apologies, this ticket predates gtk+3.0 (3.24.34-4) which was released on Fri, 18 Nov 2022 11:53:03 +0000.

      I guess this is similar, but different.

       
      • Chris Mayo

        Chris Mayo - 2022-11-26

        Except that, scintilla.patch above does fix this on vanilla GTK 3.24.35.

         
        • Neil Hodgson

          Neil Hodgson - 2022-11-26

          It looks like the problem will be solved once the GTK 0c1ea9221976b838101d2593754b658808fdc542 commit reaches distributions implying that there is no need to change Scintilla.

          The issue that led to the commit shows this issue was also occurring with Eclipse.
          https://gitlab.gnome.org/GNOME/gtk/-/issues/5217

           
          • Alexander

            Alexander - 2022-11-27

            After upgrading to GTK 3.24.35 (which seems to include the commit 0c1ea9221976b838101d2593754b658808fdc542) I cannot paste the text from Geany and SciTE even to the GTK3 and XWayland apps.

            So, the bug definitely needs to be patched from the Scintilla side.

             
            • Neil Hodgson

              Neil Hodgson - 2022-12-01

              seems to include the commit

              Not definitive enough for me. As GTK upstream have worked on a fix, any problems with that fix should be reported there.

               
1 2 > >> (Page 1 of 2)

Log in to post a comment.

MongoDB Logo MongoDB