View Issue Details

IDProjectCategoryView StatusLast Update
0031950LazarusWidgetsetpublic2017-06-08 16:51
ReporterCudaText man Assigned ToZeljan Rikalo  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformUbuntu 16.4 
Product Version1.9 (SVN) 
Summary0031950: Gtk2: Form with constraints cannot resize
DescriptionOn Gtk2 form cannot resize by user.
On Win32 it can.
It has Constraints set, like my real app has.
  Constraints.MinHeight = 300
  Constraints.MaxHeight = 300
  Constraints.MaxWidth = 500
TagsNo tags attached.
Fixed in Revision55184
LazTarget-
WidgetsetGTK 2
Attached Files

Relationships

related to 0031826 closedZeljan Rikalo Main window cannot be resized 

Activities

CudaText man

2017-06-01 21:53

reporter  

tst-cannot-resize.zip (3,338 bytes)

Zeljan Rikalo

2017-06-01 22:34

developer  

gtk2_issue31950.diff (1,260 bytes)   
Index: lcl/interfaces/gtk2/gtk2wscontrols.pp
===================================================================
--- lcl/interfaces/gtk2/gtk2wscontrols.pp	(revision 55131)
+++ lcl/interfaces/gtk2/gtk2wscontrols.pp	(working copy)
@@ -691,19 +691,23 @@
       if not AFixedWidthHeight and (AForm.Constraints.MinWidth > 0) then
         min_width := AForm.Constraints.MinWidth
       else
+      if AFixedWidthHeight then
         min_width := AForm.Width;
       if not AFixedWidthHeight and (AForm.Constraints.MaxWidth > 0) then
         max_width := AForm.Constraints.MaxWidth
       else
-      max_width := AForm.Width;
+      if AFixedWidthHeight then
+        max_width := AForm.Width;
       if not AFixedWidthHeight and (AForm.Constraints.MinHeight > 0) then
         min_height := AForm.Constraints.MinHeight
       else
-        min_height := AForm.Height;
+        if AFixedWidthHeight then
+          min_height := AForm.Height;
       if not AFixedWidthHeight and (AForm.Constraints.MaxHeight > 0) then
         max_height := AForm.Constraints.MaxHeight
       else
-        max_height := AForm.Height;
+        if AFixedWidthHeight then
+          max_height := AForm.Height;
 
       base_width := AForm.Width;
       base_height := AForm.Height;
gtk2_issue31950.diff (1,260 bytes)   

Zeljan Rikalo

2017-06-01 22:34

developer   ~0100782

Please test with attached diff and give feedback.

CudaText man

2017-06-01 23:23

reporter   ~0100783

Will see it.
Found this bad place-

gtk2proc.inc
  // X warns if marking a fixed size window resizeable:
  if ((AForm.Constraints.MinWidth>0)
  and (AForm.Constraints.MinWidth=AForm.Constraints.MaxWidth))
  or ((AForm.Constraints.MinHeight>0)
  and (AForm.Constraints.MinHeight=AForm.Constraints.MaxHeight)) then
    Result:=Result-GDK_FUNC_RESIZE;

here resize flag turned off.

CudaText man

2017-06-01 23:37

reporter  

resize-fix.diff (584 bytes)   
Index: lcl/interfaces/gtk2/gtk2proc.inc
===================================================================
--- lcl/interfaces/gtk2/gtk2proc.inc	(revision 55146)
+++ lcl/interfaces/gtk2/gtk2proc.inc	(working copy)
@@ -9387,7 +9387,7 @@
   // X warns if marking a fixed size window resizeable:
   if ((AForm.Constraints.MinWidth>0)
   and (AForm.Constraints.MinWidth=AForm.Constraints.MaxWidth))
-  or ((AForm.Constraints.MinHeight>0)
+  and ((AForm.Constraints.MinHeight>0)
   and (AForm.Constraints.MinHeight=AForm.Constraints.MaxHeight)) then
     Result:=Result-GDK_FUNC_RESIZE;
 
resize-fix.diff (584 bytes)   

CudaText man

2017-06-01 23:39

reporter   ~0100784

your diff makes IDE not starting.

My fix posted. It changes "or" to "and"; so if BOTH W+H are fixed, then no resize, but if only ONE of W/H is fixed, resize is on.

Zeljan Rikalo

2017-06-02 17:29

developer   ~0100799

I'll check your patch

Zeljan Rikalo

2017-06-02 22:24

developer  

gtk2_issue31950_2.diff (1,844 bytes)   
Index: lcl/interfaces/gtk2/gtk2proc.inc
===================================================================
--- lcl/interfaces/gtk2/gtk2proc.inc	(revision 55166)
+++ lcl/interfaces/gtk2/gtk2proc.inc	(working copy)
@@ -9387,7 +9387,7 @@
   // X warns if marking a fixed size window resizeable:
   if ((AForm.Constraints.MinWidth>0)
   and (AForm.Constraints.MinWidth=AForm.Constraints.MaxWidth))
-  or ((AForm.Constraints.MinHeight>0)
+  and ((AForm.Constraints.MinHeight>0)
   and (AForm.Constraints.MinHeight=AForm.Constraints.MaxHeight)) then
     Result:=Result-GDK_FUNC_RESIZE;
 
Index: lcl/interfaces/gtk2/gtk2wscontrols.pp
===================================================================
--- lcl/interfaces/gtk2/gtk2wscontrols.pp	(revision 55166)
+++ lcl/interfaces/gtk2/gtk2wscontrols.pp	(working copy)
@@ -691,19 +691,23 @@
       if not AFixedWidthHeight and (AForm.Constraints.MinWidth > 0) then
         min_width := AForm.Constraints.MinWidth
       else
+      if AFixedWidthHeight then
         min_width := AForm.Width;
       if not AFixedWidthHeight and (AForm.Constraints.MaxWidth > 0) then
         max_width := AForm.Constraints.MaxWidth
       else
-      max_width := AForm.Width;
+      if AFixedWidthHeight then
+        max_width := AForm.Width;
       if not AFixedWidthHeight and (AForm.Constraints.MinHeight > 0) then
         min_height := AForm.Constraints.MinHeight
       else
-        min_height := AForm.Height;
+        if AFixedWidthHeight then
+          min_height := AForm.Height;
       if not AFixedWidthHeight and (AForm.Constraints.MaxHeight > 0) then
         max_height := AForm.Constraints.MaxHeight
       else
-        max_height := AForm.Height;
+        if AFixedWidthHeight then
+          max_height := AForm.Height;
 
       base_width := AForm.Width;
       base_height := AForm.Height;
gtk2_issue31950_2.diff (1,844 bytes)   

Zeljan Rikalo

2017-06-02 22:25

developer   ~0100807

Please check with gtk2_issue31950_2.diff. I've merged both patches into one.

CudaText man

2017-06-02 22:48

reporter   ~0100809

Checked it: Ubuntu 16.4. IDE dont start with patch, Logo window shows and IDE exits.

Zeljan Rikalo

2017-06-03 12:58

developer   ~0100826

hm..here is Fedora 24 64bit under KDE Plasma, gtk2 ide works fine, so could be something related to window manager. Besides that your patch fixes exactly nothing under my environment, but complete patch makes things work ok. I'll check if I have somewhere around ubuntu in virtual machine.

Zeljan Rikalo

2017-06-03 13:02

developer   ~0100827

Please send gtk2int (Gtk2Widgetset.GetWindowManager) output in terminal.

Zeljan Rikalo

2017-06-03 15:07

developer  

gtk2_size_diff.diff (3,220 bytes)   
Index: lcl/interfaces/gtk2/gtk2proc.inc
===================================================================
--- lcl/interfaces/gtk2/gtk2proc.inc	(revision 55182)
+++ lcl/interfaces/gtk2/gtk2proc.inc	(working copy)
@@ -9387,7 +9393,7 @@
   // X warns if marking a fixed size window resizeable:
   if ((AForm.Constraints.MinWidth>0)
   and (AForm.Constraints.MinWidth=AForm.Constraints.MaxWidth))
-  or ((AForm.Constraints.MinHeight>0)
+  and ((AForm.Constraints.MinHeight>0)
   and (AForm.Constraints.MinHeight=AForm.Constraints.MaxHeight)) then
     Result:=Result-GDK_FUNC_RESIZE;
 
Index: lcl/interfaces/gtk2/gtk2wscontrols.pp
===================================================================
--- lcl/interfaces/gtk2/gtk2wscontrols.pp	(revision 55182)
+++ lcl/interfaces/gtk2/gtk2wscontrols.pp	(working copy)
@@ -670,7 +670,6 @@
 begin
   if not WSCheckHandleAllocated(AWinControl, 'SetBounds')
   then Exit;
-
   ResizeHandle(AWinControl);
   InvalidateLastWFPResult(AWinControl, Rect(ALeft, ATop, AWidth, AHeight));
   if not AWinControl.Visible then // Gtk2WSForms.ShowHide will correct visibility
@@ -686,25 +685,35 @@
     // as expected for some reason.issue #20741.
     // Constraints fix issue #29563
     AFixedWidthHeight := AForm.BorderStyle in [bsDialog, bsSingle, bsToolWindow];
+    FillChar(Geometry, SizeOf(TGdkGeometry), 0);
     with Geometry do
     begin
       if not AFixedWidthHeight and (AForm.Constraints.MinWidth > 0) then
         min_width := AForm.Constraints.MinWidth
       else
+      if AFixedWidthHeight then
         min_width := AForm.Width;
       if not AFixedWidthHeight and (AForm.Constraints.MaxWidth > 0) then
         max_width := AForm.Constraints.MaxWidth
       else
-      max_width := AForm.Width;
+      if AFixedWidthHeight then
+        max_width := AForm.Width;
       if not AFixedWidthHeight and (AForm.Constraints.MinHeight > 0) then
         min_height := AForm.Constraints.MinHeight
       else
-        min_height := AForm.Height;
+        if AFixedWidthHeight then
+          min_height := AForm.Height;
       if not AFixedWidthHeight and (AForm.Constraints.MaxHeight > 0) then
         max_height := AForm.Constraints.MaxHeight
       else
-        max_height := AForm.Height;
+        if AFixedWidthHeight then
+          max_height := AForm.Height;
 
+      if AForm.Constraints.MaxHeight = 0 then
+        max_height := 32767;
+      if AForm.Constraints.MaxWidth = 0 then
+        max_width := 32767;
+
       base_width := AForm.Width;
       base_height := AForm.Height;
       width_inc := 1;
@@ -713,7 +722,8 @@
       max_aspect := 1;
       win_gravity := gtk_window_get_gravity({%H-}PGtkWindow(AForm.Handle));
     end;
-    //debugln('TGtk2WSWinControl.ConstraintsChange A ',GetWidgetDebugReport(Widget),' max=',dbgs(Geometry.max_width),'x',dbgs(Geometry.max_height));
+    //debugln('TGtk2WSWinControl.SetBounds A maxw=',dbgs(Geometry.max_width),' maxh=',dbgs(Geometry.max_height),
+    //' base w=',dbgs(Geometry.base_width),' h=',dbgs(Geometry.base_height));
     if AFixedWidthHeight then
       gtk_window_set_geometry_hints({%H-}PGtkWindow(AForm.Handle), nil, @Geometry,
         GDK_HINT_POS or GDK_HINT_MIN_SIZE or GDK_HINT_MAX_SIZE)
gtk2_size_diff.diff (3,220 bytes)   

Zeljan Rikalo

2017-06-03 15:08

developer   ~0100831

Please test with gtk2_size_diff.diff. Just tested under Ubuntu 16.04 and everything works fine here.

CudaText man

2017-06-03 16:04

reporter   ~0100835

It works, fixed.

Zeljan Rikalo

2017-06-03 16:23

developer   ~0100836

Please test and close if ok.

Issue History

Date Modified Username Field Change
2017-06-01 21:52 CudaText man New Issue
2017-06-01 21:53 CudaText man File Added: tst-cannot-resize.zip
2017-06-01 22:34 Zeljan Rikalo File Added: gtk2_issue31950.diff
2017-06-01 22:34 Zeljan Rikalo LazTarget => -
2017-06-01 22:34 Zeljan Rikalo Note Added: 0100782
2017-06-01 22:34 Zeljan Rikalo Assigned To => Zeljan Rikalo
2017-06-01 22:34 Zeljan Rikalo Status new => feedback
2017-06-01 23:23 CudaText man Note Added: 0100783
2017-06-01 23:23 CudaText man Status feedback => assigned
2017-06-01 23:37 CudaText man File Added: resize-fix.diff
2017-06-01 23:39 CudaText man Note Added: 0100784
2017-06-02 17:29 Zeljan Rikalo Note Added: 0100799
2017-06-02 22:24 Zeljan Rikalo File Added: gtk2_issue31950_2.diff
2017-06-02 22:25 Zeljan Rikalo Note Added: 0100807
2017-06-02 22:25 Zeljan Rikalo Status assigned => feedback
2017-06-02 22:48 CudaText man Note Added: 0100809
2017-06-02 22:48 CudaText man Status feedback => assigned
2017-06-03 12:58 Zeljan Rikalo Note Added: 0100826
2017-06-03 12:58 Zeljan Rikalo Status assigned => feedback
2017-06-03 13:02 Zeljan Rikalo Note Added: 0100827
2017-06-03 15:07 Zeljan Rikalo File Added: gtk2_size_diff.diff
2017-06-03 15:08 Zeljan Rikalo Note Added: 0100831
2017-06-03 15:08 Zeljan Rikalo Status feedback => confirmed
2017-06-03 16:04 CudaText man Note Added: 0100835
2017-06-03 16:23 Zeljan Rikalo Fixed in Revision => 55184
2017-06-03 16:23 Zeljan Rikalo Note Added: 0100836
2017-06-03 16:23 Zeljan Rikalo Status confirmed => resolved
2017-06-03 16:23 Zeljan Rikalo Resolution open => fixed
2017-06-08 16:51 Zeljan Rikalo Relationship added related to 0031826