Browse Source

fixed Android focus gain handling

dmuratshin 9 years ago
parent
commit
a37b5a859a

+ 1 - 1
oxygine/src/core/ZipFileSystem.cpp

@@ -195,7 +195,7 @@ namespace oxygine
         {
         {
             std::sort(_files.begin(), _files.end(), sortFiles);
             std::sort(_files.begin(), _files.end(), sortFiles);
 #ifdef OX_DEBUG
 #ifdef OX_DEBUG
-            for (size_t i = 0; i < _files.size() - 1; ++i)
+            for (int i = 0; i < (int)_files.size() - 1; ++i)
             {
             {
                 OX_ASSERT(strcmp(_files[i].name, _files[i + 1].name) != 0);
                 OX_ASSERT(strcmp(_files[i].name, _files[i + 1].name) != 0);
             }
             }

+ 17 - 3
oxygine/src/core/oxygine.cpp

@@ -70,11 +70,11 @@ extern "C"
 
 
 
 
 #if EMSCRIPTEN
 #if EMSCRIPTEN
-#define HANDLE_FOCUS_LOST 0
+#   define HANDLE_FOCUS_LOST 0
 #elif !SDL_VIDEO_OPENGL
 #elif !SDL_VIDEO_OPENGL
-#define HANDLE_FOCUS_LOST 1
+#   define HANDLE_FOCUS_LOST 1
 #else
 #else
-#define HANDLE_FOCUS_LOST 0
+#   define HANDLE_FOCUS_LOST 0
 #endif
 #endif
 
 
 #define LOST_RESET_CONTEXT 0
 #define LOST_RESET_CONTEXT 0
@@ -534,7 +534,10 @@ namespace oxygine
             if (!wnd)
             if (!wnd)
             {
             {
                 if (!focus)
                 if (!focus)
+                {
+                    log::messageln("!focus");
                     return false;
                     return false;
+                }
 
 
                 wnd = _window;
                 wnd = _window;
             }
             }
@@ -549,6 +552,10 @@ namespace oxygine
                 IVideoDriver::_stats.start = getTimeMS();
                 IVideoDriver::_stats.start = getTimeMS();
                 updatePortProcessItems();
                 updatePortProcessItems();
             }
             }
+            else
+            {
+                log::messageln("!ready");
+            }
 
 
             return ready;
             return ready;
         }
         }
@@ -617,6 +624,8 @@ namespace oxygine
                         active = true;
                         active = true;
                         */
                         */
 
 
+                        log::messageln("SDL_WINDOWEVENT %d", (int)event.window.event);
+
                         if (event.window.event == SDL_WINDOWEVENT_MINIMIZED)
                         if (event.window.event == SDL_WINDOWEVENT_MINIMIZED)
                             active = false;
                             active = false;
                         if (event.window.event == SDL_WINDOWEVENT_RESTORED)
                         if (event.window.event == SDL_WINDOWEVENT_RESTORED)
@@ -627,6 +636,11 @@ namespace oxygine
                             newFocus = false;
                             newFocus = false;
                         if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
                         if (event.window.event == SDL_WINDOWEVENT_FOCUS_GAINED)
                             newFocus = true;
                             newFocus = true;
+#ifdef __ANDROID__
+                        if (event.window.event == SDL_WINDOWEVENT_ENTER)
+                            newFocus = true;
+#endif
+
                         if (focus != newFocus)
                         if (focus != newFocus)
                         {
                         {
 #if HANDLE_FOCUS_LOST
 #if HANDLE_FOCUS_LOST

+ 2 - 2
oxygine/src/dev_tools/TexturesInspector.cpp

@@ -48,10 +48,10 @@ namespace oxygine
             path::normalize(t->getName().c_str(), path);
             path::normalize(t->getName().c_str(), path);
 
 
             char txt[255];
             char txt[255];
-            safe_sprintf(txt, "%s\n<div c=\"FF0000\">%s</div>-<div c=\"0000ff\">%dx%d</div>\nid: %d",
+            safe_sprintf(txt, "%s\n<div c=\"FF0000\">%s</div>-<div c=\"0000ff\">%dx%d</div>\nid: %d tid: %d",
                          path,
                          path,
                          textureFormat2String(t->getFormat()),
                          textureFormat2String(t->getFormat()),
-                         t->getWidth(), t->getHeight(), t->getObjectID());
+                         t->getWidth(), t->getHeight(), t->getObjectID(), (int)(size_t)t->getHandle());
 
 
             spTextField text = initActor(new TextField,
             spTextField text = initActor(new TextField,
                                          arg_color = Color::Black,
                                          arg_color = Color::Black,