home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / lisp / x / 215 < prev    next >
Encoding:
Text File  |  1992-09-09  |  6.8 KB  |  245 lines

  1. Newsgroups: comp.lang.lisp.x
  2. Path: sparky!uunet!decwrl!pa.dec.com!nntpd2.cxo.dec.com!talguy!scott
  3. From: scott@talguy.cxo.dec.com (Scott Johnson)
  4. Subject: Forget the previous note about trouble with clx and lcl.
  5. Message-ID: <1992Sep9.223136.9810@nntpd2.cxo.dec.com>
  6. Lines: 233
  7. Sender: scott@talguy (Scott Johnson)
  8. Reply-To: scott@talguy.cxo.dec.com (Scott Johnson)
  9. Organization: Digital Equipment Corporation, Colorado Springs, Co
  10. Date: Wed, 9 Sep 1992 22:31:36 GMT
  11.  
  12.  
  13. Return-Path: scott
  14. To: gilroy::"dec-support@lucid.com"
  15. Cc: scott, gldoa::fuller
  16. Subject: More Information for CLX Problem and help requested.
  17. Date: Wed, 09 Sep 92 16:26:05 -0600
  18. From: scott
  19. X-Mts: smtp
  20.  
  21. Hi,
  22.  
  23. There seems to be a problem between lcl and the xlib/clx routines. If you can
  24. help any, I would appreciate it.
  25.  
  26. The problem is that the lisp stuff does not succeed as does the same thing 
  27. in c.  To demonstrate the problem, I create two decterm windows with on being
  28. titled "talguy" and the other being titled "csc32".  The one titled "csc32"
  29. is the one that gets popped to the top or pushed to the bottom of the stack
  30. of windows.  Oh yeah, the windows do occlude each other. The decterm labeled 
  31. "talguy" is on the top of and partially occludes the decterm labeled "csc32".
  32.  
  33. To perform the test using the lisp code, simply load the code and invoke
  34. (decwindows-toggle-up) followed by a call to (decwindows-toggle-down).  The
  35. c code will do this automatically when it is executed.  To succeed, the decterm
  36. labeled "csc32" should pop to the top of the stack and then get pushed to the 
  37. bottom of the stack.
  38.  
  39. Scott Johnson
  40.  
  41. -------------
  42. test.lisp
  43. -------------
  44. ;
  45. ; This is used to test a problem with clx.  It seems to have trouble finding
  46. ; a match for the title name when it calls clx:wm-name.  Unless it finds a 
  47. ; match, knowledge-window and driver-window are set to nil.  If
  48. ; these two variables are set to nil, then the call to circulate-window-up
  49. ; and circulate-window-down fails.
  50. ;
  51. (IN-PACKAGE "USER")
  52.  
  53. #.(if (equal "DEC ULTRIX" (software-type))
  54.     (rename-package "XLIB" "XLIB" '("CLX"))
  55. )
  56.                                                                
  57. (progn
  58.     (defvar display (clx:open-display (machine-instance)))
  59.     (defvar screen (clx:display-default-screen display))
  60.     (defvar root (clx:screen-root screen))
  61.     (defvar knowledge-window nil)
  62.     (defvar driver-window nil)
  63. )
  64.  
  65. (defun windowlist (window-id)
  66.    (if (not (null window-id))
  67.       (progn
  68.          (setq win (clx:wm-name window-id))
  69.          (if (not (equal "" win))
  70.         (format nil "The wm-name for ~D is ~A." window-id win))
  71.          (if (equal "csc32" win)
  72.             (setq knowledge-window window-id))
  73.          (mapcar #'(lambda (x) 
  74.             (if (null knowledge-window) (windowlist x))
  75.                    )
  76.             (clx:query-tree window-id)))))
  77.  
  78. (defun windowlist1 (window-id)
  79.    (if (not (null window-id))
  80.       (progn
  81.          (setq win (clx:wm-name window-id))
  82.          (if (not (equal "" win))
  83.         (format nil "The wm-name for ~D is ~A." window-id win))
  84.          (if (equal "talguy" win)
  85.             (setq driver-window window-id))
  86.          (mapcar #'(lambda (x) 
  87.             (if (null driver-window) (windowlist1 x))
  88.                    )
  89.             (clx:query-tree window-id)))))
  90.  
  91. (progn
  92.    (windowlist  root)
  93.    (windowlist1 root)
  94.    (if (equal "DEC ULTRIX" (software-type)) 
  95.        (shell "clear")
  96.        (spawn :command-string "set terminal/width=80" :parallel t)
  97. )  )
  98.  
  99. (defun decwindows-toggle-up (&rest ignore) 
  100.     (clx:circulate-window-up knowledge-window)
  101.     (clx:set-input-focus display knowledge-window :none)
  102.     (clx:query-tree root)
  103. )
  104.  
  105. (defun decwindows-toggle-down (&rest ignore) 
  106.      (clx:circulate-window-down knowledge-window)
  107.      (clx:set-input-focus display driver-window :none)
  108.      (clx:query-tree root)
  109. )
  110.  
  111. ---------
  112. test.c
  113. ---------
  114. #include <stdio.h>
  115. #include <X11/X.h>
  116. #include <X11/Xlib.h>
  117. #include <X11/Xutil.h>
  118.  
  119. void windowlist();
  120. void windowlist1();
  121. void decwindows_toggle_up();
  122. void decwindows_toggle_down();
  123. Display *dpy;
  124. Screen *screen; 
  125. Window root;
  126. Window knowledge_window;
  127. Window driver_window;
  128.  
  129. main()
  130. {
  131.  
  132.     char c;
  133.  
  134.     if (!(dpy = XOpenDisplay(NULL))) {
  135.         printf("Can't open display.\n"); 
  136.     exit(-1);
  137.     }
  138.  
  139.     if (!(screen = DefaultScreenOfDisplay(dpy))) {
  140.         printf("Can't get default screen.\n");
  141.     exit(-1);
  142.     }
  143.  
  144.     if (!(root = RootWindow(dpy,DefaultScreen(dpy)))) {
  145.         printf("Can't get root window of screen.\n");
  146.         exit(-1);
  147.     }
  148.  
  149.     windowlist(root); 
  150.  
  151.     windowlist1(root);    
  152.  
  153.     decwindows_toggle_up();
  154.  
  155.     sleep(3);
  156.  
  157.     decwindows_toggle_down();
  158.  
  159.     sleep(3);
  160. }
  161.  
  162. void windowlist(window_id)
  163. Window window_id;
  164. {
  165.     int status;
  166.     XTextProperty txt;
  167.     Window root,parent,*children,*child;
  168.     int num_children,i,total;
  169.    
  170.     XGetWMName(dpy,window_id,&txt);
  171.     if ((txt.value != NULL) && (txt.encoding == 31) && (txt.format == 8))
  172.         if (!strcmp(txt.value,"csc32")) {
  173.            knowledge_window = window_id;
  174.            printf("Assigned knowledge_window\n");
  175.         }
  176.     if (knowledge_window == NULL) {
  177.     if (!(status = XQueryTree(dpy,window_id,&root,&parent,
  178.                             &children,&num_children))) 
  179.         printf("Failed in call to XQueryTree()\n");
  180.     else {
  181.         total = num_children; 
  182.                 child = children;
  183.                 for (i=0; i<total; i++, child++) windowlist(*child);
  184.                 XFree(children);
  185.         }
  186.     }
  187. }
  188.  
  189. void windowlist1(window_id)
  190. Window window_id;
  191. {
  192.     int status;
  193.     XTextProperty txt;
  194.     Window root,parent,*children,*child;
  195.     int num_children,i,total;
  196.    
  197.     XGetWMName(dpy,window_id,&txt);
  198.     if ((txt.value != NULL) && (txt.encoding == 31) && (txt.format == 8))
  199.         if (!strcmp(txt.value,"talguy")) {
  200.            driver_window = window_id;
  201.            printf("Assigned driver_window\n");
  202.         }
  203.     if (driver_window == NULL) {
  204.     if (!(status = XQueryTree(dpy,window_id,&root,&parent,
  205.                             &children,&num_children))) 
  206.         printf("Failed in call to XQueryTree()\n");
  207.     else {
  208.         total = num_children; 
  209.                 child = children;
  210.                 for (i=0; i<total; i++, child++) windowlist1(*child);
  211.                 XFree(children);
  212.         }
  213.     }
  214. }
  215.  
  216.  
  217. void decwindows_toggle_up()
  218. {
  219.     int status;
  220.     Window lroot,parent,*children;
  221.     int num_children;
  222.  
  223.     XCirculateSubwindowsUp(dpy,knowledge_window);
  224.     XSetInputFocus(dpy,knowledge_window,RevertToNone,CurrentTime);
  225.     XQueryTree(dpy,root,&lroot,&parent,&children,&num_children); 
  226. }
  227.  
  228. void decwindows_toggle_down()
  229. {
  230.     Window lroot,parent,*children;
  231.     int num_children;
  232.  
  233.     XCirculateSubwindowsDown(dpy,knowledge_window);
  234.     XSetInputFocus(dpy,driver_window,RevertToNone,CurrentTime);
  235.     XQueryTree(dpy,root,&lroot,&parent,&children,&num_children);
  236. }
  237.  
  238.  
  239. ----------------------------------------------------------------------------
  240.  
  241.    Scott Johnson
  242.    Digital Equipment Corporation
  243.    Colorado Springs, Co
  244.  
  245.