All pastes #610512 Raw Edit

set _NET_WM_ICON from GdkPixbuf

public text v1 · immutable
·published 2007-07-09 14:43 UTC
rendered paste body
void
egg_tray_icon_set_from_pixbuf (GtkWidget *icon,
			       GdkPixbuf *pixbuf) {
	GdkPixmap *pixmap;
	GdkBitmap *mask;
	Window window;
	XWMHints *wm_hints;
	
	window = (Window) gtk_plug_get_id (GTK_PLUG(icon));
	
	gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 255);
	
	wm_hints = XGetWMHints (gdk_display, window);
	if (!wm_hints)
		wm_hints = XAllocWMHints ();
	
	if (pixmap != NULL) {
		wm_hints->flags |= IconPixmapHint;
		wm_hints->icon_pixmap = (Pixmap) gdk_x11_drawable_get_xid(pixmap);
	}
	
	if (mask != NULL) {
		wm_hints->flags |= IconMaskHint;
		wm_hints->icon_mask = (Pixmap) gdk_x11_drawable_get_xid(mask);
	}
	
	XSetWMHints (gdk_display, window, wm_hints);
	XFree (wm_hints);
}