OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/base/gtk/gtk_windowing.h" | 5 #include "ui/base/gtk/gtk_windowing.h" |
6 | 6 |
7 #include <gdk/gdkx.h> | 7 #include <gdk/gdkx.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/base/gtk/gtk_compat.h" |
10 #include "ui/base/x/x11_util.h" | 11 #include "ui/base/x/x11_util.h" |
11 | 12 |
12 namespace ui { | 13 namespace ui { |
13 | 14 |
14 void StackPopupWindow(GtkWidget* popup, GtkWidget* toplevel) { | 15 void StackPopupWindow(GtkWidget* popup, GtkWidget* toplevel) { |
15 DCHECK(GTK_IS_WINDOW(popup) && GTK_WIDGET_TOPLEVEL(popup) && | 16 DCHECK(GTK_IS_WINDOW(popup) && gtk_widget_is_toplevel(popup) && |
16 GTK_WIDGET_REALIZED(popup)); | 17 gtk_widget_get_realized(popup)); |
17 DCHECK(GTK_IS_WINDOW(toplevel) && GTK_WIDGET_TOPLEVEL(toplevel) && | 18 DCHECK(GTK_IS_WINDOW(toplevel) && gtk_widget_is_toplevel(toplevel) && |
18 GTK_WIDGET_REALIZED(toplevel)); | 19 gtk_widget_get_realized(toplevel)); |
19 | 20 |
20 // Stack the |popup| window directly above the |toplevel| window. | 21 // Stack the |popup| window directly above the |toplevel| window. |
21 // The popup window is a direct child of the root window, so we need to | 22 // The popup window is a direct child of the root window, so we need to |
22 // find a similar ancestor for the toplevel window (which might have been | 23 // find a similar ancestor for the toplevel window (which might have been |
23 // reparented by a window manager). We grab the server while we're doing | 24 // reparented by a window manager). We grab the server while we're doing |
24 // this -- otherwise, we'll get an error if the window manager reparents the | 25 // this -- otherwise, we'll get an error if the window manager reparents the |
25 // toplevel window right after we call GetHighestAncestorWindow(). | 26 // toplevel window right after we call GetHighestAncestorWindow(). |
26 gdk_x11_display_grab(gtk_widget_get_display(toplevel)); | 27 gdk_x11_display_grab(gtk_widget_get_display(toplevel)); |
27 XID toplevel_window_base = ui::GetHighestAncestorWindow( | 28 XID toplevel_window_base = ui::GetHighestAncestorWindow( |
28 ui::GetX11WindowFromGtkWidget(toplevel), | 29 ui::GetX11WindowFromGtkWidget(toplevel), |
29 ui::GetX11RootWindow()); | 30 ui::GetX11RootWindow()); |
30 if (toplevel_window_base) { | 31 if (toplevel_window_base) { |
31 XID window_xid = ui::GetX11WindowFromGtkWidget(popup); | 32 XID window_xid = ui::GetX11WindowFromGtkWidget(popup); |
32 XID window_parent = ui::GetParentWindow(window_xid); | 33 XID window_parent = ui::GetParentWindow(window_xid); |
33 if (window_parent == ui::GetX11RootWindow()) { | 34 if (window_parent == ui::GetX11RootWindow()) { |
34 ui::RestackWindow(window_xid, toplevel_window_base, true); | 35 ui::RestackWindow(window_xid, toplevel_window_base, true); |
35 } else { | 36 } else { |
36 // The window manager shouldn't reparent override-redirect windows. | 37 // The window manager shouldn't reparent override-redirect windows. |
37 DLOG(ERROR) << "override-redirect window " << window_xid | 38 DLOG(ERROR) << "override-redirect window " << window_xid |
38 << "'s parent is " << window_parent | 39 << "'s parent is " << window_parent |
39 << ", rather than root window " | 40 << ", rather than root window " |
40 << ui::GetX11RootWindow(); | 41 << ui::GetX11RootWindow(); |
41 } | 42 } |
42 } | 43 } |
43 gdk_x11_display_ungrab(gtk_widget_get_display(toplevel)); | 44 gdk_x11_display_ungrab(gtk_widget_get_display(toplevel)); |
44 } | 45 } |
45 | 46 |
46 } // namespace ui | 47 } // namespace ui |
47 | 48 |
OLD | NEW |