From ca4f6f4e37c4733549072ff38874ab237d71ca8f Mon Sep 17 00:00:00 2001
From: Michele Calgaro <michele.calgaro@yahoo.it>
Date: Tue, 17 Nov 2026 00:11:02 +0900
Subject: Replace use of TQKeyEvent::stateAfter().

`TQKeyEvent::stateAfter()` is unreliable, so replace its usage with the current keyboard status. The call is used to swap the mouse cursor based on the selected tool (zoom or move), so querying the X server for the real keyboard state at the time the event is processed is not a problem.
This also keeps the cursor state consistent if left CTRL is pressed followed by right CTRL. The original code in master would display and select the wrong tool in such scenario.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
---
 src/gvcore/imageview.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/gvcore/imageview.cpp b/src/gvcore/imageview.cpp
index dbb827b..42117da 100644
--- a/src/gvcore/imageview.cpp
+++ b/src/gvcore/imageview.cpp
@@ -1041,7 +1041,8 @@ bool ImageView::eventFilter(TQObject* obj, TQEvent* event) {
 
 
 bool ImageView::viewportKeyEvent(TQKeyEvent* event) {
-	selectTool(event->stateAfter(), false);
+	Q_UNUSED(event);
+	selectTool(tdeApp->keyboardMouseState(), false);
 	return false;
 }
 
-- 
cgit v1.2.3

