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

Side by Side Diff: ash/display/display_change_observer_x11.cc

Issue 15830003: Manual Merge 201756 "Changes how to compute the id of a display." (2nd) (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1500/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
« no previous file with comments | « no previous file | ui/gfx/display.h » ('j') | 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 "ash/display/display_change_observer_x11.h" 5 #include "ash/display/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 "ash/display/display_controller.h" 14 #include "ash/display/display_controller.h"
15 #include "ash/display/display_info.h" 15 #include "ash/display/display_info.h"
16 #include "ash/display/display_manager.h" 16 #include "ash/display/display_manager.h"
17 #include "ash/shell.h" 17 #include "ash/shell.h"
18 #include "base/hash.h"
18 #include "base/message_pump_aurax11.h" 19 #include "base/message_pump_aurax11.h"
19 #include "grit/ash_strings.h" 20 #include "grit/ash_strings.h"
20 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/x/x11_util.h" 22 #include "ui/base/x/x11_util.h"
22 #include "ui/compositor/dip_util.h" 23 #include "ui/compositor/dip_util.h"
23 #include "ui/gfx/display.h" 24 #include "ui/gfx/display.h"
24 25
25 namespace ash { 26 namespace ash {
26 namespace internal { 27 namespace internal {
27 28
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 } 78 }
78 79
79 std::string GetDisplayName(XID output_id) { 80 std::string GetDisplayName(XID output_id) {
80 std::string display_name; 81 std::string display_name;
81 ui::GetOutputDeviceData(output_id, NULL, NULL, &display_name); 82 ui::GetOutputDeviceData(output_id, NULL, NULL, &display_name);
82 return display_name; 83 return display_name;
83 } 84 }
84 85
85 int64 GetDisplayId(XID output_id, int output_index) { 86 int64 GetDisplayId(XID output_id, int output_index) {
86 uint16 manufacturer_id = 0; 87 uint16 manufacturer_id = 0;
87 uint16 product_code = 0; 88 std::string product_name;
88 if (ui::GetOutputDeviceData( 89
89 output_id, &manufacturer_id, &product_code, NULL) && 90 // ui::GetOutputDeviceData fails if it doesn't have product_name.
90 manufacturer_id != 0) { 91 ui::GetOutputDeviceData(output_id, &manufacturer_id, NULL, &product_name);
92
93 // Generates product specific value from product_name instead of product code.
94 // See crbug.com/240341
95 uint32 product_code_hash = product_name.empty() ?
96 0 : base::Hash(product_name);
97 if (manufacturer_id != 0) {
91 // An ID based on display's index will be assigned later if this call 98 // An ID based on display's index will be assigned later if this call
92 // fails. 99 // fails.
93 return gfx::Display::GetID(manufacturer_id, product_code, output_index); 100 return gfx::Display::GetID(
101 manufacturer_id, product_code_hash, output_index);
94 } 102 }
95 return gfx::Display::kInvalidDisplayID; 103 return gfx::Display::kInvalidDisplayID;
96 } 104 }
97 105
98 } // namespace 106 } // namespace
99 107
100 DisplayChangeObserverX11::DisplayChangeObserverX11() 108 DisplayChangeObserverX11::DisplayChangeObserverX11()
101 : xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()), 109 : xdisplay_(base::MessagePumpAuraX11::GetDefaultXDisplay()),
102 x_root_window_(DefaultRootWindow(xdisplay_)), 110 x_root_window_(DefaultRootWindow(xdisplay_)),
103 xrandr_event_base_(0) { 111 xrandr_event_base_(0) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 void DisplayChangeObserverX11::OnAppTerminating() { 236 void DisplayChangeObserverX11::OnAppTerminating() {
229 #if defined(USE_ASH) 237 #if defined(USE_ASH)
230 // Stop handling display configuration events once the shutdown 238 // Stop handling display configuration events once the shutdown
231 // process starts. crbug.com/177014. 239 // process starts. crbug.com/177014.
232 Shell::GetInstance()->output_configurator()->Stop(); 240 Shell::GetInstance()->output_configurator()->Stop();
233 #endif 241 #endif
234 } 242 }
235 243
236 } // namespace internal 244 } // namespace internal
237 } // namespace ash 245 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ui/gfx/display.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698