IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

using on the last of the events in the queue for each type

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/kii/event/EventLoop.c

    r2466 r2892  
    11# include "Ximage.h"
    2 # define MAX_STRING 100
    3 /* WARNING: this is defined because the HP UX installation i have does not
    4 seem to know this structure, though it should */
    5 # ifdef DUMMY
    6 struct Ktimeval {
    7   unsigned long tv_sec;         /* seconds */
    8   long          tv_usec;        /* and microseconds */
    9 };
    10 # endif
     2
     3int LastEvent (Display *display, int type, XEvent *event) {
     4
     5  int found;
     6
     7  found = FALSE;
     8  while (XCheckTypedEvent (display, type, event)) {
     9    found = TRUE;
     10  }
     11  return (found);
     12}
    1113
    1214int EventLoop (Graphic *graphic, Layout *layout) {
     
    1416  XEvent          event;
    1517  int             status;
     18  Display        *display;
    1619 
    17   /* gettimeofday (&then, (struct timeval *) NULL); */
    18 
    1920  Refresh (graphic, layout, 1);
    2021
     
    3031    }
    3132
    32     if (XCheckMaskEvent (graphic[0].display, EVENT_MASK, &event)) {
     33    display = graphic[0].display;
    3334
    34       switch (event.type)  {
    35        
    36       case MotionNotify:
    37         if (XEventsQueued (graphic[0].display, QueuedAlready) < 2) {
    38           UpdatePointer (graphic, layout, (XMotionEvent *) &event);
    39         }
    40         break;
    41       case ButtonPress:
    42         status = InterpretPresses (graphic, layout, (XButtonEvent *) &event);
    43         break;
    44        
    45       case Expose:
    46         if (XEventsQueued (graphic[0].display, QueuedAlready) < 2) {
    47           Refresh (graphic, layout, 1);
    48         }
    49         break;
    50         /* if (event.xexpose.count == 0) */
    51        
    52       case ConfigureNotify:
    53         status = Reconfig (graphic, layout, &event);
    54         /*
    55         if (XEventsQueued (graphic[0].display, QueuedAlready) < 2) {
    56           status = Reconfig (graphic, layout, &event);
    57         }
    58         */
    59         break;
    60        
    61       case KeyPress:
    62         status = InterpretKeys (graphic, layout, &event);
    63         break;
    64        
    65       case MappingNotify:
    66         if (XEventsQueued (graphic[0].display, QueuedAlready) < 2) {
    67           XRefreshKeyboardMapping ((XMappingEvent *) &event);
    68         }
    69         break;
    70        
    71       }
    72     }
     35    /* only do the last entry for these events */
     36    /* this ignores the return status from these functions */
     37    if (LastEvent (display, ConfigureNotify, &event)) Reconfig (graphic, layout, &event);
     38    if (LastEvent (display, Expose,          &event)) Refresh (graphic, layout, 1);
     39    if (LastEvent (display, MappingNotify,   &event)) XRefreshKeyboardMapping ((XMappingEvent *) &event);
     40    if (LastEvent (display, MotionNotify,    &event)) UpdatePointer (graphic, layout, (XMotionEvent *) &event);
     41    if (LastEvent (display, ButtonPress,     &event)) InterpretPresses (graphic, layout, (XButtonEvent *) &event);
     42    if (LastEvent (display, KeyPress,        &event)) InterpretKeys (graphic, layout, &event);
    7343  }
    7444  return (status);
    7545}
    7646
    77 /*     
    78 while (XPending (graphic[0].display) {
    79 if (readfds && display_mask) {
    80 */
    81 /*
    82   while (1) {
    83     fprintf (stderr, "window in EventLoop: %x  %d\n", graphic[0].display, graphic[0].window);
    84     XNextEvent (graphic[0].display, &event);
    85     if (event.type == ClientMessage) {
    86       fprintf (stderr, "choice 1\n");
    87     }
    88    
    89     if (event.xclient.send_event) {
    90       fprintf (stderr, "choice 2\n");
    91     }
    92   }
    93 */
    94  
     47# if (0)
     48/* WARNING: this is defined because the HP UX installation i have does not
     49seem to know this structure, though it should.  Clearly a need for autoconf.. */
     50struct Ktimeval {
     51  unsigned long tv_sec;         /* seconds */
     52  long          tv_usec;        /* and microseconds */
     53};
     54# endif
     55
Note: See TracChangeset for help on using the changeset viewer.