FLTK logo

Re: [MOD] STR #3352: Linux: Tiny window problem if child group larger than window

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.bugs  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: [MOD] STR #3352: Linux: Tiny window problem if child group larger than window Albrecht Schlosser Dec 05, 2021  
 
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR Pending]

Link: https://www.fltk.org/str.php?L3352
Version: 1.3.4


+1 on fix_str_3352_v2_fltk-1.4.x.patch

I agree with Greg (and this patch version and Matt in comment #10) that
setting an arbitrary minimum value for the window size is something we
shouldn't do. OTOH, if the WM forces a certain minimum size this would be
OK.

I'm uploading 0001-Fix-Tiny-window-problem-.-STR-3352.patch which is the
same as the above mentioned patch adjusted to Git current (1.4.0).

Note: Tested with 'winsize-problem.cxx' and different group and window
sizes on Linux only. It would be interesting what happens on macOS and
Windows if the window size is set to (w=2, h=2), for instance.

Greg, please feel free to use this patch and commit yourself, since it's
your work. Otherwise I can merge my branch with *my* commit message, see
https://github.com/Albrecht-S/fltk/tree/str-3352_v2 and
https://github.com/Albrecht-S/fltk/commit/0f15df24eca6d81eee7544501b3b8633c57644cc
(the patch).

It's your choice...

PS: note to readers: the GitHub links will go stale after a while once the
branch is deleted.


Link: https://www.fltk.org/str.php?L3352
Version: 1.3.4
From 0f15df24eca6d81eee7544501b3b8633c57644cc Mon Sep 17 00:00:00 2001
From: Albrecht Schlosser <albrechts.fltk@online.de>
Date: Sun, 5 Dec 2021 20:05:07 +0100
Subject: [PATCH] Fix "Tiny window problem ..." (STR 3352)

... if child group larger than window
(https://www.fltk.org/str.php?L3352)

Applied fix_str_3352_v2_fltk-1.4.x.patch and rebased.
---
 src/Fl_cocoa.mm  |  8 +++++---
 src/Fl_win32.cxx | 14 ++++++--------
 src/Fl_x.cxx     |  8 +++++---
 3 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm
index e15115026..5cf74ea3e 100644
--- a/src/Fl_cocoa.mm
+++ b/src/Fl_cocoa.mm
@@ -2954,9 +2954,11 @@ Fl_X* Fl_Cocoa_Window_Driver::makeWindow()
   } else {
     if (w->resizable()) {
       Fl_Widget *o = w->resizable();
-      int minw = o->w(); if (minw > 100) minw = 100;
-      int minh = o->h(); if (minh > 100) minh = 100;
-      w->size_range(w->w() - o->w() + minw, w->h() - o->h() + minh, 0, 0);
+      int minw = w->w();                     // minw is window's initial width
+      int minh = w->h();                     // minh is window's initial height
+      int maxw = (o->w() == 0) ? minw : 0;   // if resizable w()==0, disable resize w()
+      int maxh = (o->h() == 0) ? minh : 0;   // if resizable h()==0, disable resize h()
+      w->size_range(minw, minh, maxw, maxh);
       if (w->border()) winstyle |= NSResizableWindowMask;
     } else {
       w->size_range(w->w(), w->h(), w->w(), w->h());
diff --git a/src/Fl_win32.cxx b/src/Fl_win32.cxx
index 9abbb5d58..0418dcc56 100644
--- a/src/Fl_win32.cxx
+++ b/src/Fl_win32.cxx
@@ -2069,14 +2069,12 @@ Fl_X *Fl_WinAPI_Window_Driver::makeWindow() {
   } else {
     if (!size_range_set()) {
       if (w->resizable()) {
-        Fl_Widget *o = w->resizable();
-        int minw = o->w();
-        if (minw > 100)
-          minw = 100;
-        int minh = o->h();
-        if (minh > 100)
-          minh = 100;
-        w->size_range(w->w() - o->w() + minw, w->h() - o->h() + minh, 0, 0);
+	Fl_Widget *o = w->resizable();
+	int minw = w->w();                     // minw is window's initial width
+	int minh = w->h();                     // minh is window's initial height
+	int maxw = (o->w() == 0) ? minw : 0;   // if resizable w()==0, disable resize w()
+	int maxh = (o->h() == 0) ? minh : 0;   // if resizable h()==0, disable resize h()
+	w->size_range(minw, minh, maxw, maxh);
       } else {
         w->size_range(w->w(), w->h(), w->w(), w->h());
       }
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx
index a57316207..55c249ecd 100644
--- a/src/Fl_x.cxx
+++ b/src/Fl_x.cxx
@@ -2791,9 +2791,11 @@ void Fl_X11_Window_Driver::sendxjunk() {
   if (!size_range_set()) { // default size_range based on resizable():
     if (w->resizable()) {
       Fl_Widget *o = w->resizable();
-      int minw = o->w(); if (minw > 100) minw = 100;
-      int minh = o->h(); if (minh > 100) minh = 100;
-      w->size_range(w->w() - o->w() + minw, w->h() - o->h() + minh, 0, 0);
+      int minw = w->w();                     // minw is window's initial width
+      int minh = w->h();                     // minh is window's initial height
+      int maxw = (o->w() == 0) ? minw : 0;   // if resizable w()==0, disable resize w()
+      int maxh = (o->h() == 0) ? minh : 0;   // if resizable h()==0, disable resize h()
+      w->size_range(minw, minh, maxw, maxh);
     } else {
       w->size_range(w->w(), w->h(), w->w(), w->h());
     }
-- 
2.25.1

Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.