| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 const int kArrowX = 18; | 29 const int kArrowX = 18; |
| 30 | 30 |
| 31 // Number of pixels between the tip of the arrow and the region we're | 31 // Number of pixels between the tip of the arrow and the region we're |
| 32 // pointing to. | 32 // pointing to. |
| 33 const int kArrowToContentPadding = -4; | 33 const int kArrowToContentPadding = -4; |
| 34 | 34 |
| 35 // We draw flat diagonal corners, each corner is an NxN square. | 35 // We draw flat diagonal corners, each corner is an NxN square. |
| 36 const int kCornerSize = 3; | 36 const int kCornerSize = 3; |
| 37 | 37 |
| 38 // Margins around the content. | 38 // Margins around the content. |
| 39 const int kTopMargin = kArrowSize + kCornerSize - 1; | 39 const int kTopMargin = kArrowSize; |
| 40 const int kBottomMargin = kCornerSize - 1; | 40 const int kBottomMargin = 0; |
| 41 const int kLeftMargin = kCornerSize - 1; | 41 const int kLeftMargin = 0; |
| 42 const int kRightMargin = kCornerSize - 1; | 42 const int kRightMargin = 0; |
| 43 | 43 |
| 44 const GdkColor kBackgroundColor = GDK_COLOR_RGB(0xff, 0xff, 0xff); | 44 const GdkColor kBackgroundColor = GDK_COLOR_RGB(0xff, 0xff, 0xff); |
| 45 const GdkColor kFrameColor = GDK_COLOR_RGB(0x63, 0x63, 0x63); | 45 const GdkColor kFrameColor = GDK_COLOR_RGB(0x63, 0x63, 0x63); |
| 46 | 46 |
| 47 // Helper functions that encapsulate arrow locations. | 47 // Helper functions that encapsulate arrow locations. |
| 48 bool HasArrow(BubbleGtk::ArrowLocationGtk location) { | 48 bool HasArrow(BubbleGtk::ArrowLocationGtk location) { |
| 49 return location != BubbleGtk::ARROW_LOCATION_NONE && | 49 return location != BubbleGtk::ARROW_LOCATION_NONE && |
| 50 location != BubbleGtk::ARROW_LOCATION_FLOAT; | 50 location != BubbleGtk::ARROW_LOCATION_FLOAT; |
| 51 } | 51 } |
| 52 | 52 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // GtkWidget only exposes the bitmap mask interface. Use GDK to more | 171 // GtkWidget only exposes the bitmap mask interface. Use GDK to more |
| 172 // efficently mask a GdkRegion. Make sure the window is realized during | 172 // efficently mask a GdkRegion. Make sure the window is realized during |
| 173 // OnSizeAllocate, so the mask can be applied to the GdkWindow. | 173 // OnSizeAllocate, so the mask can be applied to the GdkWindow. |
| 174 gtk_widget_realize(window_); | 174 gtk_widget_realize(window_); |
| 175 | 175 |
| 176 UpdateArrowLocation(true); // Force move and reshape. | 176 UpdateArrowLocation(true); // Force move and reshape. |
| 177 StackWindow(); | 177 StackWindow(); |
| 178 | 178 |
| 179 gtk_widget_add_events(window_, GDK_BUTTON_PRESS_MASK); | 179 gtk_widget_add_events(window_, GDK_BUTTON_PRESS_MASK); |
| 180 | 180 |
| 181 signals_.Connect(window_, "expose-event", G_CALLBACK(OnExposeThunk), this); | 181 // Connect during the bubbling phase so the border is always on top. |
| 182 signals_.ConnectAfter(window_, "expose-event", |
| 183 G_CALLBACK(OnExposeThunk), this); |
| 182 signals_.Connect(window_, "size-allocate", G_CALLBACK(OnSizeAllocateThunk), | 184 signals_.Connect(window_, "size-allocate", G_CALLBACK(OnSizeAllocateThunk), |
| 183 this); | 185 this); |
| 184 signals_.Connect(window_, "button-press-event", | 186 signals_.Connect(window_, "button-press-event", |
| 185 G_CALLBACK(OnButtonPressThunk), this); | 187 G_CALLBACK(OnButtonPressThunk), this); |
| 186 signals_.Connect(window_, "destroy", G_CALLBACK(OnDestroyThunk), this); | 188 signals_.Connect(window_, "destroy", G_CALLBACK(OnDestroyThunk), this); |
| 187 signals_.Connect(window_, "hide", G_CALLBACK(OnHideThunk), this); | 189 signals_.Connect(window_, "hide", G_CALLBACK(OnHideThunk), this); |
| 188 | 190 |
| 189 // If the toplevel window is being used as the anchor, then the signals below | 191 // If the toplevel window is being used as the anchor, then the signals below |
| 190 // are enough to keep us positioned correctly. | 192 // are enough to keep us positioned correctly. |
| 191 if (anchor_widget_ != toplevel_window_) { | 193 if (anchor_widget_ != toplevel_window_) { |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 gboolean BubbleGtk::OnToplevelUnmap(GtkWidget* widget, GdkEvent* event) { | 669 gboolean BubbleGtk::OnToplevelUnmap(GtkWidget* widget, GdkEvent* event) { |
| 668 Close(); | 670 Close(); |
| 669 return FALSE; | 671 return FALSE; |
| 670 } | 672 } |
| 671 | 673 |
| 672 void BubbleGtk::OnAnchorAllocate(GtkWidget* widget, | 674 void BubbleGtk::OnAnchorAllocate(GtkWidget* widget, |
| 673 GtkAllocation* allocation) { | 675 GtkAllocation* allocation) { |
| 674 if (!UpdateArrowLocation(false)) | 676 if (!UpdateArrowLocation(false)) |
| 675 MoveWindow(); | 677 MoveWindow(); |
| 676 } | 678 } |
| OLD | NEW |