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

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

Issue 11369220: Move the desktop aura classes into a desktop subdir to make the gyp simpler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/views/widget/desktop_root_window_host_win.h"
6
7 #include "third_party/skia/include/core/SkPath.h"
8 #include "third_party/skia/include/core/SkRegion.h"
9 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/client/default_capture_client.h"
11 #include "ui/aura/focus_manager.h"
12 #include "ui/aura/root_window.h"
13 #include "ui/views/corewm/compound_event_filter.h"
14 #include "ui/views/corewm/input_method_event_filter.h"
15 #include "ui/aura/window_property.h"
16 #include "ui/base/cursor/cursor_loader_win.h"
17 #include "ui/base/native_theme/native_theme_aura.h"
18 #include "ui/base/native_theme/native_theme_win.h"
19 #include "ui/base/win/shell.h"
20 #include "ui/gfx/native_widget_types.h"
21 #include "ui/gfx/path_win.h"
22 #include "ui/views/ime/input_method_win.h"
23 #include "ui/views/widget/desktop_aura/desktop_activation_client.h"
24 #include "ui/views/widget/desktop_aura/desktop_cursor_client.h"
25 #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h"
26 #include "ui/views/widget/desktop_native_widget_aura.h"
27 #include "ui/views/widget/desktop_screen_position_client.h"
28 #include "ui/views/widget/widget_delegate.h"
29 #include "ui/views/widget/widget_hwnd_utils.h"
30 #include "ui/views/win/fullscreen_handler.h"
31 #include "ui/views/win/hwnd_message_handler.h"
32 #include "ui/views/window/native_frame_view.h"
33
34 namespace views {
35
36 DEFINE_WINDOW_PROPERTY_KEY(aura::Window*, kContentWindowForRootWindow, NULL);
37
38 ////////////////////////////////////////////////////////////////////////////////
39 // DesktopRootWindowHostWin, public:
40
41 DesktopRootWindowHostWin::DesktopRootWindowHostWin(
42 internal::NativeWidgetDelegate* native_widget_delegate,
43 DesktopNativeWidgetAura* desktop_native_widget_aura,
44 const gfx::Rect& initial_bounds)
45 : ALLOW_THIS_IN_INITIALIZER_LIST(
46 message_handler_(new HWNDMessageHandler(this))),
47 native_widget_delegate_(native_widget_delegate),
48 desktop_native_widget_aura_(desktop_native_widget_aura),
49 root_window_host_delegate_(NULL),
50 content_window_(NULL) {
51 }
52
53 DesktopRootWindowHostWin::~DesktopRootWindowHostWin() {
54 }
55
56 // static
57 aura::Window* DesktopRootWindowHostWin::GetContentWindowForHWND(HWND hwnd) {
58 aura::RootWindow* root = aura::RootWindow::GetForAcceleratedWidget(hwnd);
59 return root ? root->GetProperty(kContentWindowForRootWindow) : NULL;
60 }
61
62 // static
63 ui::NativeTheme* DesktopRootWindowHost::GetNativeTheme(aura::Window* window) {
64 // Use NativeThemeWin for windows shown on the desktop, those not on the
65 // desktop come from Ash and get NativeThemeAura.
66 aura::RootWindow* root = window->GetRootWindow();
67 if (root) {
68 HWND root_hwnd = root->GetAcceleratedWidget();
69 if (root_hwnd &&
70 DesktopRootWindowHostWin::GetContentWindowForHWND(root_hwnd)) {
71 return ui::NativeThemeWin::instance();
72 }
73 }
74 return ui::NativeThemeAura::instance();
75 }
76
77 ////////////////////////////////////////////////////////////////////////////////
78 // DesktopRootWindowHostWin, DesktopRootWindowHost implementation:
79
80 aura::RootWindow* DesktopRootWindowHostWin::Init(
81 aura::Window* content_window,
82 const Widget::InitParams& params) {
83 // TODO(beng): SetInitParams().
84 content_window_ = content_window;
85
86 ConfigureWindowStyles(message_handler_.get(), params,
87 GetWidget()->widget_delegate(),
88 native_widget_delegate_);
89
90 message_handler_->Init(NULL, params.bounds);
91
92 message_handler_->set_remove_standard_frame(!ShouldUseNativeFrame());
93
94 aura::RootWindow::CreateParams rw_params(params.bounds);
95 rw_params.host = this;
96 root_window_ = new aura::RootWindow(rw_params);
97
98 // TODO(beng): We probably need to move these two calls to some function that
99 // can change depending on the native-ness of the frame. For right
100 // now in the hack-n-slash days of win-aura, we can just
101 // unilaterally turn this on.
102 root_window_->compositor()->SetHostHasTransparentBackground(true);
103 root_window_->SetTransparent(true);
104
105 root_window_->Init();
106 root_window_->AddChild(content_window_);
107
108 native_widget_delegate_->OnNativeWidgetCreated();
109
110 capture_client_.reset(new aura::client::DefaultCaptureClient(root_window_));
111 aura::client::SetCaptureClient(root_window_, capture_client_.get());
112
113 focus_manager_.reset(new aura::FocusManager);
114 root_window_->set_focus_manager(focus_manager_.get());
115
116 activation_client_.reset(
117 new DesktopActivationClient(root_window_->GetFocusManager()));
118 aura::client::SetActivationClient(root_window_,
119 activation_client_.get());
120
121 dispatcher_client_.reset(new DesktopDispatcherClient);
122 aura::client::SetDispatcherClient(root_window_,
123 dispatcher_client_.get());
124
125 cursor_client_.reset(new DesktopCursorClient(root_window_));
126 aura::client::SetCursorClient(root_window_, cursor_client_.get());
127
128
129 position_client_.reset(new DesktopScreenPositionClient());
130 aura::client::SetScreenPositionClient(root_window_,
131 position_client_.get());
132
133 // CEF sets focus to the window the user clicks down on.
134 // TODO(beng): see if we can't do this some other way. CEF seems a heavy-
135 // handed way of accomplishing focus.
136 root_window_event_filter_ = new views::corewm::CompoundEventFilter;
137 root_window_->SetEventFilter(root_window_event_filter_);
138
139 input_method_filter_.reset(new views::corewm::InputMethodEventFilter);
140 input_method_filter_->SetInputMethodPropertyInRootWindow(root_window_);
141 root_window_event_filter_->AddFilter(input_method_filter_.get());
142
143 focus_manager_->SetFocusedWindow(content_window_, NULL);
144 root_window_->SetProperty(kContentWindowForRootWindow, content_window_);
145 return root_window_;
146 }
147
148 void DesktopRootWindowHostWin::Close() {
149 message_handler_->Close();
150 }
151
152 void DesktopRootWindowHostWin::CloseNow() {
153 message_handler_->CloseNow();
154 }
155
156 aura::RootWindowHost* DesktopRootWindowHostWin::AsRootWindowHost() {
157 return this;
158 }
159
160 void DesktopRootWindowHostWin::ShowWindowWithState(
161 ui::WindowShowState show_state) {
162 message_handler_->ShowWindowWithState(show_state);
163 }
164
165 void DesktopRootWindowHostWin::ShowMaximizedWithBounds(
166 const gfx::Rect& restored_bounds) {
167 message_handler_->ShowMaximizedWithBounds(restored_bounds);
168 }
169
170 bool DesktopRootWindowHostWin::IsVisible() const {
171 return message_handler_->IsVisible();
172 }
173
174 void DesktopRootWindowHostWin::SetSize(const gfx::Size& size) {
175 message_handler_->SetSize(size);
176 }
177
178 void DesktopRootWindowHostWin::CenterWindow(const gfx::Size& size) {
179 message_handler_->CenterWindow(size);
180 }
181
182 void DesktopRootWindowHostWin::GetWindowPlacement(
183 gfx::Rect* bounds,
184 ui::WindowShowState* show_state) const {
185 message_handler_->GetWindowPlacement(bounds, show_state);
186 }
187
188 gfx::Rect DesktopRootWindowHostWin::GetWindowBoundsInScreen() const {
189 return message_handler_->GetWindowBoundsInScreen();
190 }
191
192 gfx::Rect DesktopRootWindowHostWin::GetClientAreaBoundsInScreen() const {
193 return message_handler_->GetClientAreaBoundsInScreen();
194 }
195
196 gfx::Rect DesktopRootWindowHostWin::GetRestoredBounds() const {
197 return message_handler_->GetRestoredBounds();
198 }
199
200 gfx::Rect DesktopRootWindowHostWin::GetWorkAreaBoundsInScreen() const {
201 MONITORINFO monitor_info;
202 monitor_info.cbSize = sizeof(monitor_info);
203 GetMonitorInfo(MonitorFromWindow(message_handler_->hwnd(),
204 MONITOR_DEFAULTTONEAREST),
205 &monitor_info);
206 return gfx::Rect(monitor_info.rcWork);
207 }
208
209 void DesktopRootWindowHostWin::SetShape(gfx::NativeRegion native_region) {
210 SkPath path;
211 native_region->getBoundaryPath(&path);
212 message_handler_->SetRegion(gfx::CreateHRGNFromSkPath(path));
213 }
214
215 void DesktopRootWindowHostWin::Activate() {
216 message_handler_->Activate();
217 }
218
219 void DesktopRootWindowHostWin::Deactivate() {
220 message_handler_->Deactivate();
221 }
222
223 bool DesktopRootWindowHostWin::IsActive() const {
224 return message_handler_->IsActive();
225 }
226
227 void DesktopRootWindowHostWin::Maximize() {
228 message_handler_->Maximize();
229 }
230
231 void DesktopRootWindowHostWin::Minimize() {
232 message_handler_->Minimize();
233 }
234
235 void DesktopRootWindowHostWin::Restore() {
236 message_handler_->Restore();
237 }
238
239 bool DesktopRootWindowHostWin::IsMaximized() const {
240 return message_handler_->IsMaximized();
241 }
242
243 bool DesktopRootWindowHostWin::IsMinimized() const {
244 return message_handler_->IsMinimized();
245 }
246
247 bool DesktopRootWindowHostWin::HasCapture() const {
248 return message_handler_->HasCapture();
249 }
250
251 void DesktopRootWindowHostWin::SetAlwaysOnTop(bool always_on_top) {
252 message_handler_->SetAlwaysOnTop(always_on_top);
253 }
254
255 InputMethod* DesktopRootWindowHostWin::CreateInputMethod() {
256 // TODO(ime): This is wrong. We need to hook up the native win32 IME on the
257 // InputMethodEventFilter, and instead create an InputMethodBridge
258 // per-NativeWidget implementation. Once we achieve that we can get rid of
259 // this function on this object and DesktopRootWindowHostLinux and just
260 // create the InputMethodBridge directly in DesktopNativeWidgetAura. Also
261 // at that time DNWA can become the InputMethodDelegate.
262 ui::InputMethod* host =
263 root_window_->GetProperty(aura::client::kRootWindowInputMethodKey);
264 return new InputMethodWin(message_handler_.get(),
265 message_handler_->hwnd(),
266 host);
267 }
268
269 internal::InputMethodDelegate*
270 DesktopRootWindowHostWin::GetInputMethodDelegate() {
271 return message_handler_.get();
272 }
273
274 void DesktopRootWindowHostWin::SetWindowTitle(const string16& title) {
275 message_handler_->SetTitle(title);
276 }
277
278 void DesktopRootWindowHostWin::ClearNativeFocus() {
279 message_handler_->ClearNativeFocus();
280 }
281
282 Widget::MoveLoopResult DesktopRootWindowHostWin::RunMoveLoop(
283 const gfx::Vector2d& drag_offset) {
284 return message_handler_->RunMoveLoop(drag_offset) ?
285 Widget::MOVE_LOOP_SUCCESSFUL : Widget::MOVE_LOOP_CANCELED;
286 }
287
288 void DesktopRootWindowHostWin::EndMoveLoop() {
289 message_handler_->EndMoveLoop();
290 }
291
292 void DesktopRootWindowHostWin::SetVisibilityChangedAnimationsEnabled(
293 bool value) {
294 message_handler_->SetVisibilityChangedAnimationsEnabled(value);
295 }
296
297 bool DesktopRootWindowHostWin::ShouldUseNativeFrame() {
298 return ui::win::IsAeroGlassEnabled();
299 }
300
301 void DesktopRootWindowHostWin::FrameTypeChanged() {
302 message_handler_->FrameTypeChanged();
303 }
304
305 NonClientFrameView* DesktopRootWindowHostWin::CreateNonClientFrameView() {
306 return GetWidget()->ShouldUseNativeFrame() ?
307 new NativeFrameView(GetWidget()) : NULL;
308 }
309
310 void DesktopRootWindowHostWin::SetFullscreen(bool fullscreen) {
311 message_handler_->fullscreen_handler()->SetFullscreen(fullscreen);
312 }
313
314 bool DesktopRootWindowHostWin::IsFullscreen() const {
315 return message_handler_->fullscreen_handler()->fullscreen();
316 }
317
318 void DesktopRootWindowHostWin::SetOpacity(unsigned char opacity) {
319 message_handler_->SetOpacity(static_cast<BYTE>(opacity));
320 GetWidget()->GetRootView()->SchedulePaint();
321 }
322
323 void DesktopRootWindowHostWin::SetWindowIcons(
324 const gfx::ImageSkia& window_icon, const gfx::ImageSkia& app_icon) {
325 message_handler_->SetWindowIcons(window_icon, app_icon);
326 }
327
328 void DesktopRootWindowHostWin::SetAccessibleName(const string16& name) {
329 message_handler_->SetAccessibleName(name);
330 }
331
332 void DesktopRootWindowHostWin::SetAccessibleRole(
333 ui::AccessibilityTypes::Role role) {
334 message_handler_->SetAccessibleRole(role);
335 }
336
337 void DesktopRootWindowHostWin::SetAccessibleState(
338 ui::AccessibilityTypes::State state) {
339 message_handler_->SetAccessibleState(state);
340 }
341
342 void DesktopRootWindowHostWin::InitModalType(ui::ModalType modal_type) {
343 message_handler_->InitModalType(modal_type);
344 }
345
346 void DesktopRootWindowHostWin::FlashFrame(bool flash_frame) {
347 message_handler_->FlashFrame(flash_frame);
348 }
349
350 void DesktopRootWindowHostWin::OnNativeWidgetFocus() {
351 // HWNDMessageHandler will perform the proper updating on its own.
352 }
353
354 void DesktopRootWindowHostWin::OnNativeWidgetBlur() {
355 }
356
357 ////////////////////////////////////////////////////////////////////////////////
358 // DesktopRootWindowHostWin, RootWindowHost implementation:
359
360
361 void DesktopRootWindowHostWin::SetDelegate(
362 aura::RootWindowHostDelegate* delegate) {
363 root_window_host_delegate_ = delegate;
364 }
365
366 aura::RootWindow* DesktopRootWindowHostWin::GetRootWindow() {
367 return root_window_;
368 }
369
370 gfx::AcceleratedWidget DesktopRootWindowHostWin::GetAcceleratedWidget() {
371 return message_handler_->hwnd();
372 }
373
374 void DesktopRootWindowHostWin::Show() {
375 message_handler_->Show();
376 }
377
378 void DesktopRootWindowHostWin::Hide() {
379 message_handler_->Hide();
380 }
381
382 void DesktopRootWindowHostWin::ToggleFullScreen() {
383 }
384
385 gfx::Rect DesktopRootWindowHostWin::GetBounds() const {
386 return GetClientAreaBoundsInScreen();
387 }
388
389 void DesktopRootWindowHostWin::SetBounds(const gfx::Rect& bounds) {
390 message_handler_->SetBounds(bounds);
391 }
392
393 gfx::Point DesktopRootWindowHostWin::GetLocationOnNativeScreen() const {
394 return gfx::Point(1, 1);
395 }
396
397 void DesktopRootWindowHostWin::SetCapture() {
398 message_handler_->SetCapture();
399 }
400
401 void DesktopRootWindowHostWin::ReleaseCapture() {
402 message_handler_->ReleaseCapture();
403 }
404
405 void DesktopRootWindowHostWin::SetCursor(gfx::NativeCursor cursor) {
406 // Custom web cursors are handled directly.
407 if (cursor == ui::kCursorCustom)
408 return;
409 ui::CursorLoaderWin cursor_loader;
410 cursor_loader.SetPlatformCursor(&cursor);
411
412 message_handler_->SetCursor(cursor.platform());
413 }
414
415 bool DesktopRootWindowHostWin::QueryMouseLocation(gfx::Point* location_return) {
416 return false;
417 }
418
419 bool DesktopRootWindowHostWin::ConfineCursorToRootWindow() {
420 return false;
421 }
422
423 void DesktopRootWindowHostWin::UnConfineCursor() {
424 }
425
426 void DesktopRootWindowHostWin::MoveCursorTo(const gfx::Point& location) {
427 }
428
429 void DesktopRootWindowHostWin::SetFocusWhenShown(bool focus_when_shown) {
430 }
431
432 bool DesktopRootWindowHostWin::CopyAreaToSkCanvas(
433 const gfx::Rect& source_bounds,
434 const gfx::Point& dest_offset,
435 SkCanvas* canvas) {
436 NOTIMPLEMENTED();
437 return false;
438 }
439
440 bool DesktopRootWindowHostWin::GrabSnapshot(
441 const gfx::Rect& snapshot_bounds,
442 std::vector<unsigned char>* png_representation) {
443 NOTIMPLEMENTED();
444 return false;
445 }
446
447 void DesktopRootWindowHostWin::PostNativeEvent(
448 const base::NativeEvent& native_event) {
449 }
450
451 void DesktopRootWindowHostWin::OnDeviceScaleFactorChanged(
452 float device_scale_factor) {
453 }
454
455 void DesktopRootWindowHostWin::PrepareForShutdown() {
456 }
457
458 ////////////////////////////////////////////////////////////////////////////////
459 // DesktopRootWindowHostWin, HWNDMessageHandlerDelegate implementation:
460
461 bool DesktopRootWindowHostWin::IsWidgetWindow() const {
462 return true;
463 }
464
465 bool DesktopRootWindowHostWin::IsUsingCustomFrame() const {
466 return !GetWidget()->ShouldUseNativeFrame();
467 }
468
469 void DesktopRootWindowHostWin::SchedulePaint() {
470 GetWidget()->GetRootView()->SchedulePaint();
471 }
472
473 void DesktopRootWindowHostWin::EnableInactiveRendering() {
474 native_widget_delegate_->EnableInactiveRendering();
475 }
476
477 bool DesktopRootWindowHostWin::IsInactiveRenderingDisabled() {
478 return native_widget_delegate_->IsInactiveRenderingDisabled();
479 }
480
481 bool DesktopRootWindowHostWin::CanResize() const {
482 return GetWidget()->widget_delegate()->CanResize();
483 }
484
485 bool DesktopRootWindowHostWin::CanMaximize() const {
486 return GetWidget()->widget_delegate()->CanMaximize();
487 }
488
489 bool DesktopRootWindowHostWin::CanActivate() const {
490 return native_widget_delegate_->CanActivate();
491 }
492
493 bool DesktopRootWindowHostWin::WidgetSizeIsClientSize() const {
494 const Widget* widget = GetWidget()->GetTopLevelWidget();
495 return IsMaximized() || (widget && widget->ShouldUseNativeFrame());
496 }
497
498 bool DesktopRootWindowHostWin::CanSaveFocus() const {
499 return GetWidget()->is_top_level();
500 }
501
502 void DesktopRootWindowHostWin::SaveFocusOnDeactivate() {
503 GetWidget()->GetFocusManager()->StoreFocusedView();
504 }
505
506 void DesktopRootWindowHostWin::RestoreFocusOnActivate() {
507 RestoreFocusOnEnable();
508 }
509
510 void DesktopRootWindowHostWin::RestoreFocusOnEnable() {
511 GetWidget()->GetFocusManager()->RestoreFocusedView();
512 }
513
514 bool DesktopRootWindowHostWin::IsModal() const {
515 return native_widget_delegate_->IsModal();
516 }
517
518 int DesktopRootWindowHostWin::GetInitialShowState() const {
519 return SW_SHOWNORMAL;
520 }
521
522 bool DesktopRootWindowHostWin::WillProcessWorkAreaChange() const {
523 return GetWidget()->widget_delegate()->WillProcessWorkAreaChange();
524 }
525
526 int DesktopRootWindowHostWin::GetNonClientComponent(
527 const gfx::Point& point) const {
528 return native_widget_delegate_->GetNonClientComponent(point);
529 }
530
531 void DesktopRootWindowHostWin::GetWindowMask(const gfx::Size& size,
532 gfx::Path* path) {
533 if (GetWidget()->non_client_view())
534 GetWidget()->non_client_view()->GetWindowMask(size, path);
535 }
536
537 bool DesktopRootWindowHostWin::GetClientAreaInsets(gfx::Insets* insets) const {
538 return false;
539 }
540
541 void DesktopRootWindowHostWin::GetMinMaxSize(gfx::Size* min_size,
542 gfx::Size* max_size) const {
543 *min_size = native_widget_delegate_->GetMinimumSize();
544 *max_size = native_widget_delegate_->GetMaximumSize();
545 }
546
547 gfx::Size DesktopRootWindowHostWin::GetRootViewSize() const {
548 return GetWidget()->GetRootView()->size();
549 }
550
551 void DesktopRootWindowHostWin::ResetWindowControls() {
552 GetWidget()->non_client_view()->ResetWindowControls();
553 }
554
555 void DesktopRootWindowHostWin::PaintLayeredWindow(gfx::Canvas* canvas) {
556 GetWidget()->GetRootView()->Paint(canvas);
557 }
558
559 gfx::NativeViewAccessible DesktopRootWindowHostWin::GetNativeViewAccessible() {
560 return GetWidget()->GetRootView()->GetNativeViewAccessible();
561 }
562
563 InputMethod* DesktopRootWindowHostWin::GetInputMethod() {
564 return GetWidget()->GetInputMethodDirect();
565 }
566
567 void DesktopRootWindowHostWin::HandleAppDeactivated() {
568 native_widget_delegate_->EnableInactiveRendering();
569 }
570
571 void DesktopRootWindowHostWin::HandleActivationChanged(bool active) {
572 native_widget_delegate_->OnNativeWidgetActivationChanged(active);
573 }
574
575 bool DesktopRootWindowHostWin::HandleAppCommand(short command) {
576 // We treat APPCOMMAND ids as an extension of our command namespace, and just
577 // let the delegate figure out what to do...
578 return GetWidget()->widget_delegate() &&
579 GetWidget()->widget_delegate()->ExecuteWindowsCommand(command);
580 }
581
582 void DesktopRootWindowHostWin::HandleCaptureLost() {
583 native_widget_delegate_->OnMouseCaptureLost();
584 }
585
586 void DesktopRootWindowHostWin::HandleClose() {
587 GetWidget()->Close();
588 }
589
590 bool DesktopRootWindowHostWin::HandleCommand(int command) {
591 return GetWidget()->widget_delegate()->ExecuteWindowsCommand(command);
592 }
593
594 void DesktopRootWindowHostWin::HandleAccelerator(
595 const ui::Accelerator& accelerator) {
596 GetWidget()->GetFocusManager()->ProcessAccelerator(accelerator);
597 }
598
599 void DesktopRootWindowHostWin::HandleCreate() {
600 // TODO(beng): moar
601 NOTIMPLEMENTED();
602
603 native_widget_delegate_->OnNativeWidgetCreated();
604
605 // 1. Window property association
606 // 2. MouseWheel.
607 // 3. Drop target.
608 // 4. Tooltip Manager.
609 }
610
611 void DesktopRootWindowHostWin::HandleDestroying() {
612 native_widget_delegate_->OnNativeWidgetDestroying();
613 }
614
615 void DesktopRootWindowHostWin::HandleDestroyed() {
616 root_window_event_filter_->RemoveFilter(input_method_filter_.get());
617 desktop_native_widget_aura_->OnHostClosed();
618 }
619
620 bool DesktopRootWindowHostWin::HandleInitialFocus() {
621 return GetWidget()->SetInitialFocus();
622 }
623
624 void DesktopRootWindowHostWin::HandleDisplayChange() {
625 GetWidget()->widget_delegate()->OnDisplayChanged();
626 }
627
628 void DesktopRootWindowHostWin::HandleBeginWMSizeMove() {
629 native_widget_delegate_->OnNativeWidgetBeginUserBoundsChange();
630 }
631
632 void DesktopRootWindowHostWin::HandleEndWMSizeMove() {
633 native_widget_delegate_->OnNativeWidgetEndUserBoundsChange();
634 }
635
636 void DesktopRootWindowHostWin::HandleMove() {
637 native_widget_delegate_->OnNativeWidgetMove();
638 }
639
640 void DesktopRootWindowHostWin::HandleWorkAreaChanged() {
641 GetWidget()->widget_delegate()->OnWorkAreaChanged();
642 }
643
644 void DesktopRootWindowHostWin::HandleVisibilityChanged(bool visible) {
645 native_widget_delegate_->OnNativeWidgetVisibilityChanged(visible);
646 }
647
648 void DesktopRootWindowHostWin::HandleClientSizeChanged(
649 const gfx::Size& new_size) {
650 if (root_window_host_delegate_)
651 root_window_host_delegate_->OnHostResized(new_size);
652 // TODO(beng): replace with a layout manager??
653 content_window_->SetBounds(gfx::Rect(new_size));
654 }
655
656 void DesktopRootWindowHostWin::HandleFrameChanged() {
657 // Replace the frame and layout the contents.
658 GetWidget()->non_client_view()->UpdateFrame(true);
659 }
660
661 void DesktopRootWindowHostWin::HandleNativeFocus(HWND last_focused_window) {
662 // TODO(beng): inform the native_widget_delegate_.
663 InputMethod* input_method = GetInputMethod();
664 if (input_method)
665 input_method->OnFocus();
666 }
667
668 void DesktopRootWindowHostWin::HandleNativeBlur(HWND focused_window) {
669 // TODO(beng): inform the native_widget_delegate_.
670 InputMethod* input_method = GetInputMethod();
671 if (input_method)
672 input_method->OnBlur();
673 }
674
675 bool DesktopRootWindowHostWin::HandleMouseEvent(const ui::MouseEvent& event) {
676 if (event.flags() & ui::EF_IS_NON_CLIENT)
677 return false;
678 return root_window_host_delegate_->OnHostMouseEvent(
679 const_cast<ui::MouseEvent*>(&event));
680 }
681
682 bool DesktopRootWindowHostWin::HandleKeyEvent(const ui::KeyEvent& event) {
683 return root_window_host_delegate_->OnHostKeyEvent(
684 const_cast<ui::KeyEvent*>(&event));
685 }
686
687 bool DesktopRootWindowHostWin::HandleUntranslatedKeyEvent(
688 const ui::KeyEvent& event) {
689 InputMethod* input_method = GetInputMethod();
690 if (input_method)
691 input_method->DispatchKeyEvent(event);
692 return !!input_method;
693 }
694
695 bool DesktopRootWindowHostWin::HandleIMEMessage(UINT message,
696 WPARAM w_param,
697 LPARAM l_param,
698 LRESULT* result) {
699 InputMethod* input_method = GetInputMethod();
700 if (!input_method || input_method->IsMock()) {
701 *result = 0;
702 return false;
703 }
704
705 InputMethodWin* ime_win = static_cast<InputMethodWin*>(input_method);
706 BOOL handled = FALSE;
707 *result = ime_win->OnImeMessages(message, w_param, l_param, &handled);
708 return !!handled;
709 }
710
711 void DesktopRootWindowHostWin::HandleInputLanguageChange(
712 DWORD character_set,
713 HKL input_language_id) {
714 InputMethod* input_method = GetInputMethod();
715 if (input_method && !input_method->IsMock()) {
716 static_cast<InputMethodWin*>(input_method)->OnInputLangChange(
717 character_set, input_language_id);
718 }
719 }
720
721 bool DesktopRootWindowHostWin::HandlePaintAccelerated(
722 const gfx::Rect& invalid_rect) {
723 return native_widget_delegate_->OnNativeWidgetPaintAccelerated(invalid_rect);
724 }
725
726 void DesktopRootWindowHostWin::HandlePaint(gfx::Canvas* canvas) {
727 root_window_host_delegate_->OnHostPaint();
728 }
729
730 void DesktopRootWindowHostWin::HandleScreenReaderDetected() {
731 }
732
733 bool DesktopRootWindowHostWin::HandleTooltipNotify(int w_param,
734 NMHDR* l_param,
735 LRESULT* l_result) {
736 return false;
737 }
738
739 void DesktopRootWindowHostWin::HandleTooltipMouseMove(UINT message,
740 WPARAM w_param,
741 LPARAM l_param) {
742 }
743
744 bool DesktopRootWindowHostWin::PreHandleMSG(UINT message,
745 WPARAM w_param,
746 LPARAM l_param,
747 LRESULT* result) {
748 return false;
749 }
750
751 void DesktopRootWindowHostWin::PostHandleMSG(UINT message,
752 WPARAM w_param,
753 LPARAM l_param) {
754 }
755
756 ////////////////////////////////////////////////////////////////////////////////
757 // DesktopRootWindowHostWin, private:
758
759 Widget* DesktopRootWindowHostWin::GetWidget() {
760 return native_widget_delegate_->AsWidget();
761 }
762
763 const Widget* DesktopRootWindowHostWin::GetWidget() const {
764 return native_widget_delegate_->AsWidget();
765 }
766
767 HWND DesktopRootWindowHostWin::GetHWND() const {
768 return message_handler_->hwnd();
769 }
770
771 ////////////////////////////////////////////////////////////////////////////////
772 // DesktopRootWindowHost, public:
773
774 // static
775 DesktopRootWindowHost* DesktopRootWindowHost::Create(
776 internal::NativeWidgetDelegate* native_widget_delegate,
777 DesktopNativeWidgetAura* desktop_native_widget_aura,
778 const gfx::Rect& initial_bounds) {
779 return new DesktopRootWindowHostWin(native_widget_delegate,
780 desktop_native_widget_aura,
781 initial_bounds);
782 }
783
784 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/desktop_root_window_host_win.h ('k') | ui/views/widget/desktop_screen_position_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698