libxputty 0.1
Loading...
Searching...
No Matches
xputty.c
Go to the documentation of this file.
1/*
2 * 0BSD
3 *
4 * BSD Zero Clause License
5 *
6 * Copyright (c) 2019 Hermann Meyer
7 *
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted.
10
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
12 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
13 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
14 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
16 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17 * PERFORMANCE OF THIS SOFTWARE.
18 *
19 */
20
21#include "xputty.h"
22
23
24void main_init(Xputty *main) {
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}
48
49void main_run(Xputty *main) {
50 os_main_run(main);
51}
52
53void run_embedded(Xputty *main) {
54 os_run_embedded(main);
55}
56
57void main_quit(Xputty *main) {
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}
Childlist_t - struct to hold a Widget_t child list Xputty main holds a list of any Widget_t created...
Definition xchildlist.h:49
Widget_t ** childs
Definition xchildlist.h:51
SystrayColor - the Systray Color struct SystrayColor could be used for the backgroung color of the Sy...
Definition xcolor.h:122
Widget_t - struct to hold the basic Widget_t info.
Definition xwidget.h:457
XColor_t - the Widget_t Color struct XColor_t could be used for theming you Widget_t set.
Definition xcolor.h:105
Xputty - the main struct. It should be declared before any other call to a Xputty function....
Definition xputty.h:228
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_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 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 main_quit(Xputty *main)
main_quit - destroy all remaining Widget_t's from the main->childlist. Free all resources which may...
Definition xputty.c:57
void main_init(Xputty *main)
main_init - open the Display and init the main->childlist. Set the bool run to true....
Definition xputty.c:24
void main_run(Xputty *main)
main_run - start the main event loop. It should be start after your Widget_t's been created....
Definition xputty.c:49
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 b...
Definition xputty.c:53
This file contains definitions and structs used on all platforms. Platform specific definitions are l...
void os_main_run(Xputty *main)
os_main_run - start the event loop
void os_init_dnd(Xputty *main)
os_init_dnd - register a Widget_t for handling drag and drop events only implemented on linux
void os_run_embedded(Xputty *main)
os_run_embedded - the event handling when run embedded on windows all messges goes into WndProc,...
void os_close_display(Display *dpy)
os_close_display - Close connection to the used display
Display * os_open_display(char *display_name)
os_open_display - Connect to the display to use
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