void CGlobalSettings::SetScreenNoL(TInt aScreenNo) { RWsSession session; ASSERT_EQUALS(session.Connect(), KErrNone); TInt maxScreens=session.NumberOfScreens(); if (maxScreens>aScreenNo) { INFO_PRINTF2(_L("New screen number for all output selected: %i"),aScreenNo); { CWsScreenDevice screen(session); screen.Construct(aScreenNo); screen.SetCurrentRotations(0,CFbsBitGc::TGraphicsOrientation(0)); screen.SetScreenMode(0); screen.SetAppScreenMode(0); } settings_instance.iScreen=aScreenNo; session.Flush(); session.Close(); } else { INFO_PRINTF1(_L("**************************")); INFO_PRINTF1(_L("")); INFO_PRINTF3(_L("Can't set screen output to %i. Only got %i screens"),aScreenNo,maxScreens); INFO_PRINTF2(_L("Screen number for all output remains at: %i"),settings_instance.iScreen); INFO_PRINTF1(_L("")); INFO_PRINTF1(_L("**************************")); session.Flush(); session.Close(); User::Leave(KErrTEFUnitFail); } }
void CTTSprite::GeneralTestsL() { // // Close cursor while still active on a window // RWindow win(TheClient->iWs); win.Construct(*TheClient->iGroup->GroupWin(),1); win.Activate(); SetUpPointerCursorL(iCursor1,TheClient->iWs); win.SetCustomPointerCursor(iCursor1); iCursor1.Close(); // // Close window while cursor active on it // SetUpPointerCursorL(iCursor1,TheClient->iWs); win.SetCustomPointerCursor(iCursor1); win.Close(); iCursor1.Close(); // // Close session with: // An open cursor active on a window & A closed cursor active on another window // RWsSession ws; User::LeaveIfError(ws.Connect()); // use correct screen // ws.SetFocusScreen(iTest->iScreenNumber); CWsScreenDevice* screen = new (ELeave) CWsScreenDevice(ws); CleanupStack::PushL(screen); User::LeaveIfError(screen->Construct(0)); RWindowGroup group(ws); User::LeaveIfError(group.Construct(123)); group.EnableReceiptOfFocus(EFalse); // Stop auto group switching on close RWindow win2(ws); User::LeaveIfError(win2.Construct(group, 1)); win2.Activate(); RWindow win3(ws); User::LeaveIfError(win3.Construct(group, 2)); win3.Activate(); // SetUpPointerCursorL(iCursor1,ws); SetUpPointerCursorL(iCursor2,ws); win2.SetCustomPointerCursor(iCursor1); win3.SetCustomPointerCursor(iCursor2); // TSpriteMember member; member.iBitmap=member.iMaskBitmap=NULL; TInt err = iCursor1.UpdateMember(9999,member); TEST(err==KErrArgument); if (err!=KErrArgument) INFO_PRINTF3(_L("iCursor1.UpdateMember(9999,member) return value - Expected: %d, Actual: %d"), KErrArgument, err); iCursor1.Close(); CleanupStack::PopAndDestroy(screen); ws.Close(); }
/** Inform with a message ,the timer seconds remaining till its up.\n Send event to windows group when timer time is up .\n */ void CTestTimer::RunL() { --iSecondsRemaining; if (iSecondsRemaining>0) { QueueAndInfoPrint(); } else { User::InfoPrint(_L("Time's up")); iCompleted = ETrue; CCoeEnv* env = CCoeEnv::Static(); TWsEvent theEvent; theEvent.SetType(EEventUser + 1); RWsSession ws; TInt theRes = ws.Connect(); if(theRes == KErrNone) { RWindowGroup& winGroup = env->RootWin(); theEvent.SetType(EEventUser + 1); theEvent.SetTimeNow(); TInt theId = winGroup.Identifier(); ws.SendEventToWindowGroup(theId, theEvent); } ws.Close(); } }
void CTcAppLauncher::RunL() { // Fatal error occurred, report User::LeaveIfError( iStatus.Int() ); if( iDismissDialog ) { TKeyEvent event; event.iCode = EKeyDevice3; RWsSession wsSession; User::LeaveIfError( wsSession.Connect() ); wsSession.SimulateKeyEvent( event ); wsSession.Close(); } RApaLsSession apparc; User::LeaveIfError( apparc.Connect() ); CleanupClosePushL( apparc ); CApaCommandLine* cmdLine = CApaCommandLine::NewLC(); cmdLine->SetExecutableNameL( iAppName ); cmdLine->SetCommandL( EApaCommandRun ); User::LeaveIfError( apparc.StartApp( *cmdLine ) ); CleanupStack::PopAndDestroy( 2 ); // Write log entry LOG( _L("[APPLAUNCHER] Client restarted.") ); delete this; }
/** @SYMTestCaseID GRAPHICS-WSERV-GCE-0700 @SYMDEF DEF123129 @SYMTestCaseDesc Test activating a sprite twice does not cause the system to hang @SYMTestPriority High @SYMTestStatus Implemented @SYMTestActions Construct a sprite and add a member to it. Activate twice. @SYMTestExpectedResults The test should terminate smoothly and it should not hang the system. */ void CTTSprite::DoubleActivateL() { RWsSession ws; User::LeaveIfError(ws.Connect()); CleanupClosePushL(ws); RWindowGroup group(ws); User::LeaveIfError(group.Construct(890, EFalse)); CleanupClosePushL(group); RWsSprite sprite = RWsSprite(ws); User::LeaveIfError(sprite.Construct(group,TPoint(),0)); CleanupClosePushL(sprite); CFbsBitmap* bitmap=new(ELeave) CFbsBitmap; CleanupStack::PushL(bitmap); User::LeaveIfError(bitmap->Create(TSize(10,12),EColor256)); TSpriteMember member; member.iMaskBitmap=NULL; member.iInvertMask=EFalse; member.iDrawMode=CGraphicsContext::EDrawModePEN; member.iOffset=TPoint(); member.iInterval=TTimeIntervalMicroSeconds32(0); member.iBitmap=bitmap; User::LeaveIfError(sprite.AppendMember(member)); User::LeaveIfError(sprite.Activate()); User::LeaveIfError(sprite.Activate()); sprite.Close(); CleanupStack::PopAndDestroy(4, &ws); group.Close(); ws.Close(); }
TInt LoadsOfText(TInt aOwningGroup) { RWsSession ws; ws.Connect(); CWsScreenDevice *device=new(ELeave) CWsScreenDevice(ws); device->Construct(); RWindowGroup group(ws); group.Construct(ENullWsHandle); group.SetOwningWindowGroup(aOwningGroup); TSize scrSize(device->SizeInPixels()); // RWindow window(ws); window.Construct(group,ENullWsHandle); window.SetExtent(TPoint(), scrSize); window.Activate(); // CWindowGc *gc; device->CreateContext(gc); window.BeginRedraw(); gc->Activate(window); gc->Clear(); window.EndRedraw(); TFontSpec fspec(KTestFontTypefaceName,200); CFbsFont *font; User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips((CFont *&)font, fspec)); gc->UseFont(font); TBuf<100> loadsatext(_L("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890zyxwvutsrqponmlkjihgfedcba")); TInt ascent=font->AscentInPixels(); TInt fheight=font->HeightInPixels(); for(TInt nTimes=0;nTimes<10;nTimes++) { TPoint pos; // for(pos.iY=ascent;pos.iY<scrSize.iHeight;pos.iY+=font->HeightInPixels()) // gc->DrawText(loadsatext,pos); for(pos.iY=0;pos.iY<scrSize.iHeight;pos.iY+=fheight) gc->DrawText(loadsatext,TRect(pos,TPoint(scrSize.iWidth,pos.iY+fheight)),ascent); gc->Clear(); } gc->Deactivate(); // ws.Flush(); delete gc; device->ReleaseFont(font); window.Close(); group.Close(); delete device; ws.Close(); return(KErrNone); }
void CTGdi::NonDrawing() // // Test all non-drawing GDI functions // { TDisplayMode mode=TheClient->iScreen->DisplayMode(); TEST((mode!=ERgb) && (mode!=ENone)); RWsSession session; TInt res = session.Connect(); TEST(res == KErrNone); CArrayFixFlat<TInt>* modeList= new CArrayFixFlat<TInt> (15); if(!modeList) return; #if defined(SYMBIAN_GRAPHICS_GCE) res = session.GetColorModeList(iTest->iScreenNumber, modeList); #else res = session.GetColorModeList(modeList); #endif //SYMBIAN_GRAPHICS_GCE session.Close(); TEST(res == KErrNone); if(res != KErrNone) { modeList->Reset(); delete modeList; return; } TBool found = EFalse; for(TInt ii = 0; ii < modeList->Count() && !found; ii++) { TDisplayMode mode1 = (TDisplayMode) ((*modeList)[ii]); if(mode == mode1) { found = ETrue; } } modeList->Reset(); delete modeList; TEST(found); }
/* ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- */ TInt CExPolicy_Server::KillTasks(TUid& aUid) { TInt RetErr(KErrNone); RWsSession wsSession; RetErr= wsSession.Connect(); if(RetErr == KErrNone) { TApaTaskList taskList( wsSession ); TApaTask task = taskList.FindApp(aUid); if( task.Exists() ) { task.KillTask(); } } wsSession.Close(); return RetErr; }
void CCustomCmdTestDeviceSecurityCheck::SimulatePasswordEntry() { RWsSession wsSession; TInt err = wsSession.Connect(); TEST(KErrNone == err); const TInt okButtonPos1 = 60; //the position of ok button const TInt okButtonPos2 = 600; //the position of ok button //Simulate the key press ,(comma) in to pin notifier dialogue TRawEvent eventDown; TRawEvent eventUp; eventDown.Set(TRawEvent::EKeyDown, EStdKeyComma); UserSvr::AddEvent(eventDown); eventUp.Set(TRawEvent::EKeyUp, EStdKeyComma); UserSvr::AddEvent(eventUp); User::After(100000); //Enter wrong pwd if iWrongPwd is ETrue if(iWrongPwd) { eventDown.Set(TRawEvent::EKeyDown, EStdKeyComma); UserSvr::AddEvent(eventDown); eventUp.Set(TRawEvent::EKeyUp, EStdKeyComma); UserSvr::AddEvent(eventUp); User::After(100000); //Reset it to false as wrong password should be entered only once iWrongPwd = EFalse; } eventDown.Set(TRawEvent::EButton1Down, okButtonPos1,okButtonPos2); UserSvr::AddEvent(eventDown); eventUp.Set(TRawEvent::EButton1Up, okButtonPos1,okButtonPos2); UserSvr::AddEvent(eventUp); User::After(100000); wsSession.Flush(); wsSession.Close(); }
void CTScreenDevice::ConstructL() { //The following is just another test... it doesn't leave any resources for use by the test class AFAICT... RWsSession aSession; CWsScreenDevice *device1; CWsScreenDevice *device2; CWsScreenDevice *device3; aSession.Connect(); device1=new(ELeave) CWsScreenDevice(aSession); device1->Construct(iTest->iScreenNumber); delete device1; device1=new(ELeave) CWsScreenDevice(aSession); device1->Construct(iTest->iScreenNumber); device2=new(ELeave) CWsScreenDevice(aSession); device2->Construct(iTest->iScreenNumber); device3=new(ELeave) CWsScreenDevice(aSession); device3->Construct(iTest->iScreenNumber); delete device3; CFbsFont *font; User::LeaveIfError(device1->GetNearestFontToDesignHeightInTwips((CFont *&)font,TFontSpec())); RWindowGroup group(aSession); group.Construct(777); group.SetOwningWindowGroup(TheClient->iGroup->GroupWin()->Identifier()); RWindow win(aSession); win.Construct(group,77); CWindowGc *gc=new(ELeave) CWindowGc(device1); gc->Construct(); gc->Activate(win); gc->UseFont(font); device1->ReleaseFont(font); aSession.Flush(); delete gc; win.Close(); group.Close(); delete device1; delete device2; aSession.Close(); }
/** @SYMTestCaseID GRAPHICS_WSERV_DYNAMICRES_0100L @SYMTestCaseDesc GetInterface in classic @SYMREQ @SYMPREQ PREQ2102 @SYMTestType CT @SYMTestPriority @SYMTestPurpose GetInterface should always return NULL in classic @SYMTestActions Create an RWsSession Create a CWsScreenDevice Call GetInterface with various GUIDS. @SYMTestExpectedResults Should always return NULL **/ void CWsDynamicResClassic::GRAPHICS_WSERV_DYNAMICRES_0100L() { RWsSession session; session.Connect(); CWsScreenDevice* screenDevice = NULL; TRAPD(err, screenDevice = new (ELeave) CWsScreenDevice(session)); PRINT_ON_ERROR2_L(err, _L("Failed to create screen device: %d"), err); if (screenDevice) { ASSERT_EQUALS_X(screenDevice->Construct(0), KErrNone); void* interface = screenDevice->GetInterface(12344321); ASSERT_NULL (interface); interface = screenDevice->GetInterface(0); ASSERT_NULL (interface); } delete screenDevice; session.Close(); }
/** Handle the window events.\n Create a window server session and connect the client\n Set the event type and call the SendEventToWindowGroup().\n Close the session on completion \n */ void CDefocusingEdwinUi::SendEventToWindowGroups(TWsEvent& aEvent) { RWsSession ws; TInt theRes = ws.Connect(); TEST(theRes == KErrNone); RWindowGroup& winGroup = iCoeEnv->RootWin(); TInt theId = winGroup.Identifier(); aEvent.SetType(EEventKeyDown); aEvent.SetTimeNow(); ws.SendEventToWindowGroup(theId, aEvent); aEvent.SetType(EEventKey); aEvent.SetTimeNow(); ws.SendEventToWindowGroup(theId, aEvent); aEvent.SetType(EEventKeyUp); aEvent.SetTimeNow(); ws.SendEventToWindowGroup(theId, aEvent); ws.Close(); }
void MainL() { RWsSession ws; ws.Connect(); CWsScreenDevice* scr = new(ELeave) CWsScreenDevice(ws); scr->Construct(); CWindowGc* gc = new(ELeave) CWindowGc(scr); gc->Construct(); RWindowGroup grp(ws); grp.Construct(0xc0decafe, ETrue); RWindow win(ws); win.Construct(grp, 0xbeefcafe); win.SetExtent(TPoint(20,160), TSize(320,240)); win.Activate(); win.Invalidate(); win.BeginRedraw(); gc->Activate(win); gc->SetPenStyle(CGraphicsContext::ENullPen); gc->SetBrushStyle(CGraphicsContext::ESolidBrush); TBool color = EFalse; if (Profiler::Start() == KErrNotFound) { _LIT(KProfiler,"profiler"); _LIT(KStart,"start -noui -drive=S"); RProcess p; if (p.Create(KProfiler,KStart) == KErrNone) { p.Resume(); p.Close(); } } for (TInt col=0; col<KCol; ++col) { color = !color; for (TInt row=0; row<KRow; ++row) { TRect rect; rect.iTl.iX = col * KSize.iWidth; rect.iTl.iY = row * KSize.iHeight; rect.SetSize(KSize); color = !color; gc->SetBrushColor(color? KRgbBlue : KRgbBlack); gc->DrawRect(rect); } } gc->Deactivate(); win.EndRedraw(); ws.Flush(); User::After(3000000); win.Close(); grp.Close(); delete gc; delete scr; ws.Close(); Profiler::Stop(); Profiler::Close(); Profiler::Unload(); }
// ----------------------------------------------------------------------------- // Cfota_engine_api::TryResumeDownload // TryResumeDownload test method function. // (other items were commented in a header). // ----------------------------------------------------------------------------- // TInt Cfota_engine_api::TryResumeDownloadL( CStifItemParser& aItem ) { RSyncMLSession syncSession; syncSession.OpenL(); CleanupClosePushL(syncSession); RSyncMLDevManProfile DMProfile; DMProfile.CreateL( syncSession ); CleanupClosePushL( DMProfile); DMProfile.SetDisplayNameL(_L("####´53")); DMProfile.SetServerIdL(_L8("ServerID53")); DMProfile.SetCreatorId(85); DMProfile.SetPasswordL(_L8("Password")); DMProfile.SetServerPasswordL(_L8("ServerPassword")); DMProfile.SetUserNameL(_L8("Username")); DMProfile.UpdateL(); RSyncMLConnection connection; connection.OpenL( DMProfile, KUidNSmlMediumTypeInternet.iUid ); CleanupClosePushL( connection ); TPtrC stringHostaddress; if( aItem.GetNextString ( stringHostaddress ) == KErrNone ) { HBufC16* newaddr = stringHostaddress.AllocL(); TBuf8<100> hostAddress((newaddr->Des()).Collapse()); connection.SetServerURIL( hostAddress ); delete newaddr; } TSmlProfileId ProfileId = DMProfile.Identifier(); CleanupStack::PopAndDestroy(); // connection CleanupStack::PopAndDestroy(); // DMProfile CleanupStack::PopAndDestroy(); // syncSession session.OpenL(); TInt PkgId = 1; TBuf8<10> PkgName; PkgName.Copy(_L8("zkg")); TBuf8<10> PkgVersion; PkgVersion.Copy(_L8("1.0")); TPtrC stringPkgUrl; if( aItem.GetNextString ( stringPkgUrl ) == KErrNone ) { HBufC16* newurl = stringHostaddress.AllocL(); TBuf8<100> PkgURL((newurl->Des()).Collapse()); delete newurl; TInt err = session.Download(PkgId,PkgURL,ProfileId,PkgName,PkgVersion); if(err) { iLog->Log(_L("CFMSInterruptAob::TryResumeDownloadL()- download error")); return err; } } User::After(5000000*6); session.Close(); RWsSession iWsSession; TInt err = iWsSession.Connect(); if(err) { iLog->Log(_L("CFMSInterruptAob::TryResumeDownloadL()- Window server session error")); return err; } TApaTask(CCoeEnv::Static()->WsSession()); TApaTaskList tasklist(iWsSession); TApaTask task=tasklist.FindApp(TUid::Uid(0x101F6DE5)); if(task.Exists()) { task.KillTask(); } iWsSession.Close(); User::After(5000000*3); session.OpenL(); session.TryResumeDownload(); User::After(5000000*3); return KErrNone; }
void PlayerController::GoToNowPlaying() { if (playerLaunched) { //Launch player RWsSession wsSession; User::LeaveIfError( wsSession.Connect() ); TApaTaskList list(wsSession); TApaTask task = list.FindApp(KMusicPlayerAppUid); CMPXParameter* param = new ( ELeave ) CMPXParameter(); CleanupStack::PushL( param ); param->iType.iUid = KMPXPluginTypePlaybackUid; param->iCmdForward = EMPXCmdFwdNone; CBufBase* buffer = CBufFlat::NewL(3 ); CleanupStack::PushL( buffer ); RBufWriteStream writeStream( *buffer ); CleanupClosePushL( writeStream ); param->ExternalizeL( writeStream ); writeStream.CommitL(); buffer->Compress(); CleanupStack::PopAndDestroy( &writeStream ); if ( task.Exists() ) { wsSession.SendMessageToWindowGroup( task.WgId(), KAppUidMusicPlayerX, buffer->Ptr( 0 ) ); } else { RApaLsSession ls; CleanupClosePushL( ls ); User::LeaveIfError( ls.Connect() ); TApaAppInfo appInfo; User::LeaveIfError( ls.GetAppInfo( appInfo, KAppUidMusicPlayerX ) ); CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC(); apaCommandLine->SetExecutableNameL( appInfo.iFullName ); apaCommandLine->SetTailEndL( buffer->Ptr( 0 ) ); User::LeaveIfError( ls.StartApp( *apaCommandLine ) ); CleanupStack::PopAndDestroy(); // apaCommandLine CleanupStack::PopAndDestroy(); // ls } CleanupStack::PopAndDestroy( buffer ); CleanupStack::PopAndDestroy( param ); wsSession.Close(); } else if (radioLaunched) { RApaLsSession ls; CleanupClosePushL( ls ); User::LeaveIfError( ls.Connect() ); TApaAppInfo appInfo; User::LeaveIfError( ls.GetAppInfo( appInfo, KRadioUid ) ); CApaCommandLine* apaCommandLine = CApaCommandLine::NewLC(); apaCommandLine->SetExecutableNameL( appInfo.iFullName ); User::LeaveIfError( ls.StartApp( *apaCommandLine ) ); CleanupStack::PopAndDestroy(); // apaCommandLine CleanupStack::PopAndDestroy(); // ls } }
int EPOC_HandleWsEvent(_THIS, const TWsEvent& aWsEvent) { int posted = 0; SDL_keysym keysym; // SDL_TRACE1("hws %d", aWsEvent.Type()); switch (aWsEvent.Type()) { case EEventPointer: /* Mouse pointer events */ { const TPointerCursorMode mode = Private->EPOC_WsSession.PointerCursorMode(); if(mode == EPointerCursorNone) { return 0; //TODO: Find out why events are get despite of cursor should be off } const TPointerEvent* pointerEvent = aWsEvent.Pointer(); TPoint mousePos = pointerEvent->iPosition; /*!! TODO Pointer do not yet work properly //SDL_TRACE1("SDL: EPOC_HandleWsEvent, pointerEvent->iType=%d", pointerEvent->iType); //!! if (Private->EPOC_ShrinkedHeight) { mousePos.iY <<= 1; // Scale y coordinate to shrinked screen height } if (Private->EPOC_ShrinkedWidth) { mousePos.iX <<= 1; // Scale x coordinate to shrinked screen width } */ posted += SDL_PrivateMouseMotion(0, 0, mousePos.iX, mousePos.iY); /* Absolute position on screen */ switch (pointerEvent->iType) { case TPointerEvent::EButton1Down: posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); break; case TPointerEvent::EButton1Up: posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); break; case TPointerEvent::EButton2Down: posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_RIGHT, 0, 0); break; case TPointerEvent::EButton2Up: posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_RIGHT, 0, 0); break; case TPointerEvent::EButton3Down: posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_MIDDLE, 0, 0); break; case TPointerEvent::EButton3Up: posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_MIDDLE, 0, 0); break; } // switch break; } case EEventKeyDown: /* Key events */ { #ifdef SYMBIAN_CRYSTAL // special case: 9300/9500 rocker down, simulate left mouse button if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA) { const TPointerCursorMode mode = Private->EPOC_WsSession.PointerCursorMode(); if(mode != EPointerCursorNone) posted += SDL_PrivateMouseButton(SDL_PRESSED, SDL_BUTTON_LEFT, 0, 0); } #endif (void*)TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym); #ifndef DISABLE_JOYSTICK /* Special handling */ switch((int)keysym.sym) { case SDLK_CAPSLOCK: if (!isCursorVisible) { /* Enable virtual cursor */ HAL::Set(HAL::EMouseState, HAL::EMouseState_Visible); } else { /* Disable virtual cursor */ HAL::Set(HAL::EMouseState, HAL::EMouseState_Invisible); } isCursorVisible = !isCursorVisible; break; } #endif posted += SDL_PrivateKeyboard(SDL_PRESSED, &keysym); break; } case EEventKeyUp: /* Key events */ { #ifdef SYMBIAN_CRYSTAL // special case: 9300/9500 rocker up, simulate left mouse button if (aWsEvent.Key()->iScanCode == EStdKeyDeviceA) { posted += SDL_PrivateMouseButton(SDL_RELEASED, SDL_BUTTON_LEFT, 0, 0); } #endif posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(_this, aWsEvent.Key()->iScanCode, &keysym)); break; } case EEventFocusGained: /* SDL window got focus */ { Private->EPOC_IsWindowFocused = ETrue; posted += SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); /* Draw window background and screen buffer */ DisableKeyBlocking(_this); //Markus: guess why:-) RedrawWindowL(_this); break; } case EEventFocusLost: /* SDL window lost focus */ { /* CFbsBitmap* bmp = new (ELeave) CFbsBitmap(); bmp->Create(Private->EPOC_ScreenSize, Private->EPOC_DisplayMode); Private->EPOC_WsScreen->CopyScreenToBitmap(bmp); Private->EPOC_WindowGc->Activate(Private->EPOC_WsWindow); Private->EPOC_WsWindow.BeginRedraw(TRect(Private->EPOC_WsWindow.Size())); Private->EPOC_WindowGc->BitBlt(TPoint(0, 0), bmp); Private->EPOC_WsWindow.EndRedraw(); Private->EPOC_WindowGc->Deactivate(); bmp->Save(_L("C:\\scr.mbm")); delete bmp; */ Private->EPOC_IsWindowFocused = EFalse; posted += SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); RWsSession s; s.Connect(); RWindowGroup g(s); g.Construct(TUint32(&g), EFalse); g.EnableReceiptOfFocus(EFalse); RWindow w(s); w.Construct(g, TUint32(&w)); w.SetExtent(TPoint(0, 0), Private->EPOC_WsWindow.Size()); w.SetOrdinalPosition(0); w.Activate(); w.Close(); g.Close(); s.Close(); /* Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(Private->EPOC_WsWindowGroupID, -1); SDL_Delay(500); TInt focus = -1; while(focus < 0) { const TInt curr = Private->EPOC_WsSession.GetFocusWindowGroup(); if(curr != Private->EPOC_WsWindowGroupID) focus = curr; else SDL_Delay(500); } if(1 < Private->EPOC_WsSession.GetWindowGroupOrdinalPriority(Private->EPOC_WsWindowGroupID)) { Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(focus, -1); SDL_Delay(500); Private->EPOC_WsSession.SetWindowGroupOrdinalPosition(focus, 0); } */ /*//and the request redraw TRawEvent redrawEvent; redrawEvent.Set(TRawEvent::ERedraw); Private->EPOC_WsSession.SimulateRawEvent(redrawEvent); Private->EPOC_WsSession.Flush();*/ #if 0 //!! Not used // Wait and eat events until focus is gained again while (ETrue) { Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus); User::WaitForRequest(Private->EPOC_WsEventStatus); Private->EPOC_WsSession.GetEvent(Private->EPOC_WsEvent); TInt eventType = Private->EPOC_WsEvent.Type(); Private->EPOC_WsEventStatus = KRequestPending; //Private->EPOC_WsSession.EventReady(&Private->EPOC_WsEventStatus); if (eventType == EEventFocusGained) { RedrawWindowL(_this); break; } } #endif break; } case EEventModifiersChanged: { TModifiersChangedEvent* modEvent = aWsEvent.ModifiersChanged(); TUint modstate = KMOD_NONE; if (modEvent->iModifiers == EModifierLeftShift) modstate |= KMOD_LSHIFT; if (modEvent->iModifiers == EModifierRightShift) modstate |= KMOD_RSHIFT; if (modEvent->iModifiers == EModifierLeftCtrl) modstate |= KMOD_LCTRL; if (modEvent->iModifiers == EModifierRightCtrl) modstate |= KMOD_RCTRL; if (modEvent->iModifiers == EModifierLeftAlt) modstate |= KMOD_LALT; if (modEvent->iModifiers == EModifierRightAlt) modstate |= KMOD_RALT; if (modEvent->iModifiers == EModifierLeftFunc) modstate |= KMOD_LMETA; if (modEvent->iModifiers == EModifierRightFunc) modstate |= KMOD_RMETA; if (modEvent->iModifiers == EModifierCapsLock) modstate |= KMOD_CAPS; SDL_SetModState(STATIC_CAST(SDLMod,(modstate | KMOD_LSHIFT))); break; } default: break; } return posted; }
void CTScreenDevice::TwipsCacheFlushL() { RWsSession session; CWsScreenDevice* device; CFont* font; CFont* font2; const TFontSpec fontspec(KTestFontTypefaceName,250); TPixelsTwipsAndRotation sizeAndRotation; // create a CWsScreenDevice instance User::LeaveIfError(session.Connect()); device=new(ELeave) CWsScreenDevice(session); device->Construct(iTest->iScreenNumber); // Record a font height for use by latter tests User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); const TInt height0=font->HeightInPixels(); device->ReleaseFont(font); // 1. find font with best-matching height in twips, // 2. change twips size of the screen (leaving pixel-size same), // 3. find font with best-matching height in twips, // 4. make sure that the newly found font is not the same as previous and has the different height in pixels device->GetDefaultScreenSizeAndRotation(sizeAndRotation); #if defined(EXTRA_LOGGING) _LIT(KLog1,"Font height: %d for unchanged device. pixels=%d,%d twips=%d,%d"); LOG_MESSAGE6(KLog1,height0,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight ,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight); #endif sizeAndRotation.iTwipsSize.iHeight=2000; sizeAndRotation.iTwipsSize.iWidth =3000; device->SetScreenSizeAndRotation(sizeAndRotation); User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); TInt height=font->HeightInPixels(); #if defined(EXTRA_LOGGING) _LIT(KLog2,"Font height: %d for device with twips set to 2000x3000"); LOG_MESSAGE2(KLog2,height); #endif TFontSpec returnedSpec=font->FontSpecInTwips(); sizeAndRotation.iTwipsSize.iHeight=4000; sizeAndRotation.iTwipsSize.iWidth =6000; device->SetScreenSizeAndRotation(sizeAndRotation); User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec)); TInt height2=font2->HeightInPixels(); TFontSpec returnedSpec2 = font2->FontSpecInTwips(); #if defined(EXTRA_LOGGING) _LIT(KLog3,"Font height: %d for device with twips set to 4000x6000"); LOG_MESSAGE2(KLog3,height2); #endif TEST(font!=font2); TEST(height!=height2); _LIT(KLogErrM,"Font Heights in pixels match unexpectantly, height=%d"); if (height==height2) INFO_PRINTF2(KLogErrM,height); device->ReleaseFont(font2); device->ReleaseFont(font); // 1. find font with best-matching height in twips, // 2. change pixel size of the screen (leaving twip-size same), // 3. find font with best-matching height in twips, // 4. make sure that the newly found font is not the same as previous and has the different height in pixels device->GetDefaultScreenSizeAndRotation(sizeAndRotation); sizeAndRotation.iPixelSize.iHeight=240; sizeAndRotation.iPixelSize.iWidth =640; device->SetScreenSizeAndRotation(sizeAndRotation); User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); height=font->HeightInPixels(); returnedSpec=font->FontSpecInTwips(); #if defined(EXTRA_LOGGING) _LIT(KLog4,"Font height: %d for device with pixels set to 240x640 twips=%d,%d"); LOG_MESSAGE4(KLog4,height,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight); #endif sizeAndRotation.iPixelSize.iHeight=480; sizeAndRotation.iPixelSize.iWidth =1280; device->SetScreenSizeAndRotation(sizeAndRotation); User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec)); height2=font2->HeightInPixels(); returnedSpec2=font2->FontSpecInTwips(); #if defined(EXTRA_LOGGING) _LIT(KLog5,"Font height: %d for device with pixels set to 480x1280"); LOG_MESSAGE2(KLog5,height2); #endif TEST(font!=font2); TEST(height!=height2); if (height==height2) INFO_PRINTF2(KLogErrM,height); device->ReleaseFont(font2); device->ReleaseFont(font); // 1. double the width and height of screen in both pixels and twips // 2. find font with best-matching height in twips, // 3. make sure that the newly found font is the same as previous and has the same height in pixels device->GetDefaultScreenSizeAndRotation(sizeAndRotation); device->SetScreenSizeAndRotation(sizeAndRotation); User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); sizeAndRotation.iPixelSize.iHeight*=2; sizeAndRotation.iPixelSize.iWidth *=2; sizeAndRotation.iTwipsSize.iHeight*=2; sizeAndRotation.iTwipsSize.iWidth *=2; device->SetScreenSizeAndRotation(sizeAndRotation); User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec)); height2=font2->HeightInPixels(); #if defined(EXTRA_LOGGING) _LIT(KLog6,"Font height: %d for device doubled size. pixels=%d,%d twips=%d,%d"); LOG_MESSAGE6(KLog6,height2,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight ,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight); #endif TEST(font==font2); TEST(height0==height2); _LIT(KLogErrD,"Font Heights in pixels don't match, expected=%d, actual=%d"); if (height0!=height2) INFO_PRINTF3(KLogErrD,height0,height2); device->ReleaseFont(font2); device->ReleaseFont(font); // 1. swap width and height sizes of screen for both pixels and twips // 2. find font with best-matching height in twips, // 3. make sure that the newly found font is the same as previous and has the same height in pixels device->GetDefaultScreenSizeAndRotation(sizeAndRotation); device->SetScreenSizeAndRotation(sizeAndRotation); User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font,fontspec)); TInt swap=sizeAndRotation.iPixelSize.iHeight; sizeAndRotation.iPixelSize.iHeight=sizeAndRotation.iPixelSize.iWidth; sizeAndRotation.iPixelSize.iWidth =swap; swap=sizeAndRotation.iTwipsSize.iHeight; sizeAndRotation.iTwipsSize.iHeight=sizeAndRotation.iTwipsSize.iWidth; sizeAndRotation.iTwipsSize.iWidth =swap; device->SetScreenSizeAndRotation(sizeAndRotation); User::LeaveIfError(device->GetNearestFontToDesignHeightInTwips(font2,fontspec)); height2 = font2->HeightInPixels(); #if defined(EXTRA_LOGGING) _LIT(KLog7,"Font height: %d for device rotated size. pixels=%d,%d twips=%d,%d"); LOG_MESSAGE6(KLog7,height2,sizeAndRotation.iPixelSize.iWidth,sizeAndRotation.iPixelSize.iHeight ,sizeAndRotation.iTwipsSize.iWidth,sizeAndRotation.iTwipsSize.iHeight); #endif TEST(font==font2); TEST(height0==height2); if (height0!=height2) INFO_PRINTF3(KLogErrD,height0,height2); device->ReleaseFont(font2); device->ReleaseFont(font); delete device; session.Close(); }