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

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

Issue 10817028: Add Fade-out/Fade-in animation during output-configuration change. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 4 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 <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #include <X11/extensions/dpms.h> 8 #include <X11/extensions/dpms.h>
9 #include <X11/extensions/Xrandr.h> 9 #include <X11/extensions/Xrandr.h>
10 10
11 // Xlib defines Status as int which causes our include of dbus/bus.h to fail 11 // Xlib defines Status as int which causes our include of dbus/bus.h to fail
12 // when it tries to name an enum Status. Thus, we need to undefine it (note 12 // when it tries to name an enum Status. Thus, we need to undefine it (note
13 // that this will cause a problem if code needs to use the Status type). 13 // that this will cause a problem if code needs to use the Status type).
14 // RootWindow causes similar problems in that there is a Chromium type with that 14 // RootWindow causes similar problems in that there is a Chromium type with that
15 // name. 15 // name.
16 #undef Status 16 #undef Status
17 #undef RootWindow 17 #undef RootWindow
18 18
19 #include "base/bind.h"
19 #include "base/chromeos/chromeos_version.h" 20 #include "base/chromeos/chromeos_version.h"
20 #include "base/logging.h" 21 #include "base/logging.h"
21 #include "base/message_pump_aurax11.h" 22 #include "base/message_pump_aurax11.h"
22 #include "base/metrics/histogram.h" 23 #include "base/metrics/histogram.h"
23 #include "base/perftimer.h" 24 #include "base/perftimer.h"
24 #include "chromeos/dbus/dbus_thread_manager.h" 25 #include "chromeos/dbus/dbus_thread_manager.h"
25 #include "dbus/bus.h" 26 #include "dbus/bus.h"
26 #include "dbus/exported_object.h" 27 #include "dbus/exported_object.h"
27 #include "dbus/message.h" 28 #include "dbus/message.h"
28 #include "dbus/object_path.h" 29 #include "dbus/object_path.h"
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 Window window = DefaultRootWindow(display); 393 Window window = DefaultRootWindow(display);
393 XRRScreenResources* screen = XRRGetScreenResources(display, window); 394 XRRScreenResources* screen = XRRGetScreenResources(display, window);
394 CHECK(screen != NULL); 395 CHECK(screen != NULL);
395 396
396 UpdateCacheAndXrandrToState(display, 397 UpdateCacheAndXrandrToState(display,
397 screen, 398 screen,
398 window, 399 window,
399 new_state); 400 new_state);
400 XRRFreeScreenResources(screen); 401 XRRFreeScreenResources(screen);
401 XUngrabServer(display); 402 XUngrabServer(display);
403
404 MessageLoop::current()->PostTask(
405 FROM_HERE, base::Bind(&OutputConfigurator::NotifyOnDisplayChanged,
406 base::Unretained(this)));
407
402 return true; 408 return true;
403 } 409 }
404 410
405 bool OutputConfigurator::Dispatch(const base::NativeEvent& event) { 411 bool OutputConfigurator::Dispatch(const base::NativeEvent& event) {
406 // Ignore this event if the Xrandr extension isn't supported. 412 // Ignore this event if the Xrandr extension isn't supported.
407 if (!is_running_on_chrome_os_ || 413 if (!is_running_on_chrome_os_ ||
408 (event->type - xrandr_event_base_ != RRNotify)) { 414 (event->type - xrandr_event_base_ != RRNotify)) {
409 return true; 415 return true;
410 } 416 }
411 XEvent* xevent = static_cast<XEvent*>(event); 417 XEvent* xevent = static_cast<XEvent*>(event);
412 XRRNotifyEvent* notify_event = 418 XRRNotifyEvent* notify_event =
413 reinterpret_cast<XRRNotifyEvent*>(xevent); 419 reinterpret_cast<XRRNotifyEvent*>(xevent);
414 if (notify_event->subtype == RRNotify_OutputChange) { 420 if (notify_event->subtype == RRNotify_OutputChange) {
415 XRROutputChangeNotifyEvent* output_change_event = 421 XRROutputChangeNotifyEvent* output_change_event =
416 reinterpret_cast<XRROutputChangeNotifyEvent*>(xevent); 422 reinterpret_cast<XRROutputChangeNotifyEvent*>(xevent);
417 if ((output_change_event->connection == RR_Connected) || 423 if ((output_change_event->connection == RR_Connected) ||
418 (output_change_event->connection == RR_Disconnected)) { 424 (output_change_event->connection == RR_Disconnected)) {
419 RecacheAndUseDefaultState(); 425 RecacheAndUseDefaultState();
420 CheckIsProjectingAndNotify(); 426 CheckIsProjectingAndNotify();
421 } 427 }
422 // Ignore the case of RR_UnkownConnection. 428 // Ignore the case of RR_UnkownConnection.
423 } 429 }
424 return true; 430 return true;
425 } 431 }
426 432
433 void OutputConfigurator::AddObserver(Observer* observer) {
434 observers_.AddObserver(observer);
435 }
436
437 void OutputConfigurator::RemoveObserver(Observer* observer) {
438 observers_.RemoveObserver(observer);
439 }
440
427 bool OutputConfigurator::TryRecacheOutputs(Display* display, 441 bool OutputConfigurator::TryRecacheOutputs(Display* display,
428 XRRScreenResources* screen) { 442 XRRScreenResources* screen) {
429 bool outputs_did_change = false; 443 bool outputs_did_change = false;
430 int previous_connected_count = 0; 444 int previous_connected_count = 0;
431 int new_connected_count = 0; 445 int new_connected_count = 0;
432 446
433 if (output_count_ != screen->noutput) { 447 if (output_count_ != screen->noutput) {
434 outputs_did_change = true; 448 outputs_did_change = true;
435 } else { 449 } else {
436 // The outputs might have changed so compare the connected states in the 450 // The outputs might have changed so compare the connected states in the
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 power_manager::kPowerManagerInterface, 850 power_manager::kPowerManagerInterface,
837 power_manager::kSetIsProjectingMethod); 851 power_manager::kSetIsProjectingMethod);
838 dbus::MessageWriter writer(&method_call); 852 dbus::MessageWriter writer(&method_call);
839 writer.AppendBool(is_projecting); 853 writer.AppendBool(is_projecting);
840 power_manager_proxy->CallMethod( 854 power_manager_proxy->CallMethod(
841 &method_call, 855 &method_call,
842 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, 856 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
843 dbus::ObjectProxy::EmptyResponseCallback()); 857 dbus::ObjectProxy::EmptyResponseCallback());
844 } 858 }
845 859
860 void OutputConfigurator::NotifyOnDisplayChanged() {
861 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChanged());
862 }
863
846 } // namespace chromeos 864 } // 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