def _callback(
              hMonitor,     # Handle to display monitor
              hdcMonitor,   # Handle to monitor DC
              lprcMonitor,  # Intersection rectangle of monitor
              dwData        # Data
             ):
    """Collects the information from a monitor and stores it in a list of
    monitor objects.

    """
    global MONITORS
    info = _monitor_info_t()
    info.cbSize = ctypes.sizeof(_monitor_info_t)
    info.rcMonitor = _rect_t()
    info.rcWork = _rect_t()
    # Retrieve monitor info.
    res = ctypes.windll.user32.GetMonitorInfoA(hMonitor,  # @UnusedVariable
        ctypes.byref(info))
    # Store monitor info.
    handle = int(hMonitor)
    r = info.rcMonitor
    rectMonitor = Rectangle(r.left, r.top, r.right - r.left, r.bottom - r.top)
    rectWork = Rectangle(r.left, r.top, r.right - r.left, r.bottom - r.top)
    monitor = Monitor(handle, rectWork, rectMonitor)
    MONITORS[str(len(MONITORS) + 1)] = monitor

    return True  # Continue enumerating monitors.
示例#2
0
    def _process_recognition(self, node, extras):
        # Determine which window to place on which monitor.
        window = extras["win_selector"]
        pos = window.get_position()
        monitor = window.get_containing_monitor().rectangle

        # Determine horizontal positioning.
        nodes = node.get_children_by_name("horz")
        horizontals = [(monitor.x1 + n.value() * monitor.dx) for n in nodes]
        if len(horizontals) == 1:
            horizontals.extend([pos.x1, pos.x2])
        elif len(horizontals) != 2:
            self._log.error("%s: Internal error." % self)
            return
        x1, x2 = min(horizontals), max(horizontals)

        # Determine vertical positioning.
        nodes = node.get_children_by_name("vert")
        verticals = [(monitor.y1 + n.value() * monitor.dy) for n in nodes]
        if len(verticals) == 1:
            verticals.extend([pos.y1, pos.y2])
        elif len(verticals) != 2:
            self._log.error("%s: Internal error." % self)
            return
        y1, y2 = min(verticals), max(verticals)

        # Move window.
        pos = Rectangle(x1, y1, x2-x1, y2-y1)
        window.set_position(pos)
示例#3
0
    def _process_recognition(self, node, extras):
        # Determine which window to place.
        window = extras["win_selector"]
        pos = window.get_position()
        monitor = window.get_containing_monitor().rectangle

        # Determine horizontal positioning.
        horizontals = [pos.x1, pos.x2]
        child = node.get_child_by_name("horz")
        if child: horizontals.append(monitor.x1 + child.value() * monitor.dx)
        x1, x2 = min(horizontals), max(horizontals)

        # Determine vertical positioning.
        verticals = [pos.y1, pos.y2]
        child = node.get_child_by_name("vert")
        if child: verticals.append(monitor.y1 + child.value() * monitor.dy)
        y1, y2 = min(verticals), max(verticals)

        # Move window.
        pos = Rectangle(x1, y1, x2 - x1, y2 - y1)
        window.set_position(pos)