Skip to content

Commit

Permalink
Merge pull request xbmc#1179 from pieh/no_longer_focusable
Browse files Browse the repository at this point in the history
  • Loading branch information
pieh committed Jul 29, 2012
2 parents 2774f6b + f472ae7 commit 1b0360e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
29 changes: 22 additions & 7 deletions xbmc/guilib/GUIControlGroup.cpp
Expand Up @@ -464,18 +464,33 @@ int CGUIControlGroup::GetFocusedControlID() const

CGUIControl *CGUIControlGroup::GetFocusedControl() const
{
// try lookup first
if (m_focusedControl)
{
// we may have multiple controls with same id - we pick first that has focus
pair<LookupMap::const_iterator, LookupMap::const_iterator> range = m_lookup.equal_range(m_focusedControl);
for (LookupMap::const_iterator i = range.first; i != range.second; ++i)
{
if (i->second->HasFocus())
return i->second;
}
}

// if lookup didn't find focused control, iterate m_children to find it
for (ciControls it = m_children.begin(); it != m_children.end(); ++it)
{
const CGUIControl* control = *it;
if (control->HasFocus())
// Avoid calling HasFocus() on control group as it will (possibly) recursively
// traverse entire group tree just to check if there is focused control.
// We are recursively traversing it here so no point in doing it twice.
if (control->IsGroup())
{
if (control->IsGroup())
{
CGUIControlGroup *group = (CGUIControlGroup *)control;
return group->GetFocusedControl();
}
return (CGUIControl *)control;
CGUIControl* focusedControl = ((CGUIControlGroup *)control)->GetFocusedControl();
if (focusedControl)
return (CGUIControl *)focusedControl;
}
else if (control->HasFocus())
return (CGUIControl *)control;
}
return NULL;
}
Expand Down
6 changes: 6 additions & 0 deletions xbmc/guilib/GUIWindow.cpp
Expand Up @@ -302,6 +302,12 @@ void CGUIWindow::DoProcess(unsigned int currentTime, CDirtyRegionList &dirtyregi
CGUIControlGroup::DoProcess(currentTime, dirtyregions);
if (size != g_graphicsContext.RemoveTransform())
CLog::Log(LOGERROR, "Unbalanced UI transforms (was %d)", size);

// check if currently focused control can have it
// and fallback to default control if not
CGUIControl* focusedControl = GetFocusedControl();
if (focusedControl && !focusedControl->CanFocus())
SET_CONTROL_FOCUS(m_defaultControl, 0);
}

void CGUIWindow::DoRender()
Expand Down

0 comments on commit 1b0360e

Please sign in to comment.