Wild Life  2.29
 All Data Structures Files Functions Variables Typedefs Macros
xpred.c
Go to the documentation of this file.
1 /* Copyright 1991 Digital Equipment Corporation.
2  ** Distributed only by permission.
3  **
4  ** Last modified on Wed Mar 2 11:32:59 MET 1994 by rmeyer
5  ** modified on Fri Jan 28 14:24:13 MET 1994 by dumant
6  ** modified on Thu Jun 24 06:55:40 1993 by Rmeyer
7  ** modified on Thu Nov 26 20:13:50 1992 by herve
8  *****************************************************************/
9 /* $Id: xpred.c,v 1.4 1997/07/18 14:50:52 duchier Exp $ */
10 
11 #ifdef X11
12 
13 #include "defs.h"
14 
15 // long x_postscript_window (Display *, Window, ListHeader *, char*);
16 // void raw_setup_builtins();
17 // void interrupt();
18 
19 /*****************************************/
20 
21 
22 #define stdin_fileno fileno(stdin)
23 #define CR 0x0d
24 #define BS 0x08
25 
26 
27 /* a closure for enum xevents_list */
28 typedef struct wl_EventClosure
29 {
30  Display *display;
31  Window window;
32  long mask;
33  ptr_psi_term beginSpan;
34 } EventClosure;
35 
36 
37 /*****************************************/
38 
39 
42 
45 
46  xenter_event,xleave_event,xmisc_event,/* RM: 3rd May 93 */
47 
50 
51 
53 
54 /*****************************************/
55 
56 static long xevent_mask[] = {
57 0, /* ??? 0 */
58 0, /* ??? 1 */
59 KeyPressMask, /* KeyPress 2 */
60 KeyReleaseMask, /* KeyRelease 3 */
61 ButtonPressMask, /* ButtonPress 4 */
62 ButtonReleaseMask, /* ButtonRelease 5 */
63 
64 PointerMotionMask | PointerMotionHintMask | ButtonMotionMask |
65 Button1MotionMask | Button2MotionMask | Button3MotionMask |
66 Button4MotionMask | Button5MotionMask,
67  /* MotionNotify 6 */
68 EnterWindowMask, /* EnterNotify 7 */
69 LeaveWindowMask, /* LeaveNotify 8 */
70 FocusChangeMask, /* FocusIn 9 */
71 FocusChangeMask, /* FocusOut 10 */
72 KeymapStateMask, /* KeymapNotify 11 */
73 ExposureMask, /* Expose 12 */
74 0, /* GraphicsExpose 13 */
75 0, /* NoExpose 14 */
76 VisibilityChangeMask, /* VisibilityNotify 15 */
77 SubstructureNotifyMask, /* CreateNotify 16 */
78 SubstructureNotifyMask, /* DestroyNotify 17 */
79 StructureNotifyMask, /* UnmapNotify 18 */
80 StructureNotifyMask, /* MapNotify 19 */
81 SubstructureRedirectMask, /* MapRequest 20 */
82 SubstructureNotifyMask, /* ReparentNotify 21 */
83 StructureNotifyMask, /* ConfigureNotify 22 */
84 SubstructureRedirectMask, /* ConfigureRequest 23 */
85 StructureNotifyMask, /* GravityNotify 24 */
86 ResizeRedirectMask, /* ResizeRequest 25 */
87 StructureNotifyMask, /* CirculateNotify 26 */
88 SubstructureRedirectMask, /* CirculateRequest 27 */
89 PropertyChangeMask, /* PropertyNotify 28 */
90 0, /* SelectionClear 29 */
91 0, /* SelectionRequest 30 */
92 0, /* SelectionNotify 31 */
93 ColormapChangeMask, /* ColormapNotify 32 */
94 0, /* ClientMessage 33 */
95 0 /* MappingNotify 34 */
96 };
97 
98 
99 
100 static char* xevent_name[] = {
101  "???",
102  "???",
103  "KeyPress",
104  "KeyRelease",
105  "ButtonPress",
106  "ButtonRelease",
107  "MotionNotify",
108  "EnterNotify",
109  "LeaveNotify",
110  "FocusIn",
111  "FocusOut",
112  "KeymapNotify",
113  "Expose",
114  "GraphicsExpose",
115  "NoExpose",
116  "VisibilityNotify",
117  "CreateNotify",
118  "DestroyNotify",
119  "UnmapNotify",
120  "MapNotify",
121  "MapRequest",
122  "ReparentNotify",
123  "ConfigureNotify",
124  "ConfigureRequest",
125  "GravityNotify",
126  "ResizeRequest",
127  "CirculateNotify",
128  "CirculateRequest",
129  "PropertyNotify",
130  "SelectionClear",
131  "SelectionRequest",
132  "SelectionNotify",
133  "ColormapNotify",
134  "ClientMessage",
135  "MappingNotify"
136 };
137 
138 
139 
140 
141 /*****************************************************************/
142 /* Macros */
143 
144 #define DrawableGC(w)(GC)GetIntAttr(GetPsiAttr(w,"graphic_context"),"id")
145 #define WindowDisplayList(w) GetIntAttr(GetPsiAttr(w,"display_list"),"id")
146 
147 /* Macros to keep GCC happy. RM: Feb 9 1994 */
148 #define DISP(X)(Display *)val[X]
149 #define DRAW(X)(Drawable)val[X]
150 #define WIND(X)(Window)val[X]
151 #define GCVAL(X)(GC)val[X]
152 #define FONT(X)(Font)val[X]
153 #define CMAP(X)(Colormap)val[X]
154 #define STRG(X) ((char *)val[X])
155 
156 
157 
158 /*****************************************************************/
159 /* Static */
160 /* handle the errors X */
161 
162 
163 static int x_handle_error(display,x_error)
164  Display *display;
165  XErrorEvent *x_error;
166 {
167  char msg[128];
168  XGetErrorText(display,x_error->error_code,msg,128);
169  Errorline("X error message: %s.\n",msg);
170  /* don't use abort_life(TRUE) because it tries to destroy windows ...
171  and loops because the window is yet in the stack !!
172  jch - Fri Aug 7 17:58:27 MET DST 1992
173  */
174  exit_life(TRUE);
175 }
176 
177 
178 static int x_handle_fatal_error(display)
179  Display *display;
180 {
181  Errorline("fatal X Error.\n");
182  exit_life(TRUE);
183 }
184 
185 
186 /* RM: Jun 24 1993 */
187 /* JCH didn't understand ANYTHING about trailing! */
188 
189 void bk_stack_add_int_attr(t,attrname,value)
190  ptr_psi_term t;
191  char *attrname;
192  long value;
193 {
194  ptr_psi_term t1;
195  ptr_node n;
196  char *perm;
197 
198 
199  perm=(char *)heap_copy_string(attrname);
200  n=find(FEATCMP,perm,t->attr_list);
201  if(n) {
202  t1=(ptr_psi_term)n->data;
203  deref_ptr(t1);
204  if(!t1->value_3) {
206  t1->value_3=heap_alloc(sizeof(REAL));
207  }
208  *(REAL *)t1->value_3 =(REAL) value;
209  }
210  else {
211  t1=stack_psi_term(4);
212  t1->type=integer;
213  t1->value_3=heap_alloc(sizeof(REAL));
214  *(REAL *)t1->value_3 =(REAL) value;
215  bk_stack_insert(FEATCMP,perm,&(t->attr_list),(GENERIC)t1);
216  }
217 }
218 
219 
220 void bk_change_psi_attr(t,attrname,value)
221  ptr_psi_term t;
222  char *attrname;
223  ptr_psi_term value;
224 {
225  ptr_psi_term t1;
226  ptr_node n;
227  char *perm;
228 
229 
230  perm=(char *)heap_copy_string(attrname);
231  n=find(FEATCMP,perm,t->attr_list);
232  if(n) {
233  t1=(ptr_psi_term)n->data;
234  deref_ptr(t1);
235  *t1= *value;
236  /*push_ptr_value(psi_term_ptr,(GENERIC *)&(t1->coref));*/
237  if(value!=t1)
238  value->coref=t1;
239  }
240  else
241  bk_stack_insert(FEATCMP,perm,&(t->attr_list),(GENERIC)value);
242 }
243 
244 
245 
246 
247 
248 /*****************************************************************/
249 /* Utility */
250 /* unify psi_term T to the integer value V */
251 /* could be in builtins.c */
252 
253 long unify_int_result(t,v)
254  ptr_psi_term t;
255  long v;
256 {
257  long smaller;
258  long success=TRUE;
259 
260 
261  deref_ptr(t);
262  push_ptr_value(int_ptr,(GENERIC *)&(t->value_3));
263  t->value_3 = heap_alloc(sizeof(REAL));
264  *(REAL *) t->value_3 = v;
265 
266  matches(t->type,integer,&smaller);
267 
268  if(!smaller)
269  {
270  push_ptr_value(def_ptr,(GENERIC *)&(t->type));
271  t->type = integer;
272  t->status = 0;
273  }
274  else
275  success = FALSE;
276 
277  if(success)
278  {
279  i_check_out(t);
280  if(t->resid)
281  release_resid(t);
282  }
283 
284  return success;
285 }
286 
287 
288 /*****************************************************************/
289 /* Static */
290 /* build a psi-term of type t with a feature f of value v */
291 
292 static ptr_psi_term NewPsi(t,f,v)
293  ptr_definition t;
294  char * f;
295  long v;
296 {
297  ptr_psi_term p;
298 
299  p = stack_psi_term(4);
300  p->type = t;
301  bk_stack_add_int_attr(p,f,v);
302  return p;
303 }
304 
305 
306 /*****************************************************************/
307 /* Utilities */
308 /* return the value of the attribute attributeName on the psi-term psiTerm */
309 
310 long GetIntAttr(psiTerm,attributeName)
311 
312  ptr_psi_term psiTerm;
313  char *attributeName;
314 {
315  ptr_node nodeAttr;
316  ptr_psi_term psiValue;
317 
318 
319  deref_ptr(psiTerm);
320  nodeAttr=find(FEATCMP,attributeName,psiTerm->attr_list);
321  if(!nodeAttr) {
322  Errorline("in GetIntAttr: didn't find %s on %P\n",
323  attributeName,
324  psiTerm);
325  exit_life(TRUE);
326  }
327 
328  psiValue=(ptr_psi_term)nodeAttr->data;
329  deref_ptr(psiValue);
330  if(psiValue->value_3)
331  return *(REAL *) psiValue->value_3;
332  else {
333  /* Errorline("in GetIntAttr: no value!\n"); */
334  return -34466; /* Real nasty hack for now RM: Apr 23 1993 */
335  }
336 }
337 
338 
339 
340 /*****************************************************************/
341 /* Utilities */
342 /* return the psi-term of the attribute attributeName on the psi-term psiTerm */
343 
344 ptr_psi_term GetPsiAttr(psiTerm,attributeName)
345 
346  ptr_psi_term psiTerm;
347  char *attributeName;
348 {
349  ptr_node nodeAttr;
350  ptr_psi_term psiValue;
351 
352 
353  if((nodeAttr = find(FEATCMP,attributeName,psiTerm->attr_list)) == NULL)
354  {
355  Errorline("in GetPsiAttr: no attribute name on psi-term ?\n");
356  exit_life(TRUE);
357  }
358 
359  if((psiValue =(ptr_psi_term) nodeAttr->data) == NULL)
360  {
361  Errorline("in GetPsiAttr: no value on psi-term ?\n");
362  exit_life(TRUE);
363  }
364 
365  return psiValue;
366 }
367 
368 /*****************************************************************/
369 /* Static */
370 /* resize the pixmap of the window */
371 
372 static void ResizePixmap(psi_window,display,window,width,height)
373 
374  ptr_psi_term psi_window;
375  Display *display;
376  Window window;
377  unsigned long width,height;
378 {
379  Pixmap pixmap;
380  GC pixmapGC;
381  ptr_psi_term psiPixmap,psiPixmapGC;
382  XGCValues gcvalues;
383  XWindowAttributes attr;
384  ptr_psi_term psi_gc;
385 
386 
387  /* free the old pixmap */
388  psiPixmap = GetPsiAttr(psi_window,"pixmap");
389  psiPixmapGC=NULL;
390 
391  if((pixmap = GetIntAttr(psiPixmap,"id")) != 0)
392  {
393  /* change the pixmap */
394  XFreePixmap(display,pixmap);
395  /* change the pixmap'gc too,because the gc is created on the pixmap ! */
396 
397  psiPixmapGC = GetPsiAttr(psiPixmap,"graphic_context");
398 
399  /* RM: Jun 24 1993 */
400  pixmapGC=(GC)GetIntAttr(psiPixmapGC,"id");
401  if(pixmapGC)
402  XFreeGC(display,pixmapGC);
403 
404  bk_stack_add_int_attr(psiPixmap,"id",(long)NULL);
405  bk_stack_add_int_attr(psiPixmapGC,"id",(long)NULL);
406  }
407 
408  /* init a new pixmap on the window */
409  XGetWindowAttributes(display,window,&attr);
410  if((pixmap = XCreatePixmap(display,window,
411  attr.width+1,attr.height+1,
412  attr.depth)) != 0)
413  {
414  bk_stack_add_int_attr(psiPixmap,"id",pixmap);
415  gcvalues.cap_style = CapRound;
416  gcvalues.join_style = JoinRound;
417  pixmapGC = XCreateGC(display,pixmap,
418  GCJoinStyle|GCCapStyle,&gcvalues);
419 
420  /* RM: Jun 24 1993 */
421  if(psiPixmapGC)
422  bk_stack_add_int_attr(psiPixmapGC,"id",(long)pixmapGC);
423  else
424  psiPixmapGC=NewPsi(xgc,"id",pixmapGC);
425  bk_change_psi_attr(psiPixmap,"graphic_context",psiPixmapGC);
426  }
427 }
428 
429 
430 /*****************************************************************/
431 /* Static */
432 /* free all attributes of a window,that is: its display list,its gc,
433  its pixmap ... */
434 
435 static void FreeWindow(display,psi_window)
436 
437  Display *display;
438  ptr_psi_term psi_window;
439 
440 {
441  ptr_psi_term psiPixmap;
442 
443 
444  XFreeGC(display,DrawableGC(psi_window));
445  x_free_display_list((ListHeader *)WindowDisplayList(psi_window));
446 
447  psiPixmap = GetPsiAttr(psi_window,"pixmap");
448  XFreeGC(display,DrawableGC(psiPixmap));
449  XFreePixmap(display,GetIntAttr(psiPixmap,"id"));
450 }
451 
452 
453 /*****************************************************************/
454 /******** xcOpenConnection
455 
456  xcOpenConnection(+Name,-Connection)
457 
458  open a connection to the X server.
459 
460  */
461 
462 long xcOpenConnection()
463 
464 {
466  ptr_definition types[2];
467  char *display;
468  Display * connection;
469  ptr_psi_term psiConnection;
470 
471 
472  types[0] = quoted_string;
473  types[1] = xdisplay;
474 
475 
476  begin_builtin(xcOpenConnection,2,1,types);
477 
478  if(strcmp(STRG(0),""))
479  display =STRG(0);
480  else
481  display = NULL;
482 
483  if(connection = XOpenDisplay(display))
484  {
485  psiConnection = NewPsi(xdisplay,"id",connection);
486  push_goal(unify,psiConnection,args[1],NULL);
487 
488  success = TRUE;
489  }
490  else
491  {
492  Errorline("could not open connection in %P.\n",g);
493  success = FALSE;
494  }
495 
496  end_builtin();
497 }
498 
499 
500 /*****************************************************************/
501 /******** xcDefaultRootWindow
502 
503  xcDefaultRootWindow(+Display,-Root)
504 
505  return the root window of the given display
506 
507  */
508 
509 long xcDefaultRootWindow()
510 
511 {
513  ptr_definition types[2];
514  Display *display;
515  ptr_psi_term psiRoot;
516 
517 
518  types[0] = real;
519  types[1] = xdrawable;
520 
521  begin_builtin(xcDefaultRootWindow,2,1,types);
522 
523  display = DISP(0);
524 
525  psiRoot = NewPsi(xwindow,"id",DefaultRootWindow(display));
526 
527  push_goal(unify,psiRoot,args[1],NULL);
528  success = TRUE;
529 
530  end_builtin();
531 }
532 
533 
534 
535 /*****************************************************************/
536 /******** static GetConnectionAttribute */
537 
538 static long GetConnectionAttribute(display,attributeId,attribute)
539 
540  Display *display;
541  long attributeId,*attribute;
542 
543 {
544  switch(attributeId)
545  {
546  case 0:
547  *attribute =(unsigned long) ConnectionNumber(display);
548  break;
549  case 1:
550 #ifndef __alpha
551  *attribute = display->proto_major_version;
552 #endif
553  break;
554  case 2:
555 #ifndef __alpha
556  *attribute =(unsigned long)(display->proto_minor_version);
557 #endif
558  break;
559  case 3:
560  *attribute =(unsigned long) ServerVendor(display);
561  break;
562  case 4:
563  *attribute =(unsigned long) ImageByteOrder(display);
564  break;
565  case 5:
566  *attribute =(unsigned long) BitmapUnit(display);
567  break;
568  case 6:
569  *attribute =(unsigned long) BitmapPad(display);
570  break;
571  case 7:
572  *attribute =(unsigned long) BitmapBitOrder(display);
573  break;
574  case 8:
575  *attribute =(unsigned long) VendorRelease(display);
576  break;
577  case 9:
578 #ifndef __alpha
579  *attribute =(unsigned long)(display->qlen);
580 #endif
581  break;
582  case 10:
583  *attribute =(unsigned long) LastKnownRequestProcessed(display);
584  break;
585  case 11:
586 #ifndef __alpha
587  *attribute =(unsigned long)(display->request);
588 #endif
589  break;
590  case 12:
591  *attribute =(unsigned long) DisplayString(display);
592  break;
593  case 13:
594  *attribute =(unsigned long) DefaultScreen(display);
595  break;
596  case 14:
597 #ifndef __alpha
598  *attribute =(unsigned long)(display->min_keycode);
599 #endif
600  break;
601  case 15:
602 #ifndef __alpha
603  *attribute =(unsigned long)(display->max_keycode);
604 #endif
605  break;
606  default:
607  return FALSE;
608  break;
609  }
610 
611  return TRUE;
612 }
613 
614 
615 long xcQueryTextExtents(); /* RM: Apr 20 1993 */
616 
617 
618 /*****************************************************************/
619 /******** xcGetConnectionAttribute
620 
621  xcGetConnectionAttribute(+Display,+AttributeId,-Value)
622 
623  returns the value corresponding to the attribute id.
624 
625  */
626 
627 long xcGetConnectionAttribute()
628 
629 {
631  ptr_definition types[3];
632  long attr;
633 
634 
635  types[0] = real;
636  types[1] = real;
637  types[2] = real;
638 
639  begin_builtin(xcGetConnectionAttribute,3,2,types);
640 
641  if(GetConnectionAttribute(DISP(0),DRAW(1),&attr))
642  {
643  unify_real_result(args[2],(REAL) attr);
644  success = TRUE;
645  }
646  else
647  {
648  Errorline("could not get connection attribute in %P.\n",g);
649  success = FALSE;
650  }
651 
652  end_builtin();
653 }
654 
655 
656 /*****************************************************************/
657 /******** GetScreenAttribute */
658 
659 static long GetScreenAttribute(display,screen,attributeId,attribute)
660 
661  Display *display;
662  long screen,attributeId,*attribute;
663 
664 {
665  Screen *s;
666 
667 
668  s = ScreenOfDisplay(display,screen);
669  switch(attributeId)
670  {
671  case 0:
672  *attribute =(unsigned long) DisplayOfScreen(s);
673  break;
674  case 1:
675  *attribute =(unsigned long) RootWindowOfScreen(s);
676  break;
677  case 2:
678  *attribute =(unsigned long) WidthOfScreen(s);
679  break;
680  case 3:
681  *attribute =(unsigned long) HeightOfScreen(s);
682  break;
683  case 4:
684  *attribute =(unsigned long) WidthMMOfScreen(s);
685  break;
686  case 5:
687  *attribute =(unsigned long) HeightMMOfScreen(s);
688  break;
689  case 6:
690  *attribute =(unsigned long) DefaultDepthOfScreen(s);
691  break;
692  case 7:
693  *attribute =(unsigned long) DefaultVisualOfScreen(s);
694  break;
695  case 8:
696  *attribute =(unsigned long) DefaultGCOfScreen(s);
697  break;
698  case 9:
699  *attribute =(unsigned long) DefaultColormapOfScreen(s);
700  break;
701  case 10:
702  *attribute =(unsigned long) WhitePixelOfScreen(s);
703  break;
704  case 11:
705  *attribute =(unsigned long) BlackPixelOfScreen(s);
706  break;
707  case 12:
708  *attribute =(unsigned long) MaxCmapsOfScreen(s);
709  break;
710  case 13:
711  *attribute =(unsigned long) MinCmapsOfScreen(s);
712  break;
713  case 14:
714  *attribute =(unsigned long) DoesBackingStore(s);
715  break;
716  case 15:
717  *attribute =(unsigned long) DoesSaveUnders(s);
718  break;
719  case 16:
720  *attribute =(unsigned long) EventMaskOfScreen(s);
721  break;
722  default:
723  return FALSE;
724  break;
725  }
726 
727  return TRUE;
728 }
729 
730 
731 /*****************************************************************/
732 /******** xcGetScreenAttribute
733 
734  xcGetScreenAttribute(+Display,+Screen,+AttributeId,-Value)
735 
736  returns the value corresponding to the attribute id.
737 
738  */
739 
740 long xcGetScreenAttribute()
741 
742 {
744  ptr_definition types[4];
745  long attr;
746 
747 
748  types[0] = real;
749  types[1] = real;
750  types[2] = real;
751  types[3] = real;
752 
753  begin_builtin(xcGetScreenAttribute,4,3,types);
754 
755  if(GetScreenAttribute(DISP(0),DRAW(1),val[2],&attr))
756  {
757  unify_real_result(args[3],(REAL) attr);
758  success = TRUE;
759  }
760  else
761  {
762  Errorline("could not get screen attribute in %P.\n",g);
763  success = FALSE;
764  }
765 
766  end_builtin();
767 }
768 
769 
770 /*****************************************************************/
771 /******** xcCloseConnection
772 
773  xcCloseConnection(+Connection)
774 
775  Close the connection.
776 
777  */
778 
779 long xcCloseConnection()
780 
781 {
783  ptr_definition types[1];
784 
785 
786  types[0] = real;
787 
788  begin_builtin(xcCloseConnection,1,1,types);
789 
790  XCloseDisplay(DISP(0));
791  success = TRUE;
792 
793  end_builtin();
794 }
795 
796 
797 
798 /*****************************************************************/
799 /******** xcCreateSimpleWindow
800 
801  xcCreateSimpleWindow(+Display,+Parent,+X,+Y,+Width,+Height,
802  +BackGroundColor,+WindowTitle,+IconTitle,
803  +BorderWidth,+BorderColor,
804  +Permanent,+Show,-Window)
805 
806  create a simple window.
807 
808  */
809 
810 long xcCreateSimpleWindow()
811 
812 {
814  ptr_definition types[14];
815  Window window;
816  Pixmap life_icon;
817  XSizeHints hints;
818  XWindowChanges changes;
819  unsigned long changesMask;
820  XSetWindowAttributes attributes;
821  unsigned long attributesMask;
822  long j;
823  long permanent,show;
824  Display *display;
825  GC gc;
826  XGCValues gcvalues;
827  ptr_psi_term psiWindow;
828 
829 
830  for(j = 0; j < 14; j++)
831  types[j] = real;
832  types[7]= quoted_string;
833  types[8]= quoted_string;
834  types[11]= boolean;
835  types[12]= boolean;
836 
837  begin_builtin(xcCreateSimpleWindow,14,13,types);
838 
839  permanent = val[11];
840  show = val[12];
841 
842  if(window = XCreateSimpleWindow(DISP(0),WIND(1),/* display,parent */
843  val[2],val[3],/* X,Y */
844  val[4],val[5],/* Width,Height */
845  val[9],val[10],/* BorderWidth,BorderColor */
846  val[6])) /* BackGround */
847  {
848  psiWindow = stack_psi_term(4);
849  psiWindow->type = xwindow;
850  bk_stack_add_int_attr(psiWindow,"id",window);
851 
852  /* attach the icon of life */
853  life_icon = XCreateBitmapFromData(DISP(0),window,life_icon_bits,
854  life_icon_width,life_icon_height);
855  /* set properties */
856 #if 0
857  hints.x = val[2];
858  hints.y = val[3];
859  hints.width =val[4] ;
860  hints.height = val[5];
861  hints.flags = PPosition | PSize;
862 #endif
863  hints.flags = 0;
864  XSetStandardProperties(DISP(0),window,
865  STRG(7),STRG(8),
866  life_icon,arg_v,arg_c,
867  &hints);
868 #if 0
869  changes.x = val[2];
870  changes.y = val[3];
871  changes.width =val[4] ;
872  changes.height = val[5];
873  changesMask = CWX | CWY | CWWidth | CWHeight;
874  display = DISP(0);
875  XReconfigureWMWindow(DISP(0),window,DefaultScreen(display),
876  changesMask,&changes);
877 #endif
878  /* set the background color */
879  XSetWindowBackground(DISP(0),window,val[6]);
880 #if 0
881  /* set the geometry before to show the window */
882  XMoveResizeWindow(DISP(0),window,
883  val[2],val[3],val[4],val[5]);
884 #endif
885  /* set the back pixel in order to have the color when deiconify */
886  attributes.background_pixel = val[6];
887  attributes.backing_pixel = val[6];
888  attributesMask = CWBackingPixel|CWBackPixel;
889  XChangeWindowAttributes(DISP(0),window,
890  attributesMask,&attributes);
891 
892  if(!permanent)
893  {
894  push_window(destroy_window,(long)DISP(0),window);
896  }
897  else
898  if(show)
899  push_window(show_window,(long)DISP(0),window);
900 
901 #if 0
902  /* map window is made in xCreateWindow(see xpred.lf) */
903  /* due to the flag overrideRedirect */
904  if(show)
905  x_show_window(DISP(0),window);
906 #endif
907 
908  /* create a GC on the window for the next outputs */
909  gcvalues.cap_style = CapRound;
910  gcvalues.join_style = JoinRound;
911  gc = XCreateGC(DISP(0),window,GCJoinStyle|GCCapStyle,&gcvalues);
912  bk_change_psi_attr(psiWindow,"graphic_context",
913  NewPsi(xgc,"id",gc));
914 
915  /* init a display list on the window for the refresh window */
916  bk_change_psi_attr(psiWindow,"display_list",
917  NewPsi(xdisplaylist,"id",x_display_list()));
918 
919  /* init a pixmap on the window for the refresh mechanism */
920  bk_change_psi_attr(psiWindow,"pixmap",
921  NewPsi(xpixmap,"id",NULL));
922  ResizePixmap(psiWindow,DISP(0),window,val[4],val[5]);
923 
924  push_goal(unify,psiWindow,args[13],NULL);
925  success = TRUE;
926  }
927  else
928  {
929  Errorline("could not create a simple window in %P.\n",g);
930  success = FALSE;
931  }
932 
933  end_builtin();
934 }
935 
936 
937 /*****************************************************************/
938 #if 0
939 
940 xcCreateWindow is not used anymore since we use xcCreateSimpleWindow.
941  I just keep this code in case - jch - Thu Aug 6 16:11:23 MET DST 1992
942 
943  /******** xcCreateWindow
944 
945  xcCreateWindow(+Connection,+Parent,+X,+Y,+Width,+Height,
946  +BorderWidth,+Depth,+Class,+Visual,
947  +Permanent,+Show,-Window)
948 
949  create a window on the display Connection.
950 
951  */
952 
953  long xcCreateWindow()
954 
955 {
957  ptr_definition types[13];
958  Window window;
959  XWindowChanges changes;
960  unsigned long changesMask;
961  XSizeHints hints;
962  long j,permanent,show;
963  GC gc;
964  XGCValues gcvalues;
965 
966 
967  for(j = 0; j < 13; j++)
968  types[j] = real;
969 
970  begin_builtin(xcCreateWindow,13,12,types);
971 
972  permanent = val[10];
973  show = val[11];
974 
975  if(window = XCreateWindow(DISP(0),WIND(1),/* display,parent */
976  val[2],val[3],/* X,Y */
977  val[4],val[5],/* Width,Height */
978  val[6],val[7],/* BorderWidth,Depth */
979  val[8],val[9],/* Class,Visual */
980  0,(XSetWindowAttributes *) NULL))
981  {
982  unify_real_result(args[12],(REAL) window);
983 
984  changes.x = val[2];
985  changes.y = val[3];
986  changes.width =val[4] ;
987  changes.height = val[5];
988  changesMask = CWX | CWY | CWWidth | CWHeight;
989  XConfigureWindow(DISP(0),window,changesMask,&changes);
990 
991  hints.x = val[2];
992  hints.y = val[3];
993  hints.width =val[4] ;
994  hints.height = val[5];
995  hints.flags = PPosition | PSize;
996  XSetNormalHints(DISP(0),window,&hints);
997 
998  if(!permanent)
999  {
1000  push_window(destroy_window,DISP(0),window);
1002  }
1003  else
1004  if(show)
1005  push_window(show_window,DISP(0),window);
1006 
1007  if(show)
1008  x_show_window(DISP(0),window);
1009 
1010  /* create a GC on the window for the next outputs */
1011  gcvalues.cap_style = CapRound;
1012  gcvalues.join_style = JoinRound;
1013  gc = XCreateGC(DISP(0),window,GCJoinStyle|GCCapStyle,&gcvalues);
1014  bk_stack_add_int_attr(args[12],"gc",gc);
1015 
1016  /* init a display list on the window for the refresh window */
1017  bk_stack_add_int_attr(args[12],"display_list",NULL);
1018 
1019  success = TRUE;
1020  }
1021  else
1022  {
1023  Errorline("could not create window in %P.\n",g);
1024  success = FALSE;
1025  }
1026 
1027  end_builtin();
1028 }
1029 
1030 #endif
1031 
1032 
1033 /*****************************************************************/
1034 /******** xcSetStandardProperties
1035 
1036  xcSetStandardProperties(+Display,+Window,+WindowTitle,+IconTitle,
1037  +X,+Y,+Width,+Height)
1038 
1039  */
1040 
1041 long xcSetStandardProperties()
1042 {
1044  ptr_definition types[8];
1045  long j;
1046  XSizeHints hints;
1047 
1048 
1049  for(j=0; j<8; j++)
1050  types[j] = real;
1051  types[1] = xwindow;
1052  types[2] = quoted_string;
1053  types[3] = quoted_string;
1054 
1055  begin_builtin(xcSetStandardProperties,8,8,types);
1056 
1057  hints.x = val[4];
1058  hints.y = val[5];
1059  hints.width = val[6] ;
1060  hints.height = val[7];
1061  hints.flags = PPosition | PSize;
1062 
1063  XSetStandardProperties(DISP(0),WIND(1),
1064  (char*)val[2],(char*)val[3],/* window title,icon title */
1065  None, /* icon pixmap */
1066  (char **) NULL,0, /* argv,argc */
1067  &hints);
1068 
1069  ResizePixmap(args[1],val[0],val[1],val[6],val[7]);
1070 
1071  success = TRUE;
1072 
1073  end_builtin();
1074 
1075 }
1076 
1077 
1078 
1079 /*****************************************************************/
1080 /******** xcGetWindowGeometry
1081 
1082  xcGetWindowGeometry(+Display,+Window,-X,-Y,-Width,-Height)
1083 
1084  returns the geometry of the window.
1085 
1086  */
1087 
1088 long xcGetWindowGeometry()
1089 
1090 {
1092  ptr_definition types[6];
1093  int j,x,y;
1094  unsigned int w,h,bw,d;
1095  Window r;
1096 
1097 
1098  for(j=0; j<6; j++)
1099  types[j] = real;
1100  types[1] = xdrawable;
1101 
1102  begin_builtin(xcGetWindowGeometry,6,2,types);
1103 
1104  if(XGetGeometry(DISP(0),DRAW(1),
1105  &r,&x,&y,&w,&h,&bw,&d))
1106  {
1107  unify_real_result(args[2],(REAL) x);
1108  unify_real_result(args[3],(REAL) y);
1109  unify_real_result(args[4],(REAL) w);
1110  unify_real_result(args[5],(REAL) h);
1111  success = TRUE;
1112  }
1113  else
1114  {
1115  Errorline("could not get the geometry in %P.\n",g);
1116  success = FALSE;
1117  }
1118 
1119  end_builtin();
1120 }
1121 
1122 
1123 /*****************************************************************/
1124 /******** GetWindowAttribute */
1125 
1126 static long GetWindowAttribute(display,window,attributeId,attribute)
1127 
1128  Display *display; long window,attributeId,*attribute;
1129 {
1130  XWindowAttributes windowAttributes;
1131 
1132 
1133  XGetWindowAttributes(display,window,&windowAttributes);
1134  switch(attributeId)
1135  {
1136  case 0:
1137  *attribute = windowAttributes.x;
1138  break;
1139  case 1:
1140  *attribute = windowAttributes.y;
1141  break;
1142  case 2:
1143  *attribute = windowAttributes.width;
1144  break;
1145  case 3:
1146  *attribute = windowAttributes.height;
1147  break;
1148  case 4:
1149  *attribute = windowAttributes.border_width;
1150  break;
1151  case 5:
1152  *attribute = windowAttributes.depth;
1153  break;
1154  case 6:
1155  *attribute = windowAttributes.root;
1156  break;
1157  case 7:
1158  *attribute =(unsigned long)windowAttributes.screen;
1159  break;
1160  case 8:
1161  *attribute =(unsigned long)windowAttributes.visual;
1162  break;
1163  case 9:
1164  *attribute = windowAttributes.class;
1165  break;
1166  case 10:
1167  *attribute = windowAttributes.all_event_masks;
1168  break;
1169  case 11:
1170  *attribute = windowAttributes.bit_gravity;
1171  break;
1172  case 12:
1173  *attribute = windowAttributes.win_gravity;
1174  break;
1175  case 13:
1176  *attribute = windowAttributes.backing_store;
1177  break;
1178  case 14:
1179  *attribute = windowAttributes.backing_planes;
1180  break;
1181  case 15:
1182  *attribute = windowAttributes.backing_pixel;
1183  break;
1184  case 16:
1185  *attribute = windowAttributes.override_redirect;
1186  break;
1187  case 17:
1188  *attribute = windowAttributes.save_under;
1189  break;
1190  case 18:
1191  *attribute = windowAttributes.your_event_mask;
1192  break;
1193  case 19:
1194  *attribute = windowAttributes.do_not_propagate_mask;
1195  break;
1196  case 20:
1197  *attribute = windowAttributes.colormap;
1198  break;
1199  case 21:
1200  *attribute = windowAttributes.map_installed;
1201  break;
1202  case 22:
1203  *attribute = windowAttributes.map_state;
1204  break;
1205  default:
1206  return FALSE;
1207  break;
1208  }
1209  return TRUE;
1210 }
1211 
1212 
1213 /*****************************************************************/
1214 /******** xcGetWindowAttribute
1215 
1216  xcGetWindowAttribute(+Display,+Window,+AttributeId,-Value)
1217 
1218  returns the value corresponding to the attribute id of the window.
1219 
1220  */
1221 
1222 long xcGetWindowAttribute()
1223 
1224 {
1226  ptr_definition types[4];
1227  long attr;
1228 
1229 
1230  types[0] = real;
1231  types[1] = xwindow;
1232  types[2] = real;
1233  types[3] = real;
1234 
1235  begin_builtin(xcGetWindowAttribute,4,3,types);
1236 
1237  if(GetWindowAttribute(DISP(0),WIND(1),val[2],&attr))
1238  {
1239  unify_real_result(args[3],(REAL) attr);
1240  success = TRUE;
1241  }
1242  else
1243  {
1244  Errorline("could not get a window attribute in %P.\n",g);
1245  success = FALSE;
1246  }
1247 
1248  end_builtin();
1249 }
1250 
1251 
1252 /*****************************************************************/
1253 /******** xcSetWindowGeometry
1254 
1255  xcSetWindowGeometry(+Display,+Window,+X,+Y,+Width,+Height)
1256 
1257  set the geometry of the window.
1258 
1259  */
1260 
1261 long xcSetWindowGeometry()
1262 
1263 {
1265  ptr_definition types[6];
1266  long j;
1267 
1268 
1269  for(j=0; j<6; j++)
1270  types[j] = real;
1271  types[1] = xdrawable;
1272 
1273  begin_builtin(xcSetWindowGeometry,6,6,types);
1274 
1275  XMoveResizeWindow(DISP(0),DRAW(1),
1276  val[2],val[3],val[4],val[5]);
1277 
1278  /* modify the pixmap */
1279  ResizePixmap(args[1],val[0],val[1],val[4],val[5]);
1280 
1281  success = TRUE;
1282 
1283  end_builtin();
1284 }
1285 
1286 
1287 
1288 /*****************************************************************/
1289 /******** xcMoveWindow
1290 
1291  xcMoveWindow(+Display,+Window,+X,+Y)
1292 
1293  Move a window to a different location.
1294 
1295  */
1296 
1297 long xcMoveWindow() /* RM: May 4 1993 */
1298 
1299 {
1301  ptr_definition types[4];
1302  long j;
1303 
1304 
1305  for(j=0; j<4; j++)
1306  types[j] = real;
1307  types[1] = xdrawable;
1308 
1309  begin_builtin(xcMoveWindow,4,4,types);
1310 
1311  XMoveWindow(DISP(0),DRAW(1), val[2],val[3]);
1312 
1313  success = TRUE;
1314 
1315  end_builtin();
1316 }
1317 
1318 
1319 
1320 /*****************************************************************/
1321 /******** SetWindowAttribute */
1322 
1323 static long SetWindowAttribute(psi_window,display,window,attributeId,attribute)
1324 
1325  ptr_psi_term psi_window;
1326  Display *display;
1327  Drawable window;
1328  unsigned long attributeId,attribute;
1329 
1330 {
1331  XSetWindowAttributes attributes;
1332  XWindowChanges changes;
1333  unsigned long attributesMask = 0;
1334  unsigned long changesMask = 0;
1335  long backgroundChange = FALSE;
1336  long sizeChange = FALSE;
1337  unsigned int width,height;
1338  int x,y;
1339  unsigned int bw,d;
1340  Window r;
1341 
1342  switch(attributeId)
1343  {
1344  case 0:
1345  changes.x = attribute;
1346  changesMask |= CWX;
1347  break;
1348  case 1:
1349  changes.y = attribute;
1350  changesMask |= CWY;
1351  break;
1352  case 2:
1353  changes.width = attribute;
1354  changesMask |= CWWidth;
1355  XGetGeometry(display,window,&r,&x,&y,&width,&height,&bw,&d);
1356  width = attribute;
1357  sizeChange = TRUE;
1358  break;
1359  case 3:
1360  changes.height = attribute;
1361  changesMask |= CWHeight;
1362  XGetGeometry(display,window,&r,&x,&y,&width,&height,&bw,&d);
1363  height = attribute;
1364  sizeChange = TRUE;
1365  break;
1366  case 4:
1367  changes.border_width = attribute;
1368  changesMask |= CWBorderWidth;
1369  break;
1370  case 11:
1371  attributes.bit_gravity = attribute;
1372  attributesMask |= CWBitGravity;
1373  break;
1374  case 12:
1375  attributes.win_gravity = attribute;
1376  attributesMask |= CWWinGravity;
1377  break;
1378  case 13:
1379  attributes.backing_store = attribute;
1380  attributesMask |= CWBackingStore;
1381  break;
1382  case 14:
1383  attributes.backing_planes = attribute;
1384  attributesMask |= CWBackingPlanes;
1385  break;
1386  case 15:
1387  attributes.backing_pixel = attribute;
1388  attributesMask |= CWBackingPixel;
1389  break;
1390  case 16:
1391  attributes.override_redirect = attribute;
1392  attributesMask |= CWOverrideRedirect;
1393  break;
1394  case 17:
1395  attributes.save_under = attribute;
1396  attributesMask |= CWSaveUnder;
1397  break;
1398  case 18:
1399  attributes.event_mask = attribute;
1400  attributesMask |= CWEventMask;
1401  break;
1402  case 19:
1403  attributes.do_not_propagate_mask = attribute;
1404  attributesMask |= CWDontPropagate;
1405  break;
1406  case 20:
1407  attributes.colormap = attribute;
1408  attributesMask |= CWColormap;
1409  break;
1410  case 23:
1411  changes.sibling = attribute;
1412  changesMask |= CWSibling;
1413  break;
1414  case 24:
1415  changes.stack_mode = attribute;
1416  changesMask |= CWStackMode;
1417  break;
1418  case 25:
1419  attributes.background_pixmap = attribute;
1420  attributesMask |= CWBackPixmap;
1421  break;
1422  case 26:
1423  attributes.background_pixel = attribute;
1424  attributesMask |= CWBackPixel;
1425  backgroundChange = TRUE;
1426 
1427  /* change the backing_pixel in order to fill the pixmap with */
1428  attributes.backing_pixel = attribute;
1429  attributesMask |= CWBackingPixel;
1430  break;
1431  case 27:
1432  attributes.border_pixmap = attribute;
1433  attributesMask |= CWBorderPixmap;
1434  break;
1435  case 28:
1436  attributes.border_pixel = attribute;
1437  attributesMask |= CWBorderPixel;
1438  break;
1439  case 29:
1440  attributes.cursor = attribute;
1441  attributesMask |= CWCursor;
1442  break;
1443  default:
1444  return FALSE;
1445  break;
1446  }
1447 
1448  if(changesMask)
1449  XConfigureWindow(display,window,changesMask,&changes);
1450 
1451  if(attributesMask)
1452  XChangeWindowAttributes(display,window,attributesMask,&attributes);
1453 
1454  if(backgroundChange)
1455  XClearArea(display,window,0,0,0,0,True);
1456 
1457  if(sizeChange)
1458  ResizePixmap(psi_window,display,window,width,height);
1459 
1460  return TRUE;
1461 }
1462 
1463 
1464 /*****************************************************************/
1465 /******** xcSetWindowAttribute
1466 
1467  xcSetWindowAttribute(+Display,+Window,+AttributeId,+Value)
1468 
1469  set the value corresponding to the attribute id.
1470 
1471  */
1472 
1473 long xcSetWindowAttribute()
1474 
1475 {
1477  ptr_definition types[4];
1478 
1479 
1480  types[0] = real;
1481  types[1] = xwindow;
1482  types[2] = real;
1483  types[3] = real;
1484 
1485  begin_builtin(xcSetWindowAttribute,4,4,types);
1486 
1487  if(SetWindowAttribute(args[1],val[0],val[1],val[2],val[3]))
1488  {
1489  XSync(DISP(0),0);
1490  success = TRUE;
1491  }
1492  else
1493  {
1494  Errorline("could not set window attribute in %P.\n",g);
1495  success = FALSE;
1496  }
1497 
1498  end_builtin();
1499 }
1500 
1501 
1502 
1503 /*****************************************************************/
1504 /******** xcMapWindow
1505 
1506  xcMapWindow(+Connection,+Window)
1507 
1508  map the Window on the display Connection.
1509 
1510  */
1511 
1512 long xcMapWindow()
1513 
1514 {
1516  ptr_definition types[2];
1517 
1518 
1519  types[0] = real;
1520  types[1] = real;
1521 
1522  begin_builtin(xcMapWindow,2,2,types);
1523 
1524  XMapWindow(DISP(0),WIND(1));
1525  XSync(DISP(0),0);
1526 
1527  push_window(hide_window,(long)DISP(0),val[1]);
1528  success = TRUE;
1529 
1530  end_builtin();
1531 }
1532 
1533 
1534 
1535 /*****************************************************************/
1536 /******** xcRaiseWindow
1537 
1538  xcRaiseWindow(+Connection,+Window)
1539 
1540  raise the Window on the display Connection.
1541 
1542  */
1543 
1544 long xcRaiseWindow()
1545 
1546 {
1548  ptr_definition types[2];
1549 
1550 
1551  types[0] = real;
1552  types[1] = real;
1553 
1554  begin_builtin(xcRaiseWindow,2,2,types);
1555 
1556  XRaiseWindow(DISP(0),WIND(1));
1557  XSync(DISP(0),0);
1558 
1559  push_window(hide_window,(long)DISP(0),WIND(1));
1560  success = TRUE;
1561 
1562  end_builtin();
1563 }
1564 
1565 
1566 
1567 /*****************************************************************/
1568 /******** xcUnmapWindow
1569 
1570  xcUnmapWindow(+Connection,+Window)
1571 
1572  unmap the Window on the display Connection.
1573 
1574  */
1575 
1576 long xcUnmapWindow()
1577 
1578 {
1580  ptr_definition types[2];
1581 
1582 
1583  types[0] = real;
1584  types[1] = real;
1585 
1586  begin_builtin(xcUnmapWindow,2,2,types);
1587 
1588  XUnmapWindow(DISP(0),WIND(1));
1589  XSync(DISP(0),0);
1590 
1591  push_window(show_window,(long)DISP(0),WIND(1));
1592  success = TRUE;
1593 
1594  end_builtin();
1595 }
1596 
1597 
1598 
1599 
1600 
1601 
1602 /*** RM 8/12/92 START ***/
1603 
1604 
1605 /*****************************************************************/
1606 /******** xcMapSubwindows
1607 
1608  xcMapSubwindows(+Connection,+Window)
1609 
1610  map the sub-windows on the display Connection.
1611 
1612  */
1613 
1614 long xcMapSubwindows()
1615 
1616 {
1618  ptr_definition types[2];
1619 
1620 
1621  types[0] = real;
1622  types[1] = real;
1623 
1624  begin_builtin(xcMapSubwindow,2,2,types);
1625 
1626  XMapSubwindows(DISP(0),WIND(1));
1627  XSync(DISP(0),0);
1628 
1629  push_window(hide_subwindow,(long)DISP(0),WIND(1));
1630  success = TRUE;
1631 
1632  end_builtin();
1633 }
1634 
1635 
1636 
1637 /*****************************************************************/
1638 /******** xcUnmapSubwindows
1639 
1640  xcUnmapSubwindows(+Connection,+Window)
1641 
1642  unmap the sub-windows on the display Connection.
1643 
1644  */
1645 
1646 long xcUnmapSubwindows()
1647 
1648 {
1650  ptr_definition types[2];
1651 
1652 
1653  types[0] = real;
1654  types[1] = real;
1655 
1656  begin_builtin(xcUnmapSubwindows,2,2,types);
1657 
1658  XUnmapSubwindows(DISP(0),WIND(1));
1659  XSync(DISP(0),0);
1660 
1661  push_window(show_subwindow,(long)DISP(0),WIND(1));
1662  success = TRUE;
1663 
1664  end_builtin();
1665 }
1666 
1667 
1668 /*** RM 8/12/82 END ***/
1669 
1670 
1671 
1672 
1673 
1674 /*****************************************************************/
1675 /******** xcClearWindow
1676 
1677  xcClearWindow(+Connection,+Window)
1678 
1679  clear the Window on the display Connection.
1680 
1681  */
1682 
1683 long xcClearWindow()
1684 
1685 {
1687  ptr_definition types[2];
1688 
1689 
1690  types[0] = real;
1691  types[1] = xwindow;
1692 
1693  begin_builtin(xcClearWindow,2,2,types);
1694 
1695  XClearWindow(DISP(0),WIND(1));
1696 XSync(DISP(0),0);
1697 
1698  x_free_display_list((ListHeader *)WindowDisplayList(args[1]));
1699  success = TRUE;
1700 
1701  end_builtin();
1702 }
1703 
1704 
1705 
1706 /*****************************************************************/
1707 /******** xcResizeWindowPixmap
1708 
1709  xcResizeWindowPixmap(+Display,+Window,+Width,+Height)
1710 
1711  resize the pixmap of the window,useful when we caught the resize event
1712  eg: the window is resized manualy.
1713 
1714  */
1715 
1716 long xcResizeWindowPixmap()
1717 
1718 {
1720  ptr_definition types[4];
1721  long j;
1722 
1723 
1724  for(j=0; j<4; j++)
1725  types[j] = real;
1726  types[1] = xdrawable;
1727 
1728  begin_builtin(xcResizeWindowPixmap,4,4,types);
1729 
1730  /* modify the pixmap */
1731  ResizePixmap(args[1],val[0],val[1],val[2],val[3]);
1732 
1733  success = TRUE;
1734 
1735  end_builtin();
1736 }
1737 
1738 
1739 
1740 /*****************************************************************/
1741 /******** xcSelectInput
1742 
1743  xcSelectInput(+Connection,+Window,+Mask)
1744 
1745  select the desired event types
1746 
1747  */
1748 
1749 long xcSelectInput()
1750 
1751 {
1753  ptr_definition types[3];
1754 
1755 
1756  types[0] = real;
1757  types[1] = real;
1758  types[2] = real;
1759 
1760  begin_builtin(xcSelectInput,3,3,types);
1761 
1762  XSelectInput(DISP(0),WIND(1),val[2]);
1763  success = TRUE;
1764 
1765  end_builtin();
1766 }
1767 
1768 
1769 
1770 /*****************************************************************/
1771 /******** xcRefreshWindow
1772 
1773 
1774  xcRefreshWindow(+Connection,+Window)
1775 
1776  refresh the window
1777 
1778  */
1779 
1780 long xcRefreshWindow()
1781 
1782 {
1784  ptr_definition types[2];
1785  Pixmap pixmap;
1786  ptr_psi_term psiPixmap;
1787 
1788 
1789  types[0] = real;
1790  types[1] = xwindow;
1791 
1792  begin_builtin(xcRefreshWindow,2,2,types);
1793 
1794  psiPixmap = GetPsiAttr(args[1],"pixmap");
1795  if((pixmap =(Pixmap) GetIntAttr(psiPixmap,"id")) != 0)
1796  x_refresh_window((Display *)val[0],val[1],pixmap,
1797  DrawableGC(psiPixmap),
1798  (ListHeader *)WindowDisplayList(args[1]));
1799  else
1800  x_refresh_window((Display *)val[0],val[1],val[1],
1801  DrawableGC(args[1]),
1802  (ListHeader *)WindowDisplayList(args[1]));
1803 
1804  success = TRUE;
1805 
1806  end_builtin();
1807 }
1808 
1809 
1810 
1811 /*****************************************************************/
1812 /******** xcPostScriptWindow
1813 
1814 
1815  xcPostScriptWindow(+Display,+Window,Filename)
1816 
1817  output the contents of the window in Filename
1818 
1819  */
1820 
1821 long xcPostScriptWindow()
1822 
1823 {
1825  ptr_definition types[3];
1826 
1827 
1828  types[0] = real;
1829  types[1] = xwindow;
1830  types[2] = quoted_string;
1831 
1832  begin_builtin(xcPostScriptWindow,3,3,types);
1833 
1834  success = x_postscript_window((Display *) val[0],val[1],(ListHeader *)GetIntAttr(GetPsiAttr(args[1],"display_list"),"id"),(char *)val[2]);
1835 
1836  end_builtin();
1837 }
1838 
1839 
1840 
1841 /*****************************************************************/
1842 /******** xcDestroyWindow
1843 
1844 
1845  xcDestroyWindow(+Connection,+Window)
1846 
1847  Close and destroy the window(unbacktrable).
1848 
1849  */
1850 
1851 long xcDestroyWindow()
1852 
1853 {
1855  ptr_definition types[2];
1856  ptr_psi_term psi;
1857 
1858  types[0] = real;
1859  types[1] = xwindow;
1860 
1861  begin_builtin(xcDestroyWindow,2,2,types);
1862 
1863  psi = GetPsiAttr(args[1],"permanent");
1864  if(!strcmp(psi->type->keyword->symbol,"true"))
1865  {
1866  Errorline("cannot destroy a permanent window.\n");
1867  exit_life(TRUE); /* was: main_loop_ok=FALSE; - jch */
1868  success = FALSE;
1869  }
1870  else
1871  {
1872  FreeWindow(val[0],args[1]);
1873  XDestroyWindow(DISP(0),WIND(1));
1874 XSync(DISP(0),0);
1875  clean_undo_window((long)DISP(0),WIND(1));
1876  success = TRUE;
1877  }
1878 
1879  end_builtin();
1880 }
1881 
1882 
1883 
1884 /*****************************************************************/
1885 /******** CREATEGC
1886 
1887  xcCreateGC(+Connection,+Drawable,-GC)
1888 
1889  create a graphic context.
1890 
1891  */
1892 
1893 long xcCreateGC()
1894 
1895 {
1897  ptr_definition types[3];
1898  GC gc;
1899  XGCValues GCvalues;
1900 
1901 
1902  types[0] = real;
1903  types[1] = xdrawable;
1904  types[2] = real;
1905 
1906  begin_builtin(xcCreateGC,3,2,types);
1907 
1908  if(gc = XCreateGC(DISP(0),WIND(1),0,&GCvalues)) /* RM: Feb 7 1994 */
1909  {
1910  unify_real_result(args[2],(REAL)(unsigned long) gc);
1911  success = TRUE;
1912  }
1913  else
1914  {
1915  Errorline("could not create gc in %P.\n",g);
1916  success = FALSE;
1917  }
1918 
1919  end_builtin();
1920 }
1921 
1922 
1923 
1924 /*****************************************************************/
1925 /******** GETGCATTRIBUTE */
1926 
1927 static long GetGCAttribute(gc,attributeId,attribute)
1928 
1929  GC gc;
1930  long attributeId,*attribute;
1931 
1932 {
1933 #ifndef __alpha
1934  switch(attributeId)
1935  {
1936  case 0:
1937  *attribute = gc->values.function;
1938  break;
1939  case 1:
1940  *attribute = gc->values.plane_mask;
1941  break;
1942  case 2:
1943  *attribute = gc->values.foreground;
1944  break;
1945  case 3:
1946  *attribute = gc->values.background;
1947  break;
1948  case 4:
1949  *attribute = gc->values.line_width;
1950  break;
1951  case 5:
1952  *attribute = gc->values.line_style;
1953  break;
1954  case 6:
1955  *attribute = gc->values.cap_style;
1956  break;
1957  case 7:
1958  *attribute = gc->values.join_style;
1959  break;
1960  case 8:
1961  *attribute = gc->values.fill_style;
1962  break;
1963  case 9:
1964  *attribute = gc->values.fill_rule;
1965  break;
1966  case 10:
1967  *attribute = gc->values.tile;
1968  break;
1969  case 11:
1970  *attribute = gc->values.stipple;
1971  break;
1972  case 12:
1973  *attribute = gc->values.ts_x_origin;
1974  break;
1975  case 13:
1976  *attribute = gc->values.ts_y_origin;
1977  break;
1978  case 14:
1979  *attribute = gc->values.font;
1980  break;
1981  case 15:
1982  *attribute = gc->values.subwindow_mode;
1983  break;
1984  case 16:
1985  *attribute = gc->values.graphics_exposures;
1986  break;
1987  case 17:
1988  *attribute = gc->values.clip_x_origin;
1989  break;
1990  case 18:
1991  *attribute = gc->values.clip_y_origin;
1992  break;
1993  case 19:
1994  *attribute = gc->values.clip_mask;
1995  break;
1996  case 20:
1997  *attribute = gc->values.dash_offset;
1998  break;
1999  case 21:
2000  *attribute =(unsigned char)(gc->values.dashes);
2001  break;
2002  case 22:
2003  *attribute = gc->values.arc_mode;
2004  break;
2005  case 23:
2006  *attribute = gc->rects;
2007  break;
2008  case 24:
2009  *attribute = gc->dashes;
2010  break;
2011  default:
2012  return FALSE;
2013  break;
2014  }
2015 #endif
2016  return TRUE;
2017 }
2018 
2019 
2020 /*****************************************************************/
2021 /******** GETGCATTRIBUTE
2022 
2023  xcGetGCAttribute(+GC,+AttributeId,-Val)
2024 
2025  get the value of the attribute id of GC.
2026 
2027  */
2028 
2029 long xcGetGCAttribute()
2030 
2031 {
2033  ptr_definition types[3];
2034  long attr;
2035 
2036 
2037  types[0] = real;
2038  types[1] = real;
2039  types[2] = real;
2040 
2041  begin_builtin(xcGetGCAttribute,3,2,types);
2042 
2043  if(GetGCAttribute((long)DISP(0),GCVAL(1),&attr))
2044  {
2045  unify_real_result(args[2],(REAL) attr);
2046  success = TRUE;
2047  }
2048  else
2049  {
2050  Errorline("could not get gc attribute in %P.\n",g);
2051  success = FALSE;
2052  }
2053 
2054  end_builtin();
2055 }
2056 
2057 
2058 
2059 /*****************************************************************/
2060 /******** SETGCATTRIBUTE */
2061 
2062 static long SetGCAttribute(display,gc,attributeId,attribute)
2063 
2064  Display *display;
2065  GC gc;
2066  long attributeId,attribute;
2067 
2068 {
2069  XGCValues attributes;
2070  unsigned long attributesMask = 0;
2071 
2072 
2073  switch(attributeId)
2074  {
2075  case 0:
2076  attributes.function = attribute;
2077  attributesMask |= GCFunction;
2078  break;
2079  case 1:
2080  attributes.plane_mask = attribute;
2081  attributesMask |= GCPlaneMask;
2082  break;
2083  case 2:
2084  attributes.foreground = attribute;
2085  attributesMask |= GCForeground;
2086  break;
2087  case 3:
2088  attributes.background = attribute;
2089  attributesMask |= GCBackground;
2090  break;
2091  case 4:
2092  attributes.line_width = attribute;
2093  attributesMask |= GCLineWidth;
2094  break;
2095  case 5:
2096  attributes.line_style = attribute;
2097  attributesMask |= GCLineStyle;
2098  break;
2099  case 6:
2100  attributes.cap_style = attribute;
2101  attributesMask |= GCCapStyle;
2102  break;
2103  case 7:
2104  attributes.join_style = attribute;
2105  attributesMask |= GCJoinStyle;
2106  break;
2107  case 8:
2108  attributes.fill_style = attribute;
2109  attributesMask |= GCFillStyle;
2110  break;
2111  case 9:
2112  attributes.fill_rule = attribute;
2113  attributesMask |= GCFillRule;
2114  break;
2115  case 10:
2116  attributes.tile = attribute;
2117  attributesMask |= GCTile;
2118  break;
2119  case 11:
2120  attributes.stipple = attribute;
2121  attributesMask |= GCStipple;
2122  break;
2123  case 12:
2124  attributes.ts_x_origin = attribute;
2125  attributesMask |= GCTileStipXOrigin;
2126  break;
2127  case 13:
2128  attributes.ts_y_origin = attribute;
2129  attributesMask |= GCTileStipYOrigin;
2130  break;
2131  case 14:
2132  attributes.font = attribute;
2133  attributesMask |= GCFont;
2134  break;
2135  case 15:
2136  attributes.subwindow_mode = attribute;
2137  attributesMask |= GCSubwindowMode;
2138  break;
2139  case 16:
2140  attributes.graphics_exposures = attribute;
2141  attributesMask |= GCGraphicsExposures;
2142  break;
2143  case 17:
2144  attributes.clip_x_origin = attribute;
2145  attributesMask |= GCClipXOrigin;
2146  break;
2147  case 18:
2148  attributes.clip_y_origin = attribute;
2149  attributesMask |= GCClipYOrigin;
2150  break;
2151  case 19:
2152  attributes.clip_mask = attribute;
2153  attributesMask |= GCClipMask;
2154  break;
2155  case 20:
2156  attributes.dash_offset = attribute;
2157  attributesMask |= GCDashOffset;
2158  break;
2159  case 21:
2160  attributes.dashes =(char)(0xFF & attribute);
2161  attributesMask |= GCDashList;
2162  break;
2163  case 22:
2164  attributes.arc_mode = attribute;
2165  attributesMask |= GCArcMode;
2166  break;
2167  default:
2168  return FALSE;
2169  break;
2170  }
2171 
2172  XChangeGC(display,gc,attributesMask,&attributes);
2173  return TRUE;
2174 }
2175 
2176 
2177 /*****************************************************************/
2178 /******** SETGCATTRIBUTE
2179 
2180  xcSetGCAttribute(+Display,+GC,+AttributeId,+Val)
2181 
2182  set the value of the attribute id of GC.
2183 
2184  */
2185 
2186 long xcSetGCAttribute()
2187 
2188 {
2190  ptr_definition types[4];
2191 
2192 
2193  types[0] = real;
2194  types[1] = real;
2195  types[2] = real;
2196  types[3] = real;
2197 
2198  begin_builtin(xcSetGCAttribute,4,4,types);
2199 
2200  if(SetGCAttribute((long)DISP(0),GCVAL(1),val[2],val[3]))
2201  success = TRUE;
2202  else
2203  {
2204  Errorline("could not set gc attribute in %P.\n",g);
2205  success = FALSE;
2206  }
2207 
2208  end_builtin();
2209 }
2210 
2211 
2212 
2213 /*****************************************************************/
2214 /******** DESTROYGC
2215 
2216  xcDestroyGC(+Connection,+GC)
2217 
2218  destroys a graphic context.
2219 
2220  */
2221 
2222 long xcDestroyGC()
2223 
2224 {
2226  ptr_definition types[2];
2227 
2228 
2229  types[0] = real;
2230  types[1] = real;
2231 
2232  begin_builtin(xcDestroyGC,2,2,types);
2233 
2234  XFreeGC(DISP(0),GCVAL(1));
2235  success = TRUE;
2236 
2237  end_builtin();
2238 }
2239 
2240 /*****************************************************************/
2241 /******** REQUESTCOLOR
2242 
2243  xcRequestColor(+Connection,+ColorMap,+Red,+Green,+Blue,-Pixel)
2244 
2245  get the closest color to(Red,Green,Blue) in the ColorMap
2246 
2247  */
2248 
2249 long xcRequestColor()
2250 
2251 {
2253  ptr_definition types[6];
2254  long j;
2255  XColor color;
2256 
2257 
2258  for(j=0; j<6; j++)
2259  types[j] = real;
2260 
2261  begin_builtin(xcRequestColor,6,5,types);
2262 
2263  color.red =(val[2]) << 8;
2264  color.green =(val[3]) << 8;
2265  color.blue =(val[4]) << 8;
2266  color.flags = DoRed|DoGreen|DoBlue;
2267 
2268  if(XAllocColor(DISP(0),CMAP(1),&color))
2269  {
2270  unify_real_result(args[5],(REAL) color.pixel);
2271  success = TRUE;
2272  }
2273  else
2274  {
2275  Errorline("could not request a color in %P.\n",g);
2276  success = FALSE;
2277  }
2278 
2279  end_builtin();
2280 }
2281 
2282 
2283 /*****************************************************************/
2284 /******** REQUESTNAMEDCOLOR
2285 
2286  xcRequestNamedColor(+Connection,+ColorMap,+Name,-Pixel)
2287 
2288  get the color corresponding to Name in the ColorMap
2289 
2290  */
2291 
2292 long xcRequestNamedColor()
2293 
2294 {
2296  ptr_definition types[4];
2297  long j;
2298  XColor cell,rgb;
2299 
2300  types[0] = real;
2301  types[1] = real;
2302  types[2] = quoted_string;
2303  types[3] = real;
2304 
2305  begin_builtin(xcRequestNamedColor,4,3,types);
2306 
2307  if(XAllocNamedColor(DISP(0),CMAP(1),STRG(2),&cell,&rgb))
2308  {
2309  unify_real_result(args[3],(REAL) cell.pixel);
2310  success = TRUE;
2311  }
2312  else
2313  {
2314  Errorline("could not request a named color in %P.\n",g);
2315  success = FALSE;
2316  }
2317 
2318  end_builtin();
2319 }
2320 
2321 
2322 /*****************************************************************/
2323 /******** FREECOLOR
2324 
2325  xcFreeColor(+Connection,+ColorMap,+Pixel)
2326 
2327  free the color in the colormap
2328 
2329  */
2330 
2331 long xcFreeColor()
2332 
2333 {
2335  ptr_definition types[3];
2336  long j;
2337  unsigned long pixel;
2338 
2339 
2340  for(j=0; j<3; j++)
2341  types[j] = real;
2342 
2343  begin_builtin(xcFreeColor,3,3,types);
2344 
2345  pixel = val[2];
2346  XFreeColors(DISP(0),CMAP(1),&pixel,1,0);
2347  success = TRUE;
2348 
2349  end_builtin();
2350 }
2351 
2352 
2353 /*****************************************************************/
2354 /******** DrawLine
2355 
2356  xcDrawLine(+Connection,+Drawable,+X0,+Y0,+X1,+Y1,
2357  +Function,+Color,+LineWidth)
2358 
2359  draw a line(X0,Y0) ->(X1,Y1)
2360 
2361  */
2362 
2363 long xcDrawLine()
2364 
2365 {
2367  ptr_definition types[9];
2368  long j;
2369  GC gc;
2370 
2371 
2372  for(j = 0; j < 9; j++)
2373  types[j] = real;
2374  types[1] = xdrawable;
2375 
2376  begin_builtin(xcDrawLine,9,9,types);
2377 
2378  gc = DrawableGC(args[1]);
2379  x_set_gc((Display *)val[0],gc,val[6],val[7],val[8],xDefaultFont);
2380 
2381  XDrawLine(DISP(0),(Window) val[1],gc,/* Display,Window,GC */
2382  val[2],val[3],val[4],val[5]); /* X0,Y0,X1,Y1 */
2383 
2384  x_record_line((ListHeader *)WindowDisplayList(args[1]),DRAW_LINE,
2385  val[2],val[3],val[4],val[5],
2386  val[6],val[7],val[8]);
2387 
2388 XSync(DISP(0),0);
2389  success = TRUE;
2390 
2391  end_builtin();
2392 }
2393 
2394 /*****************************************************************/
2395 /******** DrawArc
2396 
2397  xcDrawArc(+Connection,+Drawable,+X,+Y,+Width,+Height,+StartAngle,+ArcAngle,
2398  +Function,+Color,+LineWidth)
2399 
2400  draw arc(see X Vol.2 page 135 for the meanings of the arguments).
2401 
2402  */
2403 
2404 long xcDrawArc()
2405 
2406 {
2407  include_var_builtin(11);
2408  ptr_definition types[11];
2409  long j;
2410  GC gc;
2411 
2412 
2413  for(j = 0; j < 11; j++)
2414  types[j] = real;
2415  types[1] = xdrawable;
2416 
2417  begin_builtin(xcDrawArc,11,11,types);
2418 
2419  gc = DrawableGC(args[1]);
2420  x_set_gc((Display *)val[0],gc,val[8],val[9],val[10],xDefaultFont);
2421 
2422  XDrawArc(DISP(0),(Window) val[1],gc,/* Display,Window,GC */
2423  val[2],val[3],val[4],val[5], /* X,Y,Width,Height */
2424  val[6],val[7]); /* StartAngle,ArcAngle */
2425 
2426  x_record_arc((ListHeader *)WindowDisplayList(args[1]),DRAW_ARC,
2427  val[2],val[3],val[4],val[5],
2428  val[6],val[7],val[8],val[9],val[10]);
2429 
2430 XSync(DISP(0),0);
2431  success = TRUE;
2432 
2433  end_builtin();
2434 }
2435 
2436 
2437 /*****************************************************************/
2438 /******** DrawRectangle
2439 
2440  xcDrawRectangle(+Connection,+Drawable,+X,+Y,+Width,+Height,
2441  +Function,+Color,+LineWidth)
2442 
2443  draw a rectangle.
2444 
2445  */
2446 
2447 long xcDrawRectangle()
2448 
2449 {
2451  ptr_definition types[9];
2452  long j;
2453  GC gc;
2454 
2455 
2456  for(j = 0; j < 9; j++)
2457  types[j] = real;
2458  types[1] = xdrawable;
2459 
2460  begin_builtin(xcDrawRectangle,9,9,types);
2461 
2462  gc = DrawableGC(args[1]);
2463  x_set_gc((Display *)val[0],gc,val[6],val[7],val[8],xDefaultFont);
2464 
2465  XDrawRectangle(DISP(0),(Window) val[1],gc,/* Display,Window,GC */
2466  val[2],val[3],val[4],val[5]); /* X,Y,Width,Height */
2467 
2468  x_record_rectangle((ListHeader *)WindowDisplayList(args[1]),DRAW_RECTANGLE,
2469  val[2],val[3],val[4],val[5],
2470  val[6],val[7],val[8]);
2471 
2472 XSync(DISP(0),0);
2473  success = TRUE;
2474 
2475  end_builtin();
2476 }
2477 
2478 
2479 /*****************************************************************/
2480 /******** FillRectangle
2481 
2482  xcFillRectangle(+Connection,+Drawable,+X,+Y,+Width,+Height,
2483  +Function,+Color)
2484 
2485  fill a rectangle.
2486 
2487  */
2488 
2489 long xcFillRectangle()
2490 
2491 {
2493  ptr_definition types[8];
2494  long j;
2495  GC gc;
2496 
2497 
2498  for(j = 0; j < 8; j++)
2499  types[j] = real;
2500  types[1] = xdrawable;
2501 
2502  begin_builtin(xcFillRectangle,8,8,types);
2503 
2504  gc = DrawableGC(args[1]);
2505  x_set_gc((Display *)val[0],gc,val[6],val[7],xDefaultLineWidth,xDefaultFont);
2506 
2507  XFillRectangle(DISP(0),(Window) val[1],gc,/* Display,Window,GC */
2508  val[2],val[3],val[4],val[5]); /* X,Y,Width,Height */
2509 
2510  x_record_rectangle((ListHeader *)WindowDisplayList(args[1]),FILL_RECTANGLE,
2511  val[2],val[3],val[4],val[5],
2512  val[6],val[7],
2514 
2515 XSync(DISP(0),0);
2516  success = TRUE;
2517 
2518  end_builtin();
2519 }
2520 
2521 
2522 /*****************************************************************/
2523 /******** FillArc
2524 
2525  xcFillArc(+Connection,+Drawable,+X,+Y,+Width,+Height,+StartAngle,+ArcAngle,
2526  +Function,+Color)
2527  fill an arc.
2528 
2529  */
2530 
2531 long xcFillArc()
2532 
2533 {
2534  include_var_builtin(10);
2535  ptr_definition types[10];
2536  long j;
2537  GC gc;
2538 
2539 
2540  for(j = 0; j < 10; j++)
2541  types[j] = real;
2542  types[1] = xdrawable;
2543 
2544  begin_builtin(xcFillArc,10,10,types);
2545 
2546  gc = DrawableGC(args[1]);
2547  x_set_gc((Display *)val[0],gc,val[8],val[9],xDefaultLineWidth,xDefaultFont);
2548 
2549  XFillArc(DISP(0),(Window) val[1],gc,/* Display,Window,GC */
2550  val[2],val[3],val[4],val[5], /* X,Y,Width,Height */
2551  val[6],val[7]); /* StartAngle,ArcAngle */
2552 
2553  x_record_arc((ListHeader *)WindowDisplayList(args[1]),FILL_ARC,
2554  val[2],val[3],val[4],val[5],
2555  val[6],val[7],val[8],val[9],
2557 
2558 XSync(DISP(0),0);
2559  success = TRUE;
2560 
2561  end_builtin();
2562 }
2563 
2564 
2565 /*****************************************************************/
2566 /******** PointsAlloc
2567 
2568  xcPointsAlloc(+NbPoints,-Points)
2569 
2570  allocate n points
2571  */
2572 
2573 long xcPointsAlloc()
2574 
2575 {
2577  ptr_definition types[2];
2578  long Points;
2579 
2580 
2581  types[0] = real;
2582  types[1] = real;
2583 
2584  begin_builtin(xcPointsAlloc,2,1,types);
2585  Points =(long) malloc((val [0]) * 2 * sizeof(short));
2586  unify_real_result(args[1],(REAL) Points);
2587 
2588  success = TRUE;
2589 
2590  end_builtin();
2591 }
2592 
2593 
2594 /*****************************************************************/
2595 /******** CoordPut
2596 
2597  xcCoordPut(+Points,+N,+Coord)
2598 
2599  put nth coordinate in Points
2600  */
2601 
2602 long xcCoordPut()
2603 
2604 {
2606  ptr_definition types[3];
2607  short *Points;
2608 
2609  types[0] = real;
2610  types[1] = real;
2611  types[2] = real;
2612 
2613  begin_builtin(xcCoordPut,3,3,types);
2614 
2615  Points =(short *) val [0];
2616  Points += val[1];
2617  *Points = val[2];
2618 
2619  success = TRUE;
2620 
2621  end_builtin();
2622 }
2623 
2624 
2625 /*****************************************************************/
2626 /******** PointsFree
2627 
2628  xcPointsFree(+Points)
2629 
2630  free points
2631  */
2632 
2633 long xcPointsFree()
2634 
2635 {
2637  ptr_definition types[1];
2638 
2639 
2640  types[0] = real;
2641 
2642  begin_builtin(xcPointsFree,1,1,types);
2643  free((void *)val [0]);
2644  success = TRUE;
2645 
2646  end_builtin();
2647 }
2648 
2649 
2650 /*****************************************************************/
2651 /******** DrawPolygon
2652 
2653  xcDrawPolygon(+Connection,+Drawable,+Points,+NbPoints,
2654  +Function,+Color,+LineWidth)
2655 
2656  draw a polygon.
2657 
2658  */
2659 
2660 long xcDrawPolygon()
2661 
2662 {
2664  ptr_definition types[7];
2665  long j;
2666  GC gc;
2667 
2668 
2669  for(j = 0; j < 7; j++)
2670  types[j] = real;
2671  types[1] = xdrawable;
2672 
2673  begin_builtin(xcDrawPolygon,7,7,types);
2674 
2675  gc = DrawableGC(args[1]);
2676  x_set_gc((Display *)val[0],gc,val[4],val[5],val[6],xDefaultFont);
2677 
2678  XDrawLines(DISP(0),(Window) val[1],gc,/* Display,Window,GC */
2679  (XPoint *)val[2],val[3],CoordModeOrigin); /* Points,NbPoints,mode */
2680 
2681  x_record_polygon((ListHeader *)WindowDisplayList(args[1]),DRAW_POLYGON,
2682  (XPoint *)val[2],val[3],val[4],val[5],val[6]);
2683 
2684 XSync(DISP(0),0);
2685  success = TRUE;
2686 
2687  end_builtin();
2688 }
2689 
2690 
2691 /*****************************************************************/
2692 /******** FillPolygon
2693 
2694  xcFillPolygon(+Connection,+Drawable,+Points,+NbPoints,+Function,+Color)
2695 
2696  fill a polygon.
2697 
2698  */
2699 
2700 long xcFillPolygon()
2701 
2702 {
2704  ptr_definition types[6];
2705  long j;
2706  GC gc;
2707 
2708 
2709  for(j = 0; j < 6; j++)
2710  types[j] = real;
2711  types[1] = xdrawable;
2712 
2713  begin_builtin(xcFillPolygon,6,6,types);
2714 
2715  gc = DrawableGC(args[1]);
2716  x_set_gc((Display *)val[0],gc,val[4],val[5],xDefaultLineWidth,xDefaultFont);
2717 
2718  XFillPolygon(DISP(0),(Window) val[1],gc,/* Display,Window,GC */
2719  (XPoint *)val[2],val[3], /* Points,NbPoints */
2720  Complex,CoordModeOrigin); /* shape,mode */
2721 
2722  x_record_polygon((ListHeader *)WindowDisplayList(args[1]),FILL_POLYGON,
2723  (XPoint *)val[2],val[3],val[4],val[5],
2725 
2726  XSync(DISP(0),0);
2727  success = TRUE;
2728 
2729  end_builtin();
2730 }
2731 
2732 
2733 /*****************************************************************/
2734 /******** LoadFont
2735 
2736  xcLoadFont(+Connection,+Name,-Font)
2737 
2738  load a font.
2739 
2740  */
2741 
2742 long xcLoadFont()
2743 
2744 {
2746  ptr_definition types[3];
2747  Font font;
2748 
2749 
2750  types[0] = real;
2751  types[1] = quoted_string;
2752  types[2] = real;
2753 
2754  begin_builtin(xcLoadFont,3,2,types);
2755 
2756  if(font=XLoadFont(DISP(0),STRG(1)))
2757  {
2758  unify_real_result(args[2],(REAL) font);
2759  XSync(DISP(0),0);
2760  success = TRUE;
2761  }
2762  else
2763  {
2764  Errorline("could not load a font in %P.\n",g);
2765  success = FALSE;
2766  }
2767 
2768  end_builtin();
2769 }
2770 
2771 
2772 
2773 /*****************************************************************/
2774 /******** UnloadFont
2775 
2776  xcUnloadFont(+Connection,+Font)
2777 
2778  unload a font.
2779 
2780  */
2781 
2782 long xcUnloadFont()
2783 
2784 {
2786  ptr_definition types[2];
2787 
2788 
2789  types[0] = real;
2790  types[1] = real;
2791 
2792  begin_builtin(xcUnloadFont,2,2,types);
2793 
2794  XUnloadFont(DISP(0),FONT(1));
2795  XSync(DISP(0),0);
2796  success = TRUE;
2797 
2798  end_builtin();
2799 }
2800 
2801 
2802 
2803 /*****************************************************************/
2804 /******** DrawString
2805 
2806  xcDrawString(+Connection,+Drawable,+X,+Y,String,
2807  +Font,+Function,+Color)
2808 
2809  Print the string(only foreground).
2810 
2811  */
2812 
2813 long xcDrawString()
2814 {
2816  ptr_definition types[8];
2817  long j;
2818  GC gc;
2819 
2820 
2821  for(j = 0; j < 8; j++)
2822  types[j] = real;
2823  types[1] = xdrawable;
2824  types[4] = quoted_string;
2825 
2826  begin_builtin(xcDrawString,8,8,types);
2827 
2828  gc = DrawableGC(args[1]);
2829  x_set_gc((Display *)val[0],gc,val[6],val[7],xDefaultLineWidth,val[5]);
2830 
2831  XDrawString(DISP(0),(Window) val[1],gc, /* Display,Window,GC */
2832  val[2],val[3],STRG(4), /* X,Y *//* String */
2833  strlen(STRG(4))); /* Length */
2834 
2835  x_record_string((ListHeader *)WindowDisplayList(args[1]),DRAW_STRING,
2836  val[2],val[3], /* X,Y */
2837  STRG(4), /* String */
2838  val[5], /* Font */
2839  val[6],val[7]); /* Function,Color */
2840 
2841  XSync(DISP(0),0);
2842  success = TRUE;
2843 
2844  end_builtin();
2845 }
2846 
2847 
2848 /*****************************************************************/
2849 /******** DrawImageString
2850 
2851  xcDrawImageString(+Connection,+Drawable,+X,+Y,String,
2852  +Font,+Function,+Color)
2853 
2854  Print the string(foreground+background).
2855 
2856  */
2857 
2858 long xcDrawImageString()
2859 {
2861  ptr_definition types[8];
2862  long j;
2863  GC gc;
2864 
2865 
2866  for(j = 0; j < 8; j++)
2867  types[j] = real;
2868  types[1] = xdrawable;
2869  types[4] = quoted_string;
2870 
2871  begin_builtin(xcDrawImageString,8,8,types);
2872 
2873  gc = DrawableGC(args[1]);
2874  x_set_gc((Display *)val[0],gc,val[6],val[7],xDefaultLineWidth,val[5]);
2875 
2876  XDrawImageString(DISP(0),WIND(1),gc, /* Display,Window,GC */
2877  val[2],val[3], /* X,Y */
2878  STRG(4), /* String */
2879  strlen(STRG(4))); /* Length */
2880 
2881  x_record_string((ListHeader *)WindowDisplayList(args[1]),DRAW_IMAGE_STRING,
2882  val[2],val[3], /* X,Y */
2883  STRG(4), /* String */
2884  val[5], /* Font */
2885  val[6],val[7]); /* Function,Color */
2886 
2887  XSync(DISP(0),0);
2888  success = TRUE;
2889 
2890  end_builtin();
2891 }
2892 
2893 
2894 /*****************************************************************/
2895 /******** StringWidth
2896 
2897  xcStringWidth(+Connection,+Font,+String)
2898 
2899 
2900  returns the width in pixels of the string in the given font.
2901 
2902  */
2903 
2904 long xcStringWidth()
2905 {
2907  ptr_definition types[3];
2908  int direction,ascent,descent;
2909  XCharStruct overall;
2910 
2911 
2912  types[0] = real;
2913  types[1] = real;
2914  types[2] = quoted_string;
2915 
2916  begin_builtin(xcStringWidth,3,3,types);
2917 
2918  if(XQueryTextExtents(DISP(0),FONT(1),
2919  STRG(2),strlen(STRG(2)),/* string,nbchars */
2920  &direction,&ascent,&descent,&overall))
2921  {
2922  unify_real_result(aim->bbbb_1,(REAL) overall.width);
2923  success = TRUE;
2924  }
2925  else
2926  {
2927  Errorline("bad font in %P.\n",g);
2928  success = FALSE;
2929  }
2930 
2931  end_builtin();
2932 }
2933 
2934 
2935 /*****************************************************************/
2936 /******** SYNC
2937 
2938  xcSync(+Connection,+Discard)
2939 
2940  flush the output of the connection.
2941 
2942  */
2943 
2944 long xcSync()
2945 
2946 {
2948  ptr_definition types[2];
2949 
2950 
2951  types[0] = real;
2952  types[1] = real;
2953 
2954  begin_builtin(xcSync,2,2,types);
2955 
2956  XSync(DISP(0),val[1]);
2957  success = TRUE;
2958 
2959  end_builtin();
2960 }
2961 
2962 
2963 
2964 /*****************************************************************/
2965 /******** EVENTtoPSITERM */
2966 
2967 static ptr_psi_term xcEventToPsiTerm(event)
2968 
2969  XEvent *event;
2970 
2971 {
2972  ptr_psi_term psiEvent,psi_str;
2973  KeySym keysym;
2974  char buffer[10];
2975  char tstr[2], *str;
2976 
2977  str=tstr;
2978  tstr[1]=0;
2979 
2980  psiEvent = stack_psi_term(4);
2981  bk_stack_add_int_attr(psiEvent,"display",(long)event->xany.display);
2982  bk_stack_add_int_attr(psiEvent,"window",event->xany.window);
2983 
2984  switch(event->type) {
2985  case KeyPress:
2986  case KeyRelease:
2987  psiEvent->type = xkeyboard_event;
2988  bk_stack_add_int_attr(psiEvent,"x",event->xkey.x);
2989  bk_stack_add_int_attr(psiEvent,"y",event->xkey.y);
2990  bk_stack_add_int_attr(psiEvent,"state",event->xkey.state);
2991 
2992  buffer[0] = 0;
2993  *str = 0;
2994  XLookupString((XKeyEvent*)event,buffer,sizeof(buffer),&keysym,NULL);
2995  bk_stack_add_int_attr(psiEvent,"keycode",buffer[0]);
2996  if(keysym==XK_Return || keysym==XK_KP_Enter || keysym==XK_Linefeed)
2997  *str = CR;
2998  else
2999  if(keysym == XK_BackSpace || keysym == XK_Delete)
3000  *str = BS;
3001  else
3002  if(isascii(buffer[0]))
3003  /* if(isalnum(buffer[0]) || isspace(buffer[0])) 8.10 */
3004  *str = buffer[0];
3005 
3006  bk_stack_add_int_attr(psiEvent,"char",*str);
3007  break;
3008 
3009  case ButtonPress:
3010  case ButtonRelease:
3011  psiEvent->type = xbutton_event;
3012  bk_stack_add_int_attr(psiEvent,"x",event->xbutton.x);
3013  bk_stack_add_int_attr(psiEvent,"y",event->xbutton.y);
3014  bk_stack_add_int_attr(psiEvent,"x_root",event->xbutton.x_root);
3015  bk_stack_add_int_attr(psiEvent,"y_root",event->xbutton.y_root);
3016  bk_stack_add_int_attr(psiEvent,"state",event->xbutton.state);
3017  bk_stack_add_int_attr(psiEvent,"button",event->xbutton.button);
3018  break;
3019 
3020  case Expose:
3021  psiEvent->type = xexpose_event;
3022  bk_stack_add_int_attr(psiEvent,"width",event->xexpose.width);
3023  bk_stack_add_int_attr(psiEvent,"height",event->xexpose.height);
3024  break;
3025 
3026  case DestroyNotify:
3027  psiEvent->type = xdestroy_event;
3028  break;
3029 
3030  /*** RM 7/12/92 ***/
3031  case MotionNotify:
3032  psiEvent->type = xmotion_event;
3033  bk_stack_add_int_attr(psiEvent,"x",event->xbutton.x);
3034  bk_stack_add_int_attr(psiEvent,"y",event->xbutton.y);
3035  bk_stack_add_int_attr(psiEvent,"x_root",event->xbutton.x_root);
3036  bk_stack_add_int_attr(psiEvent,"y_root",event->xbutton.y_root);
3037  break;
3038 
3039  case ConfigureNotify:
3040  psiEvent->type = xconfigure_event;
3041  bk_stack_add_int_attr(psiEvent,"x",event->xconfigure.x);
3042  bk_stack_add_int_attr(psiEvent,"y",event->xconfigure.y);
3043  bk_stack_add_int_attr(psiEvent,"width",event->xconfigure.width);
3044  bk_stack_add_int_attr(psiEvent,"height",event->xconfigure.height);
3045  bk_stack_add_int_attr(psiEvent,"border_width",
3046  event->xconfigure.border_width);
3047  break;
3048  /*** RM 7/12/92(END) ***/
3049 
3050 
3051  /*** RM: May 3rd 1993 ***/
3052  case EnterNotify:
3053  psiEvent->type = xenter_event;
3054  goto LeaveEnterCommon;
3055 
3056  case LeaveNotify:
3057  psiEvent->type = xleave_event;
3058 
3059  LeaveEnterCommon:
3060  bk_stack_add_int_attr(psiEvent,"root", event->xcrossing.root);
3061  bk_stack_add_int_attr(psiEvent,"subwindow",event->xcrossing.subwindow);
3062 
3063  bk_stack_add_int_attr(psiEvent,"x",event->xcrossing.x);
3064  bk_stack_add_int_attr(psiEvent,"y",event->xcrossing.y);
3065 
3066  bk_stack_add_int_attr(psiEvent,"focus",event->xcrossing.focus);
3067  bk_stack_add_int_attr(psiEvent,"state",event->xcrossing.state);
3068 
3069  break;
3070 
3071 
3072  default:
3073  psiEvent->type = xmisc_event;
3074  bk_stack_add_int_attr(psiEvent,"event_type",event->type);
3075  break;
3076  }
3077 
3078  return psiEvent;
3079 }
3080 
3081 
3082 
3083 /*****************************************************************/
3084 
3085 /* some stuff to handle a list of psi-terms */
3086 /* RM: Dec 15 1992 Re-written to handle new list structure */
3087 
3088 
3089 
3090 /* RM: Dec 15 1992 Test if a list is empty */
3091 long list_is_nil(lst)
3092 
3093  ptr_psi_term(lst);
3094 
3095 {
3096  deref_ptr(lst);
3097  return lst->type==nil;
3098 }
3099 
3100 
3101 
3102 /* RM: Dec 15 1992 Return the CDR of a list */
3103 ptr_psi_term list_cdr(lst)
3104 
3105  ptr_psi_term(lst);
3106 {
3107  ptr_psi_term car;
3108  ptr_psi_term cdr;
3109 
3110 
3111  deref_ptr(lst);
3112  if(lst->type==alist) {
3113  get_two_args(lst->attr_list,&car,&cdr);
3114  if(cdr) {
3115  deref_ptr(cdr);
3116  return cdr;
3117  }
3118  }
3119 
3120  Errorline("X event handling error in CDR(%P)\n",lst);
3121  return lst;
3122 }
3123 
3124 
3125 
3126 /* RM: Dec 15 1992 Return the CAR of a list */
3127 ptr_psi_term list_car(lst)
3128 
3129  ptr_psi_term(lst);
3130 {
3131  ptr_psi_term car;
3132  ptr_psi_term cdr;
3133 
3134 
3135  deref_ptr(lst);
3136  if(lst->type==alist) {
3137  get_two_args(lst->attr_list,&car,&cdr);
3138  if(car) {
3139  deref_ptr(car);
3140  return car;
3141  }
3142  }
3143 
3144  Errorline("X event handling error in CAR(%P)\n",lst);
3145  return lst;
3146 }
3147 
3148 
3149 
3150 /* RM: Dec 15 1992 Set the CAR of a list */
3151 void list_set_car(lst,value)
3152 
3153  ptr_psi_term lst;
3154  ptr_psi_term value;
3155 {
3156  deref_ptr(lst);
3157  stack_insert(FEATCMP,one,&(lst->attr_list),(GENERIC)value);
3158 }
3159 
3160 
3161 /* RM: Dec 15 1992 Set the CDR of a list */
3162 void list_set_cdr(lst,value)
3163 
3164  ptr_psi_term lst;
3165  ptr_psi_term value;
3166 {
3167  deref_ptr(lst);
3168  stack_insert(FEATCMP,two,&(lst->attr_list),(GENERIC)value);
3169 }
3170 
3171 
3172 
3173 /* RM: Dec 15 1992 Return the last element of a list */
3174 ptr_psi_term list_last_cdr(lst)
3175 
3176  ptr_psi_term lst;
3177 {
3178  while(!list_is_nil(lst))
3179  lst=list_cdr(lst);
3180  return lst;
3181 }
3182 
3183 
3184 
3185 /* RM: Dec 15 1992 Append an element to a list,return the new CONS cell */
3186 ptr_psi_term append_to_list(lst,value)
3187 
3188  ptr_psi_term lst;
3189  ptr_psi_term value;
3190 {
3191  ptr_psi_term end;
3192 
3193  end=list_last_cdr(lst);
3195  end->coref=stack_cons(value,stack_nil());
3196  return end->coref;
3197 }
3198 
3199 
3200 /* RM: Dec 15 1992
3201  Map a function,while TRUE,over the CONS cells of a list */
3202 long map_funct_over_list(lst,proc,closure)
3203  ptr_psi_term lst;
3204  long(*proc)();
3205  long *closure;
3206 {
3207  long notInterrupted=TRUE;
3208 
3209  while(notInterrupted && !list_is_nil(lst)) {
3210  notInterrupted =(*proc)(lst,closure);
3211  lst=list_cdr(lst);
3212  }
3213 
3214  return notInterrupted;
3215 }
3216 
3217 
3218 
3219 /* RM: Dec 15 1992 Same thing,except map over the CARs of the list */
3220 long map_funct_over_cars(lst,proc,closure)
3221  ptr_psi_term lst;
3222  long(*proc)();
3223  long *closure;
3224 {
3225  ptr_psi_term cdr;
3226  int notInterrupted = TRUE;
3227 
3228  while(notInterrupted && !list_is_nil(lst)) {
3229  /* save the next because the current could be removed
3230  (eg: xcFlushEvents) */
3231 
3232  cdr=list_cdr(lst);
3233  notInterrupted=(*proc)(list_car(lst),closure);
3234  lst=cdr;
3235  }
3236 
3237  return notInterrupted;
3238 }
3239 
3240 
3241 
3242 /* RM: Dec 15 1992 Re-written for new lists */
3243 void list_remove_value(lst,value)
3244 
3245  ptr_psi_term lst;
3246  ptr_psi_term value;
3247 {
3248  ptr_psi_term car,cdr;
3249  long still_there=TRUE;
3250 
3251  deref_ptr(value);
3252  while(!list_is_nil(lst) && still_there) {
3253  car=list_car(lst);
3254  cdr=list_cdr(lst);
3255  if(car==value) {
3256  still_there=FALSE;
3257  push_ptr_value_global(psi_term_ptr,(GENERIC *)&(lst->coref));
3258  lst->coref=cdr;
3259  }
3260  lst=cdr;
3261  }
3262 }
3263 
3264 
3265 
3266 /*****************************************************************/
3267 /* Static */
3268 /* return FALSE if the events match */
3269 
3270 static long x_union_event(psiEvent,closure)
3271 
3272  ptr_psi_term psiEvent;
3273  EventClosure *closure;
3274 
3275 {
3276  return !((Display *)GetIntAttr(psiEvent,"display") == closure->display
3277  && (Window)GetIntAttr(psiEvent,"window") == closure->window
3278  &&(GetIntAttr(psiEvent,"mask") & closure->mask) != 0);
3279 }
3280 
3281 
3282 
3283 
3284 
3285 /*****************************************************************/
3286 /******** GetEvent
3287 
3288  xcGetEvent(+Display,+Window,+Mask)
3289 
3290  return an event matching the mask in the window.
3291  if no event residuate the call else return a null event.
3292 
3293  */
3294 
3295 long xcGetEvent()
3296 
3297 {
3299  ptr_definition types[3];
3300  XEvent event;
3301  ptr_psi_term psiEvent;
3302  ptr_psi_term eventElt;
3303  EventClosure eventClosure;
3304  ptr_psi_term result;
3305 
3306 
3307  types[0] = real;
3308  types[1] = xwindow;
3309  types[2] = real;
3310 
3311  result=aim->bbbb_1;
3312 
3313  begin_builtin(xcGetEvent,3,3,types);
3314 
3315  if(!xevent_existing) {
3316 
3317  /* warning if a same event is already waiting */
3318  eventClosure.display =DISP(0);
3319  eventClosure.window =WIND(1);
3320  eventClosure.mask = val[2];
3321  if(!map_funct_over_cars(xevent_list,x_union_event,(long *)&eventClosure))
3322  warningline("you have coinciding event handlers on the same window");
3323 
3324  /* transform the request into a psi-term */
3325  eventElt = stack_psi_term(4);
3326  bk_stack_add_int_attr(eventElt,"display",val[0]);
3327  bk_stack_add_int_attr(eventElt,"window",val[1]);
3328  bk_stack_add_int_attr(eventElt,"mask",val[2]);
3329 
3330  /* stack_insert(FEATURECMP,"event",&(eventElt->attr_list),(GENERIC)result); */
3331 
3332  /* add the request in the list of waiting events */
3333  append_to_list(xevent_list,eventElt); /* RM: Dec 15 1992 */
3334 
3335  /* residuate the call */
3336  residuate(eventElt); /* RM: May 5 1993 */
3337 
3338  /* return a psi-term containing an `empty' event */
3339  /* psiEvent = stack_psi_term(4);
3340  psiEvent->type = xevent; RM: May 5 1993 */
3341  }
3342  else {
3343  /* get the event built by x_exist_event */
3344  psiEvent = GetPsiAttr(xevent_existing,"event");
3345  push_ptr_value_global(psi_term_ptr,(GENERIC *)&xevent_existing);
3346  xevent_existing = NULL;
3347  push_goal(unify,psiEvent,aim->bbbb_1,NULL); /* RM: May 5 1993 */
3348  }
3349 
3350  /* push_goal(unify,psiEvent,aim->bbbb_1,NULL); RM: May 5 1993 */
3351 
3352  success = TRUE;
3353 
3354  end_builtin();
3355 }
3356 
3357 
3358 
3359 /*****************************************************************/
3360 /* Static */
3361 /* remove the event from the queue if matching */
3362 
3363 static long x_flush_event(eventElt,closure)
3364  ptr_psi_term eventElt;
3365  EventClosure *closure;
3366 {
3367  ptr_psi_term psiEvent;
3368 
3369 
3370  psiEvent = list_car(eventElt);
3371  if ((Display *)GetIntAttr(psiEvent,"display") == closure->display
3372  && (Window)GetIntAttr(psiEvent,"window") ==closure->window
3373  && (GetIntAttr(psiEvent,"mask") & closure->mask) != 0)
3374  {
3375  /* 9.10 */
3376  /* if(xevent_list == eventElt) */
3377  /* push_ptr_value_global(psi_term_ptr,(GENERIC *)&xevent_list); */
3378  /* xevent_list = list_remove_value(xevent_list,psiEvent); */
3379  list_remove_value(xevent_list,psiEvent); /* RM: Dec 15 1992 */
3380  }
3381 
3382  return TRUE;
3383 }
3384 
3385 
3386 /*****************************************************************/
3387 /******** FlushEvents
3388 
3389  xcFlushEvents(+Display,+Window,+Mask)
3390 
3391  flush all residuated events matching(display,window,mask).
3392 
3393  */
3394 
3395 long xcFlushEvents()
3396 
3397 {
3399  ptr_definition types[3];
3400  EventClosure eventClosure;
3401 
3402 
3403  types[0] = real;
3404  types[1] = xwindow;
3405  types[2] = real;
3406 
3407  begin_builtin(xcFlushEvents,3,3,types);
3408 
3409  eventClosure.display =DISP(0);
3410  eventClosure.window = val[1];
3411  eventClosure.mask = val[2];
3412  map_funct_over_list(xevent_list,x_flush_event,(long *)&eventClosure);
3413 
3414  success = TRUE;
3415 
3416  end_builtin();
3417 }
3418 
3419 #if 0
3420 
3421 /*****************************************************************/
3422 /******** xcSendEvent
3423 
3424  xcSendEvent(+Display,+Window,+Event)
3425 
3426  send the event to the specified window
3427 
3428  */
3429 
3430 long xcSendEvent()
3431 
3432 {
3434  ptr_definition types[3];
3435  XEvent event;
3436  ptr_psi_term psiEvent;
3437  ptr_node nodeAttr;
3438  ptr_psi_term psiValue;
3439 
3440 
3441  types[0] = real;
3442  types[1] = xwindow;
3443  types[2] = xevent;
3444 
3445  begin_builtin(xcSendEvent,3,3,types);
3446 
3447  if(xcPsiEventToEvent(val[2],&event))
3448  {
3449  XSendEvent((long)DISP(0),WIND(1),False,?,&event);
3450  success = TRUE;
3451  }
3452  else
3453  {
3454  Errorline("%P is not an event in %P.\n",val[2],g);
3455  success = FALSE;
3456  }
3457 
3458  end_builtin();
3459 }
3460 
3461 #endif
3462 
3463 
3464 /*** RM: 7/12/92 ***/
3465 
3466 /*****************************************************************/
3467 /******** xcQueryPointer
3468 
3469  xcQueryPointer(+Display,+Window,
3470  -root_return, -child_return,
3471  -root_x_return,-root_y_return,
3472  -win_x_return, -win_y_return,
3473  -mask_return, -same_screen)
3474 
3475  this predicate returns a psi-term containing loads of info about where the
3476  pointer is at. See 'XQueryPointer' for a complete definition(the boolean
3477  result of XQueryPointer is stored as 'same_screen'.
3478  */
3479 
3480 long xcQueryPointer()
3481 
3482 {
3483  include_var_builtin(10);
3484  ptr_definition types[10];
3485  Window root_return,child_return;
3486  int root_x_return,root_y_return;
3487  int win_x_return,win_y_return;
3488  unsigned int mask_return;
3489  long same_screen;
3490  long j;
3491 
3492 
3493 
3494  for(j=0; j<10; j++)
3495  types[j] = real;
3496 
3497  types[1] = xdrawable;
3498 
3499  begin_builtin(xcQueryPointer,10,2,types);
3500 
3501 
3502  same_screen=XQueryPointer(DISP(0),
3503  WIND(1),
3504  &root_return, &child_return,
3505  &root_x_return,&root_y_return,
3506  &win_x_return, &win_y_return,
3507  &mask_return);
3508 
3509 
3510  unify_real_result(args[2],(REAL)root_return);
3511  unify_real_result(args[3],(REAL)child_return);
3512  unify_real_result(args[4],(REAL)root_x_return);
3513  unify_real_result(args[5],(REAL)root_y_return);
3514  unify_real_result(args[6],(REAL)win_x_return);
3515  unify_real_result(args[7],(REAL)win_y_return);
3516  unify_real_result(args[8],(REAL)mask_return);
3517  unify_real_result(args[9],(REAL)same_screen);
3518 
3519  /* printf("root: %ld\nchild: %ld\n",root_return,child_return); */
3520 
3521  success = TRUE;
3522 
3523  end_builtin();
3524 }
3525 
3526 /*** RM: 7/12/92(END) ***/
3527 
3528 
3529 
3530 
3531 /*****************************************************************/
3532 /******** SETUPBUILTINS
3533 
3534  Set up the X built-in predicates.
3535 
3536  */
3537 
3538 void x_setup_builtins()
3539 
3540 {
3541  set_current_module(x_module); /* RM: Feb 3 1993 */
3542 
3543  raw_setup_builtins(); /* to move in life.c */
3544 
3545  XSetErrorHandler(x_handle_error);
3546  XSetIOErrorHandler(x_handle_fatal_error);
3547 
3548  set_current_module(x_module); /* RM: Feb 3 1993 */
3549  xevent = update_symbol(x_module,"event");
3550  xkeyboard_event = update_symbol(x_module,"keyboard_event");
3551  xbutton_event = update_symbol(x_module,"button_event");
3552  xexpose_event = update_symbol(x_module,"expose_event");
3553  xdestroy_event = update_symbol(x_module,"destroy_event");
3554 
3555  /*** RM: 7/12/92 ***/
3556  xconfigure_event = update_symbol(x_module,"configure_event");
3557  xmotion_event = update_symbol(x_module,"motion_event");
3558  /*** RM: 7/12/92 ***/
3559 
3560 
3561  /*** RM: 3 May 92 ***/
3562  xenter_event = update_symbol(x_module,"enter_event");
3563  xleave_event = update_symbol(x_module,"leave_event");
3564  xmisc_event = update_symbol(x_module,"misc_event");
3565 
3566  /*** RM: 3 May 92 ***/
3567 
3568  xdisplay = update_symbol(x_module,"display");
3569  xdrawable = update_symbol(x_module,"drawable");
3570  xwindow = update_symbol(x_module,"window");
3571  xpixmap = update_symbol(x_module,"pixmap");
3572 
3573  xgc = update_symbol(x_module,"graphic_context");
3574  xdisplaylist = update_symbol(x_module,"display_list");
3575 
3576  new_built_in(x_module,"xcOpenConnection", (def_type) predicate,xcOpenConnection);
3577  new_built_in(x_module,"xcDefaultRootWindow", (def_type) predicate,xcDefaultRootWindow);
3578  new_built_in(x_module,"xcGetScreenAttribute", (def_type) predicate,xcGetScreenAttribute);
3579  new_built_in(x_module,"xcGetConnectionAttribute",(def_type) predicate,xcGetConnectionAttribute);
3580  new_built_in(x_module,"xcCloseConnection", (def_type) predicate,xcCloseConnection);
3581 
3582  new_built_in(x_module,"xcCreateSimpleWindow", (def_type) predicate,xcCreateSimpleWindow);
3583 #if 0
3584  new_built_in(x_module,"xcCreateWindow", (def_type) predicate,xcCreateWindow);
3585 #endif
3586 
3587  new_built_in(x_module,"xcSetStandardProperties", (def_type) predicate,xcSetStandardProperties);
3588  new_built_in(x_module,"xcGetWindowGeometry", (def_type) predicate,xcGetWindowGeometry);
3589  new_built_in(x_module,"xcSetWindowGeometry", (def_type) predicate,xcSetWindowGeometry);
3590  new_built_in(x_module,"xcGetWindowAttribute", (def_type) predicate,xcGetWindowAttribute);
3591  new_built_in(x_module,"xcSetWindowAttribute", (def_type) predicate,xcSetWindowAttribute);
3592  new_built_in(x_module,"xcMapWindow", (def_type) predicate,xcMapWindow);
3593 
3594  /* RM: May 6 1993 */
3595  new_built_in(x_module,"xcRaiseWindow", (def_type) predicate,xcRaiseWindow);
3596 
3597  new_built_in(x_module,"xcUnmapWindow", (def_type) predicate,xcUnmapWindow);
3598 
3599  /*** RM 8/12/92 ***/
3600  new_built_in(x_module,"xcMapSubwindows", (def_type) predicate,xcMapSubwindows);
3601  new_built_in(x_module,"xcUnmapSubwindows", (def_type) predicate,xcUnmapSubwindows);
3602  /*** RM 8/12/92 ***/
3603 
3604  new_built_in(x_module,"xcClearWindow", (def_type) predicate,xcClearWindow);
3605  new_built_in(x_module,"xcResizeWindowPixmap", (def_type) predicate,xcResizeWindowPixmap);
3606 
3607  new_built_in(x_module,"xcSelectInput", (def_type) predicate,xcSelectInput);
3608  new_built_in(x_module,"xcRefreshWindow", (def_type) predicate,xcRefreshWindow);
3609  new_built_in(x_module,"xcPostScriptWindow", (def_type) predicate,xcPostScriptWindow);
3610  new_built_in(x_module,"xcDestroyWindow", (def_type) predicate,xcDestroyWindow);
3611 
3612  new_built_in(x_module,"xcCreateGC", (def_type) predicate,xcCreateGC);
3613  new_built_in(x_module,"xcGetGCAttribute", (def_type) predicate,xcGetGCAttribute);
3614  new_built_in(x_module,"xcSetGCAttribute", (def_type) predicate,xcSetGCAttribute);
3615  new_built_in(x_module,"xcDestroyGC", (def_type) predicate,xcDestroyGC);
3616 
3617  new_built_in(x_module,"xcDrawLine", (def_type) predicate,xcDrawLine);
3618  new_built_in(x_module,"xcMoveWindow", (def_type) predicate,xcMoveWindow);
3619  new_built_in(x_module,"xcDrawArc", (def_type) predicate,xcDrawArc);
3620  new_built_in(x_module,"xcDrawRectangle", (def_type) predicate,xcDrawRectangle);
3621  new_built_in(x_module,"xcDrawPolygon", (def_type) predicate,xcDrawPolygon);
3622 
3623  new_built_in(x_module,"xcLoadFont", (def_type) predicate,xcLoadFont);
3624  new_built_in(x_module,"xcUnloadFont", (def_type) predicate,xcUnloadFont);
3625  new_built_in(x_module,"xcDrawString", (def_type) predicate,xcDrawString);
3626  new_built_in(x_module,"xcDrawImageString", (def_type) predicate,xcDrawImageString);
3627  new_built_in(x_module,"xcStringWidth", (def_type) function_it, xcStringWidth);
3628 
3629  new_built_in(x_module,"xcRequestColor", (def_type) predicate,xcRequestColor);
3630  new_built_in(x_module,"xcRequestNamedColor", (def_type) predicate,xcRequestNamedColor);
3631  new_built_in(x_module,"xcFreeColor", (def_type) predicate,xcFreeColor);
3632 
3633  new_built_in(x_module,"xcFillRectangle", (def_type) predicate,xcFillRectangle);
3634  new_built_in(x_module,"xcFillArc", (def_type) predicate,xcFillArc);
3635  new_built_in(x_module,"xcFillPolygon", (def_type) predicate,xcFillPolygon);
3636 
3637  new_built_in(x_module,"xcPointsAlloc", (def_type) predicate,xcPointsAlloc);
3638  new_built_in(x_module,"xcCoordPut", (def_type) predicate,xcCoordPut);
3639  new_built_in(x_module,"xcPointsFree", (def_type) predicate,xcPointsFree);
3640 
3641  new_built_in(x_module,"xcSync", (def_type) predicate,xcSync);
3642  new_built_in(x_module,"xcGetEvent", (def_type) function_it, xcGetEvent);
3643  new_built_in(x_module,"xcFlushEvents", (def_type) predicate,xcFlushEvents);
3644 
3645  /*** RM: 7/12/92 ***/
3646  new_built_in(x_module,"xcQueryPointer", (def_type) predicate,xcQueryPointer);
3647  /*** RM: 7/12/92 ***/
3648 
3649  /* RM: Apr 20 1993 */
3650  new_built_in(x_module,"xcQueryTextExtents",(def_type) predicate,xcQueryTextExtents);
3651 }
3652 
3653 
3654 
3655 /*****************************************************************/
3656 /* not a built-in */
3657 /* called by what_next_aim in login.c */
3658 
3659 static long WaitNextEvent(ptreventflag)
3660  long *ptreventflag;
3661 {
3662  long nfds;
3663  fd_set readfd,writefd,exceptfd;
3664  struct timeval timeout;
3665  long charflag = FALSE,nbchar;
3666  char c = 0;
3667 
3668 
3669  *ptreventflag = FALSE;
3670 
3671  do
3672  {
3673  FD_ZERO(&readfd);
3674  FD_SET(stdin_fileno, &readfd);
3675  FD_ZERO(&writefd);
3676  FD_ZERO(&exceptfd);
3677  timeout.tv_sec = 0;
3678  timeout.tv_usec = 100000;
3679 
3680  nfds = select(32,&readfd,&writefd,&exceptfd,&timeout);
3681  if(nfds == -1)
3682  {
3683 #if 0
3684  /* not an error,but a signal has been occured */
3685  /* handle_interrupt(); does not work */
3686  exit();
3687 #endif
3688  if(errno != EINTR)
3689  {
3690  Errorline("in select: interruption error.\n");
3691  exit_life(TRUE);
3692  }
3693  else
3694  interrupt();
3695  }
3696 
3697  else
3698  if(nfds == 0)
3699  {
3700 #ifdef X11
3701  if(x_exist_event())
3702  {
3703  *ptreventflag = TRUE;
3704  start_of_line = TRUE;
3705  }
3706 #endif
3707  }
3708  else
3709  {
3710  if(FD_ISSET(stdin_fileno, &readfd) != 0)
3711  {
3712 #if 0
3713  if((nbchar = read(stdin_fileno,&c,1)) == -1)
3714  {
3715  Errorline("in select: keyboard error.\n");
3716  exit_life(TRUE);
3717  }
3718 
3719  /* see manpage of read */
3720  if(nbchar == 0)
3721  c = EOF;
3722 #endif
3723  c = fgetc(input_stream);
3724  charflag = TRUE;
3725  }
3726  else
3727  {
3728  Errorline("select error.\n");
3729  exit_life(TRUE);
3730  }
3731  }
3732  } while(!(charflag || *ptreventflag));
3733 
3734  return c;
3735 }
3736 
3737 /*****************************************/
3738 
3739 
3740 long x_read_stdin_or_event(ptreventflag)
3741  long *ptreventflag;
3742 {
3743  long c = 0;
3744 
3745 
3746  *ptreventflag = FALSE;
3747 
3748  if(c = saved_char) /* not an error ;-) */
3749  {
3751  old_saved_char=0;
3752  }
3753  else
3754  {
3755  if(input_stream == NULL || feof(input_stream))
3756  c = EOF;
3757  else
3758  {
3759  if(start_of_line)
3760  {
3761  start_of_line = FALSE;
3762  line_count ++ ;
3763  infoline("%s",prompt);
3764  fflush(output_stream);
3765  }
3766 
3767  c = WaitNextEvent(ptreventflag);
3768 
3769  if(*ptreventflag)
3770  {
3771  if(verbose) printf("<X event>");
3772  if(NOTQUIET) printf("\n"); /* 21.1 */
3773  }
3774 
3775  if(c == EOLN)
3776  start_of_line = TRUE;
3777  }
3778  }
3779 
3780  return c;
3781 }
3782 
3783 
3784 /*****************************************************************/
3785 /* Static */
3786 /* returns TRUE if the mask matches the type */
3787 
3788 static long mask_match_type(mask,type)
3789  long mask,type;
3790 {
3791  long em;
3792 
3793  /* printf("mask=%d,type=%d=%s\n",mask,type,xevent_name[type]); */
3794 
3795  em=xevent_mask[type];
3796  if(!em ||(em & mask))
3797  return TRUE;
3798 
3799  /* printf("FALSE\n"); printf("event mask=%d\n",em); */
3800 
3801  return FALSE;
3802 }
3803 
3804 
3805 
3806 /*****************************************************************/
3807 /* Static */
3808 /* returns the psi-event of the list corresponding to the existing event */
3809 
3810 static ptr_psi_term x_what_psi_event(beginSpan,endSpan,eventType)
3811  ptr_psi_term beginSpan,endSpan;
3812  long eventType;
3813 {
3814  if(beginSpan == endSpan)
3815  return list_car(beginSpan);
3816  else
3817  if(mask_match_type(GetIntAttr(list_car(beginSpan),"mask"),
3818  eventType))
3819  return list_car(beginSpan);
3820  else
3821  return x_what_psi_event(list_cdr(beginSpan),
3822  endSpan,eventType);
3823 }
3824 
3825 
3826 
3827 /*****************************************************************/
3828 /* Static */
3829 /* builds xevent_existing */
3830 
3831 static void x_build_existing_event(event,beginSpan,endSpan,eventType)
3832  XEvent *event;
3833  ptr_psi_term beginSpan,endSpan;
3834  long eventType;
3835 {
3836  ptr_psi_term psiEvent;
3837 
3838 
3839  /* printf("building event: type=%s event=%s\n",
3840  xevent_name[type],xevent_name[event->type]); */
3841 
3842  /* get the event from the list */
3843  psiEvent = x_what_psi_event(beginSpan,endSpan,eventType);
3844 
3845  /* put the event on the waiting event */
3846  bk_change_psi_attr(psiEvent,"event",xcEventToPsiTerm(event));
3847 
3848  /* set the global */
3849  if(xevent_existing)
3850  warningline("xevent_existing is non-null in x_build_existing_event");
3851  push_ptr_value_global(psi_term_ptr,(GENERIC *)&xevent_existing);
3852  xevent_existing = psiEvent;
3853 
3854  /* remove the event from the list */
3855  /* 9.10 */
3856  /* if(list_car(xevent_list) == psiEvent) */
3857  /* push_ptr_value_global(psi_term_ptr,(GENERIC *)&xevent_list); */
3858  /* xevent_list = list_remove_value(xevent_list,psiEvent); */
3859  list_remove_value(xevent_list,psiEvent); /* RM: Dec 15 1992 */
3860 }
3861 
3862 
3863 
3864 /*****************************************************************/
3865 /* Static */
3866 /* get the next span of waiting events */
3867 
3868 static long x_next_event_span(eventElt,eventClosure)
3869  ptr_psi_term eventElt;
3870  EventClosure *eventClosure;
3871 {
3872  ptr_psi_term psiEvent;
3873  Display *display;
3874  Window window;
3875  long mask;
3876  XEvent event;
3877 
3878 
3879  psiEvent = list_car(eventElt);
3880  display =(Display *)GetIntAttr(psiEvent,"display");
3881  window =(Window)GetIntAttr(psiEvent,"window");
3882  mask = GetIntAttr(psiEvent,"mask");
3883 
3884  if(eventClosure->display == NULL) {
3885  /* new span */
3886  eventClosure->display = display;
3887  eventClosure->window = window;
3888  eventClosure->mask = mask;
3889  eventClosure->beginSpan = eventElt;
3890  return TRUE;
3891  }
3892  else
3893  if(eventClosure->display == display && eventClosure->window == window) {
3894  /* same span */
3895  eventClosure->mask |= mask;
3896  return TRUE;
3897  }
3898  else {
3899  /* a next span begins,check the current span */
3900  Repeat:
3901  if(XCheckWindowEvent(eventClosure->display,eventClosure->window,
3902  eventClosure->mask,&event)
3903  /* && event.xany.window == eventClosure->window */)
3904  {
3905  /* 9.10 */
3906  /* printf("Event type = %ld.\n",event.type); */
3907 
3908 
3909  if((event.type==Expose || event.type==GraphicsExpose)
3910  && event.xexpose.count!=0) {
3911  /* printf("Expose count = %ld.\n", event.xexpose.count); */
3912  goto Repeat;
3913  }
3914 
3915  /* build a psi-term containing the event */
3916 
3917  /* printf("*** event %d ***\n",event.type); */
3918 
3919  x_build_existing_event(&event,
3920  eventClosure->beginSpan,
3921  eventElt,event.type);
3922 
3923  return FALSE; /* stop ! we have an existing event !! */
3924  }
3925  else
3926  {
3927  /* init the new span */
3928  eventClosure->display = display;
3929  eventClosure->window = window;
3930  eventClosure->mask = mask;
3931  eventClosure->beginSpan = eventElt;
3932  return TRUE;
3933  }
3934  }
3935 }
3936 
3937 
3938 
3939 /*****************************************************************/
3940 /* not a built-in */
3941 /* used by main_prove() and what_next() */
3942 
3943 long x_exist_event()
3944 {
3945  XEvent event,exposeEvent;
3946  ptr_psi_term eventElt;
3947  EventClosure eventClosure;
3948 
3949 
3950  /*Infoline("xevent_list=%P\n",xevent_list); */
3951 
3952  if(xevent_existing)
3953  return TRUE;
3954 
3955  if(list_is_nil(xevent_list)) {
3956  /* printf("nil event list\n"); */
3957  return FALSE;
3958  }
3959 
3960 
3961  /* traverse the list of waiting events */
3962  eventClosure.display = NULL;
3963  if(!map_funct_over_list(xevent_list,x_next_event_span,(long *)&eventClosure))
3964  return TRUE;
3965 
3966  /* printf("display=%d,window=%d,mask=%d\n",
3967  eventClosure.display,eventClosure.window,eventClosure.mask); */
3968 
3969 
3970 
3971  /* check the last span */
3972  if(XCheckWindowEvent(eventClosure.display,
3973  eventClosure.window,
3974  eventClosure.mask,
3975  &event)) {
3976 
3977  /* printf("*** here event %d ***\n",event.xany.type); */
3978 
3979  if(event.xany.window==eventClosure.window) {
3980  if(event.type == Expose)
3981  while(XCheckWindowEvent(eventClosure.display,
3982  eventClosure.window,
3983  ExposureMask,
3984  &exposeEvent))
3985  ; /* that is continue until no expose event */
3986 
3987  /* build a psi-term containing the event */
3988  x_build_existing_event(&event,
3989  eventClosure.beginSpan,
3990  list_last_cdr(xevent_list),/* RM: Dec 15 1992*/
3991  event.type);
3992  return TRUE;
3993  }
3994  }
3995  else
3996  return FALSE;
3997 }
3998 
3999 
4000 
4001 /*****************************************************************/
4002 /* used when backtracking a created window in order to destroy the window */
4003 
4004 void x_destroy_window(display,window)
4005 
4006  Display *display;
4007  Window window;
4008 
4009 {
4010  /* we need the psi-term window(not the value) to get the display list,the pixmap ...
4011  jch - Fri Aug 7 15:29:14 MET DST 1992
4012 
4013  FreeWindow(display,window);
4014  */
4015  XDestroyWindow(display,window);
4016  XSync(display,0);
4017 }
4018 
4019 
4020 /*****************************************************************/
4021 /* used when backtracking a xcUnmapWindow in order to show the window */
4022 
4023 void x_show_window(display,window)
4024 
4025  Display *display;long window;
4026 
4027 {
4028  XMapWindow(display,window);
4029  XSync(display,0);
4030 }
4031 
4032 
4033 /*****************************************************************/
4034 /* used when backtracking a xcMapWindow in order to hide the window */
4035 
4036 void x_hide_window(display,window)
4037 
4038  Display *display; long window;
4039 
4040 {
4041  XUnmapWindow(display,window);
4042  XSync(display,0);
4043 }
4044 
4045 
4046 /*** RM 8/12/92 ***/
4047 
4048 /*****************************************************************/
4049 /* used when backtracking a xcUnmapWindow in order to show the window */
4050 
4051 void x_show_subwindow(display,window)
4052 
4053  Display *display; long window;
4054 
4055 {
4056  XMapSubwindows(display,window);
4057  XSync(display,0);
4058 }
4059 
4060 
4061 /*****************************************************************/
4062 /* used when backtracking a xcMapWindow in order to hide the window */
4063 
4064 void x_hide_subwindow(display,window)
4065 
4066  Display *display; long window;
4067 
4068 {
4069  XUnmapSubwindows(display,window);
4070  XSync(display,0);
4071 }
4072 
4073 /*** RM 8/12/92 ***/
4074 
4075 
4076 
4077 /*** RM: Apr 20 1993 ***/
4078 
4079 
4080 /*
4081  xcQueryTextExtents(display,font,string,
4082  direction,font-ascent,font-descent,
4083  left-bearing,right-bearing,width,ascent,descent)
4084  */
4085 
4086 long xcQueryTextExtents()
4087 
4088 {
4089  include_var_builtin(11);
4090  ptr_definition types[11];
4091  Font font;
4092  XCharStruct over;
4093  int i;
4094  int direction,ascent,descent; /* RM: 28 Jan 94 */
4095 
4096  types[0] = real; /* +Display */
4097  types[1] = real; /* +Font ID */
4098  types[2] = quoted_string; /* +String */
4099  types[3] = real; /* -Direction */
4100  types[4] = real; /* -Font-ascent */
4101  types[5] = real; /* -Font-descent */
4102  types[6] = real; /* -left bearing */
4103  types[7] = real; /* -right bearing */
4104  types[8] = real; /* -width */
4105  types[9] = real; /* -ascent */
4106  types[10]= real; /* -descent */
4107 
4108 
4109 
4110  begin_builtin(xcLoadFont,11,3,types);
4111 
4112 
4113  XQueryTextExtents(DISP(0),
4114  (XID)val[1],
4115  STRG(2),
4116  strlen(STRG(2)),
4117  &direction,
4118  &ascent,
4119  &descent,
4120  &over);
4121 
4122  val[3]=direction;
4123  val[4]=ascent;
4124  val[5]=descent;
4125 
4126  val[6] =over.lbearing;
4127  val[7] =over.rbearing;
4128  val[8] =over.width;
4129  val[9] =over.ascent;
4130  val[10]=over.descent;
4131 
4132  for(i=3;i<11;i++)
4133  unify_real_result(args[i],(REAL)val[i]);
4134 
4135  end_builtin();
4136 }
4137 /*** RM: Apr 20 1993 ***/
4138 
4139 
4140 /*****************************************************************/
4141 /* not used anymore, but interesting */
4142 
4143 ptr_goal GoalFromPsiTerm(psiTerm)
4144 
4145  ptr_psi_term psiTerm;
4146 
4147 {
4148  ptr_residuation resid;
4149  ptr_goal aim;
4150 
4151 
4152  if(psiTerm == NULL)
4153  {
4154  Errorline("X error in GoalFromPsiTerm: psiTerm is null\n");
4155  return FALSE;
4156  }
4157 
4158  if((resid = psiTerm->resid) == NULL)
4159  {
4160  Errorline("X error in GoalFromPsiTerm: psiTerm has no residuating functions\n");
4161  return FALSE;
4162  }
4163 
4164  if(resid->next != NULL)
4165  {
4166  Errorline("X error in GoalFromPsiTerm: psiTerm has more than one residuating function\n");
4167  return FALSE;
4168  }
4169 
4170  if((aim = resid->goal) == NULL)
4171  {
4172  Errorline("X error in GoalFromPsiTerm: psiTerm has no goal\n");
4173  return FALSE;
4174  }
4175 
4176  return aim;
4177 }
4178 
4179 
4180 #endif
#define show_subwindow
Definition: def_const.h:186
void new_built_in(ptr_module m, char *s, def_type t, long(*r)())
Definition: built_ins.c:5054
#define xDefaultLineWidth
Definition: def_const.h:240
#define hide_subwindow
Definition: def_const.h:187
#define predicate
Definition: def_const.h:361
#define function_it
Definition: def_const.h:362
void get_two_args(ptr_node t, ptr_psi_term *a, ptr_psi_term *b)
Definition: login.c:37
void interrupt()
Definition: interrupt.c:13
#define FEATCMP
Definition: def_const.h:257
void show(long limit)
Definition: parser.c:52
ptr_psi_term stack_cons(ptr_psi_term head, ptr_psi_term tail)
Definition: built_ins.c:47
void residuate(ptr_psi_term t)
Definition: lefun.c:113
void exit_life(long nl_flag)
Definition: built_ins.c:2090
void push_ptr_value(type_ptr t, GENERIC *p)
Definition: login.c:360
#define show_window
Definition: def_const.h:184
#define NOTQUIET
Definition: def_macro.h:10
ptr_definition xdisplaylist
Definition: def_glob.h:211
void push_goal(goals t, ptr_psi_term a, ptr_psi_term b, GENERIC c)
Definition: login.c:555
#define def_ptr
Definition: def_const.h:173
ptr_node bk_stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:309
ptr_goal goal
Definition: def_struct.h:156
ptr_psi_term xevent_list
Definition: def_glob.h:208
long start_of_line
Definition: def_glob.h:191
ptr_definition xbutton_event
Definition: def_glob.h:211
ptr_residuation next
Definition: def_struct.h:157
long verbose
Definition: def_glob.h:273
char * two
Definition: def_glob.h:251
void push_ptr_value_global(type_ptr t, GENERIC *p)
Definition: login.c:488
long matches(ptr_definition t1, ptr_definition t2, long *smaller)
Definition: types.c:1565
#define destroy_window
Definition: def_const.h:183
#define stdin_fileno
Definition: def_const.h:343
ptr_definition xexpose_event
Definition: def_glob.h:211
ptr_keyword keyword
Definition: def_struct.h:124
GENERIC data
Definition: def_struct.h:185
long old_saved_char
Definition: def_glob.h:193
#define NULL
Definition: def_const.h:203
char * symbol
Definition: def_struct.h:91
long saved_char
Definition: def_glob.h:192
ptr_definition xgc
Definition: def_glob.h:211
#define REAL
Definition: def_const.h:72
long x_window_creation
Definition: def_glob.h:217
ptr_definition update_symbol(ptr_module module, char *symbol)
Definition: modules.c:264
ptr_definition xmotion_event
Definition: def_glob.h:211
#define begin_builtin(FUNCNAME, NBARGS, NBARGSIN, TYPES)
Definition: def_macro.h:198
ptr_definition xmisc_event
Definition: def_glob.h:211
void release_resid(ptr_psi_term t)
Definition: lefun.c:414
long line_count
Definition: def_glob.h:39
#define hide_window
Definition: def_const.h:185
void Errorline(char *format,...)
Definition: error.c:414
char * heap_copy_string(char *s)
Definition: trees.c:147
#define EOLN
Definition: def_const.h:140
ptr_definition real
Definition: def_glob.h:102
ptr_node stack_insert(long comp, char *keystr, ptr_node *tree, GENERIC info)
Definition: trees.c:291
char * buffer
Definition: def_glob.h:175
#define deref_ptr(P)
Definition: def_macro.h:95
ptr_definition alist
Definition: def_glob.h:94
void infoline(char *format,...)
Definition: error.c:245
ptr_definition xkeyboard_event
Definition: def_glob.h:211
#define TRUE
Definition: def_const.h:127
ptr_definition xwindow
Definition: def_glob.h:211
ptr_definition integer
Definition: def_glob.h:93
#define FALSE
Definition: def_const.h:128
int arg_c
Definition: def_glob.h:5
ptr_definition quoted_string
Definition: def_glob.h:101
char * arg_v[10]
Definition: def_glob.h:6
ptr_psi_term stack_psi_term(long stat)
Definition: lefun.c:15
FILE * input_stream
Definition: def_glob.h:38
GENERIC value_3
Definition: def_struct.h:170
ptr_psi_term stack_nil()
Definition: built_ins.c:29
ptr_goal aim
Definition: def_glob.h:49
ptr_psi_term coref
Definition: def_struct.h:172
ptr_definition xpixmap
Definition: def_glob.h:211
char * one
Definition: def_glob.h:250
ptr_definition xenter_event
Definition: def_glob.h:211
ptr_definition xevent
Definition: def_glob.h:211
void clean_undo_window(long disp, long wind)
Definition: login.c:792
#define xDefaultFont
Definition: def_const.h:239
#define unify
Definition: def_const.h:274
ptr_node find(long comp, char *keystr, ptr_node tree)
Definition: trees.c:341
void push_window(long type, long disp, long wind)
Definition: login.c:510
ptr_definition xdisplay
Definition: def_glob.h:211
struct wl_psi_term * ptr_psi_term
Definition: def_struct.h:34
void raw_setup_builtins()
Definition: raw.c:327
char * prompt
Definition: def_glob.h:42
long unify_real_result(ptr_psi_term t, REAL v)
Definition: built_ins.c:371
ptr_module x_module
Definition: def_glob.h:158
ptr_definition xdestroy_event
Definition: def_glob.h:211
FILE * output_stream
Definition: def_glob.h:41
ptr_definition nil
Definition: def_glob.h:97
ptr_definition xleave_event
Definition: def_glob.h:211
void warningline(char *format,...)
Definition: error.c:327
ptr_definition type
Definition: def_struct.h:165
ptr_psi_term bbbb_1
Definition: def_struct.h:225
ptr_definition xconfigure_event
Definition: def_glob.h:211
ptr_definition boolean
Definition: def_glob.h:73
unsigned long * GENERIC
Definition: def_struct.h:17
ptr_psi_term xevent_existing
Definition: def_glob.h:208
#define include_var_builtin(NBARGS)
Definition: def_macro.h:191
#define end_builtin()
Definition: def_macro.h:254
ptr_module set_current_module(ptr_module module)
Definition: modules.c:95
ptr_goal GoalFromPsiTerm(ptr_psi_term psiTerm)
long i_check_out(ptr_psi_term t)
Definition: lefun.c:985
GENERIC heap_alloc(long s)
Definition: memory.c:1518
ptr_definition xdrawable
Definition: def_glob.h:211
#define psi_term_ptr
Definition: def_const.h:170
#define int_ptr
Definition: def_const.h:172