2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
25 * (c) Copyright 1993, 1994 International Business Machines Corp. *
26 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
27 * (c) Copyright 1993, 1994 Novell, Inc. *
29 #ifdef VERBOSE_REV_INFO
30 static char rcsid[] = "$TOG: dthello.c /main/9 1998/04/20 12:52:17 mgreess $";
31 #endif /* VERBOSE_REV_INFO */
32 /******************************<+>*************************************
33 **********************************************************************
37 ** Project: HP Visual User Environment
41 ** This file implements the startup transition for the DT
45 **********************************************************************
47 ** (c) Copyright 1990, 1991, 1992 Hewlett-Packard Company
48 ** All rights reserved
50 **********************************************************************
51 ******************************<+>*************************************/
54 * Notes on conditional compilation:
56 * AUTO_TOP If defined, the dthello window will automatically
57 * raise itself over any window that obscures it.
60 * If defined, dthello will center the text from
61 * input files as a block as opposed to line-by-line.
72 #include <X11/Intrinsic.h>
73 #include <X11/StringDefs.h>
74 #include <X11/Xutil.h>
75 #include <Xm/MwmUtil.h>
76 #include <sys/signal.h>
78 #include <Dt/GetDispRes.h>
80 #include </sys5/usr/include/limits.h>
85 #ifndef NO_MESSAGE_CATALOG
86 # include <nl_types.h>
89 #include <Dt/EnvControlP.h>
92 #ifndef NO_MESSAGE_CATALOG
93 # define GETMESSAGE(set, number, string) GetMessage(set, number, string)
95 # define GETMESSAGE(set, number, string) string
98 #if !defined(NL_CAT_LOCALE)
99 #define NL_CAT_LOCALE 0
105 Window welcome; /* Welcome window ID */
106 Display *dpy; /* X server connection */
107 struct globalStruct vhGD;
108 int x_offset = 0; /* for left-justifying text */
109 int box_line_width = 0; /* for drawing a box */
110 XFontSet fontset; /* Font descriptor for ILS */
111 unsigned long textHeight; /* Font size parameters */
112 unsigned long fg, bg; /* Pixel values */
113 Boolean colorSuccess = True; /* Success at allocating colors */
114 XGCValues gcv; /* Struct for creating GC */
115 unsigned int totalHeight; /* total Height used for text */
116 unsigned int displayHeight; /* height of display in pixels */
117 int maxWidth; /* max width of lines read in from file */
118 unsigned int displayWidth; /* width of display in pixels */
119 GC gc; /* GC to draw with */
121 static XrmOptionDescRec optTable[] = {
122 {"-font", "*vfont", XrmoptionSepArg, (XtPointer) NULL},
123 {"-fnt", "*vfont", XrmoptionSepArg, (XtPointer) NULL},
125 static int noptTable = sizeof(optTable)/sizeof(optTable[0]);
129 {"-bground", 8}, /* background color */
132 {"-fground", 8}, /* foreground color */
135 {"-string", 7}, /* string to display */
138 {"-fnt", 4}, /* font to use */
141 {"-timeout", 8}, /* timeout amount in seconds*/
144 {"-file", 5}, /* file */
149 char *ppchFileNames[MAX_FILES]; /* names of files to print */
150 unsigned char *ppchText[MAX_LINES]; /* text lines to print out */
151 int numFiles; /* number of files to print */
152 int numLines; /* number of text lines to print out */
153 #ifdef BLOCK_CENTER_FILES
154 int centerLines; /* number of text lines to print centered */
155 #endif /* BLOCK_CENTER_FILES */
156 char *progName; /* who we are */
157 char *fontArg; /* font argument */
159 char *stringArg; /* string argument */
161 char *bgArg; /* background argument */
163 char *fgArg; /* foreground argument */
165 char *xoffsetArg; /* text x_offset argument */
167 char *timeArg; /* timeout argument, in seconds */
170 Boolean Done; /* while painting text */
172 static VhResourceEntry restable[] = {
173 { vNbackground, vCBackground, &bgArg, &sizeBgArg },
174 { vNforeground, vCForeground, &fgArg, &sizeFgArg },
175 { vNfont, vCFont, &fontArg, &sizeFontArg },
176 { vNxoffset, vCXoffset, &xoffsetArg, &sizeXoffsetArg },
177 { vNstring, vCString, &stringArg, &sizeStringArg },
178 { vNfile, vCFile, &ppchFileNames[0], &sizeFileArg },
179 { vNtimeout, vCTimeout, &timeArg, &sizeTimeArg },
185 fprintf(stderr, (char *) GETMESSAGE (4, 4,
186 "usage: %s [-display <display>] [-bground <color>] [-fground <color>]\n"),
188 fprintf(stderr, "%s", (char *) GETMESSAGE (4, 5,
189 "\t[-font <font>] [-string <message>] [-timeout <seconds>] [-file <name>]\n"));
193 /*************************************<->*************************************
200 * This is the main routine that does almost all the work.
204 * argc = Std C argument count
205 * argv = Std C argument vector
213 * This works by creating an override-redirect window the size of
214 * the screen and painting a message on it. At the same time, a
215 * 1x1 window is created that will be picked up by the window
216 * manager. When the window manager reparents the little window,
217 * this program exits.
221 * dthello [-display <display>] [-fground <color>] [-bground <color>]
222 * [-font <fontname>] [-string <message>] [-file <filename>]
223 * [-timeout <seconds>]
225 *************************************<->***********************************/
227 main (int argc, char **argv)
229 Window wmwin; /* Window ID for wm */
230 XEvent event; /* Event received */
231 unsigned long mask; /* mask for window attribs */
232 XSetWindowAttributes xwa; /* Set Window Attribute struct */
233 int argn; /* temp for parsing args */
234 XColor colorDef; /* for parsing/allocating colors */
235 Colormap colormap; /* color map of screen */
236 Atom xaMwmHints; /* mwm hints atom */
237 PropMotifWmHints mwmHints; /* mwm hints structure */
238 Visual *pdv; /* X visual structure */
239 FILE *fp; /* file pointer */
240 int i; /* loop index */
241 char *default_string; /* default message */
242 XtAppContext appcontext;
244 char **missing_clist;
246 XFontSetExtents *extents;
248 XtSetLanguageProc( NULL, NULL, NULL );
254 * Set up NLSPATH, app-defaults, etc. for this DT client.
256 _DtEnvControl(DT_ENV_SET);
259 * Process command line arguments
262 /* fontArg = DEFAULT_FONT; */
265 timeArg = DEFAULT_TIME;
270 * Initialize Toolkit, open display
272 XtToolkitInitialize();
273 appcontext = XtCreateApplicationContext();
275 dpy = XtOpenDisplay (appcontext, NULL, argv[0], DTHELLO_CLASS_NAME,
276 optTable, noptTable, (int *)(&argc), argv);
280 setlocale(LC_ALL, "");
281 fprintf(stderr, (char *)
282 GETMESSAGE(4, 1, "%s: can't open display\n"), progName);
286 default_string = strdup (
287 ((char *)GETMESSAGE(2, 3,
288 "Starting the\nCommon Desktop Environment\n\n")));
290 stringArg = default_string;
293 * Find appropriate default font
294 * and offset from the left side of the screen
297 switch (_DtGetDisplayResolution(dpy, XDefaultScreen(dpy)))
299 case LOW_RES_DISPLAY:
300 fontArg = DEFAULT_FONT_SMALL;
301 x_offset = DEFAULT_XOFFSET_SMALL;
302 box_line_width = BOX_LINE_WIDTH_SMALL;
305 case MED_RES_DISPLAY:
306 fontArg = DEFAULT_FONT_MEDIUM;
307 x_offset = DEFAULT_XOFFSET_MEDIUM;
308 box_line_width = BOX_LINE_WIDTH_MEDIUM;
311 case HIGH_RES_DISPLAY:
312 fontArg = DEFAULT_FONT_LARGE;
313 x_offset = DEFAULT_XOFFSET_LARGE;
314 box_line_width = BOX_LINE_WIDTH_LARGE;
317 fontArg = DEFAULT_FONT_SMALL;
318 x_offset = DEFAULT_XOFFSET_SMALL;
319 box_line_width = BOX_LINE_WIDTH_SMALL;
326 VhGetResources (dpy, progName, DTHELLO_CLASS,
327 restable, XtNumber(restable));
329 /* assign the x_offset to the value set in the resource list if given by the user */
331 if( xoffsetArg != NULL)
332 x_offset = atoi(xoffsetArg);
335 x_offset = -x_offset;
338 if (sizeFileArg != 0)
344 * Parse remaining command line arguments
346 for (argn = 1; argn < argc; argn++)
348 if ((*argv[argn] == '-') &&
351 if (ArgMatch (argv[argn], BG_ARG))
353 bgArg = argv[++argn];
357 else if (ArgMatch (argv[argn], FG_ARG))
359 fgArg = argv[++argn];
363 else if (ArgMatch (argv[argn], STRING_ARG))
365 stringArg = argv[++argn];
369 else if (ArgMatch (argv[argn], FONT_ARG))
371 fontArg = argv[++argn];
375 else if (ArgMatch (argv[argn], TIME_ARG))
377 timeArg = argv[++argn];
378 if (atoi(timeArg) <= 0)
380 fprintf (stderr, (char *)
381 GETMESSAGE(4, 2, "%s: timeout must be positive\n"),
383 timeArg = DEFAULT_TIME;
388 else if (ArgMatch (argv[argn], FILE_ARG))
391 if (numFiles < MAX_FILES)
393 ppchFileNames[numFiles] = (char *) argv[argn];
398 fprintf(stderr, (char *) GETMESSAGE(4, 3,
399 "%1$s: Maxiumum of %2$d files allowed, skipping %3$s\n"),
400 argv[0], MAX_FILES, argv[argn]);
419 displayHeight = XDisplayHeight (dpy, XDefaultScreen(dpy));
420 displayWidth = XDisplayWidth (dpy, XDefaultScreen(dpy));
423 * Set default fg/bg colors if not specified.
424 * (adjust for low-color systems)
427 pdv = XDefaultVisual(dpy, XDefaultScreen(dpy));
430 * Set default colors if not specified on command line.
432 if ((XDefaultDepth(dpy, XDefaultScreen(dpy)) <= 4) ||
433 (pdv->class == StaticGray) ||
434 (pdv->class == GrayScale))
437 * B&W, GrayScale, or low-color systems
441 bgArg = DEFAULT_LOW_BG;
446 fgArg = DEFAULT_LOW_FG;
452 * Medium- to High-color systems
468 if ((fontset = XCreateFontSet(dpy, fontArg, &missing_clist, &missing_count,
471 fprintf(stderr, (char *)
472 GETMESSAGE (4, 6, "%1$s: display %2$s doesn't know font %3$s\n"),
473 argv[0], DisplayString(dpy), fontArg);
475 if ((fontset = XCreateFontSet(dpy, DEFAULT_FONT, &missing_clist,
476 &missing_count, &def_str)) == NULL)
478 fprintf(stderr, (char *)
479 GETMESSAGE (4, 6, "%1$s: display %2$s doesn't know font %3$s\n"),
480 argv[0], DisplayString(dpy), DEFAULT_FONT);
483 if ((NULL == fontset) &&
484 (fontset = XCreateFontSet(dpy, FIXED_FONT, &missing_clist,
485 &missing_count, &def_str)) == NULL)
487 fprintf(stderr, (char *)
488 GETMESSAGE (4, 6, "%1$s: display %2$s doesn't know font %3$s\n"),
489 argv[0], DisplayString(dpy), FIXED_FONT);
493 extents = XExtentsOfFontSet(fontset);
494 textHeight = extents->max_ink_extent.height;
497 * Print the copyright file by default if no other file
503 ppchFileNames[numFiles] = (char *) DEFAULT_FILE;
509 * Break the text string up into separate lines
510 * and place into message buffer.
512 SeparateTextLines ((unsigned char *)stringArg);
514 #ifdef BLOCK_CENTER_FILES
515 centerLines = numLines;
516 #endif /* BLOCK_CENTER_FILES */
518 for (i = 0; i < numFiles; i++)
521 if (!(fp = fopen ((char *)ppchFileNames[i], "r")))
523 fprintf (stderr, (char *)
524 GETMESSAGE (4, 7, "%1$s: unable to open file %2$s\n"),
525 argv[0], ppchFileNames[i]);
532 ReadInTextLines (fp, fontset, (unsigned int *)&maxWidth);
539 colormap = XDefaultColormap (dpy, XDefaultScreen(dpy));
542 * Get background color
544 if (!XParseColor (dpy, colormap, bgArg, &colorDef))
546 /* failed to get background color, try low color default */
547 colorSuccess = False;
548 fprintf(stderr, (char *) GETMESSAGE (4, 8,
549 "%1$s: can't set background to %2$s, using %3$s.\n"),
550 argv[0], bgArg, DEFAULT_LOW_BG);
551 XParseColor (dpy, colormap, DEFAULT_LOW_BG, &colorDef);
553 XAllocColor (dpy, colormap, &colorDef);
558 * Get foreground color
560 if (!XParseColor (dpy, colormap, fgArg, &colorDef))
562 /* failed to get foreground color, try low color default */
563 colorSuccess = False;
564 fprintf(stderr, (char *) GETMESSAGE (4, 9,
565 "%1$s: can't set foreground to %2$s, using %3$s.\n"),
566 argv[0], fgArg, DEFAULT_LOW_FG);
567 XParseColor (dpy, colormap, DEFAULT_LOW_FG, &colorDef);
569 XAllocColor (dpy, colormap, &colorDef);
574 * Create 1x1 window to catch reparenting action of window manager
575 * Request no mwm decoration to reduce flash.
576 * Request no mwm functions to avoid icon in icon box.
578 wmwin = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
579 0, 0, 1, 1, 0, bg, bg);
581 xaMwmHints = XInternAtom (dpy, _XA_MOTIF_WM_HINTS, 0);
583 mwmHints.flags = MWM_HINTS_DECORATIONS | MWM_HINTS_FUNCTIONS;
584 mwmHints.decorations = 0;
585 mwmHints.functions = 0;
587 XChangeProperty (dpy, wmwin, xaMwmHints, xaMwmHints, 32,
588 PropModeReplace, (unsigned char *) &mwmHints,
589 sizeof(PropMotifWmHints)/sizeof(long));
591 XSelectInput (dpy, wmwin, StructureNotifyMask);
593 XMapWindow(dpy, wmwin);
596 * Create override-redirect window for display of transition
600 welcome = XCreateSimpleWindow (dpy, DefaultRootWindow (dpy), 0, 0,
601 displayWidth, displayHeight, 0, bg, bg);
603 mask = CWOverrideRedirect | CWEventMask | CWCursor;
605 xwa.override_redirect = 1;
607 xwa.event_mask = ExposureMask | VisibilityChangeMask;
609 xwa.event_mask = ExposureMask;
610 #endif /* AUTO_TOP */
611 xwa.cursor = GetHourGlass (dpy);
613 XChangeWindowAttributes (dpy, welcome, mask, &xwa);
615 XMapWindow(dpy, welcome);
617 * Event loop for painting text
627 /* XNextEvent(dpy, &event); */
629 XtAppNextEvent(appcontext, &event);
631 if (event.type == Expose &&
632 event.xexpose.window == welcome &&
633 event.xexpose.count == 0)
637 * Remove any other pending Expose events from the queue
639 while (XCheckTypedEvent(dpy, Expose, &event));
642 * Create the GC for drawing the box and painting the text.
646 gc = XCreateGC(dpy, welcome, (GCForeground | GCBackground), &gcv);
647 XClearWindow(dpy, welcome);
658 signal (SIGALRM, (void (*)()) CatchAlarm);
659 alarm (atoi(timeArg));
669 /* XNextEvent(dpy, &event); */
671 XtAppNextEvent(appcontext, &event);
673 if (event.type == ReparentNotify &&
674 event.xany.window == wmwin)
677 * this is our cue...exit, stage left
684 /* normal color serving process */
685 XtDispatchEvent(&event);
694 /*************************************<->*************************************
696 * ArgMatch (pch, arn)
701 * This function determines if a string matches a predefined switch.
705 * pch = candidate string
706 * arn = number of switch we are trying to match.
710 * Return = True if match succeeds.
714 * Would need work to be localized.
716 *************************************<->***********************************/
718 ArgMatch (char *pch, int arn)
722 if (!strncmp(pch, argSpecs[arn].name, argSpecs[arn].len))
731 /*************************************<->*************************************
733 * SkipWhitespace (*pch)
738 * This procedure scans a string and returns a pointer to the first
739 * non-whitespace character.
743 * pch = pointer to string to scan
747 * Return = pointer to first non-white character
751 * Skips blanks and horizontal tabs.
753 *************************************<->***********************************/
755 SkipWhitespace (unsigned char *pch)
761 while ((*pch != '\0') &&
762 ((chlen = mblen ((char *)pch, MB_CUR_MAX)) == 1) &&
763 ((*pch == '\t') || (*pch == ' ')))
773 /*************************************<->*************************************
775 * KillNewlines (*pch)
780 * This procedure scans a string and replaces the first newline
785 * pch = pointer to string to scan
794 *************************************<->***********************************/
796 KillNewlines (unsigned char *pch)
804 if (((chlen = mblen ((char *)pch, MB_CUR_MAX)) == 1) &&
816 /*************************************<->*************************************
818 * ReadInTextLines (fp, font, pMaxWidth)
823 * This procedure reads in lines from a file for the message to
828 * pchIn = pointer to message string
829 * font = font structure to be used to print with
830 * pMaxWidth = width of largest line
835 * modifies global numLines
839 * Global data ppchText is modified by this routine to contain
840 * copies of the text lines from pchIn. pchIn is not modified.
842 *************************************<->***********************************/
844 ReadInTextLines (FILE *fp, XFontSet fontset, unsigned int *pMaxWidth)
849 /* count the number of lines in the file */
850 allowedLines = (displayHeight - (2 * box_line_width))/ textHeight;
852 while (numLines < allowedLines)
854 ppchText[numLines] = (unsigned char *) malloc (1+MAX_COLUMNS);
855 if (!ppchText[numLines] ||
856 !fgets ((char *)ppchText[numLines], MAX_COLUMNS, fp))
860 KillNewlines (ppchText[numLines]);
861 #ifndef BLOCK_CENTER_FILES
862 ppchText[numLines] = SkipWhitespace (ppchText[numLines]);
863 #endif /* not BLOCK_CENTER_FILES */
864 width = XmbTextEscapement(fontset, (char *)(ppchText[numLines]),
865 strlen((char *)ppchText[numLines]));
866 if (width > *pMaxWidth)
875 /*************************************<->*************************************
877 * SeparateTextLines (pchIn)
882 * This procedure takes a message string and separates it into
883 * text lines based on the presence of new line characters.
887 * pchIn = pointer to message string
895 * Global data ppchText is modified by this routine to contain
896 * copies of the text lines from pchIn. pchIn is not modified.
898 *************************************<->***********************************/
900 SeparateTextLines (unsigned char *pchIn)
902 unsigned char *pch, *pch1, *pch2;
903 unsigned char *pchInEnd;
906 /* count the number of new line characters in the string */
909 for (pch = pchIn; *pch; )
911 if (((chlen = mblen ((char *)pch, MB_CUR_MAX)) == 1) &&
919 if ((chlen == 1) && (*(pch-1) == '\n'))
921 numLines--; /* don't count terminating newline */
925 pchInEnd = pchIn + strlen((char *)pchIn);
927 for (i = 0; (i < numLines) && (pch1 < pchInEnd); i++)
929 while ((*pch2 != '\0') &&
930 !(((chlen = mblen ((char *)pch2, MB_CUR_MAX)) == 1) &&
940 ppchText[i] = (unsigned char *) malloc (1+strlen ((char *)pch1));
943 strcpy ((char *)ppchText[i], (char *)pch1);
947 fprintf (stderr, (char *) GETMESSAGE (4, 10,
948 "%s: Insufficient memory (SeparateTextLines)\n"),
953 /* advance pointers */
961 /*************************************<->*************************************
968 * This function catches the SIG_ALRM signal generated when the
973 * sig = signal number
982 *************************************<->***********************************/
984 CatchAlarm ( int sig)
986 /* timer expired, exit */
991 /*************************************<->*************************************
993 * Cursor GetHourGlass ()
998 * Builds and returns the appropriate Hourglass cursor
1011 * None. (None doesn't count as a comment)
1013 *************************************<->***********************************/
1015 #define time32_width 32
1016 #define time32_height 32
1017 #define time32_x_hot 15
1018 #define time32_y_hot 15
1019 static unsigned char time32_bits[] = {
1020 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,
1021 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
1022 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
1023 0x8c, 0x00, 0x00, 0x31, 0x0c, 0x7f, 0xfe, 0x30, 0x0c, 0xfe, 0x7f, 0x30,
1024 0x0c, 0xfc, 0x3f, 0x30, 0x0c, 0xf8, 0x1f, 0x30, 0x0c, 0xe0, 0x07, 0x30,
1025 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x60, 0x06, 0x30,
1026 0x0c, 0x18, 0x18, 0x30, 0x0c, 0x04, 0x20, 0x30, 0x0c, 0x02, 0x40, 0x30,
1027 0x0c, 0x01, 0x80, 0x30, 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x80, 0x01, 0x32,
1028 0x4c, 0xc0, 0x03, 0x32, 0x4c, 0xf0, 0x1f, 0x32, 0x4c, 0xff, 0xff, 0x32,
1029 0xcc, 0xff, 0xff, 0x33, 0x8c, 0xff, 0xff, 0x31, 0xfe, 0xff, 0xff, 0x7f,
1030 0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00};
1032 #define time32m_width 32
1033 #define time32m_height 32
1034 static unsigned char time32m_bits[] = {
1035 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1036 0xcf, 0x00, 0x00, 0xf3, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
1037 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
1038 0xce, 0x00, 0x00, 0x73, 0x8e, 0x7f, 0xfe, 0x71, 0x0e, 0xff, 0xff, 0x70,
1039 0x0e, 0xfe, 0x7f, 0x70, 0x0e, 0xfc, 0x3f, 0x70, 0x0e, 0xf8, 0x1f, 0x70,
1040 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0x78, 0x1e, 0x70,
1041 0x0e, 0x1c, 0x38, 0x70, 0x0e, 0x06, 0x60, 0x70, 0x0e, 0x03, 0xc0, 0x70,
1042 0x8e, 0x01, 0x80, 0x71, 0xce, 0x00, 0x00, 0x73, 0x6e, 0x80, 0x01, 0x76,
1043 0x6e, 0xc0, 0x03, 0x76, 0x6e, 0xf0, 0x1f, 0x76, 0x6e, 0xff, 0xff, 0x76,
1044 0xee, 0xff, 0xff, 0x77, 0xcf, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff,
1045 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1048 #define time16_x_hot 7
1049 #define time16_y_hot 7
1050 #define time16_width 16
1051 #define time16_height 16
1052 static unsigned char time16_bits[] = {
1053 0x00, 0x00, 0xfe, 0x7f, 0x14, 0x28, 0x14, 0x28, 0x14, 0x28, 0x24, 0x24,
1054 0x44, 0x22, 0x84, 0x21, 0x84, 0x21, 0x44, 0x22, 0x24, 0x24, 0x14, 0x28,
1055 0x94, 0x29, 0xd4, 0x2b, 0xfe, 0x7f, 0x00, 0x00};
1057 #define time16m_width 16
1058 #define time16m_height 16
1059 static unsigned char time16m_bits[] = {
1060 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
1061 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
1062 0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff};
1065 Cursor GetHourGlass (Display *dpy)
1067 unsigned char *bits;
1068 unsigned char *maskBits;
1070 unsigned int height;
1071 unsigned int xHotspot;
1072 unsigned int yHotspot;
1076 unsigned int cWidth;
1077 unsigned int cHeight;
1078 int useLargeCursors = 0;
1081 if (XQueryBestCursor (dpy, DefaultRootWindow(dpy),
1082 32, 32, &cWidth, &cHeight))
1084 if ((cWidth >= 32) && (cHeight >= 32))
1086 useLargeCursors = 1;
1090 if (useLargeCursors)
1092 width = time32_width;
1093 height = time32_height;
1095 maskBits = time32m_bits;
1096 xHotspot = time32_x_hot;
1097 yHotspot = time32_y_hot;
1101 width = time16_width;
1102 height = time16_height;
1104 maskBits = time16m_bits;
1105 xHotspot = time16_x_hot;
1106 yHotspot = time16_y_hot;
1109 pixmap = XCreateBitmapFromData (dpy,
1110 DefaultRootWindow(dpy), (char *)bits,
1113 maskPixmap = XCreateBitmapFromData (dpy,
1114 DefaultRootWindow(dpy), (char *)maskBits,
1117 xcolors[0].pixel = BlackPixelOfScreen(DefaultScreenOfDisplay(dpy));
1118 xcolors[1].pixel = WhitePixelOfScreen(DefaultScreenOfDisplay(dpy));
1121 DefaultColormapOfScreen(DefaultScreenOfDisplay
1122 (dpy)), xcolors, 2);
1124 waitCursor = XCreatePixmapCursor (dpy, pixmap, maskPixmap,
1125 &(xcolors[0]), &(xcolors[1]),
1126 xHotspot, yHotspot);
1127 XFreePixmap (dpy, pixmap);
1128 XFreePixmap (dpy, maskPixmap);
1130 return (waitCursor);
1133 #ifndef NO_MESSAGE_CATALOG
1134 /*****************************************************************************
1136 * Function: GetMessage
1140 * int set - The message catalog set number.
1142 * int n - The message number.
1144 * char *s - The default message if the message is not
1145 * retrieved from a message catalog.
1147 * Returns: the string for set 'set' and number 'n'.
1149 *****************************************************************************/
1161 static int first = 1;
1162 static nl_catd nlmsg_fd;
1167 lang = (char *) getenv ("LANG");
1169 if (!lang || !(strcmp (lang, "C")))
1171 * If LANG is not set or if LANG=C, then there
1172 * is no need to open the message catalog - just
1173 * return the built-in string "s".
1175 nlmsg_fd = (nl_catd)-1;
1177 nlmsg_fd = catopen("dthello", NL_CAT_LOCALE);
1179 msg=catgets(nlmsg_fd,set,n,s);
1185 /*************************************<->*************************************
1187 * void VhGetResources
1192 * Gets the resources for the client
1204 *************************************<->***********************************/
1207 VhGetResources(Display *dpy, char *name, char *class,
1208 VhResourceEntry *res, int num)
1210 #define INIT_SIZE 256
1211 #define SRCH_SIZE 20
1214 XrmQuark Qtype, Qstring, Qname, Qclass;
1215 XrmQuark Qnres[4], Qcres[4];
1216 XrmHashTable searchList[SRCH_SIZE];
1219 * We only deal with string-type resources
1222 Qstring = XrmStringToQuark (XtRString);
1225 * Get resource search list for "dthello"
1227 XrmStringToQuarkList (name, Qnres);
1228 XrmStringToQuarkList (class, Qcres);
1230 if (XrmQGetSearchList(XtDatabase(dpy), Qnres, Qcres, searchList,
1234 * Look for all resources at this level
1237 for (i = 0; i < num; i++)
1239 Qname = XrmStringToQuark (res[i].resname);
1240 Qclass = XrmStringToQuark (res[i].resclass);
1242 if ((XrmQGetSearchResource (searchList, Qname, Qclass,
1246 *(res[i].ppvalue) = (char *) xrmv.addr;
1247 *res[i].size = (int) xrmv.size;
1257 XFontSetExtents *extents;
1260 * Paint the string onto the screen
1264 y = (displayHeight - totalHeight) / 2;
1270 /* adjust origin by font metric */
1271 extents = XExtentsOfFontSet(fontset);
1272 y += -(extents->max_logical_extent.y);
1274 x = box_line_width + x_offset;
1276 for (i = 0; i < numLines; i++)
1278 /* draw the string */
1279 XmbDrawString (dpy, welcome, fontset, gc, x, y,
1280 (char *)(ppchText[i]), strlen((char *)ppchText[i]));
1282 /* move to next "line" */
1289 int LTX, LTY, RTX, RTY, LBX, LBY, RBX, RBY;
1290 int L_middle; /* pixels to the midpoint of the line width */
1292 Boolean useDecoration = True;
1294 /* compute the height of the font */
1295 totalHeight = textHeight * numLines;
1300 if ((( 2 * box_line_width ) + x_offset + maxWidth) > displayWidth)
1302 useDecoration = False;
1309 L_middle = box_line_width / 2;
1310 /********************************************************
1311 +----------------------------------------------+
1312 | (LTX, LTY) (RTX, RTY) |
1314 | (Draw counterclockwise, beginning from |
1322 | (LBX, LBY) (RBX, RBY) |
1323 +----------------------------------------------+
1324 ********************************************************/
1332 LBY = displayHeight;
1334 RBX = displayWidth ;
1335 RBY = displayHeight;
1337 XSetLineAttributes(dpy, gc, box_line_width, LineSolid, CapButt, JoinMiter);
1338 XDrawLine(dpy, welcome, gc,
1339 LTX, LTY + L_middle,
1340 RTX, RTY + L_middle);
1342 XDrawLine(dpy, welcome, gc,
1343 RTX - L_middle, RTY,
1344 RBX - L_middle, RBY);
1346 XDrawLine(dpy, welcome, gc,
1347 RBX, RBY - L_middle,
1348 LBX, LBY - L_middle);
1350 XDrawLine(dpy, welcome, gc,
1351 LBX + L_middle, LBY,
1352 LTX + L_middle, LTY);
1357 Xestrcmp(const char * const s1, const char * const s2)
1359 if (s1 == s2) return 0;
1361 const char * p1 = (s1) ? s1 : "";
1362 const char * p2 = (s2) ? s2 : "";
1364 return strcmp((char *)p1, (char *)p2);
1368 /************** eof ******************/