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

Side by Side Diff: ash/ui_controls_ash.cc

Issue 10909043: Cancel drag if display configuration changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | « ash/root_window_controller.cc ('k') | ash/wm/toplevel_window_event_handler.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 (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/root_window.h" 11 #include "ui/aura/root_window.h"
11 #include "ui/aura/ui_controls_aura.h" 12 #include "ui/aura/ui_controls_aura.h"
12 #include "ui/gfx/screen.h" 13 #include "ui/gfx/screen.h"
13 #include "ui/ui_controls/ui_controls_aura.h" 14 #include "ui/ui_controls/ui_controls_aura.h"
14 15
15 namespace ash { 16 namespace ash {
16 namespace internal { 17 namespace internal {
17 namespace { 18 namespace {
18 19
19 // Returns the UIControls object for RootWindow. 20 // Returns the UIControls object for RootWindow.
20 // kUIControlsKey is owned property and UIControls object 21 // kUIControlsKey is owned property and UIControls object
21 // will be deleted when the root window is deleted. 22 // will be deleted when the root window is deleted.
22 ui_controls::UIControlsAura* GetUIControlsForRootWindow( 23 ui_controls::UIControlsAura* GetUIControlsForRootWindow(
23 aura::RootWindow* root_window) { 24 aura::RootWindow* root_window) {
24 ui_controls::UIControlsAura* native_ui_control = 25 ui_controls::UIControlsAura* native_ui_control =
25 root_window->GetProperty(kUIControlsKey); 26 root_window->GetProperty(kUIControlsKey);
26 if (!native_ui_control) { 27 if (!native_ui_control) {
27 native_ui_control = aura::CreateUIControlsAura(root_window); 28 native_ui_control = aura::CreateUIControlsAura(root_window);
28 // Pass the ownership to the |root_window|. 29 // Pass the ownership to the |root_window|.
29 root_window->SetProperty(kUIControlsKey, native_ui_control); 30 root_window->SetProperty(kUIControlsKey, native_ui_control);
30 } 31 }
31 return native_ui_control; 32 return native_ui_control;
32 } 33 }
33 34
34 // Returns the UIControls object for the RootWindow at the |point| in 35 // Returns the UIControls object for the RootWindow at the |point| in
35 // absolute screen coordinates. NULL if there is no RootWindow under the 36 // virtual screen coordinates, and updates the |point| relative to the
36 // |point|. 37 // UIControlsAura's root window. NULL if there is no RootWindow under
37 ui_controls::UIControlsAura* GetUIControlsAt(const gfx::Point& point) { 38 // the |point|.
39 ui_controls::UIControlsAura* GetUIControlsAt(gfx::Point* point) {
38 // If there is a capture events must be relative to it. 40 // If there is a capture events must be relative to it.
39 aura::client::CaptureClient* capture_client = 41 aura::client::CaptureClient* capture_client =
40 GetCaptureClient(ash::Shell::GetInstance()->GetPrimaryRootWindow()); 42 GetCaptureClient(ash::Shell::GetInstance()->GetPrimaryRootWindow());
41 if (capture_client && capture_client->GetCaptureWindow()) { 43 aura::RootWindow* root = NULL;
42 return GetUIControlsForRootWindow( 44 if (capture_client && capture_client->GetCaptureWindow())
43 capture_client->GetCaptureWindow()->GetRootWindow()); 45 root = capture_client->GetCaptureWindow()->GetRootWindow();
44 } 46 else
45 aura::RootWindow* root = wm::GetRootWindowAt(point); 47 root = wm::GetRootWindowAt(*point);
46 return root ? GetUIControlsForRootWindow(root) : NULL; 48
49 aura::client::ScreenPositionClient* screen_position_client =
50 aura::client::GetScreenPositionClient(root);
51 if (screen_position_client)
52 screen_position_client->ConvertPointFromScreen(root, point);
53
54 return GetUIControlsForRootWindow(root);
47 } 55 }
48 56
49 } // namespace 57 } // namespace
50 58
51 class UIControlsAsh : public ui_controls::UIControlsAura { 59 class UIControlsAsh : public ui_controls::UIControlsAura {
52 public: 60 public:
53 UIControlsAsh() { 61 UIControlsAsh() {
54 } 62 }
55 virtual ~UIControlsAsh() { 63 virtual ~UIControlsAsh() {
56 } 64 }
(...skipping 18 matching lines...) Expand all
75 bool command, 83 bool command,
76 const base::Closure& closure) OVERRIDE { 84 const base::Closure& closure) OVERRIDE {
77 aura::RootWindow* root = 85 aura::RootWindow* root =
78 window ? window->GetRootWindow() : Shell::GetActiveRootWindow(); 86 window ? window->GetRootWindow() : Shell::GetActiveRootWindow();
79 ui_controls::UIControlsAura* ui_controls = GetUIControlsForRootWindow(root); 87 ui_controls::UIControlsAura* ui_controls = GetUIControlsForRootWindow(root);
80 return ui_controls && ui_controls->SendKeyPressNotifyWhenDone( 88 return ui_controls && ui_controls->SendKeyPressNotifyWhenDone(
81 window, key, control, shift, alt, command, closure); 89 window, key, control, shift, alt, command, closure);
82 } 90 }
83 91
84 virtual bool SendMouseMove(long x, long y) OVERRIDE { 92 virtual bool SendMouseMove(long x, long y) OVERRIDE {
85 ui_controls::UIControlsAura* ui_controls = 93 gfx::Point p(x, y);
86 GetUIControlsAt(gfx::Point(x, y)); 94 ui_controls::UIControlsAura* ui_controls = GetUIControlsAt(&p);
87 return ui_controls && ui_controls->SendMouseMove(x, y); 95 return ui_controls && ui_controls->SendMouseMove(p.x(), p.y());
88 } 96 }
89 97
90 virtual bool SendMouseMoveNotifyWhenDone( 98 virtual bool SendMouseMoveNotifyWhenDone(
91 long x, 99 long x,
92 long y, 100 long y,
93 const base::Closure& closure) OVERRIDE { 101 const base::Closure& closure) OVERRIDE {
94 ui_controls::UIControlsAura* ui_controls = 102 gfx::Point p(x, y);
95 GetUIControlsAt(gfx::Point(x, y)); 103 ui_controls::UIControlsAura* ui_controls = GetUIControlsAt(&p);
96 return ui_controls && 104 return ui_controls &&
97 ui_controls->SendMouseMoveNotifyWhenDone(x, y, closure); 105 ui_controls->SendMouseMoveNotifyWhenDone(p.x(), p.y(), closure);
98 } 106 }
99 107
100 virtual bool SendMouseEvents(ui_controls::MouseButton type, 108 virtual bool SendMouseEvents(ui_controls::MouseButton type,
101 int state) OVERRIDE { 109 int state) OVERRIDE {
102 ui_controls::UIControlsAura* ui_controls = 110 gfx::Point p(gfx::Screen::GetCursorScreenPoint());
103 GetUIControlsAt(gfx::Screen::GetCursorScreenPoint()); 111 ui_controls::UIControlsAura* ui_controls = GetUIControlsAt(&p);
104 return ui_controls && ui_controls->SendMouseEvents(type, state); 112 return ui_controls && ui_controls->SendMouseEvents(type, state);
105 } 113 }
106 114
107 virtual bool SendMouseEventsNotifyWhenDone( 115 virtual bool SendMouseEventsNotifyWhenDone(
108 ui_controls::MouseButton type, 116 ui_controls::MouseButton type,
109 int state, 117 int state,
110 const base::Closure& closure) OVERRIDE { 118 const base::Closure& closure) OVERRIDE {
111 ui_controls::UIControlsAura* ui_controls = 119 gfx::Point p(gfx::Screen::GetCursorScreenPoint());
112 GetUIControlsAt(gfx::Screen::GetCursorScreenPoint()); 120 ui_controls::UIControlsAura* ui_controls = GetUIControlsAt(&p);
113 return ui_controls && ui_controls->SendMouseEventsNotifyWhenDone( 121 return ui_controls && ui_controls->SendMouseEventsNotifyWhenDone(
114 type, state, closure); 122 type, state, closure);
115 } 123 }
116 124
117 virtual bool SendMouseClick(ui_controls::MouseButton type) OVERRIDE { 125 virtual bool SendMouseClick(ui_controls::MouseButton type) OVERRIDE {
118 ui_controls::UIControlsAura* ui_controls = 126 gfx::Point p(gfx::Screen::GetCursorScreenPoint());
119 GetUIControlsAt(gfx::Screen::GetCursorScreenPoint()); 127 ui_controls::UIControlsAura* ui_controls = GetUIControlsAt(&p);
120 return ui_controls && ui_controls->SendMouseClick(type); 128 return ui_controls && ui_controls->SendMouseClick(type);
121 } 129 }
122 130
123 virtual void RunClosureAfterAllPendingUIEvents( 131 virtual void RunClosureAfterAllPendingUIEvents(
124 const base::Closure& closure) OVERRIDE { 132 const base::Closure& closure) OVERRIDE {
125 ui_controls::UIControlsAura* ui_controls = GetUIControlsForRootWindow( 133 ui_controls::UIControlsAura* ui_controls = GetUIControlsForRootWindow(
126 Shell::GetActiveRootWindow()); 134 Shell::GetActiveRootWindow());
127 if (ui_controls) 135 if (ui_controls)
128 ui_controls->RunClosureAfterAllPendingUIEvents(closure); 136 ui_controls->RunClosureAfterAllPendingUIEvents(closure);
129 } 137 }
130 138
131 private: 139 private:
132 DISALLOW_COPY_AND_ASSIGN(UIControlsAsh); 140 DISALLOW_COPY_AND_ASSIGN(UIControlsAsh);
133 }; 141 };
134 142
135 ui_controls::UIControlsAura* CreateUIControls() { 143 ui_controls::UIControlsAura* CreateUIControls() {
136 return new UIControlsAsh(); 144 return new UIControlsAsh();
137 } 145 }
138 146
139 } // namespace internal 147 } // namespace internal
140 } // namespace ash 148 } // namespace ash
OLDNEW
« no previous file with comments | « ash/root_window_controller.cc ('k') | ash/wm/toplevel_window_event_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698