diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-02 01:30:54 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-02 01:30:54 +0000 |
commit | 7acc214800c8b824ec6c704e7395143dbc702594 (patch) | |
tree | 7f4bdcb61492fc84c3193369a8c278b4d77eb971 /ui | |
parent | 8a5a84ab8334b6039c33df72af3ce947f4fdf767 (diff) | |
download | chromium_src-7acc214800c8b824ec6c704e7395143dbc702594.zip chromium_src-7acc214800c8b824ec6c704e7395143dbc702594.tar.gz chromium_src-7acc214800c8b824ec6c704e7395143dbc702594.tar.bz2 |
Fullscreen can't use the desktop as a parent in metro mode
Also moved the rootwindow stuff to the hwnd_util and cleaned it up.
BUG=118641
TEST=see bug
Review URL: https://chromiumcodereview.appspot.com/10270029
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134848 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/base/win/hwnd_util.cc | 15 | ||||
-rw-r--r-- | ui/base/win/hwnd_util.h | 5 | ||||
-rw-r--r-- | ui/base/win/window_impl.cc | 27 |
3 files changed, 22 insertions, 25 deletions
diff --git a/ui/base/win/hwnd_util.cc b/ui/base/win/hwnd_util.cc index 4da6594..38a7253 100644 --- a/ui/base/win/hwnd_util.cc +++ b/ui/base/win/hwnd_util.cc @@ -6,6 +6,7 @@ #include "base/i18n/rtl.h" #include "base/string_util.h" +#include "base/win/metro.h" #include "ui/gfx/rect.h" #include "ui/gfx/size.h" @@ -181,4 +182,18 @@ void ShowSystemMenu(HWND window, int screen_x, int screen_y) { SendMessage(window, WM_SYSCOMMAND, command, 0); } +extern "C" { + typedef HWND (*RootWindow)(); +} + +HWND GetWindowToParentTo(bool get_real_hwnd) { + HMODULE metro = base::win::GetMetroModule(); + if (!metro) + return get_real_hwnd ? ::GetDesktopWindow() : HWND_DESKTOP; + // In windows 8 metro-mode the root window is not the desktop. + RootWindow root_window = + reinterpret_cast<RootWindow>(::GetProcAddress(metro, "GetRootWindow")); + return root_window(); +} + } // namespace ui diff --git a/ui/base/win/hwnd_util.h b/ui/base/win/hwnd_util.h index 7fbe591..09f777a 100644 --- a/ui/base/win/hwnd_util.h +++ b/ui/base/win/hwnd_util.h @@ -47,6 +47,11 @@ UI_EXPORT void CheckWindowCreated(HWND hwnd); // user selected something. UI_EXPORT void ShowSystemMenu(HWND window, int screen_x, int screen_y); +// Returns the window you can use to parent a top level window. +// Note that in some cases we create child windows not parented to its final +// container so in those cases you should pass true in |get_real_hwnd|. +UI_EXPORT HWND GetWindowToParentTo(bool get_real_hwnd); + } // namespace ui #endif // UI_BASE_WIN_HWND_UTIL_H_ diff --git a/ui/base/win/window_impl.cc b/ui/base/win/window_impl.cc index 8221253..31d0fe3 100644 --- a/ui/base/win/window_impl.cc +++ b/ui/base/win/window_impl.cc @@ -12,29 +12,6 @@ #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 = @@ -164,10 +141,10 @@ void WindowImpl::Init(HWND parent, const gfx::Rect& bounds) { 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); + parent = GetWindowToParentTo(false); } else if (parent == ::GetDesktopWindow()) { // Any type of window can have the "Desktop Window" as their parent. - parent = RootWindow(true); + parent = GetWindowToParentTo(true); } else if (parent != HWND_MESSAGE) { CHECK(::IsWindow(parent)); } |