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

Side by Side Diff: ash/host/ash_window_tree_host.cc

Issue 1676713002: ash/mash: Add a mus-client that sets up ash to provide the system ui for mash. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix-cros-build Created 4 years, 10 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
« no previous file with comments | « ash/host/ash_window_tree_host.h ('k') | ash/host/ash_window_tree_host_platform.h » ('j') | 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 "ash/host/ash_window_tree_host.h" 5 #include "ash/host/ash_window_tree_host.h"
6 6
7 #include "ash/host/ash_window_tree_host_init_params.h" 7 #include "ash/host/ash_window_tree_host_init_params.h"
8 #include "ash/host/ash_window_tree_host_unified.h" 8 #include "ash/host/ash_window_tree_host_unified.h"
9 #include "ui/aura/client/screen_position_client.h" 9 #include "ui/aura/client/screen_position_client.h"
10 #include "ui/aura/window_tree_host.h" 10 #include "ui/aura/window_tree_host.h"
11 #include "ui/events/event.h" 11 #include "ui/events/event.h"
12 #include "ui/gfx/geometry/rect.h" 12 #include "ui/gfx/geometry/rect.h"
13 13
14 #if defined(USE_OZONE) 14 #if defined(USE_OZONE)
15 #include "ash/host/ash_window_tree_host_platform.h" 15 #include "ash/host/ash_window_tree_host_platform.h"
16 #elif defined(USE_X11) 16 #elif defined(USE_X11)
17 #include "ash/host/ash_window_tree_host_x11.h" 17 #include "ash/host/ash_window_tree_host_x11.h"
18 #elif defined(OS_WIN) 18 #elif defined(OS_WIN)
19 #include "ash/host/ash_window_tree_host_win.h" 19 #include "ash/host/ash_window_tree_host_win.h"
20 #endif 20 #endif
21 21
22 namespace ash { 22 namespace ash {
23 23
24 namespace {
25
26 AshWindowTreeHost::Factory creation_factory;
27
28 } // namespace
29
24 AshWindowTreeHost::AshWindowTreeHost() : input_method_handler_(nullptr) { 30 AshWindowTreeHost::AshWindowTreeHost() : input_method_handler_(nullptr) {
25 } 31 }
26 32
27 void AshWindowTreeHost::TranslateLocatedEvent(ui::LocatedEvent* event) { 33 void AshWindowTreeHost::TranslateLocatedEvent(ui::LocatedEvent* event) {
28 if (event->IsTouchEvent()) 34 if (event->IsTouchEvent())
29 return; 35 return;
30 36
31 aura::WindowTreeHost* wth = AsWindowTreeHost(); 37 aura::WindowTreeHost* wth = AsWindowTreeHost();
32 aura::Window* root_window = wth->window(); 38 aura::Window* root_window = wth->window();
33 aura::client::ScreenPositionClient* screen_position_client = 39 aura::client::ScreenPositionClient* screen_position_client =
34 aura::client::GetScreenPositionClient(root_window); 40 aura::client::GetScreenPositionClient(root_window);
35 gfx::Rect local(wth->GetBounds().size()); 41 gfx::Rect local(wth->GetBounds().size());
36 local.Inset(GetHostInsets()); 42 local.Inset(GetHostInsets());
37 43
38 if (screen_position_client && !local.Contains(event->location())) { 44 if (screen_position_client && !local.Contains(event->location())) {
39 gfx::Point location(event->location()); 45 gfx::Point location(event->location());
40 // In order to get the correct point in screen coordinates 46 // In order to get the correct point in screen coordinates
41 // during passive grab, we first need to find on which host window 47 // during passive grab, we first need to find on which host window
42 // the mouse is on, and find out the screen coordinates on that 48 // the mouse is on, and find out the screen coordinates on that
43 // host window, then convert it back to this host window's coordinate. 49 // host window, then convert it back to this host window's coordinate.
44 screen_position_client->ConvertHostPointToScreen(root_window, &location); 50 screen_position_client->ConvertHostPointToScreen(root_window, &location);
45 screen_position_client->ConvertPointFromScreen(root_window, &location); 51 screen_position_client->ConvertPointFromScreen(root_window, &location);
46 wth->ConvertPointToHost(&location); 52 wth->ConvertPointToHost(&location);
47 event->set_location(location); 53 event->set_location(location);
48 event->set_root_location(location); 54 event->set_root_location(location);
49 } 55 }
50 } 56 }
51 57
58 // static
52 AshWindowTreeHost* AshWindowTreeHost::Create( 59 AshWindowTreeHost* AshWindowTreeHost::Create(
53 const AshWindowTreeHostInitParams& init_params) { 60 const AshWindowTreeHostInitParams& init_params) {
61 if (!creation_factory.is_null())
62 return creation_factory.Run(init_params);
63
54 if (init_params.offscreen) 64 if (init_params.offscreen)
55 return new AshWindowTreeHostUnified(init_params.initial_bounds); 65 return new AshWindowTreeHostUnified(init_params.initial_bounds);
56 #if defined(USE_OZONE) 66 #if defined(USE_OZONE)
57 return new AshWindowTreeHostPlatform(init_params.initial_bounds); 67 return new AshWindowTreeHostPlatform(init_params.initial_bounds);
58 #elif defined(USE_X11) 68 #elif defined(USE_X11)
59 return new AshWindowTreeHostX11(init_params.initial_bounds); 69 return new AshWindowTreeHostX11(init_params.initial_bounds);
60 #elif defined(OS_WIN) 70 #elif defined(OS_WIN)
61 return new AshWindowTreeHostWin(init_params.initial_bounds); 71 return new AshWindowTreeHostWin(init_params.initial_bounds);
62 #else 72 #else
63 #error Unsupported platform. 73 #error Unsupported platform.
64 #endif 74 #endif
65 } 75 }
66 76
77 // static
78 void AshWindowTreeHost::SetFactory(const Factory& factory) {
79 creation_factory = factory;
80 }
81
67 } // namespace ash 82 } // namespace ash
OLDNEW
« no previous file with comments | « ash/host/ash_window_tree_host.h ('k') | ash/host/ash_window_tree_host_platform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698