summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-14 19:05:03 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-14 19:05:03 +0000
commit4a6ccfae6fc623853692256afc65b8afd7e33107 (patch)
tree908b8cde4844ef57adb58f020cb134e0f82d2f6d /views
parentc933965b0974d3bd8b090b12766520c0878502a0 (diff)
downloadchromium_src-4a6ccfae6fc623853692256afc65b8afd7e33107.zip
chromium_src-4a6ccfae6fc623853692256afc65b8afd7e33107.tar.gz
chromium_src-4a6ccfae6fc623853692256afc65b8afd7e33107.tar.bz2
Migrate more of BrowserFrame's event handling down into WindowWin/WidgetWin and their delegate interfaces.
BUG=72040 TEST=none Review URL: http://codereview.chromium.org/6683007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78062 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/widget/widget_delegate.h21
-rw-r--r--views/widget/widget_gtk.cc2
-rw-r--r--views/widget/widget_win.cc6
-rw-r--r--views/window/native_window.h6
-rw-r--r--views/window/native_window_delegate.h4
-rw-r--r--views/window/window.cc10
-rw-r--r--views/window/window.h2
-rw-r--r--views/window/window_delegate.h9
-rw-r--r--views/window/window_gtk.cc16
-rw-r--r--views/window/window_gtk.h4
-rw-r--r--views/window/window_win.cc45
-rw-r--r--views/window/window_win.h6
12 files changed, 93 insertions, 38 deletions
diff --git a/views/widget/widget_delegate.h b/views/widget/widget_delegate.h
index 71ea6ee..b37c391 100644
--- a/views/widget/widget_delegate.h
+++ b/views/widget/widget_delegate.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2006-2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 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.
@@ -14,15 +14,20 @@ class WidgetDelegate {
public:
virtual ~WidgetDelegate() {}
- // Called with the display changes (color depth or resolution).
- virtual void DisplayChanged() {}
+ // Called whenever the widget is activated or deactivated.
+ // TODO(beng): This should be consolidated with
+ // WindowDelegate::OnWindowActivationChanged().
+ virtual void OnWidgetActivated(bool active) {}
+
+ // Called whenever the widget's position changes.
+ virtual void OnWidgetMove() {}
- // Called when widget active state has changed.
- virtual void IsActiveChanged(bool active) {}
+ // Called with the display changes (color depth or resolution).
+ virtual void OnDisplayChanged() {}
- // Called when the work area (the desktop area minus taskbars,
- // menubars, etc.) changes in size.
- virtual void WorkAreaChanged() {}
+ // Called when the work area (the desktop area minus task bars,
+ // menu bars, etc.) changes in size.
+ virtual void OnWorkAreaChanged() {}
};
} // namespace views
diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc
index ec9ef0c..a33d70f 100644
--- a/views/widget/widget_gtk.cc
+++ b/views/widget/widget_gtk.cc
@@ -423,7 +423,7 @@ void WidgetGtk::DoDrag(const OSExchangeData& data, int operation) {
void WidgetGtk::IsActiveChanged() {
if (widget_delegate())
- widget_delegate()->IsActiveChanged(IsActive());
+ widget_delegate()->OnWidgetActivated(IsActive());
}
void WidgetGtk::ResetDropTarget() {
diff --git a/views/widget/widget_win.cc b/views/widget/widget_win.cc
index 783c5ca..3be1d70 100644
--- a/views/widget/widget_win.cc
+++ b/views/widget/widget_win.cc
@@ -564,7 +564,7 @@ void WidgetWin::OnDestroy() {
void WidgetWin::OnDisplayChange(UINT bits_per_pixel, CSize screen_size) {
if (widget_delegate())
- widget_delegate()->DisplayChanged();
+ widget_delegate()->OnDisplayChanged();
}
LRESULT WidgetWin::OnDwmCompositionChanged(UINT msg,
@@ -723,10 +723,12 @@ LRESULT WidgetWin::OnMouseWheel(UINT message, WPARAM w_param, LPARAM l_param) {
}
void WidgetWin::OnMove(const CPoint& point) {
+ widget_delegate()->OnWidgetMove();
SetMsgHandled(FALSE);
}
void WidgetWin::OnMoving(UINT param, const LPRECT new_bounds) {
+ widget_delegate()->OnWidgetMove();
}
LRESULT WidgetWin::OnNCActivate(BOOL active) {
@@ -851,7 +853,7 @@ LRESULT WidgetWin::OnSetText(const wchar_t* text) {
void WidgetWin::OnSettingChange(UINT flags, const wchar_t* section) {
if (flags == SPI_SETWORKAREA && widget_delegate())
- widget_delegate()->WorkAreaChanged();
+ widget_delegate()->OnWorkAreaChanged();
SetMsgHandled(FALSE);
}
diff --git a/views/window/native_window.h b/views/window/native_window.h
index 7e4bd6a..a2fb965 100644
--- a/views/window/native_window.h
+++ b/views/window/native_window.h
@@ -37,6 +37,9 @@ class NativeWindow {
virtual Window* GetWindow() = 0;
+ virtual NativeWidget* AsNativeWidget() = 0;
+ virtual const NativeWidget* AsNativeWidget() const = 0;
+
protected:
friend class Window;
@@ -75,9 +78,6 @@ class NativeWindow {
virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) = 0;
virtual void SetAccessibleState(ui::AccessibilityTypes::State state) = 0;
- virtual NativeWidget* AsNativeWidget() = 0;
- virtual const NativeWidget* AsNativeWidget() const = 0;
-
// Window pass-thrus ---------------------------------------------------------
// See documentation in window.h
diff --git a/views/window/native_window_delegate.h b/views/window/native_window_delegate.h
index 3807cfa..23705a5 100644
--- a/views/window/native_window_delegate.h
+++ b/views/window/native_window_delegate.h
@@ -51,6 +51,10 @@ class NativeWindowDelegate {
// Called when the activation state of a window has changed.
virtual void OnNativeWindowActivationChanged(bool active) = 0;
+ // Called when the user begins/ends to change the bounds of the window.
+ virtual void OnNativeWindowBeginUserBoundsChange() = 0;
+ virtual void OnNativeWindowEndUserBoundsChange() = 0;
+
// Called just before the native window is destroyed. This is the delegate's
// last chance to do anything with the native window handle.
virtual void OnNativeWindowDestroying() = 0;
diff --git a/views/window/window.cc b/views/window/window.cc
index 71f8cd8..ba7d055 100644
--- a/views/window/window.cc
+++ b/views/window/window.cc
@@ -298,7 +298,15 @@ void Window::OnNativeWindowCreated(const gfx::Rect& bounds) {
void Window::OnNativeWindowActivationChanged(bool active) {
if (!active)
SaveWindowPosition();
- window_delegate_->OnWindowActivate(active);
+ window_delegate_->OnWindowActivationChanged(active);
+}
+
+void Window::OnNativeWindowBeginUserBoundsChange() {
+ window_delegate_->OnWindowBeginUserBoundsChange();
+}
+
+void Window::OnNativeWindowEndUserBoundsChange() {
+ window_delegate_->OnWindowEndUserBoundsChange();
}
void Window::OnNativeWindowDestroying() {
diff --git a/views/window/window.h b/views/window/window.h
index fc9f3a5..f18f4bb 100644
--- a/views/window/window.h
+++ b/views/window/window.h
@@ -213,6 +213,8 @@ class Window : public internal::NativeWindowDelegate {
virtual bool ExecuteCommand(int command_id) OVERRIDE;
virtual void OnNativeWindowCreated(const gfx::Rect& bounds) OVERRIDE;
virtual void OnNativeWindowActivationChanged(bool active) OVERRIDE;
+ virtual void OnNativeWindowBeginUserBoundsChange() OVERRIDE;
+ virtual void OnNativeWindowEndUserBoundsChange() OVERRIDE;
virtual void OnNativeWindowDestroying() OVERRIDE;
virtual void OnNativeWindowDestroyed() OVERRIDE;
virtual void OnNativeWindowBoundsChanged() OVERRIDE;
diff --git a/views/window/window_delegate.h b/views/window/window_delegate.h
index 379276c..d1a350a 100644
--- a/views/window/window_delegate.h
+++ b/views/window/window_delegate.h
@@ -10,6 +10,7 @@
#include "base/scoped_ptr.h"
#include "ui/base/accessibility/accessibility_types.h"
+#include "views/widget/widget_delegate.h"
class SkBitmap;
@@ -33,7 +34,7 @@ class Window;
// it should be displayed and notify the delegate object of certain events.
//
///////////////////////////////////////////////////////////////////////////////
-class WindowDelegate {
+class WindowDelegate : public WidgetDelegate {
public:
WindowDelegate();
virtual ~WindowDelegate();
@@ -117,7 +118,11 @@ class WindowDelegate {
virtual void DeleteDelegate() {}
// Called when the window's activation state changes.
- virtual void OnWindowActivate(bool active) {}
+ virtual void OnWindowActivationChanged(bool active) {}
+
+ // Called when the user begins/ends to change the bounds of the window.
+ virtual void OnWindowBeginUserBoundsChange() {}
+ virtual void OnWindowEndUserBoundsChange() {}
// Returns the View that is contained within this Window.
virtual View* GetContentsView();
diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc
index 28bbd6c..46af221 100644
--- a/views/window/window_gtk.cc
+++ b/views/window/window_gtk.cc
@@ -233,6 +233,14 @@ void WindowGtk::SetInitialFocus() {
////////////////////////////////////////////////////////////////////////////////
// WindowGtk, NativeWindow implementation:
+NativeWidget* WindowGtk::AsNativeWidget() {
+ return this;
+}
+
+const NativeWidget* WindowGtk::AsNativeWidget() const {
+ return this;
+}
+
gfx::Rect WindowGtk::GetRestoredBounds() const {
// We currently don't support tiling, so this doesn't matter.
return GetWindowScreenBounds();
@@ -297,14 +305,6 @@ void WindowGtk::SetAccessibleRole(ui::AccessibilityTypes::Role role) {
void WindowGtk::SetAccessibleState(ui::AccessibilityTypes::State state) {
}
-NativeWidget* WindowGtk::AsNativeWidget() {
- return this;
-}
-
-const NativeWidget* WindowGtk::AsNativeWidget() const {
- return this;
-}
-
Window* WindowGtk::GetWindow() {
return this;
}
diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h
index 23d0bce..a6f2c9f 100644
--- a/views/window/window_gtk.h
+++ b/views/window/window_gtk.h
@@ -46,6 +46,8 @@ class WindowGtk : public WidgetGtk, public NativeWindow, public Window {
protected:
// Overridden from NativeWindow:
+ virtual NativeWidget* AsNativeWidget() OVERRIDE;
+ virtual const NativeWidget* AsNativeWidget() const OVERRIDE;
virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
virtual void ShowNativeWindow(ShowState state) OVERRIDE;
virtual void BecomeModal() OVERRIDE;
@@ -59,8 +61,6 @@ class WindowGtk : public WidgetGtk, public NativeWindow, public Window {
virtual void SetAccessibleName(const std::wstring& name) OVERRIDE;
virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE;
virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE;
- virtual NativeWidget* AsNativeWidget() OVERRIDE;
- virtual const NativeWidget* AsNativeWidget() const OVERRIDE;
virtual Window* GetWindow() OVERRIDE;
virtual void SetWindowBounds(const gfx::Rect& bounds,
gfx::NativeWindow other_window) OVERRIDE;
diff --git a/views/window/window_win.cc b/views/window/window_win.cc
index 32583e3..e984b59 100644
--- a/views/window/window_win.cc
+++ b/views/window/window_win.cc
@@ -142,6 +142,13 @@ void EnableMenuItem(HMENU menu, UINT command, bool enabled) {
EnableMenuItem(menu, command, flags);
}
+bool IsDwmRenderingWindowControls(HWND window) {
+ DWMNCRENDERINGPOLICY policy;
+ DwmGetWindowAttribute(window, DWMWA_NCRENDERING_POLICY, &policy,
+ sizeof(policy));
+ return policy == DWMNCRP_ENABLED;
+}
+
// If the hung renderer warning doesn't fit on screen, the amount of padding to
// be left between the edge of the window and the edge of the nearest monitor,
// after the window is nudged back on screen. Pixels.
@@ -432,6 +439,16 @@ LRESULT WindowWin::OnDwmCompositionChanged(UINT msg, WPARAM w_param,
return 0;
}
+void WindowWin::OnEnterSizeMove() {
+ WidgetWin::OnEnterSizeMove();
+ delegate_->OnNativeWindowBeginUserBoundsChange();
+}
+
+void WindowWin::OnExitSizeMove() {
+ WidgetWin::OnExitSizeMove();
+ delegate_->OnNativeWindowEndUserBoundsChange();
+}
+
void WindowWin::OnFinalMessage(HWND window) {
delegate_->OnNativeWindowDestroyed();
WidgetWin::OnFinalMessage(window);
@@ -605,9 +622,19 @@ LRESULT WindowWin::OnNCCalcSize(BOOL mode, LPARAM l_param) {
}
LRESULT WindowWin::OnNCHitTest(const CPoint& point) {
+ // If the DWM is rendering the window controls, we need to give the DWM's
+ // default window procedure first chance to handle hit testing.
+ if (IsDwmRenderingWindowControls(GetNativeView())) {
+ LRESULT result;
+ if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0,
+ MAKELPARAM(point.x, point.y), &result)) {
+ return result;
+ }
+ }
+
// First, give the NonClientView a chance to test the point to see if it
// provides any of the non-client area.
- CPoint temp = point;
+ POINT temp = point;
MapWindowPoints(HWND_DESKTOP, GetNativeView(), &temp, 1);
int component = delegate_->GetNonClientComponent(gfx::Point(temp));
if (component != HTNOWHERE)
@@ -852,6 +879,14 @@ void WindowWin::OnWindowPosChanging(WINDOWPOS* window_pos) {
////////////////////////////////////////////////////////////////////////////////
// WindowWin, NativeWindow implementation:
+NativeWidget* WindowWin::AsNativeWidget() {
+ return this;
+}
+
+const NativeWidget* WindowWin::AsNativeWidget() const {
+ return this;
+}
+
gfx::Rect WindowWin::GetRestoredBounds() const {
// If we're in fullscreen mode, we've changed the normal bounds to the monitor
// rect, so return the saved bounds instead.
@@ -984,14 +1019,6 @@ void WindowWin::SetAccessibleState(ui::AccessibilityTypes::State state) {
}
}
-NativeWidget* WindowWin::AsNativeWidget() {
- return this;
-}
-
-const NativeWidget* WindowWin::AsNativeWidget() const {
- return this;
-}
-
void WindowWin::SetWindowBounds(const gfx::Rect& bounds,
gfx::NativeWindow other_window) {
SetChildBounds(GetNativeView(), GetParent(), other_window, bounds,
diff --git a/views/window/window_win.h b/views/window/window_win.h
index 222608a..114ea1e 100644
--- a/views/window/window_win.h
+++ b/views/window/window_win.h
@@ -104,6 +104,8 @@ class WindowWin : public WidgetWin,
virtual LRESULT OnDwmCompositionChanged(UINT msg,
WPARAM w_param,
LPARAM l_param) OVERRIDE;
+ virtual void OnEnterSizeMove() OVERRIDE;
+ virtual void OnExitSizeMove() OVERRIDE;
virtual void OnFinalMessage(HWND window) OVERRIDE;
virtual void OnGetMinMaxInfo(MINMAXINFO* minmax_info) OVERRIDE;
virtual void OnInitMenu(HMENU menu) OVERRIDE;
@@ -135,6 +137,8 @@ class WindowWin : public WidgetWin,
virtual const Window* GetWindow() const OVERRIDE { return this; }
// Overridden from NativeWindow:
+ virtual NativeWidget* AsNativeWidget() OVERRIDE;
+ virtual const NativeWidget* AsNativeWidget() const OVERRIDE;
virtual gfx::Rect GetRestoredBounds() const OVERRIDE;
virtual void ShowNativeWindow(ShowState state) OVERRIDE;
virtual void BecomeModal() OVERRIDE;
@@ -148,8 +152,6 @@ class WindowWin : public WidgetWin,
virtual void SetAccessibleName(const std::wstring& name) OVERRIDE;
virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE;
virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE;
- virtual NativeWidget* AsNativeWidget() OVERRIDE;
- virtual const NativeWidget* AsNativeWidget() const OVERRIDE;
virtual void SetWindowBounds(const gfx::Rect& bounds,
gfx::NativeWindow other_window) OVERRIDE;
virtual void HideWindow() OVERRIDE;