|
ginnOS
The reference: libc, the libraries and the kernel
|
libheimdall: the client side of the heimdalld protocol. More...
#include "heimdall.h"#include <errno.h>#include <fcntl.h>#include <poll.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/mman.h>#include <sys/socket.h>#include <sys/un.h>#include <unistd.h>Macros | |
| #define | MSG_SIZE ((int)sizeof(heim_msg_t)) |
| #define | IN_BUFFER (MSG_SIZE * 32) |
| #define | FD_QUEUE 8 |
Functions | |
| bool | heim_pending (const heim_conn_t *conn) |
| true if a whole message is already read from the socket: the next heim_next_event returns at once. | |
| int | heim_next_event (heim_conn_t *conn, heim_event_t *event, int timeout_ms) |
| the next event. | |
| heim_conn_t * | heim_connect (void) |
| connect to the window server. | |
| void | heim_disconnect (heim_conn_t *conn) |
| close the connection. | |
| int | heim_fd (const heim_conn_t *conn) |
| the connection's socket, to wait for events with poll() together with other files. | |
| void | heim_screen_size (const heim_conn_t *conn, int32_t *width, int32_t *height) |
| bool | heim_window_resize (heim_window_t *win, int32_t width, int32_t height) |
| a new buffer of another size (its pixels are transparent). | |
| heim_window_t * | heim_window_new (heim_conn_t *conn, int32_t width, int32_t height, const char *title, uint32_t flags) |
| make a window with a buffer of that size (its content, without the title bar). | |
| heim_window_t * | heim_popup_new (heim_window_t *parent, int32_t width, int32_t height, uint32_t flags) |
| make a popup of parent (a menu, a popover; with HEIM_WINDOW_TOOLTIP a tooltip). | |
| void | heim_window_place (heim_window_t *popup, gfx_rect_t r, uint32_t side, int32_t margin) |
| where a popup goes: next to the rect r of its parent's content, on a side (HEIM_SIDE_). | |
| void | heim_window_free (heim_window_t *win) |
| gfx_buffer_t * | heim_window_buffer (heim_window_t *win) |
| the buffer to draw into. | |
| void | heim_window_commit (heim_window_t *win, gfx_rect_t damage) |
| show a changed part of the buffer. | |
| bool | heim_window_busy (const heim_window_t *win) |
| true from a commit until its HEIM_EV_FRAME: drawing then can be seen half done. | |
| void | heim_window_set_title (heim_window_t *win, const char *title) |
| void | heim_window_set_cursor (heim_window_t *win, uint32_t shape) |
| the pointer shape over the window's content (HEIM_CURSOR_). | |
| void | heim_window_set_data (heim_window_t *win, void *data) |
| a pointer of the program's own for the window (NULL at first). | |
| void * | heim_window_data (const heim_window_t *win) |
| void | heim_clipboard_set (heim_conn_t *conn, const char *text, size_t length) |
| put text on the clipboard (length 0 empties it). | |
| void | heim_clipboard_request (heim_conn_t *conn) |
| ask for the clipboard's text: it comes as a HEIM_EV_CLIPBOARD event. | |
| void | heim_settings_changed (heim_conn_t *conn, const char *name) |
| tell all clients that the settings file name changed (after conf_save): each gets a HEIM_EV_SETTINGS event with the name, also this one. | |
| void | heim_window_set_app (heim_window_t *win, const char *app) |
| name the program of a window, so the shell can show its icon (the id of its .app file: "idunn-gallery"). | |
| void | heim_shell_start (heim_conn_t *conn) |
| be the desktop shell: from now on HEIM_EV_WINDOW, HEIM_EV_WINDOW_APP and HEIM_EV_WINDOW_GONE tell about every normal window (the event's window is NULL; msg.info.id names the window). | |
| void | heim_shell_act (heim_conn_t *conn, uint32_t id, uint32_t action) |
| the shell does something to a window. | |
| void | heim_shell_quit (heim_conn_t *conn) |
| the shell ends the session: heimdalld stops and the text console comes back. | |
libheimdall: the client side of the heimdalld protocol.
the socket is blocking for sends (64-byte messages, which the server reads quickly) and polled for receives. files that come with messages are kept in a queue until the message that uses them is read.
| #define MSG_SIZE ((int)sizeof(heim_msg_t)) |
| #define IN_BUFFER (MSG_SIZE * 32) |
| #define FD_QUEUE 8 |
| bool heim_pending | ( | const heim_conn_t * | conn | ) |
true if a whole message is already read from the socket: the next heim_next_event returns at once.
a loop that polls heim_fd with other fds checks this first.
| int heim_next_event | ( | heim_conn_t * | conn, |
| heim_event_t * | event, | ||
| int | timeout_ms ) |
the next event.
| timeout_ms | how long to wait: -1 for as long as it takes, 0 not at all. |
| heim_conn_t * heim_connect | ( | void | ) |
connect to the window server.
| void heim_disconnect | ( | heim_conn_t * | conn | ) |
close the connection.
its windows go away (free them first, or not).
| int heim_fd | ( | const heim_conn_t * | conn | ) |
the connection's socket, to wait for events with poll() together with other files.
POLLIN on it: call heim_next_event.
| void heim_screen_size | ( | const heim_conn_t * | conn, |
| int32_t * | width, | ||
| int32_t * | height ) |
| bool heim_window_resize | ( | heim_window_t * | win, |
| int32_t | width, | ||
| int32_t | height ) |
a new buffer of another size (its pixels are transparent).
the old content stays on the screen until the next commit. for HEIM_EV_CONFIGURE, or when the program wants another size.
| heim_window_t * heim_window_new | ( | heim_conn_t * | conn, |
| int32_t | width, | ||
| int32_t | height, | ||
| const char * | title, | ||
| uint32_t | flags ) |
make a window with a buffer of that size (its content, without the title bar).
it shows after the first heim_window_commit.
| flags | HEIM_WINDOW_RESIZABLE, HEIM_WINDOW_ALPHA, HEIM_WINDOW_UNDECORATED. |
| heim_window_t * heim_popup_new | ( | heim_window_t * | parent, |
| int32_t | width, | ||
| int32_t | height, | ||
| uint32_t | flags ) |
make a popup of parent (a menu, a popover; with HEIM_WINDOW_TOOLTIP a tooltip).
place it with heim_window_place before its first commit.
| void heim_window_place | ( | heim_window_t * | popup, |
| gfx_rect_t | r, | ||
| uint32_t | side, | ||
| int32_t | margin ) |
where a popup goes: next to the rect r of its parent's content, on a side (HEIM_SIDE_).
margin: the shadow around its card in its buffer.
| void heim_window_free | ( | heim_window_t * | win | ) |
| gfx_buffer_t * heim_window_buffer | ( | heim_window_t * | win | ) |
the buffer to draw into.
after heim_window_resize it is another one.
| void heim_window_commit | ( | heim_window_t * | win, |
| gfx_rect_t | damage ) |
show a changed part of the buffer.
| bool heim_window_busy | ( | const heim_window_t * | win | ) |
true from a commit until its HEIM_EV_FRAME: drawing then can be seen half done.
an animation draws its next frame when this is false.
| void heim_window_set_title | ( | heim_window_t * | win, |
| const char * | title ) |
| void heim_window_set_cursor | ( | heim_window_t * | win, |
| uint32_t | shape ) |
the pointer shape over the window's content (HEIM_CURSOR_).
| void heim_window_set_data | ( | heim_window_t * | win, |
| void * | data ) |
a pointer of the program's own for the window (NULL at first).
| void * heim_window_data | ( | const heim_window_t * | win | ) |
| void heim_clipboard_set | ( | heim_conn_t * | conn, |
| const char * | text, | ||
| size_t | length ) |
put text on the clipboard (length 0 empties it).
| void heim_clipboard_request | ( | heim_conn_t * | conn | ) |
ask for the clipboard's text: it comes as a HEIM_EV_CLIPBOARD event.
| void heim_settings_changed | ( | heim_conn_t * | conn, |
| const char * | name ) |
tell all clients that the settings file name changed (after conf_save): each gets a HEIM_EV_SETTINGS event with the name, also this one.
| name | the libconf name, "theme". |
| void heim_window_set_app | ( | heim_window_t * | win, |
| const char * | app ) |
name the program of a window, so the shell can show its icon (the id of its .app file: "idunn-gallery").
| void heim_shell_start | ( | heim_conn_t * | conn | ) |
be the desktop shell: from now on HEIM_EV_WINDOW, HEIM_EV_WINDOW_APP and HEIM_EV_WINDOW_GONE tell about every normal window (the event's window is NULL; msg.info.id names the window).
only the first client that asks is the shell.
| void heim_shell_act | ( | heim_conn_t * | conn, |
| uint32_t | id, | ||
| uint32_t | action ) |
the shell does something to a window.
| id | msg.info.id of the window. |
| action | HEIM_ACT_ACTIVATE, HEIM_ACT_MINIMIZE or HEIM_ACT_CLOSE. |
| void heim_shell_quit | ( | heim_conn_t * | conn | ) |
the shell ends the session: heimdalld stops and the text console comes back.