|
PatchworkOS
|
Window. More...
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. | |
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.
| 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 |
Get the window's rectangle in local coordinates.
Equivalent to RECT_INIT_DIM(0, 0, width, height).
| win | The window. |
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 LEVENT_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.
References levent_force_action_t::dest, window_t::disp, display_push(), EINVAL, element_dispatch(), element_find(), ERR, errno, EVENT_REPORT, event_report_t::flags, levent_redraw_t::id, element_t::id, LEVENT_FORCE_ACTION, LEVENT_REDRAW, event_t::lForceAction, event_t::lRedraw, NULL, window_t::rect, RECT_HEIGHT, RECT_WIDTH, event_t::report, REPORT_RECT, window_t::root, window_t::surface, event_t::type, and window_invalidate_flush().
Referenced by display_dispatch().
| void window_free | ( | window_t * | win | ) |
Free a window.
| win | The window to free. |
Definition at line 415 of file window.c.
References abort(), window_t::buffer, CMD_SURFACE_FREE, window_t::disp, display_cmd_alloc(), display_cmds_flush(), element_free(), window_t::entry, free(), list_remove(), mtx_lock(), mtx_unlock(), munmap(), display_t::mutex, NULL, window_t::rect, RECT_HEIGHT, RECT_WIDTH, window_t::root, window_t::surface, cmd_surface_free_t::target, and display_t::windows.
Referenced by display_free(), main(), popup_open(), start_menu_new(), taskbar_new(), taskbar_procedure(), terminal_new(), and window_new().
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.
References window_t::clientElement, and NULL.
Referenced by start_menu_close(), start_menu_get_state(), start_menu_load_entries(), start_menu_open(), and terminal_loop().
Get the display associated with the window.
| win | The window. |
Definition at line 467 of file window.c.
References window_t::disp, and NULL.
Referenced by popup_procedure(), procedure(), start_menu_close(), start_menu_open(), startmenu_procedure(), taskbar_procedure(), terminal_loop(), terminal_procedure(), and window_deco_init_controls().
| surface_id_t window_get_id | ( | window_t * | win | ) |
Get the surface ID of the window.
| win | The window. |
SURFACE_ID_NONE if win is NULL. Definition at line 477 of file window.c.
References NULL, window_t::surface, and SURFACE_ID_NONE.
Referenced by start_menu_close(), and terminal_loop().
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.
References NULL, and window_t::rect.
Referenced by start_menu_open(), and startmenu_procedure().
| surface_type_t window_get_type | ( | window_t * | win | ) |
Get the surface type of the window.
| win | The window. |
SURFACE_NONE if win is NULL. Definition at line 487 of file window.c.
References NULL, SURFACE_NONE, and window_t::type.
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.
References window_t::invalidRect, NULL, RECT_AREA, and RECT_EXPAND_TO_CONTAIN.
Referenced by element_draw_end().
Flush invalidated rectangles to the DWM.
This will send the invalidated rectangle to the DWM and clear the invalid rectangle.
| win | The window. |
0. On failure, ERR and errno is set. Definition at line 570 of file window.c.
References CMD_SURFACE_INVALIDATE, window_t::disp, display_cmd_alloc(), display_cmds_flush(), EINVAL, ERR, errno, cmd_surface_invalidate_t::invalidRect, window_t::invalidRect, NULL, RECT_AREA, window_t::surface, and cmd_surface_invalidate_t::target.
Referenced by window_dispatch().
Move and/or resize the window.
| win | The window. |
| rect | The new screen rectangle for the window. |
0. On failure, ERR and errno is set. Definition at line 507 of file window.c.
References CMD_SURFACE_MOVE, window_t::disp, display_cmd_alloc(), display_cmds_flush(), EINVAL, EPERM, ERR, errno, window_t::flags, NULL, cmd_surface_move_t::rect, window_t::rect, RECT_HEIGHT, RECT_WIDTH, window_t::surface, cmd_surface_move_t::target, and WINDOW_RESIZABLE.
Referenced by start_menu_open(), startmenu_procedure(), and window_deco_handle_dragging().
| 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.
References rect_t::bottom, window_t::buffer, claim(), window_t::clientElement, close(), CMD_SURFACE_NEW, window_t::disp, display_cmd_alloc(), display_cmds_flush(), display_wait(), EINVAL, element_new(), element_new_root(), ELEMENT_NONE, ENOMEM, window_t::entry, ERR, errno, EVENT_SURFACE_NEW, window_t::flags, theme_t::frameSize, free(), window_t::invalidRect, rect_t::left, list_entry_init(), list_push(), malloc(), MAX_NAME, mmap(), mtx_lock(), mtx_unlock(), display_t::mutex, cmd_surface_new_t::name, window_t::name, NULL, procedure(), PROT_READ, PROT_WRITE, cmd_surface_new_t::rect, window_t::rect, RECT_HEIGHT, RECT_INIT, RECT_INIT_DIM, RECT_WIDTH, rect_t::right, window_t::root, event_surface_new_t::shmemKey, strcpy(), strnlen_s(), window_t::surface, event_t::surfaceNew, theme, theme_global_get(), theme_t::titlebarSize, rect_t::top, cmd_surface_new_t::type, window_t::type, WINDOW_CLIENT_ELEM_ID, WINDOW_DECO, WINDOW_DECO_ELEM_ID, window_deco_procedure(), window_free(), and display_t::windows.
Referenced by main(), popup_open(), start_menu_new(), taskbar_new(), and terminal_new().
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.
References CMD_SURFACE_FOCUS_SET, window_t::disp, display_cmd_alloc(), display_cmds_flush(), EINVAL, ERR, errno, cmd_surface_focus_set_t::isGlobal, NULL, window_t::surface, and cmd_surface_focus_set_t::target.
Referenced by start_menu_open().
| 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.
References CMD_SURFACE_TIMER_SET, window_t::disp, display_cmd_alloc(), display_cmds_flush(), EINVAL, ERR, errno, cmd_surface_timer_set_t::flags, NULL, window_t::surface, cmd_surface_timer_set_t::target, and cmd_surface_timer_set_t::timeout.
Referenced by procedure(), start_menu_close(), start_menu_open(), startmenu_procedure(), taskbar_procedure(), terminal_handle_output(), and terminal_procedure().
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 LEVENT_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.
References CMD_SURFACE_VISIBLE_SET, window_t::disp, display_cmd_alloc(), display_cmds_flush(), display_dispatch_pending(), EINVAL, ERR, errno, cmd_surface_visible_set_t::isGlobal, cmd_surface_visible_set_t::isVisible, LEVENT_REDRAW, NULL, window_t::surface, and cmd_surface_visible_set_t::target.
Referenced by main(), start_menu_new(), taskbar_new(), and terminal_new().