Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions source/ODApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ void ODApplication::startClient()
OD_LOG_INF("Creating window...");

const unsigned int MIN_WIDTH = 800;
const unsigned int MIN_HEIGHT = 600;
// MenuMain.layout stacks its seven buttons around the vertical centre, from
// {0.5,-240} down to {0.5,320}, inside a root window inset by 10px top and bottom.
// The last one ("Quit") therefore only fits when 0.5*(h-20)+320 <= h-20, i.e. from
// 660px up. Anything shorter silently clips the bottom of the menu.
const unsigned int MIN_HEIGHT = 660;

// Get width/height values from config
unsigned int w = MIN_WIDTH;
Expand Down Expand Up @@ -301,7 +305,24 @@ void ODApplication::startClient()
sfmlWindow.display();
}
#else /* OD_USE_SFML_WINDOW */
ogreRoot.startRendering();
// NOTE: Ogre::Root::startRendering() does not pump window events (Ogre::Bites does
// that for applications built on its context, which we are not). Without a message
// pump, ConfigureNotify never arrives, so windowResized() would only ever run once
// at startup and CEGUI's display size and OIS' clipping rectangle would go stale as
// soon as the window is resized. Drive the loop ourselves and pump every frame.
while (true)
{
Ogre::WindowEventUtilities::messagePump();

// Closing the window destroys the mode manager from within the pump above, so
// bail out here rather than rendering a frame that would still use it.
if (frameListener.isExitRequested())
break;

// renderOneFrame() returns false once an exit has been requested.
if (!ogreRoot.renderOneFrame())
break;
}
#endif /* OD_USE_SFML_WINDOW */

OD_LOG_INF("Disconnecting client...");
Expand Down
5 changes: 4 additions & 1 deletion source/modes/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@ InputManager::InputManager(Ogre::RenderWindow* renderWindow):
paramList.insert(std::make_pair(std::string("w32_keyboard"), std::string(keyboardGrab ? "DISCL_EXCLUSIVE" : "DISCL_NONEXCLUSIVE")));
#elif defined OIS_LINUX_PLATFORM
paramList.insert(std::make_pair(std::string("x11_mouse_grab"), std::string(mouseGrab ? "true" : "false")));
paramList.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false")));
// When grabbing, OIS tracks the pointer by accumulating relative motion and warps
// the real pointer back to the window centre near the edges. Leaving the system
// cursor visible then shows it drifting away from the one CEGUI draws, so hide it.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It took me a while to understand what it is trying to say.
Anyway shoudn't the system cursor be always hidden ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Ubuntu 24.04 there was a serious mouse sync issue.

paramList.insert(std::make_pair(std::string("x11_mouse_hide"), std::string(mouseGrab ? "true" : "false")));
paramList.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string(keyboardGrab ? "true" : "false")));
paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
#endif
Expand Down
4 changes: 4 additions & 0 deletions source/render/ODFrameListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ void ODFrameListener::windowResized(Ogre::RenderWindow* rw)

void ODFrameListener::windowClosed(Ogre::RenderWindow*)
{
// Stop the render loop: we are about to destroy the mode manager, which
// frameStarted() dereferences unconditionally.
requestExit();

// We remove the mode manager to make sure it is destroyed before the window is. That
// allows to release all taken resources in the mode
mModeManager = nullptr;
Expand Down
6 changes: 6 additions & 0 deletions source/render/ODFrameListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ friend class ODClient;

void requestExit();

//! \brief Whether shutting down has been asked for, either by the game itself or by
//! the window being closed. Once set, no further frame may be rendered: closing the
//! window destroys the mode manager that frameStarted() relies on.
inline bool isExitRequested() const
{ return mExitRequested; }

inline float getEventMaxTimeDisplay() const
{ return mEventMaxTimeDisplay; }

Expand Down
7 changes: 6 additions & 1 deletion source/utils/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1882,7 +1882,12 @@ bool ConfigManager::initVideoConfig(Ogre::Root& ogreRoot)
}
if (!valueIsPossible)
{
optionsToRemove.push_back(setting.first);
// The video mode also sizes the window when running windowed, where it
// need not be one of the render system's fullscreen modes. Dropping it
// would silently fall back to the minimum window size, so keep the
// user's value and simply don't push it to the render system.
if (setting.first != Config::VIDEO_MODE)
optionsToRemove.push_back(setting.first);
continue;
}

Expand Down