A few changes to make this more robust.

I am able to get stuck in window management mode without ctrl+alt
held down somehow but it's not reproducable. These changes should
hopefully make this a bit more robust.
This commit is contained in:
John Scipione
2013-01-25 03:01:53 -05:00
parent ae883c5f15
commit 70171c2634
@@ -700,12 +700,12 @@ void
DefaultWindowBehaviour::ManageWindowState::EnterState(State* previousState) DefaultWindowBehaviour::ManageWindowState::EnterState(State* previousState)
{ {
// Update the mouse cursor // Update the mouse cursor
if ((fWindow->Flags() & B_NOT_MOVABLE) == 0) if ((fWindow->Flags() & B_NOT_MOVABLE) != 0)
fBehavior._SetMoveCursor(); fBehavior._SetNotAllowedCursor();
else if ((fWindow->Flags() & kAcceptKeyboardFocusFlag) != 0) else if ((fWindow->Flags() & kAcceptKeyboardFocusFlag) != 0)
fBehavior._ResetCursor(); fBehavior._ResetCursor();
else else
fBehavior._SetNotAllowedCursor(); fBehavior._SetMoveCursor();
_UpdateResizeArrows(fLastMousePosition); _UpdateResizeArrows(fLastMousePosition);
} }
@@ -747,15 +747,14 @@ DefaultWindowBehaviour::ManageWindowState::MouseMoved(BMessage* message,
BPoint where, bool isFake) BPoint where, bool isFake)
{ {
// Update the mouse cursor // Update the mouse cursor
if ((fDesktop->WindowAt(where)->Flags() & B_NOT_RESIZABLE) != 0 if ((fDesktop->WindowAt(where)->Flags() & B_NOT_MOVABLE) != 0
&& (message->FindInt32("buttons") & B_SECONDARY_MOUSE_BUTTON) != 0) { || ((fDesktop->WindowAt(where)->Flags() & B_NOT_RESIZABLE) != 0
&& (message->FindInt32("buttons") & B_SECONDARY_MOUSE_BUTTON) != 0)) {
fBehavior._SetNotAllowedCursor(); fBehavior._SetNotAllowedCursor();
} else if ((fDesktop->WindowAt(where)->Flags() & B_NOT_MOVABLE) == 0) } else if ((fWindow->Flags() & kAcceptKeyboardFocusFlag) != 0)
fBehavior._SetMoveCursor();
else if ((fWindow->Flags() & kAcceptKeyboardFocusFlag) != 0)
fBehavior._ResetCursor(); fBehavior._ResetCursor();
else else
fBehavior._SetNotAllowedCursor(); fBehavior._SetMoveCursor();
// If the cursor is still over our window, update the borders. // If the cursor is still over our window, update the borders.
// Otherwise leave the state. // Otherwise leave the state.
@@ -772,15 +771,13 @@ DefaultWindowBehaviour::ManageWindowState::ModifiersChanged(BPoint where,
int32 modifiers) int32 modifiers)
{ {
fBehavior.fLastModifiers = modifiers; fBehavior.fLastModifiers = modifiers;
if (!fBehavior._IsWindowModifier(modifiers)) { if ((fWindow->Flags() & B_NOT_RESIZABLE) == 0
if ((fWindow->Flags() & B_NOT_RESIZABLE) == 0 && fBehavior._IsControlModifier(modifiers)) {
&& fBehavior._IsControlModifier(modifiers)) { fBehavior._SetBorderResizeCursor(where);
fBehavior._SetBorderResizeCursor(where); } else
} else fBehavior._ResetCursor();
fBehavior._ResetCursor();
fBehavior._NextState(NULL); fBehavior._NextState(NULL);
}
} }
@@ -1043,12 +1040,12 @@ DefaultWindowBehaviour::MouseMoved(BMessage* message, BPoint where,
if (fState != NULL) { if (fState != NULL) {
fState->MouseMoved(message, where, isFake); fState->MouseMoved(message, where, isFake);
} else { } else {
int32 modifiers = message->FindInt32("modifiers"); fLastModifiers = message->FindInt32("modifiers");
if (_IsWindowModifier(modifiers)) { if (_IsWindowModifier(fLastModifiers)) {
// Enter the window management state. // Enter the window management state.
_NextState(new(std::nothrow) ManageWindowState(*this, where)); _NextState(new(std::nothrow) ManageWindowState(*this, where));
} else if ((fWindow->Flags() & B_NOT_RESIZABLE) == 0 } else if ((fWindow->Flags() & B_NOT_RESIZABLE) == 0
&& _IsControlModifier(modifiers)) { && _IsControlModifier(fLastModifiers)) {
_SetBorderResizeCursor(where); _SetBorderResizeCursor(where);
} else } else
_ResetCursor(); _ResetCursor();
@@ -1072,12 +1069,12 @@ DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where)
if (fState != NULL) if (fState != NULL)
fState->MouseUp(message, where); fState->MouseUp(message, where);
else { else {
int32 modifiers = message->FindInt32("modifiers"); fLastModifiers = message->FindInt32("modifiers");
if (_IsWindowModifier(modifiers)) { if (_IsWindowModifier(fLastModifiers)) {
// Enter the window management state. // Enter the window management state.
_NextState(new(std::nothrow) ManageWindowState(*this, where)); _NextState(new(std::nothrow) ManageWindowState(*this, where));
} else if ((fWindow->Flags() & B_NOT_RESIZABLE) == 0 } else if ((fWindow->Flags() & B_NOT_RESIZABLE) == 0
&& _IsControlModifier(modifiers)) { && _IsControlModifier(fLastModifiers)) {
_SetBorderResizeCursor(where); _SetBorderResizeCursor(where);
} else } else
_ResetCursor(); _ResetCursor();
@@ -1095,11 +1092,12 @@ DefaultWindowBehaviour::ModifiersChanged(int32 modifiers)
if (fState != NULL) { if (fState != NULL) {
fState->ModifiersChanged(where, modifiers); fState->ModifiersChanged(where, modifiers);
} else { } else {
if (_IsWindowModifier(modifiers)) { fLastModifiers = modifiers;
if (_IsWindowModifier(fLastModifiers)) {
// Enter the window management state. // Enter the window management state.
_NextState(new(std::nothrow) ManageWindowState(*this, where)); _NextState(new(std::nothrow) ManageWindowState(*this, where));
} else if ((fWindow->Flags() & B_NOT_RESIZABLE) == 0 } else if ((fWindow->Flags() & B_NOT_RESIZABLE) == 0
&& _IsControlModifier(modifiers)) { && _IsControlModifier(fLastModifiers)) {
_SetBorderResizeCursor(where); _SetBorderResizeCursor(where);
} else } else
_ResetCursor(); _ResetCursor();