コード例 #1
0
ファイル: titleinfo.c プロジェクト: noodlylight/fusilli
static void
titleinfoUpdateVisibleName (CompWindow *w)
{
	CompDisplay *d = &display;
	char        *text = NULL, *machine = NULL;
	const char  *root = "", *title;

	TITLEINFO_DISPLAY (d);
	TITLEINFO_WINDOW (w);

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

	const BananaValue *
	option_show_root = bananaGetOption (bananaIndex,
	                                    "show_root",
	                                    w->screen->screenNum);

	const BananaValue *
	option_show_remote_machine = bananaGetOption (bananaIndex,
	                                              "show_remote_machine",
	                                              w->screen->screenNum);

	if (option_show_root->b && tw->owner == 0)
		root = "ROOT: ";

	if (option_show_remote_machine->b && tw->remoteMachine)
	{
		char hostname[256];

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

	if (machine)
	{
#pragma GCC diagnostic ignored "-Wunused-variable"
		int retval = asprintf (&text, "%s%s (@%s)", root, title, machine);
	}
	else if (root[0])
	{
#pragma GCC diagnostic ignored "-Wunused-variable"
		int retval = asprintf (&text, "%s%s", root, title);
	}

	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);
	}
}
コード例 #2
0
ファイル: titleinfo.c プロジェクト: AtheistSpacePirate/compiz
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);
}
コード例 #3
0
ファイル: titleinfo.c プロジェクト: noodlylight/fusilli
static void
titleinfoUpdatePid (CompWindow *w)
{
	CompDisplay   *d = &display;
	int pid = -1;
	Atom type;
	int result, format;
	unsigned long nItems, bytesAfter;
	unsigned char *propVal;

	TITLEINFO_DISPLAY (d);
	TITLEINFO_WINDOW (w);

	tw->owner = -1;

	result = XGetWindowProperty (d->display, w->id, td->wmPidAtom,
	                             0L, 1L, False, XA_CARDINAL, &type,
	                             &format, &nItems, &bytesAfter, &propVal);

	if (result == Success && propVal)
	{
		if (nItems)
		{
			unsigned long value;

			memcpy (&value, propVal, sizeof (unsigned long));
			pid = value;
		}

		XFree (propVal);
	}

	if (pid >= 0)
	{
		char path[512];
		struct stat fileStat;

		snprintf (path, 512, "/proc/%d", pid);
		if (!lstat (path, &fileStat))
			tw->owner = fileStat.st_uid;
	}

	const BananaValue *
	option_show_root = bananaGetOption (bananaIndex,
	                                    "show_root",
	                                    w->screen->screenNum);

	if (option_show_root->b)
		titleinfoUpdateVisibleName (w);
}
コード例 #4
0
ファイル: titleinfo.c プロジェクト: AtheistSpacePirate/compiz
static void titleinfoFiniWindow(CompPlugin * p, CompWindow * w)
{
	TITLEINFO_WINDOW(w);

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

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

	tw->remoteMachine = NULL;
	titleinfoUpdateVisibleName(w);

	free(tw);
}
コード例 #5
0
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);
    }
}
コード例 #6
0
ファイル: titleinfo.c プロジェクト: AtheistSpacePirate/compiz
static void titleinfoUpdateTitle(CompWindow * w)
{
	CompDisplay *d = w->screen->display;
	char *title;

	TITLEINFO_WINDOW(w);

	title = titleinfoGetUtf8Property(d, w->id, d->wmNameAtom);

	if (!title)
		title = titleinfoGetTextProperty(d, w->id, XA_WM_NAME);

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

	tw->title = title;
	titleinfoUpdateVisibleName(w);
}
コード例 #7
0
ファイル: titleinfo.c プロジェクト: noodlylight/fusilli
static void
titleinfoUpdateMachine (CompWindow *w)
{
	TITLEINFO_WINDOW (w);

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

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

	const BananaValue *
	option_show_remote_machine = bananaGetOption (bananaIndex,
	                                              "show_remote_machine",
	                                              w->screen->screenNum);

	if (option_show_remote_machine->b)
		titleinfoUpdateVisibleName (w);
}