* Implemented that pressing the window modifier plus double click will minimize

the window. This closes ticket #6429.
* Got rid of useless _Extract*() methods. Also removed the _ActionFor() variant
  that only took a message.
* Removed unused "invalidate" variable in MouseUp().
* Coding style cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37998 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2010-08-10 10:00:16 +00:00
parent 3d08ac9237
commit d45bbb649e
2 changed files with 51 additions and 84 deletions
+25 -55
View File
@@ -63,24 +63,24 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
if (decorator != NULL)
inBorderRegion = decorator->GetFootprint().Contains(where);
int32 modifiers = _ExtractModifiers(message);
bool windowModifier
= (fWindow->Flags() & B_NO_SERVER_SIDE_WINDOW_MODIFIERS) == 0
&& (modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY
| B_SHIFT_KEY)) == (B_COMMAND_KEY | B_CONTROL_KEY);
int32 modifiers = message->FindInt32("modifiers");
bool windowModifier = _IsWindowModifier(modifiers);
click_type action = CLICK_NONE;
if (windowModifier || inBorderRegion) {
// Click on the window border or we have the window modifier keys held
int32 buttons = _ExtractButtons(message);
int32 buttons = message->FindInt32("buttons");
if (inBorderRegion)
action = _ActionFor(message, buttons, modifiers);
else {
if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0)
action = CLICK_MOVE_TO_BACK;
else if ((fWindow->Flags() & B_NOT_MINIMIZABLE) == 0
&& message->FindInt32("clicks") == 2)
action = CLICK_MINIMIZE;
else if ((fWindow->Flags() & B_NOT_MOVABLE) == 0
&& decorator != NULL)
&& decorator != NULL)
action = CLICK_DRAG;
else {
// pass click on to the application
@@ -165,6 +165,9 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
engine->UnlockParallelAccess();
fWindow->RegionPool()->Recycle(visibleBorder);
} else if (fIsMinimizing) {
fWindow->ServerWindow()->NotifyQuitRequested();
return true;
}
if (action == CLICK_MOVE_TO_BACK) {
@@ -198,11 +201,10 @@ DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where)
{
Decorator* decorator = fWindow->Decorator();
bool invalidate = false;
// TODO: not used - can it be removed?
if (decorator != NULL) {
click_type action = _ActionFor(message);
int32 modifiers = message->FindInt32("modifiers");
int32 buttons = message->FindInt32("buttons");
click_type action = _ActionFor(message, buttons, modifiers);
// redraw decorator
BRegion* visibleBorder = fWindow->RegionPool()->GetRegion();
@@ -216,36 +218,26 @@ DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where)
if (fIsZooming) {
fIsZooming = false;
decorator->SetZoom(false);
if (action == CLICK_ZOOM) {
invalidate = true;
if (action == CLICK_ZOOM)
fWindow->ServerWindow()->NotifyZoom();
}
}
if (fIsClosing) {
fIsClosing = false;
decorator->SetClose(false);
if (action == CLICK_CLOSE) {
invalidate = true;
if (action == CLICK_CLOSE)
fWindow->ServerWindow()->NotifyQuitRequested();
}
}
if (fIsMinimizing) {
fIsMinimizing = false;
decorator->SetMinimize(false);
if (action == CLICK_MINIMIZE) {
invalidate = true;
if (action == CLICK_MINIMIZE || _IsWindowModifier(modifiers))
fWindow->ServerWindow()->NotifyMinimize(true);
}
}
engine->UnlockParallelAccess();
fWindow->RegionPool()->Recycle(visibleBorder);
int32 buttons;
if (message->FindInt32("buttons", &buttons) != B_OK)
buttons = 0;
// if the primary mouse button is released, stop
// dragging/resizing/sliding
if ((buttons & B_PRIMARY_MOUSE_BUTTON) == 0) {
@@ -311,7 +303,10 @@ DefaultWindowBehaviour::MouseMoved(BMessage *message, BPoint where, bool isFake)
engine->LockParallelAccess();
engine->ConstrainClippingRegion(visibleBorder);
click_type type = _ActionFor(message);
int32 buttons = message->FindInt32("buttons");
int32 modifiers = message->FindInt32("modifiers");
click_type type = _ActionFor(message, buttons, modifiers);
if (fIsZooming)
decorator->SetZoom(type == CLICK_ZOOM);
else if (fIsClosing)
@@ -399,37 +394,12 @@ DefaultWindowBehaviour::MouseMoved(BMessage *message, BPoint where, bool isFake)
}
int32
DefaultWindowBehaviour::_ExtractButtons(const BMessage* message) const
bool
DefaultWindowBehaviour::_IsWindowModifier(int32 modifiers) const
{
int32 buttons;
if (message->FindInt32("buttons", &buttons) == B_OK)
return buttons;
return 0;
}
int32
DefaultWindowBehaviour::_ExtractModifiers(const BMessage* message) const
{
int32 modifiers;
if (message->FindInt32("modifiers", &modifiers) == B_OK)
return modifiers;
return 0;
}
click_type
DefaultWindowBehaviour::_ActionFor(const BMessage* message) const
{
if (fWindow->Decorator() == NULL)
return CLICK_NONE;
int32 buttons = _ExtractButtons(message);
int32 modifiers = _ExtractModifiers(message);
return _ActionFor(message, buttons, modifiers);
return (fWindow->Flags() & B_NO_SERVER_SIDE_WINDOW_MODIFIERS) == 0
&& (modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY
| B_SHIFT_KEY)) == (B_COMMAND_KEY | B_CONTROL_KEY);
}
+26 -29
View File
@@ -25,39 +25,36 @@ class Window;
class DefaultWindowBehaviour : public WindowBehaviour {
public:
DefaultWindowBehaviour(Window* window);
virtual ~DefaultWindowBehaviour();
DefaultWindowBehaviour(Window* window);
virtual ~DefaultWindowBehaviour();
virtual bool MouseDown(BMessage* message, BPoint where);
virtual void MouseUp(BMessage* message, BPoint where);
virtual void MouseMoved(BMessage *message, BPoint where,
bool isFake);
virtual bool MouseDown(BMessage* message, BPoint where);
virtual void MouseUp(BMessage* message, BPoint where);
virtual void MouseMoved(BMessage *message, BPoint where,
bool isFake);
protected:
Window* fWindow;
Desktop* fDesktop;
bool fIsClosing : 1;
bool fIsMinimizing : 1;
bool fIsZooming : 1;
bool fIsSlidingTab : 1;
bool fActivateOnMouseUp : 1;
BPoint fLastMousePosition;
float fMouseMoveDistance;
bigtime_t fLastMoveTime;
bigtime_t fLastSnapTime;
private:
int32 _ExtractButtons(const BMessage* message) const;
int32 _ExtractModifiers(const BMessage* message) const;
click_type _ActionFor(const BMessage* message) const;
click_type _ActionFor(const BMessage* message, int32 buttons,
int32 modifiers) const;
bool _IsWindowModifier(int32 modifiers) const;
click_type _ActionFor(const BMessage* message,
int32 buttons, int32 modifiers) const;
void _AlterDeltaForSnap(BPoint& delta,
bigtime_t now);
void _AlterDeltaForSnap(BPoint& delta,
bigtime_t now);
protected:
Window* fWindow;
Desktop* fDesktop;
bool fIsClosing : 1;
bool fIsMinimizing : 1;
bool fIsZooming : 1;
bool fIsSlidingTab : 1;
bool fActivateOnMouseUp : 1;
BPoint fLastMousePosition;
float fMouseMoveDistance;
bigtime_t fLastMoveTime;
bigtime_t fLastSnapTime;
};
#endif
#endif // DEFAULT_WINDOW_BEHAVIOUR_H