blob: d04f2a3f7fad918ad428103b7e181a30b34d4ed2 [file] [log] [blame]
// Copyright (c) 2012 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/base/win/hidden_window.h"
#include "ui/gfx/win/window_impl.h"
namespace ui {
namespace {
// We need to have a parent window for the compositing code to work correctly.
// A tab will not have a parent HWND whenever it is not active in its
// host window - for example at creation time and when it's in the
// background, so we provide a default widget to host them.
// It may be tempting to use GetDesktopWindow() instead, but this is
// problematic as the shell sends messages to children of the desktop
// window that interact poorly with us.
// See:
class TempParent : public gfx::WindowImpl {
static TempParent* Get() {
static TempParent* g_temp_parent;
if (!g_temp_parent) {
g_temp_parent = new TempParent();
g_temp_parent->Init(GetDesktopWindow(), gfx::Rect());
EnableWindow(g_temp_parent->hwnd(), FALSE);
return g_temp_parent;
// Explicitly do nothing in Close. We do this as some external apps may get a
// handle to this window and attempt to close it.
void OnClose() {
} // namespace
HWND GetHiddenWindow() {
return TempParent::Get()->hwnd();
} // namespace ui