diff options
Diffstat (limited to 'ash')
-rw-r--r-- | ash/wm/caption_buttons/frame_caption_button_container_view.cc | 4 | ||||
-rw-r--r-- | ash/wm/caption_buttons/frame_caption_button_container_view.h | 9 | ||||
-rw-r--r-- | ash/wm/caption_buttons/frame_caption_button_container_view_unittest.cc | 14 | ||||
-rw-r--r-- | ash/wm/caption_buttons/frame_maximize_button.cc | 72 | ||||
-rw-r--r-- | ash/wm/caption_buttons/frame_maximize_button.h | 16 | ||||
-rw-r--r-- | ash/wm/custom_frame_view_ash.cc | 2 | ||||
-rw-r--r-- | ash/wm/frame_painter_unittest.cc | 3 | ||||
-rw-r--r-- | ash/wm/panels/panel_frame_view.cc | 2 |
8 files changed, 55 insertions, 67 deletions
diff --git a/ash/wm/caption_buttons/frame_caption_button_container_view.cc b/ash/wm/caption_buttons/frame_caption_button_container_view.cc index 7609978..3425afa4 100644 --- a/ash/wm/caption_buttons/frame_caption_button_container_view.cc +++ b/ash/wm/caption_buttons/frame_caption_button_container_view.cc @@ -21,7 +21,6 @@ #include "ui/views/controls/button/image_button.h" #include "ui/views/widget/widget.h" #include "ui/views/widget/widget_delegate.h" -#include "ui/views/window/non_client_view.h" namespace ash { @@ -65,7 +64,6 @@ const char FrameCaptionButtonContainerView::kViewClassName[] = "FrameCaptionButtonContainerView"; FrameCaptionButtonContainerView::FrameCaptionButtonContainerView( - views::NonClientFrameView* frame_view, views::Widget* frame, MinimizeAllowed minimize_allowed) : frame_(frame), @@ -85,7 +83,7 @@ FrameCaptionButtonContainerView::FrameCaptionButtonContainerView( AlternateFrameCaptionButton::ACTION_CLOSE); } else { minimize_button_ = new views::ImageButton(this); - size_button_ = new FrameMaximizeButton(this, frame_view); + size_button_ = new FrameMaximizeButton(this, frame); close_button_ = new views::ImageButton(this); } diff --git a/ash/wm/caption_buttons/frame_caption_button_container_view.h b/ash/wm/caption_buttons/frame_caption_button_container_view.h index c9590c6..bcd5b37 100644 --- a/ash/wm/caption_buttons/frame_caption_button_container_view.h +++ b/ash/wm/caption_buttons/frame_caption_button_container_view.h @@ -12,7 +12,6 @@ namespace views { class CustomButton; -class NonClientFrameView; class Widget; } @@ -45,14 +44,10 @@ class ASH_EXPORT FrameCaptionButtonContainerView HEADER_STYLE_MAXIMIZED_HOSTED_APP }; - // |frame_view| and |frame| are the NonClientFrameView and the views::Widget - // that the caption buttons act on. + // |frame| is the views::Widget that the caption buttons act on. // |minimize_allowed| indicates whether the frame can be minimized (either via // the maximize/restore button or via a dedicated button). - // TODO(pkotwicz): Remove the |frame_view| parameter once FrameMaximizeButton - // is refactored to take in a views::Widget instead. - FrameCaptionButtonContainerView(views::NonClientFrameView* frame_view, - views::Widget* frame, + FrameCaptionButtonContainerView(views::Widget* frame, MinimizeAllowed minimize_allowed); virtual ~FrameCaptionButtonContainerView(); diff --git a/ash/wm/caption_buttons/frame_caption_button_container_view_unittest.cc b/ash/wm/caption_buttons/frame_caption_button_container_view_unittest.cc index ade3399..ef86851 100644 --- a/ash/wm/caption_buttons/frame_caption_button_container_view_unittest.cc +++ b/ash/wm/caption_buttons/frame_caption_button_container_view_unittest.cc @@ -138,7 +138,7 @@ TEST_F(FrameCaptionButtonContainerViewTestOldStyle, ButtonVisibility) { // are allowed because the size button can do both. scoped_ptr<views::Widget> widget_can_maximize( CreateTestWidget(MAXIMIZE_ALLOWED)); - FrameCaptionButtonContainerView container1(NULL, widget_can_maximize.get(), + FrameCaptionButtonContainerView container1(widget_can_maximize.get(), FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); container1.Layout(); FrameCaptionButtonContainerView::TestApi t1(&container1); @@ -152,7 +152,7 @@ TEST_F(FrameCaptionButtonContainerViewTestOldStyle, ButtonVisibility) { // maximizing is disallowed. scoped_ptr<views::Widget> widget_cannot_maximize( CreateTestWidget(MAXIMIZE_DISALLOWED)); - FrameCaptionButtonContainerView container2(NULL, widget_cannot_maximize.get(), + FrameCaptionButtonContainerView container2(widget_cannot_maximize.get(), FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); container2.Layout(); FrameCaptionButtonContainerView::TestApi t2(&container2); @@ -164,7 +164,7 @@ TEST_F(FrameCaptionButtonContainerViewTestOldStyle, ButtonVisibility) { // Neither the minimize button nor the size button should be visible when // neither minimizing nor maximizing are allowed. - FrameCaptionButtonContainerView container3(NULL, widget_cannot_maximize.get(), + FrameCaptionButtonContainerView container3(widget_cannot_maximize.get(), FrameCaptionButtonContainerView::MINIMIZE_DISALLOWED); container3.Layout(); FrameCaptionButtonContainerView::TestApi t3(&container3); @@ -177,7 +177,7 @@ TEST_F(FrameCaptionButtonContainerViewTestOldStyle, ButtonVisibility) { // Neither the minimize button nor the size button should be visible when the // "force-maximize-mode" experiment is turned on. CommandLine::ForCurrentProcess()->AppendSwitch(switches::kForcedMaximizeMode); - FrameCaptionButtonContainerView container4(NULL, widget_can_maximize.get(), + FrameCaptionButtonContainerView container4(widget_can_maximize.get(), FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); container4.Layout(); FrameCaptionButtonContainerView::TestApi t4(&container4); @@ -196,7 +196,7 @@ TEST_F(FrameCaptionButtonContainerViewTestOldStyle, LayoutBorder) { const int kRightInset = 4; scoped_ptr<views::Widget> widget(CreateTestWidget(MAXIMIZE_ALLOWED)); - FrameCaptionButtonContainerView container(NULL, widget.get(), + FrameCaptionButtonContainerView container(widget.get(), FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); container.set_border(views::Border::CreateEmptyBorder( kTopInset, kLeftInset, kBottomInset, kRightInset)); @@ -214,7 +214,7 @@ TEST_F(FrameCaptionButtonContainerViewTestOldStyle, LayoutBorder) { // Test how the header style affects which images are used for the buttons. TEST_F(FrameCaptionButtonContainerViewTestOldStyle, HeaderStyle) { scoped_ptr<views::Widget> widget(CreateTestWidget(MAXIMIZE_ALLOWED)); - FrameCaptionButtonContainerView container(NULL, widget.get(), + FrameCaptionButtonContainerView container(widget.get(), FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); FrameCaptionButtonContainerView::TestApi t(&container); @@ -311,7 +311,7 @@ TEST_F(FrameCaptionButtonContainerViewTestAlternateStyle, ButtonVisibility) { // button style. scoped_ptr<views::Widget> widget_can_maximize( CreateTestWidget(MAXIMIZE_ALLOWED)); - FrameCaptionButtonContainerView container(NULL, widget_can_maximize.get(), + FrameCaptionButtonContainerView container(widget_can_maximize.get(), FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); container.Layout(); FrameCaptionButtonContainerView::TestApi t(&container); diff --git a/ash/wm/caption_buttons/frame_maximize_button.cc b/ash/wm/caption_buttons/frame_maximize_button.cc index d2bab34..bc32f263 100644 --- a/ash/wm/caption_buttons/frame_maximize_button.cc +++ b/ash/wm/caption_buttons/frame_maximize_button.cc @@ -82,12 +82,12 @@ void FrameMaximizeButton::EscapeEventFilter::OnKeyEvent( // FrameMaximizeButton --------------------------------------------------------- FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener, - views::NonClientFrameView* frame) + views::Widget* frame) : ImageButton(listener), frame_(frame), + observing_frame_(false), is_snap_enabled_(false), exceeded_drag_threshold_(false), - widget_(NULL), press_is_gesture_(false), snap_type_(SNAP_NONE), bubble_appearance_delay_ms_(kBubbleAppearanceDelayMS) { @@ -102,8 +102,8 @@ FrameMaximizeButton::~FrameMaximizeButton() { // Before the window gets destroyed, the maximizer dialog needs to be shut // down since it would otherwise call into a deleted object. maximizer_.reset(); - if (widget_) - OnWindowDestroying(widget_->GetNativeWindow()); + if (observing_frame_) + OnWindowDestroying(frame_->GetNativeWindow()); } void FrameMaximizeButton::SnapButtonHovered(SnapType type) { @@ -181,11 +181,11 @@ void FrameMaximizeButton::OnWindowPropertyChanged(aura::Window* window, void FrameMaximizeButton::OnWindowDestroying(aura::Window* window) { maximizer_.reset(); - if (widget_) { - CHECK_EQ(widget_->GetNativeWindow(), window); - widget_->GetNativeWindow()->RemoveObserver(this); - widget_->RemoveObserver(this); - widget_ = NULL; + if (observing_frame_) { + CHECK_EQ(frame_->GetNativeWindow(), window); + frame_->GetNativeWindow()->RemoveObserver(this); + frame_->RemoveObserver(this); + observing_frame_ = false; } } @@ -214,10 +214,10 @@ void FrameMaximizeButton::OnMouseEntered(const ui::MouseEvent& event) { ImageButton::OnMouseEntered(event); if (!maximizer_) { DCHECK(GetWidget()); - if (!widget_) { - widget_ = frame_->GetWidget(); - widget_->GetNativeWindow()->AddObserver(this); - widget_->AddObserver(this); + if (!observing_frame_) { + observing_frame_ = true; + frame_->GetNativeWindow()->AddObserver(this); + frame_->AddObserver(this); } maximizer_.reset(new MaximizeBubbleController( this, @@ -421,7 +421,7 @@ void FrameMaximizeButton::UpdateSnap(const gfx::Point& location, if (snap_sizer_) { snap_sizer_->Update(LocationForSnapSizer(location)); phantom_window_->Show(ScreenAsh::ConvertRectToScreen( - frame_->GetWidget()->GetNativeView()->parent(), + frame_->GetNativeView()->parent(), snap_sizer_->target_bounds())); } return; @@ -442,7 +442,7 @@ void FrameMaximizeButton::UpdateSnap(const gfx::Point& location, SnapSizer::InputType input_type = is_touch ? SnapSizer::TOUCH_MAXIMIZE_BUTTON_INPUT : SnapSizer::OTHER_INPUT; - snap_sizer_.reset(new SnapSizer(frame_->GetWidget()->GetNativeWindow(), + snap_sizer_.reset(new SnapSizer(frame_->GetNativeWindow(), LocationForSnapSizer(location), snap_edge, input_type)); @@ -451,7 +451,7 @@ void FrameMaximizeButton::UpdateSnap(const gfx::Point& location, } if (!phantom_window_) { phantom_window_.reset(new internal::PhantomWindowController( - frame_->GetWidget()->GetNativeWindow())); + frame_->GetNativeWindow())); } if (maximizer_) { phantom_window_->set_phantom_below_window(maximizer_->GetBubbleWindow()); @@ -479,13 +479,12 @@ SnapType FrameMaximizeButton::SnapTypeForLocation( gfx::Rect FrameMaximizeButton::ScreenBoundsForType( SnapType type, const SnapSizer& snap_sizer) const { - aura::Window* window = frame_->GetWidget()->GetNativeWindow(); + aura::Window* window = frame_->GetNativeWindow(); switch (type) { case SNAP_LEFT: case SNAP_RIGHT: - return ScreenAsh::ConvertRectToScreen( - frame_->GetWidget()->GetNativeView()->parent(), - snap_sizer.target_bounds()); + return ScreenAsh::ConvertRectToScreen(window->parent(), + snap_sizer.target_bounds()); case SNAP_MAXIMIZE: return ScreenAsh::ConvertRectToScreen( window->parent(), @@ -501,8 +500,7 @@ gfx::Rect FrameMaximizeButton::ScreenBoundsForType( } case SNAP_RESTORE: { const gfx::Rect* restore = GetRestoreBoundsInScreen(window); - return restore ? - *restore : frame_->GetWidget()->GetWindowBoundsInScreen(); + return restore ? *restore : frame_->GetWindowBoundsInScreen(); } case SNAP_NONE: NOTREACHED(); @@ -519,7 +517,6 @@ gfx::Point FrameMaximizeButton::LocationForSnapSizer( void FrameMaximizeButton::Snap(const SnapSizer& snap_sizer) { ash::Shell* shell = ash::Shell::GetInstance(); - views::Widget* widget = frame_->GetWidget(); switch (snap_type_) { case SNAP_LEFT: case SNAP_RIGHT: { @@ -528,9 +525,9 @@ void FrameMaximizeButton::Snap(const SnapSizer& snap_sizer) { ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_LEFT : ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE_RIGHT); // Get the bounds in screen coordinates for restore purposes. - gfx::Rect restore = widget->GetWindowBoundsInScreen(); - if (widget->IsMaximized() || widget->IsFullscreen()) { - aura::Window* window = widget->GetNativeWindow(); + gfx::Rect restore = frame_->GetWindowBoundsInScreen(); + if (frame_->IsMaximized() || frame_->IsFullscreen()) { + aura::Window* window = frame_->GetNativeWindow(); // In case of maximized we have a restore boundary. DCHECK(ash::GetRestoreBoundsInScreen(window)); // If it was maximized we need to recover the old restore set. @@ -547,7 +544,7 @@ void FrameMaximizeButton::Snap(const SnapSizer& snap_sizer) { ash::SetRestoreBoundsInScreen(window, ScreenBoundsForType(snap_type_, snap_sizer)); - widget->Restore(); + frame_->Restore(); // After the window is where we want it to be we allow the window to be // auto managed again. @@ -556,27 +553,27 @@ void FrameMaximizeButton::Snap(const SnapSizer& snap_sizer) { // Others might also have set up a restore rectangle already. If so, // we should not overwrite the restore rectangle. bool restore_set = - GetRestoreBoundsInScreen(widget->GetNativeWindow()) != NULL; - widget->SetBounds(ScreenBoundsForType(snap_type_, snap_sizer)); + GetRestoreBoundsInScreen(frame_->GetNativeWindow()) != NULL; + frame_->SetBounds(ScreenBoundsForType(snap_type_, snap_sizer)); if (restore_set) break; } // Remember the widow's bounds for restoration. - ash::SetRestoreBoundsInScreen(widget->GetNativeWindow(), restore); + ash::SetRestoreBoundsInScreen(frame_->GetNativeWindow(), restore); break; } case SNAP_MAXIMIZE: - widget->Maximize(); + frame_->Maximize(); shell->delegate()->RecordUserMetricsAction( ash::UMA_WINDOW_MAXIMIZE_BUTTON_MAXIMIZE); break; case SNAP_MINIMIZE: - widget->Minimize(); + frame_->Minimize(); shell->delegate()->RecordUserMetricsAction( ash::UMA_WINDOW_MAXIMIZE_BUTTON_MINIMIZE); break; case SNAP_RESTORE: - widget->Restore(); + frame_->Restore(); shell->delegate()->RecordUserMetricsAction( ash::UMA_WINDOW_MAXIMIZE_BUTTON_RESTORE); break; @@ -588,16 +585,15 @@ void FrameMaximizeButton::Snap(const SnapSizer& snap_sizer) { MaximizeBubbleFrameState FrameMaximizeButton::GetMaximizeBubbleFrameState() const { // When there are no restore bounds, we are in normal mode. - if (!ash::GetRestoreBoundsInScreen( - frame_->GetWidget()->GetNativeWindow())) + if (!ash::GetRestoreBoundsInScreen(frame_->GetNativeWindow())) return FRAME_STATE_NONE; // The normal maximized test can be used. - if (frame_->GetWidget()->IsMaximized()) + if (frame_->IsMaximized()) return FRAME_STATE_FULL; // For Left/right maximize we need to check the dimensions. - gfx::Rect bounds = frame_->GetWidget()->GetWindowBoundsInScreen(); + gfx::Rect bounds = frame_->GetWindowBoundsInScreen(); gfx::Rect screen = Shell::GetScreen()->GetDisplayNearestWindow( - frame_->GetWidget()->GetNativeView()).work_area(); + frame_->GetNativeView()).work_area(); if (bounds.width() < (screen.width() * kMinSnapSizePercent) / 100) return FRAME_STATE_NONE; // We might still have a horizontally filled window at this point which we diff --git a/ash/wm/caption_buttons/frame_maximize_button.h b/ash/wm/caption_buttons/frame_maximize_button.h index 65cad11..05ef4c2 100644 --- a/ash/wm/caption_buttons/frame_maximize_button.h +++ b/ash/wm/caption_buttons/frame_maximize_button.h @@ -15,7 +15,7 @@ #include "ui/views/widget/widget_observer.h" namespace views { -class NonClientFrameView; +class Widget; } namespace ash { @@ -33,7 +33,7 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton, public aura::WindowObserver { public: FrameMaximizeButton(views::ButtonListener* listener, - views::NonClientFrameView* frame); + views::Widget* frame); virtual ~FrameMaximizeButton(); // Updates |snap_type_| based on a a given snap type. This is used by @@ -138,8 +138,12 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton, // Determine the maximize type of this window. MaximizeBubbleFrameState GetMaximizeBubbleFrameState() const; - // Frame that the maximize button acts on. - views::NonClientFrameView* frame_; + // Widget that the maximize button acts on. This is different than the widget + // which contains the button in the case of AppNonClientFrameViewAsh. + views::Widget* frame_; + + // True if we have put observers on |frame_|. + bool observing_frame_; // Renders the snap position. scoped_ptr<internal::PhantomWindowController> phantom_window_; @@ -151,10 +155,6 @@ class ASH_EXPORT FrameMaximizeButton : public views::ImageButton, // Did the user drag far enough to trigger snapping? bool exceeded_drag_threshold_; - // Remember the widget on which we have put some an observers, - // so that we can remove it upon destruction. - views::Widget* widget_; - // Location of the press. gfx::Point press_location_; diff --git a/ash/wm/custom_frame_view_ash.cc b/ash/wm/custom_frame_view_ash.cc index a4b8efb..a606f01 100644 --- a/ash/wm/custom_frame_view_ash.cc +++ b/ash/wm/custom_frame_view_ash.cc @@ -53,7 +53,7 @@ void CustomFrameViewAsh::Init(views::Widget* frame) { frame_->widget_delegate()->CanMaximize() ? FrameCaptionButtonContainerView::MINIMIZE_ALLOWED : FrameCaptionButtonContainerView::MINIMIZE_DISALLOWED; - caption_button_container_ = new FrameCaptionButtonContainerView(this, frame, + caption_button_container_ = new FrameCaptionButtonContainerView(frame, minimize_allowed); AddChildView(caption_button_container_); diff --git a/ash/wm/frame_painter_unittest.cc b/ash/wm/frame_painter_unittest.cc index 14fc889..7353bc4 100644 --- a/ash/wm/frame_painter_unittest.cc +++ b/ash/wm/frame_painter_unittest.cc @@ -119,7 +119,6 @@ FramePainter* CreateTestPainter(Widget* widget) { NonClientFrameView* frame_view = widget->non_client_view()->frame_view(); ash::FrameCaptionButtonContainerView* container = new ash::FrameCaptionButtonContainerView( - frame_view, widget, ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); // Add the container to the widget's non-client frame view so that it will be @@ -576,7 +575,7 @@ TEST_F(FramePainterTest, MinimalHeaderStyle) { TEST_F(FramePainterTest, TitleIconAlignment) { scoped_ptr<Widget> w(CreateTestWidget()); FramePainter p; - ash::FrameCaptionButtonContainerView container(NULL, w.get(), + ash::FrameCaptionButtonContainerView container(w.get(), ash::FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); views::View window_icon; window_icon.SetBounds(0, 0, 16, 16); diff --git a/ash/wm/panels/panel_frame_view.cc b/ash/wm/panels/panel_frame_view.cc index cc0b062..7a1e31f 100644 --- a/ash/wm/panels/panel_frame_view.cc +++ b/ash/wm/panels/panel_frame_view.cc @@ -45,7 +45,7 @@ const char* PanelFrameView::GetClassName() const { void PanelFrameView::InitFramePainter() { frame_painter_.reset(new FramePainter); - caption_button_container_ = new FrameCaptionButtonContainerView(this, frame_, + caption_button_container_ = new FrameCaptionButtonContainerView(frame_, FrameCaptionButtonContainerView::MINIMIZE_ALLOWED); AddChildView(caption_button_container_); |