diff options
author | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-31 11:47:44 +0000 |
---|---|---|
committer | oshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-31 11:47:44 +0000 |
commit | 95db9c14ba28e571c925736bd7d52d1dd6fd092d (patch) | |
tree | 44a53d8e9515cdd327f1bb12e29a21f3cc9db482 | |
parent | 39eefa5297bc6671e8e442a11308b85e4fd5e438 (diff) | |
download | chromium_src-95db9c14ba28e571c925736bd7d52d1dd6fd092d.zip chromium_src-95db9c14ba28e571c925736bd7d52d1dd6fd092d.tar.gz chromium_src-95db9c14ba28e571c925736bd7d52d1dd6fd092d.tar.bz2 |
Panels on 2nd launcher: step1
* Enable panel layout manager
* Specify the bounds for callout widgets so that it's
created within the same root window
* Set the bounds so that the panel will be created
in the current active display.
* Move panel windows when a display is disconnected.
* Added minimum tests
In next CL, I'll add "click and move", plus more tests.
BUG=166195
TEST=covered by test
Review URL: https://chromiumcodereview.appspot.com/12096057
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179865 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/root_window_controller.cc | 6 | ||||
-rw-r--r-- | ash/root_window_controller_unittest.cc | 9 | ||||
-rw-r--r-- | ash/shell/panel_window.cc | 4 | ||||
-rw-r--r-- | ash/wm/panel_layout_manager.cc | 19 | ||||
-rw-r--r-- | ash/wm/panel_layout_manager_unittest.cc | 14 | ||||
-rw-r--r-- | chrome/browser/ui/views/extensions/native_app_window_views.cc | 20 |
6 files changed, 62 insertions, 10 deletions
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc index bbd611e..97cdf4a 100644 --- a/ash/root_window_controller.cc +++ b/ash/root_window_controller.cc @@ -111,6 +111,7 @@ void ReparentAllWindows(aura::RootWindow* src, aura::RootWindow* dst) { // Set of windows to move. const int kContainerIdsToMove[] = { internal::kShellWindowId_DefaultContainer, + internal::kShellWindowId_PanelContainer, internal::kShellWindowId_AlwaysOnTopContainer, internal::kShellWindowId_SystemModalContainer, internal::kShellWindowId_LockSystemModalContainer, @@ -296,9 +297,8 @@ void RootWindowController::InitForPrimaryDisplay() { workspace_controller()->SetShelf(shelf_); - // TODO(oshima): Disable panels on non primary display for now. - // crbug.com/166195. - if (root_window_ == Shell::GetPrimaryRootWindow()) { + if (Shell::IsLauncherPerDisplayEnabled() || + root_window_ == Shell::GetPrimaryRootWindow()) { // Create Panel layout manager aura::Window* panel_container = GetContainer( internal::kShellWindowId_PanelContainer); diff --git a/ash/root_window_controller_unittest.cc b/ash/root_window_controller_unittest.cc index 09af6d3..6aef751f 100644 --- a/ash/root_window_controller_unittest.cc +++ b/ash/root_window_controller_unittest.cc @@ -176,6 +176,11 @@ TEST_F(RootWindowControllerTest, MAYBE_MoveWindows_Basic) { EXPECT_EQ(internal::kShellWindowId_UnparentedControlContainer, unparented_control->GetNativeView()->parent()->id()); + aura::Window* panel = CreateTestWindowInShellWithDelegateAndType( + NULL, aura::client::WINDOW_TYPE_PANEL, 0, gfx::Rect(700, 100, 100, 100)); + EXPECT_EQ(root_windows[1], panel->GetRootWindow()); + EXPECT_EQ(internal::kShellWindowId_PanelContainer, panel->parent()->id()); + // Make sure a window that will delete itself when losing focus // will not crash. aura::WindowTracker tracker; @@ -232,6 +237,10 @@ TEST_F(RootWindowControllerTest, MAYBE_MoveWindows_Basic) { unparented_control->GetNativeView()->GetRootWindow()); EXPECT_EQ(internal::kShellWindowId_UnparentedControlContainer, unparented_control->GetNativeView()->parent()->id()); + + // Test if the panel has moved. + EXPECT_EQ(root_windows[0], panel->GetRootWindow()); + EXPECT_EQ(internal::kShellWindowId_PanelContainer, panel->parent()->id()); } #if defined(OS_WIN) diff --git a/ash/shell/panel_window.cc b/ash/shell/panel_window.cc index 8ab5ae3..9147078 100644 --- a/ash/shell/panel_window.cc +++ b/ash/shell/panel_window.cc @@ -4,6 +4,7 @@ #include "ash/shell/panel_window.h" +#include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/wm/panel_frame_view.h" #include "base/utf_string_conversions.h" @@ -45,6 +46,9 @@ views::Widget* PanelWindow::CreateWidget() { params().bounds.set_width(kDefaultWidth); if (params().bounds.height() == 0) params().bounds.set_height(kDefaultHeight); + params().bounds = ScreenAsh::ConvertRectToScreen( + Shell::GetActiveRootWindow(), + params().bounds); widget->Init(params()); widget->GetNativeView()->SetName(name_); diff --git a/ash/wm/panel_layout_manager.cc b/ash/wm/panel_layout_manager.cc index 645aff4..d1d9494 100644 --- a/ash/wm/panel_layout_manager.cc +++ b/ash/wm/panel_layout_manager.cc @@ -8,6 +8,7 @@ #include <map> #include "ash/launcher/launcher.h" +#include "ash/screen_ash.h" #include "ash/shell.h" #include "ash/wm/frame_painter.h" #include "ash/wm/property_util.h" @@ -137,11 +138,14 @@ PanelLayoutManager::PanelLayoutManager(aura::Window* panel_container) params.keep_on_top = true; params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; params.parent = panel_container_; + params.bounds = ScreenAsh::ConvertRectToScreen(panel_container_, gfx::Rect()); params.bounds.set_width(kArrowWidth); params.bounds.set_height(kArrowHeight); // Why do we need this and can_activate = false? callout_widget_->set_focus_on_creation(false); callout_widget_->Init(params); + DCHECK_EQ(callout_widget_->GetNativeView()->GetRootWindow(), + panel_container_->GetRootWindow()); views::View* content_view = new views::View; content_view->set_background(new CalloutWidgetBackground); callout_widget_->SetContentsView(content_view); @@ -296,8 +300,11 @@ void PanelLayoutManager::OnWindowVisibilityChanged( void PanelLayoutManager::OnWindowActivated(aura::Window* gained_active, aura::Window* lost_active) { + // Ignore if the panel that is not managed by this was activated. if (gained_active && - gained_active->type() == aura::client::WINDOW_TYPE_PANEL) { + gained_active->type() == aura::client::WINDOW_TYPE_PANEL && + gained_active->GetRootWindow() == + launcher_->widget()->GetNativeView()->GetRootWindow()) { UpdateStacking(gained_active); UpdateCallout(gained_active); } else { @@ -358,11 +365,9 @@ void PanelLayoutManager::Relayout() { DCHECK(!active_panel); active_panel = panel; } - + icon_bounds = ScreenAsh::ConvertRectFromScreen(panel_container_, + icon_bounds); gfx::Point icon_origin = icon_bounds.origin(); - aura::Window::ConvertPointToTarget(panel_container_->GetRootWindow(), - panel_container_, &icon_origin); - VisiblePanelPositionInfo position_info; position_info.min_x = std::max(panel_left_bounds, icon_origin.x() + icon_bounds.width() - panel->bounds().width()); @@ -478,6 +483,10 @@ void PanelLayoutManager::ShowCalloutHelper(aura::Window* active_panel) { callout_bounds.set_x( icon_bounds.x() + (icon_bounds.width() - callout_bounds.width()) / 2); callout_bounds.set_y(bounds.bottom()); + callout_bounds = ScreenAsh::ConvertRectFromScreen( + callout_widget_->GetNativeWindow()->parent(), + callout_bounds); + SetChildBoundsDirect(callout_widget_->GetNativeWindow(), callout_bounds); panel_container_->StackChildAtTop(callout_widget_->GetNativeWindow()); callout_widget_->Show(); diff --git a/ash/wm/panel_layout_manager_unittest.cc b/ash/wm/panel_layout_manager_unittest.cc index a3e5e3c..77735c8 100644 --- a/ash/wm/panel_layout_manager_unittest.cc +++ b/ash/wm/panel_layout_manager_unittest.cc @@ -324,5 +324,19 @@ TEST_F(PanelLayoutManagerTest, MinimizeRestorePanel) { EXPECT_TRUE(IsCalloutVisible()); } +TEST_F(PanelLayoutManagerTest, PanelOnMultipleDisplays) { + UpdateDisplay("300x400,400x400"); + Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); + + scoped_ptr<aura::Window> p1_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); + scoped_ptr<aura::Window> p2_d1(CreatePanelWindow(gfx::Rect(0, 0, 50, 50))); + scoped_ptr<aura::Window> p1_d2(CreatePanelWindow(gfx::Rect(400, 0, 50, 50))); + scoped_ptr<aura::Window> p2_d2(CreatePanelWindow(gfx::Rect(400, 0, 50, 50))); + EXPECT_EQ(root_windows[0], p1_d1->GetRootWindow()); + EXPECT_EQ(root_windows[0], p2_d1->GetRootWindow()); + EXPECT_EQ(root_windows[1], p1_d2->GetRootWindow()); + EXPECT_EQ(root_windows[1], p2_d2->GetRootWindow()); +} + } // namespace internal } // namespace ash diff --git a/chrome/browser/ui/views/extensions/native_app_window_views.cc b/chrome/browser/ui/views/extensions/native_app_window_views.cc index 9a4b9c3..7746904 100644 --- a/chrome/browser/ui/views/extensions/native_app_window_views.cc +++ b/chrome/browser/ui/views/extensions/native_app_window_views.cc @@ -26,9 +26,12 @@ #endif #if defined(USE_ASH) +#include "ash/screen_ash.h" +#include "ash/shell.h" #include "ash/wm/custom_frame_view_ash.h" #include "ash/wm/panel_frame_view.h" #include "chrome/browser/ui/ash/ash_util.h" +#include "ui/aura/root_window.h" #endif namespace { @@ -119,17 +122,30 @@ void NativeAppWindowViews::InitializePanelWindow( preferred_size_.set_height(kDefaultPanelHeight); else if (preferred_size_.height() < kMinPanelHeight) preferred_size_.set_height(kMinPanelHeight); - - params.bounds = gfx::Rect(preferred_size_.width(), preferred_size_.height()); +#if defined(USE_ASH) + // Open a new panel on the active root window where + // a current active/focused window is on. + aura::RootWindow* active = ash::Shell::GetActiveRootWindow(); + params.bounds = ash::ScreenAsh::ConvertRectToScreen( + active, gfx::Rect(preferred_size_)); +#else + params.bounds = gfx::Rect(preferred_size_); +#endif // TODO(erg): Conceptually, these are toplevel windows, but we theoretically // could plumb context through to here in some cases. params.top_level = true; window_->Init(params); +#if !defined(USE_ASH) + // TODO(oshima|stevenjb): Ideally, we should be able to just pre-determine + // the exact location and size, but this doesn't work well + // on non-ash environment where we don't have full control over + // window management. gfx::Rect window_bounds = window_->non_client_view()->GetWindowBoundsForClientBounds( create_params.bounds); window_->SetBounds(window_bounds); +#endif } // BaseWindow implementation. |