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

Side by Side Diff: ash/display/display_manager.cc

Issue 12217120: Add IsInternal property to gfx::Display (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Get rid of static initializer Created 7 years, 10 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
« no previous file with comments | « ash/display/display_manager.h ('k') | ash/display/event_transformation_handler.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/display/display_manager.h" 5 #include "ash/display/display_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 using aura::RootWindow; 92 using aura::RootWindow;
93 using aura::Window; 93 using aura::Window;
94 using std::string; 94 using std::string;
95 using std::vector; 95 using std::vector;
96 96
97 DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey, 97 DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey,
98 gfx::Display::kInvalidDisplayID); 98 gfx::Display::kInvalidDisplayID);
99 99
100 DisplayManager::DisplayManager() : 100 DisplayManager::DisplayManager() :
101 internal_display_id_(gfx::Display::kInvalidDisplayID),
102 force_bounds_changed_(false) { 101 force_bounds_changed_(false) {
103 Init(); 102 Init();
104 } 103 }
105 104
106 DisplayManager::~DisplayManager() { 105 DisplayManager::~DisplayManager() {
107 } 106 }
108 107
109 // static 108 // static
110 void DisplayManager::CycleDisplay() { 109 void DisplayManager::CycleDisplay() {
111 Shell::GetInstance()->display_manager()->CycleDisplayImpl(); 110 Shell::GetInstance()->display_manager()->CycleDisplayImpl();
112 } 111 }
113 112
114 // static 113 // static
115 void DisplayManager::ToggleDisplayScale() { 114 void DisplayManager::ToggleDisplayScale() {
116 Shell::GetInstance()->display_manager()->ScaleDisplayImpl(); 115 Shell::GetInstance()->display_manager()->ScaleDisplayImpl();
117 } 116 }
118 117
119 bool DisplayManager::IsActiveDisplay(const gfx::Display& display) const { 118 bool DisplayManager::IsActiveDisplay(const gfx::Display& display) const {
120 for (DisplayList::const_iterator iter = displays_.begin(); 119 for (DisplayList::const_iterator iter = displays_.begin();
121 iter != displays_.end(); ++iter) { 120 iter != displays_.end(); ++iter) {
122 if ((*iter).id() == display.id()) 121 if ((*iter).id() == display.id())
123 return true; 122 return true;
124 } 123 }
125 return false; 124 return false;
126 } 125 }
127 126
128 bool DisplayManager::HasInternalDisplay() const { 127 bool DisplayManager::HasInternalDisplay() const {
129 return internal_display_id_ != gfx::Display::kInvalidDisplayID; 128 return gfx::Display::InternalDisplayId() != gfx::Display::kInvalidDisplayID;
130 } 129 }
131 130
132 bool DisplayManager::IsInternalDisplayId(int64 id) const { 131 bool DisplayManager::IsInternalDisplayId(int64 id) const {
133 return internal_display_id_ == id; 132 return gfx::Display::InternalDisplayId() == id;
134 } 133 }
135 134
136 bool DisplayManager::UpdateWorkAreaOfDisplayNearestWindow( 135 bool DisplayManager::UpdateWorkAreaOfDisplayNearestWindow(
137 const aura::Window* window, 136 const aura::Window* window,
138 const gfx::Insets& insets) { 137 const gfx::Insets& insets) {
139 const RootWindow* root = window->GetRootWindow(); 138 const RootWindow* root = window->GetRootWindow();
140 gfx::Display& display = FindDisplayForRootWindow(root); 139 gfx::Display& display = FindDisplayForRootWindow(root);
141 gfx::Rect old_work_area = display.work_area(); 140 gfx::Rect old_work_area = display.work_area();
142 display.UpdateWorkAreaFromInsets(insets); 141 display.UpdateWorkAreaFromInsets(insets);
143 return old_work_area != display.work_area(); 142 return old_work_area != display.work_area();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 // - the device is suspended. (kernel turns off all displays) 184 // - the device is suspended. (kernel turns off all displays)
186 // - the internal display's brightness is set to 0 and no external 185 // - the internal display's brightness is set to 0 and no external
187 // display is connected. 186 // display is connected.
188 // - the internal display's brightness is 0 and external display is 187 // - the internal display's brightness is 0 and external display is
189 // disconnected. 188 // disconnected.
190 // The display will be updated when one of displays is turned on, and the 189 // The display will be updated when one of displays is turned on, and the
191 // display list will be updated correctly. 190 // display list will be updated correctly.
192 return; 191 return;
193 } 192 }
194 DisplayList new_displays = updated_displays; 193 DisplayList new_displays = updated_displays;
195 if (internal_display_id_ != gfx::Display::kInvalidDisplayID) { 194 if (HasInternalDisplay()) {
196 bool internal_display_connected = false; 195 bool internal_display_connected = false;
197 for (DisplayList::const_iterator iter = updated_displays.begin(); 196 for (DisplayList::const_iterator iter = updated_displays.begin();
198 iter != updated_displays.end(); ++iter) { 197 iter != updated_displays.end(); ++iter) {
199 if ((*iter).id() == internal_display_id_) { 198 if ((*iter).IsInternal()) {
200 internal_display_connected = true; 199 internal_display_connected = true;
201 // Update the internal display cache. 200 // Update the internal display cache.
202 internal_display_.reset(new gfx::Display); 201 internal_display_.reset(new gfx::Display);
203 *internal_display_.get() = *iter; 202 *internal_display_.get() = *iter;
204 break; 203 break;
205 } 204 }
206 } 205 }
207 // If the internal display wasn't connected, use the cached value. 206 // If the internal display wasn't connected, use the cached value.
208 if (!internal_display_connected) { 207 if (!internal_display_connected) {
209 // Internal display may be reported as disconnect during startup time. 208 // Internal display may be reported as disconnect during startup time.
210 if (!internal_display_.get()) { 209 if (!internal_display_.get()) {
211 internal_display_.reset(new gfx::Display(internal_display_id_, 210 internal_display_.reset(
212 gfx::Rect(800, 600))); 211 new gfx::Display(gfx::Display::InternalDisplayId(),
212 gfx::Rect(800, 600)));
213 } 213 }
214 new_displays.push_back(*internal_display_.get()); 214 new_displays.push_back(*internal_display_.get());
215 } 215 }
216 } else { 216 } else {
217 new_displays = updated_displays; 217 new_displays = updated_displays;
218 } 218 }
219 219
220 RefreshDisplayInfo(); 220 RefreshDisplayInfo();
221 221
222 for (DisplayList::const_iterator iter = new_displays.begin(); 222 for (DisplayList::const_iterator iter = new_displays.begin();
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 445
446 void DisplayManager::Init() { 446 void DisplayManager::Init() {
447 #if defined(OS_CHROMEOS) 447 #if defined(OS_CHROMEOS)
448 if (base::chromeos::IsRunningOnChromeOS()) { 448 if (base::chromeos::IsRunningOnChromeOS()) {
449 std::vector<XID> outputs; 449 std::vector<XID> outputs;
450 ui::GetOutputDeviceHandles(&outputs); 450 ui::GetOutputDeviceHandles(&outputs);
451 std::vector<std::string> output_names = ui::GetOutputNames(outputs); 451 std::vector<std::string> output_names = ui::GetOutputNames(outputs);
452 for (size_t i = 0; i < output_names.size(); ++i) { 452 for (size_t i = 0; i < output_names.size(); ++i) {
453 if (chromeos::OutputConfigurator::IsInternalOutputName( 453 if (chromeos::OutputConfigurator::IsInternalOutputName(
454 output_names[i])) { 454 output_names[i])) {
455 internal_display_id_ = GetDisplayIdForOutput(outputs[i], i); 455 gfx::Display::SetInternalDisplayId(
456 GetDisplayIdForOutput(outputs[i], i));
456 break; 457 break;
457 } 458 }
458 } 459 }
459 } 460 }
460 #endif 461 #endif
461 462
462 RefreshDisplayInfo(); 463 RefreshDisplayInfo();
463 464
464 // TODO(oshima): Move this logic to DisplayChangeObserver. 465 // TODO(oshima): Move this logic to DisplayChangeObserver.
465 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 466 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 gfx::Display display = CreateDisplayFromSpec(spec); 531 gfx::Display display = CreateDisplayFromSpec(spec);
531 532
532 const gfx::Insets insets = display.GetWorkAreaInsets(); 533 const gfx::Insets insets = display.GetWorkAreaInsets();
533 const gfx::Rect& native_bounds = display.bounds_in_pixel(); 534 const gfx::Rect& native_bounds = display.bounds_in_pixel();
534 display.SetScaleAndBounds(display.device_scale_factor(), native_bounds); 535 display.SetScaleAndBounds(display.device_scale_factor(), native_bounds);
535 display.UpdateWorkAreaFromInsets(insets); 536 display.UpdateWorkAreaFromInsets(insets);
536 displays_.push_back(display); 537 displays_.push_back(display);
537 } 538 }
538 539
539 int64 DisplayManager::SetFirstDisplayAsInternalDisplayForTest() { 540 int64 DisplayManager::SetFirstDisplayAsInternalDisplayForTest() {
540 internal_display_id_ = displays_[0].id(); 541 gfx::Display::SetInternalDisplayId(displays_[0].id());
541 internal_display_.reset(new gfx::Display); 542 internal_display_.reset(new gfx::Display);
542 *internal_display_ = displays_[0]; 543 *internal_display_ = displays_[0];
543 return internal_display_id_; 544 return gfx::Display::InternalDisplayId();
544 } 545 }
545 546
546 void DisplayManager::EnsurePointerInDisplays() { 547 void DisplayManager::EnsurePointerInDisplays() {
547 // Don't try to move the pointer during the boot/startup. 548 // Don't try to move the pointer during the boot/startup.
548 if (!DisplayController::HasPrimaryDisplay()) 549 if (!DisplayController::HasPrimaryDisplay())
549 return; 550 return;
550 gfx::Point location_in_screen = Shell::GetScreen()->GetCursorScreenPoint(); 551 gfx::Point location_in_screen = Shell::GetScreen()->GetCursorScreenPoint();
551 gfx::Point target_location; 552 gfx::Point target_location;
552 int64 closest_distance_squared = -1; 553 int64 closest_distance_squared = -1;
553 554
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 } 649 }
649 650
650 gfx::Display display(synthesized_display_id++); 651 gfx::Display display(synthesized_display_id++);
651 display.SetScaleAndBounds(scale, bounds); 652 display.SetScaleAndBounds(scale, bounds);
652 DVLOG(1) << "Display bounds=" << bounds.ToString() << ", scale=" << scale; 653 DVLOG(1) << "Display bounds=" << bounds.ToString() << ", scale=" << scale;
653 return display; 654 return display;
654 } 655 }
655 656
656 } // namespace internal 657 } // namespace internal
657 } // namespace ash 658 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_manager.h ('k') | ash/display/event_transformation_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698