OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fwl/core/fwl_noteimp.h" | 7 #include "xfa/fwl/core/fwl_noteimp.h" |
8 | 8 |
9 #include "core/fxcrt/include/fx_ext.h" | 9 #include "core/fxcrt/include/fx_ext.h" |
| 10 #include "third_party/base/stl_util.h" |
10 #include "xfa/fwl/basewidget/fwl_tooltipctrlimp.h" | 11 #include "xfa/fwl/basewidget/fwl_tooltipctrlimp.h" |
11 #include "xfa/fwl/basewidget/ifwl_tooltip.h" | 12 #include "xfa/fwl/basewidget/ifwl_tooltip.h" |
12 #include "xfa/fwl/core/cfwl_message.h" | 13 #include "xfa/fwl/core/cfwl_message.h" |
13 #include "xfa/fwl/core/cfwl_widgetmgr.h" | 14 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
14 #include "xfa/fwl/core/fwl_appimp.h" | 15 #include "xfa/fwl/core/fwl_appimp.h" |
15 #include "xfa/fwl/core/fwl_formimp.h" | 16 #include "xfa/fwl/core/fwl_formimp.h" |
16 #include "xfa/fwl/core/fwl_widgetimp.h" | 17 #include "xfa/fwl/core/fwl_widgetimp.h" |
17 #include "xfa/fwl/core/ifwl_app.h" | 18 #include "xfa/fwl/core/ifwl_app.h" |
18 #include "xfa/fwl/core/ifwl_tooltiptarget.h" | 19 #include "xfa/fwl/core/ifwl_tooltiptarget.h" |
19 | 20 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse); | 95 CFWL_ToolTipContainer::getInstance()->ProcessLeave(pMouse); |
95 } | 96 } |
96 } | 97 } |
97 for (const auto& pair : m_eventTargets) { | 98 for (const auto& pair : m_eventTargets) { |
98 CFWL_EventTarget* pEventTarget = pair.second; | 99 CFWL_EventTarget* pEventTarget = pair.second; |
99 if (pEventTarget && !pEventTarget->IsInvalid()) | 100 if (pEventTarget && !pEventTarget->IsInvalid()) |
100 pEventTarget->ProcessEvent(pNote); | 101 pEventTarget->ProcessEvent(pNote); |
101 } | 102 } |
102 } | 103 } |
103 | 104 |
104 #define FWL_NoteDriver_EventKey 1100 | |
105 FWL_Error CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener, | 105 FWL_Error CFWL_NoteDriver::RegisterEventTarget(IFWL_Widget* pListener, |
106 IFWL_Widget* pEventSource, | 106 IFWL_Widget* pEventSource, |
107 uint32_t dwFilter) { | 107 uint32_t dwFilter) { |
108 uint32_t key = (uint32_t)(uintptr_t)pListener->GetPrivateData( | 108 uint32_t key = pListener->GetEventKey(); |
109 (void*)(uintptr_t)FWL_NoteDriver_EventKey); | |
110 if (key == 0) { | 109 if (key == 0) { |
111 void* random = FX_Random_MT_Start(0); | 110 do { |
112 key = rand(); | 111 key = rand(); |
113 FX_Random_MT_Close(random); | 112 } while (key == 0 || pdfium::ContainsKey(m_eventTargets, key)); |
114 pListener->SetPrivateData((void*)(uintptr_t)FWL_NoteDriver_EventKey, | 113 pListener->SetEventKey(key); |
115 (void*)(uintptr_t)key, NULL); | |
116 } | 114 } |
117 if (!m_eventTargets[key]) | 115 if (!m_eventTargets[key]) |
118 m_eventTargets[key] = new CFWL_EventTarget(this, pListener); | 116 m_eventTargets[key] = new CFWL_EventTarget(this, pListener); |
119 | 117 |
120 m_eventTargets[key]->SetEventSource(pEventSource, dwFilter); | 118 m_eventTargets[key]->SetEventSource(pEventSource, dwFilter); |
121 return FWL_Error::Succeeded; | 119 return FWL_Error::Succeeded; |
122 } | 120 } |
123 | 121 |
124 FWL_Error CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) { | 122 FWL_Error CFWL_NoteDriver::UnregisterEventTarget(IFWL_Widget* pListener) { |
125 uint32_t key = (uint32_t)(uintptr_t)pListener->GetPrivateData( | 123 uint32_t key = pListener->GetEventKey(); |
126 (void*)(uintptr_t)FWL_NoteDriver_EventKey); | |
127 if (key == 0) | 124 if (key == 0) |
128 return FWL_Error::Indefinite; | 125 return FWL_Error::Indefinite; |
129 | 126 |
130 auto it = m_eventTargets.find(key); | 127 auto it = m_eventTargets.find(key); |
131 if (it != m_eventTargets.end()) | 128 if (it != m_eventTargets.end()) |
132 it->second->FlagInvalid(); | 129 it->second->FlagInvalid(); |
133 | 130 |
134 return FWL_Error::Succeeded; | 131 return FWL_Error::Succeeded; |
135 } | 132 } |
136 | 133 |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 if (HasToolTip(pEvt->m_pDstTarget) && NULL != m_pToolTipImp) { | 885 if (HasToolTip(pEvt->m_pDstTarget) && NULL != m_pToolTipImp) { |
889 m_pToolTipImp->Hide(); | 886 m_pToolTipImp->Hide(); |
890 pCurTarget = NULL; | 887 pCurTarget = NULL; |
891 return TRUE; | 888 return TRUE; |
892 } | 889 } |
893 return FALSE; | 890 return FALSE; |
894 } | 891 } |
895 IFWL_ToolTipTarget* CFWL_ToolTipContainer::GetCurrentToolTipTarget() { | 892 IFWL_ToolTipTarget* CFWL_ToolTipContainer::GetCurrentToolTipTarget() { |
896 return pCurTarget; | 893 return pCurTarget; |
897 } | 894 } |
OLD | NEW |