From 397ec4cbe80d8f6647f42bcbff55de297223210f Mon Sep 17 00:00:00 2001 From: upstream svn Date: Fri, 2 Jun 2017 08:41:08 +0000 Subject: [PATCH] Close tab only works with the mouse events down/up on the same tab --- .svn-revision | 2 +- src/MuleNotebook.cpp | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.svn-revision b/.svn-revision index c6111dbe..a1e633a9 100644 --- a/.svn-revision +++ b/.svn-revision @@ -1 +1 @@ -10987 +10988 diff --git a/src/MuleNotebook.cpp b/src/MuleNotebook.cpp index 5d3ad045..21e10b08 100644 --- a/src/MuleNotebook.cpp +++ b/src/MuleNotebook.cpp @@ -45,7 +45,9 @@ BEGIN_EVENT_TABLE(CMuleNotebook, wxNotebook) EVT_MENU(MP_CLOSE_OTHER_TABS, CMuleNotebook::OnPopupCloseOthers) // Madcat - tab closing engine + EVT_LEFT_DOWN(CMuleNotebook::OnMouseButtonRelease) EVT_LEFT_UP(CMuleNotebook::OnMouseButtonRelease) + EVT_MIDDLE_DOWN(CMuleNotebook::OnMouseButtonRelease) EVT_MIDDLE_UP(CMuleNotebook::OnMouseButtonRelease) EVT_MOTION(CMuleNotebook::OnMouseMotion) #if MULE_NEEDS_DELETEPAGE_WORKAROUND @@ -228,10 +230,28 @@ void CMuleNotebook::OnMouseButtonRelease(wxMouseEvent &event) long flags = 0; int tab = HitTest(wxPoint(xpos,ypos),&flags); + static int tab_down_icon = -1; + static int tab_down_label = -1; - if ((tab != -1) && (((flags == wxNB_HITTEST_ONICON) && event.LeftUp()) || - ((flags == wxNB_HITTEST_ONLABEL) && event.MiddleUp()))) { + if (event.LeftDown() && (flags == wxNB_HITTEST_ONICON)) { + tab_down_icon = tab; + return; + } + else if (event.MiddleDown() && (flags == wxNB_HITTEST_ONLABEL)) { + tab_down_label = tab; + return; + } + else if (event.LeftDown() || event.MiddleDown()) { + tab_down_icon = -1; + tab_down_label = -1; + return; + } + + if (((tab != -1) && (((flags == wxNB_HITTEST_ONICON) && event.LeftUp() && (tab == tab_down_icon)) || + ((flags == wxNB_HITTEST_ONLABEL) && event.MiddleUp() && (tab == tab_down_label))))) { // User did click on a 'x' or middle click on the label + tab_down_icon = -1; + tab_down_label = -1; #if MULE_NEEDS_DELETEPAGE_WORKAROUND /* WORKAROUND: Instead of calling DeletePage, we need to wait for the * mouse release signal to reach Gtk. Inconsistent with normal wxEvent -- 2.11.4.GIT