Chromium Code Reviews| 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 "ash/system/chromeos/tray_display.h" | 5 #include "ash/system/chromeos/tray_display.h" |
| 6 | 6 |
| 7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
| 8 #include "ash/display/multi_display_manager.h" | |
| 8 #include "ash/screen_ash.h" | 9 #include "ash/screen_ash.h" |
| 9 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 10 #include "ash/system/tray/system_tray.h" | 11 #include "ash/system/tray/system_tray.h" |
| 11 #include "ash/system/tray/system_tray_delegate.h" | 12 #include "ash/system/tray/system_tray_delegate.h" |
| 12 #include "ash/system/tray/tray_constants.h" | 13 #include "ash/system/tray/tray_constants.h" |
| 13 #include "ash/system/tray/tray_views.h" | 14 #include "ash/system/tray/tray_views.h" |
| 14 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 15 #include "grit/ash_resources.h" | 16 #include "grit/ash_resources.h" |
| 16 #include "grit/ash_strings.h" | 17 #include "grit/ash_strings.h" |
| 17 #include "ui/aura/display_manager.h" | 18 #include "ui/aura/display_manager.h" |
| 18 #include "ui/aura/env.h" | 19 #include "ui/aura/env.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/gfx/image/image.h" | 22 #include "ui/gfx/image/image.h" |
| 22 #include "ui/views/controls/image_view.h" | 23 #include "ui/views/controls/image_view.h" |
| 23 #include "ui/views/controls/label.h" | 24 #include "ui/views/controls/label.h" |
| 24 #include "ui/views/layout/box_layout.h" | 25 #include "ui/views/layout/box_layout.h" |
| 25 | 26 |
| 26 #if defined(USE_X11) | |
| 27 #include "ui/base/x/x11_util.h" | |
| 28 #endif | |
| 29 | |
| 30 namespace ash { | 27 namespace ash { |
| 31 namespace internal { | 28 namespace internal { |
| 32 | 29 |
| 33 class DisplayView : public ash::internal::ActionableView { | 30 class DisplayView : public ash::internal::ActionableView { |
| 34 public: | 31 public: |
| 35 explicit DisplayView(user::LoginStatus login_status) | 32 explicit DisplayView(user::LoginStatus login_status) |
| 36 : login_status_(login_status) { | 33 : login_status_(login_status) { |
| 37 SetLayoutManager(new | 34 SetLayoutManager(new |
| 38 views::BoxLayout(views::BoxLayout::kHorizontal, | 35 views::BoxLayout(views::BoxLayout::kHorizontal, |
| 39 ash::kTrayPopupPaddingHorizontal, 0, | 36 ash::kTrayPopupPaddingHorizontal, 0, |
| 40 ash::kTrayPopupPaddingBetweenItems)); | 37 ash::kTrayPopupPaddingBetweenItems)); |
| 41 | 38 |
| 42 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 39 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 43 views::ImageView* image = | 40 views::ImageView* image = |
| 44 new ash::internal::FixedSizedImageView(0, ash::kTrayPopupItemHeight); | 41 new ash::internal::FixedSizedImageView(0, ash::kTrayPopupItemHeight); |
| 45 image->SetImage( | 42 image->SetImage( |
| 46 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DISPLAY).ToImageSkia()); | 43 bundle.GetImageNamed(IDR_AURA_UBER_TRAY_DISPLAY).ToImageSkia()); |
| 47 AddChildView(image); | 44 AddChildView(image); |
| 48 label_ = new views::Label(); | 45 label_ = new views::Label(); |
| 49 AddChildView(label_); | 46 AddChildView(label_); |
| 50 Update(); | 47 Update(); |
| 51 } | 48 } |
| 52 | 49 |
| 53 virtual ~DisplayView() {} | 50 virtual ~DisplayView() {} |
| 54 | 51 |
| 55 void Update() { | 52 void Update() { |
| 53 MultiDisplayManager* display_manager = static_cast<MultiDisplayManager*>( | |
| 54 aura::Env::GetInstance()->display_manager()); | |
| 55 | |
| 56 switch (Shell::GetInstance()->output_configurator()->output_state()) { | 56 switch (Shell::GetInstance()->output_configurator()->output_state()) { |
| 57 case chromeos::STATE_INVALID: | 57 case chromeos::STATE_INVALID: |
| 58 case chromeos::STATE_HEADLESS: | 58 case chromeos::STATE_HEADLESS: |
| 59 case chromeos::STATE_SINGLE: | 59 case chromeos::STATE_SINGLE: |
| 60 SetVisible(false); | 60 SetVisible(false); |
| 61 return; | 61 return; |
| 62 case chromeos::STATE_DUAL_MIRROR: { | 62 case chromeos::STATE_DUAL_MIRROR: { |
| 63 // Simply assumes that the primary display appears first and the | 63 std::vector<std::string> display_names = |
| 64 // secondary display appears next in the list. | 64 display_manager->GetExternalDisplayNames(); |
| 65 std::vector<std::string> display_names; | 65 if (!display_names.empty()) { |
| 66 #if defined(USE_X11) | |
| 67 std::vector<XID> output_ids; | |
| 68 ui::GetOutputDeviceHandles(&output_ids); | |
| 69 display_names = ui::GetDisplayNames(output_ids); | |
| 70 #endif | |
| 71 if (display_names.size() > 1) { | |
| 72 label_->SetText(l10n_util::GetStringFUTF16( | 66 label_->SetText(l10n_util::GetStringFUTF16( |
| 73 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING, | 67 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING, |
| 74 UTF8ToUTF16(display_names[1]))); | 68 UTF8ToUTF16(display_names[0]))); |
| 75 SetVisible(true); | 69 SetVisible(true); |
| 76 } else { | 70 } else { |
| 77 SetVisible(false); | 71 SetVisible(false); |
|
oshima
2012/11/02 06:33:56
This state shouldn't happen, but if we ever failed
Jun Mukai
2012/11/02 16:09:07
Done.
| |
| 78 } | 72 } |
| 79 return; | 73 return; |
| 80 } | 74 } |
| 81 case chromeos::STATE_DUAL_PRIMARY_ONLY: | 75 case chromeos::STATE_DUAL_PRIMARY_ONLY: |
| 82 case chromeos::STATE_DUAL_SECONDARY_ONLY: { | 76 case chromeos::STATE_DUAL_SECONDARY_ONLY: { |
| 83 aura::DisplayManager* display_manager = | |
| 84 aura::Env::GetInstance()->display_manager(); | |
| 85 if (display_manager->GetNumDisplays() > 1) { | 77 if (display_manager->GetNumDisplays() > 1) { |
| 86 label_->SetText(l10n_util::GetStringFUTF16( | 78 label_->SetText(l10n_util::GetStringFUTF16( |
| 87 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, | 79 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, |
| 88 UTF8ToUTF16(display_manager->GetDisplayNameFor( | 80 UTF8ToUTF16(display_manager->GetDisplayNameFor( |
| 89 ScreenAsh::GetSecondaryDisplay())))); | 81 ScreenAsh::GetSecondaryDisplay())))); |
| 90 SetVisible(true); | 82 SetVisible(true); |
| 91 } else { | 83 } else { |
| 92 SetVisible(false); | 84 SetVisible(false); |
| 93 } | 85 } |
| 94 return; | 86 return; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 default_->Update(); | 143 default_->Update(); |
| 152 } | 144 } |
| 153 | 145 |
| 154 void TrayDisplay::OnDisplayModeChanged() { | 146 void TrayDisplay::OnDisplayModeChanged() { |
| 155 if (default_) | 147 if (default_) |
| 156 default_->Update(); | 148 default_->Update(); |
| 157 } | 149 } |
| 158 | 150 |
| 159 } // namespace internal | 151 } // namespace internal |
| 160 } // namespace ash | 152 } // namespace ash |
| OLD | NEW |