gtk2,gtk3: gtk should always send LM_SETFOCUS before mouse messages, like Qt and Win32 does. issue #31900

git-svn-id: trunk@55062 -
This commit is contained in:
zeljko 2017-05-23 15:39:42 +00:00
parent 47e4060861
commit 09f9152b29
2 changed files with 24 additions and 11 deletions

View File

@ -2114,22 +2114,26 @@ begin
MessI.Result:=0;
{always send LM_SETFOCUS first}
{Gtk2 should always send LM_SETFOCUS first, as qt and win32 does. issues #24308, #31900}
if ((MessI.Msg = LM_LBUTTONDOWN) or (MessI.Msg = LM_RBUTTONDOWN) or
(MessI.Msg = LM_MBUTTONDOWN) or (MessI.Msg = LM_LBUTTONDBLCLK) or
(MessI.Msg = LM_XBUTTONDOWN)) and
not AWinControl.Focused and AWinControl.CanFocus and
not (csDesigning in AWinControl.ComponentState) and (AWinControl is TCustomEdit) then
not (csDesigning in AWinControl.ComponentState) then
begin
AClipText := '';
AClip := gtk_clipboard_get(GDK_SELECTION_PRIMARY);
if gtk_clipboard_get_owner(AClip) = AClip then
AClip := nil;
if (AClip <> nil) and gtk_clipboard_wait_is_text_available(AClip) then
AClipText := gtk_clipboard_wait_for_text(AClip);
LCLIntf.SetFocus(AWinControl.Handle);
if Assigned(AClip) then
gtk_clipboard_set_text(AClip, PgChar(AClipText), length(AClipText));
if (AWinControl is TCustomEdit) then
begin
AClipText := '';
AClip := gtk_clipboard_get(GDK_SELECTION_PRIMARY);
if gtk_clipboard_get_owner(AClip) = AClip then
AClip := nil;
if (AClip <> nil) and gtk_clipboard_wait_is_text_available(AClip) then
AClipText := gtk_clipboard_wait_for_text(AClip);
LCLIntf.SetFocus(AWinControl.Handle);
if Assigned(AClip) then
gtk_clipboard_set_text(AClip, PgChar(AClipText), length(AClipText));
end else
LCLIntf.SetFocus(AWinControl.Handle);
end;
// send the message directly to the LCL

View File

@ -2130,6 +2130,15 @@ begin
Msg.Msg := LM_MBUTTONUP;
end;
end;
{Issues #24308,#21900. Gtk should always send LM_SETFOCUS before LM_XXXX - mouse click}
if ((Msg.Msg = LM_LBUTTONDOWN) or (Msg.Msg = LM_RBUTTONDOWN) or
(Msg.Msg = LM_MBUTTONDOWN) or (Msg.Msg = LM_LBUTTONDBLCLK) or
(Msg.Msg = LM_XBUTTONDOWN)) and Assigned(LCLObject) and
not LCLObject.Focused and LCLObject.CanFocus and
not (csDesigning in LCLObject.ComponentState) then
LCLIntf.SetFocus(LCLObject.Handle);
{$IF DEFINED(GTK3DEBUGEVENTS) OR DEFINED(GTK3DEBUGMOUSE)}
DebugLn('TGtk3Widget.GtkEventMouse ',dbgsName(LCLObject),
' msg=',dbgs(msg.Msg), ' point=',dbgs(Msg.XPos),',',dbgs(Msg.YPos));