/* Add icon to the tray */ void add_icon(Window w, int cmode) { struct TrayIcon *ti; /* Aviod adding duplicates */ if ((ti = icon_list_find(w)) != NULL) { LOG_TRACE(("ignoring second request to embed 0x%x" "(requested cmode=%d, current cmode=%d\n", w, cmode, ti->cmode)); return; } /* Dear Edsger W. Dijkstra, I see you behind my back =( */ if ((ti = icon_list_new(w, cmode)) == NULL) goto failed0; LOG_TRACE(("starting embedding for icon 0x%x, cmode=%d\n", w, cmode)); x11_dump_win_info(tray_data.dpy, w); /* Start embedding cycle */ if (!xembed_check_support(ti)) goto failed1; if (ti->is_xembed_supported) ti->is_visible = xembed_get_mapped_state(ti); else ti->is_visible = True; if (ti->is_visible) { if (!embedder_reset_size(ti)) goto failed1; //if (!layout_add(ti)) goto failed1; } if (!xembed_embed(ti)) goto failed1; if (!embedder_embed(ti)) goto failed2; refresh_icons_later(FALSE); /* Report success */ LOG_INFO(("added icon %s (wid 0x%x) as %s\n", x11_get_window_name(tray_data.dpy, ti->wid, "<unknown>"), ti->wid, ti->is_visible ? "visible" : "hidden")); goto ok; failed2: //layout_remove(ti); failed1: icon_list_free(ti); failed0: LOG_INFO(("failed to add icon %s (wid 0x%x)\n", x11_get_window_name(tray_data.dpy, ti->wid, "<unknown>"), ti->wid)); ok: if (settings.log_level >= LOG_LEVEL_TRACE) dump_tray_status(); return; }
/* Remove icon from the tray */ void remove_icon(Window w) { struct TrayIcon *ti; //char *name; /* Ignore false alarms */ if ((ti = icon_list_find(w)) == NULL) return; dump_tray_status(); embedder_unembed(ti); xembed_unembed(ti); //layout_remove(ti); icon_list_free(ti); LOG_INFO(("removed icon %s (wid 0x%x)\n", x11_get_window_name(tray_data.dpy, ti->wid, "<unknown>"), w)); refresh_icons_later(FALSE); dump_tray_status(); }
/* Remove a destroyed icon from the tray */ void destroy_icon(Window w) { struct TrayIcon *ti; //char *name; /* Ignore false alarms */ if ((ti = icon_list_find(w)) == NULL) return; dump_tray_status(); ti->is_destroyed = True; embedder_unembed(ti); xembed_unembed(ti); //layout_remove(ti); icon_list_free(ti); LOG_INFO(("destroy icon (wid 0x%x)\n", w)); refresh_icons_later(FALSE); dump_tray_status(); }
/* Remove icon from the tray */ void remove_icon(Window w) { struct TrayIcon *ti; char *name; /* Ignore false alarms */ if ((ti = icon_list_find(w)) == NULL) return; dump_tray_status(); embedder_unembed(ti); xembed_unembed(ti); layout_remove(ti); icon_list_free(ti); LOG_INFO(("removed icon %s (wid 0x%x)\n", x11_get_window_name(tray_data.dpy, ti->wid, "<unknown>"), w)); /* no need to call embedde_update_positions(), as * scrollbars_click(SB_WND_MAX) will call it */ /* XXX: maybe we need a different name for this * routine instad of passing cryptinc constant? */ scrollbars_click(SB_WND_MAX); tray_update_window_props(); dump_tray_status(); }