LCL, gtk2, updated VerboseFocus debug info

git-svn-id: trunk@42937 -
This commit is contained in:
jesus 2013-09-25 22:42:13 +00:00
parent c33a15d30d
commit 49a69fc324
3 changed files with 76 additions and 145 deletions

View File

@ -791,33 +791,14 @@ begin
FillChar(Mess{%H-},SizeOf(Mess),#0);
{$IFDEF VerboseFocus}
write('gtkfrmactivateAfter Widget=',DbgS(Widget),' Event^.theIn=',Event^._in);
LCLObject:=TObject(data);
if LCLObject<>nil then begin
if LCLObject is TComponent then begin
write(' LCLObject=',TComponent(LCLObject).Name,':',LCLObject.ClassName)
end else begin
write(' LCLObject=',LCLObject.ClassName)
end;
end else
write(' LCLObject=nil');
DebugLn(''); DbgOut(' ');
DebugLnEnter(['gtkfrmActivateAfter INIT Widget=',DbgS(Widget),' Event^.theIn=',Event^._in,
' LCLObject=',dbgsname(LCLObject)]);
CurFocusWidget:=PGtkWidget(GetFocus);
if CurFocusWidget<>nil then begin
write(' GetFocus=',DbgS(CurFocusWidget));
LCLObject:=GetNearestLCLObject(CurFocusWidget);
if LCLObject<>nil then begin
if LCLObject is TComponent then begin
DbgOut(' ParentLCLFocus=',TComponent(LCLObject).Name,':',LCLObject.ClassName)
end else begin
DbgOut(' ParentLCLFocus=',LCLObject.ClassName)
end;
end else
DbgOut(' LCLObject=nil');
end else begin
DbgOut(' GetFocus=nil');
DebugLn(' GetFocus=',DbgS(CurFocusWidget),' ParentLCLObject=',dbgsName(LCLObject));
end;
DebugLn('');
{$ENDIF}
Info := GetWidgetInfo(Widget, false);
@ -842,6 +823,9 @@ begin
end;
Result := CallBackDefaultReturn;
{$IFDEF VerboseFocus}
DebugLnExit('gtkfrmActivateAfter DONE');
{$ENDIF}
end;
function gtkfrmdeactivateAfter( widget: PGtkWidget; Event : PgdkEventFocus;
@ -858,13 +842,9 @@ begin
{$ENDIF}
if (Widget=nil) or (Event=nil) then ;
{$IFDEF VerboseFocus}
write('gtkfrmdeactivate Widget=',DbgS(Widget),' ',Event^._in,
' GetFocus=',DbgS(Widget));
LCLObject:=TControl(GetLCLObject(Widget));
if LCLObject<>nil then
DebugLn(' LCLObject=',LCLObject.Name,':',LCLObject.ClassName)
else
DebugLn(' LCLObject=nil');
LCLObject := TControl(GetLCLObject(Widget));
DebugLnEnter(['gtkfrmDeactivate INIT Widget=',DbgS(Widget),' ',Event^._in,
' GetFocus=',DbgS(Widget),' LCLObject=', dbgsName(LCLObject)]);
{$ENDIF}
ResetDefaultIMContext;
@ -888,6 +868,9 @@ begin
end;
Result := CallBackDefaultReturn;
{$IFDEF VerboseFocus}
DebugLnExit('gtkfrmDeactivate DONE');
{$ENDIF}
end;
function GTKMap(Widget: PGTKWidget; Data: gPointer): GBoolean; cdecl;
@ -999,40 +982,21 @@ begin
UpdateShiftState(TGtk2WidgetSet(WidgetSet).KeyStateList, GTKEventStateToShiftState(Word(Mask)));
{$IFDEF VerboseFocus}
write('GTKFocusCBAfter Widget=',DbgS(Widget),' Event^.theIn=',Event^._in);
if LCLObject<>nil then begin
if LCLObject is TComponent then begin
write(' LCLObject=',TComponent(LCLObject).Name,':',LCLObject.ClassName)
end else begin
write(' LCLObject=',LCLObject.ClassName)
end;
end else
write(' LCLObject=nil');
DebugLn(''); DbgOut(' ');
DebugLnEnter(['GTKFocusCB INIT Widget=',DbgS(Widget),' Event^.theIn=',Event^._in,
' LCLObject=',dbgsName(LCLObject)]);
CurFocusWidget:=PGtkWidget(GetFocus);
if CurFocusWidget<>nil then begin
write(' GetFocus=',DbgS(CurFocusWidget));
LCLObject:=GetNearestLCLObject(CurFocusWidget);
if LCLObject<>nil then begin
if LCLObject is TComponent then begin
write(' ParentLCLFocus=',TComponent(LCLObject).Name,':',LCLObject.ClassName)
end else begin
write(' ParentLCLFocus=',LCLObject.ClassName);
{$IFDEF VerboseSizeMsg}
DebugLn(['GTKWindowStateEventCB ',DbgSName(TheForm),
' GTK=',GtkWidth,'x',GtkHeight,
' LCL=',TheForm.Width,'x',TheForm.Height,
' SizeType=',SizeMsg.SizeType-Size_SourceIsInterface,'+Size_SourceIsInterface'
]);
{$ENDIF}
// DeliverMessage(TheForm, SizeMsg);
end;
end else
write(' LCLObject=nil');
end else begin
write(' GetFocus=nil');
LCLObject:=GetNearestLCLObject(CurFocusWidget); // NOTE: overrides argument data !!!
DebugLn('GetFocus=',DbgS(CurFocusWidget), ' ParentLCLFocus=',DbgsName(LCLObject));
{$IFDEF VerboseSizeMsg}
DebugLn(['GTKWindowStateEventCB ',DbgSName(TheForm),
' GTK=',GtkWidth,'x',GtkHeight,
' LCL=',TheForm.Width,'x',TheForm.Height,
' SizeType=',SizeMsg.SizeType-Size_SourceIsInterface,'+Size_SourceIsInterface'
]);
{$ENDIF}
LCLObject := TObject(Data); // restore original LCLObject
end;
DebugLn('');
{$ENDIF}
if LCLObject is TCustomForm then begin
@ -1079,6 +1043,9 @@ begin
DeliverMessage(Data, Mess);
Result := CallBackDefaultReturn;
{$IFDEF VerboseFocus}
DebugLnExit('GTKFocusCB DONE');
{$ENDIF}
end;
function GTKKillFocusCB(widget: PGtkWidget; event:PGdkEventFocus;
@ -1095,34 +1062,15 @@ begin
if (Widget=nil) or (Event=nil) then ;
//DebugLn('GTKKillFocusCB ',DbgSName(TObject(Data)),' ',GetWidgetDebugReport(Widget));
{$IFDEF VerboseFocus}
write('GTKillFocusCB Widget=',DbgS(Widget),' Event^.theIn=',Event^._in);
NeedShiftUpdateAfternFocus := True;
NeedShiftUpdateAfternFocus := True; // <- JRA: this doesn't look like simply log !!!
LCLObject:=TObject(data);
if LCLObject<>nil then begin
if LCLObject is TComponent then begin
write(' LCLObject=',TComponent(LCLObject).Name,':',LCLObject.ClassName)
end else begin
write(' LCLObject=',LCLObject.ClassName)
end;
end else
write(' LCLObject=nil');
DebugLn(''); DbgOut(' ');
DebugLn(['GTKillFocusCB Widget=',DbgS(Widget),' Event^.theIn=',Event^._in,
' LCLObject=',dbgsName(LCLobject)]);
CurFocusWidget:=PGtkWidget(GetFocus);
if CurFocusWidget<>nil then begin
write(' GetFocus=',DbgS(CurFocusWidget));
LCLObject:=GetNearestLCLObject(CurFocusWidget);
if LCLObject<>nil then begin
if LCLObject is TComponent then begin
write(' ParentLCLFocus=',TComponent(LCLObject).Name,':',LCLObject.ClassName)
end else begin
write(' ParentLCLFocus=',LCLObject.ClassName)
end;
end else
write(' LCLObject=nil');
end else begin
write(' GetFocus=nil');
DebugLn('GTKillFocusCB GetFocus=',dbgs(CurFocusWidget),' ParentLCLObject=',dbgsName(LCLObject));
end;
DebugLn('');
{$ENDIF}
Result:=CallBackDefaultReturn;
end;
@ -1166,34 +1114,15 @@ begin
{$ENDIF}
//DebugLn('GTKKillFocusCBAfter ',DbgSName(TObject(Data)),' ',GetWidgetDebugReport(Widget));
{$IFDEF VerboseFocus}
write('GTKillFocusCBAfter Widget=',DbgS(Widget),' Event^.theIn=',Event^._in);
NeedShiftUpdateAfternFocus := True;
NeedShiftUpdateAfternFocus := True; // <- JRA: this doesn't look like simply log !!!
LCLObject:=TObject(data);
if LCLObject<>nil then begin
if LCLObject is TComponent then begin
write(' LCLObject=',TComponent(LCLObject).Name,':',LCLObject.ClassName)
end else begin
write(' LCLObject=',LCLObject.ClassName)
end;
end else
write(' LCLObject=nil');
DebugLn(''); DbgOut(' ');
DebugLnEnter(['GTKillFocusCBAfter INIT Widget=',DbgS(Widget),' Event^.theIn=',Event^._in,
' LCLObject=',dbgsName(LCLObject)]);
CurFocusWidget:=PGtkWidget(GetFocus);
if CurFocusWidget<>nil then begin
write(' GetFocus=',DbgS(CurFocusWidget));
LCLObject:=GetNearestLCLObject(CurFocusWidget);
if LCLObject<>nil then begin
if LCLObject is TComponent then begin
write(' ParentLCLFocus=',TComponent(LCLObject).Name,':',LCLObject.ClassName)
end else begin
write(' ParentLCLFocus=',LCLObject.ClassName)
end;
end else
write(' LCLObject=nil');
end else begin
write(' GetFocus=nil');
DebugLn('GetFocus=',DbgS(CurFocusWidget),' ParentLCLFocus=', dbgsName(LCLObject));
end;
DebugLn('');
{$ENDIF}
ResetDefaultIMContext;
@ -1230,6 +1159,9 @@ begin
end;
Result:=true;
{$IFDEF VerboseFocus}
DebugLnExit('GTKillFocusCBAfter DONE');
{$ENDIF}
end;
function GTKWindowStateEventCB(widget: PGtkWidget;

View File

@ -9402,7 +9402,7 @@ begin
then begin
// handle is a gtk combo
{$IfDef VerboseFocus}
DebugLn(' D taking gtkcombo entry');
DebugLn('D taking gtkcombo entry');
{$EndIf}
Result := PgtkWidget(PGtkCombo(AWidget)^.entry);
Exit;
@ -9421,7 +9421,7 @@ begin
if GtkWidgetIsA(ImplWidget, gtk_list_get_type)
then begin
{$IfDef VerboseFocus}
DebugLn(' E using list');
DebugLn('E using list');
{$EndIf}
// Try the last added selected
if not (selection_mode(PGtkList(ImplWidget)^) in [GTK_SELECTION_SINGLE, GTK_SELECTION_BROWSE])
@ -9432,7 +9432,7 @@ begin
then begin
Result := PGtkList(ImplWidget)^.last_focus_child;
{$IfDef VerboseFocus}
DebugLn(' E.1 using last_focus_child');
DebugLn('E.1 using last_focus_child');
{$EndIf}
Exit;
end;
@ -9444,7 +9444,7 @@ begin
then begin
Result := GList^.data;
{$IfDef VerboseFocus}
DebugLn(' E.2 using 1st selection');
DebugLn('E.2 using 1st selection');
{$EndIf}
Exit;
end;
@ -9464,14 +9464,14 @@ begin
if GList^.Data = nil then Exit;
Result := GList^.Data;
{$IfDef VerboseFocus}
DebugLn(' E.4 using 1st child');
DebugLn('E.4 using 1st child');
{$EndIf}
Exit;
end;
{$IfDef VerboseFocus}
DebugLn(' E taking ImplementationWidget');
DebugLn('E taking ImplementationWidget');
{$EndIf}
end;

View File

@ -8241,7 +8241,8 @@ begin
Widget:={%H-}PGtkWidget(hWnd);
{$IfDef VerboseFocus}
DebugLn('');
debugln('[TGtk2WidgetSet.SetFocus] A hWnd=',GetWidgetDebugReport(Widget));
DebuglnEnter('TGtk2WidgetSet.SetFocus INIT');
DebugLn('A hWnd=',GetWidgetDebugReport(Widget));
//DebugLn(getStackTrace(true));
//if GtkWidgetIsA(Widget,GTK_TYPE_NOTEBOOK) then DumpStack;
{$EndIf}
@ -8252,28 +8253,28 @@ begin
TopLevel := gtk_widget_get_toplevel(Widget);
{$IfDef VerboseFocus}
Debugln('[TGtk2WidgetSet.SetFocus] B');
DbgOut(' TopLevel=',DbgS(TopLevel));
DbgOut(' OldFocus=',GetWidgetDebugReport(PGtkWidget(Result)));
DebugLn('');
if not GTK_WIDGET_VISIBLE(Widget) then
Debugln('B TopLevel=',DbgS(TopLevel),' OldFocus=',GetWidgetDebugReport(PGtkWidget(Result)));
if not GTK_WIDGET_VISIBLE(Widget) then begin
DebugLnExit('TGtk2WidgetSet.SetFocus EXIT: Widget is not visible');
raise Exception.Create('TGtk2WidgetSet.SetFocus: Widget is not visible');
end;
{$EndIf}
if Result=hWnd then exit;
if Result=hWnd then begin
{$IfDef VerboseFocus}
DebugLnExit('TGtk2WidgetSet.SetFocus EXIT: focusing same control');
{$EndIf}
exit;
end;
if GtkWidgetIsA(TopLevel, gtk_window_get_type) then
begin
// TopLevel is a gtkwindow
{$IfDef VerboseFocus}
AWinControl:=TWinControl(GetNearestLCLObject(PGtkWindow(TopLevel)^.focus_widget));
write(' C TopLevel is a gtkwindow ');
write(' focus_widget=',DbgS(PGtkWindow(TopLevel)^.focus_widget));
if AWinControl<>nil then
write(' LCLParent=',AWinControl.Name,':',AWinControl.ClassName)
else
write(' LCLParent=nil');
DebugLn('');
DbgOut('C TopLevel is a gtkwindow ');
DbgOut(' focus_widget=',DbgS(PGtkWindow(TopLevel)^.focus_widget));
DebugLn(' LCLParent=',dbgsName(AWinControl));
{$EndIf}
NewTopLevelObject:=GetNearestLCLObject(TopLevel);
@ -8293,12 +8294,12 @@ begin
NewFocusWidget := FindFocusWidget(Widget);
{$IfDef VerboseFocus}
write(' G NewFocusWidget=',DbgS(NewFocusWidget),' ',DbgSName(GetNearestLCLObject(NewFocusWidget)));
write(' WidVisible=',GTK_WIDGET_VISIBLE(PGtkWidget(NewFocusWidget)));
write(' WidRealized=',GTK_WIDGET_REALIZED(PGtkWidget(NewFocusWidget)));
write(' WidMapped=',GTK_WIDGET_MAPPED(PGtkWidget(NewFocusWidget)));
write(' WidCanfocus=',GTK_WIDGET_CAN_FOCUS(PGtkWidget(NewFocusWidget)));
write(' TopLvlVisible=',GTK_WIDGET_VISIBLE(PGtkWidget(TopLevel)));
DbgOut('G NewFocusWidget=',DbgS(NewFocusWidget),' ',DbgSName(GetNearestLCLObject(NewFocusWidget)));
DbgOut([' WidVisible=',GTK_WIDGET_VISIBLE(PGtkWidget(NewFocusWidget))]);
DbgOut([' WidRealized=',GTK_WIDGET_REALIZED(PGtkWidget(NewFocusWidget))]);
DbgOut([' WidMapped=',GTK_WIDGET_MAPPED(PGtkWidget(NewFocusWidget))]);
DbgOut([' WidCanfocus=',GTK_WIDGET_CAN_FOCUS(PGtkWidget(NewFocusWidget))]);
DbgOut([' TopLvlVisible=',GTK_WIDGET_VISIBLE(PGtkWidget(TopLevel))]);
DebugLn('');
{$EndIf}
if (NewFocusWidget<>nil) and GTK_WIDGET_CAN_FOCUS(NewFocusWidget) then
@ -8306,12 +8307,14 @@ begin
if (PGtkWindow(TopLevel)^.Focus_Widget<>NewFocusWidget) then
begin
{$IfDef VerboseFocus}
DebugLn(' H SETTING NewFocusWidget=',dbgs(NewFocusWidget),' ',DbgSName(GetNearestLCLObject(NewFocusWidget)));
{$EndIf}
DebugLn('H SETTING NewFocusWidget=',dbgs(NewFocusWidget),' ',DbgSName(GetNearestLCLObject(NewFocusWidget)));
//DebugLn('TGtk2WidgetSet.SetFocus TopLevel[',DebugGtkWidgets.GetInfo(TopLevel,false),'] NewFocusWidget=[',DebugGtkWidgets.GetInfo(NewFocusWidget,false),']');
DebugLnEnter('Recursive focus INIT');
{$EndIf}
gtk_window_set_focus(PGtkWindow(TopLevel), NewFocusWidget);
{$IfDef VerboseFocus}
DebugLn(' I NewTopLevel FocusWidget=',DbgS(PGtkWindow(TopLevel)^.Focus_Widget),' Success=',dbgs(PGtkWindow(TopLevel)^.Focus_Widget=NewFocusWidget));
DebugLnExit('Recursive focus DONE');
DebugLn('I NewTopLevel FocusWidget=',DbgS(PGtkWindow(TopLevel)^.Focus_Widget),' Success=',dbgs(PGtkWindow(TopLevel)^.Focus_Widget=NewFocusWidget));
{$EndIf}
end;
end;
@ -8328,13 +8331,13 @@ begin
if (Screen<>nil) and (Screen.GetCurrentModalForm<>nil) and (NewTopLevelObject <>Screen.GetCurrentModalForm) then
begin
{$IFDEF VerboseFocus}
DebugLn('[TGtk2WidgetSet.SetFocus] there is a modal form -> not grabbing');
DebugLn('There is a modal form -> not grabbing');
{$ENDIF}
end
else
begin
{$IfDef VerboseFocus}
DebugLn(' J Grabbing focus ',GetWidgetDebugReport(NewFocusWidget));
DebugLn('J Grabbing focus ',GetWidgetDebugReport(NewFocusWidget));
{$EndIf}
if NewTopLevelObject is TCustomForm then
begin
@ -8347,15 +8350,11 @@ begin
end;
{$IfDef VerboseFocus}
write('[TGtk2WidgetSet.SetFocus] END hWnd=',DbgS(hWnd));
NewFocusWidget:=PGtkWidget(GetFocus);
write(' NewFocus=',DbgS(NewFocusWidget));
AWinControl:=TWinControl(GetNearestLCLObject(NewFocusWidget));
if AWinControl<>nil then
write(' NewLCLParent=',AWinControl.Name,':',AWinControl.ClassName)
else
write(' NewLCLParent=nil');
DebugLn('');
NewFocusWidget:=PGtkWidget(GetFocus);
DebugLnExit('TGtk2WidgetSet.SetFocus END hWnd=',DbgS(hWnd),
' NewFocus=',DbgS(NewFocusWidget),
' NewLCLParent=',dbgsName(AWinControl));
{$EndIf}
end;