Пример #1
0
static void
NewCurrentClipContents(char *data, int len)
{
    XawTextBlock textBlock;

    SaveClip (text, currentClip);

    /* append new clips at the end */
    while (currentClip && currentClip->next)
	currentClip = currentClip->next;
    /* any trailing clips with no text get overwritten */
    if (strlen (currentClip->clip) != 0)
	currentClip = NewClip (text, currentClip);
    
    textBlock.ptr = data;
    textBlock.firstPos = 0;
    textBlock.length = len;
    textBlock.format = FMT8BIT;
    if (XawTextReplace(text, 0, TextLength (text), &textBlock)) {
#ifdef XKB
	XkbStdBell(XtDisplay(text), XtWindow(text), 0, XkbBI_Info);
#else
	XBell( XtDisplay(text), 0);
#endif
    }
    set_button_state ();
}
Пример #2
0
Файл: util.c Проект: aosm/X11
void Feep(int type, int volume, Window win)
{
#ifdef XKB
    XkbStdBell(theDisplay, win, volume, type);
#else
    XBell(theDisplay, volume);
#endif
}
Пример #3
0
Файл: lock.c Проект: aosm/X11
void
UnableToLockSession(char *session_name)
{
    /*
     * We should popup a dialog here giving error.
     */

#ifdef XKB
    XkbStdBell(XtDisplay(topLevel),XtWindow(topLevel),0,XkbBI_Failure);
#else
    XBell (XtDisplay (topLevel), 0);
#endif
    sleep (2);

    ChooseSession ();
}
Пример #4
0
static void
ChooseSessionLoadXtProc(Widget w, XtPointer client_data, XtPointer callData)
{
    XawListReturnStruct *current;

    CheckDeleteCancel ();
    CheckBreakLockCancel ();

    current = XawListShowCurrent (chooseSessionListWidget);

    if (!current || !current->string || *(current->string) == '\0')
    {
	if (current)
	    XtFree ((char *) current);
#ifdef XKB
	XkbStdBell(XtDisplay(topLevel),XtWindow(topLevel),0,XkbBI_BadValue);
#else
	XBell (XtDisplay (topLevel), 0);
#endif
	return;
    }

    /*
     * Pop down choice of sessions and start the specified session.
     */

    XtPopdown (chooseSessionPopup);

    if (session_name)
	XtFree (session_name);

    session_name = XtNewString (current->string);

    XtFree ((char *) current);

    FreeSessionNames (sessionNameCount,
	sessionNamesShort, sessionNamesLong, sessionsLocked);


    /*
     * Start the session, looking for .XSM-<session name> startup file.
     */

    if (!StartSession (session_name, False))
	UnableToLockSession (session_name);
}
Пример #5
0
Файл: xclock.c Проект: 8l/x11
static void 
quit(Widget w, XEvent *event, String *params, Cardinal *num_params)
{
    Arg arg;

    if (event->type == ClientMessage &&
	event->xclient.data.l[0] != wm_delete_window) {
#ifdef XKB
	XkbStdBell(XtDisplay(w), XtWindow(w), 0, XkbBI_MinorError);
#else
	XBell (XtDisplay(w), 0);
#endif
    } else {
	/* resign from the session */
	XtSetArg(arg, XtNjoinSession, False);
	XtSetValues(w, &arg, ONE);
	die(w, NULL, NULL);
    }
}
Пример #6
0
Файл: xcutsel.c Проект: aosm/X11
static void 
StoreBuffer(Widget w, XtPointer client_data, Atom *selection, Atom *type, 
	    XtPointer value, unsigned long *length, int *format)
{

    if (*type == 0 || *type == XT_CONVERT_FAIL || *length == 0) {
#ifdef XKB
	XkbStdBell( XtDisplay(w), XtWindow(w), 0, XkbBI_MinorError );
#else
	XBell( XtDisplay(w), 0 );
#endif
	return;
    }

    XStoreBuffer( XtDisplay(w), (char*)value, (int)(*length),
		  options.buffer );
   
    XtFree(value);
}
Пример #7
0
Файл: restart.c Проект: aosm/X11
void
Clone(ClientRec *client, Bool useSavedState)
{
    char	*cwd;
    char	*program;
    char	**args;
    char	**env;
    char	**pp;
    char	*p;
    char	*restart_service_prop;
    char	*restart_protocol;
    char	*restart_machine;
    Bool	run_local;
    List	*pl, *pj;

    if (verbose)
    {
	printf ("Cloning id '%s', useSavedState = %d...\n",
		client->clientId, useSavedState);
	printf ("Host = %s\n", client->clientHostname);
    }

    cwd = ".";
    env = NULL;
    program = NULL;
    args = NULL;
    restart_service_prop = NULL;

    for (pl = ListFirst (client->props); pl; pl = ListNext (pl))
    {
	Prop *pprop = (Prop *) pl->thing;
	List *vl = ListFirst (pprop->values);
	PropValue *pval = (PropValue *) vl->thing;

	if (strcmp (pprop->name, SmProgram) == 0)
	    program = (char *) pval->value;
	else if (strcmp (pprop->name, SmCurrentDirectory) == 0)
	    cwd = (char *) pval->value;
	else if (strcmp (pprop->name, "_XC_RestartService") == 0)
	    restart_service_prop = (char *) pval->value;
	else if (
	    (!useSavedState && strcmp (pprop->name, SmCloneCommand) == 0) ||
	    (useSavedState && strcmp (pprop->name, SmRestartCommand) == 0))
	{
	    args = (char **) XtMalloc (
		(ListCount (pprop->values) + 1) * sizeof (char *));

	    pp = args;

	    for (pj = ListFirst (pprop->values); pj; pj = ListNext (pj))
	    {
		pval = (PropValue *) pj->thing;
		*pp++ = (char *) pval->value;
	    }
	    *pp = NULL;
	}
	else if (strcmp (pprop->name, SmEnvironment) == 0)
	{
	    env = (char **) XtMalloc (
		(ListCount (pprop->values) + 3 + 1) * sizeof (char *));
	    pp = env;

	    for (pj = ListFirst (pprop->values); pj; pj = ListNext (pj))
	    {
		pval = (PropValue *) pj->thing;
		p = (char *) pval->value;

		if ((display_env && strbw (p, "DISPLAY="))
	         || (session_env && strbw (p, "SESSION_MANAGER="))
		 || (audio_env && strbw (p, "AUDIOSERVER=")))
		    continue;

		*pp++ = p;
	    }

	    if (display_env)
		*pp++ = display_env;
	    if (session_env)
		*pp++ = session_env;
	    if (audio_env)
		*pp++ = audio_env;

	    *pp = NULL;
	}
    }

    if (program && args)
    {
	if (verbose)
	{
	    printf("\t%s\n", program);
	    printf("\t");
	    for (pp = args; *pp; pp++)
		printf ("%s ", *pp);
	    printf("\n");
	}

	GetRestartInfo (restart_service_prop, client->clientHostname,
    	    &run_local, &restart_protocol, &restart_machine);

	if (run_local)
	{
	    /*
	     * The client is being cloned on the local machine.
	     */

	    char msg[256];

	    switch(fork()) {
	    case -1:
		sprintf (msg, "%s: Can't fork() %s", Argv[0], program);
		add_log_text (msg);
		perror (msg);
		break;
	    case 0:		/* kid */
		chdir(cwd);
		if(env) environ = env;
		execvp(program, args);
		sprintf (msg, "%s: Can't execvp() %s", Argv[0], program);
		perror (msg);
		/*
		 * TODO : We would like to send this log information to the
		 * log window in the parent.  This would require opening
		 * a pipe between the parent and child.  The child would
		 * set close-on-exec.  If the exec succeeds, the pipe will
		 * be closed.  If it fails, the child can write a message
		 * to the parent.
		 */
		_exit(255);
	    default:	/* parent */
		break;
	    }
	}
	else if (!remote_allowed)
	{
	    fprintf(stderr,
		   "Can't remote clone client ID '%s': only local supported\n",
			client->clientId);
	}
	else
	{
	    /*
	     * The client is being cloned on a remote machine.
	     */

	    remote_start (restart_protocol, restart_machine,
		program, args, cwd, env,
		non_local_display_env, non_local_session_env);
	}

	if (restart_protocol)
	    XtFree (restart_protocol);

	if (restart_machine)
	    XtFree (restart_machine);

    }
    else
    {
#ifdef XKB
	XkbStdBell(XtDisplay(topLevel),XtWindow(topLevel),0,XkbBI_Failure);
#else
	XBell (XtDisplay (topLevel), 0);
#endif

	fprintf(stderr, "Can't restart ID '%s':  no program or no args\n",
		client->clientId);
    }

    if (args)
	XtFree ((char *)args);
    if (env)
	XtFree ((char *)env);
}
Пример #8
0
/*ARGSUSED*/
static void 
InsertClipboard(Widget w, XtPointer client_data, Atom *selection, 
		Atom *type, XtPointer value, unsigned long *length, 
		int *format)
{
    Display *d = XtDisplay(w);
    Atom target = (Atom)client_data;
    Boolean convert_failed = (*type == XT_CONVERT_FAIL);

    if (!convert_failed)
    {
	char **list;
	int i, ret, count;

	XTextProperty prop;
	prop.value = value;
	prop.nitems = *length;
	prop.format = *format;
	prop.encoding = *type;
	ret = XmbTextPropertyToTextList(d, &prop, &list, &count);
	if (ret >= Success)
	{
	    /* manuals say something about multiple strings in a disjoint
	    text selection (?), it should be harmless to get them all */
	    for (i = 0; i < count; i++)
		NewCurrentClipContents(list[i], strlen(list[i]));
	    XFreeStringList(list);
	} else
	    convert_failed = True;
	XFree(value);
    }

    if (convert_failed) {
	/* if UTF8_STRING failed try COMPOUND_TEXT */
	if (target == XA_UTF8_STRING(d))
	{
	    XtGetSelectionValue(w, *selection, XA_COMPOUND_TEXT(d),
				InsertClipboard,
				(XtPointer)(XA_COMPOUND_TEXT(d)),
				CurrentTime);
	    return;
	}
	/* if COMPOUND_TEXT failed try STRING */
	else if (target == XA_COMPOUND_TEXT(d))
	{
	    XtGetSelectionValue(w, *selection, XA_STRING,
				InsertClipboard,
				NULL,
				CurrentTime);
	    return;
	}
	/* all conversions failed */
	else
	{
	    Arg arg;
	    XtSetArg (arg, XtNlabel, "CLIPBOARD selection conversion failed");
	    XtSetValues (failDialog, &arg, 1);
	    CenterWidgetOnWidget (failDialogShell, text);
	    XtPopup (failDialogShell, XtGrabNone);
#ifdef XKB
	    XkbStdBell (d, XtWindow(w), 0, XkbBI_MinorError);
#else
	    XBell (d, 0);
#endif
	}
    }
    
    XtOwnSelection(top, ClipboardAtom, CurrentTime,
		   ConvertSelection, LoseSelection, NULL);
}
Пример #9
0
static void
ChooseSessionBreakLockXtProc(Widget w, XtPointer client_data, 
			     XtPointer callData)
{
    XawListReturnStruct *current;
    char *name;

    CheckDeleteCancel ();

    current = XawListShowCurrent (chooseSessionListWidget);

    if (!current || !(name = current->string) || *name == '\0')
    {
	if (current)
	    XtFree ((char *) current);
#ifdef XKB
	XkbStdBell(XtDisplay(topLevel),XtWindow(topLevel),0,XkbBI_BadValue);
#else
	XBell (XtDisplay (topLevel), 0);
#endif
	return;
    }

    break_lock_phase++;

    if (break_lock_phase == 1)
    {
	XtVaSetValues (chooseSessionMessageLabel,
	    XtNforeground, save_message_foreground,
            NULL);

#ifdef XKB
	XkbStdBell(XtDisplay(topLevel),XtWindow(topLevel),0,XkbBI_BadValue);
#else
	XBell (XtDisplay (topLevel), 0);
#endif
    }
    else
    {
	int longest;

	XtVaSetValues (chooseSessionMessageLabel,
	    XtNforeground, save_message_background,
            NULL);

	name = sessionNamesShort[current->list_index];

	(void) GetLockId (name);

	UnlockSession (name);

	sessionsLocked[current->list_index] = False;
	XtFree ((char *) sessionNamesLong[current->list_index]);
	sessionNamesLong[current->list_index] =
	    sessionNamesShort[current->list_index];

	XtVaGetValues (chooseSessionListWidget,
	    XtNlongest, &longest,
	    NULL);

	XawListChange (chooseSessionListWidget,
	    sessionNamesLong, sessionNameCount, longest, True);

	SessionSelected (current->list_index, True);

	break_lock_phase = 0;
    }

    XtFree ((char *) current);
}
Пример #10
0
static void
ChooseSessionDeleteXtProc(Widget w, XtPointer client_data, XtPointer callData)
{
    XawListReturnStruct *current;
    int longest;
    char *name;

    CheckBreakLockCancel ();

    current = XawListShowCurrent (chooseSessionListWidget);

    if (!current || !(name = current->string) || *name == '\0')
    {
	if (current)
	    XtFree ((char *) current);
#ifdef XKB
	XkbStdBell(XtDisplay(w),XtWindow(w),0,XkbBI_BadValue);
#else
	XBell (XtDisplay (topLevel), 0);
#endif
	return;
    }

    delete_session_phase++;

    if (delete_session_phase == 1)
    {
	XtVaSetValues (chooseSessionMessageLabel,
	    XtNforeground, save_message_foreground,
            NULL);

#ifdef XKB
	XkbStdBell(XtDisplay(w),XtWindow(w),0,XkbBI_BadValue);
#else
	XBell (XtDisplay (topLevel), 0);
#endif
    }
    else
    {
	XtVaSetValues (chooseSessionMessageLabel,
	    XtNforeground, save_message_background,
            NULL);

	if (DeleteSession (name))
	{
	    int i, j;

	    for (i = 0; i < sessionNameCount; i++)
	    {
		if (strcmp (sessionNamesLong[i], name) == 0)
		{
		    XtFree ((char *) sessionNamesShort[i]);

		    if (sessionsLocked[i])
			XtFree ((char *) sessionNamesLong[i]);

		    for (j = i; j < sessionNameCount - 1; j++)
		    {
			sessionNamesLong[j] = sessionNamesLong[j + 1];
			sessionNamesShort[j] = sessionNamesShort[j + 1];
			sessionsLocked[j] = sessionsLocked[j + 1];
		    }
		    sessionNameCount--;
		    break;
		}
	    }

	    if (sessionNameCount == 0)
	    {
		XtSetSensitive (chooseSessionLoadButton, 0);
		XtSetSensitive (chooseSessionDeleteButton, 0);
		XtUnmanageChild (chooseSessionListWidget);
	    }
	    else
	    {
		XtVaGetValues (chooseSessionListWidget,
		    XtNlongest, &longest,
		    NULL);

		XawListChange (chooseSessionListWidget,
		    sessionNamesLong, sessionNameCount, longest, True);

		SessionSelected (-1, False);
	    }
	}

	delete_session_phase = 0;
    }

    XtFree ((char *) current);
}