Switching between OS and CEGUI cursor (windowed mode)

I’m using the following snippet in my mouseMoved-Event to handle the switching between the windows os mouse cursor and the cegui mouse cursor when entering/leaving the RenderWindow. if (mMouseInWindow) { CEGUI::System::getSingleton().injectMousePosition( arg.state.X.abs, arg.state.Y.abs ); if (arg.state.X.abs == 0 || arg.state.Y.abs == 0 || arg.state.X.abs == mWindowMaxWidth || arg.state.Y.abs == mWindowMaxHeight) { CEGUI::MouseCursor::getSingleton().hide(); ShowCursor(true); // windows [...]