From dbca4a9ec7d128611dd2f9ccb5a5b39ae692e927 Mon Sep 17 00:00:00 2001
From: Christophe Geuzaine <cgeuzaine@ulg.ac.be>
Date: Mon, 9 Feb 2009 19:24:13 +0000
Subject: [PATCH] fix resize problem on Mac (when the size of the graphic
 window was set in a script, and when this size was different than the current
 size, it was impossible to make the window larger)

---
 Common/Options.cpp     | 20 ++++++++++++++------
 Fltk/graphicWindow.cpp |  5 +++++
 Fltk/graphicWindow.h   |  1 +
 3 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/Common/Options.cpp b/Common/Options.cpp
index 6ffae185a7..9767388922 100644
--- a/Common/Options.cpp
+++ b/Common/Options.cpp
@@ -2386,10 +2386,14 @@ double opt_general_graphics_size0(OPT_ARGS_NUM)
     CTX::instance()->glSize[0] = (int)val;
 #if defined(HAVE_FLTK)
   if(GUI::available()){
-    if(action & GMSH_SET)
+    if(action & GMSH_SET){
       GUI::instance()->graph[0]->win->size
-        (CTX::instance()->glSize[0], GUI::instance()->graph[0]->bottom->h() + 
-         CTX::instance()->glSize[1]);
+        (CTX::instance()->glSize[0],
+         GUI::instance()->graph[0]->win->h());
+      // workaround resizing bug on Mac
+      GUI::instance()->graph[0]->win->size_range
+        (GUI::instance()->graph[0]->minWidth, GUI::instance()->graph[0]->minHeight);
+    }
   }
 #endif
   return CTX::instance()->glSize[0];
@@ -2401,10 +2405,14 @@ double opt_general_graphics_size1(OPT_ARGS_NUM)
     CTX::instance()->glSize[1] = (int)val;
 #if defined(HAVE_FLTK)
   if(GUI::available()){
-    if(action & GMSH_SET)
+    if(action & GMSH_SET){
       GUI::instance()->graph[0]->win->size
-        (CTX::instance()->glSize[0], GUI::instance()->graph[0]->bottom->h() + 
-         CTX::instance()->glSize[1]);
+        (GUI::instance()->graph[0]->win->w(),
+         GUI::instance()->graph[0]->bottom->h() + CTX::instance()->glSize[1]);
+      // workaround resizing bug on Mac
+      GUI::instance()->graph[0]->win->size_range
+        (GUI::instance()->graph[0]->minWidth, GUI::instance()->graph[0]->minHeight);
+    }
   }
 #endif
   return CTX::instance()->glSize[1];
diff --git a/Fltk/graphicWindow.cpp b/Fltk/graphicWindow.cpp
index 0e04f9f535..b133724f4e 100644
--- a/Fltk/graphicWindow.cpp
+++ b/Fltk/graphicWindow.cpp
@@ -416,6 +416,11 @@ graphicWindow::graphicWindow(bool main, int numTiles)
   dummyBox *resbox = new dummyBox(x, 0, width - x, glheight);
   win->resizable(resbox);
 
+  // set mininum window size
+  minWidth = x;
+  minHeight = 100;
+  win->size_range(minWidth, minHeight);
+
   // tiled opengl windows
   tile = new Fl_Tile(0, 0, width, glheight);
 
diff --git a/Fltk/graphicWindow.h b/Fltk/graphicWindow.h
index 3747c98514..bcd71e47c3 100644
--- a/Fltk/graphicWindow.h
+++ b/Fltk/graphicWindow.h
@@ -24,6 +24,7 @@ class graphicWindow{
   Fl_Box *bottom;
   Fl_Button *butt[12];
   Fl_Box *label[2];
+  int minWidth, minHeight;
  public:
   graphicWindow(bool main=true, int numTiles=1);
   ~graphicWindow();
-- 
GitLab