2
Clif - A C-like Interpreter Framework
3
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997 T. Hruz, L. Koren
5
This program is free software; you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation; either version 2 of the License, or
8
(at your option) any later version.
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
15
You should have received a copy of the GNU General Public License
16
along with this program; if not, write to the Free Software
17
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
* Alphanumerical window opening.
30
#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined(__STDC__)
31
#define PROTO(ARGS) ARGS
33
#define PROTO(ARGS) ()
37
extern char *callocx PROTO((unsigned, unsigned));
38
extern void error_message PROTO((int));
49
int wind_w PROTO((void));
55
char arg1[32], arg2[32];
58
if ((disp = XOpenDisplay (NULL)) == NULL)
60
printf (" XOpen fails write\n");
68
root = XDefaultRootWindow (disp);
69
screen = XDefaultScreen (disp);
72
if (!XGetWindowAttributes (disp, root, &root_window_att))
74
printf ("get window att failed \n");
78
XSynchronize (disp, 1);
81
width = XDisplayWidth (disp, screen);
83
XSynchronize (disp, 1);
85
height = XDisplayHeight (disp, screen);
87
XSynchronize (disp, 1);
88
printf ("w: %d, h: %d \n", width, height);
90
default_gc = XDefaultGC (disp, screen);
91
XSynchronize (disp, 1);
93
XSetState (disp, default_gc, 0xffffffL, 0L, GXcopy, 0xffffffffL);
94
XSynchronize (disp, 1);
95
printf ("xsetstate\n");
101
height_w = (((int)(channel[channel_handle].fields/5)) + 1) * 15;
108
mywin_att.background_pixmap = None;
109
mywin_att.background_pixel = 0L;
110
mywin_att.border_pixmap = CopyFromParent;
111
mywin_att.border_pixel = 1L;
112
mywin_att.bit_gravity = ForgetGravity;
113
mywin_att.win_gravity = NorthWestGravity;
114
mywin_att.backing_store = Always;
115
mywin_att.backing_planes = 0xffffffffL;
116
mywin_att.backing_pixel = 0L;
117
mywin_att.save_under = True;
118
mywin_att.event_mask = KeyPressMask|ExposureMask|ButtonPressMask|VisibilityChangeMask|SubstructureNotifyMask|StructureNotifyMask;
119
mywin_att.do_not_propagate_mask = NoEventMask;
120
mywin_att.override_redirect = False;
121
mywin_att.colormap = CopyFromParent;
122
mywin_att.cursor = None;
129
channel[channel_handle].mywin_write
130
= XCreateWindow (disp, root, x, y, width_w, height_w, border,
131
CopyFromParent, InputOutput, CopyFromParent,
132
CWBackPixel|CWSaveUnder|CWBackingStore|CWEventMask|CWBackingPlanes|CWDontPropagate,
139
* It is used when the exposure event occurs.
141
channel[channel_handle].mypix_write
142
= XCreatePixmap (disp, channel[channel_handle].mywin_write,
143
width_w, height_w, XDefaultDepth (disp, screen));
146
XSynchronize (disp, 1);
147
printf ("xcreatewritewindow\n");
150
value.background = 0L;
151
value.graphics_exposures = True;
152
value.foreground = 0xffffffL;
154
set_gc_write = XCreateGC (disp, channel[channel_handle].mywin_write,
155
GCForeground|GCBackground|GCGraphicsExposures,
160
XClearWindow (disp, channel[channel_handle].mywin_write);
162
XFillRectangle (disp, channel[channel_handle].mypix_write,
164
channel[channel_handle].w_resolution[0],
165
channel[channel_handle].w_resolution[1]);
168
XSynchronize (disp, 1);
172
* Name of the window.
174
sprintf (window_name_tmp, "%d", channel_handle);
175
strcat (window_name_wr_cur, window_name_tmp);
176
XStoreName (disp, channel[channel_handle].mywin_write,
178
strcpy (window_name_wr_cur, window_name_wr_init);
180
XSynchronize (disp, 1);
181
printf ("xstowriterename\n");
184
XMapWindow (disp, channel[channel_handle].mywin_write);
186
XSynchronize (disp, 1);
187
printf ("xmapwritewindow\n");
190
XSynchronize (disp, 1);
193
channel[channel_handle].item.chars=" ";
194
channel[channel_handle].item.nchars
195
= strlen (channel[channel_handle].item.chars);
198
channel[channel_handle].item.delta = 1;
199
channel[channel_handle].item.font = None;
202
printf ("item filled\n");
208
XSetFontPath (disp, &path, 0);
210
printf ("xsetfontpath\n");
213
if ((act_cnt = (int *) callocx (1, sizeof(int))) == NULL)
215
error_message (4002);
218
while (*act_cnt == 0)
219
list = XListFonts (disp, "*", 10, act_cnt);
222
printf ("xlistfonts\n");
225
channel[channel_handle].item.font = XLoadFont (disp, list[0]);
227
printf ("xloadfont\n");
229
channel[channel_handle].myfont
230
= XQueryFont (disp, channel[channel_handle].item.font);
232
printf ("xqueryfont\n");
237
* Fork for managers that cannot manage exposure events.
240
if ((channel[channel_handle].ch_pid_write = fork ()) < 0)
241
printf ("could not fork %d\n", errno);
242
else if(channel[channel_handle].ch_pid_write == 0) /* child */
244
sprintf (arg1, "%ld", channel[channel_handle].mywin_write);
245
sprintf (arg2, "%ld", channel[channel_handle].mypix_write);
247
printf ("fork child\n");
249
execl ("rw", "rw", arg1, arg2, (char *)0);
250
printf ("errno %d\n", errno);
251
printf ("bad exec\n");
254
#endif /* FORK_YES */