mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-02 18:23:44 +02:00
gtk2 intf: clean up old mouse capture
git-svn-id: trunk@37032 -
This commit is contained in:
parent
5c73765c8b
commit
53e5a4ea10
@ -714,7 +714,6 @@ begin
|
||||
if (Widget=nil) or (Event=nil) then ;
|
||||
|
||||
ResetDefaultIMContext;
|
||||
UpdateMouseCaptureControl;
|
||||
|
||||
FillChar(Mess{%H-},SizeOf(Mess),#0);
|
||||
{$IFDEF VerboseFocus}
|
||||
@ -791,7 +790,6 @@ begin
|
||||
DebugLn(' LCLObject=nil');
|
||||
{$ENDIF}
|
||||
ResetDefaultIMContext;
|
||||
UpdateMouseCaptureControl;
|
||||
|
||||
Info := GetWidgetInfo(Widget,false);
|
||||
try
|
||||
@ -962,7 +960,6 @@ begin
|
||||
end;
|
||||
|
||||
ResetDefaultIMContext;
|
||||
UpdateMouseCaptureControl;
|
||||
|
||||
//TODO: fill in old focus
|
||||
FillChar(Mess{%H-}, SizeOf(Mess), 0);
|
||||
@ -1069,7 +1066,6 @@ begin
|
||||
{$ENDIF}
|
||||
|
||||
ResetDefaultIMContext;
|
||||
UpdateMouseCaptureControl;
|
||||
|
||||
FillChar(Mess{%H-},SizeOf(Mess),0);
|
||||
Mess.msg := LM_KILLFOCUS;
|
||||
@ -1445,8 +1441,6 @@ begin
|
||||
);
|
||||
{$ENDIF}
|
||||
|
||||
UpdateMouseCaptureControl;
|
||||
|
||||
ShiftState := GTKEventStateToShiftState(Event^.State);
|
||||
|
||||
if (ShiftState*[ssShift, ssCtrl, ssAlt, ssSuper] <> LastModifierKeys) or NeedShiftUpdateAfternFocus
|
||||
@ -1518,8 +1512,6 @@ begin
|
||||
// stop the signal, so that it is not sent to the parent widgets
|
||||
g_signal_stop_emission_by_name(PGTKObject(Widget),'motion-notify-event');
|
||||
|
||||
UpdateMouseCaptureControl;
|
||||
|
||||
if (csDesigning in TComponent(Data).ComponentState) then exit;
|
||||
if ControlGetsMouseMoveBefore(TControl(Data), True, Event) then exit;
|
||||
|
||||
@ -1782,7 +1774,6 @@ begin
|
||||
{$ENDIF}
|
||||
|
||||
ResetDefaultIMContext;
|
||||
UpdateMouseCaptureControl;
|
||||
|
||||
//debugln('[gtkMouseBtnPress] calling DeliverMouseDownMessage Result=',dbgs(Result));
|
||||
{$IFDEF Gtk2CallMouseDownBeforeContext}
|
||||
@ -2108,7 +2099,6 @@ begin
|
||||
{$ENDIF}
|
||||
|
||||
ResetDefaultIMContext;
|
||||
UpdateMouseCaptureControl;
|
||||
|
||||
// stop the signal, so that it is not sent to the parent widgets
|
||||
g_signal_stop_emission_by_name(PGTKObject(Widget), 'button-press-event');
|
||||
@ -2242,7 +2232,6 @@ begin
|
||||
//' GDK_BUTTON_RELEASE_MASK=',DbgS(GDK_BUTTON_RELEASE_MASK));
|
||||
|
||||
ResetDefaultIMContext;
|
||||
UpdateMouseCaptureControl;
|
||||
|
||||
if not (csDesigning in TComponent(Data).ComponentState) then
|
||||
begin
|
||||
@ -2301,7 +2290,6 @@ begin
|
||||
g_signal_stop_emission_by_name(PGTKObject(Widget),'button-release-event');
|
||||
|
||||
ResetDefaultIMContext;
|
||||
UpdateMouseCaptureControl;
|
||||
|
||||
if (csDesigning in TComponent(Data).ComponentState) then exit;
|
||||
if ControlGetsMouseUpBefore(TControl(Data)) then exit;
|
||||
|
@ -4566,46 +4566,6 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Function: UpdateMouseCaptureControl
|
||||
Params: none
|
||||
Returns: none
|
||||
|
||||
Sets MouseCaptureWidget to the current capturing widget.
|
||||
------------------------------------------------------------------------------}
|
||||
procedure UpdateMouseCaptureControl;
|
||||
var
|
||||
OldMouseCaptureWidget,
|
||||
CurMouseCaptureWidget: PGtkWidget;
|
||||
begin
|
||||
{$IFNDEF GTK2_USE_OLD_CAPTURE}
|
||||
exit;
|
||||
{$ENDIF}
|
||||
OldMouseCaptureWidget:=MouseCaptureWidget;
|
||||
CurMouseCaptureWidget:=gtk_grab_get_current;
|
||||
|
||||
if OldMouseCaptureWidget<>CurMouseCaptureWidget then begin
|
||||
// the mouse grab changed
|
||||
// -> this means the gtk itself has changed the mouse grab
|
||||
{$IFDEF VerboseMouseCapture}
|
||||
DebugLn('UpdateMouseCaptureControl Capture changed from ',
|
||||
'[',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
|
||||
MouseCaptureWidget:=CurMouseCaptureWidget;
|
||||
MouseCaptureType:=mctGTK;
|
||||
if MouseCaptureWidget<>nil then begin
|
||||
// the MouseCaptureWidget is probably not a main widget
|
||||
SendMessage(HWnd({%H-}PtrUInt(MouseCaptureWidget)), LM_CAPTURECHANGED, 0,
|
||||
HWnd({%H-}PtrUInt(OldMouseCaptureWidget)));
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure IncreaseMouseCaptureIndex;
|
||||
begin
|
||||
if MouseCaptureIndex<$ffffffff then
|
||||
@ -4614,49 +4574,6 @@ begin
|
||||
MouseCaptureIndex:=0;
|
||||
end;
|
||||
|
||||
{$IFDEF GTK2_USE_OLD_CAPTURE}
|
||||
procedure CaptureMouseForWidget(Widget: PGtkWidget; Owner: TMouseCaptureType);
|
||||
var
|
||||
CaptureWidget: PGtkWidget;
|
||||
NowIndex: Cardinal;
|
||||
begin
|
||||
{$IFDEF VerboseMouseCapture}
|
||||
DebugLn('CaptureMouseForWidget START ',GetWidgetDebugReport(Widget));
|
||||
{$ENDIF}
|
||||
if not (Owner in [mctGTKIntf,mctLCL]) then exit;
|
||||
// not every widget can capture the mouse
|
||||
CaptureWidget := GetDefaultMouseCaptureWidget(Widget);
|
||||
if CaptureWidget=nil then exit;
|
||||
|
||||
UpdateMouseCaptureControl;
|
||||
if (MouseCaptureType<>mctGTK) then begin
|
||||
// we are capturing
|
||||
if (MouseCaptureWidget=CaptureWidget) then begin
|
||||
// we are already capturing this widget
|
||||
exit;
|
||||
end;
|
||||
// release old capture
|
||||
ReleaseMouseCapture;
|
||||
end;
|
||||
|
||||
{$IFDEF VerboseMouseCapture}
|
||||
DebugLn('CaptureMouseForWidget Start Capturing for ',GetWidgetDebugReport(CaptureWidget));
|
||||
{$ENDIF}
|
||||
IncreaseMouseCaptureIndex;
|
||||
NowIndex:=MouseCaptureIndex;
|
||||
if not gtk_widget_has_focus(CaptureWidget) then
|
||||
gtk_widget_grab_focus(CaptureWidget);
|
||||
if NowIndex=MouseCaptureIndex then begin
|
||||
{$IFDEF VerboseMouseCapture}
|
||||
DebugLn('CaptureMouseForWidget Commit Capturing for ',GetWidgetDebugReport(CaptureWidget));
|
||||
{$ENDIF}
|
||||
MouseCaptureWidget:=CaptureWidget;
|
||||
MouseCaptureType:=Owner;
|
||||
gtk_grab_add(CaptureWidget);
|
||||
end;
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
function GetDefaultMouseCaptureWidget(Widget: PGtkWidget
|
||||
): PGtkWidget;
|
||||
var
|
||||
@ -4717,9 +4634,6 @@ begin
|
||||
Result := WidgetInfo^.ClientWidget
|
||||
else
|
||||
Result := WidgetInfo^.CoreWidget;
|
||||
{$IFDEF GTK2_USE_OLD_CAPTURE}
|
||||
end;
|
||||
{$ELSE}
|
||||
end else
|
||||
if GTK_IS_SCROLLED_WINDOW(Widget) and (GTK_IS_BIN(Widget)) then
|
||||
begin
|
||||
@ -4728,7 +4642,6 @@ begin
|
||||
{$ENDIF}
|
||||
Result := gtk_bin_get_child(PGtkBin(Widget));
|
||||
end;
|
||||
{$ENDIF}
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
@ -470,13 +470,9 @@ function TranslateGdkPointToClientArea(SourceWindow: PGdkWindow;
|
||||
function SubtractScoll(AWidget: PGtkWidget; APosition: TPoint): TPoint;
|
||||
|
||||
// mouse capturing
|
||||
{$IFDEF GTK2_USE_OLD_CAPTURE}
|
||||
procedure CaptureMouseForWidget(Widget: PGtkWidget; Owner: TMouseCaptureType);
|
||||
{$ENDIF}
|
||||
function GetDefaultMouseCaptureWidget(Widget: PGtkWidget): PGtkWidget;
|
||||
procedure ReleaseMouseCapture;
|
||||
procedure ReleaseCaptureWidget(Widget : PGtkWidget);
|
||||
procedure UpdateMouseCaptureControl;
|
||||
|
||||
|
||||
const
|
||||
|
@ -8275,9 +8275,7 @@ end;
|
||||
function TGtk2WidgetSet.SetCapture(AHandle: HWND): HWND;
|
||||
var
|
||||
Widget: PGtkWidget;
|
||||
{$IFNDEF GTK2_USE_OLD_CAPTURE}
|
||||
CaptureWidget: PGtkWidget;
|
||||
{$ENDIF}
|
||||
begin
|
||||
Widget := {%H-}PGtkWidget(AHandle);
|
||||
{$IfDef VerboseMouseCapture}
|
||||
@ -8287,11 +8285,6 @@ begin
|
||||
// return old capture handle
|
||||
Result := GetCapture;
|
||||
|
||||
{$IFDEF GTK2_USE_OLD_CAPTURE}
|
||||
// capture
|
||||
CaptureMouseForWidget(Widget, mctLCL);
|
||||
{$ELSE}
|
||||
|
||||
if Result <> 0 then
|
||||
gtk_grab_remove(gtk_grab_get_current);
|
||||
|
||||
@ -8307,7 +8300,6 @@ begin
|
||||
MouseCaptureWidget := CaptureWidget;
|
||||
if MouseCaptureWidget<>nil then
|
||||
SendMessage(HWnd({%H-}PtrUInt(MouseCaptureWidget)), LM_CAPTURECHANGED, 0, Result);
|
||||
{$ENDIF}
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user