29 Display *d = XOpenDisplay(dispnm);
41 screen = DefaultScreen(d);
42 dw = DisplayWidth(d, screen);
43 dh = DisplayHeight(d, screen);
46 xw.
window = XCreateSimpleWindow
47 (d, RootWindow(d, screen),
48 dw / 3, dh / 3, 350, dh / 4, 4,
49 BlackPixel(d, screen), WhitePixel(d, screen));
52 XSetStandardProperties
53 (d, xw.
window, wintitle,
"Doodle", None, 0, 0, 0);
62 xw.
gc = XCreateGC(d, xw.
window, 0L, &values);
65 XSetForeground(d, xw.
gc, BlackPixel(d, screen));
75 return XCloseDisplay(xw.
display);
85 coord->
x1, coord->
y1, coord->
x2, coord->
y2);
105 Window rootw, childw;
106 int rootx, rooty, wx, wy;
107 unsigned int keys_buttons;
108 static XPoint points[2000] = { {0}, {0} };
109 static int index = 0;
111 if (pending && !XPending(xw.
display)) {
115 XNextEvent(xw.
display, &report);
116 switch (report.type) {
124 if (report.xbutton.button == 3)
128 while (XCheckMaskEvent
130 PointerMotionMask | ButtonMotionMask,
136 (xw.
display, report.xmotion.window,
137 &rootw, &childw, &rootx, &rooty, &wx, &wy, &keys_buttons);
139 newseg->
x1 = points[index].x;
140 newseg->
y1 = points[index].y;
146 newseg->
x2 = points[index].x = wx;
147 newseg->
y2 = points[index].y = wy;
148 return report.xbutton.button;
165 if (p == NULL)
return 0;
175 if (
'A' <= c && c <=
'F') d = (long)(c + 10 -
'A');
176 if (
'a' <= c && c <=
'f') d = (long)(c + 10 -
'a');
178 if (
'0' <= c && c <=
'9') d = (long)(c -
'0');
182 if (sign ==
'-') x = -x;
196 int main(
int argc,
char *argv[],
char **envp)
198 OneLn seg = { 0, 0, 100, 100, 0 };
203 "usage: %s <display-hostname> <color-number> <window-title>\n",
212 printf(
"openxwindow(%s, %s, %s) returned %d\n",
213 argv[1], argv[2], argv[3], b);
215 printf(
"press button 3 (Right) to terminate; color %ld", seg.
color);
219 printf(
"line from (%2d, %2d) to (%2d, %2d) button %d\n",
int trackpointer(OneLn *newseg, int pending)
int openxwindow(char dispnm[], char wintitle[])
int main(int argc, char *argv[])
long atoir(char *p, int r)
void drawline(OneLn *coord)