Changeset 5354
- Timestamp:
- Oct 17, 2005, 10:01:34 AM (21 years ago)
- Location:
- trunk/Ohana/src/kapa
- Files:
-
- 2 edited
-
event/Refresh.c (modified) (1 diff)
-
graph/cursor.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kapa/event/Refresh.c
r2473 r5354 4 4 5 5 int i; 6 7 if (HAVE_BACKING) return; 6 8 7 8 9 /* XClearWindow (graphic.display, graphic.window); */ 9 10 XSetForeground (graphic.display, graphic.gc, graphic.back); -
trunk/Ohana/src/kapa/graph/cursor.c
r5349 r5354 1 1 # include "Ximage.h" 2 # define EventMask (long) (KeyPressMask | ExposureMask | StructureNotifyMask | ButtonPressMask) 2 3 # define IgnoreMask (long) (ClientMessage | ButtonReleaseMask | PointerMotionMask) 4 5 int LastEvent (Display *display, int type, XEvent *event); 3 6 4 7 int cursor () { 5 8 9 Display *display; 6 10 XEvent event; 7 11 KeySym keysym; … … 22 26 buffer[4] = 0; 23 27 24 switch (status) { 25 case -1: 26 /* no input from pipe: continue */ 27 break; 28 29 case 0: 30 fprintf (stderr, "pipe has died!\n"); 31 return (FALSE); 32 break; 28 if (status == -1) goto events; 29 if (status == 0) return (FALSE); 30 if (status == 4) { 31 if (!strcmp (buffer, "NCUR")) return (TRUE); 32 goto events; 33 } 34 fprintf (stderr, "weird signal: too many or few bytes! %d\n", status); 35 return (TRUE); 33 36 34 case 4: 35 if (!strcmp (buffer, "NCUR")) { /* stop reading cursor */ 36 return (TRUE); 37 } 38 break; 39 40 default: 41 fprintf (stderr, "weird signal: too many or few bytes! %d\n", status); 42 return (TRUE); 43 break; 44 } 45 37 events: 46 38 if (XEventsQueued (graphic.display, QueuedAfterFlush) < 1){ 47 usleep ( 10000);39 usleep (50000); 48 40 continue; 49 41 } 50 42 51 43 /* check for x events */ 52 if (XCheckMaskEvent (graphic.display, EVENT_MASK, &event)) { 53 54 switch (event.type) { 44 display = graphic.display; 55 45 56 case MotionNotify: 57 break; 46 /* grab the last entry for these events */ 47 if (LastEvent (display, ConfigureNotify, &event)) Reconfig (&event); 48 if (LastEvent (display, CirculateNotify, &event)) Reconfig (&event); 49 if (LastEvent (display, Expose, &event)) Refresh (1); 58 50 59 case Expose: 60 if (HAVE_BACKING) { 61 continue; 62 } 63 if (XEventsQueued (graphic.display, QueuedAlready) < 2) { 64 Refresh (1); 65 } 66 break; 51 if (LastEvent (display, MappingNotify, &event)) XRefreshKeyboardMapping ((XMappingEvent *) &event); 67 52 68 case ConfigureNotify: 69 status = Reconfig (&event); 70 break; 71 72 case MappingNotify: 73 XRefreshKeyboardMapping ((XMappingEvent *) &event); 74 break; 75 76 case ButtonPress: 77 mouse_event = (XButtonEvent *) &event; 78 sprintf (string, "Button%d", mouse_event[0].button); 79 x = (mouse_event[0].x - layout[0].axis[0].fx)*(layout[0].axis[0].max - layout[0].axis[0].min)/layout[0].axis[0].dfx + layout[0].axis[0].min; 80 y = (mouse_event[0].y - layout[0].axis[1].fy)*(layout[0].axis[1].max - layout[0].axis[1].min)/layout[0].axis[1].dfy + layout[0].axis[1].min; 81 snprintf (line, 40, "%12s %12.6f %12.6f ", string, x, y); 82 write (sock, line, 40); 83 break; 53 /* drop and ignore the following StructureNotifyMask events */ 54 LastEvent (display, GravityNotify, &event); 55 LastEvent (display, ReparentNotify, &event); 56 LastEvent (display, MapNotify, &event); 57 LastEvent (display, UnmapNotify, &event); 84 58 85 case KeyPress: 86 value = XLookupString ((XKeyEvent *) &event, string, 9, &keysym, &composestatus); 87 name = XKeysymToString (keysym); 59 /* handle button presses */ 60 if (LastEvent (display, ButtonPress, &event)) { 61 mouse_event = (XButtonEvent *) &event; 62 sprintf (string, "Button%d", mouse_event[0].button); 63 x = (mouse_event[0].x - layout[0].axis[0].fx)*(layout[0].axis[0].max - layout[0].axis[0].min)/layout[0].axis[0].dfx + layout[0].axis[0].min; 64 y = (mouse_event[0].y - layout[0].axis[1].fy)*(layout[0].axis[1].max - layout[0].axis[1].min)/layout[0].axis[1].dfy + layout[0].axis[1].min; 65 snprintf (line, 40, "%12s %12.6f %12.6f ", string, x, y); 66 write (sock, line, 40); 67 } 88 68 89 x = (event.xkey.x - layout[0].axis[0].fx)*(layout[0].axis[0].max - layout[0].axis[0].min)/layout[0].axis[0].dfx + layout[0].axis[0].min; 90 y = (event.xkey.y - layout[0].axis[1].fy)*(layout[0].axis[1].max - layout[0].axis[1].min)/layout[0].axis[1].dfy + layout[0].axis[1].min; 69 /* handle key presses */ 70 if (LastEvent (display, KeyPress, &event)) { 71 value = XLookupString ((XKeyEvent *) &event, string, 9, &keysym, &composestatus); 72 name = XKeysymToString (keysym); 91 73 92 // skip the following keys: 93 if (!strcmp (name, "Shift_L")) break; 94 if (!strcmp (name, "Shift_R")) break; 95 if (!strcmp (name, "Control_L")) break; 96 if (!strcmp (name, "Control_R")) break; 97 if (!strcmp (name, "Alt_L")) break; 98 if (!strcmp (name, "Alt_R")) break; 99 if (!strcmp (name, "Super_L")) break; 100 if (!strcmp (name, "Super_R")) break; 101 if (!strcmp (name, "Caps_Lock")) break; 102 if (!strcmp (name, "Pause")) break; 103 if (!strcmp (name, "Break")) break; 104 if (!strcmp (name, "Num_Lock")) break; 105 if (!strcmp (name, "Scroll_Lock")) break; 106 if (!strcmp (name, "Print")) break; 107 if (!strcmp (name, "(null)")) break; 74 x = (event.xkey.x - layout[0].axis[0].fx)*(layout[0].axis[0].max - layout[0].axis[0].min)/layout[0].axis[0].dfx + layout[0].axis[0].min; 75 y = (event.xkey.y - layout[0].axis[1].fy)*(layout[0].axis[1].max - layout[0].axis[1].min)/layout[0].axis[1].dfy + layout[0].axis[1].min; 108 76 109 snprintf (line, 40, "%12s %12.6f %12.6f ", name, x, y); 110 write (sock, line, 40); 111 break; 112 } 77 // skip the following keys: 78 if (!strcmp (name, "Shift_L")) continue; 79 if (!strcmp (name, "Shift_R")) continue; 80 if (!strcmp (name, "Control_L")) continue; 81 if (!strcmp (name, "Control_R")) continue; 82 if (!strcmp (name, "Alt_L")) continue; 83 if (!strcmp (name, "Alt_R")) continue; 84 if (!strcmp (name, "Super_L")) continue; 85 if (!strcmp (name, "Super_R")) continue; 86 if (!strcmp (name, "Caps_Lock")) continue; 87 if (!strcmp (name, "Pause")) continue; 88 if (!strcmp (name, "Continue")) continue; 89 if (!strcmp (name, "Num_Lock")) continue; 90 if (!strcmp (name, "Scroll_Lock")) continue; 91 if (!strcmp (name, "Print")) continue; 92 if (!strcmp (name, "(null)")) continue; 93 94 snprintf (line, 40, "%12s %12.6f %12.6f ", name, x, y); 95 write (sock, line, 40); 113 96 } 97 98 /* remove those events we will ignore */ 99 while (XCheckMaskEvent (display, IgnoreMask, &event)) continue; 114 100 } 101 return (FALSE); 115 102 }
Note:
See TracChangeset
for help on using the changeset viewer.
