blob: 37dca58f774e206341931ef235b712d2b12ea111 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ui/views/win/hwnd_util.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/views/widget/widget.h"
namespace views {
HWND HWNDForView(const View* view) {
return view->GetWidget() ? HWNDForWidget(view->GetWidget()) : NULL;
}
HWND HWNDForWidget(const Widget* widget) {
return HWNDForNativeWindow(widget->GetNativeWindow());
}
HWND HWNDForNativeView(const gfx::NativeView view) {
return view && view->GetRootWindow() ?
view->GetHost()->GetAcceleratedWidget() : NULL;
}
HWND HWNDForNativeWindow(const gfx::NativeWindow window) {
return window && window->GetRootWindow() ?
window->GetHost()->GetAcceleratedWidget() : NULL;
}
gfx::Rect GetWindowBoundsForClientBounds(View* view,
const gfx::Rect& client_bounds) {
DCHECK(view);
aura::WindowTreeHost* host = view->GetWidget()->GetNativeWindow()->GetHost();
if (host) {
HWND hwnd = host->GetAcceleratedWidget();
RECT rect = client_bounds.ToRECT();
DWORD style = ::GetWindowLong(hwnd, GWL_STYLE);
DWORD ex_style = ::GetWindowLong(hwnd, GWL_EXSTYLE);
AdjustWindowRectEx(&rect, style, FALSE, ex_style);
return gfx::Rect(rect);
}
return client_bounds;
}
} // namespace views
|