gtk1 intf: workaround for popupmenu of TEdit/TComboBox mouse capture release bug #9452

git-svn-id: trunk@15423 -
This commit is contained in:
mattias 2008-06-14 13:20:10 +00:00
parent e3520a6d50
commit 63efcb6dec
4 changed files with 33 additions and 6 deletions

View File

@ -1715,9 +1715,9 @@ begin
if not TempPopupMenu.AutoPopup then Exit;
// SendCancelMode(nil);
TempPopupMenu.PopupComponent := Control;
//DebugLn(['TControl.WMContextMenu ',DbgSName(Self),' Message.pos=',dbgs(P2)]);
DebugLn(['TControl.WMContextMenu ',DbgSName(Self),' Message.pos=',dbgs(P2)]);
P2 := ClientToScreen(P2);
//DebugLn(['TControl.WMContextMenu ',DbgSName(Self),' P2=',dbgs(P2)]);
DebugLn(['TControl.WMContextMenu ',DbgSName(Self),' P2=',dbgs(P2)]);
TempPopupMenu.Popup(P2.X, P2.Y);
Message.Result:= 1;
Exit;

View File

@ -1134,6 +1134,7 @@ function gtkMotionNotify(Widget:PGTKWidget; Event: PGDKEventMotion;
Data: gPointer): GBoolean; cdecl;
var
DesignOnlySignal: boolean;
ShiftState: TShiftState;
begin
Result := CallBackDefaultReturn;
MousePositionValid:=false;
@ -1149,6 +1150,28 @@ begin
{$ENDIF}
UpdateMouseCaptureControl;
ShiftState := GTKEventStateToShiftState(Event^.State);
if (MouseCaptureWidget=Widget)
and (MouseCaptureType=mctGTK)
and ([ssLeft,ssRight,ssMiddle]*ShiftState=[]) then begin
{$IFDEF VerboseMouseCapture}
DebugLn(['gtkMotionNotify gtk capture without mouse down: ',GetWidgetDebugReport(Widget)]);
{$ENDIF}
{$IFDEF Gtk1}
// workaround for buggy gtk1: release capture and clean up editable
// (happens when popupmenu of TEdit/TComboBox closes)
gtk_grab_remove(MouseCaptureWidget);
if GtkWidgetIsA(MouseCaptureWidget,GTK_TYPE_ENTRY) then begin
PGtkEntry(MouseCaptureWidget)^.button:=0;
end;
if GtkWidgetIsA(MouseCaptureWidget,gtk_editable_get_type) then begin
PGtkEditable(MouseCaptureWidget)^.flag0:=
PGtkEditable(MouseCaptureWidget)^.flag0 and not bm_TGtkEditable_has_selection;
end;
UpdateMouseCaptureControl;
{$ENDIF}
end;
if not (csDesigning in TComponent(Data).ComponentState) then begin
DesignOnlySignal:=GetDesignOnlySignalFlag(Widget,dstMouseMotion);

View File

@ -45,6 +45,11 @@ type
mctGTKIntf, // gtk interface has captured the mouse
mctLCL // a LCL control has captured the mouse
);
const
MouseCaptureTypeNames: array[TMouseCaptureType] of string = (
'GTK','GTKintf','LCL'
);
var
//drag icons

View File

@ -4616,7 +4616,7 @@ end;
Params: none
Returns: none
Sets MCaptureControl to the current capturing widget.
Sets MouseCaptureWidget to the current capturing widget.
------------------------------------------------------------------------------}
procedure UpdateMouseCaptureControl;
var
@ -4631,11 +4631,10 @@ begin
// -> this means the gtk itself has changed the mouse grab
{$IFDEF VerboseMouseCapture}
DebugLn('UpdateMouseCaptureControl Capture changed from ',
'[',GetWidgetDebugReport(OldMouseCaptureWidget),']',
' to [',GetWidgetDebugReport(CurMouseCaptureWidget),']');
'[',GetWidgetDebugReport(OldMouseCaptureWidget),' type=',MouseCaptureTypeNames[MouseCaptureType],']',
' to [',GetWidgetDebugReport(CurMouseCaptureWidget),' type=GTK]');
if CurMouseCaptureWidget<>nil then
DebugLn('parent ', GetWidgetDebugReport(CurMouseCaptureWidget^.Parent));
{$ENDIF}
// notify the new capture control