diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-04 02:51:34 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-04 02:51:34 +0000 |
commit | 847dda8ade71638fae9596d4b5102667c29fad1e (patch) | |
tree | 961773bbd2b5645cb129869f2ed0f7a50b63c9d6 | |
parent | b01a2c21bfaa8d4a64efa648e3637d9d3c0d3bb1 (diff) | |
download | chromium_src-847dda8ade71638fae9596d4b5102667c29fad1e.zip chromium_src-847dda8ade71638fae9596d4b5102667c29fad1e.tar.gz chromium_src-847dda8ade71638fae9596d4b5102667c29fad1e.tar.bz2 |
Fix regression where the window caption buttons weren't clickable when maximized. This is because of the nonclient frameview/clientview hierarchy changes.
Make sure that the frame gets a chance to respond to GetViewForPoint before the client view if the client view does not visually overlap.
http://crbug.com/8312
Review URL: http://codereview.chromium.org/40062
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10857 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/views/frame/opaque_browser_frame_view.cc | 28 | ||||
-rw-r--r-- | chrome/browser/views/frame/opaque_browser_frame_view.h | 3 | ||||
-rw-r--r-- | chrome/views/non_client_view.cc | 30 | ||||
-rw-r--r-- | chrome/views/non_client_view.h | 8 |
4 files changed, 51 insertions, 18 deletions
diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc index a908d7f..4e45151 100644 --- a/chrome/browser/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc @@ -565,21 +565,19 @@ void OpaqueBrowserFrameView::Layout() { LayoutClientView(); } -views::View* OpaqueBrowserFrameView::GetViewForPoint(const gfx::Point& point, - bool can_create_floating) { - // We override this function because the ClientView can overlap the non - - // client view, making it impossible to click on the window controls. We need - // to ensure the window controls are checked _first_. - views::View* views[] = - { close_button_, restore_button_, maximize_button_, minimize_button_ }; - for (int i = 0; i < arraysize(views); ++i) { - if (!views[i]->IsVisible()) - continue; - // Apply mirroring transformation on view bounds for RTL chrome. - if (views[i]->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) - return views[i]; - } - return View::GetViewForPoint(point, can_create_floating); +bool OpaqueBrowserFrameView::HitTest(const gfx::Point& l) const { + // If the point is outside the bounds of the client area, claim it. + bool in_nonclient = NonClientFrameView::HitTest(l); + if (in_nonclient) + return in_nonclient; + + // Otherwise claim it only if it's in a non-tab portion of the tabstrip. + if (l.y() > browser_view_->tabstrip()->bounds().bottom()) + return false; + + gfx::Point tabstrip_point(l); + View::ConvertPointToView(this, browser_view_->tabstrip(), &tabstrip_point); + return browser_view_->tabstrip()->PointIsWithinWindowCaption(tabstrip_point); } void OpaqueBrowserFrameView::ViewHierarchyChanged(bool is_add, diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.h b/chrome/browser/views/frame/opaque_browser_frame_view.h index 7eed20d..f25e4f4 100644 --- a/chrome/browser/views/frame/opaque_browser_frame_view.h +++ b/chrome/browser/views/frame/opaque_browser_frame_view.h @@ -46,8 +46,7 @@ class OpaqueBrowserFrameView : public BrowserNonClientFrameView, // Overridden from views::View: virtual void Paint(ChromeCanvas* canvas); virtual void Layout(); - virtual views::View* GetViewForPoint(const gfx::Point& point, - bool can_create_floating); + virtual bool HitTest(const gfx::Point& l) const; virtual void ViewHierarchyChanged(bool is_add, views::View* parent, views::View* child); diff --git a/chrome/views/non_client_view.cc b/chrome/views/non_client_view.cc index ca54796..2e7804c 100644 --- a/chrome/views/non_client_view.cc +++ b/chrome/views/non_client_view.cc @@ -159,6 +159,36 @@ void NonClientView::ViewHierarchyChanged(bool is_add, View* parent, } } +views::View* NonClientView::GetViewForPoint(const gfx::Point& point) { + return GetViewForPoint(point, false); +} + +views::View* NonClientView::GetViewForPoint(const gfx::Point& point, + bool can_create_floating) { + // Because of the z-ordering of our child views (the client view is positioned + // over the non-client frame view, if the client view ever overlaps the frame + // view visually (as it does for the browser window), then it will eat mouse + // events for the window controls. We override this method here so that we can + // detect this condition and re-route the events to the non-client frame view. + // The assumption is that the frame view's implementation of HitTest will only + // return true for area not occupied by the client view. + gfx::Point point_in_child_coords(point); + View::ConvertPointToView(this, frame_view_.get(), &point_in_child_coords); + if (frame_view_->HitTest(point_in_child_coords)) + return frame_view_->GetViewForPoint(point); + + return View::GetViewForPoint(point, can_create_floating); +} + +//////////////////////////////////////////////////////////////////////////////// +// NonClientFrameView, View overrides: + +bool NonClientFrameView::HitTest(const gfx::Point& l) const { + // For the default case, we assume the non-client frame view never overlaps + // the client view. + return !GetWidget()->AsWindow()->client_view()->bounds().Contains(l); +} + //////////////////////////////////////////////////////////////////////////////// // NonClientFrameView, protected: diff --git a/chrome/views/non_client_view.h b/chrome/views/non_client_view.h index f801d6f..32130c3 100644 --- a/chrome/views/non_client_view.h +++ b/chrome/views/non_client_view.h @@ -22,7 +22,7 @@ namespace views { // responds to events within the frame portions of the non-client area of a // window. This view does _not_ contain the ClientView, but rather is a sibling // of it. -class NonClientFrameView : public views::View { +class NonClientFrameView : public View { public: // Various edges of the frame border have a 1 px shadow along their edges; in // a few cases we shift elements based on this amount for visual appeal. @@ -55,6 +55,9 @@ class NonClientFrameView : public views::View { virtual void EnableClose(bool enable) = 0; virtual void ResetWindowControls() = 0; + // Overridden from View: + virtual bool HitTest(const gfx::Point& l) const; + protected: NonClientFrameView() : paint_as_active_(false) {} @@ -191,6 +194,9 @@ class NonClientView : public View { protected: // NonClientView, View overrides: virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child); + virtual views::View* GetViewForPoint(const gfx::Point& point); + virtual views::View* GetViewForPoint(const gfx::Point& point, + bool can_create_floating); private: // The frame that hosts this NonClientView. |