| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/win/hwnd_util.h" | 5 #include "ui/views/win/hwnd_util.h" |
| 6 | 6 |
| 7 #include "ui/aura/root_window.h" | 7 #include "ui/aura/root_window.h" |
| 8 #include "ui/views/widget/widget.h" | 8 #include "ui/views/widget/widget.h" |
| 9 | 9 |
| 10 namespace views { | 10 namespace views { |
| 11 | 11 |
| 12 HWND HWNDForView(View* view) { | 12 HWND HWNDForView(View* view) { |
| 13 return view->GetWidget() ? HWNDForWidget(view->GetWidget()) : NULL; | 13 return view->GetWidget() ? HWNDForWidget(view->GetWidget()) : NULL; |
| 14 } | 14 } |
| 15 | 15 |
| 16 HWND HWNDForWidget(Widget* widget) { | 16 HWND HWNDForWidget(Widget* widget) { |
| 17 return HWNDForNativeWindow(widget->GetNativeWindow()); | 17 return HWNDForNativeWindow(widget->GetNativeWindow()); |
| 18 } | 18 } |
| 19 | 19 |
| 20 HWND HWNDForNativeView(gfx::NativeView view) { | 20 HWND HWNDForNativeView(gfx::NativeView view) { |
| 21 return view && view->GetRootWindow() ? | 21 return view && view->GetRootWindow() ? |
| 22 view->GetRootWindow()->GetAcceleratedWidget() : NULL; | 22 view->GetRootWindow()->GetAcceleratedWidget() : NULL; |
| 23 } | 23 } |
| 24 | 24 |
| 25 HWND HWNDForNativeWindow(gfx::NativeWindow window) { | 25 HWND HWNDForNativeWindow(gfx::NativeWindow window) { |
| 26 return window && window->GetRootWindow() ? | 26 return window && window->GetRootWindow() ? |
| 27 window->GetRootWindow()->GetAcceleratedWidget() : NULL; | 27 window->GetRootWindow()->GetAcceleratedWidget() : NULL; |
| 28 } | 28 } |
| 29 | 29 |
| 30 gfx::Rect GetWindowBoundsForClientBounds(View* view, |
| 31 const gfx::Rect& client_bounds) { |
| 32 DCHECK(view); |
| 33 aura::RootWindow* window = |
| 34 view->GetWidget()->GetNativeWindow()->GetRootWindow(); |
| 35 if (window) { |
| 36 HWND hwnd = window->GetAcceleratedWidget(); |
| 37 RECT rect = client_bounds.ToRECT(); |
| 38 DWORD style = ::GetWindowLong(hwnd, GWL_STYLE); |
| 39 DWORD ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE); |
| 40 AdjustWindowRectEx(&rect, style, FALSE, ex_style); |
| 41 return gfx::Rect(rect); |
| 42 } |
| 43 return client_bounds; |
| 30 } | 44 } |
| 45 |
| 46 } // namespace views |
| OLD | NEW |