Refactor panel refresh; new debug option debug_frames

This commit is contained in:
o9000 2017-03-04 12:19:35 +01:00
parent cb72aa7996
commit d7f294d7c2
14 changed files with 93 additions and 64 deletions

View file

@ -202,7 +202,7 @@ void battery_default_font_changed()
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 @@ void update_battery_tick(void *arg)
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();
}
}
}

View file

@ -118,7 +118,7 @@ void update_clocks_sec(void *arg)
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 @@ void update_clocks_min(void *arg)
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 @@ void clock_default_font_changed()
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,

View file

@ -226,7 +226,7 @@ void execp_default_font_changed()
}
}
}
panel_refresh = TRUE;
schedule_panel_redraw();
}
void cleanup_execp()

View file

@ -121,6 +121,6 @@ gboolean resize_freespace(void *obj)
}
schedule_redraw(&freespace->area);
panel_refresh = TRUE;
schedule_panel_redraw();
return TRUE;
}

View file

@ -111,7 +111,7 @@ void init_launcher_panel(void *p)
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 @@ void launcher_default_icon_theme_changed()
launcher_load_icons(launcher);
launcher->area.resize_needed = 1;
}
panel_refresh = TRUE;
schedule_panel_redraw();
}

View file

@ -969,7 +969,7 @@ void autohide_show(void *p)
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 @@ void autohide_hide(void *p)
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 @@ void 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);
}
}

View file

@ -90,6 +90,8 @@ extern Imlib_Image default_icon;
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);

View file

@ -135,7 +135,7 @@ gboolean resize_separator(void *obj)
}
schedule_redraw(&separator->area);
panel_refresh = TRUE;
schedule_panel_redraw();
return TRUE;
}

View file

@ -1106,7 +1106,7 @@ void systray_reconfigure_event(TrayWindow *traywin, XEvent *e)
profiling_get_time(),
__FUNCTION__,
__LINE__);
panel_refresh = TRUE;
schedule_panel_redraw();
refresh_systray = TRUE;
}
@ -1185,7 +1185,7 @@ void systray_resize_request_event(TrayWindow *traywin, XEvent *e)
profiling_get_time(),
__FUNCTION__,
__LINE__);
panel_refresh = TRUE;
schedule_panel_redraw();
refresh_systray = TRUE;
}
@ -1393,7 +1393,7 @@ void systray_render_icon_composited(void *t)
if (error)
goto on_error;
panel_refresh = TRUE;
schedule_panel_redraw();
if (systray_profile)
fprintf(stderr,

View file

@ -640,7 +640,7 @@ void set_task_state(Task *task, TaskState state)
p->area.resize_needed = TRUE;
}
}
panel_refresh = TRUE;
schedule_panel_redraw();
}
}
}
@ -658,7 +658,7 @@ void blink_urgent(void *arg)
}
urgent_task = urgent_task->next;
}
panel_refresh = TRUE;
schedule_panel_redraw();
}
void add_urgent(Task *task)

View file

@ -366,7 +366,7 @@ void taskbar_default_font_changed()
}
}
}
panel_refresh = TRUE;
schedule_panel_redraw();
}
void taskbar_remove_task(Window *win)
@ -536,7 +536,7 @@ void set_taskbar_state(Taskbar *taskbar, TaskbarState state)
schedule_redraw((Area *)l->data);
}
}
panel_refresh = TRUE;
schedule_panel_redraw();
}
#define NONTRIVIAL 2
@ -649,7 +649,7 @@ void sort_tasks(Taskbar *taskbar)
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;
}

View file

@ -113,7 +113,7 @@ void taskbarname_default_font_changed()
schedule_redraw(&taskbar->bar_name.area);
}
}
panel_refresh = TRUE;
schedule_panel_redraw();
}
void cleanup_taskbarname()

View file

@ -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 @@ void init(int argc, char *argv[])
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 @@ void 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 @@ void get_snapshot(const char *path)
}
}
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 @@ void event_button_motion_notify(XEvent *e)
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 @@ void event_button_motion_notify(XEvent *e)
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 @@ void update_desktop_names()
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 @@ void update_task_desktop(Task *task)
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 @@ void event_property_notify(XEvent *e)
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 @@ void event_property_notify(XEvent *e)
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 @@ void event_property_notify(XEvent *e)
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 @@ void event_property_notify(XEvent *e)
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 @@ void event_property_notify(XEvent *e)
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 @@ void event_property_notify(XEvent *e)
}
if (taskbar_sort_method == TASKBAR_SORT_TITLE)
sort_taskbar_for_win(win);
panel_refresh = TRUE;
schedule_panel_redraw();
}
}
// Demand attention
@ -1277,7 +1285,7 @@ void event_property_notify(XEvent *e)
}
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 @@ void event_property_notify(XEvent *e)
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 @@ void event_property_notify(XEvent *e)
}
XFree(wmhints);
task_update_icon(task);
panel_refresh = TRUE;
schedule_panel_redraw();
}
if (!server.got_root_win)
@ -1322,7 +1330,7 @@ void event_expose(XEvent *e)
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 @@ void event_configure_notify(XEvent *e)
set_task_state(task, TASK_ACTIVE);
active_task = task;
}
panel_refresh = TRUE;
schedule_panel_redraw();
}
}
}
@ -1748,7 +1756,7 @@ start:
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 @@ start:
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 @@ start:
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 @@ start:
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();
}
}
}

View file

@ -17,6 +17,7 @@
* 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 @@ void schedule_redraw(Area *a)
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 @@ void show(Area *a)
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 @@ void update_dependent_gradients(Area *a)
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 @@ void remove_area(Area *a)
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 @@ void add_area(Area *a, Area *parent)
parent->children = g_list_append(parent->children, a);
parent->resize_needed = TRUE;
schedule_redraw(parent);
panel_refresh = TRUE;
}
}
@ -652,7 +654,7 @@ void mouse_over(Area *area, int pressed)
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 @@ void mouse_out()
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 @@ void update_gradient(GradientInstance *gi)
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 @@ void update_gradient(GradientInstance *gi)
gi->gradient_class->end_color.rgb[1],
gi->gradient_class->end_color.rgb[2],
gi->gradient_class->end_color.alpha);
schedule_redraw(gi->area);
}