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

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: remove persistent_id() and change id() to int64 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 std::string unused_name;
158 if (ui::GetOutputDeviceData(screen_resources->outputs[o], &manufacturer_id,
159 &serial_number, &unused_name)) {
160 displays.back().set_id(
161 gfx::Display::GetID(manufacturer_id, serial_number));
162 }
oshima 2012/08/10 03:09:51 Please add comment that we fallback the to use ind
Jun Mukai 2012/08/10 09:39:52 Done.
163
153 displays.back().set_device_scale_factor(device_scale_factor); 164 displays.back().set_device_scale_factor(device_scale_factor);
154 y_coords.insert(crtc_info->y); 165 y_coords.insert(crtc_info->y);
155 XRRFreeOutputInfo(output_info); 166 XRRFreeOutputInfo(output_info);
156 } 167 }
157 168
158 // Free all allocated resources. 169 // Free all allocated resources.
159 for (std::map<XID, XRRCrtcInfo*>::const_iterator iter = crtc_info_map.begin(); 170 for (std::map<XID, XRRCrtcInfo*>::const_iterator iter = crtc_info_map.begin();
160 iter != crtc_info_map.end(); ++iter) { 171 iter != crtc_info_map.end(); ++iter) {
161 XRRFreeCrtcInfo(iter->second); 172 XRRFreeCrtcInfo(iter->second);
162 } 173 }
163 XRRFreeScreenResources(screen_resources); 174 XRRFreeScreenResources(screen_resources);
164 175
165 // PowerManager lays out the outputs vertically. Sort them by Y 176 // PowerManager lays out the outputs vertically. Sort them by Y
166 // coordinates. 177 // coordinates.
167 std::sort(displays.begin(), displays.end(), CompareDisplayY); 178 std::sort(displays.begin(), displays.end(), CompareDisplayY);
168 // TODO(oshima): Assisgn index as ID for now. Use unique ID.
169 int id = 0; 179 int id = 0;
170 for (std::vector<gfx::Display>::iterator iter = displays.begin(); 180 for (std::vector<gfx::Display>::iterator iter = displays.begin();
171 iter != displays.end(); ++iter, ++id) 181 iter != displays.end(); ++iter, ++id) {
172 (*iter).set_id(id); 182 if (iter->id() == -1)
183 iter->set_id(id);
184 }
173 185
174 Env::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays); 186 Env::GetInstance()->display_manager()->OnNativeDisplaysChanged(displays);
175 } 187 }
176 188
177 } // namespace internal 189 } // namespace internal
178 } // namespace aura 190 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698