Skip to content

Fix terminal-position base discrepancy by semantic click

Koichi Murase requested to merge akinomyoga/konsole:fix-semantic-click into master

I received a report in my project, which seems to be an issue with Konsole. In short, the issue is that "the mouse click of the semantic shell integration does not work for the top line in the terminal display". Although the problem was first reported to my project, the problem is reproducible with the plain Bash with only Konsole's integration code.

For the semantic mouse click, TerminalDisplay::mousePressEvent sends the mouse position by 0-based coordinates to Vt102Emulation::sendMouseEvent through a Q_SIGNAL. However, Vt102Emulation::sendMouseEvent assumes the 1-based coordinates as described in its code documentation and performs the bound check at the beginning. This bound check rejects the semantic mouse click performed on the first line (cy = 0) without the actual processing. This also rejects the mouse click on the first column (cx = 0). It should be noted that the other mouse events sent by TerminalDisplay::mousePressEvent honor the 1-base assumption by adding 1 to the second and third arguments.

In this patch, we change to send the 1-based coordinates with the semantic mouse click following the documentation and other use cases of Vt102Emulation::sendMouseEvent. Also, we need a backward conversion of the coordinates inside Vt102Emulation::sendMouseEvent to manipulate the 0-based internal coordinates using the received ones. A note for it is added in the code comment of the conversion. This patch was tested on release/23.08.

Edited by Koichi Murase

Merge request reports