Commit 2fe7efd4 authored by o9000's avatar o9000

Taskbar: thumbnails (optimizations)

parent 1b6fd916
...@@ -630,7 +630,7 @@ void task_refresh_thumbnail(Task *task) ...@@ -630,7 +630,7 @@ void task_refresh_thumbnail(Task *task)
if (now - task->thumbnail_last_update < 0.1) if (now - task->thumbnail_last_update < 0.1)
return; return;
fprintf(stderr, "tint2: thumbnail for window: %s" RESET "\n", task->title ? task->title : ""); 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) if (!thumbnail)
return; return;
if (task->thumbnail) if (task->thumbnail)
......
...@@ -414,26 +414,26 @@ cairo_surface_t *screenshot(Window win, size_t size) ...@@ -414,26 +414,26 @@ cairo_surface_t *screenshot(Window win, size_t size)
(unsigned)wa.width, (unsigned)wa.width,
(unsigned)wa.height); (unsigned)wa.height);
if (!ximg) { if (!ximg) {
fprintf(stderr, "tint2: !ximg\n"); fprintf(stderr, RED "tint2: !ximg" RESET "\n");
goto err0; goto err0;
} }
shminfo.shmid = shmget(IPC_PRIVATE, (size_t)(ximg->bytes_per_line * ximg->height), IPC_CREAT | 0777); shminfo.shmid = shmget(IPC_PRIVATE, (size_t)(ximg->bytes_per_line * ximg->height), IPC_CREAT | 0777);
if (shminfo.shmid < 0) { if (shminfo.shmid < 0) {
fprintf(stderr, "tint2: !shmget\n"); fprintf(stderr, RED "tint2: !shmget" RESET "\n");
goto err1; goto err1;
} }
shminfo.shmaddr = ximg->data = (char *)shmat(shminfo.shmid, 0, 0); shminfo.shmaddr = ximg->data = (char *)shmat(shminfo.shmid, 0, 0);
if (!shminfo.shmaddr) { if (!shminfo.shmaddr) {
fprintf(stderr, "tint2: !shmat\n"); fprintf(stderr, RED "tint2: !shmat" RESET "\n");
goto err2; goto err2;
} }
shminfo.readOnly = False; shminfo.readOnly = False;
if (!XShmAttach(server.display, &shminfo)) { if (!XShmAttach(server.display, &shminfo)) {
fprintf(stderr, "tint2: !xshmattach\n"); fprintf(stderr, RED "tint2: !xshmattach" RESET "\n");
goto err3; goto err3;
} }
if (!XShmGetImage(server.display, win, ximg, 0, 0, AllPlanes)) { if (!XShmGetImage(server.display, win, ximg, 0, 0, AllPlanes)) {
fprintf(stderr, "tint2: !xshmgetimage\n"); fprintf(stderr, RED "tint2: !xshmgetimage" RESET "\n");
goto err4; goto err4;
} }
...@@ -569,25 +569,30 @@ gboolean cairo_surface_is_blank(cairo_surface_t *image_surface) ...@@ -569,25 +569,30 @@ gboolean cairo_surface_is_blank(cairo_surface_t *image_surface)
return empty; 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; cairo_surface_t *image_surface = NULL;
if (server.has_shm && server.composite_manager) { if (server.has_shm && server.composite_manager) {
image_surface = screenshot(win, (size_t)size); 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); cairo_surface_destroy(image_surface);
image_surface = NULL; image_surface = NULL;
} }
if (!image_surface)
fprintf(stderr, YELLOW "tint2: thumbnail fast path failed, trying slow path" RESET "\n");
} }
if (!image_surface) { if (!image_surface) {
image_surface = get_window_thumbnail_cairo(win, size); 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); cairo_surface_destroy(image_surface);
image_surface = NULL; image_surface = NULL;
} }
if (!image_surface)
fprintf(stderr, YELLOW "tint2: thumbnail slow path failed" RESET "\n");
} }
if (!image_surface) if (!image_surface)
return NULL; return NULL;
......
...@@ -34,6 +34,6 @@ int get_icon_count(gulong *data, int num); ...@@ -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); 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); 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 #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment