summaryrefslogtreecommitdiffstats
path: root/ash/display/mirror_window_controller.cc
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/mirror_window_controller.cc
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/mirror_window_controller.cc')
-rw-r--r--ash/display/mirror_window_controller.cc218
1 files changed, 0 insertions, 218 deletions
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