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/libgtk2ui/gtk2_ui.h" | 5 #include "chrome/browser/ui/libgtkui/gtk2_ui.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <pango/pango.h> | 8 #include <pango/pango.h> |
9 #include <X11/Xcursor/Xcursor.h> | 9 #include <X11/Xcursor/Xcursor.h> |
10 #include <set> | 10 #include <set> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/debug/leak_annotations.h" | 14 #include "base/debug/leak_annotations.h" |
15 #include "base/environment.h" | 15 #include "base/environment.h" |
16 #include "base/i18n/rtl.h" | 16 #include "base/i18n/rtl.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/nix/mime_util_xdg.h" | 19 #include "base/nix/mime_util_xdg.h" |
20 #include "base/nix/xdg_util.h" | 20 #include "base/nix/xdg_util.h" |
21 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
22 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
23 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
24 #include "chrome/browser/themes/theme_properties.h" | 24 #include "chrome/browser/themes/theme_properties.h" |
25 #include "chrome/browser/ui/libgtk2ui/app_indicator_icon.h" | 25 #include "chrome/browser/ui/libgtkui/app_indicator_icon.h" |
26 #include "chrome/browser/ui/libgtk2ui/gtk2_event_loop.h" | 26 #include "chrome/browser/ui/libgtkui/gtk2_event_loop.h" |
27 #include "chrome/browser/ui/libgtk2ui/gtk2_key_bindings_handler.h" | 27 #include "chrome/browser/ui/libgtkui/gtk2_key_bindings_handler.h" |
28 #include "chrome/browser/ui/libgtk2ui/gtk2_status_icon.h" | 28 #include "chrome/browser/ui/libgtkui/gtk2_status_icon.h" |
29 #include "chrome/browser/ui/libgtk2ui/gtk2_util.h" | 29 #include "chrome/browser/ui/libgtkui/gtk2_util.h" |
30 #include "chrome/browser/ui/libgtk2ui/native_theme_gtk2.h" | 30 #include "chrome/browser/ui/libgtkui/native_theme_gtk2.h" |
31 #include "chrome/browser/ui/libgtk2ui/print_dialog_gtk2.h" | 31 #include "chrome/browser/ui/libgtkui/print_dialog_gtk2.h" |
32 #include "chrome/browser/ui/libgtk2ui/printing_gtk2_util.h" | 32 #include "chrome/browser/ui/libgtkui/printing_gtk2_util.h" |
33 #include "chrome/browser/ui/libgtk2ui/select_file_dialog_impl.h" | 33 #include "chrome/browser/ui/libgtkui/select_file_dialog_impl.h" |
34 #include "chrome/browser/ui/libgtk2ui/skia_utils_gtk2.h" | 34 #include "chrome/browser/ui/libgtkui/skia_utils_gtk2.h" |
35 #include "chrome/browser/ui/libgtk2ui/unity_service.h" | 35 #include "chrome/browser/ui/libgtkui/unity_service.h" |
36 #include "chrome/browser/ui/libgtk2ui/x11_input_method_context_impl_gtk2.h" | 36 #include "chrome/browser/ui/libgtkui/x11_input_method_context_impl_gtk2.h" |
37 #include "chrome/grit/theme_resources.h" | 37 #include "chrome/grit/theme_resources.h" |
38 #include "components/grit/components_scaled_resources.h" | 38 #include "components/grit/components_scaled_resources.h" |
39 #include "third_party/skia/include/core/SkBitmap.h" | 39 #include "third_party/skia/include/core/SkBitmap.h" |
40 #include "third_party/skia/include/core/SkCanvas.h" | 40 #include "third_party/skia/include/core/SkCanvas.h" |
41 #include "third_party/skia/include/core/SkColor.h" | 41 #include "third_party/skia/include/core/SkColor.h" |
42 #include "third_party/skia/include/core/SkShader.h" | 42 #include "third_party/skia/include/core/SkShader.h" |
43 #include "ui/base/resource/resource_bundle.h" | 43 #include "ui/base/resource/resource_bundle.h" |
44 #include "ui/display/display.h" | 44 #include "ui/display/display.h" |
45 #include "ui/gfx/canvas.h" | 45 #include "ui/gfx/canvas.h" |
46 #include "ui/gfx/geometry/rect.h" | 46 #include "ui/gfx/geometry/rect.h" |
47 #include "ui/gfx/geometry/size.h" | 47 #include "ui/gfx/geometry/size.h" |
48 #include "ui/gfx/image/image.h" | 48 #include "ui/gfx/image/image.h" |
49 #include "ui/gfx/image/image_skia_source.h" | 49 #include "ui/gfx/image/image_skia_source.h" |
50 #include "ui/gfx/skbitmap_operations.h" | 50 #include "ui/gfx/skbitmap_operations.h" |
51 #include "ui/gfx/skia_util.h" | 51 #include "ui/gfx/skia_util.h" |
52 #include "ui/gfx/x/x11_types.h" | 52 #include "ui/gfx/x/x11_types.h" |
53 #include "ui/native_theme/native_theme.h" | 53 #include "ui/native_theme/native_theme.h" |
54 #include "ui/resources/grit/ui_resources.h" | 54 #include "ui/resources/grit/ui_resources.h" |
55 #include "ui/views/controls/button/blue_button.h" | 55 #include "ui/views/controls/button/blue_button.h" |
56 #include "ui/views/controls/button/label_button.h" | 56 #include "ui/views/controls/button/label_button.h" |
57 #include "ui/views/controls/button/label_button_border.h" | 57 #include "ui/views/controls/button/label_button_border.h" |
58 #include "ui/views/linux_ui/window_button_order_observer.h" | 58 #include "ui/views/linux_ui/window_button_order_observer.h" |
59 #include "ui/views/resources/grit/views_resources.h" | 59 #include "ui/views/resources/grit/views_resources.h" |
60 | 60 |
61 #if defined(ENABLE_BASIC_PRINTING) | 61 #if defined(ENABLE_BASIC_PRINTING) |
62 #include "printing/printing_context_linux.h" | 62 #include "printing/printing_context_linux.h" |
63 #endif | 63 #endif |
64 #if defined(USE_GCONF) | 64 #if defined(USE_GCONF) |
65 #include "chrome/browser/ui/libgtk2ui/gconf_listener.h" | 65 #include "chrome/browser/ui/libgtkui/gconf_listener.h" |
66 #endif | 66 #endif |
67 | 67 |
68 // A minimized port of GtkThemeService into something that can provide colors | 68 // A minimized port of GtkThemeService into something that can provide colors |
69 // and images for aura. | 69 // and images for aura. |
70 // | 70 // |
71 // TODO(erg): There's still a lot that needs ported or done for the first time: | 71 // TODO(erg): There's still a lot that needs ported or done for the first time: |
72 // | 72 // |
73 // - Render and inject the omnibox background. | 73 // - Render and inject the omnibox background. |
74 // - Make sure to test with a light on dark theme, too. | 74 // - Make sure to test with a light on dark theme, too. |
75 | 75 |
76 // Work around a header bug: | 76 // Work around a header bug: |
77 // linux/debian_wheezy_i386-sysroot/usr/include/linux/stddef.h redefines NULL | 77 // linux/debian_wheezy_i386-sysroot/usr/include/linux/stddef.h redefines NULL |
78 // to 0, which breaks -Wsentinel. Get back the normal definition of NULL. | 78 // to 0, which breaks -Wsentinel. Get back the normal definition of NULL. |
79 // TODO(thakis): Remove this once we update sysroots. | 79 // TODO(thakis): Remove this once we update sysroots. |
80 #define __need_NULL | 80 #define __need_NULL |
81 #include <stddef.h> | 81 #include <stddef.h> |
82 | 82 |
83 namespace libgtk2ui { | 83 namespace libgtkui { |
84 | 84 |
85 namespace { | 85 namespace { |
86 | 86 |
87 class GtkButtonImageSource : public gfx::ImageSkiaSource { | 87 class GtkButtonImageSource : public gfx::ImageSkiaSource { |
88 public: | 88 public: |
89 GtkButtonImageSource(const char* idr_string, gfx::Size size) | 89 GtkButtonImageSource(const char* idr_string, gfx::Size size) |
90 : width_(size.width()), height_(size.height()) { | 90 : width_(size.width()), height_(size.height()) { |
91 is_blue_ = !!strstr(idr_string, "IDR_BLUE"); | 91 is_blue_ = !!strstr(idr_string, "IDR_BLUE"); |
92 focus_ = !!strstr(idr_string, "_FOCUSED_"); | 92 focus_ = !!strstr(idr_string, "_FOCUSED_"); |
93 | 93 |
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1077 if (display::Display::HasForceDeviceScaleFactor()) | 1077 if (display::Display::HasForceDeviceScaleFactor()) |
1078 return display::Display::GetForcedDeviceScaleFactor(); | 1078 return display::Display::GetForcedDeviceScaleFactor(); |
1079 const int kCSSDefaultDPI = 96; | 1079 const int kCSSDefaultDPI = 96; |
1080 const float scale = GetDPI() / kCSSDefaultDPI; | 1080 const float scale = GetDPI() / kCSSDefaultDPI; |
1081 | 1081 |
1082 // Blacklist scaling factors <130% (crbug.com/484400) and round | 1082 // Blacklist scaling factors <130% (crbug.com/484400) and round |
1083 // to 1 decimal to prevent rendering problems (crbug.com/485183). | 1083 // to 1 decimal to prevent rendering problems (crbug.com/485183). |
1084 return scale < 1.3f ? 1.0f : roundf(scale * 10) / 10; | 1084 return scale < 1.3f ? 1.0f : roundf(scale * 10) / 10; |
1085 } | 1085 } |
1086 | 1086 |
1087 } // namespace libgtk2ui | 1087 } // namespace libgtkui |
1088 | 1088 |
1089 views::LinuxUI* BuildGtk2UI() { | 1089 views::LinuxUI* BuildGtk2UI() { |
1090 return new libgtk2ui::Gtk2UI; | 1090 return new libgtkui::Gtk2UI; |
1091 } | 1091 } |
OLD | NEW |