OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/input_method/candidate_window_controller_impl.
h" | 5 #include "chrome/browser/chromeos/input_method/candidate_window_controller_impl.
h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
| 10 #include "ash/shell.h" |
| 11 #include "ash/shell_window_ids.h" |
| 12 #include "ash/wm/window_animations.h" |
10 #include "base/logging.h" | 13 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
12 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
13 #include "chrome/browser/chromeos/input_method/candidate_window_view.h" | 16 #include "chrome/browser/chromeos/input_method/candidate_window_view.h" |
14 #include "chrome/browser/chromeos/input_method/delayable_widget.h" | 17 #include "chrome/browser/chromeos/input_method/delayable_widget.h" |
15 #include "chrome/browser/chromeos/input_method/infolist_window_view.h" | 18 #include "chrome/browser/chromeos/input_method/infolist_window_view.h" |
16 #include "chromeos/dbus/dbus_thread_manager.h" | 19 #include "chromeos/dbus/dbus_thread_manager.h" |
17 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
18 | 21 |
19 #if defined(USE_ASH) | |
20 #include "ash/shell.h" | |
21 #include "ash/shell_window_ids.h" | |
22 #include "ash/wm/window_animations.h" | |
23 #endif // USE_ASH | |
24 | 22 |
25 namespace chromeos { | 23 namespace chromeos { |
26 namespace input_method { | 24 namespace input_method { |
27 | 25 |
28 namespace { | 26 namespace { |
29 // The milliseconds of the delay to show the infolist window. | 27 // The milliseconds of the delay to show the infolist window. |
30 const int kInfolistShowDelayMilliSeconds = 500; | 28 const int kInfolistShowDelayMilliSeconds = 500; |
31 // The milliseconds of the delay to hide the infolist window. | 29 // The milliseconds of the delay to hide the infolist window. |
32 const int kInfolistHideDelayMilliSeconds = 500; | 30 const int kInfolistHideDelayMilliSeconds = 500; |
33 | 31 |
(...skipping 26 matching lines...) Expand all Loading... |
60 | 58 |
61 void CandidateWindowControllerImpl::CreateView() { | 59 void CandidateWindowControllerImpl::CreateView() { |
62 // Create a non-decorated frame. | 60 // Create a non-decorated frame. |
63 frame_.reset(new views::Widget); | 61 frame_.reset(new views::Widget); |
64 // The size is initially zero. | 62 // The size is initially zero. |
65 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 63 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
66 // |frame_| and |infolist_window_| are owned by controller impl so | 64 // |frame_| and |infolist_window_| are owned by controller impl so |
67 // they should use WIDGET_OWNS_NATIVE_WIDGET ownership. | 65 // they should use WIDGET_OWNS_NATIVE_WIDGET ownership. |
68 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 66 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
69 // Show the candidate window always on top | 67 // Show the candidate window always on top |
70 #if defined(USE_ASH) | |
71 params.parent = ash::Shell::GetContainer( | 68 params.parent = ash::Shell::GetContainer( |
72 ash::Shell::GetActiveRootWindow(), | 69 ash::Shell::GetActiveRootWindow(), |
73 ash::internal::kShellWindowId_InputMethodContainer); | 70 ash::internal::kShellWindowId_InputMethodContainer); |
74 #else | |
75 params.keep_on_top = true; | |
76 #endif | |
77 frame_->Init(params); | 71 frame_->Init(params); |
78 #if defined(USE_ASH) | 72 |
79 views::corewm::SetWindowVisibilityAnimationType( | 73 views::corewm::SetWindowVisibilityAnimationType( |
80 frame_->GetNativeView(), | 74 frame_->GetNativeView(), |
81 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); | 75 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); |
82 #endif // USE_ASH | |
83 | 76 |
84 // Create the candidate window. | 77 // Create the candidate window. |
85 candidate_window_ = new CandidateWindowView(frame_.get()); | 78 candidate_window_ = new CandidateWindowView(frame_.get()); |
86 candidate_window_->Init(); | 79 candidate_window_->Init(); |
87 candidate_window_->AddObserver(this); | 80 candidate_window_->AddObserver(this); |
88 | 81 |
89 frame_->SetContentsView(candidate_window_); | 82 frame_->SetContentsView(candidate_window_); |
90 | 83 |
91 | 84 |
92 // Create the infolist window. | 85 // Create the infolist window. |
93 infolist_window_.reset(new DelayableWidget); | 86 infolist_window_.reset(new DelayableWidget); |
94 infolist_window_->Init(params); | 87 infolist_window_->Init(params); |
95 #if defined(USE_ASH) | 88 |
96 views::corewm::SetWindowVisibilityAnimationType( | 89 views::corewm::SetWindowVisibilityAnimationType( |
97 infolist_window_->GetNativeView(), | 90 infolist_window_->GetNativeView(), |
98 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); | 91 views::corewm::WINDOW_VISIBILITY_ANIMATION_TYPE_FADE); |
99 #endif // USE_ASH | |
100 | 92 |
101 InfolistWindowView* infolist_view = new InfolistWindowView; | 93 InfolistWindowView* infolist_view = new InfolistWindowView; |
102 infolist_view->Init(); | 94 infolist_view->Init(); |
103 infolist_window_->SetContentsView(infolist_view); | 95 infolist_window_->SetContentsView(infolist_view); |
104 } | 96 } |
105 | 97 |
106 CandidateWindowControllerImpl::CandidateWindowControllerImpl() | 98 CandidateWindowControllerImpl::CandidateWindowControllerImpl() |
107 : candidate_window_(NULL), | 99 : candidate_window_(NULL), |
108 latest_infolist_focused_index_(InfolistWindowView::InvalidFocusIndex()) {} | 100 latest_infolist_focused_index_(InfolistWindowView::InvalidFocusIndex()) {} |
109 | 101 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 | 343 |
352 if (candidate_window_rect.y() + infolist_window_size.height() > | 344 if (candidate_window_rect.y() + infolist_window_size.height() > |
353 screen_rect.bottom()) | 345 screen_rect.bottom()) |
354 result.set_y(screen_rect.bottom() - infolist_window_size.height()); | 346 result.set_y(screen_rect.bottom() - infolist_window_size.height()); |
355 | 347 |
356 return result; | 348 return result; |
357 } | 349 } |
358 | 350 |
359 } // namespace input_method | 351 } // namespace input_method |
360 } // namespace chromeos | 352 } // namespace chromeos |
OLD | NEW |