summaryrefslogtreecommitdiffstats
path: root/ash/display
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-23 02:41:41 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-23 02:41:41 +0000
commit99634c2a3bc49500b4cc26dfb88b1e5ecd3bf3e4 (patch)
tree81f3680975f9cf6e8021aabc1b826fd214b98bfe /ash/display
parentb3239979c58d07fb797d8a9f4260d9a0c4b67186 (diff)
downloadchromium_src-99634c2a3bc49500b4cc26dfb88b1e5ecd3bf3e4.zip
chromium_src-99634c2a3bc49500b4cc26dfb88b1e5ecd3bf3e4.tar.gz
chromium_src-99634c2a3bc49500b4cc26dfb88b1e5ecd3bf3e4.tar.bz2
Revert 201618 because it broke cros bots and win-aura bot.
> This CL create just a window which will be used to show > the mirrored content of the source window. See the next steps > for > > misc: > * added debug+desktop only shortcut > * rotating square display now update the root window. > > Next steps: > * Mirror cursor > * Modify OutputConfigurator to fallback to software mirror mode. > * Scale the root window size for mirror window so that > it has the same size as the source root window. > * Copy texture from soruce window to dest window. > * Handle device scale factor/cursor scaling. > > BUG=239776 > TEST=covered by test > > Review URL: https://chromiumcodereview.appspot.com/15367003 TBR=oshima@chromium.org Review URL: https://codereview.chromium.org/15799002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@201668 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash/display')
-rw-r--r--ash/display/display_controller.cc19
-rw-r--r--ash/display/display_manager.cc144
-rw-r--r--ash/display/display_manager.h18
-rw-r--r--ash/display/display_manager_unittest.cc33
-rw-r--r--ash/display/mirror_window_controller.cc218
-rw-r--r--ash/display/mirror_window_controller.h63
6 files changed, 44 insertions, 451 deletions
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index dd6307c..c2f981f 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -621,10 +621,6 @@ DisplayLayout DisplayController::GetRegisteredDisplayLayout(
}
void DisplayController::ToggleMirrorMode() {
- internal::DisplayManager* display_manager = GetDisplayManager();
- if (display_manager->num_connected_displays() <= 1)
- return;
-
if (limiter_) {
if (limiter_->IsThrottled())
return;
@@ -632,12 +628,15 @@ void DisplayController::ToggleMirrorMode() {
}
#if defined(OS_CHROMEOS) && defined(USE_X11)
Shell* shell = Shell::GetInstance();
- internal::OutputConfiguratorAnimation* animation =
- shell->output_configurator_animation();
- animation->StartFadeOutAnimation(base::Bind(
- base::IgnoreResult(&internal::DisplayManager::SetMirrorMode),
- base::Unretained(display_manager),
- !display_manager->IsMirrored()));
+ internal::DisplayManager* display_manager = GetDisplayManager();
+ if (display_manager->num_connected_displays() > 1) {
+ internal::OutputConfiguratorAnimation* animation =
+ shell->output_configurator_animation();
+ animation->StartFadeOutAnimation(base::Bind(
+ base::IgnoreResult(&internal::DisplayManager::SetMirrorMode),
+ base::Unretained(display_manager),
+ !display_manager->IsMirrored()));
+ }
#endif
}
diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc
index 869517c..d15f2d1 100644
--- a/ash/display/display_manager.cc
+++ b/ash/display/display_manager.cc
@@ -11,7 +11,6 @@
#include "ash/ash_switches.h"
#include "ash/display/display_controller.h"
-#include "ash/display/mirror_window_controller.h"
#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "base/auto_reset.h"
@@ -39,7 +38,6 @@
#endif
#if defined(OS_CHROMEOS)
-#include "ash/display/output_configurator_animation.h"
#include "base/chromeos/chromeos_version.h"
#include "chromeos/display/output_configurator.h"
#endif
@@ -93,41 +91,6 @@ gfx::Display& GetInvalidDisplay() {
return *invalid_display;
}
-// Used to either create or close the mirror window
-// after all displays and associated RootWidows are
-// configured in UpdateDisplay.
-class MirrorWindowUpdater {
- public:
- virtual ~MirrorWindowUpdater() {}
-};
-
-class MirrorWindowCreator : public MirrorWindowUpdater {
- public:
- explicit MirrorWindowCreator(const DisplayInfo& display_info)
- : display_info_(display_info) {
- }
-
- virtual ~MirrorWindowCreator() {
- Shell::GetInstance()->mirror_window_controller()->
- UpdateWindow(display_info_);
- }
-
- private:
- const DisplayInfo display_info_;
- DISALLOW_COPY_AND_ASSIGN(MirrorWindowCreator);
-};
-
-class MirrorWindowCloser : public MirrorWindowUpdater {
- public:
- MirrorWindowCloser() {}
- virtual ~MirrorWindowCloser() {
- Shell::GetInstance()->mirror_window_controller()->Close();
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MirrorWindowCloser);
-};
-
} // namespace
using aura::RootWindow;
@@ -140,10 +103,10 @@ DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey,
DisplayManager::DisplayManager()
: first_display_id_(gfx::Display::kInvalidDisplayID),
+ mirrored_display_id_(gfx::Display::kInvalidDisplayID),
num_connected_displays_(0),
force_bounds_changed_(false),
- change_display_upon_host_resize_(false),
- software_mirroring_enabled_(false) {
+ change_display_upon_host_resize_(false) {
#if defined(OS_CHROMEOS)
change_display_upon_host_resize_ = !base::chromeos::IsRunningOnChromeOS();
#endif
@@ -374,7 +337,7 @@ void DisplayManager::OnNativeDisplaysChanged(
bool internal_display_connected = false;
num_connected_displays_ = updated_displays.size();
- mirrored_display_ = gfx::Display();
+ mirrored_display_id_ = gfx::Display::kInvalidDisplayID;
DisplayInfoList new_display_info_list;
for (DisplayInfoList::const_iterator iter = updated_displays.begin();
iter != updated_displays.end();
@@ -385,7 +348,7 @@ void DisplayManager::OnNativeDisplaysChanged(
int y = iter->bounds_in_pixel().y();
if (y_coords.find(y) != y_coords.end()) {
InsertAndUpdateDisplayInfo(*iter);
- mirrored_display_ = CreateDisplayFromDisplayInfoById(iter->id());
+ mirrored_display_id_ = iter->id();
} else {
y_coords.insert(y);
new_display_info_list.push_back(*iter);
@@ -431,31 +394,8 @@ void DisplayManager::UpdateDisplays(
DisplayList new_displays;
bool update_mouse_location = false;
- scoped_ptr<MirrorWindowUpdater> mirror_window_updater;
- // TODO(oshima): We may want to use external as the source.
- int mirrored_display_id = gfx::Display::kInvalidDisplayID;
- if (software_mirroring_enabled_ && updated_display_info_list.size() == 2)
- mirrored_display_id = updated_display_info_list[1].id();
-
while (curr_iter != displays_.end() ||
new_info_iter != new_display_info_list.end()) {
- if (new_info_iter != new_display_info_list.end() &&
- mirrored_display_id == new_info_iter->id()) {
- InsertAndUpdateDisplayInfo(*new_info_iter);
- mirrored_display_ = CreateDisplayFromDisplayInfoById(new_info_iter->id());
- mirror_window_updater.reset(
- new MirrorWindowCreator(display_info_[new_info_iter->id()]));
- ++new_info_iter;
- // Remove existing external dispaly if it is going to be mirrored.
- if (curr_iter != displays_.end() &&
- curr_iter->id() == mirrored_display_id) {
- removed_displays.push_back(*curr_iter);
- ++curr_iter;
- }
- update_mouse_location = true;
- continue;
- }
-
if (curr_iter == displays_.end()) {
// more displays in new list.
added_display_indices.push_back(new_displays.size());
@@ -482,13 +422,16 @@ void DisplayManager::UpdateDisplays(
current_display_info.bounds_in_pixel() !=
new_display_info.bounds_in_pixel();
+ // TODO(oshima): Rotating square dislay doesn't work as the size
+ // won't change. This doesn't cause a problem now as there is no
+ // such display. This will be fixed by comparing the rotation as
+ // well when the rotation variable is added to gfx::Display.
if (force_bounds_changed_ ||
host_window_bounds_changed ||
(current_display.device_scale_factor() !=
new_display.device_scale_factor()) ||
(current_display_info.size_in_pixel() !=
- new_display.GetSizeInPixel()) ||
- (current_display.rotation() != new_display.rotation())) {
+ new_display.GetSizeInPixel())) {
// Don't update mouse location if the display size has
// changed due to rotation or zooming.
@@ -517,10 +460,6 @@ void DisplayManager::UpdateDisplays(
}
}
- // Try to close mirror window unless mirror window is necessary.
- if (!mirror_window_updater.get())
- mirror_window_updater.reset(new MirrorWindowCloser);
-
// Do not update |displays_| if there's nothing to be updated. Without this,
// it will not update the display layout, which causes the bug
// http://crbug.com/155948.
@@ -602,7 +541,7 @@ size_t DisplayManager::GetNumDisplays() const {
}
bool DisplayManager::IsMirrored() const {
- return mirrored_display_.id() != gfx::Display::kInvalidDisplayID;
+ return mirrored_display_id_ != gfx::Display::kInvalidDisplayID;
}
const gfx::Display& DisplayManager::GetDisplayNearestWindow(
@@ -663,6 +602,21 @@ std::string DisplayManager::GetDisplayNameForId(int64 id) {
return base::StringPrintf("Display %d", static_cast<int>(id));
}
+void DisplayManager::OnRootWindowResized(const aura::RootWindow* root,
+ const gfx::Size& old_size) {
+ if (change_display_upon_host_resize_) {
+ gfx::Display& display = FindDisplayForRootWindow(root);
+ gfx::Size old_display_size_in_pixel = display.GetSizeInPixel();
+ display_info_[display.id()].SetBounds(
+ gfx::Rect(root->GetHostOrigin(), root->GetHostSize()));
+ const gfx::Size& new_root_size = root->bounds().size();
+ if (old_size != new_root_size) {
+ display.SetSize(display_info_[display.id()].size_in_pixel());
+ Shell::GetInstance()->screen()->NotifyBoundsChanged(display);
+ }
+ }
+}
+
void DisplayManager::SetMirrorMode(bool mirrored) {
if (num_connected_displays() <= 1)
return;
@@ -672,22 +626,8 @@ void DisplayManager::SetMirrorMode(bool mirrored) {
chromeos::OutputState new_state = mirrored ?
chromeos::STATE_DUAL_MIRROR : chromeos::STATE_DUAL_EXTENDED;
Shell::GetInstance()->output_configurator()->SetDisplayMode(new_state);
- return;
- }
-#endif
- SetSoftwareMirroring(mirrored);
- DisplayInfoList display_info_list;
- int count = 0;
- for (std::map<int64, DisplayInfo>::const_iterator iter =
- display_info_.begin();
- count < 2; ++iter, ++count) {
- display_info_list.push_back(GetDisplayInfo(iter->second.id()));
- }
- UpdateDisplays(display_info_list);
-#if defined(OS_CHROMEOS)
- if (Shell::GetInstance()->output_configurator_animation()) {
- Shell::GetInstance()->output_configurator_animation()->
- StartFadeInAnimation();
+ } else {
+ // TODO(oshima): Compositor based mirroring.
}
#endif
}
@@ -697,8 +637,8 @@ void DisplayManager::AddRemoveDisplay() {
std::vector<DisplayInfo> new_display_info_list;
new_display_info_list.push_back(
GetDisplayInfo(DisplayController::GetPrimaryDisplay().id()));
- // Add if there is only one display connected.
- if (num_connected_displays() == 1) {
+ // Add if there is only one display.
+ if (displays_.size() == 1) {
// Layout the 2nd display below the primary as with the real device.
aura::RootWindow* primary = Shell::GetPrimaryRootWindow();
gfx::Rect host_bounds =
@@ -724,26 +664,6 @@ void DisplayManager::ToggleDisplayScaleFactor() {
UpdateDisplays(new_display_info_list);
}
-void DisplayManager::OnRootWindowResized(const aura::RootWindow* root,
- const gfx::Size& old_size) {
- if (change_display_upon_host_resize_) {
- gfx::Display& display = FindDisplayForRootWindow(root);
- gfx::Size old_display_size_in_pixel = display.GetSizeInPixel();
- display_info_[display.id()].SetBounds(
- gfx::Rect(root->GetHostOrigin(), root->GetHostSize()));
- const gfx::Size& new_root_size = root->bounds().size();
- if (old_size != new_root_size) {
- display.SetSize(display_info_[display.id()].size_in_pixel());
- Shell::GetInstance()->screen()->NotifyBoundsChanged(display);
- }
- }
-}
-
-void DisplayManager::SetSoftwareMirroring(bool enabled) {
- software_mirroring_enabled_ = enabled;
- mirrored_display_ = gfx::Display();
-}
-
int64 DisplayManager::GetDisplayIdForUIScaling() const {
// UI Scaling is effective only on internal display.
int64 display_id = gfx::Display::InternalDisplayId();
@@ -775,12 +695,6 @@ void DisplayManager::Init() {
gfx::Display& DisplayManager::FindDisplayForRootWindow(
const aura::RootWindow* root_window) {
int64 id = root_window->GetProperty(kDisplayIdKey);
- // RootWindow needs Display to determine it's device scale factor.
- // TODO(oshima): We don't need full display info for mirror
- // window. Refactor so that RootWindow doesn't use it.
- if (mirrored_display_.id() == id)
- return mirrored_display_;
-
// if id is |kInvaildDisplayID|, it's being deleted.
DCHECK(id != gfx::Display::kInvalidDisplayID);
gfx::Display& display = FindDisplayForId(id);
diff --git a/ash/display/display_manager.h b/ash/display/display_manager.h
index 9dfc0aa..99441fc 100644
--- a/ash/display/display_manager.h
+++ b/ash/display/display_manager.h
@@ -14,7 +14,6 @@
#include "base/gtest_prod_util.h"
#include "ui/aura/root_window_observer.h"
#include "ui/aura/window.h"
-#include "ui/gfx/display.h"
namespace gfx {
class Display;
@@ -135,7 +134,7 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver {
// Returns the mirroring status.
bool IsMirrored() const;
- int64 mirrored_display_id() const { return mirrored_display_.id(); }
+ int64 mirrored_display_id() const { return mirrored_display_id_; }
// Returns the display object nearest given |window|.
const gfx::Display& GetDisplayNearestPoint(
@@ -161,6 +160,10 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver {
// desktop, this returns the first display ID.
int64 GetDisplayIdForUIScaling() const;
+ // RootWindowObserver overrides:
+ virtual void OnRootWindowResized(const aura::RootWindow* root,
+ const gfx::Size& new_size) OVERRIDE;
+
// Change the mirror mode.
void SetMirrorMode(bool mirrored);
@@ -169,13 +172,6 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver {
void AddRemoveDisplay();
void ToggleDisplayScaleFactor();
- // RootWindowObserver overrides:
- virtual void OnRootWindowResized(const aura::RootWindow* root,
- const gfx::Size& new_size) OVERRIDE;
-
- // TODO(oshima): This will be SoftwareMirroringController override:
- void SetSoftwareMirroring(bool enabled);
-
private:
FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, ConvertPoint);
FRIEND_TEST_ALL_PREFIXES(DisplayManagerTest, TestNativeDisplaysChanged);
@@ -213,7 +209,7 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver {
int64 first_display_id_;
- gfx::Display mirrored_display_;
+ int64 mirrored_display_id_;
// List of current active dispays.
DisplayList displays_;
@@ -232,8 +228,6 @@ class ASH_EXPORT DisplayManager : public aura::RootWindowObserver {
// on device as well as during the unit tests.
bool change_display_upon_host_resize_;
- bool software_mirroring_enabled_;
-
DISALLOW_COPY_AND_ASSIGN(DisplayManager);
};
diff --git a/ash/display/display_manager_unittest.cc b/ash/display/display_manager_unittest.cc
index 0106576..0706b0e 100644
--- a/ash/display/display_manager_unittest.cc
+++ b/ash/display/display_manager_unittest.cc
@@ -9,7 +9,6 @@
#include "ash/shell.h"
#include "ash/test/ash_test_base.h"
#include "ash/test/display_manager_test_api.h"
-#include "ash/test/mirror_window_test_api.h"
#include "base/format_macros.h"
#include "base/stringprintf.h"
#include "ui/aura/env.h"
@@ -713,11 +712,7 @@ TEST_F(DisplayManagerTest, Rotate) {
GetDisplayInfoAt(1).bounds_in_pixel().ToString());
EXPECT_EQ("400x300",
GetDisplayInfoAt(1).size_in_pixel().ToString());
- reset();
UpdateDisplay("100x200/b,300x400");
- EXPECT_EQ("2 0 0", GetCountSummary());
- reset();
-
EXPECT_EQ("1,1 100x200",
GetDisplayInfoAt(0).bounds_in_pixel().ToString());
EXPECT_EQ("100x200",
@@ -727,13 +722,6 @@ TEST_F(DisplayManagerTest, Rotate) {
GetDisplayInfoAt(1).bounds_in_pixel().ToString());
EXPECT_EQ("300x400",
GetDisplayInfoAt(1).size_in_pixel().ToString());
-
- UpdateDisplay("200x200");
- EXPECT_EQ("1 0 1", GetCountSummary());
- reset();
-
- UpdateDisplay("200x200/l");
- EXPECT_EQ("1 0 0", GetCountSummary());
}
TEST_F(DisplayManagerTest, UIScale) {
@@ -851,26 +839,5 @@ TEST_F(DisplayManagerTest, MAYBE_UpdateMouseCursorAfterRotateZoom) {
EXPECT_EQ("750,75", env->last_mouse_location().ToString());
}
-TEST_F(DisplayManagerTest, SoftwareMirroring) {
- UpdateDisplay("300x400,400x500");
-
- test::MirrorWindowTestApi test_api;
- EXPECT_EQ(NULL, test_api.GetRootWindow());
-
- DisplayManager* display_manager = Shell::GetInstance()->display_manager();
- display_manager->SetSoftwareMirroring(true);
- display_manager->UpdateDisplays();
- EXPECT_EQ(1U, display_manager->GetNumDisplays());
- EXPECT_EQ("0,0 300x400",
- Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString());
- EXPECT_EQ("400x500", test_api.GetRootWindow()->GetHostSize().ToString());
- EXPECT_TRUE(display_manager->IsMirrored());
-
- display_manager->SetMirrorMode(false);
- EXPECT_EQ(NULL, test_api.GetRootWindow());
- EXPECT_EQ(2U, display_manager->GetNumDisplays());
- EXPECT_FALSE(display_manager->IsMirrored());
-}
-
} // namespace internal
} // namespace ash
diff --git a/ash/display/mirror_window_controller.cc b/ash/display/mirror_window_controller.cc
deleted file mode 100644
index 3c8f3c7..0000000
--- a/ash/display/mirror_window_controller.cc
+++ /dev/null
@@ -1,218 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ash/display/mirror_window_controller.h"
-
-#if defined(USE_X11)
-#include <X11/Xlib.h>
-
-// Xlib.h defines RootWindow.
-#undef RootWindow
-#endif
-
-#include "ash/display/display_info.h"
-#include "ash/display/display_manager.h"
-#include "ash/host/root_window_host_factory.h"
-#include "ash/shell.h"
-#include "base/stringprintf.h"
-#include "ui/aura/client/capture_client.h"
-#include "ui/aura/env.h"
-#include "ui/aura/root_window.h"
-#include "ui/aura/window_delegate.h"
-#include "ui/base/cursor/cursors_aura.h"
-#include "ui/base/hit_test.h"
-#include "ui/base/layout.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/compositor/compositor.h"
-#include "ui/gfx/canvas.h"
-#include "ui/gfx/image/image_skia.h"
-#include "ui/gfx/native_widget_types.h"
-
-namespace ash {
-namespace internal {
-namespace {
-
-#if defined(USE_X11)
-// Mirror window shouldn't handle input events.
-void DisableInput(XID window) {
- long event_mask = ExposureMask | VisibilityChangeMask |
- StructureNotifyMask | PropertyChangeMask;
- XSelectInput(base::MessagePumpAuraX11::GetDefaultXDisplay(),
- window, event_mask);
-}
-#endif
-
-class NoneCaptureClient : public aura::client::CaptureClient {
- public:
- NoneCaptureClient() {}
- virtual ~NoneCaptureClient() {}
-
- private:
- // Does a capture on the |window|.
- virtual void SetCapture(aura::Window* window) OVERRIDE {}
-
- // Releases a capture from the |window|.
- virtual void ReleaseCapture(aura::Window* window) OVERRIDE {}
-
- // Returns the current capture window.
- virtual aura::Window* GetCaptureWindow() OVERRIDE {
- return NULL;
- }
-
- DISALLOW_COPY_AND_ASSIGN(NoneCaptureClient);
-};
-
-} // namespace
-
-class CursorWindowDelegate : public aura::WindowDelegate {
- public:
- CursorWindowDelegate() {}
- virtual ~CursorWindowDelegate() {}
-
- // aura::WindowDelegate overrides:
- virtual gfx::Size GetMinimumSize() const OVERRIDE {
- return cursor_image_.size();
- }
- virtual gfx::Size GetMaximumSize() const OVERRIDE {
- return cursor_image_.size();
- }
- virtual void OnBoundsChanged(const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) OVERRIDE {
- }
- virtual gfx::NativeCursor GetCursor(const gfx::Point& point) OVERRIDE {
- return gfx::kNullCursor;
- }
- virtual int GetNonClientComponent(
- const gfx::Point& point) const OVERRIDE {
- return HTNOWHERE;
- }
- virtual bool ShouldDescendIntoChildForEventHandling(
- aura::Window* child,
- const gfx::Point& location) OVERRIDE {
- return false;
- }
- virtual bool CanFocus() OVERRIDE {
- return false;
- }
- virtual void OnCaptureLost() OVERRIDE {
- }
- virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
- canvas->DrawImageInt(cursor_image_, 0, 0);
- }
- virtual void OnDeviceScaleFactorChanged(
- float device_scale_factor) OVERRIDE {
- }
- virtual void OnWindowDestroying() OVERRIDE {}
- virtual void OnWindowDestroyed() OVERRIDE {}
- virtual void OnWindowTargetVisibilityChanged(bool visible) OVERRIDE {
- }
- virtual bool HasHitTestMask() const OVERRIDE {
- return false;
- }
- virtual void GetHitTestMask(gfx::Path* mask) const OVERRIDE {}
- virtual scoped_refptr<ui::Texture> CopyTexture() OVERRIDE {
- NOTREACHED();
- return scoped_refptr<ui::Texture>();
- }
-
- void SetCursorImage(const gfx::ImageSkia& image) {
- cursor_image_ = image;
- }
-
- private:
- gfx::ImageSkia cursor_image_;
-
- DISALLOW_COPY_AND_ASSIGN(CursorWindowDelegate);
-};
-
-MirrorWindowController::MirrorWindowController()
- : current_cursor_type_(ui::kCursorNone),
- cursor_window_(NULL),
- cursor_window_delegate_(new CursorWindowDelegate) {
-}
-
-MirrorWindowController::~MirrorWindowController() {
- // Make sure the root window gets deleted before cursor_window_delegate.
- root_window_.reset();
-}
-
-void MirrorWindowController::UpdateWindow(const DisplayInfo& display_info) {
- static int mirror_root_window_count = 0;
- if (root_window_.get()) {
- root_window_->SetHostBounds(display_info.bounds_in_pixel());
- return;
- }
- Shell* shell = Shell::GetInstance();
- const gfx::Rect& bounds_in_pixel = display_info.bounds_in_pixel();
- aura::RootWindow::CreateParams params(bounds_in_pixel);
- params.host = shell->root_window_host_factory()->
- CreateRootWindowHost(bounds_in_pixel);
- root_window_.reset(new aura::RootWindow(params));
- root_window_->SetName(
- base::StringPrintf("MirrorRootWindow-%d", mirror_root_window_count++));
- root_window_->compositor()->SetBackgroundColor(SK_ColorBLACK);
- // No need to remove RootWindowObserver because
- // the DisplayManager object outlives RootWindow objects.
- root_window_->AddRootWindowObserver(shell->display_manager());
- // TODO(oshima): TouchHUD is using idkey.
- root_window_->SetProperty(internal::kDisplayIdKey, display_info.id());
- root_window_->Init();
-#if defined(USE_X11)
- DisableInput(root_window_->GetAcceleratedWidget());
-#endif
- aura::client::SetCaptureClient(root_window_.get(), new NoneCaptureClient());
- root_window_->ShowRootWindow();
-
- cursor_window_ = new aura::Window(cursor_window_delegate_.get());
- cursor_window_->Init(ui::LAYER_TEXTURED);
- root_window_->AddChild(cursor_window_);
- cursor_window_->Show();
-}
-
-void MirrorWindowController::Close() {
- if (root_window_.get()) {
- NoneCaptureClient* capture_client = static_cast<NoneCaptureClient*>(
- aura::client::GetCaptureClient(root_window_.get()));
- delete capture_client;
- root_window_.reset();
- cursor_window_ = NULL;
- }
-}
-
-void MirrorWindowController::UpdateCursorLocation() {
- if (cursor_window_) {
- gfx::Point point = aura::Env::GetInstance()->last_mouse_location();
- point.Offset(-hot_point_.x(), -hot_point_.y());
- gfx::Rect bounds = cursor_window_->bounds();
- bounds.set_origin(point);
- cursor_window_->SetBounds(bounds);
- }
-}
-
-void MirrorWindowController::SetMirroredCursor(gfx::NativeCursor cursor) {
- if (current_cursor_type_ == cursor.native_type())
- return;
- current_cursor_type_ = cursor.native_type();
- int resource_id;
- bool success = ui::GetCursorDataFor(
- current_cursor_type_, 1.0, &resource_id, &hot_point_);
- if (!success)
- return;
- const gfx::ImageSkia* image =
- ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id);
- cursor_window_delegate_->SetCursorImage(*image);
- if (cursor_window_) {
- cursor_window_->SchedulePaintInRect(
- gfx::Rect(cursor_window_->bounds().size()));
- UpdateCursorLocation();
- }
-}
-
-void MirrorWindowController::SetMirroredCursorVisibility(bool visible) {
- if (cursor_window_)
- visible ? cursor_window_->Show() : cursor_window_->Hide();
-}
-
-} // namespace internal
-} // namespace ash
diff --git a/ash/display/mirror_window_controller.h b/ash/display/mirror_window_controller.h
deleted file mode 100644
index e7b96c7..0000000
--- a/ash/display/mirror_window_controller.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef ASH_DISPLAY_MIRROR_WINDOW_CONTROLLER_H_
-#define ASH_DISPLAY_MIRROR_WINDOW_CONTROLLER_H_
-
-#include "ash/ash_export.h"
-#include "base/compiler_specific.h"
-#include "base/memory/scoped_ptr.h"
-#include "ui/gfx/native_widget_types.h"
-#include "ui/gfx/point.h"
-
-namespace aura {
-class RootWindow;
-class Window;
-}
-
-namespace ash {
-namespace test{
-class MirrorWindowTestApi;
-}
-
-namespace internal {
-class DisplayInfo;
-class CursorWindowDelegate;
-
-// An object that copies the content of the primary root window to a
-// mirror window. This also draws a mouse cursor as the mouse cursor
-// is typically drawn by the window system.
-class MirrorWindowController {
- public:
- MirrorWindowController();
- ~MirrorWindowController();
-
- // Updates the root window's bounds using |display_info|.
- // Creates the new root window if one doesn't exist.
- void UpdateWindow(const DisplayInfo& display_info);
-
- void Close();
-
- // Updates the mirrored cursor location,shape and
- // visibility.
- void UpdateCursorLocation();
- void SetMirroredCursor(gfx::NativeCursor cursor);
- void SetMirroredCursorVisibility(bool visible);
-
- private:
- friend class test::MirrorWindowTestApi;
-
- int current_cursor_type_;
- aura::Window* cursor_window_; // owned by root window.
- scoped_ptr<aura::RootWindow> root_window_;
- scoped_ptr<CursorWindowDelegate> cursor_window_delegate_;
- gfx::Point hot_point_;
-
- DISALLOW_COPY_AND_ASSIGN(MirrorWindowController);
-};
-
-} // namespace internal
-} // namespace ash
-
-#endif // ASH_DISPLAY_MIRROR_WINDOW_CONTROLLER_H_