| 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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 202 |
| 203 gtk_widget_show_all(window_); | 203 gtk_widget_show_all(window_); |
| 204 // Make sure our window has focus, is brought to the top, etc. | 204 // Make sure our window has focus, is brought to the top, etc. |
| 205 gtk_window_present(GTK_WINDOW(window_)); | 205 gtk_window_present(GTK_WINDOW(window_)); |
| 206 // We add a GTK (application level) grab. This means we will get all | 206 // We add a GTK (application level) grab. This means we will get all |
| 207 // keyboard and mouse events for our application, even if they were delivered | 207 // keyboard and mouse events for our application, even if they were delivered |
| 208 // on another window. This allows us to close when the user clicks outside | 208 // on another window. This allows us to close when the user clicks outside |
| 209 // of the info bubble. We don't use an X grab since that would steal | 209 // of the info bubble. We don't use an X grab since that would steal |
| 210 // keystrokes from your window manager, prevent you from interacting with | 210 // keystrokes from your window manager, prevent you from interacting with |
| 211 // other applications, etc. | 211 // other applications, etc. |
| 212 // |
| 213 // Before adding the grab, we need to ensure that the bubble is added |
| 214 // to the window group of the top level window. This ensures that the |
| 215 // grab only affects the current browser window, and not all the open |
| 216 // browser windows in the application. |
| 217 gtk_window_group_add_window(gtk_window_get_group(transient_toplevel), |
| 218 GTK_WINDOW(window_)); |
| 212 gtk_grab_add(window_); | 219 gtk_grab_add(window_); |
| 213 | 220 |
| 214 registrar_.Add(this, NotificationType::ACTIVE_WINDOW_CHANGED, | 221 registrar_.Add(this, NotificationType::ACTIVE_WINDOW_CHANGED, |
| 215 NotificationService::AllSources()); | 222 NotificationService::AllSources()); |
| 216 } | 223 } |
| 217 | 224 |
| 218 void InfoBubbleGtk::Observe(NotificationType type, | 225 void InfoBubbleGtk::Observe(NotificationType type, |
| 219 const NotificationSource& source, | 226 const NotificationSource& source, |
| 220 const NotificationDetails& details) { | 227 const NotificationDetails& details) { |
| 221 DCHECK(type.value == NotificationType::ACTIVE_WINDOW_CHANGED); | 228 DCHECK(type.value == NotificationType::ACTIVE_WINDOW_CHANGED); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 return TRUE; | 279 return TRUE; |
| 273 } | 280 } |
| 274 | 281 |
| 275 gboolean InfoBubbleGtk::HandleDestroy() { | 282 gboolean InfoBubbleGtk::HandleDestroy() { |
| 276 // We are self deleting, we have a destroy signal setup to catch when we | 283 // We are self deleting, we have a destroy signal setup to catch when we |
| 277 // destroy the widget manually, or the window was closed via X. This will | 284 // destroy the widget manually, or the window was closed via X. This will |
| 278 // delete the InfoBubbleGtk object. | 285 // delete the InfoBubbleGtk object. |
| 279 delete this; | 286 delete this; |
| 280 return FALSE; // Propagate. | 287 return FALSE; // Propagate. |
| 281 } | 288 } |
| OLD | NEW |