Fix XK_NO_MOD and XK_ANY_MOD behavior
XK_NO_MOD match a key without modifiers and XK_ANY_MOD match a key does not matter what modifiers are pressed to. Like they are mask the best value for XK_ANY_MOD is all the bits to 1, so the and with any state will be equal to the state. This also imply that is necessary check the case for XK_NO_MOD (no modifiers at all) with some modifier in state, and the inverse (some mask different to XK_ANY_MOD or XK_NO_MOD and no modifiers in state). --- st.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
This commit is contained in:
		
							
								
								
									
										12
									
								
								st.c
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								st.c
									
									
									
									
									
								
							| @@ -59,8 +59,8 @@ | |||||||
| #define STR_ARG_SIZ   16 | #define STR_ARG_SIZ   16 | ||||||
| #define DRAW_BUF_SIZ  20*1024 | #define DRAW_BUF_SIZ  20*1024 | ||||||
| #define UTF_SIZ       4 | #define UTF_SIZ       4 | ||||||
| #define XK_NO_MOD     UINT_MAX | #define XK_ANY_MOD    UINT_MAX | ||||||
| #define XK_ANY_MOD    0 | #define XK_NO_MOD     0 | ||||||
|  |  | ||||||
| #define REDRAW_TIMEOUT (80*1000) /* 80 ms */ | #define REDRAW_TIMEOUT (80*1000) /* 80 ms */ | ||||||
|  |  | ||||||
| @@ -2700,10 +2700,12 @@ kmap(KeySym k, uint state) { | |||||||
| 		if(kp->k != k) | 		if(kp->k != k) | ||||||
| 			continue; | 			continue; | ||||||
|  |  | ||||||
| 		if((state & mask) != mask && | 		if(mask == XK_NO_MOD && state) | ||||||
| 				(mask == XK_NO_MOD && state)) { | 			continue; | ||||||
|  | 		if(mask != XK_ANY_MOD && mask != XK_NO_MOD && !state) | ||||||
|  | 			continue; | ||||||
|  | 		if((state & mask) != state) | ||||||
| 			continue; | 			continue; | ||||||
| 		} |  | ||||||
|  |  | ||||||
| 		if((kp->appkey < 0 && IS_SET(MODE_APPKEYPAD)) || | 		if((kp->appkey < 0 && IS_SET(MODE_APPKEYPAD)) || | ||||||
| 				(kp->appkey > 0 && !IS_SET(MODE_APPKEYPAD))) { | 				(kp->appkey > 0 && !IS_SET(MODE_APPKEYPAD))) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user