Author Topic: : Clipboard bugs and focus warnings under native Wayland (LCL Qt5, Ubuntu 26.04)  (Read 364 times)

mix-7

  • Newbie
  • Posts: 1
Hello!

I am experiencing a critical issue with clipboard synchronization and focus handling in an LCL-based application running on Ubuntu 26.04 / Wayland. The problem specifically affects the text editor CudaText, while another LCL application, Double Commander (built with a different component set), manages the system clipboard without these issues in the same environment.

Environment details:

• Application: CudaText 1.237.0.2

• Widgetset: linux-x86_64-qt5

• Compiler: FPC 3.2.3

• OS: Ubuntu 26.04 LTS (GNOME session with native Wayland)

Symptom 1: Clipboard synchronization failure
When running natively under Wayland, pasting from the system clipboard (Ctrl+V) frequently breaks. Instead of inserting the newly copied text (e.g., text from a browser or Gnome's "Clipboard Indicator" extension), the application completely ignores the external system clipboard and persistently pastes stale text from its own internal application clipboard.
To make it fetch the system clipboard data again, the application often has to be fully restarted.

Symptom 2: Console warnings during operation

When running the application from the terminal, any attempt to focus the window or interact with popups floods the console log with the following recurring Qt messages:
QSocketNotifier: Can only be used with threads started with QThread
qt.qpa.wayland: Wayland does not support QWindow::requestActivate()
This plugin supports grabbing the mouse only for popup windows

Current Workaround:
Forcing X11 backend compatibility via XWayland by launching the app with the environment flag bypasses all clipboard and focus synchronization issues entirely:
QT_QPA_PLATFORM=xcb cudatext
It appears that the LCL Qt5 backend struggles to safely communicate with Wayland's strict asynchronous clipboard policy and window activation rules. Are there any known fixes or configurations in recent FPC/Lazarus Trunk to address this clipboard isolation bug for native Qt5 LCL apps?

Thank you!

Thaddy

  • Hero Member
  • *****
  • Posts: 19966
  • Pointless static linking author
The LCL should not fight Wayland at all: simply use QT6 which behaves.
XWayland is a stop gap, waiting to be removed.

And - frankly - do some research first.... X is OUT! passed its sell-by date.


Furthermore: I can't replicate any clipboard issues: Ubuntu 24 tls / x86_64.
I think that by tinkering without research you dug your own grave.
« Last Edit: October 01, 2026, 12:20:45 pm by Thaddy »
Any "programmer" that knows only one programming language is not a programmer

PascalDragon

  • Hero Member
  • *****
  • Posts: 6451
  • Compiler Developer
XWayland is a stop gap, waiting to be removed.

XWayland is here to stay which is what the Xorg developers are concentrating on for X11 applications on top of Wayland. So as long as users want/need to use X11 applications XWayland will be there.

dbannon

  • Hero Member
  • *****
  • Posts: 3894
    • tomboy-ng, a rewrite of the classic Tomboy
Forcing X11 backend compatibility via XWayland by launching the app with the environment flag bypasses all clipboard and focus synchronization

Try including this unit early in your lpr file. It will do the environment passing for you. I used to set that env var in the Desktop file but users complained that when they started the app from the command line (without the env var set) it behaved differently.

https://github.com/tomboy-notes/tomboy-ng/blob/master/source/qtWorkAround.pas

Davo
Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Fred vS

  • Hero Member
  • *****
  • Posts: 3966
    • StrumPract is the musicians best friend
The LCL should not fight Wayland at all: simply use QT6 which behaves.
XWayland is a stop gap, waiting to be removed.

And - frankly - do some research first.... X is OUT! passed its sell-by date.


Furthermore: I can't replicate any clipboard issues: Ubuntu 24 tls / x86_64.
I think that by tinkering without research you dug your own grave.

They say Wayland is the future, but ever since Freedesktop started trying to force it on everyone, the number of Linux users has plummeted, and the number of users switching back to Windows has skyrocketed.
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

Thaddy

  • Hero Member
  • *****
  • Posts: 19966
  • Pointless static linking author
They say Wayland is the future, but ever since Freedesktop started trying to force it on everyone, the number of Linux users has plummeted, and the number of users switching back to Windows has skyrocketed.
Where is that evidence? It does not exist.
Any "programmer" that knows only one programming language is not a programmer

Fred vS

  • Hero Member
  • *****
  • Posts: 3966
    • StrumPract is the musicians best friend
They say Wayland is the future, but ever since Freedesktop started trying to force it on everyone, the number of Linux users has plummeted, and the number of users switching back to Windows has skyrocketed.
Where is that evidence? It does not exist.

I didn't say that Linux's decline in popularity is due to Wayland, but rather that the promised boom—where Linux would replace Windows—never happened. And that is sad.
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

dbannon

  • Hero Member
  • *****
  • Posts: 3894
    • tomboy-ng, a rewrite of the classic Tomboy
Yes, I can confirm the problems reported by mix-7

I have tested on three platforms, all using Wayland (he turns, spits on the ground) and current.

RasPiOS Trixie - I see Qt5 work OK with or without xcb, Qt6 cannot cp from an LCL window after having been copied into.

Ubuntu 26.04 Gnome - both Qt5 and Qt6 fail to copy in either direction under Wayland. With xcb, they work OK.

Debian Trixie KDE - both Qt5 and Qt6 work OK.

. - Qt6 version - - libqt6pas6 - - Qt5 version - - libqt5pas1 -
RasPiOS 6.8.2  2.2 5.15.15 4.0 
U2604  6.10.2 2.3 5.15.18 4.4 
Trixie 6.8.2  2.2 5.15.15 4.0~rc3 

Its easy to dismiss this all as a Wayland issue but much as we'd like it to, wayland will not go away. And not the worst performer in above table, U26.04, has newer Qt libraries. The libqt?pas are from the relevant distro repos, the version numbers are, as I have noted before, absolute nonsense, do not comply with zeljko wishes.

Thaddy, please look up the phrase "shoot the messager".

Davo
Lazarus 4, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018