Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1836)

Side by Side Diff: ash/system/chromeos/tray_display.cc

Issue 12746002: Re-implement overscan & Implement Display Rotation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/display/display_manager_unittest.cc ('k') | ash/test/ash_test_base.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/screen_ash.h" 9 #include "ash/screen_ash.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/system/tray/fixed_sized_image_view.h" 11 #include "ash/system/tray/fixed_sized_image_view.h"
12 #include "ash/system/tray/system_tray.h" 12 #include "ash/system/tray/system_tray.h"
13 #include "ash/system/tray/system_tray_delegate.h" 13 #include "ash/system/tray/system_tray_delegate.h"
14 #include "ash/system/tray/tray_constants.h" 14 #include "ash/system/tray/tray_constants.h"
15 #include "ash/system/tray/tray_views.h" 15 #include "ash/system/tray/tray_views.h"
16 #include "base/chromeos/chromeos_version.h"
16 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
17 #include "grit/ash_resources.h" 18 #include "grit/ash_resources.h"
18 #include "grit/ash_strings.h" 19 #include "grit/ash_strings.h"
19 #include "ui/aura/env.h" 20 #include "ui/aura/env.h"
20 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
22 #include "ui/gfx/image/image.h" 23 #include "ui/gfx/image/image.h"
23 #include "ui/views/controls/image_view.h" 24 #include "ui/views/controls/image_view.h"
24 #include "ui/views/controls/label.h" 25 #include "ui/views/controls/label.h"
25 #include "ui/views/layout/box_layout.h" 26 #include "ui/views/layout/box_layout.h"
(...skipping 24 matching lines...) Expand all
50 label_ = new views::Label(); 51 label_ = new views::Label();
51 label_->SetMultiLine(true); 52 label_->SetMultiLine(true);
52 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 53 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
53 AddChildView(label_); 54 AddChildView(label_);
54 Update(); 55 Update();
55 } 56 }
56 57
57 virtual ~DisplayView() {} 58 virtual ~DisplayView() {}
58 59
59 void Update() { 60 void Update() {
60 switch (Shell::GetInstance()->output_configurator()->output_state()) { 61 chromeos::OutputState state =
62 base::chromeos::IsRunningOnChromeOS() ?
63 Shell::GetInstance()->output_configurator()->output_state() :
64 InferOutputState();
65 switch (state) {
61 case chromeos::STATE_INVALID: 66 case chromeos::STATE_INVALID:
62 case chromeos::STATE_HEADLESS: 67 case chromeos::STATE_HEADLESS:
63 case chromeos::STATE_SINGLE: 68 case chromeos::STATE_SINGLE:
64 SetVisible(false); 69 SetVisible(false);
65 return; 70 return;
66 case chromeos::STATE_DUAL_MIRROR: { 71 case chromeos::STATE_DUAL_MIRROR: {
67 label_->SetText(l10n_util::GetStringFUTF16( 72 label_->SetText(l10n_util::GetStringFUTF16(
68 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING, GetExternalDisplayName())); 73 IDS_ASH_STATUS_TRAY_DISPLAY_MIRRORING, GetExternalDisplayName()));
69 SetVisible(true); 74 SetVisible(true);
70 return; 75 return;
71 } 76 }
72 case chromeos::STATE_DUAL_EXTENDED: 77 case chromeos::STATE_DUAL_EXTENDED:
73 case chromeos::STATE_DUAL_UNKNOWN: { 78 case chromeos::STATE_DUAL_UNKNOWN: {
74 label_->SetText(l10n_util::GetStringFUTF16( 79 label_->SetText(l10n_util::GetStringFUTF16(
75 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, GetExternalDisplayName())); 80 IDS_ASH_STATUS_TRAY_DISPLAY_EXTENDED, GetExternalDisplayName()));
76 SetVisible(true); 81 SetVisible(true);
77 return; 82 return;
78 } 83 }
79 default: 84 default:
80 NOTREACHED(); 85 NOTREACHED();
81 } 86 }
82 } 87 }
83 88
89 chromeos::OutputState InferOutputState() const {
90 return Shell::GetScreen()->GetNumDisplays() == 1 ?
91 chromeos::STATE_SINGLE : chromeos::STATE_DUAL_EXTENDED;
92 }
93
84 private: 94 private:
85 // Returns the name of the currently connected external display. 95 // Returns the name of the currently connected external display.
86 string16 GetExternalDisplayName() { 96 string16 GetExternalDisplayName() const {
87 #if defined(USE_X11) 97 if (base::chromeos::IsRunningOnChromeOS())
98 return GetNativeExternalDisplayName();
99 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME);
100 }
101
102 string16 GetNativeExternalDisplayName() const {
88 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 103 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
89 int64 internal_display_id = gfx::Display::InternalDisplayId(); 104 int64 internal_display_id = gfx::Display::InternalDisplayId();
90 int64 primary_display_id = 105 int64 primary_display_id =
91 gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().id(); 106 Shell::GetScreen()->GetPrimaryDisplay().id();
92 107
93 // Use xrandr features rather than DisplayManager to find out the external 108 // Use xrandr features rather than DisplayManager to find out the external
94 // display's name. DisplayManager's API doesn't work well in mirroring mode 109 // display's name. DisplayManager's API doesn't work well in mirroring mode
95 // since it's based on gfx::Display but in mirroring mode there's only one 110 // since it's based on gfx::Display but in mirroring mode there's only one
96 // gfx::Display instance which represents both displays. 111 // gfx::Display instance which represents both displays.
112 // TODO(oshima): Use DisplayManager to get external display name.
97 std::vector<XID> outputs; 113 std::vector<XID> outputs;
98 ui::GetOutputDeviceHandles(&outputs); 114 ui::GetOutputDeviceHandles(&outputs);
99 for (size_t i = 0; i < outputs.size(); ++i) { 115 for (size_t i = 0; i < outputs.size(); ++i) {
100 std::string name; 116 std::string name;
101 uint16 manufacturer_id = 0; 117 uint16 manufacturer_id = 0;
102 uint16 product_code = 0; 118 uint16 product_code = 0;
103 if (ui::GetOutputDeviceData( 119 if (ui::GetOutputDeviceData(
104 outputs[i], &manufacturer_id, &product_code, &name)) { 120 outputs[i], &manufacturer_id, &product_code, &name)) {
105 int64 display_id = gfx::Display::GetID( 121 int64 display_id = gfx::Display::GetID(
106 manufacturer_id, product_code, i); 122 manufacturer_id, product_code, i);
107 if (display_id == internal_display_id) 123 if (display_id == internal_display_id)
108 continue; 124 continue;
109 // Some systems like stumpy don't have the internal display at all. It 125 // Some systems like stumpy don't have the internal display at all. It
110 // means both of the displays are external but we need to choose either 126 // means both of the displays are external but we need to choose either
111 // one. Currently we adopt simple heuristics which just avoids the 127 // one. Currently we adopt simple heuristics which just avoids the
112 // primary display. 128 // primary display.
113 if (!display_manager->HasInternalDisplay() && 129 if (!display_manager->HasInternalDisplay() &&
114 display_id == primary_display_id) { 130 display_id == primary_display_id) {
115 continue; 131 continue;
116 } 132 }
117 133
118 return UTF8ToUTF16(name); 134 return UTF8ToUTF16(name);
119 } 135 }
120 } 136 }
121 #endif
122 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME); 137 return l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_UNKNOWN_DISPLAY_NAME);
123 } 138 }
124 139
125 // Overridden from ActionableView. 140 // Overridden from ActionableView.
126 virtual bool PerformAction(const ui::Event& event) OVERRIDE { 141 virtual bool PerformAction(const ui::Event& event) OVERRIDE {
127 if (login_status_ == ash::user::LOGGED_IN_USER || 142 if (login_status_ == ash::user::LOGGED_IN_USER ||
128 login_status_ == ash::user::LOGGED_IN_OWNER || 143 login_status_ == ash::user::LOGGED_IN_OWNER ||
129 login_status_ == ash::user::LOGGED_IN_GUEST) { 144 login_status_ == ash::user::LOGGED_IN_GUEST) {
130 ash::Shell::GetInstance()->system_tray_delegate()->ShowDisplaySettings(); 145 ash::Shell::GetInstance()->system_tray_delegate()->ShowDisplaySettings();
131 } 146 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 200
186 #if defined(OS_CHROMEOS) 201 #if defined(OS_CHROMEOS)
187 void TrayDisplay::OnDisplayModeChanged() { 202 void TrayDisplay::OnDisplayModeChanged() {
188 if (default_) 203 if (default_)
189 default_->Update(); 204 default_->Update();
190 } 205 }
191 #endif 206 #endif
192 207
193 } // namespace internal 208 } // namespace internal
194 } // namespace ash 209 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_manager_unittest.cc ('k') | ash/test/ash_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698