Browse Source

Merge 4cf68c29fc into af251bf5d2

pull/419/merge
Vladimír Vondruš 2 years ago committed by GitHub
parent
commit
f505c38c6c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      src/Magnum/Platform/GlfwApplication.h
  2. 20
      src/Magnum/Platform/Sdl2Application.h
  3. 5
      src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp

4
src/Magnum/Platform/GlfwApplication.h

@ -673,6 +673,10 @@ class GlfwApplication {
glfwSetCursorPos(_window, Double(position.x()), Double(position.y()));
}
/** @todo GLFW_CURSOR_CAPTURED, currently only in a branch:
https://github.com/glfw/glfw/issues/58
https://github.com/glfw/glfw/compare/captured-cursor-mode-r2 */
private:
/** @copydoc Sdl2Application::mousePressEvent() */
virtual void mousePressEvent(MouseEvent& event);

20
src/Magnum/Platform/Sdl2Application.h

@ -1060,6 +1060,26 @@ class Sdl2Application {
void warpCursor(const Vector2i& position) {
SDL_WarpMouseInWindow(_window, position.x(), position.y());
}
/**
* @brief Whether the mouse is captured
* @m_since_latest
*
* @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten".
*/
bool isMouseCaptured() {
return SDL_GetWindowFlags(_window) & SDL_WINDOW_MOUSE_CAPTURE;
}
/**
* @brief Capture mouse
* @m_since_latest
*
* @note Not available in @ref CORRADE_TARGET_EMSCRIPTEN "Emscripten".
*/
void setMouseCaptured(bool enabled) {
SDL_CaptureMouse(enabled ? SDL_TRUE : SDL_FALSE);
}
#endif
#ifdef MAGNUM_BUILD_DEPRECATED

5
src/Magnum/Platform/Test/Sdl2ApplicationTest.cpp

@ -254,7 +254,10 @@ struct Sdl2ApplicationTest: Platform::Application {
setWindowTitle("This is a UTF-8 Window Title™ and it should have no exclamation mark!!"_s.exceptSuffix(2));
}
#ifndef CORRADE_TARGET_EMSCRIPTEN
else if(event.key() == KeyEvent::Key::S) {
else if(event.key() == KeyEvent::Key::C) {
Debug{} << "toggling mouse capture to" << !isMouseCaptured();
setMouseCaptured(!isMouseCaptured());
} else if(event.key() == KeyEvent::Key::S) {
Debug{} << "setting window size, which should trigger a viewport event";
setWindowSize(Vector2i{300, 200});
} else if(event.key() == KeyEvent::Key::W) {

Loading…
Cancel
Save