From 05f2a74ef5eaf9a1b80b768f6d841b526ec80dd5 Mon Sep 17 00:00:00 2001 From: kojima Date: Fri, 9 Feb 2001 16:03:09 +0000 Subject: [PATCH] fixed modifier bug in textfield again --- WINGs/ChangeLog | 1 + WINGs/WINGs/WINGs.h | 3 +++ WINGs/WINGs/WINGsP.h | 2 ++ WINGs/widgets.c | 52 +++++++++++++++++++++++++++++++++++++++++++- WINGs/wtextfield.c | 3 +++ 5 files changed, 60 insertions(+), 1 deletion(-) diff --git a/WINGs/ChangeLog b/WINGs/ChangeLog index a08f7f51..f6a21ec4 100644 --- a/WINGs/ChangeLog +++ b/WINGs/ChangeLog @@ -9,6 +9,7 @@ changes since wmaker 0.63.1: - Fixed a mem leak in WMList. - Fixed a bug that caused sigsegv for a WMList with more than 32767 items. - Added an example of how to create a server type program with WMConnection. +- added WMOpenScreen() changes since wmaker 0.62.1: diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h index cf2f3d40..0912ecd6 100644 --- a/WINGs/WINGs/WINGs.h +++ b/WINGs/WINGs/WINGs.h @@ -588,6 +588,9 @@ char *WMGetApplicationName(); /* Try to locate resource file. ext may be NULL */ char *WMPathForResourceOfType(char *resource, char *ext); + +WMScreen *WMOpenScreen(); + WMScreen *WMCreateScreenWithRContext(Display *display, int screen, RContext *context); diff --git a/WINGs/WINGs/WINGsP.h b/WINGs/WINGs/WINGsP.h index f8c0da34..4a1a67cb 100644 --- a/WINGs/WINGs/WINGsP.h +++ b/WINGs/WINGs/WINGsP.h @@ -189,6 +189,8 @@ typedef struct W_Screen { WMHashTable *fontCache; Bool useMultiByte; + + unsigned int ignoredModifierMask; /* modifiers to ignore when typing txt */ struct W_Balloon *balloon; diff --git a/WINGs/widgets.c b/WINGs/widgets.c index 8feae066..9a9051fc 100644 --- a/WINGs/widgets.c +++ b/WINGs/widgets.c @@ -3,7 +3,7 @@ #include "WINGsP.h" #include - +#include #include /********** data ************/ @@ -515,6 +515,20 @@ loadPixmaps(WMScreen *scr) } +WMScreen* +WMOpenScreen() +{ + Display *dpy = XOpenDisplay(""); + + if (!dpy) { + wwarning("WINGs: could not open display %s", + XDisplayName("")); + return NULL; + } + + return WMCreateSimpleApplicationScreen(dpy); +} + WMScreen* WMCreateSimpleApplicationScreen(Display *display) @@ -602,6 +616,42 @@ WMCreateScreenWithRContext(Display *display, int screen, RContext *context) scrPtr->fontCache = WMCreateHashTable(WMStringPointerHashCallbacks); + scrPtr->ignoredModifierMask = 0; + { + int i; + XModifierKeymap *modmap; + KeyCode nlock, slock; + static int mask_table[8] = { + ShiftMask,LockMask,ControlMask,Mod1Mask, + Mod2Mask, Mod3Mask, Mod4Mask, Mod5Mask + }; + unsigned int numLockMask, scrollLockMask; + + nlock = XKeysymToKeycode(display, XK_Num_Lock); + slock = XKeysymToKeycode(display, XK_Scroll_Lock); + + /* + * Find out the masks for the NumLock and ScrollLock modifiers, + * so that we can bind the grabs for when they are enabled too. + */ + modmap = XGetModifierMapping(display); + + if (modmap!=NULL && modmap->max_keypermod>0) { + for (i=0; i<8*modmap->max_keypermod; i++) { + if (modmap->modifiermap[i]==nlock && nlock!=0) + numLockMask = mask_table[i/modmap->max_keypermod]; + else if (modmap->modifiermap[i]==slock && slock!=0) + scrollLockMask = mask_table[i/modmap->max_keypermod]; + } + } + + if (modmap) + XFreeModifiermap(modmap); + + + scrPtr->ignoredModifierMask = numLockMask|scrollLockMask|LockMask; + } + /* initially allocate some colors */ WMWhiteColor(scrPtr); WMBlackColor(scrPtr); diff --git a/WINGs/wtextfield.c b/WINGs/wtextfield.c index 8b6f2e98..e310dda8 100644 --- a/WINGs/wtextfield.c +++ b/WINGs/wtextfield.c @@ -1000,7 +1000,10 @@ handleTextFieldKeyPress(TextField *tPtr, XEvent *event) int cancelSelection = 1; Bool shifted, controled, modified; Bool relay = True; + WMScreen *scr = tPtr->view->screen; + event->xkey.state &= ~scr->ignoredModifierMask; + /*printf("(%d,%d) -> ", tPtr->selection.position, tPtr->selection.count);*/ if (((XKeyEvent *) event)->state & WM_EMACSKEYMASK) control_pressed = 1;