slehar@park.bu.edu (Steve Lehar) (02/15/91)
I wrote an X program to work something like "talk" except that you can send sketches to the other window by dragging the mouse. The program ran VERY slowly presumably because one cpu had to manage both windows on two machines. To get around this problem, I tried the following... open a pair of pipes fork() into two processes open an xwindow (in each process) exchange display, window & gc identifiers through the pipes event loop: if event == mouse drag, then draw a line on this window draw a line on the other window (using piped identifiers) . . . end loop That way each process would pay attention only to it's own window input, but would send output to both. The technique works fine if both windows are on the same display, but if I try sending to another display on another machine, the graphics only appears locally and never arrives in the other window, although that window does appear. To get around the problem, I tried something else. Instead of drawing on the other window, I sent a ClientMessage to the other window with the coordinates to draw, so the loop now looked like this... event loop: if event == mouse drag, then draw a line on this window send a ClientMessage to the other window with line coordinates if event == ClientMessage, then draw a line on this window using the ClientMessage coordinates . . . end loop Now each process was only drawing on it's own window, although they still exchanged display and window id's in order to target the ClientMessage properly. Again, the system worked fine on a single display, but would not work on different displays. The remote display RECEIVED THE CLIENT MESSAGE with the proper coordinates, but still could not display them on it's own window! My suspicion is that the fork() screws up the xwindow pointers somehow. Is this true? Should a fork() NEVER be used in an x window application? And if this is the case, how do you get separate processes to communicate through X? I have consulted a number of X books on this question without success. Anyone know the answer? -- (O)((O))(((O)))((((O))))(((((O)))))(((((O)))))((((O))))(((O)))((O))(O) (O)((O))((( slehar@park.bu.edu )))((O))(O) (O)((O))((( Steve Lehar Boston University Boston MA )))((O))(O) (O)((O))((( (617) 424-7035 (H) (617) 353-6741 (W) )))((O))(O) (O)((O))(((O)))((((O))))(((((O)))))(((((O)))))((((O))))(((O)))((O))(O)