Index: code/branches/gui/src/core/input/InputManager.cc
===================================================================
--- code/branches/gui/src/core/input/InputManager.cc	(revision 2815)
+++ code/branches/gui/src/core/input/InputManager.cc	(revision 2816)
@@ -109,5 +109,4 @@
         , internalState_(Uninitialised)
         , stateEmpty_(0)
-        , stateMaster_(0)
         , keyDetector_(0)
         , calibratorCallbackBuffer_(0)
@@ -219,20 +218,15 @@
 
             // Lowest priority empty InputState
-            stateEmpty_ = createInputState<SimpleInputState>("empty", InputStatePriority::Empty);
+            stateEmpty_ = createInputState<SimpleInputState>("empty", false, false, InputStatePriority::Empty);
             stateEmpty_->setHandler(&EMPTY_HANDLER);
             activeStates_[stateEmpty_->getPriority()] = stateEmpty_;
 
-            // Always active master InputState
-            stateMaster_ = new ExtendedInputState();
-            stateMaster_->setName("master");
-            stateMaster_->setNumOfJoySticks(joySticksSize_);
-
             // KeyDetector to evaluate a pressed key's name
-            SimpleInputState* detector = createInputState<SimpleInputState>("detector", InputStatePriority::Detector);
+            SimpleInputState* detector = createInputState<SimpleInputState>("detector", false, false, InputStatePriority::Detector);
             keyDetector_ = new KeyDetector();
             detector->setHandler(keyDetector_);
 
             // Joy stick calibration helper callback
-            SimpleInputState* calibrator = createInputState<SimpleInputState>("calibrator", InputStatePriority::Calibrator);
+            SimpleInputState* calibrator = createInputState<SimpleInputState>("calibrator", false, false, InputStatePriority::Calibrator);
             calibrator->setHandler(&EMPTY_HANDLER);
             calibratorCallbackBuffer_ = new InputBuffer();
@@ -425,5 +419,5 @@
 
         // state management
-        activeStatesTop_.resize(devicesNum_);
+        activeStatesTriggered_.resize(devicesNum_);
 
         // inform all states
@@ -433,7 +427,4 @@
             it->second->setNumOfJoySticks(joySticksSize_);
         }
-        // inform master state
-        if (stateMaster_)
-            this->stateMaster_->setNumOfJoySticks(joySticksSize_);
 
         // inform all JoyStick Device Number Listeners
@@ -550,7 +541,4 @@
                 // destroy the empty InputState
                 _destroyState(this->stateEmpty_);
-                // destroy the master input state. This might trigger a memory leak
-                // because the user has forgotten to destroy the KeyBinder or any Handler!
-                delete stateMaster_;
 
                 // destroy all user InputStates
@@ -847,6 +835,7 @@
             {
                 KeyEvent kEvt(keysDown_[iKey], keyboardModifiers_);
-                activeStatesTop_[Keyboard]->keyHeld(kEvt);
-                stateMaster_->keyHeld(kEvt);
+
+                for (unsigned int iState = 0; iState < activeStatesTriggered_[Keyboard].size(); ++iState)
+                    activeStatesTriggered_[Keyboard][iState]->keyHeld(kEvt);
             }
 
@@ -854,6 +843,6 @@
             for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
             {
-                activeStatesTop_[Mouse]->mouseButtonHeld(mouseButtonsDown_[iButton]);
-                stateMaster_->mouseButtonHeld(mouseButtonsDown_[iButton]);
+                for (unsigned int iState = 0; iState < activeStatesTriggered_[Mouse].size(); ++iState)
+                    activeStatesTriggered_[Mouse][iState]->mouseButtonHeld(mouseButtonsDown_[iButton]);
             }
 
@@ -862,7 +851,6 @@
                 for (unsigned int iButton   = 0; iButton   < joyStickButtonsDown_[iJoyStick].size(); iButton++)
                 {
-                    activeStatesTop_[JoyStick0 + iJoyStick]
-                        ->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]);
-                    stateMaster_->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]);
+                    for (unsigned int iState = 0; iState < activeStatesTriggered_[JoyStick0 + iJoyStick].size(); ++iState)
+                        activeStatesTriggered_[JoyStick0 + iJoyStick][iState]->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]);
                 }
 
@@ -870,7 +858,6 @@
             for (unsigned int i = 0; i < devicesNum_; ++i)
             {
-                activeStatesTop_[i]->updateInput(time.getDeltaTime(), i);
-                if (stateMaster_->isInputDeviceEnabled(i))
-                    stateMaster_->updateInput(time.getDeltaTime(), i);
+                for (unsigned int iState = 0; iState < activeStatesTriggered_[i].size(); ++iState)
+                    activeStatesTriggered_[i][iState]->updateInput(time.getDeltaTime(), i);
             }
 
@@ -878,5 +865,4 @@
             for (unsigned int i = 0; i < activeStatesTicked_.size(); ++i)
                 activeStatesTicked_[i]->updateInput(time.getDeltaTime());
-            stateMaster_->updateInput(time.getDeltaTime());
         }
 
@@ -891,8 +877,18 @@
     void InputManager::_updateActiveStates()
     {
-        for (std::map<int, InputState*>::const_iterator it = activeStates_.begin(); it != activeStates_.end(); ++it)
-            for (unsigned int i = 0; i < devicesNum_; ++i)
-                if (it->second->isInputDeviceEnabled(i))
-                    activeStatesTop_[i] = it->second;
+        for (unsigned int i = 0; i < devicesNum_; ++i)
+        {
+            bool occupied = false;
+            activeStatesTriggered_[i].clear();
+            for (std::map<int, InputState*>::const_reverse_iterator rit = activeStates_.rbegin(); rit != activeStates_.rend(); ++rit)
+            {
+                if (rit->second->isInputDeviceEnabled(i) && (!occupied || rit->second->bAlwaysGetsInput_))
+                {
+                    activeStatesTriggered_[i].push_back(rit->second);
+                    if (!rit->second->bTransparent_)
+                        occupied = true;
+                }
+            }
+        }
 
         // update tickables (every state will only appear once)
@@ -900,7 +896,8 @@
         std::set<InputState*> tempSet;
         for (unsigned int i = 0; i < devicesNum_; ++i)
-            tempSet.insert(activeStatesTop_[i]);
-
-        // copy the content of the set back to the actual vector
+            for (unsigned int iState = 0; iState < activeStatesTriggered_[i].size(); ++iState)
+                tempSet.insert(activeStatesTriggered_[i][iState]);
+
+        // copy the content of the std::set back to the actual vector
         activeStatesTicked_.clear();
         for (std::set<InputState*>::const_iterator it = tempSet.begin();it != tempSet.end(); ++it)
@@ -960,6 +957,6 @@
 
         KeyEvent kEvt(e, keyboardModifiers_);
-        activeStatesTop_[Keyboard]->keyPressed(kEvt);
-        stateMaster_->keyPressed(kEvt);
+        for (unsigned int iState = 0; iState < activeStatesTriggered_[Keyboard].size(); ++iState)
+            activeStatesTriggered_[Keyboard][iState]->keyPressed(kEvt);
 
         return true;
@@ -993,6 +990,6 @@
 
         KeyEvent kEvt(e, keyboardModifiers_);
-        activeStatesTop_[Keyboard]->keyReleased(kEvt);
-        stateMaster_->keyReleased(kEvt);
+        for (unsigned int iState = 0; iState < activeStatesTriggered_[Keyboard].size(); ++iState)
+            activeStatesTriggered_[Keyboard][iState]->keyReleased(kEvt);
 
         return true;
@@ -1016,6 +1013,6 @@
             IntVector2 rel(e.state.X.rel, e.state.Y.rel);
             IntVector2 clippingSize(e.state.width, e.state.height);
-            activeStatesTop_[Mouse]->mouseMoved(abs, rel, clippingSize);
-            stateMaster_->mouseMoved(abs, rel, clippingSize);
+            for (unsigned int iState = 0; iState < activeStatesTriggered_[Mouse].size(); ++iState)
+                activeStatesTriggered_[Mouse][iState]->mouseMoved(abs, rel, clippingSize);
         }
 
@@ -1023,6 +1020,6 @@
         if (e.state.Z.rel != 0)
         {
-            activeStatesTop_[Mouse]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
-            stateMaster_->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
+            for (unsigned int iState = 0; iState < activeStatesTriggered_[Mouse].size(); ++iState)
+                activeStatesTriggered_[Mouse][iState]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
         }
 
@@ -1047,6 +1044,6 @@
             mouseButtonsDown_.push_back((MouseButtonCode::ByEnum)id);
 
-        activeStatesTop_[Mouse]->mouseButtonPressed((MouseButtonCode::ByEnum)id);
-        stateMaster_->mouseButtonPressed((MouseButtonCode::ByEnum)id);
+        for (unsigned int iState = 0; iState < activeStatesTriggered_[Mouse].size(); ++iState)
+            activeStatesTriggered_[Mouse][iState]->mouseButtonPressed((MouseButtonCode::ByEnum)id);
 
         return true;
@@ -1073,6 +1070,6 @@
         }
 
-        activeStatesTop_[Mouse]->mouseButtonReleased((MouseButtonCode::ByEnum)id);
-        stateMaster_->mouseButtonReleased((MouseButtonCode::ByEnum)id);
+        for (unsigned int iState = 0; iState < activeStatesTriggered_[Mouse].size(); ++iState)
+            activeStatesTriggered_[Mouse][iState]->mouseButtonReleased((MouseButtonCode::ByEnum)id);
 
         return true;
@@ -1110,6 +1107,6 @@
             buttonsDown.push_back((JoyStickButtonCode::ByEnum)button);
 
-        activeStatesTop_[2 + iJoyStick]->joyStickButtonPressed(iJoyStick, (JoyStickButtonCode::ByEnum)button);
-        stateMaster_->joyStickButtonPressed(iJoyStick, (JoyStickButtonCode::ByEnum)button);
+        for (unsigned int iState = 0; iState < activeStatesTriggered_[2 + iJoyStick].size(); ++iState)
+            activeStatesTriggered_[2 + iJoyStick][iState]->joyStickButtonPressed(iJoyStick, (JoyStickButtonCode::ByEnum)button);
 
         return true;
@@ -1131,6 +1128,6 @@
         }
 
-        activeStatesTop_[2 + iJoyStick]->joyStickButtonReleased(iJoyStick, (JoyStickButtonCode::ByEnum)button);
-        stateMaster_->joyStickButtonReleased(iJoyStick, (JoyStickButtonCode::ByEnum)button);
+        for (unsigned int iState = 0; iState < activeStatesTriggered_[2 + iJoyStick].size(); ++iState)
+            activeStatesTriggered_[2 + iJoyStick][iState]->joyStickButtonReleased(iJoyStick, (JoyStickButtonCode::ByEnum)button);
 
         return true;
@@ -1159,6 +1156,6 @@
                 fValue *= joyStickCalibrations_[iJoyStick].negativeCoeff[axis];
 
-            activeStatesTop_[2 + iJoyStick]->joyStickAxisMoved(iJoyStick, axis, fValue);
-            stateMaster_->joyStickAxisMoved(iJoyStick, axis, fValue);
+            for (unsigned int iState = 0; iState < activeStatesTriggered_[2 + iJoyStick].size(); ++iState)
+                activeStatesTriggered_[2 + iJoyStick][iState]->joyStickAxisMoved(iJoyStick, axis, fValue);
         }
     }
@@ -1269,5 +1266,5 @@
         True if added, false if name or priority already existed.
     */
-    bool InputManager::_configureInputState(InputState* state, const std::string& name, int priority)
+    bool InputManager::_configureInputState(InputState* state, const std::string& name, bool bAlwaysGetsInput, bool bTransparent, int priority)
     {
         if (name == "")
@@ -1294,4 +1291,6 @@
             state->setNumOfJoySticks(numberOfJoySticks());
             state->setName(name);
+            state->bAlwaysGetsInput_ = bAlwaysGetsInput;
+            state->bTransparent_ = bTransparent;
             if (priority >= InputStatePriority::HighPriority || priority == InputStatePriority::Empty)
                 state->setPriority(priority);
Index: code/branches/gui/src/core/input/InputManager.h
===================================================================
--- code/branches/gui/src/core/input/InputManager.h	(revision 2815)
+++ code/branches/gui/src/core/input/InputManager.h	(revision 2816)
@@ -130,9 +130,8 @@
 
         template <class T>
-        T* createInputState(const std::string& name, InputStatePriority priority = InputStatePriority::Dynamic);
+        T* createInputState(const std::string& name, bool bAlwaysGetsInput = false, bool bTransparent = false, InputStatePriority priority = InputStatePriority::Dynamic);
 
         InputState* getState       (const std::string& name);
         InputState* getCurrentState();
-        ExtendedInputState* getMasterInputState() { return this->stateMaster_; }
         bool requestDestroyState   (const std::string& name);
         bool requestEnterState     (const std::string& name);
@@ -179,5 +178,5 @@
 
         void _updateActiveStates();
-        bool _configureInputState(InputState* state, const std::string& name, int priority);
+        bool _configureInputState(InputState* state, const std::string& name, bool bAlwaysGetsInput, bool bTransparent, int priority);
 
         // input events
@@ -211,5 +210,4 @@
         // some internally handled states and handlers
         SimpleInputState*                   stateEmpty_;
-        ExtendedInputState*                 stateMaster_;          //!< Always active master input state
         KeyDetector*                        keyDetector_;          //!< KeyDetector instance
         InputBuffer*                        calibratorCallbackBuffer_;
@@ -222,6 +220,6 @@
 
         std::map<int, InputState*>          activeStates_;
-        std::vector<InputState*>            activeStatesTop_;      //!< Current input states for joy stick events.
-        std::vector<InputState*>            activeStatesTicked_;   //!< Current input states for joy stick events.
+        std::vector<std::vector<InputState*> > activeStatesTriggered_;
+        std::vector<InputState*>            activeStatesTicked_;
 
         // joystick calibration
@@ -262,8 +260,8 @@
     */
     template <class T>
-    T* InputManager::createInputState(const std::string& name, InputStatePriority priority)
+    T* InputManager::createInputState(const std::string& name, bool bAlwaysGetsInput, bool bTransparent, InputStatePriority priority)
     {
         T* state = new T;
-        if (_configureInputState(state, name, priority))
+        if (_configureInputState(state, name, bAlwaysGetsInput, bTransparent, priority))
             return state;
         else
Index: code/branches/gui/src/core/input/InputState.h
===================================================================
--- code/branches/gui/src/core/input/InputState.h	(revision 2815)
+++ code/branches/gui/src/core/input/InputState.h	(revision 2816)
@@ -90,5 +90,12 @@
 
     protected:
-        InputState() : bHandlersChanged_(false), priority_(0), executorOnEnter_(0), executorOnLeave_(0) { }
+        InputState()
+            : bHandlersChanged_(false)
+            , priority_(0)
+            , bAlwaysGetsInput_(false)
+            , bTransparent_(false)
+            , executorOnEnter_(0)
+            , executorOnLeave_(0)
+        { }
         virtual ~InputState() { }
 
@@ -114,4 +121,6 @@
         int                                         priority_;
         std::vector<bool>                           bInputDeviceEnabled_;
+        bool                                        bAlwaysGetsInput_;
+        bool                                        bTransparent_;
 
         Executor*                                   executorOnEnter_;
