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

Side by Side Diff: chromeos/display/output_configurator.cc

Issue 12367007: Don't handle display change event/requests to avoid being killed by session manager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « chromeos/display/output_configurator.h ('k') | no next file » | 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 "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 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 } 519 }
520 if (props) 520 if (props)
521 XFree(props); 521 XFree(props);
522 522
523 return ret; 523 return ret;
524 } 524 }
525 525
526 } // namespace 526 } // namespace
527 527
528 OutputConfigurator::OutputConfigurator() 528 OutputConfigurator::OutputConfigurator()
529 : is_running_on_chrome_os_(base::chromeos::IsRunningOnChromeOS()), 529 // If we aren't running on ChromeOS (like linux desktop),
530 // don't try to configure display.
531 : configure_display_(base::chromeos::IsRunningOnChromeOS()),
530 is_panel_fitting_enabled_(false), 532 is_panel_fitting_enabled_(false),
531 connected_output_count_(0), 533 connected_output_count_(0),
532 xrandr_event_base_(0), 534 xrandr_event_base_(0),
533 output_state_(STATE_INVALID), 535 output_state_(STATE_INVALID),
534 mirror_mode_will_preserve_aspect_(false), 536 mirror_mode_will_preserve_aspect_(false),
535 mirror_mode_preserved_aspect_(false), 537 mirror_mode_preserved_aspect_(false),
536 last_enter_state_time_() { 538 last_enter_state_time_() {
537 } 539 }
538 540
539 OutputConfigurator::~OutputConfigurator() { 541 OutputConfigurator::~OutputConfigurator() {
540 RecordPreviousStateUMA(); 542 RecordPreviousStateUMA();
541 } 543 }
542 544
543 void OutputConfigurator::Init(bool is_panel_fitting_enabled, 545 void OutputConfigurator::Init(bool is_panel_fitting_enabled,
544 uint32 background_color_argb) { 546 uint32 background_color_argb) {
545 TRACE_EVENT0("chromeos", "OutputConfigurator::Init"); 547 TRACE_EVENT0("chromeos", "OutputConfigurator::Init");
546 if (!is_running_on_chrome_os_) 548 if (!configure_display_)
547 return; 549 return;
548 is_panel_fitting_enabled_ = is_panel_fitting_enabled; 550 is_panel_fitting_enabled_ = is_panel_fitting_enabled;
549 551
550 // Cache the initial output state. 552 // Cache the initial output state.
551 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); 553 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay();
552 CHECK(display != NULL); 554 CHECK(display != NULL);
553 XGrabServer(display); 555 XGrabServer(display);
554 Window window = DefaultRootWindow(display); 556 Window window = DefaultRootWindow(display);
555 XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window); 557 XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window);
556 CHECK(screen != NULL); 558 CHECK(screen != NULL);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 CHECK(DPMSForceLevel(display, DPMSModeOn)); 608 CHECK(DPMSForceLevel(display, DPMSModeOn));
607 609
608 // Relinquish X resources. 610 // Relinquish X resources.
609 XRRFreeScreenResources(screen); 611 XRRFreeScreenResources(screen);
610 XUngrabServer(display); 612 XUngrabServer(display);
611 613
612 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 614 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
613 SetIsProjecting(is_projecting); 615 SetIsProjecting(is_projecting);
614 } 616 }
615 617
618 void OutputConfigurator::Stop() {
619 configure_display_ = false;
620 }
621
616 bool OutputConfigurator::CycleDisplayMode() { 622 bool OutputConfigurator::CycleDisplayMode() {
617 TRACE_EVENT0("chromeos", "OutputConfigurator::CycleDisplayMode"); 623 TRACE_EVENT0("chromeos", "OutputConfigurator::CycleDisplayMode");
618 VLOG(1) << "CycleDisplayMode"; 624 VLOG(1) << "CycleDisplayMode";
619 if (!is_running_on_chrome_os_) 625 if (!configure_display_)
620 return false; 626 return false;
621 627
622 bool did_change = false; 628 bool did_change = false;
623 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); 629 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay();
624 CHECK(display != NULL); 630 CHECK(display != NULL);
625 XGrabServer(display); 631 XGrabServer(display);
626 Window window = DefaultRootWindow(display); 632 Window window = DefaultRootWindow(display);
627 XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window); 633 XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window);
628 CHECK(screen != NULL); 634 CHECK(screen != NULL);
629 635
(...skipping 17 matching lines...) Expand all
647 NotifyOnDisplayChanged(); 653 NotifyOnDisplayChanged();
648 else 654 else
649 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChangeFailed()); 655 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChangeFailed());
650 return did_change; 656 return did_change;
651 } 657 }
652 658
653 bool OutputConfigurator::ScreenPowerSet(bool power_on, bool all_displays) { 659 bool OutputConfigurator::ScreenPowerSet(bool power_on, bool all_displays) {
654 TRACE_EVENT0("chromeos", "OutputConfigurator::ScreenPowerSet"); 660 TRACE_EVENT0("chromeos", "OutputConfigurator::ScreenPowerSet");
655 VLOG(1) << "OutputConfigurator::SetScreensOn " << power_on 661 VLOG(1) << "OutputConfigurator::SetScreensOn " << power_on
656 << " all displays " << all_displays; 662 << " all displays " << all_displays;
657 if (!is_running_on_chrome_os_) 663 if (!configure_display_)
658 return false; 664 return false;
659 665
660 bool success = false; 666 bool success = false;
661 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); 667 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay();
662 CHECK(display != NULL); 668 CHECK(display != NULL);
663 XGrabServer(display); 669 XGrabServer(display);
664 Window window = DefaultRootWindow(display); 670 Window window = DefaultRootWindow(display);
665 XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window); 671 XRRScreenResources* screen = GetScreenResourcesAndRecordUMA(display, window);
666 CHECK(screen != NULL); 672 CHECK(screen != NULL);
667 673
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 NotifyOnDisplayChanged(); 758 NotifyOnDisplayChanged();
753 else 759 else
754 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChangeFailed()); 760 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChangeFailed());
755 return true; 761 return true;
756 } 762 }
757 763
758 bool OutputConfigurator::Dispatch(const base::NativeEvent& event) { 764 bool OutputConfigurator::Dispatch(const base::NativeEvent& event) {
759 TRACE_EVENT0("chromeos", "OutputConfigurator::Dispatch"); 765 TRACE_EVENT0("chromeos", "OutputConfigurator::Dispatch");
760 if (event->type - xrandr_event_base_ == RRScreenChangeNotify) 766 if (event->type - xrandr_event_base_ == RRScreenChangeNotify)
761 XRRUpdateConfiguration(event); 767 XRRUpdateConfiguration(event);
762 // Ignore this event if the Xrandr extension isn't supported. 768 // Ignore this event if the Xrandr extension isn't supported, or
763 if (!is_running_on_chrome_os_ || 769 // the device is being shutdown.
770 if (!configure_display_ ||
764 (event->type - xrandr_event_base_ != RRNotify)) { 771 (event->type - xrandr_event_base_ != RRNotify)) {
765 return true; 772 return true;
766 } 773 }
767 XEvent* xevent = static_cast<XEvent*>(event); 774 XEvent* xevent = static_cast<XEvent*>(event);
768 XRRNotifyEvent* notify_event = 775 XRRNotifyEvent* notify_event =
769 reinterpret_cast<XRRNotifyEvent*>(xevent); 776 reinterpret_cast<XRRNotifyEvent*>(xevent);
770 if (notify_event->subtype == RRNotify_OutputChange) { 777 if (notify_event->subtype == RRNotify_OutputChange) {
771 XRROutputChangeNotifyEvent* output_change_event = 778 XRROutputChangeNotifyEvent* output_change_event =
772 reinterpret_cast<XRROutputChangeNotifyEvent*>(xevent); 779 reinterpret_cast<XRROutputChangeNotifyEvent*>(xevent);
773 if ((output_change_event->connection == RR_Connected) || 780 if ((output_change_event->connection == RR_Connected) ||
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
1337 // static 1344 // static
1338 RRMode OutputConfigurator::GetOutputNativeMode( 1345 RRMode OutputConfigurator::GetOutputNativeMode(
1339 const XRROutputInfo* output_info) { 1346 const XRROutputInfo* output_info) {
1340 if (output_info->nmode <= 0) 1347 if (output_info->nmode <= 0)
1341 return None; 1348 return None;
1342 1349
1343 return output_info->modes[0]; 1350 return output_info->modes[0];
1344 } 1351 }
1345 1352
1346 } // namespace chromeos 1353 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/display/output_configurator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698