Browse Source

Platform: fix SDL2/GLFW viewportEvent() on Retina-aware {i,mac}OS apps.

pull/338/head
Vladimír Vondruš 7 years ago
parent
commit
f383959fb0
  1. 3
      doc/changelog.dox
  2. 16
      src/Magnum/Platform/GlfwApplication.cpp
  3. 6
      src/Magnum/Platform/Sdl2Application.cpp

3
doc/changelog.dox

@ -325,6 +325,9 @@ See also:
- Properly zero-initializing the UTF-8 buffer in
@ref Platform::GlfwApplication::textInputEvent() (see
[mosra/magnum#324](https://github.com/mosra/magnum/pull/324))
- @ref Platform::Sdl2Application::viewportEvent() and
@ref Platform::GlfwApplication::viewportEvent() is fixed to behave
correctly with @ref platforms-macos-hidpi "Retina-aware" apps on macOS/iOS
- @ref Text::AbstractFontConverter::exportFontToFile() and
@ref Text::AbstractFontConverter::exportGlyphCacheToFile() now properly
returns failure when the underlying data export function returns an empty

16
src/Magnum/Platform/GlfwApplication.cpp

@ -470,15 +470,19 @@ void GlfwApplication::setupCallbacks() {
/* Properly redraw after the window is restored from minimized state */
static_cast<GlfwApplication*>(glfwGetWindowUserPointer(window))->drawEvent();
});
#ifdef MAGNUM_TARGET_GL
glfwSetFramebufferSizeCallback(_window, [](GLFWwindow* const window, const int w, const int h) {
auto& app = *static_cast<GlfwApplication*>(glfwGetWindowUserPointer(window));
ViewportEvent e{{w, h}
#ifdef MAGNUM_TARGET_GL
, app.framebufferSize()
#endif
, app.dpiScaling()};
static_cast<GlfwApplication*>(glfwGetWindowUserPointer(window))->viewportEvent(e);
ViewportEvent e{app.windowSize(), {w, h}, app.dpiScaling()};
app.viewportEvent(e);
});
#else
glfwSetWindowSizeCallback(_window, [](GLFWwindow* const window, const int w, const int h) {
auto& app = *static_cast<GlfwApplication*>(glfwGetWindowUserPointer(window));
ViewportEvent e{{w, h}, app.dpiScaling()};
app.viewportEvent(e);
});
#endif
glfwSetKeyCallback(_window, [](GLFWwindow* const window, const int key, int, const int action, const int mods) {
auto& app = *static_cast<GlfwApplication*>(glfwGetWindowUserPointer(window));

6
src/Magnum/Platform/Sdl2Application.cpp

@ -693,7 +693,11 @@ void Sdl2Application::mainLoopIteration() {
https://github.com/kripken/emscripten/issues/1731 */
CORRADE_ASSERT_UNREACHABLE();
#else
ViewportEvent e{event, {event.window.data1, event.window.data2},
/* {event.window.data1, event.window.data2} seems to be
framebuffer size and not window size on macOS, which
is weird. Query the values directly instead to be
really sure. */
ViewportEvent e{event, windowSize(),
#ifdef MAGNUM_TARGET_GL
framebufferSize(),
#endif

Loading…
Cancel
Save