1 /************************************************************************** 2 * task : 3 * - 4 * 5 **************************************************************************/ 6 7 #ifndef TASK_H 8 #define TASK_H 9 10 #include <X11/Xlib.h> 11 #include <pango/pangocairo.h> 12 #include <Imlib2.h> 13 14 #include "common.h" 15 #include "timer.h" 16 17 typedef enum TaskState { 18 TASK_NORMAL = 0, 19 TASK_ACTIVE, 20 TASK_ICONIFIED, 21 TASK_URGENT, 22 TASK_UNDEFINED, 23 TASK_STATE_COUNT, 24 } TaskState; 25 26 typedef struct GlobalTask { 27 Area area; 28 gboolean has_text; 29 gboolean has_icon; 30 gboolean centered; 31 int icon_posy; 32 int icon_size1; 33 int maximum_width; 34 int maximum_height; 35 int alpha[TASK_STATE_COUNT]; 36 int saturation[TASK_STATE_COUNT]; 37 int brightness[TASK_STATE_COUNT]; 38 int config_asb_mask; 39 Background *background[TASK_STATE_COUNT]; 40 GList *gradient[TASK_STATE_COUNT]; 41 int config_background_mask; 42 // starting position for text ~ task_padding + task_border + icon_size 43 double text_posx, text_height; 44 gboolean has_font; 45 gboolean has_content_tint; 46 PangoFontDescription *font_desc; 47 Color font[TASK_STATE_COUNT]; 48 int config_font_mask; 49 gboolean tooltip_enabled; 50 gboolean thumbnail_enabled; 51 int thumbnail_width; 52 } GlobalTask; 53 54 // Stores information about a task. 55 // Warning: any dynamically allocated members are shared between the Task instances created for the same window 56 // (if the task appears on all desktops, there will be a different instance on each desktop's taskbar). 57 typedef struct Task { 58 Area area; 59 Window win; 60 int desktop; 61 TaskState current_state; 62 Imlib_Image icon[TASK_STATE_COUNT]; 63 Imlib_Image icon_hover[TASK_STATE_COUNT]; 64 Imlib_Image icon_press[TASK_STATE_COUNT]; 65 unsigned int icon_width; 66 unsigned int icon_height; 67 Color icon_color; 68 Color icon_color_hover; 69 Color icon_color_press; 70 char *title; 71 char *application; 72 int urgent_tick; 73 // These may not be up-to-date 74 int win_x; 75 int win_y; 76 int win_w; 77 int win_h; 78 struct timespec last_activation_time; 79 int _text_width; 80 int _text_height; 81 double _text_posy; 82 int _icon_x; 83 int _icon_y; 84 cairo_surface_t *thumbnail; 85 double thumbnail_last_update; 86 } Task; 87 88 extern Timer urgent_timer; 89 extern GSList *urgent_list; 90 91 Task *add_task(Window win); 92 void remove_task(Task *task); 93 94 void draw_task(void *obj, cairo_t *c); 95 void on_change_task(void *obj); 96 97 void task_update_icon(Task *task); 98 void task_update_desktop(Task *task); 99 gboolean task_update_title(Task *task); 100 void reset_active_task(); 101 void set_task_state(Task *task, TaskState state); 102 void task_handle_mouse_event(Task *task, MouseAction action); 103 void task_refresh_thumbnail(Task *task); 104 105 // Given a pointer to the task that is currently under the mouse (current_task), 106 // returns a pointer to the Task for the active window on the same taskbar. 107 // If not found, returns the current task. 108 Task *find_active_task(Task *current_task); 109 110 Task *next_task(Task *task); 111 Task *prev_task(Task *task); 112 113 void add_urgent(Task *task); 114 void del_urgent(Task *task); 115 116 #endif 117