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; |
79 //On a real device target the coordinate system is always rotated together with wserv's screendevice. |
80 //On a real device target the coordinate system is always rotated together with wserv's screendevice. |
80 _LIT( KWSERVIniFileVarEmulatorRotPointCoords, "EMULATOR_ROTATE_POINTER_COORDS"); |
81 _LIT( KWSERVIniFileVarEmulatorRotPointCoords, "EMULATOR_ROTATE_POINTER_COORDS"); |
81 iEmulatorRotatePointerCoords = WsIniFile->FindVar(KWSERVIniFileVarEmulatorRotPointCoords); |
82 iEmulatorRotatePointerCoords = WsIniFile->FindVar(KWSERVIniFileVarEmulatorRotPointCoords); |
82 #endif |
83 #endif |
83 |
84 |
84 iRootWindow = CWsTop::Screen()->RootWindow(); |
85 const CScreen* screen = CWsTop::Screen(); |
|
86 WS_ASSERT_ALWAYS(screen, EWsPanicNoScreen); |
|
87 iRootWindow = screen->RootWindow(); |
85 |
88 |
86 TMachineInfoV1Buf machineInfo; |
89 TMachineInfoV1Buf machineInfo; |
87 UserHal::MachineInfo(machineInfo); |
90 UserHal::MachineInfo(machineInfo); |
88 iXyInputType=machineInfo().iXYInputType; |
91 iXyInputType=machineInfo().iXYInputType; |
89 |
92 |
106 { |
109 { |
107 iMaxPointers = 1; |
110 iMaxPointers = 1; |
108 } |
111 } |
109 } |
112 } |
110 |
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 |
111 // Does device support Z coordinate of the pointers? |
119 // Does device support Z coordinate of the pointers? |
112 if(HAL::Get(HALData::EPointer3D,iIs3DPointer)!=KErrNone) |
120 if(HAL::Get(HALData::EPointer3D,iIs3DPointer)!=KErrNone) |
113 { |
121 { |
114 iIs3DPointer=EFalse; // No API, then no 3D pointers |
122 iIs3DPointer=EFalse; // No API, then no 3D pointers |
115 } |
123 } |
116 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 |
117 |
129 |
118 // Initialize thresholds for EEnterCloseProximity, EExitCloseProximity, |
130 // Initialize thresholds for EEnterCloseProximity, EExitCloseProximity, |
119 // EEnterHighPressure and EExitHightPressure events. |
131 // EEnterHighPressure and EExitHightPressure events. |
120 if(HAL::Get(HALData::EPointer3DEnterCloseProximityThreshold, |
132 if(HAL::Get(HALData::EPointer3DEnterCloseProximityThreshold, |
121 iEnterCloseProximityThreshold) != KErrNone) |
133 iEnterCloseProximityThreshold) != KErrNone) |
481 (aWindow->AdvancedPointersEnabled() || |
493 (aWindow->AdvancedPointersEnabled() || |
482 TAdvancedPointerEventHelper::PointerNumber(aEvent) == iPrimaryPointer)) |
494 TAdvancedPointerEventHelper::PointerNumber(aEvent) == iPrimaryPointer)) |
483 { |
495 { |
484 CEventQueue* queue=aWindow->EventQueue(); |
496 CEventQueue* queue=aWindow->EventQueue(); |
485 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 |
486 if (aEvent.Handle()!=0) |
501 if (aEvent.Handle()!=0) |
487 { |
502 { |
488 if(!aWindow->AdvancedPointersEnabled()) |
503 if(!aWindow->AdvancedPointersEnabled()) |
489 { |
504 { |
490 // 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. |
504 case TPointerEvent::EButton2Up: |
519 case TPointerEvent::EButton2Up: |
505 case TPointerEvent::EButton3Up: |
520 case TPointerEvent::EButton3Up: |
506 case TPointerEvent::EExitHighPressure: |
521 case TPointerEvent::EExitHighPressure: |
507 if (CheckMatchingEventPurged(aEvent.Pointer()->iType)) |
522 if (CheckMatchingEventPurged(aEvent.Pointer()->iType)) |
508 { |
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 |
509 return ETrue; |
527 return ETrue; |
510 } |
528 } |
511 if (queue->CheckRoom()) |
529 if (queue->CheckRoom()) |
512 { |
530 { |
513 if (CheckMatchingEventPurged(aEvent.Pointer()->iType)) |
531 if (CheckMatchingEventPurged(aEvent.Pointer()->iType)) |
514 { |
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 |
515 return ETrue; |
536 return ETrue; |
516 } |
537 } |
517 } |
538 } |
518 /*Fall Through if an event was not purged*/ |
539 /*Fall Through if an event was not purged*/ |
519 case TPointerEvent::EButton1Down: |
540 case TPointerEvent::EButton1Down: |
653 if (!XyInput()) |
677 if (!XyInput()) |
654 { |
678 { |
655 return EFalse; |
679 return EFalse; |
656 } |
680 } |
657 |
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 |
658 // check correctness of aRawEvent.PointerNumber() |
688 // check correctness of aRawEvent.PointerNumber() |
659 if (iMaxPointers > 1) |
689 if (iMaxPointers > 1) |
660 { |
690 { |
661 if (aRawEvent.PointerNumber() >= iMaxPointers) |
691 if (aRawEvent.PointerNumber() >= iMaxPointers) |
662 { |
692 { |
706 RestrictPos(xy); |
736 RestrictPos(xy); |
707 } |
737 } |
708 aRawEvent.Set(type, xy.iX, xy.iY, |
738 aRawEvent.Set(type, xy.iX, xy.iY, |
709 iIs3DPointer ? aRawEvent.Pos3D().iZ : 0); |
739 iIs3DPointer ? aRawEvent.Pos3D().iZ : 0); |
710 } |
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 |
711 return ETrue; |
746 return ETrue; |
712 } |
747 } |
713 |
748 |
714 void TWsPointer::TranslateCoordsOnRotation(TPoint& aPoint) |
749 void TWsPointer::TranslateCoordsOnRotation(TPoint& aPoint) |
715 { |
750 { |
852 // re-log and update parent position |
887 // re-log and update parent position |
853 TPoint parPos; |
888 TPoint parPos; |
854 ReLogCurrentWindow(pointerEvent.iPosition,parPos,aForceInGroup); |
889 ReLogCurrentWindow(pointerEvent.iPosition,parPos,aForceInGroup); |
855 pointerEvent.iParentPosition=parPos; |
890 pointerEvent.iParentPosition=parPos; |
856 |
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 |
857 // update state |
897 // update state |
858 switch(eventType) |
898 switch(eventType) |
859 { |
899 { |
860 case TPointerEvent::EButton1Down: |
900 case TPointerEvent::EButton1Down: |
861 if (iGrabWindow==NULL && iCurrentWindow->HasPointerGrab()) |
901 if (iGrabWindow==NULL && iCurrentWindow->HasPointerGrab()) |
1003 */ |
1043 */ |
1004 void TWsPointer::ProcessOutOfRangeEvent(TWsEvent& aEvent,const CWsWindowGroup* aForceInGroup, TBool aNatural) |
1044 void TWsPointer::ProcessOutOfRangeEvent(TWsEvent& aEvent,const CWsWindowGroup* aForceInGroup, TBool aNatural) |
1005 { |
1045 { |
1006 if (iState != EPointerStateOutOfRange) |
1046 if (iState != EPointerStateOutOfRange) |
1007 { |
1047 { |
|
1048 #ifdef LOG_WSERV_EVENTS |
|
1049 RDebug::Printf("_WSEVENT_POINTER: TWsPointer::ProcessOutOfRangeEvent Pointer Number = %d, iState =%d ", iNumber, iState); |
|
1050 #endif |
|
1051 |
1008 // OutOfRange event generated by driver doesn't contain correct coordinates, |
1052 // OutOfRange event generated by driver doesn't contain correct coordinates, |
1009 // 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. |
1010 SendEnterExitEvent(EEventPointerExit); |
1054 SendEnterExitEvent(EEventPointerExit); |
1011 |
1055 |
1012 iState = EPointerStateOutOfRange; |
1056 iState = EPointerStateOutOfRange; |
1074 CWsPointerBuffer::PointerEvent((CWsClientWindow *)iCurrentWindow,pos); |
1118 CWsPointerBuffer::PointerEvent((CWsClientWindow *)iCurrentWindow,pos); |
1075 ProcessPointerEvent(aEvent); |
1119 ProcessPointerEvent(aEvent); |
1076 } |
1120 } |
1077 else if (!WsKeyboardEmulator::PointerEvent(type,pos,iCurrentWindow->PointerKeyList())) |
1121 else if (!WsKeyboardEmulator::PointerEvent(type,pos,iCurrentWindow->PointerKeyList())) |
1078 { |
1122 { |
|
1123 #ifdef LOG_WSERV_EVENTS |
|
1124 RDebug::Printf("_WSEVENT_POINTER: Calling ProcessPointerEvent for primary pointer"); |
|
1125 #endif |
1079 ProcessPointerEvent(aEvent); |
1126 ProcessPointerEvent(aEvent); |
1080 } |
1127 } |
1081 } |
1128 } |
1082 else if (!iCurrentWindow->UsingPointerBuffer() || (type != TPointerEvent::EMove && type != TPointerEvent::EDrag)) |
1129 else if (!iCurrentWindow->UsingPointerBuffer() || (type != TPointerEvent::EMove && type != TPointerEvent::EDrag)) |
1083 { |
1130 { |
|
1131 #ifdef LOG_WSERV_EVENTS |
|
1132 RDebug::Printf("_WSEVENT_POINTER: Calling ProcessPointerEvent for non primary pointer"); |
|
1133 #endif |
1084 ProcessPointerEvent(aEvent); |
1134 ProcessPointerEvent(aEvent); |
1085 } |
1135 } |
1086 } |
1136 } |
1087 if (!MovesAvailable() && (type==TPointerEvent::EButton1Up || |
1137 if (!MovesAvailable() && (type==TPointerEvent::EButton1Up || |
1088 type==TPointerEvent::ESwitchOn || |
1138 type==TPointerEvent::ESwitchOn || |
1390 { |
1440 { |
1391 iPreviousPrimaryPointer = iPrimaryPointer; |
1441 iPreviousPrimaryPointer = iPrimaryPointer; |
1392 |
1442 |
1393 TRawEvent::TType type=aRawEvent.Type(); |
1443 TRawEvent::TType type=aRawEvent.Type(); |
1394 TInt pointerNumber = aRawEvent.PointerNumber(); |
1444 TInt pointerNumber = aRawEvent.PointerNumber(); |
1395 |
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 |
1396 // 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 |
1397 // start being detected (come back in range) will become primary. |
1455 // start being detected (come back in range) will become primary. |
1398 if (iPointers[iPrimaryPointer].iState == EPointerStateOutOfRange) |
1456 if (iPointers[iPrimaryPointer].iState == EPointerStateOutOfRange) |
1399 { |
1457 { |
1400 if (type != TRawEvent::EPointer3DOutOfRange && iPointers[pointerNumber].iState == EPointerStateOutOfRange) |
1458 if (type != TRawEvent::EPointer3DOutOfRange && iPointers[pointerNumber].iState == EPointerStateOutOfRange) |
1401 { |
1459 { |
1402 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 |
1403 } |
1464 } |
1404 return; |
1465 return; |
1405 } |
1466 } |
1406 |
1467 |
1407 // if non-primary pointer sends EButton1Down event, and actual primary pointer |
1468 // if non-primary pointer sends EButton1Down event, and actual primary pointer |
1408 // 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. |
1409 if (type == TRawEvent::EButton1Down && |
1470 if (type == TRawEvent::EButton1Down && |
1410 iPointers[iPrimaryPointer].iState != EPointerStateDown) |
1471 iPointers[iPrimaryPointer].iState != EPointerStateDown) |
1411 { |
1472 { |
1412 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 |
1413 return; |
1477 return; |
1414 } |
1478 } |
1415 } |
1479 } |
1416 |
1480 |
1417 /** Sets Z coordinate threshold values for TPointerEvent::EEnterCloseProximity |
1481 /** Sets Z coordinate threshold values for TPointerEvent::EEnterCloseProximity |