update TODO
[tint2-nick87720z.git] / src / panel.h
blob8433be5e3554c357cefa33103f5fddc3e919e686
1 /**************************************************************************
2 * Copyright (C) 2008 Pål Staurland (staura@gmail.com)
3 * Modified (C) 2008/2009 thierry lorthiois (lorthiois@bbsoft.fr)
5 * panel :
6 * - draw panel and all objects according to panel_layout
9 **************************************************************************/
11 #ifndef PANEL_H
12 #define PANEL_H
14 #include <pango/pangocairo.h>
15 #include <sys/time.h>
17 #include "common.h"
18 #include "clock.h"
19 #include "task.h"
20 #include "taskbar.h"
21 #include "systraybar.h"
22 #include "launcher.h"
23 #include "freespace.h"
24 #include "execplugin.h"
25 #include "separator.h"
26 #include "button.h"
28 #ifdef ENABLE_BATTERY
29 #include "battery.h"
30 #endif
32 // --------------------------------------------------
33 // mouse events
34 extern MouseAction mouse_left;
35 extern MouseAction mouse_middle;
36 extern MouseAction mouse_right;
37 extern MouseAction mouse_scroll_up;
38 extern MouseAction mouse_scroll_down;
39 extern MouseAction mouse_tilt_left;
40 extern MouseAction mouse_tilt_right;
42 typedef enum TaskbarMode {
43 // panel mode
44 SINGLE_DESKTOP,
45 MULTI_DESKTOP,
46 } TaskbarMode;
48 typedef enum Layer {
49 BOTTOM_LAYER,
50 NORMAL_LAYER,
51 TOP_LAYER,
52 } Layer;
54 typedef enum PanelPosition {
55 // panel position
56 LEFT = 0x01,
57 RIGHT = 0x02,
58 CENTER = 0X04,
59 TOP = 0X08,
60 BOTTOM = 0x10,
61 } PanelPosition;
63 typedef enum StrutPolicy {
64 STRUT_MINIMUM,
65 STRUT_FOLLOW_SIZE,
66 STRUT_NONE,
67 } StrutPolicy;
69 enum StrutType {
70 STRUT_LEFT,
71 STRUT_RIGHT,
72 STRUT_TOP,
73 STRUT_BOTTOM,
74 STRUT_LEFT_Y1,
75 STRUT_LEFT_Y2,
76 STRUT_RIGHT_Y1,
77 STRUT_RIGHT_Y2,
78 STRUT_TOP_X1,
79 STRUT_TOP_X2,
80 STRUT_BOTTOM_X1,
81 STRUT_BOTTOM_X2,
82 STRUT_COUNT,
83 STRUT_COUNT_OLD = 4,
85 typedef long StrutType;
87 extern TaskbarMode taskbar_mode;
88 extern gboolean wm_menu;
89 extern gboolean panel_dock;
90 extern gboolean panel_pivot_struts;
91 extern Layer panel_layer;
92 extern char *panel_window_name;
93 extern PanelPosition panel_position;
94 extern gboolean panel_horizontal;
95 extern gboolean panel_redraw;
96 extern gboolean task_dragged;
97 extern gboolean panel_autohide;
98 extern int panel_autohide_show_timeout;
99 extern int panel_autohide_hide_timeout;
100 extern int panel_autohide_height; // for vertical panels this is, of course, the width
101 extern gboolean panel_shrink;
102 extern StrutPolicy panel_strut_policy;
103 extern char *panel_items_order;
104 extern int max_tick_urgent;
105 extern GArray *backgrounds;
106 extern GArray *gradients;
107 extern Imlib_Image default_icon;
108 #define DEFAULT_FONT "sans 10"
109 extern char *default_font;
110 extern XSettingsClient *xsettings_client;
111 extern gboolean startup_notifications;
112 extern gboolean debug_geometry;
113 extern gboolean debug_fps;
114 extern double tracing_fps_threshold;
115 extern gboolean debug_frames;
116 extern gboolean debug_thumbnails;
117 extern double ui_scale_dpi_ref;
118 extern double ui_scale_monitor_size_ref;
119 extern gboolean thumb_use_shm;
120 extern gboolean debug_blink;
122 typedef struct Panel {
123 Area area;
125 Window main_win;
126 Pixmap temp_pmap;
128 // position relative to root window
129 int posx, posy;
130 int marginx, marginy;
131 gboolean fractional_width, fractional_height;
132 int max_size;
133 int monitor;
134 gboolean font_shadow;
135 gboolean mouse_effects;
137 // Mouse effects for icons
138 int mouse_over_alpha;
139 int mouse_over_saturation;
140 int mouse_over_brightness;
141 int mouse_pressed_alpha;
142 int mouse_pressed_saturation;
143 int mouse_pressed_brightness;
144 double scale;
146 // Per-panel parameters and states for Taskbar and Task
147 GlobalTaskbar g_taskbar;
148 GlobalTask g_task;
150 // Array of Taskbar, with num_desktops items
151 Taskbar *taskbar;
152 int num_desktops;
153 gboolean taskbarname_has_font;
154 PangoFontDescription *taskbarname_font_desc;
156 Clock clock;
158 #ifdef ENABLE_BATTERY
159 Battery battery;
160 #endif
162 Launcher launcher;
163 GList *freespace_list;
164 GList *separator_list;
165 GList *execp_list;
166 GList *button_list;
168 // Autohide
169 gboolean is_hidden;
170 int hidden_width, hidden_height;
171 Pixmap hidden_pixmap;
172 Timer autohide_timer;
173 } Panel;
175 extern Panel panel_config;
176 extern Panel *panels;
177 extern int num_panels;
179 void default_panel(); // default global data
180 void cleanup_panel(); // freed memory
182 void init_panel();
183 // realloc panels according to number of monitor
184 // use panel_config as default value
186 void init_panel_geometry(Panel *panel);
187 gboolean resize_panel(void *obj);
188 void render_panel(Panel *panel);
189 void shrink_panel(Panel *panel);
190 void _schedule_panel_redraw(const char *file, const char *function, const int line);
191 #define schedule_panel_redraw() _schedule_panel_redraw(__FILE__, __func__, __LINE__)
193 void set_panel_items_order(Panel *p);
194 void place_panel_all_desktops(Panel *p);
195 void replace_panel_all_desktops(Panel *p);
196 void set_panel_properties(Panel *p);
197 void set_panel_window_geometry(Panel *panel);
198 void set_panel_layer(Panel *p, Layer layer);
200 void set_panel_background(Panel *p);
201 // draw background panel
203 Panel *get_panel(Window win);
204 // detect witch panel
206 Taskbar *click_taskbar(Panel *panel, int x, int y);
207 Task *click_task(Panel *panel, int x, int y);
208 Launcher *click_launcher(Panel *panel, int x, int y);
209 LauncherIcon *click_launcher_icon(Panel *panel, int x, int y);
210 Clock *click_clock(Panel *panel, int x, int y);
212 #ifdef ENABLE_BATTERY
213 Battery *click_battery(Panel *panel, int x, int y);
214 #endif
216 Area *click_area(Panel *panel, int x, int y);
217 Execp *click_execp(Panel *panel, int x, int y);
218 Button *click_button(Panel *panel, int x, int y);
220 void autohide_show(void *p);
221 void autohide_hide(void *p);
222 void autohide_trigger_show(Panel *p, bool forced);
223 void autohide_trigger_hide(Panel *p, bool forced);
225 const char *get_default_font();
227 void default_icon_theme_changed();
228 void default_font_changed();
230 void free_icon(Imlib_Image icon);
231 Imlib_Image scale_adjust_icon( Imlib_Image original, int icon_size);
233 void save_screenshot(const char *path);
234 void save_panel_screenshot(const Panel *panel, const char *path);
236 /// Helper shortcut macroses
238 #define BUTTON_CASE(i,c) case i: command = c; \
239 cmd_sink = c ## _sink; \
240 break
242 #define lower_if_bottom(p) \
243 if (panel_layer == BOTTOM_LAYER) \
244 XLowerWindow(server.display, (p)->main_win);
246 #endif