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

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