View Issue Details

IDProjectCategoryView StatusLast Update
0027384LazarusLCLpublic2020-05-05 20:14
ReporterAlexander Koblov Assigned ToZeljan Rikalo  
PrioritynormalSeverityminorReproducibilityalways
Status assignedResolutionfixed 
OSLinux 
Product Version1.3 (SVN) 
Summary0027384: [Qt] Blocking mouse at whole system
DescriptionLong operation in mouse double click event blocking mouse at whole system when program build with Qt4 widgetset.
Steps To ReproduceCompile example program with Qt4 widgetset. Run it without Lazarus.
Double click at the form, try to do something in system using mouse. It does not work. When operation complete then mouse works again.
Repeat same actions with GTK2 widgetset, mouse works as expected.
Additional InformationQt 4.8.6. Also checked with Lazarus 1.2.6, same problem.
TagsNo tags attached.
Fixed in Revision47579
LazTarget-
WidgetsetQT
Attached Files

Activities

Alexander Koblov

2015-01-31 12:33

reporter  

bug.tar.gz (128,332 bytes)

Zeljan Rikalo

2015-02-01 10:20

developer   ~0080712

32 or 64 bit or both ?

Zeljan Rikalo

2015-02-01 11:25

developer   ~0080717

Please test and close if ok.

Zeljan Rikalo

2015-02-01 11:45

developer   ~0080718

Reopened, reverted with r47580. It can lock with any control, not form only when setting capture inside mousedblclick.

Zeljan Rikalo

2015-02-05 10:06

developer   ~0080800

I've tried to implement it directly via X11 and it's same. Seem that gtk2 capture works in some another way, and it bypasses X11 somehow.

Zeljan Rikalo

2015-02-05 10:58

developer  

qt_dblclick_x11_lock.diff (2,319 bytes)   
Index: lcl/interfaces/qt/qtwinapi.inc
===================================================================
--- lcl/interfaces/qt/qtwinapi.inc	(revision 47591)
+++ lcl/interfaces/qt/qtwinapi.inc	(working copy)
@@ -5673,8 +5673,16 @@
       end else
         Windows.SetCapture(QWidget_winID(TQtWidget(AHandle).Widget));
       {$ELSE}
+      {$IFDEF HASX11}
+      if qtwsInsideMouseDoubleClickEvent in TQtWidget(AHandle).WidgetState then
+        // issue #27384
+        DebugLn('TQtWidgetSet.SetCapture: Avoid X11 lock, setting capture inside mouse dbl click.',dbgsName(TQtWidget(AHandle)))
+      else
+        TQtWidget(AHandle).grabMouse();
+      {$ELSE}
       TQtWidget(AHandle).grabMouse();
       {$ENDIF}
+      {$ENDIF}
     end;
     {$ifdef VerboseQtWinAPI}
       WriteLn('[WinAPI SetCapture] Capture = ', Result, ' New capture = ', AHandle);
Index: lcl/interfaces/qt/qtwidgets.pas
===================================================================
--- lcl/interfaces/qt/qtwidgets.pas	(revision 47591)
+++ lcl/interfaces/qt/qtwidgets.pas	(working copy)
@@ -60,7 +60,8 @@
   {state is setted up only when LCL is doing changes.}
   TQtWidgetState = (qtwsColorUpdating, qtwsFontUpdating, qtwsSizeUpdating,
     qtwsPositionUpdating, qtwsInsideRightMouseButtonPressEvent,
-    qtwsHiddenInsideRightMouseButtonPressEvent);
+    qtwsHiddenInsideRightMouseButtonPressEvent,
+    qtwsInsideMouseDoubleClickEvent);
 
   TQtWidgetStates = set of TQtWidgetState;
 
@@ -3530,6 +3531,13 @@
         QtMidButton: Msg.Msg := CheckMouseButtonDown(2);
       end;
 
+      {$IFDEF HASX11}
+      if (QEvent_type(Event) = QEventMouseButtonDblClick) and
+        (MButton = QtLeftButton) then
+          Include(FWidgetState, qtwsInsideMouseDoubleClickEvent);
+      try
+      {$ENDIF}
+
       {$IFDEF MSWINDOWS}
       if (QEvent_type(Event) = QEventMouseButtonPress) and
           (MButton = QtRightButton) then
@@ -3555,6 +3563,13 @@
       end;
       {$ENDIF}
 
+      {$IFDEF HASX11}
+      finally
+        if qtwsInsideMouseDoubleClickEvent in FWidgetState then
+          Exclude(FWidgetState, qtwsInsideMouseDoubleClickEvent);
+      end;
+      {$ENDIF}
+
       // Check if our objects exists since LCL can destroy object during
       // mouse events...
       if CanSendLCLMessage and (Sender <> nil) then
qt_dblclick_x11_lock.diff (2,319 bytes)   

Zeljan Rikalo

2015-02-05 11:00

developer   ~0080802

Please test with attached patch. Note that GetCapture inside mouseDblClick event will return 0 in this case (qt under x11).
Tried also with pure Qt application and same thing happens. If events aren't processed then X11 locks mouse until it passed. Think that gtk2 does the same thing.
Maybe we should add an internal mouse capture list in this case and remove handles inside releasecapture.

Alexander Koblov

2015-02-11 20:52

reporter   ~0080965

Work with test application, but does not work with my original application.
In my original application mouseDblClick used with TDrawGrid control. I checked with simple example using TDrawGrid and see that it does not work. And debug message "TQtWidgetSet.SetCapture: Avoid X11 lock..." does not shown in this case.

Zeljan Rikalo

2015-02-12 16:08

developer   ~0080994

Probably because TQtWidget(AHandle) in TQtWidgetSet.SetCapture() should be asked if it's TCustomControl and then check lock on TQtCustomControl(AHandle).viewport

Zeljan Rikalo

2020-04-01 10:55

developer   ~0121825

@Alexander, can you test with current trunk and give feedback (qt/qt5) ?

Alexander Koblov

2020-05-05 20:14

reporter   ~0122635

I checked with current trunk. Problem still exists, both Qt4/Qt5.

Issue History

Date Modified Username Field Change
2015-01-31 12:33 Alexander Koblov New Issue
2015-01-31 12:33 Alexander Koblov File Added: bug.tar.gz
2015-02-01 10:07 Zeljan Rikalo Assigned To => Zeljan Rikalo
2015-02-01 10:07 Zeljan Rikalo Status new => assigned
2015-02-01 10:20 Zeljan Rikalo LazTarget => -
2015-02-01 10:20 Zeljan Rikalo Note Added: 0080712
2015-02-01 10:20 Zeljan Rikalo Status assigned => feedback
2015-02-01 11:25 Zeljan Rikalo Fixed in Revision => 47579
2015-02-01 11:25 Zeljan Rikalo Note Added: 0080717
2015-02-01 11:25 Zeljan Rikalo Status feedback => resolved
2015-02-01 11:25 Zeljan Rikalo Resolution open => fixed
2015-02-01 11:45 Zeljan Rikalo Note Added: 0080718
2015-02-01 11:45 Zeljan Rikalo Status resolved => confirmed
2015-02-05 10:06 Zeljan Rikalo Note Added: 0080800
2015-02-05 10:58 Zeljan Rikalo File Added: qt_dblclick_x11_lock.diff
2015-02-05 11:00 Zeljan Rikalo Note Added: 0080802
2015-02-05 11:00 Zeljan Rikalo Status confirmed => feedback
2015-02-11 20:52 Alexander Koblov Note Added: 0080965
2015-02-11 20:52 Alexander Koblov Status feedback => assigned
2015-02-12 16:08 Zeljan Rikalo Note Added: 0080994
2020-04-01 10:55 Zeljan Rikalo Status assigned => feedback
2020-04-01 10:55 Zeljan Rikalo Note Added: 0121825
2020-05-05 20:14 Alexander Koblov Note Added: 0122635
2020-05-05 20:14 Alexander Koblov Status feedback => assigned