From cb0be69dcf9ca771943fbe36c8b740490a6f459c Mon Sep 17 00:00:00 2001
From: Steve Cotton <steve@s.cotton.clara.co.uk>
Date: Wed, 11 Feb 2009 23:28:18 +0000
Subject: Ignore "window manager + arrow" key combinations

Adds two configurable "ignore" keys.
Stops the character moving about if the user's window manager
uses "ignore+arrow key" to switch virtual desktops.
---
 src/game.cpp           | 9 +++++++++
 src/keyboardconfig.cpp | 4 +++-
 src/keyboardconfig.h   | 2 ++
 3 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/game.cpp b/src/game.cpp
index 03febaff..e4b6e54d 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -792,6 +792,15 @@ void Game::handleInput()
         // Get the state of the keyboard keys
         keyboard.refreshActiveKeys();
 
+        // Ignore input if either "ignore" key is pressed
+        // Stops the character moving about if the user's window manager
+        // uses "ignore+arrow key" to switch virtual desktops.
+        if (keyboard.isKeyActive(keyboard.KEY_IGNORE_INPUT_1) ||
+            keyboard.isKeyActive(keyboard.KEY_IGNORE_INPUT_2))
+        {
+            return;
+        }
+
         const Uint16 x = player_node->mX;
         const Uint16 y = player_node->mY;
         unsigned char direction = 0;
diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp
index 1976e803..8187bef7 100644
--- a/src/keyboardconfig.cpp
+++ b/src/keyboardconfig.cpp
@@ -96,7 +96,9 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = {
     {"keyChatScrollUp", SDLK_PAGEUP, _("Scroll Chat Up")},
     {"keyChatScrollDown", SDLK_PAGEDOWN, _("Scroll Chat Down")},
     {"keyOK", SDLK_RETURN, _("Select OK")},
-    {"keyQuit", SDLK_ESCAPE, _("Quit")}
+    {"keyQuit", SDLK_ESCAPE, _("Quit")},
+    {"keyIgnoreInput1", SDLK_LSUPER, _("Ignore input 1")},
+    {"keyIgnoreInput2", SDLK_RSUPER, _("Ignore input 2")}
 };
 
 void KeyboardConfig::init()
diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h
index 484c0c63..61d7887d 100644
--- a/src/keyboardconfig.h
+++ b/src/keyboardconfig.h
@@ -208,6 +208,8 @@ class KeyboardConfig
             KEY_SCROLL_CHAT_DOWN,
             KEY_OK,
             KEY_QUIT,
+            KEY_IGNORE_INPUT_1,
+            KEY_IGNORE_INPUT_2,
             KEY_TOTAL
         };
 
-- 
cgit v1.2.3-70-g09d2