[comp.windows.x] V11 fix #29, clients/xmodmap/xmodmap.c, allow increase in keys per mod

RWS@ZERMATT.LCS.MIT.EDU (Robert Scheifler) (10/22/87)

VERSION:
	X11 release 1
SYNOPSIS:
	xmodmap as written wouldn't allow an increase in the number of
	keycodes per modifier
DESCRIPTION:
	ditto
REPEAT-BY:
	try adding a new key to the modifier with the longest list of keycodes
FIX:
	in clients/xmodmap/xmodmap.c:

*** /tmp/,RCSt1003343	Thu Oct 22 08:44:50 1987
--- xmodmap.c	Wed Sep 30 08:05:56 1987
***************
*** 26,32 ****
  
  ********************************************************/
  
! /* $Header: xmodmap.c,v 1.4 87/09/13 22:03:20 toddb Exp $ */
  #include <stdio.h>
  #include <ctype.h>
  #include "X11/Xlib.h"
--- 26,32 ----
  
  ********************************************************/
  
! /* $Header: xmodmap.c,v 1.5 87/09/30 08:09:11 swick Exp $ */
  #include <stdio.h>
  #include <ctype.h>
  #include "X11/Xlib.h"
***************
*** 91,97 ****
  SetMod(argc, argv, map, mod)
      int argc;
      char **argv;
!     XModifierKeymap *map;
      int mod;
  {
      if (argc) {
--- 91,97 ----
  SetMod(argc, argv, map, mod)
      int argc;
      char **argv;
!     XModifierKeymap **map;
      int mod;
  {
      if (argc) {
***************
*** 107,141 ****
  		keycode = XKeysymToKeycode(dpy, ks);
  	}
  	fprintf(stderr, "%s: 0x%x\n", *argv, keycode);
! 	if (keycode) {
! 	    int i;
! 	    
! 	    for (i = 0; i < map->max_keypermod; i++) {
! 		int index = mod*map->max_keypermod + i;
! 		if (map->modifiermap[index] == 0) {
! 		    map->modifiermap[index] = (unsigned char) keycode;
! 		    return (1);
! 		}
! 	    }
! 	}
      }
      return (0);
  }
  
  ClearMod(map, mod)
!     XModifierKeymap *map;
      int mod;
  {
      int i;
  
!     for (i = 0; i < map->max_keypermod; i++)
! 	map->modifiermap[mod * map->max_keypermod + i] = '\0';
  }
  
  DecodeArgs(argc, argv, map)
      int argc;
      char **argv;
!     XModifierKeymap *map;
  {
      while (--argc > 0) {
  	argv++;
--- 107,132 ----
  		keycode = XKeysymToKeycode(dpy, ks);
  	}
  	fprintf(stderr, "%s: 0x%x\n", *argv, keycode);
! 	if (keycode)
! 	    *map = XInsertModifiermapEntry(*map, keycode, mod);
      }
      return (0);
  }
  
  ClearMod(map, mod)
!     register XModifierKeymap **map;
      int mod;
  {
      int i;
  
!     for (i = 0; i < (*map)->max_keypermod; i++)
! 	(*map)->modifiermap[mod * (*map)->max_keypermod + i] = '\0';
  }
  
  DecodeArgs(argc, argv, map)
      int argc;
      char **argv;
!     XModifierKeymap **map;
  {
      while (--argc > 0) {
  	argv++;
***************
*** 225,230 ****
--- 216,222 ----
  {
      int i, k = 0;
  
+     fprintf(fout, "Currently max %d keys/mod\n", map->max_keypermod);
      for (i = 0; i < 8; i++) {
  	int j;
  
***************
*** 256,262 ****
  
      map = XGetModifierMapping(dpy);
  
!     DecodeArgs(argc, argv, map);
  
      if (fout)
  	PrintModifierMapping(map, fout);
--- 248,254 ----
  
      map = XGetModifierMapping(dpy);
  
!     DecodeArgs(argc, argv, &map);
  
      if (fout)
  	PrintModifierMapping(map, fout);