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

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

Issue 15067012: Move chromeos specific utility functions for display to chromeos/display (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/real_output_configurator_delegate.h" 5 #include "chromeos/display/real_output_configurator_delegate.h"
6 6
7 #include <X11/Xatom.h> 7 #include <X11/Xatom.h>
8 #include <X11/Xlib.h> 8 #include <X11/Xlib.h>
9 #include <X11/extensions/dpms.h> 9 #include <X11/extensions/dpms.h>
10 #include <X11/extensions/XInput.h> 10 #include <X11/extensions/XInput.h>
11 #include <X11/extensions/XInput2.h> 11 #include <X11/extensions/XInput2.h>
12 #include <X11/extensions/Xrandr.h> 12 #include <X11/extensions/Xrandr.h>
13 13
14 #include <cmath> 14 #include <cmath>
15 15
16 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/message_pump_aurax11.h" 17 #include "base/message_pump_aurax11.h"
18 #include "chromeos/dbus/dbus_thread_manager.h" 18 #include "chromeos/dbus/dbus_thread_manager.h"
19 #include "chromeos/dbus/power_manager_client.h" 19 #include "chromeos/dbus/power_manager_client.h"
20 #include "chromeos/display/output_util.h"
20 21
21 namespace chromeos { 22 namespace chromeos {
22 23
23 namespace { 24 namespace {
24 25
25 // DPI measurements. 26 // DPI measurements.
26 const float kMmInInch = 25.4; 27 const float kMmInInch = 25.4;
27 const float kDpi96 = 96.0; 28 const float kDpi96 = 96.0;
28 const float kPixelsToMmScale = kMmInInch / kDpi96; 29 const float kPixelsToMmScale = kMmInInch / kDpi96;
29 30
30 bool IsInternalOutput(const XRROutputInfo* output_info) { 31 bool IsInternalOutput(const XRROutputInfo* output_info) {
31 return OutputConfigurator::IsInternalOutputName( 32 return IsInternalOutputName(std::string(output_info->name));
32 std::string(output_info->name));
33 } 33 }
34 34
35 RRMode GetOutputNativeMode(const XRROutputInfo* output_info) { 35 RRMode GetOutputNativeMode(const XRROutputInfo* output_info) {
36 return output_info->nmode > 0 ? output_info->modes[0] : None; 36 return output_info->nmode > 0 ? output_info->modes[0] : None;
37 } 37 }
38 38
39 } // namespace 39 } // namespace
40 40
41 RealOutputConfiguratorDelegate::RealOutputConfiguratorDelegate() 41 RealOutputConfiguratorDelegate::RealOutputConfiguratorDelegate()
42 : display_(base::MessagePumpAuraX11::GetDefaultXDisplay()), 42 : display_(base::MessagePumpAuraX11::GetDefaultXDisplay()),
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 RRCrtc last_used_crtc = None; 114 RRCrtc last_used_crtc = None;
115 115
116 for (int i = 0; i < screen_->noutput && outputs.size() < 2; ++i) { 116 for (int i = 0; i < screen_->noutput && outputs.size() < 2; ++i) {
117 RROutput this_id = screen_->outputs[i]; 117 RROutput this_id = screen_->outputs[i];
118 XRROutputInfo* output_info = XRRGetOutputInfo(display_, screen_, this_id); 118 XRROutputInfo* output_info = XRRGetOutputInfo(display_, screen_, this_id);
119 bool is_connected = (output_info->connection == RR_Connected); 119 bool is_connected = (output_info->connection == RR_Connected);
120 120
121 if (is_connected) { 121 if (is_connected) {
122 OutputConfigurator::OutputSnapshot to_populate; 122 OutputConfigurator::OutputSnapshot to_populate;
123 to_populate.output = this_id; 123 to_populate.output = this_id;
124 GetDisplayId(this_id, i, &to_populate.display_id);
124 (outputs.empty() ? one_info : two_info) = output_info; 125 (outputs.empty() ? one_info : two_info) = output_info;
125 126
126 // Now, look up the current CRTC and any related info. 127 // Now, look up the current CRTC and any related info.
127 if (output_info->crtc) { 128 if (output_info->crtc) {
128 XRRCrtcInfo* crtc_info = XRRGetCrtcInfo( 129 XRRCrtcInfo* crtc_info = XRRGetCrtcInfo(
129 display_, screen_, output_info->crtc); 130 display_, screen_, output_info->crtc);
130 to_populate.current_mode = crtc_info->mode; 131 to_populate.current_mode = crtc_info->mode;
131 to_populate.height = crtc_info->height; 132 to_populate.height = crtc_info->height;
132 to_populate.y = crtc_info->y; 133 to_populate.y = crtc_info->y;
133 XRRFreeCrtcInfo(crtc_info); 134 XRRFreeCrtcInfo(crtc_info);
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 << " id " << info[i].deviceid 562 << " id " << info[i].deviceid
562 << " width " << width 563 << " width " << width
563 << " height " << height; 564 << " height " << height;
564 } 565 }
565 } 566 }
566 567
567 XIFreeDeviceInfo(info); 568 XIFreeDeviceInfo(info);
568 } 569 }
569 570
570 } // namespace chromeos 571 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698