2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
26 * Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
27 * ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
28 * the full copyright text.
35 static char rcsid[] = "$TOG: xmbind.c /main/10 1997/06/18 17:34:48 samborn $"
41 /* Internal routines "borrowed" from libXm. Don't try this at home! */
42 extern Boolean _XmVirtKeysLoadFileBindings(char *fileName, String *binding);
43 extern int _XmVirtKeysLoadFallbackBindings(Display *display, String *binding);
49 enum { XA_MOTIF_DEFAULT_BINDINGS, XA_MOTIF_BINDINGS };
50 static char *atom_names[] = {
51 "_MOTIF_DEFAULT_BINDINGS", "_MOTIF_BINDINGS" };
53 Atom atoms[XtNumber(atom_names)];
54 XtAppContext app_context;
56 String bindings = NULL;
58 XtToolkitInitialize();
59 app_context = XtCreateApplicationContext();
60 display = XtOpenDisplay(app_context, NULL, argv[0], "Xmbind",
61 NULL, 0, &argc, argv);
63 if (display == NULL) {
64 fprintf(stderr, "%s: Can't open display\n", argv[0]);
68 XInternAtoms(display, atom_names, XtNumber(atom_names), False, atoms);
70 if (_XmVirtKeysLoadFileBindings (argv[1], &bindings) == True) {
71 XDeleteProperty (display, RootWindow (display, 0),
72 atoms[XA_MOTIF_DEFAULT_BINDINGS]);
73 XChangeProperty (display, RootWindow(display, 0),
74 atoms[XA_MOTIF_BINDINGS],
75 XA_STRING, 8, PropModeReplace,
76 (unsigned char *)bindings, strlen(bindings));
82 fprintf(stderr, "%s: Can't open %s\n", argv[0], argv[1]);
87 XDeleteProperty (display, RootWindow (display, 0),
88 atoms[XA_MOTIF_BINDINGS]);
89 XDeleteProperty (display, RootWindow (display, 0),
90 atoms[XA_MOTIF_DEFAULT_BINDINGS]);
92 _XmVirtKeysLoadFallbackBindings (display, &bindings);