View Issue Details

IDProjectCategoryView StatusLast Update
0038710LazarusWidgetsetpublic2021-05-13 10:49
ReporterCudaText man Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionopen 
OSUbuntu 20.04 
Product Version2.1 (SVN) 
Summary0038710: gtk3: InputBox() has problems
Descriptiondemo added.
My PC has 2 monitors, Laz IDE and main demo form open on right monitor.

- InputBox form is opened on another (left) monitor
- InputBox has too tall buttons ok/cancel (about 2x taller than in gtk2)
- first clicks on OK/Cancel buttons are IGNORED, only 2nd click works

feel free to split my report to 3 reports.

TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetGTK 3
Attached Files

Activities

CudaText man

2021-04-06 10:46

reporter  

tst-gtk3-inputbox.zip (3,539 bytes)

Anton Kavalenka

2021-04-10 14:19

reporter   ~0130231

Step by step.
Implemented TGtk3WIdgetset.MonitorFromWindow. This should bring the InputBox on the nearest monitor. Please test
gtk3monitor.diff (1,314 bytes)   
Index: lcl/interfaces/gtk3/gtk3winapi.inc
===================================================================
--- lcl/interfaces/gtk3/gtk3winapi.inc	(revision 64949)
+++ lcl/interfaces/gtk3/gtk3winapi.inc	(working copy)
@@ -2938,6 +2938,16 @@
   Result:=HMONITOR(nmon+1);
 end;
 
+function TGtk3WidgetSet.MonitorFromWindow(hWnd: HWND; dwFlags: DWord): HMONITOR;
+var
+  pscr:PGdkScreen;
+  nmon:gint;
+begin
+  pscr:=TGdkScreen.get_default;
+  nmon:=pscr^.get_monitor_at_window(TGtk3Widget(hWnd).GetWindow);
+  Result:=HMONITOR(nmon+1);
+end;
+
 function TGtk3WidgetSet.MoveToEx(DC: HDC; X, Y: Integer; OldPoint: PPoint
   ): Boolean;
 begin
Index: lcl/interfaces/gtk3/gtk3winapih.inc
===================================================================
--- lcl/interfaces/gtk3/gtk3winapih.inc	(revision 64949)
+++ lcl/interfaces/gtk3/gtk3winapih.inc	(working copy)
@@ -167,6 +167,7 @@
 
 function MessageBox({%H-}hWnd: HWND; lpText, lpCaption: PChar; uType: Cardinal): integer; override;
 function MonitorFromPoint(ptScreenCoords: TPoint; dwFlags: DWord): HMONITOR;override;
+function MonitorFromWindow(hWnd: HWND; dwFlags: DWord): HMONITOR;override;
 function MoveToEx(DC: HDC; X, Y: Integer; OldPoint: PPoint): Boolean; override;
 
 function OffsetRgn(RGN: HRGN; nXOffset, nYOffset: Integer): Integer; override;
gtk3monitor.diff (1,314 bytes)   

CudaText man

2021-04-10 20:07

reporter   ~0130250

- it first appears on OK monitor, BUT...
- after I close this inputbox (X icon) it APPEARS AGAIN on the left (bad) monitor!

Anton Kavalenka

2021-04-29 11:33

reporter   ~0130656

Fix inputbox
gtk3widgets.diff (3,377 bytes)   
Index: lcl/interfaces/gtk3/gtk3widgets.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3widgets.pas	(revision 65067)
+++ lcl/interfaces/gtk3/gtk3widgets.pas	(working copy)
@@ -383,6 +383,7 @@
   protected
     function CreateWidget(const Params: TCreateParams):PGtkWidget; override;
   public
+    procedure InitializeWidget;override;
     function getClientRect: TRect; override;
     function getPagesCount: integer;
     procedure InsertPage(ACustomPage: TCustomPage; AIndex: Integer);
@@ -1173,7 +1174,8 @@
     end;
   GDK_BUTTON_RELEASE:
     begin
-      //if not (csClickEvents in TGtk3Widget(Data).LCLObject.ControlStyle) then
+      if not ((csClickEvents in TGtk3Widget(Data).LCLObject.ControlStyle) and
+         (csClicked in TGtk3Widget(Data).LCLObject.ControlState)) then
         Result := TGtk3Widget(Data).GtkEventMouse(Widget , Event);
     end;
   GDK_KEY_PRESS:
@@ -2582,7 +2584,7 @@
 
 procedure TGtk3Widget.DestroyWidget;
 begin
-  if IsWidgetOk and FOwnWidget and Assigned(fWidget) then
+  if IsValidHandle and FOwnWidget then
     FWidget^.destroy_;
   FWidget := nil;
 end;
@@ -2662,8 +2664,10 @@
     fWidget^.get_preferred_height(@mh,@nh);
     fWidget^.get_preferred_width(@mw,@nw);
 
-    LCLObject.Constraints.MinHeight:=mh;
-    LCLObject.Constraints.MinWidth:=mw;
+    if mh>LCLObject.Constraints.MinHeight then
+      LCLObject.Constraints.MinHeight:=mh;
+    if mw>LCLObject.Constraints.MinWidth then
+      LCLObject.Constraints.MinWidth:=mw;
   end;
   LCLIntf.SetProp(HWND(Self),'lclwidget',Self);
 
@@ -3318,12 +3322,7 @@
   FCentralWidget := TGtkFixed.new;
   PGtkBin(Result)^.add(FCentralWidget);
   FCentralWidget^.set_has_window(True);
-
-  {fWidgetRGBA[0].R:=0.8;
-  fWidgetRGBA[0].Alpha:=0.7;
-  PgtkFrame(Result)^.override_color(GTK_STATE_NORMAL,@Self.FWidgetRGBA[0]);}
-  // nil resets color to gtk default
-  //FWidget^.override_background_color(GTK_STATE_FLAG_NORMAL, nil);
+  PgtkFrame(result)^.set_label_align(0.1,0.5);
 end;
 
 function TGtk3GroupBox.getText: String;
@@ -4578,6 +4577,12 @@
   // g_signal_connect_data(FCentralWidget,'select-page', TGCallback(@GtkNotebookSelectPage), Self, nil, 0);
 end;
 
+procedure TGtk3NoteBook.InitializeWidget;
+begin
+  inherited;
+  SetTabPosition(TCustomTabControl(LCLObject).TabPosition);
+end;
+
 function TGtk3NoteBook.getClientRect: TRect;
 var
   AAlloc: TGtkAllocation;
@@ -6732,8 +6737,8 @@
 
 procedure TGtk3Button.ButtonClicked(pData: pointer); cdecl;
 begin
-  if TObject(pdata) is TButton then
-  TButton(pdata).Click;
+  if TObject(pdata) is TCustomButton then
+  TCustomButton(pdata).Click;
 end;
 
 procedure TGtk3Button.SetImage(AImage: TBitmap);
Index: lcl/interfaces/gtk3/gtk3wsbuttons.pp
===================================================================
--- lcl/interfaces/gtk3/gtk3wsbuttons.pp	(revision 65067)
+++ lcl/interfaces/gtk3/gtk3wsbuttons.pp	(working copy)
@@ -87,7 +87,7 @@
   DebugLn('TGtk3WSBitBtn.CreateHandle');
   {$ENDIF}
   ABitBtn := TGtk3Button.Create(AWinControl, AParams);
-  with ARect do
+{  with ARect do
   begin
     x := AWinControl.Left;
     y := AWinControl.Top;
@@ -95,7 +95,7 @@
     height := AWinControl.Height;
   end;
 
-  ABitBtn.Widget^.set_allocation(@ARect);
+  ABitBtn.Widget^.set_allocation(@ARect);}
 
   Result := TLCLIntfHandle(ABitBtn);
   {$IFDEF GTK3DEBUGCORE}
gtk3widgets.diff (3,377 bytes)   

CudaText man

2021-04-29 20:53

reporter   ~0130666

These are not fixed:
- InputBox form is opened on another (left) monitor
- InputBox has too tall buttons
3rd bug is fixed.

Anton Kavalenka

2021-04-30 07:43

reporter   ~0130671

MonitorFromWindow patch (previos) should be also applied

CudaText man

2021-04-30 12:52

reporter   ~0130677

with 2 patches, it's better: monitor of msgbox is correct. buttons click works.
what is not fixed-

- InputBox has too tall buttons ok/cancel (about 2x taller than in gtk2)
- on dlg appearing, I see very strange blinking on right monitor, like half-transparent border near the inputbox (4 times bigger it).

Anton Kavalenka

2021-04-30 15:51

reporter   ~0130681

The only way I can force TButtonPanel be of proper size under GTK3 is:
inputdialog.diff (360 bytes)   
Index: lcl/include/inputdialog.inc
===================================================================
--- lcl/include/inputdialog.inc	(revision 65072)
+++ lcl/include/inputdialog.inc	(working copy)
@@ -81,6 +81,7 @@
       Parent := Form;
       ShowBevel := False;
       ShowButtons := [pbOK, pbCancel];
+      Height:=0;
       Align := alTop;
     end;
 
inputdialog.diff (360 bytes)   

Anton Kavalenka

2021-04-30 15:51

reporter   ~0130682

In any way it is autosizing then

CudaText man

2021-04-30 17:25

reporter   ~0130684

Now it's almost ok. let's apply all patches. I may tell about side effect later.

Juha Manninen

2021-04-30 21:04

developer   ~0130687

I applied gtk3monitor.diff and parts of gtk3widgets.diff in r65075. Rest of gtk3widgets.diff conflicted.

Setting TButtonPanel Height to 0 looks like a hack. Are you sure it is needed? It means the LCL layout system does not work with GTK3 widgetset. It should be fixed instead.

CudaText man

2021-05-02 10:21

reporter   ~0130719

Anton,
Rest of gtk3widgets.diff conflicted.

CudaText man

2021-05-13 10:49

reporter   ~0130850

Anton, note that current version (I tested it before applying conflicted patch) gave the strange desktop invisible window, only border was visible - border around InputBox, but increased. I wait for new patch to test it more.

Issue History

Date Modified Username Field Change
2021-04-06 10:46 CudaText man New Issue
2021-04-06 10:46 CudaText man File Added: tst-gtk3-inputbox.zip
2021-04-06 10:46 CudaText man File Added: Screenshot from 2021-04-06 13-42-45.png
2021-04-10 14:19 Anton Kavalenka Note Added: 0130231
2021-04-10 14:19 Anton Kavalenka File Added: gtk3monitor.diff
2021-04-10 20:07 CudaText man Note Added: 0130250
2021-04-29 11:33 Anton Kavalenka Note Added: 0130656
2021-04-29 11:33 Anton Kavalenka File Added: gtk3widgets.diff
2021-04-29 20:53 CudaText man Note Added: 0130666
2021-04-30 07:43 Anton Kavalenka Note Added: 0130671
2021-04-30 12:52 CudaText man Note Added: 0130677
2021-04-30 15:51 Anton Kavalenka Note Added: 0130681
2021-04-30 15:51 Anton Kavalenka File Added: inputdialog.diff
2021-04-30 15:51 Anton Kavalenka Note Added: 0130682
2021-04-30 17:25 CudaText man Note Added: 0130684
2021-04-30 20:30 Juha Manninen Assigned To => Juha Manninen
2021-04-30 20:30 Juha Manninen Status new => assigned
2021-04-30 21:04 Juha Manninen Note Added: 0130687
2021-04-30 21:04 Juha Manninen Status assigned => feedback
2021-04-30 21:04 Juha Manninen LazTarget => -
2021-05-02 10:21 CudaText man Note Added: 0130719
2021-05-02 10:21 CudaText man Status feedback => assigned
2021-05-13 10:49 CudaText man Note Added: 0130850