Skip to content

Commit bd54a9d

Browse files
committed
Optimized speed of adding hotspots
1 parent 94ff377 commit bd54a9d

File tree

1 file changed

+31
-19
lines changed

1 file changed

+31
-19
lines changed

scripting/methods/methods_miniwindows.cpp

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,8 @@ long CMUSHclientDoc::WindowAddHotspot(LPCTSTR Name,
546546
if (it == m_MiniWindows.end ())
547547
return eNoSuchWindow;
548548

549+
CMiniWindow * mw = it->second;
550+
549551
static bool bInWindowAddHotspot = false;
550552

551553
// don't recurse into infinite loops
@@ -561,29 +563,39 @@ static bool bInWindowAddHotspot = false;
561563

562564
long status;
563565

564-
status = it->second->AddHotspot (this,
565-
HotspotId,
566-
sPluginID,
567-
Left, Top, Right, Bottom,
568-
MouseOver,
569-
CancelMouseOver,
570-
MouseDown,
571-
CancelMouseDown,
572-
MouseUp,
573-
TooltipText,
574-
Cursor,
575-
Flags);
566+
status = mw->AddHotspot (this,
567+
HotspotId,
568+
sPluginID,
569+
Left, Top, Right, Bottom,
570+
MouseOver,
571+
CancelMouseOver,
572+
MouseDown,
573+
CancelMouseDown,
574+
MouseUp,
575+
TooltipText,
576+
Cursor,
577+
Flags);
576578

577579
// in mouse was over hotspot when it was created, do a "mouse move" to detect this
578580
if (status == eOK)
579581
{
580-
for(POSITION pos=GetFirstViewPosition();pos!=NULL;)
581-
{
582-
CView* pView = GetNextView(pos);
583-
584-
if (pView->IsKindOf(RUNTIME_CLASS(CMUSHView)))
585-
((CMUSHView*)pView)->Mouse_Move_MiniWindow (this, m_lastMousePosition);
586-
} // end of looping through views
582+
583+
// only check the current hotspot, not all of them
584+
HotspotMapIterator it = mw->m_Hotspots.find (HotspotId);
585+
if (it != mw->m_Hotspots.end ())
586+
{
587+
CHotspot * pHotspot = it->second;
588+
if ( pHotspot->m_rect.PtInRect(mw->m_last_mouseposition) )
589+
{
590+
for(POSITION pos=GetFirstViewPosition();pos!=NULL;)
591+
{
592+
CView* pView = GetNextView(pos);
593+
594+
if (pView->IsKindOf(RUNTIME_CLASS(CMUSHView)))
595+
((CMUSHView*)pView)->Mouse_Move_MiniWindow (this, m_lastMousePosition);
596+
} // end of looping through views
597+
}
598+
} // end of hotspot found
587599
} // end of added hotspot OK
588600

589601

0 commit comments

Comments
 (0)