gtk2 intf: added flag Gtk2CallMouseDownBeforeContext to call mousedown before lm_context

git-svn-id: trunk@30939 -
This commit is contained in:
mattias 2011-05-27 20:20:17 +00:00
parent 33c214c32e
commit b68fd5c06b
3 changed files with 23 additions and 11 deletions

View File

@ -8065,14 +8065,13 @@ var
begin begin
// find if at the click place we have a control and if so then pass the message // find if at the click place we have a control and if so then pass the message
// to it // to it
// don't check csDesigning here - let a child control to check it // don't check csDesigning here - let a child control to check it
if (Message.Result <> 0) then if (Message.Result <> 0) then
Exit; Exit;
if Message.XPos <> -1 then if Message.XPos <> -1 then
begin begin
// don't allow disabled and don't search wincontrols - they recieve their // don't allow disabled and don't search wincontrols - they receive their
// message themself // message themself
Child := ControlAtPos(ScreenToClient(SmallPointToPoint(Message.Pos)), []); Child := ControlAtPos(ScreenToClient(SmallPointToPoint(Message.Pos)), []);
if Assigned(Child) then if Assigned(Child) then

View File

@ -1509,9 +1509,9 @@ var
Info: PWidgetInfo; Info: PWidgetInfo;
Old: TObject; Old: TObject;
Mess: TLMessage; Mess: TLMessage;
{$IFDEF VerboseMouseBugfix} { $IFDEF VerboseMouseBugfix}
AWinControl: TWinControl; AWinControl: TWinControl;
{$ENDIF} { $ENDIF}
begin begin
Result := CallBackDefaultReturn; Result := CallBackDefaultReturn;
@ -1535,6 +1535,15 @@ begin
ResetDefaultIMContext; ResetDefaultIMContext;
UpdateMouseCaptureControl; UpdateMouseCaptureControl;
//debugln('[gtkMouseBtnPress] calling DeliverMouseDownMessage Result=',dbgs(Result));
{$IFDEF Gtk2CallMouseDownBeforeContext}
if DeliverMouseDownMessage(Widget, Event, TWinControl(Data))<>0 then begin
//debugln(['[gtkMouseBtnPress] DeliverMouseDownMessage handled, stopping event']);
g_signal_stop_emission_by_name(PGTKObject(Widget), 'button-press-event');
exit(false);
end;
{$ENDIF}
if not (csDesigning in TComponent(Data).ComponentState) then if not (csDesigning in TComponent(Data).ComponentState) then
begin begin
// fix gtklist selection first // fix gtklist selection first
@ -1603,8 +1612,12 @@ begin
g_signal_stop_emission_by_name(PGTKObject(Widget), 'button-press-event'); g_signal_stop_emission_by_name(PGTKObject(Widget), 'button-press-event');
end; end;
end; end;
{$IFDEF Gtk2CallMouseDownBeforeContext}
{$ELSE}
//debugln('[gtkMouseBtnPress] calling DeliverMouseDownMessage Result=',dbgs(Result)); //debugln('[gtkMouseBtnPress] calling DeliverMouseDownMessage Result=',dbgs(Result));
DeliverMouseDownMessage(Widget, Event, TWinControl(Data)); DeliverMouseDownMessage(Widget, Event, TWinControl(Data));
{$ENDIF}
//debugln(['gtkMouseBtnPress END Control=',DbgSName(TObject(Data))]);
end; end;
@ -1614,8 +1627,8 @@ end;
Translate a gdk mouse press event into a LCL mouse down message and send it. Translate a gdk mouse press event into a LCL mouse down message and send it.
-------------------------------------------------------------------------------} -------------------------------------------------------------------------------}
procedure DeliverMouseDownMessage(widget: PGtkWidget; event : pgdkEventButton; function DeliverMouseDownMessage(widget: PGtkWidget; event : pgdkEventButton;
AWinControl: TWinControl); AWinControl: TWinControl): PtrInt;
const const
LastModifierKeys: TShiftState = []; LastModifierKeys: TShiftState = [];
WHEEL_DELTA : array[Boolean] of Integer = (-120, 120); WHEEL_DELTA : array[Boolean] of Integer = (-120, 120);
@ -1739,7 +1752,7 @@ var
end; end;
begin begin
Result := 0;
EventXY := Point(TruncToInt(Event^.X), TruncToInt(Event^.Y)); EventXY := Point(TruncToInt(Event^.X), TruncToInt(Event^.Y));
ShiftState := GTKEventStateToShiftState(Event^.State); ShiftState := GTKEventStateToShiftState(Event^.State);
@ -1769,7 +1782,7 @@ begin
// send the message directly to the LCL // send the message directly to the LCL
NotifyApplicationUserInput(MessE.Msg); NotifyApplicationUserInput(MessE.Msg);
DeliverMessage(AWinControl, MessE); Result:=DeliverMessage(AWinControl, MessE);
end end
else else
begin begin
@ -1800,7 +1813,7 @@ begin
MessI.Result:=0; MessI.Result:=0;
// send the message directly to the LCL // send the message directly to the LCL
NotifyApplicationUserInput(MessI.Msg); NotifyApplicationUserInput(MessI.Msg);
DeliverMessage(AWinControl, MessI); Result := DeliverMessage(AWinControl, MessI);
end; end;
end; end;

View File

@ -147,8 +147,8 @@ function GTKMotionNotifyAfter(widget:PGTKWidget; event: PGDKEventMotion;
data: gPointer): GBoolean; cdecl; data: gPointer): GBoolean; cdecl;
function ControlGetsMouseDownBefore(AControl: TControl; function ControlGetsMouseDownBefore(AControl: TControl;
AWidget: PGtkWidget): boolean; AWidget: PGtkWidget): boolean;
procedure DeliverMouseDownMessage(widget: PGtkWidget; event: pgdkEventButton; function DeliverMouseDownMessage(widget: PGtkWidget; event: pgdkEventButton;
AWinControl: TWinControl); AWinControl: TWinControl): PtrInt;
function gtk2ScrollBarMouseBtnPress(widget: PGtkWidget; event: pgdkEventButton; function gtk2ScrollBarMouseBtnPress(widget: PGtkWidget; event: pgdkEventButton;
data: gPointer): GBoolean; cdecl; data: gPointer): GBoolean; cdecl;