wip II
[sdk] / ecere / src / gui / Window.ec
index 1570be7..d05144e 100644 (file)
@@ -942,6 +942,7 @@ private:
    void ComputeAnchors(Anchor anchor, SizeAnchor sizeAnchor, int *ox, int *oy, int *ow, int *oh)
    {
       Window parent = this.parent ? this.parent : guiApp.desktop;
+      int xOffset = 0, yOffset = 0;
       int vpw = parent ? parent.clientSize.w : 0;
       int vph = parent ? parent.clientSize.h : 0;
       int pw = parent ? parent.clientSize.w : 0;
@@ -1036,12 +1037,46 @@ private:
       }
 
       // This is required to get proper initial decoration size using native decorations on Windows
+#if defined(__WIN32__)
       if(nativeDecorations && windowHandle && guiApp && guiApp.interfaceDriver && !visible)
          guiApp.interfaceDriver.PositionRootWindow(this, x, y, Max(1, size.w), Max(1, size.h), true, true);
+#endif
       GetDecorationsSize(&ew, &eh);
 
       if(anchor.left.type >= cascade && (state == normal /*|| state == Hidden*/))
       {
+         // Leave room for non client windows (eventually dockable panels)
+         Window win;
+         int loX = 0, loY = 0, hiX = pw, hiY = ph;
+         for(win = parent.children.first; win; win = win.next)
+         {
+            if(!win.isActiveClient && win.visible)
+            {
+               Size size = win.size;
+               Point pos = win.position;
+               int left = pos.x, top = pos.y;
+               int right = pos.x + size.w, bottom = pos.y + size.h;
+               if(win.size.w > win.size.h)
+               {
+                  if(bottom < ph / 4)
+                     loY = Max(loY, bottom);
+                  else if(top > ph - ph / 4)
+                     hiY = Min(hiY, top);
+               }
+               else
+               {
+                  if(right < pw / 4)
+                     loX = Max(loX, right);
+                  else if(left > pw - pw / 4)
+                     hiX = Min(hiX, left);
+               }
+            }
+         }
+         xOffset = loX;
+         yOffset = loY;
+         pw = hiX - loX;
+         ph = hiY - loY;
+
          if(parent.sbv && !parent.sbv.style.hidden) 
             pw += guiApp.currentSkin.VerticalSBW();
          if(parent.sbh && !parent.sbh.style.hidden)
@@ -1081,17 +1116,17 @@ private:
 
             if(positionID >= tilingSplit)
             {
-               x = pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
-               y = ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
-               x2 = pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
-               y2 = ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
+               x = xOffset + pw * (tilingSplit / tilingH + (positionID - tilingSplit) / tilingLastH)/tilingW;
+               y = yOffset + ph * ((positionID - tilingSplit) % tilingLastH) / tilingLastH;
+               x2 = xOffset + pw * (tilingSplit/tilingH + (positionID - tilingSplit) / tilingLastH + 1)/tilingW;
+               y2 = yOffset + ph * (((positionID - tilingSplit) % tilingLastH) + 1) / tilingLastH;
             }
             else
             {
-               x = pw * (positionID / tilingH) / tilingW;
-               y = ph * (positionID % tilingH) / tilingH;
-               x2 = pw * (positionID / tilingH + 1) / tilingW;
-               y2 = ph * ((positionID % tilingH) + 1) / tilingH;
+               x = xOffset + pw * (positionID / tilingH) / tilingW;
+               y = yOffset + ph * (positionID % tilingH) / tilingH;
+               x2 = xOffset + pw * (positionID / tilingH + 1) / tilingW;
+               y2 = yOffset + ph * ((positionID % tilingH) + 1) / tilingH;
             }
             if(guiApp.textMode)
             {
@@ -1240,8 +1275,8 @@ private:
             cascadeH = (float)(ph - h) / (numCascade-1);
          }
 
-         x = (int)((positionID % numCascade) * cascadeW);
-         y = (int)((positionID % numCascade) * cascadeH);
+         x = (int)((positionID % numCascade) * cascadeW) + xOffset;
+         y = (int)((positionID % numCascade) * cascadeH) + yOffset;
       }
       else if(anchor.left.type < vTiled)
       {
@@ -2215,7 +2250,11 @@ private:
       Point scroll = this.scroll;
 
       if(state == maximized)
+      {
          parent = GetParentMenuBar();
+         if(!parent && nativeDecorations)
+            parent = rootWindow;
+      }
 
       if(parent)
       {
@@ -2700,9 +2739,10 @@ private:
             if(!opaque)
             {
                // Adjust renderArea to the root window level
-               Extent * renderArea = &rootWindow.tempExtents[1];
+               Extent * renderArea = &rootWindow.tempExtents[3];
 
-               int offsetX = child.absPosition.x - rootWindow.absPosition.x, offsetY = child.absPosition.y - rootWindow.absPosition.y;
+               int offsetX = child.absPosition.x - rootWindow.absPosition.x;
+               int offsetY = child.absPosition.y - rootWindow.absPosition.y;
                if(child.rootWindow.nativeDecorations && rootWindow.windowHandle)
                {
                   offsetX -= child.rootWindow.clientStart.x;
@@ -2731,7 +2771,12 @@ private:
                */
 
                renderArea->Copy(child.dirtyArea /*childRenderArea*/);
+
+               // This intersection with child clip extent was missing and causing #708 (Installer components list scrolling bug):
+               renderArea->Intersection(child.clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
+
                renderArea->Offset(offsetX, offsetY);
+
                dirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
                // overDirtyExtent.Union(renderArea);
                renderArea->Empty();
@@ -3231,6 +3276,9 @@ private:
                      }
                   }
                }
+
+               if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
+                  result = null;
             }
          }
       }
@@ -4205,7 +4253,7 @@ private:
                guiApp.prevWindow = null;
 
                // Eventually fix this not to include captured?
-               if(!prevWindow.OnMouseLeave(*mods))
+               if(!trueWindow.IsDescendantOf(prevWindow) && !prevWindow.OnMouseLeave(*mods))
                   result = false;
             }
             if(result && trueWindow && !trueWindow.destroyed/* && trueWindow == window*/)
@@ -4685,7 +4733,7 @@ private:
 
             if(prevActiveWindow) incref prevActiveWindow;
             incref hotKeyWindow;
-            if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient)
+            if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown && !hotKeyWindow.style.nonClient && !hotKeyWindow.inactive)
                if(!hotKeyWindow.ActivateEx(true, true, false, true, null, null))
                {
                   status = false;
@@ -7753,7 +7801,7 @@ public:
       return false;
    }
    virtual void UpdateNonClient();
-   virtual void SetBox(Box box);
+   virtual void SetBox(Box box);    // This isn't used anywhere at this time
    virtual bool IsInside(int x, int y)
    {
       return box.IsPointInside({x, y});