Subject: modifiers, locks and mouse/key bindings

From: [email-masked]
Date: Mon, 22 Feb 1999 04:51:43 -0600 (CST)

Full_Name: Benoit TRIQUET
Version: 2.1.10
CVS_Date: 
OS: linux 2.0.34 (rh 5.1)
X_Server: xfree86 3.3.3.1
Submission from: (NULL) (216.100.248.201)

I finally found why my window buttons would stop working after "some time",
and why
windows couldn't be activated when using click to focus.
Actually "some time" is "once i have engaged num lock".
It seems to me that locks shouldn't be taken into account when matching
mouse or key
bindings, or checking for focus change.
I have little knowldedge in X or xf86, but it seems there is no practical
way to
know which modifiers are actually locks. And patching fvwm/events.c to
remove Mod2
through Mod5 from the used_mods mask is not very machine-independent.
So i wrote a new fvwm command, ModifierLocks. Here is my addition to the
manpage :

     ModifierLocks [Modifiers]
              Tells  FVWM  which modifiers are actually locks and
              hence should be ignored when matching Mouse or  Key
              bindings (if any binding actually have one of those
              modifiers, they will never be matched).

              Modifiers has the same syntax as in  the  Mouse  or
              Key  bindings,  with the addition of L meaning caps
              lock. The default is L25 (this  means  ignore  caps
              lock, num lock and scroll lock for XFree86).  Modi-
              fiers can be  omitted,  meaning  no  modifiers  are
              locks.

here are the context diffs for the stock 2.1.10 tgz archive i got from
your
web site :

--- builtins.c.orig	Wed Jan 13 17:42:51 1999
+++ builtins.c	Sun Feb 21 21:51:35 1999
@@ -4852,3 +4852,69 @@
     rgpctMovementDefault[i++] = 1.0;
   }
 }
+
+
+/***********************************************************************
+ *
+ *	SetModifierLocks : declares which X modifiers are actually locks
+ *		and should be ignored when testing mouse/key binding modifiers.
+ *	syntax :
+ *		ModifierLocks [S][L][C][M][1][2][3][4][5]
+ *
+ *	S is shift
+ *	L is caps lock
+ *	C is control
+ *	M is meta, the same as mod1
+ *	1-5 are mod1-mod5
+ *	The default is L25 (ie. mask out caps lock, num lock & scroll lock
+ *	for XFree86 3.3.3.1
+ *
+ *	Benoit TRIQUET <[email-masked]> 2/21/99
+ ***********************************************************************/
+#include <X11/X.h>
+unsigned int modifier_locks_mask = LockMask|Mod2Mask|Mod5Mask;
+void SetModifierLocks(XEvent *eventp,Window w,FvwmWindow *tmp_win,
+              unsigned long context, char *action,int* Module)
+{
+	char *arg, c;
+	GetNextToken( action, &arg );
+	modifier_locks_mask = 0;
+	if( arg==NULL )
+		return;
+	while( ( c = *arg ++ )!='\0' ) {
+		switch( c ) {
+		case 's':
+		case 'S':
+			modifier_locks_mask |= ShiftMask;
+			break;
+		case 'l':
+		case 'L':
+			modifier_locks_mask |= LockMask;
+			break;
+		case 'c':
+		case 'C':
+			modifier_locks_mask |= ControlMask;
+			break;
+		case 'm':
+		case 'M':
+		case '1':
+			modifier_locks_mask |= Mod1Mask;
+			break;
+		case '2':
+			modifier_locks_mask |= Mod2Mask;
+			break;
+		case '3':
+			modifier_locks_mask |= Mod3Mask;
+			break;
+		case '4':
+			modifier_locks_mask |= Mod4Mask;
+			break;
+		case '5':
+			modifier_locks_mask |= Mod5Mask;
+			break;
+		default:
+			fvwm_msg( ERR, "SetModifierLocks",
+			 "syntax: ModifierLocks [S][L][C][M][1][2][3][4][5]");
+		}
+	}
+}
--- events.c.orig	Sat Jan  9 17:48:15 1999
+++ events.c	Sun Feb 21 21:50:48 1999
@@ -66,6 +66,7 @@
 
 unsigned int mods_used = (ShiftMask | ControlMask | Mod1Mask |
 			  Mod2Mask| Mod3Mask| Mod4Mask| Mod5Mask);
+unsigned int modifier_locks_mask;
 extern int menuFromFrameOrWindowOrTitlebar;
 
 extern Boolean debugging;
@@ -374,7 +375,7 @@
 {
   Binding *key;
   unsigned int modifier;
-  modifier = (Event.xkey.state & mods_used);
+  modifier = (Event.xkey.state & mods_used)&~modifier_locks_mask;
   ButtonWindow = Tmp_win;
 
   DBUG("HandleKeyPress","Routine Entered");
@@ -391,7 +392,7 @@
   for (key = Scr.AllBindings; key != NULL; key = key->NextBinding)
     {
       if ((key->Button_Key == Event.xkey.keycode) &&
-	  ((key->Modifier == (modifier&(~LockMask)))||
+	  ((key->Modifier == modifier)||
 	   (key->Modifier == AnyModifier)) &&
 	  (key->Context & Context)&&
 	  (key->IsMouse == 0))
@@ -1081,7 +1082,8 @@
   /* click to focus stuff goes here */
   if((Tmp_win)&&(Tmp_win->flags & ClickToFocus)&&(Tmp_win !=
Scr.Ungrabbed) &&
      ((Event.xbutton.state&
-       (ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) == 0))
+      ((ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)&
+       ~modifier_locks_mask)) == 0))
   {
     SetFocus(Tmp_win->w,Tmp_win,1);
 /* #ifdef CLICKY_MODE_1 */
@@ -1116,7 +1118,8 @@
   {
     if (Tmp_win != Scr.LastWindowRaised &&
         (Event.xbutton.state &
-         (ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) == 0
&&
+         ((ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)&
+          ~modifier_locks_mask)) == 0 &&
         GetContext(Tmp_win,&Event, &PressedW) == C_WINDOW)
     {
       RaiseWindow(Tmp_win);
@@ -1145,7 +1148,7 @@
   /* we have to execute a function or pop up a menu
    */
 
-  modifier = (Event.xbutton.state & mods_used);
+  modifier = (Event.xbutton.state & mods_used)&~modifier_locks_mask;
   /* need to search for an appropriate mouse binding */
   for (MouseEntry = Scr.AllBindings; MouseEntry != NULL;
        MouseEntry= MouseEntry->NextBinding)
@@ -1154,7 +1157,7 @@
         (MouseEntry->Button_Key == 0))&&
        (MouseEntry->Context & Context)&&
        ((MouseEntry->Modifier == AnyModifier)||
-        (MouseEntry->Modifier == (modifier& (~LockMask))))&&
+        (MouseEntry->Modifier == modifier))&&
        (MouseEntry->IsMouse == 1))
     {
       /* got a match, now process it */
--- functions.c.orig	Tue Jan 12 13:07:42 1999
+++ functions.c	Mon Feb 22 01:22:35 1999
@@ -121,6 +121,7 @@
   {"Maximize",     Maximize,         F_MAXIMIZE,           
FUNC_NEEDS_WINDOW},
   {"Menu",         staysup_func,     F_STAYSUP,            
FUNC_NO_WINDOW},
   {"MenuStyle",    SetMenuStyle,     F_MENUSTYLE,          
FUNC_NO_WINDOW},
+  {"ModifierLocks",SetModifierLocks, F_MODIFIER_LOCKS,     
FUNC_NO_WINDOW},
   {"Module",       executeModule,    F_MODULE,             
FUNC_NO_WINDOW},
   {"ModulePath",   setModulePath,    F_MODULE_PATH,        
FUNC_NO_WINDOW},
   {"Mouse",        ParseMouseEntry,  F_MOUSE,              
FUNC_NO_WINDOW},
--- fvwm2.1.orig	Mon Feb 22 01:35:21 1999
+++ fvwm2.1	Mon Feb 22 01:48:06 1999
@@ -1849,6 +1849,16 @@
 
 See also \fISetAnimation\fP command.
 
+.IP "ModifierLocks \fI[Modifiers]\fP"
+Tells FVWM which modifiers are actually locks and hence should be
+ignored when matching Mouse or Key bindings (if any binding actually
+have one of those modifiers, they will never be matched).
+
+\fIModifiers\fP has the same syntax as in the Mouse or Key bindings,
+with the addition of L meaning caps lock. The default is L25 (this
+means ignore caps lock, num lock and scroll lock for XFree86).
+\fIModifiers\fP can be omitted, meaning no modifiers are locks.
+
 .IP "Module \fIModuleName\fP"
 Specifies a module which should be spawned during initialization.  At
 the current time the available modules (included with fvwm) are
--- misc.h.orig	Tue Jan 12 13:07:43 1999
+++ misc.h	Sun Feb 21 21:52:37 1999
@@ -472,6 +472,7 @@
 void DestroyModConfig(F_CMD_ARGS);
 void AddModConfig(F_CMD_ARGS);
 void SetEnv(F_CMD_ARGS);
+void SetModifierLocks(F_CMD_ARGS);
 
 void CoerceEnterNotifyOnCurrentWindow();
 
--- parse.h.orig	Tue Jan 12 13:07:44 1999
+++ parse.h	Sun Feb 21 21:14:29 1999
@@ -116,6 +116,7 @@
     F_WINDOW_SHADE,
     F_COLOR_LIMIT,
     F_ANIMATED_MOVE,
+    F_MODIFIER_L
====> MESSAGE TRUNCATED AT 8192 <====

--
Visit the official FVWM web page at <URL:http://fvwm.math.uh.edu/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [email-masked].
To report problems, send mail to [email-masked].