View Issue Details

IDProjectCategoryView StatusLast Update
0038401LazarusWidgetsetpublic2021-01-28 09:21
ReporterAndrzej Kilijanski Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformamd64OSLinux Mint 
Product Version2.1 (SVN) 
Summary0038401: GTK2: SpeedButton freezes (need extra click) after close popup menu without choosing any popup menu item (Fix 1).
DescriptionI found more cases where the controls freeze after using the popup menu. This patch is a rework of https://bugs.freepascal.org/view.php?id=38345 and https://bugs.freepascal.org/view.php?id=35094 to handle new cases. I think this patch also fixes rare freezes of the entire window or listView when a popup menu is closed. But I have no proof of it - it just stopped happening to me.

I divided the whole solution into two parts to facilitate review/application of patch - this part fixes the popup menu created in Lazarus.

In the sample program this part (fix 1) will fix the controls with PopupMenu added in Lazarus and the case of opening the second form (modal or not).
Steps To ReproduceThe easiest way to cause the controls to freeze is:
1. Add SpeedButton to the Form
2. Add a ListView to the Form
3. Add PopupMenu to ListView (add some menu items)
4. After run click right on ListView and then click on the form to hide the popup menu
5. At this point, the SpeedButton will be inactive
Tagspatches
Fixed in Revisionr64430
LazTarget-
WidgetsetGTK 2
Attached Files

Relationships

related to 0038402 resolvedJuha Manninen Lazarus GTK2: SpeedButton freezes (need extra click) after close popup menu without choosing any popup menu item (Fix 2). 
related to 0038345 resolvedJuha Manninen Patches GTK2: When open non-modal form by popup menu SpeedButtons don't work 
related to 0035094 resolvedMichl Lazarus TSpeedButton, TStringGrid and TDBGrid do not react to left mouse click with first time 

Activities

Andrzej Kilijanski

2021-01-26 14:46

reporter  

popupmenu_fix1.diff (1,410 bytes)   
Index: lcl/interfaces/gtk2/gtk2wsforms.pp
===================================================================
--- lcl/interfaces/gtk2/gtk2wsforms.pp	(wersja 64422)
+++ lcl/interfaces/gtk2/gtk2wsforms.pp	(kopia robocza)
@@ -742,16 +742,6 @@
 
   GtkWindow := {%H-}PGtkWindow(AForm.Handle);
 
-  if AForm.HandleObjectShouldBeVisible then
-  begin
-    LastMouse.Button := 0;
-    LastMouse.ClickCount := 0;
-    LastMouse.Down := False;
-    LastMouse.MousePos := Point(0, 0);
-    LastMouse.Time := 0;
-    LastMouse.WinControl := nil;
-  end;
-
   if (fsModal in AForm.FormState) and AForm.HandleObjectShouldBeVisible then
   begin
     gtk_window_set_default_size(GtkWindow, Max(1,AForm.Width), Max(1,AForm.Height));
Index: lcl/interfaces/gtk2/gtk2wsmenus.pp
===================================================================
--- lcl/interfaces/gtk2/gtk2wsmenus.pp	(wersja 64422)
+++ lcl/interfaces/gtk2/gtk2wsmenus.pp	(kopia robocza)
@@ -612,7 +612,16 @@
 begin
   Result := False;
   if PopupMenu is TPopupMenu then
+  begin
     PopupMenu.Close;
+    // Fix freezing some controls (eg SpeedButton) when close PopupMenu
+    LastMouse.Button := 0;
+    LastMouse.ClickCount := 0;
+    LastMouse.Down := False;
+    LastMouse.MousePos := Point(0, 0);
+    LastMouse.Time := 0;
+    LastMouse.WinControl := nil;
+  end;
 end;
 
 procedure gtkWSPopupMenuDeactivate(widget: PGtkWidget; data: gPointer); cdecl;
popupmenu_fix1.diff (1,410 bytes)   

Andrzej Kilijanski

2021-01-26 22:15

reporter   ~0128607

This report should be in Patches subproject. Is there any way to move it?

Juha Manninen

2021-01-27 10:40

developer   ~0128611

No need to move. I will test it soon.

Juha Manninen

2021-01-28 09:21

developer   ~0128633

The patch works as advertised. Thanks. Applied.

Issue History

Date Modified Username Field Change
2021-01-26 14:46 Andrzej Kilijanski New Issue
2021-01-26 14:46 Andrzej Kilijanski File Added: popupmenu_spedbtn_gtk2.tar.gz
2021-01-26 14:46 Andrzej Kilijanski File Added: popupmenu_fix1.diff
2021-01-26 15:57 Andrzej Kilijanski Tag Attached: patches
2021-01-26 22:15 Andrzej Kilijanski Note Added: 0128607
2021-01-27 10:40 Juha Manninen Note Added: 0128611
2021-01-27 10:42 Juha Manninen Relationship added related to 0038402
2021-01-27 10:43 Juha Manninen Relationship added related to 0038345
2021-01-27 10:44 Juha Manninen Relationship added related to 0035094
2021-01-27 10:45 Juha Manninen Assigned To => Juha Manninen
2021-01-27 10:45 Juha Manninen Status new => assigned
2021-01-28 09:21 Juha Manninen Status assigned => resolved
2021-01-28 09:21 Juha Manninen Resolution open => fixed
2021-01-28 09:21 Juha Manninen Fixed in Revision => r64430
2021-01-28 09:21 Juha Manninen LazTarget => -
2021-01-28 09:21 Juha Manninen Widgetset GTK 2 => GTK 2
2021-01-28 09:21 Juha Manninen Note Added: 0128633