| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/gtk/info_bubble_gtk.h" | 5 #include "chrome/browser/gtk/info_bubble_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include "app/gfx/path.h" | 10 #include "app/gfx/path.h" |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 197 |
| 198 gtk_widget_show_all(window_); | 198 gtk_widget_show_all(window_); |
| 199 // Make sure our window has focus, is brought to the top, etc. | 199 // Make sure our window has focus, is brought to the top, etc. |
| 200 gtk_window_present(GTK_WINDOW(window_)); | 200 gtk_window_present(GTK_WINDOW(window_)); |
| 201 // We add a GTK (application level) grab. This means we will get all | 201 // We add a GTK (application level) grab. This means we will get all |
| 202 // keyboard and mouse events for our application, even if they were delivered | 202 // keyboard and mouse events for our application, even if they were delivered |
| 203 // on another window. This allows us to close when the user clicks outside | 203 // on another window. This allows us to close when the user clicks outside |
| 204 // of the info bubble. We don't use an X grab since that would steal | 204 // of the info bubble. We don't use an X grab since that would steal |
| 205 // keystrokes from your window manager, prevent you from interacting with | 205 // keystrokes from your window manager, prevent you from interacting with |
| 206 // other applications, etc. | 206 // other applications, etc. |
| 207 // |
| 208 // Before adding the grab, we need to ensure that the bubble is added |
| 209 // to the window group of the top level window. This ensures that the |
| 210 // grab only affects the current browser window, and not all the open |
| 211 // browser windows in the application. |
| 212 gtk_window_group_add_window(gtk_window_get_group(transient_toplevel), |
| 213 GTK_WINDOW(window_)); |
| 207 gtk_grab_add(window_); | 214 gtk_grab_add(window_); |
| 208 } | 215 } |
| 209 | 216 |
| 210 void InfoBubbleGtk::Close(bool closed_by_escape) { | 217 void InfoBubbleGtk::Close(bool closed_by_escape) { |
| 211 // Notify the delegate that we're about to close. This gives the chance | 218 // Notify the delegate that we're about to close. This gives the chance |
| 212 // to save state / etc from the hosted widget before it's destroyed. | 219 // to save state / etc from the hosted widget before it's destroyed. |
| 213 if (delegate_) | 220 if (delegate_) |
| 214 delegate_->InfoBubbleClosing(this, closed_by_escape); | 221 delegate_->InfoBubbleClosing(this, closed_by_escape); |
| 215 | 222 |
| 216 DCHECK(window_); | 223 DCHECK(window_); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 // destroy the widget manually, or the window was closed via X. This will | 255 // destroy the widget manually, or the window was closed via X. This will |
| 249 // delete the InfoBubbleGtk object. | 256 // delete the InfoBubbleGtk object. |
| 250 delete this; | 257 delete this; |
| 251 return FALSE; // Propagate. | 258 return FALSE; // Propagate. |
| 252 } | 259 } |
| 253 | 260 |
| 254 gboolean InfoBubbleGtk::HandleFocusOut(GdkEventButton* event) { | 261 gboolean InfoBubbleGtk::HandleFocusOut(GdkEventButton* event) { |
| 255 Close(); | 262 Close(); |
| 256 return FALSE; // Propagate. | 263 return FALSE; // Propagate. |
| 257 } | 264 } |
| OLD | NEW |