Form autosize problem in Linux lazarus / 32-Linux ---------------------------------------------------------------------- artem101 · 2023-03-07 09:43 I have not-resizable form with auto sizing. Small example: Code: [Select]object Form1: TForm1   Left = 260   Height = 240   Top = 250   Width = 320   AutoSize = True   BorderStyle = bsSingle   Caption = 'Form1'   ChildSizing.Layout = cclLeftToRightThenTopToBottom   ChildSizing.ControlsPerLine = 1   ClientHeight = 240   ClientWidth = 320   LCLVersion = '2.2.4.0'   object Label1: TLabel     Left = 0     Height = 16     Top = 0     Width = 70     Caption = 'Label1'     ParentColor = False   end   object Button1: TButton     Left = 0     Height = 28     Top = 16     Width = 70     Caption = 'Long text'     OnClick = Button1Click     TabOrder = 0   end   object Button2: TButton     Left = 0     Height = 28     Top = 44     Width = 70     Caption = 'Short text'     OnClick = Button2Click     TabOrder = 1   end end Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    Button2: TButton;    Label1: TLabel;    procedure Button1Click(Sender: TObject);    procedure Button2Click(Sender: TObject);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);begin  Label1.Caption:='llklklk kljkljklj jkhklhklj hkhklh'+LineEnding+'jjhkjhj jbkjbj bkjbjk'  +LineEnding+'kkjkjkjk';end; procedure TForm1.Button2Click(Sender: TObject);begin  Label1.Caption:='text...';end; end.  On MS Windows this code works as expected, but on Linux window changes size only once and no more reaction to component resizing (see attached image). I checked this on Linux Mint 20.3 and Ubuntu 20.04.5. ---------------------------------------------------------------------- artem101 · 2023-03-08 12:15 It's possible to trigger form size recalculation by setting AutoSize to False and then back to True. But I think it`s not good solution, because I need to manually call this in every place of code where form size may be changed. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    Button2: TButton;    Label1: TLabel;    procedure Button1Click(Sender: TObject);    procedure Button2Click(Sender: TObject);  private    procedure UpdateAutoSize; // Should be manually called in every place where form size may be changed  public   end; var  Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);begin  Label1.Caption:='llklklk kljkljklj jkhklhklj hkhklh'+LineEnding+'jjhkjhj jbkjbj bkjbjk'  +LineEnding+'kkjkjkjk';   UpdateAutoSize;end; procedure TForm1.Button2Click(Sender: TObject);begin  Label1.Caption:='text...';   UpdateAutoSize;end; procedure TForm1.UpdateAutoSize;begin  // Not needed for Windows  {$IfDef Linux}  AutoSize := not AutoSize; // Turn off  AutoSize := not AutoSize; // Turn on again  {$EndIf}end; end.  Any ideas how to make it more correct? ---------------------------------------------------------------------- wp · 2023-03-08 14:26 Just tested on Linux Mint 20.2 and on macOS 10.14 (Mojave) and found no issue, the test application that you described worked flawlessly (even without UpdateAutoSize) (Laz/main + fpc 3.2.2, on Mint also Laz 2.0.0). Please post a full compilable project (.lpi, lpr, .lfm, .pas files - pack them into a shared zip which you can upload diretly via "Attachments and other options"); maybe the issue is in some other setting. ---------------------------------------------------------------------- artem101 · 2023-03-08 16:51 Quote from: wp on March 08, 2023, 03:26:44 pmPlease post a full compilable project (.lpi, lpr, .lfm, .pas files - pack them into a shared zip which you can upload diretly via "Attachments and other options"); maybe the issue is in some other setting. Already attached to the first post. I use latest Lazarus 2.2.4 and FPC 3.2.2. Just tested my first code in latest Linux Mint 21.1 with XFCE. The problem is reproduced. ---------------------------------------------------------------------- wp · 2023-03-08 18:18 Sorry, I was distracted by the screenshot... You demo seems to be exactly like mine, except for the BorderStyle (I had it at bsSizeable), different "words" in the long caption and having the label's WordWrap=true. I could reproduce the issue on Linux Mint now (this was not possible with my demo). Switching BorderStyle to bsSizeable or bsNone or bsSizeToolWin, however, made your application work correctly, it does not work correctly for BorderStyle = bsSingle, bsDialog and bsToolWin. Then returned to Windows and saw another issue here. At first: the form did not shrink to tightly enclose the label and the buttons (Width = 130), and after clicking on the "Long text" button it grew somehow but truncated all controls, the "Short text" button was below the bottom form border. Trying to resize the form at designtime I noticed that this is not possible... Had the idea to restrict the width of the buttons and specified Button1.Constraints.minWidth := 130 - the issue is gone (any larger value can be used, 129 makes the issue return again). Quite mystical. No idea where that magic number 130 comes from, maybe related to the minimum form width of 120 px in windows (which exists also in Delphi)... ---------------------------------------------------------------------- artem101 · 2023-03-11 12:20 Quote from: wp on March 08, 2023, 07:18:15 pmThen returned to Windows and saw another issue here.. This is not what I interested in. I make another more real demo. It has no problem in Windows, in Linus problem still the same ---------------------------------------------------------------------- zeljko · 2023-03-12 09:15 This works perfect under linux, but with qt,qt5 or qt6 ws. ---------------------------------------------------------------------- artem101 · 2023-03-12 15:17 Quote from: zeljko on March 12, 2023, 10:15:33 amThis works perfect under linux, but with qt,qt5 or qt6 ws. But what about GTK? ---------------------------------------------------------------------- balazsszekely · 2023-03-12 16:14 @artem101 Try this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.CheckBox1Change(Sender: TObject);begin  CheckGroup2.Visible:=CheckBox1.Checked;  {$ifdef LCLGTK2}  Self.AutoSize := False;  Self.AutoSize := True;  {$endif}end;