static void faviconcb(webview * const view) { tab * const cur = findtab(view); if (!cur || cur->state != TS_WEB) return; if (cur->icon) delete cur->icon; cur->icon = wk_get_favicon(cur->url); g->url->url->input().image(NULL); if (!cur->icon) return; // It may be in a wrong resolution - resize in that case if (cur->icon->w() != 16 || cur->icon->h() != 16) { Fl_RGB_Image *old = cur->icon; cur->icon = (Fl_RGB_Image *) old->copy(16, 16); delete old; } if (g->tabs[g->curtab].web == view) { g->url->url->input().image(cur->icon); g->url->redraw(); } g->tabwidget->redraw(); }
void TaskButton::update_image_from_xid(void) { E_RETURN_IF_FAIL(xid >= 0); Fl_RGB_Image *img = netwm_window_get_icon(xid, TASKBUTTON_ICON_W); if(!img) return; int width = img->w(), height = img->h(); /* some safety, scale it if needed */ if((width > TASKBUTTON_ICON_W) || (height > TASKBUTTON_ICON_H)) { width = (width > TASKBUTTON_ICON_W) ? TASKBUTTON_ICON_W : width; height = (height > TASKBUTTON_ICON_H) ? TASKBUTTON_ICON_H : height; /* safe casting */ Fl_RGB_Image *scaled = (Fl_RGB_Image*)img->copy(width, height); delete img; img = scaled; } clear_image(); image(img); image_alloc = true; }