mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 17:01:35 +02:00
gtk2 intf: fixed gtk2GrabNotify, added comment
git-svn-id: trunk@37290 -
This commit is contained in:
parent
7f05ade0fb
commit
3bcdf39bcb
@ -245,6 +245,7 @@ const
|
|||||||
{$ifdef GTK_2_10}
|
{$ifdef GTK_2_10}
|
||||||
function gdk_screen_is_composited(screen: PGdkScreen): gboolean; cdecl; external gdklib;
|
function gdk_screen_is_composited(screen: PGdkScreen): gboolean; cdecl; external gdklib;
|
||||||
{$endif}
|
{$endif}
|
||||||
|
function gtk_window_get_group(window:PGtkWindow):PGtkWindowGroup; cdecl; external gtklib;
|
||||||
|
|
||||||
type
|
type
|
||||||
TGtkTreeViewGridLines = cardinal;
|
TGtkTreeViewGridLines = cardinal;
|
||||||
|
@ -4703,6 +4703,21 @@ begin
|
|||||||
ReleaseMouseCapture;
|
ReleaseMouseCapture;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function GetGtkWindowGroup(Widget: PGtkWidget): PGtkWindowGroup;
|
||||||
|
var
|
||||||
|
toplevel: PGtkWidget;
|
||||||
|
begin
|
||||||
|
if Widget<>nil then
|
||||||
|
toplevel:=gtk_widget_get_toplevel(Widget)
|
||||||
|
else
|
||||||
|
toplevel:=nil;
|
||||||
|
|
||||||
|
if GTK_IS_WINDOW (toplevel) then
|
||||||
|
Result:=gtk_window_get_group(GTK_WINDOW(toplevel))
|
||||||
|
else
|
||||||
|
Result:=gtk_window_get_group(nil);
|
||||||
|
end;
|
||||||
|
|
||||||
{-------------------------------------------------------------------------------
|
{-------------------------------------------------------------------------------
|
||||||
procedure: SignalConnect
|
procedure: SignalConnect
|
||||||
Params: AWidget: PGTKWidget
|
Params: AWidget: PGTKWidget
|
||||||
|
@ -474,6 +474,8 @@ function GetDefaultMouseCaptureWidget(Widget: PGtkWidget): PGtkWidget;
|
|||||||
procedure ReleaseMouseCapture;
|
procedure ReleaseMouseCapture;
|
||||||
procedure ReleaseCaptureWidget(Widget : PGtkWidget);
|
procedure ReleaseCaptureWidget(Widget : PGtkWidget);
|
||||||
|
|
||||||
|
// window group
|
||||||
|
function GetGtkWindowGroup(Widget: PGtkWidget): PGtkWindowGroup;
|
||||||
|
|
||||||
const
|
const
|
||||||
// for now return the same value, in the future we may want to return an
|
// for now return the same value, in the future we may want to return an
|
||||||
|
@ -149,24 +149,28 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function gtk2GrabNotify(widget: PGtkWidget; grabbed: GBoolean; {%H-}data: GPointer): GBoolean; cdecl;
|
function gtk2GrabNotify(widget: PGtkWidget; grabbed: GBoolean; {%H-}data: GPointer): GBoolean; cdecl;
|
||||||
|
// called for all widgets on every gtk_grab_add and gtk_grab_remove
|
||||||
|
// grabbed = true if called by gtk_grab_remove
|
||||||
|
// grabbed = false if called by gtk_grab_add
|
||||||
var
|
var
|
||||||
W: PGtkWidget;
|
CurCaptureWidget: PGtkWidget;
|
||||||
WidgetInfo: PWidgetInfo;
|
|
||||||
begin
|
begin
|
||||||
|
{$IFDEF VerboseMouseCapture}
|
||||||
|
//debugln(['gtk2GrabNotify ',GetWidgetDebugReport(widget),' grabbed=',grabbed,' MouseCaptureWidget=',dbgs(MouseCaptureWidget)]);
|
||||||
|
{$ENDIF}
|
||||||
Result := CallBackDefaultReturn;
|
Result := CallBackDefaultReturn;
|
||||||
if Grabbed then
|
if Grabbed then
|
||||||
begin
|
begin
|
||||||
w := gtk_grab_get_current;
|
// grab release
|
||||||
if MouseCaptureWidget <> nil then
|
CurCaptureWidget := gtk_grab_get_current;
|
||||||
WidgetInfo := GetWidgetInfo(MouseCaptureWidget)
|
if (MouseCaptureWidget<>nil)
|
||||||
else
|
and ((CurCaptureWidget=nil) or (CurCaptureWidget = MouseCaptureWidget)) then
|
||||||
WidgetInfo := nil;
|
|
||||||
|
|
||||||
if (WidgetInfo <> nil) and (W = MouseCaptureWidget) and (W <> Widget)
|
|
||||||
and (WidgetInfo^.ClientWidget = nil) then
|
|
||||||
begin
|
begin
|
||||||
Result := True;
|
{$IFDEF VerboseMouseCapture}
|
||||||
ReleaseCaptureWidget(W);
|
debugln(['gtk2GrabNotify ungrab ',GetWidgetDebugReport(widget),' grabbed=',grabbed,' MouseCaptureWidget=',dbgs(MouseCaptureWidget)]);
|
||||||
|
{$ENDIF}
|
||||||
|
//Result := True;
|
||||||
|
ReleaseCaptureWidget(MouseCaptureWidget);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -8278,6 +8278,8 @@ var
|
|||||||
CaptureWidget: PGtkWidget;
|
CaptureWidget: PGtkWidget;
|
||||||
{$IfDef VerboseMouseCapture}
|
{$IfDef VerboseMouseCapture}
|
||||||
toplevel: PGtkWidget;
|
toplevel: PGtkWidget;
|
||||||
|
WndGroup: PGtkWindowGroup;
|
||||||
|
DefWndGroup: PGtkWindowGroup;
|
||||||
{$EndIf}
|
{$EndIf}
|
||||||
begin
|
begin
|
||||||
Widget := {%H-}PGtkWidget(AHandle);
|
Widget := {%H-}PGtkWidget(AHandle);
|
||||||
@ -8288,12 +8290,20 @@ begin
|
|||||||
// return old capture handle
|
// return old capture handle
|
||||||
Result := GetCapture;
|
Result := GetCapture;
|
||||||
|
|
||||||
if Result <> 0 then begin
|
if (Result <> 0) then begin
|
||||||
{$IfDef VerboseMouseCapture}
|
{$IfDef VerboseMouseCapture}
|
||||||
DebugLn('TGtk2WidgetSet.SetCapture gtk_grab_remove=[',GetWidgetDebugReport(gtk_grab_get_current),']');
|
DebugLn('TGtk2WidgetSet.SetCapture gtk_grab_remove=[',GetWidgetDebugReport(gtk_grab_get_current),']');
|
||||||
{$EndIf}
|
{$EndIf}
|
||||||
gtk_grab_remove(gtk_grab_get_current);
|
gtk_grab_remove(gtk_grab_get_current);
|
||||||
end;
|
end;
|
||||||
|
if (MouseCaptureWidget<>nil) and (gtk_grab_get_current=nil)
|
||||||
|
and (GTK_WIDGET_HAS_GRAB(MouseCaptureWidget))
|
||||||
|
then begin
|
||||||
|
{$IfDef VerboseMouseCapture}
|
||||||
|
DebugLn('TGtk2WidgetSet.SetCapture gtk_grab_get_current=nil, but GTK_WIDGET_HAS_GRAB(MouseCaptureWidget)=true => gtk_grab_remove=[',GetWidgetDebugReport(MouseCaptureWidget),']');
|
||||||
|
{$EndIf}
|
||||||
|
gtk_grab_remove(MouseCaptureWidget);
|
||||||
|
end;
|
||||||
|
|
||||||
MouseCaptureWidget := nil;
|
MouseCaptureWidget := nil;
|
||||||
|
|
||||||
@ -8312,13 +8322,11 @@ begin
|
|||||||
// ToDo: find out how to grab LCLWinapiClient with ubuntu liboverlay
|
// ToDo: find out how to grab LCLWinapiClient with ubuntu liboverlay
|
||||||
if GtkWidgetIsA(Widget,GTK_TYPE_SCROLLED_WINDOW) then
|
if GtkWidgetIsA(Widget,GTK_TYPE_SCROLLED_WINDOW) then
|
||||||
begin
|
begin
|
||||||
debugln(['TGtk2WidgetSet.SetCapture AAA1 is api widget ',
|
debugln(['TGtk2WidgetSet.SetCapture is api widget ',
|
||||||
' widget=',GetWidgetClassName(Widget),
|
' widget=',GetWidgetClassName(Widget),
|
||||||
' container.container.focus_child=',GetWidgetClassName(PGtkScrolledWindow(Widget)^.container.container.focus_child),
|
' container.container.focus_child=',GetWidgetClassName(PGtkScrolledWindow(Widget)^.container.container.focus_child),
|
||||||
' container.child=',GetWidgetClassName(PGtkScrolledWindow(Widget)^.container.child),
|
' container.child=',GetWidgetClassName(PGtkScrolledWindow(Widget)^.container.child),
|
||||||
'']);
|
'']);
|
||||||
debugln(['TGtk2WidgetSet.SetCapture gtk_widget_is_sensitive=',gtk_widget_is_sensitive(CaptureWidget)]);
|
|
||||||
debugln(['TGtk2WidgetSet.SetCapture gtk_widget_has_grab=',gtk_widget_has_grab (CaptureWidget)]);
|
|
||||||
//CaptureWidget:=PGtkScrolledWindow(Widget)^.container;
|
//CaptureWidget:=PGtkScrolledWindow(Widget)^.container;
|
||||||
end;
|
end;
|
||||||
{$EndIf}
|
{$EndIf}
|
||||||
@ -8331,18 +8339,29 @@ begin
|
|||||||
then begin
|
then begin
|
||||||
debugln(['WARNING: TGtk2WidgetSet.SetCapture capturewidget is offscreen']);
|
debugln(['WARNING: TGtk2WidgetSet.SetCapture capturewidget is offscreen']);
|
||||||
end;
|
end;
|
||||||
|
WndGroup := GetGtkWindowGroup(CaptureWidget);
|
||||||
|
DefWndGroup:=GetGtkWindowGroup(CaptureWidget);
|
||||||
|
debugln(['TGtk2WidgetSet.SetCapture WndGroup=',dbgs(WndGroup),' DefWndGroup=',dbgs(DefWndGroup),' same=',WndGroup=DefWndGroup]);
|
||||||
// Note: liboverlay: gtk_grab_add sets gtk_widget_has_grab, but gtk_grab_get_current returns nil
|
// Note: liboverlay: gtk_grab_add sets gtk_widget_has_grab, but gtk_grab_get_current returns nil
|
||||||
// ToDo: check window group
|
// ToDo: check window group
|
||||||
{$EndIf}
|
{$EndIf}
|
||||||
gtk_grab_add(CaptureWidget);
|
|
||||||
{$IfDef VerboseMouseCapture}
|
|
||||||
if gtk_grab_get_current=CaptureWidget then
|
|
||||||
DebugLn('TGtk2WidgetSet.SetCapture success gtk_grab_get_current=[',GetWidgetDebugReport(gtk_grab_get_current),']')
|
|
||||||
else
|
|
||||||
DebugLn('WARNING: TGtk2WidgetSet.SetCapture failed gtk_grab_get_current=[',GetWidgetDebugReport(gtk_grab_get_current),']');
|
|
||||||
{$EndIf}
|
|
||||||
|
|
||||||
MouseCaptureWidget := CaptureWidget;
|
MouseCaptureWidget := CaptureWidget;
|
||||||
|
gtk_grab_add(CaptureWidget);
|
||||||
|
if gtk_grab_get_current=CaptureWidget then
|
||||||
|
begin
|
||||||
|
{$IfDef VerboseMouseCapture}
|
||||||
|
DebugLn('TGtk2WidgetSet.SetCapture gtk_grab_add success: gtk_grab_get_current=[',GetWidgetDebugReport(gtk_grab_get_current),']')
|
||||||
|
{$EndIf}
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
{$IfDef VerboseMouseCapture}
|
||||||
|
if gtk_widget_has_grab(CaptureWidget) then
|
||||||
|
DebugLn('WARNING: TGtk2WidgetSet.SetCapture gtk_grab_add failed (partial success): gtk_grab_get_current=[',GetWidgetDebugReport(gtk_grab_get_current),'] has_grab=true')
|
||||||
|
else
|
||||||
|
DebugLn('WARNING: TGtk2WidgetSet.SetCapture gtk_grab_add failed (complete): gtk_grab_get_current=[',GetWidgetDebugReport(gtk_grab_get_current),'] has_grab=false');
|
||||||
|
{$EndIf}
|
||||||
|
end;
|
||||||
|
|
||||||
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);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user