Chromium Code Reviews| Index: ash/system/audio/tray_audio.cc |
| diff --git a/ash/system/audio/tray_audio.cc b/ash/system/audio/tray_audio.cc |
| index a3b32ca96a822b0a1d33de7e9fb6b443055391d9..acd57005173d59051e8d27c618c19a95c43b22e0 100644 |
| --- a/ash/system/audio/tray_audio.cc |
| +++ b/ash/system/audio/tray_audio.cc |
| @@ -7,6 +7,7 @@ |
| #include <cmath> |
| #include "ash/ash_constants.h" |
| +#include "ash/display/display_manager.h" |
| #include "ash/metrics/user_metrics_recorder.h" |
| #include "ash/shell.h" |
| #include "ash/system/audio/tray_audio_delegate.h" |
| @@ -26,6 +27,7 @@ |
| #include "third_party/skia/include/core/SkRect.h" |
| #include "third_party/skia/include/effects/SkGradientShader.h" |
| #include "ui/gfx/canvas.h" |
| +#include "ui/gfx/display.h" |
| #include "ui/gfx/font_list.h" |
| #include "ui/gfx/image/image.h" |
| #include "ui/gfx/image/image_skia_operations.h" |
| @@ -45,9 +47,11 @@ TrayAudio::TrayAudio(SystemTray* system_tray, |
| volume_view_(NULL), |
| pop_up_volume_view_(false) { |
| Shell::GetInstance()->system_tray_notifier()->AddAudioObserver(this); |
| + Shell::GetScreen()->AddObserver(this); |
| } |
| TrayAudio::~TrayAudio() { |
| + Shell::GetScreen()->RemoveObserver(this); |
| Shell::GetInstance()->system_tray_notifier()->RemoveAudioObserver(this); |
| } |
| @@ -127,12 +131,39 @@ void TrayAudio::OnAudioNodesChanged() { |
| void TrayAudio::OnActiveOutputNodeChanged() { |
| Update(); |
| + ChangeAudioChannelMode(); |
| } |
| void TrayAudio::OnActiveInputNodeChanged() { |
| Update(); |
| } |
| +void TrayAudio::OnDisplayAdded(const gfx::Display& new_display) { |
| +} |
| + |
| +void TrayAudio::OnDisplayRemoved(const gfx::Display& old_display) { |
| +} |
| + |
| +void TrayAudio::OnDisplayMetricsChanged(const gfx::Display& display, |
| + uint32_t changed_metrics) { |
| + if (display.id() != gfx::Display::InternalDisplayId()) |
| + return; |
| + |
| + if (changed_metrics & gfx::DisplayObserver::DISPLAY_METRIC_ROTATION) |
| + ChangeAudioChannelMode(); |
| +} |
| + |
| +void TrayAudio::ChangeAudioChannelMode() { |
| + // Swap left/right channel if it is in Yoga mode. |
| + const DisplayInfo& display_info = |
| + Shell::GetInstance()->display_manager()->GetDisplayInfo( |
| + gfx::Display::InternalDisplayId()); |
|
oshima
2014/10/01 00:45:52
you should check if there is internal display (==
flackr
2014/10/01 17:25:28
In which case we should call this from OnDisplayRe
jennyz
2014/10/01 17:43:53
Done.
jennyz
2014/10/01 17:43:54
Done.
|
| + audio_delegate_->SetAudioChannelMode( |
| + display_info.rotation() == gfx::Display::ROTATE_180 |
| + ? system::TrayAudioDelegate::LEFT_RIGHT_SWAPPED |
| + : system::TrayAudioDelegate::NORMAL); |
| +} |
| + |
| void TrayAudio::Update() { |
| if (tray_view()) |
| tray_view()->SetVisible(GetInitialVisibility()); |