mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 12:51:05 +08:00
[Android] onCreate nows waits for sf::Window to be created
This commit is contained in:
parent
fb81ddfdcb
commit
cf52687203
@ -94,12 +94,6 @@ void* main(ActivityStates* states)
|
|||||||
// Initialize the thread before giving the hand
|
// Initialize the thread before giving the hand
|
||||||
initializeMain(states);
|
initializeMain(states);
|
||||||
|
|
||||||
{
|
|
||||||
Lock lock(states->mutex);
|
|
||||||
|
|
||||||
states->initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
sleep(seconds(0.5));
|
sleep(seconds(0.5));
|
||||||
::main(0, NULL);
|
::main(0, NULL);
|
||||||
|
|
||||||
@ -383,14 +377,6 @@ static void onLowMemory(ANativeActivity* activity)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
|
||||||
int dummyProcessEvent(int fd, int events, void* data)
|
|
||||||
{
|
|
||||||
// Do nothing
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_t savedStateSize)
|
void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_t savedStateSize)
|
||||||
{
|
{
|
||||||
@ -410,12 +396,8 @@ void ANativeActivity_onCreate(ANativeActivity* activity, void* savedState, size_
|
|||||||
|
|
||||||
states->display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
states->display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||||
|
|
||||||
// As the input queue will be created before the SFML window, we need to use
|
if (savedState != NULL)
|
||||||
// this dummy function that will be replaced later by the first created
|
{
|
||||||
// SFML window
|
|
||||||
states->processEvent = dummyProcessEvent;
|
|
||||||
|
|
||||||
if (savedState != NULL) {
|
|
||||||
states->savedState = malloc(savedStateSize);
|
states->savedState = malloc(savedStateSize);
|
||||||
states->savedStateSize = savedStateSize;
|
states->savedStateSize = savedStateSize;
|
||||||
memcpy(states->savedState, savedState, savedStateSize);
|
memcpy(states->savedState, savedState, savedStateSize);
|
||||||
|
@ -46,22 +46,22 @@ namespace priv
|
|||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WindowImplAndroid::WindowImplAndroid(WindowHandle handle)
|
WindowImplAndroid::WindowImplAndroid(WindowHandle handle)
|
||||||
|
: m_size(0, 0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
WindowImplAndroid::WindowImplAndroid(VideoMode mode, const String& title, unsigned long style, const ContextSettings& settings)
|
WindowImplAndroid::WindowImplAndroid(VideoMode mode, const String& title, unsigned long style, const ContextSettings& settings)
|
||||||
|
: m_size(mode.width, mode.height)
|
||||||
{
|
{
|
||||||
ActivityStates* states = getActivity(NULL);
|
ActivityStates* states = getActivity(NULL);
|
||||||
Lock lock(states->mutex);
|
Lock lock(states->mutex);
|
||||||
|
|
||||||
// Replace our dummy process event function with the actual one
|
// Register process event callback
|
||||||
AInputQueue_detachLooper(states->inputQueue);
|
|
||||||
AInputQueue_attachLooper(states->inputQueue, states->looper, 1, processEvent, NULL);
|
|
||||||
|
|
||||||
// Register the actual process event function so it can be set automatically later by the OS
|
|
||||||
states->processEvent = processEvent;
|
states->processEvent = processEvent;
|
||||||
|
|
||||||
|
states->initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -98,6 +98,10 @@ void WindowImplAndroid::processEvents()
|
|||||||
if (tempEvent.type == Event::GainedFocus)
|
if (tempEvent.type == Event::GainedFocus)
|
||||||
{
|
{
|
||||||
states->context->createSurface(states->window);
|
states->context->createSurface(states->window);
|
||||||
|
|
||||||
|
m_size.x = ANativeWindow_getWidth(states->window);
|
||||||
|
m_size.y = ANativeWindow_getHeight(states->window);
|
||||||
|
|
||||||
states->updated = true;
|
states->updated = true;
|
||||||
}
|
}
|
||||||
else if (tempEvent.type == Event::LostFocus)
|
else if (tempEvent.type == Event::LostFocus)
|
||||||
@ -129,13 +133,7 @@ void WindowImplAndroid::setPosition(const Vector2i& position)
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
Vector2u WindowImplAndroid::getSize() const
|
Vector2u WindowImplAndroid::getSize() const
|
||||||
{
|
{
|
||||||
ActivityStates* states = getActivity(NULL);
|
return m_size;
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -200,6 +200,8 @@ private:
|
|||||||
///
|
///
|
||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
static int getUnicode(AInputEvent* event);
|
static int getUnicode(AInputEvent* event);
|
||||||
|
|
||||||
|
Vector2u m_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace priv
|
} // namespace priv
|
||||||
|
Loading…
Reference in New Issue
Block a user