summaryrefslogtreecommitdiffstats
path: root/views/widget/native_widget_views.cc
diff options
context:
space:
mode:
authoroshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-19 19:06:15 +0000
committeroshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-19 19:06:15 +0000
commit8647714eef4b0eb718c5b2682f14c9b0f5ecce13 (patch)
treee38a7ec5f5839f3f2ffbe5c546bac5406e09258a /views/widget/native_widget_views.cc
parent02fe9c2b6adab15311c621a611d2405f1ea6551b (diff)
downloadchromium_src-8647714eef4b0eb718c5b2682f14c9b0f5ecce13.zip
chromium_src-8647714eef4b0eb718c5b2682f14c9b0f5ecce13.tar.gz
chromium_src-8647714eef4b0eb718c5b2682f14c9b0f5ecce13.tar.bz2
Simple WindowManager that can move/resize window.
Fixes TouchFrame's NonClientHitTest to ignore VirtualKeyboard area. Move mouse capture logic to Window Manager so that nested mouse capture with nested NWVs works correctly. Note1: This is a tentative WM that allows us to move/resize window in views desktop until we have real window manager based on aura/layer API. Note2: There is an compositor related issue and doesn't work well when compositor is enabled. I'll look into it after this CL. Review URL: http://codereview.chromium.org/7530017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97492 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/widget/native_widget_views.cc')
-rw-r--r--views/widget/native_widget_views.cc43
1 files changed, 27 insertions, 16 deletions
diff --git a/views/widget/native_widget_views.cc b/views/widget/native_widget_views.cc
index 4009df8..ebb141e 100644
--- a/views/widget/native_widget_views.cc
+++ b/views/widget/native_widget_views.cc
@@ -10,6 +10,7 @@
#include "views/views_delegate.h"
#include "views/widget/native_widget_view.h"
#include "views/widget/root_view.h"
+#include "views/widget/window_manager.h"
#if defined(HAVE_IBUS)
#include "views/ime/input_method_ibus.h"
@@ -215,28 +216,15 @@ void NativeWidgetViews::SendNativeAccessibilityEvent(
}
void NativeWidgetViews::SetMouseCapture() {
- View* parent_root_view = GetParentNativeWidget()->GetWidget()->GetRootView();
- static_cast<internal::RootView*>(parent_root_view)->set_capture_view(view_);
- GetParentNativeWidget()->SetMouseCapture();
+ WindowManager::Get()->SetMouseCapture(GetWidget());
}
void NativeWidgetViews::ReleaseMouseCapture() {
- View* parent_root_view = GetParentNativeWidget()->GetWidget()->GetRootView();
- static_cast<internal::RootView*>(parent_root_view)->set_capture_view(NULL);
- GetParentNativeWidget()->ReleaseMouseCapture();
+ WindowManager::Get()->ReleaseMouseCapture(GetWidget());
}
bool NativeWidgetViews::HasMouseCapture() const {
- // NOTE: we may need to tweak this to only return true if the parent native
- // widget's RootView has us as the capture view.
- const internal::NativeWidgetPrivate* parent_widget = GetParentNativeWidget();
- if (!parent_widget)
- return false;
- const internal::RootView* parent_root =
- static_cast<const internal::RootView*>(parent_widget->GetWidget()->
- GetRootView());
- return parent_widget->HasMouseCapture() &&
- view_ == parent_root->capture_view();
+ return WindowManager::Get()->HasMouseCapture(GetWidget());
}
InputMethod* NativeWidgetViews::GetInputMethodNative() {
@@ -363,6 +351,8 @@ void NativeWidgetViews::Show() {
void NativeWidgetViews::Hide() {
view_->SetVisible(false);
+ if (HasMouseCapture())
+ ReleaseMouseCapture();
}
void NativeWidgetViews::ShowWithState(ShowState state) {
@@ -491,6 +481,27 @@ void NativeWidgetViews::FocusNativeView(gfx::NativeView native_view) {
GetParentNativeWidget()->FocusNativeView(native_view);
}
+bool NativeWidgetViews::ConvertPointFromAncestor(
+ const Widget* ancestor, gfx::Point* point) const {
+ // This method converts the point from ancestor's coordinates to
+ // this widget's coordinate using recursion as the widget hierachy
+ // is usually shallow.
+
+ if (ancestor == GetWidget())
+ return true; // no conversion necessary
+
+ const Widget* parent_widget = view_->GetWidget();
+ if (!parent_widget) // couldn't reach the ancestor.
+ return false;
+
+ if (parent_widget == ancestor ||
+ parent_widget->ConvertPointFromAncestor(ancestor, point)) {
+ View::ConvertPointToView(parent_widget->GetRootView(), GetView(), point);
+ return true;
+ }
+ return false;
+}
+
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetViews, private: