summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2002-10-14 08:09:29 +0000
committerDaniel Stenberg <daniel@haxx.se>2002-10-14 08:09:29 +0000
commit5fcce4da583b2524c93febefb0e2962a889c9ae1 (patch)
tree7dfd35da4ac481bc71f4dd8c3c20c6f716504942
parentea60436cd8b26dc375993eede6b98653f00e2548 (diff)
downloadrockbox-5fcce4da583b2524c93febefb0e2962a889c9ae1.zip
rockbox-5fcce4da583b2524c93febefb0e2962a889c9ae1.tar.gz
rockbox-5fcce4da583b2524c93febefb0e2962a889c9ae1.tar.bz2
rockbox-5fcce4da583b2524c93febefb0e2962a889c9ae1.tar.xz
Now the X11 simulator sets the BUTTON_REL bit properly and thus generates
button release events, much in the same way the actual target behaves. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2606 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--uisimulator/x11/button-x11.c16
-rw-r--r--uisimulator/x11/screenhack.c27
-rw-r--r--uisimulator/x11/screenhack.h55
3 files changed, 30 insertions, 68 deletions
diff --git a/uisimulator/x11/button-x11.c b/uisimulator/x11/button-x11.c
index d1310d7..c838677 100644
--- a/uisimulator/x11/button-x11.c
+++ b/uisimulator/x11/button-x11.c
@@ -63,19 +63,14 @@ int button_set_release(int newmask)
*/
/* from uibasic.c */
-extern int screenhack_handle_events (void);
+extern int screenhack_handle_events(bool *release);
static int get_raw_button (void)
{
int k;
- static int next = 0;
- if ( next ) {
- k = next;
- next = 0;
- return k;
- }
+ bool release=false; /* is this a release event */
- switch(screenhack_handle_events())
+ switch(screenhack_handle_events(&release))
{
case XK_KP_Left:
case XK_Left:
@@ -153,8 +148,9 @@ static int get_raw_button (void)
break;
}
- if ( k )
- next = k | BUTTON_REL;
+ if ( release )
+ /* return a release event */
+ k |= BUTTON_REL;
return k;
}
diff --git a/uisimulator/x11/screenhack.c b/uisimulator/x11/screenhack.c
index 2106c17..bdbdd6d 100644
--- a/uisimulator/x11/screenhack.c
+++ b/uisimulator/x11/screenhack.c
@@ -188,9 +188,12 @@ static Atom XA_WM_PROTOCOLS, XA_WM_DELETE_WINDOW;
/* Dead-trivial event handling: exits if "q" or "ESC" are typed.
Exit if the WM_PROTOCOLS WM_DELETE_WINDOW ClientMessage is received.
*/
-int screenhack_handle_event (Display *dpy, XEvent *event)
+int screenhack_handle_event(Display *dpy, XEvent *event, bool *release)
{
int key=0;
+
+ *release = FALSE;
+
switch (event->xany.type) {
case KeyPress:
{
@@ -201,6 +204,18 @@ int screenhack_handle_event (Display *dpy, XEvent *event)
/* fprintf(stderr, "KEY PRESSED: %c (%02x)\n", c, c); */
}
break;
+ case KeyRelease:
+ {
+ KeySym keysym;
+ unsigned char c = 0;
+ XLookupString (&event->xkey, &c, 1, &keysym, 0);
+ key = keysym;
+ /* fprintf(stderr, "KEY RELEASED: %c (%02x) %x\n", c, c,
+ event->xkey.keycode); */
+
+ *release = TRUE;
+ }
+ break;
case ResizeRequest:
screen_resized(event->xresizerequest.width,
event->xresizerequest.height);
@@ -248,14 +263,14 @@ int screenhack_handle_event (Display *dpy, XEvent *event)
}
-int screenhack_handle_events (void)
+int screenhack_handle_events(bool *release)
{
int key=0;
- while (XPending (dpy))
+ while (XPending(dpy))
{
XEvent event;
- XNextEvent (dpy, &event);
- key=screenhack_handle_event (dpy, &event);
+ XNextEvent(dpy, &event);
+ key=screenhack_handle_event(dpy, &event, release);
}
return key;
}
@@ -421,7 +436,7 @@ int main (int argc, char **argv)
XWindowAttributes xgwa;
XGetWindowAttributes (dpy, window, &xgwa);
XSelectInput (dpy, window,
- xgwa.your_event_mask | KeyPressMask |
+ xgwa.your_event_mask | KeyPressMask | KeyRelease |
ButtonPressMask | ResizeRedirectMask | ExposureMask);
XChangeProperty (dpy, window, XA_WM_PROTOCOLS, XA_ATOM, 32,
PropModeReplace,
diff --git a/uisimulator/x11/screenhack.h b/uisimulator/x11/screenhack.h
index 12cd873..ac9b01b 100644
--- a/uisimulator/x11/screenhack.h
+++ b/uisimulator/x11/screenhack.h
@@ -9,51 +9,11 @@
* implied warranty.
*/
-/* Found in Don Hopkins' .plan file:
- *
- * The color situation is a total flying circus. The X approach to
- * device independence is to treat everything like a MicroVax framebuffer
- * on acid. A truely portable X application is required to act like the
- * persistent customer in the Monty Python ``Cheese Shop'' sketch. Even
- * the simplest applications must answer many difficult questions, like:
- *
- * WHAT IS YOUR DISPLAY?
- * display = XOpenDisplay("unix:0");
- * WHAT IS YOUR ROOT?
- * root = RootWindow(display, DefaultScreen(display));
- * AND WHAT IS YOUR WINDOW?
- * win = XCreateSimpleWindow(display, root, 0, 0, 256, 256, 1,
- * BlackPixel(display, DefaultScreen(display)),
- * WhitePixel(display, DefaultScreen(display)))
- * OH ALL RIGHT, YOU CAN GO ON.
- *
- * WHAT IS YOUR DISPLAY?
- * display = XOpenDisplay("unix:0");
- * WHAT IS YOUR COLORMAP?
- * cmap = DefaultColormap(display, DefaultScreen(display));
- * AND WHAT IS YOUR FAVORITE COLOR?
- * favorite_color = 0; / * Black. * /
- * / * Whoops! No, I mean: * /
- * favorite_color = BlackPixel(display, DefaultScreen(display));
- * / * AAAYYYYEEEEE!! (client dumps core & falls into the chasm) * /
- *
- * WHAT IS YOUR DISPLAY?
- * display = XOpenDisplay("unix:0");
- * WHAT IS YOUR VISUAL?
- * struct XVisualInfo vinfo;
- * if (XMatchVisualInfo(display, DefaultScreen(display),
- * 8, PseudoColor, &vinfo) != 0)
- * visual = vinfo.visual;
- * AND WHAT IS THE NET SPEED VELOCITY OF AN XConfigureWindow REQUEST?
- * / * Is that a SubStructureRedirectMask or a ResizeRedirectMask? * /
- * WHAT?! HOW AM I SUPPOSED TO KNOW THAT?
- * AAAAUUUGGGHHH!!!! (server dumps core & falls into the chasm)
- */
-
#ifndef __SCREENHACK_H__
#define __SCREENHACK_H__
#include <stdlib.h>
+#include <stdbool.h>
#include "config.h"
@@ -69,15 +29,6 @@
#include <X11/Xresource.h>
#include <X11/Xos.h>
-/* M_PI ought to have been defined in math.h, but... */
-#ifndef M_PI
-# define M_PI 3.1415926535
-#endif
-
-#ifndef M_PI_2
-# define M_PI_2 1.5707963267
-#endif
-
#include "resources.h"
#include "visual.h"
@@ -89,8 +40,8 @@ extern XrmOptionDescRec options [];
extern char *defaults [];
extern void screenhack (Display*,Window);
-extern int screenhack_handle_event (Display*, XEvent*);
-extern int screenhack_handle_events (void);
+extern int screenhack_handle_event(Display*, XEvent*, bool *);
+extern int screenhack_handle_events(bool *);
extern void screen_redraw();
extern void screen_resized();