ecere/gui/drivers/XInterface: Fixes to avoid window with broken anchor to jump around...
authorJerome St-Louis <jerome@ecere.com>
Sun, 9 Feb 2014 00:33:15 +0000 (07:33 +0700)
committerJerome St-Louis <jerome@ecere.com>
Sun, 9 Feb 2014 03:57:58 +0000 (10:57 +0700)
ecere/src/gui/drivers/XInterface.ec

index fbaa1e2..ca9fae2 100644 (file)
@@ -1999,13 +1999,14 @@ class XInterface : Interface
                      }
                   }
                   {
+                     bool offset = false;
                      int x, y, w, h;
                      if(unmaximized)
                      {
-                        // Ensure we set the normal size anchor when un-maximizing
                         if(window.nativeDecorations && RequestFrameExtents(window))
                            WaitForFrameExtents(window);
-                        x = window.position.x, y = window.position.y, w = window.size.w, h = window.size.h;
+
+                        // Ensure we set the normal size anchor when un-maximizing
                         window.ComputeAnchors(window.normalAnchor, window.normalSizeAnchor, &x, &y, &w, &h);
                      }
                      else
@@ -2021,8 +2022,12 @@ class XInterface : Interface
                            XTranslateCoordinates(xGlobalDisplay, event->window,
                               RootWindow(xGlobalDisplay, DefaultScreen(xGlobalDisplay)), 0, 0,
                               &rootX, &rootY, &rootChild);
-                           x = rootX;
-                           y = rootY;
+                           if(x != rootX || y != rootY)
+                           {
+                              x = rootX;
+                              y = rootY;
+                              offset = true;
+                           }
                         }
 
                         x -= desktopX;
@@ -2034,6 +2039,7 @@ class XInterface : Interface
                            y -= windowData.decor.top;
                            w += windowData.decor.left + windowData.decor.right;
                            h += windowData.decor.top + windowData.decor.bottom;
+
                            /*
                            x -= window.clientStart.x;
                            y -= window.clientStart.y - (window.hasMenuBar ? skinMenuHeight : 0);
@@ -2043,23 +2049,20 @@ class XInterface : Interface
                         }
                      }
 
-                     // Break the anchors for moveable/resizable windows
-                     if(window.style.fixed && window.state == normal)
-                     {
-                        window.normalAnchor = Anchor { left = x, top = y };
-                        window.normalSizeAnchor = SizeAnchor { { w, h } };
-                        window.anchored = false;
-                     }
+                     window.Position(x, y, w, h, true, true, true, true, false, unmaximized);
 
                      // Break the anchors for moveable/resizable windows
-                     if(window.style.fixed && window.state == normal)
+                     // Avoid doing this if the translation wasn't in sync as it will cause the window to move around
+                     if(!unmaximized && !offset && window.style.fixed && window.state == normal)
                      {
-                        window.normalAnchor = Anchor { left = x, top = y };
-                        window.normalSizeAnchor = SizeAnchor { { w, h } };
-                        window.anchored = false;
+                        window.normalAnchor = Anchor
+                        {
+                           left = x + windowData.decor.left,
+                           top = y + windowData.decor.top
+                        };
+                        window.normalSizeAnchor =
+                           SizeAnchor { { window.clientSize.w, window.clientSize.h }, isClientW = true, isClientH = true };
                      }
-
-                     window.Position(x, y, w, h, true, true, true, true, false, unmaximized);
                   }
                   break;
                }