wip II
[sdk] / ecere / src / gui / Window.ec
index b2f90e3..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)
       {
@@ -2197,16 +2232,14 @@ private:
 
    Window GetParentMenuBar()
    {
-      Window result = this;
-      bool notActiveClient = false;
       Window menuBarParent;
       for(menuBarParent = this; menuBarParent; menuBarParent = menuBarParent.parent)
       {
-         if(menuBarParent.menuBar) { result = notActiveClient ? null : menuBarParent.menuBar; break; }
-         if(menuBarParent.parent && /*menuBarParent != */!menuBarParent.parent.activeClient)
-            notActiveClient = true;
+         if(menuBarParent.menuBar) return menuBarParent.menuBar;
+         if(menuBarParent && !menuBarParent.isActiveClient)
+            return null;
       }
-      return result;
+      return null;
    }
 
    void CreateSystemChildren(void)
@@ -2217,7 +2250,11 @@ private:
       Point scroll = this.scroll;
 
       if(state == maximized)
+      {
          parent = GetParentMenuBar();
+         if(!parent && nativeDecorations)
+            parent = rootWindow;
+      }
 
       if(parent)
       {
@@ -2702,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;
@@ -2733,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();
@@ -3206,7 +3249,12 @@ private:
             // If the window is disabled, stop looking in children (for acceptDisabled mode)
             if(!disabled)
             {
-               for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
+               bool isD = (last && last != this && last.IsDescendantOf(this)); //  Fix for WSMS (#844)
+               Window ancestor = null;
+               if(isD)
+                  for(ancestor = last; ancestor && ancestor.parent != this; ancestor = ancestor.parent);
+               // for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
+               for(child = isD ? (ancestor.previous == children.first ? null : ancestor) : children.last; child; child = child.prev)
                {
                   if(child != statusBar && child.rootWindow == rootWindow)
                   {
@@ -3217,7 +3265,8 @@ private:
                }
                if(clickThru)
                {
-                  for(child = (last && last.parent == this) ? last.previous : children.last; child; child = child.prev)
+                  //for(child = isD ? (last.previous == children.first ? null : last.previous) : children.last; child; child = child.prev)
+                  for(child = isD ? (ancestor.previous == children.first ? null : ancestor.previous) : children.last; child; child = child.prev)
                   {
                      if(child != statusBar && child.rootWindow == rootWindow)
                      {
@@ -3227,6 +3276,9 @@ private:
                      }
                   }
                }
+
+               if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
+                  result = null;
             }
          }
       }
@@ -4066,6 +4118,8 @@ private:
                            return false;
                         }
                         delete activateWindow;
+                        // Trouble with clickThrough, siblings and activation (Fix for nicktick scrolling, siblings/activation endless loops, #844)
+                        activate = false;
                      }
                      mods->isActivate = true;
                   }
@@ -4199,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*/)
@@ -4679,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;
@@ -7747,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});
@@ -7894,7 +7948,9 @@ public:
                {
                   if(!style.noCycle)
                      parent.childrenCycle.Insert(
-                        (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null, 
+                        // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
+                        //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null, 
+                        null,
                         cycle = OldLink { data = this });
                   parent.childrenOrder.Insert(
                      (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last, 
@@ -8268,7 +8324,9 @@ public:
                if(!style.noCycle)
                {
                   parent.childrenCycle.Insert(
-                     (parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null, 
+                     // Note: changed to 'null' to fix broken tab cycling in WSMS custom reports
+                     //(parent.activeChild && parent.activeChild.cycle) ? parent.activeChild.cycle.prev : null, 
+                     null,
                      cycle = OldLink { data = this });
                }
                parent.childrenOrder.Insert(