summaryrefslogtreecommitdiffstats
path: root/views/window
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-14 23:53:45 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-14 23:53:45 +0000
commit883ce2fa8fc0b8f8bf15fb4279ea2464a22cc052 (patch)
tree4eb19bb2c187ba53924b13a0e90d61c669a15c83 /views/window
parente042db5288480d9ca61b155d8b8fa9ea42481554 (diff)
downloadchromium_src-883ce2fa8fc0b8f8bf15fb4279ea2464a22cc052.zip
chromium_src-883ce2fa8fc0b8f8bf15fb4279ea2464a22cc052.tar.gz
chromium_src-883ce2fa8fc0b8f8bf15fb4279ea2464a22cc052.tar.bz2
Reland 78062 with some NULL checks.
Revert 78062 - 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 TBR=ben@chromium.org Review URL: http://codereview.chromium.org/6686059 Review URL: http://codereview.chromium.org/6677029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@78129 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/window')
-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.h4
-rw-r--r--views/window/window_win.cc48
-rw-r--r--views/window/window_win.h6
8 files changed, 70 insertions, 19 deletions
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.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..4708df5 100644
--- a/views/window/window_win.cc
+++ b/views/window/window_win.cc
@@ -142,6 +142,16 @@ void EnableMenuItem(HMENU menu, UINT command, bool enabled) {
EnableMenuItem(menu, command, flags);
}
+bool IsDwmRenderingWindowControls(HWND window) {
+ if (base::win::GetVersion() < base::win::VERSION_VISTA)
+ return false;
+
+ 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 +442,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 +625,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 +882,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 +1022,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;