diff options
author | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-14 19:51:27 +0000 |
---|---|---|
committer | oshima@google.com <oshima@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-14 19:51:27 +0000 |
commit | 5084fddc4d0672d5062bb3626d3a7c13525a2a41 (patch) | |
tree | 9d19bde6c1706550c013c7cb47d6dc0f4d2e3009 /views | |
parent | a485f51aef852de42617b523db71794349664764 (diff) | |
download | chromium_src-5084fddc4d0672d5062bb3626d3a7c13525a2a41.zip chromium_src-5084fddc4d0672d5062bb3626d3a7c13525a2a41.tar.gz chromium_src-5084fddc4d0672d5062bb3626d3a7c13525a2a41.tar.bz2 |
Revert "Relanding 100792"
This reverts commit 1de05c148460b26037b069501c19ee0c20aeb4ad.
TBR=backer@chromium.org
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7888049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101131 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/controls/button/menu_button.cc | 4 | ||||
-rw-r--r-- | views/widget/native_widget_gtk.cc | 28 | ||||
-rw-r--r-- | views/widget/native_widget_gtk.h | 1 | ||||
-rw-r--r-- | views/widget/native_widget_private.h | 1 | ||||
-rw-r--r-- | views/widget/native_widget_view.cc | 51 | ||||
-rw-r--r-- | views/widget/native_widget_views.cc | 83 | ||||
-rw-r--r-- | views/widget/native_widget_views.h | 12 | ||||
-rw-r--r-- | views/widget/native_widget_win.cc | 4 | ||||
-rw-r--r-- | views/widget/native_widget_win.h | 1 | ||||
-rw-r--r-- | views/widget/widget.cc | 6 | ||||
-rw-r--r-- | views/widget/widget.h | 3 |
11 files changed, 73 insertions, 121 deletions
diff --git a/views/controls/button/menu_button.cc b/views/controls/button/menu_button.cc index e9d8f61..64f4795 100644 --- a/views/controls/button/menu_button.cc +++ b/views/controls/button/menu_button.cc @@ -258,7 +258,9 @@ int MenuButton::GetMaximumScreenXCoordinate() { return 0; } - gfx::Rect monitor_bounds = GetWidget()->GetWorkAreaBoundsInScreen(); + gfx::Rect monitor_bounds = + gfx::Screen::GetMonitorWorkAreaNearestWindow( + GetWidget()->GetTopLevelWidget()->GetNativeView()); return monitor_bounds.right() - 1; } diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc index 564bb46..634a754 100644 --- a/views/widget/native_widget_gtk.cc +++ b/views/widget/native_widget_gtk.cc @@ -1331,10 +1331,6 @@ bool NativeWidgetGtk::ConvertPointFromAncestor( return false; } -gfx::Rect NativeWidgetGtk::GetWorkAreaBoundsInScreen() const { - return gfx::Screen::GetMonitorWorkAreaNearestWindow(GetNativeView()); -} - //////////////////////////////////////////////////////////////////////////////// // NativeWidgetGtk, protected: @@ -2136,20 +2132,22 @@ bool Widget::ConvertRect(const Widget* source, DCHECK(target); DCHECK(rect); - // TODO(oshima): Add check if source and target belongs to the same - // screen. - - if (source == target) + GtkWidget* source_widget = source->GetNativeView(); + GtkWidget* target_widget = target->GetNativeView(); + if (source_widget == target_widget) return true; - if (!source || !target) - return false; - gfx::Point source_point = source->GetWindowScreenBounds().origin(); - gfx::Point target_point = target->GetWindowScreenBounds().origin(); + if (!source_widget || !target_widget) + return false; - rect->set_origin( - source_point.Subtract(target_point).Add(rect->origin())); - return true; + GdkRectangle gdk_rect = rect->ToGdkRectangle(); + if (gtk_widget_translate_coordinates(source_widget, target_widget, + gdk_rect.x, gdk_rect.y, + &gdk_rect.x, &gdk_rect.y)) { + *rect = gdk_rect; + return true; + } + return false; } namespace internal { diff --git a/views/widget/native_widget_gtk.h b/views/widget/native_widget_gtk.h index 152d462..0cdc9f2 100644 --- a/views/widget/native_widget_gtk.h +++ b/views/widget/native_widget_gtk.h @@ -220,7 +220,6 @@ class VIEWS_EXPORT NativeWidgetGtk : public internal::NativeWidgetPrivate, virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE; virtual bool ConvertPointFromAncestor( const Widget* ancestor, gfx::Point* point) const OVERRIDE; - virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE; protected: // Modifies event coordinates to the targeted widget contained by this widget. diff --git a/views/widget/native_widget_private.h b/views/widget/native_widget_private.h index 63471d4..43f0935 100644 --- a/views/widget/native_widget_private.h +++ b/views/widget/native_widget_private.h @@ -203,7 +203,6 @@ class VIEWS_EXPORT NativeWidgetPrivate : public NativeWidget, virtual void FocusNativeView(gfx::NativeView native_view) = 0; virtual bool ConvertPointFromAncestor( const Widget* ancestor, gfx::Point* point) const = 0; - virtual gfx::Rect GetWorkAreaBoundsInScreen() const = 0; // Overridden from NativeWidget: virtual internal::NativeWidgetPrivate* AsNativeWidgetPrivate() OVERRIDE; diff --git a/views/widget/native_widget_view.cc b/views/widget/native_widget_view.cc index 65762b1..8037e9b 100644 --- a/views/widget/native_widget_view.cc +++ b/views/widget/native_widget_view.cc @@ -5,6 +5,10 @@ #include "views/widget/native_widget_view.h" #include "ui/gfx/canvas.h" +#if defined(OS_LINUX) +#include "views/window/hit_test.h" +#endif +#include "views/widget/window_manager.h" namespace views { namespace internal { @@ -56,7 +60,7 @@ void NativeWidgetView::ViewHierarchyChanged(bool is_add, } void NativeWidgetView::OnBoundsChanged(const gfx::Rect& previous_bounds) { - native_widget_->OnBoundsChanged(bounds(), previous_bounds); + delegate()->OnNativeWidgetSizeChanged(size()); } void NativeWidgetView::OnPaint(gfx::Canvas* canvas) { @@ -68,15 +72,46 @@ gfx::NativeCursor NativeWidgetView::GetCursor(const MouseEvent& event) { } bool NativeWidgetView::OnMousePressed(const MouseEvent& event) { - return native_widget_->OnMouseEvent(event); + Widget* hosting_widget = GetAssociatedWidget(); + if (hosting_widget->non_client_view()) { + int hittest_code = hosting_widget->non_client_view()->NonClientHitTest( + event.location()); + switch (hittest_code) { + case HTCAPTION: { + if (!event.IsOnlyRightMouseButton()) { + WindowManager::Get()->StartMoveDrag(hosting_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( + hosting_widget, event.location(), hittest_code); + return true; + } + default: + // Everything else falls into standard client event handling... + break; + } + } + + return delegate()->OnMouseEvent(event); } bool NativeWidgetView::OnMouseDragged(const MouseEvent& event) { - return native_widget_->OnMouseEvent(event); + return delegate()->OnMouseEvent(event); } void NativeWidgetView::OnMouseReleased(const MouseEvent& event) { - native_widget_->OnMouseEvent(event); + delegate()->OnMouseEvent(event); } void NativeWidgetView::OnMouseCaptureLost() { @@ -84,15 +119,15 @@ void NativeWidgetView::OnMouseCaptureLost() { } void NativeWidgetView::OnMouseMoved(const MouseEvent& event) { - native_widget_->OnMouseEvent(event); + delegate()->OnMouseEvent(event); } void NativeWidgetView::OnMouseEntered(const MouseEvent& event) { - native_widget_->OnMouseEvent(event); + delegate()->OnMouseEvent(event); } void NativeWidgetView::OnMouseExited(const MouseEvent& event) { - native_widget_->OnMouseEvent(event); + delegate()->OnMouseEvent(event); } ui::TouchStatus NativeWidgetView::OnTouchEvent(const TouchEvent& event) { @@ -108,7 +143,7 @@ bool NativeWidgetView::OnKeyReleased(const KeyEvent& event) { } bool NativeWidgetView::OnMouseWheel(const MouseWheelEvent& event) { - return native_widget_->OnMouseEvent(event); + return delegate()->OnMouseEvent(event); } void NativeWidgetView::VisibilityChanged(View* starting_from, diff --git a/views/widget/native_widget_views.cc b/views/widget/native_widget_views.cc index f01a0a9..ed12405 100644 --- a/views/widget/native_widget_views.cc +++ b/views/widget/native_widget_views.cc @@ -18,10 +18,6 @@ #include "views/ime/mock_input_method.h" #endif -#if defined(OS_LINUX) -#include "views/window/hit_test.h" -#endif - namespace views { //////////////////////////////////////////////////////////////////////////////// @@ -34,6 +30,7 @@ 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) { } @@ -98,18 +95,6 @@ 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) { @@ -117,13 +102,11 @@ void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) { always_on_top_ = params.keep_on_top; View* parent_view = NULL; if (params.parent_widget) { - parent_view = params.parent_widget->GetChildViewParent(); - } else if (ViewsDelegate::views_delegate && - ViewsDelegate::views_delegate->GetDefaultParentView()) { + hosting_widget_ = params.parent_widget; + parent_view = hosting_widget_->GetChildViewParent(); + } else { parent_view = ViewsDelegate::views_delegate->GetDefaultParentView(); - } else if (params.parent) { - Widget* widget = Widget::GetWidgetForNativeView(params.parent); - parent_view = widget->GetChildViewParent(); + hosting_widget_ = parent_view->GetWidget(); } view_ = new internal::NativeWidgetView(this); @@ -141,8 +124,7 @@ void NativeWidgetViews::InitNativeWidget(const Widget::InitParams& params) { if (ownership_ == Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET) view_->set_delete_native_widget(false); - if (parent_view) - parent_view->AddChildView(view_); + parent_view->AddChildView(view_); // TODO(beng): SetInitParams(). } @@ -183,8 +165,7 @@ Widget* NativeWidgetViews::GetTopLevelWidget() { // view_ has already been unset. if (!view_) return GetWidget(); - if (ViewsDelegate::views_delegate && - view_->parent() == ViewsDelegate::views_delegate->GetDefaultParentView()) + if (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 @@ -195,11 +176,11 @@ Widget* NativeWidgetViews::GetTopLevelWidget() { } const ui::Compositor* NativeWidgetViews::GetCompositor() const { - return view_->GetWidget() ? view_->GetWidget()->GetCompositor() : NULL; + return hosting_widget_->GetCompositor(); } ui::Compositor* NativeWidgetViews::GetCompositor() { - return view_->GetWidget() ? view_->GetWidget()->GetCompositor() : NULL; + return hosting_widget_->GetCompositor(); } void NativeWidgetViews::CalculateOffsetToAncestorWithLayer( @@ -486,7 +467,7 @@ void NativeWidgetViews::RunShellDrag(View* view, } void NativeWidgetViews::SchedulePaintInRect(const gfx::Rect& rect) { - view_->SchedulePaintInRect(rect); + view_->SchedulePaintInternal(rect); } void NativeWidgetViews::SetCursor(gfx::NativeCursor cursor) { @@ -523,13 +504,6 @@ 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: @@ -548,41 +522,4 @@ 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 diff --git a/views/widget/native_widget_views.h b/views/widget/native_widget_views.h index 3c43a57..2600c32 100644 --- a/views/widget/native_widget_views.h +++ b/views/widget/native_widget_views.h @@ -47,12 +47,7 @@ class VIEWS_EXPORT NativeWidgetViews : public internal::NativeWidgetPrivate { internal::NativeWidgetDelegate* delegate() const { return delegate_; } protected: - friend class internal::NativeWidgetView; - - // Event handlers that subclass can implmenet custom behavior. - virtual void OnBoundsChanged(const gfx::Rect& new_bounds, - const gfx::Rect& old_bounds); - virtual bool OnMouseEvent(const MouseEvent& event); + friend class NativeWidgetView; // Overridden from internal::NativeWidgetPrivate: virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE; @@ -135,7 +130,6 @@ class VIEWS_EXPORT NativeWidgetViews : public internal::NativeWidgetPrivate { virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE; virtual bool ConvertPointFromAncestor( const Widget* ancestor, gfx::Point* point) const OVERRIDE; - virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE; // Overridden from internal::InputMethodDelegate virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE; @@ -147,8 +141,6 @@ class VIEWS_EXPORT NativeWidgetViews : public internal::NativeWidgetPrivate { internal::NativeWidgetPrivate* GetParentNativeWidget(); const internal::NativeWidgetPrivate* GetParentNativeWidget() const; - bool HandleWindowOperation(const MouseEvent& event); - internal::NativeWidgetDelegate* delegate_; internal::NativeWidgetView* view_; @@ -167,6 +159,8 @@ class VIEWS_EXPORT NativeWidgetViews : public internal::NativeWidgetPrivate { gfx::Rect restored_bounds_; ui::Transform restored_transform_; + Widget* hosting_widget_; + // See class documentation for Widget in widget.h for a note about ownership. Widget::InitParams::Ownership ownership_; diff --git a/views/widget/native_widget_win.cc b/views/widget/native_widget_win.cc index a22c4cc..af30d49 100644 --- a/views/widget/native_widget_win.cc +++ b/views/widget/native_widget_win.cc @@ -1105,10 +1105,6 @@ bool NativeWidgetWin::ConvertPointFromAncestor( return false; } -gfx::Rect NativeWidgetWin::GetWorkAreaBoundsInScreen() const { - return gfx::Screen::GetMonitorWorkAreaNearestWindow(GetNativeView()); -} - //////////////////////////////////////////////////////////////////////////////// // NativeWidgetWin, MessageLoop::Observer implementation: diff --git a/views/widget/native_widget_win.h b/views/widget/native_widget_win.h index 11125fe..1132d47 100644 --- a/views/widget/native_widget_win.h +++ b/views/widget/native_widget_win.h @@ -266,7 +266,6 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl, virtual void FocusNativeView(gfx::NativeView native_view) OVERRIDE; virtual bool ConvertPointFromAncestor( const Widget* ancestor, gfx::Point* point) const OVERRIDE; - virtual gfx::Rect GetWorkAreaBoundsInScreen() const OVERRIDE; protected: // Information saved before going into fullscreen mode, used to restore the diff --git a/views/widget/widget.cc b/views/widget/widget.cc index e298cff..b16a557 100644 --- a/views/widget/widget.cc +++ b/views/widget/widget.cc @@ -609,7 +609,7 @@ ThemeProvider* Widget::GetThemeProvider() const { } FocusManager* Widget::GetFocusManager() { - const Widget* toplevel_widget = GetTopLevelWidget(); + Widget* toplevel_widget = GetTopLevelWidget(); return toplevel_widget ? toplevel_widget->focus_manager_.get() : NULL; } @@ -804,10 +804,6 @@ View* Widget::GetChildViewParent() { return GetContentsView() ? GetContentsView() : GetRootView(); } -gfx::Rect Widget::GetWorkAreaBoundsInScreen() const { - return native_widget_->GetWorkAreaBoundsInScreen(); -} - //////////////////////////////////////////////////////////////////////////////// // Widget, NativeWidgetDelegate implementation: diff --git a/views/widget/widget.h b/views/widget/widget.h index 368432c..8104b1c 100644 --- a/views/widget/widget.h +++ b/views/widget/widget.h @@ -565,9 +565,6 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, // TYPE_CONTROL and TYPE_TOOLTIP is not considered top level. bool is_top_level() const { return is_top_level_; } - // Returns the bounds of work area in the screen that Widget belongs to. - gfx::Rect GetWorkAreaBoundsInScreen() const; - // Overridden from NativeWidgetDelegate: virtual bool IsModal() const OVERRIDE; virtual bool IsDialogBox() const OVERRIDE; |