diff options
Diffstat (limited to 'ash/wm/overview/window_selector_panels.cc')
-rw-r--r-- | ash/wm/overview/window_selector_panels.cc | 68 |
1 files changed, 59 insertions, 9 deletions
diff --git a/ash/wm/overview/window_selector_panels.cc b/ash/wm/overview/window_selector_panels.cc index bd165b2..588bf3b 100644 --- a/ash/wm/overview/window_selector_panels.cc +++ b/ash/wm/overview/window_selector_panels.cc @@ -4,16 +4,18 @@ #include "ash/wm/overview/window_selector_panels.h" +#include "ash/screen_util.h" #include "ash/shell.h" #include "ash/shell_window_ids.h" #include "ash/wm/overview/scoped_transform_overview_window.h" +#include "ash/wm/overview/transparent_activate_window_button.h" #include "ash/wm/panels/panel_layout_manager.h" -#include "ui/aura/client/screen_position_client.h" +#include "ash/wm/window_util.h" #include "ui/aura/window.h" #include "ui/compositor/layer.h" #include "ui/compositor/layer_animation_observer.h" #include "ui/compositor/layer_animation_sequence.h" -#include "ui/views/widget/widget.h" +#include "ui/views/controls/button/button.h" namespace ash { @@ -22,7 +24,8 @@ namespace { const int kPanelCalloutFadeInDurationMilliseconds = 50; // This class extends ScopedTransformOverviewMode to hide and show the callout -// widget for a panel window when entering / leaving overview mode. +// widget for a panel window when entering / leaving overview mode, as well as +// to add a transparent button for each panel window. class ScopedTransformPanelWindow : public ScopedTransformOverviewWindow { public: ScopedTransformPanelWindow(aura::Window* window); @@ -31,6 +34,11 @@ class ScopedTransformPanelWindow : public ScopedTransformOverviewWindow { // ScopedTransformOverviewWindow overrides: virtual void PrepareForOverview() OVERRIDE; + virtual void SetTransform( + aura::Window* root_window, + const gfx::Transform& transform, + bool animate) OVERRIDE; + private: // Returns the callout widget for the transformed panel. views::Widget* GetCalloutWidget(); @@ -41,8 +49,13 @@ class ScopedTransformPanelWindow : public ScopedTransformOverviewWindow { // Trigger relayout void Relayout(); + // Returns the panel window bounds after the transformation. + gfx::Rect GetTransformedBounds(); + bool callout_visible_; + scoped_ptr<TransparentActivateWindowButton> window_button_; + DISALLOW_COPY_AND_ASSIGN(ScopedTransformPanelWindow); }; @@ -59,6 +72,15 @@ ScopedTransformPanelWindow::~ScopedTransformPanelWindow() { void ScopedTransformPanelWindow::PrepareForOverview() { ScopedTransformOverviewWindow::PrepareForOverview(); GetCalloutWidget()->GetLayer()->SetOpacity(0.0f); + window_button_.reset(new TransparentActivateWindowButton(window())); +} + +void ScopedTransformPanelWindow::SetTransform( + aura::Window* root_window, + const gfx::Transform& transform, + bool animate) { + ScopedTransformOverviewWindow::SetTransform(root_window, transform, animate); + window_button_->SetBounds(GetTransformedBounds()); } views::Widget* ScopedTransformPanelWindow::GetCalloutWidget() { @@ -81,6 +103,19 @@ void ScopedTransformPanelWindow::RestoreCallout() { sequence.release()); } +gfx::Rect ScopedTransformPanelWindow::GetTransformedBounds() { + gfx::RectF bounds(ScreenUtil::ConvertRectToScreen( + window()->GetRootWindow(), window()->layer()->bounds())); + gfx::Transform new_transform; + new_transform.Translate(bounds.x(), + bounds.y()); + new_transform.PreconcatTransform(window()->layer()->GetTargetTransform()); + new_transform.Translate(-bounds.x(), + -bounds.y()); + new_transform.TransformRect(&bounds); + return ToEnclosingRect(bounds); +} + } // namespace WindowSelectorPanels::WindowSelectorPanels() { @@ -106,13 +141,13 @@ bool WindowSelectorPanels::HasSelectableWindow(const aura::Window* window) { return false; } -aura::Window* WindowSelectorPanels::TargetedWindow(const aura::Window* target) { +bool WindowSelectorPanels::Contains(const aura::Window* target) { for (WindowList::const_iterator iter = transform_windows_.begin(); iter != transform_windows_.end(); ++iter) { if ((*iter)->Contains(target)) - return (*iter)->window(); + return true; } - return NULL; + return false; } void WindowSelectorPanels::RestoreWindowOnExit(aura::Window* window) { @@ -145,10 +180,25 @@ bool WindowSelectorPanels::empty() const { } void WindowSelectorPanels::PrepareForOverview() { - for (WindowList::iterator iter = transform_windows_.begin(); - iter != transform_windows_.end(); ++iter) { - (*iter)->PrepareForOverview(); + // |panel_windows| will hold all the windows in the panel container, sorted + // according to their stacking order. + const aura::Window::Windows panels = + transform_windows_[0]->window()->parent()->children(); + + // Call PrepareForOverview() in the reverse stacking order so that the + // transparent windows that handle the events are in the correct stacking + // order. + size_t transformed_windows = 0; + for (aura::Window::Windows::const_reverse_iterator iter = panels.rbegin(); + iter != panels.rend(); iter++) { + for (size_t j = 0; j < transform_windows_.size(); ++j) { + if (transform_windows_[j]->window() == (*iter)) { + transform_windows_[j]->PrepareForOverview(); + transformed_windows++; + } + } } + DCHECK(transformed_windows == transform_windows_.size()); } void WindowSelectorPanels::SetItemBounds(aura::Window* root_window, |