| 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/libgtkui/gtk_ui.h" | 5 #include "chrome/browser/ui/libgtkui/gtk_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 | 10 |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 // Chrome, but at least avoid lowering windows in response to middle | 404 // Chrome, but at least avoid lowering windows in response to middle |
| 405 // clicks to avoid surprising users who expect the KDE behavior. | 405 // clicks to avoid surprising users who expect the KDE behavior. |
| 406 return views::LinuxUI::MIDDLE_CLICK_ACTION_NONE; | 406 return views::LinuxUI::MIDDLE_CLICK_ACTION_NONE; |
| 407 default: | 407 default: |
| 408 return views::LinuxUI::MIDDLE_CLICK_ACTION_LOWER; | 408 return views::LinuxUI::MIDDLE_CLICK_ACTION_LOWER; |
| 409 } | 409 } |
| 410 } | 410 } |
| 411 | 411 |
| 412 } // namespace | 412 } // namespace |
| 413 | 413 |
| 414 Gtk2UI::Gtk2UI() : middle_click_action_(GetDefaultMiddleClickAction()) { | 414 GtkUi::GtkUi() : middle_click_action_(GetDefaultMiddleClickAction()) { |
| 415 GtkInitFromCommandLine(*base::CommandLine::ForCurrentProcess()); | 415 GtkInitFromCommandLine(*base::CommandLine::ForCurrentProcess()); |
| 416 #if GTK_MAJOR_VERSION == 2 | 416 #if GTK_MAJOR_VERSION == 2 |
| 417 native_theme_ = NativeThemeGtk2::instance(); | 417 native_theme_ = NativeThemeGtk2::instance(); |
| 418 fake_window_ = chrome_gtk_frame_new(); | 418 fake_window_ = chrome_gtk_frame_new(); |
| 419 gtk_widget_realize(fake_window_); // Is this necessary? | 419 gtk_widget_realize(fake_window_); // Is this necessary? |
| 420 #elif GTK_MAJOR_VERSION == 3 | 420 #elif GTK_MAJOR_VERSION == 3 |
| 421 native_theme_ = NativeThemeGtk3::instance(); | 421 native_theme_ = NativeThemeGtk3::instance(); |
| 422 #else | 422 #else |
| 423 #error "Unsupported GTK version" | 423 #error "Unsupported GTK version" |
| 424 #endif | 424 #endif |
| 425 } | 425 } |
| 426 | 426 |
| 427 Gtk2UI::~Gtk2UI() { | 427 GtkUi::~GtkUi() { |
| 428 #if GTK_MAJOR_VERSION == 2 | 428 #if GTK_MAJOR_VERSION == 2 |
| 429 gtk_widget_destroy(fake_window_); | 429 gtk_widget_destroy(fake_window_); |
| 430 #endif | 430 #endif |
| 431 } | 431 } |
| 432 | 432 |
| 433 void OnThemeChanged(GObject* obj, GParamSpec* param, Gtk2UI* gtkui) { | 433 void OnThemeChanged(GObject* obj, GParamSpec* param, GtkUi* gtkui) { |
| 434 gtkui->ResetStyle(); | 434 gtkui->ResetStyle(); |
| 435 } | 435 } |
| 436 | 436 |
| 437 void Gtk2UI::Initialize() { | 437 void GtkUi::Initialize() { |
| 438 GtkSettings* settings = gtk_settings_get_default(); | 438 GtkSettings* settings = gtk_settings_get_default(); |
| 439 g_signal_connect_after(settings, "notify::gtk-theme-name", | 439 g_signal_connect_after(settings, "notify::gtk-theme-name", |
| 440 G_CALLBACK(OnThemeChanged), this); | 440 G_CALLBACK(OnThemeChanged), this); |
| 441 g_signal_connect_after(settings, "notify::gtk-icon-theme-name", | 441 g_signal_connect_after(settings, "notify::gtk-icon-theme-name", |
| 442 G_CALLBACK(OnThemeChanged), this); | 442 G_CALLBACK(OnThemeChanged), this); |
| 443 | 443 |
| 444 LoadGtkValues(); | 444 LoadGtkValues(); |
| 445 | 445 |
| 446 LoadCursorTheme(); | 446 LoadCursorTheme(); |
| 447 | 447 |
| 448 #if BUILDFLAG(ENABLE_BASIC_PRINTING) | 448 #if BUILDFLAG(ENABLE_BASIC_PRINTING) |
| 449 printing::PrintingContextLinux::SetCreatePrintDialogFunction( | 449 printing::PrintingContextLinux::SetCreatePrintDialogFunction( |
| 450 &PrintDialogGtk2::CreatePrintDialog); | 450 &PrintDialogGtk2::CreatePrintDialog); |
| 451 printing::PrintingContextLinux::SetPdfPaperSizeFunction( | 451 printing::PrintingContextLinux::SetPdfPaperSizeFunction( |
| 452 &GetPdfPaperSizeDeviceUnitsGtk); | 452 &GetPdfPaperSizeDeviceUnitsGtk); |
| 453 #endif | 453 #endif |
| 454 | 454 |
| 455 #if defined(USE_GCONF) | 455 #if defined(USE_GCONF) |
| 456 // We must build this after GTK gets initialized. | 456 // We must build this after GTK gets initialized. |
| 457 gconf_listener_.reset(new GConfListener(this)); | 457 gconf_listener_.reset(new GConfListener(this)); |
| 458 #endif // defined(USE_GCONF) | 458 #endif // defined(USE_GCONF) |
| 459 | 459 |
| 460 indicators_count = 0; | 460 indicators_count = 0; |
| 461 | 461 |
| 462 // Instantiate the singleton instance of Gtk2EventLoop. | 462 // Instantiate the singleton instance of Gtk2EventLoop. |
| 463 Gtk2EventLoop::GetInstance(); | 463 Gtk2EventLoop::GetInstance(); |
| 464 } | 464 } |
| 465 | 465 |
| 466 bool Gtk2UI::GetTint(int id, color_utils::HSL* tint) const { | 466 bool GtkUi::GetTint(int id, color_utils::HSL* tint) const { |
| 467 switch (id) { | 467 switch (id) { |
| 468 // Tints for which the cross-platform default is fine. Before adding new | 468 // Tints for which the cross-platform default is fine. Before adding new |
| 469 // values here, specifically verify they work well on Linux. | 469 // values here, specifically verify they work well on Linux. |
| 470 case ThemeProperties::TINT_BACKGROUND_TAB: | 470 case ThemeProperties::TINT_BACKGROUND_TAB: |
| 471 // TODO(estade): Return something useful for TINT_BUTTONS so that chrome:// | 471 // TODO(estade): Return something useful for TINT_BUTTONS so that chrome:// |
| 472 // page icons are colored appropriately. | 472 // page icons are colored appropriately. |
| 473 case ThemeProperties::TINT_BUTTONS: | 473 case ThemeProperties::TINT_BUTTONS: |
| 474 break; | 474 break; |
| 475 default: | 475 default: |
| 476 // Assume any tints not specifically verified on Linux aren't usable. | 476 // Assume any tints not specifically verified on Linux aren't usable. |
| 477 // TODO(pkasting): Try to remove values from |colors_| that could just be | 477 // TODO(pkasting): Try to remove values from |colors_| that could just be |
| 478 // added to the group above instead. | 478 // added to the group above instead. |
| 479 NOTREACHED(); | 479 NOTREACHED(); |
| 480 } | 480 } |
| 481 return false; | 481 return false; |
| 482 } | 482 } |
| 483 | 483 |
| 484 bool Gtk2UI::GetColor(int id, SkColor* color) const { | 484 bool GtkUi::GetColor(int id, SkColor* color) const { |
| 485 ColorMap::const_iterator it = colors_.find(id); | 485 ColorMap::const_iterator it = colors_.find(id); |
| 486 if (it != colors_.end()) { | 486 if (it != colors_.end()) { |
| 487 *color = it->second; | 487 *color = it->second; |
| 488 return true; | 488 return true; |
| 489 } | 489 } |
| 490 | 490 |
| 491 return false; | 491 return false; |
| 492 } | 492 } |
| 493 | 493 |
| 494 SkColor Gtk2UI::GetFocusRingColor() const { | 494 SkColor GtkUi::GetFocusRingColor() const { |
| 495 return focus_ring_color_; | 495 return focus_ring_color_; |
| 496 } | 496 } |
| 497 | 497 |
| 498 SkColor Gtk2UI::GetThumbActiveColor() const { | 498 SkColor GtkUi::GetThumbActiveColor() const { |
| 499 return thumb_active_color_; | 499 return thumb_active_color_; |
| 500 } | 500 } |
| 501 | 501 |
| 502 SkColor Gtk2UI::GetThumbInactiveColor() const { | 502 SkColor GtkUi::GetThumbInactiveColor() const { |
| 503 return thumb_inactive_color_; | 503 return thumb_inactive_color_; |
| 504 } | 504 } |
| 505 | 505 |
| 506 SkColor Gtk2UI::GetTrackColor() const { | 506 SkColor GtkUi::GetTrackColor() const { |
| 507 return track_color_; | 507 return track_color_; |
| 508 } | 508 } |
| 509 | 509 |
| 510 SkColor Gtk2UI::GetActiveSelectionBgColor() const { | 510 SkColor GtkUi::GetActiveSelectionBgColor() const { |
| 511 return active_selection_bg_color_; | 511 return active_selection_bg_color_; |
| 512 } | 512 } |
| 513 | 513 |
| 514 SkColor Gtk2UI::GetActiveSelectionFgColor() const { | 514 SkColor GtkUi::GetActiveSelectionFgColor() const { |
| 515 return active_selection_fg_color_; | 515 return active_selection_fg_color_; |
| 516 } | 516 } |
| 517 | 517 |
| 518 SkColor Gtk2UI::GetInactiveSelectionBgColor() const { | 518 SkColor GtkUi::GetInactiveSelectionBgColor() const { |
| 519 return inactive_selection_bg_color_; | 519 return inactive_selection_bg_color_; |
| 520 } | 520 } |
| 521 | 521 |
| 522 SkColor Gtk2UI::GetInactiveSelectionFgColor() const { | 522 SkColor GtkUi::GetInactiveSelectionFgColor() const { |
| 523 return inactive_selection_fg_color_; | 523 return inactive_selection_fg_color_; |
| 524 } | 524 } |
| 525 | 525 |
| 526 double Gtk2UI::GetCursorBlinkInterval() const { | 526 double GtkUi::GetCursorBlinkInterval() const { |
| 527 // From http://library.gnome.org/devel/gtk/unstable/GtkSettings.html, this is | 527 // From http://library.gnome.org/devel/gtk/unstable/GtkSettings.html, this is |
| 528 // the default value for gtk-cursor-blink-time. | 528 // the default value for gtk-cursor-blink-time. |
| 529 static const gint kGtkDefaultCursorBlinkTime = 1200; | 529 static const gint kGtkDefaultCursorBlinkTime = 1200; |
| 530 | 530 |
| 531 // Dividing GTK's cursor blink cycle time (in milliseconds) by this value | 531 // Dividing GTK's cursor blink cycle time (in milliseconds) by this value |
| 532 // yields an appropriate value for | 532 // yields an appropriate value for |
| 533 // content::RendererPreferences::caret_blink_interval. This matches the | 533 // content::RendererPreferences::caret_blink_interval. This matches the |
| 534 // logic in the WebKit GTK port. | 534 // logic in the WebKit GTK port. |
| 535 static const double kGtkCursorBlinkCycleFactor = 2000.0; | 535 static const double kGtkCursorBlinkCycleFactor = 2000.0; |
| 536 | 536 |
| 537 gint cursor_blink_time = kGtkDefaultCursorBlinkTime; | 537 gint cursor_blink_time = kGtkDefaultCursorBlinkTime; |
| 538 gboolean cursor_blink = TRUE; | 538 gboolean cursor_blink = TRUE; |
| 539 g_object_get(gtk_settings_get_default(), "gtk-cursor-blink-time", | 539 g_object_get(gtk_settings_get_default(), "gtk-cursor-blink-time", |
| 540 &cursor_blink_time, "gtk-cursor-blink", &cursor_blink, NULL); | 540 &cursor_blink_time, "gtk-cursor-blink", &cursor_blink, NULL); |
| 541 return cursor_blink ? (cursor_blink_time / kGtkCursorBlinkCycleFactor) : 0.0; | 541 return cursor_blink ? (cursor_blink_time / kGtkCursorBlinkCycleFactor) : 0.0; |
| 542 } | 542 } |
| 543 | 543 |
| 544 ui::NativeTheme* Gtk2UI::GetNativeTheme(aura::Window* window) const { | 544 ui::NativeTheme* GtkUi::GetNativeTheme(aura::Window* window) const { |
| 545 ui::NativeTheme* native_theme_override = NULL; | 545 ui::NativeTheme* native_theme_override = NULL; |
| 546 if (!native_theme_overrider_.is_null()) | 546 if (!native_theme_overrider_.is_null()) |
| 547 native_theme_override = native_theme_overrider_.Run(window); | 547 native_theme_override = native_theme_overrider_.Run(window); |
| 548 | 548 |
| 549 if (native_theme_override) | 549 if (native_theme_override) |
| 550 return native_theme_override; | 550 return native_theme_override; |
| 551 | 551 |
| 552 return native_theme_; | 552 return native_theme_; |
| 553 } | 553 } |
| 554 | 554 |
| 555 void Gtk2UI::SetNativeThemeOverride(const NativeThemeGetter& callback) { | 555 void GtkUi::SetNativeThemeOverride(const NativeThemeGetter& callback) { |
| 556 native_theme_overrider_ = callback; | 556 native_theme_overrider_ = callback; |
| 557 } | 557 } |
| 558 | 558 |
| 559 bool Gtk2UI::GetDefaultUsesSystemTheme() const { | 559 bool GtkUi::GetDefaultUsesSystemTheme() const { |
| 560 std::unique_ptr<base::Environment> env(base::Environment::Create()); | 560 std::unique_ptr<base::Environment> env(base::Environment::Create()); |
| 561 | 561 |
| 562 switch (base::nix::GetDesktopEnvironment(env.get())) { | 562 switch (base::nix::GetDesktopEnvironment(env.get())) { |
| 563 case base::nix::DESKTOP_ENVIRONMENT_GNOME: | 563 case base::nix::DESKTOP_ENVIRONMENT_GNOME: |
| 564 case base::nix::DESKTOP_ENVIRONMENT_UNITY: | 564 case base::nix::DESKTOP_ENVIRONMENT_UNITY: |
| 565 case base::nix::DESKTOP_ENVIRONMENT_XFCE: | 565 case base::nix::DESKTOP_ENVIRONMENT_XFCE: |
| 566 return true; | 566 return true; |
| 567 case base::nix::DESKTOP_ENVIRONMENT_KDE3: | 567 case base::nix::DESKTOP_ENVIRONMENT_KDE3: |
| 568 case base::nix::DESKTOP_ENVIRONMENT_KDE4: | 568 case base::nix::DESKTOP_ENVIRONMENT_KDE4: |
| 569 case base::nix::DESKTOP_ENVIRONMENT_KDE5: | 569 case base::nix::DESKTOP_ENVIRONMENT_KDE5: |
| 570 case base::nix::DESKTOP_ENVIRONMENT_OTHER: | 570 case base::nix::DESKTOP_ENVIRONMENT_OTHER: |
| 571 return false; | 571 return false; |
| 572 } | 572 } |
| 573 // Unless GetDesktopEnvironment() badly misbehaves, this should never happen. | 573 // Unless GetDesktopEnvironment() badly misbehaves, this should never happen. |
| 574 NOTREACHED(); | 574 NOTREACHED(); |
| 575 return false; | 575 return false; |
| 576 } | 576 } |
| 577 | 577 |
| 578 void Gtk2UI::SetDownloadCount(int count) const { | 578 void GtkUi::SetDownloadCount(int count) const { |
| 579 if (unity::IsRunning()) | 579 if (unity::IsRunning()) |
| 580 unity::SetDownloadCount(count); | 580 unity::SetDownloadCount(count); |
| 581 } | 581 } |
| 582 | 582 |
| 583 void Gtk2UI::SetProgressFraction(float percentage) const { | 583 void GtkUi::SetProgressFraction(float percentage) const { |
| 584 if (unity::IsRunning()) | 584 if (unity::IsRunning()) |
| 585 unity::SetProgressFraction(percentage); | 585 unity::SetProgressFraction(percentage); |
| 586 } | 586 } |
| 587 | 587 |
| 588 bool Gtk2UI::IsStatusIconSupported() const { | 588 bool GtkUi::IsStatusIconSupported() const { |
| 589 return true; | 589 return true; |
| 590 } | 590 } |
| 591 | 591 |
| 592 std::unique_ptr<views::StatusIconLinux> Gtk2UI::CreateLinuxStatusIcon( | 592 std::unique_ptr<views::StatusIconLinux> GtkUi::CreateLinuxStatusIcon( |
| 593 const gfx::ImageSkia& image, | 593 const gfx::ImageSkia& image, |
| 594 const base::string16& tool_tip) const { | 594 const base::string16& tool_tip) const { |
| 595 if (AppIndicatorIcon::CouldOpen()) { | 595 if (AppIndicatorIcon::CouldOpen()) { |
| 596 ++indicators_count; | 596 ++indicators_count; |
| 597 return std::unique_ptr<views::StatusIconLinux>(new AppIndicatorIcon( | 597 return std::unique_ptr<views::StatusIconLinux>(new AppIndicatorIcon( |
| 598 base::StringPrintf("%s%d", kAppIndicatorIdPrefix, indicators_count), | 598 base::StringPrintf("%s%d", kAppIndicatorIdPrefix, indicators_count), |
| 599 image, tool_tip)); | 599 image, tool_tip)); |
| 600 } else { | 600 } else { |
| 601 return std::unique_ptr<views::StatusIconLinux>( | 601 return std::unique_ptr<views::StatusIconLinux>( |
| 602 new Gtk2StatusIcon(image, tool_tip)); | 602 new Gtk2StatusIcon(image, tool_tip)); |
| 603 } | 603 } |
| 604 } | 604 } |
| 605 | 605 |
| 606 gfx::Image Gtk2UI::GetIconForContentType(const std::string& content_type, | 606 gfx::Image GtkUi::GetIconForContentType(const std::string& content_type, |
| 607 int size) const { | 607 int size) const { |
| 608 // This call doesn't take a reference. | 608 // This call doesn't take a reference. |
| 609 GtkIconTheme* theme = gtk_icon_theme_get_default(); | 609 GtkIconTheme* theme = gtk_icon_theme_get_default(); |
| 610 | 610 |
| 611 std::string content_types[] = {content_type, kUnknownContentType}; | 611 std::string content_types[] = {content_type, kUnknownContentType}; |
| 612 | 612 |
| 613 for (size_t i = 0; i < arraysize(content_types); ++i) { | 613 for (size_t i = 0; i < arraysize(content_types); ++i) { |
| 614 ScopedGIcon icon(g_content_type_get_icon(content_types[i].c_str())); | 614 ScopedGIcon icon(g_content_type_get_icon(content_types[i].c_str())); |
| 615 ScopedGtkIconInfo icon_info(gtk_icon_theme_lookup_by_gicon( | 615 ScopedGtkIconInfo icon_info(gtk_icon_theme_lookup_by_gicon( |
| 616 theme, icon.get(), size, | 616 theme, icon.get(), size, |
| 617 static_cast<GtkIconLookupFlags>(GTK_ICON_LOOKUP_FORCE_SIZE))); | 617 static_cast<GtkIconLookupFlags>(GTK_ICON_LOOKUP_FORCE_SIZE))); |
| 618 if (!icon_info) | 618 if (!icon_info) |
| 619 continue; | 619 continue; |
| 620 ScopedGdkPixbuf pixbuf(gtk_icon_info_load_icon(icon_info.get(), NULL)); | 620 ScopedGdkPixbuf pixbuf(gtk_icon_info_load_icon(icon_info.get(), NULL)); |
| 621 if (!pixbuf) | 621 if (!pixbuf) |
| 622 continue; | 622 continue; |
| 623 | 623 |
| 624 SkBitmap bitmap = GdkPixbufToImageSkia(pixbuf.get()); | 624 SkBitmap bitmap = GdkPixbufToImageSkia(pixbuf.get()); |
| 625 DCHECK_EQ(size, bitmap.width()); | 625 DCHECK_EQ(size, bitmap.width()); |
| 626 DCHECK_EQ(size, bitmap.height()); | 626 DCHECK_EQ(size, bitmap.height()); |
| 627 gfx::ImageSkia image_skia = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); | 627 gfx::ImageSkia image_skia = gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
| 628 image_skia.MakeThreadSafe(); | 628 image_skia.MakeThreadSafe(); |
| 629 return gfx::Image(image_skia); | 629 return gfx::Image(image_skia); |
| 630 } | 630 } |
| 631 return gfx::Image(); | 631 return gfx::Image(); |
| 632 } | 632 } |
| 633 | 633 |
| 634 std::unique_ptr<views::Border> Gtk2UI::CreateNativeBorder( | 634 std::unique_ptr<views::Border> GtkUi::CreateNativeBorder( |
| 635 views::LabelButton* owning_button, | 635 views::LabelButton* owning_button, |
| 636 std::unique_ptr<views::LabelButtonBorder> border) { | 636 std::unique_ptr<views::LabelButtonBorder> border) { |
| 637 if (owning_button->GetNativeTheme() != native_theme_) | 637 if (owning_button->GetNativeTheme() != native_theme_) |
| 638 return std::move(border); | 638 return std::move(border); |
| 639 | 639 |
| 640 std::unique_ptr<views::LabelButtonAssetBorder> gtk_border( | 640 std::unique_ptr<views::LabelButtonAssetBorder> gtk_border( |
| 641 new views::LabelButtonAssetBorder(owning_button->style())); | 641 new views::LabelButtonAssetBorder(owning_button->style())); |
| 642 | 642 |
| 643 gtk_border->set_insets(border->GetInsets()); | 643 gtk_border->set_insets(border->GetInsets()); |
| 644 | 644 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 std::string idr = is_blue ? paintstate[i].idr_blue : paintstate[i].idr; | 693 std::string idr = is_blue ? paintstate[i].idr_blue : paintstate[i].idr; |
| 694 painter = new GtkButtonPainter(idr); | 694 painter = new GtkButtonPainter(idr); |
| 695 } | 695 } |
| 696 | 696 |
| 697 gtk_border->SetPainter(paintstate[i].focus, paintstate[i].state, painter); | 697 gtk_border->SetPainter(paintstate[i].focus, paintstate[i].state, painter); |
| 698 } | 698 } |
| 699 | 699 |
| 700 return std::move(gtk_border); | 700 return std::move(gtk_border); |
| 701 } | 701 } |
| 702 | 702 |
| 703 void Gtk2UI::AddWindowButtonOrderObserver( | 703 void GtkUi::AddWindowButtonOrderObserver( |
| 704 views::WindowButtonOrderObserver* observer) { | 704 views::WindowButtonOrderObserver* observer) { |
| 705 if (!leading_buttons_.empty() || !trailing_buttons_.empty()) { | 705 if (!leading_buttons_.empty() || !trailing_buttons_.empty()) { |
| 706 observer->OnWindowButtonOrderingChange(leading_buttons_, trailing_buttons_); | 706 observer->OnWindowButtonOrderingChange(leading_buttons_, trailing_buttons_); |
| 707 } | 707 } |
| 708 | 708 |
| 709 observer_list_.AddObserver(observer); | 709 observer_list_.AddObserver(observer); |
| 710 } | 710 } |
| 711 | 711 |
| 712 void Gtk2UI::RemoveWindowButtonOrderObserver( | 712 void GtkUi::RemoveWindowButtonOrderObserver( |
| 713 views::WindowButtonOrderObserver* observer) { | 713 views::WindowButtonOrderObserver* observer) { |
| 714 observer_list_.RemoveObserver(observer); | 714 observer_list_.RemoveObserver(observer); |
| 715 } | 715 } |
| 716 | 716 |
| 717 void Gtk2UI::SetWindowButtonOrdering( | 717 void GtkUi::SetWindowButtonOrdering( |
| 718 const std::vector<views::FrameButton>& leading_buttons, | 718 const std::vector<views::FrameButton>& leading_buttons, |
| 719 const std::vector<views::FrameButton>& trailing_buttons) { | 719 const std::vector<views::FrameButton>& trailing_buttons) { |
| 720 leading_buttons_ = leading_buttons; | 720 leading_buttons_ = leading_buttons; |
| 721 trailing_buttons_ = trailing_buttons; | 721 trailing_buttons_ = trailing_buttons; |
| 722 | 722 |
| 723 for (views::WindowButtonOrderObserver& observer : observer_list_) | 723 for (views::WindowButtonOrderObserver& observer : observer_list_) |
| 724 observer.OnWindowButtonOrderingChange(leading_buttons_, trailing_buttons_); | 724 observer.OnWindowButtonOrderingChange(leading_buttons_, trailing_buttons_); |
| 725 } | 725 } |
| 726 | 726 |
| 727 void Gtk2UI::SetNonClientMiddleClickAction(NonClientMiddleClickAction action) { | 727 void GtkUi::SetNonClientMiddleClickAction(NonClientMiddleClickAction action) { |
| 728 middle_click_action_ = action; | 728 middle_click_action_ = action; |
| 729 } | 729 } |
| 730 | 730 |
| 731 std::unique_ptr<ui::LinuxInputMethodContext> Gtk2UI::CreateInputMethodContext( | 731 std::unique_ptr<ui::LinuxInputMethodContext> GtkUi::CreateInputMethodContext( |
| 732 ui::LinuxInputMethodContextDelegate* delegate, | 732 ui::LinuxInputMethodContextDelegate* delegate, |
| 733 bool is_simple) const { | 733 bool is_simple) const { |
| 734 return std::unique_ptr<ui::LinuxInputMethodContext>( | 734 return std::unique_ptr<ui::LinuxInputMethodContext>( |
| 735 new X11InputMethodContextImplGtk2(delegate, is_simple)); | 735 new X11InputMethodContextImplGtk2(delegate, is_simple)); |
| 736 } | 736 } |
| 737 | 737 |
| 738 gfx::FontRenderParams Gtk2UI::GetDefaultFontRenderParams() const { | 738 gfx::FontRenderParams GtkUi::GetDefaultFontRenderParams() const { |
| 739 static gfx::FontRenderParams params = GetGtkFontRenderParams(); | 739 static gfx::FontRenderParams params = GetGtkFontRenderParams(); |
| 740 return params; | 740 return params; |
| 741 } | 741 } |
| 742 | 742 |
| 743 void Gtk2UI::GetDefaultFontDescription( | 743 void GtkUi::GetDefaultFontDescription(std::string* family_out, |
| 744 std::string* family_out, | 744 int* size_pixels_out, |
| 745 int* size_pixels_out, | 745 int* style_out, |
| 746 int* style_out, | 746 gfx::Font::Weight* weight_out, |
| 747 gfx::Font::Weight* weight_out, | 747 gfx::FontRenderParams* params_out) const { |
| 748 gfx::FontRenderParams* params_out) const { | |
| 749 *family_out = default_font_family_; | 748 *family_out = default_font_family_; |
| 750 *size_pixels_out = default_font_size_pixels_; | 749 *size_pixels_out = default_font_size_pixels_; |
| 751 *style_out = default_font_style_; | 750 *style_out = default_font_style_; |
| 752 *weight_out = default_font_weight_; | 751 *weight_out = default_font_weight_; |
| 753 *params_out = default_font_render_params_; | 752 *params_out = default_font_render_params_; |
| 754 } | 753 } |
| 755 | 754 |
| 756 ui::SelectFileDialog* Gtk2UI::CreateSelectFileDialog( | 755 ui::SelectFileDialog* GtkUi::CreateSelectFileDialog( |
| 757 ui::SelectFileDialog::Listener* listener, | 756 ui::SelectFileDialog::Listener* listener, |
| 758 ui::SelectFilePolicy* policy) const { | 757 ui::SelectFilePolicy* policy) const { |
| 759 return SelectFileDialogImpl::Create(listener, policy); | 758 return SelectFileDialogImpl::Create(listener, policy); |
| 760 } | 759 } |
| 761 | 760 |
| 762 bool Gtk2UI::UnityIsRunning() { | 761 bool GtkUi::UnityIsRunning() { |
| 763 return unity::IsRunning(); | 762 return unity::IsRunning(); |
| 764 } | 763 } |
| 765 | 764 |
| 766 views::LinuxUI::NonClientMiddleClickAction | 765 views::LinuxUI::NonClientMiddleClickAction |
| 767 Gtk2UI::GetNonClientMiddleClickAction() { | 766 GtkUi::GetNonClientMiddleClickAction() { |
| 768 return middle_click_action_; | 767 return middle_click_action_; |
| 769 } | 768 } |
| 770 | 769 |
| 771 void Gtk2UI::NotifyWindowManagerStartupComplete() { | 770 void GtkUi::NotifyWindowManagerStartupComplete() { |
| 772 // TODO(port) Implement this using _NET_STARTUP_INFO_BEGIN/_NET_STARTUP_INFO | 771 // TODO(port) Implement this using _NET_STARTUP_INFO_BEGIN/_NET_STARTUP_INFO |
| 773 // from http://standards.freedesktop.org/startup-notification-spec/ instead. | 772 // from http://standards.freedesktop.org/startup-notification-spec/ instead. |
| 774 gdk_notify_startup_complete(); | 773 gdk_notify_startup_complete(); |
| 775 } | 774 } |
| 776 | 775 |
| 777 bool Gtk2UI::MatchEvent(const ui::Event& event, | 776 bool GtkUi::MatchEvent(const ui::Event& event, |
| 778 std::vector<ui::TextEditCommandAuraLinux>* commands) { | 777 std::vector<ui::TextEditCommandAuraLinux>* commands) { |
| 779 // Ensure that we have a keyboard handler. | 778 // Ensure that we have a keyboard handler. |
| 780 if (!key_bindings_handler_) | 779 if (!key_bindings_handler_) |
| 781 key_bindings_handler_.reset(new Gtk2KeyBindingsHandler); | 780 key_bindings_handler_.reset(new Gtk2KeyBindingsHandler); |
| 782 | 781 |
| 783 return key_bindings_handler_->MatchEvent(event, commands); | 782 return key_bindings_handler_->MatchEvent(event, commands); |
| 784 } | 783 } |
| 785 | 784 |
| 786 void Gtk2UI::SetScrollbarColors() { | 785 void GtkUi::SetScrollbarColors() { |
| 787 thumb_active_color_ = SkColorSetRGB(244, 244, 244); | 786 thumb_active_color_ = SkColorSetRGB(244, 244, 244); |
| 788 thumb_inactive_color_ = SkColorSetRGB(234, 234, 234); | 787 thumb_inactive_color_ = SkColorSetRGB(234, 234, 234); |
| 789 track_color_ = SkColorSetRGB(211, 211, 211); | 788 track_color_ = SkColorSetRGB(211, 211, 211); |
| 790 | 789 |
| 791 GetChromeStyleColor("scrollbar-slider-prelight-color", &thumb_active_color_); | 790 GetChromeStyleColor("scrollbar-slider-prelight-color", &thumb_active_color_); |
| 792 GetChromeStyleColor("scrollbar-slider-normal-color", &thumb_inactive_color_); | 791 GetChromeStyleColor("scrollbar-slider-normal-color", &thumb_inactive_color_); |
| 793 GetChromeStyleColor("scrollbar-trough-color", &track_color_); | 792 GetChromeStyleColor("scrollbar-trough-color", &track_color_); |
| 794 } | 793 } |
| 795 | 794 |
| 796 void Gtk2UI::LoadGtkValues() { | 795 void GtkUi::LoadGtkValues() { |
| 797 // TODO(erg): GtkThemeService had a comment here about having to muck with | 796 // TODO(erg): GtkThemeService had a comment here about having to muck with |
| 798 // the raw Prefs object to remove prefs::kCurrentThemeImages or else we'd | 797 // the raw Prefs object to remove prefs::kCurrentThemeImages or else we'd |
| 799 // regress startup time. Figure out how to do that when we can't access the | 798 // regress startup time. Figure out how to do that when we can't access the |
| 800 // prefs system from here. | 799 // prefs system from here. |
| 801 | 800 |
| 802 SkColor toolbar_color = | 801 SkColor toolbar_color = |
| 803 native_theme_->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); | 802 native_theme_->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); |
| 804 SkColor label_color = native_theme_->GetSystemColor( | 803 SkColor label_color = native_theme_->GetSystemColor( |
| 805 ui::NativeTheme::kColorId_LabelEnabledColor); | 804 ui::NativeTheme::kColorId_LabelEnabledColor); |
| 806 | 805 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 native_theme_->GetSystemColor( | 877 native_theme_->GetSystemColor( |
| 879 ui::NativeTheme::kColorId_ThrobberWaitingColor); | 878 ui::NativeTheme::kColorId_ThrobberWaitingColor); |
| 880 | 879 |
| 881 #if GTK_MAJOR_VERSION > 2 | 880 #if GTK_MAJOR_VERSION > 2 |
| 882 colors_[ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR] = | 881 colors_[ThemeProperties::COLOR_TOOLBAR_BOTTOM_SEPARATOR] = |
| 883 colors_[ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_SEPARATOR] = | 882 colors_[ThemeProperties::COLOR_DETACHED_BOOKMARK_BAR_SEPARATOR] = |
| 884 GetBorderColor("GtkToolbar.primary-toolbar.toolbar"); | 883 GetBorderColor("GtkToolbar.primary-toolbar.toolbar"); |
| 885 #endif | 884 #endif |
| 886 } | 885 } |
| 887 | 886 |
| 888 void Gtk2UI::LoadCursorTheme() { | 887 void GtkUi::LoadCursorTheme() { |
| 889 GtkSettings* settings = gtk_settings_get_default(); | 888 GtkSettings* settings = gtk_settings_get_default(); |
| 890 | 889 |
| 891 gchar* theme = nullptr; | 890 gchar* theme = nullptr; |
| 892 gint size = 0; | 891 gint size = 0; |
| 893 g_object_get(settings, "gtk-cursor-theme-name", &theme, | 892 g_object_get(settings, "gtk-cursor-theme-name", &theme, |
| 894 "gtk-cursor-theme-size", &size, nullptr); | 893 "gtk-cursor-theme-size", &size, nullptr); |
| 895 | 894 |
| 896 if (theme) | 895 if (theme) |
| 897 XcursorSetTheme(gfx::GetXDisplay(), theme); | 896 XcursorSetTheme(gfx::GetXDisplay(), theme); |
| 898 if (size) | 897 if (size) |
| 899 XcursorSetDefaultSize(gfx::GetXDisplay(), size); | 898 XcursorSetDefaultSize(gfx::GetXDisplay(), size); |
| 900 | 899 |
| 901 g_free(theme); | 900 g_free(theme); |
| 902 } | 901 } |
| 903 | 902 |
| 904 void Gtk2UI::BuildFrameColors() { | 903 void GtkUi::BuildFrameColors() { |
| 905 #if GTK_MAJOR_VERSION == 2 | 904 #if GTK_MAJOR_VERSION == 2 |
| 906 color_utils::HSL kDefaultFrameShift = {-1, -1, 0.4}; | 905 color_utils::HSL kDefaultFrameShift = {-1, -1, 0.4}; |
| 907 SkColor frame_color = | 906 SkColor frame_color = |
| 908 native_theme_->GetSystemColor(ui::NativeTheme::kColorId_WindowBackground); | 907 native_theme_->GetSystemColor(ui::NativeTheme::kColorId_WindowBackground); |
| 909 frame_color = color_utils::HSLShift(frame_color, kDefaultFrameShift); | 908 frame_color = color_utils::HSLShift(frame_color, kDefaultFrameShift); |
| 910 GetChromeStyleColor("frame-color", &frame_color); | 909 GetChromeStyleColor("frame-color", &frame_color); |
| 911 colors_[ThemeProperties::COLOR_FRAME] = frame_color; | 910 colors_[ThemeProperties::COLOR_FRAME] = frame_color; |
| 912 | 911 |
| 913 GtkStyle* style = gtk_rc_get_style(fake_window_); | 912 GtkStyle* style = gtk_rc_get_style(fake_window_); |
| 914 SkColor temp_color = color_utils::HSLShift( | 913 SkColor temp_color = color_utils::HSLShift( |
| 915 GdkColorToSkColor(style->bg[GTK_STATE_INSENSITIVE]), kDefaultFrameShift); | 914 GdkColorToSkColor(style->bg[GTK_STATE_INSENSITIVE]), kDefaultFrameShift); |
| 916 GetChromeStyleColor("inactive-frame-color", &temp_color); | 915 GetChromeStyleColor("inactive-frame-color", &temp_color); |
| 917 colors_[ThemeProperties::COLOR_FRAME_INACTIVE] = temp_color; | 916 colors_[ThemeProperties::COLOR_FRAME_INACTIVE] = temp_color; |
| 918 | 917 |
| 919 temp_color = color_utils::HSLShift(frame_color, kDefaultTintFrameIncognito); | 918 temp_color = color_utils::HSLShift(frame_color, kDefaultTintFrameIncognito); |
| 920 GetChromeStyleColor("incognito-frame-color", &temp_color); | 919 GetChromeStyleColor("incognito-frame-color", &temp_color); |
| 921 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO] = temp_color; | 920 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO] = temp_color; |
| 922 | 921 |
| 923 temp_color = | 922 temp_color = |
| 924 color_utils::HSLShift(frame_color, kDefaultTintFrameIncognitoInactive); | 923 color_utils::HSLShift(frame_color, kDefaultTintFrameIncognitoInactive); |
| 925 GetChromeStyleColor("incognito-inactive-frame-color", &temp_color); | 924 GetChromeStyleColor("incognito-inactive-frame-color", &temp_color); |
| 926 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE] = temp_color; | 925 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE] = temp_color; |
| 927 #else | 926 #else |
| 928 // TODO(thomasanderson): Render a GtkHeaderBar directly. | 927 // TODO(thomasanderson): Render a GtkHeaderBar directly. |
| 929 SkColor color_frame = GetBGColor(".headerbar.header-bar.titlebar"); | 928 SkColor color_frame = GetBgColor(".headerbar.header-bar.titlebar"); |
| 930 SkColor color_frame_inactive = | 929 SkColor color_frame_inactive = |
| 931 GetBGColor(".headerbar.header-bar.titlebar:backdrop"); | 930 GetBgColor(".headerbar.header-bar.titlebar:backdrop"); |
| 932 colors_[ThemeProperties::COLOR_FRAME] = color_frame; | 931 colors_[ThemeProperties::COLOR_FRAME] = color_frame; |
| 933 colors_[ThemeProperties::COLOR_FRAME_INACTIVE] = color_frame_inactive; | 932 colors_[ThemeProperties::COLOR_FRAME_INACTIVE] = color_frame_inactive; |
| 934 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO] = | 933 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO] = |
| 935 color_utils::HSLShift(color_frame, kDefaultTintFrameIncognito); | 934 color_utils::HSLShift(color_frame, kDefaultTintFrameIncognito); |
| 936 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE] = | 935 colors_[ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE] = |
| 937 color_utils::HSLShift(color_frame_inactive, kDefaultTintFrameIncognito); | 936 color_utils::HSLShift(color_frame_inactive, kDefaultTintFrameIncognito); |
| 938 #endif | 937 #endif |
| 939 } | 938 } |
| 940 | 939 |
| 941 void Gtk2UI::GetNormalButtonTintHSL(color_utils::HSL* tint) const { | 940 void GtkUi::GetNormalButtonTintHSL(color_utils::HSL* tint) const { |
| 942 SkColor accent_color = native_theme_->GetSystemColor( | 941 SkColor accent_color = native_theme_->GetSystemColor( |
| 943 ui::NativeTheme::kColorId_ProminentButtonColor); | 942 ui::NativeTheme::kColorId_ProminentButtonColor); |
| 944 SkColor text_color = native_theme_->GetSystemColor( | 943 SkColor text_color = native_theme_->GetSystemColor( |
| 945 ui::NativeTheme::kColorId_LabelEnabledColor); | 944 ui::NativeTheme::kColorId_LabelEnabledColor); |
| 946 SkColor base_color = | 945 SkColor base_color = |
| 947 native_theme_->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); | 946 native_theme_->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground); |
| 948 | 947 |
| 949 PickButtonTintFromColors(accent_color, text_color, base_color, tint); | 948 PickButtonTintFromColors(accent_color, text_color, base_color, tint); |
| 950 } | 949 } |
| 951 | 950 |
| 952 void Gtk2UI::GetNormalEntryForegroundHSL(color_utils::HSL* tint) const { | 951 void GtkUi::GetNormalEntryForegroundHSL(color_utils::HSL* tint) const { |
| 953 SkColor accent_color = native_theme_->GetSystemColor( | 952 SkColor accent_color = native_theme_->GetSystemColor( |
| 954 ui::NativeTheme::kColorId_ProminentButtonColor); | 953 ui::NativeTheme::kColorId_ProminentButtonColor); |
| 955 SkColor text_color = native_theme_->GetSystemColor( | 954 SkColor text_color = native_theme_->GetSystemColor( |
| 956 ui::NativeTheme::kColorId_TextfieldDefaultColor); | 955 ui::NativeTheme::kColorId_TextfieldDefaultColor); |
| 957 SkColor base_color = native_theme_->GetSystemColor( | 956 SkColor base_color = native_theme_->GetSystemColor( |
| 958 ui::NativeTheme::kColorId_TextfieldDefaultBackground); | 957 ui::NativeTheme::kColorId_TextfieldDefaultBackground); |
| 959 | 958 |
| 960 PickButtonTintFromColors(accent_color, text_color, base_color, tint); | 959 PickButtonTintFromColors(accent_color, text_color, base_color, tint); |
| 961 } | 960 } |
| 962 | 961 |
| 963 void Gtk2UI::GetSelectedEntryForegroundHSL(color_utils::HSL* tint) const { | 962 void GtkUi::GetSelectedEntryForegroundHSL(color_utils::HSL* tint) const { |
| 964 // The simplest of all the tints. We just use the selected text in the entry | 963 // The simplest of all the tints. We just use the selected text in the entry |
| 965 // since the icons tinted this way will only be displayed against | 964 // since the icons tinted this way will only be displayed against |
| 966 // base[GTK_STATE_SELECTED]. | 965 // base[GTK_STATE_SELECTED]. |
| 967 SkColor color = native_theme_->GetSystemColor( | 966 SkColor color = native_theme_->GetSystemColor( |
| 968 ui::NativeTheme::kColorId_TextfieldSelectionColor); | 967 ui::NativeTheme::kColorId_TextfieldSelectionColor); |
| 969 | 968 |
| 970 color_utils::SkColorToHSL(color, tint); | 969 color_utils::SkColorToHSL(color, tint); |
| 971 } | 970 } |
| 972 | 971 |
| 973 void Gtk2UI::UpdateDefaultFont() { | 972 void GtkUi::UpdateDefaultFont() { |
| 974 GtkWidget* fake_label = gtk_label_new(nullptr); | 973 GtkWidget* fake_label = gtk_label_new(nullptr); |
| 975 g_object_ref_sink(fake_label); // Remove the floating reference. | 974 g_object_ref_sink(fake_label); // Remove the floating reference. |
| 976 PangoContext* pc = gtk_widget_get_pango_context(fake_label); | 975 PangoContext* pc = gtk_widget_get_pango_context(fake_label); |
| 977 const PangoFontDescription* desc = pango_context_get_font_description(pc); | 976 const PangoFontDescription* desc = pango_context_get_font_description(pc); |
| 978 | 977 |
| 979 // Use gfx::FontRenderParams to select a family and determine the rendering | 978 // Use gfx::FontRenderParams to select a family and determine the rendering |
| 980 // settings. | 979 // settings. |
| 981 gfx::FontRenderParamsQuery query; | 980 gfx::FontRenderParamsQuery query; |
| 982 query.families = | 981 query.families = |
| 983 base::SplitString(pango_font_description_get_family(desc), ",", | 982 base::SplitString(pango_font_description_get_family(desc), ",", |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1007 query.style |= gfx::Font::ITALIC; | 1006 query.style |= gfx::Font::ITALIC; |
| 1008 | 1007 |
| 1009 default_font_render_params_ = | 1008 default_font_render_params_ = |
| 1010 gfx::GetFontRenderParams(query, &default_font_family_); | 1009 gfx::GetFontRenderParams(query, &default_font_family_); |
| 1011 default_font_style_ = query.style; | 1010 default_font_style_ = query.style; |
| 1012 | 1011 |
| 1013 gtk_widget_destroy(fake_label); | 1012 gtk_widget_destroy(fake_label); |
| 1014 g_object_unref(fake_label); | 1013 g_object_unref(fake_label); |
| 1015 } | 1014 } |
| 1016 | 1015 |
| 1017 bool Gtk2UI::GetChromeStyleColor(const char* style_property, | 1016 bool GtkUi::GetChromeStyleColor(const char* style_property, |
| 1018 SkColor* ret_color) const { | 1017 SkColor* ret_color) const { |
| 1019 #if GTK_MAJOR_VERSION == 2 | 1018 #if GTK_MAJOR_VERSION == 2 |
| 1020 GdkColor* style_color = nullptr; | 1019 GdkColor* style_color = nullptr; |
| 1021 gtk_widget_style_get(fake_window_, style_property, &style_color, nullptr); | 1020 gtk_widget_style_get(fake_window_, style_property, &style_color, nullptr); |
| 1022 if (style_color) { | 1021 if (style_color) { |
| 1023 *ret_color = GdkColorToSkColor(*style_color); | 1022 *ret_color = GdkColorToSkColor(*style_color); |
| 1024 gdk_color_free(style_color); | 1023 gdk_color_free(style_color); |
| 1025 return true; | 1024 return true; |
| 1026 } | 1025 } |
| 1027 #endif | 1026 #endif |
| 1028 | 1027 |
| 1029 return false; | 1028 return false; |
| 1030 } | 1029 } |
| 1031 | 1030 |
| 1032 void Gtk2UI::ResetStyle() { | 1031 void GtkUi::ResetStyle() { |
| 1033 LoadGtkValues(); | 1032 LoadGtkValues(); |
| 1034 native_theme_->NotifyObservers(); | 1033 native_theme_->NotifyObservers(); |
| 1035 } | 1034 } |
| 1036 | 1035 |
| 1037 void Gtk2UI::UpdateDeviceScaleFactor() { | 1036 void GtkUi::UpdateDeviceScaleFactor() { |
| 1038 // Note: Linux chrome currently does not support dynamic DPI | 1037 // Note: Linux chrome currently does not support dynamic DPI |
| 1039 // changes. This is to allow flags to override the DPI settings | 1038 // changes. This is to allow flags to override the DPI settings |
| 1040 // during startup. | 1039 // during startup. |
| 1041 float scale = GetRawDeviceScaleFactor(); | 1040 float scale = GetRawDeviceScaleFactor(); |
| 1042 // Blacklist scaling factors <120% (crbug.com/484400) and round | 1041 // Blacklist scaling factors <120% (crbug.com/484400) and round |
| 1043 // to 1 decimal to prevent rendering problems (crbug.com/485183). | 1042 // to 1 decimal to prevent rendering problems (crbug.com/485183). |
| 1044 device_scale_factor_ = scale < 1.2f ? 1.0f : roundf(scale * 10) / 10; | 1043 device_scale_factor_ = scale < 1.2f ? 1.0f : roundf(scale * 10) / 10; |
| 1045 UpdateDefaultFont(); | 1044 UpdateDefaultFont(); |
| 1046 } | 1045 } |
| 1047 | 1046 |
| 1048 float Gtk2UI::GetDeviceScaleFactor() const { | 1047 float GtkUi::GetDeviceScaleFactor() const { |
| 1049 return device_scale_factor_; | 1048 return device_scale_factor_; |
| 1050 } | 1049 } |
| 1051 | 1050 |
| 1052 } // namespace libgtkui | 1051 } // namespace libgtkui |
| 1053 | 1052 |
| 1054 views::LinuxUI* BuildGtk2UI() { | 1053 views::LinuxUI* BuildGtkUi() { |
| 1055 return new libgtkui::Gtk2UI; | 1054 return new libgtkui::GtkUi; |
| 1056 } | 1055 } |
| OLD | NEW |