Ejemplo n.º 1
0
/* Track icon visibility state changes */
void icon_track_visibility_changes(Window w)
{
	struct TrayIcon *ti;
	int mapped;
	/* Ignore false alarms */
	if ((ti = icon_list_find(w)) == NULL || !ti->is_xembed_supported) return;
	mapped = xembed_get_mapped_state(ti);
	LOG_TRACE(("xembed_is_mapped(0x%x) = %u\n", w, mapped));
	LOG_TRACE(("is_visible = %u\n", ti->is_visible));
#ifdef DEBUG
	x11_dump_win_info(tray_data.dpy, ti->wid);
#endif
	/* Nothing has changed */
	if (mapped == ti->is_visible) return;
	ti->is_visible = mapped;
	LOG_INFO(("%s icon 0x%x\n", mapped ? "showing" : "hiding", w));
	if (mapped) { /* Icon has become mapped and is listed as hidden. Show this icon. */
		embedder_reset_size(ti);
		if (!layout_add(ti)) {
			xembed_set_mapped_state(ti, False);
			return;
		}
		embedder_show(ti);
	} else { /* Icon has become unmapped and is listed as visible. Hide this icon. */
		layout_remove(ti);
		embedder_hide(ti);
	}
	embedder_update_positions(False);
	tray_update_window_props();
}
Ejemplo n.º 2
0
void reparent_notify(XReparentEvent ev)
{
	struct TrayIcon *ti;
	ti = icon_list_find(ev.window);
	if (ti == NULL) return;
	/* Reparenting out of the tray is one of non-destructive
	 * ways to end XEMBED protocol (see spec) */
	if (ti->is_embedded && ti->mid_parent != ev.parent) {
		LOG_TRACE(("will now unembed 0x%x\n", ti->wid));
#ifdef DEBUG
		print_icon_data(ti);
		x11_dump_win_info(tray_data.dpy, ev.parent);
#endif
		remove_icon(ev.window);
	}
}
Ejemplo n.º 3
0
/* 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;
}