summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-29 18:52:32 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-29 18:52:32 +0000
commit159b2a3a31ff9aab59dc489e2bb1549eefec6039 (patch)
tree120cec2f3450530c60cfaf903a18201dda30092a
parent28a664412359284fa2b5b4cd549b38682ce8fe85 (diff)
downloadchromium_src-159b2a3a31ff9aab59dc489e2bb1549eefec6039.zip
chromium_src-159b2a3a31ff9aab59dc489e2bb1549eefec6039.tar.gz
chromium_src-159b2a3a31ff9aab59dc489e2bb1549eefec6039.tar.bz2
Linux test shell: get rid of popups when they "lose focus".
Review URL: http://codereview.chromium.org/14912 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7483 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/tools/test_shell/test_shell_gtk.cc24
1 files changed, 20 insertions, 4 deletions
diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc
index 7d63e87..b4cce51 100644
--- a/webkit/tools/test_shell/test_shell_gtk.cc
+++ b/webkit/tools/test_shell/test_shell_gtk.cc
@@ -158,6 +158,12 @@ gboolean MainWindowDestroyed(GtkWindow* window, TestShell* shell) {
return FALSE; // Don't stop this message.
}
+gboolean MainWindowLostFocus(GtkWidget* widget, GdkEventFocus* event,
+ TestShell* shell) {
+ shell->ClosePopup();
+ return FALSE;
+}
+
// Callback for when you click the back button.
void BackButtonClicked(GtkButton* button, TestShell* shell) {
shell->GoBackOrForward(-1);
@@ -184,7 +190,7 @@ void URLEntryActivate(GtkEntry* entry, TestShell* shell) {
shell->LoadURL(UTF8ToWide(url).c_str());
}
-};
+}
bool TestShell::Initialize(const std::wstring& startingURL) {
m_mainWnd = gtk_window_new(GTK_WINDOW_TOPLEVEL);
@@ -192,7 +198,8 @@ bool TestShell::Initialize(const std::wstring& startingURL) {
gtk_window_set_default_size(GTK_WINDOW(m_mainWnd), 640, 480);
g_signal_connect(G_OBJECT(m_mainWnd), "destroy",
G_CALLBACK(MainWindowDestroyed), this);
-
+ g_signal_connect(G_OBJECT(m_mainWnd), "focus-out-event",
+ G_CALLBACK(MainWindowLostFocus), this);
g_object_set_data(G_OBJECT(m_mainWnd), "test-shell", this);
GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
@@ -320,16 +327,25 @@ WebWidget* TestShell::CreatePopupWidget(WebView* webview) {
gtk_container_add(GTK_CONTAINER(popupwindow), vbox);
m_popupHost = host;
+ // Grab all input to the test shell and funnel it to the popup.
+ // The popup will detect if mouseclicks are outside its bounds and destroy
+ // itself if so. Clicks that are outside the test_shell window will destroy
+ // the popup by taking focus away from the main window.
+ gtk_grab_add(host->view_handle());
+
return host->webwidget();
}
void TestShell::ClosePopup() {
- DCHECK(m_popupHost);
+ if (!m_popupHost)
+ return;
GtkWidget* drawing_area = m_popupHost->view_handle();
+ // gtk_widget_destroy will recursively call ClosePopup, so to avoid GTK
+ // warnings set m_popupHost to null here before making the call.
+ m_popupHost = NULL;
GtkWidget* window =
gtk_widget_get_parent(gtk_widget_get_parent(drawing_area));
gtk_widget_destroy(window);
- m_popupHost = NULL;
}
void TestShell::ResizeSubViews() {