ecere/gui/Window: Fixed null pointer crash on fullscreen app
[sdk] / ecere / src / gui / Window.ec
index 876d221..3d47585 100644 (file)
@@ -140,7 +140,7 @@ private struct FastList
       {
          int c;
          int newSize;
-               
+
          if(size)
          {
             newSize = (size + (size >> 1));
@@ -255,10 +255,10 @@ public /*private */struct Extent : OldList //FastList
 
       temp.Copy(this);
       Empty();
-      
+
       for(extentBox = (BoxItem)temp.first; extentBox; extentBox = (BoxItem)extentBox.next)
       {
-         if(extentBox.box.left < box.right && extentBox.box.right > box.left && 
+         if(extentBox.box.left < box.right && extentBox.box.right > box.left &&
             extentBox.box.top < box.bottom && extentBox.box.bottom > box.top)
          {
             // Top box
@@ -266,7 +266,7 @@ public /*private */struct Extent : OldList //FastList
             {
                Box newBox
                {
-                  extentBox.box.left, extentBox.box.top, 
+                  extentBox.box.left, extentBox.box.top,
                   extentBox.box.right, Min(extentBox.box.bottom, box.top -1)
                };
                AddBox(newBox);
@@ -324,14 +324,14 @@ public /*private */struct Extent : OldList //FastList
       // First pass: check if this box is not already covered by one of the extent's box
       for(extentBox = (BoxItem)this.first; extentBox; extentBox = (BoxItem)extentBox.next)
       {
-         if(extentBox.box.left <= box.left && extentBox.box.right >= box.right && 
+         if(extentBox.box.left <= box.left && extentBox.box.right >= box.right &&
             extentBox.box.top <= box.top && extentBox.box.bottom >= box.bottom)
          {
             // No change
             return;
          }
       }
-        
+
       // Second pass: only keep boxes not completely covered in the new box
       for(extentBox = (BoxItem)this.first; extentBox; extentBox = next)
       {
@@ -377,7 +377,7 @@ public /*private */struct Extent : OldList //FastList
                }
             }
          }
-         
+
          // Else, add it
          if(!extentBox)
             AddBox(box);
@@ -411,7 +411,7 @@ public /*private */struct Extent : OldList //FastList
 
    void Exclusion(Extent b, Extent temp)
    {
-      BoxItem extentBox;   
+      BoxItem extentBox;
       for(extentBox = (BoxItem)b.first; extentBox; extentBox = (BoxItem)extentBox.next)
          ExcludeBox(extentBox.box, temp);
    }
@@ -436,7 +436,7 @@ private define CASCADE_SPACE = 16;
 
 private class ScrollFlags
 {
-   bool snapX:1, snapY:1, dontHide:1;   
+   bool snapX:1, snapY:1, dontHide:1;
 };
 
 public class BorderBits { public: bool contour:1, fixed:1, sizable:1, deep:1, bevel:1, thin:1; };
@@ -527,7 +527,7 @@ private:
             }
          }
       }
-      
+
       //tempExtents[0] = { /*first = -1, last = -1, free = -1*/ };
       //tempExtents[1] = { /*first = -1, last = -1, free = -1*/ };
       //tempExtents[2] = { /*first = -1, last = -1, free = -1*/ };
@@ -544,7 +544,7 @@ private:
       maxSize = Size { MAXINT, MAXINT };
       background = white;
       foreground = black;
-      
+
       //style.isActiveClient = true;
       mergeMenus = true;
       autoCreate = true;
@@ -578,7 +578,7 @@ private:
       }
 
       if(!destroyed)
-      { 
+      {
          // Prevent destructor from being called again...
          incref this;
          incref this;
@@ -695,7 +695,7 @@ private:
    {
       if(this == activeDesigner)
          return "(Desktop)";
-      else 
+      else
       {
          char * name = property::name;
          return name ? name : "";
@@ -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;
@@ -980,7 +981,7 @@ private:
             ph = vph = box.bottom - box.top + 1;
          }
       }
-      
+
       if(!parent)
       {
          *ow = w;
@@ -1027,7 +1028,7 @@ private:
 
          if(anchor.top.type)
          {
-            SNAPUP(y, textCellH);   
+            SNAPUP(y, textCellH);
          }
          else if(anchor.bottom.type)
          {
@@ -1036,13 +1037,47 @@ 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*/))
       {
-         if(parent.sbv && !parent.sbv.style.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)
             ph += guiApp.currentSkin.HorizontalSBH();
@@ -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)
             {
@@ -1108,7 +1143,7 @@ private:
       {
          if(sizeAnchor.isClientW) w += ew;
          if(sizeAnchor.isClientH) h += eh;
-         
+
          if(anchor.left.type == offset)
             x = anchor.left.distance;
          else if(anchor.left.type == relative)
@@ -1133,8 +1168,8 @@ private:
          {
             switch(anchor.right.type)
             {
-               case relative: 
-                  ex = pw * (1.0f-anchor.right.percent); 
+               case relative:
+                  ex = pw * (1.0f-anchor.right.percent);
                   w = Max((int)(ex + 0.5) - x, 0);
                   break;
                case offset:
@@ -1160,7 +1195,7 @@ private:
       }
 
       w -= ew;
-      h -= eh; 
+      h -= eh;
 
       if(state == normal /*|| state == Hidden*/)
       {
@@ -1174,12 +1209,12 @@ private:
          w = Min(w, maxSize.w);
          h = Min(h, maxSize.h);
 
-         if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv) 
+         if((sizeAnchor.isClientW || !w || (anchor.left.type && anchor.right.type)) && reqScrollArea.h > h /*&& w*/ && sbv)
          {
             if(w) w -= guiApp.currentSkin.VerticalSBW();
             addSbV = true;
          }
-         if((sizeAnchor.isClientH || !h ||  (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh) 
+         if((sizeAnchor.isClientH || !h ||  (anchor.top.type && anchor.bottom.type)) && reqScrollArea.w > w /*&& h*/ && sbh)
          {
             if(h) h -= guiApp.currentSkin.HorizontalSBH();
             addSbH = true;
@@ -1191,7 +1226,7 @@ private:
             h = clientSize.h;
          }
 
-         if((addSbV)) // || reqScrollArea.h > h) && sbv) 
+         if((addSbV)) // || reqScrollArea.h > h) && sbv)
             w += guiApp.currentSkin.VerticalSBW();
          if((addSbH)) // || reqScrollArea.w > w) && sbh)
             h += guiApp.currentSkin.HorizontalSBH();
@@ -1206,7 +1241,7 @@ private:
       }
 
       w += ew;
-      h += eh; 
+      h += eh;
 
       if(guiApp.textMode)
       {
@@ -1219,9 +1254,9 @@ private:
          if(parent.numIcons) ph -= guiApp.textMode ? 16 : 24;
 
          numCascade = Min(
-            (pw - w) / CASCADE_SPACE, 
+            (pw - w) / CASCADE_SPACE,
             (ph - h) / CASCADE_SPACE);
-         
+
          if(guiApp.textMode)
          {
                int cascW, cascH;
@@ -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)
       {
@@ -1267,7 +1302,7 @@ private:
                if(anchor.vert.type == middleRelative)
                   y = (int)(vph * (0.5 + anchor.vert.percent) - h / 2);
                else
-                  y = vph / 2 + anchor.vert.distance - h / 2;      
+                  y = vph / 2 + anchor.vert.distance - h / 2;
             }
             else
                y = (int)(ey - h);
@@ -1313,13 +1348,13 @@ private:
          int y = caretPos.y - scroll.y;
 
          if((erase || this.caretSize) &&
-            x >= clientArea.left && x <= clientArea.right && 
+            x >= clientArea.left && x <= clientArea.right &&
             y >= clientArea.top  && y <= clientArea.bottom)
          {
             if(!erase)
             {
                guiApp.interfaceDriver.SetCaret(
-                  x + absPosition.x + clientStart.x, 
+                  x + absPosition.x + clientStart.x,
                   y + absPosition.y + clientStart.y, this.caretSize);
                guiApp.caretEnabled = true;
             }
@@ -1418,7 +1453,7 @@ private:
                //if((w > reqScrollArea.w) || (h > reqScrollArea.w))
                {
                   int stepX = sbStep.x, stepY = sbStep.y;
-                  // Needed to make snapped down position match the skin's check of client area 
+                  // Needed to make snapped down position match the skin's check of client area
                   // against realvirtual
                   if(guiApp.textMode)
                   {
@@ -1448,7 +1483,7 @@ private:
       // Automatic MDI Client Scrolling Area Adjustment
       if(parent && !parent.noAutoScrollArea)
       {
-         if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) && 
+         if(modifyArea && modifyVirtArea /*&& !anchored*/ && (parent.sbv || parent.sbh) &&
             !style.dontScrollHorz && !style.dontScrollVert && !style.nonClient)
          {
             Window parent = this.parent;
@@ -1464,12 +1499,12 @@ private:
             else if(stateAnchor.bottom.type == none && stateAnchor.top.type == none)
                h = Max(h, Max(position.y, 0) + size.h);
 
-            if((w > parent.clientSize.w && w > parent.reqScrollArea.w) || 
+            if((w > parent.clientSize.w && w > parent.reqScrollArea.w) ||
                (h > parent.clientSize.h && h > parent.reqScrollArea.h))
             {
                /*bool resize = false;
                int stepX = parent.sbStep.x, stepY = parent.sbStep.y;
-               // Needed to make snapped down position match the skin's check of client area 
+               // Needed to make snapped down position match the skin's check of client area
                // against realvirtual
                if(guiApp.textMode)
                {
@@ -1488,12 +1523,12 @@ private:
                   parent.reqScrollArea.h = h;*/
 
                  // parent.UpdateScrollBars(true, true);
-                  parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h, 
+                  parent.Position(parent.position.x, parent.position.y, parent.size.w, parent.size.h,
                      false, true, true, true, false, false);
                   return;
                //}
             }
-            else 
+            else
                GetRidOfVirtualArea();
          }
       }
@@ -1585,7 +1620,7 @@ private:
             {
                Window parent = this.parent;
                parent.Position(
-                  parent.position.x, parent.position.y, parent.size.w, parent.size.h, 
+                  parent.position.x, parent.position.y, parent.size.w, parent.size.h,
                   false, true, true, true, false, false);
                /*
                parent.SetScrollArea(0,0,true);
@@ -1617,16 +1652,16 @@ private:
 
       // windowResized = realResized || force;
       windowResized = size.w != w || size.h != h || force;
-     
+
       if(rootWindow != this && display && !display.flags.flipping && scrolledPos.x != MININT)
       {
          if(style.nonClient)
          {
             Box box
-            { 
-               scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top, 
+            {
+               scrolledPos.x - parent.clientStart.x + this.box.left, scrolledPos.y - parent.clientStart.y + this.box.top,
                scrolledPos.x - parent.clientStart.x + this.box.right,
-               scrolledPos.y - parent.clientStart.y + this.box.bottom 
+               scrolledPos.y - parent.clientStart.y + this.box.bottom
             };
             parent.Update(box);
          }
@@ -1671,7 +1706,7 @@ private:
                   int x,y,w,h;
                   for(child = children.first; child; child = child.next)
                   {
-                     if(child.created && 
+                     if(child.created &&
                      ((child.stateAnchor.left.type != offset ||
                        child.stateAnchor.top.type != offset ||
                        child.stateAnchor.right.type != none ||
@@ -1751,12 +1786,12 @@ private:
                else if(clientResized)
                   Update(clientArea);
                // --- Major Slow Down / Fix OpenGL Resizing Main Window Lag
-               
+
                /*
                if(!guiApp.fullScreenMode && !guiApp.modeSwitching && this == rootWindow)
                   UpdateDisplay();
                */
-               
+
                if(windowMoved || windowResized)
                {
                   display.Unlock();
@@ -1766,7 +1801,7 @@ private:
             {
                if(windowResized || windowMoved)
                   if(!display || display.flags.memBackBuffer)
-                     guiApp.interfaceDriver.PositionRootWindow(this, 
+                     guiApp.interfaceDriver.PositionRootWindow(this,
                         x, y, w, h, windowMoved, windowResized);
                guiApp.interfaceDriver.UpdateRootWindow(this);
             }
@@ -1938,7 +1973,7 @@ private:
             if(flag && (resizeH || resizeV) && fullThing)
             {
                Position(position.x, position.y, size.w, size.h, false, true, false, false, false, false);
-               
+
                if(!positioned)
                {
                   positioned = true;
@@ -1946,7 +1981,7 @@ private:
                   positioned = false;
                }
             }
-      
+
             if(resizeH && sbh)
                sbh.visible = sbhVisible;
             if(resizeV && sbv)
@@ -2191,22 +2226,21 @@ private:
                Update(null);
                break;
             }
-         }         
+         }
       }
    }
 
    Window GetParentMenuBar()
    {
-      Window result = this;
-      bool notActiveClient = false;
       Window menuBarParent;
-      for(menuBarParent = this; menuBarParent; menuBarParent = menuBarParent.parent)
+      if(formDesigner) return null;
+      for(menuBarParent = this ? parent : null; 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 +2251,11 @@ private:
       Point scroll = this.scroll;
 
       if(state == maximized)
+      {
          parent = GetParentMenuBar();
+         if(!parent)
+            parent = this;
+      }
 
       if(parent)
       {
@@ -2249,7 +2287,7 @@ private:
       {
          if(!sysButtons[2])
          {
-            sysButtons[2] = 
+            sysButtons[2] =
                Button
                {
                   parent, master = this,
@@ -2267,7 +2305,7 @@ private:
                sysButtons[2].hotKey = ctrlF4;
             sysButtons[2].Create();
          }
-         
+
          sysButtons[2].symbol = 'X';
          sysButtons[2].disabled = !style.hasClose;
       }
@@ -2277,7 +2315,7 @@ private:
          SkinBitmap skin;
          unichar symbol;
          bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
-         if(state == maximized) 
+         if(state == maximized)
          {
             skin = restore;
             method = RestoreButtonClicked;
@@ -2310,7 +2348,7 @@ private:
          SkinBitmap skin;
          unichar symbol;
          bool (* method)(Window window, Button button, int x, int y, Modifiers mods);
-         if (state == minimized) 
+         if (state == minimized)
          {
             skin = restore;
             method = RestoreButtonClicked;
@@ -2384,9 +2422,9 @@ private:
       }
       if(scrollBarChanged)
       {
-         SetScrollLineStep(sbStep.x, sbStep.y);   
+         SetScrollLineStep(sbStep.x, sbStep.y);
          UpdateScrollBars(true, true);
-      }   
+      }
       UpdateNonClient();
 
       if(scrollBarChanged)
@@ -2463,10 +2501,10 @@ private:
                      char name[2048], caption[2048];
                      document.FigureCaption(caption);
                      sprintf(name, "%d %s", id+1, caption);
-                     windowMenu.AddDynamic(MenuItem 
-                        { 
-                           copyText = true, text = name, hotKey = Key { k1 + id }, id = id++, 
-                           NotifySelect = MenuWindowSelectWindow 
+                     windowMenu.AddDynamic(MenuItem
+                        {
+                           copyText = true, text = name, hotKey = Key { k1 + id }, id = id++,
+                           NotifySelect = MenuWindowSelectWindow
                         }, this, false);
                   }
                   cycle = cycle.next;
@@ -2474,7 +2512,7 @@ private:
                }
             }
          }
-         
+
          if((!previous && activeClient) || !activeClient)
          {
             if(!activeClient)
@@ -2497,7 +2535,7 @@ private:
             if(item) item.disabled = false;
             item = menu.FindItem(MenuWindowWindows, 0);
             if(item) item.disabled = false;
-         }      
+         }
 
          item = menu.FindItem(MenuFileClose, 0);
          if(item) item.disabled = !activeClient || !activeClient.style.hasClose;
@@ -2535,7 +2573,7 @@ private:
          {
             char caption[2048];
             FigureCaption(caption);
-            
+
             if(post)
                ShowDecorations(captionFont.font,
                   surface,
@@ -2548,7 +2586,7 @@ private:
                   caption,
                   active, //parent.activeClient == this
                   guiApp.windowMoving == this);
-               
+
             delete surface;
          }
       }
@@ -2561,9 +2599,9 @@ private:
       if(!manageDisplay) { OnRedraw(null);return; }
       _ShowDecorations(refresh, false);
 
-      surface = Redraw(refresh);               
+      surface = Redraw(refresh);
       // Opaque background: just fill before EW_REDRAW (clear?)
-      if(surface) 
+      if(surface)
       {
          surface.SetBackground(background);
          surface.SetForeground(foreground);
@@ -2625,8 +2663,8 @@ private:
 
    void DrawOverChildren(Box refresh)
    {
-      Surface surface = Redraw(refresh);               
-      if(surface) 
+      Surface surface = Redraw(refresh);
+      if(surface)
       {
          // Default Settings
          surface.DrawingChar(' ');
@@ -2650,12 +2688,12 @@ private:
       Extent clipExtent { /*first = -1, last = -1, free = -1*/ };
 
       clipExtent.Copy(this.clipExtent);
-      
+
       for(child = children.last; child; child = child.prev)
       {
          if(!child.style.hidden && child.created && !child.is3D && child.rootWindow)
          {
-            bool opaque = child.IsOpaque(); // TODO: acess background directly 
+            bool opaque = child.IsOpaque(); // TODO: acess background directly
             int dx = child.absPosition.x - absPosition.x, dy = child.absPosition.y - absPosition.y;
 
             child.clipExtent.Copy(clipExtent);
@@ -2670,7 +2708,7 @@ private:
                Box box { child.box.left + dx, child.box.top + dy, child.box.right + dx, child.box.bottom + dy };
                clipExtent.ExcludeBox(box, rootWindow.tempExtents[0]);
             }
-            
+
          }
       }
       // ??? Only do this for overlapped window or if parent has with clip children flag
@@ -2702,9 +2740,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;
@@ -2713,7 +2752,7 @@ private:
 
                /*
                Extent childRenderArea;
-               
+
                if(backBufferUpdate != null)
                {
                   childRenderArea.Copy(backBufferUpdate);
@@ -2733,7 +2772,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();
@@ -2800,16 +2844,16 @@ private:
       {
          renderArea.Copy(backBufferUpdate);
          renderArea.Offset(-offsetX, -offsetY);
-         
+
          overRenderArea.Copy(backBufferUpdate);
          overRenderArea.Offset(-offsetX, -offsetY);
-         
-         
+
+
       }
       else
       {
          renderArea.Copy(dirtyArea);
-         
+
          overRenderArea.Copy(dirtyArea);
       }
 
@@ -2846,8 +2890,8 @@ private:
                FASTLIST_LOOP(renderArea, extentBox)
                {
       #ifdef _DEBUG
-                  printf("(%d, %d) - (%d, %d)\n", 
-                     extentBox.box.left, extentBox.box.top, 
+                  printf("(%d, %d) - (%d, %d)\n",
+                     extentBox.box.left, extentBox.box.top,
                      extentBox.box.right, extentBox.box.bottom);
       #endif
                }
@@ -2857,7 +2901,7 @@ private:
          }
       }
       */
-      
+
       // WHY WAS THIS COMMENTED ??
 
       // Add extent forced by DrawOverChildren to the dirty area, adjusting dirty extent to the window
@@ -2868,7 +2912,7 @@ private:
 
       // Intersect with the clip extent
       overRenderArea.Intersection(clipExtent, rootWindow.tempExtents[0], rootWindow.tempExtents[1], rootWindow.tempExtents[2]);
-      
+
 
       if(opaque)
       {
@@ -2921,17 +2965,17 @@ private:
          dirtyExtent.Union(renderArea);
          renderArea.Free();
       }*/
-      
-      
+
+
       {
          Extent renderArea { };
-         
+
          renderArea.Copy(overRenderArea);
          renderArea.Offset(offsetX, offsetY);
          overDirtyExtent.Union(renderArea, rootWindow.tempExtents[0]);
          renderArea.Empty();
       }
-      
+
 
       if(backBufferUpdate != null)
       {
@@ -2975,22 +3019,22 @@ private:
          foreground = (background.color.r > 128 || background.color.g > 128) ? black : white;
          */
 #endif
-            
+
 #ifdef _DEBUG
          /*if(renderArea.count)
             printf("\n\nRendering %s (%x):\n------------------------------------------\n", _class.name, this);*/
 #endif
-            
+
          for(extentBox = (BoxItem)renderArea.first; extentBox; extentBox = (BoxItem)extentBox.next)
          {
             Box box = extentBox.box;
 
 #ifdef _DEBUG
-               /*printf("(%d, %d) - (%d, %d)\n", 
-                  extentBox.box.left, extentBox.box.top, 
+               /*printf("(%d, %d) - (%d, %d)\n",
+                  extentBox.box.left, extentBox.box.top,
                   extentBox.box.right, extentBox.box.bottom);*/
 #endif
-               
+
             UpdateExtent(box);
 
             box.left += offsetX;
@@ -3040,7 +3084,7 @@ private:
    public void UpdateDisplay(void)
    {
       if(!manageDisplay) { OnRedraw(null);return; }
-      if(rootWindow && this != rootWindow) 
+      if(rootWindow && this != rootWindow)
          rootWindow.UpdateDisplay();
       else if(display)
       {
@@ -3062,7 +3106,7 @@ private:
             ComputeRenderArea(dirtyExtent, overExtent, null);
          }
          else
-            clipExtent.Free(null);                     
+            clipExtent.Free(null);
 
          dirtyExtent.Free(null);
          overExtent.Free(null);
@@ -3080,22 +3124,22 @@ private:
             Render(updateExtent);
             if(fullRender)
                updateExtent.UnionBox(this.box, tempExtents[0]);
-            
+
 #ifdef _DEBUG
             //printf("\n\nUpdate:\n------------------------------------------\n");
 #endif
-            
+
             //FASTLIST_LOOP(updateExtent, extentBox)
             for(extentBox = (BoxItem)updateExtent.first; extentBox; extentBox = (BoxItem)extentBox.next)
             {
 #ifdef _DEBUG
-               /*printf("Updating (%d, %d) - (%d, %d)\n", 
-                  extentBox.box.left, extentBox.box.top, 
+               /*printf("Updating (%d, %d) - (%d, %d)\n",
+                  extentBox.box.left, extentBox.box.top,
                   extentBox.box.right, extentBox.box.bottom);*/
 #endif
-               
+
                display.Update(extentBox.box);
-               
+
             }
             updateExtent.Free(null);
          }
@@ -3123,12 +3167,12 @@ private:
          {
             intersection.Copy(dirtyBack);
             intersection.IntersectBox(box);
-         
+
             dirtyExtent.Clear();
             overExtent.Clear();
 
             clipExtent.AddBox(box);
-         
+
             if(!rootWindow.fullRender)
             {
                ComputeClipExtents();
@@ -3206,18 +3250,24 @@ 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)
                   {
                      Window childResult = child.GetAtPosition(x, y, clickThru, acceptDisabled, last);
-                     if(childResult) 
+                     if(childResult)
                         return childResult;
                   }
                }
                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 +3277,9 @@ private:
                      }
                   }
                }
+
+               if(last && last != this && this.IsDescendantOf(last)) // Fix for installer lockup
+                  result = null;
             }
          }
       }
@@ -3305,7 +3358,7 @@ private:
       mouseWindow = rootWindow ? rootWindow.GetAtPosition(x,y, true, false, null) : null;
 
       if((guiApp.windowMoving && !guiApp.windowIsResizing) || guiApp.windowScrolling)
-         guiApp.SetCurrentCursor(guiApp.systemCursors[moving]);
+         guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[moving]);
       else if(mouseWindow)
       {
          modalWindow = mouseWindow.FindModal();
@@ -3318,30 +3371,31 @@ private:
             rx = guiApp.resizeX;
             ry = guiApp.resizeY;
             if((rex && rey) || (rx && ry))
-               guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
+               guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
             else if((rex && ry) || (rx && rey))
-               guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
+               guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
             else if((ry || rey) && (!rx && !rex))
-               guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
+               guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
             else if((rx || rex) && (!ry && !rey))
-               guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
+               guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
          }
          else if(!modalWindow && !guiApp.windowCaptured &&
             mouseWindow.IsMouseResizing(x, y, mouseWindow.size.w, mouseWindow.size.h,
                &rx, &ry, &rex, &rey))
          {
             if((rex && rey) || (rx && ry))
-               guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNWSE]);
+               guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNWSE]);
             else if((rex && ry) || (rx && rey))
-               guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNESW]);
+               guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNESW]);
             else if((ry || rey) && (!rx && !rex))
-               guiApp.SetCurrentCursor(guiApp.systemCursors[sizeNS]);
+               guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeNS]);
             else if((rx || rex) && (!ry && !rey))
-               guiApp.SetCurrentCursor(guiApp.systemCursors[sizeWE]);
+               guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[sizeWE]);
          }
          else if(!guiApp.windowCaptured && !modalWindow && !guiApp.interimWindow)
          {
-            if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}))
+            if(!mouseWindow.clientArea.IsPointInside({x - mouseWindow.clientStart.x, y - mouseWindow.clientStart.y}) &&
+               mouseWindow.rootWindow != mouseWindow)
                cursorWindow = mouseWindow.parent;
             else
                cursorWindow = mouseWindow;
@@ -3350,19 +3404,19 @@ private:
             cursorWindow = guiApp.windowCaptured;
          if(cursorWindow)
          {
-            for(; !cursorWindow.cursor && !cursorWindow.style.nonClient; cursorWindow = cursorWindow.parent);
-            guiApp.SetCurrentCursor(cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
+            for(; !cursorWindow.cursor && !cursorWindow.style.nonClient && cursorWindow.rootWindow != cursorWindow; cursorWindow = cursorWindow.parent);
+            guiApp.SetCurrentCursor(mouseWindow, cursorWindow.cursor ? cursorWindow.cursor : guiApp.systemCursors[arrow]);
          }
          else if(modalWindow)
          {
-            guiApp.SetCurrentCursor(guiApp.systemCursors[arrow]);
+            guiApp.SetCurrentCursor(mouseWindow, guiApp.systemCursors[arrow]);
          }
          else if(guiApp.interimWindow)
          {
             if(guiApp.interimWindow.cursor)
-               guiApp.SetCurrentCursor(guiApp.interimWindow.cursor);
+               guiApp.SetCurrentCursor(mouseWindow, guiApp.interimWindow.cursor);
             else
-               guiApp.SetCurrentCursor(mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
+               guiApp.SetCurrentCursor(mouseWindow, mouseWindow.cursor ? mouseWindow.cursor : guiApp.systemCursors[arrow]);
          }
       }
    }
@@ -3371,7 +3425,7 @@ private:
    bool AcquireInputEx(bool state)
    {
       bool result;
-      if(state) 
+      if(state)
       {
          guiApp.interfaceDriver.GetMousePosition(&guiApp.acquiredMouseX, &guiApp.acquiredMouseY);
          guiApp.interfaceDriver.SetMousePosition(clientSize.w/2 + absPosition.x, clientSize.h/2 + absPosition.y);
@@ -3382,7 +3436,7 @@ private:
       if(state && result)
       {
          SetMouseRangeToClient();
-         guiApp.interfaceDriver.SetMouseCursor((SystemCursor)-1);
+         guiApp.interfaceDriver.SetMouseCursor(guiApp.acquiredWindow, (SystemCursor)-1);
       }
       else
       {
@@ -3405,6 +3459,15 @@ private:
          if(rootWindow == this)
             Log(active ? "active\n" : "inactive\n");
          */
+         if(active && requireRemaximize)
+         {
+            if(state == maximized)
+            {
+               property::state = normal;
+               property::state = maximized;
+            }
+            requireRemaximize = false;
+         }
 
          // Testing this here...
          if(!parent || parent == guiApp.desktop || parent.active)
@@ -3434,11 +3497,11 @@ private:
                   {
                      if(guiApp.caretOwner)
                      {
-                        Box extent 
+                        Box extent
                         {
-                           guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1, 
+                           guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 1,
                            guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + 1,
-                           guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2, 
+                           guiApp.caretOwner.caretPos.x - guiApp.caretOwner.scroll.x + 2,
                            guiApp.caretOwner.caretPos.y - guiApp.caretOwner.scroll.y + guiApp.caretOwner.caretSize - 1
                         };
                         guiApp.caretOwner.Update(extent);
@@ -3543,8 +3606,8 @@ private:
          {
             if(!active)
                StopMoving();
-            if(activateParent && 
-               (parent.activeChild != this || 
+            if(activateParent &&
+               (parent.activeChild != this ||
                (guiApp.interimWindow && !IsDescendantOf(guiApp.interimWindow))) &&
                active && _isModal &&
                parent != master && master)
@@ -3557,8 +3620,8 @@ private:
                   bool real = parent.activeChild != this;
 
                   // TEST THIS: New activateParent check here!!! CAUSED MENUS NOT GOING AWAY
-                  if(!style.inactive && /*activateParent && */guiApp.interimWindow && 
-                     !IsDescendantOf(guiApp.interimWindow) && 
+                  if(!style.inactive && /*activateParent && */guiApp.interimWindow &&
+                     !IsDescendantOf(guiApp.interimWindow) &&
                      !IsSlaveOf(guiApp.interimWindow))
                   {
                      Window interimWindow = guiApp.interimWindow;
@@ -3622,7 +3685,7 @@ private:
                         {
                            bool goOn = true;
                            result = PropagateActive(true, swap, &goOn, true);
-                           if(!result && !goOn) 
+                           if(!result && !goOn)
                            {
                               delete this;
                               return false;
@@ -3690,14 +3753,14 @@ private:
                         }
                      }
                   }
-               
+
                   if(result && real && (!style.inactive || moveInactive) && parent)
                   {
                      Window last = parent.children.last;
 
                      if(!style.stayOnTop)
                         for(; last && last.style.stayOnTop; last = last.prev);
-                     
+
                      parent.children.Move(this, last);
 
                      // Definitely don't want that:   why not?
@@ -3708,7 +3771,7 @@ private:
                   }
                }
             }
-            else 
+            else
             {
                if(!parent || style.interim || (parent.activeChild == this && !style.inactive))
                {
@@ -3765,9 +3828,9 @@ private:
       if(guiApp.windowScrolling && !consequential)
       {
          guiApp.windowScrolling.SetScrollPosition(
-            (guiApp.windowScrolling.sbh) ? 
+            (guiApp.windowScrolling.sbh) ?
                (guiApp.windowScrollingBefore.x - mouseX + guiApp.windowScrollingStart.x) : 0,
-            (guiApp.windowScrolling.sbv) ? 
+            (guiApp.windowScrolling.sbv) ?
                (guiApp.windowScrollingBefore.y - mouseY + guiApp.windowScrollingStart.y) : 0);
       }
       if(guiApp.windowMoving)
@@ -3860,7 +3923,7 @@ private:
                   h = guiApp.windowResizingBefore.h - ry;
                }
             }
-         
+
             // Position
             if(!guiApp.windowIsResizing || guiApp.resizeX)
                x = guiApp.windowMovingBefore.x + rx;
@@ -3914,7 +3977,7 @@ private:
 
             // Break the anchors for moveable/resizable windows
             // Will probably cause problem with IDE windows... Will probably need a way to specify if anchors should break
-            if(window.style.fixed) 
+            if(window.style.fixed)
             {
                if(window.state == normal)
                {
@@ -3954,7 +4017,7 @@ private:
          w = msgWindow;
          if(w) incref w;
          window = (w && !w.disabled) ? w : null;
-         
+
          if(trueWindow) incref trueWindow;
 
          if(consequential) mods->isSideEffect = true;
@@ -3979,9 +4042,9 @@ private:
             {
                Window moved = trueWindow;
                for(moved = trueWindow; moved; moved = moved.parent)
-                  if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized)) 
+                  if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
                      break;
-               if(moved) 
+               if(moved)
                {
                   window = moved;
                   windowDragged = true;
@@ -4004,9 +4067,9 @@ private:
             {
                Window moved = window;
                for(moved = window; moved; moved = moved.parent)
-                  if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized)) 
+                  if(method == OnRightButtonDown || ((moved.style.fixed || moved.moveable) && moved.state != maximized))
                      break;
-               if(moved) 
+               if(moved)
                {
                   window = moved;
                   windowDragged = true;
@@ -4040,7 +4103,7 @@ private:
                      doActivation = false;
                   */
 
-                  if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) || 
+                  if((doActivation && (activateWindow.parent != guiApp.desktop || guiApp.fullScreen)) ||
                      (guiApp.interimWindow && !window.IsDescendantOf(guiApp.interimWindow)))
                   {
                      // Let the OnLeftButtonDown do the activating instead
@@ -4066,6 +4129,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;
                   }
@@ -4107,7 +4172,7 @@ private:
                   else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnRightButtonDown)
                   {
                      if(window.style.fixed &&
-                        (windowDragged || 
+                        (windowDragged ||
                         window.IsMouseMoving(
                            x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h)))
                      {
@@ -4129,8 +4194,8 @@ private:
                   }
                   else if(method == __ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnLeftDoubleClick)
                   {
-                     if(window.style.hasMaximize && 
-                        window.IsMouseMoving( 
+                     if(window.style.hasMaximize &&
+                        window.IsMouseMoving(
                            x - window.absPosition.x, y - window.absPosition.y, window.size.w, window.size.h))
                      {
                         window.SetState(
@@ -4142,7 +4207,7 @@ private:
             }
             else
                window = null;
-            if(guiApp.windowMoving) 
+            if(guiApp.windowMoving)
             {
                if(guiApp.windowMoving.parent)
                {
@@ -4179,7 +4244,7 @@ private:
 
          if(trueWindow && trueWindow.FindModal())
             delete trueWindow;
-         
+
          /*if(trueWindow)
             incref trueWindow;
          */
@@ -4199,7 +4264,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*/)
@@ -4303,7 +4368,7 @@ private:
          if(status && !destroyed && menuBar && state != minimized)
          {
             // Disable the ALT
-            if((SmartKey)key != alt) 
+            if((SmartKey)key != alt)
                menuBar.KeyMessage(__ecereVMethodID___ecereNameSpace__ecere__gui__Window_OnKeyDown, 0, 0);
             if(menuBar.focus)
             {
@@ -4376,7 +4441,7 @@ private:
 
                         if(!guiApp.windowIsResizing || guiApp.resizeY)
                            y = (y - guiApp.windowMovingBefore.y) + guiApp.windowMovingStart.y;
-                        else                           
+                        else
                            y = (h - guiApp.windowResizingBefore.h) + guiApp.windowMovingStart.y;
 
                         guiApp.interfaceDriver.SetMousePosition(x, y);
@@ -4392,7 +4457,7 @@ private:
                      {
                         guiApp.windowMoving.StopMoving();
                         ConsequentialMouseMove(false);
-                  
+
                         status = false;
                      }
                      break;
@@ -4434,7 +4499,7 @@ private:
                   if((defaultControl.active ||
                      defaultControl.ActivateEx(true, true, false, true, null, null)) && !defaultControl.disabled)
                      defaultControl.KeyMessage(method, defaultKey, character);
-                  status = false;                       
+                  status = false;
                }
             }
          }
@@ -4487,7 +4552,7 @@ private:
                         Window cycleParent = this;
                         if(this == guiApp.interimWindow && master && !master.style.interim && !cycleParent.style.tabCycle && master.parent)
                            cycleParent = master.parent;
-                        
+
                         if(!guiApp.windowCaptured && cycleParent.style.tabCycle)
                         {
                            if(cycleParent.CycleChildren(!key.shift, false, false, true))
@@ -4499,7 +4564,7 @@ private:
                               if(cycleParent.sbh && !child.style.dontScrollHorz)
                               {
                                  if(child.scrolledPos.x < 0)
-                                    cycleParent.sbh.Action(Position, 
+                                    cycleParent.sbh.Action(Position,
                                        cycleParent.scroll.x + child.scrolledPos.x, 0);
                                  else if(child.scrolledPos.x + child.size.w > cycleParent.clientSize.w)
                                     cycleParent.sbh.Action(Position,
@@ -4508,7 +4573,7 @@ private:
                               if(cycleParent.sbv && !child.style.dontScrollVert)
                               {
                                  if(child.scrolledPos.y < 0)
-                                    cycleParent.sbv.Action(Position, 
+                                    cycleParent.sbv.Action(Position,
                                        cycleParent.scroll.y + child.scrolledPos.y, 0);
                                  else if(child.scrolledPos.y + child.size.w > window.clientSize.h)
                                     cycleParent.sbv.Action(Position,
@@ -4578,7 +4643,7 @@ private:
                               }
                            }
                         }
-                        break;            
+                        break;
                      }
                      */
                   }
@@ -4679,7 +4744,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;
@@ -4729,7 +4794,7 @@ private:
       Window child;
 
       // Setup relationship with outside world (bb root || !bb)
-      if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop || 
+      if((!guiApp.fullScreenMode && parent == guiApp.desktop) || this == guiApp.desktop ||
          (_displayDriver && parent.dispDriver && dispDriver != parent.dispDriver))
       {
          rootWindow = this;
@@ -4807,7 +4872,10 @@ private:
       for(child = children.first; child; child = child.next)
       {
          if(child.created && !child.Setup(false))
-            result = false; 
+            result = false;
+
+         if(guiApp.modeSwitching && guiApp.fullScreen && child.rootWindow == child)
+            child.UpdateCaption();
       }
       return result;
    }
@@ -4815,8 +4883,8 @@ private:
    bool SetupDisplay(void)
    {
 #if !defined(ECERE_NO3D) && !defined(ECERE_VANILLA)
-      if(is3D) return Window3D_SetupDisplay(this); else 
-#endif   
+      if(is3D) return Window3D_SetupDisplay(this); else
+#endif
       if(SetupRoot())
          return Setup(true);
       return false;
@@ -4863,7 +4931,7 @@ private:
             }
          }
       }
-      
+
       if(guiApp.fullScreenMode || this != guiApp.desktop)
       {
          SetWindowMinimum(&skinMinSize.w, &skinMinSize.h);
@@ -4902,7 +4970,7 @@ private:
                      }
                   for(cursor = guiApp.customCursors.first; cursor; cursor = cursor.next)
                   {
-                     cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null, 
+                     cursor.bitmap = eBitmap_LoadT(cursor.bitmapName, null,
                         cursor.paletteShades ? null : guiApp.desktop.display.displaySystem);
                      if(cursor.bitmap)
                         cursor.bitmap.paletteShades = cursor.paletteShades;
@@ -4919,7 +4987,7 @@ private:
             }
 
             // Load Window Graphic Resources
-            
+
             /*
             if(usedFont == setFont || usedFont == window.systemFont)
                RemoveResource(usedFont);
@@ -4929,7 +4997,7 @@ private:
 
             if(systemFont)
                RemoveResource(systemFont);
-            
+
             if(captionFont)
                RemoveResource(captionFont);
 
@@ -4981,7 +5049,7 @@ private:
                display.Unlock();
 
                //SetScrollLineStep(sbStep.x, sbStep.y);
-               
+
                if(this != guiApp.desktop)
                {
                   if(resetAnchors)
@@ -5005,22 +5073,22 @@ private:
                   switch(state)
                   {
                      case maximized:
-                     
+
                         stateAnchor = Anchor { left = 0, top = 0, right = 0, bottom = 0 };
                         stateSizeAnchor = SizeAnchor {};
                         break;
-                     
+
                      case minimized:
                      {
                         int maxIcons = parent.clientSize.w / MINIMIZED_WIDTH;
 
-                        stateAnchor = 
-                           Anchor 
+                        stateAnchor =
+                           Anchor
                            {
                               left = (iconID % maxIcons) * MINIMIZED_WIDTH,
                               bottom = (iconID / maxIcons) * (guiApp.textMode ? 16 : 24)
                            };
-                        
+
                         stateSizeAnchor = SizeAnchor { size.w = MINIMIZED_WIDTH };
                         break;
                      }
@@ -5256,7 +5324,7 @@ private:
       if(interimWindow && interimWindow.master)
          interimMaster = interimWindow.master.rootWindow;
 
-      if(active && state == minimized) // && (!window.nativeDecorations || window.rootWindow != window)
+      if(active && state == minimized && window.parent) // && (!window.nativeDecorations || window.rootWindow != window)
          // SetState(normal, false, 0);
          SetState(lastState, false, 0);
 
@@ -5267,7 +5335,7 @@ private:
       /* WTH is this doing here?
       while(swap && swap.activeChild)
       {
-         swap = swap.activeChild;         
+         swap = swap.activeChild;
       }
       */
       // TESTING THIS BEFORE...
@@ -5317,7 +5385,7 @@ private:
       OldLink prevOrder = null;
       Window client = null;
 
-      if(parent) stopwatching(parent, font); 
+      if(parent) stopwatching(parent, font);
 
       // if(window.modalSlave) return false;
       if(destroyed || !created)
@@ -5353,7 +5421,7 @@ private:
          guiApp.prevWindow = null;
          OnMouseLeave(0);
       }
-      if(guiApp.caretOwner == this) 
+      if(guiApp.caretOwner == this)
       {
          guiApp.interfaceDriver.SetCaret(0,0,0);
          UpdateCaret(false, true);
@@ -5393,7 +5461,7 @@ private:
                if(client == this) { client = null; break; }
                if(client && (client.style.nonClient || !client.style.isActiveClient || client.style.hidden || client.destroyed || !client.created))
                   tmpPrev = client.order.prev;
-               else 
+               else
                {
                   if(client)
                      prevOrder = tmpPrev;
@@ -5443,7 +5511,7 @@ private:
                   parent.UpdateActiveDocument(null);
                }
             }
-            else 
+            else
             {
                if(guiApp.interimWindow == this)
                {
@@ -5734,7 +5802,7 @@ private:
 
          Position(x, y, w, h, true, true, true, true, false, true);
 
-         if(!style.inactive && !style.interim && this == parent.activeClient)
+         if(!style.inactive && !style.interim && parent && this == parent.activeClient)
             parent.UpdateActiveDocument(null);
       }
 
@@ -5818,7 +5886,7 @@ private:
          {
             guiApp.desktop.mutex.Wait();
             guiApp.desktop.display.Lock(true);
-         
+
             Update(extent);
             if(guiApp.desktop.active)
             {
@@ -5838,7 +5906,7 @@ private:
                   guiApp.RestoreCursorBackground();
                }
             }
-         
+
             guiApp.desktop.display.Unlock();
             guiApp.desktop.mutex.Release();
          }
@@ -5847,7 +5915,7 @@ private:
             Window rootWindow = this.rootWindow;
             rootWindow.mutex.Wait();
             display.Lock(true);
-         
+
             Update(extent);
             if(guiApp.waiting)
                guiApp.SignalEvent();
@@ -5901,7 +5969,7 @@ private:
          isForegroundWindow = true;
          ActivateEx(active, active, false, false, null, null);
          isForegroundWindow = false;
-      }  
+      }
    }
    */
 
@@ -5971,7 +6039,7 @@ private:
          guiApp.windowMovingBefore = scrolledPos;
          guiApp.windowResizingBefore = size;
          guiApp.windowMoving.UpdateDecorations();
-         if(guiApp.windowIsResizing) 
+         if(guiApp.windowIsResizing)
             guiApp.resizeEndX = guiApp.resizeEndY = true;
 
          if(setCursorPosition)
@@ -5982,7 +6050,7 @@ private:
             guiApp.interfaceDriver.GetMousePosition(&x, &y);
             guiApp.windowMovingStart.x += x - absPosition.x;
             guiApp.windowMovingStart.y += y - absPosition.y;
-         } 
+         }
 
          if(guiApp.windowMoving)
          {
@@ -6014,7 +6082,7 @@ public:
          Window last;
          bool visible = !style.hidden;
 
-         if(style.embedded) 
+         if(style.embedded)
          {
             systemParent = parent;
             parent = guiApp.desktop;
@@ -6094,7 +6162,7 @@ public:
 
             this.visible = false;
             style.hidden = true;
-    
+
             //created = true;
             // autoCreate = true;
             wasCreated = true;
@@ -6124,7 +6192,7 @@ public:
 
                      if(style.hasMenuBar /*&& menu*/)
                      {
-                        menuBar = 
+                        menuBar =
                            PopupMenu
                            {
                               this,
@@ -6136,7 +6204,7 @@ public:
 
                      if(statusBar)
                         statusBar.Create();
-                     
+
                      // Create the system buttons
                      CreateSystemChildren();
 
@@ -6206,6 +6274,8 @@ public:
 
                      parent.OnChildAddedOrRemoved(this, false);
 
+                     if(rootWindow == this && visible)   // So that X11 windows don't show as 'unknown'
+                        UpdateCaption();
                      // Real set state & activate for proper display & activation
                      property::visible = visible;
                      //  SetState(state & 0x00000003, true, 0);
@@ -6272,7 +6342,7 @@ public:
          {
             Window child;
             Box realBox;
-            
+
             // Testing this to avoid repetitve full update to take time...
             if(dirtyArea.count == 1)
             {
@@ -6297,7 +6367,7 @@ public:
                   return;
                }
             }
-            
+
             rootWindow.dirty = true;
 
             if(region != null)
@@ -6312,7 +6382,7 @@ public:
             else
                realBox = box;
 
-            if(realBox.right >= realBox.left && 
+            if(realBox.right >= realBox.left &&
                realBox.bottom >= realBox.top)
             {
                // if(!rootWindow.fullRender)
@@ -6361,7 +6431,7 @@ public:
                      childBox.top     -= window.absPosition.y - guiApp.desktop.absPosition.y;
                      childBox.right   -= window.absPosition.x - guiApp.desktop.absPosition.x;
                      childBox.bottom  -= window.absPosition.y - guiApp.desktop.absPosition.y;
-       
+
                      window.Update(childBox);
                   }
                   else
@@ -6446,7 +6516,7 @@ public:
       if(snapToStep)
       {
          int stepX = sbStep.x, stepY = sbStep.y;
-         // Needed to make snapped down position match the skin's check of client area 
+         // Needed to make snapped down position match the skin's check of client area
          // against realvirtual
          if(guiApp.textMode)
          {
@@ -6562,7 +6632,7 @@ public:
             // This has the effect of activating the window through the system...
             if(rootWindow == this)
                guiApp.interfaceDriver.SetRootWindowState(this, newState, !style.hidden);
-      
+
             SetStateEx(newState, activate);
 
             if(rootWindow == this && !rootWindow.nativeDecorations)
@@ -6593,15 +6663,15 @@ public:
                parent.UpdateScrollBars(true, true);
 
             /*
-            // Do we really need this stuff here? 
-            // Shouldn't the Activate stuff take care of it?              
+            // Do we really need this stuff here?
+            // Shouldn't the Activate stuff take care of it?
             if(parent.rootWindow == parent && style)
             {
                char caption[2048];
                parent.FigureCaption(caption);
                guiApp.interfaceDriver.SetRootWindowCaption(parent, caption);
                parent.UpdateDecorations();
-            }         
+            }
             */
 
             rootWindow.ConsequentialMouseMove(false);
@@ -6669,32 +6739,32 @@ public:
       PopupMenu windowMenu { master = this, interim = true, position = { x + 1 - guiApp.desktop.position.x, y + 1 - guiApp.desktop.position.y }, menu = menu };
       MenuItem
       {
-         menu, $"Restore", r, NotifySelect = MenuWindowRestore, 
+         menu, $"Restore", r, NotifySelect = MenuWindowRestore,
          disabled = (!style.hasMaximize && !style.hasMinimize) || state == normal, bitmap = guiApp.currentSkin.GetBitmap(restore)
       };
       MenuItem
       {
-         menu, $"Move", m, NotifySelect = MenuWindowMove, 
+         menu, $"Move", m, NotifySelect = MenuWindowMove,
          disabled = !style.fixed || state == maximized
       };
       MenuItem
       {
-         menu, $"Size", s, NotifySelect = MenuWindowSize, 
+         menu, $"Size", s, NotifySelect = MenuWindowSize,
          disabled = !style.sizable || state != normal
       };
       MenuItem
       {
-         menu, $"Minimize", n, NotifySelect = MenuWindowMinimize, 
+         menu, $"Minimize", n, NotifySelect = MenuWindowMinimize,
          disabled = !style.hasMinimize || state == minimized, bitmap = guiApp.currentSkin.GetBitmap(minimize)
       };
       MenuItem
       {
-         menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize, 
+         menu, $"Maximize", KeyCode::x, NotifySelect = MenuWindowMaximize,
          disabled = !style.hasMaximize || state == maximized, bitmap = guiApp.currentSkin.GetBitmap(maximize)
       };
       MenuItem
       {
-         menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop, 
+         menu, $"Stay On Top", t, NotifySelect = MenuWindowStayOnTop,
          disabled = !style.fixed, checkable = true, checked = style.stayOnTop
       };
       MenuDivider { menu };
@@ -6765,7 +6835,7 @@ public:
             }
          }
          /*
-         if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) && 
+         if(!clientOnly && child.cycle == (backward ? childrenCycle.first : childrenCycle.last) &&
             parent.tabCycle && parent.CycleChildren(backward, false, false))
             return true;
          */
@@ -6956,7 +7026,7 @@ public:
       }
    }
 
-   void SetText(char * format, ...)
+   private void _SetCaption(char * format, va_list args)
    {
       if(this)
       {
@@ -6964,21 +7034,34 @@ public:
          if(format)
          {
             char caption[MAX_F_STRING];
-            va_list args;
-            va_start(args, format);
             vsnprintf(caption, sizeof(caption), format, args);
             caption[sizeof(caption)-1] = 0;
-            va_end(args);
 
             this.caption = CopyString(caption);
          }
          if(created)
             UpdateCaption();
 
-         firewatchers text;
+         firewatchers caption;
       }
    }
 
+   /*deprecated*/ void SetText(char * format, ...)
+   {
+      va_list args;
+      va_start(args, format);
+      _SetCaption(format, args);
+      va_end(args);
+   }
+
+   void SetCaption(char * format, ...)
+   {
+      va_list args;
+      va_start(args, format);
+      _SetCaption(format, args);
+      va_end(args);
+   }
+
    bool Grab(Bitmap bitmap, Box box, bool decorations)
    {
       bool result = false;
@@ -7017,12 +7100,12 @@ public:
          {
             Window window { };
             window.Create();
-            result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top, 
+            result = window.display.displaySystem.driver.GrabScreen(null, bitmap, clip.left, clip.top,
                clip.right - clip.left + 1, clip.bottom - clip.top + 1);
             delete window;
          }
          else
-            result = display.Grab(bitmap, clip.left, clip.top, 
+            result = display.Grab(bitmap, clip.left, clip.top,
                clip.right - clip.left + 1, clip.bottom - clip.top + 1);
 
          if(bitmap.pixelFormat != pixelFormat888 && bitmap.pixelFormat != pixelFormat8)
@@ -7150,7 +7233,7 @@ public:
          return false;
       if(terminateX > 1)
          return true;
-         
+
       closing = true;
 
       if(!OnClose(parentClosing))
@@ -7300,7 +7383,7 @@ public:
                   MessageBox dialog { master = master.parent ? master : this, type = yesNoCancel, text = $"Error writing file", contents = $"Save as a different file?" };
                   DialogResult answer = dialog.Modal();
                   saving = false;
-                  if(answer != yes) 
+                  if(answer != yes)
                   {
                      result = answer;
                      break;
@@ -7509,7 +7592,7 @@ public:
       }
       document = cycle.data;
       document.Activate();
-      
+
       //if(activeChild.state == maximized)
       //  document.SetState(maximized, false, mods);
       //else if(document.state == minimized)
@@ -7721,7 +7804,7 @@ public:
    virtual void SetWindowArea(int * x, int * y, MinMaxValue * w, MinMaxValue * h, MinMaxValue * cw, MinMaxValue * ch)
    {
       *cw = *w;
-      *ch = *h;      
+      *ch = *h;
    }
    virtual void ShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
    virtual void PreShowDecorations(Font captionFont, Surface surface, char * name, bool active, bool moving);
@@ -7734,7 +7817,7 @@ public:
       return false;
    }
    virtual void UpdateNonClient();
-   virtual void SetBox(Box box);
+   virtual void SetBox(Box box);    // This is used in the MySkin skin
    virtual bool IsInside(int x, int y)
    {
       return box.IsPointInside({x, y});
@@ -7772,7 +7855,7 @@ public:
 
             if(!master || (master == this.parent && master == guiApp.desktop))
                property::master = value;
-            
+
             if(parent)
             {
                parent.children.Remove(this);
@@ -7828,12 +7911,12 @@ public:
                if(created)
                {
                   int x = position.x, y = position.y, w = size.w, h = size.h;
-                  
+
                   int vpw, vph;
 
                   x += parent.absPosition.x - value.absPosition.x + parent.clientStart.x - value.clientStart.x;
                   y += parent.absPosition.y - value.absPosition.y + parent.clientStart.y - value.clientStart.y;
-                  
+
                   vpw = value.clientSize.w;
                   vph = value.clientSize.h;
                   if(style.nonClient)
@@ -7881,10 +7964,12 @@ 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, 
+                     (parent.activeChild && parent.activeChild.order) ? parent.activeChild.order.prev : parent.childrenOrder.last,
                      order = OldLink { data = this });
                }
 
@@ -7896,7 +7981,7 @@ public:
                }
 
                // *** FONT INHERITANCE ***
-               if(!setFont && oldParent) 
+               if(!setFont && oldParent)
                   stopwatching(oldParent, font);
 
                if(systemFont)
@@ -7929,21 +8014,21 @@ public:
                         Update(null);
                      }
                   };
-               
+
                firewatchers font;
 
 
                if(value.rootWindow && value.rootWindow.display && rootWindow)
                {
-                  bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) || 
+                  bool reloadGraphics = (oldParent.rootWindow == oldParent && value.rootWindow) || (!value.rootWindow && rootWindow == this) ||
                         (value.rootWindow.display && value.rootWindow.display.displaySystem != rootWindow.display.displaySystem);
-                  
+
                   if(reloadGraphics)
                      UnloadGraphics(false);
                   SetupDisplay();
                   if(reloadGraphics)
                      LoadGraphics(false, false);
-                     
+
                   /*
                   if(value.rootWindow != rootWindow)
                      DisplayModeChanged();
@@ -8131,7 +8216,7 @@ public:
             CreateSystemChildren();
          }
       }
-      get { return (BorderStyle)style.borderBits; } 
+      get { return (BorderStyle)style.borderBits; }
    };
 
    property Size minClientSize
@@ -8208,7 +8293,7 @@ public:
       }
       get { return style.hasClose; }
    };
-   
+
    property bool nonClient
    {
       property_category $"Layout"
@@ -8226,7 +8311,7 @@ public:
       property_category $"Behavior"
       set
       {
-         if(value) 
+         if(value)
          {
             // *** NEW HERE: ***
             if(!style.inactive)
@@ -8255,7 +8340,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(
@@ -8309,7 +8396,7 @@ public:
       set { style.tabCycle = value; }
       get { return style.tabCycle; }
    };
-     
+
    property bool isDefault
    {
       property_category $"Behavior"
@@ -8351,7 +8438,7 @@ public:
       property_category $"Window Style"
       set
       {
-         if(value) 
+         if(value)
          {
             if(!menu)
             {
@@ -8361,13 +8448,13 @@ public:
             if(created && !menuBar)
             {
                menuBar =
-                  PopupMenu 
+                  PopupMenu
                   {
                      this, menu = menu,
                      isMenuBar = true,
                      anchor = Anchor { top = 23, left = 1, right = 1 },
                      size.h = 24,
-                     inactive = true, nonClient = true                            
+                     inactive = true, nonClient = true
                   };
                menuBar.Create();
             }
@@ -8434,14 +8521,14 @@ public:
                   if(order)
                   {
                      OldLink order;
-                     for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev; 
+                     for(order = (this.order == parent.childrenOrder.first) ? null : this.order.prev;
                          order && ((Window)order.data).style.stayOnTop;
                          order = (order == parent.childrenOrder.first) ? null : order.prev);
                       last = order ? order.data : null;
                   }
                   else
                   {
-                     for(last = parent.children.last; 
+                     for(last = parent.children.last;
                          last && last.style.stayOnTop;
                          last = last.prev);
                   }
@@ -8478,9 +8565,9 @@ public:
             if(!menuBar && style.hasMenuBar && value)
             {
                menuBar = PopupMenu
-                         { 
-                            this, menu = value, isMenuBar = true, 
-                            anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24, 
+                         {
+                            this, menu = value, isMenuBar = true,
+                            anchor = Anchor { left = 1, top = 23, right = 1 }, size.h = 24,
                             inactive = true, nonClient = true
                          };
                 menuBar.Create();
@@ -8553,7 +8640,7 @@ public:
       property_category $"Layout"
       isset
       {
-         return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) || 
+         return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
                 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
             sizeAnchor.isClientW != sizeAnchor.isClientH;
       }
@@ -8594,7 +8681,7 @@ public:
          bool leftRight = (anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none);
          bool topBottom = (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none);
          bool isClient = !sizeAnchor.isClientW && !sizeAnchor.isClientH;
-         return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) || 
+         return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
                 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
             !sizeAnchor.isClientW && !sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
       }
@@ -8626,7 +8713,7 @@ public:
       property_category $"Layout"
       isset
       {
-         return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) || 
+         return ((anchor.left.type == none || anchor.left.type == middleRelative || anchor.right.type == none) ||
                 (anchor.top.type == none || anchor.top.type == middleRelative || anchor.bottom.type == none)) &&
             sizeAnchor.isClientW && sizeAnchor.isClientH && sizeAnchor.size.w && sizeAnchor.size.h;
       }
@@ -8646,9 +8733,10 @@ public:
 
             ComputeAnchors(stateAnchor, stateSizeAnchor, &x, &y, &w, &h);
             Position(x,y, w, h, true, true, true, true, false, true);
+            if(parent && parent.created && !nonClient) parent.OnChildResized(this, x, y, w, h);
          }
       }
-      get { value = clientSize; }
+      get { value = this ? clientSize : { 0, 0 }; }
    };
 
    property Size initSize { get { value = sizeAnchor.size; } };
@@ -8674,7 +8762,7 @@ public:
             }
             anchor = value;
 
-            if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type)) 
+            if(anchor.right.type && (anchor.horz.type == middleRelative || !anchor.left.type))
             {
                anchor.left.distance = 0;
                anchor.horz.type = 0;
@@ -8692,7 +8780,7 @@ public:
                int x, y, w, h;
 
                normalAnchor = anchor;
-               
+
                // Break the anchors for moveable/resizable windows
                /*if(style.fixed ) //&& value.left.type == cascade)
                {
@@ -8871,7 +8959,7 @@ public:
                         {
                            tmpPrev = client.order.prev;
                         }
-                        else 
+                        else
                         {
                            if(client)
                               prevOrder = tmpPrev;
@@ -8911,7 +8999,7 @@ public:
                cycle = null;
                order = null;
                */
-               
+
                SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
             }
 
@@ -8943,7 +9031,7 @@ public:
                   if(!(style.noCycle))
                   {
                      cycle = parent.childrenCycle.AddAfter(
-                        (parent.activeChild && parent.activeChild.cycle) ? 
+                        (parent.activeChild && parent.activeChild.cycle) ?
                            parent.activeChild.cycle.prev : null, sizeof(OldLink));
                      cycle.data = this;
                   }
@@ -8953,7 +9041,7 @@ public:
                   order.data = this;
                }
                */
-     
+
                /*
                if(true || !parent.activeChild)
                   ActivateEx(true, false, true, true, null, null);
@@ -8961,7 +9049,7 @@ public:
                if(creationActivation == activate)
                   ActivateEx(true, false, true, true, null, null);
                else if(creationActivation == flash && !object)
-                  Flash();               
+                  Flash();
 
                //SetVisibility(!parent.style.hidden && (style.hidden ? false : true));
                Update(null);
@@ -8978,7 +9066,7 @@ public:
 
       get { return (style.hidden || !setVisible) ? false : true; }
    };
-    
+
    property bool isDocument
    {
       property_category $"Document"
@@ -9002,7 +9090,7 @@ public:
          {
             if(!style.hasHorzScroll && created)
             {
-               CreateSystemChildren();         
+               CreateSystemChildren();
                Position(position.x, position.y, size.w, size.h, false, true, false, false, false, true);
             }
          }
@@ -9100,7 +9188,7 @@ public:
    property Point scroll
    {
       property_category $"Behavior"
-      set { SetScrollPosition(value.x, value.y); }
+      set { if(this) SetScrollPosition(value.x, value.y); }
       get { value = scroll; }
    };
 
@@ -9201,7 +9289,7 @@ public:
          SelectMouseCursor();
       }
       get { return cursor; }
-   };      
+   };
 
 //#if !defined(ECERE_VANILLA)
    property char * name
@@ -9258,19 +9346,19 @@ public:
    };
 
    // Runtime Only Properties (No Set, can display the displayable ones depending on the type?)
-                                                                                                            
+
    // Will be merged with font later
    property Font fontObject { get { return usedFont ? usedFont.font : null; } };
    property Point clientStart { get { value = clientStart; } };
    property Point absPosition { get { value = absPosition; } };
-   property Anchor normalAnchor { get {value = normalAnchor; } };
+   property Anchor normalAnchor { get { value = normalAnchor; } };
    // property Size normalSizeAnchor { get { value = normalSizeAnchor; } };
    property bool active { get { return (bool)active; } };
    property bool created { get { return (bool)created; } };
    property bool destroyed { get { return (bool)destroyed; } };
    property Window firstSlave { get { return slaves.first ? ((OldLink)slaves.first).data : null; } };
-   property Window firstChild { get { return children.first; } };   
-   property Window lastChild { get { return children.last; } };   
+   property Window firstChild { get { return children.first; } };
+   property Window lastChild { get { return children.last; } };
    property Window activeClient { get { return activeClient; } };
    property Window activeChild { get { return activeChild; } };
    property Display display  { get { return display ? display : ((parent && parent.rootWindow) ? parent.rootWindow.display : null); } };
@@ -9278,7 +9366,7 @@ public:
    property ScrollBar horzScroll { get { return sbh; } };
    property ScrollBar vertScroll { get { return sbv; } };
    property StatusBar statusBar { get { return statusBar; } };
-   property Window rootWindow { get { return rootWindow; } };   
+   property Window rootWindow { get { return rootWindow; } };
    property bool closing { get { return (bool)closing; } set { closing = value; } };
    property int documentID { get { return documentID; } };
    property Window previous { get { return prev; } }
@@ -9290,7 +9378,7 @@ public:
    property bool fullRender { set { fullRender = value; } get { return (bool)fullRender; } }
    property void * systemHandle { get { return windowHandle; } }
    property Button minimizeButton { get { return sysButtons[0]; } };
-   property Button maximizeButton { get { return sysButtons[1]; } };   
+   property Button maximizeButton { get { return sysButtons[1]; } };
    property Button closeButton { get { return sysButtons[2]; } };
    property BitmapResource icon
    {
@@ -9396,7 +9484,7 @@ private:
    void * windowHandle;    // System window handle
 
    DialogResult returnCode;// Return code for modal windows
-  
+
    Point sbStep;           // Scrollbar line scrolling steps
 
    Anchor stateAnchor;
@@ -9498,7 +9586,8 @@ private:
       bool nativeDecorations:1;
       bool manageDisplay:1;
       bool formDesigner:1; // True if we this is running in the form editor
-   }; 
+      bool requireRemaximize:1;
+   };
 
    // Checks used internally for them not to take effect in FormDesigner
    property bool _isModal        { get { return !formDesigner ? style.modal : false; } }
@@ -9558,7 +9647,7 @@ public class Percentage : float
       c = strlen(string)-1;
       for( ; c >= 0; c--)
       {
-         if(string[c] != '0') 
+         if(string[c] != '0')
             last = Max(last, c);
          if(string[c] == '.')
          {
@@ -9588,7 +9677,7 @@ public void ApplySkin(Class c, char * name, void ** vTbl)
    c._vTbl = new void *[c.vTblSize];
    memcpy(c._vTbl, wc.pureVTbl, c.vTblSize * sizeof(void *));
    sc = eSystem_FindClass(c.module.application, className);
-   
+
    if(vTbl)
    {
       for(m = 0; m < c.base.vTblSize; m++)
@@ -9605,7 +9694,7 @@ public void ApplySkin(Class c, char * name, void ** vTbl)
             c._vTbl[m] = sc._vTbl[m];
       }
    }
-      
+
    for(d = c.derivatives.first; d; d = d.next)
    {
       ApplySkin(d.data, name, c._vTbl);
@@ -9858,7 +9947,7 @@ public:
    virtual void V::OnUnloadGraphics(WindowController controller);
 
 private:
-   int (** windowVTbl)();   
+   int (** windowVTbl)();
    V controlled;
    Window window;