forked from len0rd/rockbox
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
This commit is contained in:
parent
ea60436cd8
commit
5fcce4da58
3 changed files with 30 additions and 68 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue