Exemplo n.º 1
0
static void titleinfoUpdateMachine(CompWindow * w)
{
	TITLEINFO_WINDOW(w);

	if (tw->remoteMachine)
		free(tw->remoteMachine);

	tw->remoteMachine = titleinfoGetTextProperty(w->screen->display, w->id,
						     XA_WM_CLIENT_MACHINE);

	if (titleinfoGetShowRemoteMachine(w->screen))
		titleinfoUpdateVisibleName(w);
}
static void
titleinfoUpdateVisibleName (CompWindow *w)
{
    CompDisplay *d = w->screen->display;
    char        *text = NULL, *machine = NULL;
    const char  *root = "", *title;

    TITLEINFO_DISPLAY (d);
    TITLEINFO_WINDOW (w);

    title = tw->title ? tw->title : "";

    if (titleinfoGetShowRoot (w->screen) && tw->owner == 0)
	root = "ROOT: ";

    if (titleinfoGetShowRemoteMachine (w->screen) && tw->remoteMachine)
    {
	char hostname[256];

	if (gethostname (hostname, 256) || strcmp (hostname, tw->remoteMachine))
	    machine = tw->remoteMachine;
    }

    if (machine)
    {
	if (asprintf (&text, "%s%s (@%s)", root, title, machine) == -1)
		return;
	}
    else if (root[0])
    {
	if (asprintf (&text, "%s%s", root, title) == -1)
		return;
	}
    if (text)
    {
	XChangeProperty (d->display, w->id, td->visibleNameAtom,
			 d->utf8StringAtom, 8, PropModeReplace,
			 (unsigned char *) text, strlen (text));
	free (text);
    }
    else
    {
	XDeleteProperty (d->display, w->id, td->visibleNameAtom);
    }
}