Index: /code/branches/core4/src/core/CorePrereqs.h
===================================================================
--- /code/branches/core4/src/core/CorePrereqs.h	(revision 3290)
+++ /code/branches/core4/src/core/CorePrereqs.h	(revision 3291)
@@ -153,5 +153,5 @@
     class TclThreadManager;
     class Template;
-    class Tickable;
+    class WindowEventListener;
     class XMLFile;
     class XMLNameListener;
Index: /code/branches/core4/src/core/WindowEventListener.cc
===================================================================
--- /code/branches/core4/src/core/WindowEventListener.cc	(revision 3290)
+++ /code/branches/core4/src/core/WindowEventListener.cc	(revision 3291)
@@ -32,7 +32,33 @@
 namespace orxonox
 {
+    unsigned int WindowEventListener::windowWidth_s  = 0;
+    unsigned int WindowEventListener::windowHeight_s = 0;
+
     WindowEventListener::WindowEventListener()
     {
         RegisterRootObject(WindowEventListener);
     }
+
+    //! Calls all registered objects
+    /*static*/ void WindowEventListener::moveWindow()
+    {
+        for (ObjectList<WindowEventListener>::iterator it = ObjectList<WindowEventListener>::begin(); it; ++it)
+            it->windowMoved();
+    }
+
+    //! Calls all registered objects and sets the static variables
+    /*static*/ void WindowEventListener::resizeWindow(unsigned int newWidth, unsigned int newHeight)
+    {
+        windowWidth_s = newWidth;
+        windowHeight_s = newHeight;
+        for (ObjectList<WindowEventListener>::iterator it = ObjectList<WindowEventListener>::begin(); it; ++it)
+            it->windowResized(newWidth, newHeight);
+    }
+
+    //! Calls all registered objects
+    /*static*/ void WindowEventListener::changeWindowFocus()
+    {
+        for (ObjectList<WindowEventListener>::iterator it = ObjectList<WindowEventListener>::begin(); it; ++it)
+            it->windowFocusChanged();
+    }
 }
Index: /code/branches/core4/src/core/WindowEventListener.h
===================================================================
--- /code/branches/core4/src/core/WindowEventListener.h	(revision 3290)
+++ /code/branches/core4/src/core/WindowEventListener.h	(revision 3291)
@@ -38,8 +38,16 @@
     class _CoreExport WindowEventListener : virtual public OrxonoxClass
     {
-        public:
+        friend class OgreWindowEventListener;
+
+        protected:
             WindowEventListener();
             virtual ~WindowEventListener() { }
 
+            //! Returns the current render window width
+            unsigned int getWindowWidth() const { return windowWidth_s; }
+            //! Returns the current render window height
+            unsigned int getWindowHeight() const { return windowHeight_s; }
+
+        private:
             //! Window has been moved
             virtual void windowMoved() { }
@@ -50,4 +58,12 @@
             //! Window has lost/gained focus
             virtual void windowFocusChanged() { }
+
+            static void moveWindow();
+            static void resizeWindow(unsigned int newWidth, unsigned int newHeight);
+            static void changeWindowFocus();
+
+            //! Static variable that holds the latest distributed information
+            static unsigned int windowWidth_s;
+            static unsigned int windowHeight_s;
     };
 }
Index: /code/branches/core4/src/core/input/InputManager.cc
===================================================================
--- /code/branches/core4/src/core/input/InputManager.cc	(revision 3290)
+++ /code/branches/core4/src/core/input/InputManager.cc	(revision 3291)
@@ -82,5 +82,5 @@
     // ##########                                        ##########
     // ############################################################
-    InputManager::InputManager(size_t windowHnd, unsigned int windowWidth, unsigned int windowHeight)
+    InputManager::InputManager(size_t windowHnd)
         : internalState_(Bad)
         , oisInputManager_(0)
@@ -100,5 +100,5 @@
         this->setConfigValues();
 
-        this->loadDevices(windowHnd, windowWidth, windowHeight);
+        this->loadDevices(windowHnd);
 
         // Lowest priority empty InputState
@@ -157,5 +157,5 @@
         The height of the render window
     */
-    void InputManager::loadDevices(size_t windowHnd, unsigned int windowWidth, unsigned int windowHeight)
+    void InputManager::loadDevices(size_t windowHnd)
     {
         CCOUT(3) << "Loading input devices..." << std::endl;
@@ -216,5 +216,5 @@
 
         // TODO: Remove the two parameters
-        this->loadMouse(windowWidth, windowHeight);
+        this->loadMouse();
         this->loadJoySticks();
 
@@ -226,5 +226,5 @@
 
     //! Creates a new orxonox::Mouse
-    void InputManager::loadMouse(unsigned int windowWidth, unsigned int windowHeight)
+    void InputManager::loadMouse()
     {
         if (oisInputManager_->getNumberOfDevices(OIS::OISMouse) > 0)
@@ -232,5 +232,5 @@
             try
             {
-                devices_[InputDeviceEnumerator::Mouse] = new Mouse(InputDeviceEnumerator::Mouse, oisInputManager_, windowWidth, windowHeight);
+                devices_[InputDeviceEnumerator::Mouse] = new Mouse(InputDeviceEnumerator::Mouse, oisInputManager_);
             }
             catch (const OIS::Exception& ex)
@@ -368,15 +368,6 @@
         CCOUT(3) << "Reloading ..." << std::endl;
 
-        // Save mouse clipping size
-        int clippingWidth = 800;
-        int clippingHeight = 600;
-        if (devices_[InputDeviceEnumerator::Mouse])
-        {
-            int clippingWidth  = static_cast<Mouse*>(devices_[InputDeviceEnumerator::Mouse])->getClippingWidth();
-            int clippingHeight = static_cast<Mouse*>(devices_[InputDeviceEnumerator::Mouse])->getClippingHeight();
-        }
-
         this->destroyDevices();
-        this->loadDevices(windowHnd_, clippingWidth, clippingHeight);
+        this->loadDevices(windowHnd_);
 
         internalState_ &= ~Bad;
@@ -563,4 +554,10 @@
     }
 
+    //! Gets called by WindowEventListener upon focus change --> clear buffers 
+    void InputManager::windowFocusChanged()
+    {
+        this->clearBuffers();
+    }
+
     // ############################################################
     // #####                    Iput States                   #####
Index: /code/branches/core4/src/core/input/InputManager.h
===================================================================
--- /code/branches/core4/src/core/input/InputManager.h	(revision 3290)
+++ /code/branches/core4/src/core/input/InputManager.h	(revision 3291)
@@ -37,5 +37,5 @@
 #include <vector>
 
-#include "core/OrxonoxClass.h"
+#include "core/WindowEventListener.h"
 #include "InputState.h"
 
@@ -62,5 +62,5 @@
           If the OIS::InputManager or the Keyboard fail, an exception is thrown.
     */
-    class _CoreExport InputManager : public OrxonoxClass
+    class _CoreExport InputManager : public WindowEventListener
     {
     public:
@@ -82,5 +82,5 @@
             the constructor fails with an std::exception.
         */
-        InputManager(size_t windowHnd, unsigned int windowWidth, unsigned int windowHeight);
+        InputManager(size_t windowHnd);
         //! Destroys all devices AND all input states!
         ~InputManager();
@@ -176,6 +176,6 @@
 
         // Intenal methods
-        void loadDevices(size_t windowHnd, unsigned int windowWidth, unsigned int windowHeight);
-        void loadMouse(unsigned int windowWidth, unsigned int windowHeight);
+        void loadDevices(size_t windowHnd);
+        void loadMouse();
         void loadJoySticks();
         void destroyDevices();
@@ -186,4 +186,7 @@
         void destroyStateInternal(InputState* state);
         void updateActiveStates();
+
+        // From WindowEventListener
+        void windowFocusChanged();
 
     private: // variables
Index: /code/branches/core4/src/core/input/JoyStickQuantityListener.h
===================================================================
--- /code/branches/core4/src/core/input/JoyStickQuantityListener.h	(revision 3290)
+++ /code/branches/core4/src/core/input/JoyStickQuantityListener.h	(revision 3291)
@@ -44,5 +44,5 @@
     {
         friend InputManager;
-    public:
+    protected:
         JoyStickQuantityListener();
         virtual ~JoyStickQuantityListener() { }
Index: /code/branches/core4/src/core/input/Mouse.cc
===================================================================
--- /code/branches/core4/src/core/input/Mouse.cc	(revision 3290)
+++ /code/branches/core4/src/core/input/Mouse.cc	(revision 3291)
@@ -30,36 +30,35 @@
 
 #include <ois/OISMouse.h>
+#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
 #include "InputState.h"
-#include "core/ConsoleCommand.h"
 
-// HACK (include this as last, X11 seems to define some macros...)
 #ifdef ORXONOX_PLATFORM_LINUX
-#  include <ois/linux/LinuxMouse.h>
+// include this as last, X11 seems to define some macros...
+#include <ois/linux/LinuxMouse.h>
 #endif
 
 namespace orxonox
 {
-    Mouse::Mouse(unsigned int id, OIS::InputManager* oisInputManager, unsigned int windowWidth, unsigned int windowHeight)
+    Mouse::Mouse(unsigned int id, OIS::InputManager* oisInputManager)
         : super(id, oisInputManager)
     {
-        this->setMouseClipping(windowWidth, windowHeight);
-        // HACK:
-        instancePointer_s = this;
-    }
+        RegisterRootObject(Mouse);
+        this->windowResized(this->getWindowHeight(), this->getWindowHeight());
 
-    void Mouse::setMouseClipping(unsigned int width, unsigned int height)
-    {
-        oisDevice_->getMouseState().width  = width;
-        oisDevice_->getMouseState().height = height;
-    }
-
-    unsigned int Mouse::getClippingWidth() const
-    {
-        return oisDevice_->getMouseState().width;
-    }
-
-    unsigned int Mouse::getClippingHeight() const
-    {
-        return oisDevice_->getMouseState().height;
+#ifdef ORXONOX_PLATFORM_LINUX
+        {
+            // Mouse grab console command
+            FunctorMember<Mouse>* functor = createFunctor(&Mouse::grab);
+            functor->setObject(this);
+            this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "grab"), false);
+        }
+        {
+            // Mouse ungrab console command
+            FunctorMember<Mouse>* functor = createFunctor(&Mouse::ungrab);
+            functor->setObject(this);
+            this->getIdentifier()->addConsoleCommand(createConsoleCommand(functor, "ungrab"), false);
+        }
+#endif
     }
 
@@ -87,16 +86,9 @@
     }
 
-    // ############################################################
-    // #####                   ugly hacks                     #####
-    // ##########                                        ##########
-    // ############################################################
-
-    // HACK:
-    SetConsoleCommand(Mouse, setMouseClipping_s, false);
-#ifdef ORXONOX_PLATFORM_LINUX
-    SetConsoleCommand(Mouse, grabMouse, true);
-    SetConsoleCommand(Mouse, ungrabMouse, true);
-#endif
-    Mouse* Mouse::instancePointer_s = NULL;
+    void Mouse::windowResized(unsigned int newWidth, unsigned int newHeight)
+    {
+        oisDevice_->getMouseState().width  = newWidth;
+        oisDevice_->getMouseState().height = newHeight;
+    }
 
 #ifdef ORXONOX_PLATFORM_LINUX
Index: /code/branches/core4/src/core/input/Mouse.h
===================================================================
--- /code/branches/core4/src/core/input/Mouse.h	(revision 3290)
+++ /code/branches/core4/src/core/input/Mouse.h	(revision 3291)
@@ -31,5 +31,7 @@
 
 #include "InputPrereqs.h"
+
 #include "InputDevice.h"
+#include "core/WindowEventListener.h"
 
 namespace orxonox
@@ -53,4 +55,5 @@
         : public InputDeviceTemplated<MouseTraits>
         , public OIS::MouseListener
+        , public WindowEventListener
     {
         friend class InputDeviceTemplated<MouseTraits>;
@@ -60,28 +63,11 @@
     public:
         //! Only sets the clipping size. Initialising is done in the base class.
-        Mouse(unsigned int id, OIS::InputManager* oisInputManager, unsigned int windowWidth, unsigned int windowHeight);
+        Mouse(unsigned int id, OIS::InputManager* oisInputManager);
         ~Mouse() { }
 
-        /**
-        @brief
-            Adjusts the mouse window metrics.
-
-            This method has to be called every time the size of the window changes.
-        */
-        void setMouseClipping(unsigned int width, unsigned int height);
-        // Returns the width of the mouse window
-        unsigned int getClippingWidth() const;
-        // Returns the height of the mouse window
-        unsigned int getClippingHeight() const;
-
-        // HACK!
-        static void setMouseClipping_s(unsigned int width, unsigned int height)
-            { instancePointer_s->setMouseClipping(width, height); }
-        void setConfigValues() { }
 #ifdef ORXONOX_PLATFORM_LINUX
-        // HACK!
         // TODO: Make this a feature rather than a hack
-        static void grabMouse();
-        static void ungrabMouse();
+        void grabMouse();
+        void ungrabMouse();
 #endif
 
@@ -103,9 +89,8 @@
         bool mouseMoved(const OIS::MouseEvent &arg);
 
+        void windowResized(unsigned int newWidth, unsigned int newHeight);
+
         // Returns the class name as string
         static std::string getClassNameImpl() { return "Mouse"; }
-
-        // HACK:
-        static Mouse* instancePointer_s;
     };
 }
Index: /code/branches/core4/src/orxonox/GraphicsManager.cc
===================================================================
--- /code/branches/core4/src/orxonox/GraphicsManager.cc	(revision 3290)
+++ /code/branches/core4/src/orxonox/GraphicsManager.cc	(revision 3291)
@@ -75,8 +75,12 @@
     class _OrxonoxExport OgreWindowEventListener : public Ogre::WindowEventListener
     {
-        void windowResized     (Ogre::RenderWindow* rw);
-        void windowFocusChange (Ogre::RenderWindow* rw);
-        void windowClosed      (Ogre::RenderWindow* rw);
-        //void windowMoved       (Ogre::RenderWindow* rw);
+        void windowResized     (Ogre::RenderWindow* rw)
+            { orxonox::WindowEventListener::resizeWindow(rw->getWidth(), rw->getHeight()); }
+        void windowFocusChange (Ogre::RenderWindow* rw)
+            { orxonox::WindowEventListener::changeWindowFocus(); }
+        void windowClosed      (Ogre::RenderWindow* rw)
+            { orxonox::Game::getInstance().stop(); }
+        void windowMoved       (Ogre::RenderWindow* rw)
+            { orxonox::WindowEventListener::moveWindow(); }
     };
 
@@ -418,23 +422,3 @@
         this->renderWindow_->writeContentsToTimestampedFile(Core::getLogPathString() + "screenShot_", ".jpg");
     }
-
-
-    /****** OgreWindowEventListener ******/
-
-    void OgreWindowEventListener::windowResized(Ogre::RenderWindow* rw)
-    {
-        for (ObjectList<orxonox::WindowEventListener>::iterator it
-            = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
-            it->windowResized(rw->getWidth(), rw->getHeight());
-    }
-    void OgreWindowEventListener::windowFocusChange(Ogre::RenderWindow* rw)
-    {
-        for (ObjectList<orxonox::WindowEventListener>::iterator it
-            = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
-            it->windowFocusChanged();
-    }
-    void OgreWindowEventListener::windowClosed(Ogre::RenderWindow* rw)
-    {
-        Game::getInstance().stop();
-    }
 }
Index: /code/branches/core4/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- /code/branches/core4/src/orxonox/OrxonoxPrereqs.h	(revision 3290)
+++ /code/branches/core4/src/orxonox/OrxonoxPrereqs.h	(revision 3291)
@@ -92,4 +92,5 @@
     class Level;
     class Scene;
+    class Tickable;
 
     class AddQuest;
Index: /code/branches/core4/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- /code/branches/core4/src/orxonox/gamestates/GSGraphics.cc	(revision 3290)
+++ /code/branches/core4/src/orxonox/gamestates/GSGraphics.cc	(revision 3291)
@@ -39,10 +39,8 @@
 
 #include "util/Convert.h"
-#include "core/ConfigValueIncludes.h"
 #include "core/Clock.h"
 #include "core/CommandExecutor.h"
 #include "core/ConsoleCommand.h"
 #include "core/Core.h"
-#include "core/CoreIncludes.h"
 #include "core/Game.h"
 #include "core/GameMode.h"
@@ -72,18 +70,7 @@
         , debugOverlay_(0)
     {
-        RegisterRootObject(GSGraphics);
     }
 
     GSGraphics::~GSGraphics()
-    {
-    }
-
-    /**
-    @brief
-        this function does nothing
-
-        Indeed. Here goes nothing.
-    */
-    void GSGraphics::setConfigValues()
     {
     }
@@ -108,6 +95,4 @@
         GameMode::setShowsGraphics(true);
 
-        setConfigValues();
-
         // Load OGRE including the render window
         this->graphicsManager_ = new GraphicsManager();
@@ -124,5 +109,5 @@
 
         // Calls the InputManager which sets up the input devices.
-        inputManager_ = new InputManager(windowHnd, renderWindow->getWidth(), renderWindow->getHeight());
+        inputManager_ = new InputManager(windowHnd);
 
         // load master key bindings
@@ -137,5 +122,5 @@
         // Load the InGameConsole
         console_ = new InGameConsole();
-        console_->initialise(renderWindow->getWidth(), renderWindow->getHeight());
+        console_->initialise();
 
         // load the CEGUI interface
@@ -233,33 +218,3 @@
         this->graphicsManager_->update(time);
     }
-
-    /**
-    @brief
-        Window has resized.
-    @param rw
-        The render window it occured in
-    @note
-        GraphicsManager has a render window stored itself. This is the same
-        as rw. But we have to be careful when using multiple render windows!
-    */
-    void GSGraphics::windowResized(unsigned int newWidth, unsigned int newHeight)
-    {
-        // OIS needs this under linux even if we only use relative input measurement.
-        // HACK:
-        CommandExecutor::execute("setWindowExtents_s " + multi_cast<std::string>(newWidth) + " " + multi_cast<std::string>(newHeight));
-    }
-
-    /**
-    @brief
-        Window focus has changed.
-    @param rw
-        The render window it occured in
-    */
-    void GSGraphics::windowFocusChanged()
-    {
-        // instruct InputManager to clear the buffers (core library so we cannot use the interface)
-        if (this->inputManager_)
-            this->inputManager_->clearBuffers();
-    }
-
 }
Index: /code/branches/core4/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- /code/branches/core4/src/orxonox/gamestates/GSGraphics.h	(revision 3290)
+++ /code/branches/core4/src/orxonox/gamestates/GSGraphics.h	(revision 3291)
@@ -37,7 +37,5 @@
 
 #include "OrxonoxPrereqs.h"
-
 #include "core/GameState.h"
-#include "core/WindowEventListener.h"
 
 namespace orxonox
@@ -49,10 +47,9 @@
         This game state is only left out if we start a dedicated server where no graphics are present.
     */
-    class _OrxonoxExport GSGraphics : public GameState, public WindowEventListener
+    class _OrxonoxExport GSGraphics : public GameState
     {
     public:
         GSGraphics(const GameStateConstrParams& params);
         ~GSGraphics();
-        void setConfigValues();
 
         void activate();
@@ -63,8 +60,4 @@
 
     private:
-        // Window events from WindowEventListener
-        void windowResized(unsigned int newWidth, unsigned int newHeight);
-        void windowFocusChanged();
-
         // managed singletons
         InputManager*         inputManager_;        //!< Reference to input management
Index: /code/branches/core4/src/orxonox/overlays/OrxonoxOverlay.cc
===================================================================
--- /code/branches/core4/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 3290)
+++ /code/branches/core4/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 3291)
@@ -47,5 +47,4 @@
 #include "core/XMLPort.h"
 #include "core/ConsoleCommand.h"
-#include "GraphicsManager.h"
 
 namespace orxonox
@@ -81,6 +80,5 @@
 
         // Get aspect ratio from the render window. Later on, we get informed automatically
-        Ogre::RenderWindow* defaultWindow = GraphicsManager::getInstance().getRenderWindow();
-        this->windowAspectRatio_ = (float)defaultWindow->getWidth() / defaultWindow->getHeight();
+        this->windowAspectRatio_ = (float)this->getWindowWidth() / this->getWindowHeight();
         this->sizeCorrectionChanged();
 
Index: /code/branches/core4/src/orxonox/overlays/console/InGameConsole.cc
===================================================================
--- /code/branches/core4/src/orxonox/overlays/console/InGameConsole.cc	(revision 3290)
+++ /code/branches/core4/src/orxonox/overlays/console/InGameConsole.cc	(revision 3291)
@@ -172,5 +172,5 @@
         @brief Initializes the InGameConsole.
     */
-    void InGameConsole::initialise(int windowWidth, int windowHeight)
+    void InGameConsole::initialise()
     {
         // create the corresponding input state
@@ -248,5 +248,5 @@
         this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
 
-        this->windowResized(windowWidth, windowHeight);
+        this->windowResized(this->getWindowWidth(), this->getWindowWidth());
 
         // move overlay "above" the top edge of the screen
Index: /code/branches/core4/src/orxonox/overlays/console/InGameConsole.h
===================================================================
--- /code/branches/core4/src/orxonox/overlays/console/InGameConsole.h	(revision 3290)
+++ /code/branches/core4/src/orxonox/overlays/console/InGameConsole.h	(revision 3291)
@@ -46,5 +46,5 @@
         ~InGameConsole();
 
-        void initialise(int windowWidth, int windowHeight);
+        void initialise();
         void destroy();
         void setConfigValues();
