OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/display/chromeos/x11/native_display_delegate_x11.h" | 5 #include "ui/display/chromeos/x11/native_display_delegate_x11.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/Xrandr.h> | 10 #include <X11/extensions/Xrandr.h> |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 info.id))); | 301 info.id))); |
302 } | 302 } |
303 } | 303 } |
304 | 304 |
305 DisplaySnapshotX11* NativeDisplayDelegateX11::InitDisplaySnapshot( | 305 DisplaySnapshotX11* NativeDisplayDelegateX11::InitDisplaySnapshot( |
306 RROutput output, | 306 RROutput output, |
307 XRROutputInfo* info, | 307 XRROutputInfo* info, |
308 RRCrtc* last_used_crtc, | 308 RRCrtc* last_used_crtc, |
309 int index) { | 309 int index) { |
310 int64_t display_id = 0; | 310 int64_t display_id = 0; |
311 bool has_display_id = GetDisplayId( | 311 if (!GetDisplayId(output, static_cast<uint8_t>(index), &display_id)) |
312 output, static_cast<uint8_t>(index), &display_id); | 312 display_id = index; |
313 | 313 |
314 bool has_overscan = false; | 314 bool has_overscan = false; |
315 GetOutputOverscanFlag(output, &has_overscan); | 315 GetOutputOverscanFlag(output, &has_overscan); |
316 | 316 |
317 DisplayConnectionType type = GetDisplayConnectionTypeFromName(info->name); | 317 DisplayConnectionType type = GetDisplayConnectionTypeFromName(info->name); |
318 if (type == DISPLAY_CONNECTION_TYPE_UNKNOWN) | 318 if (type == DISPLAY_CONNECTION_TYPE_UNKNOWN) |
319 LOG(ERROR) << "Unknown link type: " << info->name; | 319 LOG(ERROR) << "Unknown link type: " << info->name; |
320 | 320 |
321 // Use the index as a valid display ID even if the internal | |
322 // display doesn't have valid EDID because the index | |
323 // will never change. | |
324 if (!has_display_id) { | |
325 if (type == DISPLAY_CONNECTION_TYPE_INTERNAL) | |
326 has_display_id = true; | |
327 | |
328 // Fallback to output index. | |
329 display_id = index; | |
330 } | |
331 | |
332 RRMode native_mode_id = GetOutputNativeMode(info); | 321 RRMode native_mode_id = GetOutputNativeMode(info); |
333 RRMode current_mode_id = None; | 322 RRMode current_mode_id = None; |
334 gfx::Point origin; | 323 gfx::Point origin; |
335 if (info->crtc) { | 324 if (info->crtc) { |
336 XRRCrtcInfo* crtc_info = XRRGetCrtcInfo(display_, screen_, info->crtc); | 325 XRRCrtcInfo* crtc_info = XRRGetCrtcInfo(display_, screen_, info->crtc); |
337 current_mode_id = crtc_info->mode; | 326 current_mode_id = crtc_info->mode; |
338 origin.SetPoint(crtc_info->x, crtc_info->y); | 327 origin.SetPoint(crtc_info->x, crtc_info->y); |
339 XRRFreeCrtcInfo(crtc_info); | 328 XRRFreeCrtcInfo(crtc_info); |
340 } | 329 } |
341 | 330 |
(...skipping 20 matching lines...) Expand all Loading... |
362 current_mode = display_modes.back(); | 351 current_mode = display_modes.back(); |
363 if (mode == native_mode_id) | 352 if (mode == native_mode_id) |
364 native_mode = display_modes.back(); | 353 native_mode = display_modes.back(); |
365 } else { | 354 } else { |
366 LOG(WARNING) << "Unable to find XRRModeInfo for mode " << mode; | 355 LOG(WARNING) << "Unable to find XRRModeInfo for mode " << mode; |
367 } | 356 } |
368 } | 357 } |
369 | 358 |
370 DisplaySnapshotX11* display_snapshot = | 359 DisplaySnapshotX11* display_snapshot = |
371 new DisplaySnapshotX11(display_id, | 360 new DisplaySnapshotX11(display_id, |
372 has_display_id, | |
373 origin, | 361 origin, |
374 gfx::Size(info->mm_width, info->mm_height), | 362 gfx::Size(info->mm_width, info->mm_height), |
375 type, | 363 type, |
376 IsOutputAspectPreservingScaling(output), | 364 IsOutputAspectPreservingScaling(output), |
377 has_overscan, | 365 has_overscan, |
378 GetDisplayName(output), | 366 GetDisplayName(output), |
379 display_modes, | 367 display_modes, |
380 current_mode, | 368 current_mode, |
381 native_mode, | 369 native_mode, |
382 output, | 370 output, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 XSetForeground(display_, gc, color.pixel); | 630 XSetForeground(display_, gc, color.pixel); |
643 XSetFillStyle(display_, gc, FillSolid); | 631 XSetFillStyle(display_, gc, FillSolid); |
644 int width = DisplayWidth(display_, DefaultScreen(display_)); | 632 int width = DisplayWidth(display_, DefaultScreen(display_)); |
645 int height = DisplayHeight(display_, DefaultScreen(display_)); | 633 int height = DisplayHeight(display_, DefaultScreen(display_)); |
646 XFillRectangle(display_, window_, gc, 0, 0, width, height); | 634 XFillRectangle(display_, window_, gc, 0, 0, width, height); |
647 XFreeGC(display_, gc); | 635 XFreeGC(display_, gc); |
648 XFreeColors(display_, colormap, &color.pixel, 1, 0); | 636 XFreeColors(display_, colormap, &color.pixel, 1, 0); |
649 } | 637 } |
650 | 638 |
651 } // namespace ui | 639 } // namespace ui |
OLD | NEW |