ecere/gui/drivers/XInterface: Always setting minimum width/height; Fixed jumping...
authorJerome St-Louis <jerome@ecere.com>
Sun, 9 Feb 2014 00:42:02 +0000 (07:42 +0700)
committerJerome St-Louis <jerome@ecere.com>
Sun, 9 Feb 2014 03:58:06 +0000 (10:58 +0700)
ecere/src/gui/dialogs/MessageBox.ec
ecere/src/gui/drivers/XInterface.ec

index 2193736..3b7ffde 100644 (file)
@@ -127,6 +127,8 @@ private:
 
    bool OnResizing(int *w, int *h)
    {
+      if(!totalHeight)
+         OnLoadGraphics();
       if(style == yesNoCancel)
          *w = Max(*w, Max(totalWidth, 208) + 24);
       else
@@ -150,6 +152,12 @@ private:
    bool OnLoadGraphics()
    {
       MsgLine line;
+      // This is to set minimum client size on X11
+      // Ideally OnLoadGraphics/OnResizing could be called prior to root window creation...
+      Display display = this.display;
+      Font fontObject = this.fontObject;
+      if(!display) display = master.display;
+      if(!fontObject) fontObject = master.fontObject;
 
       totalHeight = 0;
       for(line = lines.first; line; line = line.next)
index ca9fae2..383a591 100644 (file)
@@ -2408,6 +2408,18 @@ class XInterface : Interface
             int x = window.position.x + desktopX, y = window.position.y + desktopY;
             int w = window.state == normal ? Max(1, window.size.w) : Max(1, window.normalSizeAnchor.size.w);
             int h = window.state == normal ? Max(1, window.size.h) : Max(1, window.normalSizeAnchor.size.h);
+            MinMaxValue smw = 0, smh = 0;
+            MinMaxValue minW = window.minSize.w, minH = window.minSize.h;
+            window.OnResizing((int *)&minW, (int *)&minH);
+
+            // To fix jumping message boxes on Cinnamon:
+            if(window.state == normal && (minW > window.minSize.w || minH > window.minSize.w))
+               window.ComputeAnchors(window.normalAnchor, window.normalSizeAnchor, &x, &y, &w, &h);
+
+            window.SetWindowMinimum(&smw, &smh);
+            minW = Max(minW, smw);
+            minH = Max(minH, smh);
+
             if(!window.nativeDecorations && window.state != normal)
             {
                w += window.size.w - window.clientSize.w;
@@ -2467,17 +2479,13 @@ class XInterface : Interface
                }
 
                // Set Normal hints for minimum/maximum size
-               if(true) //window.minSize.w || window.minSize.h || window.maxSize.w < MAXINT || window.maxSize.h < MAXINT)
+               if(true)
                {
                   XSizeHints hints = { 0 };
-                  MinMaxValue mw, mh;
-                  window.SetWindowMinimum(&mw, &mh);
-                  if(window.minSize.w || window.minSize.h)
-                  {
-                     hints.min_width = Max(window.minSize.w, mw);
-                     hints.min_height = Max(window.minSize.h, mh);
-                     hints.flags |= PMinSize;
-                  }
+                  hints.min_width = minW;
+                  hints.min_height = minH;
+                  hints.flags |= PMinSize;
+
                   if(window.maxSize.w < MAXINT || window.minSize.h < MAXINT)
                   {
                      hints.max_width = window.maxSize.w;