|
PatchworkOS
966e257
A non-POSIX operating system.
|
Window. More...
Window.
A window represents a rectangular area on the screen that can display content and receive user input, this includes panels, cursors, wallpapers and normal application windows. It can be considered to be the client side implementation of the Desktop Window Managers surfaces.
If WINDOW_DECO flag is set, the window will have decorations (titlebar, close/minimize buttons, etc) which will serve as the root element with the client element as a child. This client element is then what the application will draw to and receive events from.
The window system is NOT thread safe, it is the responsibility of the application to ensure that windows are only accessed from a single thread at a time.
Data Structures | |
| struct | window_t |
| Opaque window structure. More... | |
Typedefs | |
| typedef struct window | window_t |
Enumerations | |
| enum | window_flags_t { WINDOW_NONE = 0 , WINDOW_DECO = 1 << 0 , WINDOW_RESIZABLE = 1 << 1 , WINDOW_NO_CONTROLS = 1 << 2 } |
| Window flags. More... | |
Functions | |
| window_t * | window_new (display_t *disp, const char *name, const rect_t *rect, surface_type_t type, window_flags_t flags, procedure_t procedure, void *private) |
| Allocate and initialize a new window. | |
| void | window_free (window_t *win) |
| Free a window. | |
| rect_t | window_get_rect (window_t *win) |
| Get the window's rectangle in screen coordinates. | |
| rect_t | window_content_rect (window_t *win) |
| Get the window's rectangle in local coordinates. | |
| display_t * | window_get_display (window_t *win) |
| Get the display associated with the window. | |
| surface_id_t | window_get_id (window_t *win) |
| Get the surface ID of the window. | |
| surface_type_t | window_get_type (window_t *win) |
| Get the surface type of the window. | |
| element_t * | window_get_client_element (window_t *win) |
| Get the client element of the window. | |
| uint64_t | window_move (window_t *win, const rect_t *rect) |
| Move and/or resize the window. | |
| uint64_t | window_set_timer (window_t *win, timer_flags_t flags, clock_t timeout) |
| Set the window timer. | |
| void | window_invalidate (window_t *win, const rect_t *rect) |
| Invalidate a rectangle of the window. | |
| uint64_t | window_invalidate_flush (window_t *win) |
| Flush invalidated rectangles to the DWM. | |
| uint64_t | window_dispatch (window_t *win, const event_t *event) |
| Dispatch an event to the window's elements. | |
| uint64_t | window_set_focus (window_t *win) |
| Set the focus to the window. | |
| uint64_t | window_set_visible (window_t *win, bool isVisible) |
| Set the visibility of the window. | |
| enum window_flags_t |
Window flags.
| Enumerator | |
|---|---|
| WINDOW_NONE | |
| WINDOW_DECO | Enable decorations (titlebar, close/minimize buttons, etc). |
| WINDOW_RESIZABLE | Allows
|
| WINDOW_NO_CONTROLS | Disable controls (close/minimize buttons), only applies if |
| window_t * window_new | ( | display_t * | disp, |
| const char * | name, | ||
| const rect_t * | rect, | ||
| surface_type_t | type, | ||
| window_flags_t | flags, | ||
| procedure_t | procedure, | ||
| void * | private | ||
| ) |
Allocate and initialize a new window.
| disp | The connection to the DWM. |
| name | The name of the window. |
| rect | The rectangle defining the position and size of the window. |
| type | The type of surface to create, (e.g., panels, cursors, wallpapers, normal windows, etc). |
| flags | The window flags. |
| procedure | The procedure for the window's client element. |
| private | Private data to associate with the window's client element. |
NULL and errno is set. Definition at line 301 of file window.c.
| void window_free | ( | window_t * | win | ) |
Get the window's rectangle in screen coordinates.
Equivalent to RECT_INIT_DIM(x, y, width, height).
| win | The window. |
Definition at line 447 of file window.c.
Get the window's rectangle in local coordinates.
Equivalent to RECT_INIT_DIM(0, 0, width, height).
| win | The window. |
| surface_id_t window_get_id | ( | window_t * | win | ) |
| surface_type_t window_get_type | ( | window_t * | win | ) |
Get the client element of the window.
The client element is the window element that applications should draw to and receive events from, if the window has decorations this will be the child of the deco element, otherwise it will be the root element.
| win | The window. |
Definition at line 497 of file window.c.
| uint64_t window_set_timer | ( | window_t * | win, |
| timer_flags_t | flags, | ||
| clock_t | timeout | ||
| ) |
Set the window timer.
When the timer fires an event of type EVENT_TIMER will be sent to the window's procedure.
| win | The window. |
| flags | The timer flags. |
| timeout | The timer timeout in clock ticks, or CLOCKS_NEVER to disable the timer. Setting a new timer will overide the previous timer if one is set. |
0. On failure, ERR and errno is set. Definition at line 533 of file window.c.
Invalidate a rectangle of the window.
This is used to notify the DWM of the change not to redraw the specified rectangle.
The changes will be flushed to the DWM when window_invalidate_flush() is called.
| win | The window. |
| rect | The rectangle to invalidate, in local coordinates. |
Definition at line 553 of file window.c.
Flush invalidated rectangles to the DWM.
This will push a command to the display to notify the DWM of all previously invalidated rectangles.
In order for the DWM to actually redraw the invalidated region, the commands must be flushed to the DWM using display_cmds_flush().
| win | The window. |
0. On failure, ERR and errno is set. Definition at line 570 of file window.c.
Dispatch an event to the window's elements.
Most events will be sent to the root element, which will then propagate the event to its children.
Some events will be handled specially, for example EVENT_LIB_FORCE_ACTION will be sent directly to the specified element.
| win | The window. |
| event | The event to dispatch. |
Definition at line 598 of file window.c.
Set the focus to the window.
Causes the window to be moved to the front and to, for example, receive keyboard input.
| win | The window. |
0. On failure, ERR and errno is set. Definition at line 673 of file window.c.
Set the visibility of the window.
Windows are invisible by default, so they must be made visible after creation to be seen.
Will also dispatch all currently pending EVENT_LIB_REDRAW events for the window.
| win | The window. |
| isVisible | Whether the window should be visible. |
0. On failure, ERR and errno is set. Definition at line 692 of file window.c.