diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 7d08eda032..3374ba3047 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -150,7 +150,6 @@ void OMW::Engine::handleSDLMessages() switch(events[i].window.event) { case SDL_WINDOWEVENT_RESIZED: - printf("Resizing window!\n"); resize = true; size_x = events[i].window.data1; size_y = events[i].window.data2; @@ -162,12 +161,7 @@ void OMW::Engine::handleSDLMessages() //handle window movements if(resize) { - if(!mOgre->getWindow()->isFullScreen()) - { - mOgre->getWindow()->windowMovedOrResized(); - mOgre->getWindow()->resize(size_x, size_y); - mOgre->adjustViewport(); - } + mOgre->getWindow()->resize(size_x, size_y); } if(SDL_PeepEvents(NULL, 1, SDL_PEEKEVENT, SDL_QUIT, SDL_QUIT) != 0) @@ -436,7 +430,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) mEnvironment.setInputManager (new MWInput::InputManager (*mOgre, MWBase::Environment::get().getWorld()->getPlayer(), - *MWBase::Environment::get().getWindowManager(), mDebug, *this, keybinderUser, keybinderUserExists)); + *MWBase::Environment::get().getWindowManager(), *this, keybinderUser, keybinderUserExists)); // load cell ESM::Position pos; diff --git a/apps/openmw/mwinput/inputmanagerimp.cpp b/apps/openmw/mwinput/inputmanagerimp.cpp index 9d80de91e4..ab873c6861 100644 --- a/apps/openmw/mwinput/inputmanagerimp.cpp +++ b/apps/openmw/mwinput/inputmanagerimp.cpp @@ -31,7 +31,6 @@ namespace MWInput InputManager::InputManager(OEngine::Render::OgreRenderer &ogre, MWWorld::Player &player, MWBase::WindowManager &windows, - bool debug, OMW::Engine& engine, const std::string& userFile, bool userFileExists) : mOgre(ogre) @@ -45,7 +44,7 @@ namespace MWInput , mUserFile(userFile) , mDragDrop(false) , mGuiCursorEnabled(false) - , mDebug(debug) + , mDebug(Settings::Manager::getBool("debug", "Engine")) , mInvertY (Settings::Manager::getBool("invert y axis", "Input")) , mCameraSensitivity (Settings::Manager::getFloat("camera sensitivity", "Input")) , mUISensitivity (Settings::Manager::getFloat("ui sensitivity", "Input")) @@ -63,7 +62,7 @@ namespace MWInput Ogre::RenderWindow* window = ogre.getWindow (); - mInputManager = new SFO::InputWrapper(window); + mInputManager = new SFO::InputWrapper(mOgre.getSDLWindow()); mInputManager->setMouseEventCallback (this); mInputManager->setKeyboardEventCallback (this); mInputManager->setWindowEventCallback(this); diff --git a/apps/openmw/mwinput/inputmanagerimp.hpp b/apps/openmw/mwinput/inputmanagerimp.hpp index 34ea92a374..9832be9a68 100644 --- a/apps/openmw/mwinput/inputmanagerimp.hpp +++ b/apps/openmw/mwinput/inputmanagerimp.hpp @@ -62,7 +62,6 @@ namespace MWInput InputManager(OEngine::Render::OgreRenderer &_ogre, MWWorld::Player&_player, MWBase::WindowManager &_windows, - bool debug, OMW::Engine& engine, const std::string& userFile, bool userFileExists); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index ae7d6612bd..5d2a5c9514 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -839,7 +839,6 @@ void RenderingManager::windowResized(Ogre::RenderWindow* rw) Settings::Manager::setInt("resolution x", "Video", rw->getWidth()); Settings::Manager::setInt("resolution y", "Video", rw->getHeight()); - mRendering.adjustViewport(); mCompositors->recreate(); mWater->assignTextures(); diff --git a/extern/sdl4ogre/sdlinputwrapper.cpp b/extern/sdl4ogre/sdlinputwrapper.cpp index cf864b20fc..464d8cb6a6 100644 --- a/extern/sdl4ogre/sdlinputwrapper.cpp +++ b/extern/sdl4ogre/sdlinputwrapper.cpp @@ -16,9 +16,9 @@ namespace SFO { /// \brief General purpose wrapper for OGRE applications around SDL's event /// queue, mostly used for handling input-related events. - InputWrapper::InputWrapper(Ogre::RenderWindow *window) : - mWindow(window), - mSDLWindow(NULL), + InputWrapper::InputWrapper(SDL_Window* window) : + mSDLWindow(window), + mOwnWindow(false), mWarpCompensate(false), mMouseRelative(false), mGrabPointer(false), @@ -29,9 +29,27 @@ namespace SFO { _setupOISKeys(); + SDL_StartTextInput(); + } + + InputWrapper::~InputWrapper() + { + if(mSDLWindow != NULL && mOwnWindow) + SDL_DestroyWindow(mSDLWindow); + mSDLWindow = NULL; + + SDL_StopTextInput(); + } + + void InputWrapper::initFromRenderWindow(Ogre::RenderWindow *win) + { + assert(mSDLWindow == NULL); + + mOwnWindow = true; + //get the HWND from ogre's renderwindow size_t windowHnd; - mWindow->getCustomAttribute("WINDOW", &windowHnd); + win->getCustomAttribute("WINDOW", &windowHnd); //wrap our own event handler around ogre's mSDLWindow = SDL_CreateWindowFrom((void*)windowHnd); @@ -42,9 +60,6 @@ namespace SFO //we alt-tab away. //SDL_SetWindowFullscreen(mSDLWindow, 0); - //translate our keypresses into text - SDL_StartTextInput(); - #if OGRE_PLATFORM == OGRE_PLATFORM_LINUX //linux-specific event-handling fixups //see http://bugzilla.libsdl.org/show_bug.cgi?id=730 @@ -78,15 +93,6 @@ namespace SFO #endif } - InputWrapper::~InputWrapper() - { - if(mSDLWindow != NULL) - SDL_DestroyWindow(mSDLWindow); - mSDLWindow = NULL; - - SDL_StopTextInput(); - } - void InputWrapper::capture() { SDL_Event evt; @@ -158,11 +164,14 @@ namespace SFO //eep, wrap the pointer manually if the input driver doesn't support //relative positioning natively - SDL_SetRelativeMouseMode(relative ? SDL_TRUE : SDL_FALSE); + int success = SDL_SetRelativeMouseMode(relative ? SDL_TRUE : SDL_FALSE); if(relative) { - mWrapPointer = true; + if(success != 0) + { + mWrapPointer = true; + } } //now remove all mouse events using the old setting from the queue @@ -200,8 +209,8 @@ namespace SFO SDL_GetWindowSize(mSDLWindow, &width, &height); - const int FUDGE_FACTOR_X = width / 4; - const int FUDGE_FACTOR_Y = height / 4; + const int FUDGE_FACTOR_X = width / 8; + const int FUDGE_FACTOR_Y = height / 8; //warp the mouse if it's about to go outside the window if(evt.x - FUDGE_FACTOR_X < 0 || evt.x + FUDGE_FACTOR_X > width diff --git a/extern/sdl4ogre/sdlinputwrapper.hpp b/extern/sdl4ogre/sdlinputwrapper.hpp index 9154ff847c..db4e6f9b00 100644 --- a/extern/sdl4ogre/sdlinputwrapper.hpp +++ b/extern/sdl4ogre/sdlinputwrapper.hpp @@ -16,9 +16,11 @@ namespace SFO class InputWrapper { public: - InputWrapper(Ogre::RenderWindow* window); + InputWrapper(SDL_Window *window=NULL); ~InputWrapper(); + void initFromRenderWindow(Ogre::RenderWindow* win); + void setMouseEventCallback(MouseListener* listen) { mMouseListener = listen; } void setKeyboardEventCallback(KeyListener* listen) { mKeyboardListener = listen; } void setWindowEventCallback(WindowListener* listen) { mWindowListener = listen; } @@ -62,8 +64,8 @@ namespace SFO Sint32 mMouseX; Sint32 mMouseY; - Ogre::RenderWindow* mWindow; SDL_Window* mSDLWindow; + bool mOwnWindow; }; } diff --git a/libs/openengine/ogre/renderer.cpp b/libs/openengine/ogre/renderer.cpp index 7696095ebc..0f29b15a09 100644 --- a/libs/openengine/ogre/renderer.cpp +++ b/libs/openengine/ogre/renderer.cpp @@ -223,7 +223,7 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings& params.insert(std::make_pair("vsync", settings.vsync ? "true" : "false")); // Create an application window with the following settings: - SDL_Window *window = SDL_CreateWindow( + mSDLWindow = SDL_CreateWindow( "OpenMW", // window title SDL_WINDOWPOS_UNDEFINED, // initial x position SDL_WINDOWPOS_UNDEFINED, // initial y position @@ -238,7 +238,7 @@ void OgreRenderer::createWindow(const std::string &title, const WindowSettings& struct SDL_SysWMinfo wmInfo; SDL_VERSION(&wmInfo.version); - if(-1 == SDL_GetWindowWMInfo(window, &wmInfo)) + if(-1 == SDL_GetWindowWMInfo(mSDLWindow, &wmInfo)) throw std::runtime_error("Couldn't get WM Info!"); Ogre::String winHandle;