* Fixed typos, this also closes ticket #4026.

* Fixed many coding style issues.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31058 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-06-15 10:51:29 +00:00
parent e494494122
commit 348ad702b6
+35 -34
View File
@@ -7,7 +7,8 @@
*/ */
#include "StatusView.h" #include "StatusView.h"
#include "CPUFrequencyView.h"
#include <string.h>
#include <Alert.h> #include <Alert.h>
#include <Application.h> #include <Application.h>
@@ -19,14 +20,16 @@
#include <Roster.h> #include <Roster.h>
#include <TextView.h> #include <TextView.h>
#include <string.h> #include "CPUFrequencyView.h"
extern "C" _EXPORT BView *instantiate_deskbar_item(void); extern "C" _EXPORT BView *instantiate_deskbar_item(void);
#define MAX_FREQ_STRING "9999MHz" #define MAX_FREQ_STRING "9999MHz"
// messages FrequencySwitcher // messages FrequencySwitcher
const uint32 kMsgDynamicPolicyPuls = '&dpp'; const uint32 kMsgDynamicPolicyPulse = '&dpp';
// messages menu // messages menu
const uint32 kMsgPolicyDynamic = 'pody'; const uint32 kMsgPolicyDynamic = 'pody';
@@ -48,7 +51,6 @@ FrequencySwitcher::FrequencySwitcher(CPUFreqDriverInterface* interface,
fCurrentFrequency(NULL), fCurrentFrequency(NULL),
fDynamicPolicyStarted(false) fDynamicPolicyStarted(false)
{ {
} }
@@ -63,7 +65,7 @@ filter_result
FrequencySwitcher::Filter(BMessage* message, BHandler** target) FrequencySwitcher::Filter(BMessage* message, BHandler** target)
{ {
filter_result result = B_DISPATCH_MESSAGE; filter_result result = B_DISPATCH_MESSAGE;
if (message->what == kMsgDynamicPolicyPuls) { if (message->what == kMsgDynamicPolicyPulse) {
_CalculateDynamicState(); _CalculateDynamicState();
result = B_SKIP_MESSAGE; result = B_SKIP_MESSAGE;
} }
@@ -84,8 +86,7 @@ FrequencySwitcher::SetMode(const freq_preferences& pref)
case DYNAMIC: case DYNAMIC:
isDynamic = true; isDynamic = true;
fSteppingThreshold = pref.stepping_threshold; fSteppingThreshold = pref.stepping_threshold;
if (fMessageRunner && fIntegrationTime != pref.integration_time) if (fMessageRunner && fIntegrationTime != pref.integration_time) {
{
fIntegrationTime = pref.integration_time; fIntegrationTime = pref.integration_time;
fMessageRunner->SetInterval(fIntegrationTime); fMessageRunner->SetInterval(fIntegrationTime);
} }
@@ -128,13 +129,12 @@ FrequencySwitcher::_CalculateDynamicState()
bigtime_t now = system_time(); bigtime_t now = system_time();
bigtime_t activeTime = sysInfo.cpu_infos[0].active_time; bigtime_t activeTime = sysInfo.cpu_infos[0].active_time;
// if the dynamic mode is not started firt init the prev values // if the dynamic mode is not started first init the prev values
if (!fDynamicPolicyStarted) { if (!fDynamicPolicyStarted) {
fPrevActiveTime = activeTime; fPrevActiveTime = activeTime;
fPrevTime = now; fPrevTime = now;
fDynamicPolicyStarted = true; fDynamicPolicyStarted = true;
} } else {
else {
float usage = (float)(activeTime - fPrevActiveTime ) float usage = (float)(activeTime - fPrevActiveTime )
/ (now - fPrevTime); / (now - fPrevTime);
if (usage >= 1.0) if (usage >= 1.0)
@@ -145,8 +145,7 @@ FrequencySwitcher::_CalculateDynamicState()
float usageOfStep = ColorStepView::UsageOfStep(i, numberOfStates, float usageOfStep = ColorStepView::UsageOfStep(i, numberOfStates,
fSteppingThreshold); fSteppingThreshold);
if (usage < usageOfStep) if (usage < usageOfStep) {
{
StateList* list = fDriverInterface->GetCpuFrequencyStates(); StateList* list = fDriverInterface->GetCpuFrequencyStates();
freq_info* newState = list->ItemAt(numberOfStates - 1 - i); freq_info* newState = list->ItemAt(numberOfStates - 1 - i);
if (newState != fCurrentFrequency) { if (newState != fCurrentFrequency) {
@@ -164,25 +163,23 @@ FrequencySwitcher::_CalculateDynamicState()
void void
FrequencySwitcher::_StartDynamicPolicy(bool start, FrequencySwitcher::_StartDynamicPolicy(bool start, const freq_preferences& pref)
const freq_preferences& pref)
{ {
if (start) { if (start) {
if (!fMessageRunner) { if (!fMessageRunner) {
fIntegrationTime = pref.integration_time; fIntegrationTime = pref.integration_time;
fMessageRunner = new BMessageRunner(fTarget, fMessageRunner = new BMessageRunner(fTarget,
new BMessage(kMsgDynamicPolicyPuls) new BMessage(kMsgDynamicPolicyPulse), pref.integration_time, -1);
, pref.integration_time, -1);
fCurrentFrequency = fDriverInterface->GetCurrentFrequencyState(); fCurrentFrequency = fDriverInterface->GetCurrentFrequencyState();
} }
} } else {
else {
if (fMessageRunner) {
delete fMessageRunner; delete fMessageRunner;
fMessageRunner = NULL; fMessageRunner = NULL;
} }
} }
}
// #pragma mark -
FrequencyMenu::FrequencyMenu(BMenu* menu, BHandler* target, FrequencyMenu::FrequencyMenu(BMenu* menu, BHandler* target,
@@ -197,7 +194,7 @@ FrequencyMenu::FrequencyMenu(BMenu* menu, BHandler* target,
new BMessage(kMsgPolicyDynamic)); new BMessage(kMsgPolicyDynamic));
fHighPerformance = new BMenuItem("High Performance", fHighPerformance = new BMenuItem("High Performance",
new BMessage(kMsgPolicyPerformance)); new BMessage(kMsgPolicyPerformance));
fLowEnergie = new BMenuItem("Low Energie", fLowEnergie = new BMenuItem("Low Energy",
new BMessage(kMsgPolicyLowEnergy)); new BMessage(kMsgPolicyLowEnergy));
menu->AddItem(fDynamicPerformance); menu->AddItem(fDynamicPerformance);
@@ -248,9 +245,8 @@ FrequencyMenu::Filter(BMessage *msg, BHandler **target)
BMenuItem* item, *superItem, *markedItem; BMenuItem* item, *superItem, *markedItem;
msg->FindPointer("source", (void**)&item); msg->FindPointer("source", (void**)&item);
if (!item) { if (!item)
return result; return result;
}
bool safeChanges = false; bool safeChanges = false;
freq_preferences* pref = fStorage->GetPreferences(); freq_preferences* pref = fStorage->GetPreferences();
@@ -307,8 +303,6 @@ FrequencyMenu::Filter(BMessage *msg, BHandler **target)
void void
FrequencyMenu::UpdateMenu() FrequencyMenu::UpdateMenu()
{ {
BMenuItem* customItem, *markedItem, *superItem;
freq_preferences* pref = fStorage->GetPreferences(); freq_preferences* pref = fStorage->GetPreferences();
switch (pref->mode) { switch (pref->mode) {
case DYNAMIC: case DYNAMIC:
@@ -324,18 +318,24 @@ FrequencyMenu::UpdateMenu()
break; break;
case CUSTOM: case CUSTOM:
markedItem = fCustomStateMenu->FindMarked(); {
BMenuItem* markedItem = fCustomStateMenu->FindMarked();
if (markedItem) if (markedItem)
markedItem->SetMarked(false); markedItem->SetMarked(false);
customItem = fCustomStateMenu->ItemAt(pref->custom_stepping); BMenuItem* customItem
= fCustomStateMenu->ItemAt(pref->custom_stepping);
if (customItem) if (customItem)
customItem->SetMarked(true); customItem->SetMarked(true);
superItem = fCustomStateMenu->Supermenu()->Superitem(); BMenuItem* superItem = fCustomStateMenu->Supermenu()->Superitem();
if (superItem && customItem) if (superItem && customItem)
superItem->SetLabel(customItem->Label()); superItem->SetLabel(customItem->Label());
break; break;
} }
} }
}
// #pragma mark -
StatusView::StatusView(BRect frame, bool inDeskbar, StatusView::StatusView(BRect frame, bool inDeskbar,
@@ -359,8 +359,7 @@ StatusView::StatusView(BRect frame, bool inDeskbar,
if (storage) { if (storage) {
fOwningStorage = false; fOwningStorage = false;
fStorage = storage; fStorage = storage;
} } else {
else {
fOwningStorage = true; fOwningStorage = true;
fStorage = new PreferencesStorage<freq_preferences>("CPUFrequency", fStorage = new PreferencesStorage<freq_preferences>("CPUFrequency",
kDefaultPreferences); kDefaultPreferences);
@@ -474,8 +473,7 @@ StatusView::AttachedToWindow()
// perferences menu // perferences menu
fPreferencesMenu = new BPopUpMenu(B_EMPTY_STRING, false, false); fPreferencesMenu = new BPopUpMenu(B_EMPTY_STRING, false, false);
fPreferencesMenuFilter = new FrequencyMenu(fPreferencesMenu, this, fPreferencesMenuFilter = new FrequencyMenu(fPreferencesMenu, this, fStorage,
fStorage,
&fDriverInterface); &fDriverInterface);
fPreferencesMenu->SetFont(be_plain_font); fPreferencesMenu->SetFont(be_plain_font);
@@ -626,10 +624,10 @@ StatusView::_Init()
void void
StatusView::_SetupNewFreqString() StatusView::_SetupNewFreqString()
{ {
if (fCurrentFrequency) if (fCurrentFrequency) {
fFreqString = ColorStepView::CreateFrequencyString( fFreqString = ColorStepView::CreateFrequencyString(
fCurrentFrequency->frequency); fCurrentFrequency->frequency);
else } else
fFreqString = "? MHz"; fFreqString = "? MHz";
ResizeToPreferred(); ResizeToPreferred();
@@ -663,6 +661,9 @@ StatusView::_OpenPreferences()
} }
// #pragma mark -
extern "C" _EXPORT BView* extern "C" _EXPORT BView*
instantiate_deskbar_item(void) instantiate_deskbar_item(void)
{ {