Cursor Movement

Graphics and Screen4.0 (8.x)Screen Graphics Subsystem Developer's GuideAPIProgrammingUtilities

There is more than one way to set up cursor movement between multiple displays.

Pointer sessions

Pointer sessions allow you to control the shape and position of the cursor along with its movement from one display to the next. See the section Pointer sessions for more information.

Display group

A simpler alternative to pointer sessions, display groups allow for cursor movement between displays by arranging the position of each display in a valid configuration. Display positions can be set when Screen is launched using the graphics.conf, or through code with the SCREEN_PROPERTY_POSITION API.

To set up cursor movement by using display groups, you need to set the position of the top left corner of each display. The 0,0 position is the top left corner and the y axis increases downwards.

You can configure the position of each display by setting the position property in the graphics.conf file. In this example, display2 is placed under display1:
...
begin display 1
position = 0,0
formats = rgbx8888
rotation = 0
video-mode = 1280 x 800 @ 60
end display
 
begin display 2
position = 0,800
rotation = 0
formats = rgbx8888
video-mode = 1280 x 800 @ 60
end display   
...
Figure 1The positions of display 1 and display 2


You can also use an API call to set the screen position by using the SCREEN_PROPERTY_POSITION property:
...
screen_set_display_property_iv(display1, SCREEN_PROPERTY_POSITION, int[2]{x,y});
...

When deciding on the location of the displays, you have to create a valid layout where each display has an edge touching another display's edge. The cursor moves from one display to the next once it crosses the edge where they touch. Otherwise, the cursor will be stuck on the current display. If the cursor is required to transition when it is not along the edges of touching displays, then you need to use pointer sessions as well.

If setting the position of a display after Screen has launched results in an invalid layout, the display is reset to its previous position.
Figure 2Valid display group where the pointer can transition without using pointer sessions


Figure 3Invalid display group where the cursor does not move between displays


Figure 4Invalid display group where the cursor does not move between displays


Default display group

If you configured your displays' positions in a valid display group configuration in the graphics.conf file, a group is created using the current configuration. If you haven't configured any of your displays' positions, a group is created with the displays aligned horizontally, as shown in the figure below.

Figure 5Default display group configuration


Adding and removing displays

When a new virtual display is created using screen_create_display(), it is added to the display group. Its default position is the bottom right of the right most display.

You can remove a display from the display group by deleting it using screen_destroy_display(). If deleting the display results in an invalid display group, a warning is written to the slog2info log and the cursor can no longer move between displays.

Errors

During startup, Screen will exit with an EXIT_FAILURE error, written to slog2info, if one of the following scenarios occurs:
  • If you only configured some of your displays' positions
  • If your displays are in an invalid or broken configuration
Page updated: