Re: [dev] [st] shift-insert patch (more general: key.mask and state)
On Mon, Aug 1, 2011 at 6:32 PM, Aurélien Aptel aurelien.ap...@gmail.com wrote: I've used it in my patch attached to match XK_ANY_MOD. I'd like to have some feedback/testing before applying it. I've pushed my patch.
Re: [dev] [st] shift-insert patch (more general: key.mask and state)
I think my patch is better. There is no special case for 0 mask and state and when we match for Ctrl and Shift it works only when they both are pressed. With your patch it will work for Ctrl only or for Shift only. Maybe it can be adopted for dwm so we would be able to remove this CLEANMASK macro. diff -r e64c97268f1a st.c --- a/st.c Thu Jun 09 18:25:56 2011 +0200 +++ b/st.c Mon Aug 01 14:31:32 2011 +0300 @@ -1833,8 +1833,9 @@ char* kmap(KeySym k, unsigned int state) { int i; + for(i = 0; i LEN(key); i++) - if(key[i].k == k (key[i].mask == 0 || key[i].mask state)) + if(key[i].k == k (state key[i].mask) == key[i].mask) return (char*)key[i].s; return NULL; }
Re: [dev] [st] shift-insert patch (more general: key.mask and state)
On Mon, Aug 01, 2011 at 03:34:46PM +0400, anonymous wrote: Maybe it can be adopted for dwm so we would be able to remove this CLEANMASK macro. Patch is attached. Maybe I missed something because I don't understand what numlockmask is for. Maybe my patch breaks something or maybe we can remove all numlockmask stuff?
Re: [dev] [st] shift-insert patch (more general: key.mask and state)
On Mon, 1 Aug 2011 15:52:37 +0400 anonymous p37si...@lavabit.com wrote: On Mon, Aug 01, 2011 at 03:34:46PM +0400, anonymous wrote: Maybe it can be adopted for dwm so we would be able to remove this CLEANMASK macro. Patch is attached. Maybe I missed something because I don't understand what numlockmask is for. Maybe my patch breaks something or maybe we can remove all numlockmask stuff? Did you test your patch both with numlock off and on? Years ago a lot of keybindings wouldn't work if numlock was in the wrong state for the app. Quite nasty, really.
Re: [dev] [st] shift-insert patch (more general: key.mask and state)
On Mon, Aug 01, 2011 at 01:50:33PM +0100, Ethan Grammatikidis wrote: On Mon, 1 Aug 2011 15:52:37 +0400 anonymous p37si...@lavabit.com wrote: On Mon, Aug 01, 2011 at 03:34:46PM +0400, anonymous wrote: Maybe it can be adopted for dwm so we would be able to remove this CLEANMASK macro. Patch is attached. Maybe I missed something because I don't understand what numlockmask is for. Maybe my patch breaks something or maybe we can remove all numlockmask stuff? Did you test your patch both with numlock off and on? Years ago a lot of keybindings wouldn't work if numlock was in the wrong state for the app. Quite nasty, really. It works with numlock off and on. It doesn't clean keycode and matches it exactly with mask. Instead it applies mask (with ) and checks if all bits that are set in the mask are set in keycode. If your mask doesn't include numlock, numlock state can't change anything. What changed is that when you bind Ctrl+A, Ctrl+Shift+A is matched too. That is why I added break in the loop. It means you should bind Mod1+Shift+Return first and Mod1+Return later, but it is how it is done in default config.h so there are no problems. We still can't remove updatenumlockmask, because it is used in grabbuttons and grabkeys. Maybe it can be removed later. If my patch doesn't break anything, I think it makes code a little cleaner.
Re: [dev] [st] shift-insert patch (more general: key.mask and state)
On Mon, Aug 1, 2011 at 1:34 PM, anonymous p37si...@lavabit.com wrote: I think my patch is better. There is no special case for 0 mask and state and when we match for Ctrl and Shift it works only when they both are pressed. With your patch it will work for Ctrl only or for Shift only. When a key in config.h has mask = 0 it's matched with any modifier, not no modifier. Instead we could: #define XK_NO_MOD UINT_MAX #define XK_ANY_MOD 0 When numlock is on, each keypress has a state of 0x10. I suppose nobody actually use keybindings involving numlock so kmap() could clear the numlock mask from state before looking for a match in key[].
Re: [dev] [st] shift-insert patch (more general: key.mask and state)
On Mon, Aug 1, 2011 at 5:55 PM, Aurélien Aptel aurelien.ap...@gmail.com wrote: When numlock is on, each keypress has a state of 0x10. I suppose nobody actually use keybindings involving numlock so kmap() could clear the numlock mask from state before looking for a match in key[]. And handle the special case when mask = XK_NO_MOD. Also anonymous forgot to attach his second patch.
Re: [dev] [st] shift-insert patch (more general: key.mask and state)
On Mon, Aug 01, 2011 at 05:55:25PM +0200, Aurélien Aptel wrote: On Mon, Aug 1, 2011 at 1:34 PM, anonymous p37si...@lavabit.com wrote: I think my patch is better. There is no special case for 0 mask and state and when we match for Ctrl and Shift it works only when they both are pressed. With your patch it will work for Ctrl only or for Shift only. When a key in config.h has mask = 0 it's matched with any modifier, not no modifier. With my patch it is matched with any modifier too, because (key 0) == 0.
Re: [dev] [st] shift-insert patch (more general: key.mask and state)
On Mon, Aug 1, 2011 at 6:14 PM, anonymous p37si...@lavabit.com wrote: With my patch it is matched with any modifier too, because (key 0) == 0. Yes but it doesn't fix the problem of redefining what XK_Insert sends while keeping shift + insert to paste. I've used it in my patch attached to match XK_ANY_MOD. I'd like to have some feedback/testing before applying it. shift-insert-fix.diff Description: Binary data
Re: [dev] [st] shift-insert patch (more general: key.mask and state)
On Mon, Aug 01, 2011 at 03:52:37PM +0400, anonymous wrote: On Mon, Aug 01, 2011 at 03:34:46PM +0400, anonymous wrote: Patch is attached. Forgot to attach. To make it work, you should reorder TAGKEYS, so masks with more modifiers are matched first. #define TAGKEYS(KEY,TAG) \ { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 TAG} }, \ { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 TAG} }, \ { MODKEY|ShiftMask, KEY, tag,{.ui = 1 TAG} }, \ { MODKEY, diff -r b46ae56abe65 dwm.c --- a/dwm.c Wed Jul 27 19:59:10 2011 +0200 +++ b/dwm.c Mon Aug 01 14:48:35 2011 +0300 @@ -42,7 +42,6 @@ /* macros */ #define BUTTONMASK (ButtonPressMask|ButtonReleaseMask) -#define CLEANMASK(mask) (mask ~(numlockmask|LockMask) (ShiftMask|ControlMask|Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)) #define INRECT(X,Y,RX,RY,RW,RH) ((X) = (RX) (X) (RX) + (RW) (Y) = (RY) (Y) (RY) + (RH)) #define ISVISIBLE(C)((C-tags C-mon-tagset[C-mon-seltags])) #define LENGTH(X) (sizeof X / sizeof X[0]) @@ -292,7 +291,6 @@ XClassHint ch = { 0 }; /* rule matching */ - c-isfloating = c-tags = 0; if(XGetClassHint(dpy, c-win, ch)) { class = ch.res_class ? ch.res_class : broken; instance = ch.res_name ? ch.res_name : broken; @@ -453,8 +451,10 @@ } for(i = 0; i LENGTH(buttons); i++) if(click == buttons[i].click buttons[i].func buttons[i].button == ev-button -CLEANMASK(buttons[i].mask) == CLEANMASK(ev-state)) +(buttons[i].mask ev-state) == buttons[i].mask) { buttons[i].func(click == ClkTagBar buttons[i].arg.i == 0 ? arg : buttons[i].arg); + break; + } } void @@ -1078,9 +1078,11 @@ keysym = XKeycodeToKeysym(dpy, (KeyCode)ev-keycode, 0); for(i = 0; i LENGTH(keys); i++) if(keysym == keys[i].keysym -CLEANMASK(keys[i].mod) == CLEANMASK(ev-state) -keys[i].func) +(keys[i].mod ev-state) == keys[i].mod +keys[i].func) { keys[i].func((keys[i].arg)); + break; + } } void