| 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 "content/common/notification_service.h" | 14 #include "content/common/notification_service.h" |
| 14 #include "ui/base/gtk/gtk_windowing.h" | 15 #include "ui/base/gtk/gtk_windowing.h" |
| 15 #include "ui/gfx/gtk_util.h" | 16 #include "ui/gfx/gtk_util.h" |
| 16 #include "ui/gfx/path.h" | 17 #include "ui/gfx/path.h" |
| 17 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 // The height of the arrow, and the width will be about twice the height. | 22 // The height of the arrow, and the width will be about twice the height. |
| 22 const int kArrowSize = 8; | 23 const int kArrowSize = 8; |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 signals_.Connect(toplevel_window_, "destroy", | 173 signals_.Connect(toplevel_window_, "destroy", |
| 173 G_CALLBACK(gtk_widget_destroyed), &toplevel_window_); | 174 G_CALLBACK(gtk_widget_destroyed), &toplevel_window_); |
| 174 | 175 |
| 175 gtk_widget_show_all(window_); | 176 gtk_widget_show_all(window_); |
| 176 | 177 |
| 177 if (grab_input_) { | 178 if (grab_input_) { |
| 178 gtk_grab_add(window_); | 179 gtk_grab_add(window_); |
| 179 GrabPointerAndKeyboard(); | 180 GrabPointerAndKeyboard(); |
| 180 } | 181 } |
| 181 | 182 |
| 182 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, | 183 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 183 Source<ThemeService>(theme_service_)); | 184 Source<ThemeService>(theme_service_)); |
| 184 theme_service_->InitThemesFor(this); | 185 theme_service_->InitThemesFor(this); |
| 185 } | 186 } |
| 186 | 187 |
| 187 // NOTE: This seems a bit overcomplicated, but it requires a bunch of careful | 188 // NOTE: This seems a bit overcomplicated, but it requires a bunch of careful |
| 188 // fudging to get the pixels rasterized exactly where we want them, the arrow to | 189 // fudging to get the pixels rasterized exactly where we want them, the arrow to |
| 189 // have a 1 pixel point, etc. | 190 // have a 1 pixel point, etc. |
| 190 // TODO(deanm): Windows draws with Skia and uses some PNG images for the | 191 // TODO(deanm): Windows draws with Skia and uses some PNG images for the |
| 191 // corners. This is a lot more work, but they get anti-aliasing. | 192 // corners. This is a lot more work, but they get anti-aliasing. |
| 192 // static | 193 // static |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 | 337 |
| 337 gtk_window_move(GTK_WINDOW(window_), screen_x, screen_y); | 338 gtk_window_move(GTK_WINDOW(window_), screen_x, screen_y); |
| 338 } | 339 } |
| 339 | 340 |
| 340 void BubbleGtk::StackWindow() { | 341 void BubbleGtk::StackWindow() { |
| 341 // Stack our window directly above the toplevel window. | 342 // Stack our window directly above the toplevel window. |
| 342 if (toplevel_window_) | 343 if (toplevel_window_) |
| 343 ui::StackPopupWindow(window_, GTK_WIDGET(toplevel_window_)); | 344 ui::StackPopupWindow(window_, GTK_WIDGET(toplevel_window_)); |
| 344 } | 345 } |
| 345 | 346 |
| 346 void BubbleGtk::Observe(NotificationType type, | 347 void BubbleGtk::Observe(int type, |
| 347 const NotificationSource& source, | 348 const NotificationSource& source, |
| 348 const NotificationDetails& details) { | 349 const NotificationDetails& details) { |
| 349 DCHECK_EQ(type.value, NotificationType::BROWSER_THEME_CHANGED); | 350 DCHECK_EQ(type, chrome::NOTIFICATION_BROWSER_THEME_CHANGED); |
| 350 if (theme_service_->UsingNativeTheme() && match_system_theme_) { | 351 if (theme_service_->UsingNativeTheme() && match_system_theme_) { |
| 351 gtk_widget_modify_bg(window_, GTK_STATE_NORMAL, NULL); | 352 gtk_widget_modify_bg(window_, GTK_STATE_NORMAL, NULL); |
| 352 } else { | 353 } else { |
| 353 // Set the background color, so we don't need to paint it manually. | 354 // Set the background color, so we don't need to paint it manually. |
| 354 gtk_widget_modify_bg(window_, GTK_STATE_NORMAL, &kBackgroundColor); | 355 gtk_widget_modify_bg(window_, GTK_STATE_NORMAL, &kBackgroundColor); |
| 355 } | 356 } |
| 356 } | 357 } |
| 357 | 358 |
| 358 void BubbleGtk::HandlePointerAndKeyboardUngrabbedByContent() { | 359 void BubbleGtk::HandlePointerAndKeyboardUngrabbedByContent() { |
| 359 if (grab_input_) | 360 if (grab_input_) |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 gboolean BubbleGtk::OnToplevelUnmap(GtkWidget* widget, GdkEvent* event) { | 528 gboolean BubbleGtk::OnToplevelUnmap(GtkWidget* widget, GdkEvent* event) { |
| 528 Close(); | 529 Close(); |
| 529 return FALSE; | 530 return FALSE; |
| 530 } | 531 } |
| 531 | 532 |
| 532 void BubbleGtk::OnAnchorAllocate(GtkWidget* widget, | 533 void BubbleGtk::OnAnchorAllocate(GtkWidget* widget, |
| 533 GtkAllocation* allocation) { | 534 GtkAllocation* allocation) { |
| 534 if (!UpdateArrowLocation(false)) | 535 if (!UpdateArrowLocation(false)) |
| 535 MoveWindow(); | 536 MoveWindow(); |
| 536 } | 537 } |
| OLD | NEW |