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

Side by Side Diff: ash/ui_controls_ash.cc

Issue 11419013: Add desktop vs. ash context to ui_controls Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 8 years, 1 month 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
OLDNEW
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 "ash/shell.h" 5 #include "ash/shell.h"
6 #include "ash/shell_factory.h" 6 #include "ash/shell_factory.h"
7 #include "ash/wm/coordinate_conversion.h" 7 #include "ash/wm/coordinate_conversion.h"
8 #include "ash/wm/window_properties.h" 8 #include "ash/wm/window_properties.h"
9 #include "ui/aura/client/capture_client.h" 9 #include "ui/aura/client/capture_client.h"
10 #include "ui/aura/client/screen_position_client.h" 10 #include "ui/aura/client/screen_position_client.h"
11 #include "ui/aura/desktop_ui_controls.h"
11 #include "ui/aura/root_window.h" 12 #include "ui/aura/root_window.h"
12 #include "ui/aura/ui_controls_aura.h"
13 #include "ui/gfx/screen.h" 13 #include "ui/gfx/screen.h"
14 #include "ui/ui_controls/ui_controls_aura.h" 14 #include "ui/ui_controls/ui_controls.h"
15 15
16 namespace ash { 16 namespace ash {
17 namespace internal { 17 namespace internal {
18 namespace { 18 namespace {
19 19
20 // Returns the UIControls object for RootWindow. 20 // Returns the UIControls object for RootWindow.
21 // kUIControlsKey is owned property and UIControls object 21 // kUIControlsKey is owned property and UIControls object
22 // will be deleted when the root window is deleted. 22 // will be deleted when the root window is deleted.
23 ui_controls::UIControlsAura* GetUIControlsForRootWindow( 23 ui_controls::UIControls* GetUIControlsForRootWindow(
24 aura::RootWindow* root_window) { 24 aura::RootWindow* root_window) {
25 ui_controls::UIControlsAura* native_ui_control = 25 ui_controls::UIControls* native_ui_control =
26 root_window->GetProperty(kUIControlsKey); 26 root_window->GetProperty(kUIControlsKey);
27 if (!native_ui_control) { 27 if (!native_ui_control) {
28 native_ui_control = aura::CreateUIControlsAura(root_window); 28 native_ui_control = aura::CreateDesktopUIControls(root_window);
29 // Pass the ownership to the |root_window|. 29 // Pass the ownership to the |root_window|.
30 root_window->SetProperty(kUIControlsKey, native_ui_control); 30 root_window->SetProperty(kUIControlsKey, native_ui_control);
31 } 31 }
32 return native_ui_control; 32 return native_ui_control;
33 } 33 }
34 34
35 // Returns the UIControls object for the RootWindow at the |point_in_screen| 35 // Returns the UIControls object for the RootWindow at the |point_in_screen|
36 // in virtual screen coordinates, and updates the |point| relative to the 36 // in virtual screen coordinates, and updates the |point| relative to the
37 // UIControlsAura's root window. NULL if there is no RootWindow under 37 // UIControls's root window. NULL if there is no RootWindow under
38 // the |point_in_screen|. 38 // the |point_in_screen|.
39 ui_controls::UIControlsAura* GetUIControlsAt(gfx::Point* point_in_screen) { 39 ui_controls::UIControls* GetUIControlsAt(gfx::Point* point_in_screen) {
40 // TODO(mazda): Support the case passive grab is taken. 40 // TODO(mazda): Support the case passive grab is taken.
41 aura::RootWindow* root = wm::GetRootWindowAt(*point_in_screen); 41 aura::RootWindow* root = wm::GetRootWindowAt(*point_in_screen);
42 42
43 aura::client::ScreenPositionClient* screen_position_client = 43 aura::client::ScreenPositionClient* screen_position_client =
44 aura::client::GetScreenPositionClient(root); 44 aura::client::GetScreenPositionClient(root);
45 if (screen_position_client) 45 if (screen_position_client)
46 screen_position_client->ConvertPointFromScreen(root, point_in_screen); 46 screen_position_client->ConvertPointFromScreen(root, point_in_screen);
47 47
48 return GetUIControlsForRootWindow(root); 48 return GetUIControlsForRootWindow(root);
49 } 49 }
50 50
51 } // namespace 51 } // namespace
52 52
53 class UIControlsAsh : public ui_controls::UIControlsAura { 53 class UIControlsAsh : public ui_controls::UIControls {
54 public: 54 public:
55 UIControlsAsh() { 55 UIControlsAsh() {
56 } 56 }
57 virtual ~UIControlsAsh() { 57 virtual ~UIControlsAsh() {
58 } 58 }
59 59
60 // ui_controls::UIControslAura overrides: 60 // ui_controls::UIControslAura overrides:
61 virtual bool SendKeyPress(gfx::NativeWindow window, 61 virtual bool SendKeyPress(gfx::NativeWindow window,
62 ui::KeyboardCode key, 62 ui::KeyboardCode key,
63 bool control, 63 bool control,
64 bool shift, 64 bool shift,
65 bool alt, 65 bool alt,
66 bool command) OVERRIDE { 66 bool command) OVERRIDE {
67 return SendKeyPressNotifyWhenDone( 67 return SendKeyPressNotifyWhenDone(
68 window, key, control, shift, alt, command, base::Closure()); 68 window, key, control, shift, alt, command, base::Closure());
69 } 69 }
70 70
71 virtual bool SendKeyPressNotifyWhenDone( 71 virtual bool SendKeyPressNotifyWhenDone(
72 gfx::NativeWindow window, 72 gfx::NativeWindow window,
73 ui::KeyboardCode key, 73 ui::KeyboardCode key,
74 bool control, 74 bool control,
75 bool shift, 75 bool shift,
76 bool alt, 76 bool alt,
77 bool command, 77 bool command,
78 const base::Closure& closure) OVERRIDE { 78 const base::Closure& closure) OVERRIDE {
79 aura::RootWindow* root = 79 aura::RootWindow* root =
80 window ? window->GetRootWindow() : Shell::GetActiveRootWindow(); 80 window ? window->GetRootWindow() : Shell::GetActiveRootWindow();
81 ui_controls::UIControlsAura* ui_controls = GetUIControlsForRootWindow(root); 81 ui_controls::UIControls* ui_controls = GetUIControlsForRootWindow(root);
82 return ui_controls && ui_controls->SendKeyPressNotifyWhenDone( 82 return ui_controls && ui_controls->SendKeyPressNotifyWhenDone(
83 window, key, control, shift, alt, command, closure); 83 window, key, control, shift, alt, command, closure);
84 } 84 }
85 85
86 virtual bool SendMouseMove(long x, long y) OVERRIDE { 86 virtual bool SendMouseMove(long x, long y) OVERRIDE {
87 gfx::Point p(x, y); 87 gfx::Point p(x, y);
88 ui_controls::UIControlsAura* ui_controls = GetUIControlsAt(&p); 88 ui_controls::UIControls* ui_controls = GetUIControlsAt(&p);
89 return ui_controls && ui_controls->SendMouseMove(p.x(), p.y()); 89 return ui_controls && ui_controls->SendMouseMove(p.x(), p.y());
90 } 90 }
91 91
92 virtual bool SendMouseMoveNotifyWhenDone( 92 virtual bool SendMouseMoveNotifyWhenDone(
93 long x, 93 long x,
94 long y, 94 long y,
95 const base::Closure& closure) OVERRIDE { 95 const base::Closure& closure) OVERRIDE {
96 gfx::Point p(x, y); 96 gfx::Point p(x, y);
97 ui_controls::UIControlsAura* ui_controls = GetUIControlsAt(&p); 97 ui_controls::UIControls* ui_controls = GetUIControlsAt(&p);
98 return ui_controls && 98 return ui_controls &&
99 ui_controls->SendMouseMoveNotifyWhenDone(p.x(), p.y(), closure); 99 ui_controls->SendMouseMoveNotifyWhenDone(p.x(), p.y(), closure);
100 } 100 }
101 101
102 virtual bool SendMouseEvents(ui_controls::MouseButton type, 102 virtual bool SendMouseEvents(ui_controls::MouseButton type,
103 int state) OVERRIDE { 103 int state) OVERRIDE {
104 gfx::Point p(Shell::GetScreen()->GetCursorScreenPoint()); 104 gfx::Point p(Shell::GetScreen()->GetCursorScreenPoint());
105 ui_controls::UIControlsAura* ui_controls = GetUIControlsAt(&p); 105 ui_controls::UIControls* ui_controls = GetUIControlsAt(&p);
106 return ui_controls && ui_controls->SendMouseEvents(type, state); 106 return ui_controls && ui_controls->SendMouseEvents(type, state);
107 } 107 }
108 108
109 virtual bool SendMouseEventsNotifyWhenDone( 109 virtual bool SendMouseEventsNotifyWhenDone(
110 ui_controls::MouseButton type, 110 ui_controls::MouseButton type,
111 int state, 111 int state,
112 const base::Closure& closure) OVERRIDE { 112 const base::Closure& closure) OVERRIDE {
113 gfx::Point p(Shell::GetScreen()->GetCursorScreenPoint()); 113 gfx::Point p(Shell::GetScreen()->GetCursorScreenPoint());
114 ui_controls::UIControlsAura* ui_controls = GetUIControlsAt(&p); 114 ui_controls::UIControls* ui_controls = GetUIControlsAt(&p);
115 return ui_controls && ui_controls->SendMouseEventsNotifyWhenDone( 115 return ui_controls && ui_controls->SendMouseEventsNotifyWhenDone(
116 type, state, closure); 116 type, state, closure);
117 } 117 }
118 118
119 virtual bool SendMouseClick(ui_controls::MouseButton type) OVERRIDE { 119 virtual bool SendMouseClick(ui_controls::MouseButton type) OVERRIDE {
120 gfx::Point p(Shell::GetScreen()->GetCursorScreenPoint()); 120 gfx::Point p(Shell::GetScreen()->GetCursorScreenPoint());
121 ui_controls::UIControlsAura* ui_controls = GetUIControlsAt(&p); 121 ui_controls::UIControls* ui_controls = GetUIControlsAt(&p);
122 return ui_controls && ui_controls->SendMouseClick(type); 122 return ui_controls && ui_controls->SendMouseClick(type);
123 } 123 }
124 124
125 virtual void RunClosureAfterAllPendingUIEvents( 125 virtual void RunClosureAfterAllPendingUIEvents(
126 const base::Closure& closure) OVERRIDE { 126 const base::Closure& closure) OVERRIDE {
127 ui_controls::UIControlsAura* ui_controls = GetUIControlsForRootWindow( 127 ui_controls::UIControls* ui_controls = GetUIControlsForRootWindow(
128 Shell::GetActiveRootWindow()); 128 Shell::GetActiveRootWindow());
129 if (ui_controls) 129 if (ui_controls)
130 ui_controls->RunClosureAfterAllPendingUIEvents(closure); 130 ui_controls->RunClosureAfterAllPendingUIEvents(closure);
131 } 131 }
132 132
133 private: 133 private:
134 DISALLOW_COPY_AND_ASSIGN(UIControlsAsh); 134 DISALLOW_COPY_AND_ASSIGN(UIControlsAsh);
135 }; 135 };
136 136
137 ui_controls::UIControlsAura* CreateUIControls() { 137 ui_controls::UIControls* CreateUIControls() {
138 return new UIControlsAsh(); 138 return new UIControlsAsh();
139 } 139 }
140 140
141 } // namespace internal 141 } // namespace internal
142 } // namespace ash 142 } // namespace ash
OLDNEW
« ash/shell.cc ('K') | « ash/shell_factory.h ('k') | ash/wm/window_properties.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698