all repos — tint2 @ d7f294d7c266a4f9081133d42dbaecf8f8800a3d

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

Refactor panel refresh; new debug option debug_frames
o9000 mrovi9000@gmail.com
commit

d7f294d7c266a4f9081133d42dbaecf8f8800a3d

parent

cb72aa7996d62763a2372806fa6a61d3287bec29

M src/battery/battery.csrc/battery/battery.c

@@ -202,7 +202,7 @@ for (int i = 0; i < num_panels; i++) {

panels[i].battery.area.resize_needed = TRUE; schedule_redraw(&panels[i].battery.area); } - panel_refresh = TRUE; + schedule_panel_redraw(); } void update_battery_tick(void *arg)

@@ -257,7 +257,7 @@ if (panels[i].battery.area.on_screen) {

if (old_found != battery_found || old_percentage != battery_state.percentage || old_hours != battery_state.time.hours || old_minutes != battery_state.time.minutes) { panels[i].battery.area.resize_needed = TRUE; - panel_refresh = TRUE; + schedule_panel_redraw(); } } }
M src/clock/clock.csrc/clock/clock.c

@@ -118,7 +118,7 @@ if (time1_format) {

for (int i = 0; i < num_panels; i++) panels[i].clock.area.resize_needed = 1; } - panel_refresh = TRUE; + schedule_panel_redraw(); } void update_clocks_min(void *arg)

@@ -132,7 +132,7 @@ if (time1_format) {

for (int i = 0; i < num_panels; i++) panels[i].clock.area.resize_needed = 1; } - panel_refresh = TRUE; + schedule_panel_redraw(); } }

@@ -239,7 +239,7 @@ for (int i = 0; i < num_panels; i++) {

panels[i].clock.area.resize_needed = TRUE; schedule_redraw(&panels[i].clock.area); } - panel_refresh = TRUE; + schedule_panel_redraw(); } void clock_compute_text_geometry(Panel *panel,
M src/execplugin/execplugin.csrc/execplugin/execplugin.c

@@ -226,7 +226,7 @@ schedule_redraw(&execp->area);

} } } - panel_refresh = TRUE; + schedule_panel_redraw(); } void cleanup_execp()
M src/freespace/freespace.csrc/freespace/freespace.c

@@ -121,6 +121,6 @@ freespace->area.height = size;

} schedule_redraw(&freespace->area); - panel_refresh = TRUE; + schedule_panel_redraw(); return TRUE; }
M src/launcher/launcher.csrc/launcher/launcher.c

@@ -111,7 +111,7 @@ // This will be recomputed on resize, we just initialize to a non-zero value

launcher->icon_size = launcher_max_icon_size > 0 ? launcher_max_icon_size : 24; launcher->area.on_screen = TRUE; - panel_refresh = TRUE; + schedule_panel_redraw(); instantiate_area_gradients(&launcher->area); launcher_load_themes(launcher);

@@ -619,5 +619,5 @@ launcher_load_themes(launcher);

launcher_load_icons(launcher); launcher->area.resize_needed = 1; } - panel_refresh = TRUE; + schedule_panel_redraw(); }
M src/panel.csrc/panel.c

@@ -969,7 +969,7 @@ XMapSubwindows(server.display, panel->main_win); // systray windows

set_panel_window_geometry(panel); set_panel_layer(panel, TOP_LAYER); refresh_systray = TRUE; // ugly hack, because we actually only need to call XSetBackgroundPixmap - panel_refresh = TRUE; + schedule_panel_redraw(); } void autohide_hide(void *p)

@@ -980,7 +980,7 @@ set_panel_layer(panel, panel_layer);

panel->is_hidden = TRUE; XUnmapSubwindows(server.display, panel->main_win); // systray windows set_panel_window_geometry(panel); - panel_refresh = TRUE; + schedule_panel_redraw(); } void autohide_trigger_show(Panel *p)

@@ -1065,3 +1065,11 @@ taskbar_default_font_changed();

taskbarname_default_font_changed(); tooltip_default_font_changed(); } + +void _schedule_panel_redraw(const char *file, const char *function, const int line) +{ + panel_refresh = TRUE; + if (debug_fps) { + fprintf(stderr, YELLOW "%s %s %d: triggering panel redraw" RESET "\n", file, function, line); + } +}
M src/panel.hsrc/panel.h

@@ -90,6 +90,8 @@ #define DEFAULT_FONT "sans 10"

extern char *default_font; extern XSettingsClient *xsettings_client; extern gboolean debug_geometry; +extern gboolean debug_fps; +extern gboolean debug_frames; typedef struct Panel { Area area;

@@ -159,6 +161,8 @@ void init_panel_size_and_position(Panel *panel);

gboolean resize_panel(void *obj); void render_panel(Panel *panel); void shrink_panel(Panel *panel); +void _schedule_panel_redraw(const char *file, const char *function, const int line); +#define schedule_panel_redraw() _schedule_panel_redraw(__FILE__, __FUNCTION__, __LINE__) void set_panel_items_order(Panel *p); void place_panel_all_desktops(Panel *p);
M src/separator/separator.csrc/separator/separator.c

@@ -135,7 +135,7 @@ separator->area.width - 2 * separator->area.paddingy - left_right_border_width(&separator->area);

} schedule_redraw(&separator->area); - panel_refresh = TRUE; + schedule_panel_redraw(); return TRUE; }
M src/systray/systraybar.csrc/systray/systraybar.c

@@ -1106,7 +1106,7 @@ BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n",

profiling_get_time(), __FUNCTION__, __LINE__); - panel_refresh = TRUE; + schedule_panel_redraw(); refresh_systray = TRUE; }

@@ -1185,7 +1185,7 @@ BLUE "[%f] %s:%d trigger resize & redraw" RESET "\n",

profiling_get_time(), __FUNCTION__, __LINE__); - panel_refresh = TRUE; + schedule_panel_redraw(); refresh_systray = TRUE; }

@@ -1393,7 +1393,7 @@

if (error) goto on_error; - panel_refresh = TRUE; + schedule_panel_redraw(); if (systray_profile) fprintf(stderr,
M src/taskbar/task.csrc/taskbar/task.c

@@ -640,7 +640,7 @@ p->taskbar->area.resize_needed = TRUE;

p->area.resize_needed = TRUE; } } - panel_refresh = TRUE; + schedule_panel_redraw(); } } }

@@ -658,7 +658,7 @@ set_task_state(t, window_is_iconified(t->win) ? TASK_ICONIFIED : TASK_NORMAL);

} urgent_task = urgent_task->next; } - panel_refresh = TRUE; + schedule_panel_redraw(); } void add_urgent(Task *task)
M src/taskbar/taskbar.csrc/taskbar/taskbar.c

@@ -366,7 +366,7 @@ schedule_redraw(&t->area);

} } } - panel_refresh = TRUE; + schedule_panel_redraw(); } void taskbar_remove_task(Window *win)

@@ -536,7 +536,7 @@ for (; l; l = l->next)

schedule_redraw((Area *)l->data); } } - panel_refresh = TRUE; + schedule_panel_redraw(); } #define NONTRIVIAL 2

@@ -649,7 +649,7 @@ return;

taskbar->area.children = g_list_sort_with_data(taskbar->area.children, (GCompareDataFunc)compare_tasks, taskbar); taskbar->area.resize_needed = TRUE; - panel_refresh = TRUE; + schedule_panel_redraw(); ((Panel *)taskbar->area.panel)->area.resize_needed = TRUE; }
M src/taskbar/taskbarname.csrc/taskbar/taskbarname.c

@@ -113,7 +113,7 @@ taskbar->bar_name.area.resize_needed = TRUE;

schedule_redraw(&taskbar->bar_name.area); } } - panel_refresh = TRUE; + schedule_panel_redraw(); } void cleanup_taskbarname()
M src/tint.csrc/tint.c

@@ -80,7 +80,9 @@ timeout *detect_compositor_timer = NULL;

int detect_compositor_timer_counter = 0; gboolean debug_fps = FALSE; +gboolean debug_frames = FALSE; float *fps_distribution = NULL; +int frame = 0; void create_fps_distribution() {

@@ -468,6 +470,7 @@

debug_geometry = getenv("DEBUG_GEOMETRY") != NULL; debug_gradients = getenv("DEBUG_GRADIENTS") != NULL; debug_fps = getenv("DEBUG_FPS") != NULL; + debug_frames = getenv("DEBUG_FRAMES") != NULL; if (debug_fps) create_fps_distribution(); }

@@ -650,28 +653,17 @@ uevent_cleanup();

cleanup_fps_distribution(); } -void get_snapshot(const char *path) +void dump_panel_to_file(const Panel *panel, const char *path) { - Panel *panel = &panels[0]; - - if (panel->area.width > server.monitors[0].width) - panel->area.width = server.monitors[0].width; - - panel->temp_pmap = - XCreatePixmap(server.display, server.root_win, panel->area.width, panel->area.height, server.depth); - render_panel(panel); - - XSync(server.display, False); - imlib_context_set_drawable(panel->temp_pmap); Imlib_Image img = imlib_create_image_from_drawable(0, 0, 0, panel->area.width, panel->area.height, 1); if (!img) { XImage *ximg = - XGetImage(server.display, panel->temp_pmap, 0, 0, panel->area.width, panel->area.height, AllPlanes, ZPixmap); + XGetImage(server.display, panel->temp_pmap, 0, 0, panel->area.width, panel->area.height, AllPlanes, ZPixmap); if (ximg) { - DATA32 *pixels = calloc(panel->area.width * panel->area.height, sizeof(DATA32)); + DATA32 *pixels = (DATA32 *)calloc(panel->area.width * panel->area.height, sizeof(DATA32)); for (int x = 0; x < panel->area.width; x++) { for (int y = 0; y < panel->area.height; y++) { DATA32 xpixel = XGetPixel(ximg, x, y);

@@ -702,6 +694,22 @@ imlib_free_image();

} } +void get_snapshot(const char *path) +{ + Panel *panel = &panels[0]; + + if (panel->area.width > server.monitors[0].width) + panel->area.width = server.monitors[0].width; + + panel->temp_pmap = + XCreatePixmap(server.display, server.root_win, panel->area.width, panel->area.height, server.depth); + render_panel(panel); + + XSync(server.display, False); + + dump_panel_to_file(panel, path); +} + void window_action(Task *task, MouseAction action) { if (!task)

@@ -869,7 +877,7 @@ gpointer temp = task_iter->data;

task_iter->data = drag_iter->data; drag_iter->data = temp; event_taskbar->area.resize_needed = 1; - panel_refresh = TRUE; + schedule_panel_redraw(); task_dragged = 1; } }

@@ -900,7 +908,7 @@

event_taskbar->area.resize_needed = 1; drag_taskbar->area.resize_needed = 1; task_dragged = 1; - panel_refresh = TRUE; + schedule_panel_redraw(); panel->area.resize_needed = 1; } }

@@ -1055,7 +1063,7 @@ }

for (GSList *l = list; l; l = l->next) g_free(l->data); g_slist_free(list); - panel_refresh = TRUE; + schedule_panel_redraw(); } void update_task_desktop(Task *task)

@@ -1065,7 +1073,7 @@ Window win = task->win;

remove_task(task); task = add_task(win); reset_active_task(); - panel_refresh = TRUE; + schedule_panel_redraw(); } void event_property_notify(XEvent *e)

@@ -1125,7 +1133,7 @@ reset_active_task();

update_all_taskbars_visibility(); if (old_desktop != server.desktop) tooltip_trigger_hide(); - panel_refresh = TRUE; + schedule_panel_redraw(); } else if (old_desktop != server.desktop) { tooltip_trigger_hide(); for (int i = 0; i < num_panels; i++) {

@@ -1144,7 +1152,7 @@ Task *task = l->data;

if (task->desktop == ALL_DESKTOPS) { task->area.on_screen = always_show_all_desktop_tasks; taskbar->area.resize_needed = 1; - panel_refresh = TRUE; + schedule_panel_redraw(); if (taskbar_mode == MULTI_DESKTOP) panel->area.resize_needed = 1; }

@@ -1195,14 +1203,14 @@ if (debug)

fprintf(stderr, "%s %d: win = root, atom = _NET_CLIENT_LIST\n", __FUNCTION__, __LINE__); taskbar_refresh_tasklist(); update_all_taskbars_visibility(); - panel_refresh = TRUE; + schedule_panel_redraw(); } // Change active else if (at == server.atom._NET_ACTIVE_WINDOW) { if (debug) fprintf(stderr, "%s %d: win = root, atom = _NET_ACTIVE_WINDOW\n", __FUNCTION__, __LINE__); reset_active_task(); - panel_refresh = TRUE; + schedule_panel_redraw(); } else if (at == server.atom._XROOTPMAP_ID || at == server.atom._XROOTMAP_ID) { if (debug) fprintf(stderr, "%s %d: win = root, atom = _XROOTPMAP_ID\n", __FUNCTION__, __LINE__);

@@ -1210,7 +1218,7 @@ // change Wallpaper

for (int i = 0; i < num_panels; i++) { set_panel_background(&panels[i]); } - panel_refresh = TRUE; + schedule_panel_redraw(); } } else { TrayWindow *traywin = systray_find_icon(win);

@@ -1241,7 +1249,7 @@ XWindowAttributes wa;

XGetWindowAttributes(server.display, win, &wa); if (wa.map_state == IsViewable && !window_is_skip_taskbar(win)) { if ((task = add_task(win))) - panel_refresh = TRUE; + schedule_panel_redraw(); } } return;

@@ -1257,7 +1265,7 @@ tooltip_update();

} if (taskbar_sort_method == TASKBAR_SORT_TITLE) sort_taskbar_for_win(win); - panel_refresh = TRUE; + schedule_panel_redraw(); } } // Demand attention

@@ -1277,7 +1285,7 @@ add_urgent(task);

} if (window_is_skip_taskbar(win)) { remove_task(task); - panel_refresh = TRUE; + schedule_panel_redraw(); } } else if (at == server.atom.WM_STATE) { // Iconic state

@@ -1285,12 +1293,12 @@ TaskState state = (active_task && task->win == active_task->win ? TASK_ACTIVE : TASK_NORMAL);

if (window_is_iconified(win)) state = TASK_ICONIFIED; set_task_state(task, state); - panel_refresh = TRUE; + schedule_panel_redraw(); } // Window icon changed else if (at == server.atom._NET_WM_ICON) { task_update_icon(task); - panel_refresh = TRUE; + schedule_panel_redraw(); } // Window desktop changed else if (at == server.atom._NET_WM_DESKTOP) {

@@ -1307,7 +1315,7 @@ add_urgent(task);

} XFree(wmhints); task_update_icon(task); - panel_refresh = TRUE; + schedule_panel_redraw(); } if (!server.got_root_win)

@@ -1322,7 +1330,7 @@ panel = get_panel(e->xany.window);

if (!panel) return; // TODO : one panel_refresh per panel ? - panel_refresh = TRUE; + schedule_panel_redraw(); } void event_configure_notify(XEvent *e)

@@ -1370,7 +1378,7 @@ if (win == get_active_window()) {

set_task_state(task, TASK_ACTIVE); active_task = task; } - panel_refresh = TRUE; + schedule_panel_redraw(); } } }

@@ -1748,7 +1756,7 @@ }

if (first_render) { first_render = FALSE; if (panel_shrink) - panel_refresh = TRUE; + schedule_panel_redraw(); } if (debug_fps) ts_render_finished = get_time();

@@ -1764,9 +1772,10 @@ double flush_ratio = (ts_flush_finished - ts_render_finished) / period;

double fps_low, fps_median, fps_high, fps_samples; fps_compute_stats(&fps_low, &fps_median, &fps_high, &fps_samples); fprintf(stderr, - BLUE "fps = %.0f (low %.0f, med %.0f, high %.0f, samples %.0f) : processing %.0f%%, rendering %.0f%%, " + BLUE "frame %d: fps = %.0f (low %.0f, med %.0f, high %.0f, samples %.0f) : processing %.0f%%, rendering %.0f%%, " "flushing %.0f%%" RESET "\n", - fps, + frame, + fps, fps_low, fps_median, fps_high,

@@ -1775,6 +1784,14 @@ proc_ratio * 100,

render_ratio * 100, flush_ratio * 100); } + if (debug_frames) { + for (int i = 0; i < num_panels; i++) { + char path[256]; + sprintf(path, "tint2-%d-panel-%d-frame-%d.png", getpid(), i, frame); + dump_panel_to_file(&panels[i], path); + } + } + frame++; } // Create a File Description Set containing x11_fd

@@ -1819,7 +1836,7 @@ GList *l_instance;

for (l_instance = execp->backend->instances; l_instance; l_instance = l_instance->next) { Execp *instance = l_instance->data; instance->area.resize_needed = TRUE; - panel_refresh = TRUE; + schedule_panel_redraw(); } } }
M src/util/area.csrc/util/area.c

@@ -17,6 +17,7 @@ * along with this program; if not, write to the Free Software

* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **************************************************************************/ +#include <assert.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/Xatom.h>

@@ -359,7 +360,7 @@ }

for (GList *l = a->children; l; l = l->next) schedule_redraw((Area *)l->data); - panel_refresh = TRUE; + schedule_panel_redraw(); } void draw_tree(Area *a)

@@ -413,7 +414,7 @@ a->on_screen = TRUE;

if (parent) parent->resize_needed = TRUE; a->resize_needed = TRUE; - panel_refresh = TRUE; + schedule_panel_redraw(); } void update_dependent_gradients(Area *a)

@@ -424,6 +425,8 @@ if (a->_changed) {

for (GList *l = a->dependent_gradients; l; l = l->next) { GradientInstance *gi = (GradientInstance *)l->data; update_gradient(gi); + if (gi->area != a) + schedule_redraw(gi->area); } } for (GList *l = a->children; l; l = l->next)

@@ -575,7 +578,7 @@

if (parent) { parent->children = g_list_remove(parent->children, area); parent->resize_needed = TRUE; - panel_refresh = TRUE; + schedule_panel_redraw(); schedule_redraw(parent); }

@@ -593,7 +596,6 @@ if (parent) {

parent->children = g_list_append(parent->children, a); parent->resize_needed = TRUE; schedule_redraw(parent); - panel_refresh = TRUE; } }

@@ -652,7 +654,7 @@ mouse_over_area->mouse_state = new_state;

mouse_over_area->pix = mouse_over_area->pix_by_state[mouse_over_area->mouse_state]; if (!mouse_over_area->pix) mouse_over_area->_redraw_needed = TRUE; - panel_refresh = TRUE; + schedule_panel_redraw(); } void mouse_out()

@@ -663,7 +665,7 @@ mouse_over_area->mouse_state = MOUSE_NORMAL;

mouse_over_area->pix = mouse_over_area->pix_by_state[mouse_over_area->mouse_state]; if (!mouse_over_area->pix) mouse_over_area->_redraw_needed = TRUE; - panel_refresh = TRUE; + schedule_panel_redraw(); mouse_over_area = NULL; }

@@ -1056,7 +1058,6 @@ return;

cairo_pattern_destroy(gi->pattern); gi->pattern = NULL; } - schedule_redraw(gi->area); double from_x, from_y, from_r; compute_control_point(gi, &gi->gradient_class->from, &from_x, &from_y, &from_r); double to_x, to_y, to_r;

@@ -1131,5 +1132,4 @@ gi->gradient_class->end_color.rgb[0],

gi->gradient_class->end_color.rgb[1], gi->gradient_class->end_color.rgb[2], gi->gradient_class->end_color.alpha); - schedule_redraw(gi->area); }