230 TBuf<16> keyDataDllName; |
239 TBuf<16> keyDataDllName; |
231 keyDataDllName.Format(KLitKeyDataDllName,keyboardIndex); |
240 keyDataDllName.Format(KLitKeyDataDllName,keyboardIndex); |
232 iKeyTranslator->ChangeKeyData(keyDataDllName); |
241 iKeyTranslator->ChangeKeyData(keyDataDllName); |
233 } |
242 } |
234 |
243 |
|
244 // CCaptureKeys is no longer used but a dummy object is required for |
|
245 // calls to CKeyTranslator::TranslateKey() until capture functionality |
|
246 // has been removed from ektran.dll. |
235 iCaptureKeys=new(ELeave) CCaptureKeys; |
247 iCaptureKeys=new(ELeave) CCaptureKeys; |
236 iCaptureKeys->Construct(); |
248 iCaptureKeys->Construct(); |
|
249 |
|
250 // Load the key event routing plug-in. The DLL name may be overridden |
|
251 // by setting the keyword KEYROUTERPLUGIN in wsini.ini. |
|
252 TPtrC pluginName(KDefaultKeyRouterPluginName); |
|
253 WsIniFile->FindVar(KWSERVIniFileVarKeyRouterPlugin, pluginName); |
|
254 const TUidType uidType(KDynamicLibraryUid, KKeyRouterPluginUid); |
|
255 TInt err = iKeyEventRouterLibrary.Load(pluginName, uidType); |
|
256 |
|
257 if (wsDebugLog) |
|
258 { |
|
259 TLogMessageText buf; |
|
260 |
|
261 if (err == KErrNone) |
|
262 { |
|
263 _LIT(KLogLoadOk, "Loaded plugin '%S' UID3 0x%x"); |
|
264 const TFileName& pluginPathname = iKeyEventRouterLibrary.FileName(); |
|
265 const TUid uid3 = iKeyEventRouterLibrary.Type()[2]; |
|
266 buf.Format(KLogLoadOk, &pluginPathname, uid3.iUid); |
|
267 } |
|
268 else |
|
269 { |
|
270 _LIT(KLogLoadError, "Failed to load plugin '%S' (error %d)"); |
|
271 buf.Format(KLogLoadError, &pluginName, err); |
|
272 } |
|
273 |
|
274 wsDebugLog->MiscMessage(CDebugLogBase::ELogImportant, buf); |
|
275 } |
|
276 |
|
277 if (err != KErrNone) |
|
278 { |
|
279 #ifdef _DEBUG |
|
280 _LIT(KLoadError, "WServ: failed to load plugin '%S' (error %d)"); |
|
281 RDebug::Print(KLoadError, &pluginName, err); |
|
282 #endif |
|
283 User::Leave(err); |
|
284 } |
|
285 |
|
286 // Create the key event router |
|
287 typedef CKeyEventRouter* (*TCreateFunc)(); |
|
288 TCreateFunc newL = reinterpret_cast<TCreateFunc>(iKeyEventRouterLibrary.Lookup(1)); |
|
289 if (newL == NULL) |
|
290 { |
|
291 User::Leave(KErrNotFound); |
|
292 } |
|
293 iKeyEventRouter = (*newL)(); |
|
294 |
237 for (TInt index=0;index<TWindowServerEvent::ENumHotKeys;index++) |
295 for (TInt index=0;index<TWindowServerEvent::ENumHotKeys;index++) |
238 ConstructDefaultHotKeyL(index,DefaultHotKeys[index]); |
296 ConstructDefaultHotKeyL(index,DefaultHotKeys[index]); |
239 CKeyboardRepeat::NewL(); |
297 CKeyboardRepeat::NewL(); |
240 CKeyboardRepeat::SetRepeatTime(EDefaultInitialRepeatTime, EDefaultRepeatTime); |
298 CKeyboardRepeat::SetRepeatTime(EDefaultInitialRepeatTime, EDefaultRepeatTime); |
241 iEventHandlers=RArray<TRawEventHandler>(2); |
299 iEventHandlers=RArray<TRawEventHandler>(2); |
651 return ETrue; |
716 return ETrue; |
652 } |
717 } |
653 |
718 |
654 void TWindowServerEvent::QueueKeyEvent(CWsWindowGroup *aWin, TWsEvent &aEvent, TWservEventPriorities aPriority) |
719 void TWindowServerEvent::QueueKeyEvent(CWsWindowGroup *aWin, TWsEvent &aEvent, TWservEventPriorities aPriority) |
655 { |
720 { |
|
721 #ifdef LOG_WSERV_EVENTS |
|
722 RDebug::Print(_L("_WSEVENT_KEY: TWindowServerEvent::QueueKeyEvent, Queuing event name %S for application read, window handle: %d"), &WsEventName(aEvent), CWsTop::FocusWindowGroup()->ClientHandle()); |
|
723 #endif |
656 aEvent.SetTimeNow(); |
724 aEvent.SetTimeNow(); |
657 aWin->EventQueue()->QueueEvent(aEvent, aPriority); |
725 aWin->EventQueue()->QueueEvent(aEvent, aPriority); |
658 } |
726 } |
659 |
727 |
660 void TWindowServerEvent::QueueKeyPress(const TKeyData& aKey, TInt aScanCode, CWsWindowGroup* aRepeatFocus, TBool aCheckRepeat,TInt aRepeats) |
728 /** |
|
729 Process a key press event. |
|
730 |
|
731 This function is called for every input key event and uses the Key Event |
|
732 Routing plug-in to check for short and long key capture and determine the |
|
733 destination window group for the queued event(s). |
|
734 Window server hotkeys are also processed. |
|
735 Note that the key repeat timer is started here but the key repeat events |
|
736 generated by the timer go directly to QueueKeyPress(). |
|
737 |
|
738 @param aKeyEvent Input key event |
|
739 @param aCheckRepeat Check for key repeat and long key capture |
|
740 @param aRepeats Repeat count |
|
741 */ |
|
742 void TWindowServerEvent::ProcessKeyPress(const TKeyEvent& aKeyEvent, TBool aCheckRepeat, TInt aRepeats) |
661 { |
743 { |
662 CWsWindowGroup* focusWin=CWsTop::FocusWindowGroup(); |
744 CWsWindowGroup* focusWin = CWsTop::FocusWindowGroup(); |
663 TWsEvent event; |
745 TUid focusAppUid = focusWin ? TUid::Uid(focusWin->Client()->SecureId().iId) : KNullUid; |
664 TKeyEvent& keyEvent=*event.Key(); |
746 |
665 keyEvent.iCode=aKey.iKeyCode; |
747 // Route the key event and check for short key capture. |
666 keyEvent.iScanCode=aScanCode; |
748 // Note that the Key Routing plugin may translate or block key events. |
667 keyEvent.iModifiers=aKey.iModifiers; |
749 TKeyEventRouterInput input(ECaptureTypeKey, aKeyEvent, focusWin, focusAppUid); |
668 keyEvent.iRepeats=aRepeats; |
750 TKeyEventRouterOutput output; |
669 if (!aRepeatFocus && CClick::IsHandler()) |
751 |
670 CClick::KeyEvent(EEventKey,keyEvent); |
752 #ifdef _DEBUG |
671 CWsCaptureLongKey* longCapture=NULL; |
753 // RouteKey() must not fail. Check for leaves in case the plug-in |
672 if (aCheckRepeat) |
754 // is badly behaved. |
673 longCapture=CWsCaptureLongKey::CheckForCapture(aKey.iKeyCode, aKey.iModifiers); |
755 TRAPD(err, iKeyEventRouter->RouteKey(input, output)); |
674 if (aKey.iIsCaptureKey) |
756 WS_ASSERT_DEBUG(err == KErrNone, EWsPanicKeyEventRouterLeave); |
675 { |
757 #else |
676 if (aKey.iApp==NULL) // Captured by Wserv itself |
758 iKeyEventRouter->RouteKey(input, output); |
|
759 #endif |
|
760 |
|
761 WS_ASSERT_DEBUG(output.iResult == ERouted || output.iResult == ECaptured || output.iResult == EConsumed, EWsPanicKeyEventRouterBadResult); |
|
762 |
|
763 if (output.iResult == EConsumed) |
|
764 { |
|
765 focusWin = NULL; |
|
766 } |
|
767 else |
|
768 { |
|
769 focusWin = static_cast<CWsWindowGroup*>(output.iWindowGroup); |
|
770 } |
|
771 WS_ASSERT_DEBUG((focusWin == NULL || focusWin->Type() == WS_HANDLE_GROUP_WINDOW) && (output.iResult != ERouted || focusWin == CWsTop::FocusWindowGroup()), EWsPanicKeyEventRouterBadWindowGroup); |
|
772 |
|
773 // Ensure that short event is not marked with EModifierLongKey |
|
774 output.iKeyEvent.iModifiers &= ~EModifierLongKey; |
|
775 |
|
776 // Generate key click unless the event is consumed. This is consistent |
|
777 // with the behaviour when CKeyTranslator::TranslateKey() yields no |
|
778 // translation for a particular scan code. (Click events for key up/down |
|
779 // will still be generated by QueueKeyUpDown()). Note however that a long |
|
780 // key press may still be captured even if the short event is consumed. |
|
781 if (CClick::IsHandler() && output.iResult != EConsumed) |
|
782 { |
|
783 output.iKeyEvent.iRepeats = aRepeats; |
|
784 CClick::KeyEvent(EEventKey, output.iKeyEvent); |
|
785 } |
|
786 |
|
787 if (output.iResult == ECaptured) |
|
788 { |
|
789 if (output.iWindowGroup == NULL) // Captured by Wserv itself |
677 { |
790 { |
678 _LIT(KWSERVDebugLogCapturedKey,"WSERV Captured Key"); |
791 _LIT(KWSERVDebugLogCapturedKey,"WSERV Captured Key"); |
679 CScreen* focusScreen=CWsTop::CurrentFocusScreen(); |
792 CScreen* focusScreen=CWsTop::CurrentFocusScreen(); |
680 TInt screenNo=focusScreen->ScreenNumber(); |
793 TInt screenNo=focusScreen->ScreenNumber(); |
681 |
794 |
682 if (wsDebugLog) |
795 if (wsDebugLog) |
683 wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,KWSERVDebugLogCapturedKey); |
796 wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,KWSERVDebugLogCapturedKey); |
684 CWsHotKey *hotKey=iHotKeys; |
797 CWsHotKey *hotKey=iHotKeys; |
685 while(hotKey) |
798 while(hotKey) |
686 { |
799 { |
687 if (hotKey->KeyHandle()==aKey.iHandle) |
800 if (hotKey->KeyHandle() == reinterpret_cast<TInt>(output.iCaptureHandle)) |
688 { |
801 { |
689 switch(hotKey->HotKeyType()) |
802 switch(hotKey->HotKeyType()) |
690 { |
803 { |
691 case EHotKeyEnableLogging: |
804 case EHotKeyEnableLogging: |
692 CWsTop::EnableLogging(); |
805 CWsTop::EnableLogging(); |
767 hotKey=hotKey->iNext; |
880 hotKey=hotKey->iNext; |
768 } |
881 } |
769 WS_PANIC_ALWAYS(EWsPanicUnknownCaptureKey); |
882 WS_PANIC_ALWAYS(EWsPanicUnknownCaptureKey); |
770 return; |
883 return; |
771 } |
884 } |
772 focusWin=((CWsWindowGroup *)aKey.iApp); |
885 |
773 _LIT(KWSERVDebugLogKeyCapturedByApp,"Key captured by app %d"); |
886 _LIT(KWSERVDebugLogKeyCapturedByApp,"Key captured by app %d"); |
774 if (wsDebugLog) |
887 if (wsDebugLog) |
775 wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,KWSERVDebugLogKeyCapturedByApp,focusWin->Identifier()); |
888 wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,KWSERVDebugLogKeyCapturedByApp,focusWin->Identifier()); |
776 if (CWsPassword::PasswordModeActive() && focusWin!=CWsPassword::PasswordWindow()->WinGroup()) |
889 if (CWsPassword::PasswordModeActive() && focusWin!=CWsPassword::PasswordWindow()->WinGroup()) |
777 return; |
890 return; |
778 } |
891 } |
779 if (aRepeatFocus && aRepeatFocus!=focusWin) |
892 |
|
893 CWsCaptureLongKey* longCapture = NULL; |
|
894 TKeyEventRouterOutput longOutput; |
|
895 if (aCheckRepeat) |
|
896 { |
|
897 // Check for long key capture. |
|
898 // Note that a long key event can only result from capture, there is |
|
899 // no default detection or routing of long events. |
|
900 input.iType = ECaptureTypeLongKey; |
|
901 #ifdef _DEBUG |
|
902 TRAPD(err, iKeyEventRouter->RouteKey(input, longOutput)); |
|
903 WS_ASSERT_DEBUG(err == KErrNone, EWsPanicKeyEventRouterLeave); |
|
904 #else |
|
905 iKeyEventRouter->RouteKey(input, longOutput); |
|
906 #endif |
|
907 |
|
908 if (longOutput.iResult == ECaptured) |
|
909 { |
|
910 longCapture = static_cast<CWsCaptureLongKey*>(longOutput.iCaptureHandle); |
|
911 |
|
912 // Mark long key events with EModifierLongKey so that applications |
|
913 // can easily distinguish short and long events. |
|
914 longOutput.iKeyEvent.iModifiers |= EModifierLongKey; |
|
915 |
|
916 // Start timer to detect long key press |
|
917 CKeyboardRepeat::StartRepeat(aKeyEvent.iScanCode, output, &longOutput); |
|
918 } |
|
919 else if (output.iResult != EConsumed && output.iKeyEvent.iModifiers & EModifierAutorepeatable) |
|
920 { |
|
921 // Start timer for key repeat |
|
922 CKeyboardRepeat::StartRepeat(aKeyEvent.iScanCode, output, NULL); |
|
923 } |
|
924 } |
|
925 |
|
926 // Queue the short event |
|
927 if (!longCapture || longCapture->iFlags & ELongCaptureShortEventImmediately) |
|
928 { |
|
929 QueueKeyPress(output, EFalse, aRepeats); |
|
930 } |
|
931 } |
|
932 |
|
933 /** |
|
934 Queue a key press event. |
|
935 |
|
936 This function is called for each key event produced by ProcessKeyPress(), |
|
937 for every key repeat and long key event generated by the timer and also for |
|
938 delayed short key events from KeyUp(). |
|
939 |
|
940 @param aOutput Output key event from routing plug-in |
|
941 @param aIsRepeat Event is due to key repeat |
|
942 @param aRepeats Repeat count |
|
943 */ |
|
944 void TWindowServerEvent::QueueKeyPress(const TKeyEventRouterOutput& aOutput, TBool aIsRepeat, TInt aRepeats) |
|
945 { |
|
946 if (aOutput.iResult == EConsumed) |
|
947 { |
|
948 // Don't deliver this key |
|
949 return; |
|
950 } |
|
951 |
|
952 TWsEvent event; |
|
953 TKeyEvent& keyEvent = *event.Key(); |
|
954 keyEvent = aOutput.iKeyEvent; |
|
955 keyEvent.iRepeats = aRepeats; |
|
956 |
|
957 CWsWindowGroup* focusWin = static_cast<CWsWindowGroup*>(aOutput.iWindowGroup); |
|
958 WS_ASSERT_DEBUG(focusWin == NULL || focusWin->Type() == WS_HANDLE_GROUP_WINDOW, EWsPanicKeyEventRouterBadWindowGroup); |
|
959 |
|
960 if (aIsRepeat && aOutput.iResult != ECaptured && focusWin != CWsTop::FocusWindowGroup()) |
780 CKeyboardRepeat::CancelRepeat(NULL); // Repeat is going to different window so cancel it and don't deliver this key |
961 CKeyboardRepeat::CancelRepeat(NULL); // Repeat is going to different window so cancel it and don't deliver this key |
781 else if (focusWin!=NULL && focusWin->CheckForPriorityKey(aKey,aScanCode)==EFalse) |
962 else if (focusWin != NULL && focusWin->CheckForPriorityKey(keyEvent) == EFalse) |
782 { |
963 { |
783 if (longCapture || (aCheckRepeat && !aRepeatFocus && aKey.iModifiers&EModifierAutorepeatable)) |
|
784 { |
|
785 if (CKeyboardRepeat::StartRepeat(aKey,aScanCode,focusWin,longCapture)) |
|
786 return; |
|
787 } |
|
788 event.SetType(EEventKey); |
964 event.SetType(EEventKey); |
789 event.SetHandle(focusWin->ClientHandle()); |
965 event.SetHandle(focusWin->ClientHandle()); |
790 if (aRepeats!=0) |
966 if (aRepeats!=0) |
791 { |
967 { |
792 CEventQueue* queue=focusWin->EventQueue(); |
968 CEventQueue* queue=focusWin->EventQueue(); |
793 queue->Wait(); |
969 queue->Wait(); |
794 const TWsEvent* prev=queue->PeekLastEvent(); |
970 const TWsEvent* prev=queue->PeekLastEvent(); |
795 if (prev!=NULL && prev->Type()==EEventKey && prev->Key()->iRepeats>0) |
971 if (prev != NULL && prev->Type() == EEventKey && prev->Key()->iRepeats > 0 && prev->Key()->iCode == keyEvent.iCode) |
796 { |
972 { |
797 event= *prev; |
973 prev->Key()->iRepeats += aRepeats; |
798 event.Key()->iRepeats+=aRepeats; |
|
799 queue->UpdateLastEvent(event); |
|
800 queue->Signal(); |
974 queue->Signal(); |
801 if (CClick::IsHandler()) |
975 if (CClick::IsHandler()) |
802 CClick::KeyEvent(EEventKeyRepeat,*event.Key()); |
976 CClick::KeyEvent(EEventKeyRepeat, *prev->Key()); |
803 return; |
977 return; |
804 } |
978 } |
805 queue->Signal(); |
979 queue->Signal(); |
806 event.Key()->iRepeats=aRepeats; |
|
807 if (CClick::IsHandler()) |
980 if (CClick::IsHandler()) |
808 CClick::KeyEvent(EEventKeyRepeat,keyEvent); |
981 CClick::KeyEvent(EEventKeyRepeat,keyEvent); |
809 } |
982 } |
810 QueueKeyEvent(focusWin, event, EEventPriorityLow); |
983 QueueKeyEvent(focusWin, event, EEventPriorityLow); |
811 } |
984 } |
812 } |
985 } |
813 |
986 |
|
987 /** |
|
988 Queue a key up/down event. |
|
989 |
|
990 @param aRawEvent Raw event |
|
991 */ |
814 void TWindowServerEvent::QueueKeyUpDown(const TRawEvent &aRawEvent) |
992 void TWindowServerEvent::QueueKeyUpDown(const TRawEvent &aRawEvent) |
815 { |
993 { |
816 CWsWindowGroup *focusWin=CWsCaptureKeyUpsAndDowns::CheckForCapture(aRawEvent.ScanCode() __REMOVE_WINS_CHARCODE, iModifierState); |
994 #ifdef LOG_WSERV_EVENTS |
817 if (!focusWin) // If not captured |
995 RDebug::Print(_L("_WSEVENT_KEY: TWindowServerEvent::QueueKeyUpDown, Event Name: %S, Scan code: %d"), &RawEventName(aRawEvent), aRawEvent.ScanCode()); |
818 focusWin=CWsTop::FocusWindowGroup(); |
996 #endif |
819 TWsEvent event; |
997 TEventCode type = aRawEvent.Type() == TRawEvent::EKeyUp ? EEventKeyUp : EEventKeyDown; |
820 TEventCode type=aRawEvent.Type()==TRawEvent::EKeyUp ? EEventKeyUp : EEventKeyDown; |
998 |
821 event.Key()->iCode=0; |
999 // Check for key up/down capture |
|
1000 TKeyEvent keyEvent; |
|
1001 keyEvent.iScanCode = aRawEvent.ScanCode() __REMOVE_WINS_CHARCODE; |
|
1002 #if defined(__WINS__) |
|
1003 keyEvent.iCode = __WINS_CHARCODE(aRawEvent.ScanCode()); |
|
1004 #else |
|
1005 keyEvent.iCode = 0; |
|
1006 #endif |
|
1007 keyEvent.iModifiers = iModifierState; |
|
1008 keyEvent.iRepeats = 0; |
|
1009 |
|
1010 CWsWindowGroup* focusWin = CWsTop::FocusWindowGroup(); |
|
1011 TUid focusAppUid = focusWin ? TUid::Uid(focusWin->Client()->SecureId().iId) : KNullUid; |
|
1012 |
|
1013 TKeyEventRouterInput input(ECaptureTypeKeyUpDown, keyEvent, focusWin, focusAppUid); |
|
1014 TKeyEventRouterOutput output; |
|
1015 #ifdef _DEBUG |
|
1016 TRAPD(err, iKeyEventRouter->RouteKey(input, output)); |
|
1017 WS_ASSERT_DEBUG(err == KErrNone, EWsPanicKeyEventRouterLeave); |
|
1018 #else |
|
1019 iKeyEventRouter->RouteKey(input, output); |
|
1020 #endif |
|
1021 |
|
1022 if (output.iResult == EConsumed) |
|
1023 { |
|
1024 // Don't deliver this key. A key click is still generated for the |
|
1025 // input event. |
|
1026 if (CClick::IsHandler()) |
|
1027 { |
|
1028 CClick::KeyEvent(type, keyEvent); |
|
1029 } |
|
1030 return; |
|
1031 } |
|
1032 WS_ASSERT_DEBUG(output.iResult == ERouted || output.iResult == ECaptured, EWsPanicKeyEventRouterBadResult); |
|
1033 |
|
1034 focusWin = static_cast<CWsWindowGroup*>(output.iWindowGroup); |
|
1035 WS_ASSERT_DEBUG((focusWin == NULL || focusWin->Type() == WS_HANDLE_GROUP_WINDOW) && (output.iResult != ERouted || focusWin == CWsTop::FocusWindowGroup()), EWsPanicKeyEventRouterBadWindowGroup); |
822 #if defined(__WINS__) |
1036 #if defined(__WINS__) |
823 if (focusWin && !focusWin->WsOwner()->RemoveKeyCode()) |
1037 if (focusWin && !focusWin->WsOwner()->RemoveKeyCode()) |
824 event.Key()->iScanCode=aRawEvent.ScanCode(); |
1038 { |
825 else |
1039 // Restore WINS character code |
826 #endif |
1040 output.iKeyEvent.iScanCode |= output.iKeyEvent.iCode; |
827 event.Key()->iScanCode=aRawEvent.ScanCode() __REMOVE_WINS_CHARCODE; |
1041 } |
828 event.Key()->iModifiers=iModifierState; |
1042 output.iKeyEvent.iCode = 0; |
829 event.Key()->iRepeats=0; |
1043 #endif |
|
1044 |
|
1045 output.iKeyEvent.iRepeats = 0; |
830 if (CClick::IsHandler()) |
1046 if (CClick::IsHandler()) |
831 CClick::KeyEvent(type,*event.Key()); |
1047 { |
|
1048 CClick::KeyEvent(type, output.iKeyEvent); |
|
1049 } |
|
1050 |
|
1051 TWsEvent event; |
|
1052 *event.Key() = output.iKeyEvent; |
832 if (focusWin!=NULL) |
1053 if (focusWin!=NULL) |
833 { |
1054 { |
834 event.SetType(type); |
1055 event.SetType(type); |
835 event.SetHandle(focusWin->ClientHandle()); |
1056 event.SetHandle(focusWin->ClientHandle()); |
836 QueueKeyEvent(focusWin, event, EEventPriorityHigh); |
1057 QueueKeyEvent(focusWin, event, EEventPriorityHigh); |
980 } |
1216 } |
981 } |
1217 } |
982 } |
1218 } |
983 if (eventHandled) |
1219 if (eventHandled) |
984 { |
1220 { |
|
1221 #ifdef LOG_WSERV_EVENTS |
|
1222 RDebug::Printf("_WSEVENT: Event is already handled by anim dll not by window server"); |
|
1223 // This is to determine when we press the power button which bring power dialog |
|
1224 // whether it is a pointer event or key event |
|
1225 // Also when we plugin the charging cable this is to determine whether it is a pointer event or key event |
|
1226 RDebug::Print(_L("_WSEVENT: RawEvent Name = %S"), &RawEventName(aRawEvent)); |
|
1227 #endif |
985 if (isPointerEvent) |
1228 if (isPointerEvent) |
986 { |
1229 { |
987 TWsPointer::RollbackPrimaryPointer(); |
1230 #ifdef LOG_WSERV_EVENTS |
|
1231 RDebug::Printf("_WSEVENT_POINTER: TWindowServerEvent::ProcessRawEvent Pointer Number= %d State = %x XY(%d,%d)",TWsPointer::iPointers[0].iNumber,TWsPointer::iPointers[0].iState,TWsPointer::iPointers[0].iPos.iX,TWsPointer::iPointers[0].iPos.iY); |
|
1232 RDebug::Printf("_WSEVENT_POINTER: TWindowServerEvent::ProcessRawEvent Pointer Number= %d State = %x XY(%d,%d)",TWsPointer::iPointers[1].iNumber,TWsPointer::iPointers[1].iState,TWsPointer::iPointers[1].iPos.iX,TWsPointer::iPointers[1].iPos.iY); |
|
1233 #endif |
|
1234 //Prevention of the phone pointer event "dead lock". |
|
1235 TPointerEvent::TType type; |
|
1236 TBool handled = ETrue; |
|
1237 GetPointerEvent(type, aRawEvent, handled); |
|
1238 switch(type) |
|
1239 { |
|
1240 case TPointerEvent::EButton1Down: |
|
1241 case TPointerEvent::EButton2Down: |
|
1242 case TPointerEvent::EButton3Down: |
|
1243 TWsPointer::iPointers[aRawEvent.PointerNumber()].iState = TWsPointer::EPointerStateDown; |
|
1244 break; |
|
1245 case TPointerEvent::EButton1Up: |
|
1246 case TPointerEvent::EButton2Up: |
|
1247 case TPointerEvent::EButton3Up: |
|
1248 TWsPointer::iPointers[aRawEvent.PointerNumber()].iState = TWsPointer::EPointerStateUp; |
|
1249 break; |
|
1250 case TPointerEvent::EOutOfRange: |
|
1251 TWsPointer::iPointers[aRawEvent.PointerNumber()].iState = TWsPointer::EPointerStateOutOfRange; |
|
1252 break; |
|
1253 default: |
|
1254 break; |
|
1255 } |
988 } |
1256 } |
989 return; |
1257 return; |
990 } |
1258 } |
|
1259 |
991 switch(eventType) |
1260 switch(eventType) |
992 { |
1261 { |
993 case TRawEvent::ERedraw: |
1262 case TRawEvent::ERedraw: |
994 CWsTop::RedrawScreens(); |
1263 CWsTop::RedrawScreens(); |
995 break; |
1264 break; |
1033 CWsTop::WindowServer()->AnimationScheduler()->OnActive(); |
1302 CWsTop::WindowServer()->AnimationScheduler()->OnActive(); |
1034 #endif |
1303 #endif |
1035 break; |
1304 break; |
1036 case TRawEvent::EKeyDown: |
1305 case TRawEvent::EKeyDown: |
1037 { |
1306 { |
|
1307 #ifdef LOG_WSERV_EVENTS |
|
1308 RDebug::Printf("_WSEVENT_KEY: TRawEvent::EKeyDown"); |
|
1309 #endif |
1038 _LIT(KWSERVDebugLogKeyDownArrival,"Key down arrives %d"); |
1310 _LIT(KWSERVDebugLogKeyDownArrival,"Key down arrives %d"); |
1039 CScreen* screen = CWsTop::Screen(); |
1311 CScreen* screen = CWsTop::Screen(); |
1040 WS_ASSERT_ALWAYS(screen, EWsPanicNoScreen); |
1312 WS_ASSERT_ALWAYS(screen, EWsPanicNoScreen); |
1041 if(CDebugBar* dbg = screen->DebugBar()) |
1313 if(CDebugBar* dbg = screen->DebugBar()) |
1042 dbg->OnKeyEvent(); |
1314 dbg->OnKeyEvent(); |
1043 if (wsDebugLog) |
1315 if (wsDebugLog) |
1044 wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,KWSERVDebugLogKeyDownArrival,aRawEvent.ScanCode()); |
1316 wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,KWSERVDebugLogKeyDownArrival,aRawEvent.ScanCode()); |
1045 CKeyboardRepeat::KeyDown(); |
1317 CKeyboardRepeat::KeyDown(); |
1046 TKeyData keyData; |
1318 TKeyData keyData; |
|
1319 // Note iCaptureKeys is needed as dummy arg only. Key capture is |
|
1320 // now handled in ProcessKeyPress(). |
1047 TBool translated=iKeyTranslator->TranslateKey(aRawEvent.ScanCode(), EFalse,*iCaptureKeys,keyData); |
1321 TBool translated=iKeyTranslator->TranslateKey(aRawEvent.ScanCode(), EFalse,*iCaptureKeys,keyData); |
1048 ProcessModifierChanges(); |
1322 ProcessModifierChanges(); |
1049 QueueKeyUpDown(aRawEvent); |
1323 QueueKeyUpDown(aRawEvent); |
1050 if (translated) |
1324 if (translated) |
1051 QueueKeyPress(keyData,aRawEvent.ScanCode() __REMOVE_WINS_CHARCODE,NULL,ETrue,0); |
1325 { |
|
1326 TKeyEvent keyEvent; |
|
1327 keyEvent.iScanCode = aRawEvent.ScanCode() __REMOVE_WINS_CHARCODE; |
|
1328 keyEvent.iCode = keyData.iKeyCode; |
|
1329 keyEvent.iModifiers = keyData.iModifiers; |
|
1330 ProcessKeyPress(keyEvent, ETrue, 0); |
|
1331 } |
1052 } |
1332 } |
1053 break; |
1333 break; |
1054 case TRawEvent::EKeyUp: |
1334 case TRawEvent::EKeyUp: |
1055 { |
1335 { |
|
1336 #ifdef LOG_WSERV_EVENTS |
|
1337 RDebug::Printf("_WSEVENT_KEY: TRawEvent::EKeyUp"); |
|
1338 #endif |
1056 _LIT(KWSERVDebugLogKeyUpArrival,"Key up arrives %d"); |
1339 _LIT(KWSERVDebugLogKeyUpArrival,"Key up arrives %d"); |
1057 CScreen* screen = CWsTop::Screen(); |
1340 CScreen* screen = CWsTop::Screen(); |
1058 WS_ASSERT_ALWAYS(screen, EWsPanicNoScreen); |
1341 WS_ASSERT_ALWAYS(screen, EWsPanicNoScreen); |
1059 if(CDebugBar* dbg = screen->DebugBar()) |
1342 if(CDebugBar* dbg = screen->DebugBar()) |
1060 dbg->OnKeyEvent(); |
1343 dbg->OnKeyEvent(); |
1097 case TRawEvent::EKeyRepeat: |
1384 case TRawEvent::EKeyRepeat: |
1098 { |
1385 { |
1099 _LIT(KWSERVDebugLogRepeatingKeyArrival,"Repeating key arrives %d"); |
1386 _LIT(KWSERVDebugLogRepeatingKeyArrival,"Repeating key arrives %d"); |
1100 if (wsDebugLog) |
1387 if (wsDebugLog) |
1101 wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,KWSERVDebugLogRepeatingKeyArrival,aRawEvent.ScanCode()); |
1388 wsDebugLog->MiscMessage(CDebugLogBase::ELogEverything,KWSERVDebugLogRepeatingKeyArrival,aRawEvent.ScanCode()); |
1102 TKeyData keyData; |
1389 TKeyEvent keyEvent; |
1103 keyData.iModifiers=iKeyTranslator->GetModifierState(); |
1390 keyEvent.iScanCode = aRawEvent.ScanCode() __REMOVE_WINS_CHARCODE; |
1104 keyData.iApp=0; |
1391 keyEvent.iCode = aRawEvent.ScanCode(); |
1105 keyData.iHandle=0; |
1392 keyEvent.iModifiers = iKeyTranslator->GetModifierState(); |
1106 keyData.iIsCaptureKey=EFalse; |
1393 ProcessKeyPress(keyEvent, EFalse, aRawEvent.Repeats()); |
1107 keyData.iKeyCode=aRawEvent.ScanCode(); |
|
1108 iCaptureKeys->ProcessCaptureKeys(keyData); |
|
1109 QueueKeyPress(keyData, aRawEvent.ScanCode() __REMOVE_WINS_CHARCODE,NULL,EFalse,aRawEvent.Repeats()); |
|
1110 } |
1394 } |
1111 break; |
1395 break; |
1112 default: |
1396 default: |
1113 break; |
1397 break; |
1114 } |
1398 } |
|
1399 #ifdef LOG_WSERV_EVENTS |
|
1400 RDebug::Printf("_WSEVENT_POINTER: TWindowServerEvent::ProcessRawEvent Number= %d State = %x XY(%d,%d)",TWsPointer::iPointers[0].iNumber,TWsPointer::iPointers[0].iState,TWsPointer::iPointers[0].iPos.iX,TWsPointer::iPointers[0].iPos.iY); |
|
1401 RDebug::Printf("_WSEVENT_POINTER: TWindowServerEvent::ProcessRawEvent Number= %d State = %x XY(%d,%d)",TWsPointer::iPointers[1].iNumber,TWsPointer::iPointers[1].iState,TWsPointer::iPointers[1].iPos.iX,TWsPointer::iPointers[1].iPos.iY); |
|
1402 #endif |
1115 } |
1403 } |
1116 |
1404 |
1117 void TWindowServerEvent::ProcessKeyEvent(const TKeyEvent &aKeyEvent,TInt aRepeats) |
1405 void TWindowServerEvent::ProcessKeyEvent(const TKeyEvent &aKeyEvent,TInt aRepeats) |
1118 { |
1406 { |
|
1407 #ifdef LOG_WSERV_EVENTS |
|
1408 RDebug::Printf("_WSEVENT_KEY: TWindowServerEvent::ProcessKeyEvent, key code: %d, repeat: %d", aKeyEvent.iCode, aRepeats); |
|
1409 #endif |
1119 TKeyData keyData; |
1410 TKeyData keyData; |
1120 keyData.iModifiers=aKeyEvent.iModifiers; |
1411 keyData.iModifiers=aKeyEvent.iModifiers; |
1121 keyData.iApp=0; |
1412 keyData.iApp=0; |
1122 keyData.iHandle=0; |
1413 keyData.iHandle=0; |
1123 keyData.iIsCaptureKey=EFalse; |
1414 keyData.iIsCaptureKey=EFalse; |
1124 keyData.iKeyCode=aKeyEvent.iCode; |
1415 keyData.iKeyCode=aKeyEvent.iCode; |
1125 if (CKeyboardRepeat::IsAreadyActive()) |
1416 if (CKeyboardRepeat::IsAreadyActive()) |
1126 { |
1417 { |
1127 CKeyboardRepeat::CancelRepeat(NULL); |
1418 CKeyboardRepeat::CancelRepeat(NULL); |
1128 } |
1419 } |
1129 iCaptureKeys->ProcessCaptureKeys(keyData); |
1420 ProcessKeyPress(aKeyEvent, aRepeats == 0, aRepeats); |
1130 QueueKeyPress(keyData,aKeyEvent.iScanCode,NULL,aRepeats==0,aRepeats); |
1421 } |
1131 } |
1422 |
1132 |
1423 void TWindowServerEvent::AddCaptureKeyL(const TKeyCaptureRequest& aRequest) |
1133 void TWindowServerEvent::AddCaptureKeyL(const TCaptureKey &aCaptureKey) |
1424 { |
1134 { |
1425 iKeyEventRouter->AddCaptureKeyL(aRequest); |
1135 iCaptureKeys->AddCaptureKeyL(aCaptureKey,aCaptureKey.iKeyCodePattern.iFiller); |
1426 } |
1136 } |
1427 |
1137 |
1428 void TWindowServerEvent::UpdateCaptureKeyL(const TKeyCaptureRequest& aRequest) |
1138 void TWindowServerEvent::SetCaptureKey(TUint32 aHandle, const TCaptureKey &aCaptureKey) |
1429 { |
1139 { |
1430 iKeyEventRouter->UpdateCaptureKeyL(aRequest); |
1140 iCaptureKeys->SetCaptureKey(aHandle, aCaptureKey,aCaptureKey.iKeyCodePattern.iFiller); |
1431 } |
1141 } |
1432 |
1142 |
1433 void TWindowServerEvent::CancelCaptureKey(TKeyCaptureType aType, TAny* aHandle) |
1143 void TWindowServerEvent::CancelCaptureKey(TUint32 aHandle) |
1434 { |
1144 { |
1435 iKeyEventRouter->CancelCaptureKey(aType, aHandle); |
1145 iCaptureKeys->CancelCaptureKey(aHandle); |
|
1146 } |
1436 } |
1147 |
1437 |
1148 TInt TWindowServerEvent::GetModifierState() |
1438 TInt TWindowServerEvent::GetModifierState() |
1149 { |
1439 { |
1150 return(iKeyTranslator->GetModifierState()); |
1440 return(iKeyTranslator->GetModifierState()); |
1509 } |
1808 } |
1510 if (timer) |
1809 if (timer) |
1511 After(iTime); |
1810 After(iTime); |
1512 else |
1811 else |
1513 iRepeating=ERepeatNone; |
1812 iRepeating=ERepeatNone; |
1514 TWindowServerEvent::QueueKeyPress(iCurrentRepeat.iKey,iCurrentRepeat.iScanCode,iFocus,EFalse,1); |
1813 |
1515 } |
1814 TWindowServerEvent::QueueKeyPress(iCurrentRepeat.iOutput, ETrue, 1); |
1516 |
1815 } |
1517 TBool CKeyboardRepeat::StartRepeat(const TKeyData &aKey, TInt aScanCode, CWsWindowGroup *aRepeatFocus, CWsCaptureLongKey* aLongCapture) |
1816 |
|
1817 /** |
|
1818 Start key repeat and long key press timer |
|
1819 |
|
1820 @param aInputScanCode Original scan code (before routing) |
|
1821 @param aShortEvent Short key event (routing plug-in output) |
|
1822 @param aLongEvent Pointer to long key event (routing plug-in output) |
|
1823 or NULL if none. |
|
1824 |
|
1825 Note: When aLongEvent != NULL, iCurrentRepeat reflects the short key event |
|
1826 until the timer has expired. This is necessary to allow a delayed short key |
|
1827 event to be delivered by KeyUp(). CancelRepeat() must therefore examine |
|
1828 iCurrentRepeat or iLongRepeat according to the repeat type in iRepeat. |
|
1829 */ |
|
1830 void CKeyboardRepeat::StartRepeat(TInt aInputScanCode, const TKeyEventRouterOutput& aShortEvent, const TKeyEventRouterOutput* aLongEvent) |
1518 { |
1831 { |
1519 TTimeIntervalMicroSeconds32 time; |
1832 TTimeIntervalMicroSeconds32 time; |
1520 TBool ret=EFalse; |
1833 iCurrentRepeat.iInputScanCode = aInputScanCode; |
1521 iCurrentRepeat.iScanCode=aScanCode; |
1834 iCurrentRepeat.iOutput = aShortEvent; |
1522 iCurrentRepeat.iKey=aKey; |
1835 |
1523 |
1836 if (aLongEvent) |
1524 if (aLongCapture) |
1837 { |
1525 { |
1838 iRepeating = ERepeatLong; |
1526 iLongCapture=aLongCapture; |
1839 iLongRepeat.iInputScanCode = aInputScanCode; |
1527 iRepeating=ERepeatLong; |
1840 iLongRepeat.iOutput = *aLongEvent; |
1528 time=aLongCapture->iData.delay; |
1841 iLongCapture = static_cast<CWsCaptureLongKey*>(aLongEvent->iCaptureHandle); |
1529 ret=!(aLongCapture->iData.flags&ELongCaptureShortEventImmediately); |
1842 time = iLongCapture->iDelay; |
1530 //need window group from long capture key or even better delete it altogether. |
|
1531 iFocus=aLongCapture->WindowGroup(); |
|
1532 } |
1843 } |
1533 else |
1844 else |
1534 { |
1845 { |
1535 iFocus=aRepeatFocus; |
1846 iLongCapture = NULL; |
1536 iRepeating=ERepeatNormal; |
1847 iRepeating=ERepeatNormal; |
1537 time=iInitialTime; |
1848 time=iInitialTime; |
1538 } |
1849 } |
1539 iThis->After(time); |
1850 iThis->After(time); |
1540 return ret; |
1851 } |
1541 } |
1852 |
1542 |
1853 /** |
|
1854 Cancel key repeat processing |
|
1855 */ |
1543 void CKeyboardRepeat::doCancelRepeat() |
1856 void CKeyboardRepeat::doCancelRepeat() |
1544 { |
1857 { |
1545 iRepeating=ERepeatNone; |
1858 iRepeating=ERepeatNone; |
1546 iThis->Cancel(); |
1859 iThis->Cancel(); |
1547 } |
1860 } |
1548 |
1861 |
|
1862 /** |
|
1863 Cancel any key repeat associated with the specified window group |
|
1864 |
|
1865 @param aRepeatFocus Destination window group or NULL for all |
|
1866 */ |
1549 void CKeyboardRepeat::CancelRepeat(CWsWindowGroup *aRepeatFocus) |
1867 void CKeyboardRepeat::CancelRepeat(CWsWindowGroup *aRepeatFocus) |
1550 { |
1868 { |
1551 if (aRepeatFocus==NULL || aRepeatFocus==iFocus) |
1869 if (iRepeating != ERepeatNone) |
1552 { |
1870 { |
1553 if (iRepeating) |
1871 if (aRepeatFocus == NULL || |
1554 doCancelRepeat(); |
1872 (iRepeating == ERepeatNormal) && (aRepeatFocus == iCurrentRepeat.iOutput.iWindowGroup) || |
1555 iAlternateRepeatExists=EFalse; |
1873 (iRepeating >= ERepeatLong) && (aRepeatFocus == iLongRepeat.iOutput.iWindowGroup)) |
1556 } |
|
1557 else if (iRepeating >= ERepeatLong) |
|
1558 { |
|
1559 // Defensive programming - iLongCapture should never be NULL if iRepeating >= ERepeatLong |
|
1560 if (iLongCapture && iLongCapture->iWindowGroup == aRepeatFocus) |
|
1561 { |
1874 { |
1562 doCancelRepeat(); |
1875 doCancelRepeat(); |
1563 iAlternateRepeatExists=EFalse; |
1876 iAlternateRepeatExists=EFalse; |
1564 } |
1877 } |
1565 } |
1878 } |
1566 } |
1879 } |
1567 |
1880 |
1568 void CKeyboardRepeat::CancelRepeat(CWsWindowGroup *aRepeatFocus,TUint aScanCode,TBool aLongCaptureFlag,TUint aModifiers) |
1881 /** |
|
1882 Cancel any key repeat associated with the specified capture handle |
|
1883 |
|
1884 @param aCaptureHandle Handle to capture request |
|
1885 @param aLongCaptureFlag ETrue for long key capture, EFalse for normal key |
|
1886 */ |
|
1887 void CKeyboardRepeat::CancelRepeat(const TAny* aCaptureHandle, TBool aLongCaptureFlag) |
1569 { |
1888 { |
1570 if (aLongCaptureFlag) |
1889 if (aLongCaptureFlag) |
1571 { |
1890 { |
1572 // long capture key is cancelled |
1891 // Cancel repeat for long capture key |
1573 if (iRepeating >= ERepeatLong && iCurrentRepeat.iScanCode==aScanCode) |
1892 if (iRepeating >= ERepeatLong && aCaptureHandle == iLongRepeat.iOutput.iCaptureHandle) |
1574 { |
1893 { |
1575 // Defensive programming - iLongCapture should never be NULL if iRepeating >= ERepeatLong |
1894 doCancelRepeat(); |
1576 if (iLongCapture && aRepeatFocus == iLongCapture->iWindowGroup && |
1895 iAlternateRepeatExists=EFalse; |
1577 (aModifiers & iLongCapture->iData.modifierMask) == iLongCapture->iData.modifiers) |
1896 } |
1578 { |
|
1579 doCancelRepeat(); |
|
1580 iAlternateRepeatExists=EFalse; |
|
1581 } |
|
1582 } |
|
1583 } |
1897 } |
1584 else |
1898 else |
1585 { |
1899 { |
1586 // normal capture key is cancelled |
1900 // Cancel repeat for normal capture key |
1587 if (aRepeatFocus==iFocus) |
1901 if (iRepeating == ERepeatNormal && aCaptureHandle == iCurrentRepeat.iOutput.iCaptureHandle) |
1588 { |
1902 { |
1589 if (iRepeating>=ERepeatNormal && iCurrentRepeat.iScanCode==aScanCode) |
1903 doCancelRepeat(); |
1590 { |
|
1591 doCancelRepeat(); |
|
1592 } |
|
1593 iAlternateRepeatExists=EFalse; |
1904 iAlternateRepeatExists=EFalse; |
1594 } |
1905 } |
1595 } |
1906 } |
1596 } |
1907 } |
1597 |
1908 |
|
1909 /** |
|
1910 Process a key down event during key repeat. |
|
1911 The current repeat data is saved for possible restoration after rollover. |
|
1912 */ |
1598 void CKeyboardRepeat::KeyDown() |
1913 void CKeyboardRepeat::KeyDown() |
1599 { |
1914 { |
1600 if (iRepeating!=ERepeatNone) |
1915 if (iRepeating!=ERepeatNone) |
1601 { |
1916 { |
1602 if (iRepeating==ERepeatNormal && iRepeatRollover>0) // 1 Allow key repeat rollover |
1917 if (iRepeating==ERepeatNormal && iRepeatRollover>0) // 1 Allow key repeat rollover |