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: chromeos/display/output_configurator.cc

Issue 10831312: Remove direct DBus calls from OutputConfigurator (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
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
« no previous file with comments | « chromeos/display/DEPS ('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/bind.h"
20 #include "base/chromeos/chromeos_version.h" 20 #include "base/chromeos/chromeos_version.h"
21 #include "base/logging.h" 21 #include "base/logging.h"
22 #include "base/message_pump_aurax11.h" 22 #include "base/message_pump_aurax11.h"
23 #include "base/metrics/histogram.h" 23 #include "base/metrics/histogram.h"
24 #include "base/perftimer.h" 24 #include "base/perftimer.h"
25 #include "chromeos/dbus/dbus_thread_manager.h" 25 #include "chromeos/dbus/dbus_thread_manager.h"
26 #include "dbus/bus.h" 26 #include "chromeos/dbus/power_manager_client.h"
27 #include "dbus/exported_object.h"
28 #include "dbus/message.h"
29 #include "dbus/object_path.h"
30 #include "dbus/object_proxy.h"
31 #include "third_party/cros_system_api/dbus/service_constants.h"
32 27
33 namespace chromeos { 28 namespace chromeos {
34 29
35 namespace { 30 namespace {
36 // DPI measurements. 31 // DPI measurements.
37 const float kMmInInch = 25.4; 32 const float kMmInInch = 25.4;
38 const float kDpi96 = 96.0; 33 const float kDpi96 = 96.0;
39 const float kPixelsToMmScale = kMmInInch / kDpi96; 34 const float kPixelsToMmScale = kMmInInch / kDpi96;
40 35
41 // The DPI threshold to detech high density screen. 36 // The DPI threshold to detech high density screen.
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 is_extended_display_enabled_(is_extended_display_enabled), 223 is_extended_display_enabled_(is_extended_display_enabled),
229 output_count_(0), 224 output_count_(0),
230 output_cache_(NULL), 225 output_cache_(NULL),
231 mirror_supported_(false), 226 mirror_supported_(false),
232 primary_output_index_(-1), 227 primary_output_index_(-1),
233 secondary_output_index_(-1), 228 secondary_output_index_(-1),
234 xrandr_event_base_(0), 229 xrandr_event_base_(0),
235 output_state_(STATE_INVALID) { 230 output_state_(STATE_INVALID) {
236 if (!is_running_on_chrome_os_) 231 if (!is_running_on_chrome_os_)
237 return; 232 return;
238 // Send the signal to powerd to tell it that we will take over output
239 // control.
240 // Note that this can be removed once the legacy powerd support is removed.
241 chromeos::DBusThreadManager* manager = chromeos::DBusThreadManager::Get();
242 dbus::Bus* bus = manager->GetSystemBus();
243 if (bus) {
244 dbus::ExportedObject* remote_object = bus->GetExportedObject(
245 dbus::ObjectPath(power_manager::kPowerManagerServicePath));
246 dbus::Signal signal(power_manager::kPowerManagerInterface,
247 power_manager::kUseNewMonitorConfigSignal);
248 CHECK(signal.raw_message() != NULL);
249 remote_object->SendSignal(&signal);
250 }
251 233
252 // Cache the initial output state. 234 // Cache the initial output state.
253 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay(); 235 Display* display = base::MessagePumpAuraX11::GetDefaultXDisplay();
254 CHECK(display != NULL); 236 CHECK(display != NULL);
255 XGrabServer(display); 237 XGrabServer(display);
256 Window window = DefaultRootWindow(display); 238 Window window = DefaultRootWindow(display);
257 XRRScreenResources* screen = XRRGetScreenResources(display, window); 239 XRRScreenResources* screen = XRRGetScreenResources(display, window);
258 CHECK(screen != NULL); 240 CHECK(screen != NULL);
259 bool did_detect_outputs = TryRecacheOutputs(display, screen); 241 bool did_detect_outputs = TryRecacheOutputs(display, screen);
260 CHECK(did_detect_outputs); 242 CHECK(did_detect_outputs);
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 for (int i = 0; i < output_count_; ++i) { 826 for (int i = 0; i < output_count_; ++i) {
845 if (output_cache_[i].is_connected) { 827 if (output_cache_[i].is_connected) {
846 connected_output_count += 1; 828 connected_output_count += 1;
847 has_internal_output |= output_cache_[i].is_internal; 829 has_internal_output |= output_cache_[i].is_internal;
848 } 830 }
849 } 831 }
850 832
851 // "Projecting" is defined as having more than 1 output connected while at 833 // "Projecting" is defined as having more than 1 output connected while at
852 // least one of them is an internal output. 834 // least one of them is an internal output.
853 bool is_projecting = has_internal_output && (connected_output_count > 1); 835 bool is_projecting = has_internal_output && (connected_output_count > 1);
854 chromeos::DBusThreadManager* manager = chromeos::DBusThreadManager::Get(); 836 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()
855 dbus::Bus* bus = manager->GetSystemBus(); 837 ->SetIsProjecting(is_projecting);
856 if (bus) {
857 dbus::ObjectProxy* power_manager_proxy = bus->GetObjectProxy(
858 power_manager::kPowerManagerServiceName,
859 dbus::ObjectPath(power_manager::kPowerManagerServicePath));
860 dbus::MethodCall method_call(
861 power_manager::kPowerManagerInterface,
862 power_manager::kSetIsProjectingMethod);
863 dbus::MessageWriter writer(&method_call);
864 writer.AppendBool(is_projecting);
865 power_manager_proxy->CallMethod(
866 &method_call,
867 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
868 dbus::ObjectProxy::EmptyResponseCallback());
869 }
870 } 838 }
871 839
872 void OutputConfigurator::NotifyOnDisplayChanged() { 840 void OutputConfigurator::NotifyOnDisplayChanged() {
873 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChanged()); 841 FOR_EACH_OBSERVER(Observer, observers_, OnDisplayModeChanged());
874 } 842 }
875 843
876 } // namespace chromeos 844 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/display/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698