From a6f08fed6493995b0299058c41d4bf000ba28961 Mon Sep 17 00:00:00 2001
From: Michele Calgaro <michele.calgaro@yahoo.it>
Date: Wed, 18 Nov 2026 10:59:54 +0900
Subject: Replace use of TQKeyEvent::stateAfter().

`TQKeyEvent::stateAfter()` is unreliable, so changed the Ctrl logic to work on press rather than release.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
---
 blinken/src/blinken.cpp | 23 ++++++++++-------------
 blinken/src/blinken.h   |  1 -
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/blinken/src/blinken.cpp b/blinken/src/blinken.cpp
index 97e8c835..009b8f6d 100644
--- a/blinken/src/blinken.cpp
+++ b/blinken/src/blinken.cpp
@@ -220,6 +220,16 @@ void blinken::keyPressEvent(TQKeyEvent *e)
 {
 	if (e -> isAutoRepeat()) return;
 	
+	if (e -> key() == TQt::Key_Control && !(e -> state() & TQt::ControlButton) &&
+	    (m_game.phase() == blinkenGame::starting || m_game.phase() == blinkenGame::choosingLevel))
+	{
+		m_showPreferences = !m_showPreferences;
+		for (int i = 0; i < 4; i++) m_buttons[i] -> setSelected(false);
+		updateButtonHighlighting(mapFromGlobal(TQCursor::pos()));
+		update();
+		return;
+	}
+
 	if (m_showPreferences)
 	{
 		int i = 0;
@@ -263,19 +273,6 @@ void blinken::keyPressEvent(TQKeyEvent *e)
 	}
 }
 
-void blinken::keyReleaseEvent(TQKeyEvent *e)
-{
-	if (e -> isAutoRepeat()) return;
-	
-	if (e -> state() == TQt::ControlButton && e -> stateAfter() != TQt::ControlButton && (m_game.phase() == blinkenGame::starting || m_game.phase() == blinkenGame::choosingLevel))
-	{
-		m_showPreferences = !m_showPreferences;
-		for (int i = 0; i < 4; i++) m_buttons[i] -> setSelected(false);
-		updateButtonHighlighting(mapFromGlobal(TQCursor::pos()));
-		update();
-	}
-}
-
 void blinken::mouseMoveEvent(TQMouseEvent *e)
 {
 	updateButtonHighlighting(e->pos());
diff --git a/blinken/src/blinken.h b/blinken/src/blinken.h
index 029288af..77bc21ae 100644
--- a/blinken/src/blinken.h
+++ b/blinken/src/blinken.h
@@ -35,7 +35,6 @@ TQ_OBJECT
 		void mouseMoveEvent(TQMouseEvent *e);
 		void mousePressEvent(TQMouseEvent *e);
 		void keyPressEvent(TQKeyEvent *e);
-		void keyReleaseEvent(TQKeyEvent *e);
 		
 	private slots:
 		void checkHS();
-- 
cgit v1.2.3

