diff options
author | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-20 05:39:26 +0000 |
---|---|---|
committer | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-20 05:39:26 +0000 |
commit | 080f34ff022299737619be0a6877b7b9b7910c54 (patch) | |
tree | 783192857c1e37f673c4540fb13f5444b05c8155 /views/widget/native_widget_views.cc | |
parent | 2f2ee5fb5fda64cce38f52adb139a6a499b58b29 (diff) | |
download | chromium_src-080f34ff022299737619be0a6877b7b9b7910c54.zip chromium_src-080f34ff022299737619be0a6877b7b9b7910c54.tar.gz chromium_src-080f34ff022299737619be0a6877b7b9b7910c54.tar.bz2 |
Relanding 100792
Use TabContentsViewViews for RenderWidgetHostViweViews.
* Removed TabContentsViewTouch.
* Changed so that mouse and resize event goes through NativeWidgetViews so that NativeTabContentsViewViews can invoke NativeTabContentsViewDelegates.
BUG=none
TEST=none
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=100792
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=100834
Review URL: http://codereview.chromium.org/7460001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101921 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget/native_widget_views.cc')
-rw-r--r-- | views/widget/native_widget_views.cc | 83 |
1 files changed, 73 insertions, 10 deletions
diff --git a/views/widget/native_widget_views.cc b/views/widget/native_widget_views.cc index a61a9b9..c0d4af2 100644 --- a/views/widget/native_widget_views.cc +++ b/views/widget/native_widget_views.cc @@ -18,6 +18,10 @@ #include "views/ime/mock_input_method.h" #endif +#if defined(OS_LINUX) +#include "views/window/hit_test.h" +#endif + namespace views { //////////////////////////////////////////////////////////////////////////////// @@ -30,7 +34,6 @@ NativeWidgetViews::NativeWidgetViews(internal::NativeWidgetDelegate* delegate) minimized_(false), always_on_top_(false), ALLOW_THIS_IN_INITIALIZER_LIST(close_widget_factory_(this)), - hosting_widget_(NULL), ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), delete_native_view_(true) { } @@ -95,6 +98,18 @@ void NativeWidgetViews::DispatchKeyEventPostIME(const KeyEvent& key) { } //////////////////////////////////////////////////////////////////////////////// +// NativeWidgetViews, protected: + +void NativeWidgetViews::OnBoundsChanged(const gfx::Rect& new_bounds, + const gfx::Rect& old_bounds) { + delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); +} + +bool NativeWidgetViews::OnMouseEvent(const MouseEvent& event) { + return HandleWindowOperation(event) ? true : delegate_->OnMouseEvent(event); +} + +//////////////////////////////////////////////////////////////////////////////// // NativeWidgetViews, NativeWidget implementation: void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) { @@ -102,18 +117,20 @@ void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) { always_on_top_ = params.keep_on_top; View* parent_view = NULL; if (params.parent_widget) { - hosting_widget_ = params.parent_widget; - parent_view = hosting_widget_->GetChildViewParent(); - } else { + parent_view = params.parent_widget->GetChildViewParent(); + } else if (ViewsDelegate::views_delegate && + ViewsDelegate::views_delegate->GetDefaultParentView()) { parent_view = ViewsDelegate::views_delegate->GetDefaultParentView(); - hosting_widget_ = parent_view->GetWidget(); + } else if (params.parent) { + Widget* widget = Widget::GetWidgetForNativeView(params.parent); + parent_view = widget->GetChildViewParent(); } view_ = new internal::NativeWidgetView(this); view_->SetBoundsRect(params.bounds); #if !defined(USE_AURA) // TODO(beng): re-enable this once we have a consolidated layer tree. - view_->SetPaintToLayer(true); + view_->SetPaintToLayer(params.create_layer); #endif // With the default NATIVE_WIDGET_OWNS_WIDGET ownership, the @@ -124,7 +141,8 @@ void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) { if (ownership_ == Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET) view_->set_delete_native_widget(false); - parent_view->AddChildView(view_); + if (parent_view) + parent_view->AddChildView(view_); // TODO(beng): SetInitParams(). } @@ -165,7 +183,8 @@ Widget* NativeWidgetViews::GetTopLevelWidget() { // view_ has already been unset. if (!view_) return GetWidget(); - if (view_->parent() == ViewsDelegate::views_delegate->GetDefaultParentView()) + if (ViewsDelegate::views_delegate && + view_->parent() == ViewsDelegate::views_delegate->GetDefaultParentView()) return GetWidget(); // During Widget destruction, this function may be called after |view_| is // detached from a Widget, at which point this NativeWidget's Widget becomes @@ -176,11 +195,11 @@ Widget* NativeWidgetViews::GetTopLevelWidget() { } const ui::Compositor* NativeWidgetViews::GetCompositor() const { - return hosting_widget_->GetCompositor(); + return view_->GetWidget() ? view_->GetWidget()->GetCompositor() : NULL; } ui::Compositor* NativeWidgetViews::GetCompositor() { - return hosting_widget_->GetCompositor(); + return view_->GetWidget() ? view_->GetWidget()->GetCompositor() : NULL; } void NativeWidgetViews::CalculateOffsetToAncestorWithLayer( @@ -504,6 +523,13 @@ bool NativeWidgetViews::ConvertPointFromAncestor( return false; } +gfx::Rect NativeWidgetViews::GetWorkAreaBoundsInScreen() const { + // TODO(oshima): This should return the views desktop window's + // working area when the system is running under views desktop + // rather than native window's working area. + return GetParentNativeWidget()->GetWorkAreaBoundsInScreen(); +} + //////////////////////////////////////////////////////////////////////////////// // NativeWidgetViews, private: @@ -522,4 +548,41 @@ const internal::NativeWidgetPrivate* NULL; } +bool NativeWidgetViews::HandleWindowOperation(const MouseEvent& event) { + if (event.type() != ui::ET_MOUSE_PRESSED) + return false; + + Widget* widget = GetWidget(); + if (widget->non_client_view()) { + int hittest_code = widget->non_client_view()->NonClientHitTest( + event.location()); + switch (hittest_code) { + case HTCAPTION: { + if (!event.IsOnlyRightMouseButton()) { + WindowManager::Get()->StartMoveDrag(widget, event.location()); + return true; + } + break; + } + case HTBOTTOM: + case HTBOTTOMLEFT: + case HTBOTTOMRIGHT: + case HTGROWBOX: + case HTLEFT: + case HTRIGHT: + case HTTOP: + case HTTOPLEFT: + case HTTOPRIGHT: { + WindowManager::Get()->StartResizeDrag( + widget, event.location(), hittest_code); + return true; + } + default: + // Everything else falls into standard client event handling. + break; + } + } + return false; +} + } // namespace views |