On Sun, 29 Sep 2013, Carlos R. Mafra escribió:

> On Sun, 29 Sep 2013 at 12:02:05 +0200, Rodolfo García Peñas (kix) wrote:
> > This patch includes the function "NumLockMask", that checks if the
> > Alt Modifier key is "NumLock". Then we can use this function in the
> > calls to Capture the key sequence and don't use this modifier.
> 
> Have you seen the NUMLOCK_HACK in src/window.c?
> 
> #ifdef NUMLOCK_HACK
>                       /* Also grab all modifier combinations possible that 
> include,
>                        * LockMask, ScrollLockMask and NumLockMask, so that 
> keygrabs
>                        * work even if the NumLock/ScrollLock key is on.
>                        */
>                       wHackedGrabKey(key->keycode, key->modifier,
>                                      wwin->frame->core->window, True, 
> GrabModeAsync, GrabModeAsync);
> #endif
> 
> Since the purpose seems to be the same I was wondering if something
> similar could be done with WPrefs too.

Hi,

I didn't see that code, some things:

1. My X11 knowledge is not too big, perhaps somebody can help with this code 
and select between my patch and this code.
2. IMO, the code (the patch I sent) in WPrefs should be always enabled (without 
the preprocessor #ifdef)
3. Perhaps the idea is the same, but I don't know how different methods impact 
in the wmaker performance.
4. Function wHackedGrabKey is defined and used in the src/ folder (wmaker) and 
the patch I sent is defined and used in the WPrefs/ folder (WPrefs). There are 
different applications.

Finally, I was testing my patch with some modifiers (Fn, NumLock, CapsLock) 
without problems. The modifier Scroll_Lock is detected as a key press, not as 
key modifier.

Cheers,
kix
 
> I don't know, I just remembered this part of the code and want to check
> whether you noticed it too.
> 
> 
> > ---
> >  WPrefs.app/KeyboardShortcuts.c | 44 
> > ++++++++++++++++++++++++++++--------------
> >  1 file changed, 30 insertions(+), 14 deletions(-)
> > 
> > diff --git a/WPrefs.app/KeyboardShortcuts.c b/WPrefs.app/KeyboardShortcuts.c
> > index 84da1d0..4c418c6 100644
> > --- a/WPrefs.app/KeyboardShortcuts.c
> > +++ b/WPrefs.app/KeyboardShortcuts.c
> > @@ -262,6 +262,22 @@ static void XConvertCase(register KeySym sym, KeySym * 
> > lower, KeySym * upper)
> >  }
> >  #endif
> >  
> > +static int NumLockMask(Display *dpy)
> > +{
> > +   int i;
> > +   XModifierKeymap *map = XGetModifierMapping(dpy);
> > +   KeyCode numlock_keycode = XKeysymToKeycode(dpy, XK_Num_Lock);
> > +   if (numlock_keycode == NoSymbol)
> > +           return 0;
> > +
> > +   for (i = 0; i < 8; i++) {
> > +           if (map->modifiermap[map->max_keypermod * i] == numlock_keycode)
> > +                   return 1 << i;
> > +   }
> > +
> > +   return 0;
> > +}
> > +
> >  char *capture_shortcut(Display *dpy, Bool *capturing, Bool convert_case)
> >  {
> >     XEvent ev;
> > @@ -297,27 +313,27 @@ char *capture_shortcut(Display *dpy, Bool *capturing, 
> > Bool convert_case)
> >  
> >     buffer[0] = 0;
> >  
> > -   if (ev.xkey.state & ControlMask) {
> > +   if (ev.xkey.state & ControlMask)
> >             strcat(buffer, "Control+");
> > -   }
> > -   if (ev.xkey.state & ShiftMask) {
> > +
> > +   if (ev.xkey.state & ShiftMask)
> >             strcat(buffer, "Shift+");
> > -   }
> > -   if (ev.xkey.state & Mod1Mask) {
> > +
> > +   if ((ev.xkey.state & Mod1Mask) && !NumLockMask(dpy))
> >             strcat(buffer, "Mod1+");
> > -   }
> > -   if (ev.xkey.state & Mod2Mask) {
> > +
> > +   if ((ev.xkey.state & Mod2Mask) && !NumLockMask(dpy))
> >             strcat(buffer, "Mod2+");
> > -   }
> > -   if (ev.xkey.state & Mod3Mask) {
> > +
> > +   if ((ev.xkey.state & Mod3Mask) && !NumLockMask(dpy))
> >             strcat(buffer, "Mod3+");
> > -   }
> > -   if (ev.xkey.state & Mod4Mask) {
> > +
> > +   if ((ev.xkey.state & Mod4Mask) && !NumLockMask(dpy))
> >             strcat(buffer, "Mod4+");
> > -   }
> > -   if (ev.xkey.state & Mod5Mask) {
> > +
> > +   if ((ev.xkey.state & Mod5Mask) && !NumLockMask(dpy))
> >             strcat(buffer, "Mod5+");
> > -   }
> > +
> >     strcat(buffer, key);
> >  
> >     return wstrdup(buffer);
> > -- 
> > 1.8.4.rc3
> > 
> > 
> > -- 
> > To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.
> 
> 
> -- 
> To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

-- 
||// //\\// Rodolfo "kix" Garcia
||\\// //\\ http://www.kix.es/


-- 
To unsubscribe, send mail to wmaker-dev-unsubscr...@lists.windowmaker.org.

Reply via email to