Commit 7acc2148 authored by cpu@chromium.org's avatar cpu@chromium.org

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
parent 8a5a84ab
...@@ -392,7 +392,7 @@ void RenderWidgetHostViewWin::InitAsFullscreen( ...@@ -392,7 +392,7 @@ void RenderWidgetHostViewWin::InitAsFullscreen(
gfx::Rect pos = gfx::Screen::GetMonitorNearestWindow( gfx::Rect pos = gfx::Screen::GetMonitorNearestWindow(
reference_host_view->GetNativeView()).bounds(); reference_host_view->GetNativeView()).bounds();
is_fullscreen_ = true; is_fullscreen_ = true;
DoPopupOrFullscreenInit(GetDesktopWindow(), pos, 0); DoPopupOrFullscreenInit(ui::GetWindowToParentTo(true), pos, 0);
} }
RenderWidgetHost* RenderWidgetHostViewWin::GetRenderWidgetHost() const { RenderWidgetHost* RenderWidgetHostViewWin::GetRenderWidgetHost() const {
...@@ -668,7 +668,7 @@ bool RenderWidgetHostViewWin::HasFocus() const { ...@@ -668,7 +668,7 @@ bool RenderWidgetHostViewWin::HasFocus() const {
void RenderWidgetHostViewWin::Show() { void RenderWidgetHostViewWin::Show() {
if (!is_fullscreen_) { if (!is_fullscreen_) {
DCHECK(parent_hwnd_); DCHECK(parent_hwnd_);
DCHECK(parent_hwnd_ != GetDesktopWindow()); DCHECK(parent_hwnd_ != ui::GetWindowToParentTo(true));
SetParent(parent_hwnd_); SetParent(parent_hwnd_);
} }
ShowWindow(SW_SHOW); ShowWindow(SW_SHOW);
...@@ -677,7 +677,7 @@ void RenderWidgetHostViewWin::Show() { ...@@ -677,7 +677,7 @@ void RenderWidgetHostViewWin::Show() {
} }
void RenderWidgetHostViewWin::Hide() { void RenderWidgetHostViewWin::Hide() {
if (!is_fullscreen_ && GetParent() == GetDesktopWindow()) { if (!is_fullscreen_ && GetParent() == ui::GetWindowToParentTo(true)) {
LOG(WARNING) << "Hide() called twice in a row: " << this << ":" << LOG(WARNING) << "Hide() called twice in a row: " << this << ":" <<
parent_hwnd_ << ":" << GetParent(); parent_hwnd_ << ":" << GetParent();
return; return;
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "base/i18n/rtl.h" #include "base/i18n/rtl.h"
#include "base/string_util.h" #include "base/string_util.h"
#include "base/win/metro.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
#include "ui/gfx/size.h" #include "ui/gfx/size.h"
...@@ -181,4 +182,18 @@ void ShowSystemMenu(HWND window, int screen_x, int screen_y) { ...@@ -181,4 +182,18 @@ void ShowSystemMenu(HWND window, int screen_x, int screen_y) {
SendMessage(window, WM_SYSCOMMAND, command, 0); 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 } // namespace ui
...@@ -47,6 +47,11 @@ UI_EXPORT void CheckWindowCreated(HWND hwnd); ...@@ -47,6 +47,11 @@ UI_EXPORT void CheckWindowCreated(HWND hwnd);
// user selected something. // user selected something.
UI_EXPORT void ShowSystemMenu(HWND window, int screen_x, int screen_y); 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 } // namespace ui
#endif // UI_BASE_WIN_HWND_UTIL_H_ #endif // UI_BASE_WIN_HWND_UTIL_H_
...@@ -12,29 +12,6 @@ ...@@ -12,29 +12,6 @@
#include "base/win/wrapped_window_proc.h" #include "base/win/wrapped_window_proc.h"
#include "ui/base/win/hwnd_util.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 { namespace ui {
static const DWORD kWindowDefaultChildStyle = static const DWORD kWindowDefaultChildStyle =
...@@ -164,10 +141,10 @@ void WindowImpl::Init(HWND parent, const gfx::Rect& bounds) { ...@@ -164,10 +141,10 @@ void WindowImpl::Init(HWND parent, const gfx::Rect& bounds) {
if (parent == HWND_DESKTOP) { if (parent == HWND_DESKTOP) {
// Only non-child windows can have HWND_DESKTOP (0) as their parent. // Only non-child windows can have HWND_DESKTOP (0) as their parent.
CHECK((window_style_ & WS_CHILD) == 0); CHECK((window_style_ & WS_CHILD) == 0);
parent = RootWindow(false); parent = GetWindowToParentTo(false);
} else if (parent == ::GetDesktopWindow()) { } else if (parent == ::GetDesktopWindow()) {
// Any type of window can have the "Desktop Window" as their parent. // Any type of window can have the "Desktop Window" as their parent.
parent = RootWindow(true); parent = GetWindowToParentTo(true);
} else if (parent != HWND_MESSAGE) { } else if (parent != HWND_MESSAGE) {
CHECK(::IsWindow(parent)); CHECK(::IsWindow(parent));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment