* Fixed millions of coding style violations introduced by the stack & tile
patch. Grmbl. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33824 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -45,7 +45,6 @@ enum click_type {
|
||||
CLICK_RESIZE_RB
|
||||
};
|
||||
|
||||
#include "Window.h"
|
||||
|
||||
class Decorator {
|
||||
public:
|
||||
|
||||
@@ -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, [email protected]
|
||||
*/
|
||||
|
||||
|
||||
/*! Default and fallback decorator for the app_server - the yellow tabs */
|
||||
|
||||
|
||||
@@ -475,22 +476,21 @@ DefaultDecorator::SetSettings(const BMessage& settings, BRegion* updateRegion)
|
||||
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) {
|
||||
int32* idRef = static_cast<int32*>(malloc(sizeof(int32)));
|
||||
@@ -502,27 +502,26 @@ DefaultDecorator::SetSettings(const BMessage& settings, BRegion* updateRegion)
|
||||
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
|
||||
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) {
|
||||
@@ -533,8 +532,7 @@ DefaultDecorator::SetSettings(const BMessage& settings, BRegion* updateRegion)
|
||||
}
|
||||
}
|
||||
|
||||
_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,8 +557,7 @@ DefaultDecorator::SetSettings(const BMessage& settings, BRegion* updateRegion)
|
||||
|
||||
void
|
||||
DefaultDecorator::_SnapWindowFromSettings(const char* label,
|
||||
SnapOrientation thisSnapOrientation,
|
||||
SnapOrientation otherSnapOrientation,
|
||||
SnapOrientation thisSnapOrientation, SnapOrientation otherSnapOrientation,
|
||||
const BMessage* settings)
|
||||
{
|
||||
type_code typeFound;
|
||||
@@ -572,13 +569,12 @@ DefaultDecorator::_SnapWindowFromSettings(const char* label,
|
||||
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) {
|
||||
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
|
||||
@@ -588,27 +584,28 @@ DefaultDecorator::_SnapWindowFromSettings(const char* label,
|
||||
BList* otherList = window->GetSnappingList(otherSnapOrientation,
|
||||
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 = "";
|
||||
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,19 +616,11 @@ DefaultDecorator::GetSettings(BMessage* settings) const
|
||||
{
|
||||
STRACE_SAT(("DefaultDecorator::GetSettings() on %s\n", fWindow->Title()));
|
||||
|
||||
if (!fTabRect.IsValid())
|
||||
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)
|
||||
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;
|
||||
|
||||
// store id's of stacked windows
|
||||
@@ -641,27 +630,20 @@ DefaultDecorator::GetSettings(BMessage* settings) const
|
||||
|
||||
// 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 @@ bool
|
||||
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 @@ DefaultDecorator::_StoreIntsInSettings(const char* label,
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
void
|
||||
DefaultDecorator::Draw(BRect update)
|
||||
{
|
||||
@@ -1632,6 +1615,7 @@ DefaultDecorator::HighlightTab(bool active, BRegion* dirty)
|
||||
fTabColor = fFocusTabColor;
|
||||
else
|
||||
fTabColor = fNonFocusTabColor;
|
||||
|
||||
dirty->Include(fTabRect);
|
||||
fTabHighlighted = active;
|
||||
}
|
||||
@@ -1641,12 +1625,7 @@ void
|
||||
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];
|
||||
|
||||
@@ -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 @@ private:
|
||||
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 @@ private:
|
||||
|
||||
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
|
||||
|
||||
+21
-34
@@ -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 @@ KeyboardFilter::Filter(BMessage* message, EventTarget** _target,
|
||||
}
|
||||
|
||||
// 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 @@ KeyboardFilter::Filter(BMessage* message, EventTarget** _target,
|
||||
// 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;
|
||||
@@ -1038,10 +1023,10 @@ Desktop::ActivateWindow(Window* window)
|
||||
|
||||
// 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);
|
||||
@@ -1056,9 +1041,10 @@ Desktop::ActivateWindow(Window* window)
|
||||
|
||||
// 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 @@ Desktop::_AddWindowsByIdsToList(BList* windowIdsToAdd, BList* windows)
|
||||
{
|
||||
if (!windowIdsToAdd || !windows)
|
||||
return false;
|
||||
|
||||
bool added = false;
|
||||
for (int i = 0; i < windowIdsToAdd->CountItems(); i++) {
|
||||
int32* id = static_cast<int32*>(windowIdsToAdd->ItemAt(i));
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
|
||||
#include "LinearSpec.h"
|
||||
|
||||
|
||||
#define USE_MULTI_LOCKER 1
|
||||
|
||||
#if USE_MULTI_LOCKER
|
||||
|
||||
@@ -896,7 +896,8 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
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
|
||||
// that are stacked/snapped against this window can be
|
||||
// re-adjusted
|
||||
fWindow->StackAndTile();
|
||||
fLink.StartMessage(B_OK);
|
||||
// }
|
||||
@@ -923,7 +924,8 @@ ServerWindow::_DispatchMessage(int32 code, BPrivate::LinkReceiver &link)
|
||||
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
|
||||
// that are stacked/snapped against this window can be
|
||||
// re-adjusted
|
||||
fWindow->StackAndTile();
|
||||
fLink.StartMessage(B_OK);
|
||||
}
|
||||
|
||||
+82
-80
@@ -2467,6 +2467,9 @@ Window::UpdateSession::Exclude(BRegion* dirtyInNextSession)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - Stack & Tile
|
||||
|
||||
|
||||
bool
|
||||
Window::HighlightTab(bool active, BRegion& dirty)
|
||||
{
|
||||
@@ -2610,11 +2613,11 @@ Window::_InitStackingAndSnapping()
|
||||
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 @@ Window::_InitStackingAndSnapping()
|
||||
|
||||
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 @@ Window::_InitStackingAndSnapping()
|
||||
// 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());
|
||||
@@ -2872,13 +2875,16 @@ Window::_CheckIfReadyToStack()
|
||||
|
||||
// if the stacking candidate has changed, change tab highlights
|
||||
if (prevWindowUnder != fWindowUnder) {
|
||||
if(!prevWindowUnder) { // candidate found for the first time
|
||||
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 @@ Window::_CheckIfReadyToSnap()
|
||||
/*! \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;
|
||||
@@ -3258,8 +3265,7 @@ void Window::_SnapWindow()
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3320,10 +3326,9 @@ void Window::_SnapWindow()
|
||||
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 @@ void Window::_SnapWindow()
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3395,10 +3399,9 @@ void Window::_SnapWindow()
|
||||
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 @@ void Window::_SnapWindow()
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3470,10 +3472,9 @@ void Window::_SnapWindow()
|
||||
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 @@ void Window::_SnapWindow()
|
||||
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,9 +3501,9 @@ void Window::_SnapWindow()
|
||||
|
||||
|
||||
void
|
||||
Window::AddToSnappingList(Window* window,
|
||||
SnapOrientation thisSnapOrientation,
|
||||
SnapOrientation otherSnapOrientation) {
|
||||
Window::AddToSnappingList(Window* window, SnapOrientation thisSnapOrientation,
|
||||
SnapOrientation otherSnapOrientation)
|
||||
{
|
||||
AddToSnappingList(window->WindowId(), thisSnapOrientation,
|
||||
otherSnapOrientation);
|
||||
}
|
||||
@@ -3519,10 +3519,9 @@ Window::AddToSnappingList(Window* window,
|
||||
\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
|
||||
@@ -3541,11 +3540,12 @@ Window::AddToSnappingList(int32 windowId,
|
||||
*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],
|
||||
windowId, Title(), snapStr[thisSnapOrientation],
|
||||
snapStr[otherSnapOrientation]));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -3559,8 +3559,8 @@ Window::AddToSnappingList(int32 windowId,
|
||||
*/
|
||||
void
|
||||
Window::RemoveFromSnappingList(int32 windowId,
|
||||
SnapOrientation thisSnapOrientation,
|
||||
SnapOrientation otherSnapOrientation) {
|
||||
SnapOrientation thisSnapOrientation, SnapOrientation otherSnapOrientation)
|
||||
{
|
||||
BList* windowIdList = GetSnappingList(thisSnapOrientation,
|
||||
otherSnapOrientation, false);
|
||||
|
||||
@@ -3575,11 +3575,13 @@ Window::RemoveFromSnappingList(int32 windowId,
|
||||
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,8 +3599,7 @@ Window::RemoveFromSnappingList(int32 windowId,
|
||||
*/
|
||||
BList*
|
||||
Window::GetSnappingList(SnapOrientation thisSnapOrientation,
|
||||
SnapOrientation otherSnapOrientation,
|
||||
bool createIfNull)
|
||||
SnapOrientation otherSnapOrientation, bool createIfNull)
|
||||
{
|
||||
BList** windowIdListRef = _GetSnappingListRef(thisSnapOrientation,
|
||||
otherSnapOrientation, createIfNull);
|
||||
@@ -3611,8 +3612,7 @@ Window::GetSnappingList(SnapOrientation thisSnapOrientation,
|
||||
|
||||
BList**
|
||||
Window::_GetSnappingListRef(SnapOrientation thisSnapOrientation,
|
||||
SnapOrientation otherSnapOrientation,
|
||||
bool createIfNull)
|
||||
SnapOrientation otherSnapOrientation, bool createIfNull)
|
||||
{
|
||||
BList** windowIdListRef = NULL;
|
||||
if (thisSnapOrientation == SNAP_LEFT
|
||||
@@ -3668,8 +3668,7 @@ Window::_GetSnappingListRef(SnapOrientation thisSnapOrientation,
|
||||
\param otherSnap snapping orientation for given window
|
||||
*/
|
||||
Constraint*
|
||||
Window::SnapToWindow(Window* otherWindow,
|
||||
SnapOrientation thisSnap,
|
||||
Window::SnapToWindow(Window* otherWindow, SnapOrientation thisSnap,
|
||||
SnapOrientation otherSnap)
|
||||
{
|
||||
Variable* thisSnappingVar;
|
||||
@@ -3699,7 +3698,8 @@ Window::SnapToWindow(Window* otherWindow,
|
||||
break;
|
||||
case SNAP_RIGHT:
|
||||
snapDistance = -11;
|
||||
moveDeltaX = otherFrame.right - thisFrame.left - snapDistance;
|
||||
moveDeltaX
|
||||
= otherFrame.right - thisFrame.left - snapDistance;
|
||||
otherSnappingVar = otherWindow->fRightVar;
|
||||
break;
|
||||
default:
|
||||
@@ -3709,10 +3709,12 @@ Window::SnapToWindow(Window* otherWindow,
|
||||
case SNAP_RIGHT:
|
||||
thisSnappingVar = fRightVar;
|
||||
snappingLabel << "rightSnapping of ";
|
||||
|
||||
switch (otherSnap) {
|
||||
case SNAP_LEFT:
|
||||
snapDistance = 11;
|
||||
moveDeltaX = otherFrame.left - thisFrame.right - snapDistance;
|
||||
moveDeltaX
|
||||
= otherFrame.left - thisFrame.right - snapDistance;
|
||||
otherSnappingVar = otherWindow->fLeftVar;
|
||||
break;
|
||||
case SNAP_RIGHT:
|
||||
@@ -3733,7 +3735,8 @@ Window::SnapToWindow(Window* otherWindow,
|
||||
break;
|
||||
case SNAP_BOTTOM:
|
||||
snapDistance = -32;
|
||||
moveDeltaY = otherFrame.bottom - thisFrame.top - snapDistance;
|
||||
moveDeltaY
|
||||
= otherFrame.bottom - thisFrame.top - snapDistance;
|
||||
otherSnappingVar = otherWindow->fBottomVar;
|
||||
break;
|
||||
default:
|
||||
@@ -3746,7 +3749,8 @@ Window::SnapToWindow(Window* otherWindow,
|
||||
switch (otherSnap) {
|
||||
case SNAP_TOP:
|
||||
snapDistance = 32;
|
||||
moveDeltaY = otherFrame.top - thisFrame.bottom - snapDistance;
|
||||
moveDeltaY
|
||||
= otherFrame.top - thisFrame.bottom - snapDistance;
|
||||
otherSnappingVar = otherWindow->fTopVar;
|
||||
break;
|
||||
case SNAP_BOTTOM:
|
||||
@@ -3764,10 +3768,11 @@ Window::SnapToWindow(Window* otherWindow,
|
||||
Constraint* snappingConstraint;
|
||||
if (snapDistance == 0)
|
||||
snappingConstraint = thisSnappingVar->IsEqual(otherSnappingVar);
|
||||
else
|
||||
else {
|
||||
snappingConstraint = fDesktop->fStackAndTileSpec->AddConstraint(
|
||||
-1, thisSnappingVar, 1, otherSnappingVar,
|
||||
OperatorType(EQ), snapDistance);
|
||||
-1, thisSnappingVar, 1, otherSnappingVar, OperatorType(EQ),
|
||||
snapDistance);
|
||||
}
|
||||
|
||||
snappingLabel << Title();
|
||||
snappingConstraint->SetLabel(snappingLabel.String());
|
||||
@@ -3795,9 +3800,8 @@ Window::SnapToWindow(Window* otherWindow,
|
||||
should be stored.
|
||||
*/
|
||||
BRect
|
||||
Window::_BoundingRectAndWindows(BList* windows,
|
||||
Window** leftmostWindow, Window** topmostWindow,
|
||||
Window** rightmostWindow, Window** bottommostWindow)
|
||||
Window::_BoundingRectAndWindows(BList* windows, Window** leftmostWindow,
|
||||
Window** topmostWindow, Window** rightmostWindow, Window** bottommostWindow)
|
||||
{
|
||||
ASSERT(!windows->IsEmpty());
|
||||
|
||||
@@ -3916,10 +3920,8 @@ Window::StackAndTile()
|
||||
}
|
||||
|
||||
// set window locations and sizes
|
||||
for (Window* window = fDesktop->GetWindows().LastWindow();
|
||||
window;
|
||||
for (Window* window = fDesktop->GetWindows().LastWindow(); window != NULL;
|
||||
window = window->PreviousWindow(fCurrentWorkspace)) {
|
||||
|
||||
if (window->fLeftVar) {
|
||||
fDesktop->MoveWindowBy(window,
|
||||
window->fLeftVar->Value() - window->fFrame.left,
|
||||
@@ -3972,8 +3974,8 @@ Window::StackAndTile()
|
||||
}
|
||||
debug_printf("\n");
|
||||
delete specStr;
|
||||
#endif
|
||||
STRACE_SAT(("Finished Window::StackAndTile() on %s\n", Title()));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -4030,8 +4032,8 @@ Window::SetWindowId(int32 windowId)
|
||||
void
|
||||
Window::_RemoveStackingPersistently()
|
||||
{
|
||||
STRACE_SAT(("Window::_RemoveStackingPersistently() on %s, fStackedWindowIds=%x\n",
|
||||
Title(), fStackedWindowIds));
|
||||
STRACE_SAT(("Window::_RemoveStackingPersistently() on %s, "
|
||||
"fStackedWindowIds=%x\n", Title(), fStackedWindowIds));
|
||||
if (!fStackedWindowIds)
|
||||
return;
|
||||
|
||||
@@ -4083,9 +4085,9 @@ Window::_RemoveSnappingPersistently()
|
||||
id from the snapping list of other relevant windows
|
||||
*/
|
||||
void
|
||||
Window::_FreeUpSnappingList(SnapOrientation thisSnap,
|
||||
SnapOrientation otherSnap,
|
||||
bool deleteFromOtherWindowsList) {
|
||||
Window::_FreeUpSnappingList(SnapOrientation thisSnap, SnapOrientation otherSnap,
|
||||
bool deleteFromOtherWindowsList)
|
||||
{
|
||||
BList** idListRef = _GetSnappingListRef(thisSnap, otherSnap, false);
|
||||
|
||||
if (!idListRef)
|
||||
@@ -4101,8 +4103,10 @@ Window::_FreeUpSnappingList(SnapOrientation thisSnap,
|
||||
Window* otherWindow = fDesktop->FindWindow(*id);
|
||||
// Remove this window from the other window's snapping list.
|
||||
// Note the order of orientation is reversed.
|
||||
if (otherWindow)
|
||||
otherWindow->RemoveFromSnappingList(WindowId(), otherSnap, thisSnap);
|
||||
if (otherWindow) {
|
||||
otherWindow->RemoveFromSnappingList(WindowId(), otherSnap,
|
||||
thisSnap);
|
||||
}
|
||||
}
|
||||
free(id);
|
||||
}
|
||||
@@ -4134,5 +4138,3 @@ Window::UpdateSession::AddCause(uint8 cause)
|
||||
{
|
||||
fCause |= cause;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+34
-31
@@ -50,6 +50,7 @@ enum SnapOrientation {
|
||||
SNAP_LEFT, SNAP_RIGHT, SNAP_TOP, SNAP_BOTTOM
|
||||
};
|
||||
|
||||
|
||||
class Window {
|
||||
public:
|
||||
Window(const BRect& frame, const char *name,
|
||||
@@ -333,6 +334,39 @@ protected:
|
||||
void _AlterDeltaForSnap(BPoint& delta,
|
||||
bigtime_t now);
|
||||
|
||||
// Stack & Tile specific members
|
||||
void _InitStackingAndSnapping();
|
||||
void _RemoveStackingAndSnapping();
|
||||
|
||||
void _CheckIfReadyToStack();
|
||||
void _StackWindow();
|
||||
void _ArrangeStackedWindowTabs();
|
||||
|
||||
void _CheckIfReadyToSnap();
|
||||
void _SnapWindow();
|
||||
BRect _BoundingRectAndWindows(BList* windows,
|
||||
Window** leftmostWindow,
|
||||
Window** topmostWindow,
|
||||
Window** rightmostWindow,
|
||||
Window** bottommostWindow);
|
||||
|
||||
void _BoundWindowByWorkspace();
|
||||
void _UnboundWindowByWorkspace();
|
||||
|
||||
void _RemoveStackingPersistently();
|
||||
void _RemoveSnappingPersistently();
|
||||
|
||||
void _FreeUpSnappingList(SnapOrientation thisSnap,
|
||||
SnapOrientation otherSnap,
|
||||
bool deleteFromOtherWindowsList);
|
||||
BList** _GetSnappingListRef(
|
||||
SnapOrientation thisSnapOrientation,
|
||||
SnapOrientation otherSnapOrientation,
|
||||
bool createIfNull);
|
||||
|
||||
void _EnsureWindowWithinScreenBounds(Window* window, Window* detached);
|
||||
|
||||
protected:
|
||||
BString fTitle;
|
||||
// TODO: no fp rects anywhere
|
||||
BRect fFrame;
|
||||
@@ -454,37 +488,6 @@ protected:
|
||||
int32 fWorkspacesViewCount;
|
||||
|
||||
// Stack & Tile specific members
|
||||
void _InitStackingAndSnapping();
|
||||
void _RemoveStackingAndSnapping();
|
||||
|
||||
void _CheckIfReadyToStack();
|
||||
void _StackWindow();
|
||||
void _ArrangeStackedWindowTabs();
|
||||
|
||||
void _CheckIfReadyToSnap();
|
||||
void _SnapWindow();
|
||||
BRect _BoundingRectAndWindows(BList* windows,
|
||||
Window** leftmostWindow,
|
||||
Window** topmostWindow,
|
||||
Window** rightmostWindow,
|
||||
Window** bottommostWindow);
|
||||
|
||||
void _BoundWindowByWorkspace();
|
||||
void _UnboundWindowByWorkspace();
|
||||
|
||||
void _RemoveStackingPersistently();
|
||||
void _RemoveSnappingPersistently();
|
||||
|
||||
void _FreeUpSnappingList(SnapOrientation thisSnap,
|
||||
SnapOrientation otherSnap,
|
||||
bool deleteFromOtherWindowsList);
|
||||
BList** _GetSnappingListRef(
|
||||
SnapOrientation thisSnapOrientation,
|
||||
SnapOrientation otherSnapOrientation,
|
||||
bool createIfNull);
|
||||
|
||||
void _EnsureWindowWithinScreenBounds(Window* window, Window* detached);
|
||||
|
||||
Variable* fLeftVar;
|
||||
Variable* fTopVar;
|
||||
Variable* fRightVar;
|
||||
|
||||
@@ -135,8 +135,7 @@ WorkspacesView::_WorkspaceAt(BPoint where, int32& index)
|
||||
|
||||
BRect
|
||||
WorkspacesView::_WindowFrame(const BRect& workspaceFrame,
|
||||
const BRect& screenFrame, const BRect& windowFrame,
|
||||
BPoint windowPosition)
|
||||
const BRect& screenFrame, const BRect& windowFrame, BPoint windowPosition)
|
||||
{
|
||||
BRect frame = windowFrame;
|
||||
frame.OffsetTo(windowPosition);
|
||||
@@ -568,7 +567,7 @@ WorkspacesView::MouseMoved(BMessage* message, BPoint where)
|
||||
if (fHasMoved) {
|
||||
Window()->Desktop()->MoveWindowBy(fSelectedWindow, left - leftTop.x,
|
||||
top - leftTop.y, fSelectedWorkspace);
|
||||
//TODO Re-apply stack & tile constraints so that any other windows
|
||||
// TODO: Re-apply stack & tile constraints so that any other windows
|
||||
// that are stacked/snapped against this window can be re-adjusted.
|
||||
// Must smartly call stack and tile after workspace shifting has
|
||||
// finalised. How?
|
||||
|
||||
Reference in New Issue
Block a user