Return list of attached monitors

        For each monitor (as dict), ``monitor["rect"]`` represents the screen as positioned
        in virtual screen. List is returned in device order, with the first element (0)
        representing the primary monitor.
506004
def getScreenDetails(self):
        
        monitors = self._getMonitorInfo()
        primary_screen = None
        screens = []
        for monitor in monitors:
            # Convert screen rect to Lackey-style rect (x,y,w,h) as position in virtual screen
            screen = {
                "rect": (
                    monitor["rect"][0],
                    monitor["rect"][1],
                    monitor["rect"][2] - monitor["rect"][0],
                    monitor["rect"][3] - monitor["rect"][1]
                )
            }
            screens.append(screen)
        return screens
970617
def viewportRect(self):
        
        w = self.width()
        h = self.height()
        
        vbar = self.verticalScrollBar()
        hbar = self.horizontalScrollBar()
        
        if vbar.isVisible():
            w -= vbar.width()
        if hbar.isVisible():
            h -= hbar.height()
        
        top_l = self.mapToScene(QPoint(0, 0))
        bot_r = self.mapToScene(QPoint(w, h))
        
        return QRectF(top_l.x(), 
                      top_l.y(), 
                      bot_r.x() - top_l.x(), 
                      bot_r.y() - top_l.y())
1124526
def screen(self):
        """"""
        hwnd = win32gui.GetDesktopWindow()
        left, top, right, bottom = self.rect
        width, height = right-left, bottom-top
        # copy bits to temporary dc
        win32gui.BitBlt(self._hdcmem, 0, 0, width, height, 
                        self._hdcwin, left, top, win32con.SRCCOPY)
        # read bits into buffer
        windll.gdi32.GetDIBits(self._hdcmem, self._hbmp.handle, 0, height, self._buf, ctypes.byref(self._bi), win32con.DIB_RGB_COLORS)
        # make a PIL Image
        img = Image.frombuffer('RGB', (width, height), self._buf, 'raw', 'BGRX', 0, 1)
        img = img.transpose(Image.FLIP_TOP_BOTTOM)
        return img
182655
def populate_display_n(self):
        
        cb = self.get_widget('display_n')
        screen = self.get_widget('config-window').get_screen()

        cb.append_text("always on primary")

        for m in range(0, int(screen.get_n_monitors())):
            if m == int(screen.get_primary_monitor()):
                # TODO l10n
                cb.append_text(str(m) + ' ' + '(primary)')
            else:
                cb.append_text(str(m))
637485
def monitors(self):
        # type: () -> Monitors
        

        if not self._monitors:
            int_ = int
            user32 = self.user32
            get_system_metrics = user32.GetSystemMetrics

            # All monitors
            self._monitors.append(
                {
                    "left": int_(get_system_metrics(76)),  # SM_XVIRTUALSCREEN
                    "top": int_(get_system_metrics(77)),  # SM_YVIRTUALSCREEN
                    "width": int_(get_system_metrics(78)),  # SM_CXVIRTUALSCREEN
                    "height": int_(get_system_metrics(79)),  # SM_CYVIRTUALSCREEN
                }
            )

            # Each monitors
            def _callback(monitor, data, rect, dc_):
                # types: (int, HDC, LPRECT, LPARAM) -> int
                """
                Callback for monitorenumproc() function, it will return
                a RECT with appropriate values.
                """
                # pylint: disable=unused-argument

                rct = rect.contents
                self._monitors.append(
                    {
                        "left": int_(rct.left),
                        "top": int_(rct.top),
                        "width": int_(rct.right - rct.left),
                        "height": int_(rct.bottom - rct.top),
                    }
                )
                return 1

            callback = self.monitorenumproc(_callback)
            user32.EnumDisplayMonitors(0, 0, callback, 0)

        return self._monitors
970553
def display(self):
        
        for line in self.adb_shell('dumpsys display').splitlines():
            m = _DISPLAY_RE.search(line, 0)
            if not m:
                continue
            w = int(m.group('width'))
            h = int(m.group('height'))
            return collections.namedtuple('Display', ['width', 'height'])(w, h)
        else:
            w, h = self.info['displayWidth'], self.info['displayHeight']
            return collections.namedtuple('Display', ['width', 'height'])(w, h)
798673
def _getVirtualScreenBitmap(self):
        

        # Collect information about the virtual screen & monitors
        min_x, min_y, screen_width, screen_height = self._getVirtualScreenRect()
        monitors = self._getMonitorInfo()

        # Initialize new black image the size of the virtual screen
        virt_screen = Image.new("RGB", (screen_width, screen_height))

        # Capture images of each of the monitors and overlay on the virtual screen
        for monitor_id in range(0, len(monitors)):
            img = self._captureScreen(monitors[monitor_id]["name"])
            # Capture virtscreen coordinates of monitor
            x1, y1, x2, y2 = monitors[monitor_id]["rect"]
            # Convert to image-local coordinates
            x = x1 - min_x
            y = y1 - min_y
            # Paste on the virtual screen
            virt_screen.paste(img, (x, y))
        return virt_screen
1271539
def get_monitor(self, topics):
        
        for monitor in self.get_monitors(MON_TOPIC_ATTR == ",".join(topics)):
            return monitor  # return the first one, even if there are multiple
        return None
1244853
def items(self):
        
        output = []
        for i in xrange(self.layout().count()):
            item = self.layout().itemAt(i)
            try:
                widget = item.widget()
            except AttributeError:
                break

            if isinstance(widget, XViewPanelItem):
                output.append(widget)
            else:
                break
        return output
546929
def grab(self, monitor):
        # type: (Monitor) -> ScreenShot
        

        # Convert PIL bbox style
        if isinstance(monitor, tuple):
            monitor = {
                "left": monitor[0],
                "top": monitor[1],
                "width": monitor[2] - monitor[0],
                "height": monitor[3] - monitor[1],
            }

        ximage = self.xlib.XGetImage(
            MSS.display,
            self.drawable,
            monitor["left"],
            monitor["top"],
            monitor["width"],
            monitor["height"],
            PLAINMASK,
            ZPIXMAP,
        )

        try:
            bits_per_pixel = ximage.contents.bits_per_pixel
            if bits_per_pixel != 32:
                raise ScreenShotError(
                    "[XImage] bits per pixel value not (yet?) implemented: {}.".format(
                        bits_per_pixel
                    )
                )

            raw_data = ctypes.cast(
                ximage.contents.data,
                ctypes.POINTER(
                    ctypes.c_ubyte * monitor["height"] * monitor["width"] * 4
                ),
            )
            data = bytearray(raw_data.contents)
        finally:
            # Free
            self.xlib.XDestroyImage(ximage)

        return self.cls_image(data, monitor)
1193058
def list():
    ''''''
    fields = [
        ('Name', 'name'),
        ('ID', 'id'),
        ('Owner', 'is_owner'),
        ('Permission', 'permission'),
    ]
    with Session() as session:
        try:
            resp = session.VFolder.list()
            if not resp:
                print('There is no virtual folders created yet.')
                return
            rows = (tuple(vf[key] for _, key in fields) for vf in resp)
            hdrs = (display_name for display_name, _ in fields)
            print(tabulate(rows, hdrs))
        except Exception as e:
            print_error(e)
            sys.exit(1)
591334
def visualRect(self, index):
        
        rect = super(XTreeWidget, self).visualRect(index)
        item = self.itemFromIndex(index)
        if not rect.isNull() and item and item.isFirstColumnSpanned():
            vpos = self.viewport().mapFromParent(QtCore.QPoint(0, 0))
            rect.setX(vpos.x())
            rect.setWidth(self.width())
            return rect
        return rect
568193
def _load_screen_settings(self):
        """"""
        # display number / use primary display
        combo = self.get_widget('display_n')
        dest_screen = self.settings.general.get_int('display-n')
        # If Guake is configured to use a screen that is not currently attached,
        # default to 'primary display' option.
        screen = self.get_widget('config-window').get_screen()
        n_screens = screen.get_n_monitors()
        if dest_screen > n_screens - 1:
            self.settings.general.set_boolean('mouse-display', False)
            dest_screen = screen.get_primary_monitor()
            self.settings.general.set_int('display-n', dest_screen)

        if dest_screen == ALWAYS_ON_PRIMARY:
            first_item = combo.get_model().get_iter_first()
            combo.set_active_iter(first_item)
        else:
            seen_first = False  # first item "always on primary" is special
            for i in combo.get_model():
                if seen_first:
                    i_int = int(i[0].split()[0])  # extracts 1 from '1' or from '1 (primary)'
                    if i_int == dest_screen:
                        combo.set_active_iter(i.iter)
                else:
                    seen_first = True
1132813
def get_monitors():
    
    count_value = ctypes.c_int(0)
    count = ctypes.pointer(count_value)
    result = _glfw.glfwGetMonitors(count)
    monitors = [result[i] for i in range(count_value.value)]
    return monitors
755962
def get_monitors(self) -> List[Monitor]:
        """"""
        raw_monitors = self._zm_request('get', ZoneMinder.MONITOR_URL)
        if not raw_monitors:
            _LOGGER.warning("Could not fetch monitors from ZoneMinder")
            return []

        monitors = []
        for raw_result in raw_monitors['monitors']:
            _LOGGER.debug("Initializing camera %s",
                          raw_result['Monitor']['Id'])
            monitors.append(Monitor(self, raw_result))

        return monitors
855171
public static GraphicsDevice[] getScreenDevices()
	{
		final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
		final GraphicsDevice[] gs = ge.getScreenDevices();
		return gs;
	}
1164591
def splunk_monitor(monitors):
    """"""
    if not exists('/opt/splunkforwarder'):
        return
    if not env.get('splunk_monitors'):
        with hide('commands'):
            env['splunk_monitors'] = str(splunk('list monitor'))
    for path, sourcetype in monitors:
        if path not in env['splunk_monitors']:
            with hide('everything'):
                run("touch '{path}'; true".format(path=path))
            splunk("add monitor '{path}' -sourcetype {st}".format(
                path=path, st=sourcetype))
            env['splunk_monitors'] += '\n' + path