[haiku-commits] r33824 - haiku/trunk/src/servers/app

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 29 Oct 2009 11:11:24 +0100 (CET)

Author: axeld
Date: 2009-10-29 11:11:24 +0100 (Thu, 29 Oct 2009)
New Revision: 33824
Changeset: http://dev.haiku-os.org/changeset/33824/haiku

Modified:
   haiku/trunk/src/servers/app/Decorator.h
   haiku/trunk/src/servers/app/DefaultDecorator.cpp
   haiku/trunk/src/servers/app/DefaultDecorator.h
   haiku/trunk/src/servers/app/Desktop.cpp
   haiku/trunk/src/servers/app/Desktop.h
   haiku/trunk/src/servers/app/ServerWindow.cpp
   haiku/trunk/src/servers/app/Window.cpp
   haiku/trunk/src/servers/app/Window.h
   haiku/trunk/src/servers/app/WorkspacesView.cpp
Log:
* Fixed millions of coding style violations introduced by the stack & tile
  patch. Grmbl.


Modified: haiku/trunk/src/servers/app/Decorator.h
===================================================================
--- haiku/trunk/src/servers/app/Decorator.h     2009-10-29 08:08:31 UTC (rev 
33823)
+++ haiku/trunk/src/servers/app/Decorator.h     2009-10-29 10:11:24 UTC (rev 
33824)
@@ -45,7 +45,6 @@
        CLICK_RESIZE_RB
 };
 
-#include "Window.h"
 
 class Decorator {
 public:

Modified: haiku/trunk/src/servers/app/DefaultDecorator.cpp
===================================================================
--- haiku/trunk/src/servers/app/DefaultDecorator.cpp    2009-10-29 08:08:31 UTC 
(rev 33823)
+++ haiku/trunk/src/servers/app/DefaultDecorator.cpp    2009-10-29 10:11:24 UTC 
(rev 33824)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2001-2008, Haiku.
+ * Copyright 2001-2009, Haiku.
  * Distributed under the terms of the MIT License.
  *
  * Authors:
@@ -8,6 +8,7 @@
  *             Philippe Saint-Pierre, stpere@xxxxxxxxx
  */
 
+
 /*!    Default and fallback decorator for the app_server - the yellow tabs */
 
 
@@ -458,8 +459,8 @@
        if (typeFound == B_INT32_TYPE && countFound > 0) {
                Window* windowToStackUnder = NULL;
 
-               //This list contains all window id's that are supposed to be
-               //stacked with current window but aren't open
+               // This list contains all window id's that are supposed to be
+               // stacked with current window but aren't open
                BList* persistentIdsToAdd = new BList();
 
                for (int i = 0; i < countFound; i++) {
@@ -475,21 +476,20 @@
                        Window* window = fWindow->Desktop()->FindWindow(id);
                        if (window && window != fWindow && 
window->StackedWindowIds()) {
                                bool idExists = false;
-                               for (int j = 0; !idExists &&
-                                               j < 
window->StackedWindowIds()->CountItems(); j++) {
-                                       int32* stackedId =
-                                               
static_cast<int32*>(window->StackedWindowIds()->ItemAt(j));
+                               for (int j = 0; !idExists
+                                               && j < 
window->StackedWindowIds()->CountItems(); j++) {
+                                       int32* stackedId = static_cast<int32*>(
+                                               
window->StackedWindowIds()->ItemAt(j));
                                        idExists = windowId == *stackedId;
                                }
+
                                if (idExists) {
                                        if (!windowToStackUnder) {
                                                //note this will execute only 
once during loop
                                                windowToStackUnder = window;
                                        }
-                               }
-                               else {
+                               } else
                                        persist = false;
-                               }
                        }
 
                        if (persist) {
@@ -502,39 +502,37 @@
                if (windowToStackUnder) {
                        fWindow->StackWindowBefore(windowToStackUnder);
                        windowToStackUnder->StackAndTile();
-               }
-               else {
+               } else
                        fWindow->InitStackedWindowIds();
-               }
 
+#ifdef DEBUG_STACK_AND_TILE
                for (int i = 0; i < fWindow->StackedWindowIds()->CountItems(); 
i++) {
-                       int32* stackedId =
-                               
static_cast<int32*>(fWindow->StackedWindowIds()->ItemAt(i));
+                       int32* stackedId
+                               = 
static_cast<int32*>(fWindow->StackedWindowIds()->ItemAt(i));
                        STRACE_SAT(("\tstackedWindowIds[%d]=%x\n", i, 
*stackedId));
                }
+#endif
 
-               //Add the remaining window id's to the persistent stacking list
-               //These are the ones that belong to currently unopened windows
+               // Add the remaining window id's to the persistent stacking list
+               // These are the ones that belong to currently unopened windows
                for (int i = 0; i < persistentIdsToAdd->CountItems(); i++) {
-                       int32* idRef =
-                               
static_cast<int32*>(persistentIdsToAdd->ItemAt(i));
+                       int32* idRef = 
static_cast<int32*>(persistentIdsToAdd->ItemAt(i));
                        bool idExists = false;
-                       for (int j = 0; !idExists &&
-                                       j < 
fWindow->StackedWindowIds()->CountItems(); j++) {
-                               int32* stackedId =
-                                       
static_cast<int32*>(fWindow->StackedWindowIds()->ItemAt(j));
+                       for (int j = 0; !idExists
+                                       && j < 
fWindow->StackedWindowIds()->CountItems(); j++) {
+                               int32* stackedId = static_cast<int32*>(
+                                       fWindow->StackedWindowIds()->ItemAt(j));
                                idExists = *idRef == *stackedId;
                        }
                        if (!idExists) {
                                STRACE_SAT(("\t** window %x isn't open - but 
stacked\n",
-                                               *idRef));
+                                       *idRef));
                                fWindow->StackedWindowIds()->AddItem(idRef);
                        }
                }
        }
 
-       _SnapWindowFromSettings("snap left2left", SNAP_LEFT, SNAP_LEFT,
-               &settings);
+       _SnapWindowFromSettings("snap left2left", SNAP_LEFT, SNAP_LEFT, 
&settings);
        _SnapWindowFromSettings("snap left2right", SNAP_LEFT, SNAP_RIGHT,
                &settings);
        _SnapWindowFromSettings("snap right2left", SNAP_RIGHT, SNAP_LEFT,
@@ -559,9 +557,8 @@
 
 void
 DefaultDecorator::_SnapWindowFromSettings(const char* label,
-               SnapOrientation thisSnapOrientation,
-               SnapOrientation otherSnapOrientation,
-               const BMessage* settings)
+       SnapOrientation thisSnapOrientation, SnapOrientation 
otherSnapOrientation,
+       const BMessage* settings)
 {
        type_code typeFound;
        int32 countFound;
@@ -572,43 +569,43 @@
                        settings->FindInt32(label, i, &id);
 
                        Window* window = fWindow->Desktop()->FindWindow(id);
-                       if (window == fWindow) {
+                       if (window == fWindow)
                                continue;
-                       }
 
-                       char* debug_suffix = "... NOT!";
+                       char* debugSuffix = "... NOT!";
 
-                       if (window) {
-                               //There can be cases where the other window to 
which this
-                               //window's snapped doesn't contain a reference 
to this window
-                               //in its snapping list. This would happen when 
the other window
-                               //was de-snapped while this window was hidden. 
So only add the
-                               //other window to this window's snapping list 
when such is not
-                               //the case.
+                       if (window != NULL) {
+                               // There can be cases where the other window to 
which this
+                               // window's snapped doesn't contain a reference 
to this window
+                               // in its snapping list. This would happen when 
the other window
+                               // was de-snapped while this window was hidden. 
So only add the
+                               // other window to this window's snapping list 
when such is not
+                               // the case.
                                BList* otherList = 
window->GetSnappingList(otherSnapOrientation,
-                                               thisSnapOrientation, false);
+                                       thisSnapOrientation, false);
                                if (!otherList) {
-                                       debug_suffix = "\n";
+                                       debugSuffix = "\n";
                                        continue;
                                }
+
                                for (int i = 0; i < otherList->CountItems(); 
i++) {
-                                       int32* snappedId = 
static_cast<int32*>(otherList->ItemAt(i));
+                                       int32* snappedId
+                                               = 
static_cast<int32*>(otherList->ItemAt(i));
                                        if (*snappedId == fWindow->WindowId()) {
                                                fWindow->SnapToWindow(window, 
thisSnapOrientation,
-                                                               
otherSnapOrientation);
-                                               debug_suffix = "";
+                                                       otherSnapOrientation);
+                                               debugSuffix = "";
                                                break;
                                        }
                                }
-                       }
-                       else { //window isn't open - still retain snap id
+                       } else { //window isn't open - still retain snap id
                                fWindow->AddToSnappingList(id, 
thisSnapOrientation,
                                        otherSnapOrientation);
-                               debug_suffix = "... ?";
+                               debugSuffix = "... ?";
                        }
 
                        STRACE_SAT(("\t%s[%d]=%x", label, i, id));
-                       STRACE_SAT(("%s\n", debug_suffix));
+                       STRACE_SAT(("%s\n", debugSuffix));
                }
        }
 }
@@ -619,21 +616,13 @@
 {
        STRACE_SAT(("DefaultDecorator::GetSettings() on %s\n", 
fWindow->Title()));
 
-       if (!fTabRect.IsValid())
+       if (!fTabRect.IsValid()
+               || settings->AddRect("tab frame", fTabRect) != B_OK
+               || settings->AddFloat("border width", fBorderWidth) != B_OK
+               || settings->AddFloat("tab location", (float)fTabOffset) != B_OK
+               || settings->AddInt32("window id", fWindow->WindowId()) != B_OK)
                return false;
 
-       if (settings->AddRect("tab frame", fTabRect) != B_OK)
-               return false;
-
-       if (settings->AddFloat("border width", fBorderWidth) != B_OK)
-               return false;
-
-       if (settings->AddFloat("tab location", (float)fTabOffset) != B_OK)
-               return false;
-
-       if (settings->AddInt32("window id", fWindow->WindowId()) != B_OK)
-               return false;
-
        // store id's of stacked windows
        if (!_StoreIntsInSettings("stacked windows", 
fWindow->StackedWindowIds(),
                        settings))
@@ -641,27 +630,20 @@
 
        // store id's of snapped windows
        if (!_StoreIntsInSettings("snap left2left",
-                       fWindow->Left2LeftSnappingWindowIds(), settings))
-               return false;
-       if (!_StoreIntsInSettings("snap left2right",
-                       fWindow->Left2RightSnappingWindowIds(), settings))
-               return false;
-       if (!_StoreIntsInSettings("snap right2right",
-                       fWindow->Right2RightSnappingWindowIds(), settings))
-               return false;
-       if (!_StoreIntsInSettings("snap right2left",
-                       fWindow->Right2LeftSnappingWindowIds(), settings))
-               return false;
-       if (!_StoreIntsInSettings("snap top2top",
-                       fWindow->Top2TopSnappingWindowIds(), settings))
-               return false;
-       if (!_StoreIntsInSettings("snap top2bottom",
-                       fWindow->Top2BottomSnappingWindowIds(), settings))
-               return false;
-       if (!_StoreIntsInSettings("snap bottom2top",
-                       fWindow->Bottom2TopSnappingWindowIds(), settings))
-               return false;
-       if (!_StoreIntsInSettings("snap bottom2bottom",
+                       fWindow->Left2LeftSnappingWindowIds(), settings)
+               || !_StoreIntsInSettings("snap left2right",
+                       fWindow->Left2RightSnappingWindowIds(), settings)
+               || !_StoreIntsInSettings("snap right2right",
+                       fWindow->Right2RightSnappingWindowIds(), settings)
+               || !_StoreIntsInSettings("snap right2left",
+                       fWindow->Right2LeftSnappingWindowIds(), settings)
+               || !_StoreIntsInSettings("snap top2top",
+                       fWindow->Top2TopSnappingWindowIds(), settings)
+               || !_StoreIntsInSettings("snap top2bottom",
+                       fWindow->Top2BottomSnappingWindowIds(), settings)
+               || !_StoreIntsInSettings("snap bottom2top",
+                       fWindow->Bottom2TopSnappingWindowIds(), settings)
+               || !_StoreIntsInSettings("snap bottom2bottom",
                        fWindow->Bottom2BottomSnappingWindowIds(), settings))
                return false;
 
@@ -675,7 +657,7 @@
 DefaultDecorator::_StoreIntsInSettings(const char* label,
        BList* ids, BMessage* settings) const
 {
-       if (ids) {
+       if (ids != NULL) {
                for (int i = 0; i < ids->CountItems(); i++) {
                        int32* id = static_cast<int32*>(ids->ItemAt(i));
                        if (settings->AddInt32(label, *id) != B_OK)
@@ -689,6 +671,7 @@
 
 // #pragma mark -
 
+
 void
 DefaultDecorator::Draw(BRect update)
 {
@@ -1632,6 +1615,7 @@
                fTabColor = fFocusTabColor;
        else
                fTabColor = fNonFocusTabColor;
+
        dirty->Include(fTabRect);
        fTabHighlighted = active;
 }
@@ -1641,12 +1625,7 @@
 DefaultDecorator::HighlightBorders(bool active, BRegion* dirty)
 {
        if (active) {
-               fFrameColors[0] = fHighlightFrameColors[0];
-               fFrameColors[1] = fHighlightFrameColors[1];
-               fFrameColors[2] = fHighlightFrameColors[2];
-               fFrameColors[3] = fHighlightFrameColors[3];
-               fFrameColors[4] = fHighlightFrameColors[4];
-               fFrameColors[5] = fHighlightFrameColors[5];
+               fFrameColors = fHighlightFrameColors;
        } else if (IsFocus()) {
                fFrameColors[0] = fNonHighlightFrameColors[0];
                fFrameColors[1] = fNonHighlightFrameColors[1];

Modified: haiku/trunk/src/servers/app/DefaultDecorator.h
===================================================================
--- haiku/trunk/src/servers/app/DefaultDecorator.h      2009-10-29 08:08:31 UTC 
(rev 33823)
+++ haiku/trunk/src/servers/app/DefaultDecorator.h      2009-10-29 10:11:24 UTC 
(rev 33824)
@@ -12,11 +12,15 @@
 
 #include "Decorator.h"
 #include "Desktop.h"
+#include "Window.h"
+
 #include <Region.h>
 
+
 class Desktop;
 class ServerBitmap;
 
+
 class DefaultDecorator: public Decorator {
 public:
                                                                
DefaultDecorator(DesktopSettings& settings,
@@ -89,6 +93,15 @@
                                                                        bool 
focus, int32 width, int32 height,
                                                                        
DefaultDecorator* object);
 
+                       // Stack & Tile specific private methods
+                       bool                            
_StoreIntsInSettings(const char* label,
+                                                                       BList* 
ids, BMessage* settings) const;
+                       void                            
_SnapWindowFromSettings(const char* label,
+                                                                       
SnapOrientation thisSnapOrientation,
+                                                                       
SnapOrientation otherSnapOrientation,
+                                                                       const 
BMessage* settings);
+
+private:
                        rgb_color                       fButtonHighColor;
                        rgb_color                       fButtonLowColor;
                        rgb_color                       fTabColor;
@@ -133,14 +146,6 @@
 
                        bigtime_t                       fLastClicked;
                        bool                            fWasDoubleClick;
-
-                       //Stack & Tile specific private methods
-                       bool                            
_StoreIntsInSettings(const char* label,
-                                                                       BList* 
ids, BMessage* settings) const;
-                       void                            
_SnapWindowFromSettings(const char* label,
-                                                                       
SnapOrientation thisSnapOrientation,
-                                                                       
SnapOrientation otherSnapOrientation,
-                                                                       const 
BMessage* settings);
 };
 
 #endif // DEFAULT_DECORATOR_H

Modified: haiku/trunk/src/servers/app/Desktop.cpp
===================================================================
--- haiku/trunk/src/servers/app/Desktop.cpp     2009-10-29 08:08:31 UTC (rev 
33823)
+++ haiku/trunk/src/servers/app/Desktop.cpp     2009-10-29 10:11:24 UTC (rev 
33824)
@@ -50,22 +50,6 @@
 #include "Workspace.h"
 #include "WorkspacesView.h"
 
-#include <ViewPrivate.h>
-#include <WindowInfo.h>
-#include <ServerProtocol.h>
-
-#include <Debug.h>
-#include <DirectWindow.h>
-#include <Entry.h>
-#include <Message.h>
-#include <MessageFilter.h>
-#include <Region.h>
-#include <Roster.h>
-
-#include <stdio.h>
-#include <string.h>
-#include <syslog.h>
-
 #if TEST_MODE
 #      include "EventStream.h"
 #endif
@@ -82,6 +66,7 @@
 #      define AutoWriteLocker BAutolock
 #endif
 
+
 class KeyboardFilter : public EventFilter {
        public:
                KeyboardFilter(Desktop* desktop);
@@ -204,23 +189,23 @@
                }
 
                // switch between stacked windows
-               if (modifiers & B_OPTION_KEY) {
+               if ((modifiers & B_OPTION_KEY) != 0) {
                        BList* stackedWindows = 
fDesktop->FocusWindow()->StackedWindows();
                        if (key == 0x61 && stackedWindows) {
-                               int32 oldIndex =
-                                       
stackedWindows->IndexOf(fDesktop->FocusWindow());
-                               int32 newIndex =
-                                       (oldIndex - 1 >= 0)?
-                                       oldIndex - 1 : 
stackedWindows->CountItems() - 1;
+                               // option key + cursor left
+                               int32 oldIndex
+                                       = 
stackedWindows->IndexOf(fDesktop->FocusWindow());
+                               int32 newIndex = (oldIndex - 1 >= 0)
+                                       ? oldIndex - 1 : 
stackedWindows->CountItems() - 1;
                                fDesktop->ActivateWindow(
                                        
static_cast<Window*>(stackedWindows->ItemAt(newIndex)));
                                return B_SKIP_MESSAGE;
                        } else if (key == 0x63 && stackedWindows) {
-                               int32 oldIndex =
-                                       
stackedWindows->IndexOf(fDesktop->FocusWindow());
-                               int32 newIndex =
-                                       (oldIndex + 1 < 
stackedWindows->CountItems())?
-                                       oldIndex + 1 : 0;
+                               // option key + cursor right
+                               int32 oldIndex
+                                       = 
stackedWindows->IndexOf(fDesktop->FocusWindow());
+                               int32 newIndex = (oldIndex + 1 < 
stackedWindows->CountItems())
+                                       ? oldIndex + 1 : 0;
                                fDesktop->ActivateWindow(
                                        
static_cast<Window*>(stackedWindows->ItemAt(newIndex)));
                                return B_SKIP_MESSAGE;
@@ -240,7 +225,7 @@
                // disable highlights if the stacking and snapping mode was 
just left
                if (fDesktop->fIsStackingAndSnapping && !(modifiers & 
B_OPTION_KEY))
                        fDesktop->FinishStackingAndSnapping();
-               fDesktop->fIsStackingAndSnapping = modifiers & B_OPTION_KEY;
+               fDesktop->fIsStackingAndSnapping = (modifiers & B_OPTION_KEY) 
!= 0;
        }
 
        return B_DISPATCH_MESSAGE;
@@ -1016,7 +1001,7 @@
 
        BList* stackedAndTiledWindows = new BList();
 
-       //Prepare to move tiled windows to the front as well
+       // Prepare to move tiled windows to the front as well
        _AddWindowsByIdsToList(window->Left2LeftSnappingWindowIds(),
                stackedAndTiledWindows);
        _AddWindowsByIdsToList(window->Left2RightSnappingWindowIds(),
@@ -1036,29 +1021,30 @@
 
        bool forceDirty = false;
 
-       //And then prepare to move stacked windows to the front
+       // And then prepare to move stacked windows to the front
        BList* stackedWindows = window->StackedWindows();
-       if (stackedWindows) {
+       if (stackedWindows != NULL) {
                for (int i = 0; i < stackedWindows->CountItems(); i++) {
-                       Window* stackedWindow =
-                               static_cast<Window*>(stackedWindows->ItemAt(i));
+                       Window* stackedWindow
+                               = 
static_cast<Window*>(stackedWindows->ItemAt(i));
                        if (stackedWindow != window
                                && 
!stackedAndTiledWindows->HasItem(stackedWindow)) {
                                stackedAndTiledWindows->AddItem(stackedWindow);
 
-                               //Basically if there are any stacked windows 
associated with
-                               //this window, then designate this window as 
"dirty" so it is
-                               //forced to repaint
+                               // Basically if there are any stacked windows 
associated with
+                               // this window, then designate this window as 
"dirty" so it is
+                               // forced to repaint
                                forceDirty = true;
                        }
                }
        }
 
-       //Do the actual moving here
+       // Do the actual moving here
        for (int i = 0; i < stackedAndTiledWindows->CountItems(); i ++) {
-               Window* win = 
static_cast<Window*>(stackedAndTiledWindows->ItemAt(i));
-               _CurrentWindows().RemoveWindow(win);
-               windows.AddWindow(win);
+               Window* window
+                       = 
static_cast<Window*>(stackedAndTiledWindows->ItemAt(i));
+               _CurrentWindows().RemoveWindow(window);
+               windows.AddWindow(window);
        }
 
        delete stackedAndTiledWindows;
@@ -1098,6 +1084,7 @@
 {
        if (!windowIdsToAdd || !windows)
                return false;
+
        bool added = false;
        for (int i = 0; i < windowIdsToAdd->CountItems(); i++) {
                int32* id = static_cast<int32*>(windowIdsToAdd->ItemAt(i));
@@ -3440,4 +3427,4 @@
                        return window;
        }
        return NULL;
-}
\ No newline at end of file
+}

Modified: haiku/trunk/src/servers/app/Desktop.h
===================================================================
--- haiku/trunk/src/servers/app/Desktop.h       2009-10-29 08:08:31 UTC (rev 
33823)
+++ haiku/trunk/src/servers/app/Desktop.h       2009-10-29 10:11:24 UTC (rev 
33824)
@@ -36,6 +36,7 @@
 
 #include "LinearSpec.h"
 
+
 #define USE_MULTI_LOCKER 1
 
 #if USE_MULTI_LOCKER

Modified: haiku/trunk/src/servers/app/ServerWindow.cpp
===================================================================
--- haiku/trunk/src/servers/app/ServerWindow.cpp        2009-10-29 08:08:31 UTC 
(rev 33823)
+++ haiku/trunk/src/servers/app/ServerWindow.cpp        2009-10-29 10:11:24 UTC 
(rev 33824)
@@ -895,8 +895,9 @@
                                fDesktop->ResizeWindowBy(fWindow,
                                        xResizeTo - fWindow->Frame().Width(),
                                        yResizeTo - fWindow->Frame().Height());
-                               //Re-apply stack & tile constraints so that any 
other windows
-                               //that are stacked/snapped against this window 
can be re-adjusted
+                               // Re-apply stack & tile constraints so that 
any other windows
+                               // that are stacked/snapped against this window 
can be
+                               // re-adjusted
                                fWindow->StackAndTile();
                                fLink.StartMessage(B_OK);
 //                     }
@@ -922,8 +923,9 @@
                        } else {
                                fDesktop->MoveWindowBy(fWindow, xMoveTo - 
fWindow->Frame().left,
                                        yMoveTo - fWindow->Frame().top);
-                               //Re-apply stack & tile constraints so that any 
other windows
-                               //that are stacked/snapped against this window 
can be re-adjusted
+                               // Re-apply stack & tile constraints so that 
any other windows
+                               // that are stacked/snapped against this window 
can be
+                               // re-adjusted
                                fWindow->StackAndTile();
                                fLink.StartMessage(B_OK);
                        }

Modified: haiku/trunk/src/servers/app/Window.cpp
===================================================================
--- haiku/trunk/src/servers/app/Window.cpp      2009-10-29 08:08:31 UTC (rev 
33823)
+++ haiku/trunk/src/servers/app/Window.cpp      2009-10-29 10:11:24 UTC (rev 
33824)
@@ -229,7 +229,7 @@
        // clean up the stackedWindowIds (they are not used by other windows
        // anymore)
        if (fStackedWindowIds
-               && (!fStackedWindows  || fStackedWindows->CountItems()==1)) {
+               && (!fStackedWindows || fStackedWindows->CountItems() == 1)) {
                for (int i = 0; i < fStackedWindowIds->CountItems(); i++) {
                        int32* id = 
static_cast<int32*>(fStackedWindowIds->ItemAt(i));
                        free(id);
@@ -2467,6 +2467,9 @@
 }
 
 
+// #pragma mark - Stack & Tile
+
+
 bool
 Window::HighlightTab(bool active, BRegion& dirty)
 {
@@ -2526,8 +2529,8 @@
                        || windowsToRight->CountItems() == 1
                                && 
*static_cast<int32*>(windowsToRight->ItemAt(0))
                                        == detached->WindowId())) {
-               //If window is off-screen to the left and there's no window 
tiled
-               //to its right that can still "save" it from going totally 
off-screen
+               // If window is off-screen to the left and there's no window 
tiled
+               // to its right that can still "save" it from going totally 
off-screen
                deltaX = 6 - window->Frame().left;
        }
        else if (window->Frame().right > screenFrame.right
@@ -2536,8 +2539,8 @@
                        || windowsToLeft->CountItems() == 1
                                && 
*static_cast<int32*>(windowsToLeft->ItemAt(0))
                                        == detached->WindowId())) {
-               //If window is off-screen to the right and there's no window 
tiled
-               //to its left that can still "save" it from going totally 
off-screen
+               // If window is off-screen to the right and there's no window 
tiled
+               // to its left that can still "save" it from going totally 
off-screen
                deltaX = screenFrame.right - window->Frame().right - 6;
        }
        if (window->Frame().top < 0
@@ -2546,8 +2549,8 @@
                        || windowsToTop->CountItems() == 1
                                && *static_cast<int32*>(windowsToTop->ItemAt(0))
                                        == detached->WindowId())) {
-               //If window is off-screen to the top and there's no window tiled
-               //to its bottom that can still "save" it from going totally 
off-screen
+               // If window is off-screen to the top and there's no window 
tiled
+               // to its bottom that can still "save" it from going totally 
off-screen
                deltaY = 27 - window->Frame().top;
        }
        else if (window->Frame().bottom > screenFrame.bottom
@@ -2556,8 +2559,8 @@
                        || windowsToBottom->CountItems() == 1
                                && 
*static_cast<int32*>(windowsToBottom->ItemAt(0))
                                        == detached->WindowId())) {
-               //If window is off-screen to the bottom and there's no window 
tiled
-               //to its top that can still "save" it from going totally 
off-screen
+               // If window is off-screen to the bottom and there's no window 
tiled
+               // to its top that can still "save" it from going totally 
off-screen
                deltaY = screenFrame.bottom - window->Frame().bottom - 6;
        }
        if (deltaX != 0 || deltaY != 0)
@@ -2610,11 +2613,11 @@
        fRightVar->SetRange(-DBL_MAX, DBL_MAX);
        fBottomVar->SetRange(-DBL_MAX, DBL_MAX);
 
-       fLeftConstraint  = fDesktop->fStackAndTileSpec
-               ->AddConstraint(1.0, fLeftVar,
+       fLeftConstraint
+               = fDesktop->fStackAndTileSpec->AddConstraint(1.0, fLeftVar,
                        OperatorType(EQ), fFrame.left, 1, 1);
-       fTopConstraint  = fDesktop->fStackAndTileSpec
-               ->AddConstraint(1.0, fTopVar,
+       fTopConstraint
+               = fDesktop->fStackAndTileSpec->AddConstraint(1.0, fTopVar,
                        OperatorType(EQ), fFrame.top, 1, 1);
        label = Title();
        label << ".fLeftConstraint";
@@ -2625,12 +2628,12 @@
 
        int32 minWidth, maxWidth, minHeight, maxHeight;
        GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
-       fMinWidthConstraint = fDesktop->fStackAndTileSpec
-               ->AddConstraint(1.0, fLeftVar, -1.0, fRightVar,
-                       OperatorType(LE), -minWidth);
-       fMinHeightConstraint = fDesktop->fStackAndTileSpec
-               ->AddConstraint(1.0, fTopVar, -1.0, fBottomVar,
-                       OperatorType(LE), -minHeight);
+       fMinWidthConstraint
+               = fDesktop->fStackAndTileSpec->AddConstraint(1.0, fLeftVar, 
-1.0,
+                       fRightVar, OperatorType(LE), -minWidth);
+       fMinHeightConstraint
+               = fDesktop->fStackAndTileSpec->AddConstraint(1.0, fTopVar, -1.0,
+                       fBottomVar, OperatorType(LE), -minHeight);
        label = Title();
        label << ".fMinWidthConstraint";
        fMinWidthConstraint->SetLabel(label.String());
@@ -2641,12 +2644,12 @@
        // The width and height constraints have higher penalties than the
        // position constraints (left, top), so a window will keep its size
        // unless explicitly resized.
-       fWidthConstraint = fDesktop->fStackAndTileSpec
-               ->AddConstraint(-1.0, fLeftVar, 1.0, fRightVar,
-                       OperatorType(EQ), fFrame.Width(), 10, 10);
-       fHeightConstraint = fDesktop->fStackAndTileSpec
-               ->AddConstraint(-1.0, fTopVar, 1.0, fBottomVar,
-                       OperatorType(EQ), fFrame.Height(), 10, 10);
+       fWidthConstraint
+               = fDesktop->fStackAndTileSpec->AddConstraint(-1.0, fLeftVar, 
1.0,
+                       fRightVar, OperatorType(EQ), fFrame.Width(), 10, 10);
+       fHeightConstraint
+               = fDesktop->fStackAndTileSpec->AddConstraint(-1.0, fTopVar, 1.0,
+                       fBottomVar, OperatorType(EQ), fFrame.Height(), 10, 10);
        label = Title();
        label << ".fWidthConstraint";
        fWidthConstraint->SetLabel(label.String());
@@ -2871,14 +2874,17 @@
        }
 
        // if the stacking candidate has changed, change tab highlights
-       if(prevWindowUnder != fWindowUnder) {
-               if(!prevWindowUnder) { // candidate found for the first time
+       if (prevWindowUnder != fWindowUnder) {
+               if (!prevWindowUnder) {
+                       // candidate found for the first time
                        fDesktop->HighlightTab(this, true);
                        fDesktop->HighlightTab(fWindowUnder, true);
-               } else if(!fWindowUnder) { // no candidate after there was one
+               } else if (!fWindowUnder) {
+                       // no candidate after there was one
                        fDesktop->HighlightTab(this, false);
                        fDesktop->HighlightTab(prevWindowUnder, false);
-               } else { // changing from one to another candidate
+               } else {
+                       // changing from one to another candidate
                        fDesktop->HighlightTab(prevWindowUnder, false);
                        fDesktop->HighlightTab(fWindowUnder, true);
                }
@@ -3181,7 +3187,8 @@
 /*!    \brief Snaps this window to the current candidate windows for snapping
        on each side. Afterwards snapping candidates are cleared.
 */
-void Window::_SnapWindow()
+void
+Window::_SnapWindow()
 {
        BRect bounds;
        Window* leftmostWindow;
@@ -3216,8 +3223,8 @@
                        topmostWindow->AddToSnappingList(this, SNAP_RIGHT, 
SNAP_LEFT);
 
                        STRACE_SAT(("Adding %s[%d] to %s[%d]'s T2T & L2R 
list\n",
-                                               topmostWindow->Title(), 
topmostWindow->WindowId(),
-                                               Title(), WindowId()));
+                               topmostWindow->Title(), 
topmostWindow->WindowId(),
+                               Title(), WindowId()));
                }
 
                // adjust bottom border
@@ -3236,8 +3243,8 @@
                        bottommostWindow->AddToSnappingList(this, SNAP_RIGHT, 
SNAP_LEFT);
 
                        STRACE_SAT(("Adding %s[%d] to %s[%d]'s B2B & L2R 
list\n",
-                                               bottommostWindow->Title(), 
bottommostWindow->WindowId(),
-                                               Title(), WindowId()));
+                               bottommostWindow->Title(), 
bottommostWindow->WindowId(),
+                               Title(), WindowId()));
                }
 
                // adjust other windows
@@ -3258,8 +3265,7 @@
                        window->AddToSnappingList(this, SNAP_RIGHT, SNAP_LEFT);
 
                        STRACE_SAT(("Adding %s[%d] to %s[%d]'s L2R list\n",
-                                               window->Title(), 
window->WindowId(), Title(),
-                                               WindowId()));
+                               window->Title(), window->WindowId(), Title(), 
WindowId()));
                }
        }
 
@@ -3291,8 +3297,8 @@
                        leftmostWindow->AddToSnappingList(this, SNAP_BOTTOM, 
SNAP_TOP);
 
                        STRACE_SAT(("Adding %s[%d] to %s[%d]'s L2L & T2B 
list\n",
-                                               leftmostWindow->Title(), 
leftmostWindow->WindowId(),
-                                               Title(), WindowId()));
+                               leftmostWindow->Title(), 
leftmostWindow->WindowId(),
+                               Title(), WindowId()));
                }
 
                // adjust right border
@@ -3311,8 +3317,8 @@
                        rightmostWindow->AddToSnappingList(this, SNAP_BOTTOM, 
SNAP_TOP);
 
                        STRACE_SAT(("Adding %s[%d] to %s[%d]'s R2R & T2B 
list\n",
-                                               rightmostWindow->Title(), 
rightmostWindow->WindowId(),
-                                               Title(), WindowId()));
+                               rightmostWindow->Title(), 
rightmostWindow->WindowId(),
+                               Title(), WindowId()));
                }
 
                // adjust other windows
@@ -3320,10 +3326,9 @@
                        Window* window = static_cast<Window*>(
                                fTopAdjacentWindows->ItemAt(i));
                        window->_InitStackingAndSnapping();
-                       Constraint* topSnapping =
-                               fDesktop->fStackAndTileSpec->AddConstraint(
-                                       -1, window->fBottomVar, 1, fTopVar,
-                                       OperatorType(EQ), 32);
+                       Constraint* topSnapping
+                               = fDesktop->fStackAndTileSpec->AddConstraint(
+                                       -1, window->fBottomVar, 1, fTopVar, 
OperatorType(EQ), 32);
                        BString label("topSnapping of ");
                        label << Title();
                        topSnapping->SetLabel(label.String());
@@ -3333,8 +3338,7 @@
                        window->AddToSnappingList(this, SNAP_BOTTOM, SNAP_TOP);
 
                        STRACE_SAT(("Adding %s[%d] to %s[%d]'s T2B list\n",
-                                               window->Title(), 
window->WindowId(), Title(),
-                                               WindowId()));
+                               window->Title(), window->WindowId(), Title(), 
WindowId()));
                }
        }
 
@@ -3366,8 +3370,8 @@
                        topmostWindow->AddToSnappingList(this, SNAP_LEFT, 
SNAP_RIGHT);
 
                        STRACE_SAT(("Adding %s[%d] to %s[%d]'s T2T & R2L 
list\n",
-                                               topmostWindow->Title(), 
topmostWindow->WindowId(),
-                                               Title(), WindowId()));
+                               topmostWindow->Title(), 
topmostWindow->WindowId(),
+                               Title(), WindowId()));
                }
 
                // adjust bottom border
@@ -3386,8 +3390,8 @@
                        bottommostWindow->AddToSnappingList(this, SNAP_LEFT, 
SNAP_RIGHT);
 
                        STRACE_SAT(("Adding %s[%d] to %s[%d]'s B2B & R2L 
list\n",
-                                               bottommostWindow->Title(), 
bottommostWindow->WindowId(),
-                                               Title(), WindowId()));
+                               bottommostWindow->Title(), 
bottommostWindow->WindowId(),
+                               Title(), WindowId()));
                }
 
                // adjust other windows
@@ -3395,10 +3399,9 @@
                        Window* window = static_cast<Window*>(
                                fRightAdjacentWindows->ItemAt(i));
                        window->_InitStackingAndSnapping();
-                       Constraint* rightSnapping =
-                               fDesktop->fStackAndTileSpec->AddConstraint(
-                                       -1, fRightVar, 1, window->fLeftVar,
-                                       OperatorType(EQ), 11);
+                       Constraint* rightSnapping
+                               = fDesktop->fStackAndTileSpec->AddConstraint(
+                                       -1, fRightVar, 1, window->fLeftVar, 
OperatorType(EQ), 11);
                        BString label("rightSnapping of ");
                        label << Title();
                        rightSnapping->SetLabel(label.String());
@@ -3408,8 +3411,7 @@
                        window->AddToSnappingList(this, SNAP_LEFT, SNAP_RIGHT);
 
                        STRACE_SAT(("Adding %s[%d] to %s[%d]'s R2L list\n",
-                                               window->Title(), 
window->WindowId(), Title(),
-                                               WindowId()));
+                               window->Title(), window->WindowId(), Title(), 
WindowId()));
                }
        }
 
@@ -3441,8 +3443,8 @@
                        leftmostWindow->AddToSnappingList(this, SNAP_TOP, 
SNAP_BOTTOM);
 
                        STRACE_SAT(("Adding %s[%d] to %s[%d]'s L2L & B2T 
list\n",
-                                               leftmostWindow->Title(), 
leftmostWindow->WindowId(),
-                                               Title(), WindowId()));
+                               leftmostWindow->Title(), 
leftmostWindow->WindowId(),
+                               Title(), WindowId()));
                }
 
                // adjust right border
@@ -3461,8 +3463,8 @@
                        rightmostWindow->AddToSnappingList(this, SNAP_TOP, 
SNAP_BOTTOM);
 
                        STRACE_SAT(("Adding %s[%d] to %s[%d]'s R2R & B2T 
list\n",
-                                               rightmostWindow->Title(), 
rightmostWindow->WindowId(),
-                                               Title(), WindowId()));
+                               rightmostWindow->Title(), 
rightmostWindow->WindowId(),
+                               Title(), WindowId()));
                }
 
                // adjust other windows
@@ -3470,10 +3472,9 @@
                        Window* window = static_cast<Window*>(
                                fBottomAdjacentWindows->ItemAt(i));
                        window->_InitStackingAndSnapping();
-                       Constraint* bottomSnapping =
-                               fDesktop->fStackAndTileSpec->AddConstraint(
-                                       -1, fBottomVar, 1, window->fTopVar,
-                                       OperatorType(EQ), 32);
+                       Constraint* bottomSnapping
+                               = fDesktop->fStackAndTileSpec->AddConstraint(
+                                       -1, fBottomVar, 1, window->fTopVar, 
OperatorType(EQ), 32);
                        BString label("bottomSnapping of ");
                        label << Title();
                        bottomSnapping->SetLabel(label.String());
@@ -3483,8 +3484,7 @@
                        window->AddToSnappingList(this, SNAP_TOP, SNAP_BOTTOM);
 
                        STRACE_SAT(("Adding %s[%d] to %s[%d]'s B2T list\n",
-                                               window->Title(), 
window->WindowId(), Title(),
-                                               WindowId()));
+                               window->Title(), window->WindowId(), Title(), 
WindowId()));
                }
        }
 
@@ -3501,11 +3501,11 @@
 
 
 void
-Window::AddToSnappingList(Window* window,
-               SnapOrientation thisSnapOrientation,
-               SnapOrientation otherSnapOrientation) {
+Window::AddToSnappingList(Window* window, SnapOrientation thisSnapOrientation,
+       SnapOrientation otherSnapOrientation)
+{
        AddToSnappingList(window->WindowId(), thisSnapOrientation,
-                       otherSnapOrientation);
+               otherSnapOrientation);
 }
 
 
@@ -3519,18 +3519,17 @@
        \param otherSnapOrientation snapping orientation for given window
  */
 void
-Window::AddToSnappingList(int32 windowId,
-               SnapOrientation thisSnapOrientation,
-               SnapOrientation otherSnapOrientation) {
-
+Window::AddToSnappingList(int32 windowId, SnapOrientation thisSnapOrientation,
+       SnapOrientation otherSnapOrientation)
+{
        BList* windowIdList = GetSnappingList(thisSnapOrientation,
                otherSnapOrientation, true);
-       //This may be the case if invalid snap orientation combo is given
-       //(e.g. top to left)
+       // This may be the case if invalid snap orientation combo is given
+       // (e.g. top to left)
        if (!windowIdList)
                return;
 
-       //don't add id if already contained
+       // don't add id if already contained
        for (int i = 0; i < windowIdList->CountItems(); i++) {
                int32* id = static_cast<int32*>(windowIdList->ItemAt(i));
                if (*id == windowId) {
@@ -3541,11 +3540,12 @@
        *id = windowId;
        windowIdList->AddItem(id);
 
+#ifdef DEBUG_STACK_AND_TILE
        char snapStr[][7] = {"left", "right", "top", "bottom"};
        STRACE_SAT(("\tAdded %s to %s's %s 2 %s list\n",
-                               windowId, Title(),
-                               snapStr[thisSnapOrientation],
-                               snapStr[otherSnapOrientation]));
+               windowId, Title(), snapStr[thisSnapOrientation],
+               snapStr[otherSnapOrientation]));
+#endif
 }
 
 
@@ -3559,8 +3559,8 @@
  */
 void
 Window::RemoveFromSnappingList(int32 windowId,
-               SnapOrientation thisSnapOrientation,
-               SnapOrientation otherSnapOrientation) {
+       SnapOrientation thisSnapOrientation, SnapOrientation 
otherSnapOrientation)
+{
        BList* windowIdList = GetSnappingList(thisSnapOrientation,
                otherSnapOrientation, false);
 
@@ -3575,11 +3575,13 @@
                        windowIdList->RemoveItem(i);
                        free(id);
 
+#ifdef DEBUG_STACK_AND_TILE
                        char snapStr[][7] = {"left", "right", "top", "bottom"};
                        STRACE_SAT(("\tRemoved %x from %s's %s 2 %s list\n",
                                                windowId, Title(),
                                                snapStr[thisSnapOrientation],
                                                snapStr[otherSnapOrientation]));
+#endif
                        return;
                }
        }
@@ -3597,11 +3599,10 @@
  */
 BList*
 Window::GetSnappingList(SnapOrientation thisSnapOrientation,
-               SnapOrientation otherSnapOrientation,
-               bool createIfNull)
+       SnapOrientation otherSnapOrientation, bool createIfNull)
 {
        BList** windowIdListRef = _GetSnappingListRef(thisSnapOrientation,
-                       otherSnapOrientation, createIfNull);
+               otherSnapOrientation, createIfNull);
 
        if (windowIdListRef)
                return *windowIdListRef;
@@ -3611,8 +3612,7 @@
 
 BList**
 Window::_GetSnappingListRef(SnapOrientation thisSnapOrientation,
-               SnapOrientation otherSnapOrientation,
-               bool createIfNull)
+       SnapOrientation otherSnapOrientation, bool createIfNull)
 {
        BList** windowIdListRef = NULL;
        if (thisSnapOrientation == SNAP_LEFT
@@ -3640,13 +3640,13 @@
                && otherSnapOrientation == SNAP_BOTTOM)
                windowIdListRef = &fBottom2BottomSnappingWindowIds;
 
-       //This will be the case if invalid snap orientation combo is given
-       //(e.g. top to left)
+       // This will be the case if invalid snap orientation combo is given
+       // (e.g. top to left)
        if (!windowIdListRef) {
                return NULL;
        }
 
-       //Create snapping list if not already initialised.
+       // Create snapping list if not already initialised.
        if (!(*windowIdListRef) && createIfNull) {
                *windowIdListRef = new BList();
        }
@@ -3660,16 +3660,15 @@
                according to given orientation). Returns the object representing
                this snapping constraint.
 
-               TODO some of the logic is duplicative w.r.t _SnapWindow - 
consider

[... truncated: 404 lines follow ...]

Other related posts: