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/browser_toolbar_gtk.h" | 5 #include "chrome/browser/gtk/browser_toolbar_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 #include <X11/XF86keysym.h> | 8 #include <X11/XF86keysym.h> |
9 | 9 |
10 #include "app/gtk_dnd_util.h" | 10 #include "app/gtk_dnd_util.h" |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 GtkWidget* left; | 424 GtkWidget* left; |
425 GtkWidget* right; | 425 GtkWidget* right; |
426 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { | 426 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { |
427 left = go_->widget(); | 427 left = go_->widget(); |
428 right = star_->widget(); | 428 right = star_->widget(); |
429 } else { | 429 } else { |
430 left = star_->widget(); | 430 left = star_->widget(); |
431 right = go_->widget(); | 431 right = go_->widget(); |
432 } | 432 } |
433 | 433 |
434 // TODO(deanm): The go and star buttons probably share the same window, | 434 gint origin_x, origin_y; |
435 // so this could be optimized to only one origin request. | 435 DCHECK_EQ(left->window, right->window); |
436 gint right_x; | 436 gdk_window_get_origin(left->window, &origin_x, &origin_y); |
437 gdk_window_get_origin(right->window, &right_x, NULL); | |
438 right_x += right->allocation.x + right->allocation.width; | |
439 | 437 |
440 gint left_x, left_y; | 438 gint right_x = origin_x + right->allocation.x + right->allocation.width; |
441 gdk_window_get_origin(left->window, &left_x, &left_y); | 439 |
442 left_x += left->allocation.x; | 440 gint left_x = origin_x + left->allocation.x; |
443 left_y += left->allocation.y + left->allocation.height; // Bottom edge. | 441 |
| 442 // Bottom edge. |
| 443 gint left_y = origin_y + left->allocation.y + left->allocation.height; |
| 444 |
| 445 DCHECK_LE(left_x, right_x); |
444 | 446 |
445 return gfx::Rect(left_x + kPopupLeftRightMargin, left_y + kPopupTopMargin, | 447 return gfx::Rect(left_x + kPopupLeftRightMargin, left_y + kPopupTopMargin, |
446 right_x - left_x - (2 * kPopupLeftRightMargin), 0); | 448 right_x - left_x - (2 * kPopupLeftRightMargin), 0); |
447 } | 449 } |
448 | 450 |
449 // BrowserToolbarGtk, private -------------------------------------------------- | 451 // BrowserToolbarGtk, private -------------------------------------------------- |
450 | 452 |
451 CustomDrawButton* BrowserToolbarGtk::BuildToolbarButton( | 453 CustomDrawButton* BrowserToolbarGtk::BuildToolbarButton( |
452 int normal_id, int active_id, int highlight_id, int depressed_id, | 454 int normal_id, int active_id, int highlight_id, int depressed_id, |
453 const std::string& localized_tooltip, const char* stock_id) { | 455 const std::string& localized_tooltip, const char* stock_id) { |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 menu->PopupAsFromKeyEvent(button); | 695 menu->PopupAsFromKeyEvent(button); |
694 menu_bar_helper_.MenuStartedShowing(button, menu->widget()); | 696 menu_bar_helper_.MenuStartedShowing(button, menu->widget()); |
695 } | 697 } |
696 | 698 |
697 void BrowserToolbarGtk::PopupForButtonNextTo(GtkWidget* button, | 699 void BrowserToolbarGtk::PopupForButtonNextTo(GtkWidget* button, |
698 GtkMenuDirectionType dir) { | 700 GtkMenuDirectionType dir) { |
699 GtkWidget* other_button = button == page_menu_button_.get() ? | 701 GtkWidget* other_button = button == page_menu_button_.get() ? |
700 app_menu_button_.get() : page_menu_button_.get(); | 702 app_menu_button_.get() : page_menu_button_.get(); |
701 PopupForButton(other_button); | 703 PopupForButton(other_button); |
702 } | 704 } |
OLD | NEW |