Do the Ogre Samples always grab input in a window system?

Problems building or running the engine, queries about how to use features etc.
Post Reply
berserkerviking
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 63
Joined: Tue May 02, 2017 8:15 pm
x 16

Do the Ogre Samples always grab input in a window system?

Post by berserkerviking »

When run in a window system, do the Ogre samples always grab mouse input (i.e. force it to go to their window)?
Some games support a "windowed mode" which sends mouse input to the window only when the cursor is over it.
This always the user to interact with other windows while the game is still running. I've been looking for this kind
of mode in the ogre samples but I haven't found it.

If the answer to this question is yes, ogre samples always grab the mouse, then is there an alternate away to resize
the window? (If the window always grabs the mouse one can never get the cursor into the correct position in order
to resize the window through the normal window system mechanism.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5298
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1279
Contact:

Re: Do the Ogre Samples always grab input in a window system

Post by dark_sylinc »

Hi!

Ogre doesn't force this behavior, but the samples do.

This is simply because the camera is tied to the cursor, so allowing the cursor to escape breaks the mechanic. Games that use the mouse for other stuff (for example RTS) can afford to allow the cursor to escape the window.

As to your question:
  • When the app is alt tabbed (or loses focus in any other way, such as when using another shortcut to open Start Menu/Launcher/Spotlight, etc), the cursor grab must be relinquished. This is one way to be able to click on the maximize button.
  • Hot keys should also work. On Windows, Super Key + Up arrow maximizes. On Linux, it depends more on the Desktop environment being used. I don't know macOS equivalent, but a quick google tells me it possible to setup a shortcut but it is unset by default.
  • If a specifc platform makes something particularly harder or unnatural (such as maximizing in macOS?), it makes sense to create a particular enhancement for that platform to make it feel more (like a button that when hit, the sample relinquishes cursor grab?)
As for C++ code in particular, we rely on SDL. All you need to do is:

Code: Select all

SdlInputHandler *inputHandler = graphicsSystem->getInputHandler();
inputHandler->setGrabMousePointer( false );
inputHandler->setMouseVisible( true );
And reverse this to get the grab back.
Post Reply