Changeset 2889
- Timestamp:
- Jan 4, 2005, 10:25:07 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/kii/picture/cursor.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kii/picture/cursor.c
r2466 r2889 1 1 # include "Ximage.h" 2 3 int LastEvent (Display *display, int type, XEvent *event); 2 4 3 5 int cursor (Graphic *graphic, Layout *layout) { 4 6 7 Display *display; 5 8 XEvent event; 6 9 KeySym keysym; 7 int status, xstatus,value;10 int status, value; 8 11 XComposeStatus composestatus; 9 12 char string[10], line[500]; 10 13 double x, y; 11 char buffer[1024];12 14 13 15 while (1) { 14 16 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; 27 21 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; 38 26 } 39 27 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); 41 40 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)) { 43 43 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; 64 51 } 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); 83 53 } 84 54 } 85 55 } 56 return (FALSE); 86 57 }
Note:
See TracChangeset
for help on using the changeset viewer.
