OLD | NEW |
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_aura/desktop_root_window_host_win.h" | 5 #include "ui/views/widget/desktop_aura/desktop_root_window_host_win.h" |
6 | 6 |
7 #include "third_party/skia/include/core/SkPath.h" | 7 #include "third_party/skia/include/core/SkPath.h" |
8 #include "third_party/skia/include/core/SkRegion.h" | 8 #include "third_party/skia/include/core/SkRegion.h" |
9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/client/default_capture_client.h" | 10 #include "ui/aura/client/default_capture_client.h" |
11 #include "ui/aura/focus_manager.h" | 11 #include "ui/aura/focus_manager.h" |
12 #include "ui/aura/root_window.h" | 12 #include "ui/aura/root_window.h" |
13 #include "ui/aura/window_property.h" | 13 #include "ui/aura/window_property.h" |
14 #include "ui/base/cursor/cursor_loader_win.h" | 14 #include "ui/base/cursor/cursor_loader_win.h" |
15 #include "ui/base/ime/input_method_win.h" | 15 #include "ui/base/ime/input_method_win.h" |
16 #include "ui/base/win/shell.h" | 16 #include "ui/base/win/shell.h" |
17 #include "ui/gfx/native_widget_types.h" | 17 #include "ui/gfx/native_widget_types.h" |
18 #include "ui/gfx/path_win.h" | 18 #include "ui/gfx/path_win.h" |
19 #include "ui/native_theme/native_theme_aura.h" | 19 #include "ui/native_theme/native_theme_aura.h" |
20 #include "ui/native_theme/native_theme_win.h" | 20 #include "ui/native_theme/native_theme_win.h" |
21 #include "ui/views/corewm/compound_event_filter.h" | 21 #include "ui/views/corewm/compound_event_filter.h" |
| 22 #include "ui/views/corewm/corewm_switches.h" |
| 23 #include "ui/views/corewm/focus_controller.h" |
22 #include "ui/views/corewm/input_method_event_filter.h" | 24 #include "ui/views/corewm/input_method_event_filter.h" |
23 #include "ui/views/ime/input_method_bridge.h" | 25 #include "ui/views/ime/input_method_bridge.h" |
24 #include "ui/views/widget/desktop_aura/desktop_activation_client.h" | 26 #include "ui/views/widget/desktop_aura/desktop_activation_client.h" |
25 #include "ui/views/widget/desktop_aura/desktop_cursor_client.h" | 27 #include "ui/views/widget/desktop_aura/desktop_cursor_client.h" |
26 #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h" | 28 #include "ui/views/widget/desktop_aura/desktop_dispatcher_client.h" |
27 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h" | 29 #include "ui/views/widget/desktop_aura/desktop_drag_drop_client_win.h" |
| 30 #include "ui/views/widget/desktop_aura/desktop_focus_rules.h" |
28 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 31 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
29 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" | 32 #include "ui/views/widget/desktop_aura/desktop_screen_position_client.h" |
30 #include "ui/views/widget/root_view.h" | 33 #include "ui/views/widget/root_view.h" |
31 #include "ui/views/widget/widget_delegate.h" | 34 #include "ui/views/widget/widget_delegate.h" |
32 #include "ui/views/widget/widget_hwnd_utils.h" | 35 #include "ui/views/widget/widget_hwnd_utils.h" |
33 #include "ui/views/win/fullscreen_handler.h" | 36 #include "ui/views/win/fullscreen_handler.h" |
34 #include "ui/views/win/hwnd_message_handler.h" | 37 #include "ui/views/win/hwnd_message_handler.h" |
35 #include "ui/views/window/native_frame_view.h" | 38 #include "ui/views/window/native_frame_view.h" |
36 | 39 |
37 namespace views { | 40 namespace views { |
38 | 41 |
39 DEFINE_WINDOW_PROPERTY_KEY(aura::Window*, kContentWindowForRootWindow, NULL); | 42 DEFINE_WINDOW_PROPERTY_KEY(aura::Window*, kContentWindowForRootWindow, NULL); |
40 | 43 |
41 //////////////////////////////////////////////////////////////////////////////// | 44 //////////////////////////////////////////////////////////////////////////////// |
42 // DesktopRootWindowHostWin, public: | 45 // DesktopRootWindowHostWin, public: |
43 | 46 |
44 DesktopRootWindowHostWin::DesktopRootWindowHostWin( | 47 DesktopRootWindowHostWin::DesktopRootWindowHostWin( |
45 internal::NativeWidgetDelegate* native_widget_delegate, | 48 internal::NativeWidgetDelegate* native_widget_delegate, |
46 DesktopNativeWidgetAura* desktop_native_widget_aura, | 49 DesktopNativeWidgetAura* desktop_native_widget_aura, |
47 const gfx::Rect& initial_bounds) | 50 const gfx::Rect& initial_bounds) |
48 : ALLOW_THIS_IN_INITIALIZER_LIST( | 51 : ALLOW_THIS_IN_INITIALIZER_LIST( |
49 message_handler_(new HWNDMessageHandler(this))), | 52 message_handler_(new HWNDMessageHandler(this))), |
50 native_widget_delegate_(native_widget_delegate), | 53 native_widget_delegate_(native_widget_delegate), |
51 desktop_native_widget_aura_(desktop_native_widget_aura), | 54 desktop_native_widget_aura_(desktop_native_widget_aura), |
52 root_window_host_delegate_(NULL), | 55 root_window_host_delegate_(NULL), |
53 content_window_(NULL) { | 56 content_window_(NULL) { |
54 } | 57 } |
55 | 58 |
56 DesktopRootWindowHostWin::~DesktopRootWindowHostWin() { | 59 DesktopRootWindowHostWin::~DesktopRootWindowHostWin() { |
| 60 if (corewm::UseFocusControllerOnDesktop()) { |
| 61 aura::client::SetFocusClient(root_window_, NULL); |
| 62 aura::client::SetActivationClient(root_window_, NULL); |
| 63 } |
57 } | 64 } |
58 | 65 |
59 // static | 66 // static |
60 aura::Window* DesktopRootWindowHostWin::GetContentWindowForHWND(HWND hwnd) { | 67 aura::Window* DesktopRootWindowHostWin::GetContentWindowForHWND(HWND hwnd) { |
61 aura::RootWindow* root = aura::RootWindow::GetForAcceleratedWidget(hwnd); | 68 aura::RootWindow* root = aura::RootWindow::GetForAcceleratedWidget(hwnd); |
62 return root ? root->GetProperty(kContentWindowForRootWindow) : NULL; | 69 return root ? root->GetProperty(kContentWindowForRootWindow) : NULL; |
63 } | 70 } |
64 | 71 |
65 // static | 72 // static |
66 ui::NativeTheme* DesktopRootWindowHost::GetNativeTheme(aura::Window* window) { | 73 ui::NativeTheme* DesktopRootWindowHost::GetNativeTheme(aura::Window* window) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 root_window_->SetTransparent(true); | 118 root_window_->SetTransparent(true); |
112 | 119 |
113 root_window_->Init(); | 120 root_window_->Init(); |
114 root_window_->AddChild(content_window_); | 121 root_window_->AddChild(content_window_); |
115 | 122 |
116 native_widget_delegate_->OnNativeWidgetCreated(); | 123 native_widget_delegate_->OnNativeWidgetCreated(); |
117 | 124 |
118 capture_client_.reset(new aura::client::DefaultCaptureClient(root_window_)); | 125 capture_client_.reset(new aura::client::DefaultCaptureClient(root_window_)); |
119 aura::client::SetCaptureClient(root_window_, capture_client_.get()); | 126 aura::client::SetCaptureClient(root_window_, capture_client_.get()); |
120 | 127 |
121 focus_client_.reset(new aura::FocusManager); | 128 if (corewm::UseFocusControllerOnDesktop()) { |
122 aura::client::SetFocusClient(root_window_, focus_client_.get()); | 129 corewm::FocusController* focus_controller = |
123 | 130 new corewm::FocusController(new DesktopFocusRules); |
124 activation_client_.reset(new DesktopActivationClient(root_window_)); | 131 focus_client_.reset(focus_controller); |
| 132 aura::client::SetFocusClient(root_window_, focus_controller); |
| 133 aura::client::SetActivationClient(root_window_, focus_controller); |
| 134 root_window_->AddPreTargetHandler(focus_controller); |
| 135 } else { |
| 136 focus_client_.reset(new aura::FocusManager); |
| 137 aura::client::SetFocusClient(root_window_, focus_client_.get()); |
| 138 activation_client_.reset(new DesktopActivationClient(root_window_)); |
| 139 } |
125 | 140 |
126 dispatcher_client_.reset(new DesktopDispatcherClient); | 141 dispatcher_client_.reset(new DesktopDispatcherClient); |
127 aura::client::SetDispatcherClient(root_window_, | 142 aura::client::SetDispatcherClient(root_window_, |
128 dispatcher_client_.get()); | 143 dispatcher_client_.get()); |
129 | 144 |
130 cursor_client_.reset(new DesktopCursorClient(root_window_)); | 145 cursor_client_.reset(new DesktopCursorClient(root_window_)); |
131 aura::client::SetCursorClient(root_window_, cursor_client_.get()); | 146 aura::client::SetCursorClient(root_window_, cursor_client_.get()); |
132 | 147 |
133 position_client_.reset(new DesktopScreenPositionClient()); | 148 position_client_.reset(new DesktopScreenPositionClient()); |
134 aura::client::SetScreenPositionClient(root_window_, | 149 aura::client::SetScreenPositionClient(root_window_, |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 DesktopRootWindowHost* DesktopRootWindowHost::Create( | 780 DesktopRootWindowHost* DesktopRootWindowHost::Create( |
766 internal::NativeWidgetDelegate* native_widget_delegate, | 781 internal::NativeWidgetDelegate* native_widget_delegate, |
767 DesktopNativeWidgetAura* desktop_native_widget_aura, | 782 DesktopNativeWidgetAura* desktop_native_widget_aura, |
768 const gfx::Rect& initial_bounds) { | 783 const gfx::Rect& initial_bounds) { |
769 return new DesktopRootWindowHostWin(native_widget_delegate, | 784 return new DesktopRootWindowHostWin(native_widget_delegate, |
770 desktop_native_widget_aura, | 785 desktop_native_widget_aura, |
771 initial_bounds); | 786 initial_bounds); |
772 } | 787 } |
773 | 788 |
774 } // namespace views | 789 } // namespace views |
OLD | NEW |