Beautified some odd code (like "a ? a : NULL" to "a").

Applied our coding style guide.
No functional change.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12464 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-04-25 14:14:09 +00:00
parent 9d7e67b1bc
commit 7b58474a09
+163 -138
View File
@@ -50,25 +50,24 @@
#define STRACE(a) /* nothing */ #define STRACE(a) /* nothing */
#endif #endif
Desktop::Desktop(void) Desktop::Desktop(void)
{ {
fActiveRootLayer = NULL; fActiveRootLayer = NULL;
fActiveScreen = NULL; fActiveScreen = NULL;
} }
Desktop::~Desktop(void) Desktop::~Desktop(void)
{ {
void *ptr; for (int32 i = 0; WinBorder *border = (WinBorder *)fWinBorderList.ItemAt(i); i++)
delete border;
for(int32 i=0; (ptr=fWinBorderList.ItemAt(i)); i++) for (int32 i = 0; RootLayer *rootLayer = (RootLayer *)fRootLayerList.ItemAt(i); i++)
delete (WinBorder*)ptr; delete rootLayer;
for(int32 i=0; (ptr=fRootLayerList.ItemAt(i)); i++)
delete (RootLayer*)ptr;
for(int32 i=0; (ptr=fScreenList.ItemAt(i)); i++)
delete (Screen*)ptr;
for (int32 i = 0; Screen *screen = (Screen *)fScreenList.ItemAt(i); i++)
delete screen;
} }
@@ -117,107 +116,122 @@ Desktop::AddDriver(DisplayDriver *driver)
} }
} }
void Desktop::InitMode(void)
void
Desktop::InitMode(void)
{ {
// this is init mode for n-SS. // this is init mode for n-SS.
fActiveScreen = fScreenList.ItemAt(0)? (Screen*)fScreenList.ItemAt(0): NULL; fActiveScreen = (Screen *)fScreenList.ItemAt(0);
for (int32 i=0; i<fScreenList.CountItems(); i++)
{
char name[32];
sprintf(name, "RootLayer %ld", i+1);
Screen *screens[1]; for (int32 i = 0; i < fScreenList.CountItems(); i++) {
screens[0] = (Screen*)fScreenList.ItemAt(i); Screen *screen = (Screen *)fScreenList.ItemAt(i);
RootLayer *rl = new RootLayer(name, 4, this, GetDisplayDriver()); char name[32];
rl->SetScreens(screens, 1, 1); sprintf(name, "RootLayer %ld", i + 1);
rl->RunThread();
RootLayer *rootLayer = new RootLayer(name, 4, this, GetDisplayDriver());
fRootLayerList.AddItem(rl); rootLayer->SetScreens(&screen, 1, 1);
rootLayer->RunThread();
fRootLayerList.AddItem(rootLayer);
} }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Methods for multiple monitors. // Methods for multiple monitors.
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
inline inline Screen *
Screen* Desktop::ScreenAt(int32 index) const Desktop::ScreenAt(int32 index) const
{ {
return static_cast<Screen*>(fScreenList.ItemAt(index)); return static_cast<Screen *>(fScreenList.ItemAt(index));
} }
inline
int32 Desktop::ScreenCount(void) const inline int32
Desktop::ScreenCount(void) const
{ {
return fScreenList.CountItems(); return fScreenList.CountItems();
} }
inline
Screen* Desktop::ActiveScreen(void) const inline Screen *
Desktop::ActiveScreen(void) const
{ {
return fActiveScreen; return fActiveScreen;
} }
inline
void Desktop::SetActiveRootLayerByIndex(int32 listIndex)
{
RootLayer *rl=RootLayerAt(listIndex);
if (rl) inline void
SetActiveRootLayer(rl); Desktop::SetActiveRootLayerByIndex(int32 listIndex)
{
RootLayer *rootLayer = RootLayerAt(listIndex);
if (rootLayer != NULL)
SetActiveRootLayer(rootLayer);
} }
inline
void Desktop::SetActiveRootLayer(RootLayer* rl) inline void
Desktop::SetActiveRootLayer(RootLayer *rootLayer)
{ {
if (fActiveRootLayer == rl) if (fActiveRootLayer == rootLayer)
return; return;
fActiveRootLayer = rl; fActiveRootLayer = rootLayer;
} }
RootLayer* Desktop::ActiveRootLayer(void) const
RootLayer *
Desktop::ActiveRootLayer(void) const
{ {
return fActiveRootLayer; return fActiveRootLayer;
} }
inline
int32 Desktop::ActiveRootLayerIndex(void) const inline int32
Desktop::ActiveRootLayerIndex(void) const
{ {
int32 rootLayerCount = CountRootLayers(); int32 rootLayerCount = CountRootLayers();
for(int32 i=0; i<rootLayerCount; i++)
{ for (int32 i = 0; i < rootLayerCount; i++) {
if(fActiveRootLayer == (RootLayer*)(fRootLayerList.ItemAt(i))) if (fActiveRootLayer == (RootLayer *)fRootLayerList.ItemAt(i))
return i; return i;
} }
return -1; return -1;
} }
inline
RootLayer* Desktop::RootLayerAt(int32 index) inline RootLayer *
Desktop::RootLayerAt(int32 index)
{ {
return static_cast<RootLayer*>(fRootLayerList.ItemAt(index)); return static_cast<RootLayer *>(fRootLayerList.ItemAt(index));
} }
inline
int32 Desktop::CountRootLayers() const inline int32
Desktop::CountRootLayers() const
{ {
return fRootLayerList.CountItems(); return fRootLayerList.CountItems();
} }
inline
DisplayDriver* Desktop::GetDisplayDriver() const inline DisplayDriver *
Desktop::GetDisplayDriver() const
{ {
return ScreenAt(0)->DDriver(); return ScreenAt(0)->DDriver();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Methods for layer(WinBorder) manipulation. // Methods for layer(WinBorder) manipulation.
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void Desktop::AddWinBorder(WinBorder *winBorder)
void
Desktop::AddWinBorder(WinBorder *winBorder)
{ {
if (!winBorder) if (!winBorder)
return; return;
@@ -233,8 +247,7 @@ void Desktop::AddWinBorder(WinBorder *winBorder)
// we're playing with window list. lock first. // we're playing with window list. lock first.
Lock(); Lock();
if (fWinBorderList.HasItem(winBorder)) if (fWinBorderList.HasItem(winBorder)) {
{
Unlock(); Unlock();
ActiveRootLayer()->Unlock(); ActiveRootLayer()->Unlock();
debugger("AddWinBorder: WinBorder already in Desktop list\n"); debugger("AddWinBorder: WinBorder already in Desktop list\n");
@@ -247,21 +260,18 @@ void Desktop::AddWinBorder(WinBorder *winBorder)
// add FLOATING_APP windows to the local list of all normal windows. // add FLOATING_APP windows to the local list of all normal windows.
// This is to keep the order all floating windows (app or subset) when we go from // This is to keep the order all floating windows (app or subset) when we go from
// one normal window to another. // one normal window to another.
if (feel == B_FLOATING_APP_WINDOW_FEEL || feel == B_NORMAL_WINDOW_FEEL) if (feel == B_FLOATING_APP_WINDOW_FEEL || feel == B_NORMAL_WINDOW_FEEL) {
{ WinBorder *wb = NULL;
WinBorder *wb = NULL; int32 count = fWinBorderList.CountItems();
int32 count = fWinBorderList.CountItems(); int32 feelToLookFor = (feel == B_NORMAL_WINDOW_FEEL ?
int32 feelToLookFor = (feel == B_NORMAL_WINDOW_FEEL ? B_FLOATING_APP_WINDOW_FEEL : B_NORMAL_WINDOW_FEEL);
B_FLOATING_APP_WINDOW_FEEL :
B_NORMAL_WINDOW_FEEL); for (int32 i = 0; i < count; i++) {
wb = (WinBorder *)fWinBorderList.ItemAt(i);
for(int32 i = 0; i < count; i++)
{
wb = (WinBorder*)fWinBorderList.ItemAt(i);
if (wb->App()->ClientTeamID() == winBorder->App()->ClientTeamID() if (wb->App()->ClientTeamID() == winBorder->App()->ClientTeamID()
&& wb->Feel() == feelToLookFor) && wb->Feel() == feelToLookFor) {
// R2: RootLayer comparison is needed. // R2: RootLayer comparison is needed.
{
feel == B_NORMAL_WINDOW_FEEL ? feel == B_NORMAL_WINDOW_FEEL ?
winBorder->fFMWList.AddWinBorder(wb) : winBorder->fFMWList.AddWinBorder(wb) :
wb->fFMWList.AddWinBorder(winBorder); wb->fFMWList.AddWinBorder(winBorder);
@@ -270,8 +280,7 @@ void Desktop::AddWinBorder(WinBorder *winBorder)
} }
// add application's list of modal windows. // add application's list of modal windows.
if (feel == B_MODAL_APP_WINDOW_FEEL) if (feel == B_MODAL_APP_WINDOW_FEEL) {
{
winBorder->App()->fAppFMWList.AddWinBorder(winBorder); winBorder->App()->fAppFMWList.AddWinBorder(winBorder);
} }
@@ -284,7 +293,9 @@ void Desktop::AddWinBorder(WinBorder *winBorder)
ActiveRootLayer()->Unlock(); ActiveRootLayer()->Unlock();
} }
void Desktop::RemoveWinBorder(WinBorder *winBorder)
void
Desktop::RemoveWinBorder(WinBorder *winBorder)
{ {
if (!winBorder) if (!winBorder)
return; return;
@@ -296,9 +307,8 @@ void Desktop::RemoveWinBorder(WinBorder *winBorder)
Lock(); Lock();
// remove from main WinBorder list. // remove from main WinBorder list.
if (fWinBorderList.RemoveItem(winBorder)) if (fWinBorderList.RemoveItem(winBorder)) {
{ int32 feel = winBorder->Feel();
int32 feel = winBorder->Feel();
// floating app/subset and modal_subset windows require special atention because // floating app/subset and modal_subset windows require special atention because
// they are/may_be added to the list of a lot normal windows. // they are/may_be added to the list of a lot normal windows.
@@ -306,30 +316,25 @@ void Desktop::RemoveWinBorder(WinBorder *winBorder)
|| feel == B_MODAL_SUBSET_WINDOW_FEEL || feel == B_MODAL_SUBSET_WINDOW_FEEL
|| feel == B_FLOATING_APP_WINDOW_FEEL) || feel == B_FLOATING_APP_WINDOW_FEEL)
{ {
WinBorder *wb = NULL; WinBorder *wb = NULL;
int32 count = fWinBorderList.CountItems(); int32 count = fWinBorderList.CountItems();
for (int32 i = 0; i < count; i++) for (int32 i = 0; i < count; i++) {
{ wb = (WinBorder*)fWinBorderList.ItemAt(i);
wb = (WinBorder*)fWinBorderList.ItemAt(i);
if (wb->Feel() == B_NORMAL_WINDOW_FEEL if (wb->Feel() == B_NORMAL_WINDOW_FEEL
&& wb->App()->ClientTeamID() == winBorder->App()->ClientTeamID()) && wb->App()->ClientTeamID() == winBorder->App()->ClientTeamID()) {
// R2: RootLayer comparison is needed. We'll see. // R2: RootLayer comparison is needed. We'll see.
{
wb->fFMWList.RemoveItem(winBorder); wb->fFMWList.RemoveItem(winBorder);
} }
} }
} }
// remove from application's list // remove from application's list
if (feel == B_MODAL_APP_WINDOW_FEEL) if (feel == B_MODAL_APP_WINDOW_FEEL) {
{
winBorder->App()->fAppFMWList.RemoveItem(winBorder); winBorder->App()->fAppFMWList.RemoveItem(winBorder);
} }
} } else {
else
{
Unlock(); Unlock();
ActiveRootLayer()->Unlock(); ActiveRootLayer()->Unlock();
debugger("RemoveWinBorder: WinBorder not found in Desktop list\n"); debugger("RemoveWinBorder: WinBorder not found in Desktop list\n");
@@ -339,13 +344,13 @@ void Desktop::RemoveWinBorder(WinBorder *winBorder)
// Tell to winBorder's RootLayer about this. // Tell to winBorder's RootLayer about this.
ActiveRootLayer()->RemoveWinBorder(winBorder); ActiveRootLayer()->RemoveWinBorder(winBorder);
// unlock!
Unlock(); Unlock();
ActiveRootLayer()->Unlock(); ActiveRootLayer()->Unlock();
} }
void Desktop::AddWinBorderToSubset(WinBorder *winBorder, WinBorder *toWinBorder)
void
Desktop::AddWinBorderToSubset(WinBorder *winBorder, WinBorder *toWinBorder)
{ {
// NOTE: we can safely lock the entire method body, because this method is called from // NOTE: we can safely lock the entire method body, because this method is called from
// RootLayer's thread only. // RootLayer's thread only.
@@ -354,24 +359,21 @@ void Desktop::AddWinBorderToSubset(WinBorder *winBorder, WinBorder *toWinBorder)
Lock(); Lock();
if (!winBorder || !toWinBorder if (!winBorder || !toWinBorder
|| !fWinBorderList.HasItem(winBorder) || !fWinBorderList.HasItem(toWinBorder)) || !fWinBorderList.HasItem(winBorder)
{ || !fWinBorderList.HasItem(toWinBorder)) {
Unlock(); Unlock();
debugger("AddWinBorderToSubset: NULL WinBorder or not found in Desktop list\n"); debugger("AddWinBorderToSubset: NULL WinBorder or not found in Desktop list\n");
return; return;
} }
if ( (winBorder->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL if ((winBorder->Feel() == B_FLOATING_SUBSET_WINDOW_FEEL
|| winBorder->Feel() == B_MODAL_SUBSET_WINDOW_FEEL) || winBorder->Feel() == B_MODAL_SUBSET_WINDOW_FEEL)
&& toWinBorder->Feel() == B_NORMAL_WINDOW_FEEL && toWinBorder->Feel() == B_NORMAL_WINDOW_FEEL
&& toWinBorder->App()->ClientTeamID() == winBorder->App()->ClientTeamID() && toWinBorder->App()->ClientTeamID() == winBorder->App()->ClientTeamID()
&& !toWinBorder->fFMWList.HasItem(winBorder)) && !toWinBorder->fFMWList.HasItem(winBorder)) {
{
// add to normal_window's list // add to normal_window's list
toWinBorder->fFMWList.AddWinBorder(winBorder); toWinBorder->fFMWList.AddWinBorder(winBorder);
} } else {
else
{
Unlock(); Unlock();
debugger("AddWinBorderToSubset: you must add a subset_window to a normal_window's subset with the same team_id\n"); debugger("AddWinBorderToSubset: you must add a subset_window to a normal_window's subset with the same team_id\n");
return; return;
@@ -380,11 +382,12 @@ void Desktop::AddWinBorderToSubset(WinBorder *winBorder, WinBorder *toWinBorder)
// send WinBorder to be added to workspaces, if not already in there. // send WinBorder to be added to workspaces, if not already in there.
ActiveRootLayer()->AddSubsetWinBorder(winBorder, toWinBorder); ActiveRootLayer()->AddSubsetWinBorder(winBorder, toWinBorder);
// hey, unlock!
Unlock(); Unlock();
} }
void Desktop::RemoveWinBorderFromSubset(WinBorder *winBorder, WinBorder *fromWinBorder)
void
Desktop::RemoveWinBorderFromSubset(WinBorder *winBorder, WinBorder *fromWinBorder)
{ {
// NOTE: we can safely lock the entire method body, because this method is called from // NOTE: we can safely lock the entire method body, because this method is called from
// RootLayer's thread only. // RootLayer's thread only.
@@ -393,8 +396,8 @@ void Desktop::RemoveWinBorderFromSubset(WinBorder *winBorder, WinBorder *fromWin
Lock(); Lock();
if (!winBorder || !fromWinBorder if (!winBorder || !fromWinBorder
|| !fWinBorderList.HasItem(winBorder) || !fWinBorderList.HasItem(fromWinBorder)) || !fWinBorderList.HasItem(winBorder)
{ || !fWinBorderList.HasItem(fromWinBorder)) {
Unlock(); Unlock();
debugger("RemoveWinBorderFromSubset: NULL WinBorder or not found in Desktop list\n"); debugger("RemoveWinBorderFromSubset: NULL WinBorder or not found in Desktop list\n");
return; return;
@@ -403,23 +406,21 @@ void Desktop::RemoveWinBorderFromSubset(WinBorder *winBorder, WinBorder *fromWin
// remove WinBorder from workspace, if needed - some other windows may still have it in their subset // remove WinBorder from workspace, if needed - some other windows may still have it in their subset
ActiveRootLayer()->RemoveSubsetWinBorder(winBorder, fromWinBorder); ActiveRootLayer()->RemoveSubsetWinBorder(winBorder, fromWinBorder);
if (fromWinBorder->Feel() == B_NORMAL_WINDOW_FEEL) if (fromWinBorder->Feel() == B_NORMAL_WINDOW_FEEL) {
{
//remove from this normal_window's subset. //remove from this normal_window's subset.
fromWinBorder->fFMWList.RemoveItem(winBorder); fromWinBorder->fFMWList.RemoveItem(winBorder);
} } else {
else
{
Unlock(); Unlock();
debugger("RemoveWinBorderFromSubset: you must remove a subset_window from a normal_window's subset\n"); debugger("RemoveWinBorderFromSubset: you must remove a subset_window from a normal_window's subset\n");
return; return;
} }
// hey, unlock!
Unlock(); Unlock();
} }
void Desktop::SetWinBorderFeel(WinBorder *winBorder, uint32 feel)
void
Desktop::SetWinBorderFeel(WinBorder *winBorder, uint32 feel)
{ {
// NOTE: this method is called from RootLayer thread only // NOTE: this method is called from RootLayer thread only
@@ -430,86 +431,110 @@ void Desktop::SetWinBorderFeel(WinBorder *winBorder, uint32 feel)
winBorder->QuietlySetFeel(feel); winBorder->QuietlySetFeel(feel);
AddWinBorder(winBorder); AddWinBorder(winBorder);
// unlock!
Unlock(); Unlock();
} }
WinBorder* Desktop::FindWinBorderByServerWindowTokenAndTeamID(int32 token, team_id teamID)
WinBorder *
Desktop::FindWinBorderByServerWindowTokenAndTeamID(int32 token, team_id teamID)
{ {
WinBorder* wb; WinBorder *wb;
Lock(); Lock();
for (int32 i = 0; (wb = (WinBorder*)fWinBorderList.ItemAt(i)); i++) for (int32 i = 0; (wb = (WinBorder *)fWinBorderList.ItemAt(i)); i++) {
{
if (wb->Window()->ClientToken() == token if (wb->Window()->ClientToken() == token
&& wb->Window()->ClientTeamID() == teamID) && wb->Window()->ClientTeamID() == teamID)
break; break;
} }
Unlock(); Unlock();
return wb; return wb;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Methods for various desktop stuff handled by the server // Methods for various desktop stuff handled by the server
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void Desktop::SetScrollBarInfo(const scroll_bar_info &info)
void
Desktop::SetScrollBarInfo(const scroll_bar_info &info)
{ {
fScrollBarInfo = info; fScrollBarInfo = info;
} }
scroll_bar_info Desktop::ScrollBarInfo(void) const
scroll_bar_info
Desktop::ScrollBarInfo(void) const
{ {
return fScrollBarInfo; return fScrollBarInfo;
} }
void Desktop::SetMenuInfo(const menu_info &info)
void
Desktop::SetMenuInfo(const menu_info &info)
{ {
fMenuInfo = info; fMenuInfo = info;
} }
menu_info Desktop::MenuInfo(void) const
menu_info
Desktop::MenuInfo(void) const
{ {
return fMenuInfo; return fMenuInfo;
} }
void Desktop::UseFFMouse(const bool &useffm)
void
Desktop::UseFFMouse(const bool &useffm)
{ {
fFFMouseMode = useffm; fFFMouseMode = useffm;
} }
bool Desktop::FFMouseInUse(void) const
bool
Desktop::FFMouseInUse(void) const
{ {
return fFFMouseMode; return fFFMouseMode;
} }
void Desktop::SetFFMouseMode(const mode_mouse &value)
void
Desktop::SetFFMouseMode(const mode_mouse &value)
{ {
fMouseMode = value; fMouseMode = value;
} }
mode_mouse Desktop::FFMouseMode(void) const
mode_mouse
Desktop::FFMouseMode(void) const
{ {
return fMouseMode; return fMouseMode;
} }
void Desktop::PrintToStream(void)
void
Desktop::PrintToStream(void)
{ {
printf("RootLayer List:\n=======\n"); printf("RootLayer List:\n=======\n");
for(int32 i=0; i<fRootLayerList.CountItems(); i++)
{ for (int32 i = 0; i < fRootLayerList.CountItems(); i++) {
printf("\t%s\n", ((RootLayer*)fRootLayerList.ItemAt(i))->GetName()); printf("\t%s\n", ((RootLayer*)fRootLayerList.ItemAt(i))->GetName());
((RootLayer*)fRootLayerList.ItemAt(i))->PrintToStream(); ((RootLayer*)fRootLayerList.ItemAt(i))->PrintToStream();
printf("-------\n"); printf("-------\n");
} }
printf("=======\nActive RootLayer: %s\n", fActiveRootLayer? fActiveRootLayer->GetName(): "NULL");
printf("=======\nActive RootLayer: %s\n",
fActiveRootLayer ? fActiveRootLayer->GetName() : "NULL");
// printf("Active WinBorder: %s\n", fActiveWinBorder? fActiveWinBorder->Name(): "NULL"); // printf("Active WinBorder: %s\n", fActiveWinBorder? fActiveWinBorder->Name(): "NULL");
printf("Screen List:\n"); printf("Screen List:\n");
for(int32 i=0; i<fScreenList.CountItems(); i++) for (int32 i = 0; i < fScreenList.CountItems(); i++)
printf("\t%ld\n", ((Screen*)fScreenList.ItemAt(i))->ScreenNumber()); printf("\t%ld\n", ((Screen*)fScreenList.ItemAt(i))->ScreenNumber());
} }
void Desktop::PrintVisibleInRootLayerNo(int32 no)
void
Desktop::PrintVisibleInRootLayerNo(int32 no)
{ {
} }