* Decorator: Replaced the MouseAction() method with a new RegionAt().

RegionAt() just gets a point and returns which region was hit. This is in
  order to move behavioral code to [Default]WindowBehaviour. I'm not happy
  with this solution either, but to do it properly one would have to break the
  Decorator interface into separate look and feel interfaces and reorganize the
  interaction with WindowBehaviour. A task for the so-inclined reader. :-)
* Adjusted the Decorators implementations, but really tested only the default
  one.
* DefaultWindowBehaviour:
  - Replaced _ActionFor() method by a _RegionFor() which interprets the region
    returned by Decorator::RegionAt() and converts it to a "functional" region,
    i.e. combines cases we handle the same way.
  - MouseDown():
    - Handle the click region cases more in detail, disentangling the mouse
      button cases. With the following effects:
      - The middle mouse button has no effect anymore.
      - Left and right mouse buttons no longer share common behavior. A right
        click on a decorator button will send the window to the back.
    - The window key window management modifier combo does now have precedence,
      i.e. Cmd-Ctrl-click on the decorator buttons will have the same effect as
      clicking anywhere in the window.
    - When modifiers change between the clicks, reset the click count. Prevents
      a standard click in the window followed by a Cmd-Ctrl-click from being
      recognized as a double-click.
  - Mouse*(): Introduced a fMinimizeCheckOnMouseUp which works similar to
    fActivateOnMouseUp, just for double-clicks. The decision whether a
    double-click minimizes the window is postponed until releasing the mouse
    button. After moving the mouse sufficiently far or waiting half a second
    without moving the mouse the window will no longer be minimized. Fixes
    #6868.
  - MouseUp(): Moved the primary mouse button check without the
    "decorator != NULL" block. I suppose this fixes issues with the Cmd-Ctrl
    actions and decoratorless windows (if those actually exist).

I can't wait to hear what things I've broken. :-)


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39602 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2010-11-24 02:09:50 +00:00
parent 1e6e9d99cf
commit 89d652d5e0
12 changed files with 419 additions and 340 deletions
@@ -89,7 +89,7 @@ BeDecorAddOn::BeDecorAddOn(image_id id, const char* name)
: :
DecorAddOn(id, name) DecorAddOn(id, name)
{ {
} }
@@ -214,76 +214,47 @@ BeDecorator::GetSizeLimits(int32* minWidth, int32* minHeight,
} }
click_type Decorator::Region
BeDecorator::MouseAction(const BMessage* message, BPoint point, int32 buttons, BeDecorator::RegionAt(BPoint where) const
int32 modifiers)
{ {
#ifdef DEBUG_DECORATOR // Let the base class version identify hits of the buttons and the tab.
printf("BeDecorator: Clicked\n"); Region region = Decorator::RegionAt(where);
printf("\tPoint: (%.1f,%.1f)\n", point.x, point.y); if (region != REGION_NONE)
printf("\tButtons: %ld, Modifiers: 0x%lx\n", buttons, modifiers); return region;
#endif // DEBUG_DECORATOR
if (buttons != 0) // check the resize corner
fWasDoubleClick = message->FindInt32("clicks") == 2; if (fLook == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(where))
return REGION_RIGHT_BOTTOM_CORNER;
// In checking for hit test stuff, we start with the smallest rectangles // hit-test the borders
// the user might be clicking on and gradually work our way out into larger if (fLeftBorder.Contains(where))
// rectangles. return REGION_LEFT_BORDER;
if (!(fFlags & B_NOT_CLOSABLE) && fCloseRect.Contains(point)) if (fTopBorder.Contains(where))
return CLICK_CLOSE; return REGION_TOP_BORDER;
if (!(fFlags & B_NOT_ZOOMABLE) && fZoomRect.Contains(point)) // Part of the bottom and right borders may be a resize-region, so we have
return CLICK_ZOOM; // to check explicitly, if it has been it.
if (fRightBorder.Contains(where))
region = REGION_RIGHT_BORDER;
else if (fBottomBorder.Contains(where))
region = REGION_BOTTOM_BORDER;
else
return REGION_NONE;
if (fLook == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(point)) // check resize area
return CLICK_RESIZE; if ((fFlags & B_NOT_RESIZABLE) == 0
&& (fLook == B_TITLED_WINDOW_LOOK
bool clicked = false; || fLook == B_FLOATING_WINDOW_LOOK
|| fLook == B_MODAL_WINDOW_LOOK
// Clicking in the tab? || fLook == kLeftTitledWindowLook)) {
if (fTabRect.Contains(point)) { BRect resizeRect(BPoint(fBottomBorder.right - kBorderResizeLength,
// tab sliding in any case if either shift key is held down fBottomBorder.bottom - kBorderResizeLength),
// except sliding up-down by moving mouse left-right would look strange fBottomBorder.RightBottom());
if ((modifiers & B_SHIFT_KEY) && (fLook != kLeftTitledWindowLook)) if (resizeRect.Contains(where))
return CLICK_SLIDE_TAB; return REGION_RIGHT_BOTTOM_CORNER;
clicked = true;
} else if (fLeftBorder.Contains(point) || fRightBorder.Contains(point)
|| fTopBorder.Contains(point) || fBottomBorder.Contains(point)) {
// Clicked on border
// check resize area
if (!(fFlags & B_NOT_RESIZABLE)
&& (fLook == B_TITLED_WINDOW_LOOK
|| fLook == B_FLOATING_WINDOW_LOOK
|| fLook == B_MODAL_WINDOW_LOOK
|| fLook == kLeftTitledWindowLook)) {
BRect resizeRect(BPoint(fBottomBorder.right - kBorderResizeLength,
fBottomBorder.bottom - kBorderResizeLength),
fBottomBorder.RightBottom());
if (resizeRect.Contains(point))
return CLICK_RESIZE;
}
clicked = true;
} }
if (clicked) { return region;
// NOTE: On R5, windows are not moved to back if clicked inside the
// resize area with the second mouse button. So we check this after
// the check above
if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0)
return CLICK_MOVE_TO_BACK;
if (fWasDoubleClick && !(fFlags & B_NOT_MINIMIZABLE))
return CLICK_MINIMIZE;
return CLICK_DRAG;
}
// Guess user didn't click anything
return CLICK_NONE;
} }
@@ -34,7 +34,7 @@ MacDecorAddOn::MacDecorAddOn(image_id id, const char* name)
: :
DecorAddOn(id, name) DecorAddOn(id, name)
{ {
} }
@@ -64,7 +64,7 @@ MacDecorator::MacDecorator(DesktopSettings& settings, BRect rect,
frame_midcol = (rgb_color){ 216, 216, 216, 255 }; frame_midcol = (rgb_color){ 216, 216, 216, 255 };
frame_lowcol = (rgb_color){ 110, 110, 110, 255 }; frame_lowcol = (rgb_color){ 110, 110, 110, 255 };
frame_lowercol = (rgb_color){ 0, 0, 0, 255 }; frame_lowercol = (rgb_color){ 0, 0, 0, 255 };
fButtonHighColor = (rgb_color){ 232, 232, 232, 255 }; fButtonHighColor = (rgb_color){ 232, 232, 232, 255 };
fButtonLowColor = (rgb_color){ 128, 128, 128, 255 }; fButtonLowColor = (rgb_color){ 128, 128, 128, 255 };
@@ -72,7 +72,7 @@ MacDecorator::MacDecorator(DesktopSettings& settings, BRect rect,
fNonFocusTextColor = settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR); fNonFocusTextColor = settings.UIColor(B_WINDOW_INACTIVE_TEXT_COLOR);
_DoLayout(); _DoLayout();
textoffset=5; textoffset=5;
STRACE(("MacDecorator()\n")); STRACE(("MacDecorator()\n"));
@@ -117,43 +117,29 @@ MacDecorator::Draw()
// TODO : add GetSizeLimits // TODO : add GetSizeLimits
click_type Decorator::Region
MacDecorator::MouseAction(const BMessage* message, BPoint point, int32 buttons, MacDecorator::RegionAt(BPoint where) const
int32 modifiers)
{ {
if (!(fFlags & B_NOT_CLOSABLE) && fCloseRect.Contains(point)) { // Let the base class version identify hits of the buttons and the tab.
STRACE(("MacDecorator():Clicked() - Close\n")); Region region = Decorator::RegionAt(where);
return CLICK_CLOSE; if (region != REGION_NONE)
} return region;
if (!(fFlags & B_NOT_ZOOMABLE) && fZoomRect.Contains(point)) { // check the resize corner
STRACE(("MacDecorator():Clicked() - Zoom\n")); if (fLook == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(where))
return CLICK_ZOOM; return REGION_RIGHT_BOTTOM_CORNER;
}
// Clicking in the tab?
if (fTabRect.Contains(point)) {
// Here's part of our window management stuff
/* TODO: This is missing CLICK_MOVETOFRONT
if(buttons == B_PRIMARY_MOUSE_BUTTON && !IsFocus())
return CLICK_MOVETOFRONT;
*/
return CLICK_DRAG;
}
// We got this far, so user is clicking on the border? // hit-test the borders
if (!(fFlags & B_NOT_RESIZABLE) if (!(fFlags & B_NOT_RESIZABLE)
&& (fLook == B_TITLED_WINDOW_LOOK && (fLook == B_TITLED_WINDOW_LOOK
|| fLook == B_FLOATING_WINDOW_LOOK || fLook == B_FLOATING_WINDOW_LOOK
|| fLook == B_MODAL_WINDOW_LOOK) || fLook == B_MODAL_WINDOW_LOOK)
&& fBorderRect.Contains(point) && !fFrame.Contains(point)) { && fBorderRect.Contains(where) && !fFrame.Contains(where)) {
STRACE(("MacDecorator():Clicked() - Resize\n")); return REGION_BOTTOM_BORDER;
return CLICK_RESIZE; // TODO: Determine the actual border!
} }
// Guess user didn't click anything return REGION_NONE;
STRACE(("MacDecorator():Clicked()\n"));
return CLICK_NONE;
} }
@@ -215,7 +201,7 @@ MacDecorator::_DoLayout()
fMinimizeRect=fZoomRect; fMinimizeRect=fZoomRect;
fCloseRect.OffsetTo(fTabRect.left+4,fTabRect.top+4); fCloseRect.OffsetTo(fTabRect.left+4,fTabRect.top+4);
fZoomRect.OffsetBy(0-(fZoomRect.Width()+4),0); fZoomRect.OffsetBy(0-(fZoomRect.Width()+4),0);
if (Title() && fDrawingEngine) { if (Title() && fDrawingEngine) {
titlepixelwidth=fDrawingEngine->StringWidth(Title(),strlen(Title())); titlepixelwidth=fDrawingEngine->StringWidth(Title(),strlen(Title()));
@@ -468,7 +454,7 @@ MacDecorator::_DrawTab(BRect invalid)
} }
} }
// Draw the buttons if we're supposed to // Draw the buttons if we're supposed to
if (!(fFlags & B_NOT_CLOSABLE)) if (!(fFlags & B_NOT_CLOSABLE))
_DrawClose(fCloseRect); _DrawClose(fCloseRect);
if (!(fFlags & B_NOT_ZOOMABLE)) if (!(fFlags & B_NOT_ZOOMABLE))
@@ -776,7 +762,7 @@ MacDecorator::_GetFootprint(BRegion* region)
if (fLook == B_NO_BORDER_WINDOW_LOOK) if (fLook == B_NO_BORDER_WINDOW_LOOK)
return; return;
region->Set(fBorderRect); region->Set(fBorderRect);
region->Exclude(fFrame); region->Exclude(fFrame);
@@ -32,9 +32,7 @@ public:
void Draw(BRect updateRect); void Draw(BRect updateRect);
void Draw(); void Draw();
click_type MouseAction(const BMessage* message, virtual Region RegionAt(BPoint where) const;
BPoint point, int32 buttons,
int32 modifiers);
protected: protected:
void _DoLayout(); void _DoLayout();
@@ -57,7 +55,7 @@ protected:
BRegion* updateRegion = NULL); BRegion* updateRegion = NULL);
void _SetFlags(uint32 flags, void _SetFlags(uint32 flags,
BRegion* updateRegion = NULL); BRegion* updateRegion = NULL);
void _SetColors(); void _SetColors();
void _MoveBy(BPoint offset); void _MoveBy(BPoint offset);
@@ -140,12 +140,22 @@ StackAndTile::MouseDown(Window* window, BMessage* message, const BPoint& where)
// we are only interested in single clicks // we are only interested in single clicks
if (message->FindInt32("clicks") == 2) if (message->FindInt32("clicks") == 2)
return; return;
int32 modifiers = message->FindInt32("modifiers");
int32 buttons = message->FindInt32("buttons"); switch (satWindow->GetDecorator()->RegionAt(where)) {
click_type clickArea = satWindow->GetDecorator()->MouseAction(message, case Decorator::REGION_TAB:
where, buttons, modifiers); case Decorator::REGION_LEFT_BORDER:
if (clickArea != CLICK_DRAG && clickArea < CLICK_RESIZE) case Decorator::REGION_RIGHT_BORDER:
return; case Decorator::REGION_TOP_BORDER:
case Decorator::REGION_BOTTOM_BORDER:
case Decorator::REGION_LEFT_TOP_CORNER:
case Decorator::REGION_LEFT_BOTTOM_CORNER:
case Decorator::REGION_RIGHT_TOP_CORNER:
case Decorator::REGION_RIGHT_BOTTOM_CORNER:
break;
default:
return;
}
ASSERT(fCurrentSATWindow == NULL); ASSERT(fCurrentSATWindow == NULL);
fCurrentSATWindow = satWindow; fCurrentSATWindow = satWindow;
@@ -330,7 +340,7 @@ StackAndTile::WindowLookChanged(Window* window, window_look look)
SATGroup* group = satWindow->GetGroup(); SATGroup* group = satWindow->GetGroup();
if (!group) if (!group)
return; return;
group->RemoveWindow(satWindow); group->RemoveWindow(satWindow);
} }
@@ -617,5 +627,5 @@ WindowIterator::_ReverseRewind()
SATSnappingBehaviour::~SATSnappingBehaviour() SATSnappingBehaviour::~SATSnappingBehaviour()
{ {
} }
@@ -77,7 +77,7 @@ WinDecorator::WinDecorator(DesktopSettings& settings, BRect rect,
// Do initial decorator setup // Do initial decorator setup
_DoLayout(); _DoLayout();
textoffset=5; textoffset=5;
STRACE(("WinDecorator()\n")); STRACE(("WinDecorator()\n"));
@@ -119,40 +119,29 @@ WinDecorator::Draw()
// TODO : add GetSizeLimits // TODO : add GetSizeLimits
click_type Decorator::Region
WinDecorator::MouseAction(const BMessage* message, BPoint where, int32 buttons, WinDecorator::RegionAt(BPoint where) const
int32 modifiers)
{ {
if (!(fFlags & B_NOT_CLOSABLE) && fCloseRect.Contains(where)) // Let the base class version identify hits of the buttons and the tab.
return CLICK_CLOSE; Region region = Decorator::RegionAt(where);
if (region != REGION_NONE)
return region;
if (!(fFlags & B_NOT_ZOOMABLE) && fZoomRect.Contains(where)) // check the resize corner
return CLICK_ZOOM; if (fLook == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(where))
return REGION_RIGHT_BOTTOM_CORNER;
// Clicking in the tab?
if (fTabRect.Contains(where)) { // hit-test the borders
// Here's part of our window management stuff if (!(fFlags & B_NOT_RESIZABLE)
/* TODO: This is missing CLICK_MOVETOFRONT && (fLook == B_TITLED_WINDOW_LOOK
if(buttons == B_PRIMARY_MOUSE_BUTTON && !IsFocus()) || fLook == B_FLOATING_WINDOW_LOOK
return CLICK_MOVETOFRONT; || fLook == B_MODAL_WINDOW_LOOK)
*/ && fBorderRect.Contains(where) && !fFrame.Contains(where)) {
return CLICK_DRAG; return REGION_BOTTOM_BORDER;
// TODO: Determine the actual border!
} }
// We got this far, so user is clicking on the border? return REGION_NONE;
if (fBorderRect.Contains(where) && !fFrame.Contains(where)) {
STRACE(("WinDecorator():Clicked() - Resize\n"));
if (!(fFlags & B_NOT_RESIZABLE)
&& (fLook == B_TITLED_WINDOW_LOOK
|| fLook == B_FLOATING_WINDOW_LOOK
|| fLook == B_MODAL_WINDOW_LOOK)) {
return CLICK_RESIZE;
}
}
// Guess user didn't click anything
STRACE(("WinDecorator():Clicked()\n"));
return CLICK_NONE;
} }
@@ -162,7 +151,7 @@ WinDecorator::_DoLayout()
STRACE(("WinDecorator()::_DoLayout()\n")); STRACE(("WinDecorator()::_DoLayout()\n"));
bool hasTab = false; bool hasTab = false;
fBorderRect=fFrame; fBorderRect=fFrame;
fTabRect=fFrame; fTabRect=fFrame;
@@ -224,13 +213,13 @@ WinDecorator::_DrawFrame(BRect rect)
return; return;
BRect r = fBorderRect; BRect r = fBorderRect;
fDrawingEngine->SetHighColor(frame_lowercol); fDrawingEngine->SetHighColor(frame_lowercol);
fDrawingEngine->StrokeRect(r); fDrawingEngine->StrokeRect(r);
if (fLook == B_BORDERED_WINDOW_LOOK) if (fLook == B_BORDERED_WINDOW_LOOK)
return; return;
BPoint pt; BPoint pt;
pt=r.RightTop(); pt=r.RightTop();
@@ -242,7 +231,7 @@ WinDecorator::_DrawFrame(BRect rect)
fDrawingEngine->StrokeLine(r.RightTop(),r.RightBottom(),frame_lowercol); fDrawingEngine->StrokeLine(r.RightTop(),r.RightBottom(),frame_lowercol);
fDrawingEngine->StrokeLine(r.LeftBottom(),r.RightBottom(),frame_lowercol); fDrawingEngine->StrokeLine(r.LeftBottom(),r.RightBottom(),frame_lowercol);
r.InsetBy(1,1); r.InsetBy(1,1);
pt=r.RightTop(); pt=r.RightTop();
pt.x--; pt.x--;
@@ -253,7 +242,7 @@ WinDecorator::_DrawFrame(BRect rect)
fDrawingEngine->StrokeLine(r.RightTop(),r.RightBottom(),frame_lowcol); fDrawingEngine->StrokeLine(r.RightTop(),r.RightBottom(),frame_lowcol);
fDrawingEngine->StrokeLine(r.LeftBottom(),r.RightBottom(),frame_lowcol); fDrawingEngine->StrokeLine(r.LeftBottom(),r.RightBottom(),frame_lowcol);
r.InsetBy(1,1); r.InsetBy(1,1);
fDrawingEngine->StrokeRect(r,frame_midcol); fDrawingEngine->StrokeRect(r,frame_midcol);
r.InsetBy(1,1); r.InsetBy(1,1);
@@ -273,7 +262,7 @@ WinDecorator::_DrawTab(BRect invalid)
_DrawTitle(fTabRect); _DrawTitle(fTabRect);
// Draw the buttons if we're supposed to // Draw the buttons if we're supposed to
// TODO : we should still draw the buttons if they are disabled, but grey them out // TODO : we should still draw the buttons if they are disabled, but grey them out
if (!(fFlags & B_NOT_CLOSABLE) && invalid.Intersects(fCloseRect)) if (!(fFlags & B_NOT_CLOSABLE) && invalid.Intersects(fCloseRect))
_DrawClose(fCloseRect); _DrawClose(fCloseRect);
@@ -287,14 +276,14 @@ WinDecorator::_DrawClose(BRect r)
{ {
// Just like DrawZoom, but for a close button // Just like DrawZoom, but for a close button
_DrawBeveledRect(r,GetClose()); _DrawBeveledRect(r,GetClose());
// Draw the X // Draw the X
BRect rect(r); BRect rect(r);
rect.InsetBy(4,4); rect.InsetBy(4,4);
rect.right--; rect.right--;
rect.top--; rect.top--;
if (GetClose()) if (GetClose())
rect.OffsetBy(1,1); rect.OffsetBy(1,1);
@@ -333,7 +322,7 @@ void
WinDecorator::_DrawZoom(BRect r) WinDecorator::_DrawZoom(BRect r)
{ {
_DrawBeveledRect(r,GetZoom()); _DrawBeveledRect(r,GetZoom());
// Draw the Zoom box // Draw the Zoom box
BRect rect(r); BRect rect(r);
@@ -341,7 +330,7 @@ WinDecorator::_DrawZoom(BRect r)
rect.InsetBy(1,0); rect.InsetBy(1,0);
rect.bottom--; rect.bottom--;
rect.right--; rect.right--;
if (GetZoom()) if (GetZoom())
rect.OffsetBy(1,1); rect.OffsetBy(1,1);
@@ -363,7 +352,7 @@ WinDecorator::_DrawMinimize(BRect r)
BRect rect(r.left+5,r.bottom-4,r.right-5,r.bottom-3); BRect rect(r.left+5,r.bottom-4,r.right-5,r.bottom-3);
if(GetMinimize()) if(GetMinimize())
rect.OffsetBy(1,1); rect.OffsetBy(1,1);
fDrawingEngine->SetHighColor(RGBColor(0,0,0)); fDrawingEngine->SetHighColor(RGBColor(0,0,0));
fDrawingEngine->StrokeRect(rect); fDrawingEngine->StrokeRect(rect);
} }
@@ -523,7 +512,7 @@ WinDecorator::_GetFootprint(BRegion* region)
if (fLook == B_NO_BORDER_WINDOW_LOOK) if (fLook == B_NO_BORDER_WINDOW_LOOK)
return; return;
region->Set(fBorderRect); region->Set(fBorderRect);
region->Include(fTabRect); region->Include(fTabRect);
region->Exclude(fFrame); region->Exclude(fFrame);
@@ -553,7 +542,7 @@ WinDecorator::_DrawBeveledRect(BRect r, bool down)
RGBColor mid; RGBColor mid;
RGBColor low; RGBColor low;
RGBColor lower; RGBColor lower;
if (down) { if (down) {
lower.SetColor(255,255,255); lower.SetColor(255,255,255);
low.SetColor(216,216,216); low.SetColor(216,216,216);
@@ -582,7 +571,7 @@ WinDecorator::_DrawBeveledRect(BRect r, bool down)
pt=rect.RightTop(); pt=rect.RightTop();
pt.y++; pt.y++;
fDrawingEngine->StrokeLine(pt,rect.RightBottom(),lower); fDrawingEngine->StrokeLine(pt,rect.RightBottom(),lower);
// Bottom shading // Bottom shading
pt=rect.LeftBottom(); pt=rect.LeftBottom();
pt.x++; pt.x++;
@@ -600,12 +589,12 @@ WinDecorator::_DrawBeveledRect(BRect r, bool down)
pt=rect.RightTop(); pt=rect.RightTop();
pt.y++; pt.y++;
fDrawingEngine->StrokeLine(pt,rect.RightBottom(),lower); fDrawingEngine->StrokeLine(pt,rect.RightBottom(),lower);
// Bottom inside shading // Bottom inside shading
pt=rect.LeftBottom(); pt=rect.LeftBottom();
pt.x++; pt.x++;
fDrawingEngine->StrokeLine(pt,rect.RightBottom(),lower); fDrawingEngine->StrokeLine(pt,rect.RightBottom(),lower);
rect.InsetBy(1,1); rect.InsetBy(1,1);
fDrawingEngine->FillRect(rect,mid); fDrawingEngine->FillRect(rect,mid);
@@ -32,9 +32,7 @@ public:
void Draw(BRect r); void Draw(BRect r);
void Draw(); void Draw();
click_type MouseAction(const BMessage* message, virtual Region RegionAt(BPoint where) const;
BPoint point, int32 buttons,
int32 modifiers);
protected: protected:
void _DoLayout(); void _DoLayout();
@@ -57,7 +55,7 @@ protected:
BRegion* updateRegion = NULL); BRegion* updateRegion = NULL);
void _SetFlags(uint32 flags, void _SetFlags(uint32 flags,
BRegion* updateRegion = NULL); BRegion* updateRegion = NULL);
void _SetColors(); void _SetColors();
void _MoveBy(BPoint pt); void _MoveBy(BPoint pt);
@@ -72,7 +70,7 @@ private:
private: private:
uint32 taboffset; uint32 taboffset;
rgb_color tab_highcol; rgb_color tab_highcol;
rgb_color tab_lowcol; rgb_color tab_lowcol;
rgb_color frame_highcol; rgb_color frame_highcol;
@@ -85,10 +83,10 @@ private:
rgb_color fFocusTextColor; rgb_color fFocusTextColor;
rgb_color fNonFocusTextColor; rgb_color fNonFocusTextColor;
uint64 solidhigh, solidlow; uint64 solidhigh, solidlow;
BString fTruncatedTitle; BString fTruncatedTitle;
int32 fTruncatedTitleLength; int32 fTruncatedTitleLength;
bool slidetab; bool slidetab;
int textoffset; int textoffset;
}; };
+30 -34
View File
@@ -6,6 +6,7 @@
* DarkWyrm <bpmagic@columbus.rr.com> * DarkWyrm <bpmagic@columbus.rr.com>
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
* Clemens Zeidler <haiku@clemens-zeidler.de> * Clemens Zeidler <haiku@clemens-zeidler.de>
* Ingo Weinhold <ingo_weinhold@gmx.de>
*/ */
@@ -314,44 +315,39 @@ Decorator::GetFootprint()
} }
/*! \brief Performs hit-testing for the decorator /*! \brief Performs hit-testing for the decorator.
Clicked is called whenever it has been determined that the window has The base class provides a basic implementation, recognizing only button and
received a mouse click. The default version returns CLICK_NONE. A subclass tab hits. Derived classes must override/enhance it to handle borders and
may use any or all of them. corners correctly.
Click type : Action taken by the server \param where The point to be tested.
\return Either of the following, depending on what was hit:
- \c CLICK_NONE: Do nothing - \c REGION_NONE: None of the decorator regions.
- \c CLICK_ZOOM: Handles the zoom button (setting states, etc) - \c REGION_TAB: The window tab (but none of the buttons embedded).
- \c CLICK_CLOSE: Handles the close button (setting states, etc) - \c REGION_CLOSE_BUTTON: The close button.
- \c CLICK_MINIMIZE: Handles the minimize button (setting states, etc) - \c REGION_ZOOM_BUTTON: The zoom button.
- \c CLICK_TAB: Currently unused - \c REGION_MINIMIZE_BUTTON: The minimize button.
- \c CLICK_DRAG: Moves the window to the front and prepares to move the - \c REGION_LEFT_BORDER: The left border.
window - \c REGION_RIGHT_BORDER: The right border.
- \c CLICK_MOVE_TO_BACK: Moves the window to the back of the stack - \c REGION_TOP_BORDER: The top border.
- \c CLICK_MOVE_TO_FRONT: Moves the window to the front of the stack - \c REGION_BOTTOM_BORDER: The bottom border.
- \c CLICK_SLIDE_TAB: Initiates tab-sliding - \c REGION_LEFT_TOP_CORNER: The left-top corner.
- \c REGION_LEFT_BOTTOM_CORNER: The left-bottom corner.
- \c CLICK_RESIZE: Handle window resizing as appropriate - \c REGION_RIGHT_TOP_CORNER: The right-top corner.
- \c CLICK_RESIZE_L - \c REGION_RIGHT_BOTTOM_CORNER The right-bottom corner.
- \c CLICK_RESIZE_T
- \c CLICK_RESIZE_R
- \c CLICK_RESIZE_B
- \c CLICK_RESIZE_LT
- \c CLICK_RESIZE_RT
- \c CLICK_RESIZE_LB
- \c CLICK_RESIZE_RB
This function is required by all subclasses.
\return The type of area clicked
*/ */
click_type Decorator::Region
Decorator::MouseAction(const BMessage* message, BPoint point, int32 buttons, Decorator::RegionAt(BPoint where) const
int32 modifiers)
{ {
return CLICK_NONE; if (fCloseRect.Contains(where))
return REGION_CLOSE_BUTTON;
if (fZoomRect.Contains(where))
return REGION_ZOOM_BUTTON;
if (fTabRect.Contains(where))
return REGION_TAB;
return REGION_NONE;
} }
+23 -2
View File
@@ -6,6 +6,7 @@
* DarkWyrm <bpmagic@columbus.rr.com> * DarkWyrm <bpmagic@columbus.rr.com>
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
* Clemens Zeidler <haiku@clemens-zeidler.de> * Clemens Zeidler <haiku@clemens-zeidler.de>
* Ingo Weinhold <ingo_weinhold@gmx.de>
*/ */
#ifndef DECORATOR_H #ifndef DECORATOR_H
#define DECORATOR_H #define DECORATOR_H
@@ -47,6 +48,27 @@ enum click_type {
class Decorator { class Decorator {
public:
enum Region {
REGION_NONE,
REGION_TAB,
REGION_CLOSE_BUTTON,
REGION_ZOOM_BUTTON,
REGION_MINIMIZE_BUTTON,
REGION_LEFT_BORDER,
REGION_RIGHT_BORDER,
REGION_TOP_BORDER,
REGION_BOTTOM_BORDER,
REGION_LEFT_TOP_CORNER,
REGION_LEFT_BOTTOM_CORNER,
REGION_RIGHT_TOP_CORNER,
REGION_RIGHT_BOTTOM_CORNER
};
public: public:
Decorator(DesktopSettings& settings, BRect rect, Decorator(DesktopSettings& settings, BRect rect,
window_look look, uint32 flags); window_look look, uint32 flags);
@@ -91,8 +113,7 @@ public:
const BRegion& GetFootprint(); const BRegion& GetFootprint();
virtual click_type MouseAction(const BMessage* message, BPoint where, virtual Region RegionAt(BPoint where) const;
int32 buttons, int32 modifiers);
void MoveBy(float x, float y); void MoveBy(float x, float y);
void MoveBy(BPoint offset); void MoveBy(BPoint offset);
+36 -59
View File
@@ -8,6 +8,7 @@
* Philippe Saint-Pierre, stpere@gmail.com * Philippe Saint-Pierre, stpere@gmail.com
* Ryan Leavengood <leavengood@gmail.com> * Ryan Leavengood <leavengood@gmail.com>
* Clemens Zeidler <haiku@clemens-zeidler.de> * Clemens Zeidler <haiku@clemens-zeidler.de>
* Ingo Weinhold <ingo_weinhold@gmx.de>
*/ */
@@ -70,8 +71,7 @@ DefaultDecorator::DefaultDecorator(DesktopSettings& settings, BRect rect,
window_look look, uint32 flags) window_look look, uint32 flags)
: Decorator(settings, rect, look, flags), : Decorator(settings, rect, look, flags),
fTabOffset(0), fTabOffset(0),
fTabLocation(0.0), fTabLocation(0.0)
fWasDoubleClick(false)
{ {
_UpdateFont(settings); _UpdateFont(settings);
@@ -180,70 +180,47 @@ DefaultDecorator::GetSizeLimits(int32* minWidth, int32* minHeight,
} }
click_type Decorator::Region
DefaultDecorator::MouseAction(const BMessage* message, BPoint point, DefaultDecorator::RegionAt(BPoint where) const
int32 buttons, int32 modifiers)
{ {
#ifdef DEBUG_DECORATOR // Let the base class version identify hits of the buttons and the tab.
printf("DefaultDecorator: Clicked\n"); Region region = Decorator::RegionAt(where);
printf("\tPoint: (%.1f,%.1f)\n", point.x, point.y); if (region != REGION_NONE)
printf("\tButtons: %ld, Modifiers: 0x%lx\n", buttons, modifiers); return region;
#endif // DEBUG_DECORATOR
click_type action = CLICK_NONE; // check the resize corner
if (fLook == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(where))
return REGION_RIGHT_BOTTOM_CORNER;
// We start with the smallest rectangles the user might be clicking // hit-test the borders
// on and gradually work our way out into larger rectangles. if (fLeftBorder.Contains(where))
if (!(fFlags & B_NOT_CLOSABLE) && fCloseRect.Contains(point)) return REGION_LEFT_BORDER;
action = CLICK_CLOSE; if (fTopBorder.Contains(where))
else if (!(fFlags & B_NOT_ZOOMABLE) && fZoomRect.Contains(point)) return REGION_TOP_BORDER;
action = CLICK_ZOOM;
else if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0)
action = CLICK_MOVE_TO_BACK;
else if (fLook == B_DOCUMENT_WINDOW_LOOK && fResizeRect.Contains(point))
action = CLICK_RESIZE;
else if (fTabRect.Contains(point)) {
// Clicked in the tab
// tab sliding in any case if either shift key is held down // Part of the bottom and right borders may be a resize-region, so we have
// except sliding up-down by moving mouse left-right would look strange // to check explicitly, if it has been it.
if ((modifiers & B_SHIFT_KEY) != 0 && fLook != kLeftTitledWindowLook) if (fRightBorder.Contains(where))
action = CLICK_SLIDE_TAB; region = REGION_RIGHT_BORDER;
else else if (fBottomBorder.Contains(where))
action = CLICK_DRAG; region = REGION_BOTTOM_BORDER;
} else if (fLeftBorder.Contains(point) || fRightBorder.Contains(point) else
|| fTopBorder.Contains(point) || fBottomBorder.Contains(point)) { return REGION_NONE;
// Clicked on border
// check resize area // check resize area
if (!(fFlags & B_NOT_RESIZABLE) if ((fFlags & B_NOT_RESIZABLE) == 0
&& (fLook == B_TITLED_WINDOW_LOOK && (fLook == B_TITLED_WINDOW_LOOK
|| fLook == B_FLOATING_WINDOW_LOOK || fLook == B_FLOATING_WINDOW_LOOK
|| fLook == B_MODAL_WINDOW_LOOK || fLook == B_MODAL_WINDOW_LOOK
|| fLook == kLeftTitledWindowLook)) { || fLook == kLeftTitledWindowLook)) {
BRect resizeRect(BPoint(fBottomBorder.right - kBorderResizeLength, BRect resizeRect(BPoint(fBottomBorder.right - kBorderResizeLength,
fBottomBorder.bottom - kBorderResizeLength), fBottomBorder.bottom - kBorderResizeLength),
fBottomBorder.RightBottom()); fBottomBorder.RightBottom());
if (resizeRect.Contains(point)) if (resizeRect.Contains(where))
action = CLICK_RESIZE; return REGION_RIGHT_BOTTOM_CORNER;
} else
action = CLICK_DRAG;
} }
if (buttons != 0) { return region;
fWasDoubleClick = message->FindInt32("clicks") == 2
&& fLastAction == action;
}
// Transform double clicks on the border to minimize, if allowed
if (action == CLICK_DRAG && fWasDoubleClick
&& (fFlags & B_NOT_MINIMIZABLE) == 0)
action = CLICK_MINIMIZE;
if (message->what == B_MOUSE_DOWN)
fLastAction = action;
return action;
} }
+1 -7
View File
@@ -37,9 +37,7 @@ public:
virtual void GetSizeLimits(int32* minWidth, int32* minHeight, virtual void GetSizeLimits(int32* minWidth, int32* minHeight,
int32* maxWidth, int32* maxHeight) const; int32* maxWidth, int32* maxHeight) const;
virtual click_type MouseAction(const BMessage* message, virtual Region RegionAt(BPoint where) const;
BPoint point, int32 buttons,
int32 modifiers);
float BorderWidth(); float BorderWidth();
float TabHeight(); float TabHeight();
@@ -134,10 +132,6 @@ protected:
float fMaxTabSize; float fMaxTabSize;
BString fTruncatedTitle; BString fTruncatedTitle;
int32 fTruncatedTitleLength; int32 fTruncatedTitleLength;
private:
click_type fLastAction;
bool fWasDoubleClick;
}; };
+191 -69
View File
@@ -9,11 +9,14 @@
* Axel Dörfler <axeld@pinc-software.de> * Axel Dörfler <axeld@pinc-software.de>
* Brecht Machiels <brecht@mos6581.org> * Brecht Machiels <brecht@mos6581.org>
* Clemens Zeidler <haiku@clemens-zeidler.de> * Clemens Zeidler <haiku@clemens-zeidler.de>
* Ingo Weinhold <ingo_weinhold@gmx.de>
*/ */
#include "DefaultWindowBehaviour.h" #include "DefaultWindowBehaviour.h"
#include <WindowPrivate.h>
#include "Desktop.h" #include "Desktop.h"
#include "DrawingEngine.h" #include "DrawingEngine.h"
#include "Window.h" #include "Window.h"
@@ -27,6 +30,7 @@
#endif #endif
// The span between mouse down
static const bigtime_t kWindowActivationTimeout = 500000LL; static const bigtime_t kWindowActivationTimeout = 500000LL;
@@ -39,11 +43,14 @@ DefaultWindowBehaviour::DefaultWindowBehaviour(Window* window)
fIsZooming(false), fIsZooming(false),
fIsSlidingTab(false), fIsSlidingTab(false),
fActivateOnMouseUp(false), fActivateOnMouseUp(false),
fMinimizeCheckOnMouseUp(false),
fLastMousePosition(0.0f, 0.0f), fLastMousePosition(0.0f, 0.0f),
fMouseMoveDistance(0.0f), fMouseMoveDistance(0.0f),
fLastMoveTime(0), fLastMoveTime(0),
fLastSnapTime(0) fLastSnapTime(0),
fLastModifiers(0),
fResetClickCount(0)
{ {
fDesktop = fWindow->Desktop(); fDesktop = fWindow->Desktop();
} }
@@ -65,33 +72,106 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
int32 modifiers = message->FindInt32("modifiers"); int32 modifiers = message->FindInt32("modifiers");
bool windowModifier = _IsWindowModifier(modifiers); bool windowModifier = _IsWindowModifier(modifiers);
// Get the click count and reset it, if the modifiers changed in the
// meantime.
// TODO: This should be done in a better place (e.g. the input server). It
// should also reset clicks after mouse movement (which we don't do here
// either -- though that's probably acceptable).
int32 clickCount = message->FindInt32("clicks");
if (clickCount <= 1) {
fResetClickCount = 0;
} else if (modifiers != fLastModifiers
|| clickCount - fResetClickCount < 1) {
fResetClickCount = clickCount - 1;
clickCount = 1;
} else
clickCount -= fResetClickCount;
fLastModifiers = modifiers;
Region hitRegion = REGION_NONE;
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 decorator or we have the window modifier keys
int32 buttons = message->FindInt32("buttons"); // held
if (inBorderRegion) // get the functional hit region
action = _ActionFor(message, buttons, modifiers); if (windowModifier) {
else { // click with window modifier keys -- let the whole window behave
if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) // like the border
action = CLICK_MOVE_TO_BACK; hitRegion = REGION_BORDER;
else if ((fWindow->Flags() & B_NOT_MINIMIZABLE) == 0 } else {
&& message->FindInt32("clicks") == 2) // click on the decorator -- get the exact region
action = CLICK_MINIMIZE; hitRegion = _RegionFor(message);
else if ((fWindow->Flags() & B_NOT_MOVABLE) == 0 }
&& decorator != NULL)
action = CLICK_DRAG; // translate the region into an action
else { int32 buttons = message->FindInt32("buttons");
// pass click on to the application bool leftButton = (buttons & B_PRIMARY_MOUSE_BUTTON) != 0;
windowModifier = false; bool rightButton = (buttons & B_SECONDARY_MOUSE_BUTTON) != 0;
} uint32 flags = fWindow->Flags();
switch (hitRegion) {
case REGION_NONE:
break;
case REGION_TAB:
// tab sliding in any case if either shift key is held down
// except sliding up-down by moving mouse left-right would look
// strange
if (leftButton && (modifiers & B_SHIFT_KEY) != 0
&& fWindow->Look() != kLeftTitledWindowLook) {
action = CLICK_SLIDE_TAB;
break;
}
// otherwise fall through -- same handling as for the border...
case REGION_BORDER:
if (leftButton)
action = CLICK_DRAG;
else if (rightButton)
action = CLICK_MOVE_TO_BACK;
break;
case REGION_CLOSE_BUTTON:
if (leftButton) {
action = (flags & B_NOT_CLOSABLE) == 0
? CLICK_CLOSE : CLICK_DRAG;
} else if (rightButton)
action = CLICK_MOVE_TO_BACK;
break;
case REGION_ZOOM_BUTTON:
if (leftButton) {
action = (flags & B_NOT_ZOOMABLE) == 0
? CLICK_ZOOM : CLICK_DRAG;
} else if (rightButton)
action = CLICK_MOVE_TO_BACK;
break;
case REGION_MINIMIZE_BUTTON:
if (leftButton) {
action = (flags & B_NOT_MINIMIZABLE) == 0
? CLICK_MINIMIZE : CLICK_DRAG;
} else if (rightButton)
action = CLICK_MOVE_TO_BACK;
break;
case REGION_RESIZE_CORNER:
if (leftButton) {
action = (flags & B_NOT_RESIZABLE) == 0
? CLICK_RESIZE : CLICK_DRAG;
} else if (rightButton)
action = CLICK_MOVE_TO_BACK;
break;
} }
} }
if (!windowModifier && !inBorderRegion) { if (action == CLICK_NONE) {
// This is a click inside the window's contents // No action -- if this is a click inside the window's contents,
return false; // let it be forwarded to the window.
return inBorderRegion;
} }
DesktopSettings desktopSettings(fDesktop); DesktopSettings desktopSettings(fDesktop);
@@ -165,9 +245,6 @@ 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) {
@@ -184,12 +261,15 @@ DefaultWindowBehaviour::MouseDown(BMessage* message, BPoint where)
else { else {
fDesktop->SetFocusWindow(fWindow); fDesktop->SetFocusWindow(fWindow);
if (action == CLICK_DRAG || action == CLICK_RESIZE) { if (action == CLICK_DRAG || action == CLICK_RESIZE)
fActivateOnMouseUp = true; fActivateOnMouseUp = true;
fMouseMoveDistance = 0.0f;
fLastMoveTime = system_time();
}
} }
if (fIsDragging && clickCount == 2)
fMinimizeCheckOnMouseUp = true;
fMouseMoveDistance = 0.0f;
fLastMoveTime = system_time();
} }
return true; return true;
@@ -201,11 +281,9 @@ DefaultWindowBehaviour::MouseUp(BMessage* message, BPoint where)
{ {
Decorator* decorator = fWindow->Decorator(); Decorator* decorator = fWindow->Decorator();
if (decorator != NULL) { int32 buttons = message->FindInt32("buttons");
int32 modifiers = message->FindInt32("modifiers");
int32 buttons = message->FindInt32("buttons");
click_type action = _ActionFor(message, buttons, modifiers);
if (decorator != NULL) {
// redraw decorator // redraw decorator
BRegion* visibleBorder = fWindow->RegionPool()->GetRegion(); BRegion* visibleBorder = fWindow->RegionPool()->GetRegion();
fWindow->GetBorderRegion(visibleBorder); fWindow->GetBorderRegion(visibleBorder);
@@ -218,44 +296,54 @@ 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 (_RegionFor(message) == REGION_ZOOM_BUTTON)
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 (_RegionFor(message) == REGION_CLOSE_BUTTON)
fWindow->ServerWindow()->NotifyQuitRequested(); fWindow->ServerWindow()->NotifyQuitRequested();
} }
if (fIsMinimizing) { if (fIsMinimizing) {
fIsMinimizing = false; fIsMinimizing = false;
decorator->SetMinimize(false); decorator->SetMinimize(false);
if (action == CLICK_MINIMIZE || _IsWindowModifier(modifiers)) if (_RegionFor(message) == REGION_MINIMIZE_BUTTON)
fWindow->ServerWindow()->NotifyMinimize(true); fWindow->ServerWindow()->NotifyMinimize(true);
} }
engine->UnlockParallelAccess(); engine->UnlockParallelAccess();
fWindow->RegionPool()->Recycle(visibleBorder); fWindow->RegionPool()->Recycle(visibleBorder);
// if the primary mouse button is released, stop
// dragging/resizing/sliding
if ((buttons & B_PRIMARY_MOUSE_BUTTON) == 0) {
fIsDragging = false;
fIsResizing = false;
fIsSlidingTab = false;
}
} }
// in FFM mode, activate the window and bring it // if the primary mouse button is released, stop
// to front in case this was a drag click but the // dragging/resizing/sliding
// mouse was not moved if ((buttons & B_PRIMARY_MOUSE_BUTTON) == 0) {
if (fActivateOnMouseUp) { if (fMinimizeCheckOnMouseUp) {
fActivateOnMouseUp = false; // If the modifiers haven't changed in the meantime and not too
// on R5, there is a time window for this feature // much time has elapsed, we're supposed to minimize the window.
// ie, click and press too long, nothing will happen fMinimizeCheckOnMouseUp = false;
if (system_time() - fLastMoveTime < kWindowActivationTimeout) if (message->FindInt32("modifiers") == fLastModifiers
fDesktop->ActivateWindow(fWindow); && (fWindow->Flags() & B_NOT_MINIMIZABLE) == 0
&& system_time() - fLastMoveTime < kWindowActivationTimeout) {
fWindow->ServerWindow()->NotifyMinimize(true);
}
}
// In FFM mode, activate the window and bring it to front in case this
// was a drag click but the mouse was not moved.
if (fActivateOnMouseUp) {
fActivateOnMouseUp = false;
// on R5, there is a time window for this feature
// ie, click and press too long, nothing will happen
if (system_time() - fLastMoveTime < kWindowActivationTimeout)
fDesktop->ActivateWindow(fWindow);
}
fIsDragging = false;
fIsResizing = false;
fIsSlidingTab = false;
} }
} }
@@ -285,10 +373,12 @@ DefaultWindowBehaviour::MouseMoved(BMessage *message, BPoint where, bool isFake)
// the then current mouse position // the then current mouse position
return; return;
} }
if (fActivateOnMouseUp) { if (fActivateOnMouseUp || fMinimizeCheckOnMouseUp) {
if (now - fLastMoveTime >= kWindowActivationTimeout) { if (now - fLastMoveTime >= kWindowActivationTimeout) {
// This click is too long already for window activation. // This click is too long already for window activation/
// minimizing.
fActivateOnMouseUp = false; fActivateOnMouseUp = false;
fMinimizeCheckOnMouseUp = false;
} }
} else } else
fLastMoveTime = now; fLastMoveTime = now;
@@ -303,16 +393,14 @@ DefaultWindowBehaviour::MouseMoved(BMessage *message, BPoint where, bool isFake)
engine->LockParallelAccess(); engine->LockParallelAccess();
engine->ConstrainClippingRegion(visibleBorder); engine->ConstrainClippingRegion(visibleBorder);
int32 buttons = message->FindInt32("buttons"); Region hitRegion = _RegionFor(message);
int32 modifiers = message->FindInt32("modifiers");
click_type type = _ActionFor(message, buttons, modifiers);
if (fIsZooming) if (fIsZooming)
decorator->SetZoom(type == CLICK_ZOOM); decorator->SetZoom(hitRegion == REGION_ZOOM_BUTTON);
else if (fIsClosing) else if (fIsClosing)
decorator->SetClose(type == CLICK_CLOSE); decorator->SetClose(hitRegion == REGION_CLOSE_BUTTON);
else if (fIsMinimizing) else if (fIsMinimizing)
decorator->SetMinimize(type == CLICK_MINIMIZE); decorator->SetMinimize(hitRegion == REGION_MINIMIZE_BUTTON);
engine->UnlockParallelAccess(); engine->UnlockParallelAccess();
fWindow->RegionPool()->Recycle(visibleBorder); fWindow->RegionPool()->Recycle(visibleBorder);
@@ -329,11 +417,12 @@ DefaultWindowBehaviour::MouseMoved(BMessage *message, BPoint where, bool isFake)
// If the window was moved enough, it doesn't come to // If the window was moved enough, it doesn't come to
// the front in FFM mode when the mouse is released. // the front in FFM mode when the mouse is released.
if (fActivateOnMouseUp) { if (fActivateOnMouseUp || fMinimizeCheckOnMouseUp) {
fMouseMoveDistance += delta.x * delta.x + delta.y * delta.y; fMouseMoveDistance += delta.x * delta.x + delta.y * delta.y;
if (fMouseMoveDistance > 16.0f) if (fMouseMoveDistance > 16.0f) {
fActivateOnMouseUp = false; fActivateOnMouseUp = false;
else fMinimizeCheckOnMouseUp = false;
} else
delta = B_ORIGIN; delta = B_ORIGIN;
} }
@@ -403,19 +492,52 @@ DefaultWindowBehaviour::_IsWindowModifier(int32 modifiers) const
} }
click_type DefaultWindowBehaviour::Region
DefaultWindowBehaviour::_ActionFor(const BMessage* message, int32 buttons, DefaultWindowBehaviour::_RegionFor(const BMessage* message) const
int32 modifiers) const
{ {
Decorator* decorator = fWindow->Decorator(); Decorator* decorator = fWindow->Decorator();
if (decorator == NULL) if (decorator == NULL)
return CLICK_NONE; return REGION_NONE;
BPoint where; BPoint where;
if (message->FindPoint("where", &where) != B_OK) if (message->FindPoint("where", &where) != B_OK)
return CLICK_NONE; return REGION_NONE;
return decorator->MouseAction(message, where, buttons, modifiers); // translate the tab region into a functional region
switch (decorator->RegionAt(where)) {
case Decorator::REGION_NONE:
return REGION_NONE;
case Decorator::REGION_TAB:
return REGION_TAB;
case Decorator::REGION_CLOSE_BUTTON:
return REGION_CLOSE_BUTTON;
case Decorator::REGION_ZOOM_BUTTON:
return REGION_ZOOM_BUTTON;
case Decorator::REGION_MINIMIZE_BUTTON:
return REGION_MINIMIZE_BUTTON;
case Decorator::REGION_LEFT_BORDER:
case Decorator::REGION_RIGHT_BORDER:
case Decorator::REGION_TOP_BORDER:
case Decorator::REGION_BOTTOM_BORDER:
return REGION_BORDER;
case Decorator::REGION_LEFT_TOP_CORNER:
case Decorator::REGION_LEFT_BOTTOM_CORNER:
case Decorator::REGION_RIGHT_TOP_CORNER:
// not supported yet
return REGION_BORDER;
case Decorator::REGION_RIGHT_BOTTOM_CORNER:
return REGION_RESIZE_CORNER;
default:
return REGION_NONE;
}
} }
+22 -5
View File
@@ -9,6 +9,7 @@
* Axel Dörfler <axeld@pinc-software.de> * Axel Dörfler <axeld@pinc-software.de>
* Brecht Machiels <brecht@mos6581.org> * Brecht Machiels <brecht@mos6581.org>
* Clemens Zeidler <haiku@clemens-zeidler.de> * Clemens Zeidler <haiku@clemens-zeidler.de>
* Ingo Weinhold <ingo_weinhold@gmx.de>
*/ */
#ifndef DEFAULT_WINDOW_BEHAVIOUR_H #ifndef DEFAULT_WINDOW_BEHAVIOUR_H
#define DEFAULT_WINDOW_BEHAVIOUR_H #define DEFAULT_WINDOW_BEHAVIOUR_H
@@ -32,28 +33,44 @@ public:
virtual void MouseUp(BMessage* message, BPoint where); virtual void MouseUp(BMessage* message, BPoint where);
virtual void MouseMoved(BMessage *message, BPoint where, virtual void MouseMoved(BMessage *message, BPoint where,
bool isFake); bool isFake);
private:
enum Region {
REGION_NONE,
REGION_TAB,
REGION_BORDER,
REGION_CLOSE_BUTTON,
REGION_ZOOM_BUTTON,
REGION_MINIMIZE_BUTTON,
REGION_RESIZE_CORNER
};
private: private:
bool _IsWindowModifier(int32 modifiers) const; bool _IsWindowModifier(int32 modifiers) const;
click_type _ActionFor(const BMessage* message, Region _RegionFor(const BMessage* message) const;
int32 buttons, int32 modifiers) const;
void _AlterDeltaForSnap(BPoint& delta, void _AlterDeltaForSnap(BPoint& delta,
bigtime_t now); bigtime_t now);
protected: protected:
Window* fWindow; Window* fWindow;
Desktop* fDesktop; Desktop* fDesktop;
bool fIsClosing : 1; bool fIsClosing : 1;
bool fIsMinimizing : 1; bool fIsMinimizing : 1;
bool fIsZooming : 1; bool fIsZooming : 1;
bool fIsSlidingTab : 1; bool fIsSlidingTab : 1;
bool fActivateOnMouseUp : 1; bool fActivateOnMouseUp : 1;
bool fMinimizeCheckOnMouseUp : 1;
BPoint fLastMousePosition; BPoint fLastMousePosition;
float fMouseMoveDistance; float fMouseMoveDistance;
bigtime_t fLastMoveTime; bigtime_t fLastMoveTime;
bigtime_t fLastSnapTime; bigtime_t fLastSnapTime;
int32 fLastModifiers;
int32 fResetClickCount;
}; };