libxputty 0.1
Loading...
Searching...
No Matches
Functions
xputty.c File Reference

Go to the source code of this file.

Functions

void main_init (Xputty *main)
 main_init - open the Display and init the main->childlist.
Set the bool run to true.
The bool run is used to terminate the main event loop.
main_init() should be called directly after the declaration of Xputty before the first Widget_t get created.
Any Widget_t created afterwards will be added to the main childlist.
The main childlist is used to check if a Widget_t is valid to receive a Event.
Xputty check if a Widget_t is registerd in the main childlist, and only forward events when it found the Widget_t in the list.
When a Widget_t call destroy_widget() any childs of this Widget_t receive a call to destroy_widget() to release there memory, they get removed from the main childlist and finaly the Widget_t itself will be removed from the main childlist as well. On main_quit() any remaining Widget_t from the main childlist will be destroyed, to ensure that we leave the memory clean.
 
void main_run (Xputty *main)
 main_run - start the main event loop.
It should be start after your Widget_t's been created.
You could create and destroy additional Widget_t's at any time later during run.
 
void run_embedded (Xputty *main)
 run_embedded - the main event loop to run embedded UI's.
It should be start after your Widget_t's been created.
You could create and destroy additional Widget_t's at any time later during run.
 
void main_quit (Xputty *main)
 main_quit - destroy all remaining Widget_t's from the main->childlist.
Free all resources which may be allocated between init and quit.
It should be called after main_run()/run_embedded();
 

Function Documentation

◆ main_init()

void main_init ( Xputty main)

main_init - open the Display and init the main->childlist.
Set the bool run to true.
The bool run is used to terminate the main event loop.
main_init() should be called directly after the declaration of Xputty before the first Widget_t get created.
Any Widget_t created afterwards will be added to the main childlist.
The main childlist is used to check if a Widget_t is valid to receive a Event.
Xputty check if a Widget_t is registerd in the main childlist, and only forward events when it found the Widget_t in the list.
When a Widget_t call destroy_widget() any childs of this Widget_t receive a call to destroy_widget() to release there memory, they get removed from the main childlist and finaly the Widget_t itself will be removed from the main childlist as well. On main_quit() any remaining Widget_t from the main childlist will be destroyed, to ensure that we leave the memory clean.

Parameters
*main- pointer to the main Xputty struct

Definition at line 24 of file xputty.c.

24 {
25 main->dpy = os_open_display(0);
26 assert(main->dpy);
27 main->childlist = (Childlist_t*)malloc(sizeof(Childlist_t));
28 assert(main->childlist);
30 main->color_scheme = (XColor_t*)malloc(sizeof(XColor_t));
31 assert(main->color_scheme);
32 set_dark_theme(main);
33 main->systray_color = (SystrayColor_t*)malloc(sizeof(SystrayColor_t));
34 assert(main->systray_color);
35 set_systray_color(main, 0.3, 0.3, 0.3, 1.0);
36 main->hold_grab = NULL;
37 main->key_snooper = NULL;
38 main->submenu = NULL;
39 main->run = true;
40 main->is_grab = false;
41 main->small_font = 10;
42 main->normal_font = 12;
43 main->big_font = 16;
44 main->ctext = NULL;
45 main->csize = 0;
46 os_init_dnd(main);
47}
Childlist_t - struct to hold a Widget_t child list Xputty main holds a list of any Widget_t created...
Definition xchildlist.h:49
SystrayColor - the Systray Color struct SystrayColor could be used for the backgroung color of the Sy...
Definition xcolor.h:122
XColor_t - the Widget_t Color struct XColor_t could be used for theming you Widget_t set.
Definition xcolor.h:105
SystrayColor_t * systray_color
Definition xputty.h:236
bool is_grab
Definition xputty.h:258
XColor_t * color_scheme
Definition xputty.h:234
bool run
Definition xputty.h:256
int big_font
Definition xputty.h:250
int normal_font
Definition xputty.h:248
Display * dpy
Definition xputty.h:232
Widget_t * hold_grab
Definition xputty.h:238
Childlist_t * childlist
Definition xputty.h:230
Widget_t * submenu
Definition xputty.h:242
Widget_t * key_snooper
Definition xputty.h:240
int csize
Definition xputty.h:252
unsigned char * ctext
Definition xputty.h:244
int small_font
Definition xputty.h:246
void childlist_init(Childlist_t *childlist)
childlist_init - internal use to allocate the array to min size You usually didn't need to call thi...
Definition xchildlist.c:25
void set_dark_theme(Xputty *main)
set_dark_theme - init the XColor_t struct to the default dark theme
Definition xcolor.c:24
void set_systray_color(Xputty *main, double r, double g, double b, double a)
set_systray_color - set the systray background color
Definition xcolor.c:300
void os_init_dnd(Xputty *main)
os_init_dnd - register a Widget_t for handling drag and drop events only implemented on linux
Display * os_open_display(char *display_name)
os_open_display - Connect to the display to use

References Xputty::big_font, Xputty::childlist, childlist_init(), Xputty::color_scheme, Xputty::csize, Xputty::ctext, Xputty::dpy, Xputty::hold_grab, Xputty::is_grab, Xputty::key_snooper, Xputty::normal_font, os_init_dnd(), os_open_display(), Xputty::run, set_dark_theme(), set_systray_color(), Xputty::small_font, Xputty::submenu, and Xputty::systray_color.

◆ main_quit()

void main_quit ( Xputty main)

main_quit - destroy all remaining Widget_t's from the main->childlist.
Free all resources which may be allocated between init and quit.
It should be called after main_run()/run_embedded();

Parameters
*main- pointer to the main Xputty struct

Definition at line 57 of file xputty.c.

57 {
58 int i = main->childlist->elem-1;
59 for(;i>-1;i--) {
60 Widget_t *w = main->childlist->childs[i];
61 destroy_widget(w, main);
62 }
64 free(main->childlist);
65 free(main->color_scheme);
66 free(main->systray_color);
67 os_close_display(main->dpy);
68 free(main->ctext);
69 debug_print("quit\n");
70}
Widget_t ** childs
Definition xchildlist.h:51
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
void childlist_destroy(Childlist_t *childlist)
childlist_destroy - internal use to free the Childlist_t You usually didn't need to call this
Definition xchildlist.c:38
void os_close_display(Display *dpy)
os_close_display - Close connection to the used display
void destroy_widget(Widget_t *w, Xputty *main)
destroy_widget - destroy a widget When a Widget_t receive a destroy_widget() call,...
Definition xwidget.c:86

References Xputty::childlist, childlist_destroy(), Childlist_t::childs, Xputty::color_scheme, Xputty::ctext, destroy_widget(), Xputty::dpy, Childlist_t::elem, os_close_display(), and Xputty::systray_color.

◆ main_run()

void main_run ( Xputty main)

main_run - start the main event loop.
It should be start after your Widget_t's been created.
You could create and destroy additional Widget_t's at any time later during run.

Parameters
*main- pointer to the main Xputty struct

Definition at line 49 of file xputty.c.

49 {
50 os_main_run(main);
51}
void os_main_run(Xputty *main)
os_main_run - start the event loop

References os_main_run().

◆ run_embedded()

void run_embedded ( Xputty main)

run_embedded - the main event loop to run embedded UI's.
It should be start after your Widget_t's been created.
You could create and destroy additional Widget_t's at any time later during run.

Parameters
*main- pointer to the main Xputty struct

Definition at line 53 of file xputty.c.

53 {
54 os_run_embedded(main);
55}
void os_run_embedded(Xputty *main)
os_run_embedded - the event handling when run embedded on windows all messges goes into WndProc,...

References os_run_embedded().