|
PatchworkOS
966e257
A non-POSIX operating system.
|
Display connection. More...
Display connection.
A display represents a connection to the Desktop Window Manager (DWM).
The display system IS thread safe, but the rest of the Patchwork library may not be. The display connection can thus be used to synchronize multiple threads when working with windows, etc.
There are two things of note for performance when using a display. First, commands are batched and sent together when display_cmds_flush() is called. Second, the display uses a internal pipe to store events that cant be processed immediately and this means that if a thread calls display_push() another thread blocking on display_next() will unblock since its blocking on both the displays DWM connection and the internal pipe.
Data Structures | |
| struct | display_t |
| Opaque display structure. More... | |
Typedefs | |
| typedef struct display | display_t |
Functions | |
| display_t * | display_new (void) |
| Create a new display connection. | |
| void | display_free (display_t *disp) |
| Free a display connection. | |
| bool | display_is_connected (display_t *disp) |
| Check if the display connection is still connected. | |
| void | display_disconnect (display_t *disp) |
| Disconnect the display connection. | |
| void * | display_cmd_alloc (display_t *disp, cmd_type_t type, uint64_t size) |
| Allocate a section of the displays command buffer. | |
| void | display_cmds_flush (display_t *disp) |
| Flush the display's command buffer. | |
| uint64_t | display_next (display_t *disp, event_t *event, clock_t timeout) |
| Retrieve the next event from the display connection. | |
| uint64_t | display_poll (display_t *disp, pollfd_t *fds, uint64_t nfds, clock_t timeout) |
| Poll the display connection for events together with other file descriptors. | |
| void | display_push (display_t *disp, surface_id_t target, event_type_t type, void *data, uint64_t size) |
| Push an event to the display's internal event queue. | |
| uint64_t | display_wait (display_t *disp, event_t *event, event_type_t expected) |
| Wait for the display to receive an event of the expected type. | |
| uint64_t | display_emit (display_t *disp, surface_id_t target, event_type_t type, void *data, uint64_t size) |
| Emit an event to a target surface. | |
| uint64_t | display_dispatch (display_t *disp, const event_t *event) |
| Dispatch an event to the appropriate surface. | |
| uint64_t | display_dispatch_pending (display_t *disp, event_type_t type, surface_id_t target) |
| Dispatch all events currently in the display's internal event queue of a specific type and target. | |
| uint64_t | display_subscribe (display_t *disp, event_type_t type) |
| Subscribe to events of a specific type. | |
| uint64_t | display_unsubscribe (display_t *disp, event_type_t type) |
| Unsubscribe from events of a specific type. | |
| uint64_t | display_get_surface_info (display_t *disp, surface_id_t id, surface_info_t *info) |
| Get information about a surface. | |
| uint64_t | display_set_focus (display_t *disp, surface_id_t id) |
| Set the focus to a surface. | |
| uint64_t | display_set_is_visible (display_t *disp, surface_id_t id, bool isVisible) |
| Set the visibility of a surface. | |
| uint64_t | display_get_screen (display_t *disp, rect_t *rect, uint64_t index) |
| Get the rectangle of a screen. | |
| display_t * display_new | ( | void | ) |
| void display_free | ( | display_t * | disp | ) |
| void display_disconnect | ( | display_t * | disp | ) |
Disconnect the display connection.
After calling this function, the display connection will be marked as disconnected and no further commands or events will be processed.
Will not free the display connection, use display_free() for that.
| disp | The display connection. |
Definition at line 168 of file display.c.
| void * display_cmd_alloc | ( | display_t * | disp, |
| cmd_type_t | type, | ||
| uint64_t | size | ||
| ) |
Allocate a section of the displays command buffer.
The display batches commands together in its command buffer, where each command is prefixed with a cmd_header_t and has a variable size.
| disp | The display connection. |
| type | Type of command to allocate. |
| size | Size of the command data to allocate. |
NULL on failure and errno is set. Definition at line 180 of file display.c.
| void display_cmds_flush | ( | display_t * | disp | ) |
Retrieve the next event from the display connection.
| disp | The display connection. |
| event | Output pointer to store the retrieved event. |
| timeout | Maximum time to wait for an event, if CLOCKS_NEVER will wait indefinitely. |
0. On failure, ERR and errno is set. Definition at line 220 of file display.c.
Poll the display connection for events together with other file descriptors.
| disp | The display connection. |
| fds | Array of file descriptors to poll alongside the display connection. |
| nfds | Number of file descriptors in the array. |
| timeout | Maximum time to wait for an event, if CLOCKS_NEVER will wait indefinitely. |
ERR and errno is set. Definition at line 295 of file display.c.
| void display_push | ( | display_t * | disp, |
| surface_id_t | target, | ||
| event_type_t | type, | ||
| void * | data, | ||
| uint64_t | size | ||
| ) |
Push an event to the display's internal event queue.
This will not send the event to the DWM, instead it will be stored in the display's internal event queue and can be retrieved using display_next().
| disp | The display connection. |
| target | Target surface ID for the event. |
| type | Type of event. |
| data | Pointer to the event data, can be NULL if size is 0. |
| size | Size of the event data, must be less than EVENT_MAX_DATA. |
Definition at line 356 of file display.c.
| uint64_t display_wait | ( | display_t * | disp, |
| event_t * | event, | ||
| event_type_t | expected | ||
| ) |
Wait for the display to receive an event of the expected type.
This function will block until an event of the expected type is received.
Any other events received while waiting will be pushed back to the display's internal event queue.
| disp | The display connection. |
| event | Output pointer to store the retrieved event. |
| expected | The expected event type to wait for. |
0. On failure, ERR and errno is set. Definition at line 374 of file display.c.
| uint64_t display_emit | ( | display_t * | disp, |
| surface_id_t | target, | ||
| event_type_t | type, | ||
| void * | data, | ||
| uint64_t | size | ||
| ) |
Emit an event to a target surface.
This function will construct an event and dispatch it to the target surface.
| disp | The display connection. |
| target | Target surface ID for the event, if SURFACE_ID_NONE the event is sent to all surfaces. |
| type | Type of event. |
| data | Pointer to the event data, can be NULL if size is 0. |
| size | Size of the event data, must be less than EVENT_MAX_DATA. |
0. On failure, ERR and errno is set. Definition at line 426 of file display.c.
Dispatch an event to the appropriate surface.
Will flush the display's command buffer after dispatching the event.
| disp | The display connection. |
| event | The event to dispatch. |
0. On failure, ERR and errno is set. Definition at line 447 of file display.c.
| uint64_t display_dispatch_pending | ( | display_t * | disp, |
| event_type_t | type, | ||
| surface_id_t | target | ||
| ) |
Dispatch all events currently in the display's internal event queue of a specific type and target.
| disp | The display connection. |
| type | The event type to check for. |
| target | The target surface ID for the events, if SURFACE_ID_NONE all events are dispatched. |
0. On failure, ERR and errno is set. Definition at line 479 of file display.c.
| uint64_t display_subscribe | ( | display_t * | disp, |
| event_type_t | type | ||
| ) |
| uint64_t display_unsubscribe | ( | display_t * | disp, |
| event_type_t | type | ||
| ) |
| uint64_t display_get_surface_info | ( | display_t * | disp, |
| surface_id_t | id, | ||
| surface_info_t * | info | ||
| ) |
Get information about a surface.
Uses a CMD_SURFACE_REPORT command to request information about the specified surface from the DWM.
| disp | The display connection. |
| id | The surface ID to query. |
| info | Output pointer to store the surface information. |
0. On failure, ERR and errno is set. Definition at line 554 of file display.c.
| uint64_t display_set_focus | ( | display_t * | disp, |
| surface_id_t | id | ||
| ) |
| uint64_t display_set_is_visible | ( | display_t * | disp, |
| surface_id_t | id, | ||
| bool | isVisible | ||
| ) |
Set the visibility of a surface.
Can apply to any surface, not just ones owned by the client.
| disp | The display connection. |
| id | The surface ID to set visibility for. |
| isVisible | Whether the surface should be visible. |
Definition at line 595 of file display.c.
Get the rectangle of a screen.
| disp | The display connection. |
| rect | Output pointer to store the rectangle of the screen. |
| index | Index of the screen to query, only 0 is supported currently. |
0. On failure, ERR and errno is set. Definition at line 610 of file display.c.