(self)
Get positions of monitors. It will populate self._monitors.
Get positions of monitors. It will populate self._monitors.
Get positions of monitors . It will populate self . _monitors .
def _monitors_impl(self):
        # type: () -> None
        """ Get positions of monitors. It will populate self._monitors. """

        display = self._get_display()
        int_ = int
        xrandr = self.xrandr

        # All monitors
        gwa = XWindowAttributes()
        self.xlib.XGetWindowAttributes(display, self.root, ctypes.byref(gwa))
        self._monitors.append(
            {
                "left": int_(gwa.x),
                "top": int_(gwa.y),
                "width": int_(gwa.width),
                "height": int_(gwa.height),
            }
        )

        # Each monitor
        # A simple benchmark calling 10 times those 2 functions:
        # XRRGetScreenResources():        0.1755971429956844 s
        # XRRGetScreenResourcesCurrent(): 0.0039125580078689 s
        # The second is faster by a factor of 44! So try to use it first.
        try:
            mon = xrandr.XRRGetScreenResourcesCurrent(display, self.drawable).contents
        except AttributeError:
            mon = xrandr.XRRGetScreenResources(display, self.drawable).contents

        crtcs = mon.crtcs
        for idx in range(mon.ncrtc):
            crtc = xrandr.XRRGetCrtcInfo(display, mon, crtcs[idx]).contents
            if crtc.noutput == 0:
                xrandr.XRRFreeCrtcInfo(crtc)
                continue

            self._monitors.append(
                {
                    "left": int_(crtc.x),
                    "top": int_(crtc.y),
                    "width": int_(crtc.width),
                    "height": int_(crtc.height),
                }
            )
            xrandr.XRRFreeCrtcInfo(crtc)
        xrandr.XRRFreeScreenResources(mon)
def _monitors_impl ( self ) : # type: () -> None display = self . _get_display ( ) int_ = int xrandr = self . xrandr # All monitors gwa = XWindowAttributes ( ) self . xlib . XGetWindowAttributes ( display , self . root , ctypes . byref ( gwa ) ) self . _monitors . append ( { "left" : int_ ( gwa . x ) , "top" : int_ ( gwa . y ) , "width" : int_ ( gwa . width ) , "height" : int_ ( gwa . height ) , } ) # Each monitor # A simple benchmark calling 10 times those 2 functions: # XRRGetScreenResources():        0.1755971429956844 s # XRRGetScreenResourcesCurrent(): 0.0039125580078689 s # The second is faster by a factor of 44! So try to use it first. try : mon = xrandr . XRRGetScreenResourcesCurrent ( display , self . drawable ) . contents except AttributeError : mon = xrandr . XRRGetScreenResources ( display , self . drawable ) . contents crtcs = mon . crtcs for idx in range ( mon . ncrtc ) : crtc = xrandr . XRRGetCrtcInfo ( display , mon , crtcs [ idx ] ) . contents if crtc . noutput == 0 : xrandr . XRRFreeCrtcInfo ( crtc ) continue self . _monitors . append ( { "left" : int_ ( crtc . x ) , "top" : int_ ( crtc . y ) , "width" : int_ ( crtc . width ) , "height" : int_ ( crtc . height ) , } ) xrandr . XRRFreeCrtcInfo ( crtc ) xrandr . XRRFreeScreenResources ( mon )