Bug 461498 - Disabled Middle Click Pasting makes text selection in some GTK apps impossible on Wayland
Summary: Disabled Middle Click Pasting makes text selection in some GTK apps impossibl...
Status: RESOLVED FIXED
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 5.26.2
Platform: openSUSE Linux
: NOR grave
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords: wayland
Depends on:
Blocks:
 
Reported: 2022-11-06 13:43 UTC by postix
Modified: 2022-12-17 05:08 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.26.5
Sentry Crash Report:


Attachments
Screen recording (315.82 KB, video/x-matroska)
2022-11-07 17:03 UTC, postix
Details
kWin Support Info (6.94 KB, text/plain)
2022-11-07 17:04 UTC, postix
Details

Note You need to log in before you can comment on or make changes to this bug.
Description postix 2022-11-06 13:43:12 UTC
SUMMARY

At this point it's not clear to me if this is a GTK or a Plasma Wayland issue. 

The selection of text is immediately gone in Gajim 1.5.3 when disabling "Middle Click Pasting" in the Workspace KCM. This affects all input fields of this app. 

I could not reproduce this issue with any other app so far, but maybe I just have not tested enough.

STEPS TO REPRODUCE
1. Open Gajim 1.5.3
2. Disable Middle Click Pasting in the Workspace KCM
3. Click into any input field of Gajim, enter some text
4. Press CTRL+A or select the text manually with the mouse or use your keyboard via shift + arrow-keys or the context menu "select all"

OBSERVED RESULT
The text becomes selected for a split second and then the selection vanishes. 
As soon as I enable the Middle Click Pasting option, the issue is gone.

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20221104
KDE Plasma Version: 5.26.2
KDE Frameworks Version: 5.99.0
Qt Version: 5.15.7
Kernel Version: 6.0.7 (64-bit)
Graphics Platform: Wayland
Graphics Processor: AMD Radeon RX 580 Series

1.5.3+e7736e632f66

GTK Version: 3.24.34
GLib Version: 2.74.0
Pango Version: 1.50.11
PyGObject Version: 3.42.2
cairo Version: 1.17.6
pycairo Version: 1.21.0
Comment 1 postix 2022-11-06 16:09:49 UTC
I found another app, which is affected: `GTK Demo 4.8.2`.
Comment 2 postix 2022-11-06 16:21:18 UTC
...and more affected GTK apps:

* GTK Widget Factory 4.8.2
* Simple-Scan 42.5
* Virtual Machine Manager 4.1.0
* Gnome Chess 43.0
* HandBrake 1.5.1
* RawTherapee 5.8
* gst-debug-viewer 1.20.4
* Xournal++ 1.1.2
Comment 3 postix 2022-11-07 17:03:56 UTC
Created attachment 153559 [details]
Screen recording
Comment 4 postix 2022-11-07 17:04:19 UTC
Created attachment 153560 [details]
kWin Support Info
Comment 5 Ridge 2022-11-23 00:07:04 UTC
Has been happening to me in all GTK apps ever since Plasma 5.25.90 but I was never really sure why. Turned middle-click paste back on, lo and behold, now I can mark text in GTK text entry fields again.

Tested with Pinta and DeaDBeeF on Plasma 5.26.3.

This does not affect Firefox, however I'm not quite sure if Firefox is GTK or Qt, or either.
Comment 6 Méven 2022-11-25 08:51:45 UTC
(In reply to Aurora Robb Kristiansen from comment #5)
> Has been happening to me in all GTK apps ever since Plasma 5.25.90 but I was
> never really sure why. Turned middle-click paste back on, lo and behold, now
> I can mark text in GTK text entry fields again.
> 
> Tested with Pinta and DeaDBeeF on Plasma 5.26.3.
> 
> This does not affect Firefox, however I'm not quite sure if Firefox is GTK
> or Qt, or either.

It seems like a bug in GTK exposed by https://invent.kde.org/plasma/kwin/-/merge_requests/3012/diffs
Gtk seems to treat primary selection as the main selection :/
Comment 7 postix 2022-11-27 16:37:36 UTC
> Gtk seems to treat primary selection as the main selection :/
I have reported it now upstream.
Comment 8 postix 2022-11-28 10:56:58 UTC
Quoting Matthias Clasen @ https://gitlab.gnome.org/GNOME/gtk/-/issues/5372#note_1603916

> I don't have plasma installed, but when I simulate a system without primary selection by ignoring
> zwp_primary_selection_device_manager_v1, Ctrl-a keeps working just fine.

> Maybe that kde patch does something else that it should not do,
> like still implementing that interface, but insisting that the selection is always empty...
Comment 9 postix 2022-12-07 21:06:58 UTC
@Meven and Vladz, maybe you had overseen the following question from the comment above:

Does the patch [1] implements the interface, but insists that the selection is always empty?
Or does the selection->cancel() line [2] maybe cause this issue?

[1] https://invent.kde.org/plasma/kwin/-/merge_requests/3012/diffs
[2] https://invent.kde.org/plasma/kwin/-/merge_requests/3012/diffs#769a60050bb02c02c80901c0b0274fd40c633c49_1329_1339
Comment 10 postix 2022-12-07 21:12:57 UTC
I built the master version of kwin and can confirm that commenting out the line 
https://invent.kde.org/plasma/kwin/-/merge_requests/3012/diffs#769a60050bb02c02c80901c0b0274fd40c633c49_1329_1339
fixes the issue for me while also still keeping the middle click pasting disabled.
Comment 11 Bug Janitor Service 2022-12-13 11:02:10 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/kwin/-/merge_requests/3298
Comment 12 Bug Janitor Service 2022-12-13 11:15:48 UTC
A possibly relevant merge request was started @ https://invent.kde.org/qt/qt/qtwayland/-/merge_requests/62
Comment 13 Vlad Zahorodnii 2022-12-16 13:41:23 UTC
Git commit da229ebe85ce9ae29b5014ee44658b5411d5313f by Vlad Zahorodnii.
Committed on 16/12/2022 at 12:47.
Pushed by vladz into branch 'master'.

Revert "Disable PrimarySelection in seat setPrimarySelection"

This reverts commit e60f26e0abd71d65044345675b64e45d7b3cd311.

Cancelling the primary selection breaks text selection in applications
such as gedit. In those apps, you can't select text neither with your
mouse nor keyboard.

M  +1    -1    src/main_wayland.cpp
M  +1    -33   src/wayland/autotests/server/test_datacontrol_interface.cpp
M  +0    -15   src/wayland/seat_interface.cpp
M  +0    -2    src/wayland/seat_interface.h
M  +0    -1    src/wayland/seat_interface_p.h
M  +11   -2    src/wayland_server.cpp
M  +3    -0    src/wayland_server.h

https://invent.kde.org/plasma/kwin/commit/da229ebe85ce9ae29b5014ee44658b5411d5313f
Comment 14 postix 2022-12-16 14:02:27 UTC
Thanks! :)
Comment 15 Vlad Zahorodnii 2022-12-16 14:43:13 UTC
Git commit 07195af2b02a044f1ef39bf0b3c26aab58e19dca by Vlad Zahorodnii.
Committed on 16/12/2022 at 13:44.
Pushed by vladz into branch 'Plasma/5.26'.

Revert "Disable PrimarySelection in seat setPrimarySelection"

This reverts commit e60f26e0abd71d65044345675b64e45d7b3cd311.

Cancelling the primary selection breaks text selection in applications
such as gedit. In those apps, you can't select text neither with your
mouse nor keyboard.
(cherry picked from commit da229ebe85ce9ae29b5014ee44658b5411d5313f)

M  +1    -1    src/main_wayland.cpp
M  +1    -33   src/wayland/autotests/server/test_datacontrol_interface.cpp
M  +0    -15   src/wayland/seat_interface.cpp
M  +0    -2    src/wayland/seat_interface.h
M  +0    -1    src/wayland/seat_interface_p.h
M  +11   -2    src/wayland_server.cpp
M  +2    -0    src/wayland_server.h

https://invent.kde.org/plasma/kwin/commit/07195af2b02a044f1ef39bf0b3c26aab58e19dca