Bug 512130

Summary: right click in terminal -> context menu -> copy text : menu pops again and scroll edit window to the end
Product: [Applications] kate Reporter: Martinus <mhamant>
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: waqar.17a
Priority: NOR    
Version First Reported In: 25.08.3   
Target Milestone: ---   
Platform: Solus   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Demonstration context menu / copy issue

Description Martinus 2025-11-15 14:03:12 UTC
Created attachment 186808 [details]
Demonstration context menu / copy issue

SUMMARY

right click in terminal -> copy text : context menu pops again and scroll edit window to the end
This only happens when the context menu doesn't fit in the remaining space below the selected text.

STEPS TO REPRODUCE
1.  In Kate terminal, copy a portion of text in a way the context menu cannot fit below that text. Two things happen then:
1.1.  You'll see that the main edit window is scrolling by itself to end of the file
1.2. The context menu unexpectedly reappears a second time. If you click "copy" in that second context menu, the clipboard will contain the last line of the edit window.

OBSERVED RESULT

Please see the screencast which is very explanatory

EXPECTED RESULT

the context menu is displayed once in a way if fits on the screen.

SOFTWARE/OS VERSIONS
Operating System: Solus 4.7
KDE Plasma Version: 6.5.2
KDE Frameworks Version: 6.19.0
Qt Version: 6.9.3
Kernel Version: 6.16.12-323.current (64-bit)
Graphics Platform: Wayland
Processors: 12 × AMD Ryzen 5 5600X 6-Core Processor
Memory: 16 GiB of RAM (15.5 GiB usable)
Graphics Processor: AMD Radeon RX 6700
Comment 1 Waqar Ahmed 2025-12-17 17:34:24 UTC
Can confirm. very annoying.
Comment 2 Bug Janitor Service 2025-12-18 07:49:52 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/konsole/-/merge_requests/1156
Comment 3 Christoph Cullmann 2025-12-20 17:37:49 UTC
Git commit 48ba7ea4c137b2fa1e7031ba0c8641a7a906c771 by Christoph Cullmann, on behalf of Waqar Ahmed.
Committed on 20/12/2025 at 17:33.
Pushed by cullmann into branch 'master'.

Fix context menu event handling

Konsole was using mousePressEvent with button == Qt::RightButton for
emulating a context menu event, which is wrong because there is a
dedicated event for context menu.

Due to this there were weird issues on wayland for e.g., you open the
context menu and then click somewhere else -> you get another context menu
if the target widget supports one. This happened because after
mousePressEvent, there is a mouseReleaseEvent, which konsole doesn't
handle always which then gets synthesized into a context menu event
and delivered to the widget where the click happened.

This is also a bug in Qt wayland I think and should be fixed there but
there is no reason for Konsole not to handle this properly.

To fix, move the logic for context menu event to contextMenuEvent.

M  +5    -8    src/terminalDisplay/TerminalDisplay.cpp

https://invent.kde.org/utilities/konsole/-/commit/48ba7ea4c137b2fa1e7031ba0c8641a7a906c771