View Issue Details

IDProjectCategoryView StatusLast Update
0038562LazarusWidgetsetpublic2021-03-03 16:56
ReporterCudaText man Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
OSUbuntu 20.4 x64 
Summary0038562: gtk3: TPanel.OnPaint don't work
DescriptionDemo added. run it with gtk2 and gtk3-- the gtk3 don't show painted TPanel, while shows other 2 controls: TForm/SpeedBtn.
Additional InformationLazarus 2.1.0 r64665 FPC 3.2.1 x86_64-linux-gtk2
TagsNo tags attached.
Fixed in Revisionr64740
LazTarget-
WidgetsetGTK 3
Attached Files

Relationships

related to 0037815 assignedJuha Manninen GTK3: TTrackbar Frozen if Form has Panel 

Activities

CudaText man

2021-03-01 14:45

reporter  

tst-icon-draw-gtk3.zip (7,951 bytes)
gk3-bad.png (11,013 bytes)   
gk3-bad.png (11,013 bytes)   

Anton Kavalenka

2021-03-01 15:42

reporter   ~0129283

I've broken resizing for TControl descendants. Wait a bit, i will upload the patch

Anton Kavalenka

2021-03-01 15:58

reporter   ~0129284

Last edited: 2021-03-01 16:00

View 2 revisions

These are fixes for resizing, some workarounds for TButton and exercises among theme colors
gtk3.diff (3,102 bytes)   
Index: lcl/interfaces/gtk3/gtk3lclintf.inc
===================================================================
--- lcl/interfaces/gtk3/gtk3lclintf.inc	(revision 64704)
+++ lcl/interfaces/gtk3/gtk3lclintf.inc	(working copy)
@@ -693,6 +693,8 @@
     Height := R.Bottom - R.Top;
   end;
 
+  WorkMask:=nil;
+
   if (Width = Image.Width) and (Height = Image.Height) then
   begin
     WorkImage := Image;
@@ -745,6 +747,7 @@
       if InvertPixels then
         WorkMask.invertPixels(QImageInvertRGB);
         *)
+      if WorkMask.bits<>nil then
       Move(WorkMask.bits^, ARawImage.Mask^, ARawImage.MaskSize);
       // if InvertPixels then
       //  WorkMask.invertPixels(QImageInvertRGB);
Index: lcl/interfaces/gtk3/gtk3widgets.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3widgets.pas	(revision 64704)
+++ lcl/interfaces/gtk3/gtk3widgets.pas	(working copy)
@@ -1712,11 +1712,14 @@
   Result := False;
   FillChar(Msg, SizeOf(Msg), #0);
   if Event^.type_ = GDK_ENTER_NOTIFY then
-    Msg.Msg := LM_MOUSEENTER
+  begin
+    Msg.Msg := LM_MOUSEENTER;
+    NotifyApplicationUserInput(LCLObject, Msg.Msg);
+  end
   else
     Msg.Msg := LM_MOUSELEAVE;
 
-  NotifyApplicationUserInput(LCLObject, Msg.Msg);
+  //NotifyApplicationUserInput(LCLObject, Msg.Msg);
   Result := DeliverMessage(Msg, True) <> 0;
   {$IFDEF GTK3DEBUGCORE}
   MousePos.X := Round(Event^.crossing.x);
@@ -2838,6 +2841,12 @@
   Alloc: TGtkAllocation;
   AMinSize, ANaturalSize: gint;
 begin
+    if Self is TGtk3Button then
+    begin
+      dec(Awidth,4);
+      dec(Aheight,4);
+    end;
+
   ARect.x := ALeft;
   ARect.y := ATop;
   ARect.width := AWidth;
@@ -2855,6 +2864,9 @@
     Widget^.get_preferred_width(@AMinSize, @ANaturalSize);
     Widget^.get_preferred_height(@AMinSize, @ANaturalSize);
 
+
+    Widget^.set_size_request(AWidth,AHeight);
+
     Widget^.size_allocate(@ARect);
     Widget^.set_allocation(@Alloc);
     if LCLObject.Parent <> nil then
@@ -6714,11 +6726,16 @@
   check := TGtkCheckButton.new;
   Result := PGtkWidget(check);
   check^.set_use_underline(True);
-  {fWidgetRGBA[0].G:=0.8;
-  fWidgetRGBA[0].Alpha:=0.7;
-  check^.override_color(GTK_STATE_NORMAL,@Self.FWidgetRGBA[0]);}
+  fWidgetRGBA[0].G:=0.8;
+  fWidgetRGBA[0].Alpha:=1;
+  check^.override_color(GTK_STATE_FLAG_NORMAL,@Self.FWidgetRGBA[0]);
+  (*fWidgetRGBA[0].G:=0.8;
+  fWidgetRGBA[0].B:=0.9;
+  fWidgetRGBA[0].Alpha:=0.9;
+  check^.override_color(GTK_STATE_FLAG_ACTIVE,@Self.FWidgetRGBA[0]); *)
   // nil resets color to gtk default
-  FWidget^.override_background_color(GTK_STATE_FLAG_NORMAL, nil);
+ { FWidget^.override_color(GTK_STATE_FLAG_NORMAL, nil);
+  FWidget^.override_background_color(GTK_STATE_FLAG_NORMAL, nil);}
 end;
 
 { TGtk3RadioButton }
@@ -7085,7 +7102,7 @@
   if not Assigned(LCLObject.Parent) then
   begin
     Result := TGtkWindow.new(GTK_WINDOW_TOPLEVEL);
-    Result^.set_size_request(0,0);
+    //Result^.set_size_request(0,0);
     gtk_widget_realize(Result);
     decor:=decoration_flags(AForm);
     gdk_window_set_decorations(Result^.window, decor);
gtk3.diff (3,102 bytes)   

Juha Manninen

2021-03-01 21:05

developer   ~0129291

Last edited: 2021-03-01 21:21

View 2 revisions

Here the patch makes no difference. I still see the 2 images just as in CudaText man's screenshot.
With LCL-GTK2 and LCL-QT5 I see a 3rd image on the panel.

Anton Kavalenka

2021-03-02 07:52

reporter   ~0129300

Last edited: 2021-03-02 07:53

View 3 revisions

Maybe LCL rebuild have to be forced

CudaText man

2021-03-02 08:53

reporter   ~0129301

yes, patch fixes this! Pls apply.

CudaText man

2021-03-02 09:33

reporter   ~0129305

but. Awful code style.
Pls see comment
https://forum.lazarus.freepascal.org/index.php?topic=53531.msg396095#msg396095

Juha Manninen

2021-03-02 10:51

developer   ~0129309

Here the patch does not fix. I did a clean build. All LCL and LCL-GTK3 was built. Still only 2 images.
I tested with Manjaro Linux 64-bit with KDE Plasma. Could GTK3 lib version make a difference? Manjaro has recent versions.

Anton Kavalenka

2021-03-02 12:31

reporter   ~0129311

Last edited: 2021-03-02 12:32

View 2 revisions

@Juha Manninen - try resize form a bit (drag a corner)

Juha Manninen

2021-03-02 17:19

developer   ~0129324

> try resize form a bit (drag a corner)

No difference.

Anton Kavalenka

2021-03-03 12:28

reporter   ~0129343

Last edited: 2021-03-03 13:35

View 5 revisions

Can confirm - Kwin/Plasma hates TPanel
@Juha Manninen
Please test new patch

Btw this maybe same problem with frozen TtrackBar (spotted by Chris Rorden 0037815)

Anton Kavalenka

2021-03-03 13:22

reporter   ~0129346

gtk3panel.diff (4,116 bytes)   
Index: lcl/interfaces/gtk3/gtk3lclintf.inc
===================================================================
--- lcl/interfaces/gtk3/gtk3lclintf.inc	(revision 64736)
+++ lcl/interfaces/gtk3/gtk3lclintf.inc	(working copy)
@@ -693,6 +693,8 @@
     Height := R.Bottom - R.Top;
   end;
 
+  WorkMask:=nil;
+
   if (Width = Image.Width) and (Height = Image.Height) then
   begin
     WorkImage := Image;
@@ -745,6 +747,7 @@
       if InvertPixels then
         WorkMask.invertPixels(QImageInvertRGB);
         *)
+      if WorkMask.bits<>nil then
       Move(WorkMask.bits^, ARawImage.Mask^, ARawImage.MaskSize);
       // if InvertPixels then
       //  WorkMask.invertPixels(QImageInvertRGB);
Index: lcl/interfaces/gtk3/gtk3widgets.pas
===================================================================
--- lcl/interfaces/gtk3/gtk3widgets.pas	(revision 64736)
+++ lcl/interfaces/gtk3/gtk3widgets.pas	(working copy)
@@ -1712,11 +1712,14 @@
   Result := False;
   FillChar(Msg, SizeOf(Msg), #0);
   if Event^.type_ = GDK_ENTER_NOTIFY then
-    Msg.Msg := LM_MOUSEENTER
+  begin
+    Msg.Msg := LM_MOUSEENTER;
+    NotifyApplicationUserInput(LCLObject, Msg.Msg);
+  end
   else
     Msg.Msg := LM_MOUSELEAVE;
 
-  NotifyApplicationUserInput(LCLObject, Msg.Msg);
+  //NotifyApplicationUserInput(LCLObject, Msg.Msg);
   Result := DeliverMessage(Msg, True) <> 0;
   {$IFDEF GTK3DEBUGCORE}
   MousePos.X := Round(Event^.crossing.x);
@@ -2838,6 +2841,12 @@
   Alloc: TGtkAllocation;
   AMinSize, ANaturalSize: gint;
 begin
+    if Self is TGtk3Button then
+    begin
+      dec(Awidth,4);
+      dec(Aheight,4);
+    end;
+
   ARect.x := ALeft;
   ARect.y := ATop;
   ARect.width := AWidth;
@@ -2855,6 +2864,9 @@
     Widget^.get_preferred_width(@AMinSize, @ANaturalSize);
     Widget^.get_preferred_height(@AMinSize, @ANaturalSize);
 
+
+    Widget^.set_size_request(AWidth,AHeight);
+
     Widget^.size_allocate(@ARect);
     Widget^.set_allocation(@Alloc);
     if LCLObject.Parent <> nil then
@@ -3106,12 +3118,19 @@
 begin
   FHasPaint := True;
   FBorderStyle := bsNone;
+
   // wtLayout = using GtkLayout
   // FWidgetType := [wtWidget, wtLayout];
   // Result := TGtkLayout.new(nil, nil);
+
   FWidgetType := [wtWidget, wtContainer];
-  Result := TGtkFixed.new;
+  Result := TGtkFixed.new();
   Result^.set_has_window(True);
+  // as GtkFixed have no child control here - nobody triggers resizing
+  // GNOME takes care of it, but other WM - not
+  // this is here to make TGtk3Panel shown under Plasma
+  Result^.set_size_request(LCLObject.Width,LCLObject.Height);
+
   // AColor := Result^.style^.bg[0];
   // writeln('BG COLOR R=',AColor.red,' G=',AColor.green,' B=',AColor.blue);
   // now we make panel completely transparent.
@@ -3184,7 +3203,7 @@
   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);
+  //FWidget^.override_background_color(GTK_STATE_FLAG_NORMAL, nil);
 end;
 
 function TGtk3GroupBox.getText: String;
@@ -7085,7 +7104,7 @@
   if not Assigned(LCLObject.Parent) then
   begin
     Result := TGtkWindow.new(GTK_WINDOW_TOPLEVEL);
-    Result^.set_size_request(0,0);
+    //Result^.set_size_request(0,0);
     gtk_widget_realize(Result);
     decor:=decoration_flags(AForm);
     gdk_window_set_decorations(Result^.window, decor);
Index: lcl/interfaces/gtk3/gtk3winapi.inc
===================================================================
--- lcl/interfaces/gtk3/gtk3winapi.inc	(revision 64736)
+++ lcl/interfaces/gtk3/gtk3winapi.inc	(working copy)
@@ -3199,6 +3199,7 @@
   Result := AWidget <> nil;
   if Result then
   begin
+    if AWidget.Widget = nil then exit;
     if AWidget.GetContainerWidget^.has_grab then
       gtk_grab_remove(AWidget.GetContainerWidget)
     else
@@ -3418,7 +3419,7 @@
     if IsValidHandle(AHandle) then
     begin
       TGtk3Widget(AHandle).SetCapture;
-      if (Result <> 0) then
+      //if (Result <> 0) then
       begin
         Message.Msg := 0;
         FillChar(Message, SizeOf(Message), 0);
gtk3panel.diff (4,116 bytes)   

Anton Kavalenka

2021-03-03 13:24

reporter   ~0129348

Last edited: 2021-03-03 15:24

View 3 revisions

@CudaText man
As far I remember you mentioned in posted forum link the FPC code style.
If smth Then
   Begin
   End
Lazarus project uses Delphi code style
if smth then
begin
end

Anton Kavalenka

2021-03-03 13:52

reporter   ~0129352

Screenshot_20210303_155022.png (24,399 bytes)   
Screenshot_20210303_155022.png (24,399 bytes)   

Juha Manninen

2021-03-03 16:46

developer   ~0129356

Wow, the new patch works. Thanks.

Issue History

Date Modified Username Field Change
2021-03-01 14:45 CudaText man New Issue
2021-03-01 14:45 CudaText man File Added: tst-icon-draw-gtk3.zip
2021-03-01 14:45 CudaText man File Added: gk3-bad.png
2021-03-01 15:42 Anton Kavalenka Note Added: 0129283
2021-03-01 15:58 Anton Kavalenka Note Added: 0129284
2021-03-01 15:58 Anton Kavalenka File Added: gtk3.diff
2021-03-01 16:00 Anton Kavalenka Note Edited: 0129284 View Revisions
2021-03-01 20:57 Juha Manninen Assigned To => Juha Manninen
2021-03-01 20:57 Juha Manninen Status new => assigned
2021-03-01 21:05 Juha Manninen Note Added: 0129291
2021-03-01 21:21 Juha Manninen Note Edited: 0129291 View Revisions
2021-03-02 07:52 Anton Kavalenka Note Added: 0129300
2021-03-02 07:52 Anton Kavalenka File Added: Здымак экрана, 2021-03-02 09-51-48.png
2021-03-02 07:53 Anton Kavalenka Note Edited: 0129300 View Revisions
2021-03-02 07:53 Anton Kavalenka Note Edited: 0129300 View Revisions
2021-03-02 08:53 CudaText man Note Added: 0129301
2021-03-02 09:33 CudaText man Note Added: 0129305
2021-03-02 10:51 Juha Manninen Note Added: 0129309
2021-03-02 12:31 Anton Kavalenka Note Added: 0129311
2021-03-02 12:32 Anton Kavalenka Note Edited: 0129311 View Revisions
2021-03-02 17:19 Juha Manninen Note Added: 0129324
2021-03-03 12:28 Anton Kavalenka Note Added: 0129343
2021-03-03 13:22 Anton Kavalenka Note Edited: 0129343 View Revisions
2021-03-03 13:22 Anton Kavalenka Note Added: 0129346
2021-03-03 13:22 Anton Kavalenka File Added: gtk3panel.diff
2021-03-03 13:24 Anton Kavalenka Note Added: 0129348
2021-03-03 13:33 Anton Kavalenka Note Edited: 0129343 View Revisions
2021-03-03 13:35 Anton Kavalenka Note Edited: 0129343 View Revisions
2021-03-03 13:35 Anton Kavalenka Note Edited: 0129343 View Revisions
2021-03-03 13:52 Anton Kavalenka Note Added: 0129352
2021-03-03 13:52 Anton Kavalenka File Added: Screenshot_20210303_155022.png
2021-03-03 15:23 Anton Kavalenka Note Edited: 0129348 View Revisions
2021-03-03 15:24 Anton Kavalenka Note Edited: 0129348 View Revisions
2021-03-03 16:40 Juha Manninen Relationship added related to 0037815
2021-03-03 16:46 Juha Manninen Status assigned => resolved
2021-03-03 16:46 Juha Manninen Resolution open => fixed
2021-03-03 16:46 Juha Manninen Fixed in Revision => r64740
2021-03-03 16:46 Juha Manninen LazTarget => -
2021-03-03 16:46 Juha Manninen Widgetset GTK 3 => GTK 3
2021-03-03 16:46 Juha Manninen Note Added: 0129356
2021-03-03 16:56 CudaText man Status resolved => closed