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

Unified Diff: ash/display/display_change_observer_x11.cc

Issue 12377035: Remove GetOutputNames from x11_util (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ash/display/display_manager.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/display/display_change_observer_x11.cc
diff --git a/ash/display/display_change_observer_x11.cc b/ash/display/display_change_observer_x11.cc
index 073b5155c51d3be2568a53270a98e02b4dc9b464..7ba4af4eb203a441b35b0cba224dcd22939b7b60 100644
--- a/ash/display/display_change_observer_x11.cc
+++ b/ash/display/display_change_observer_x11.cc
@@ -85,6 +85,19 @@ std::string GetDisplayName(XID output_id) {
return display_name;
}
+int64 GetDisplayId(XID output_id, int output_index) {
+ uint16 manufacturer_id = 0;
+ uint16 product_code = 0;
+ if (ui::GetOutputDeviceData(
+ output_id, &manufacturer_id, &product_code, NULL) &&
+ manufacturer_id != 0) {
+ // An ID based on display's index will be assigned later if this call
+ // fails.
+ return gfx::Display::GetID(manufacturer_id, product_code, output_index);
+ }
+ return gfx::Display::kInvalidDisplayID;
+}
+
} // namespace
DisplayChangeObserverX11::DisplayChangeObserverX11()
@@ -93,6 +106,26 @@ DisplayChangeObserverX11::DisplayChangeObserverX11()
xrandr_event_base_(0) {
int error_base_ignored;
XRRQueryExtension(xdisplay_, &xrandr_event_base_, &error_base_ignored);
+
+ // Find internal display.
+ XRRScreenResources* screen_resources =
+ XRRGetScreenResources(xdisplay_, x_root_window_);
+ for (int output_index = 0; output_index < screen_resources->noutput;
+ output_index++) {
+ XID output = screen_resources->outputs[output_index];
+ XRROutputInfo *output_info =
+ XRRGetOutputInfo(xdisplay_, screen_resources, output);
+ bool is_internal = chromeos::OutputConfigurator::IsInternalOutputName(
+ std::string(output_info->name));
+ XRRFreeOutputInfo(output_info);
+ if (is_internal) {
+ // No need to check the return value of |GetDisplayID()| as
+ // the default value is |gfx::Display::kInvalidDisplayID| anyway.
+ gfx::Display::SetInternalDisplayId(GetDisplayId(output, output_index));
+ break;
+ }
+ }
+ XRRFreeScreenResources(screen_resources);
}
DisplayChangeObserverX11::~DisplayChangeObserverX11() {
@@ -160,21 +193,10 @@ void DisplayChangeObserverX11::OnDisplayModeChanged() {
bool has_overscan = false;
ui::GetOutputOverscanFlag(output, &has_overscan);
- uint16 manufacturer_id = 0;
- uint16 product_code = 0;
- int64 id = gfx::Display::kInvalidDisplayID;
-
- if (ui::GetOutputDeviceData(
- output, &manufacturer_id, &product_code, NULL) &&
- manufacturer_id != 0) {
- // An ID based on display's index will be assigned later if this call
- // fails.
- int64 new_id = gfx::Display::GetID(
- manufacturer_id, product_code, output_index);
- if (ids.find(new_id) == ids.end())
- id = new_id;
- }
- if (id == gfx::Display::kInvalidDisplayID)
+ int64 id = GetDisplayId(output, output_index);
+
+ // If ID is invalid or there is an duplicate, just use output index.
+ if (id == gfx::Display::kInvalidDisplayID || ids.find(id) != ids.end())
id = output_index;
ids.insert(id);
« no previous file with comments | « no previous file | ash/display/display_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698