Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Unified Diff: ui/base/win/hidden_window.cc

Issue 10832011: Makes NativeViewHostWin change the parent of the hwnd when (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix focus issues Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/win/hidden_window.h ('k') | ui/ui.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/win/hidden_window.cc
diff --git a/ui/base/win/hidden_window.cc b/ui/base/win/hidden_window.cc
new file mode 100644
index 0000000000000000000000000000000000000000..fb4f4836b24b2fd6586235f4b3610dbcb5bed19f
--- /dev/null
+++ b/ui/base/win/hidden_window.cc
@@ -0,0 +1,56 @@
+// 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/base/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: http://crbug.com/16476
+class TempParent : public ui::WindowImpl {
+ public:
+ static TempParent* Get() {
+ static TempParent* g_temp_parent;
+ if (!g_temp_parent) {
+ g_temp_parent = new TempParent();
+
+ g_temp_parent->set_window_style(WS_POPUP);
+ g_temp_parent->set_window_ex_style(WS_EX_TOOLWINDOW);
+ g_temp_parent->Init(GetDesktopWindow(), gfx::Rect());
+ EnableWindow(g_temp_parent->hwnd(), FALSE);
+ }
+ return g_temp_parent;
+ }
+
+ private:
+ // 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() {
+ }
+
+ BEGIN_MSG_MAP_EX(WebContentsViewWin)
+ MSG_WM_CLOSE(OnClose)
+ END_MSG_MAP()
+};
+
+} // namespace
+
+HWND GetHiddenWindow() {
+ return TempParent::Get()->hwnd();
+}
+
+} // namespace ui
« no previous file with comments | « ui/base/win/hidden_window.h ('k') | ui/ui.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698