diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-04 02:01:35 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-04 02:01:35 +0000 |
commit | 1cb860667c51472ff266e6b74042414d8bb0cbc0 (patch) | |
tree | 3158b5238c84e3bc8af706b767ba125c223f1bab /ui/base/win/window_impl.cc | |
parent | 4586bf050399b2607c803e781fa99606f1d9e731 (diff) | |
download | chromium_src-1cb860667c51472ff266e6b74042414d8bb0cbc0.zip chromium_src-1cb860667c51472ff266e6b74042414d8bb0cbc0.tar.gz chromium_src-1cb860667c51472ff266e6b74042414d8bb0cbc0.tar.bz2 |
Enforce the use of a root window
So for metro we need to have a specific root window, so we
need to enforce it. We know we are in metro because of the metro_driver
dll being loaded (it was loaded by chrome.exe)
I also removed your last change. I assume that you gathered enough data
by now.
BUG=118641
TES=chrome runs
Review URL: https://chromiumcodereview.appspot.com/9965094
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130540 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base/win/window_impl.cc')
-rw-r--r-- | ui/base/win/window_impl.cc | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/ui/base/win/window_impl.cc b/ui/base/win/window_impl.cc index 2094cf9..296ca85 100644 --- a/ui/base/win/window_impl.cc +++ b/ui/base/win/window_impl.cc @@ -11,6 +11,29 @@ #include "base/win/wrapped_window_proc.h" #include "ui/base/win/hwnd_util.h" +namespace { + +extern "C" { + typedef HWND (*GetRootWindow)(); +} + +HMODULE GetMetroDll() { + static HMODULE hm = ::GetModuleHandleA("metro_driver.dll"); + return hm; +} + +HWND RootWindow(bool is_child_window) { + HMODULE metro = GetMetroDll(); + if (!metro) { + return is_child_window ? ::GetDesktopWindow() : HWND_DESKTOP; + } + GetRootWindow get_root_window = + reinterpret_cast<GetRootWindow>(::GetProcAddress(metro, "GetRootWindow")); + return get_root_window(); +} + +} // namespace + namespace ui { static const DWORD kWindowDefaultChildStyle = @@ -132,15 +155,16 @@ void WindowImpl::Init(HWND parent, const gfx::Rect& bounds) { if (window_style_ == 0) window_style_ = parent ? kWindowDefaultChildStyle : kWindowDefaultStyle; - // Ensures the parent we have been passed is valid, otherwise CreateWindowEx - // will fail. - HWND original_parent = parent; - if (parent && !::IsWindow(parent)) { - NOTREACHED() << "invalid parent window specified."; - parent = NULL; + if (parent == HWND_DESKTOP) { + // Only non-child windows can have HWND_DESKTOP (0) as their parent. + CHECK((window_style_ & WS_CHILD) == 0); + parent = RootWindow(false); + } else if (parent == ::GetDesktopWindow()) { + // Any type of window can have the "Desktop Window" as their parent. + parent = RootWindow(true); + } else if (parent != HWND_MESSAGE) { + CHECK(::IsWindow(parent)); } - CHECK((window_style() & WS_CHILD) == 0 || parent) << - " WS_CHILD must have a non-NULL parent " << original_parent; int x, y, width, height; if (bounds.IsEmpty()) { |