Taskbar: thumbnails (optimizations)
o9000 mrovi9000@gmail.com
3 files changed,
15 insertions(+),
10 deletions(-)
M
src/taskbar/task.c
→
src/taskbar/task.c
@@ -630,7 +630,7 @@ double now = get_time();
if (now - task->thumbnail_last_update < 0.1) return; fprintf(stderr, "tint2: thumbnail for window: %s" RESET "\n", task->title ? task->title : ""); - cairo_surface_t *thumbnail = get_window_thumbnail(task->win, panel_config.g_task.thumbnail_width, task->current_state == TASK_ACTIVE); + cairo_surface_t *thumbnail = get_window_thumbnail(task->win, panel_config.g_task.thumbnail_width); if (!thumbnail) return; if (task->thumbnail)
M
src/util/window.c
→
src/util/window.c
@@ -414,26 +414,26 @@ &shminfo,
(unsigned)wa.width, (unsigned)wa.height); if (!ximg) { - fprintf(stderr, "tint2: !ximg\n"); + fprintf(stderr, RED "tint2: !ximg" RESET "\n"); goto err0; } shminfo.shmid = shmget(IPC_PRIVATE, (size_t)(ximg->bytes_per_line * ximg->height), IPC_CREAT | 0777); if (shminfo.shmid < 0) { - fprintf(stderr, "tint2: !shmget\n"); + fprintf(stderr, RED "tint2: !shmget" RESET "\n"); goto err1; } shminfo.shmaddr = ximg->data = (char *)shmat(shminfo.shmid, 0, 0); if (!shminfo.shmaddr) { - fprintf(stderr, "tint2: !shmat\n"); + fprintf(stderr, RED "tint2: !shmat" RESET "\n"); goto err2; } shminfo.readOnly = False; if (!XShmAttach(server.display, &shminfo)) { - fprintf(stderr, "tint2: !xshmattach\n"); + fprintf(stderr, RED "tint2: !xshmattach" RESET "\n"); goto err3; } if (!XShmGetImage(server.display, win, ximg, 0, 0, AllPlanes)) { - fprintf(stderr, "tint2: !xshmgetimage\n"); + fprintf(stderr, RED "tint2: !xshmgetimage" RESET "\n"); goto err4; }@@ -569,24 +569,29 @@ }
return empty; } -cairo_surface_t *get_window_thumbnail(Window win, int size, gboolean active) +cairo_surface_t *get_window_thumbnail(Window win, int size) { cairo_surface_t *image_surface = NULL; if (server.has_shm && server.composite_manager) { image_surface = screenshot(win, (size_t)size); - if (cairo_surface_is_blank(image_surface)) { + if (image_surface && cairo_surface_is_blank(image_surface)) { cairo_surface_destroy(image_surface); image_surface = NULL; } + if (!image_surface) + fprintf(stderr, YELLOW "tint2: thumbnail fast path failed, trying slow path" RESET "\n"); } if (!image_surface) { image_surface = get_window_thumbnail_cairo(win, size); - if (cairo_surface_is_blank(image_surface)) { + if (image_surface && cairo_surface_is_blank(image_surface)) { cairo_surface_destroy(image_surface); image_surface = NULL; } + if (!image_surface) + fprintf(stderr, YELLOW "tint2: thumbnail slow path failed" RESET "\n"); } + if (!image_surface) return NULL;
M
src/util/window.h
→
src/util/window.h
@@ -34,6 +34,6 @@ int get_icon_count(gulong *data, int num);
gulong *get_best_icon(gulong *data, int icon_count, int num, int *iw, int *ih, int best_icon_size); char *get_window_name(Window win); -cairo_surface_t *get_window_thumbnail(Window win, int size, gboolean active); +cairo_surface_t *get_window_thumbnail(Window win, int size); #endif