diff options
author | idanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-18 18:55:46 +0000 |
---|---|---|
committer | idanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-18 18:55:46 +0000 |
commit | 67a8eb11dc38258403e5de88558f7b9bb4fecbf3 (patch) | |
tree | c22450d0a78042dbd0a15f8397a4075a0e11da98 /chrome/browser | |
parent | edbae4bd7199e77524a1bedfe96947ea3b9750e8 (diff) | |
download | chromium_src-67a8eb11dc38258403e5de88558f7b9bb4fecbf3.zip chromium_src-67a8eb11dc38258403e5de88558f7b9bb4fecbf3.tar.gz chromium_src-67a8eb11dc38258403e5de88558f7b9bb4fecbf3.tar.bz2 |
Solved 2 bugs which caused Chrome to maximize itself whendouble clicking, either on the new tab button, on the closetab button or on a single tab.BUG=2827BUG=3787The problem comes from the Windows event sequence upon adouble-click (simplified here):1 - hit-test2 - mouse-down4 - mouse-up/click5 - hit-test6 - mouse down7 - mouse up/double-clickThe 1st hit-test is always performed correctly, returningclient for tabs and non-client for the tab-strip (background).The 2nd hit test is not performed correctly to avoid crashesin Chromebot from events being processed while tabs are animating.Since we have no record of these crashes, Ben prefers we keepthis special-case, even though we are responding incorrectlyto the windows hit-test. So, when the tabs are animating wereturn a HTNOWHERE hit which the caller translates into anHTCAPTION hit. This even though a tab-control (new-tab/close-tab)may have been hit.The problem is that having returned HTCAPTION to Windows defaultmessage handling, we get a NON-CLIENT double-click event insteadof a standard one.To keep the behavior of the second hit-test AND prevent theChrome window from maximizing, this change simply declaresthe non-client double-click as handled when the tabs areanimating.Another trick we pulled in the hit-test is to return HTCAPTIONwhen a single tab is present. This allows the entire window to be dragged but causes the context menu to be wrong and the windowto maximize when double clicking on the single tab.The solution here is to correct return a client hit for a singletab and, upon handling a client single-click, delegate to thenon-client single-click default handler.
Review URL: http://codereview.chromium.org/21268
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@9953 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/views/tabs/tab.cc | 11 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab.h | 3 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.cc | 9 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_strip.h | 1 |
4 files changed, 18 insertions, 6 deletions
diff --git a/chrome/browser/views/tabs/tab.cc b/chrome/browser/views/tabs/tab.cc index cdc3502..86f0b2c 100644 --- a/chrome/browser/views/tabs/tab.cc +++ b/chrome/browser/views/tabs/tab.cc @@ -158,7 +158,16 @@ void Tab::GetHitTestMask(gfx::Path* mask) const { } bool Tab::OnMousePressed(const views::MouseEvent& event) { - if (event.IsOnlyLeftMouseButton()) { + if (event.IsLeftMouseButton()) { + // When only one tab is present, instead of ripping it out on drag, + // it dragged the whole window. This is done by sending a non-client + // message which is handled by the default window procedure and causes + // the window get the default drag-on-caption behavior. + if (delegate_->ContainsExactlyOneTab()) { + SendMessage(GetWidget()->GetHWND(), WM_NCLBUTTONDOWN, + HTCAPTION, MAKELPARAM(event.x(), event.y())); + return false; + } // Store whether or not we were selected just now... we only want to be // able to drag foreground tabs, so we don't start dragging the tab if // it was in the background. diff --git a/chrome/browser/views/tabs/tab.h b/chrome/browser/views/tabs/tab.h index de3c981..40577cf 100644 --- a/chrome/browser/views/tabs/tab.h +++ b/chrome/browser/views/tabs/tab.h @@ -69,6 +69,9 @@ class Tab : public TabRenderer, // other than the user releasing the mouse. Returns whether the tab has been // destroyed. virtual bool EndDrag(bool canceled) = 0; + + // Returns true if only one tab exists. + virtual bool ContainsExactlyOneTab() const = 0; }; explicit Tab(TabDelegate* delegate); diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index 693ba35..efd7658 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -529,11 +529,6 @@ bool TabStrip::PointIsWithinWindowCaption(const gfx::Point& point) { if (v == this) return true; - // If the point is within the bounds of a Tab, the point can be considered - // part of the caption if there are no available drag operations for the Tab. - if (v->GetClassName() == Tab::kTabClassName && !HasAvailableDragActions()) - return true; - // Check to see if the point is within the non-button parts of the new tab // button. The button has a non-rectangular shape, so if it's not in the // visual portions of the button we treat it as a click to the caption. @@ -1027,6 +1022,10 @@ bool TabStrip::EndDrag(bool canceled) { return drag_controller_.get() ? drag_controller_->EndDrag(canceled) : false; } +bool TabStrip::ContainsExactlyOneTab() const { + return GetTabCount() == 1; +} + /////////////////////////////////////////////////////////////////////////////// // TabStrip, views::BaseButton::ButtonListener implementation: diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h index 36398c7..3dcf1a0 100644 --- a/chrome/browser/views/tabs/tab_strip.h +++ b/chrome/browser/views/tabs/tab_strip.h @@ -142,6 +142,7 @@ class TabStrip : public views::View, virtual void MaybeStartDrag(Tab* tab, const views::MouseEvent& event); virtual void ContinueDrag(const views::MouseEvent& event); virtual bool EndDrag(bool canceled); + virtual bool ContainsExactlyOneTab() const; // views::Button::ButtonListener implementation: virtual void ButtonPressed(views::BaseButton* sender); |