diff options
author | jmarshallnz <jmarshallnz@svn> | 2009-10-15 22:59:31 +0000 |
---|---|---|
committer | jmarshallnz <jmarshallnz@svn> | 2009-10-15 22:59:31 +0000 |
commit | 3e95d0f0a3814cc74ae6fff067c78b99b9eabbba (patch) | |
tree | f4dad453d16cd85aaaf704356df2b1564f001afb /guilib | |
parent | 3bb2f1096789e377b55c9d90ae76cdb948b17054 (diff) |
changed: Better exclusive access control tracking for the mouse - should help with multiple scrollbars with the same id (which is highly discouraged)
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@23755 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'guilib')
-rw-r--r-- | guilib/GUIControlGroup.cpp | 13 | ||||
-rw-r--r-- | guilib/GUIControlGroup.h | 9 | ||||
-rw-r--r-- | guilib/GUIMoverControl.cpp | 4 | ||||
-rw-r--r-- | guilib/GUIResizeControl.cpp | 4 | ||||
-rw-r--r-- | guilib/GUIScrollBarControl.cpp | 4 | ||||
-rw-r--r-- | guilib/GUISliderControl.cpp | 4 | ||||
-rw-r--r-- | guilib/GUIWindow.cpp | 10 |
7 files changed, 33 insertions, 15 deletions
diff --git a/guilib/GUIControlGroup.cpp b/guilib/GUIControlGroup.cpp index a699477a01..3ddb3517d8 100644 --- a/guilib/GUIControlGroup.cpp +++ b/guilib/GUIControlGroup.cpp @@ -544,6 +544,19 @@ void CGUIControlGroup::RemoveLookup(CGUIControl *control) ((CGUIControlGroup *)m_parentControl)->RemoveLookup(control); } +bool CGUIControlGroup::IsValidControl(const CGUIControl *control) const +{ + if (control->GetID()) + { + for (LookupMap::const_iterator it = m_lookup.begin(); it != m_lookup.end(); it++) + { + if (control == it->second) + return true; + } + } + return false; +} + bool CGUIControlGroup::InsertControl(CGUIControl *control, const CGUIControl *insertPoint) { // find our position diff --git a/guilib/GUIControlGroup.h b/guilib/GUIControlGroup.h index e0458d6055..1567fe4b33 100644 --- a/guilib/GUIControlGroup.h +++ b/guilib/GUIControlGroup.h @@ -89,6 +89,15 @@ public: virtual void DumpTextureUse(); #endif protected: + /*! + \brief Check whether a given control is valid + Runs through controls and returns whether this control is valid. Only functional + for controls with non-zero id. + \param control to check + \return true if the control is valid, false otherwise. + */ + bool IsValidControl(const CGUIControl *control) const; + // sub controls std::vector<CGUIControl *> m_children; typedef std::vector<CGUIControl *>::iterator iControls; diff --git a/guilib/GUIMoverControl.cpp b/guilib/GUIMoverControl.cpp index 029df7fbb4..3b84cfc3ee 100644 --- a/guilib/GUIMoverControl.cpp +++ b/guilib/GUIMoverControl.cpp @@ -138,7 +138,7 @@ void CGUIMoverControl::OnRight() bool CGUIMoverControl::OnMouseDrag(const CPoint &offset, const CPoint &point) { g_Mouse.SetState(MOUSE_STATE_DRAG); - g_Mouse.SetExclusiveAccess(GetID(), GetParentID(), point); + g_Mouse.SetExclusiveAccess(this, GetParentID(), point); Move((int)offset.x, (int)offset.y); return true; } @@ -146,7 +146,7 @@ bool CGUIMoverControl::OnMouseDrag(const CPoint &offset, const CPoint &point) bool CGUIMoverControl::OnMouseClick(int button, const CPoint &point) { if (button != MOUSE_LEFT_BUTTON) return false; - g_Mouse.EndExclusiveAccess(GetID(), GetParentID()); + g_Mouse.EndExclusiveAccess(this, GetParentID()); return true; } diff --git a/guilib/GUIResizeControl.cpp b/guilib/GUIResizeControl.cpp index fab57f1925..475d3e684c 100644 --- a/guilib/GUIResizeControl.cpp +++ b/guilib/GUIResizeControl.cpp @@ -127,7 +127,7 @@ void CGUIResizeControl::OnRight() bool CGUIResizeControl::OnMouseDrag(const CPoint &offset, const CPoint &point) { g_Mouse.SetState(MOUSE_STATE_DRAG); - g_Mouse.SetExclusiveAccess(GetID(), GetParentID(), point); + g_Mouse.SetExclusiveAccess(this, GetParentID(), point); Resize(offset.x, offset.y); return true; } @@ -135,7 +135,7 @@ bool CGUIResizeControl::OnMouseDrag(const CPoint &offset, const CPoint &point) bool CGUIResizeControl::OnMouseClick(int button, const CPoint &point) { if (button != MOUSE_LEFT_BUTTON) return false; - g_Mouse.EndExclusiveAccess(GetID(), GetParentID()); + g_Mouse.EndExclusiveAccess(this, GetParentID()); return true; } diff --git a/guilib/GUIScrollBarControl.cpp b/guilib/GUIScrollBarControl.cpp index 9cd7125367..ed6618b29d 100644 --- a/guilib/GUIScrollBarControl.cpp +++ b/guilib/GUIScrollBarControl.cpp @@ -259,7 +259,7 @@ bool CGUIScrollBar::OnMouseClick(int button, const CPoint &point) { g_Mouse.SetState(MOUSE_STATE_CLICK); // turn off any exclusive access, if it's on... - g_Mouse.EndExclusiveAccess(GetID(), GetParentID()); + g_Mouse.EndExclusiveAccess(this, GetParentID()); if (m_guiBackground.HitTest(point)) { // set the position SetFromPosition(point); @@ -272,7 +272,7 @@ bool CGUIScrollBar::OnMouseDrag(const CPoint &offset, const CPoint &point) { g_Mouse.SetState(MOUSE_STATE_DRAG); // get exclusive access to the mouse - g_Mouse.SetExclusiveAccess(GetID(), GetParentID(), point); + g_Mouse.SetExclusiveAccess(this, GetParentID(), point); // get the position of the mouse SetFromPosition(point); return true; diff --git a/guilib/GUISliderControl.cpp b/guilib/GUISliderControl.cpp index 582a195c84..8d648d828d 100644 --- a/guilib/GUISliderControl.cpp +++ b/guilib/GUISliderControl.cpp @@ -308,7 +308,7 @@ bool CGUISliderControl::OnMouseClick(int button, const CPoint &point) { g_Mouse.SetState(MOUSE_STATE_CLICK); // turn off any exclusive access, if it's on... - g_Mouse.EndExclusiveAccess(GetID(), GetParentID()); + g_Mouse.EndExclusiveAccess(this, GetParentID()); if (m_guiBackground.HitTest(point)) { // set the position SetFromPosition(point); @@ -321,7 +321,7 @@ bool CGUISliderControl::OnMouseDrag(const CPoint &offset, const CPoint &point) { g_Mouse.SetState(MOUSE_STATE_DRAG); // get exclusive access to the mouse - g_Mouse.SetExclusiveAccess(GetID(), GetParentID(), point); + g_Mouse.SetExclusiveAccess(this, GetParentID(), point); // get the position of the mouse SetFromPosition(point); return true; diff --git a/guilib/GUIWindow.cpp b/guilib/GUIWindow.cpp index e685fa2853..210b38c8da 100644 --- a/guilib/GUIWindow.cpp +++ b/guilib/GUIWindow.cpp @@ -393,14 +393,10 @@ bool CGUIWindow::OnMouseAction() bool bHandled = false; // check if we have exclusive access - if (g_Mouse.GetExclusiveWindowID() == GetID()) + if (g_Mouse.GetExclusiveWindowID() == GetID() && IsValidControl(g_Mouse.GetExclusiveControl())) { // we have exclusive access to the mouse... - CGUIControl *pControl = (CGUIControl *)GetControl(g_Mouse.GetExclusiveControlID()); - if (pControl) - { // this control has exclusive access to the mouse - HandleMouse(pControl, mousePoint + g_Mouse.GetExclusiveOffset()); - return true; - } + HandleMouse((CGUIControl *)g_Mouse.GetExclusiveControl(), mousePoint + g_Mouse.GetExclusiveOffset()); + return true; } // run through the controls, and unfocus all those that aren't under the pointer, |