mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-05-07 09:33:13 +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 ;
|
if (Widget=nil) or (Event=nil) then ;
|
||||||
|
|
||||||
ResetDefaultIMContext;
|
ResetDefaultIMContext;
|
||||||
UpdateMouseCaptureControl;
|
|
||||||
|
|
||||||
FillChar(Mess{%H-},SizeOf(Mess),#0);
|
FillChar(Mess{%H-},SizeOf(Mess),#0);
|
||||||
{$IFDEF VerboseFocus}
|
{$IFDEF VerboseFocus}
|
||||||
@ -791,7 +790,6 @@ begin
|
|||||||
DebugLn(' LCLObject=nil');
|
DebugLn(' LCLObject=nil');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
ResetDefaultIMContext;
|
ResetDefaultIMContext;
|
||||||
UpdateMouseCaptureControl;
|
|
||||||
|
|
||||||
Info := GetWidgetInfo(Widget,false);
|
Info := GetWidgetInfo(Widget,false);
|
||||||
try
|
try
|
||||||
@ -962,7 +960,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
ResetDefaultIMContext;
|
ResetDefaultIMContext;
|
||||||
UpdateMouseCaptureControl;
|
|
||||||
|
|
||||||
//TODO: fill in old focus
|
//TODO: fill in old focus
|
||||||
FillChar(Mess{%H-}, SizeOf(Mess), 0);
|
FillChar(Mess{%H-}, SizeOf(Mess), 0);
|
||||||
@ -1069,7 +1066,6 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
ResetDefaultIMContext;
|
ResetDefaultIMContext;
|
||||||
UpdateMouseCaptureControl;
|
|
||||||
|
|
||||||
FillChar(Mess{%H-},SizeOf(Mess),0);
|
FillChar(Mess{%H-},SizeOf(Mess),0);
|
||||||
Mess.msg := LM_KILLFOCUS;
|
Mess.msg := LM_KILLFOCUS;
|
||||||
@ -1445,8 +1441,6 @@ begin
|
|||||||
);
|
);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
UpdateMouseCaptureControl;
|
|
||||||
|
|
||||||
ShiftState := GTKEventStateToShiftState(Event^.State);
|
ShiftState := GTKEventStateToShiftState(Event^.State);
|
||||||
|
|
||||||
if (ShiftState*[ssShift, ssCtrl, ssAlt, ssSuper] <> LastModifierKeys) or NeedShiftUpdateAfternFocus
|
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
|
// stop the signal, so that it is not sent to the parent widgets
|
||||||
g_signal_stop_emission_by_name(PGTKObject(Widget),'motion-notify-event');
|
g_signal_stop_emission_by_name(PGTKObject(Widget),'motion-notify-event');
|
||||||
|
|
||||||
UpdateMouseCaptureControl;
|
|
||||||
|
|
||||||
if (csDesigning in TComponent(Data).ComponentState) then exit;
|
if (csDesigning in TComponent(Data).ComponentState) then exit;
|
||||||
if ControlGetsMouseMoveBefore(TControl(Data), True, Event) then exit;
|
if ControlGetsMouseMoveBefore(TControl(Data), True, Event) then exit;
|
||||||
|
|
||||||
@ -1782,7 +1774,6 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
ResetDefaultIMContext;
|
ResetDefaultIMContext;
|
||||||
UpdateMouseCaptureControl;
|
|
||||||
|
|
||||||
//debugln('[gtkMouseBtnPress] calling DeliverMouseDownMessage Result=',dbgs(Result));
|
//debugln('[gtkMouseBtnPress] calling DeliverMouseDownMessage Result=',dbgs(Result));
|
||||||
{$IFDEF Gtk2CallMouseDownBeforeContext}
|
{$IFDEF Gtk2CallMouseDownBeforeContext}
|
||||||
@ -2108,7 +2099,6 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
|
||||||
ResetDefaultIMContext;
|
ResetDefaultIMContext;
|
||||||
UpdateMouseCaptureControl;
|
|
||||||
|
|
||||||
// stop the signal, so that it is not sent to the parent widgets
|
// stop the signal, so that it is not sent to the parent widgets
|
||||||
g_signal_stop_emission_by_name(PGTKObject(Widget), 'button-press-event');
|
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));
|
//' GDK_BUTTON_RELEASE_MASK=',DbgS(GDK_BUTTON_RELEASE_MASK));
|
||||||
|
|
||||||
ResetDefaultIMContext;
|
ResetDefaultIMContext;
|
||||||
UpdateMouseCaptureControl;
|
|
||||||
|
|
||||||
if not (csDesigning in TComponent(Data).ComponentState) then
|
if not (csDesigning in TComponent(Data).ComponentState) then
|
||||||
begin
|
begin
|
||||||
@ -2301,7 +2290,6 @@ begin
|
|||||||
g_signal_stop_emission_by_name(PGTKObject(Widget),'button-release-event');
|
g_signal_stop_emission_by_name(PGTKObject(Widget),'button-release-event');
|
||||||
|
|
||||||
ResetDefaultIMContext;
|
ResetDefaultIMContext;
|
||||||
UpdateMouseCaptureControl;
|
|
||||||
|
|
||||||
if (csDesigning in TComponent(Data).ComponentState) then exit;
|
if (csDesigning in TComponent(Data).ComponentState) then exit;
|
||||||
if ControlGetsMouseUpBefore(TControl(Data)) then exit;
|
if ControlGetsMouseUpBefore(TControl(Data)) then exit;
|
||||||
|
@ -4566,46 +4566,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
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;
|
procedure IncreaseMouseCaptureIndex;
|
||||||
begin
|
begin
|
||||||
if MouseCaptureIndex<$ffffffff then
|
if MouseCaptureIndex<$ffffffff then
|
||||||
@ -4614,49 +4574,6 @@ begin
|
|||||||
MouseCaptureIndex:=0;
|
MouseCaptureIndex:=0;
|
||||||
end;
|
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
|
function GetDefaultMouseCaptureWidget(Widget: PGtkWidget
|
||||||
): PGtkWidget;
|
): PGtkWidget;
|
||||||
var
|
var
|
||||||
@ -4717,9 +4634,6 @@ begin
|
|||||||
Result := WidgetInfo^.ClientWidget
|
Result := WidgetInfo^.ClientWidget
|
||||||
else
|
else
|
||||||
Result := WidgetInfo^.CoreWidget;
|
Result := WidgetInfo^.CoreWidget;
|
||||||
{$IFDEF GTK2_USE_OLD_CAPTURE}
|
|
||||||
end;
|
|
||||||
{$ELSE}
|
|
||||||
end else
|
end else
|
||||||
if GTK_IS_SCROLLED_WINDOW(Widget) and (GTK_IS_BIN(Widget)) then
|
if GTK_IS_SCROLLED_WINDOW(Widget) and (GTK_IS_BIN(Widget)) then
|
||||||
begin
|
begin
|
||||||
@ -4728,7 +4642,6 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Result := gtk_bin_get_child(PGtkBin(Widget));
|
Result := gtk_bin_get_child(PGtkBin(Widget));
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -470,13 +470,9 @@ function TranslateGdkPointToClientArea(SourceWindow: PGdkWindow;
|
|||||||
function SubtractScoll(AWidget: PGtkWidget; APosition: TPoint): TPoint;
|
function SubtractScoll(AWidget: PGtkWidget; APosition: TPoint): TPoint;
|
||||||
|
|
||||||
// mouse capturing
|
// mouse capturing
|
||||||
{$IFDEF GTK2_USE_OLD_CAPTURE}
|
|
||||||
procedure CaptureMouseForWidget(Widget: PGtkWidget; Owner: TMouseCaptureType);
|
|
||||||
{$ENDIF}
|
|
||||||
function GetDefaultMouseCaptureWidget(Widget: PGtkWidget): PGtkWidget;
|
function GetDefaultMouseCaptureWidget(Widget: PGtkWidget): PGtkWidget;
|
||||||
procedure ReleaseMouseCapture;
|
procedure ReleaseMouseCapture;
|
||||||
procedure ReleaseCaptureWidget(Widget : PGtkWidget);
|
procedure ReleaseCaptureWidget(Widget : PGtkWidget);
|
||||||
procedure UpdateMouseCaptureControl;
|
|
||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
|
@ -8275,9 +8275,7 @@ end;
|
|||||||
function TGtk2WidgetSet.SetCapture(AHandle: HWND): HWND;
|
function TGtk2WidgetSet.SetCapture(AHandle: HWND): HWND;
|
||||||
var
|
var
|
||||||
Widget: PGtkWidget;
|
Widget: PGtkWidget;
|
||||||
{$IFNDEF GTK2_USE_OLD_CAPTURE}
|
|
||||||
CaptureWidget: PGtkWidget;
|
CaptureWidget: PGtkWidget;
|
||||||
{$ENDIF}
|
|
||||||
begin
|
begin
|
||||||
Widget := {%H-}PGtkWidget(AHandle);
|
Widget := {%H-}PGtkWidget(AHandle);
|
||||||
{$IfDef VerboseMouseCapture}
|
{$IfDef VerboseMouseCapture}
|
||||||
@ -8287,11 +8285,6 @@ begin
|
|||||||
// return old capture handle
|
// return old capture handle
|
||||||
Result := GetCapture;
|
Result := GetCapture;
|
||||||
|
|
||||||
{$IFDEF GTK2_USE_OLD_CAPTURE}
|
|
||||||
// capture
|
|
||||||
CaptureMouseForWidget(Widget, mctLCL);
|
|
||||||
{$ELSE}
|
|
||||||
|
|
||||||
if Result <> 0 then
|
if Result <> 0 then
|
||||||
gtk_grab_remove(gtk_grab_get_current);
|
gtk_grab_remove(gtk_grab_get_current);
|
||||||
|
|
||||||
@ -8307,7 +8300,6 @@ begin
|
|||||||
MouseCaptureWidget := CaptureWidget;
|
MouseCaptureWidget := CaptureWidget;
|
||||||
if MouseCaptureWidget<>nil then
|
if MouseCaptureWidget<>nil then
|
||||||
SendMessage(HWnd({%H-}PtrUInt(MouseCaptureWidget)), LM_CAPTURECHANGED, 0, Result);
|
SendMessage(HWnd({%H-}PtrUInt(MouseCaptureWidget)), LM_CAPTURECHANGED, 0, Result);
|
||||||
{$ENDIF}
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user