summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorsuzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 08:20:19 +0000
committersuzhe@chromium.org <suzhe@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-15 08:20:19 +0000
commitaeba67b45fc66b5c03205a470cb87d3995ab198a (patch)
tree84dcd8a86108ddd2b0c18e40795dfbea1b32dc7d /chrome/browser
parentf35334961b26e1382810780a99761c8fc1086d5f (diff)
downloadchromium_src-aeba67b45fc66b5c03205a470cb87d3995ab198a.zip
chromium_src-aeba67b45fc66b5c03205a470cb87d3995ab198a.tar.gz
chromium_src-aeba67b45fc66b5c03205a470cb87d3995ab198a.tar.bz2
Linux: Stack autocomplete popup window directly on top of the browser's toplevel window.
BUG=19082 "Linux: Omnibox auto-complete popup is on top of IME candidate window when using SCIM" TEST=Please refer to the bug report for how to test. Review URL: http://codereview.chromium.org/274046 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29102 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc12
-rw-r--r--chrome/browser/autocomplete/autocomplete_popup_view_gtk.h3
-rw-r--r--chrome/browser/gtk/info_bubble_gtk.cc22
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_gtk.cc16
-rw-r--r--chrome/browser/views/autocomplete/autocomplete_popup_gtk.h4
5 files changed, 34 insertions, 23 deletions
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
index 78d8708..06e7c1a 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.cc
@@ -18,13 +18,14 @@
#include "base/string_util.h"
#include "chrome/browser/autocomplete/autocomplete.h"
#include "chrome/browser/autocomplete/autocomplete_edit.h"
-#include "chrome/browser/autocomplete/autocomplete_edit_view.h"
+#include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h"
#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
#include "chrome/browser/bubble_positioner.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_model.h"
+#include "chrome/common/gtk_util.h"
#include "chrome/common/notification_service.h"
#include "grit/theme_resources.h"
@@ -345,6 +346,7 @@ void AutocompletePopupViewGtk::Show(size_t num_results) {
gtk_window_move(GTK_WINDOW(window_), rect.x(), rect.y());
gtk_widget_set_size_request(window_, rect.width(), rect.height());
gtk_widget_show(window_);
+ StackWindow();
opened_ = true;
}
@@ -353,6 +355,14 @@ void AutocompletePopupViewGtk::Hide() {
opened_ = false;
}
+void AutocompletePopupViewGtk::StackWindow() {
+ gfx::NativeView edit_view = edit_view_->GetNativeView();
+ DCHECK(GTK_IS_WIDGET(edit_view));
+ GtkWidget* toplevel = gtk_widget_get_toplevel(edit_view);
+ DCHECK(GTK_WIDGET_TOPLEVEL(toplevel));
+ gtk_util::StackPopupWindow(window_, toplevel);
+}
+
size_t AutocompletePopupViewGtk::LineFromY(int y) {
size_t line = std::max(y - kBorderThickness, 0) / kHeightPerResult;
return std::min(line, model_->result().size() - 1);
diff --git a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.h b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.h
index eed6182..26ab682 100644
--- a/chrome/browser/autocomplete/autocomplete_popup_view_gtk.h
+++ b/chrome/browser/autocomplete/autocomplete_popup_view_gtk.h
@@ -37,6 +37,9 @@ class AutocompletePopupViewGtk : public AutocompletePopupView {
void Show(size_t num_results);
void Hide();
+ // Restack the popup window directly above the browser's toplevel window.
+ void StackWindow();
+
// Convert a y-coordinate to the closest line / result.
size_t LineFromY(int y);
diff --git a/chrome/browser/gtk/info_bubble_gtk.cc b/chrome/browser/gtk/info_bubble_gtk.cc
index 3163555..6ee8e45 100644
--- a/chrome/browser/gtk/info_bubble_gtk.cc
+++ b/chrome/browser/gtk/info_bubble_gtk.cc
@@ -260,26 +260,8 @@ void InfoBubbleGtk::MoveWindow() {
}
void InfoBubbleGtk::StackWindow() {
- // Stack our window directly above the toplevel window. Our 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).
- XID toplevel_window_base = x11_util::GetHighestAncestorWindow(
- x11_util::GetX11WindowFromGtkWidget(GTK_WIDGET(toplevel_window_)),
- x11_util::GetX11RootWindow());
- if (toplevel_window_base) {
- XID window_xid = x11_util::GetX11WindowFromGtkWidget(GTK_WIDGET(window_));
- XID window_parent = x11_util::GetParentWindow(window_xid);
- if (window_parent == x11_util::GetX11RootWindow()) {
- x11_util::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 "
- << x11_util::GetX11RootWindow();
- }
- }
+ // Stack our window directly above the toplevel window.
+ gtk_util::StackPopupWindow(window_, GTK_WIDGET(toplevel_window_));
}
void InfoBubbleGtk::Observe(NotificationType type,
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_gtk.cc b/chrome/browser/views/autocomplete/autocomplete_popup_gtk.cc
index 0905546..d7698ec 100644
--- a/chrome/browser/views/autocomplete/autocomplete_popup_gtk.cc
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_gtk.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/autocomplete/autocomplete_edit_view.h"
#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
#include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h"
+#include "chrome/common/gtk_util.h"
////////////////////////////////////////////////////////////////////////////////
// AutocompletePopupGtk, public:
@@ -15,7 +16,8 @@
AutocompletePopupGtk::AutocompletePopupGtk(
AutocompletePopupContentsView* contents)
: WidgetGtk(WidgetGtk::TYPE_POPUP),
- contents_(contents) {
+ contents_(contents),
+ edit_view_(NULL) {
set_delete_on_destroy(false);
}
@@ -31,14 +33,18 @@ void AutocompletePopupGtk::Init(AutocompleteEditView* edit_view,
// The contents is owned by the LocationBarView.
contents_->SetParentOwned(false);
SetContentsView(contents_);
+
+ edit_view_ = edit_view;
}
void AutocompletePopupGtk::Show() {
// Move the popup to the place appropriate for the window's current position -
// it may have been moved since it was last shown.
SetBounds(contents_->GetPopupBounds());
- if (!IsVisible())
+ if (!IsVisible()) {
WidgetGtk::Show();
+ StackWindow();
+ }
}
bool AutocompletePopupGtk::IsOpen() const {
@@ -48,3 +54,9 @@ bool AutocompletePopupGtk::IsOpen() const {
bool AutocompletePopupGtk::IsCreated() const {
return GTK_IS_WIDGET(GetNativeView());
}
+
+void AutocompletePopupGtk::StackWindow() {
+ GtkWidget* toplevel = gtk_widget_get_toplevel(edit_view_->GetNativeView());
+ DCHECK(GTK_WIDGET_TOPLEVEL(toplevel));
+ gtk_util::StackPopupWindow(GetNativeView(), toplevel);
+}
diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_gtk.h b/chrome/browser/views/autocomplete/autocomplete_popup_gtk.h
index 3ae2625..08e003e 100644
--- a/chrome/browser/views/autocomplete/autocomplete_popup_gtk.h
+++ b/chrome/browser/views/autocomplete/autocomplete_popup_gtk.h
@@ -28,8 +28,12 @@ class AutocompletePopupGtk : public views::WidgetGtk {
// Returns true if the popup has been created.
bool IsCreated() const;
+ // Restack the popup window directly above the browser's toplevel window.
+ void StackWindow();
+
private:
AutocompletePopupContentsView* contents_;
+ AutocompleteEditView* edit_view_;
DISALLOW_COPY_AND_ASSIGN(AutocompletePopupGtk);
};