Skip to content

Commit 5334bac

Browse files
committed
Improved hotspot callbacks for miniwindows
1 parent 3170778 commit 5334bac

File tree

1 file changed

+94
-37
lines changed

1 file changed

+94
-37
lines changed

mushview.cpp

Lines changed: 94 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -6490,12 +6490,22 @@ bool CMUSHView::Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point)
64906490
string sHotspotId;
64916491
string sMiniWindowId;
64926492

6493+
// find which miniwindow we are over, if any (and hotspot, if any)
64936494
mw = Mouse_Over_Miniwindow (pDoc, point, sHotspotId, pHotspot, sMiniWindowId);
64946495

6496+
// the original hotspot that we moused over, in this window (if any)
6497+
string sOldMouseOverHotspotInThisWindow;
6498+
64956499
if (mw)
64966500
{
6501+
// remember mouse position in *this* window
64976502
mw->m_last_mouseposition = CPoint (point.x - mw->m_rect.left, point.y - mw->m_rect.top);
64986503
mw->m_last_mouse_update++;
6504+
6505+
// remember original hotspot ID
6506+
sOldMouseOverHotspotInThisWindow = mw->m_sMouseOverHotspot;
6507+
// change to new one for the benefit of WindowInfo (19)
6508+
mw->m_sMouseOverHotspot = sHotspotId;
64996509
}
65006510

65016511

@@ -6558,7 +6568,8 @@ bool CMUSHView::Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point)
65586568
// end drag-and-drop
65596569

65606570

6561-
// next see if they have moved away from our previous miniwindow, if any
6571+
// Next see if they have moved away from our previous miniwindow, if any
6572+
// Note: This code is for when we change miniwindows
65626573
if (sMiniWindowId != m_sPreviousMiniWindow && !m_sPreviousMiniWindow.empty ())
65636574
{
65646575

@@ -6578,6 +6589,9 @@ bool CMUSHView::Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point)
65786589
// lookup that HotspotId
65796590
HotspotMapIterator it = old_mw->m_Hotspots.find (old_mw->m_sMouseOverHotspot);
65806591

6592+
string sOldMouseOverHotspot = old_mw->m_sMouseOverHotspot;
6593+
old_mw->m_sMouseOverHotspot.erase (); // no mouse-over right now (changed windows)
6594+
65816595
// call CancelMouseOver for that hotspot, if it exists
65826596
if (it != old_mw->m_Hotspots.end ())
65836597
{
@@ -6586,10 +6600,9 @@ bool CMUSHView::Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point)
65866600
Send_Mouse_Event_To_Plugin (it->second->m_dispid_CancelMouseOver,
65876601
old_mw->m_sCallbackPlugin,
65886602
it->second->m_sCancelMouseOver,
6589-
old_mw->m_sMouseOverHotspot);
6603+
sOldMouseOverHotspot);
65906604
old_mw->m_bExecutingScript = false;
65916605
}
6592-
old_mw->m_sMouseOverHotspot.erase (); // no mouse-over right now
65936606
m_sPreviousMiniWindow.erase (); // no longer have a previous mouse-over
65946607
} // we had previous hotspot
65956608

@@ -6599,17 +6612,21 @@ bool CMUSHView::Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point)
65996612
} // moved to different window
66006613

66016614

6602-
// here if currently over a miniwindow
6615+
// here if currently over a miniwindow and mouse is not captured (down)
66036616
if (mw && GetCapture () != this)
66046617
{
66056618

66066619

6607-
// cancel previous move-over hotspot (in this miniwindow)
6608-
if ((pHotspot == NULL || // not on any hotspot
6609-
mw->m_sMouseOverHotspot != sHotspotId) // or on different hotspot
6610-
&& !mw->m_sMouseOverHotspot.empty ()) // and we previously were over one in this miniwindow
6620+
// Cancel previous move-over hotspot (in this miniwindow)
6621+
// if either there is no hotspot at all, or there was a previous, different, one.
6622+
// Note: Won't apply to changing miniwindows - we handled that above
6623+
6624+
if ((pHotspot == NULL || // not on any hotspot
6625+
sOldMouseOverHotspotInThisWindow != sHotspotId)// or on different hotspot
6626+
&& !sOldMouseOverHotspotInThisWindow.empty () // and we previously were over one in this miniwindow
6627+
&& sMiniWindowId == m_sPreviousMiniWindow) // and it is the same miniwindow
66116628
{
6612-
HotspotMapIterator it = mw->m_Hotspots.find (mw->m_sMouseOverHotspot);
6629+
HotspotMapIterator it = mw->m_Hotspots.find (sOldMouseOverHotspotInThisWindow);
66136630

66146631
if (it != mw->m_Hotspots.end ())
66156632
{
@@ -6618,11 +6635,10 @@ bool CMUSHView::Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point)
66186635
Send_Mouse_Event_To_Plugin (it->second->m_dispid_CancelMouseOver,
66196636
mw->m_sCallbackPlugin,
66206637
it->second->m_sCancelMouseOver,
6621-
mw->m_sMouseOverHotspot);
6638+
sOldMouseOverHotspotInThisWindow);
66226639
mw->m_bExecutingScript = false;
66236640
}
66246641

6625-
mw->m_sMouseOverHotspot.erase (); // no mouse-over right now
66266642
} // previous one which isn't this one, or we are no longer on one
66276643

66286644
// now, are we now over a hotspot?
@@ -6636,10 +6652,9 @@ bool CMUSHView::Mouse_Move_MiniWindow (CMUSHclientDoc* pDoc, CPoint point)
66366652
m_sPreviousMiniWindow = sMiniWindowId; // remember in case they move outside window
66376653

66386654
// if different hotspot from before
6639-
if (sHotspotId != mw->m_sMouseOverHotspot)
6655+
if (sHotspotId != sOldMouseOverHotspotInThisWindow)
66406656
{
66416657
// this is our new one
6642-
mw->m_sMouseOverHotspot = sHotspotId;
66436658
mw->m_bExecutingScript = true;
66446659
Send_Mouse_Event_To_Plugin (pHotspot->m_dispid_MouseOver,
66456660
mw->m_sCallbackPlugin,
@@ -6706,6 +6721,21 @@ bool CMUSHView::Mouse_Down_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long
67066721

67076722
mw = Mouse_Over_Miniwindow (pDoc, point, sHotspotId, pHotspot, sMiniWindowId);
67086723

6724+
// the original hotspot that we moused over, in this window (if any)
6725+
string sOldMouseOverHotspotInThisWindow;
6726+
6727+
if (mw)
6728+
{
6729+
// remember mouse position in *this* window
6730+
mw->m_last_mouseposition = CPoint (point.x - mw->m_rect.left, point.y - mw->m_rect.top);
6731+
mw->m_last_mouse_update++;
6732+
6733+
// remember original hotspot ID
6734+
sOldMouseOverHotspotInThisWindow = mw->m_sMouseOverHotspot;
6735+
// change to new one for the benefit of WindowInfo (19/20)
6736+
mw->m_sMouseDownHotspot = sHotspotId;
6737+
}
6738+
67096739
// ANY mouse-down cancels a previous mouse-over
67106740
if (!m_sPreviousMiniWindow.empty ())
67116741
{
@@ -6723,17 +6753,19 @@ bool CMUSHView::Mouse_Down_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long
67236753
// lookup that HotspotId
67246754
HotspotMapIterator it = old_mw->m_Hotspots.find (old_mw->m_sMouseOverHotspot);
67256755

6756+
string sOldMouseOverHotspot = old_mw->m_sMouseOverHotspot;
6757+
old_mw->m_sMouseOverHotspot.erase (); // no mouse-over right now
6758+
67266759
// call CancelMouseOver for that hotspot, if it exists
67276760
if (it != old_mw->m_Hotspots.end ())
67286761
{
67296762
old_mw->m_bExecutingScript = true;
67306763
Send_Mouse_Event_To_Plugin (it->second->m_dispid_CancelMouseOver,
67316764
old_mw->m_sCallbackPlugin,
67326765
it->second->m_sCancelMouseOver,
6733-
old_mw->m_sMouseOverHotspot);
6766+
sOldMouseOverHotspot);
67346767
old_mw->m_bExecutingScript = false;
67356768
}
6736-
old_mw->m_sMouseOverHotspot.erase (); // no mouse-over right now
67376769
m_sPreviousMiniWindow.erase (); // no longer have a previous mouse-over
67386770
} // we had previous hotspot
67396771

@@ -6744,14 +6776,11 @@ bool CMUSHView::Mouse_Down_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long
67446776
// here if currently over a miniwindow
67456777
if (mw)
67466778
{
6747-
6748-
mw->m_last_mouseposition = CPoint (point.x - mw->m_rect.left, point.y - mw->m_rect.top);
6749-
mw->m_last_mouse_update++;
6779+
mw->m_sMouseOverHotspot.erase ();
67506780

67516781
// now, are we now over a hotspot?
67526782
if (pHotspot)
67536783
{
6754-
mw->m_sMouseDownHotspot = sHotspotId; // remember this is mousedown hotspot
67556784
mw->m_FlagsOnMouseDown = flags & 0x70; // remember mouse flags
67566785
mw->m_bExecutingScript = true;
67576786
Send_Mouse_Event_To_Plugin (pHotspot->m_dispid_MouseDown,
@@ -6782,6 +6811,38 @@ bool CMUSHView::Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long fl
67826811
string sMiniWindowId;
67836812
bool bPreviouslyInMiniwindow = false;
67846813

6814+
mw = Mouse_Over_Miniwindow (pDoc, point, sHotspotId, pHotspot, sMiniWindowId);
6815+
6816+
// the original hotspot that we moused over, in this window (if any)
6817+
string sOldMouseDownHotspotInThisWindow;
6818+
string sOldMouseDownHotspot;
6819+
6820+
6821+
if (mw)
6822+
{
6823+
// remember mouse position in *this* window
6824+
mw->m_last_mouseposition = CPoint (point.x - mw->m_rect.left, point.y - mw->m_rect.top);
6825+
mw->m_last_mouse_update++;
6826+
6827+
// remember original hotspot ID
6828+
sOldMouseDownHotspotInThisWindow = mw->m_sMouseDownHotspot;
6829+
// change to new one for the benefit of WindowInfo (19/20)
6830+
mw->m_sMouseOverHotspot = sHotspotId;
6831+
}
6832+
6833+
// find mouse-down hotspot in previous window, if any
6834+
if (!m_sPreviousMiniWindow.empty ())
6835+
{
6836+
MiniWindowMapIterator it = pDoc->m_MiniWindows.find (m_sPreviousMiniWindow);
6837+
if (it != pDoc->m_MiniWindows.end ())
6838+
{
6839+
sOldMouseDownHotspot = it->second->m_sMouseDownHotspot;
6840+
it->second->m_sMouseDownHotspot.empty ();
6841+
}
6842+
}
6843+
6844+
if (mw)
6845+
mw->m_sMouseDownHotspot.erase ();
67856846

67866847
// drag-and-drop stuff
67876848

@@ -6805,16 +6866,17 @@ bool CMUSHView::Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long fl
68056866
if (!prev_mw->m_sMouseDownHotspot.empty ()) // mouse was clicked
68066867
{
68076868
// lookup that HotspotId
6808-
HotspotMapIterator it = prev_mw->m_Hotspots.find (prev_mw->m_sMouseDownHotspot);
6869+
HotspotMapIterator it = prev_mw->m_Hotspots.find (sOldMouseDownHotspot);
68096870

68106871
// call ReleaseCallback for that hotspot, if it exists
68116872
if (it != prev_mw->m_Hotspots.end ())
68126873
{
6874+
68136875
prev_mw->m_bExecutingScript = true;
68146876
Send_Mouse_Event_To_Plugin (it->second->m_dispid_ReleaseCallback,
68156877
prev_mw->m_sCallbackPlugin,
68166878
it->second->m_sReleaseCallback,
6817-
prev_mw->m_sMouseDownHotspot,
6879+
sOldMouseDownHotspot,
68186880
prev_mw->m_FlagsOnMouseDown);
68196881
prev_mw->m_bExecutingScript = false;
68206882
}
@@ -6831,9 +6893,6 @@ bool CMUSHView::Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long fl
68316893
// end drag-and-drop
68326894

68336895

6834-
6835-
mw = Mouse_Over_Miniwindow (pDoc, point, sHotspotId, pHotspot, sMiniWindowId);
6836-
68376896
// A mouse-up not in this miniwindow cancels a previous mouse-down
68386897
if (sMiniWindowId != m_sPreviousMiniWindow && !m_sPreviousMiniWindow.empty ())
68396898
{
@@ -6851,10 +6910,10 @@ bool CMUSHView::Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long fl
68516910
old_mw->m_last_mouse_update++;
68526911

68536912
// cancel previous move-down hotspot
6854-
if (!old_mw->m_sMouseDownHotspot.empty ()) // HotspotId was used
6913+
if (!sOldMouseDownHotspot.empty ()) // HotspotId was used
68556914
{
68566915
// lookup that HotspotId
6857-
HotspotMapIterator it = old_mw->m_Hotspots.find (old_mw->m_sMouseDownHotspot);
6916+
HotspotMapIterator it = old_mw->m_Hotspots.find (sOldMouseDownHotspot);
68586917

68596918
// call CancelMouseDown for that hotspot, if it exists
68606919
if (it != old_mw->m_Hotspots.end ())
@@ -6863,11 +6922,10 @@ bool CMUSHView::Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long fl
68636922
Send_Mouse_Event_To_Plugin (it->second->m_dispid_CancelMouseDown,
68646923
old_mw->m_sCallbackPlugin,
68656924
it->second->m_sCancelMouseDown,
6866-
old_mw->m_sMouseDownHotspot,
6925+
sOldMouseDownHotspot,
68676926
old_mw->m_FlagsOnMouseDown);
68686927
old_mw->m_bExecutingScript = false;
68696928
}
6870-
old_mw->m_sMouseDownHotspot.erase (); // no mouse-down right now
68716929
} // we had previous hotspot
68726930

68736931
} // previous window still exists
@@ -6881,36 +6939,34 @@ bool CMUSHView::Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long fl
68816939
// here if currently over a miniwindow
68826940
if (mw)
68836941
{
6942+
mw->m_sMouseDownHotspot.erase ();
68846943

6885-
mw->m_last_mouseposition = CPoint (point.x - mw->m_rect.left, point.y - mw->m_rect.top);
6886-
mw->m_last_mouse_update++;
68876944
ReleaseCapture(); // Release the mouse capture established at
68886945
// the beginning of the mouse click.
68896946

68906947
// if mouse-up outside the current hotspot just cancel previous one
68916948
// cancel previous mouse-down hotspot (in this miniwindow)
68926949
if ((pHotspot == NULL || // not on any hotspot
6893-
mw->m_sMouseDownHotspot != sHotspotId) // or on different hotspot
6894-
&& !mw->m_sMouseDownHotspot.empty ()) // and we previously were down in this miniwindow
6950+
sOldMouseDownHotspotInThisWindow != sHotspotId) // or on different hotspot
6951+
&& !sOldMouseDownHotspotInThisWindow.empty ()) // and we previously were down in this miniwindow
68956952
{
6896-
HotspotMapIterator it = mw->m_Hotspots.find (mw->m_sMouseDownHotspot);
6953+
HotspotMapIterator it = mw->m_Hotspots.find (sOldMouseDownHotspotInThisWindow);
68976954

68986955
if (it != mw->m_Hotspots.end ())
68996956
{
69006957
mw->m_bExecutingScript = true;
69016958
Send_Mouse_Event_To_Plugin (it->second->m_dispid_CancelMouseDown,
69026959
mw->m_sCallbackPlugin,
69036960
it->second->m_sCancelMouseDown,
6904-
mw->m_sMouseDownHotspot,
6961+
sOldMouseDownHotspotInThisWindow,
69056962
mw->m_FlagsOnMouseDown);
69066963
mw->m_bExecutingScript = false;
69076964
}
69086965

6909-
mw->m_sMouseDownHotspot.erase (); // no mouse-down right now
69106966
} // previous one which isn't this one, or we are no longer on one
69116967

69126968
// now, did we release mouse over the hotspot it went down in?
6913-
if (pHotspot && mw->m_sMouseDownHotspot == sHotspotId)
6969+
if (pHotspot && sOldMouseDownHotspotInThisWindow == sHotspotId)
69146970
{
69156971
mw->m_bExecutingScript = true;
69166972
Send_Mouse_Event_To_Plugin (pHotspot->m_dispid_MouseUp,
@@ -6919,11 +6975,12 @@ bool CMUSHView::Mouse_Up_MiniWindow (CMUSHclientDoc* pDoc, CPoint point, long fl
69196975
sHotspotId,
69206976
mw->m_FlagsOnMouseDown); // LH / RH mouse?
69216977
mw->m_bExecutingScript = false;
6922-
mw->m_sMouseDownHotspot.erase (); // no mouse-down right now
69236978
}
69246979

69256980
m_sPreviousMiniWindow.erase (); // no longer have a previous mouse-over
69266981

6982+
mw->m_sMouseOverHotspot.erase (); // erase it so Mouse_Move_MiniWindow will work
6983+
Mouse_Move_MiniWindow (pDoc, point); // we are no longer down so maybe we are over again
69276984
return true; // we are over mini-window - don't check for underlying text
69286985
}
69296986

0 commit comments

Comments
 (0)