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/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/display/display_controller.h" | 10 #include "ash/display/display_controller.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 #if defined(OS_CHROMEOS) | 65 #if defined(OS_CHROMEOS) |
66 int64 GetDisplayIdForOutput(XID output) { | 66 int64 GetDisplayIdForOutput(XID output) { |
67 uint16 manufacturer_id = 0; | 67 uint16 manufacturer_id = 0; |
68 uint32 serial_number = 0; | 68 uint32 serial_number = 0; |
69 ui::GetOutputDeviceData( | 69 ui::GetOutputDeviceData( |
70 output, &manufacturer_id, &serial_number, NULL); | 70 output, &manufacturer_id, &serial_number, NULL); |
71 return gfx::Display::GetID(manufacturer_id, serial_number); | 71 return gfx::Display::GetID(manufacturer_id, serial_number); |
72 } | 72 } |
73 #endif | 73 #endif |
74 | 74 |
75 gfx::Insets GetDefaultDisplayOverscan(const gfx::Display& display) { | |
76 // Currently we assume 5% for each edge. | |
77 int width = display.bounds().width() / 20; | |
78 int height = display.bounds().height() / 20; | |
79 return gfx::Insets(height, width, height, width); | |
oshima
2013/01/12 02:06:38
Is 5% good assumption?
Isn't it better to just le
Jun Mukai
2013/01/14 18:18:51
No info, there's only a bool flag and marcheu sugg
| |
80 } | |
81 | |
75 } // namespace | 82 } // namespace |
76 | 83 |
77 using aura::RootWindow; | 84 using aura::RootWindow; |
78 using aura::Window; | 85 using aura::Window; |
79 using std::string; | 86 using std::string; |
80 using std::vector; | 87 using std::vector; |
81 | 88 |
82 DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey, | 89 DEFINE_WINDOW_PROPERTY_KEY(int64, kDisplayIdKey, |
83 gfx::Display::kInvalidDisplayID); | 90 gfx::Display::kInvalidDisplayID); |
84 | 91 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 const gfx::Display& display = *iter; | 146 const gfx::Display& display = *iter; |
140 if (display.bounds().Contains(point_in_screen)) | 147 if (display.bounds().Contains(point_in_screen)) |
141 return display; | 148 return display; |
142 } | 149 } |
143 return GetInvalidDisplay(); | 150 return GetInvalidDisplay(); |
144 } | 151 } |
145 | 152 |
146 void DisplayManager::SetOverscanInsets(int64 display_id, | 153 void DisplayManager::SetOverscanInsets(int64 display_id, |
147 const gfx::Insets& insets_in_dip) { | 154 const gfx::Insets& insets_in_dip) { |
148 display_info_[display_id].overscan_insets_in_dip = insets_in_dip; | 155 display_info_[display_id].overscan_insets_in_dip = insets_in_dip; |
156 display_info_[display_id].overscan_insets_specified = true; | |
149 | 157 |
150 // Copies the |displays_| because UpdateDisplays() compares the passed | 158 // Copies the |displays_| because UpdateDisplays() compares the passed |
151 // displays and its internal |displays_|. | 159 // displays and its internal |displays_|. |
152 DisplayList displays = displays_; | 160 DisplayList displays = displays_; |
153 UpdateDisplays(displays); | 161 UpdateDisplays(displays); |
154 } | 162 } |
155 | 163 |
156 gfx::Insets DisplayManager::GetOverscanInsets(int64 display_id) const { | 164 gfx::Insets DisplayManager::GetOverscanInsets(int64 display_id) const { |
157 std::map<int64, DisplayInfo>::const_iterator it = | 165 std::map<int64, DisplayInfo>::const_iterator it = |
158 display_info_.find(display_id); | 166 display_info_.find(display_id); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 if (!internal_display_.get()) { | 202 if (!internal_display_.get()) { |
195 internal_display_.reset(new gfx::Display(internal_display_id_, | 203 internal_display_.reset(new gfx::Display(internal_display_id_, |
196 gfx::Rect(800, 600))); | 204 gfx::Rect(800, 600))); |
197 } | 205 } |
198 new_displays.push_back(*internal_display_.get()); | 206 new_displays.push_back(*internal_display_.get()); |
199 } | 207 } |
200 } else { | 208 } else { |
201 new_displays = updated_displays; | 209 new_displays = updated_displays; |
202 } | 210 } |
203 | 211 |
212 RefreshDisplayInfo(); | |
213 | |
204 for (DisplayList::const_iterator iter = new_displays.begin(); | 214 for (DisplayList::const_iterator iter = new_displays.begin(); |
205 iter != new_displays.end(); ++iter) { | 215 iter != new_displays.end(); ++iter) { |
206 std::map<int64, DisplayInfo>::iterator info = | 216 std::map<int64, DisplayInfo>::iterator info = |
207 display_info_.find(iter->id()); | 217 display_info_.find(iter->id()); |
208 if (info != display_info_.end()) { | 218 if (info != display_info_.end()) { |
209 info->second.original_bounds_in_pixel = iter->bounds_in_pixel(); | 219 info->second.original_bounds_in_pixel = iter->bounds_in_pixel(); |
220 if (info->second.overscan && !info->second.overscan_insets_specified) | |
221 info->second.overscan_insets_in_dip = GetDefaultDisplayOverscan(*iter); | |
210 } else { | 222 } else { |
211 display_info_[iter->id()].original_bounds_in_pixel = | 223 display_info_[iter->id()].original_bounds_in_pixel = |
212 iter->bounds_in_pixel(); | 224 iter->bounds_in_pixel(); |
213 } | 225 } |
214 } | 226 } |
215 | 227 |
216 UpdateDisplays(new_displays); | 228 UpdateDisplays(new_displays); |
217 RefreshDisplayNames(); | |
218 } | 229 } |
219 | 230 |
220 void DisplayManager::UpdateDisplays( | 231 void DisplayManager::UpdateDisplays( |
221 const std::vector<gfx::Display>& updated_displays) { | 232 const std::vector<gfx::Display>& updated_displays) { |
222 DisplayList new_displays = updated_displays; | 233 DisplayList new_displays = updated_displays; |
223 | 234 |
224 for (DisplayList::iterator iter = new_displays.begin(); | 235 for (DisplayList::iterator iter = new_displays.begin(); |
225 iter != new_displays.end(); ++iter) { | 236 iter != new_displays.end(); ++iter) { |
226 std::map<int64, DisplayInfo>::const_iterator info = | 237 std::map<int64, DisplayInfo>::const_iterator info = |
227 display_info_.find(iter->id()); | 238 display_info_.find(iter->id()); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
413 for (size_t i = 0; i < output_names.size(); ++i) { | 424 for (size_t i = 0; i < output_names.size(); ++i) { |
414 if (chromeos::OutputConfigurator::IsInternalOutputName( | 425 if (chromeos::OutputConfigurator::IsInternalOutputName( |
415 output_names[i])) { | 426 output_names[i])) { |
416 internal_display_id_ = GetDisplayIdForOutput(outputs[i]); | 427 internal_display_id_ = GetDisplayIdForOutput(outputs[i]); |
417 break; | 428 break; |
418 } | 429 } |
419 } | 430 } |
420 } | 431 } |
421 #endif | 432 #endif |
422 | 433 |
423 RefreshDisplayNames(); | 434 RefreshDisplayInfo(); |
424 | 435 |
425 #if defined(OS_WIN) | 436 #if defined(OS_WIN) |
426 if (base::win::GetVersion() >= base::win::VERSION_WIN8) | 437 if (base::win::GetVersion() >= base::win::VERSION_WIN8) |
427 aura::SetUseFullscreenHostWindow(true); | 438 aura::SetUseFullscreenHostWindow(true); |
428 #endif | 439 #endif |
429 // TODO(oshima): Move this logic to DisplayChangeObserver. | 440 // TODO(oshima): Move this logic to DisplayChangeObserver. |
430 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 441 const string size_str = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
431 switches::kAuraHostWindowSize); | 442 switches::kAuraHostWindowSize); |
432 vector<string> parts; | 443 vector<string> parts; |
433 base::SplitString(size_str, ',', &parts); | 444 base::SplitString(size_str, ',', &parts); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
539 } | 550 } |
540 | 551 |
541 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); | 552 aura::RootWindow* root_window = Shell::GetPrimaryRootWindow(); |
542 aura::client::ScreenPositionClient* client = | 553 aura::client::ScreenPositionClient* client = |
543 aura::client::GetScreenPositionClient(root_window); | 554 aura::client::GetScreenPositionClient(root_window); |
544 client->ConvertPointFromScreen(root_window, &target_location); | 555 client->ConvertPointFromScreen(root_window, &target_location); |
545 | 556 |
546 root_window->MoveCursorTo(target_location); | 557 root_window->MoveCursorTo(target_location); |
547 } | 558 } |
548 | 559 |
549 void DisplayManager::RefreshDisplayNames() { | 560 DisplayManager::DisplayInfo::DisplayInfo() |
561 : overscan(false), overscan_insets_specified(false) { | |
oshima
2013/01/12 02:06:38
one argument per line (I think)
Jun Mukai
2013/01/14 18:18:51
Done.
| |
562 } | |
563 | |
564 void DisplayManager::RefreshDisplayInfo() { | |
550 #if defined(OS_CHROMEOS) | 565 #if defined(OS_CHROMEOS) |
551 if (!base::chromeos::IsRunningOnChromeOS()) | 566 if (!base::chromeos::IsRunningOnChromeOS()) |
552 return; | 567 return; |
553 #endif | 568 #endif |
554 | 569 |
555 #if defined(USE_X11) | 570 #if defined(USE_X11) |
556 std::vector<XID> outputs; | 571 std::vector<XID> outputs; |
557 if (!ui::GetOutputDeviceHandles(&outputs)) | 572 if (!ui::GetOutputDeviceHandles(&outputs)) |
558 return; | 573 return; |
559 | 574 |
560 for (size_t i = 0; i < outputs.size(); ++i) { | 575 for (size_t i = 0; i < outputs.size(); ++i) { |
561 uint16 manufacturer_id = 0; | 576 uint16 manufacturer_id = 0; |
562 uint32 serial_number = 0; | 577 uint32 serial_number = 0; |
563 std::string name; | 578 std::string name; |
564 ui::GetOutputDeviceData( | 579 ui::GetOutputDeviceData( |
565 outputs[i], &manufacturer_id, &serial_number, &name); | 580 outputs[i], &manufacturer_id, &serial_number, &name); |
566 int64 id = gfx::Display::GetID(manufacturer_id, serial_number); | 581 int64 id = gfx::Display::GetID(manufacturer_id, serial_number); |
567 if (IsInternalDisplayId(id)) { | 582 if (IsInternalDisplayId(id)) { |
568 display_info_[id].name = | 583 display_info_[id].name = |
569 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME); | 584 l10n_util::GetStringUTF8(IDS_ASH_INTERNAL_DISPLAY_NAME); |
570 } else if (!name.empty()) { | 585 } else if (!name.empty()) { |
571 display_info_[id].name = name; | 586 display_info_[id].name = name; |
572 } | 587 } |
588 | |
589 bool overscan = false; | |
590 if (ui::GetOutputOverscanFlag(outputs[i], &overscan)) { | |
591 display_info_[id].overscan = true; | |
592 } | |
oshima
2013/01/12 02:06:38
the code looks a bit odd. Won't
ui::GetOutputOve
Jun Mukai
2013/01/14 18:18:51
Done.
| |
573 } | 593 } |
574 #endif | 594 #endif |
575 } | 595 } |
576 | 596 |
577 void DisplayManager::SetDisplayIdsForTest(DisplayList* to_update) const { | 597 void DisplayManager::SetDisplayIdsForTest(DisplayList* to_update) const { |
578 DisplayList::iterator iter_to_update = to_update->begin(); | 598 DisplayList::iterator iter_to_update = to_update->begin(); |
579 DisplayList::const_iterator iter = displays_.begin(); | 599 DisplayList::const_iterator iter = displays_.begin(); |
580 for (; iter != displays_.end() && iter_to_update != to_update->end(); | 600 for (; iter != displays_.end() && iter_to_update != to_update->end(); |
581 ++iter, ++iter_to_update) { | 601 ++iter, ++iter_to_update) { |
582 (*iter_to_update).set_id((*iter).id()); | 602 (*iter_to_update).set_id((*iter).id()); |
583 } | 603 } |
584 } | 604 } |
585 | 605 |
586 } // namespace internal | 606 } // namespace internal |
587 } // namespace ash | 607 } // namespace ash |
OLD | NEW |