Changeset 7351 in project


Ignore:
Timestamp:
01/15/08 14:51:54 (12 years ago)
Author:
felix winkelmann
Message:

added ezx-event-pending and better ezx-next-event

Location:
ezxdisp
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • ezxdisp/ezxdisp.h

    r4 r7351  
    101101int    ezx_sensebutton(ezx_t *e, int *x, int *y);
    102102int    ezx_pushbutton(ezx_t *e, int *x, int *y);
    103 void   ezx_next_event(ezx_t *ezx, ezx_event_t *ezx_event);
     103int   ezx_next_event(ezx_t *ezx, int *x, int *y, int *b, int *k);
     104int    ezx_event_pending(ezx_t *ezx);
    104105
    105106// for 2D graphics
  • ezxdisp/ezxdisp.html

    r4232 r7351  
    3939<h3>Version:</h3>
    4040<ul>
     41<li>1.3
     42Added <code>ezx-event-pending</code>
    4143<li>1.2
    4244Adapted to externalized <code>easyffi</code> extension
  • ezxdisp/ezxdisp.scm

    r1 r7351  
    2727int    ezx_sensebutton(ezxp e, ___out int *x, ___out int *y);
    2828int    ezx_pushbutton(ezxp e, ___out int *x, ___out int *y);
     29___bool ezx_event_pending(ezxp e);
     30int ezx_next_event(ezxp e, ___out int *x, ___out int *y, ___out int *b, ___out int *k);
    2931
    3032// for 2D graphics
  • ezxdisp/ezxdisp.setup

    r3949 r7351  
    33 'ezxdisp
    44 '("ezxdisp.so")
    5  '((version 1.2)
     5 '((version 1.3)
    66   (examples "3d_clock.scm")
    77   (documentation "ezxdisp.html")
  • ezxdisp/ezxdisp0.c

    r4 r7351  
    924924}
    925925
    926 void ezx_next_event(ezx_t *ezx, ezx_event_t *ezx_event)
     926int ezx_next_event(ezx_t *ezx, int *x, int *y, int *b, int *k)
    927927{
    928928  XEvent xevent;
     
    945945      XQueryPointer(ezx->display, ezx->top, &root, &child, &root_x, &root_y,
    946946                    &win_x, &win_y, &keys_buttons);
    947       ezx_event->x = ((XButtonEvent *)&xevent)->x;
    948       ezx_event->y = ((XButtonEvent *)&xevent)->y;
    949       ezx_event->b = ((XButtonEvent *)&xevent)->button;
     947      *x = ((XButtonEvent *)&xevent)->x;
     948      *y = ((XButtonEvent *)&xevent)->y;
     949      *b = ((XButtonEvent *)&xevent)->button;
    950950      if (keys_buttons & ShiftMask)
    951         ezx_event->b |= 8;
     951        *b |= 8;
    952952      if (keys_buttons & ControlMask)
    953         ezx_event->b |= 16;
    954       ezx_event->type = EzxButtonPress;
    955       break;
     953        *b |= 16;
     954      *k = 0;
     955      return EzxButtonPress;
    956956    }
    957957
     
    959959      char s[10];
    960960      if (XLookupString((XKeyEvent *)&xevent, s, 10, NULL, NULL) == 1) {
    961         ezx_event->type = EzxKeyPress;
    962         ezx_event->k    = s[0];
    963         ezx_event->x     = xevent.xkey.x;
    964         ezx_event->y     = xevent.xkey.y;
    965         break;
     961        *b = 0;
     962        *k    = s[0];
     963        *x     = xevent.xkey.x;
     964        *y     = xevent.xkey.y;
     965        return EzxKeyPress;
    966966      }
    967967    }
     
    969969}
    970970
     971int ezx_event_pending(ezx_t *ezx)
     972{
     973  assert(ezx->magic == MAGIC1);
     974
     975  return XPending(ezx->display) > 0;
     976}
  • ezxdisp/hello.scm

    r1403 r7351  
    1 (use ezxdisp)
     1(use ezxdisp srfi-18)
    22
    33(define ezx (ezx-init 100 100 "Hello, ezxdisp"))
     
    77
    88(let loop ()
    9   (let-values ([(b _ _) (ezx-pushbutton ezx)])
    10     (when (zero? b) (loop)) ) )
     9  (thread-sleep! 0.25)
     10  (when (ezx-event-pending ezx)
     11    (pp (receive (ezx-next-event ezx))) )
     12  (loop))
    1113
    1214(ezx-quit ezx)
Note: See TracChangeset for help on using the changeset viewer.