IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2889


Ignore:
Timestamp:
Jan 4, 2005, 10:25:07 AM (22 years ago)
Author:
eugene
Message:

moved interpretation of pipe signals to CheckPipe

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/kii/picture/cursor.c

    r2466 r2889  
    11# include "Ximage.h"
     2
     3int LastEvent (Display *display, int type, XEvent *event);
    24
    35int cursor (Graphic *graphic, Layout *layout) {
    46
     7  Display        *display;
    58  XEvent          event;
    69  KeySym          keysym;
    7   int             status, xstatus, value;
     10  int             status, value;
    811  XComposeStatus  composestatus;
    912  char            string[10], line[500];
    1013  double          x, y;
    11   char            buffer[1024];
    1214 
    1315  while (1) {
    1416   
    15     status = read (layout[0].Ximage, buffer, 4);
    16     buffer[4] = 0;
    17    
    18     switch (status) {
    19     case -1:
    20       /* no input from pipe: continue */
    21       break;
    22      
    23     case 0:
    24       fprintf (stderr, "pipe has died!\n");
    25       return (FALSE);
    26       break;
     17    status = CheckPipe (graphic, layout);
     18    if (status == 0) return (FALSE);
     19    if (status == 2) return (TRUE);
     20    if (status == 1) goto events;
    2721
    28     case 4:
    29       if (!strcmp (buffer, "NCUR")) {  /* stop reading cursor */
    30         return (TRUE);
    31       }
    32       break;
    33 
    34     default:
    35       fprintf (stderr, "weird signal: too many or few bytes!  %d\n", status);
    36       return (TRUE);
    37       break;
     22  events:
     23    if (XEventsQueued (graphic[0].display, QueuedAfterFlush) < 1) {
     24      usleep (10000);
     25      continue;
    3826    }
    3927
    40     if ((xstatus = XCheckMaskEvent (graphic[0].display, EVENT_MASK, &event))) {
     28    display = graphic[0].display;
     29
     30    /* only do the last entry for these events */
     31    /* this ignores the return status from these functions */
     32    if (LastEvent (display, ConfigureNotify, &event)) Reconfig (graphic, layout, &event);
     33    if (LastEvent (display, Expose,          &event)) Refresh (graphic, layout, 1);
     34    if (LastEvent (display, MappingNotify,   &event)) XRefreshKeyboardMapping ((XMappingEvent *) &event);
     35    if (LastEvent (display, MotionNotify,    &event)) UpdatePointer (graphic, layout, (XMotionEvent *) &event);
     36    if (LastEvent (display, ButtonPress,     &event)) InterpretPresses (graphic, layout, (XButtonEvent *) &event);
     37
     38    if (LastEvent (display, KeyPress,        &event)) {
     39      value = XLookupString ((XKeyEvent *) &event, string, 9, &keysym, &composestatus);
    4140     
    42       switch (event.type)  {
     41      if ((event.xkey.x >= layout[0].picture.x) && (event.xkey.x <= layout[0].picture.x + layout[0].picture.dx) &&
     42          (event.xkey.y >= layout[0].picture.y) && (event.xkey.y <= layout[0].picture.y + layout[0].picture.dy)) {
    4343       
    44       case ButtonPress:
    45         status = InterpretPresses (graphic, layout, (XButtonEvent *) &event);
    46         break;
    47        
    48       case Expose:
    49         if (event.xexpose.count == 0)
    50           Refresh (graphic, layout, 1);
    51         break;
    52        
    53       case ConfigureNotify:
    54         status =  Reconfig (graphic, layout, &event);
    55         break;
    56        
    57       case MappingNotify:
    58         XRefreshKeyboardMapping ((XMappingEvent *) &event);
    59         break;
    60        
    61       case MotionNotify:
    62         if (XPending (graphic[0].display) < 2) {
    63           UpdatePointer (graphic, layout, (XMotionEvent *) &event);
     44        Screen_to_Image (&x, &y, (double)event.xkey.x, (double)event.xkey.y, layout);
     45
     46        if (isprint(string[0]))
     47          sprintf (line, "%c %6.1f %6.1f ", string[0], x, y);
     48        else {
     49          sprintf (line, "X %6.1f %6.1f ", x, y);
     50          break;
    6451        }
    65         break;
    66 
    67       case KeyPress:
    68         value = XLookupString ((XKeyEvent *) &event, string, 9, &keysym, &composestatus);
    69 
    70         if ((event.xkey.x >= layout[0].picture.x) && (event.xkey.x <= layout[0].picture.x + layout[0].picture.dx) &&
    71             (event.xkey.y >= layout[0].picture.y) && (event.xkey.y <= layout[0].picture.y + layout[0].picture.dy)) {
    72 
    73           Screen_to_Image (&x, &y, (double)event.xkey.x, (double)event.xkey.y, layout);
    74 
    75           if (isprint(string[0]))
    76             sprintf (line, "%c %6.1f %6.1f ", string[0], x, y);
    77           else {
    78             sprintf (line, "X %6.1f %6.1f ", x, y);
    79             break;
    80           }
    81           write (layout[0].Ximage, line, 16);
    82         }
     52        write (layout[0].Ximage, line, 16);
    8353      }
    8454    }
    8555  }
     56  return (FALSE);
    8657}
Note: See TracChangeset for help on using the changeset viewer.