From 1cd90e3dea62a08c001586ff729663cef819b851 Mon Sep 17 00:00:00 2001 From: cxl Date: Sat, 24 Oct 2015 17:42:45 +0000 Subject: [PATCH] CtrlCore: gtk: fixed issue with popup mouse events #1027 git-svn-id: svn://ultimatepp.org/upp/trunk@9075 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlCore/GtkCreate.cpp | 25 ++++++++----------------- uppsrc/CtrlCore/GtkCtrl.h | 3 ++- uppsrc/CtrlCore/GtkEvent.cpp | 4 ++-- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/uppsrc/CtrlCore/GtkCreate.cpp b/uppsrc/CtrlCore/GtkCreate.cpp index c88c21fcf..57d47f45d 100644 --- a/uppsrc/CtrlCore/GtkCreate.cpp +++ b/uppsrc/CtrlCore/GtkCreate.cpp @@ -115,9 +115,15 @@ void Ctrl::WndDestroy() } Vector< Ptr > Ctrl::activePopup; +Vector< Ptr > Ctrl::visiblePopup; void Ctrl::GuiPlatformRemove() { + for(int i = 0; i < visiblePopup.GetCount();) + if(visiblePopup[i] == this) + visiblePopup.Remove(i); + else + i++; for(int i = 0; i < activePopup.GetCount();) if(activePopup[i] == this) { if(this == grabpopup && gdk_pointer_is_grabbed()) @@ -129,23 +135,6 @@ void Ctrl::GuiPlatformRemove() i++; } -/* -void Ctrl::PopUp(Ctrl *owner, bool savebits, bool activate, bool, bool) -{ - GuiLock __; - LLOG("POPUP " << Name() << ", " << GetRect() << ", activate " << activate); - Create(owner ? owner->GetTopCtrl() : GetActiveCtrl(), true); - popup = true; - if(activate) - SetFocus(); - Ptr _this = this; - if(_this) { - activePopup.Add(this); - StartGrabPopup(); - CheckMouseCtrl(); - } -} -*/ void Ctrl::PopUp(Ctrl *owner, bool savebits, bool activate, bool, bool) { GuiLock __; @@ -161,6 +150,8 @@ void Ctrl::PopUp(Ctrl *owner, bool savebits, bool activate, bool, bool) CheckMouseCtrl(); } } + if(_this) + visiblePopup.Add(this); } diff --git a/uppsrc/CtrlCore/GtkCtrl.h b/uppsrc/CtrlCore/GtkCtrl.h index 9f94851bf..51a3007a8 100644 --- a/uppsrc/CtrlCore/GtkCtrl.h +++ b/uppsrc/CtrlCore/GtkCtrl.h @@ -66,7 +66,8 @@ _DBG_ bool SweepFocus(bool wait); static BiVector Events; - static Vector< Ptr > activePopup; + static Vector< Ptr > activePopup; // created with 'activate' flag - usually menu + static Vector< Ptr > visiblePopup; // any popup visible on screen static Vector wins; static int WndCaretTime; static bool WndCaretVisible; diff --git a/uppsrc/CtrlCore/GtkEvent.cpp b/uppsrc/CtrlCore/GtkEvent.cpp index e9ce9fd2c..099a996c9 100644 --- a/uppsrc/CtrlCore/GtkEvent.cpp +++ b/uppsrc/CtrlCore/GtkEvent.cpp @@ -305,8 +305,8 @@ bool Ctrl::DispatchMouseIn(int act, int zd) void Ctrl::GtkMouseEvent(int action, int act, int zd) { if(grabpopup && activePopup.GetCount()) { - for(int i = activePopup.GetCount(); --i >= 0;) - if(activePopup[i] && activePopup[i]->DispatchMouseIn(act, zd)) + for(int i = visiblePopup.GetCount(); --i >= 0;) + if(visiblePopup[i] && visiblePopup[i]->DispatchMouseIn(act, zd)) return; if(action == DOWN) { // Deactivate active popup(s) if clicked outside of active popups IgnoreMouseUp();