| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/gtk_util.h" | 5 #include "chrome/browser/gtk/gtk_util.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 #include <gdk/gdkx.h> | 8 #include <gdk/gdkx.h> |
| 9 | 9 |
| 10 #include <cstdarg> | 10 #include <cstdarg> |
| 11 #include <map> | 11 #include <map> |
| 12 | 12 |
| 13 #include "app/gtk_util.h" | 13 #include "app/gtk_util.h" |
| 14 #include "app/l10n_util.h" | |
| 15 #include "app/resource_bundle.h" | 14 #include "app/resource_bundle.h" |
| 16 #include "app/x11_util.h" | 15 #include "app/x11_util.h" |
| 16 #include "base/i18n/rtl.h" |
| 17 #include "base/linux_util.h" | 17 #include "base/linux_util.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| 19 #include "chrome/browser/browser_list.h" | 19 #include "chrome/browser/browser_list.h" |
| 20 #include "chrome/browser/browser_window.h" | 20 #include "chrome/browser/browser_window.h" |
| 21 #include "chrome/browser/gtk/cairo_cached_surface.h" | 21 #include "chrome/browser/gtk/cairo_cached_surface.h" |
| 22 #include "chrome/browser/gtk/gtk_theme_provider.h" | 22 #include "chrome/browser/gtk/gtk_theme_provider.h" |
| 23 #include "chrome/common/renderer_preferences.h" | 23 #include "chrome/common/renderer_preferences.h" |
| 24 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
| 25 #include "third_party/skia/include/core/SkBitmap.h" | 25 #include "third_party/skia/include/core/SkBitmap.h" |
| 26 #include "third_party/skia/include/core/SkColor.h" | 26 #include "third_party/skia/include/core/SkColor.h" |
| (...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 G_CALLBACK(OnMouseButtonPressed), userdata); | 497 G_CALLBACK(OnMouseButtonPressed), userdata); |
| 498 g_signal_connect(button, "button-release-event", | 498 g_signal_connect(button, "button-release-event", |
| 499 G_CALLBACK(OnMouseButtonReleased), userdata); | 499 G_CALLBACK(OnMouseButtonReleased), userdata); |
| 500 } | 500 } |
| 501 | 501 |
| 502 void SetButtonTriggersNavigation(GtkWidget* button) { | 502 void SetButtonTriggersNavigation(GtkWidget* button) { |
| 503 SetButtonClickableByMouseButtons(button, true, true, false); | 503 SetButtonClickableByMouseButtons(button, true, true, false); |
| 504 } | 504 } |
| 505 | 505 |
| 506 int MirroredLeftPointForRect(GtkWidget* widget, const gfx::Rect& bounds) { | 506 int MirroredLeftPointForRect(GtkWidget* widget, const gfx::Rect& bounds) { |
| 507 if (l10n_util::GetTextDirection() != l10n_util::RIGHT_TO_LEFT) { | 507 if (base::i18n::IsRTL()) |
| 508 return bounds.x(); | 508 return bounds.x(); |
| 509 } | |
| 510 return widget->allocation.width - bounds.x() - bounds.width(); | 509 return widget->allocation.width - bounds.x() - bounds.width(); |
| 511 } | 510 } |
| 512 | 511 |
| 513 int MirroredXCoordinate(GtkWidget* widget, int x) { | 512 int MirroredXCoordinate(GtkWidget* widget, int x) { |
| 514 if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT) { | 513 if (base::i18n::IsRTL()) |
| 515 return widget->allocation.width - x; | 514 return widget->allocation.width - x; |
| 516 } | |
| 517 return x; | 515 return x; |
| 518 } | 516 } |
| 519 | 517 |
| 520 bool WidgetContainsCursor(GtkWidget* widget) { | 518 bool WidgetContainsCursor(GtkWidget* widget) { |
| 521 gint x = 0; | 519 gint x = 0; |
| 522 gint y = 0; | 520 gint y = 0; |
| 523 gtk_widget_get_pointer(widget, &x, &y); | 521 gtk_widget_get_pointer(widget, &x, &y); |
| 524 | 522 |
| 525 // To quote the gtk docs: | 523 // To quote the gtk docs: |
| 526 // | 524 // |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 NOTREACHED(); | 818 NOTREACHED(); |
| 821 return NEW_FOREGROUND_TAB; | 819 return NEW_FOREGROUND_TAB; |
| 822 } | 820 } |
| 823 | 821 |
| 824 guint state = event->button.state; | 822 guint state = event->button.state; |
| 825 gdk_event_free(event); | 823 gdk_event_free(event); |
| 826 return event_utils::DispositionFromEventFlags(state); | 824 return event_utils::DispositionFromEventFlags(state); |
| 827 } | 825 } |
| 828 | 826 |
| 829 } // namespace gtk_util | 827 } // namespace gtk_util |
| OLD | NEW |