28 #include "wstop.h" |
28 #include "wstop.h" |
29 #include "inifile.h" |
29 #include "inifile.h" |
30 #include <hal.h> |
30 #include <hal.h> |
31 #include "advancedpointereventhelper.h" |
31 #include "advancedpointereventhelper.h" |
32 #include "graphics/pointereventdata.h" |
32 #include "graphics/pointereventdata.h" |
|
33 #include "debughelper.h" |
33 |
34 |
34 TTimeIntervalMicroSeconds32 TWsPointer::iDoubleClickMaxInterval; |
35 TTimeIntervalMicroSeconds32 TWsPointer::iDoubleClickMaxInterval; |
35 TInt TWsPointer::iDoubleClickMaxDistance; |
36 TInt TWsPointer::iDoubleClickMaxDistance; |
36 CWsPointerCursor* TWsPointer::iCursorSprite; |
37 CWsPointerCursor* TWsPointer::iCursorSprite; |
37 TPointerCursorMode TWsPointer::iPointerCursorMode=EPointerCursorNormal; |
38 TPointerCursorMode TWsPointer::iPointerCursorMode=EPointerCursorNormal; |
108 { |
109 { |
109 iMaxPointers = 1; |
110 iMaxPointers = 1; |
110 } |
111 } |
111 } |
112 } |
112 |
113 |
|
114 //** Log the number of pointers here i,e iMaxPointers |
|
115 #ifdef LOG_WSERV_EVENTS |
|
116 RDebug::Printf("_WSEVENT_POINTER: Number of pointers system supports %d", iMaxPointers); |
|
117 #endif |
|
118 |
113 // Does device support Z coordinate of the pointers? |
119 // Does device support Z coordinate of the pointers? |
114 if(HAL::Get(HALData::EPointer3D,iIs3DPointer)!=KErrNone) |
120 if(HAL::Get(HALData::EPointer3D,iIs3DPointer)!=KErrNone) |
115 { |
121 { |
116 iIs3DPointer=EFalse; // No API, then no 3D pointers |
122 iIs3DPointer=EFalse; // No API, then no 3D pointers |
117 } |
123 } |
118 WS_ASSERT_ALWAYS(!iIs3DPointer || XyInput(), EWsPanicPointer3DInconsistent); |
124 WS_ASSERT_ALWAYS(!iIs3DPointer || XyInput(), EWsPanicPointer3DInconsistent); |
|
125 |
|
126 #ifdef LOG_WSERV_EVENTS |
|
127 RDebug::Printf("_WSEVENT_POINTER: Z coordinate supported %d", iIs3DPointer); |
|
128 #endif |
119 |
129 |
120 // Initialize thresholds for EEnterCloseProximity, EExitCloseProximity, |
130 // Initialize thresholds for EEnterCloseProximity, EExitCloseProximity, |
121 // EEnterHighPressure and EExitHightPressure events. |
131 // EEnterHighPressure and EExitHightPressure events. |
122 if(HAL::Get(HALData::EPointer3DEnterCloseProximityThreshold, |
132 if(HAL::Get(HALData::EPointer3DEnterCloseProximityThreshold, |
123 iEnterCloseProximityThreshold) != KErrNone) |
133 iEnterCloseProximityThreshold) != KErrNone) |
483 (aWindow->AdvancedPointersEnabled() || |
493 (aWindow->AdvancedPointersEnabled() || |
484 TAdvancedPointerEventHelper::PointerNumber(aEvent) == iPrimaryPointer)) |
494 TAdvancedPointerEventHelper::PointerNumber(aEvent) == iPrimaryPointer)) |
485 { |
495 { |
486 CEventQueue* queue=aWindow->EventQueue(); |
496 CEventQueue* queue=aWindow->EventQueue(); |
487 aEvent.SetHandle(aWindow->ClientHandle()); |
497 aEvent.SetHandle(aWindow->ClientHandle()); |
|
498 #ifdef LOG_WSERV_EVENTS |
|
499 RDebug::Printf("_WSEVENT_POINTER: TWsPointer::QueuePointerEvent with AdvancedPointerEnabled"); |
|
500 #endif |
488 if (aEvent.Handle()!=0) |
501 if (aEvent.Handle()!=0) |
489 { |
502 { |
490 if(!aWindow->AdvancedPointersEnabled()) |
503 if(!aWindow->AdvancedPointersEnabled()) |
491 { |
504 { |
492 // Re-assign from WServ primary pointer number, to EDefaultPointerNumber for Cone and other clients. |
505 // Re-assign from WServ primary pointer number, to EDefaultPointerNumber for Cone and other clients. |
506 case TPointerEvent::EButton2Up: |
519 case TPointerEvent::EButton2Up: |
507 case TPointerEvent::EButton3Up: |
520 case TPointerEvent::EButton3Up: |
508 case TPointerEvent::EExitHighPressure: |
521 case TPointerEvent::EExitHighPressure: |
509 if (CheckMatchingEventPurged(aEvent.Pointer()->iType)) |
522 if (CheckMatchingEventPurged(aEvent.Pointer()->iType)) |
510 { |
523 { |
|
524 #ifdef LOG_WSERV_EVENTS |
|
525 RDebug::Printf("_WSEVENT_POINTER: Check matching event has been purged so no addition of event 01"); |
|
526 #endif |
511 return ETrue; |
527 return ETrue; |
512 } |
528 } |
513 if (queue->CheckRoom()) |
529 if (queue->CheckRoom()) |
514 { |
530 { |
515 if (CheckMatchingEventPurged(aEvent.Pointer()->iType)) |
531 if (CheckMatchingEventPurged(aEvent.Pointer()->iType)) |
516 { |
532 { |
|
533 #ifdef LOG_WSERV_EVENTS |
|
534 RDebug::Printf("_WSEVENT_POINTER: Check matching event has been purged so no addition of event 02"); |
|
535 #endif |
517 return ETrue; |
536 return ETrue; |
518 } |
537 } |
519 } |
538 } |
520 /*Fall Through if an event was not purged*/ |
539 /*Fall Through if an event was not purged*/ |
521 case TPointerEvent::EButton1Down: |
540 case TPointerEvent::EButton1Down: |
655 if (!XyInput()) |
677 if (!XyInput()) |
656 { |
678 { |
657 return EFalse; |
679 return EFalse; |
658 } |
680 } |
659 |
681 |
|
682 //** Log the type, pointer number, and its coordinates |
|
683 #ifdef LOG_WSERV_EVENTS |
|
684 RDebug::Printf("_WSEVENT_POINTER: Pointer number = %d RawEvent Type = %d Coordinates [%d, %d]", |
|
685 aRawEvent.PointerNumber(), type, aRawEvent.Pos().iX, aRawEvent.Pos().iY); |
|
686 #endif |
|
687 |
660 // check correctness of aRawEvent.PointerNumber() |
688 // check correctness of aRawEvent.PointerNumber() |
661 if (iMaxPointers > 1) |
689 if (iMaxPointers > 1) |
662 { |
690 { |
663 if (aRawEvent.PointerNumber() >= iMaxPointers) |
691 if (aRawEvent.PointerNumber() >= iMaxPointers) |
664 { |
692 { |
708 RestrictPos(xy); |
736 RestrictPos(xy); |
709 } |
737 } |
710 aRawEvent.Set(type, xy.iX, xy.iY, |
738 aRawEvent.Set(type, xy.iX, xy.iY, |
711 iIs3DPointer ? aRawEvent.Pos3D().iZ : 0); |
739 iIs3DPointer ? aRawEvent.Pos3D().iZ : 0); |
712 } |
740 } |
|
741 |
|
742 #ifdef LOG_WSERV_EVENTS |
|
743 RDebug::Printf("_WSEVENT_POINTER: Coordinates after Rotation and shift [%d, %d]", |
|
744 aRawEvent.Pos().iX, aRawEvent.Pos().iY); |
|
745 #endif |
713 return ETrue; |
746 return ETrue; |
714 } |
747 } |
715 |
748 |
716 void TWsPointer::TranslateCoordsOnRotation(TPoint& aPoint) |
749 void TWsPointer::TranslateCoordsOnRotation(TPoint& aPoint) |
717 { |
750 { |
854 // re-log and update parent position |
887 // re-log and update parent position |
855 TPoint parPos; |
888 TPoint parPos; |
856 ReLogCurrentWindow(pointerEvent.iPosition,parPos,aForceInGroup); |
889 ReLogCurrentWindow(pointerEvent.iPosition,parPos,aForceInGroup); |
857 pointerEvent.iParentPosition=parPos; |
890 pointerEvent.iParentPosition=parPos; |
858 |
891 |
|
892 |
|
893 #ifdef LOG_WSERV_EVENTS |
|
894 RDebug::Printf("_WSEVENT_POINTER: TWsPointer::ProcessEvent Event to be sent to this window %U", reinterpret_cast<TUint32>(iCurrentWindow)); |
|
895 RDebug::Print(_L("_WSEVENT_POINTER: TWsPointer::ProcessEvent EventName %S and Event State %d "), &WsEventName(aEvent), iState); |
|
896 #endif |
859 // update state |
897 // update state |
860 switch(eventType) |
898 switch(eventType) |
861 { |
899 { |
862 case TPointerEvent::EButton1Down: |
900 case TPointerEvent::EButton1Down: |
863 if (iGrabWindow==NULL && iCurrentWindow->HasPointerGrab()) |
901 if (iGrabWindow==NULL && iCurrentWindow->HasPointerGrab()) |
1005 */ |
1043 */ |
1006 void TWsPointer::ProcessOutOfRangeEvent(TWsEvent& aEvent,const CWsWindowGroup* aForceInGroup, TBool aNatural) |
1044 void TWsPointer::ProcessOutOfRangeEvent(TWsEvent& aEvent,const CWsWindowGroup* aForceInGroup, TBool aNatural) |
1007 { |
1045 { |
1008 if (iState != EPointerStateOutOfRange) |
1046 if (iState != EPointerStateOutOfRange) |
1009 { |
1047 { |
|
1048 #ifdef LOG_WSERV_EVENTS |
|
1049 RDebug::Printf("_WSEVENT_POINTER: TWsPointer::ProcessOutOfRangeEvent Pointer Number = %d, iState =%d ", iNumber, iState); |
|
1050 #endif |
|
1051 |
1010 // OutOfRange event generated by driver doesn't contain correct coordinates, |
1052 // OutOfRange event generated by driver doesn't contain correct coordinates, |
1011 // we update them from last state in order to deliver event to the proper window. |
1053 // we update them from last state in order to deliver event to the proper window. |
1012 SendEnterExitEvent(EEventPointerExit); |
1054 SendEnterExitEvent(EEventPointerExit); |
1013 |
1055 |
1014 iState = EPointerStateOutOfRange; |
1056 iState = EPointerStateOutOfRange; |
1076 CWsPointerBuffer::PointerEvent((CWsClientWindow *)iCurrentWindow,pos); |
1118 CWsPointerBuffer::PointerEvent((CWsClientWindow *)iCurrentWindow,pos); |
1077 ProcessPointerEvent(aEvent); |
1119 ProcessPointerEvent(aEvent); |
1078 } |
1120 } |
1079 else if (!WsKeyboardEmulator::PointerEvent(type,pos,iCurrentWindow->PointerKeyList())) |
1121 else if (!WsKeyboardEmulator::PointerEvent(type,pos,iCurrentWindow->PointerKeyList())) |
1080 { |
1122 { |
|
1123 #ifdef LOG_WSERV_EVENTS |
|
1124 RDebug::Printf("_WSEVENT_POINTER: Calling ProcessPointerEvent for primary pointer"); |
|
1125 #endif |
1081 ProcessPointerEvent(aEvent); |
1126 ProcessPointerEvent(aEvent); |
1082 } |
1127 } |
1083 } |
1128 } |
1084 else if (!iCurrentWindow->UsingPointerBuffer() || (type != TPointerEvent::EMove && type != TPointerEvent::EDrag)) |
1129 else if (!iCurrentWindow->UsingPointerBuffer() || (type != TPointerEvent::EMove && type != TPointerEvent::EDrag)) |
1085 { |
1130 { |
|
1131 #ifdef LOG_WSERV_EVENTS |
|
1132 RDebug::Printf("_WSEVENT_POINTER: Calling ProcessPointerEvent for non primary pointer"); |
|
1133 #endif |
1086 ProcessPointerEvent(aEvent); |
1134 ProcessPointerEvent(aEvent); |
1087 } |
1135 } |
1088 } |
1136 } |
1089 if (!MovesAvailable() && (type==TPointerEvent::EButton1Up || |
1137 if (!MovesAvailable() && (type==TPointerEvent::EButton1Up || |
1090 type==TPointerEvent::ESwitchOn || |
1138 type==TPointerEvent::ESwitchOn || |
1392 { |
1440 { |
1393 iPreviousPrimaryPointer = iPrimaryPointer; |
1441 iPreviousPrimaryPointer = iPrimaryPointer; |
1394 |
1442 |
1395 TRawEvent::TType type=aRawEvent.Type(); |
1443 TRawEvent::TType type=aRawEvent.Type(); |
1396 TInt pointerNumber = aRawEvent.PointerNumber(); |
1444 TInt pointerNumber = aRawEvent.PointerNumber(); |
1397 |
1445 |
|
1446 #ifdef LOG_WSERV_EVENTS |
|
1447 RDebug::Printf("_WSEVENT_POINTER: TWsPointer::UpdatePrimaryPointer Current Primary pointer = %d",iPrimaryPointer); |
|
1448 for(TInt i=0; i< iMaxPointers; i++) |
|
1449 { |
|
1450 RDebug::Printf("_WSEVENT_POINTER: TWsPointer::UpdatePrimaryPointer Pointer Number= %d State = %x XY(%d,%d)",iPointers[i].iNumber,iPointers[i].iState,iPointers[i].iPos.iX,iPointers[i].iPos.iY); |
|
1451 } |
|
1452 #endif |
|
1453 |
1398 // If primary pointer is out of range, then the first pointer that will |
1454 // If primary pointer is out of range, then the first pointer that will |
1399 // start being detected (come back in range) will become primary. |
1455 // start being detected (come back in range) will become primary. |
1400 if (iPointers[iPrimaryPointer].iState == EPointerStateOutOfRange) |
1456 if (iPointers[iPrimaryPointer].iState == EPointerStateOutOfRange) |
1401 { |
1457 { |
1402 if (type != TRawEvent::EPointer3DOutOfRange && iPointers[pointerNumber].iState == EPointerStateOutOfRange) |
1458 if (type != TRawEvent::EPointer3DOutOfRange && iPointers[pointerNumber].iState == EPointerStateOutOfRange) |
1403 { |
1459 { |
1404 iPrimaryPointer = pointerNumber; |
1460 iPrimaryPointer = pointerNumber; |
|
1461 #ifdef LOG_WSERV_EVENTS |
|
1462 RDebug::Printf("_WSEVENT_POINTER: TWsPointer::UpdatePrimaryPointer New Primary pointer(OutRange) = %d",iPrimaryPointer); |
|
1463 #endif |
1405 } |
1464 } |
1406 return; |
1465 return; |
1407 } |
1466 } |
1408 |
1467 |
1409 // if non-primary pointer sends EButton1Down event, and actual primary pointer |
1468 // if non-primary pointer sends EButton1Down event, and actual primary pointer |
1410 // is not down, then the pointer which has sent EButton1Down becomes primary. |
1469 // is not down, then the pointer which has sent EButton1Down becomes primary. |
1411 if (type == TRawEvent::EButton1Down && |
1470 if (type == TRawEvent::EButton1Down && |
1412 iPointers[iPrimaryPointer].iState != EPointerStateDown) |
1471 iPointers[iPrimaryPointer].iState != EPointerStateDown) |
1413 { |
1472 { |
1414 iPrimaryPointer = pointerNumber; |
1473 iPrimaryPointer = pointerNumber; |
|
1474 #ifdef LOG_WSERV_EVENTS |
|
1475 RDebug::Printf("_WSEVENT_POINTER: TWsPointer::UpdatePrimaryPointer New Primary pointer(ButtonDown) = %d",iPrimaryPointer); |
|
1476 #endif |
1415 return; |
1477 return; |
1416 } |
1478 } |
1417 } |
1479 } |
1418 |
1480 |
1419 /** Sets Z coordinate threshold values for TPointerEvent::EEnterCloseProximity |
1481 /** Sets Z coordinate threshold values for TPointerEvent::EEnterCloseProximity |