| 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 "chrome/browser/ui/gtk/bubble/bubble_gtk.h" | 5 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" |
| 6 | 6 |
| 7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/ui/gtk/bubble/bubble_accelerators_gtk.h" | 10 #include "chrome/browser/ui/gtk/bubble/bubble_accelerators_gtk.h" |
| 11 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 11 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 12 #include "chrome/browser/ui/gtk/gtk_util.h" | 12 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 13 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
| 14 #include "content/public/browser/notification_source.h" | 14 #include "content/public/browser/notification_source.h" |
| 15 #include "ui/base/gtk/gtk_compat.h" |
| 15 #include "ui/base/gtk/gtk_hig_constants.h" | 16 #include "ui/base/gtk/gtk_hig_constants.h" |
| 16 #include "ui/base/gtk/gtk_windowing.h" | 17 #include "ui/base/gtk/gtk_windowing.h" |
| 17 #include "ui/gfx/gtk_util.h" | 18 #include "ui/gfx/gtk_util.h" |
| 18 #include "ui/gfx/path.h" | 19 #include "ui/gfx/path.h" |
| 19 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // The height of the arrow, and the width will be about twice the height. | 24 // The height of the arrow, and the width will be about twice the height. |
| 24 const int kArrowSize = 8; | 25 const int kArrowSize = 8; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 ArrowLocationGtk arrow_location, | 94 ArrowLocationGtk arrow_location, |
| 94 bool grab_input) { | 95 bool grab_input) { |
| 95 // If there is a current grab widget (menu, other bubble, etc.), hide it. | 96 // If there is a current grab widget (menu, other bubble, etc.), hide it. |
| 96 GtkWidget* current_grab_widget = gtk_grab_get_current(); | 97 GtkWidget* current_grab_widget = gtk_grab_get_current(); |
| 97 if (current_grab_widget) | 98 if (current_grab_widget) |
| 98 gtk_widget_hide(current_grab_widget); | 99 gtk_widget_hide(current_grab_widget); |
| 99 | 100 |
| 100 DCHECK(!window_); | 101 DCHECK(!window_); |
| 101 anchor_widget_ = anchor_widget; | 102 anchor_widget_ = anchor_widget; |
| 102 toplevel_window_ = GTK_WINDOW(gtk_widget_get_toplevel(anchor_widget_)); | 103 toplevel_window_ = GTK_WINDOW(gtk_widget_get_toplevel(anchor_widget_)); |
| 103 DCHECK(GTK_WIDGET_TOPLEVEL(toplevel_window_)); | 104 DCHECK(gtk_widget_is_toplevel(GTK_WIDGET(toplevel_window_))); |
| 104 rect_ = rect ? *rect : gtk_util::WidgetBounds(anchor_widget); | 105 rect_ = rect ? *rect : gtk_util::WidgetBounds(anchor_widget); |
| 105 preferred_arrow_location_ = arrow_location; | 106 preferred_arrow_location_ = arrow_location; |
| 106 | 107 |
| 107 grab_input_ = grab_input; | 108 grab_input_ = grab_input; |
| 108 // Using a TOPLEVEL window may cause placement issues with certain WMs but it | 109 // Using a TOPLEVEL window may cause placement issues with certain WMs but it |
| 109 // is necessary to be able to focus the window. | 110 // is necessary to be able to focus the window. |
| 110 window_ = gtk_window_new(grab_input ? GTK_WINDOW_POPUP : GTK_WINDOW_TOPLEVEL); | 111 window_ = gtk_window_new(grab_input ? GTK_WINDOW_POPUP : GTK_WINDOW_TOPLEVEL); |
| 111 | 112 |
| 112 gtk_widget_set_app_paintable(window_, TRUE); | 113 gtk_widget_set_app_paintable(window_, TRUE); |
| 113 // Resizing is handled by the program, not user. | 114 // Resizing is handled by the program, not user. |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 gboolean BubbleGtk::OnToplevelUnmap(GtkWidget* widget, GdkEvent* event) { | 526 gboolean BubbleGtk::OnToplevelUnmap(GtkWidget* widget, GdkEvent* event) { |
| 526 Close(); | 527 Close(); |
| 527 return FALSE; | 528 return FALSE; |
| 528 } | 529 } |
| 529 | 530 |
| 530 void BubbleGtk::OnAnchorAllocate(GtkWidget* widget, | 531 void BubbleGtk::OnAnchorAllocate(GtkWidget* widget, |
| 531 GtkAllocation* allocation) { | 532 GtkAllocation* allocation) { |
| 532 if (!UpdateArrowLocation(false)) | 533 if (!UpdateArrowLocation(false)) |
| 533 MoveWindow(); | 534 MoveWindow(); |
| 534 } | 535 } |
| OLD | NEW |