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.tar.gz
rockbox-5fcce4da583b2524c93febefb0e2962a889c9ae1.zip
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 d1310d71e2..c838677778 100644
--- a/uisimulator/x11/button-x11.c
+++ b/uisimulator/x11/button-x11.c
@@ -63,19 +63,14 @@ int button_set_release(int newmask)
63 */ 63 */
64 64
65/* from uibasic.c */ 65/* from uibasic.c */
66extern int screenhack_handle_events (void); 66extern int screenhack_handle_events(bool *release);
67 67
68static int get_raw_button (void) 68static int get_raw_button (void)
69{ 69{
70 int k; 70 int k;
71 static int next = 0; 71 bool release=false; /* is this a release event */
72 if ( next ) {
73 k = next;
74 next = 0;
75 return k;
76 }
77 72
78 switch(screenhack_handle_events()) 73 switch(screenhack_handle_events(&release))
79 { 74 {
80 case XK_KP_Left: 75 case XK_KP_Left:
81 case XK_Left: 76 case XK_Left:
@@ -153,8 +148,9 @@ static int get_raw_button (void)
153 break; 148 break;
154 } 149 }
155 150
156 if ( k ) 151 if ( release )
157 next = k | BUTTON_REL; 152 /* return a release event */
153 k |= BUTTON_REL;
158 154
159 return k; 155 return k;
160} 156}
diff --git a/uisimulator/x11/screenhack.c b/uisimulator/x11/screenhack.c
index 2106c17062..bdbdd6d757 100644
--- a/uisimulator/x11/screenhack.c
+++ b/uisimulator/x11/screenhack.c
@@ -188,9 +188,12 @@ static Atom XA_WM_PROTOCOLS, XA_WM_DELETE_WINDOW;
188/* Dead-trivial event handling: exits if "q" or "ESC" are typed. 188/* Dead-trivial event handling: exits if "q" or "ESC" are typed.
189 Exit if the WM_PROTOCOLS WM_DELETE_WINDOW ClientMessage is received. 189 Exit if the WM_PROTOCOLS WM_DELETE_WINDOW ClientMessage is received.
190 */ 190 */
191int screenhack_handle_event (Display *dpy, XEvent *event) 191int screenhack_handle_event(Display *dpy, XEvent *event, bool *release)
192{ 192{
193 int key=0; 193 int key=0;
194
195 *release = FALSE;
196
194 switch (event->xany.type) { 197 switch (event->xany.type) {
195 case KeyPress: 198 case KeyPress:
196 { 199 {
@@ -201,6 +204,18 @@ int screenhack_handle_event (Display *dpy, XEvent *event)
201 /* fprintf(stderr, "KEY PRESSED: %c (%02x)\n", c, c); */ 204 /* fprintf(stderr, "KEY PRESSED: %c (%02x)\n", c, c); */
202 } 205 }
203 break; 206 break;
207 case KeyRelease:
208 {
209 KeySym keysym;
210 unsigned char c = 0;
211 XLookupString (&event->xkey, &c, 1, &keysym, 0);
212 key = keysym;
213 /* fprintf(stderr, "KEY RELEASED: %c (%02x) %x\n", c, c,
214 event->xkey.keycode); */
215
216 *release = TRUE;
217 }
218 break;
204 case ResizeRequest: 219 case ResizeRequest:
205 screen_resized(event->xresizerequest.width, 220 screen_resized(event->xresizerequest.width,
206 event->xresizerequest.height); 221 event->xresizerequest.height);
@@ -248,14 +263,14 @@ int screenhack_handle_event (Display *dpy, XEvent *event)
248} 263}
249 264
250 265
251int screenhack_handle_events (void) 266int screenhack_handle_events(bool *release)
252{ 267{
253 int key=0; 268 int key=0;
254 while (XPending (dpy)) 269 while (XPending(dpy))
255 { 270 {
256 XEvent event; 271 XEvent event;
257 XNextEvent (dpy, &event); 272 XNextEvent(dpy, &event);
258 key=screenhack_handle_event (dpy, &event); 273 key=screenhack_handle_event(dpy, &event, release);
259 } 274 }
260 return key; 275 return key;
261} 276}
@@ -421,7 +436,7 @@ int main (int argc, char **argv)
421 XWindowAttributes xgwa; 436 XWindowAttributes xgwa;
422 XGetWindowAttributes (dpy, window, &xgwa); 437 XGetWindowAttributes (dpy, window, &xgwa);
423 XSelectInput (dpy, window, 438 XSelectInput (dpy, window,
424 xgwa.your_event_mask | KeyPressMask | 439 xgwa.your_event_mask | KeyPressMask | KeyRelease |
425 ButtonPressMask | ResizeRedirectMask | ExposureMask); 440 ButtonPressMask | ResizeRedirectMask | ExposureMask);
426 XChangeProperty (dpy, window, XA_WM_PROTOCOLS, XA_ATOM, 32, 441 XChangeProperty (dpy, window, XA_WM_PROTOCOLS, XA_ATOM, 32,
427 PropModeReplace, 442 PropModeReplace,
diff --git a/uisimulator/x11/screenhack.h b/uisimulator/x11/screenhack.h
index 12cd873e22..ac9b01bf75 100644
--- a/uisimulator/x11/screenhack.h
+++ b/uisimulator/x11/screenhack.h
@@ -9,51 +9,11 @@
9 * implied warranty. 9 * implied warranty.
10 */ 10 */
11 11
12/* Found in Don Hopkins' .plan file:
13 *
14 * The color situation is a total flying circus. The X approach to
15 * device independence is to treat everything like a MicroVax framebuffer
16 * on acid. A truely portable X application is required to act like the
17 * persistent customer in the Monty Python ``Cheese Shop'' sketch. Even
18 * the simplest applications must answer many difficult questions, like:
19 *
20 * WHAT IS YOUR DISPLAY?
21 * display = XOpenDisplay("unix:0");
22 * WHAT IS YOUR ROOT?
23 * root = RootWindow(display, DefaultScreen(display));
24 * AND WHAT IS YOUR WINDOW?
25 * win = XCreateSimpleWindow(display, root, 0, 0, 256, 256, 1,
26 * BlackPixel(display, DefaultScreen(display)),
27 * WhitePixel(display, DefaultScreen(display)))
28 * OH ALL RIGHT, YOU CAN GO ON.
29 *
30 * WHAT IS YOUR DISPLAY?
31 * display = XOpenDisplay("unix:0");
32 * WHAT IS YOUR COLORMAP?
33 * cmap = DefaultColormap(display, DefaultScreen(display));
34 * AND WHAT IS YOUR FAVORITE COLOR?
35 * favorite_color = 0; / * Black. * /
36 * / * Whoops! No, I mean: * /
37 * favorite_color = BlackPixel(display, DefaultScreen(display));
38 * / * AAAYYYYEEEEE!! (client dumps core & falls into the chasm) * /
39 *
40 * WHAT IS YOUR DISPLAY?
41 * display = XOpenDisplay("unix:0");
42 * WHAT IS YOUR VISUAL?
43 * struct XVisualInfo vinfo;
44 * if (XMatchVisualInfo(display, DefaultScreen(display),
45 * 8, PseudoColor, &vinfo) != 0)
46 * visual = vinfo.visual;
47 * AND WHAT IS THE NET SPEED VELOCITY OF AN XConfigureWindow REQUEST?
48 * / * Is that a SubStructureRedirectMask or a ResizeRedirectMask? * /
49 * WHAT?! HOW AM I SUPPOSED TO KNOW THAT?
50 * AAAAUUUGGGHHH!!!! (server dumps core & falls into the chasm)
51 */
52
53#ifndef __SCREENHACK_H__ 12#ifndef __SCREENHACK_H__
54#define __SCREENHACK_H__ 13#define __SCREENHACK_H__
55 14
56#include <stdlib.h> 15#include <stdlib.h>
16#include <stdbool.h>
57 17
58#include "config.h" 18#include "config.h"
59 19
@@ -69,15 +29,6 @@
69#include <X11/Xresource.h> 29#include <X11/Xresource.h>
70#include <X11/Xos.h> 30#include <X11/Xos.h>
71 31
72/* M_PI ought to have been defined in math.h, but... */
73#ifndef M_PI
74# define M_PI 3.1415926535
75#endif
76
77#ifndef M_PI_2
78# define M_PI_2 1.5707963267
79#endif
80
81#include "resources.h" 32#include "resources.h"
82#include "visual.h" 33#include "visual.h"
83 34
@@ -89,8 +40,8 @@ extern XrmOptionDescRec options [];
89extern char *defaults []; 40extern char *defaults [];
90 41
91extern void screenhack (Display*,Window); 42extern void screenhack (Display*,Window);
92extern int screenhack_handle_event (Display*, XEvent*); 43extern int screenhack_handle_event(Display*, XEvent*, bool *);
93extern int screenhack_handle_events (void); 44extern int screenhack_handle_events(bool *);
94extern void screen_redraw(); 45extern void screen_redraw();
95extern void screen_resized(); 46extern void screen_resized();
96 47