void kde_update_icons() { gulong count = (unsigned) -1; /* grab as many as possible */ Window *ids; unsigned int i; GSList *it, *next; gboolean removed = FALSE; /* were any removed? */ if (! xprop_get32(root, kde_systray_prop, XA_WINDOW, sizeof(Window)*8, &count, &ids)) return; /* add new windows to our list */ for (i = 0; i < count; ++i) { for (it = icons; it != NULL; it = g_slist_next(it)) { TrayWindow *traywin = it->data; if (traywin->id == ids[i]) break; } if (!it) icon_add(ids[i], KDE); } /* remove windows from our list that no longer exist in the property */ for (it = icons; it != NULL;) { TrayWindow *traywin = it->data; gboolean exists; if (traywin->type != KDE) { /* don't go removing non-kde windows */ exists = TRUE; } else { exists = FALSE; for (i = 0; i < count; ++i) { if (traywin->id == ids[i]) { exists = TRUE; break; } } } next = g_slist_next(it); if (!exists) { icon_remove(it); removed =TRUE; } it = next; } if (removed) { /* at least one tray app was removed, so reorganize 'em all and resize*/ reposition_icons(); fix_geometry(); } XFree(ids); }
static void add(Window w){ warn(DEBUG_INFO, "fdtray: Dock request for window %lx", w); int *data = malloc(sizeof(int)); if(!data){ warn(DEBUG_ERROR, "memory allocation failed"); return; } void *v=catch_BadWindow_errors(); XWithdrawWindow(display, w, screen); XSelectInput(display, w, StructureNotifyMask|PropertyChangeMask); Bool map = get_map(w); if(uncatch_BadWindow_errors(v)){ warn(DEBUG_WARN, "fdtray: Dock request for invalid window %lx", w); free(data); return; } struct trayicon *icon = icon_add(my_id, w, data); if(!icon){ free(data); return; } icon_set_mapping(icon, map); }