From 860c23250797695f9210cd84a34e82fcaa17a6dc Mon Sep 17 00:00:00 2001 From: Jonathan De Wachter Date: Wed, 27 Nov 2013 10:46:28 +0100 Subject: [PATCH] [Android] No longer cache the window size Because onContextRectChanged happens after the surface creation thus, the window doesn't return the correct value when the surface gets created. --- src/SFML/Window/Android/WindowImplAndroid.cpp | 17 ++++++++++------- src/SFML/Window/Android/WindowImplAndroid.hpp | 7 ------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/SFML/Window/Android/WindowImplAndroid.cpp b/src/SFML/Window/Android/WindowImplAndroid.cpp index 97988d3c..79b6efe1 100644 --- a/src/SFML/Window/Android/WindowImplAndroid.cpp +++ b/src/SFML/Window/Android/WindowImplAndroid.cpp @@ -95,12 +95,7 @@ void WindowImplAndroid::processEvents() Event tempEvent = states->pendingEvents.back(); states->pendingEvents.pop_back(); - if (tempEvent.type == Event::Resized) - { - m_width = tempEvent.size.width; - m_height = tempEvent.size.height; - } - else if (tempEvent.type == Event::GainedFocus) + if (tempEvent.type == Event::GainedFocus) { states->context->createSurface(states->window); states->updated = true; @@ -134,7 +129,13 @@ void WindowImplAndroid::setPosition(const Vector2i& position) //////////////////////////////////////////////////////////// Vector2u WindowImplAndroid::getSize() const { - return Vector2u(static_cast(m_width), static_cast(m_height)); + ActivityStates* states = getActivity(NULL); + Lock lock(states->mutex); + + int32_t width = ANativeWindow_getWidth(states->window); + int32_t height = ANativeWindow_getHeight(states->window); + + return Vector2u(static_cast(width), static_cast(height)); } @@ -161,12 +162,14 @@ void WindowImplAndroid::setIcon(unsigned int width, unsigned int height, const U //////////////////////////////////////////////////////////// void WindowImplAndroid::setVisible(bool visible) { + // Not applicable } //////////////////////////////////////////////////////////// void WindowImplAndroid::setMouseCursorVisible(bool visible) { + // Not applicable } diff --git a/src/SFML/Window/Android/WindowImplAndroid.hpp b/src/SFML/Window/Android/WindowImplAndroid.hpp index 057ebc48..b7c2c32a 100644 --- a/src/SFML/Window/Android/WindowImplAndroid.hpp +++ b/src/SFML/Window/Android/WindowImplAndroid.hpp @@ -200,13 +200,6 @@ private: /// //////////////////////////////////////////////////////////// static int getUnicode(AInputEvent* event); - - //////////////////////////////////////////////////////////// - // Member data - //////////////////////////////////////////////////////////// - // Cache the width and height, as calls to ANativeWindow_getWidth/Height can be slow - int m_width; - int m_height; }; } // namespace priv