mirror of
https://github.com/gryf/wmdocklib.git
synced 2025-12-18 20:10:23 +01:00
1723401: key events are not completely translated
added the field 'button' to key events. the reason for calling it 'button' is so that it has the same name as mouse events. the value is the translation as returned by XLookupString.
This commit is contained in:
@@ -182,12 +182,18 @@ pywmgeneral_copyXPMArea(PyObject *self, PyObject *args) {
|
||||
|
||||
static PyObject *
|
||||
pywmgeneral_checkForEvents(PyObject *self, PyObject *args) {
|
||||
/* If we find an event we handle, return a dicitionary containing some
|
||||
/* If we find an event we handle, return a dictionary containing some
|
||||
* information about it. Return None if there are no events we handle.
|
||||
* Ignore events we don't handle. Also we provide a handler for when the
|
||||
* window is exposed, redraw it.
|
||||
*/
|
||||
XEvent event;
|
||||
static char buffer[8];
|
||||
int bufsize = 8;
|
||||
XComposeStatus dummy;
|
||||
KeySym keysym;
|
||||
int count;
|
||||
|
||||
if (!PyArg_ParseTuple(args, ""))
|
||||
return NULL;
|
||||
while (XPending(display)) {
|
||||
@@ -205,10 +211,14 @@ pywmgeneral_checkForEvents(PyObject *self, PyObject *args) {
|
||||
break;
|
||||
|
||||
case KeyPress:
|
||||
return Py_BuildValue("{s:s,s:i,s:i}",
|
||||
"type", "keypress",
|
||||
"state", event.xkey.state,
|
||||
"keycode", event.xkey.keycode);
|
||||
count = XLookupString((XKeyEvent*)&event, buffer, bufsize, &keysym, &dummy);
|
||||
buffer[count] = '\0';
|
||||
|
||||
return Py_BuildValue("{s:s,s:i,s:i,s:s}",
|
||||
"type", "keypress",
|
||||
"state", event.xkey.state,
|
||||
"keycode", event.xkey.keycode,
|
||||
"button", buffer);
|
||||
|
||||
case ButtonPress:
|
||||
case ButtonRelease:
|
||||
@@ -255,6 +265,11 @@ static PyMethodDef PyWmgeneralMethods[] = {
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
/*
|
||||
* here comes the definition of the class Drawable
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
/* Type-specific fields go here. */
|
||||
@@ -404,6 +419,11 @@ static PyTypeObject drawable_DrawableType = {
|
||||
Drawable_new, /* tp_new */
|
||||
};
|
||||
|
||||
/*
|
||||
* end of class Dawable
|
||||
*
|
||||
*/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Original C sources (With some modifications) */
|
||||
/*****************************************************************************/
|
||||
|
||||
@@ -150,7 +150,7 @@ class Application:
|
||||
for evtype, key, area, callback in self._events:
|
||||
if evtype is not None and evtype != event['type']: continue
|
||||
if key is not None and key != event['button']: continue
|
||||
if area is not None:
|
||||
if area is not None and 'x' in event:
|
||||
if not area[0] <= event['x'] <= area[2]: continue
|
||||
if not area[1] <= event['y'] <= area[3]: continue
|
||||
|
||||
|
||||
Reference in New Issue
Block a user