diff options
author | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-11 17:46:07 +0000 |
---|---|---|
committer | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-08-11 17:46:07 +0000 |
commit | 621adaae105bee50e90d58accbe4d52f6bd8139c (patch) | |
tree | 90d49a019e072a16f61263e761a75fb648c0d4a0 /chrome/views | |
parent | 59b872f5f1d071077e57b828162e9246c2a5c255 (diff) | |
download | chromium_src-621adaae105bee50e90d58accbe4d52f6bd8139c.zip chromium_src-621adaae105bee50e90d58accbe4d52f6bd8139c.tar.gz chromium_src-621adaae105bee50e90d58accbe4d52f6bd8139c.tar.bz2 |
Add support for ChromeViews::Windows to disable inactive rendering. This is for the new frames to make it so when infobubbles are activated the window frame isn't deactivated.
B=1318343
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@659 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views')
-rw-r--r-- | chrome/views/custom_frame_window.cc | 13 | ||||
-rw-r--r-- | chrome/views/custom_frame_window.h | 1 | ||||
-rw-r--r-- | chrome/views/non_client_view.h | 17 | ||||
-rw-r--r-- | chrome/views/window.cc | 33 | ||||
-rw-r--r-- | chrome/views/window.h | 17 |
5 files changed, 67 insertions, 14 deletions
diff --git a/chrome/views/custom_frame_window.cc b/chrome/views/custom_frame_window.cc index 711ccc8..5dc425a 100644 --- a/chrome/views/custom_frame_window.cc +++ b/chrome/views/custom_frame_window.cc @@ -274,7 +274,8 @@ class DefaultNonClientView : public NonClientView, // Returns the resource collection to be used when rendering the window. WindowResources* resources() const { - return container_->is_active() ? active_resources_ : inactive_resources_; + return container_->is_active() || paint_as_active() ? active_resources_ + : inactive_resources_; } // The View that provides the background for the window, and optionally @@ -332,7 +333,8 @@ static const int kWindowVerticalBorderSize = 4; DefaultNonClientView::DefaultNonClientView( CustomFrameWindow* container) - : client_view_(NULL), + : NonClientView(), + client_view_(NULL), close_button_(new Button), restore_button_(new Button), maximize_button_(new Button), @@ -902,6 +904,13 @@ void CustomFrameWindow::EnableClose(bool enable) { Window::EnableClose(enable); } +void CustomFrameWindow::DisableInactiveRendering(bool disable) { + Window::DisableInactiveRendering(disable); + non_client_view_->set_paint_as_active(disable); + if (!disable) + non_client_view_->SchedulePaint(); +} + void CustomFrameWindow::SizeWindowToDefault() { CSize pref(0, 0); client_view()->GetPreferredSize(&pref); diff --git a/chrome/views/custom_frame_window.h b/chrome/views/custom_frame_window.h index b540de0..592c317 100644 --- a/chrome/views/custom_frame_window.h +++ b/chrome/views/custom_frame_window.h @@ -73,6 +73,7 @@ class CustomFrameWindow : public Window { // Overridden from Window: virtual void SizeWindowToDefault(); virtual void EnableClose(bool enable); + virtual void DisableInactiveRendering(bool disable); // Overridden from HWNDViewContainer: virtual void OnInitMenu(HMENU menu); diff --git a/chrome/views/non_client_view.h b/chrome/views/non_client_view.h index 9c83a67..ad5dec8 100644 --- a/chrome/views/non_client_view.h +++ b/chrome/views/non_client_view.h @@ -79,7 +79,15 @@ class NonClientView : public View { // the system menu). virtual void EnableClose(bool enable) = 0; + // Prevents the non-client view from rendering as inactive when called with + // |disable| true, until called with false. + void set_paint_as_active(bool paint_as_active) { + paint_as_active_ = paint_as_active; + } + protected: + NonClientView() : paint_as_active_(false) {} + // Helper for non-client view implementations to determine which area of the // window border the specified |point| falls within. The other parameters are // the size of the sizing edges, and whether or not the window can be @@ -89,6 +97,15 @@ class NonClientView : public View { int resize_area_corner_size, int top_resize_area_size, bool can_resize); + + // Accessor for paint_as_active_. + bool paint_as_active() const { return paint_as_active_; } + + private: + // True when the non-client view should always be rendered as if the window + // were active, regardless of whether or not the top level window actually + // is active. + bool paint_as_active_; }; } // namespace ChromeViews diff --git a/chrome/views/window.cc b/chrome/views/window.cc index 66f3f93..47b4444 100644 --- a/chrome/views/window.cc +++ b/chrome/views/window.cc @@ -158,20 +158,19 @@ bool Window::IsMinimized() const { void Window::EnableClose(bool enable) { EnableMenuItem(::GetSystemMenu(GetHWND(), false), - SC_CLOSE, - enable ? MF_ENABLED : MF_GRAYED); + SC_CLOSE, enable ? MF_ENABLED : MF_GRAYED); // Let the window know the frame changed. SetWindowPos(NULL, 0, 0, 0, 0, - SWP_FRAMECHANGED | - SWP_NOACTIVATE | - SWP_NOCOPYBITS | - SWP_NOMOVE | - SWP_NOOWNERZORDER | - SWP_NOREPOSITION | - SWP_NOSENDCHANGING | - SWP_NOSIZE | - SWP_NOZORDER); + SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOCOPYBITS | + SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOREPOSITION | + SWP_NOSENDCHANGING | SWP_NOSIZE | SWP_NOZORDER); +} + +void Window::DisableInactiveRendering(bool disable) { + disable_inactive_rendering_ = disable; + if (!disable_inactive_rendering_) + DefWindowProc(GetHWND(), WM_NCACTIVATE, FALSE, 0); } void Window::UpdateWindowTitle() { @@ -275,7 +274,8 @@ Window::Window(WindowDelegate* window_delegate) is_modal_(false), restored_enabled_(false), is_always_on_top_(false), - window_closed_(false) { + window_closed_(false), + disable_inactive_rendering_(false) { InitClass(); DCHECK(window_delegate_); window_delegate_->window_.reset(this); @@ -368,6 +368,15 @@ LRESULT Window::OnEraseBkgnd(HDC dc) { return 1; } +LRESULT Window::OnNCActivate(BOOL active) { + if (disable_inactive_rendering_) { + disable_inactive_rendering_ = false; + return DefWindowProc(GetHWND(), WM_NCACTIVATE, TRUE, 0); + } + // Otherwise just do the default thing. + return HWNDViewContainer::OnNCActivate(active); +} + LRESULT Window::OnNCHitTest(const CPoint& point) { // First, give the ClientView a chance to test the point to see if it is part // of the non-client area. diff --git a/chrome/views/window.h b/chrome/views/window.h index c7686c3..87349e7 100644 --- a/chrome/views/window.h +++ b/chrome/views/window.h @@ -100,6 +100,13 @@ class Window : public HWNDViewContainer { // the system menu). virtual void EnableClose(bool enable); + // Prevents the window from being rendered as deactivated when |disable| is + // true, until called with |disable| false. Used when a sub-window is to be + // shown that shouldn't visually de-activate the window. + // Subclasses can override this to perform additional actions when this value + // changes. + virtual void DisableInactiveRendering(bool disable); + WindowDelegate* window_delegate() const { return window_delegate_; } // Returns the ClientView object used by this Window. @@ -173,6 +180,7 @@ class Window : public HWNDViewContainer { virtual void OnCommand(UINT notification_code, int command_id, HWND window); virtual void OnDestroy(); virtual LRESULT OnEraseBkgnd(HDC dc); + virtual LRESULT OnNCActivate(BOOL active); virtual LRESULT OnNCHitTest(const CPoint& point); virtual LRESULT OnSetCursor(HWND window, UINT hittest_code, UINT message); virtual void OnSize(UINT size_param, const CSize& new_size); @@ -184,6 +192,11 @@ class Window : public HWNDViewContainer { // desired implementation before calling |Init|. NonClientView* non_client_view_; + // Accessor for disable_inactive_rendering_. + bool disable_inactive_rendering() const { + return disable_inactive_rendering_; + } + private: // Set the window as modal (by disabling all the other windows). void BecomeModal(); @@ -254,6 +267,10 @@ class Window : public HWNDViewContainer { // Set to true if the window is in the process of closing . bool window_closed_; + // True when the window should be rendered as active, regardless of whether + // or not it actually is. + bool disable_inactive_rendering_; + DISALLOW_EVIL_CONSTRUCTORS(Window); }; |