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 "chromeos/display/output_configurator.h" | 5 #include "chromeos/display/output_configurator.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include <X11/Xatom.h> | 9 #include <X11/Xatom.h> |
10 #include <X11/Xlib.h> | 10 #include <X11/Xlib.h> |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
527 : is_running_on_chrome_os_(base::chromeos::IsRunningOnChromeOS()), | 527 : is_running_on_chrome_os_(base::chromeos::IsRunningOnChromeOS()), |
528 is_panel_fitting_enabled_(false), | 528 is_panel_fitting_enabled_(false), |
529 connected_output_count_(0), | 529 connected_output_count_(0), |
530 xrandr_event_base_(0), | 530 xrandr_event_base_(0), |
531 output_state_(STATE_INVALID), | 531 output_state_(STATE_INVALID), |
532 mirror_mode_will_preserve_aspect_(false), | 532 mirror_mode_will_preserve_aspect_(false), |
533 mirror_mode_preserved_aspect_(false), | 533 mirror_mode_preserved_aspect_(false), |
534 last_enter_state_time_() { | 534 last_enter_state_time_() { |
535 } | 535 } |
536 | 536 |
537 void OutputConfigurator::Init(bool is_panel_fitting_enabled) { | 537 OutputConfigurator::~OutputConfigurator() { |
538 RecordPreviousStateUMA(); | |
539 } | |
540 | |
541 void OutputConfigurator::Init(bool is_panel_fitting_enabled, | |
542 bool is_first_run_after_boot) { | |
538 if (!is_running_on_chrome_os_) | 543 if (!is_running_on_chrome_os_) |
539 return; | 544 return; |
540 | 545 |
541 is_panel_fitting_enabled_ = is_panel_fitting_enabled; | 546 is_panel_fitting_enabled_ = is_panel_fitting_enabled; |
542 | 547 |
543 // Cache the initial output state. | 548 // Cache the initial output state. |
544 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); | 549 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); |
545 CHECK(display != NULL); | 550 CHECK(display != NULL); |
546 XGrabServer(display); | 551 XGrabServer(display); |
547 Window window = DefaultRootWindow(display); | 552 Window window = DefaultRootWindow(display); |
548 XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window); | 553 XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window); |
549 CHECK(screen != NULL); | 554 CHECK(screen != NULL); |
550 | 555 |
551 // Detect our initial state. | 556 // Detect our initial state. |
552 std::vector<OutputSnapshot> outputs = GetDualOutputs(display, screen); | 557 std::vector<OutputSnapshot> outputs = GetDualOutputs(display, screen); |
553 connected_output_count_ = outputs.size(); | 558 connected_output_count_ = outputs.size(); |
559 | |
560 if (is_first_run_after_boot && outputs.size() > 1) { | |
561 // Configuring the CRTC/Framebuffer clears the boot screen image. | |
562 // Set the same background color (0xfefefe) while configuring the | |
563 // display to minimize the duration of black screen at boot | |
564 // time. The background will be removed when | |
565 // aura::RootWindowHostLinux is created. | |
566 // crbug.com/171050. | |
567 XColor color; | |
568 Colormap colormap = DefaultColormap(display, 0); | |
569 char chromeos_backcolor[] = "#FEFEFE"; | |
Daniel Erat
2013/01/26 15:52:30
don't hardcode this here; i think it's defined as
oshima
2013/01/26 23:10:42
I couldn't find one for sharing, but found this on
| |
570 XParseColor(display, colormap, chromeos_backcolor, &color); | |
571 XAllocColor(display, colormap, &color); | |
572 XSetWindowAttributes swa = {0}; | |
573 swa.background_pixel = color.pixel; | |
574 XChangeWindowAttributes(display, window, CWBackPixel, &swa); | |
575 XFreeColors(display, colormap, &color.pixel, 1, 0); | |
576 } | |
577 | |
554 output_state_ = InferCurrentState(display, screen, outputs); | 578 output_state_ = InferCurrentState(display, screen, outputs); |
555 // Ensure that we are in a supported state with all connected displays powered | 579 // Ensure that we are in a supported state with all connected displays powered |
556 // on. | 580 // on. |
557 OutputState starting_state = GetNextState(display, | 581 OutputState starting_state = GetNextState(display, |
558 screen, | 582 screen, |
559 STATE_INVALID, | 583 STATE_INVALID, |
560 outputs); | 584 outputs); |
561 if (output_state_ != starting_state && | 585 if (output_state_ != starting_state && |
562 EnterState(display, | 586 EnterState(display, |
563 screen, | 587 screen, |
(...skipping 14 matching lines...) Expand all Loading... | |
578 CHECK(DPMSForceLevel(display, DPMSModeOn)); | 602 CHECK(DPMSForceLevel(display, DPMSModeOn)); |
579 | 603 |
580 // Relinquish X resources. | 604 // Relinquish X resources. |
581 XRRFreeScreenResources(screen); | 605 XRRFreeScreenResources(screen); |
582 XUngrabServer(display); | 606 XUngrabServer(display); |
583 | 607 |
584 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 608 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
585 SetIsProjecting(is_projecting); | 609 SetIsProjecting(is_projecting); |
586 } | 610 } |
587 | 611 |
588 OutputConfigurator::~OutputConfigurator() { | |
589 RecordPreviousStateUMA(); | |
590 } | |
591 | |
592 bool OutputConfigurator::CycleDisplayMode() { | 612 bool OutputConfigurator::CycleDisplayMode() { |
593 VLOG(1) << "CycleDisplayMode"; | 613 VLOG(1) << "CycleDisplayMode"; |
594 if (!is_running_on_chrome_os_) | 614 if (!is_running_on_chrome_os_) |
595 return false; | 615 return false; |
596 | 616 |
597 bool did_change = false; | 617 bool did_change = false; |
598 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); | 618 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); |
599 CHECK(display != NULL); | 619 CHECK(display != NULL); |
600 XGrabServer(display); | 620 XGrabServer(display); |
601 Window window = DefaultRootWindow(display); | 621 Window window = DefaultRootWindow(display); |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1306 // static | 1326 // static |
1307 RRMode OutputConfigurator::GetOutputNativeMode( | 1327 RRMode OutputConfigurator::GetOutputNativeMode( |
1308 const XRROutputInfo* output_info) { | 1328 const XRROutputInfo* output_info) { |
1309 if (output_info->nmode <= 0) | 1329 if (output_info->nmode <= 0) |
1310 return None; | 1330 return None; |
1311 | 1331 |
1312 return output_info->modes[0]; | 1332 return output_info->modes[0]; |
1313 } | 1333 } |
1314 | 1334 |
1315 } // namespace chromeos | 1335 } // namespace chromeos |
OLD | NEW |