summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-29 00:14:28 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-29 00:14:28 +0000
commit608de6c37623cffef25091a29ad9eb8a22406367 (patch)
tree4655e3fd74f9ac00ea71284a049c2a86e45f5bab
parenteb03353241d2cf444a1f1ef5c4ea12d2815f2b30 (diff)
downloadchromium_src-608de6c37623cffef25091a29ad9eb8a22406367.zip
chromium_src-608de6c37623cffef25091a29ad9eb8a22406367.tar.gz
chromium_src-608de6c37623cffef25091a29ad9eb8a22406367.tar.bz2
VIRTUAL KEYBOARD mode for second display
This is a place holder so that bshe can add VK to this root window. BUG=310325 R=bshe@chromium.org Review URL: https://codereview.chromium.org/41583002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231454 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/ash.gyp2
-rw-r--r--ash/display/display_controller.cc20
-rw-r--r--ash/display/display_controller.h4
-rw-r--r--ash/display/display_manager.cc34
-rw-r--r--ash/display/display_manager.h7
-rw-r--r--ash/display/virtual_keyboard_window_controller.cc71
-rw-r--r--ash/display/virtual_keyboard_window_controller.h41
-rw-r--r--ash/root_window_controller.cc20
-rw-r--r--ash/root_window_controller.h11
-rw-r--r--ash/shell.cc5
10 files changed, 197 insertions, 18 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index abb7234..6e00290 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -127,6 +127,8 @@
'display/screen_position_controller.h',
'display/shared_display_edge_indicator.cc',
'display/shared_display_edge_indicator.h',
+ 'display/virtual_keyboard_window_controller.cc',
+ 'display/virtual_keyboard_window_controller.h',
'drag_drop/drag_drop_controller.cc',
'drag_drop/drag_drop_controller.h',
'drag_drop/drag_drop_tracker.cc',
diff --git a/ash/display/display_controller.cc b/ash/display/display_controller.cc
index 68c6f53..8a0b6b9 100644
--- a/ash/display/display_controller.cc
+++ b/ash/display/display_controller.cc
@@ -13,6 +13,7 @@
#include "ash/display/display_manager.h"
#include "ash/display/mirror_window_controller.h"
#include "ash/display/root_window_transformers.h"
+#include "ash/display/virtual_keyboard_window_controller.h"
#include "ash/host/root_window_host_factory.h"
#include "ash/root_window_controller.h"
#include "ash/root_window_settings.h"
@@ -221,7 +222,9 @@ bool DisplayController::DisplayChangeLimiter::IsThrottled() const {
DisplayController::DisplayController()
: primary_root_window_for_replace_(NULL),
focus_activation_store_(new internal::FocusActivationStore()),
- mirror_window_controller_(new internal::MirrorWindowController) {
+ mirror_window_controller_(new internal::MirrorWindowController),
+ virtual_keyboard_window_controller_(
+ new internal::VirtualKeyboardWindowController) {
#if defined(OS_CHROMEOS)
CommandLine* command_line = CommandLine::ForCurrentProcess();
if (!command_line->HasSwitch(switches::kAshDisableDisplayChangeLimiter) &&
@@ -251,6 +254,7 @@ void DisplayController::Shutdown() {
Shell::GetInstance()->display_manager()->set_delegate(NULL);
mirror_window_controller_.reset();
+ virtual_keyboard_window_controller_.reset();
DCHECK(!primary_display_for_shutdown);
primary_display_for_shutdown = new gfx::Display(
@@ -676,11 +680,23 @@ void DisplayController::OnRootWindowHostResized(const aura::RootWindow* root) {
void DisplayController::CreateOrUpdateNonDesktopDisplay(
const internal::DisplayInfo& info) {
- mirror_window_controller_->UpdateWindow(info);
+ switch (GetDisplayManager()->second_display_mode()) {
+ case internal::DisplayManager::MIRRORING:
+ mirror_window_controller_->UpdateWindow(info);
+ virtual_keyboard_window_controller_->Close();
+ break;
+ case internal::DisplayManager::VIRTUAL_KEYBOARD:
+ mirror_window_controller_->Close();
+ virtual_keyboard_window_controller_->UpdateWindow(info);
+ break;
+ case internal::DisplayManager::EXTENDED:
+ NOTREACHED();
+ }
}
void DisplayController::CloseNonDesktopDisplay() {
mirror_window_controller_->Close();
+ virtual_keyboard_window_controller_->Close();
}
void DisplayController::PreDisplayConfigurationChange(bool display_removed) {
diff --git a/ash/display/display_controller.h b/ash/display/display_controller.h
index 1070684..ec84a58 100644
--- a/ash/display/display_controller.h
+++ b/ash/display/display_controller.h
@@ -42,6 +42,7 @@ class DisplayManager;
class FocusActivationStore;
class MirrorWindowController;
class RootWindowController;
+class VirtualKeyboardWindowController;
}
// DisplayController owns and maintains RootWindows for each attached
@@ -209,8 +210,9 @@ class ASH_EXPORT DisplayController : public gfx::DisplayObserver,
scoped_ptr<internal::FocusActivationStore> focus_activation_store_;
-
scoped_ptr<internal::MirrorWindowController> mirror_window_controller_;
+ scoped_ptr<internal::VirtualKeyboardWindowController>
+ virtual_keyboard_window_controller_;
// Stores the curent cursor location (in native coordinates) used to
// restore the cursor location when display configuration
diff --git a/ash/display/display_manager.cc b/ash/display/display_manager.cc
index 0f3ae27..7724c85 100644
--- a/ash/display/display_manager.cc
+++ b/ash/display/display_manager.cc
@@ -581,26 +581,37 @@ void DisplayManager::UpdateDisplays(
// the root window so that it matches the external display's
// resolution. This is necessary in order for scaling to work while
// mirrored.
- if (second_display_mode_ == MIRRORING && new_display_info_list.size() == 2) {
+ int64 non_desktop_display_id = gfx::Display::kInvalidDisplayID;
+
+ if (second_display_mode_ != EXTENDED && new_display_info_list.size() == 2) {
bool zero_is_source =
first_display_id_ == new_display_info_list[0].id() ||
gfx::Display::InternalDisplayId() == new_display_info_list[0].id();
- mirrored_display_id_ = new_display_info_list[zero_is_source ? 1 : 0].id();
+ if (second_display_mode_ == MIRRORING) {
+ mirrored_display_id_ = new_display_info_list[zero_is_source ? 1 : 0].id();
+ non_desktop_display_id = mirrored_display_id_;
+ } else {
+ // TODO(oshima|bshe): The virtual keyboard is currently assigned to
+ // the 1st display.
+ non_desktop_display_id =
+ new_display_info_list[zero_is_source ? 0 : 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()) {
+ non_desktop_display_id == new_info_iter->id()) {
DisplayInfo info = *new_info_iter;
info.SetOverscanInsets(gfx::Insets());
InsertAndUpdateDisplayInfo(info);
non_desktop_display_ =
- CreateDisplayFromDisplayInfoById(mirrored_display_id_);
+ CreateDisplayFromDisplayInfoById(non_desktop_display_id);
++new_info_iter;
- // Remove existing external dispaly if it is going to be mirrored.
+ // Remove existing external dispaly if it is going to be used as
+ // non desktop.
if (curr_iter != displays_.end() &&
- curr_iter->id() == mirrored_display_id_) {
+ curr_iter->id() == non_desktop_display_id) {
removed_displays.push_back(*curr_iter);
++curr_iter;
}
@@ -699,7 +710,7 @@ void DisplayManager::UpdateDisplays(
Shell::GetInstance()->screen()->NotifyDisplayRemoved(displays_.back());
displays_.pop_back();
}
- // Close the mirror window here to avoid creating two compositor on
+ // Close the non desktop window here to avoid creating two compositor on
// one display.
if (!non_desktop_display_updater->enabled())
non_desktop_display_updater.reset();
@@ -707,7 +718,7 @@ void DisplayManager::UpdateDisplays(
iter != added_display_indices.end(); ++iter) {
Shell::GetInstance()->screen()->NotifyDisplayAdded(displays_[*iter]);
}
- // Create the mirror window after all displays are added so that
+ // Create the non destkop window after all displays are added so that
// it can mirror the display newly added. This can happen when switching
// from dock mode to software mirror mode.
non_desktop_display_updater.reset();
@@ -730,9 +741,8 @@ const gfx::Display& DisplayManager::GetDisplayAt(size_t index) const {
}
const gfx::Display& DisplayManager::GetPrimaryDisplayCandidate() const {
- if (GetNumDisplays() == 1) {
+ if (GetNumDisplays() == 1)
return displays_[0];
- }
DisplayLayout layout = layout_store_->GetRegisteredDisplayLayout(
GetCurrentDisplayIdPair());
return GetDisplayForId(layout.primary_id);
@@ -837,6 +847,10 @@ void DisplayManager::ToggleDisplayScaleFactor() {
#if defined(OS_CHROMEOS)
void DisplayManager::SetSoftwareMirroring(bool enabled) {
+ // TODO(oshima|bshe): Support external display on the system
+ // that has virtual keyboard display.
+ if (second_display_mode_ == VIRTUAL_KEYBOARD)
+ return;
SetSecondDisplayMode(enabled ? MIRRORING : EXTENDED);
}
#endif
diff --git a/ash/display/display_manager.h b/ash/display/display_manager.h
index e21b7ec..eaedfe8 100644
--- a/ash/display/display_manager.h
+++ b/ash/display/display_manager.h
@@ -64,9 +64,16 @@ class ASH_EXPORT DisplayManager
};
// How the second display will be used.
+ // 1) EXTENDED mode extends the desktop to the second dislpay.
+ // 2) MIRRORING mode copies the content of the primary display to
+ // the 2nd display. (Software Mirroring).
+ // 3) In VIRTUAL_KEYBOARD mode, the 2nd display is used as a
+ // dedicated display for virtual keyboard, and it is not
+ // recognized as a part of desktop.
enum SecondDisplayMode {
EXTENDED,
MIRRORING,
+ VIRTUAL_KEYBOARD
};
// Returns the list of possible UI scales for the display.
diff --git a/ash/display/virtual_keyboard_window_controller.cc b/ash/display/virtual_keyboard_window_controller.cc
new file mode 100644
index 0000000..111ce3a
--- /dev/null
+++ b/ash/display/virtual_keyboard_window_controller.cc
@@ -0,0 +1,71 @@
+// Copyright 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/virtual_keyboard_window_controller.h"
+
+#include "ash/display/display_controller.h"
+#include "ash/display/display_info.h"
+#include "ash/display/display_manager.h"
+#include "ash/host/root_window_host_factory.h"
+#include "ash/root_window_controller.h"
+#include "ash/root_window_settings.h"
+#include "ash/shell.h"
+#include "ash/shell_window_ids.h"
+#include "base/strings/stringprintf.h"
+#include "base/strings/utf_string_conversions.h"
+#include "ui/aura/env.h"
+#include "ui/aura/root_window.h"
+
+namespace ash {
+namespace internal {
+
+VirtualKeyboardWindowController::VirtualKeyboardWindowController() {
+}
+
+VirtualKeyboardWindowController::~VirtualKeyboardWindowController() {
+ // Make sure the root window gets deleted before cursor_window_delegate.
+ Close();
+}
+
+void VirtualKeyboardWindowController::UpdateWindow(
+ const DisplayInfo& display_info) {
+ static int virtual_keyboard_root_window_count = 0;
+ if (!root_window_controller_.get()) {
+ const gfx::Rect& bounds_in_native = display_info.bounds_in_native();
+ aura::RootWindow::CreateParams params(bounds_in_native);
+ params.host = Shell::GetInstance()->root_window_host_factory()->
+ CreateRootWindowHost(bounds_in_native);
+ aura::RootWindow* root_window = new aura::RootWindow(params);
+
+ root_window->SetName(
+ base::StringPrintf("VirtualKeyboardRootWindow-%d",
+ virtual_keyboard_root_window_count++));
+
+ // No need to remove RootWindowObserver because
+ // the DisplayController object outlives RootWindow objects.
+ root_window->AddRootWindowObserver(
+ Shell::GetInstance()->display_controller());
+ InitRootWindowSettings(root_window)->display_id = display_info.id();
+ root_window->Init();
+ RootWindowController::CreateForVirtualKeyboardDisplay(root_window);
+ root_window_controller_.reset(GetRootWindowController(root_window));
+ root_window_controller_->root_window()->ShowRootWindow();
+ } else {
+ aura::RootWindow* root_window = root_window_controller_->root_window();
+ GetRootWindowSettings(root_window)->display_id = display_info.id();
+ root_window->SetHostBounds(display_info.bounds_in_native());
+ }
+}
+
+void VirtualKeyboardWindowController::Close() {
+ if (root_window_controller_.get()) {
+ root_window_controller_->root_window()->RemoveRootWindowObserver(
+ Shell::GetInstance()->display_controller());
+ root_window_controller_->Shutdown();
+ root_window_controller_.reset();
+ }
+}
+
+} // namespace internal
+} // namespace ash
diff --git a/ash/display/virtual_keyboard_window_controller.h b/ash/display/virtual_keyboard_window_controller.h
new file mode 100644
index 0000000..def3c06
--- /dev/null
+++ b/ash/display/virtual_keyboard_window_controller.h
@@ -0,0 +1,41 @@
+// Copyright 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_VIRTUAL_KEYBOARD_WINDOW_CONTROLLER_H_
+#define ASH_DISPLAY_VIRTUAL_KEYBOARD_WINDOW_CONTROLLER_H_
+
+#include "ash/ash_export.h"
+#include "base/compiler_specific.h"
+#include "base/memory/scoped_ptr.h"
+
+namespace ash {
+
+namespace internal {
+class DisplayInfo;
+class RootWindowController;
+
+// This class maintains the RootWindowController dedicated for
+// virtual keyboard.
+class ASH_EXPORT VirtualKeyboardWindowController {
+ public:
+ VirtualKeyboardWindowController();
+ virtual ~VirtualKeyboardWindowController();
+
+ // 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);
+
+ // Close the mirror window.
+ void Close();
+
+ private:
+ scoped_ptr<RootWindowController> root_window_controller_;
+
+ DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardWindowController);
+};
+
+} // namespace internal
+} // namespace ash
+
+#endif // ASH_DISPLAY_VIRTUAL_KEYBOARD_WINDOW_CONTROLLER_H_
diff --git a/ash/root_window_controller.cc b/ash/root_window_controller.cc
index 8afa501..072608c 100644
--- a/ash/root_window_controller.cc
+++ b/ash/root_window_controller.cc
@@ -219,13 +219,20 @@ namespace internal {
void RootWindowController::CreateForPrimaryDisplay(
aura::RootWindow* root) {
RootWindowController* controller = new RootWindowController(root);
- controller->Init(true /* primary */,
+ controller->Init(RootWindowController::PRIMARY,
Shell::GetInstance()->delegate()->IsFirstRunAfterBoot());
}
void RootWindowController::CreateForSecondaryDisplay(aura::RootWindow * root) {
RootWindowController* controller = new RootWindowController(root);
- controller->Init(false /* secondary */, false /* first run */);
+ controller->Init(RootWindowController::SECONDARY, false /* first run */);
+}
+
+void RootWindowController::CreateForVirtualKeyboardDisplay(
+ aura::RootWindow * root) {
+ RootWindowController* controller = new RootWindowController(root);
+ controller->Init(RootWindowController::VIRTUAL_KEYBOARD,
+ false /* first run */);
}
// static
@@ -569,11 +576,16 @@ RootWindowController::RootWindowController(aura::RootWindow* root_window)
capture_client_.reset(new views::corewm::ScopedCaptureClient(root_window));
}
-void RootWindowController::Init(bool is_primary, bool first_run_after_boot) {
+void RootWindowController::Init(RootWindowType root_window_type,
+ bool first_run_after_boot) {
Shell::GetInstance()->InitRootWindow(root_window_.get());
root_window_->SetCursor(ui::kCursorPointer);
CreateContainersInRootWindow(root_window_.get());
+
+ if (root_window_type == VIRTUAL_KEYBOARD)
+ return;
+
CreateSystemBackground(first_run_after_boot);
InitLayoutManagers();
@@ -587,7 +599,7 @@ void RootWindowController::Init(bool is_primary, bool first_run_after_boot) {
Shell* shell = Shell::GetInstance();
shell->AddShellObserver(this);
- if (is_primary) {
+ if (root_window_type == PRIMARY) {
root_window_layout()->OnWindowResized();
shell->InitKeyboard(this);
} else {
diff --git a/ash/root_window_controller.h b/ash/root_window_controller.h
index 3bbc469..fa8172f 100644
--- a/ash/root_window_controller.h
+++ b/ash/root_window_controller.h
@@ -84,6 +84,10 @@ class ASH_EXPORT RootWindowController : public ShellObserver {
// Creates and Initialize the RootWindowController for secondary displays.
static void CreateForSecondaryDisplay(aura::RootWindow* root_window);
+ // Creates and Initialize the RootWindowController for virtual
+ // keyboard displays.
+ static void CreateForVirtualKeyboardDisplay(aura::RootWindow* root_window);
+
// Returns a RootWindowController that has a launcher for given
// |window|. This returns the RootWindowController for the |window|'s
// root window when multiple launcher mode is enabled, or the primary
@@ -222,11 +226,16 @@ class ASH_EXPORT RootWindowController : public ShellObserver {
private:
explicit RootWindowController(aura::RootWindow* root_window);
+ enum RootWindowType {
+ PRIMARY,
+ SECONDARY,
+ VIRTUAL_KEYBOARD
+ };
// Initializes the RootWindowController. |is_primary| is true if
// the controller is for primary display. |first_run_after_boot| is
// set to true only for primary root window after boot.
- void Init(bool is_primary, bool first_run_after_boot);
+ void Init(RootWindowType root_window_type, bool first_run_after_boot);
void InitLayoutManagers();
diff --git a/ash/shell.cc b/ash/shell.cc
index 177638f..54ff005 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -96,6 +96,7 @@
#include "ui/gfx/size.h"
#include "ui/keyboard/keyboard.h"
#include "ui/keyboard/keyboard_controller.h"
+#include "ui/keyboard/keyboard_switches.h"
#include "ui/keyboard/keyboard_util.h"
#include "ui/message_center/message_center.h"
#include "ui/views/corewm/compound_event_filter.h"
@@ -695,6 +696,10 @@ void Shell::Init() {
output_configurator_animation_.reset(
new internal::OutputConfiguratorAnimation());
output_configurator_->AddObserver(output_configurator_animation_.get());
+ if (command_line->HasSwitch(keyboard::switches::kKeyboardUsabilityTest)) {
+ display_manager_->SetSecondDisplayMode(
+ internal::DisplayManager::VIRTUAL_KEYBOARD);
+ }
if (base::SysInfo::IsRunningOnChromeOS()) {
display_change_observer_.reset(new internal::DisplayChangeObserver);
// Register |display_change_observer_| first so that the rest of