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/focus_manager.h" | 10 #include "ui/aura/focus_manager.h" |
11 #include "ui/aura/root_window.h" | 11 #include "ui/aura/root_window.h" |
12 #include "ui/aura/window_property.h" | 12 #include "ui/aura/window_property.h" |
13 #include "ui/base/cursor/cursor_loader_win.h" | 13 #include "ui/base/cursor/cursor_loader_win.h" |
14 #include "ui/base/ime/input_method_win.h" | 14 #include "ui/base/ime/input_method_win.h" |
| 15 #include "ui/base/win/dpi.h" |
15 #include "ui/base/win/shell.h" | 16 #include "ui/base/win/shell.h" |
16 #include "ui/gfx/insets.h" | 17 #include "ui/gfx/insets.h" |
17 #include "ui/gfx/native_widget_types.h" | 18 #include "ui/gfx/native_widget_types.h" |
18 #include "ui/gfx/path_win.h" | 19 #include "ui/gfx/path_win.h" |
19 #include "ui/native_theme/native_theme_aura.h" | 20 #include "ui/native_theme/native_theme_aura.h" |
20 #include "ui/native_theme/native_theme_win.h" | 21 #include "ui/native_theme/native_theme_win.h" |
21 #include "ui/views/corewm/compound_event_filter.h" | 22 #include "ui/views/corewm/compound_event_filter.h" |
22 #include "ui/views/corewm/corewm_switches.h" | 23 #include "ui/views/corewm/corewm_switches.h" |
23 #include "ui/views/corewm/cursor_manager.h" | 24 #include "ui/views/corewm/cursor_manager.h" |
24 #include "ui/views/corewm/focus_controller.h" | 25 #include "ui/views/corewm/focus_controller.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 GetWidget()->widget_delegate(), | 100 GetWidget()->widget_delegate(), |
100 native_widget_delegate_); | 101 native_widget_delegate_); |
101 | 102 |
102 HWND parent_hwnd = NULL; | 103 HWND parent_hwnd = NULL; |
103 aura::Window* parent_window = params.parent; | 104 aura::Window* parent_window = params.parent; |
104 if (parent_window) | 105 if (parent_window) |
105 parent_hwnd = parent_window->GetRootWindow()->GetAcceleratedWidget(); | 106 parent_hwnd = parent_window->GetRootWindow()->GetAcceleratedWidget(); |
106 | 107 |
107 message_handler_->set_remove_standard_frame(params.remove_standard_frame); | 108 message_handler_->set_remove_standard_frame(params.remove_standard_frame); |
108 | 109 |
109 message_handler_->Init(parent_hwnd, params.bounds); | 110 gfx::Rect pixel_bounds = ui::win::DIPToScreenRect(params.bounds); |
| 111 message_handler_->Init(parent_hwnd, pixel_bounds); |
110 | 112 |
111 aura::RootWindow::CreateParams rw_params(params.bounds); | 113 aura::RootWindow::CreateParams rw_params(params.bounds); |
112 rw_params.host = this; | 114 rw_params.host = this; |
113 root_window_ = new aura::RootWindow(rw_params); | 115 root_window_ = new aura::RootWindow(rw_params); |
114 | 116 |
115 // TODO(beng): We probably need to move these two calls to some function that | 117 // TODO(beng): We probably need to move these two calls to some function that |
116 // can change depending on the native-ness of the frame. For right | 118 // can change depending on the native-ness of the frame. For right |
117 // now in the hack-n-slash days of win-aura, we can just | 119 // now in the hack-n-slash days of win-aura, we can just |
118 // unilaterally turn this on. | 120 // unilaterally turn this on. |
119 root_window_->compositor()->SetHostHasTransparentBackground(true); | 121 root_window_->compositor()->SetHostHasTransparentBackground(true); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 return this; | 181 return this; |
180 } | 182 } |
181 | 183 |
182 void DesktopRootWindowHostWin::ShowWindowWithState( | 184 void DesktopRootWindowHostWin::ShowWindowWithState( |
183 ui::WindowShowState show_state) { | 185 ui::WindowShowState show_state) { |
184 message_handler_->ShowWindowWithState(show_state); | 186 message_handler_->ShowWindowWithState(show_state); |
185 } | 187 } |
186 | 188 |
187 void DesktopRootWindowHostWin::ShowMaximizedWithBounds( | 189 void DesktopRootWindowHostWin::ShowMaximizedWithBounds( |
188 const gfx::Rect& restored_bounds) { | 190 const gfx::Rect& restored_bounds) { |
189 message_handler_->ShowMaximizedWithBounds(restored_bounds); | 191 gfx::Rect pixel_bounds = ui::win::DIPToScreenRect(restored_bounds); |
| 192 message_handler_->ShowMaximizedWithBounds(pixel_bounds); |
190 } | 193 } |
191 | 194 |
192 bool DesktopRootWindowHostWin::IsVisible() const { | 195 bool DesktopRootWindowHostWin::IsVisible() const { |
193 return message_handler_->IsVisible(); | 196 return message_handler_->IsVisible(); |
194 } | 197 } |
195 | 198 |
196 void DesktopRootWindowHostWin::SetSize(const gfx::Size& size) { | 199 void DesktopRootWindowHostWin::SetSize(const gfx::Size& size) { |
197 message_handler_->SetSize(size); | 200 gfx::Size size_in_pixels = ui::win::DIPToScreenSize(size); |
| 201 message_handler_->SetSize(size_in_pixels); |
198 } | 202 } |
199 | 203 |
200 void DesktopRootWindowHostWin::CenterWindow(const gfx::Size& size) { | 204 void DesktopRootWindowHostWin::CenterWindow(const gfx::Size& size) { |
201 message_handler_->CenterWindow(size); | 205 gfx::Size size_in_pixels = ui::win::DIPToScreenSize(size); |
| 206 message_handler_->CenterWindow(size_in_pixels); |
202 } | 207 } |
203 | 208 |
204 void DesktopRootWindowHostWin::GetWindowPlacement( | 209 void DesktopRootWindowHostWin::GetWindowPlacement( |
205 gfx::Rect* bounds, | 210 gfx::Rect* bounds, |
206 ui::WindowShowState* show_state) const { | 211 ui::WindowShowState* show_state) const { |
207 message_handler_->GetWindowPlacement(bounds, show_state); | 212 message_handler_->GetWindowPlacement(bounds, show_state); |
| 213 *bounds = ui::win::ScreenToDIPRect(*bounds); |
208 } | 214 } |
209 | 215 |
210 gfx::Rect DesktopRootWindowHostWin::GetWindowBoundsInScreen() const { | 216 gfx::Rect DesktopRootWindowHostWin::GetWindowBoundsInScreen() const { |
211 return message_handler_->GetWindowBoundsInScreen(); | 217 gfx::Rect pixel_bounds = message_handler_->GetWindowBoundsInScreen(); |
| 218 return ui::win::ScreenToDIPRect(pixel_bounds); |
212 } | 219 } |
213 | 220 |
214 gfx::Rect DesktopRootWindowHostWin::GetClientAreaBoundsInScreen() const { | 221 gfx::Rect DesktopRootWindowHostWin::GetClientAreaBoundsInScreen() const { |
215 return message_handler_->GetClientAreaBoundsInScreen(); | 222 gfx::Rect pixel_bounds = message_handler_->GetClientAreaBoundsInScreen(); |
| 223 return ui::win::ScreenToDIPRect(pixel_bounds); |
216 } | 224 } |
217 | 225 |
218 gfx::Rect DesktopRootWindowHostWin::GetRestoredBounds() const { | 226 gfx::Rect DesktopRootWindowHostWin::GetRestoredBounds() const { |
219 return message_handler_->GetRestoredBounds(); | 227 gfx::Rect pixel_bounds = message_handler_->GetRestoredBounds(); |
| 228 return ui::win::ScreenToDIPRect(pixel_bounds); |
220 } | 229 } |
221 | 230 |
222 gfx::Rect DesktopRootWindowHostWin::GetWorkAreaBoundsInScreen() const { | 231 gfx::Rect DesktopRootWindowHostWin::GetWorkAreaBoundsInScreen() const { |
223 MONITORINFO monitor_info; | 232 MONITORINFO monitor_info; |
224 monitor_info.cbSize = sizeof(monitor_info); | 233 monitor_info.cbSize = sizeof(monitor_info); |
225 GetMonitorInfo(MonitorFromWindow(message_handler_->hwnd(), | 234 GetMonitorInfo(MonitorFromWindow(message_handler_->hwnd(), |
226 MONITOR_DEFAULTTONEAREST), | 235 MONITOR_DEFAULTTONEAREST), |
227 &monitor_info); | 236 &monitor_info); |
228 return gfx::Rect(monitor_info.rcWork); | 237 gfx::Rect pixel_bounds = gfx::Rect(monitor_info.rcWork); |
| 238 return ui::win::ScreenToDIPRect(pixel_bounds); |
229 } | 239 } |
230 | 240 |
231 void DesktopRootWindowHostWin::SetShape(gfx::NativeRegion native_region) { | 241 void DesktopRootWindowHostWin::SetShape(gfx::NativeRegion native_region) { |
232 SkPath path; | 242 SkPath path; |
233 native_region->getBoundaryPath(&path); | 243 native_region->getBoundaryPath(&path); |
234 message_handler_->SetRegion(gfx::CreateHRGNFromSkPath(path)); | 244 message_handler_->SetRegion(gfx::CreateHRGNFromSkPath(path)); |
235 } | 245 } |
236 | 246 |
237 void DesktopRootWindowHostWin::Activate() { | 247 void DesktopRootWindowHostWin::Activate() { |
238 message_handler_->Activate(); | 248 message_handler_->Activate(); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 message_handler_->Show(); | 375 message_handler_->Show(); |
366 } | 376 } |
367 | 377 |
368 void DesktopRootWindowHostWin::Hide() { | 378 void DesktopRootWindowHostWin::Hide() { |
369 message_handler_->Hide(); | 379 message_handler_->Hide(); |
370 } | 380 } |
371 | 381 |
372 void DesktopRootWindowHostWin::ToggleFullScreen() { | 382 void DesktopRootWindowHostWin::ToggleFullScreen() { |
373 } | 383 } |
374 | 384 |
| 385 // GetBounds and SetBounds work in pixel coordinates, whereas other get/set |
| 386 // methods work in DIP. |
| 387 |
375 gfx::Rect DesktopRootWindowHostWin::GetBounds() const { | 388 gfx::Rect DesktopRootWindowHostWin::GetBounds() const { |
376 // Match the logic in HWNDMessageHandler::ClientAreaSizeChanged(). | 389 // Match the logic in HWNDMessageHandler::ClientAreaSizeChanged(). |
377 return WidgetSizeIsClientSize() ? | 390 return WidgetSizeIsClientSize() ? |
378 GetClientAreaBoundsInScreen() : GetWindowBoundsInScreen(); | 391 message_handler_->GetClientAreaBoundsInScreen() : |
| 392 message_handler_->GetWindowBoundsInScreen(); |
379 } | 393 } |
380 | 394 |
381 void DesktopRootWindowHostWin::SetBounds(const gfx::Rect& bounds) { | 395 void DesktopRootWindowHostWin::SetBounds(const gfx::Rect& bounds) { |
382 message_handler_->SetBounds(bounds); | 396 message_handler_->SetBounds(bounds); |
383 } | 397 } |
384 | 398 |
385 gfx::Insets DesktopRootWindowHostWin::GetInsets() const { | 399 gfx::Insets DesktopRootWindowHostWin::GetInsets() const { |
386 return gfx::Insets(); | 400 return gfx::Insets(); |
387 } | 401 } |
388 | 402 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 | 666 |
653 void DesktopRootWindowHostWin::HandleVisibilityChanged(bool visible) { | 667 void DesktopRootWindowHostWin::HandleVisibilityChanged(bool visible) { |
654 native_widget_delegate_->OnNativeWidgetVisibilityChanged(visible); | 668 native_widget_delegate_->OnNativeWidgetVisibilityChanged(visible); |
655 } | 669 } |
656 | 670 |
657 void DesktopRootWindowHostWin::HandleClientSizeChanged( | 671 void DesktopRootWindowHostWin::HandleClientSizeChanged( |
658 const gfx::Size& new_size) { | 672 const gfx::Size& new_size) { |
659 if (root_window_host_delegate_) | 673 if (root_window_host_delegate_) |
660 root_window_host_delegate_->OnHostResized(new_size); | 674 root_window_host_delegate_->OnHostResized(new_size); |
661 // TODO(beng): replace with a layout manager?? | 675 // TODO(beng): replace with a layout manager?? |
662 content_window_->SetBounds(gfx::Rect(new_size)); | 676 |
| 677 gfx::Size dip_size = ui::win::ScreenToDIPSize(gfx::Size(new_size)); |
| 678 content_window_->SetBounds(gfx::Rect(dip_size)); |
663 } | 679 } |
664 | 680 |
665 void DesktopRootWindowHostWin::HandleFrameChanged() { | 681 void DesktopRootWindowHostWin::HandleFrameChanged() { |
666 // Replace the frame and layout the contents. | 682 // Replace the frame and layout the contents. |
667 GetWidget()->non_client_view()->UpdateFrame(true); | 683 GetWidget()->non_client_view()->UpdateFrame(true); |
668 } | 684 } |
669 | 685 |
670 void DesktopRootWindowHostWin::HandleNativeFocus(HWND last_focused_window) { | 686 void DesktopRootWindowHostWin::HandleNativeFocus(HWND last_focused_window) { |
671 // TODO(beng): inform the native_widget_delegate_. | 687 // TODO(beng): inform the native_widget_delegate_. |
672 InputMethod* input_method = GetInputMethod(); | 688 InputMethod* input_method = GetInputMethod(); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 DesktopRootWindowHost* DesktopRootWindowHost::Create( | 800 DesktopRootWindowHost* DesktopRootWindowHost::Create( |
785 internal::NativeWidgetDelegate* native_widget_delegate, | 801 internal::NativeWidgetDelegate* native_widget_delegate, |
786 DesktopNativeWidgetAura* desktop_native_widget_aura, | 802 DesktopNativeWidgetAura* desktop_native_widget_aura, |
787 const gfx::Rect& initial_bounds) { | 803 const gfx::Rect& initial_bounds) { |
788 return new DesktopRootWindowHostWin(native_widget_delegate, | 804 return new DesktopRootWindowHostWin(native_widget_delegate, |
789 desktop_native_widget_aura, | 805 desktop_native_widget_aura, |
790 initial_bounds); | 806 initial_bounds); |
791 } | 807 } |
792 | 808 |
793 } // namespace views | 809 } // namespace views |
OLD | NEW |