ecere/Android: Latest Android fixes
[sdk] / ecere / src / gui / Window.ec
index 7e1986e..55baee9 100644 (file)
@@ -494,7 +494,7 @@ private class HotKeySlot : struct
 public struct TouchPointerInfo
 {
    int id;
-   int x, y;
+   Point point;
    float size, pressure;
 };
 
@@ -4086,14 +4086,14 @@ private:
    public bool MultiTouchMessage(TouchPointerEvent event, Array<TouchPointerInfo> infos, Modifiers * mods, bool consequential, bool activate)
    {
       bool result = true;
-      if(infos.count)
+      if((infos && infos.count) || (event == up || event == pointerUp))
       {
          Window w = null;
          while(result && w != this)
          {
             // TODO: How to handle this?
-            int x = infos[0].x;
-            int y = infos[0].y;
+            int x = (infos && infos.count) ? infos[0].point.x : 0;
+            int y = (infos && infos.count) ? infos[0].point.y : 0;
             Window msgWindow = GetAtPosition(x,y, false, true, w);
             Window window;
             delete w;
@@ -4101,6 +4101,14 @@ private:
             if(w) incref w;
             window = (w && !w.disabled) ? w : null;
 
+            if(guiApp.windowCaptured && (guiApp.windowCaptured.rootWindow == this))
+            {
+               if(!guiApp.windowCaptured.isEnabled)
+                  guiApp.windowCaptured.ReleaseCapture();
+               else
+                  window = guiApp.windowCaptured;
+            }
+
             if(consequential) mods->isSideEffect = true;
             if(!result || (window && window.destroyed)) window = null;
 
@@ -4108,16 +4116,20 @@ private:
             {
                if(window.OnMultiTouch && !window.disabled)
                {
-                  Array<TouchPointerInfo> in { size = infos.size };
-                  memcpy(in.array, infos.array, sizeof(TouchPointerInfo) * infos.size);
-
-                  for(i : in)
+                  Array<TouchPointerInfo> in = null;
+                  if(infos && infos.count)
                   {
-                     i.x -= (window.absPosition.x + window.clientStart.x);
-                     i.y -= (window.absPosition.y + window.clientStart.y);
+                     in = { size = infos.size };
+                     memcpy(in.array, infos.array, sizeof(TouchPointerInfo) * infos.size);
 
-                     i.x = Max(Min(i.x, 32767),-32768);
-                     i.y = Max(Min(i.y, 32767),-32768);
+                     for(i : in)
+                     {
+                        i.point.x -= (window.absPosition.x + window.clientStart.x);
+                        i.point.y -= (window.absPosition.y + window.clientStart.y);
+
+                        i.point.x = Max(Min(i.point.x, 32767),-32768);
+                        i.point.y = Max(Min(i.point.y, 32767),-32768);
+                     }
                   }
 
                   incref window;
@@ -4399,13 +4411,13 @@ private:
 
             while(it.Next())
             {
-               Window w = it.data;
-               if(trueWindow != w && !trueWindow.IsDescendantOf(w))
+               Window ww = it.data;
+               if(trueWindow != ww && !trueWindow.IsDescendantOf(ww))
                {
                   it.pointer = null;
-                  result = w.OnMouseLeave(*mods);
+                  result = ww.OnMouseLeave(*mods);
                   if(!result) break;
-                  overWindows.TakeOut(w);
+                  overWindows.TakeOut(ww);
                }
             }
 
@@ -4449,10 +4461,10 @@ private:
             }
             if(trueWindow && trueWindow._refCount > 1 && !trueWindow.destroyed)
             {
-               for(w : guiApp.overWindows; w == trueWindow)
+               for(wi : guiApp.overWindows; wi == trueWindow)
                {
                   OnMouseLeave(0);
-                  guiApp.overWindows.TakeOut(w);
+                  guiApp.overWindows.TakeOut(wi);
                   break;
                }
                guiApp.prevWindow = trueWindow;
@@ -6260,7 +6272,7 @@ private:
             guiApp.interfaceDriver.SetMousePosition(guiApp.windowMovingStart.x, guiApp.windowMovingStart.y);
          else
          {
-            int x, y;
+            int x = 0, y = 0;
             guiApp.interfaceDriver.GetMousePosition(&x, &y);
             guiApp.windowMovingStart.x += x - absPosition.x;
             guiApp.windowMovingStart.y += y - absPosition.y;