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/libgtk2ui/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 <set> | 9 #include <set> |
10 #include <utility> | 10 #include <utility> |
11 #include <X11/Xcursor/Xcursor.h> | |
Lei Zhang
2016/07/11 22:34:56
nit: C headers above C++ headers.
Tom (Use chromium acct)
2016/07/11 22:56:29
Done.
| |
11 | 12 |
12 #include "base/command_line.h" | 13 #include "base/command_line.h" |
13 #include "base/debug/leak_annotations.h" | 14 #include "base/debug/leak_annotations.h" |
14 #include "base/environment.h" | 15 #include "base/environment.h" |
15 #include "base/i18n/rtl.h" | 16 #include "base/i18n/rtl.h" |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
17 #include "base/macros.h" | 18 #include "base/macros.h" |
18 #include "base/nix/mime_util_xdg.h" | 19 #include "base/nix/mime_util_xdg.h" |
19 #include "base/nix/xdg_util.h" | 20 #include "base/nix/xdg_util.h" |
20 #include "base/stl_util.h" | 21 #include "base/stl_util.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
42 #include "ui/base/material_design/material_design_controller.h" | 43 #include "ui/base/material_design/material_design_controller.h" |
43 #include "ui/base/resource/resource_bundle.h" | 44 #include "ui/base/resource/resource_bundle.h" |
44 #include "ui/display/display.h" | 45 #include "ui/display/display.h" |
45 #include "ui/gfx/canvas.h" | 46 #include "ui/gfx/canvas.h" |
46 #include "ui/gfx/geometry/rect.h" | 47 #include "ui/gfx/geometry/rect.h" |
47 #include "ui/gfx/geometry/size.h" | 48 #include "ui/gfx/geometry/size.h" |
48 #include "ui/gfx/image/image.h" | 49 #include "ui/gfx/image/image.h" |
49 #include "ui/gfx/image/image_skia_source.h" | 50 #include "ui/gfx/image/image_skia_source.h" |
50 #include "ui/gfx/skbitmap_operations.h" | 51 #include "ui/gfx/skbitmap_operations.h" |
51 #include "ui/gfx/skia_util.h" | 52 #include "ui/gfx/skia_util.h" |
53 #include "ui/gfx/x/x11_types.h" | |
52 #include "ui/native_theme/native_theme.h" | 54 #include "ui/native_theme/native_theme.h" |
53 #include "ui/resources/grit/ui_resources.h" | 55 #include "ui/resources/grit/ui_resources.h" |
54 #include "ui/views/controls/button/blue_button.h" | 56 #include "ui/views/controls/button/blue_button.h" |
55 #include "ui/views/controls/button/label_button.h" | 57 #include "ui/views/controls/button/label_button.h" |
56 #include "ui/views/controls/button/label_button_border.h" | 58 #include "ui/views/controls/button/label_button_border.h" |
57 #include "ui/views/linux_ui/window_button_order_observer.h" | 59 #include "ui/views/linux_ui/window_button_order_observer.h" |
58 #include "ui/views/resources/grit/views_resources.h" | 60 #include "ui/views/resources/grit/views_resources.h" |
59 | 61 |
60 #if defined(ENABLE_BASIC_PRINTING) | 62 #if defined(ENABLE_BASIC_PRINTING) |
61 #include "printing/printing_context_linux.h" | 63 #include "printing/printing_context_linux.h" |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
501 GtkSettings* settings = gtk_settings_get_default(); | 503 GtkSettings* settings = gtk_settings_get_default(); |
502 g_signal_connect_after(settings, | 504 g_signal_connect_after(settings, |
503 "notify::gtk-theme-name", | 505 "notify::gtk-theme-name", |
504 G_CALLBACK(OnThemeChanged), | 506 G_CALLBACK(OnThemeChanged), |
505 this); | 507 this); |
506 g_signal_connect_after(settings, | 508 g_signal_connect_after(settings, |
507 "notify::gtk-icon-theme-name", | 509 "notify::gtk-icon-theme-name", |
508 G_CALLBACK(OnThemeChanged), | 510 G_CALLBACK(OnThemeChanged), |
509 this); | 511 this); |
510 | 512 |
513 LoadGtkValues(); | |
511 | 514 |
512 LoadGtkValues(); | 515 LoadCursorTheme(); |
513 | 516 |
514 #if defined(ENABLE_BASIC_PRINTING) | 517 #if defined(ENABLE_BASIC_PRINTING) |
515 printing::PrintingContextLinux::SetCreatePrintDialogFunction( | 518 printing::PrintingContextLinux::SetCreatePrintDialogFunction( |
516 &PrintDialogGtk2::CreatePrintDialog); | 519 &PrintDialogGtk2::CreatePrintDialog); |
517 printing::PrintingContextLinux::SetPdfPaperSizeFunction( | 520 printing::PrintingContextLinux::SetPdfPaperSizeFunction( |
518 &GetPdfPaperSizeDeviceUnitsGtk); | 521 &GetPdfPaperSizeDeviceUnitsGtk); |
519 #endif | 522 #endif |
520 | 523 |
521 #if defined(USE_GCONF) | 524 #if defined(USE_GCONF) |
522 // We must build this after GTK gets initialized. | 525 // We must build this after GTK gets initialized. |
(...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
989 inactive_selection_fg_color_ = | 992 inactive_selection_fg_color_ = |
990 theme->GetSystemColor( | 993 theme->GetSystemColor( |
991 ui::NativeTheme::kColorId_TextfieldReadOnlyColor); | 994 ui::NativeTheme::kColorId_TextfieldReadOnlyColor); |
992 | 995 |
993 colors_[ThemeProperties::COLOR_TAB_THROBBER_SPINNING] = | 996 colors_[ThemeProperties::COLOR_TAB_THROBBER_SPINNING] = |
994 theme->GetSystemColor(ui::NativeTheme::kColorId_ThrobberSpinningColor); | 997 theme->GetSystemColor(ui::NativeTheme::kColorId_ThrobberSpinningColor); |
995 colors_[ThemeProperties::COLOR_TAB_THROBBER_WAITING] = | 998 colors_[ThemeProperties::COLOR_TAB_THROBBER_WAITING] = |
996 theme->GetSystemColor(ui::NativeTheme::kColorId_ThrobberWaitingColor); | 999 theme->GetSystemColor(ui::NativeTheme::kColorId_ThrobberWaitingColor); |
997 } | 1000 } |
998 | 1001 |
1002 void Gtk2UI::LoadCursorTheme() { | |
1003 GtkSettings* settings = gtk_settings_get_default(); | |
1004 | |
1005 gchar* theme = nullptr; | |
1006 gint size = 0; | |
1007 g_object_get(settings, | |
1008 "gtk-cursor-theme-name", &theme, | |
1009 "gtk-cursor-theme-size", &size, | |
1010 nullptr); | |
1011 XcursorSetTheme(gfx::GetXDisplay(), theme); | |
1012 XcursorSetDefaultSize(gfx::GetXDisplay(), size); | |
1013 } | |
1014 | |
999 void Gtk2UI::UpdateMaterialDesignColors() { | 1015 void Gtk2UI::UpdateMaterialDesignColors() { |
1000 // TODO(varkha): This should be merged back into LoadGtkValues() once Material | 1016 // TODO(varkha): This should be merged back into LoadGtkValues() once Material |
1001 // Design is on unconditionally. | 1017 // Design is on unconditionally. |
1002 // Early return when Material Design Controller is not initialized yet. This | 1018 // Early return when Material Design Controller is not initialized yet. This |
1003 // is harmless and the colors will get updated when this method is called | 1019 // is harmless and the colors will get updated when this method is called |
1004 // again after the initialization. See http://crbug.com/622234. | 1020 // again after the initialization. See http://crbug.com/622234. |
1005 if (!ui::MaterialDesignController::is_mode_initialized() || | 1021 if (!ui::MaterialDesignController::is_mode_initialized() || |
1006 !ui::MaterialDesignController::IsModeMaterial()) { | 1022 !ui::MaterialDesignController::IsModeMaterial()) { |
1007 return; | 1023 return; |
1008 } | 1024 } |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1411 // Blacklist scaling factors <130% (crbug.com/484400) and round | 1427 // Blacklist scaling factors <130% (crbug.com/484400) and round |
1412 // to 1 decimal to prevent rendering problems (crbug.com/485183). | 1428 // to 1 decimal to prevent rendering problems (crbug.com/485183). |
1413 return scale < 1.3f ? 1.0f : roundf(scale * 10) / 10; | 1429 return scale < 1.3f ? 1.0f : roundf(scale * 10) / 10; |
1414 } | 1430 } |
1415 | 1431 |
1416 } // namespace libgtk2ui | 1432 } // namespace libgtk2ui |
1417 | 1433 |
1418 views::LinuxUI* BuildGtk2UI() { | 1434 views::LinuxUI* BuildGtk2UI() { |
1419 return new libgtk2ui::Gtk2UI; | 1435 return new libgtk2ui::Gtk2UI; |
1420 } | 1436 } |
OLD | NEW |