66 // Each device orientation is defined to be the value where just the bit |
66 // Each device orientation is defined to be the value where just the bit |
67 // corresponding to the GDI orientation value is set. |
67 // corresponding to the GDI orientation value is set. |
68 return (TDeviceOrientation)(1 << aGcOrientation); |
68 return (TDeviceOrientation)(1 << aGcOrientation); |
69 } |
69 } |
70 |
70 |
71 LOCAL_D TBool FindNextValue(TLex& aLex, TInt& aValue) // assumes the list cannot contain *negative* integers |
71 /** Convert a TGraphicsOrientation value into a TDigitiserOrientation. |
|
72 Note: The algorithm used makes use of the ordering of the values of the respective enums, |
|
73 thus this is checked for (at compile time) at the start of the function. |
|
74 @param aGcOrientation A value from the TGraphicsOrientation enums. |
|
75 @return The equivalent value from the TDigitiserOrientation enums. |
|
76 */ |
|
77 inline HALData::TDigitiserOrientation GcToDigitiser(CFbsBitGc::TGraphicsOrientation aGcOrientation) |
|
78 { |
|
79 __ASSERT_COMPILE(CFbsBitGc::EGraphicsOrientationNormal+1==CFbsBitGc::EGraphicsOrientationRotated90); |
|
80 __ASSERT_COMPILE(CFbsBitGc::EGraphicsOrientationNormal+2==CFbsBitGc::EGraphicsOrientationRotated180); |
|
81 __ASSERT_COMPILE(CFbsBitGc::EGraphicsOrientationNormal+3==CFbsBitGc::EGraphicsOrientationRotated270); |
|
82 __ASSERT_COMPILE(HALData::EDigitiserOrientation_000+1==HALData::EDigitiserOrientation_090); |
|
83 __ASSERT_COMPILE(HALData::EDigitiserOrientation_000+2==HALData::EDigitiserOrientation_180); |
|
84 __ASSERT_COMPILE(HALData::EDigitiserOrientation_000+3==HALData::EDigitiserOrientation_270); |
|
85 HALData::TDigitiserOrientation ret = static_cast<HALData::TDigitiserOrientation> |
|
86 (HALData::EDigitiserOrientation_000 + (aGcOrientation - CFbsBitGc::EGraphicsOrientationNormal)); |
|
87 return ret; |
|
88 } |
|
89 |
|
90 LOCAL_C TBool FindNextValue(TLex& aLex, TInt& aValue) // assumes the list cannot contain *negative* integers |
72 { |
91 { |
73 while (!aLex.Eos()) |
92 while (!aLex.Eos()) |
74 { |
93 { |
75 const TUint character=aLex.Peek(); |
94 const TUint character=aLex.Peek(); |
76 if (Rng(TUint('0'), character, TUint('9')) || (character=='-')) |
95 if (Rng(TUint('0'), character, TUint('9')) || (character=='-')) |
1120 WS_ASSERT_DEBUG(KErrNone == errUnregister, EWsPanicDirectScreenAccess); |
1139 WS_ASSERT_DEBUG(KErrNone == errUnregister, EWsPanicDirectScreenAccess); |
1121 iDsaSurface = newSurface; |
1140 iDsaSurface = newSurface; |
1122 } |
1141 } |
1123 |
1142 |
1124 //updaterotation should not fail after this point (no cleanup) |
1143 //updaterotation should not fail after this point (no cleanup) |
|
1144 |
|
1145 //update the last set config with the new rotation change so we don't incorrectly |
|
1146 //change the layer extents |
|
1147 if (iDisplayControl) |
|
1148 { |
|
1149 TDisplayConfiguration config; |
|
1150 config.SetRotation(static_cast<TDisplayConfiguration::TRotation>(newRotation)); |
|
1151 iConfigChangeNotifier->UpdateLastSetConfiguration(config); |
|
1152 } |
1125 |
1153 |
1126 TWservCrEvent crEvent(TWservCrEvent::EDeviceOrientationChanged,iScreenNumber,&gcOrientation); |
1154 TWservCrEvent crEvent(TWservCrEvent::EDeviceOrientationChanged,iScreenNumber,&gcOrientation); |
1127 TWindowServerEvent::NotifyDrawer(crEvent); |
1155 TWindowServerEvent::NotifyDrawer(crEvent); |
1128 |
1156 |
1129 if(iDsaDevice && iDsaDevice->GraphicsAccelerator()) |
1157 if(iDsaDevice && iDsaDevice->GraphicsAccelerator()) |
1132 } |
1160 } |
1133 |
1161 |
1134 } |
1162 } |
1135 |
1163 |
1136 iRootWindow->AdjustCoordsDueToRotation(); |
1164 iRootWindow->AdjustCoordsDueToRotation(); |
1137 if (rotating) |
1165 if (rotating || (iFlags & ERepeatSettingHalOrientation)) |
1138 { |
1166 { |
1139 if(BlankScreenOnRotation()) |
1167 if (HAL::Set(iScreenNumber, HALData::EDigitiserOrientation, GcToDigitiser(gcOrientation)) != KErrNone) |
1140 { |
1168 { |
1141 iRootWindow->ClearDisplay(); |
1169 iFlags |= ERepeatSettingHalOrientation; |
1142 } |
1170 } |
1143 |
1171 else |
1144 CWsTop::ClearAllRedrawStores(); |
1172 { |
1145 DiscardAllSchedules(); |
1173 iFlags &= ~ERepeatSettingHalOrientation; |
1146 iRootWindow->InvalidateWholeScreen(); |
1174 } |
1147 } |
1175 } |
|
1176 |
|
1177 if (rotating) |
|
1178 { |
|
1179 if (BlankScreenOnRotation()) |
|
1180 { |
|
1181 iRootWindow->ClearDisplay(); |
|
1182 } |
|
1183 CWsTop::ClearAllRedrawStores(); |
|
1184 DiscardAllSchedules(); |
|
1185 iRootWindow->InvalidateWholeScreen(); |
|
1186 } |
|
1187 |
1148 return ETrue; |
1188 return ETrue; |
1149 } |
1189 } |
1150 |
1190 |
1151 TPoint CScreen::PhysicalToLogical(TPoint aPhysicalPt) |
1191 TPoint CScreen::PhysicalToLogical(TPoint aPhysicalPt) |
1152 { |
1192 { |
1982 } |
2022 } |
1983 if (reply==KErrNone) |
2023 if (reply==KErrNone) |
1984 { |
2024 { |
1985 TSize oldConfigRes; |
2025 TSize oldConfigRes; |
1986 oldConfig.GetResolution(oldConfigRes); |
2026 oldConfig.GetResolution(oldConfigRes); |
|
2027 TDisplayConfiguration newConfig; |
1987 if (oldConfigRes.iWidth == 0 || oldConfigRes.iHeight == 0) |
2028 if (oldConfigRes.iWidth == 0 || oldConfigRes.iHeight == 0) |
1988 { |
2029 { |
1989 TDisplayConfiguration newConfig; |
|
1990 iDisplayControl->GetConfiguration(newConfig); |
2030 iDisplayControl->GetConfiguration(newConfig); |
1991 RecalculateModeTwips(&newConfig); //needs res and twips information |
2031 RecalculateModeTwips(&newConfig); //needs res and twips information |
1992 } |
2032 } |
1993 UpdateDynamicScreenModes(); |
2033 UpdateDynamicScreenModes(); |
|
2034 |
|
2035 //update the last set config in the config change notifier to |
|
2036 //prevent SetConfiguration() from being called again! |
|
2037 newConfig.ClearAll(); |
|
2038 iDisplayControl->GetConfiguration(newConfig); |
|
2039 iConfigChangeNotifier->UpdateLastSetConfiguration(newConfig); |
1994 |
2040 |
1995 TWindowServerEvent::NotifyDrawer(TWservCrEvent(TWservCrEvent::EScreenSizeModeAboutToChange, iScreenSizeMode)); |
2041 TWindowServerEvent::NotifyDrawer(TWservCrEvent(TWservCrEvent::EScreenSizeModeAboutToChange, iScreenSizeMode)); |
1996 // This will remove all the DSA elements from the scene |
2042 // This will remove all the DSA elements from the scene |
1997 AbortAllDirectDrawing(RDirectScreenAccess::ETerminateRotation); |
2043 AbortAllDirectDrawing(RDirectScreenAccess::ETerminateRotation); |
1998 |
2044 |
2034 reply = KErrNotSupported; |
2080 reply = KErrNotSupported; |
2035 } |
2081 } |
2036 return reply; |
2082 return reply; |
2037 } |
2083 } |
2038 |
2084 |
|
2085 TInt CScreen::UpdateConfiguration(const TDisplayConfiguration& aConfigInput) |
|
2086 { |
|
2087 TInt reply = KErrNone; |
|
2088 if(iDisplayControl) |
|
2089 { |
|
2090 TDisplayConfiguration config(aConfigInput); |
|
2091 TRect sizeModePosition; |
|
2092 if (iDisplayPolicy) |
|
2093 { //validate config and update to a valid hardware config |
|
2094 reply = iDisplayPolicy->GetSizeModeConfiguration(iScreenSizeMode,config,sizeModePosition); |
|
2095 if (reply >= KErrNone) |
|
2096 {//set appmode in policy |
|
2097 if (iDisplayMapping) |
|
2098 { |
|
2099 iDisplayMapping->SetSizeModeExtent(sizeModePosition,MWsDisplayMapping::KOffsetAll); |
|
2100 } |
|
2101 } |
|
2102 } |
|
2103 else |
|
2104 { //exessive strategy: limit rotation agains curr app mode. |
|
2105 //really we want the system to accept the rotation change regardless of the app mode. |
|
2106 TDisplayConfiguration::TRotation newRot; |
|
2107 if (aConfigInput.GetRotation(newRot)) |
|
2108 { //This should cast between rotation enumertaions "properly" |
|
2109 if (!(iModes[0][iScreenSizeMode]->iAlternativeRotations&(1<<newRot))) |
|
2110 { |
|
2111 reply=KErrArgument; |
|
2112 } |
|
2113 } |
|
2114 } |
|
2115 |
|
2116 MWsScene::TSceneRotation oldRotation; |
|
2117 oldRotation = iScene->SceneRotation(); |
|
2118 TSize newUiSize; |
|
2119 config.GetResolution(newUiSize); |
|
2120 if(iFlags&EHasDynamicSizeModes) |
|
2121 { |
|
2122 reply = iFallbackMap->Resize(newUiSize); |
|
2123 } |
|
2124 |
|
2125 RecalculateModeTwips(&config); //needs res and twips information |
|
2126 UpdateDynamicScreenModes(); |
|
2127 |
|
2128 TWindowServerEvent::NotifyDrawer(TWservCrEvent(TWservCrEvent::EScreenSizeModeAboutToChange, iScreenSizeMode)); |
|
2129 // This will remove all the DSA elements from the scene |
|
2130 AbortAllDirectDrawing(RDirectScreenAccess::ETerminateRotation); |
|
2131 |
|
2132 //SetDigitiserAreas needs revisiting if/when we support dynamic resolutions |
|
2133 //on a screen with touch input. |
|
2134 //SetDigitiserAreas(newUiSize); |
|
2135 |
|
2136 //failure here should only be because of DSA orientation change failure, which shouldn't happen, either. |
|
2137 //Or there may be no change to do. |
|
2138 (void)UpdateOrientation(&oldRotation); |
|
2139 |
|
2140 iWindowElementSet->ResubmitAllElementExtents(); |
|
2141 if(iDsaDevice && iDsaDevice->GraphicsAccelerator()) |
|
2142 { |
|
2143 iDsaDevice->ChangeScreenDevice(iDsaDevice); // orientation has changed, therefore we need to re-initialise the screen device's graphics accelerator |
|
2144 } |
|
2145 |
|
2146 iRootWindow->AdjustCoordsDueToRotation(); |
|
2147 |
|
2148 //TODO jonas: we'd like to not have to clear at all... make the actual change to compositor etc lazily! |
|
2149 if(BlankScreenOnRotation()) |
|
2150 { |
|
2151 iRootWindow->ClearDisplay(); |
|
2152 } |
|
2153 |
|
2154 CWsTop::ClearAllRedrawStores(); |
|
2155 DiscardAllSchedules(); |
|
2156 iRootWindow->InvalidateWholeScreen(); |
|
2157 CWsWindowGroup::SetScreenDeviceValidStates(this); |
|
2158 TWindowServerEvent::SendScreenDeviceChangedEvents(this); |
|
2159 } |
|
2160 else |
|
2161 { |
|
2162 reply = KErrNotSupported; |
|
2163 } |
|
2164 return reply; |
|
2165 } |
|
2166 |
2039 void CScreen::UpdateDynamicScreenModes() |
2167 void CScreen::UpdateDynamicScreenModes() |
2040 { |
2168 { |
2041 WS_ASSERT_DEBUG(iDisplayControl,EWsPanicNoDisplayControl); |
2169 WS_ASSERT_DEBUG(iDisplayControl,EWsPanicNoDisplayControl); |
2042 TDisplayConfiguration newConfig; |
2170 TDisplayConfiguration newConfig; |
2043 iDisplayControl->GetConfiguration(newConfig); |
2171 iDisplayControl->GetConfiguration(newConfig); |