* 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
+24 -54
View File
@@ -63,22 +63,22 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
if (decorator != NULL) if (decorator != NULL)
inBorderRegion = decorator->GetFootprint().Contains(where); inBorderRegion = decorator->GetFootprint().Contains(where);
int32 modifiers = _ExtractModifiers(message); int32 modifiers = message->FindInt32("modifiers");
bool windowModifier bool windowModifier = _IsWindowModifier(modifiers);
= (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);
click_type action = CLICK_NONE; click_type action = CLICK_NONE;
if (windowModifier || inBorderRegion) { if (windowModifier || inBorderRegion) {
// Click on the window border or we have the window modifier keys held // Click on the window border or we have the window modifier keys held
int32 buttons = _ExtractButtons(message); int32 buttons = message->FindInt32("buttons");
if (inBorderRegion) if (inBorderRegion)
action = _ActionFor(message, buttons, modifiers); action = _ActionFor(message, buttons, modifiers);
else { else {
if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0)
action = CLICK_MOVE_TO_BACK; 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 else if ((fWindow->Flags() & B_NOT_MOVABLE) == 0
&& decorator != NULL) && decorator != NULL)
action = CLICK_DRAG; action = CLICK_DRAG;
@@ -165,6 +165,9 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
engine->UnlockParallelAccess(); engine->UnlockParallelAccess();
fWindow->RegionPool()->Recycle(visibleBorder); fWindow->RegionPool()->Recycle(visibleBorder);
} else if (fIsMinimizing) {
fWindow->ServerWindow()->NotifyQuitRequested();
return true;
} }
if (action == CLICK_MOVE_TO_BACK) { if (action == CLICK_MOVE_TO_BACK) {
@@ -198,11 +201,10 @@ DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where)
{ {
Decorator* decorator = fWindow->Decorator(); Decorator* decorator = fWindow->Decorator();
bool invalidate = false;
// TODO: not used - can it be removed?
if (decorator != NULL) { 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 // redraw decorator
BRegion* visibleBorder = fWindow->RegionPool()->GetRegion(); BRegion* visibleBorder = fWindow->RegionPool()->GetRegion();
@@ -216,36 +218,26 @@ DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where)
if (fIsZooming) { if (fIsZooming) {
fIsZooming = false; fIsZooming = false;
decorator->SetZoom(false); decorator->SetZoom(false);
if (action == CLICK_ZOOM) { if (action == CLICK_ZOOM)
invalidate = true;
fWindow->ServerWindow()->NotifyZoom(); fWindow->ServerWindow()->NotifyZoom();
} }
}
if (fIsClosing) { if (fIsClosing) {
fIsClosing = false; fIsClosing = false;
decorator->SetClose(false); decorator->SetClose(false);
if (action == CLICK_CLOSE) { if (action == CLICK_CLOSE)
invalidate = true;
fWindow->ServerWindow()->NotifyQuitRequested(); fWindow->ServerWindow()->NotifyQuitRequested();
} }
}
if (fIsMinimizing) { if (fIsMinimizing) {
fIsMinimizing = false; fIsMinimizing = false;
decorator->SetMinimize(false); decorator->SetMinimize(false);
if (action == CLICK_MINIMIZE) { if (action == CLICK_MINIMIZE || _IsWindowModifier(modifiers))
invalidate = true;
fWindow->ServerWindow()->NotifyMinimize(true); fWindow->ServerWindow()->NotifyMinimize(true);
} }
}
engine->UnlockParallelAccess(); engine->UnlockParallelAccess();
fWindow->RegionPool()->Recycle(visibleBorder); fWindow->RegionPool()->Recycle(visibleBorder);
int32 buttons;
if (message->FindInt32("buttons", &buttons) != B_OK)
buttons = 0;
// if the primary mouse button is released, stop // if the primary mouse button is released, stop
// dragging/resizing/sliding // dragging/resizing/sliding
if ((buttons & B_PRIMARY_MOUSE_BUTTON) == 0) { if ((buttons & B_PRIMARY_MOUSE_BUTTON) == 0) {
@@ -311,7 +303,10 @@ DefaultWindowBehaviour::MouseMoved(BMessage *message, BPoint where, bool isFake)
engine->LockParallelAccess(); engine->LockParallelAccess();
engine->ConstrainClippingRegion(visibleBorder); 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) if (fIsZooming)
decorator->SetZoom(type == CLICK_ZOOM); decorator->SetZoom(type == CLICK_ZOOM);
else if (fIsClosing) else if (fIsClosing)
@@ -399,37 +394,12 @@ DefaultWindowBehaviour::MouseMoved(BMessage *message, BPoint where, bool isFake)
} }
int32 bool
DefaultWindowBehaviour::_ExtractButtons(const BMessage* message) const DefaultWindowBehaviour::_IsWindowModifier(int32 modifiers) const
{ {
int32 buttons; return (fWindow->Flags() & B_NO_SERVER_SIDE_WINDOW_MODIFIERS) == 0
if (message->FindInt32("buttons", &buttons) == B_OK) && (modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY
return buttons; | B_SHIFT_KEY)) == (B_COMMAND_KEY | B_CONTROL_KEY);
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);
} }
+8 -11
View File
@@ -33,6 +33,13 @@ public:
virtual void MouseMoved(BMessage *message, BPoint where, virtual void MouseMoved(BMessage *message, BPoint where,
bool isFake); bool isFake);
private:
bool _IsWindowModifier(int32 modifiers) const;
click_type _ActionFor(const BMessage* message,
int32 buttons, int32 modifiers) const;
void _AlterDeltaForSnap(BPoint& delta,
bigtime_t now);
protected: protected:
Window* fWindow; Window* fWindow;
Desktop* fDesktop; Desktop* fDesktop;
@@ -47,17 +54,7 @@ protected:
float fMouseMoveDistance; float fMouseMoveDistance;
bigtime_t fLastMoveTime; bigtime_t fLastMoveTime;
bigtime_t fLastSnapTime; 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;
void _AlterDeltaForSnap(BPoint& delta,
bigtime_t now);
}; };
#endif #endif // DEFAULT_WINDOW_BEHAVIOUR_H