Commit e7dc3d58 authored by pkotwicz@chromium.org's avatar pkotwicz@chromium.org

Fix regression where the active window header was not used for v2 apps on CrOS

BUG=331343
TEST=Manual, see bug

Review URL: https://codereview.chromium.org/99553008

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243677 0039d316-1c4b-4281-b951-d872f2087c98
parent ee8808c5
......@@ -21,6 +21,7 @@
#include "ui/gfx/canvas.h"
#include "ui/gfx/font.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/size.h"
#include "ui/views/view.h"
#include "ui/views/widget/native_widget_aura.h"
......@@ -160,11 +161,6 @@ class CustomFrameViewAsh::HeaderView
virtual void Layout() OVERRIDE;
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
// Sets whether the header should be painted as active.
void set_paint_as_active(bool paint_as_active) {
paint_as_active_ = paint_as_active;
}
HeaderPainter* header_painter() {
return header_painter_.get();
}
......@@ -196,9 +192,6 @@ class CustomFrameViewAsh::HeaderView
// Keeps track of whether |maximize_bubble_| is still alive.
scoped_ptr<views::WidgetDeletionObserver> maximize_bubble_lifetime_observer_;
// Whether the header should be painted as active.
bool paint_as_active_;
// The fraction of the header's height which is visible while in fullscreen.
// This value is meaningless when not in fullscreen.
double fullscreen_visible_fraction_;
......@@ -211,7 +204,6 @@ CustomFrameViewAsh::HeaderView::HeaderView(views::Widget* frame)
header_painter_(new ash::HeaderPainter),
caption_button_container_(NULL),
maximize_bubble_(NULL),
paint_as_active_(false),
fullscreen_visible_fraction_(0) {
// Unfortunately, there is no views::WidgetDelegate::CanMinimize(). Assume
// that the window frame can be minimized if it can be maximized.
......@@ -272,7 +264,7 @@ void CustomFrameViewAsh::HeaderView::OnPaint(gfx::Canvas* canvas) {
int theme_image_id = 0;
if (frame_->IsMaximized() || frame_->IsFullscreen())
theme_image_id = IDR_AURA_WINDOW_HEADER_BASE_MINIMAL;
else if (paint_as_active_)
else if (frame_->non_client_view()->frame_view()->ShouldPaintAsActive())
theme_image_id = IDR_AURA_WINDOW_HEADER_BASE_ACTIVE;
else
theme_image_id = IDR_AURA_WINDOW_HEADER_BASE_INACTIVE;
......@@ -477,8 +469,9 @@ gfx::Size CustomFrameViewAsh::GetMaximumSize() {
void CustomFrameViewAsh::SchedulePaintInRect(const gfx::Rect& r) {
// The HeaderView is not a child of CustomFrameViewAsh. Redirect the paint to
// HeaderView instead.
header_view_->set_paint_as_active(ShouldPaintAsActive());
header_view_->SchedulePaint();
gfx::RectF to_paint(r);
views::View::ConvertRectToTarget(this, header_view_, &to_paint);
header_view_->SchedulePaintInRect(gfx::ToEnclosingRect(to_paint));
}
bool CustomFrameViewAsh::HitTestRect(const gfx::Rect& rect) const {
......
......@@ -1001,10 +1001,6 @@ bool DesktopNativeWidgetAura::ShouldActivate() const {
void DesktopNativeWidgetAura::OnWindowActivated(aura::Window* gained_active,
aura::Window* lost_active) {
DCHECK(content_window_ == gained_active || content_window_ == lost_active);
if ((content_window_ == gained_active || content_window_ == lost_active) &&
IsVisible() && GetWidget()->non_client_view()) {
GetWidget()->non_client_view()->SchedulePaint();
}
if (gained_active == content_window_ && restore_focus_on_activate_) {
restore_focus_on_activate_ = false;
GetWidget()->GetFocusManager()->RestoreFocusedView();
......
......@@ -879,8 +879,6 @@ void NativeWidgetAura::OnWindowActivated(aura::Window* gained_active,
GetWidget()->GetFocusManager()->StoreFocusedView(true);
}
delegate_->OnNativeWidgetActivationChanged(window_ == gained_active);
if (IsVisible() && GetWidget()->non_client_view())
GetWidget()->non_client_view()->SchedulePaint();
}
////////////////////////////////////////////////////////////////////////////////
......
......@@ -625,7 +625,7 @@ void NativeWidgetWin::HandleAppDeactivated() {
// TODO(pkotwicz): Remove need for SchedulePaint(). crbug.com/165841
View* non_client_view = GetWidget()->non_client_view();
if (non_client_view)
non_client_view->SchedulePaint();
non_client_view->frame_view()->SchedulePaint();
}
}
......
......@@ -1002,6 +1002,9 @@ void Widget::OnNativeWidgetActivationChanged(bool active) {
FOR_EACH_OBSERVER(WidgetObserver, observers_,
OnWidgetActivationChanged(this, active));
if (IsVisible() && non_client_view())
non_client_view()->frame_view()->SchedulePaint();
}
void Widget::OnNativeFocus(gfx::NativeView old_focused_view) {
......
......@@ -232,12 +232,23 @@ views::View* NonClientView::GetTooltipHandlerForPoint(const gfx::Point& point) {
////////////////////////////////////////////////////////////////////////////////
// NonClientFrameView, public:
NonClientFrameView::~NonClientFrameView() {
}
void NonClientFrameView::SetInactiveRenderingDisabled(bool disable) {
if (paint_as_active_ == disable)
if (inactive_rendering_disabled_ == disable)
return;
paint_as_active_ = disable;
ShouldPaintAsActiveChanged();
bool should_paint_as_active_old = ShouldPaintAsActive();
inactive_rendering_disabled_ = disable;
// The widget schedules a paint when the activation changes.
if (should_paint_as_active_old != ShouldPaintAsActive())
SchedulePaint();
}
bool NonClientFrameView::ShouldPaintAsActive() const {
return inactive_rendering_disabled_ || GetWidget()->IsActive();
}
int NonClientFrameView::GetHTComponentForFrame(const gfx::Point& point,
......@@ -301,14 +312,6 @@ bool NonClientFrameView::HitTestRect(const gfx::Rect& rect) const {
////////////////////////////////////////////////////////////////////////////////
// NonClientFrameView, protected:
bool NonClientFrameView::ShouldPaintAsActive() const {
return GetWidget()->IsActive() || paint_as_active_;
}
void NonClientFrameView::ShouldPaintAsActiveChanged() {
SchedulePaint();
}
void NonClientFrameView::GetAccessibleState(ui::AccessibleViewState* state) {
state->role = ui::AccessibilityTypes::ROLE_CLIENT;
}
......@@ -322,4 +325,7 @@ void NonClientFrameView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
// FrameView when it is itself laid out, see comment in NonClientView::Layout.
}
NonClientFrameView::NonClientFrameView() : inactive_rendering_disabled_(false) {
}
} // namespace views
......@@ -37,12 +37,18 @@ class VIEWS_EXPORT NonClientFrameView : public View {
kClientEdgeThickness = 1,
};
virtual ~NonClientFrameView();
// Sets whether the window should be rendered as active regardless of the
// actual active state. Used when bubbles become active to make their parent
// appear active. A value of true makes the window render as active always,
// false gives normal behavior.
void SetInactiveRenderingDisabled(bool disable);
// Used to determine if the frame should be painted as active. Keyed off the
// window's actual active state and |inactive_rendering_disabled_|.
bool ShouldPaintAsActive() const;
// 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
......@@ -80,22 +86,12 @@ class VIEWS_EXPORT NonClientFrameView : public View {
protected:
virtual void OnBoundsChanged(const gfx::Rect& previous_bounds) OVERRIDE;
NonClientFrameView() : paint_as_active_(false) {}
// Used to determine if the frame should be painted as active. Keyed off the
// window's actual active state and the override, see
// SetInactiveRenderingDisabled() above.
bool ShouldPaintAsActive() const;
// Invoked from SetInactiveRenderingDisabled(). This implementation invokes
// SchedulesPaint as necessary.
virtual void ShouldPaintAsActiveChanged();
NonClientFrameView();
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_;
// Prevents the non-client frame view from being rendered as inactive when
// true.
bool inactive_rendering_disabled_;
};
////////////////////////////////////////////////////////////////////////////////
......@@ -166,8 +162,6 @@ class VIEWS_EXPORT NonClientView : public View {
// 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.
void SetInactiveRenderingDisabled(bool disable);
// Returns the bounds of the window required to display the content area at
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment