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

Side by Side Diff: ui/aura/display_change_observer_x11.cc

Issue 10826198: Use persistent ID/names for displays. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 "ui/aura/display_change_observer_x11.h" 5 #include "ui/aura/display_change_observer_x11.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include <X11/extensions/Xrandr.h> 12 #include <X11/extensions/Xrandr.h>
13 13
14 #include "base/message_pump_aurax11.h" 14 #include "base/message_pump_aurax11.h"
15 #include "ui/aura/dispatcher_linux.h" 15 #include "ui/aura/dispatcher_linux.h"
16 #include "ui/aura/env.h" 16 #include "ui/aura/env.h"
17 #include "ui/aura/display_manager.h" 17 #include "ui/aura/display_manager.h"
18 #include "ui/base/x/x11_util.h"
18 #include "ui/compositor/dip_util.h" 19 #include "ui/compositor/dip_util.h"
19 #include "ui/gfx/display.h" 20 #include "ui/gfx/display.h"
20 21
21 namespace aura { 22 namespace aura {
22 namespace internal { 23 namespace internal {
23 24
24 namespace { 25 namespace {
25 26
26 // The DPI threshold to detect high density screen. 27 // The DPI threshold to detect high density screen.
27 // Higher DPI than this will use device_scale_factor=2. 28 // Higher DPI than this will use device_scale_factor=2.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 displays.push_back(gfx::Display( 144 displays.push_back(gfx::Display(
144 0, 145 0,
145 gfx::Rect(crtc_info->x, crtc_info->y, mode->width, mode->height))); 146 gfx::Rect(crtc_info->x, crtc_info->y, mode->width, mode->height)));
146 147
147 float device_scale_factor = 1.0f; 148 float device_scale_factor = 1.0f;
148 if (!ShouldIgnoreSize(output_info) && 149 if (!ShouldIgnoreSize(output_info) &&
149 (kInchInMm * mode->width / output_info->mm_width) > 150 (kInchInMm * mode->width / output_info->mm_width) >
150 kHighDensityDIPThreshold) { 151 kHighDensityDIPThreshold) {
151 device_scale_factor = 2.0f; 152 device_scale_factor = 2.0f;
152 } 153 }
154
155 uint16 manufacturer_id = 0;
156 uint32 serial_number = 0;
157 if (ui::GetOutputDeviceData(screen_resources->outputs[o], &manufacturer_id,
158 &serial_number, NULL)) {
Daniel Erat 2012/08/16 15:28:49 maybe also check that manufacturer_id is greater t
Jun Mukai 2012/08/17 05:50:10 Done.
159 // Fallback to use index in case that it fails to retrieve these data.
Daniel Erat 2012/08/16 15:28:49 nit: change to something like "An ID based on the
Jun Mukai 2012/08/17 05:50:10 Done.
160 // See below.
161 displays.back().set_id(
162 gfx::Display::GetID(manufacturer_id, serial_number));
163 }
164
153 displays.back().set_device_scale_factor(device_scale_factor); 165 displays.back().set_device_scale_factor(device_scale_factor);
154 y_coords.insert(crtc_info->y); 166 y_coords.insert(crtc_info->y);
155 XRRFreeOutputInfo(output_info); 167 XRRFreeOutputInfo(output_info);
156 } 168 }
157 169
158 // Free all allocated resources. 170 // Free all allocated resources.
159 for (std::map<XID, XRRCrtcInfo*>::const_iterator iter = crtc_info_map.begin(); 171 for (std::map<XID, XRRCrtcInfo*>::const_iterator iter = crtc_info_map.begin();
160 iter != crtc_info_map.end(); ++iter) { 172 iter != crtc_info_map.end(); ++iter) {
161 XRRFreeCrtcInfo(iter->second); 173 XRRFreeCrtcInfo(iter->second);
162 } 174 }
163 XRRFreeScreenResources(screen_resources); 175 XRRFreeScreenResources(screen_resources);
164 176
165 // PowerManager lays out the outputs vertically. Sort them by Y 177 // PowerManager lays out the outputs vertically. Sort them by Y
166 // coordinates. 178 // coordinates.
167 std::sort(displays.begin(), displays.end(), CompareDisplayY); 179 std::sort(displays.begin(), displays.end(), CompareDisplayY);
168 // TODO(oshima): Assisgn index as ID for now. Use unique ID.
169 int id = 0; 180 int id = 0;
170 for (std::vector<gfx::Display>::iterator iter = displays.begin(); 181 for (std::vector<gfx::Display>::iterator iter = displays.begin();
171 iter != displays.end(); ++iter, ++id) 182 iter != displays.end(); ++iter) {
172 (*iter).set_id(id); 183 if (iter->id() == -1) {
Daniel Erat 2012/08/16 15:28:49 nit: add a public constant static gfx::Display::kI
Jun Mukai 2012/08/17 05:50:10 Done.
184 iter->set_id(id);
185 ++id;
186 }
187 }
173 188
174 Env::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays); 189 Env::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays);
175 } 190 }
176 191
177 } // namespace internal 192 } // namespace internal
178 } // namespace aura 193 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698