all repos — tint2 @ df241dfd895a0b4332672557c90aa6f5b97b9527

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

src/util/common.h (raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**************************************************************************
* Common declarations
*
**************************************************************************/

#ifndef COMMON_H
#define COMMON_H

#define WM_CLASS_TINT "panel"

#include <Imlib2.h>
#include <pango/pangocairo.h>
#include "area.h"

#define GREEN  "\033[1;32m"
#define YELLOW "\033[1;33m"
#define RED    "\033[1;31m"
#define BLUE   "\033[1;34m"
#define RESET  "\033[0m"

// mouse actions
typedef enum MouseAction {
	NONE = 0,
	CLOSE,
	TOGGLE,
	ICONIFY,
	SHADE,
	TOGGLE_ICONIFY,
	MAXIMIZE_RESTORE,
	MAXIMIZE,
	RESTORE,
	DESKTOP_LEFT,
	DESKTOP_RIGHT,
	NEXT_TASK,
	PREV_TASK
} MouseAction;

#define ALL_DESKTOPS  0xFFFFFFFF

// Copies a file to another path
void copy_file(const char *path_src, const char *path_dest);

// Parses lines with the format 'key = value' into key and value.
// Strips key and value.
// Values may contain spaces and the equal sign.
// Returns 1 if both key and value could be read, zero otherwise.
int parse_line(const char *line, char **key, char **value);

void extract_values(const char *value, char **value1, char **value2, char **value3);

// Executes a command in a shell.
void tint_exec(const char *command);

// Returns a copy of s in which "~" is expanded to the path to the user's home directory.
// The caller takes ownership of the string.
char *expand_tilde(const char *s);

// The opposite of expand_tilde: replaces the path to the user's home directory with "~".
// The caller takes ownership of the string.
char *contract_tilde(const char *s);

// Color
int hex_char_to_int(char c);
int hex_to_rgb(char *hex, int *r, int *g, int *b);
void get_color(char *hex, double *rgb);

Imlib_Image load_image(const char *path, int cached);

// Adjusts the alpha/saturation/brightness on an ARGB image.
// Parameters: alpha from 0 to 100, satur from 0 to 1, bright from 0 to 1.
void adjust_asb(DATA32 *data, int w, int h, int alpha, float satur, float bright);
Imlib_Image adjust_icon(Imlib_Image original, int alpha, int saturation, int brightness);

void create_heuristic_mask(DATA32 *data, int w, int h);

// Renders the current Imlib image to a drawable. Wrapper around imlib_render_image_on_drawable.
void render_image(Drawable d, int x, int y);

void get_text_size2(PangoFontDescription *font,
					int *height_ink,
					int *height,
					int *width,
					int panel_height,
					int panel_with,
					char *text,
					int len,
					PangoWrapMode wrap,
					PangoEllipsizeMode ellipsis,
					gboolean markup);

void draw_text(PangoLayout *layout, cairo_t *c, int posx, int posy, Color *color, int font_shadow);

// Draws a rounded rectangle
void draw_rect(cairo_t *c, double x, double y, double w, double h, double r);

// Clears the pixmap (with transparent color)
void clear_pixmap(Pixmap p, int x, int y, int w, int h);

// Appends to the list locations all the directories contained in the environment variable var (split by ":").
// Optional suffixes are added to each directory. The suffix arguments MUST end with NULL.
// Returns the new value of the list.
GSList *load_locations_from_env(GSList *locations, const char *var, ...);

GSList *slist_remove_duplicates(GSList *list, GCompareFunc eq, GDestroyNotify fr);

#define free_and_null(p) { free(p); p = NULL; }

#if !GLIB_CHECK_VERSION (2, 33, 4)
GList *g_list_copy_deep(GList *list, GCopyFunc func, gpointer user_data);
#endif

#if !GLIB_CHECK_VERSION (2, 38, 0)
#define g_assert_null(expr) g_assert((expr) == NULL)
#endif

#endif