Changeset 5349
- Timestamp:
- Oct 15, 2005, 2:41:53 PM (21 years ago)
- Location:
- trunk/Ohana/src
- Files:
-
- 3 edited
-
kapa/graph/cursor.c (modified) (4 diffs)
-
kii/picture/cursor.c (modified) (3 diffs)
-
opihi/cmd.data/cursor.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/kapa/graph/cursor.c
r4769 r5349 1 1 # include "Ximage.h" 2 # define EventMask (long) (KeyPressMask | ExposureMask | StructureNotifyMask )2 # define EventMask (long) (KeyPressMask | ExposureMask | StructureNotifyMask | ButtonPressMask) 3 3 4 4 int cursor () { … … 8 8 int status, value; 9 9 XComposeStatus composestatus; 10 char string[10], line[ 35];10 char string[10], line[40], *name; 11 11 double x, y; 12 12 char buffer[10]; 13 13 Layout *layout; 14 14 XButtonEvent *mouse_event; 15 15 16 layout = §ion[TheSection]; 16 17 … … 22 23 23 24 switch (status) { 24 case -1:25 /* no input from pipe: continue */26 break;25 case -1: 26 /* no input from pipe: continue */ 27 break; 27 28 28 case 0:29 fprintf (stderr, "pipe has died!\n");30 return (FALSE);31 break;29 case 0: 30 fprintf (stderr, "pipe has died!\n"); 31 return (FALSE); 32 break; 32 33 33 case 4: 34 if (!strcmp (buffer, "NCUR")) { /* stop reading cursor */ 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); 35 42 return (TRUE); 36 } 37 break; 38 39 default: 40 fprintf (stderr, "weird signal: too many or few bytes! %d\n", status); 41 return (TRUE); 42 break; 43 break; 43 44 } 44 45 … … 53 54 switch (event.type) { 54 55 55 case MotionNotify:56 break;56 case MotionNotify: 57 break; 57 58 58 case Expose:59 if (HAVE_BACKING) {60 continue;61 }62 if (XEventsQueued (graphic.display, QueuedAlready) < 2) {63 Refresh (1);64 }65 break;59 case Expose: 60 if (HAVE_BACKING) { 61 continue; 62 } 63 if (XEventsQueued (graphic.display, QueuedAlready) < 2) { 64 Refresh (1); 65 } 66 break; 66 67 67 case ConfigureNotify:68 status = Reconfig (&event);69 break;68 case ConfigureNotify: 69 status = Reconfig (&event); 70 break; 70 71 71 case MappingNotify:72 XRefreshKeyboardMapping ((XMappingEvent *) &event);73 break;72 case MappingNotify: 73 XRefreshKeyboardMapping ((XMappingEvent *) &event); 74 break; 74 75 75 case KeyPress: 76 string[0] = 0; 77 value = XLookupString ((XKeyEvent *) &event, string, 9, &keysym, &composestatus); 78 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; 79 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; 80 if ((value > 0) && (isdigit(string[0]) || isalpha(string[0]))) { 81 sprintf (line, "%c %12.6f %12.6f ", string[0], x, y); 82 write (sock, line, 32); 83 } 84 break; 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; 84 85 case KeyPress: 86 value = XLookupString ((XKeyEvent *) &event, string, 9, &keysym, &composestatus); 87 name = XKeysymToString (keysym); 88 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; 91 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; 108 109 snprintf (line, 40, "%12s %12.6f %12.6f ", name, x, y); 110 write (sock, line, 40); 111 break; 85 112 } 86 113 } -
trunk/Ohana/src/kii/picture/cursor.c
r3464 r5349 10 10 int status; 11 11 XComposeStatus composestatus; 12 char string[10], line[ 500];12 char string[10], line[40], *name; 13 13 double x, y; 14 14 … … 35 35 if (LastEvent (display, MotionNotify, &event)) UpdatePointer (graphic, layout, (XMotionEvent *) &event); 36 36 if (LastEvent (display, ButtonPress, &event)) InterpretPresses (graphic, layout, (XButtonEvent *) &event); 37 38 37 if (LastEvent (display, KeyPress, &event)) { 39 38 status = XLookupString ((XKeyEvent *) &event, string, 9, &keysym, &composestatus); 40 39 41 if (!status) continue;42 40 if (event.xkey.x < layout[0].picture.x) continue; 43 41 if (event.xkey.x > layout[0].picture.x + layout[0].picture.dx) continue; … … 46 44 47 45 Screen_to_Image (&x, &y, (double)event.xkey.x, (double)event.xkey.y, layout); 46 name = XKeysymToString (keysym); 48 47 49 if (isprint(string[0])) 50 sprintf (line, "%c %6.1f %6.1f ", string[0], x, y); 51 else { 52 sprintf (line, "X %6.1f %6.1f ", x, y); 53 } 54 write (layout[0].Ximage, line, 16); 48 // skip the following keys: 49 if (!strcmp (name, "Shift_L")) continue; 50 if (!strcmp (name, "Shift_R")) continue; 51 if (!strcmp (name, "Control_L")) continue; 52 if (!strcmp (name, "Control_R")) continue; 53 if (!strcmp (name, "Alt_L")) continue; 54 if (!strcmp (name, "Alt_R")) continue; 55 if (!strcmp (name, "Super_L")) continue; 56 if (!strcmp (name, "Super_R")) continue; 57 if (!strcmp (name, "Caps_Lock")) continue; 58 if (!strcmp (name, "Pause")) continue; 59 if (!strcmp (name, "Continue")) continue; 60 if (!strcmp (name, "Num_Lock")) continue; 61 if (!strcmp (name, "Scroll_Lock")) continue; 62 if (!strcmp (name, "Print")) continue; 63 if (!strcmp (name, "(null)")) continue; 64 65 snprintf (line, 40, "%12s %12.6f %12.6f ", name, x, y); 66 write (layout[0].Ximage, line, 40); 55 67 } 56 68 } -
trunk/Ohana/src/opihi/cmd.data/cursor.c
r2843 r5349 3 3 int cursor (int argc, char **argv) { 4 4 5 char buffer[40], string[20], key ;5 char buffer[40], string[20], key[20], keyname[20]; 6 6 int i, N, Nsource, Source, IsImage; 7 7 double X, Y, R, D, Z; … … 49 49 Z = -1.0; 50 50 for (i = 0; ((i < N) || (N == 0)) && !interrupt; i++) { 51 bzero (buffer, 20); 52 read (Source, buffer, 32); 53 buffer[32] = 0; 54 sscanf (buffer, "%c %lf %lf", &key, &X, &Y); 55 56 sprintf (string, "X%1c", key); 51 bzero (buffer, 40); 52 read (Source, buffer, 40); 53 buffer[39] = 0; 54 sscanf (buffer, "%s %lf %lf", key, &X, &Y); 55 if (ispunct(key[0])) { 56 strcpy (keyname, "_"); 57 } else { 58 strcpy (keyname, key); 59 } 60 sprintf (string, "X%s", keyname); 57 61 set_variable (string, X); 58 sprintf (string, "Y% 1c", key);62 sprintf (string, "Y%s", keyname); 59 63 set_variable (string, Y); 60 sprintf (string, "%c", key); 61 set_str_variable ("KEY", string); 64 set_str_variable ("KEY", key); 62 65 63 66 if (IsImage && (buf != NULL)) … … 66 69 if (!IsImage) { 67 70 XY_to_RD (&R, &D, X, Y, &graphmode.coords); 68 sprintf (string, "R% 1c", key);71 sprintf (string, "R%s", keyname); 69 72 set_variable (string, R); 70 sprintf (string, "D% 1c", key);73 sprintf (string, "D%s", keyname); 71 74 set_variable (string, D); 72 75 } … … 74 77 /* I still don't like this, but I have to decide which to print... */ 75 78 if (IsImage) { 76 fprintf (GetOutfile(), "% c%f %f %f\n", key, X, Y, Z);79 fprintf (GetOutfile(), "%s %f %f %f\n", key, X, Y, Z); 77 80 } else { 78 fprintf (GetOutfile(), "% c%f %f\n", key, X, Y);81 fprintf (GetOutfile(), "%s %f %f\n", key, X, Y); 79 82 } 80 83 81 if ( (key == 'q') || (key == 'Q')) {84 if (!strcasecmp (key, "Q")) { 82 85 signal (SIGINT, (void *) oldsignal); 83 86 write (Source, "NCUR", 4); /* ask Source to stop looking for the keystrokes */
Note:
See TracChangeset
for help on using the changeset viewer.
