From: Daniel Caujolle-B. <f1...@us...> - 2001-08-26 20:17:12
|
Update of /cvsroot/xine/xine-ui/src/xitk/xine-toolkit In directory usw-pr-cvs1:/tmp/cvs-serv27527/src/xitk/xine-toolkit Modified Files: inputtext.c inputtext.h xitk.h Log Message: UI can know which modifier keys is currently pressed, window resizing use it now (you can see xith.h, for all MODIFIER_ available). Index: inputtext.c =================================================================== RCS file: /cvsroot/xine/xine-ui/src/xitk/xine-toolkit/inputtext.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- inputtext.c 2001/07/24 14:16:59 1.7 +++ inputtext.c 2001/08/26 20:17:08 1.8 @@ -43,15 +43,63 @@ #define NORMAL 1 #define FOCUS 2 -#define MODIFIER_NOMOD 0x00000000 -#define MODIFIER_SHIFT 0x00000001 -#define MODIFIER_LOCK 0x00000002 -#define MODIFIER_CTRL 0x00000004 -#define MODIFIER_META 0x00000008 -#define MODIFIER_NUML 0x00000010 -#define MODIFIER_MOD3 0x00000020 -#define MODIFIER_MOD4 0x00000040 -#define MODIFIER_MOD5 0x00000080 +/* + * Extract modifier keys. + */ +int xitk_get_key_modifier(XEvent *xev, int *modifier) { + + *modifier = MODIFIER_NOMOD; + + if(!xev) + return 0; + + /* + printf("%s(): ", __FUNCTION__); + if(xev->xbutton.state & ShiftMask) + printf("Shift "); + if(xev->xbutton.state & LockMask) + printf("CapsLock "); + if(xev->xbutton.state & ControlMask) + printf("Control "); + if(xev->xbutton.state & Mod1Mask) + printf("Meta(mod1) "); + if(xev->xbutton.state & Mod2Mask) + printf("NumLock(mod2) "); + if(xev->xbutton.state & Mod3Mask) + printf("Mod3 "); + if(xev->xbutton.state & Mod4Mask) + printf("Mod4 "); + if(xev->xbutton.state & Mod5Mask) + printf("Mod5 "); + printf(".\n"); + */ + + if(xev->xbutton.state & ShiftMask) + *modifier |= MODIFIER_SHIFT; + + if(xev->xbutton.state & LockMask) + *modifier |= MODIFIER_LOCK; + + if(xev->xbutton.state & ControlMask) + *modifier |= MODIFIER_CTRL; + + if(xev->xbutton.state & Mod1Mask) + *modifier |= MODIFIER_META; + + if(xev->xbutton.state & Mod2Mask) + *modifier |= MODIFIER_NUML; + + if(xev->xbutton.state & Mod3Mask) + *modifier |= MODIFIER_MOD3; + + if(xev->xbutton.state & Mod4Mask) + *modifier |= MODIFIER_MOD4; + + if(xev->xbutton.state & Mod5Mask) + *modifier |= MODIFIER_MOD5; + + return (*modifier != MODIFIER_NOMOD); +} /* * Return a pixmap with text drawed. @@ -534,59 +582,6 @@ } /* - * Extract modifier keys. - */ -static int get_key_modifier(XEvent *xev, int *mod) { - - *mod = MODIFIER_NOMOD; - - /* - if(xev->xbutton.state & ShiftMask) - printf("Shift\n"); - if(xev->xbutton.state & LockMask) - printf("Lock\n"); - if(xev->xbutton.state & ControlMask) - printf("Control\n"); - if(xev->xbutton.state & Mod1Mask) - printf("Mod1\n"); - if(xev->xbutton.state & Mod2Mask) - printf("Mod2\n"); - if(xev->xbutton.state & Mod3Mask) - printf("Mod3\n"); - if(xev->xbutton.state & Mod4Mask) - printf("Mod4\n"); - if(xev->xbutton.state & Mod5Mask) - printf("Mod5\n"); - */ - - if(xev->xbutton.state & ShiftMask) - *mod |= MODIFIER_SHIFT; - - if(xev->xbutton.state & LockMask) - *mod |= MODIFIER_LOCK; - - if(xev->xbutton.state & ControlMask) - *mod |= MODIFIER_CTRL; - - if(xev->xbutton.state & Mod1Mask) - *mod |= MODIFIER_META; - - if(xev->xbutton.state & Mod2Mask) - *mod |= MODIFIER_NUML; - - if(xev->xbutton.state & Mod3Mask) - *mod |= MODIFIER_MOD3; - - if(xev->xbutton.state & Mod4Mask) - *mod |= MODIFIER_MOD4; - - if(xev->xbutton.state & Mod5Mask) - *mod |= MODIFIER_MOD5; - - return (*mod != MODIFIER_NOMOD); -} - -/* * Handle keyboard event in input text box. */ static void notify_keyevent_inputtext(widget_list_t *wl, @@ -607,7 +602,7 @@ buf[len] = '\0'; - get_key_modifier(xev, &modifier); + (void) xitk_get_key_modifier(xev, &modifier); /* One of modifier key is pressed, none of keylock or shift */ if(((buf[0] != 0) && (buf[1] == 0)) Index: inputtext.h =================================================================== RCS file: /cvsroot/xine/xine-ui/src/xitk/xine-toolkit/inputtext.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- inputtext.h 2001/07/23 23:24:45 1.3 +++ inputtext.h 2001/08/26 20:17:08 1.4 @@ -31,6 +31,16 @@ #include "_xitk.h" +#define MODIFIER_NOMOD 0x00000000 +#define MODIFIER_SHIFT 0x00000001 +#define MODIFIER_LOCK 0x00000002 +#define MODIFIER_CTRL 0x00000004 +#define MODIFIER_META 0x00000008 +#define MODIFIER_NUML 0x00000010 +#define MODIFIER_MOD3 0x00000020 +#define MODIFIER_MOD4 0x00000040 +#define MODIFIER_MOD5 0x00000080 + typedef struct { Display *display; @@ -59,5 +69,6 @@ widget_t *inputtext_create(xitk_inputtext_t *it); char *inputttext_get_text(widget_t *it); void inputtext_change_text(widget_list_t *wl, widget_t *it, char *text); +int xitk_get_key_modifier(XEvent *xev, int *modifier); #endif Index: xitk.h =================================================================== RCS file: /cvsroot/xine/xine-ui/src/xitk/xine-toolkit/xitk.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- xitk.h 2001/07/23 23:24:45 1.12 +++ xitk.h 2001/08/26 20:17:08 1.13 @@ -915,6 +915,25 @@ } xitk_inputtext_t; /** + * All states of modifiers (see xitk_get_key_modifier() bellow). + */ +#define MODIFIER_NOMOD 0x00000000 +#define MODIFIER_SHIFT 0x00000001 +#define MODIFIER_LOCK 0x00000002 +#define MODIFIER_CTRL 0x00000004 +#define MODIFIER_META 0x00000008 +#define MODIFIER_NUML 0x00000010 +#define MODIFIER_MOD3 0x00000020 +#define MODIFIER_MOD4 0x00000040 +#define MODIFIER_MOD5 0x00000080 + +/** + * return 1 if a modifier key has been pressed (extracted from XEvent *) + * modifier pointer will contain the modifier(s) bits (MODIFIER_*) + */ +int xitk_get_key_modifier(XEvent *xev, int *modifier); + +/** * Create an input text box. */ widget_t *inputtext_create (xitk_inputtext_t *it); |