/* $XConsortium: xkbrefresh.c /main/6 1996/02/05 11:44:43 kaleb $ */ /************************************************************ Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of Silicon Graphics not be used in advertising or publicity pertaining to distribution of the software without specific prior written permission. Silicon Graphics makes no representation about the suitability of this software for any purpose. It is provided "as is" without any express or implied warranty. SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ********************************************************/ #include #include #include #include #include #include /***====================================================================***/ static char *dpyName = NULL; static int changeAll = 0; static int synch = 0; static unsigned full; static XkbMapChangesRec changes; static unsigned whichNames = XkbAllNamesMask; static unsigned firstNamesKeyType = 0; static unsigned nNamesKeyTypes = 0; int #if NeedFunctionPrototypes parseArgs(int argc,char *argv[]) #else parseArgs(argc,argv) int argc; char *argv[]; #endif { int i; for (i=1;i0) continue; } fprintf(stderr,"must specify a legal range of key types\n"); return 0; } else full|= XkbKeyActionsMask; } else if ( strcmp(argv[i],"-synch")==0 ) { synch= 1; } else if ( strcmp(argv[i],"-all")==0 ) { changeAll= 1; } else { fprintf(stderr,"Unknown option %s\n",argv[i]); return 0; } } return 1; } int #if NeedFunctionPrototypes main(int argc,char *argv[]) #else main(argc,argv) int argc; char *argv[]; #endif { Display *dpy; int major,minor,why; XkbDescRec *map; if (!parseArgs(argc,argv)) { fprintf(stderr,"Usage: %s \n",argv[0]); fprintf(stderr,"Where legal options are:\n"); fprintf(stderr,"-display specifies display to use\n"); fprintf(stderr,"-t[ypes] [range] specifies a range of key types to refresh\n"); fprintf(stderr,"-s[yms] [range] specifies a range of key syms to refresh\n"); fprintf(stderr,"-a[ctions] [range] specifies a range of acts to refresh\n"); fprintf(stderr,"-b[ehaviors] [range] specifies a range of key behaviors to refresh\n"); fprintf(stderr,"-v[mods] [mask] specifies a mask of virtual modifiers to refresh\n"); fprintf(stderr,"-e[xplicit] [range] specifies a mask of key explicit components to refresh\n"); fprintf(stderr,"-x specifies unchanged subset of keyboard mapping\n"); fprintf(stderr," Legal subsets are:\n"); fprintf(stderr," t: Key Types\n"); fprintf(stderr," a: Key Actions\n"); fprintf(stderr," s: Key Syms\n"); fprintf(stderr," b: Key Behavior\n"); fprintf(stderr," v: Virtual Modifiers\n"); fprintf(stderr," e: Explicit Components\n"); fprintf(stderr,"-xn specifies unchanges subset of keyboard names\n"); fprintf(stderr," legal name subsets are:\n"); fprintf(stderr," c: Keycode name\n"); fprintf(stderr," s: Symbols name\n"); fprintf(stderr," g: Geometry name\n"); fprintf(stderr," i: Indicator names\n"); fprintf(stderr," m: Modifier names\n"); fprintf(stderr," l: Key type level names\n"); fprintf(stderr," v: Virtual modifier names\n"); fprintf(stderr,"-cmn [range] specifies a range of column map names to refresh\n"); return 1; } major= XkbMajorVersion; minor= XkbMinorVersion; dpy = XkbOpenDisplay(dpyName,NULL,NULL,&major,&minor,&why); if (dpy==NULL) { if (dpyName==NULL) dpyName= "default display"; switch (why) { case XkbOD_BadLibraryVersion: fprintf(stderr,"%s was compiled with XKB version %d.%02d\n", argv[0],XkbMajorVersion,XkbMinorVersion); fprintf(stderr,"Xlib supports incompatible version %d.%02d\n", major,minor); break; case XkbOD_ConnectionRefused: fprintf(stderr,"Cannot open display \"%s\"\n",dpyName); break; case XkbOD_NonXkbServer: fprintf(stderr,"XKB extension not present on %s\n",dpyName); break; case XkbOD_BadServerVersion: fprintf(stderr,"%s was compiled with XKB version %d.%02d\n", argv[0],XkbMajorVersion,XkbMinorVersion); fprintf(stderr,"Server %s uses incompatible version %d.%02d\n", dpyName,major,minor); break; default: fprintf(stderr, "Internal Error! Unknown error %d from XkbOpenDisplay\n", why); } return 1; } XSynchronize(dpy,1); map = XkbGetMap(dpy,XkbAllMapComponentsMask,XkbUseCoreKbd); if (!map) { fprintf(stderr,"XkbGetMap failed\n"); goto BAIL; } if (XkbGetNames(dpy,XkbAllNamesMask,map)!=Success) { fprintf(stderr,"XkbGetNames failed\n"); goto BAIL; } if ((!changeAll)&&(!changes.changed)) { changeAll = 1; full = XkbAllMapComponentsMask; } if (changeAll) { printf("Refreshing entire mapping..."); if (XkbSetMap(dpy,full,map)) printf("done\n"); else printf("XkbSetMap failed!\n"); } else { printf("Refreshing:"); if (changes.changed&XkbKeyTypesMask) { if ((changes.first_type==0)&&(changes.num_types==0)) changes.num_types = map->map->num_types; printf(" key types: %d-%d\n",changes.first_type, changes.num_types); } if (changes.changed&XkbKeySymsMask) { if ((changes.first_key_sym==0)&&(changes.num_key_syms==0)) { changes.first_key_sym = map->min_key_code; changes.num_key_syms = map->max_key_code-map->min_key_code+1; } printf(" key syms: %d-%d\n",changes.first_key_sym, changes.num_key_syms); } if (changes.changed&XkbKeyActionsMask) { if ((changes.first_key_act==0)&&(changes.num_key_acts==0)) { changes.first_key_act = map->min_key_code; changes.num_key_acts = map->max_key_code-map->min_key_code+1; } printf(" key acts: %d-%d\n",changes.first_key_act, changes.num_key_acts); } if (changes.changed&XkbKeyBehaviorsMask) { if ((!changes.first_key_behavior)&&(!changes.num_key_behaviors)) { changes.first_key_behavior = map->min_key_code; changes.num_key_behaviors = map->max_key_code-map->min_key_code+1; } printf(" key behaviors: %d-%d\n",changes.first_key_behavior, changes.num_key_behaviors); } if (XkbChangeMap(dpy,map,&changes)) printf("Map refreshed\n"); else printf("XkbChangeMap failed!\n"); } if (whichNames) { printf("Refreshing names..."); if (nNamesKeyTypes==0) { firstNamesKeyType = 0; nNamesKeyTypes= map->map->num_types; } XkbSetNames(dpy,whichNames,firstNamesKeyType,nNamesKeyTypes,map); printf("done\n"); } return 0; BAIL: XCloseDisplay(dpy); return 0; }