Qt,Qt5: fixed system mouse lock when TCustomControl is double clicked. issue #27384

This commit is contained in:
Željan Rikalo 2021-10-15 17:17:57 +02:00
parent 5081a5269f
commit 9057aece81
4 changed files with 63 additions and 18 deletions

View File

@ -61,7 +61,8 @@ type
TQtWidgetState = (qtwsColorUpdating, qtwsFontUpdating, qtwsSizeUpdating,
qtwsPositionUpdating, qtwsInsideRightMouseButtonPressEvent,
qtwsHiddenInsideRightMouseButtonPressEvent,
qtwsForceSendMove {mantis #34589 , LM_MOVE from ScrollWindowEx(SW_SCROLLCHILDREN)});
qtwsForceSendMove {mantis #34589 , LM_MOVE from ScrollWindowEx(SW_SCROLLCHILDREN)},
qtwsInsideMouseDoubleClickEvent {issue #27384 - do not lock system with capture});
TQtWidgetStates = set of TQtWidgetState;
@ -3680,25 +3681,41 @@ begin
if (QEvent_type(Event) = QEventMouseButtonPress) and
(MButton = QtRightButton) then
Include(FWidgetState, qtwsInsideRightMouseButtonPressEvent);
try
{$ENDIF}
NotifyApplicationUserInput(LCLObject, Msg.Msg);
if (QEvent_type(Event) = QEventMouseButtonDblClick) and
(MButton = QtLeftButton) then
begin
if FChildOfComplexWidget in
[ccwAbstractScrollArea, ccwCustomControl, ccwScrollingWinControl, ccwScrollingWindow] then
Include(FOwner.FWidgetState, qtwsInsideMouseDoubleClickEvent);
Include(FWidgetState, qtwsInsideMouseDoubleClickEvent);
end;
try
if not CanSendLCLMessage or (Sender = nil) then
exit(True);
NotifyApplicationUserInput(LCLObject, Msg.Msg);
DeliverMessage(Msg, True);
if not CanSendLCLMessage or (Sender = nil) then
exit(True);
DeliverMessage(Msg, True);
{$IFDEF MSWINDOWS}
finally
if qtwsInsideMouseDoubleClickEvent in FWidgetState then
begin
if FChildOfComplexWidget in
[ccwAbstractScrollArea, ccwCustomControl, ccwScrollingWinControl, ccwScrollingWindow] then
Exclude(FOwner.FWidgetState, qtwsInsideMouseDoubleClickEvent);
Exclude(FWidgetState, qtwsInsideMouseDoubleClickEvent);
end;
{$IFDEF MSWINDOWS}
if (QEvent_type(Event) = QEventMouseButtonPress) and
(MButton = QtRightButton) then
begin
Exclude(FWidgetState, qtwsInsideRightMouseButtonPressEvent);
Exclude(FWidgetState, qtwsHiddenInsideRightMouseButtonPressEvent);
end;
{$ENDIF}
end;
{$ENDIF}
// Check if our objects exists since LCL can destroy object during
// mouse events...

View File

@ -6059,7 +6059,13 @@ begin
end else
Windows.SetCapture(QWidget_winID(TQtWidget(AHandle).Widget));
{$ELSE}
TQtWidget(AHandle).grabMouse();
if qtwsInsideMouseDoubleClickEvent in TQtWidget(AHandle).WidgetState then
// issue #27384
{$IFDEF DebugQtFocus}
DebugLn('TQtWidgetSet.SetCapture: Avoid system lock, setting capture inside mouse dbl click.',dbgsName(TQtWidget(AHandle)))
{$ENDIF}
else
TQtWidget(AHandle).grabMouse();
{$ENDIF}
end;
{$ifdef VerboseQtWinAPI}

View File

@ -61,7 +61,8 @@ type
TQtWidgetState = (qtwsColorUpdating, qtwsFontUpdating, qtwsSizeUpdating,
qtwsPositionUpdating, qtwsInsideRightMouseButtonPressEvent,
qtwsHiddenInsideRightMouseButtonPressEvent,
qtwsForceSendMove {mantis #34589 , LM_MOVE from ScrollWindowEx(SW_SCROLLCHILDREN)});
qtwsForceSendMove {mantis #34589 , LM_MOVE from ScrollWindowEx(SW_SCROLLCHILDREN)},
qtwsInsideMouseDoubleClickEvent {issue #27384 - do not lock system with capture});
TQtWidgetStates = set of TQtWidgetState;
@ -3710,26 +3711,41 @@ begin
if (QEvent_type(Event) = QEventMouseButtonPress) and
(MButton = QtRightButton) then
Include(FWidgetState, qtwsInsideRightMouseButtonPressEvent);
try
{$ENDIF}
if (QEvent_type(Event) = QEventMouseButtonDblClick) and
(MButton = QtLeftButton) then
begin
if FChildOfComplexWidget in
[ccwAbstractScrollArea, ccwCustomControl, ccwScrollingWinControl, ccwScrollingWindow] then
Include(FOwner.FWidgetState, qtwsInsideMouseDoubleClickEvent);
Include(FWidgetState, qtwsInsideMouseDoubleClickEvent);
end;
try
NotifyApplicationUserInput(LCLObject, Msg.Msg);
NotifyApplicationUserInput(LCLObject, Msg.Msg);
if not CanSendLCLMessage or (Sender = nil) then
exit(True);
if not CanSendLCLMessage or (Sender = nil) then
exit(True);
DeliverMessage(Msg, True);
DeliverMessage(Msg, True);
{$IFDEF MSWINDOWS}
finally
if qtwsInsideMouseDoubleClickEvent in FWidgetState then
begin
if FChildOfComplexWidget in
[ccwAbstractScrollArea, ccwCustomControl, ccwScrollingWinControl, ccwScrollingWindow] then
Exclude(FOwner.FWidgetState, qtwsInsideMouseDoubleClickEvent);
Exclude(FWidgetState, qtwsInsideMouseDoubleClickEvent);
end;
{$IFDEF MSWINDOWS}
if (QEvent_type(Event) = QEventMouseButtonPress) and
(MButton = QtRightButton) then
begin
Exclude(FWidgetState, qtwsInsideRightMouseButtonPressEvent);
Exclude(FWidgetState, qtwsHiddenInsideRightMouseButtonPressEvent);
end;
{$ENDIF}
end;
{$ENDIF}
// Check if our objects exists since LCL can destroy object during
// mouse events...

View File

@ -6005,7 +6005,13 @@ begin
end else
Windows.SetCapture(QWidget_winID(TQtWidget(AHandle).Widget));
{$ELSE}
TQtWidget(AHandle).grabMouse();
if qtwsInsideMouseDoubleClickEvent in TQtWidget(AHandle).WidgetState then
// issue #27384
{$IFDEF DebugQtFocus}
DebugLn('TQtWidgetSet.SetCapture: Avoid system lock, setting capture inside mouse dbl click.',dbgsName(TQtWidget(AHandle)))
{$ENDIF}
else
TQtWidget(AHandle).grabMouse();
{$ENDIF}
end;
{$ifdef VerboseQtWinAPI}