The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
app.c File Reference

idunn: the app loop and windows on the window server. More...

#include "idunn_internal.h"
#include <errno.h>
#include <heimdall.h>
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/input.h>
#include <time.h>

Macros

#define FONT_DIR   "/usr/share/fonts"

Functions

idunn_app_t * idunn_app_new (const char *name)
 connect to the window server and read the theme.
void idunn_app_quit (idunn_app_t *app)
heim_conn_t * idunn_app_conn (const idunn_app_t *app)
 the connection to the window server, for calls idunn does not wrap (the shell's heim_shell_start, for example).
void idunn_app_on_event (idunn_app_t *app, void(*on_event)(idunn_app_t *app, const heim_msg_t *msg, void *data), void *data)
 get the events that are about no window of the app (the shell's HEIM_EV_WINDOW, HEIM_EV_WINDOW_APP, HEIM_EV_WINDOW_GONE), and HEIM_EV_SETTINGS (after idunn applied a new theme).
void idunn_app_every (idunn_app_t *app, uint32_t period, void(*every)(void *data), void *data)
 call every(data) each period ms while the app runs (a clock).
void idunn_app_watch (idunn_app_t *app, int fd, void(*ready)(int fd, void *data), void *data)
 call ready(fd, data) when fd can be read (or has hung up) while the app runs: a pty, a pipe.
void idunn_window_set_title (idunn_window_t *win, const char *title)
 a new title in the window's title bar (and the shell's window list).
const idunn_theme_t * idunn_app_theme (const idunn_app_t *app)
void idunn_app_set_theme (idunn_app_t *app, const idunn_theme_t *theme)
 use another theme in all windows of the app (they are drawn again).
bool idunn_app_save_theme (idunn_app_t *app, const char *key, const char *value)
 change a theme setting (mode, accent, radius, font_size, scale, motion) in the user's theme file.
idunn_window_t * idunn_window_new (idunn_app_t *app, const char *title, int32_t width, int32_t height)
 a window with a title bar; it shows when the app runs.
idunn_window_t * idunn_screen_window_new (idunn_app_t *app, const gfx_buffer_t *backdrop)
 a window as large as the screen with no title bar (a login screen).
idunn_window_t * idunn_panel_new (idunn_app_t *app, int32_t height)
 a panel of the desktop shell: no title bar, at the bottom of the screen, as wide as the screen, above the windows (HEIM_WINDOW_PANEL).
void idunn_window_close (idunn_window_t *win)
 close and free the window (and its widgets).
int idunn_app_run (idunn_app_t *app)
 run until the last window is closed or idunn_app_quit.
void idunn_app_paste (idunn_app_t *app, void(*got)(const char *text, size_t length, void *data), void *data)
 ask for the clipboard's text for the program itself (not a widget): got gets it when it comes ("" when the clipboard is empty).
void idunn_window_on_close (idunn_window_t *win, bool(*on_close)(idunn_window_t *win, void *data), void *data)
 the close button (or the shell's Close): on_close returns true to let the window close, false to keep it (to ask about unsaved changes first, and close it later with idunn_window_close).

Detailed Description

idunn: the app loop and windows on the window server.

a window is drawn only when its last frame is on the screen (after HEIM_EV_FRAME), so it is never drawn twice before it shows, and a transition draws one step per frame.

Macro Definition Documentation

◆ FONT_DIR

#define FONT_DIR   "/usr/share/fonts"

Function Documentation

◆ idunn_app_new()

idunn_app_t * idunn_app_new ( const char * name)

connect to the window server and read the theme.

Parameters
namethe program's id, the name of its .app file ("idunn-gallery"): the shell shows its icon with its windows.
Returns
the app, or NULL (no server, or no fonts).

◆ idunn_app_quit()

void idunn_app_quit ( idunn_app_t * app)

◆ idunn_app_conn()

heim_conn_t * idunn_app_conn ( const idunn_app_t * app)

the connection to the window server, for calls idunn does not wrap (the shell's heim_shell_start, for example).

◆ idunn_app_on_event()

void idunn_app_on_event ( idunn_app_t * app,
void(* on_event )(idunn_app_t *app, const heim_msg_t *msg, void *data),
void * data )

get the events that are about no window of the app (the shell's HEIM_EV_WINDOW, HEIM_EV_WINDOW_APP, HEIM_EV_WINDOW_GONE), and HEIM_EV_SETTINGS (after idunn applied a new theme).

◆ idunn_app_every()

void idunn_app_every ( idunn_app_t * app,
uint32_t period,
void(* every )(void *data),
void * data )

call every(data) each period ms while the app runs (a clock).

one per app; a new call replaces it, period 0 stops it.

◆ idunn_app_watch()

void idunn_app_watch ( idunn_app_t * app,
int fd,
void(* ready )(int fd, void *data),
void * data )

call ready(fd, data) when fd can be read (or has hung up) while the app runs: a pty, a pipe.

at most IDUNN_WATCH_MAX at a time; ready NULL stops watching fd.

◆ idunn_window_set_title()

void idunn_window_set_title ( idunn_window_t * win,
const char * title )

a new title in the window's title bar (and the shell's window list).

◆ idunn_app_theme()

const idunn_theme_t * idunn_app_theme ( const idunn_app_t * app)

◆ idunn_app_set_theme()

void idunn_app_set_theme ( idunn_app_t * app,
const idunn_theme_t * theme )

use another theme in all windows of the app (they are drawn again).

◆ idunn_app_save_theme()

bool idunn_app_save_theme ( idunn_app_t * app,
const char * key,
const char * value )

change a theme setting (mode, accent, radius, font_size, scale, motion) in the user's theme file.

every app and the window decorations change.

Returns
false if the file cannot be written; this app changes then.

◆ idunn_window_new()

idunn_window_t * idunn_window_new ( idunn_app_t * app,
const char * title,
int32_t width,
int32_t height )

a window with a title bar; it shows when the app runs.

Parameters
widththe size of its content, in design pixels.

◆ idunn_screen_window_new()

idunn_window_t * idunn_screen_window_new ( idunn_app_t * app,
const gfx_buffer_t * backdrop )

a window as large as the screen with no title bar (a login screen).

Parameters
backdropthe picture under the widgets, as large as the screen (or NULL: the surface colour). it must stay until the app ends.

◆ idunn_panel_new()

idunn_window_t * idunn_panel_new ( idunn_app_t * app,
int32_t height )

a panel of the desktop shell: no title bar, at the bottom of the screen, as wide as the screen, above the windows (HEIM_WINDOW_PANEL).

Parameters
heightin design pixels.

◆ idunn_window_close()

void idunn_window_close ( idunn_window_t * win)

close and free the window (and its widgets).

◆ idunn_app_run()

int idunn_app_run ( idunn_app_t * app)

run until the last window is closed or idunn_app_quit.

Returns
the exit status for main.

◆ idunn_app_paste()

void idunn_app_paste ( idunn_app_t * app,
void(* got )(const char *text, size_t length, void *data),
void * data )

ask for the clipboard's text for the program itself (not a widget): got gets it when it comes ("" when the clipboard is empty).

◆ idunn_window_on_close()

void idunn_window_on_close ( idunn_window_t * win,
bool(* on_close )(idunn_window_t *win, void *data),
void * data )

the close button (or the shell's Close): on_close returns true to let the window close, false to keep it (to ask about unsaved changes first, and close it later with idunn_window_close).