Refactor focus debug logging in wxGTK
No real changes, just add a helper wxDumpWindow() function to make focus logging less verbose and slightly more readable (as the label is not shown any more if it's empty).
This commit is contained in:
@@ -308,6 +308,24 @@ static wxPoint gs_lastGesturePoint;
|
|||||||
// the trace mask used for the focus debugging messages
|
// the trace mask used for the focus debugging messages
|
||||||
#define TRACE_FOCUS wxT("focus")
|
#define TRACE_FOCUS wxT("focus")
|
||||||
|
|
||||||
|
// Function used to dump a brief description of a window.
|
||||||
|
static
|
||||||
|
wxString wxDumpWindow(wxWindow* win)
|
||||||
|
{
|
||||||
|
if ( !win )
|
||||||
|
return "(no window)";
|
||||||
|
|
||||||
|
wxString s = wxString::Format("%s(%p",
|
||||||
|
win->GetClassInfo()->GetClassName(), win);
|
||||||
|
|
||||||
|
wxString label = win->GetLabel();
|
||||||
|
if ( !label.empty() )
|
||||||
|
s += wxString::Format(", \"%s\"", label);
|
||||||
|
s += ")";
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
// A handy function to run from under gdb to show information about the given
|
// A handy function to run from under gdb to show information about the given
|
||||||
// GtkWidget. Right now it only shows its type, we could enhance it to show
|
// GtkWidget. Right now it only shows its type, we could enhance it to show
|
||||||
// more information later but this is already pretty useful.
|
// more information later but this is already pretty useful.
|
||||||
@@ -4335,8 +4353,8 @@ bool wxWindowGTK::GTKHandleFocusIn()
|
|||||||
// GTK+ focus changed from this wxWindow back to itself, so don't
|
// GTK+ focus changed from this wxWindow back to itself, so don't
|
||||||
// emit any events at all
|
// emit any events at all
|
||||||
wxLogTrace(TRACE_FOCUS,
|
wxLogTrace(TRACE_FOCUS,
|
||||||
"filtered out spurious focus change within %s(%p, %s)",
|
"filtered out spurious focus change within %s",
|
||||||
GetClassInfo()->GetClassName(), this, GetLabel());
|
wxDumpWindow(this));
|
||||||
gs_deferredFocusOut = NULL;
|
gs_deferredFocusOut = NULL;
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@@ -4349,8 +4367,8 @@ bool wxWindowGTK::GTKHandleFocusIn()
|
|||||||
|
|
||||||
|
|
||||||
wxLogTrace(TRACE_FOCUS,
|
wxLogTrace(TRACE_FOCUS,
|
||||||
"handling focus_in event for %s(%p, %s)",
|
"handling focus_in event for %s",
|
||||||
GetClassInfo()->GetClassName(), this, GetLabel());
|
wxDumpWindow(this));
|
||||||
|
|
||||||
if (m_imContext)
|
if (m_imContext)
|
||||||
gtk_im_context_focus_in(m_imContext);
|
gtk_im_context_focus_in(m_imContext);
|
||||||
@@ -4401,8 +4419,8 @@ bool wxWindowGTK::GTKHandleFocusOut()
|
|||||||
wxASSERT_MSG( gs_deferredFocusOut == NULL,
|
wxASSERT_MSG( gs_deferredFocusOut == NULL,
|
||||||
"deferred focus out event already pending" );
|
"deferred focus out event already pending" );
|
||||||
wxLogTrace(TRACE_FOCUS,
|
wxLogTrace(TRACE_FOCUS,
|
||||||
"deferring focus_out event for %s(%p, %s)",
|
"deferring focus_out event for %s",
|
||||||
GetClassInfo()->GetClassName(), this, GetLabel());
|
wxDumpWindow(this));
|
||||||
gs_deferredFocusOut = this;
|
gs_deferredFocusOut = this;
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
@@ -4415,8 +4433,8 @@ bool wxWindowGTK::GTKHandleFocusOut()
|
|||||||
void wxWindowGTK::GTKHandleFocusOutNoDeferring()
|
void wxWindowGTK::GTKHandleFocusOutNoDeferring()
|
||||||
{
|
{
|
||||||
wxLogTrace(TRACE_FOCUS,
|
wxLogTrace(TRACE_FOCUS,
|
||||||
"handling focus_out event for %s(%p, %s)",
|
"handling focus_out event for %s",
|
||||||
GetClassInfo()->GetClassName(), this, GetLabel());
|
wxDumpWindow(this));
|
||||||
|
|
||||||
gs_lastFocus = this;
|
gs_lastFocus = this;
|
||||||
|
|
||||||
@@ -4435,8 +4453,8 @@ void wxWindowGTK::GTKHandleFocusOutNoDeferring()
|
|||||||
// * or it goes to another control, in which case focus-in event will
|
// * or it goes to another control, in which case focus-in event will
|
||||||
// follow immediately and it will set gs_currentFocus to the right
|
// follow immediately and it will set gs_currentFocus to the right
|
||||||
// value
|
// value
|
||||||
wxLogDebug("window %s(%p, %s) lost focus even though it didn't have it",
|
wxLogDebug("window %s lost focus even though it didn't have it",
|
||||||
GetClassInfo()->GetClassName(), this, GetLabel());
|
wxDumpWindow(this));
|
||||||
}
|
}
|
||||||
gs_currentFocus = NULL;
|
gs_currentFocus = NULL;
|
||||||
|
|
||||||
@@ -4463,8 +4481,8 @@ void wxWindowGTK::GTKHandleDeferredFocusOut()
|
|||||||
gs_deferredFocusOut = NULL;
|
gs_deferredFocusOut = NULL;
|
||||||
|
|
||||||
wxLogTrace(TRACE_FOCUS,
|
wxLogTrace(TRACE_FOCUS,
|
||||||
"processing deferred focus_out event for %s(%p, %s)",
|
"processing deferred focus_out event for %s",
|
||||||
GetClassInfo()->GetClassName(), this, GetLabel());
|
wxDumpWindow(this));
|
||||||
|
|
||||||
GTKHandleFocusOutNoDeferring();
|
GTKHandleFocusOutNoDeferring();
|
||||||
}
|
}
|
||||||
@@ -4493,15 +4511,15 @@ void wxWindowGTK::SetFocus()
|
|||||||
!gtk_widget_get_can_focus(widget) )
|
!gtk_widget_get_can_focus(widget) )
|
||||||
{
|
{
|
||||||
wxLogTrace(TRACE_FOCUS,
|
wxLogTrace(TRACE_FOCUS,
|
||||||
wxT("Setting focus to a child of %s(%p, %s)"),
|
wxT("Setting focus to a child of %s"),
|
||||||
GetClassInfo()->GetClassName(), this, GetLabel().c_str());
|
wxDumpWindow(this));
|
||||||
gtk_widget_child_focus(widget, GTK_DIR_TAB_FORWARD);
|
gtk_widget_child_focus(widget, GTK_DIR_TAB_FORWARD);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxLogTrace(TRACE_FOCUS,
|
wxLogTrace(TRACE_FOCUS,
|
||||||
wxT("Setting focus to %s(%p, %s)"),
|
wxT("Setting focus to %s"),
|
||||||
GetClassInfo()->GetClassName(), this, GetLabel().c_str());
|
wxDumpWindow(this));
|
||||||
gtk_widget_grab_focus(widget);
|
gtk_widget_grab_focus(widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user