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

Side by Side Diff: ui/views/widget/desktop_native_widget_helper_aura.cc

Issue 10939006: Make cursors work on win aura. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync 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
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 "ui/views/widget/desktop_native_widget_helper_aura.h" 5 #include "ui/views/widget/desktop_native_widget_helper_aura.h"
6 6
7 #include "ui/aura/client/dispatcher_client.h" 7 #include "ui/aura/client/dispatcher_client.h"
8 #include "ui/aura/client/screen_position_client.h"
9 #include "ui/aura/desktop/desktop_activation_client.h" 8 #include "ui/aura/desktop/desktop_activation_client.h"
10 #include "ui/aura/desktop/desktop_cursor_client.h" 9 #include "ui/aura/desktop/desktop_cursor_client.h"
11 #include "ui/aura/desktop/desktop_dispatcher_client.h" 10 #include "ui/aura/desktop/desktop_dispatcher_client.h"
12 #include "ui/aura/focus_manager.h" 11 #include "ui/aura/focus_manager.h"
13 #include "ui/aura/root_window.h" 12 #include "ui/aura/root_window.h"
14 #include "ui/aura/shared/compound_event_filter.h" 13 #include "ui/aura/shared/compound_event_filter.h"
15 #include "ui/aura/shared/input_method_event_filter.h" 14 #include "ui/aura/shared/input_method_event_filter.h"
16 #include "ui/aura/shared/root_window_capture_client.h" 15 #include "ui/aura/shared/root_window_capture_client.h"
17 #include "ui/aura/window_property.h" 16 #include "ui/aura/window_property.h"
17 #include "ui/views/widget/desktop_screen_position_client.h"
18 #include "ui/views/widget/native_widget_aura.h" 18 #include "ui/views/widget/native_widget_aura.h"
19 19
20 #if defined(OS_WIN) 20 #if defined(OS_WIN)
21 #include "ui/base/win/hwnd_subclass.h" 21 #include "ui/base/win/hwnd_subclass.h"
22 #include "ui/views/widget/widget_message_filter.h" 22 #include "ui/views/widget/widget_message_filter.h"
23 #elif defined(USE_X11) 23 #elif defined(USE_X11)
24 #include "ui/base/x/x11_util.h" 24 #include "ui/base/x/x11_util.h"
25 #include "ui/views/widget/x11_desktop_handler.h" 25 #include "ui/views/widget/x11_desktop_handler.h"
26 #include "ui/views/widget/x11_desktop_window_move_client.h" 26 #include "ui/views/widget/x11_desktop_window_move_client.h"
27 #include "ui/views/widget/x11_window_event_filter.h" 27 #include "ui/views/widget/x11_window_event_filter.h"
28 #endif 28 #endif
29 29
30 namespace views { 30 namespace views {
31 31
32 DEFINE_WINDOW_PROPERTY_KEY( 32 DEFINE_WINDOW_PROPERTY_KEY(
33 aura::Window*, kViewsWindowForRootWindow, NULL); 33 aura::Window*, kViewsWindowForRootWindow, NULL);
34 34
35 namespace {
36
37 // Client that always offsets by the toplevel RootWindow of the passed
38 // in child NativeWidgetAura.
39 class DesktopScreenPositionClient
40 : public aura::client::ScreenPositionClient {
41 public:
42 DesktopScreenPositionClient() {}
43 virtual ~DesktopScreenPositionClient() {}
44
45 // aura::client::ScreenPositionClient overrides:
46 virtual void ConvertPointToScreen(const aura::Window* window,
47 gfx::Point* point) OVERRIDE {
48 const aura::RootWindow* root_window = window->GetRootWindow();
49 aura::Window::ConvertPointToTarget(window, root_window, point);
50 gfx::Point origin = root_window->GetHostOrigin();
51 point->Offset(origin.x(), origin.y());
52 }
53
54 virtual void ConvertPointFromScreen(const aura::Window* window,
55 gfx::Point* point) OVERRIDE {
56 const aura::RootWindow* root_window = window->GetRootWindow();
57 gfx::Point origin = root_window->GetHostOrigin();
58 point->Offset(-origin.x(), -origin.y());
59 aura::Window::ConvertPointToTarget(root_window, window, point);
60 }
61
62 virtual void SetBounds(aura::Window* window,
63 const gfx::Rect& bounds,
64 const gfx::Display& display) OVERRIDE {
65 // TODO: Use the 3rd parameter, |display|.
66 gfx::Point origin = bounds.origin();
67 aura::RootWindow* root = window->GetRootWindow();
68 aura::Window::ConvertPointToTarget(window->parent(), root, &origin);
69
70 #if !defined(OS_WIN)
71 if (window->type() == aura::client::WINDOW_TYPE_CONTROL) {
72 window->SetBounds(gfx::Rect(origin, bounds.size()));
73 return;
74 } else if (window->type() == aura::client::WINDOW_TYPE_POPUP) {
75 // The caller expects windows we consider "embedded" to be placed in the
76 // screen coordinate system. So we need to offset the root window's
77 // position (which is in screen coordinates) from these bounds.
78 gfx::Point host_origin = root->GetHostOrigin();
79 origin.Offset(-host_origin.x(), -host_origin.y());
80 window->SetBounds(gfx::Rect(origin, bounds.size()));
81 return;
82 }
83 #endif // !defined(OS_WIN)
84 root->SetHostBounds(bounds);
85 window->SetBounds(gfx::Rect(bounds.size()));
86 }
87 };
88
89 } // namespace
90
91 DesktopNativeWidgetHelperAura::DesktopNativeWidgetHelperAura( 35 DesktopNativeWidgetHelperAura::DesktopNativeWidgetHelperAura(
92 NativeWidgetAura* widget) 36 NativeWidgetAura* widget)
93 : widget_(widget), 37 : widget_(widget),
94 window_(NULL), 38 window_(NULL),
95 root_window_event_filter_(NULL), 39 root_window_event_filter_(NULL),
96 is_embedded_window_(false) { 40 is_embedded_window_(false) {
97 } 41 }
98 42
99 DesktopNativeWidgetHelperAura::~DesktopNativeWidgetHelperAura() { 43 DesktopNativeWidgetHelperAura::~DesktopNativeWidgetHelperAura() {
100 if (window_) 44 if (window_)
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // Pass ownership of the filter to the root_window. 109 // Pass ownership of the filter to the root_window.
166 root_window_->SetEventFilter(root_window_event_filter_); 110 root_window_->SetEventFilter(root_window_event_filter_);
167 111
168 input_method_filter_.reset(new aura::shared::InputMethodEventFilter()); 112 input_method_filter_.reset(new aura::shared::InputMethodEventFilter());
169 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window_.get()); 113 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window_.get());
170 root_window_event_filter_->AddFilter(input_method_filter_.get()); 114 root_window_event_filter_->AddFilter(input_method_filter_.get());
171 115
172 capture_client_.reset( 116 capture_client_.reset(
173 new aura::shared::RootWindowCaptureClient(root_window_.get())); 117 new aura::shared::RootWindowCaptureClient(root_window_.get()));
174 118
175 cursor_client_.reset(new aura::DesktopCursorClient(root_window_.get()));
176 aura::client::SetCursorClient(root_window_.get(), cursor_client_.get());
177
178 #if defined(USE_X11) 119 #if defined(USE_X11)
179 x11_window_event_filter_.reset( 120 x11_window_event_filter_.reset(
180 new X11WindowEventFilter(root_window_.get(), activation_client)); 121 new X11WindowEventFilter(root_window_.get(), activation_client));
181 x11_window_event_filter_->SetUseHostWindowBorders(false); 122 x11_window_event_filter_->SetUseHostWindowBorders(false);
182 root_window_event_filter_->AddFilter(x11_window_event_filter_.get()); 123 root_window_event_filter_->AddFilter(x11_window_event_filter_.get());
183 124
184 if (params.type == Widget::InitParams::TYPE_MENU) { 125 if (params.type == Widget::InitParams::TYPE_MENU) {
185 ::Window window = root_window_->GetAcceleratedWidget(); 126 ::Window window = root_window_->GetAcceleratedWidget();
186 XSetWindowAttributes attributes; 127 XSetWindowAttributes attributes;
187 memset(&attributes, 0, sizeof(attributes)); 128 memset(&attributes, 0, sizeof(attributes));
(...skipping 12 matching lines...) Expand all
200 aura::client::SetDispatcherClient(root_window_.get(), 141 aura::client::SetDispatcherClient(root_window_.get(),
201 new aura::DesktopDispatcherClient); 142 new aura::DesktopDispatcherClient);
202 #if defined(USE_X11) 143 #if defined(USE_X11)
203 // TODO(ben): A window implementation of this will need to be written. 144 // TODO(ben): A window implementation of this will need to be written.
204 x11_window_move_client_.reset(new X11DesktopWindowMoveClient); 145 x11_window_move_client_.reset(new X11DesktopWindowMoveClient);
205 root_window_event_filter_->AddFilter(x11_window_move_client_.get()); 146 root_window_event_filter_->AddFilter(x11_window_move_client_.get());
206 aura::client::SetWindowMoveClient(root_window_.get(), 147 aura::client::SetWindowMoveClient(root_window_.get(),
207 x11_window_move_client_.get()); 148 x11_window_move_client_.get());
208 #endif 149 #endif
209 150
151 #if !defined(OS_WIN) // Windows does this in DesktopRootWindowHostWin.
152 cursor_client_.reset(new aura::DesktopCursorClient(root_window_.get()));
153 aura::client::SetCursorClient(root_window_.get(), cursor_client_.get());
154
210 position_client_.reset(new DesktopScreenPositionClient()); 155 position_client_.reset(new DesktopScreenPositionClient());
211 aura::client::SetScreenPositionClient(root_window_.get(), 156 aura::client::SetScreenPositionClient(root_window_.get(),
212 position_client_.get()); 157 position_client_.get());
158 #endif
213 } 159 }
214 160
215 void DesktopNativeWidgetHelperAura::PostInitialize() { 161 void DesktopNativeWidgetHelperAura::PostInitialize() {
216 #if defined(OS_WIN) 162 #if defined(OS_WIN)
217 DCHECK(root_window_->GetAcceleratedWidget()); 163 DCHECK(root_window_->GetAcceleratedWidget());
218 hwnd_message_filter_.reset(new WidgetMessageFilter(root_window_.get(), 164 hwnd_message_filter_.reset(new WidgetMessageFilter(root_window_.get(),
219 widget_->GetWidget())); 165 widget_->GetWidget()));
220 ui::HWNDSubclass::AddFilterToTarget(root_window_->GetAcceleratedWidget(), 166 ui::HWNDSubclass::AddFilterToTarget(root_window_->GetAcceleratedWidget(),
221 hwnd_message_filter_.get()); 167 hwnd_message_filter_.get());
222 #endif 168 #endif
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 widget_->GetWidget()->Close(); 228 widget_->GetWidget()->Close();
283 } 229 }
284 230
285 void DesktopNativeWidgetHelperAura::OnRootWindowMoved( 231 void DesktopNativeWidgetHelperAura::OnRootWindowMoved(
286 const aura::RootWindow* root, 232 const aura::RootWindow* root,
287 const gfx::Point& new_origin) { 233 const gfx::Point& new_origin) {
288 widget_->GetWidget()->OnNativeWidgetMove(); 234 widget_->GetWidget()->OnNativeWidgetMove();
289 } 235 }
290 236
291 } // namespace views 237 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_native_widget_aura.cc ('k') | ui/views/widget/desktop_root_window_host_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698