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

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

Issue 1683853003: Revert of 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: 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
30 AshWindowTreeHost::AshWindowTreeHost() : input_method_handler_(nullptr) { 24 AshWindowTreeHost::AshWindowTreeHost() : input_method_handler_(nullptr) {
31 } 25 }
32 26
33 void AshWindowTreeHost::TranslateLocatedEvent(ui::LocatedEvent* event) { 27 void AshWindowTreeHost::TranslateLocatedEvent(ui::LocatedEvent* event) {
34 if (event->IsTouchEvent()) 28 if (event->IsTouchEvent())
35 return; 29 return;
36 30
37 aura::WindowTreeHost* wth = AsWindowTreeHost(); 31 aura::WindowTreeHost* wth = AsWindowTreeHost();
38 aura::Window* root_window = wth->window(); 32 aura::Window* root_window = wth->window();
39 aura::client::ScreenPositionClient* screen_position_client = 33 aura::client::ScreenPositionClient* screen_position_client =
40 aura::client::GetScreenPositionClient(root_window); 34 aura::client::GetScreenPositionClient(root_window);
41 gfx::Rect local(wth->GetBounds().size()); 35 gfx::Rect local(wth->GetBounds().size());
42 local.Inset(GetHostInsets()); 36 local.Inset(GetHostInsets());
43 37
44 if (screen_position_client && !local.Contains(event->location())) { 38 if (screen_position_client && !local.Contains(event->location())) {
45 gfx::Point location(event->location()); 39 gfx::Point location(event->location());
46 // In order to get the correct point in screen coordinates 40 // In order to get the correct point in screen coordinates
47 // during passive grab, we first need to find on which host window 41 // during passive grab, we first need to find on which host window
48 // the mouse is on, and find out the screen coordinates on that 42 // the mouse is on, and find out the screen coordinates on that
49 // host window, then convert it back to this host window's coordinate. 43 // host window, then convert it back to this host window's coordinate.
50 screen_position_client->ConvertHostPointToScreen(root_window, &location); 44 screen_position_client->ConvertHostPointToScreen(root_window, &location);
51 screen_position_client->ConvertPointFromScreen(root_window, &location); 45 screen_position_client->ConvertPointFromScreen(root_window, &location);
52 wth->ConvertPointToHost(&location); 46 wth->ConvertPointToHost(&location);
53 event->set_location(location); 47 event->set_location(location);
54 event->set_root_location(location); 48 event->set_root_location(location);
55 } 49 }
56 } 50 }
57 51
58 // static
59 AshWindowTreeHost* AshWindowTreeHost::Create( 52 AshWindowTreeHost* AshWindowTreeHost::Create(
60 const AshWindowTreeHostInitParams& init_params) { 53 const AshWindowTreeHostInitParams& init_params) {
61 if (!creation_factory.is_null())
62 return creation_factory.Run(init_params);
63
64 if (init_params.offscreen) 54 if (init_params.offscreen)
65 return new AshWindowTreeHostUnified(init_params.initial_bounds); 55 return new AshWindowTreeHostUnified(init_params.initial_bounds);
66 #if defined(USE_OZONE) 56 #if defined(USE_OZONE)
67 return new AshWindowTreeHostPlatform(init_params.initial_bounds); 57 return new AshWindowTreeHostPlatform(init_params.initial_bounds);
68 #elif defined(USE_X11) 58 #elif defined(USE_X11)
69 return new AshWindowTreeHostX11(init_params.initial_bounds); 59 return new AshWindowTreeHostX11(init_params.initial_bounds);
70 #elif defined(OS_WIN) 60 #elif defined(OS_WIN)
71 return new AshWindowTreeHostWin(init_params.initial_bounds); 61 return new AshWindowTreeHostWin(init_params.initial_bounds);
72 #else 62 #else
73 #error Unsupported platform. 63 #error Unsupported platform.
74 #endif 64 #endif
75 } 65 }
76 66
77 // static
78 void AshWindowTreeHost::SetFactory(const Factory& factory) {
79 creation_factory = factory;
80 }
81
82 } // namespace ash 67 } // 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