• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2014 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5"""Module for display info."""
6
7class DisplayInfo(object):
8    """The class match displayInfo object from chrome.system.display API.
9    """
10
11    class Bounds(object):
12        """The class match Bounds object from chrome.system.display API.
13
14        @param left: The x-coordinate of the upper-left corner.
15        @param top: The y-coordinate of the upper-left corner.
16        @param width: The width of the display in pixels.
17        @param height: The height of the display in pixels.
18        """
19        def __init__(self, d):
20            self.left = d['left']
21            self.top = d['top']
22            self.width = d['width']
23            self.height = d['height']
24
25
26    class Insets(object):
27        """The class match Insets object from chrome.system.display API.
28
29        @param left: The x-axis distance from the left bound.
30        @param left: The y-axis distance from the top bound.
31        @param left: The x-axis distance from the right bound.
32        @param left: The y-axis distance from the bottom bound.
33        """
34
35        def __init__(self, d):
36            self.left = d['left']
37            self.top = d['top']
38            self.right = d['right']
39            self.bottom = d['bottom']
40
41
42    def __init__(self, d):
43        self.display_id = d['id']
44        self.name = d['name']
45        self.mirroring_source_id = d['mirroringSourceId']
46        self.is_primary = d['isPrimary']
47        self.is_internal = d['isInternal']
48        self.is_enabled = d['isEnabled']
49        self.dpi_x = d['dpiX']
50        self.dpi_y = d['dpiY']
51        self.rotation = d['rotation']
52        self.bounds = self.Bounds(d['bounds'])
53        self.overscan = self.Insets(d['overscan'])
54        self.work_area = self.Bounds(d['workArea'])
55