[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.
This commit is contained in:
Jonathan De Wachter 2013-11-27 10:46:28 +01:00
parent 17430ef372
commit 860c232507
2 changed files with 10 additions and 14 deletions

View File

@ -95,12 +95,7 @@ void WindowImplAndroid::processEvents()
Event tempEvent = states->pendingEvents.back(); Event tempEvent = states->pendingEvents.back();
states->pendingEvents.pop_back(); states->pendingEvents.pop_back();
if (tempEvent.type == Event::Resized) if (tempEvent.type == Event::GainedFocus)
{
m_width = tempEvent.size.width;
m_height = tempEvent.size.height;
}
else if (tempEvent.type == Event::GainedFocus)
{ {
states->context->createSurface(states->window); states->context->createSurface(states->window);
states->updated = true; states->updated = true;
@ -134,7 +129,13 @@ void WindowImplAndroid::setPosition(const Vector2i& position)
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
Vector2u WindowImplAndroid::getSize() const Vector2u WindowImplAndroid::getSize() const
{ {
return Vector2u(static_cast<unsigned int>(m_width), static_cast<unsigned int>(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<unsigned int>(width), static_cast<unsigned int>(height));
} }
@ -161,12 +162,14 @@ void WindowImplAndroid::setIcon(unsigned int width, unsigned int height, const U
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void WindowImplAndroid::setVisible(bool visible) void WindowImplAndroid::setVisible(bool visible)
{ {
// Not applicable
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
void WindowImplAndroid::setMouseCursorVisible(bool visible) void WindowImplAndroid::setMouseCursorVisible(bool visible)
{ {
// Not applicable
} }

View File

@ -200,13 +200,6 @@ private:
/// ///
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
static int getUnicode(AInputEvent* event); 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 } // namespace priv