summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-24 15:57:31 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-24 15:57:31 +0000
commitf5a38d53a017fb3f2966028c606608e8e275e398 (patch)
treef9bc45d733fe98609d156e06cfa49338aeb689b3 /ui
parentb0e688e49baa2d22ec306b9aecbe212e4bb8b32c (diff)
downloadchromium_src-f5a38d53a017fb3f2966028c606608e8e275e398.zip
chromium_src-f5a38d53a017fb3f2966028c606608e8e275e398.tar.gz
chromium_src-f5a38d53a017fb3f2966028c606608e8e275e398.tar.bz2
Convert some WidgetWin construction to use CreateParams.
BUG=72040 TEST=none R=erg@chromium.org,estade@chromium.org Review URL: http://codereview.chromium.org/6719006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79279 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/base/gtk/gtk_windowing.cc47
-rw-r--r--ui/base/gtk/gtk_windowing.h17
2 files changed, 64 insertions, 0 deletions
diff --git a/ui/base/gtk/gtk_windowing.cc b/ui/base/gtk/gtk_windowing.cc
new file mode 100644
index 0000000..7f26b84
--- /dev/null
+++ b/ui/base/gtk/gtk_windowing.cc
@@ -0,0 +1,47 @@
+// Copyright (c) 2011 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/gtk/gtk_windowing.h"
+
+#include <gdk/gdkx.h>
+
+#include "base/logging.h"
+#include "ui/base/x/x11_util.h"
+
+namespace ui {
+
+void StackPopupWindow(GtkWidget* popup, GtkWidget* toplevel) {
+ DCHECK(GTK_IS_WINDOW(popup) && GTK_WIDGET_TOPLEVEL(popup) &&
+ GTK_WIDGET_REALIZED(popup));
+ DCHECK(GTK_IS_WINDOW(toplevel) && GTK_WIDGET_TOPLEVEL(toplevel) &&
+ GTK_WIDGET_REALIZED(toplevel));
+
+ // Stack the |popup| window directly above the |toplevel| window.
+ // The popup window is a direct child of the root window, so we need to
+ // find a similar ancestor for the toplevel window (which might have been
+ // reparented by a window manager). We grab the server while we're doing
+ // this -- otherwise, we'll get an error if the window manager reparents the
+ // toplevel window right after we call GetHighestAncestorWindow().
+ gdk_x11_display_grab(gtk_widget_get_display(toplevel));
+ XID toplevel_window_base = ui::GetHighestAncestorWindow(
+ ui::GetX11WindowFromGtkWidget(toplevel),
+ ui::GetX11RootWindow());
+ if (toplevel_window_base) {
+ XID window_xid = ui::GetX11WindowFromGtkWidget(popup);
+ XID window_parent = ui::GetParentWindow(window_xid);
+ if (window_parent == ui::GetX11RootWindow()) {
+ ui::RestackWindow(window_xid, toplevel_window_base, true);
+ } else {
+ // The window manager shouldn't reparent override-redirect windows.
+ DLOG(ERROR) << "override-redirect window " << window_xid
+ << "'s parent is " << window_parent
+ << ", rather than root window "
+ << ui::GetX11RootWindow();
+ }
+ }
+ gdk_x11_display_ungrab(gtk_widget_get_display(toplevel));
+}
+
+} // namespace ui
+
diff --git a/ui/base/gtk/gtk_windowing.h b/ui/base/gtk/gtk_windowing.h
new file mode 100644
index 0000000..d94520f
--- /dev/null
+++ b/ui/base/gtk/gtk_windowing.h
@@ -0,0 +1,17 @@
+// Copyright (c) 2011 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.
+
+#ifndef UI_BASE_GTK_GTK_WINDOWING_H_
+#define UI_BASE_GTK_GTK_WINDOWING_H_
+
+#include <gtk/gtk.h>
+
+namespace ui {
+
+// Stacks a |popup| window directly on top of a |toplevel| window.
+void StackPopupWindow(GtkWidget* popup, GtkWidget* toplevel);
+
+} // namespace ui
+
+#endif // UI_BASE_GTK_GTK_WINDOWING_H_