mirror of
https://github.com/gryf/wmdocklib.git
synced 2025-12-19 12:28:10 +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 *
|
static PyObject *
|
||||||
pywmgeneral_checkForEvents(PyObject *self, PyObject *args) {
|
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.
|
* 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
|
* Ignore events we don't handle. Also we provide a handler for when the
|
||||||
* window is exposed, redraw it.
|
* window is exposed, redraw it.
|
||||||
*/
|
*/
|
||||||
XEvent event;
|
XEvent event;
|
||||||
|
static char buffer[8];
|
||||||
|
int bufsize = 8;
|
||||||
|
XComposeStatus dummy;
|
||||||
|
KeySym keysym;
|
||||||
|
int count;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, ""))
|
if (!PyArg_ParseTuple(args, ""))
|
||||||
return NULL;
|
return NULL;
|
||||||
while (XPending(display)) {
|
while (XPending(display)) {
|
||||||
@@ -205,10 +211,14 @@ pywmgeneral_checkForEvents(PyObject *self, PyObject *args) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case KeyPress:
|
case KeyPress:
|
||||||
return Py_BuildValue("{s:s,s:i,s:i}",
|
count = XLookupString((XKeyEvent*)&event, buffer, bufsize, &keysym, &dummy);
|
||||||
"type", "keypress",
|
buffer[count] = '\0';
|
||||||
"state", event.xkey.state,
|
|
||||||
"keycode", event.xkey.keycode);
|
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 ButtonPress:
|
||||||
case ButtonRelease:
|
case ButtonRelease:
|
||||||
@@ -255,6 +265,11 @@ static PyMethodDef PyWmgeneralMethods[] = {
|
|||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* here comes the definition of the class Drawable
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
PyObject_HEAD
|
PyObject_HEAD
|
||||||
/* Type-specific fields go here. */
|
/* Type-specific fields go here. */
|
||||||
@@ -404,6 +419,11 @@ static PyTypeObject drawable_DrawableType = {
|
|||||||
Drawable_new, /* tp_new */
|
Drawable_new, /* tp_new */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* end of class Dawable
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* Original C sources (With some modifications) */
|
/* Original C sources (With some modifications) */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ class Application:
|
|||||||
for evtype, key, area, callback in self._events:
|
for evtype, key, area, callback in self._events:
|
||||||
if evtype is not None and evtype != event['type']: continue
|
if evtype is not None and evtype != event['type']: continue
|
||||||
if key is not None and key != event['button']: 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[0] <= event['x'] <= area[2]: continue
|
||||||
if not area[1] <= event['y'] <= area[3]: continue
|
if not area[1] <= event['y'] <= area[3]: continue
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user