From f3865bb12c2b3506e181f15f09b8429a59a618f8 Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Mon, 6 Jan 2003 06:02:22 +0000 Subject: [PATCH] ignore num/caps/scroll lock in events --- otk/display.cc | 19 ++++++++++--------- otk/display.hh | 9 +++++++++ otk/eventdispatcher.cc | 18 +++++++++++++++--- otk/otk_wrap.cc | 30 ++++++++++++++++++++++++++++++ 4 files changed, 64 insertions(+), 12 deletions(-) diff --git a/otk/display.cc b/otk/display.cc index bd6d2d05..3a15ff22 100644 --- a/otk/display.cc +++ b/otk/display.cc @@ -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)); diff --git a/otk/display.hh b/otk/display.hh index 0ebd4140..0fbf2b34 100644 --- a/otk/display.hh +++ b/otk/display.hh @@ -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(); diff --git a/otk/eventdispatcher.cc b/otk/eventdispatcher.cc index 51e2251e..62335781 100644 --- a/otk/eventdispatcher.cc +++ b/otk/eventdispatcher.cc @@ -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: diff --git a/otk/otk_wrap.cc b/otk/otk_wrap.cc index f3951d49..dc49a85b 100644 --- a/otk/otk_wrap.cc +++ b/otk/otk_wrap.cc @@ -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 }, -- 2.45.2