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/cfwl_notedriver.h" | 7 #include "xfa/fwl/core/cfwl_notedriver.h" |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 return p; | 84 return p; |
85 } | 85 } |
86 | 86 |
87 bool CFWL_NoteDriver::SetFocus(CFWL_Widget* pFocus, bool bNotify) { | 87 bool CFWL_NoteDriver::SetFocus(CFWL_Widget* pFocus, bool bNotify) { |
88 if (m_pFocus == pFocus) | 88 if (m_pFocus == pFocus) |
89 return true; | 89 return true; |
90 | 90 |
91 CFWL_Widget* pPrev = m_pFocus; | 91 CFWL_Widget* pPrev = m_pFocus; |
92 m_pFocus = pFocus; | 92 m_pFocus = pFocus; |
93 if (pPrev) { | 93 if (pPrev) { |
94 CFWL_MsgKillFocus ms; | 94 CFWL_MsgKillFocus ms(pPrev, pPrev); |
95 ms.m_pDstTarget = pPrev; | |
96 ms.m_pSrcTarget = pPrev; | |
97 if (bNotify) | 95 if (bNotify) |
98 ms.m_dwExtend = 1; | 96 ms.m_dwExtend = 1; |
99 | 97 |
100 if (IFWL_WidgetDelegate* pDelegate = pPrev->GetDelegate()) | 98 if (IFWL_WidgetDelegate* pDelegate = pPrev->GetDelegate()) |
101 pDelegate->OnProcessMessage(&ms); | 99 pDelegate->OnProcessMessage(&ms); |
102 } | 100 } |
103 if (pFocus) { | 101 if (pFocus) { |
104 CFWL_Widget* pWidget = | 102 CFWL_Widget* pWidget = |
105 pFocus->GetOwnerApp()->GetWidgetMgr()->GetSystemFormWidget(pFocus); | 103 pFocus->GetOwnerApp()->GetWidgetMgr()->GetSystemFormWidget(pFocus); |
106 CFWL_Form* pForm = static_cast<CFWL_Form*>(pWidget); | 104 CFWL_Form* pForm = static_cast<CFWL_Form*>(pWidget); |
107 if (pForm) | 105 if (pForm) |
108 pForm->SetSubFocus(pFocus); | 106 pForm->SetSubFocus(pFocus); |
109 | 107 |
110 CFWL_MsgSetFocus ms; | 108 CFWL_MsgSetFocus ms(nullptr, pFocus); |
111 ms.m_pDstTarget = pFocus; | |
112 if (bNotify) | 109 if (bNotify) |
113 ms.m_dwExtend = 1; | 110 ms.m_dwExtend = 1; |
114 if (IFWL_WidgetDelegate* pDelegate = pFocus->GetDelegate()) | 111 if (IFWL_WidgetDelegate* pDelegate = pFocus->GetDelegate()) |
115 pDelegate->OnProcessMessage(&ms); | 112 pDelegate->OnProcessMessage(&ms); |
116 } | 113 } |
117 return true; | 114 return true; |
118 } | 115 } |
119 | 116 |
120 void CFWL_NoteDriver::Run() { | 117 void CFWL_NoteDriver::Run() { |
121 #if (_FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_WIN32_DESKTOP_ || \ | 118 #if (_FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_WIN32_DESKTOP_ || \ |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 CFWL_WidgetMgr* pWidgetMgr = | 212 CFWL_WidgetMgr* pWidgetMgr = |
216 pMessage->m_pDstTarget->GetOwnerApp()->GetWidgetMgr(); | 213 pMessage->m_pDstTarget->GetOwnerApp()->GetWidgetMgr(); |
217 CFWL_Widget* pMessageForm = pWidgetMgr->IsFormDisabled() | 214 CFWL_Widget* pMessageForm = pWidgetMgr->IsFormDisabled() |
218 ? pMessage->m_pDstTarget | 215 ? pMessage->m_pDstTarget |
219 : GetMessageForm(pMessage->m_pDstTarget); | 216 : GetMessageForm(pMessage->m_pDstTarget); |
220 if (!pMessageForm) | 217 if (!pMessageForm) |
221 return; | 218 return; |
222 if (!DispatchMessage(pMessage, pMessageForm)) | 219 if (!DispatchMessage(pMessage, pMessageForm)) |
223 return; | 220 return; |
224 | 221 |
225 if (pMessage->GetClassID() == CFWL_MessageType::Mouse) | 222 if (pMessage->GetType() == CFWL_Message::Type::Mouse) |
226 MouseSecondary(pMessage); | 223 MouseSecondary(pMessage); |
227 } | 224 } |
228 | 225 |
229 bool CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage, | 226 bool CFWL_NoteDriver::DispatchMessage(CFWL_Message* pMessage, |
230 CFWL_Widget* pMessageForm) { | 227 CFWL_Widget* pMessageForm) { |
231 switch (pMessage->GetClassID()) { | 228 switch (pMessage->GetType()) { |
232 case CFWL_MessageType::SetFocus: { | 229 case CFWL_Message::Type::SetFocus: { |
233 if (!DoSetFocus(pMessage, pMessageForm)) | 230 if (!DoSetFocus(pMessage, pMessageForm)) |
234 return false; | 231 return false; |
235 break; | 232 break; |
236 } | 233 } |
237 case CFWL_MessageType::KillFocus: { | 234 case CFWL_Message::Type::KillFocus: { |
238 if (!DoKillFocus(pMessage, pMessageForm)) | 235 if (!DoKillFocus(pMessage, pMessageForm)) |
239 return false; | 236 return false; |
240 break; | 237 break; |
241 } | 238 } |
242 case CFWL_MessageType::Key: { | 239 case CFWL_Message::Type::Key: { |
243 if (!DoKey(pMessage, pMessageForm)) | 240 if (!DoKey(pMessage, pMessageForm)) |
244 return false; | 241 return false; |
245 break; | 242 break; |
246 } | 243 } |
247 case CFWL_MessageType::Mouse: { | 244 case CFWL_Message::Type::Mouse: { |
248 if (!DoMouse(pMessage, pMessageForm)) | 245 if (!DoMouse(pMessage, pMessageForm)) |
249 return false; | 246 return false; |
250 break; | 247 break; |
251 } | 248 } |
252 case CFWL_MessageType::MouseWheel: { | 249 case CFWL_Message::Type::MouseWheel: { |
253 if (!DoWheel(pMessage, pMessageForm)) | 250 if (!DoWheel(pMessage, pMessageForm)) |
254 return false; | 251 return false; |
255 break; | 252 break; |
256 } | 253 } |
257 default: | 254 default: |
258 break; | 255 break; |
259 } | 256 } |
260 if (IFWL_WidgetDelegate* pDelegate = pMessage->m_pDstTarget->GetDelegate()) | 257 if (IFWL_WidgetDelegate* pDelegate = pMessage->m_pDstTarget->GetDelegate()) |
261 pDelegate->OnProcessMessage(pMessage); | 258 pDelegate->OnProcessMessage(pMessage); |
262 | 259 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 return true; | 406 return true; |
410 } | 407 } |
411 | 408 |
412 void CFWL_NoteDriver::MouseSecondary(CFWL_Message* pMessage) { | 409 void CFWL_NoteDriver::MouseSecondary(CFWL_Message* pMessage) { |
413 CFWL_Widget* pTarget = pMessage->m_pDstTarget; | 410 CFWL_Widget* pTarget = pMessage->m_pDstTarget; |
414 if (pTarget == m_pHover) | 411 if (pTarget == m_pHover) |
415 return; | 412 return; |
416 | 413 |
417 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 414 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
418 if (m_pHover) { | 415 if (m_pHover) { |
419 CFWL_MsgMouse msLeave; | 416 CFWL_MsgMouse msLeave(nullptr, m_pHover); |
420 msLeave.m_pDstTarget = m_pHover; | |
421 msLeave.m_fx = pMsg->m_fx; | 417 msLeave.m_fx = pMsg->m_fx; |
422 msLeave.m_fy = pMsg->m_fy; | 418 msLeave.m_fy = pMsg->m_fy; |
423 pTarget->TransformTo(m_pHover, msLeave.m_fx, msLeave.m_fy); | 419 pTarget->TransformTo(m_pHover, msLeave.m_fx, msLeave.m_fy); |
424 | 420 |
425 msLeave.m_dwFlags = 0; | 421 msLeave.m_dwFlags = 0; |
426 msLeave.m_dwCmd = FWL_MouseCommand::Leave; | 422 msLeave.m_dwCmd = FWL_MouseCommand::Leave; |
427 DispatchMessage(&msLeave, nullptr); | 423 DispatchMessage(&msLeave, nullptr); |
428 } | 424 } |
429 if (pTarget->GetClassID() == FWL_Type::Form) { | 425 if (pTarget->GetClassID() == FWL_Type::Form) { |
430 m_pHover = nullptr; | 426 m_pHover = nullptr; |
431 return; | 427 return; |
432 } | 428 } |
433 m_pHover = pTarget; | 429 m_pHover = pTarget; |
434 | 430 |
435 CFWL_MsgMouse msHover; | 431 CFWL_MsgMouse msHover(nullptr, pTarget); |
436 msHover.m_pDstTarget = pTarget; | |
437 msHover.m_fx = pMsg->m_fx; | 432 msHover.m_fx = pMsg->m_fx; |
438 msHover.m_fy = pMsg->m_fy; | 433 msHover.m_fy = pMsg->m_fy; |
439 msHover.m_dwFlags = 0; | 434 msHover.m_dwFlags = 0; |
440 msHover.m_dwCmd = FWL_MouseCommand::Hover; | 435 msHover.m_dwCmd = FWL_MouseCommand::Hover; |
441 DispatchMessage(&msHover, nullptr); | 436 DispatchMessage(&msHover, nullptr); |
442 } | 437 } |
443 | 438 |
444 bool CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) { | 439 bool CFWL_NoteDriver::IsValidMessage(CFWL_Message* pMessage) { |
445 for (int32_t i = 0; i < m_noteLoopQueue.GetSize(); i++) { | 440 for (int32_t i = 0; i < m_noteLoopQueue.GetSize(); i++) { |
446 CFWL_NoteLoop* pNoteLoop = m_noteLoopQueue[i]; | 441 CFWL_NoteLoop* pNoteLoop = m_noteLoopQueue[i]; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 void CFWL_NoteDriver::ClearEventTargets(bool bRemoveAll) { | 474 void CFWL_NoteDriver::ClearEventTargets(bool bRemoveAll) { |
480 auto it = m_eventTargets.begin(); | 475 auto it = m_eventTargets.begin(); |
481 while (it != m_eventTargets.end()) { | 476 while (it != m_eventTargets.end()) { |
482 auto old = it++; | 477 auto old = it++; |
483 if (old->second && (bRemoveAll || old->second->IsInvalid())) { | 478 if (old->second && (bRemoveAll || old->second->IsInvalid())) { |
484 delete old->second; | 479 delete old->second; |
485 m_eventTargets.erase(old); | 480 m_eventTargets.erase(old); |
486 } | 481 } |
487 } | 482 } |
488 } | 483 } |
OLD | NEW |