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

Side by Side Diff: apps/shell/browser/shell_desktop_controller.cc

Issue 310463010: Fixes the initialization of focus and activation management. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git-cl format Created 6 years, 6 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "apps/shell/browser/shell_desktop_controller.h" 5 #include "apps/shell/browser/shell_desktop_controller.h"
6 6
7 #include "apps/shell/browser/shell_app_window.h" 7 #include "apps/shell/browser/shell_app_window.h"
8 #include "content/public/browser/context_factory.h" 8 #include "content/public/browser/context_factory.h"
9 #include "ui/aura/client/cursor_client.h" 9 #include "ui/aura/client/cursor_client.h"
10 #include "ui/aura/client/default_capture_client.h" 10 #include "ui/aura/client/default_capture_client.h"
11 #include "ui/aura/env.h" 11 #include "ui/aura/env.h"
12 #include "ui/aura/layout_manager.h" 12 #include "ui/aura/layout_manager.h"
13 #include "ui/aura/test/test_screen.h" 13 #include "ui/aura/test/test_screen.h"
14 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
15 #include "ui/aura/window_event_dispatcher.h" 15 #include "ui/aura/window_event_dispatcher.h"
16 #include "ui/aura/window_tree_host.h" 16 #include "ui/aura/window_tree_host.h"
17 #include "ui/base/cursor/cursor.h" 17 #include "ui/base/cursor/cursor.h"
18 #include "ui/base/cursor/image_cursors.h" 18 #include "ui/base/cursor/image_cursors.h"
19 #include "ui/base/ime/input_method_initializer.h" 19 #include "ui/base/ime/input_method_initializer.h"
20 #include "ui/gfx/native_widget_types.h" 20 #include "ui/gfx/native_widget_types.h"
21 #include "ui/gfx/screen.h" 21 #include "ui/gfx/screen.h"
22 #include "ui/wm/core/base_focus_rules.h" 22 #include "ui/wm/core/base_focus_rules.h"
23 #include "ui/wm/core/compound_event_filter.h" 23 #include "ui/wm/core/compound_event_filter.h"
24 #include "ui/wm/core/cursor_manager.h" 24 #include "ui/wm/core/cursor_manager.h"
25 #include "ui/wm/core/default_activation_client.h"
26 #include "ui/wm/core/focus_controller.h" 25 #include "ui/wm/core/focus_controller.h"
27 #include "ui/wm/core/input_method_event_filter.h" 26 #include "ui/wm/core/input_method_event_filter.h"
28 #include "ui/wm/core/native_cursor_manager.h" 27 #include "ui/wm/core/native_cursor_manager.h"
29 #include "ui/wm/core/native_cursor_manager_delegate.h" 28 #include "ui/wm/core/native_cursor_manager_delegate.h"
30 #include "ui/wm/core/user_activity_detector.h" 29 #include "ui/wm/core/user_activity_detector.h"
31 30
32 #if defined(OS_CHROMEOS) 31 #if defined(OS_CHROMEOS)
33 #include "ui/chromeos/user_activity_power_manager_notifier.h" 32 #include "ui/chromeos/user_activity_power_manager_notifier.h"
34 #include "ui/display/types/chromeos/display_mode.h" 33 #include "ui/display/types/chromeos/display_mode.h"
35 #include "ui/display/types/chromeos/display_snapshot.h" 34 #include "ui/display/types/chromeos/display_snapshot.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 DCHECK_EQ(host_.get(), host); 223 DCHECK_EQ(host_.get(), host);
225 CloseAppWindow(); 224 CloseAppWindow();
226 base::MessageLoop::current()->PostTask(FROM_HERE, 225 base::MessageLoop::current()->PostTask(FROM_HERE,
227 base::MessageLoop::QuitClosure()); 226 base::MessageLoop::QuitClosure());
228 } 227 }
229 228
230 void ShellDesktopController::CreateRootWindow() { 229 void ShellDesktopController::CreateRootWindow() {
231 test_screen_.reset(aura::TestScreen::Create()); 230 test_screen_.reset(aura::TestScreen::Create());
232 // TODO(jamescook): Replace this with a real Screen implementation. 231 // TODO(jamescook): Replace this with a real Screen implementation.
233 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get()); 232 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, test_screen_.get());
234 // TODO(jamescook): Initialize a real input method. 233 // TODO(mukai): Set up input method.
235 ui::InitializeInputMethodForTesting();
oshima 2014/06/03 00:42:53 can you check if app_shell_browsertests passes wit
Jun Mukai 2014/06/03 00:57:46 It passes.
236 234
237 // Set up basic pieces of ui::wm. 235 // Set up basic pieces of ui::wm.
238 gfx::Size size = GetPrimaryDisplaySize(); 236 gfx::Size size = GetPrimaryDisplaySize();
239 if (size.IsEmpty()) 237 if (size.IsEmpty())
240 size = gfx::Size(800, 600); 238 size = gfx::Size(800, 600);
241 239
242 host_.reset(aura::WindowTreeHost::Create(gfx::Rect(size))); 240 host_.reset(aura::WindowTreeHost::Create(gfx::Rect(size)));
243 host_->InitHost(); 241 host_->InitHost();
244 aura::client::SetWindowTreeClient(host_->window(), this); 242 aura::client::SetWindowTreeClient(host_->window(), this);
245 root_window_event_filter_.reset(new wm::CompoundEventFilter); 243 root_window_event_filter_.reset(new wm::CompoundEventFilter);
246 host_->window()->AddPreTargetHandler(root_window_event_filter_.get()); 244 host_->window()->AddPreTargetHandler(root_window_event_filter_.get());
247 InitWindowManager(); 245 InitWindowManager();
248 246
249 host_->AddObserver(this); 247 host_->AddObserver(this);
250 248
251 // Ensure the X window gets mapped. 249 // Ensure the X window gets mapped.
252 host_->Show(); 250 host_->Show();
253 } 251 }
254 252
255 void ShellDesktopController::InitWindowManager() { 253 void ShellDesktopController::InitWindowManager() {
256 focus_client_.reset(new wm::FocusController(new AppsFocusRules())); 254 wm::FocusController* focus_controller =
257 aura::client::SetFocusClient(host_->window(), focus_client_.get()); 255 new wm::FocusController(new AppsFocusRules());
256 aura::client::SetFocusClient(host_->window(), focus_controller);
257 host_->window()->AddPreTargetHandler(focus_controller);
258 aura::client::SetActivationClient(host_->window(), focus_controller);
259 focus_client_.reset(focus_controller);
258 260
259 input_method_filter_.reset( 261 input_method_filter_.reset(
260 new wm::InputMethodEventFilter(host_->GetAcceleratedWidget())); 262 new wm::InputMethodEventFilter(host_->GetAcceleratedWidget()));
261 input_method_filter_->SetInputMethodPropertyInRootWindow(host_->window()); 263 input_method_filter_->SetInputMethodPropertyInRootWindow(host_->window());
262 root_window_event_filter_->AddHandler(input_method_filter_.get()); 264 root_window_event_filter_->AddHandler(input_method_filter_.get());
263 265
264 new wm::DefaultActivationClient(host_->window());
265
266 capture_client_.reset( 266 capture_client_.reset(
267 new aura::client::DefaultCaptureClient(host_->window())); 267 new aura::client::DefaultCaptureClient(host_->window()));
268 268
269 // Ensure new windows fill the display. 269 // Ensure new windows fill the display.
270 host_->window()->SetLayoutManager(new FillLayout); 270 host_->window()->SetLayoutManager(new FillLayout);
271 271
272 cursor_manager_.reset( 272 cursor_manager_.reset(
273 new wm::CursorManager(scoped_ptr<wm::NativeCursorManager>( 273 new wm::CursorManager(scoped_ptr<wm::NativeCursorManager>(
274 new ShellNativeCursorManager(host_.get())))); 274 new ShellNativeCursorManager(host_.get()))));
275 cursor_manager_->SetDisplay( 275 cursor_manager_->SetDisplay(
(...skipping 11 matching lines...) Expand all
287 } 287 }
288 288
289 void ShellDesktopController::DestroyRootWindow() { 289 void ShellDesktopController::DestroyRootWindow() {
290 host_->RemoveObserver(this); 290 host_->RemoveObserver(this);
291 if (input_method_filter_) 291 if (input_method_filter_)
292 root_window_event_filter_->RemoveHandler(input_method_filter_.get()); 292 root_window_event_filter_->RemoveHandler(input_method_filter_.get());
293 if (user_activity_detector_) { 293 if (user_activity_detector_) {
294 host_->event_processor()->GetRootTarget()->RemovePreTargetHandler( 294 host_->event_processor()->GetRootTarget()->RemovePreTargetHandler(
295 user_activity_detector_.get()); 295 user_activity_detector_.get());
296 } 296 }
297 wm::FocusController* focus_controller =
298 static_cast<wm::FocusController*>(focus_client_.get());
299 if (focus_controller) {
300 host_->window()->RemovePreTargetHandler(focus_controller);
301 aura::client::SetActivationClient(host_->window(), NULL);
302 }
297 root_window_event_filter_.reset(); 303 root_window_event_filter_.reset();
298 capture_client_.reset(); 304 capture_client_.reset();
299 input_method_filter_.reset(); 305 input_method_filter_.reset();
300 focus_client_.reset(); 306 focus_client_.reset();
301 cursor_manager_.reset(); 307 cursor_manager_.reset();
302 #if defined(OS_CHROMEOS) 308 #if defined(OS_CHROMEOS)
303 user_activity_notifier_.reset(); 309 user_activity_notifier_.reset();
304 #endif 310 #endif
305 user_activity_detector_.reset(); 311 user_activity_detector_.reset();
306 host_.reset(); 312 host_.reset();
307 ui::ShutdownInputMethodForTesting();
308 } 313 }
309 314
310 gfx::Size ShellDesktopController::GetPrimaryDisplaySize() { 315 gfx::Size ShellDesktopController::GetPrimaryDisplaySize() {
311 #if defined(OS_CHROMEOS) 316 #if defined(OS_CHROMEOS)
312 const std::vector<ui::DisplayConfigurator::DisplayState>& displays = 317 const std::vector<ui::DisplayConfigurator::DisplayState>& displays =
313 display_configurator_->cached_displays(); 318 display_configurator_->cached_displays();
314 if (displays.empty()) 319 if (displays.empty())
315 return gfx::Size(); 320 return gfx::Size();
316 const ui::DisplayMode* mode = displays[0].display->current_mode(); 321 const ui::DisplayMode* mode = displays[0].display->current_mode();
317 return mode ? mode->size() : gfx::Size(); 322 return mode ? mode->size() : gfx::Size();
318 #else 323 #else
319 return gfx::Size(); 324 return gfx::Size();
320 #endif 325 #endif
321 } 326 }
322 327
323 } // namespace apps 328 } // namespace apps
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698