Skip to content

Support for monitors with RandR 1.5 #204

Open

Description

@vincentbernat

Hey!

From the specification:

Version 1.5 adds monitors

• A 'Monitor' is a rectangular subset of the screen which represents
a coherent collection of pixels presented to the user.

• Each Monitor is be associated with a list of outputs (which may be
empty).

• When clients define monitors, the associated outputs are removed from
existing Monitors. If removing the output causes the list for that
monitor to become empty, that monitor will be deleted.

• For active CRTCs that have no output associated with any
client-defined Monitor, one server-defined monitor will
automatically be defined of the first Output associated with them.

• When defining a monitor, setting the geometry to all zeros will
cause that monitor to dynamically track the bounding box of the
active outputs associated with them

This new object separates the physical configuration of the hardware
from the logical subsets the screen that applications should
consider as single viewable areas.

Activity

  1. allfro commented on May 9, 2022

    @allfro
    Contributor

    There is a PR open for this support in #224 pending your approval. The following code has been tested
    and works on my machine 😂 with the changes applied from #224.

    from Xlib import display
    
    d = display.Display()
    
    print('Current monitors:', d.screen().root.xrandr_get_monitors())
    
    # Add a virtual monitor
    name = d.intern_atom('test')
    d.screen().root.xrandr_set_monitor(dict(
        name=name,
        primary=0,
        automatic=0,
        crtcs=[],
        x=0,
        y=0,
        width_in_pixels=100,
        height_in_pixels=100,
        width_in_millimeters=1,
        height_in_millimeters=1
    ))
    
    print('Updated monitors:', d.screen().root.xrandr_get_monitors())
    
    # Delete monitor
    d.screen().root.xrandr_delete_monitor(name)
    print('Updated monitors after delete:', d.screen().root.xrandr_get_monitors())
  2. vasily-v-ryabov commented on May 10, 2022

    @vasily-v-ryabov
    Collaborator

    @allfro thanks for the PR. I think this example code could be added to examples/xrandr.py somewhere after r = self.d.xrandr_query_version().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions