summaryrefslogtreecommitdiffstats
path: root/views/widget
diff options
context:
space:
mode:
Diffstat (limited to 'views/widget')
-rw-r--r--views/widget/native_widget_gtk.cc28
-rw-r--r--views/widget/native_widget_gtk.h1
-rw-r--r--views/widget/native_widget_private.h1
-rw-r--r--views/widget/native_widget_view.cc51
-rw-r--r--views/widget/native_widget_views.cc79
-rw-r--r--views/widget/native_widget_views.h12
-rw-r--r--views/widget/native_widget_win.cc4
-rw-r--r--views/widget/native_widget_win.h1
-rw-r--r--views/widget/widget.cc6
-rw-r--r--views/widget/widget.h3
10 files changed, 69 insertions, 117 deletions
diff --git a/views/widget/native_widget_gtk.cc b/views/widget/native_widget_gtk.cc
index d1eeb23..7cb5892 100644
--- a/views/widget/native_widget_gtk.cc
+++ b/views/widget/native_widget_gtk.cc
@@ -1333,10 +1333,6 @@ bool NativeWidgetGtk::ConvertPointFromAncestor(
return false;
}
-gfx::Rect NativeWidgetGtk::GetWorkAreaBoundsInScreen() const {
- return gfx::Screen::GetMonitorWorkAreaNearestWindow(GetNativeView());
-}
-
////////////////////////////////////////////////////////////////////////////////
// NativeWidgetGtk, protected:
@@ -2138,20 +2134,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 fed434f..eb5ec4a 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 f47c5ac..dbeab12 100644
--- a/views/widget/native_widget_private.h
+++ b/views/widget/native_widget_private.h
@@ -204,7 +204,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 500c614..0b60850 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 {
@@ -63,7 +67,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) {
@@ -75,15 +79,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() {
@@ -91,15 +126,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) {
@@ -115,7 +150,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 68b9c0e..44f2d9d 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,12 +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->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);
@@ -140,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().
}
@@ -193,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::MarkLayerDirty() {
@@ -487,7 +470,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) {
@@ -524,13 +507,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:
@@ -549,41 +525,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 b0c2ea3..eaa2804 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 b75a4a9..23ef015 100644
--- a/views/widget/native_widget_win.cc
+++ b/views/widget/native_widget_win.cc
@@ -1092,10 +1092,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 43b4a76..967ed85 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 39e7e8b..8ed6c8d 100644
--- a/views/widget/widget.cc
+++ b/views/widget/widget.cc
@@ -604,7 +604,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;
}
@@ -803,10 +803,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 b5ba346..dd23dd6 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;