Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(110)

Side by Side Diff: ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.cc

Issue 2445293002: Make the virtual keyboard show up on the display with input focus. (Closed)
Patch Set: fix one more compilation error on Windows Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h" 5 #include "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/common/keyboard/keyboard_ui.h" 9 #include "ash/common/keyboard/keyboard_ui.h"
10 #include "ash/common/material_design/material_design_controller.h" 10 #include "ash/common/material_design/material_design_controller.h"
11 #include "ash/common/shelf/shelf_constants.h" 11 #include "ash/common/shelf/shelf_constants.h"
12 #include "ash/common/shelf/wm_shelf.h"
12 #include "ash/common/shelf/wm_shelf_util.h" 13 #include "ash/common/shelf/wm_shelf_util.h"
13 #include "ash/common/system/tray/tray_constants.h" 14 #include "ash/common/system/tray/tray_constants.h"
14 #include "ash/common/system/tray/tray_utils.h" 15 #include "ash/common/system/tray/tray_utils.h"
15 #include "ash/common/wm_shell.h" 16 #include "ash/common/wm_shell.h"
17 #include "ash/common/wm_window.h"
16 #include "grit/ash_resources.h" 18 #include "grit/ash_resources.h"
17 #include "grit/ash_strings.h" 19 #include "grit/ash_strings.h"
18 #include "ui/base/l10n/l10n_util.h" 20 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
22 #include "ui/display/display.h"
20 #include "ui/events/event.h" 23 #include "ui/events/event.h"
21 #include "ui/gfx/image/image_skia.h" 24 #include "ui/gfx/image/image_skia.h"
22 #include "ui/gfx/paint_vector_icon.h" 25 #include "ui/gfx/paint_vector_icon.h"
23 #include "ui/gfx/vector_icons_public.h" 26 #include "ui/gfx/vector_icons_public.h"
24 #include "ui/keyboard/keyboard_controller.h" 27 #include "ui/keyboard/keyboard_controller.h"
25 #include "ui/views/controls/image_view.h" 28 #include "ui/views/controls/image_view.h"
26 29
27 namespace ash { 30 namespace ash {
28 31
29 VirtualKeyboardTray::VirtualKeyboardTray(WmShelf* wm_shelf) 32 VirtualKeyboardTray::VirtualKeyboardTray(WmShelf* wm_shelf)
30 : TrayBackgroundView(wm_shelf), icon_(new views::ImageView) { 33 : TrayBackgroundView(wm_shelf),
34 icon_(new views::ImageView),
35 wm_shelf_(wm_shelf) {
31 if (MaterialDesignController::IsShelfMaterial()) { 36 if (MaterialDesignController::IsShelfMaterial()) {
32 SetInkDropMode(InkDropMode::ON); 37 SetInkDropMode(InkDropMode::ON);
33 SetContentsBackground(false); 38 SetContentsBackground(false);
34 gfx::ImageSkia image_md = 39 gfx::ImageSkia image_md =
35 CreateVectorIcon(gfx::VectorIconId::SHELF_KEYBOARD, kShelfIconColor); 40 CreateVectorIcon(gfx::VectorIconId::SHELF_KEYBOARD, kShelfIconColor);
36 icon_->SetImage(image_md); 41 icon_->SetImage(image_md);
37 } else { 42 } else {
38 SetContentsBackground(true); 43 SetContentsBackground(true);
39 gfx::ImageSkia* image_non_md = 44 gfx::ImageSkia* image_non_md =
40 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 45 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
(...skipping 30 matching lines...) Expand all
71 return l10n_util::GetStringUTF16( 76 return l10n_util::GetStringUTF16(
72 IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME); 77 IDS_ASH_VIRTUAL_KEYBOARD_TRAY_ACCESSIBLE_NAME);
73 } 78 }
74 79
75 void VirtualKeyboardTray::HideBubbleWithView( 80 void VirtualKeyboardTray::HideBubbleWithView(
76 const views::TrayBubbleView* bubble_view) {} 81 const views::TrayBubbleView* bubble_view) {}
77 82
78 void VirtualKeyboardTray::ClickedOutsideBubble() {} 83 void VirtualKeyboardTray::ClickedOutsideBubble() {}
79 84
80 bool VirtualKeyboardTray::PerformAction(const ui::Event& event) { 85 bool VirtualKeyboardTray::PerformAction(const ui::Event& event) {
81 WmShell::Get()->keyboard_ui()->Show(); 86 const int64_t display_id =
87 wm_shelf_->GetWindow()->GetDisplayNearestWindow().id();
88 WmShell::Get()->keyboard_ui()->ShowInDisplay(display_id);
82 // Normally, active status is set when virtual keyboard is shown/hidden, 89 // Normally, active status is set when virtual keyboard is shown/hidden,
83 // however, showing virtual keyboard happens asynchronously and, especially 90 // however, showing virtual keyboard happens asynchronously and, especially
84 // the first time, takes some time. We need to set active status here to 91 // the first time, takes some time. We need to set active status here to
85 // prevent bad things happening if user clicked the button before keyboard is 92 // prevent bad things happening if user clicked the button before keyboard is
86 // shown. 93 // shown.
87 SetIsActive(true); 94 SetIsActive(true);
88 return true; 95 return true;
89 } 96 }
90 97
91 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_enabled) { 98 void VirtualKeyboardTray::OnKeyboardEnabledStateChanged(bool new_enabled) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 142 }
136 143
137 void VirtualKeyboardTray::UnobserveKeyboardController() { 144 void VirtualKeyboardTray::UnobserveKeyboardController() {
138 keyboard::KeyboardController* keyboard_controller = 145 keyboard::KeyboardController* keyboard_controller =
139 keyboard::KeyboardController::GetInstance(); 146 keyboard::KeyboardController::GetInstance();
140 if (keyboard_controller) 147 if (keyboard_controller)
141 keyboard_controller->RemoveObserver(this); 148 keyboard_controller->RemoveObserver(this);
142 } 149 }
143 150
144 } // namespace ash 151 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698