1 /* This module, and the entire ModuleDebugger program, and the concept for
2  * interfacing this module to the Window Manager, are all original work
3  * by Robert Nation
4  *
5  * Copyright 1994, Robert Nation. No guarantees or warantees or anything
6  * are provided or implied in any way whatsoever. Use this program at your
7  * own risk. Permission to use this program for any purpose is given,
8  * as long as the copyright is kept intact. */
9 
10 /* Modified for AfterStep by Dan Weeks, 1996
11  */
12 
13 #define TRUE 1
14 #define FALSE
15 
16 #include "../../configure.h"
17 
18 #include <stdio.h>
19 #include <signal.h>
20 #include <fcntl.h>
21 #include <string.h>
22 #include <sys/wait.h>
23 #include <sys/time.h>
24 #include <unistd.h>
25 #include <ctype.h>
26 #ifdef ISC /* Saul */
27 #include <sys/bsdtypes.h> /* Saul */
28 #endif /* Saul */
29 
30 #include <stdlib.h>
31 #if defined ___AIX || defined _AIX || defined __QNX__ || defined ___AIXV3 || defined AIXV3 || defined _SEQUENT_
32 #include <sys/select.h>
33 #endif
34 
35 #include <X11/Xlib.h>
36 #include <X11/Xutil.h>
37 #include <X11/Xproto.h>
38 #include <X11/Xatom.h>
39 #include <X11/Intrinsic.h>
40 
41 #include "../../afterstep/module.h"
42 
43 #include "../../lib/aftersteplib.h"
44 #include "Pager.h"
45 #include "../../version.h"
46 #include "../../afterstep/afterstep.h"
47 
48 char *MyName;
49 int fd_width;
50 int fd[2];
51 
52 /*************************************************************************
53  *
54  * Screen, font, etc info
55  *
56  **************************************************************************/
57 ScreenInfo Scr;
58 PagerWindow *Start = NULL;
59 PagerWindow *FocusWin = NULL;
60 
61 Display *dpy;			/* which display are we talking to */
62 int x_fd,fd_width;
63 
64 char *PagerFore = "black";
65 char *PagerBack="white";
66 char *font_string = "fixed";
67 char *smallFont = NULL;
68 char *HilightC = "black";
69 
70 char *HiBack = "white";
71 char *HiFore = "black";
72 
73 int window_w=0, window_h=0, window_x=0, window_y=0;
74 int icon_x=-10000, icon_y=-10000, icon_w=0, icon_h=0;
75 int usposition = 0,uselabel = 1;
76 extern DeskInfo *Desks;
77 int StartIconic = 0;
78 int Rows = -1, Columns = -1;
79 int desk1=0, desk2 =0;
80 int ndesks = 0;
81 int StickyIcons = 0;
82 /***********************************************************************
83  *
84  *  Procedure:
85  *	main - start of module
86  *
87  ***********************************************************************/
main(int argc,char ** argv)88 int main(int argc, char **argv)
89 {
90   char *temp, *s, *cptr;
91   char *display_name = NULL;
92   int itemp,i;
93   char line[100];
94   char mask_mesg[50];
95 
96   /* Save our program  name - for error messages */
97   temp = argv[0];
98   s=strrchr(argv[0], '/');
99   if (s != NULL)
100     temp = s + 1;
101 
102   MyName = safemalloc(strlen(temp)+2);
103   strcpy(MyName, temp);
104 
105   if((argc != 7)&&(argc != 6))
106     {
107       fprintf(stderr,"%s Version %s should only be executed by afterstep!\n",MyName,
108 	      VERSION);
109       exit(1);
110     }
111   if(argc != 7)
112     {
113       fprintf(stderr,"%s Version %s requires an argument: %s n m\n",
114 	      MyName,VERSION,MyName);
115       fprintf(stderr,"   where desktops n through m are displayed\n");
116       exit(1);
117     }
118 
119   /* Dead pipe == AS died */
120   signal (SIGPIPE, DeadPipe);
121 
122   fd[0] = atoi(argv[1]);
123   fd[1] = atoi(argv[2]);
124 
125   fd_width = GetFdWidth();
126 
127   cptr = argv[6];
128   while((isspace(*cptr))&&(*cptr != 0))cptr++;
129   desk1 = atoi(cptr);
130   while(!(isspace(*cptr))&&(*cptr != 0))cptr++;
131   while((isspace(*cptr))&&(*cptr != 0))cptr++;
132   desk2 = atoi(cptr);
133   if(desk2 < desk1)
134     {
135       itemp = desk1;
136       desk1 = desk2;
137       desk2 = itemp;
138     }
139   ndesks = desk2 - desk1 + 1;
140 
141   Desks = (DeskInfo *)malloc(ndesks*sizeof(DeskInfo));
142   for(i=0;i<ndesks;i++)
143     {
144       sprintf(line,"Desk %d",i+desk1);
145       CopyString(&Desks[i].label,line);
146     }
147 
148   /* Initialize X connection */
149   if (!(dpy = XOpenDisplay(display_name)))
150     {
151       fprintf(stderr,"%s: can't open display %s", MyName,
152 	      XDisplayName(display_name));
153       exit (1);
154     }
155   x_fd = XConnectionNumber(dpy);
156 
157   Scr.screen= DefaultScreen(dpy);
158   Scr.Root = RootWindow(dpy, Scr.screen);
159   if(Scr.Root == None)
160     {
161       fprintf(stderr,"%s: Screen %d is not valid ", MyName, (int)Scr.screen);
162       exit(1);
163     }
164   Scr.d_depth = DefaultDepth(dpy, Scr.screen);
165 
166   sprintf(mask_mesg,"SET_MASK %lu\n",(unsigned long)(M_ADD_WINDOW|
167     M_CONFIGURE_WINDOW|
168     M_DESTROY_WINDOW|
169     M_FOCUS_CHANGE|
170     M_NEW_PAGE|
171     M_NEW_DESK|
172     M_RAISE_WINDOW|
173     M_LOWER_WINDOW|
174     M_ICONIFY|
175     M_ICON_LOCATION|
176     M_DEICONIFY|
177     M_ICON_NAME|
178     M_END_WINDOWLIST));
179   SendInfo(fd,mask_mesg,0);
180 
181   ParseOptions(argv[3]);
182 
183   /* open a pager window */
184   initialize_pager();
185 
186   /* Create a list of all windows */
187   /* Request a list of all windows,
188    * wait for ConfigureWindow packets */
189   SendInfo(fd,"Send_WindowList",0);
190 
191   Loop(fd);
192 }
193 
194 /***********************************************************************
195  *
196  *  Procedure:
197  *	Loop - wait for data to process
198  *
199  ***********************************************************************/
Loop(int * fd)200 void Loop(int *fd)
201 {
202   XEvent Event;
203 
204   while(1)
205     {
206       if(My_XNextEvent(dpy,&Event))
207 	DispatchEvent(&Event);
208     }
209 }
210 
211 
212 /***********************************************************************
213  *
214  *  Procedure:
215  *	Process message - examines packet types, and takes appropriate action
216  *
217  ***********************************************************************/
process_message(unsigned long type,unsigned long * body)218 void process_message(unsigned long type,unsigned long *body)
219 {
220   switch(type)
221     {
222     case M_ADD_WINDOW:
223       list_configure(body);
224       break;
225     case M_CONFIGURE_WINDOW:
226       list_configure(body);
227       break;
228     case M_DESTROY_WINDOW:
229       list_destroy(body);
230       break;
231     case M_FOCUS_CHANGE:
232       list_focus(body);
233       break;
234     case M_NEW_PAGE:
235       list_new_page(body);
236       break;
237     case M_NEW_DESK:
238       list_new_desk(body);
239       break;
240     case M_RAISE_WINDOW:
241       list_raise(body);
242       break;
243     case M_LOWER_WINDOW:
244       list_lower(body);
245       break;
246     case M_ICONIFY:
247     case M_ICON_LOCATION:
248       list_iconify(body);
249       break;
250     case M_DEICONIFY:
251       list_deiconify(body);
252       break;
253     case M_ICON_NAME:
254       list_icon_name(body);
255       break;
256     case M_END_WINDOWLIST:
257       list_end();
258       break;
259     default:
260       list_unknown(body);
261       break;
262     }
263 }
264 
265 
266 /***********************************************************************
267  *
268  *  Procedure:
269  *	SIGPIPE handler - SIGPIPE means afterstep is dying
270  *
271  ***********************************************************************/
DeadPipe(int nonsense)272 void DeadPipe(int nonsense)
273 {
274   exit(0);
275 }
276 
277 /***********************************************************************
278  *
279  *  Procedure:
280  *	list_add - displays packet contents to stderr
281  *
282  ***********************************************************************/
list_add(unsigned long * body)283 void list_add(unsigned long *body)
284 {
285   PagerWindow *t,**prev;
286   int i=0;
287 
288   t = Start;
289   prev = &Start;
290   while(t!= NULL)
291     {
292       prev = &(t->next);
293       t = t->next;
294       i++;
295     }
296   *prev = (PagerWindow *)safemalloc(sizeof(PagerWindow));
297   (*prev)->w = body[0];
298   (*prev)->t = (char *)body[2];
299   (*prev)->frame = body[1];
300   (*prev)->x = body[3];
301   (*prev)->y = body[4];
302   (*prev)->width = body[5];
303   (*prev)->height = body[6];
304   (*prev)->desk = body[7];
305   (*prev)->next = NULL;
306   (*prev)->flags = body[8];
307   (*prev)->icon_name = NULL;
308   (*prev)->title_height = body[9];
309   (*prev)->border_width = body[10];
310   (*prev)->icon_w = body[19];
311   (*prev)->icon_pixmap_w = body[20];
312   (*prev)->text = body[22];
313   (*prev)->back = body[23];
314   AddNewWindow(*prev);
315 }
316 
317 /***********************************************************************
318  *
319  *  Procedure:
320  *	list_configure - displays packet contents to stderr
321  *
322  ***********************************************************************/
list_configure(unsigned long * body)323 void list_configure(unsigned long *body)
324 {
325   PagerWindow *t;
326   Window target_w;
327 
328   target_w = body[0];
329   t = Start;
330   while((t!= NULL)&&(t->w != target_w))
331     {
332       t = t->next;
333     }
334   if(t== NULL)
335     {
336       list_add(body);
337 
338     }
339   else
340     {
341       t->t = (char *)body[2];
342       t->frame = body[1];
343       t->frame_x = body[3];
344       t->frame_y = body[4];
345       t->frame_width = body[5];
346       t->frame_height = body[6];
347       t->title_height = body[9];
348       t->border_width = body[10];
349       t->flags = body[8];
350       t->icon_w = body[19];
351       t->icon_pixmap_w = body[20];
352       t->text = body[22];
353       t->back = body[23];
354       if(t->flags & ICONIFIED)
355 	{
356 	  t->x = t->icon_x;
357 	  t->y = t->icon_y;
358 	  t->width = t->icon_width;
359 	  t->height = t->icon_height;
360 	  if(t->flags & SUPPRESSICON)
361 	    {
362 	      t->x = -10000;
363 	      t->y = -10000;
364 	    }
365 	}
366       else
367 	{
368 	  t->x = t->frame_x;
369 	  t->y = t->frame_y;
370 	  t->width = t->frame_width;
371 	  t->height = t->frame_height;
372 	}
373       if(t->desk != body[7])
374 	{
375 	  ChangeDeskForWindow(t,body[7]);
376 	}
377 
378       else
379 	MoveResizePagerView(t);
380       if(FocusWin == t)
381 	Hilight(t,ON);
382       else
383 	Hilight(t,OFF);
384     }
385 }
386 
387 /***********************************************************************
388  *
389  *  Procedure:
390  *	list_destroy - displays packet contents to stderr
391  *
392  ***********************************************************************/
list_destroy(unsigned long * body)393 void list_destroy(unsigned long *body)
394 {
395   PagerWindow *t,**prev;
396   Window target_w;
397 
398   target_w = body[0];
399   t = Start;
400   prev = &Start;
401   while((t!= NULL)&&(t->w != target_w))
402     {
403       prev = &(t->next);
404       t = t->next;
405     }
406   if(t!= NULL)
407     {
408       if(prev != NULL)
409 	*prev = t->next;
410       /* remove window from the chain */
411       if(t->PagerView != None)
412 	XDestroyWindow(dpy,t->PagerView);
413       XDestroyWindow(dpy,t->IconView);
414       if(FocusWin == t)
415 	FocusWin = NULL;
416 
417       free(t);
418     }
419 }
420 
421 /***********************************************************************
422  *
423  *  Procedure:
424  *	list_focus - displays packet contents to stderr
425  *
426  ***********************************************************************/
list_focus(unsigned long * body)427 void list_focus(unsigned long *body)
428 {
429   PagerWindow *t,*temp;
430   Window target_w;
431 
432   target_w = body[0];
433 
434   t = Start;
435   while((t!= NULL)&&(t->w != target_w))
436     {
437       t = t->next;
438     }
439   if(t != FocusWin)
440     {
441       temp = FocusWin;
442       FocusWin = t;
443 
444       if(temp != NULL)
445 	Hilight(temp,OFF);
446       if(FocusWin != NULL)
447 	Hilight(FocusWin,ON);
448     }
449 }
450 
451 /***********************************************************************
452  *
453  *  Procedure:
454  *	list_new_page - displays packet contents to stderr
455  *
456  ***********************************************************************/
list_new_page(unsigned long * body)457 void list_new_page(unsigned long *body)
458 {
459   Scr.Vx = (long)body[0];
460   Scr.Vy = (long)body[1];
461   Scr.CurrentDesk = (long)body[2];
462   MovePage();
463   MoveStickyWindows();
464   Hilight(FocusWin,OFF);
465   Hilight(FocusWin,ON);
466 }
467 
468 /***********************************************************************
469  *
470  *  Procedure:
471  *	list_new_desk - displays packet contents to stderr
472  *
473  ***********************************************************************/
list_new_desk(unsigned long * body)474 void list_new_desk(unsigned long *body)
475 {
476   int oldDesk;
477 
478   oldDesk = Scr.CurrentDesk;
479   Scr.CurrentDesk = (long)body[0];
480 
481   MovePage();
482 
483   DrawGrid(oldDesk - desk1,1);
484   DrawGrid(Scr.CurrentDesk - desk1,1);
485   MoveStickyWindows();
486   Hilight(FocusWin,OFF);
487   Hilight(FocusWin,ON);
488 }
489 
490 /***********************************************************************
491  *
492  *  Procedure:
493  *	list_raise - displays packet contents to stderr
494  *
495  ***********************************************************************/
list_raise(unsigned long * body)496 void list_raise(unsigned long *body)
497 {
498   PagerWindow *t;
499   Window target_w;
500 
501   target_w = body[0];
502   t = Start;
503   while((t!= NULL)&&(t->w != target_w))
504     {
505       t = t->next;
506     }
507   if(t!= NULL)
508     {
509       if(t->PagerView != None)
510 	XRaiseWindow(dpy,t->PagerView);
511       XRaiseWindow(dpy,t->IconView);
512     }
513 }
514 
515 
516 /***********************************************************************
517  *
518  *  Procedure:
519  *	list_lower - displays packet contents to stderr
520  *
521  ***********************************************************************/
list_lower(unsigned long * body)522 void list_lower(unsigned long *body)
523 {
524   PagerWindow *t;
525   Window target_w;
526 
527   target_w = body[0];
528   t = Start;
529   while((t!= NULL)&&(t->w != target_w))
530     {
531       t = t->next;
532     }
533   if(t!= NULL)
534     {
535       if(t->PagerView != None)
536 	XLowerWindow(dpy,t->PagerView);
537       if((t->desk - desk1>=0)&&(t->desk - desk1<ndesks))
538 	XLowerWindow(dpy,Desks[t->desk - desk1].CPagerWin);
539       XLowerWindow(dpy,t->IconView);
540     }
541 }
542 
543 
544 /***********************************************************************
545  *
546  *  Procedure:
547  *	list_unknow - handles an unrecognized packet.
548  *
549  ***********************************************************************/
list_unknown(unsigned long * body)550 void list_unknown(unsigned long *body)
551 {
552   /*  fprintf(stderr,"Unknown packet type\n");*/
553 }
554 
555 /***********************************************************************
556  *
557  *  Procedure:
558  *	list_iconify - displays packet contents to stderr
559  *
560  ***********************************************************************/
list_iconify(unsigned long * body)561 void list_iconify(unsigned long *body)
562 {
563   PagerWindow *t;
564   Window target_w;
565 
566   target_w = body[0];
567   t = Start;
568   while((t!= NULL)&&(t->w != target_w))
569     {
570       t = t->next;
571     }
572   if(t== NULL)
573     {
574       return;
575     }
576   else
577     {
578       t->t = (char *)body[2];
579       t->frame = body[1];
580       t->icon_x = body[3];
581       t->icon_y = body[4];
582       t->icon_width = body[5];
583       t->icon_height = body[6];
584       t->flags |= ICONIFIED;
585       t->x = t->icon_x;
586       t->y = t->icon_y;
587       if(t->flags & SUPPRESSICON)
588 	{
589 	  t->x = -10000;
590 	  t->y = -10000;
591 	}
592       t->width = t->icon_width;
593       t->height = t->icon_height;
594       MoveResizePagerView(t);
595     }
596 }
597 
598 
599 /***********************************************************************
600  *
601  *  Procedure:
602  *	list_deiconify - displays packet contents to stderr
603  *
604  ***********************************************************************/
605 
list_deiconify(unsigned long * body)606 void list_deiconify(unsigned long *body)
607 {
608   PagerWindow *t;
609   Window target_w;
610 
611   target_w = body[0];
612   t = Start;
613   while((t!= NULL)&&(t->w != target_w))
614     {
615       t = t->next;
616     }
617   if(t== NULL)
618     {
619       return;
620     }
621   else
622     {
623       t->flags &= ~ICONIFIED;
624       t->x = t->frame_x;
625       t->y = t->frame_y;
626       t->width = t->frame_width;
627       t->height = t->frame_height;
628       MoveResizePagerView(t);
629       if(FocusWin == t)
630 	Hilight(t,ON);
631       else
632 	Hilight(t,OFF);
633     }
634 }
635 
636 
637 /***********************************************************************
638  *
639  *  Procedure:
640  *	list_icon_name - displays packet contents to stderr
641  *
642  ***********************************************************************/
list_icon_name(unsigned long * body)643 void list_icon_name(unsigned long *body)
644 {
645   PagerWindow *t;
646   Window target_w;
647 
648   target_w = body[0];
649   t = Start;
650   while((t!= NULL)&&(t->w != target_w))
651     {
652       t = t->next;
653     }
654   if(t!= NULL)
655     {
656       if(t->icon_name != NULL)
657 	free(t->icon_name);
658       CopyString(&t->icon_name,(char *)(&body[3]));
659       LabelWindow(t);
660       LabelIconWindow(t);
661     }
662 }
663 
664 
665 
666 
667 /***********************************************************************
668  *
669  *  Procedure:
670  *	list_end - displays packet contents to stderr
671  *
672  ***********************************************************************/
list_end(void)673 void list_end(void)
674 {
675   unsigned int nchildren,i;
676   Window root, parent, *children;
677   PagerWindow *ptr;
678 
679   if(!XQueryTree(dpy, Scr.Root, &root, &parent, &children, &nchildren))
680     return;
681 
682   for(i=0; i<nchildren;i++)
683     {
684       ptr = Start;
685       while(ptr != NULL)
686 	{
687 	  if((ptr->frame == children[i])||(ptr->icon_w == children[i])||
688 	     (ptr->icon_pixmap_w == children[i]))
689 	    {
690 	      if(ptr->PagerView != None)
691 		XRaiseWindow(dpy,ptr->PagerView);
692 	      XRaiseWindow(dpy,ptr->IconView);
693 	    }
694 	  ptr = ptr->next;
695 	}
696     }
697 
698 
699   if(nchildren > 0)
700     XFree((char *)children);
701 }
702 
703 
704 
705 
706 /***************************************************************************
707  *
708  * Waits for next X event, or for an auto-raise timeout.
709  *
710  ****************************************************************************/
My_XNextEvent(Display * dpy,XEvent * event)711 int My_XNextEvent(Display *dpy, XEvent *event)
712 {
713   fd_set in_fdset;
714   unsigned long header[3];
715   int body_length;
716   int count,count2 = 0;
717   static int miss_counter = 0;
718   unsigned long *body;
719   int total;
720   char *cbody;
721 
722   if(XPending(dpy))
723     {
724       XNextEvent(dpy,event);
725       return 1;
726     }
727 
728   FD_ZERO(&in_fdset);
729   FD_SET(x_fd,&in_fdset);
730   FD_SET(fd[1],&in_fdset);
731 
732 #ifdef __hpux
733   select(fd_width,(int *)&in_fdset, 0, 0, NULL);
734 #else
735   select(fd_width,&in_fdset, 0, 0, NULL);
736 #endif
737 
738   if(FD_ISSET(x_fd, &in_fdset))
739     {
740       if(XPending(dpy))
741 	{
742 	  XNextEvent(dpy,event);
743 	  miss_counter = 0;
744 	  return 1;
745 	}
746       else
747 	miss_counter++;
748       if(miss_counter > 100)
749 	DeadPipe(0);
750     }
751 
752   if(FD_ISSET(fd[1], &in_fdset))
753     {
754       if((count = ReadASPacket(fd[1],header,&body)) > 0)
755 	 {
756 	   process_message(header[1],body);
757 	   free(body);
758 	 }
759     }
760   return 0;
761 }
762 
763 
764 
765 /*****************************************************************************
766  *
767  * This routine is responsible for reading and parsing the config file
768  *
769  ****************************************************************************/
ParseOptions(char * filename)770 void ParseOptions(char *filename)
771 {
772   FILE *fd = (FILE *)0;
773   char line[256];
774   char *tline,*orig_tline,*tmp;
775   int Clength,n,desk;
776 
777   Scr.ASRoot = NULL;
778   Scr.Hilite = NULL;
779   Scr.VScale = 32;
780 
781   Scr.MyDisplayWidth = DisplayWidth(dpy, Scr.screen);
782   Scr.MyDisplayHeight = DisplayHeight(dpy, Scr.screen);
783 
784   Scr.VxMax = 3*Scr.MyDisplayWidth - Scr.MyDisplayWidth;
785   Scr.VyMax = 3*Scr.MyDisplayHeight - Scr.MyDisplayHeight;
786   if(Scr.VxMax <0)
787     Scr.VxMax = 0;
788   if(Scr.VyMax <0)
789     Scr.VyMax = 0;
790   Scr.Vx = 0;
791   Scr.Vy = 0;
792 
793   fd = fopen(filename,"r");
794   if(fd == (FILE *)0)
795     {
796       fprintf(stderr,"%s: can't open config file %s",MyName,filename);
797       exit(1);
798     }
799 
800   tline = fgets(line,(sizeof line)-1,fd);
801   orig_tline = tline;
802   Clength = strlen(MyName);
803   while(tline != (char *)0)
804     {
805       int g_x, g_y, flags;
806       unsigned width,height;
807 
808       while(isspace(*tline))tline++;
809 
810       if((strlen(&tline[0])>1)&&
811 	 (mystrncasecmp(tline, CatString3("*", MyName, "Geometry"),Clength+9)==0))
812 	{
813 	  tmp = &tline[Clength+9];
814 	  while(((isspace(*tmp))&&(*tmp != '\n'))&&(*tmp != 0))
815 	    {
816 	      tmp++;
817 	    }
818 	  tmp[strlen(tmp)-1] = 0;
819 
820 	  flags = XParseGeometry(tmp,&g_x,&g_y,&width,&height);
821 	  if (flags & WidthValue)
822 	    window_w = width;
823 	  if (flags & HeightValue)
824 	    window_h = height;
825 	  if (flags & XValue)
826 	    {
827 	      window_x = g_x;
828 	      usposition = 1;
829 	    }
830 	  if (flags & YValue)
831 	    {
832 	      window_y = g_y;
833 	      usposition = 1;
834 	    }
835 	}
836       else if((strlen(&tline[0])>1)&&
837 	 (mystrncasecmp(tline, CatString3("*", MyName, "IconGeometry"),
838 		      Clength+13)==0))
839 	{
840 	  tmp = &tline[Clength+13];
841 	  while(((isspace(*tmp))&&(*tmp != '\n'))&&(*tmp != 0))
842 	    {
843 	      tmp++;
844 	    }
845 	  tmp[strlen(tmp)-1] = 0;
846 
847 	  flags = XParseGeometry(tmp,&g_x,&g_y,&width,&height);
848 	  if (flags & WidthValue)
849 	    icon_w = width;
850 	  if (flags & HeightValue)
851 	    icon_h = height;
852 	  if (flags & XValue)
853 	    {
854 	      icon_x = g_x;
855 	    }
856 	  if (flags & YValue)
857 	    {
858 	      icon_y = g_y;
859 	    }
860 	}
861       else if((strlen(&tline[0])>1)&&
862 	      (mystrncasecmp(tline,CatString3("*",MyName,"Label"),Clength+6)==0))
863 	{
864 	  desk = desk1;
865 	  sscanf(&tline[Clength+6],"%d",&desk);
866 	  if((desk >= desk1)&&(desk <=desk2))
867 	    {
868 	      n = 0;
869 	      while(isspace(tline[Clength+6+n]))n++;
870 	      while(!isspace(tline[Clength+6+n]))n++;
871 	      free(Desks[desk - desk1].label);
872 	      CopyString(&Desks[desk - desk1].label,&tline[Clength+6+n]);
873 	    }
874 	}
875       else if((strlen(&tline[0])>1)&&
876 	      (mystrncasecmp(tline, CatString3("*", MyName, "Font"),Clength+5)==0))
877 	{
878 	  CopyString(&font_string,&tline[Clength+5]);
879 	  if(mystrncasecmp(font_string,"none",4) == 0)
880 	    uselabel = 0;
881 
882 	}
883       else if((strlen(&tline[0])>1)&&
884 	      (mystrncasecmp(tline, CatString3("*", MyName, "Fore"),Clength+5)==0))
885 	{
886 	  CopyString(&PagerFore,&tline[Clength+5]);
887 	}
888       else if((strlen(&tline[0])>1)&&
889 	      (mystrncasecmp(tline,CatString3("*", MyName, "Back"),Clength+5)==0))
890 	{
891 	  CopyString(&PagerBack,&tline[Clength+5]);
892 	}
893       else if((strlen(&tline[0])>1)&&
894 	      (mystrncasecmp(tline,CatString3("*",MyName,"Hilight"),Clength+8)==0))
895 	{
896 	  if(Scr.d_depth > 1)
897 	    CopyString(&HilightC,&tline[Clength+8]);
898 	}
899       else if((strlen(&tline[0])>1)&&
900 	      (mystrncasecmp(tline,CatString3("*",MyName,"SmallFont"),
901 			   Clength+10)==0))
902 	{
903 	  CopyString(&smallFont,&tline[Clength+10]);
904 	}
905       else if((strlen(&tline[0])>1)&&
906 	      (mystrncasecmp(tline,CatString3("*",MyName,"StartIconic"),
907 			   Clength+12)==0))
908 	{
909 	  StartIconic = 1;
910 	}
911       else if((strlen(&tline[0])>1)&&
912 	      (mystrncasecmp(tline,CatString3("*",MyName,"Rows"),
913 			   Clength+5)==0))
914 	{
915 	  sscanf(&tline[Clength+5],"%d",&Rows);
916 	}
917       else if((strlen(&tline[0])>1)&&
918 	      (mystrncasecmp(tline,CatString3("*",MyName,"Columns"),
919 			   Clength+8)==0))
920 	{
921 	  sscanf(&tline[Clength+8],"%d",&Columns);
922 	}
923       else if((strlen(&tline[0])>1)&&
924 	      (mystrncasecmp(tline,"HiBackColor",11)==0))
925 	{
926 	  if(Scr.d_depth > 1)
927 	    CopyString(&HiBack,&tline[11]);
928 	}
929       else if((strlen(&tline[0])>1)&&
930 	      (mystrncasecmp(tline,"HiForeColor",11)==0))
931 	{
932 	  if(Scr.d_depth > 1)
933 	    CopyString(&HiFore,&tline[11]);
934 	}
935       else if((strlen(&tline[0])>1)&&
936 	      (mystrncasecmp(tline,"StickyIcons",11)==0))
937 	{
938 	  StickyIcons = 1;
939 	}
940       else if((strlen(&tline[0])>1)&&
941 	      (mystrncasecmp(tline,"DeskTopSize",11)==0))
942 	{
943 	  sscanf(&tline[11],"%dx%d",&Scr.VxMax,&Scr.VyMax);
944 	  Scr.VxMax = Scr.VxMax*Scr.MyDisplayWidth - Scr.MyDisplayWidth;
945 	  Scr.VyMax = Scr.VyMax*Scr.MyDisplayHeight - Scr.MyDisplayHeight;
946 	}
947       else if((strlen(&tline[0])>1)&&
948 	      (mystrncasecmp(tline,"DeskTopScale",12)==0))
949 	{
950 	  sscanf(&tline[12],"%d",&Scr.VScale);
951 	}
952       tline = fgets(line,(sizeof line)-1,fd);
953       orig_tline = tline;
954     }
955   return;
956 }
957 
958 
959 
960