diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-13 19:40:23 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-13 19:40:23 +0000 |
commit | 400a61c5463c029125d6c854c9eee773b9be302b (patch) | |
tree | 2322ca5fffc23cd90393c3096a882c42e105c792 /ash/frame/frame_border_hit_test_controller.cc | |
parent | 5009ee278b587d7d42bb84203566b1a471b92974 (diff) | |
download | chromium_src-400a61c5463c029125d6c854c9eee773b9be302b.zip chromium_src-400a61c5463c029125d6c854c9eee773b9be302b.tar.gz chromium_src-400a61c5463c029125d6c854c9eee773b9be302b.tar.bz2 |
Move frame related code to ash/frame, plus add OWNERS file.
An attempt to reduce and reorg files in ash/wm as it has too many files.
BUG=None
R=pkotwicz@chromium.org, sky@chromium.org
Review URL: https://codereview.chromium.org/196653008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@256891 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/frame/frame_border_hit_test_controller.cc')
-rw-r--r-- | ash/frame/frame_border_hit_test_controller.cc | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/ash/frame/frame_border_hit_test_controller.cc b/ash/frame/frame_border_hit_test_controller.cc new file mode 100644 index 0000000..228db6b --- /dev/null +++ b/ash/frame/frame_border_hit_test_controller.cc @@ -0,0 +1,71 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ash/frame/frame_border_hit_test_controller.h" + +#include "ash/ash_constants.h" +#include "ash/frame/header_painter.h" +#include "ash/wm/resize_handle_window_targeter.h" +#include "ash/wm/window_state_observer.h" +#include "ui/aura/env.h" +#include "ui/aura/window.h" +#include "ui/aura/window_observer.h" +#include "ui/aura/window_targeter.h" +#include "ui/base/hit_test.h" +#include "ui/views/widget/widget.h" +#include "ui/views/widget/widget_delegate.h" +#include "ui/views/window/non_client_view.h" + +namespace ash { + +FrameBorderHitTestController::FrameBorderHitTestController(views::Widget* frame) + : frame_window_(frame->GetNativeWindow()) { + frame_window_->SetEventTargeter(scoped_ptr<ui::EventTargeter>( + new ResizeHandleWindowTargeter(frame_window_, NULL))); +} + +FrameBorderHitTestController::~FrameBorderHitTestController() { +} + +// static +int FrameBorderHitTestController::NonClientHitTest( + views::NonClientFrameView* view, + HeaderPainter* header_painter, + const gfx::Point& point) { + gfx::Rect expanded_bounds = view->bounds(); + int outside_bounds = kResizeOutsideBoundsSize; + + if (aura::Env::GetInstance()->is_touch_down()) + outside_bounds *= kResizeOutsideBoundsScaleForTouch; + expanded_bounds.Inset(-outside_bounds, -outside_bounds); + + if (!expanded_bounds.Contains(point)) + return HTNOWHERE; + + // Check the frame first, as we allow a small area overlapping the contents + // to be used for resize handles. + views::Widget* frame = view->GetWidget(); + bool can_ever_resize = frame->widget_delegate()->CanResize(); + // Don't allow overlapping resize handles when the window is maximized or + // fullscreen, as it can't be resized in those states. + int resize_border = + frame->IsMaximized() || frame->IsFullscreen() ? 0 : + kResizeInsideBoundsSize; + int frame_component = view->GetHTComponentForFrame(point, + resize_border, + resize_border, + kResizeAreaCornerSize, + kResizeAreaCornerSize, + can_ever_resize); + if (frame_component != HTNOWHERE) + return frame_component; + + int client_component = frame->client_view()->NonClientHitTest(point); + if (client_component != HTNOWHERE) + return client_component; + + return header_painter->NonClientHitTest(point); +} + +} // namespace ash |