LibCapy - x11display

Class to display graphics on screen, using X11.

Macros:

Enumerations:

Types of events

Types of source of events

Typedefs:

X11Display opaque structure

Type for the dimensions of a CapyX11Display

Type of one channel in pixel's RGB data

Struct CapyX11DisplayPos :

Struct CapyX11DisplayPos's properties:

Position (0,0 is the top-left corner, x toward right, y toward bottom)

Struct CapyX11DisplayPos's methods:

None.

Struct CapyX11DisplayEvt :

Struct CapyX11DisplayEvt's properties:

0: no event, 1: press, 2: release

0: key, 1: mouse

Time of the event in millisecond (comes from XLib, not sure relative to what)

key or button mask, 'or' combination of: NoModMask, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask, ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask, Mod4Mask, and Mod5Mask

key/button value, one of: for key: NoSymbol or the XK_... macro (see complete list here: /usr/include/X11/keysymdef.h) which map to ASCII (XK_a == 'a') for button: Button1, Button2, Button3, Button4, Button5

Coordinates of the pointer at the time of event

Struct CapyX11DisplayEvt's methods:

None.

Struct CapyX11RGB :

Struct CapyX11RGB's properties:

Position (0,0 is the top-left corner, x toward right, y toward bottom)

Struct CapyX11RGB's methods:

None.

Struct { :

Struct {'s properties:

Dimensions of the buffer

RGB buffers, three channels, ordered by row of RGB pixel value in [0, 255]

Struct {'s methods:

Set a pixel color in the buffer.

Input argument(s):

pos: the pixel coordinates (0,0 at top left corner, y downward)
rgb: the color to be set

Output and side effect(s):

Set the pixel's rgb values. Do nothing if the coordinates are out of the buffer.

Fill a rectangle with a color.

Input argument(s):

rect: the rectangle
rgb: the color to be set

Output and side effect(s):

Set the pixel's rgb values inside the rectangle (clipped to the buffer dimensions).

Clear the buffer.

Input argument(s):

rgb: the color to used to clear the buffer

Output and side effect(s):

The whole buffer is set to the given color.

Reset the buffer.

Input argument(s):

flagColor: if true the buffer is reset to white, else it is reset to black

Output and side effect(s):

The whole buffer is reset.

Draw a line.

Input argument(s):

seg: the segment to draw
rgb: the color of the line

Output and side effect(s):

Draw a one pixel line (clipped to the buffer dimensions).

Draw a circle.

Input argument(s):

circle: the circle
rgb: the color of the line

Output and side effect(s):

Draw a one pixel circle line (clipped to the buffer dimensions).

Draw a bezier.

Input argument(s):

bezier: the bezier
rgb: the color of the line

Output and side effect(s):

Draw a one pixel bezier line (clipped to the buffer dimensions).

Functions:

Allocate memory and create a new CapyX11Display instance

Input argument(s):

width: initial width of the display
height: initial height of the display
displayName: the display name as hostname:server_number.screen_number, if
NULL ":0.0" is used instead
title: the title of the window

Output and side effect(s):

Return a new CapyX11Display instance, or NULL if it couldn't be created

Free the resource used by a CapyX11Display instance

Input argument(s):

that: pointer to the CapyX11Display instance

Output and side effect(s):

*that is set to NULL, the display is closed if it has been shown, all memory allocated by the instance is released

Display the CapyX11Display instance and starts its main loop in a separate thread. The thread will end when the window has focus and the user presses ctrl-c (the key combination, not the signal), or CapyX11DisplayHide() is called, or CapyX11DisplayFree() is called.

Input argument(s):

that: the CapyX11Display instance

Hide the CapyX11Display instance. The display is unmapped and its thread is terminated but its reources are not freed and it is ready to be shown again anytime.

Input argument(s):

that: the CapyX11Display instance

Check if a display is currently shown

Input argument(s):

that: the CapyX11Display instance

Output and side effect(s):

Return true if the display is shown, else false

Get the average refresh rate (number of times the window content is updated per second) since the last call to CapyX11DisplayGetRefreshRate() or CapyX11DisplayShow().

Input argument(s):

that: the CapyX11Display instance

Output and side effect(s):

Return the refresh rate

Get the average frame rate (number of times the image buffer is updated per second) since the last call to CapyX11DisplayGetFrameRate() or CapyX11DisplayShow().

Input argument(s):

that: the CapyX11Display instance

Output and side effect(s):

Return the frame rate

Return the next event in the queue of events

Input argument(s):

that: the CapyX11Display instance

Output and side effect(s):

Pop the next event from the queue and return it. If there was no event in the queue an event with type == 0 is returned instead.

Flush the event queue

Input argument(s):

that: the CapyX11Display instance

Get the las known position of the pointer in the display

Input argument(s):

that: the CapyX11Display instance

Output and side effect(s):

Return the last known position.

Get the current rendering buffer.

Input argument(s):

that: the CapyX11Display instance

Output and side effect(s):

Return the buffer to write on. The content of the buffer is undefined. The width and height of the buffer may be different from the previous buffer.

Publish the current editing buffer

Input argument(s):

that: the CapyX11Display instance

Get the elapsed time in millisecond since the display is shown

Input argument(s):

that: the CapyX11Display instance

Output and side effect(s):

Return the elapsed time.

Set the title of the window

Input argument(s):

that: pointer to the CapyX11Display instance
title: the window's new title

2023-05-05
in LibCapy,
11 views
Copyright 2021-2024 Baillehache Pascal