ignore num/caps/scroll lock in events

This commit is contained in:
Dana Jansens 2003-01-06 06:02:22 +00:00
parent dbf077a59a
commit f3865bb12c
4 changed files with 64 additions and 12 deletions

View file

@ -49,6 +49,8 @@ int OBDisplay::_shape_event_basep = 0;
bool OBDisplay::_xinerama = false;
int OBDisplay::_xinerama_event_basep = 0;
unsigned int OBDisplay::_mask_list[8];
unsigned int OBDisplay::_scrollLockMask = 0;
unsigned int OBDisplay::_numLockMask = 0;
OBDisplay::ScreenInfoList OBDisplay::_screenInfoList;
BGCCache *OBDisplay::_gccache = (BGCCache*) 0;
int OBDisplay::_grab_count = 0;
@ -113,7 +115,6 @@ line argument.\n\n"));
// get lock masks that are defined by the display (not constant)
XModifierKeymap *modmap;
unsigned int NumLockMask = 0, ScrollLockMask = 0;
modmap = XGetModifierMapping(display);
if (modmap && modmap->max_keypermod > 0) {
@ -133,9 +134,9 @@ line argument.\n\n"));
if (! modmap->modifiermap[cnt]) continue;
if (num_lock == modmap->modifiermap[cnt])
NumLockMask = mask_table[cnt / modmap->max_keypermod];
_numLockMask = mask_table[cnt / modmap->max_keypermod];
if (scroll_lock == modmap->modifiermap[cnt])
ScrollLockMask = mask_table[cnt / modmap->max_keypermod];
_scrollLockMask = mask_table[cnt / modmap->max_keypermod];
}
}
@ -143,12 +144,12 @@ line argument.\n\n"));
_mask_list[0] = 0;
_mask_list[1] = LockMask;
_mask_list[2] = NumLockMask;
_mask_list[3] = LockMask | NumLockMask;
_mask_list[4] = ScrollLockMask;
_mask_list[5] = ScrollLockMask | LockMask;
_mask_list[6] = ScrollLockMask | NumLockMask;
_mask_list[7] = ScrollLockMask | LockMask | NumLockMask;
_mask_list[2] = _numLockMask;
_mask_list[3] = LockMask | _numLockMask;
_mask_list[4] = _scrollLockMask;
_mask_list[5] = _scrollLockMask | LockMask;
_mask_list[6] = _scrollLockMask | _numLockMask;
_mask_list[7] = _scrollLockMask | LockMask | _numLockMask;
// Get information on all the screens which are available.
_screenInfoList.reserve(ScreenCount(display));

View file

@ -42,6 +42,12 @@ private:
//! A list of all possible combinations of keyboard lock masks
static unsigned int _mask_list[8];
//! The value of the mask for the NumLock modifier
static unsigned int _numLockMask;
//! The value of the mask for the ScrollLock modifier
static unsigned int _scrollLockMask;
//! The number of requested grabs on the display
static int _grab_count;
@ -97,6 +103,9 @@ public:
//! Returns if the display has the xinerama extention available
inline static bool xinerama() { return _xinerama; }
inline static unsigned int numLockMask() { return _numLockMask; }
inline static unsigned int scrollLockMask() { return _scrollLockMask; }
//! Grabs the display
static void grab();

View file

@ -56,13 +56,25 @@ void OtkEventDispatcher::dispatchEvents(void)
printf("Event %d window %lx\n", e.type, e.xany.window);
#endif
// grab the lasttime
printf("num=%u scroll=%u\n", OBDisplay::numLockMask(), OBDisplay::scrollLockMask());
// grab the lasttime and hack up the modifiers
switch (e.type) {
case ButtonPress:
case ButtonRelease:
_lasttime = e.xbutton.time; break;
_lasttime = e.xbutton.time;
e.xbutton.state &= ~(LockMask | OBDisplay::numLockMask() |
OBDisplay::scrollLockMask());
break;
case KeyPress:
e.xkey.state &= ~(LockMask | OBDisplay::numLockMask() |
OBDisplay::scrollLockMask());
break;
case MotionNotify:
_lasttime = e.xmotion.time; break;
_lasttime = e.xmotion.time;
e.xmotion.state &= ~(LockMask | OBDisplay::numLockMask() |
OBDisplay::scrollLockMask());
break;
case PropertyNotify:
_lasttime = e.xproperty.time; break;
case EnterNotify:

View file

@ -5539,6 +5539,34 @@ static PyObject *_wrap_OBDisplay_xinerama(PyObject *self, PyObject *args) {
}
static PyObject *_wrap_OBDisplay_numLockMask(PyObject *self, PyObject *args) {
PyObject *resultobj;
unsigned int result;
if(!PyArg_ParseTuple(args,(char *)":OBDisplay_numLockMask")) goto fail;
result = (unsigned int)otk::OBDisplay::numLockMask();
resultobj = PyInt_FromLong((long)result);
return resultobj;
fail:
return NULL;
}
static PyObject *_wrap_OBDisplay_scrollLockMask(PyObject *self, PyObject *args) {
PyObject *resultobj;
unsigned int result;
if(!PyArg_ParseTuple(args,(char *)":OBDisplay_scrollLockMask")) goto fail;
result = (unsigned int)otk::OBDisplay::scrollLockMask();
resultobj = PyInt_FromLong((long)result);
return resultobj;
fail:
return NULL;
}
static PyObject *_wrap_OBDisplay_grab(PyObject *self, PyObject *args) {
PyObject *resultobj;
@ -13041,6 +13069,8 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"OBDisplay_shape", _wrap_OBDisplay_shape, METH_VARARGS },
{ (char *)"OBDisplay_shapeEventBase", _wrap_OBDisplay_shapeEventBase, METH_VARARGS },
{ (char *)"OBDisplay_xinerama", _wrap_OBDisplay_xinerama, METH_VARARGS },
{ (char *)"OBDisplay_numLockMask", _wrap_OBDisplay_numLockMask, METH_VARARGS },
{ (char *)"OBDisplay_scrollLockMask", _wrap_OBDisplay_scrollLockMask, METH_VARARGS },
{ (char *)"OBDisplay_grab", _wrap_OBDisplay_grab, METH_VARARGS },
{ (char *)"OBDisplay_ungrab", _wrap_OBDisplay_ungrab, METH_VARARGS },
{ (char *)"OBDisplay_grabButton", _wrap_OBDisplay_grabButton, METH_VARARGS },