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 libraries 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>
81 #ifndef NO_MESSAGE_CATALOG
82 # include <nl_types.h>
85 #include <Dt/EnvControlP.h>
88 #ifndef NO_MESSAGE_CATALOG
89 # define GETMESSAGE(set, number, string) GetMessage(set, number, string)
91 # define GETMESSAGE(set, number, string) string
94 #if !defined(NL_CAT_LOCALE)
95 #define NL_CAT_LOCALE 0
101 Window welcome; /* Welcome window ID */
102 Display *dpy; /* X server connection */
103 struct globalStruct vhGD;
104 int x_offset = 0; /* for left-justifying text */
105 int box_line_width = 0; /* for drawing a box */
106 XFontSet fontset; /* Font descriptor for ILS */
107 unsigned long textHeight; /* Font size parameters */
108 unsigned long fg, bg; /* Pixel values */
109 Boolean colorSuccess = True; /* Success at allocating colors */
110 XGCValues gcv; /* Struct for creating GC */
111 unsigned int totalHeight; /* total Height used for text */
112 unsigned int displayHeight; /* height of display in pixels */
113 int maxWidth; /* max width of lines read in from file */
114 unsigned int displayWidth; /* width of display in pixels */
115 GC gc; /* GC to draw with */
117 static XrmOptionDescRec optTable[] = {
118 {"-font", "*vfont", XrmoptionSepArg, (XtPointer) NULL},
119 {"-fnt", "*vfont", XrmoptionSepArg, (XtPointer) NULL},
121 static int noptTable = sizeof(optTable)/sizeof(optTable[0]);
125 {"-bground", 8}, /* background color */
128 {"-fground", 8}, /* foreground color */
131 {"-string", 7}, /* string to display */
134 {"-fnt", 4}, /* font to use */
137 {"-timeout", 8}, /* timeout amount in seconds*/
140 {"-file", 5}, /* file */
145 char *ppchFileNames[MAX_FILES]; /* names of files to print */
146 unsigned char *ppchText[MAX_LINES]; /* text lines to print out */
147 int numFiles; /* number of files to print */
148 int numLines; /* number of text lines to print out */
149 #ifdef BLOCK_CENTER_FILES
150 int centerLines; /* number of text lines to print centered */
151 #endif /* BLOCK_CENTER_FILES */
152 char *progName; /* who we are */
153 char *fontArg; /* font argument */
155 char *stringArg; /* string argument */
157 char *bgArg; /* background argument */
159 char *fgArg; /* foreground argument */
161 char *xoffsetArg; /* text x_offset argument */
163 char *timeArg; /* timeout argument, in seconds */
166 Boolean Done; /* while painting text */
168 static VhResourceEntry restable[] = {
169 { vNbackground, vCBackground, &bgArg, &sizeBgArg },
170 { vNforeground, vCForeground, &fgArg, &sizeFgArg },
171 { vNfont, vCFont, &fontArg, &sizeFontArg },
172 { vNxoffset, vCXoffset, &xoffsetArg, &sizeXoffsetArg },
173 { vNstring, vCString, &stringArg, &sizeStringArg },
174 { vNfile, vCFile, &ppchFileNames[0], &sizeFileArg },
175 { vNtimeout, vCTimeout, &timeArg, &sizeTimeArg },
181 fprintf(stderr, (char *) GETMESSAGE (4, 4,
182 "usage: %s [-display <display>] [-bground <color>] [-fground <color>]\n"),
184 fprintf(stderr, "%s", (char *) GETMESSAGE (4, 5,
185 "\t[-font <font>] [-string <message>] [-timeout <seconds>] [-file <name>]\n"));
189 /*************************************<->*************************************
196 * This is the main routine that does almost all the work.
200 * argc = Std C argument count
201 * argv = Std C argument vector
209 * This works by creating an override-redirect window the size of
210 * the screen and painting a message on it. At the same time, a
211 * 1x1 window is created that will be picked up by the window
212 * manager. When the window manager reparents the little window,
213 * this program exits.
217 * dthello [-display <display>] [-fground <color>] [-bground <color>]
218 * [-font <fontname>] [-string <message>] [-file <filename>]
219 * [-timeout <seconds>]
221 *************************************<->***********************************/
223 main (int argc, char **argv)
225 Window wmwin; /* Window ID for wm */
226 XEvent event; /* Event received */
227 unsigned long mask; /* mask for window attribs */
228 XSetWindowAttributes xwa; /* Set Window Attribute struct */
229 int argn; /* temp for parsing args */
230 XColor colorDef; /* for parsing/allocating colors */
231 Colormap colormap; /* color map of screen */
232 Atom xaMwmHints; /* mwm hints atom */
233 PropMotifWmHints mwmHints; /* mwm hints structure */
234 Visual *pdv; /* X visual structure */
235 FILE *fp; /* file pointer */
236 int i; /* loop index */
237 char *default_string; /* default message */
238 XtAppContext appcontext;
240 char **missing_clist;
242 XFontSetExtents *extents;
244 XtSetLanguageProc( NULL, NULL, NULL );
250 * Set up NLSPATH, app-defaults, etc. for this DT client.
252 _DtEnvControl(DT_ENV_SET);
255 * Process command line arguments
258 /* fontArg = DEFAULT_FONT; */
261 timeArg = DEFAULT_TIME;
266 * Initialize Toolkit, open display
268 XtToolkitInitialize();
269 appcontext = XtCreateApplicationContext();
271 dpy = XtOpenDisplay (appcontext, NULL, argv[0], DTHELLO_CLASS_NAME,
272 optTable, noptTable, (int *)(&argc), argv);
276 setlocale(LC_ALL, "");
277 fprintf(stderr, (char *)
278 GETMESSAGE(4, 1, "%s: can't open display\n"), progName);
282 default_string = strdup (
283 ((char *)GETMESSAGE(2, 3,
284 "Starting the\nCommon Desktop Environment\n\n")));
286 stringArg = default_string;
289 * Find appropriate default font
290 * and offset from the left side of the screen
293 switch (_DtGetDisplayResolution(dpy, XDefaultScreen(dpy)))
295 case LOW_RES_DISPLAY:
296 fontArg = DEFAULT_FONT_SMALL;
297 x_offset = DEFAULT_XOFFSET_SMALL;
298 box_line_width = BOX_LINE_WIDTH_SMALL;
301 case MED_RES_DISPLAY:
302 fontArg = DEFAULT_FONT_MEDIUM;
303 x_offset = DEFAULT_XOFFSET_MEDIUM;
304 box_line_width = BOX_LINE_WIDTH_MEDIUM;
307 case HIGH_RES_DISPLAY:
308 fontArg = DEFAULT_FONT_LARGE;
309 x_offset = DEFAULT_XOFFSET_LARGE;
310 box_line_width = BOX_LINE_WIDTH_LARGE;
313 fontArg = DEFAULT_FONT_SMALL;
314 x_offset = DEFAULT_XOFFSET_SMALL;
315 box_line_width = BOX_LINE_WIDTH_SMALL;
322 VhGetResources (dpy, progName, DTHELLO_CLASS,
323 restable, XtNumber(restable));
325 /* assign the x_offset to the value set in the resource list if given by the user */
327 if( xoffsetArg != NULL)
328 x_offset = atoi(xoffsetArg);
331 x_offset = -x_offset;
334 if (sizeFileArg != 0)
340 * Parse remaining command line arguments
342 for (argn = 1; argn < argc; argn++)
344 if ((*argv[argn] == '-') &&
347 if (ArgMatch (argv[argn], BG_ARG))
349 bgArg = argv[++argn];
353 else if (ArgMatch (argv[argn], FG_ARG))
355 fgArg = argv[++argn];
359 else if (ArgMatch (argv[argn], STRING_ARG))
361 stringArg = argv[++argn];
365 else if (ArgMatch (argv[argn], FONT_ARG))
367 fontArg = argv[++argn];
371 else if (ArgMatch (argv[argn], TIME_ARG))
373 timeArg = argv[++argn];
374 if (atoi(timeArg) <= 0)
376 fprintf (stderr, (char *)
377 GETMESSAGE(4, 2, "%s: timeout must be positive\n"),
379 timeArg = DEFAULT_TIME;
384 else if (ArgMatch (argv[argn], FILE_ARG))
387 if (numFiles < MAX_FILES)
389 ppchFileNames[numFiles] = (char *) argv[argn];
394 fprintf(stderr, (char *) GETMESSAGE(4, 3,
395 "%1$s: Maxiumum of %2$d files allowed, skipping %3$s\n"),
396 argv[0], MAX_FILES, argv[argn]);
415 displayHeight = XDisplayHeight (dpy, XDefaultScreen(dpy));
416 displayWidth = XDisplayWidth (dpy, XDefaultScreen(dpy));
419 * Set default fg/bg colors if not specified.
420 * (adjust for low-color systems)
423 pdv = XDefaultVisual(dpy, XDefaultScreen(dpy));
426 * Set default colors if not specified on command line.
428 if ((XDefaultDepth(dpy, XDefaultScreen(dpy)) <= 4) ||
429 (pdv->class == StaticGray) ||
430 (pdv->class == GrayScale))
433 * B&W, GrayScale, or low-color systems
437 bgArg = DEFAULT_LOW_BG;
442 fgArg = DEFAULT_LOW_FG;
448 * Medium- to High-color systems
464 if ((fontset = XCreateFontSet(dpy, fontArg, &missing_clist, &missing_count,
467 fprintf(stderr, (char *)
468 GETMESSAGE (4, 6, "%1$s: display %2$s doesn't know font %3$s\n"),
469 argv[0], DisplayString(dpy), fontArg);
471 if ((fontset = XCreateFontSet(dpy, DEFAULT_FONT, &missing_clist,
472 &missing_count, &def_str)) == NULL)
474 fprintf(stderr, (char *)
475 GETMESSAGE (4, 6, "%1$s: display %2$s doesn't know font %3$s\n"),
476 argv[0], DisplayString(dpy), DEFAULT_FONT);
479 if ((NULL == fontset) &&
480 (fontset = XCreateFontSet(dpy, FIXED_FONT, &missing_clist,
481 &missing_count, &def_str)) == NULL)
483 fprintf(stderr, (char *)
484 GETMESSAGE (4, 6, "%1$s: display %2$s doesn't know font %3$s\n"),
485 argv[0], DisplayString(dpy), FIXED_FONT);
489 extents = XExtentsOfFontSet(fontset);
490 textHeight = extents->max_ink_extent.height;
493 * Print the copyright file by default if no other file
499 ppchFileNames[numFiles] = (char *) DEFAULT_FILE;
505 * Break the text string up into separate lines
506 * and place into message buffer.
508 SeparateTextLines ((unsigned char *)stringArg);
510 #ifdef BLOCK_CENTER_FILES
511 centerLines = numLines;
512 #endif /* BLOCK_CENTER_FILES */
514 for (i = 0; i < numFiles; i++)
517 if (!(fp = fopen ((char *)ppchFileNames[i], "r")))
519 fprintf (stderr, (char *)
520 GETMESSAGE (4, 7, "%1$s: unable to open file %2$s\n"),
521 argv[0], ppchFileNames[i]);
528 ReadInTextLines (fp, fontset, (unsigned int *)&maxWidth);
535 colormap = XDefaultColormap (dpy, XDefaultScreen(dpy));
538 * Get background color
540 if (!XParseColor (dpy, colormap, bgArg, &colorDef))
542 /* failed to get background color, try low color default */
543 colorSuccess = False;
544 fprintf(stderr, (char *) GETMESSAGE (4, 8,
545 "%1$s: can't set background to %2$s, using %3$s.\n"),
546 argv[0], bgArg, DEFAULT_LOW_BG);
547 XParseColor (dpy, colormap, DEFAULT_LOW_BG, &colorDef);
549 XAllocColor (dpy, colormap, &colorDef);
554 * Get foreground color
556 if (!XParseColor (dpy, colormap, fgArg, &colorDef))
558 /* failed to get foreground color, try low color default */
559 colorSuccess = False;
560 fprintf(stderr, (char *) GETMESSAGE (4, 9,
561 "%1$s: can't set foreground to %2$s, using %3$s.\n"),
562 argv[0], fgArg, DEFAULT_LOW_FG);
563 XParseColor (dpy, colormap, DEFAULT_LOW_FG, &colorDef);
565 XAllocColor (dpy, colormap, &colorDef);
570 * Create 1x1 window to catch reparenting action of window manager
571 * Request no mwm decoration to reduce flash.
572 * Request no mwm functions to avoid icon in icon box.
574 wmwin = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
575 0, 0, 1, 1, 0, bg, bg);
577 xaMwmHints = XInternAtom (dpy, _XA_MOTIF_WM_HINTS, 0);
579 mwmHints.flags = MWM_HINTS_DECORATIONS | MWM_HINTS_FUNCTIONS;
580 mwmHints.decorations = 0;
581 mwmHints.functions = 0;
583 XChangeProperty (dpy, wmwin, xaMwmHints, xaMwmHints, 32,
584 PropModeReplace, (unsigned char *) &mwmHints,
585 sizeof(PropMotifWmHints)/sizeof(long));
587 XSelectInput (dpy, wmwin, StructureNotifyMask);
589 XMapWindow(dpy, wmwin);
592 * Create override-redirect window for display of transition
596 welcome = XCreateSimpleWindow (dpy, DefaultRootWindow (dpy), 0, 0,
597 displayWidth, displayHeight, 0, bg, bg);
599 mask = CWOverrideRedirect | CWEventMask | CWCursor;
601 xwa.override_redirect = 1;
603 xwa.event_mask = ExposureMask | VisibilityChangeMask;
605 xwa.event_mask = ExposureMask;
606 #endif /* AUTO_TOP */
607 xwa.cursor = GetHourGlass (dpy);
609 XChangeWindowAttributes (dpy, welcome, mask, &xwa);
611 XMapWindow(dpy, welcome);
613 * Event loop for painting text
623 /* XNextEvent(dpy, &event); */
625 XtAppNextEvent(appcontext, &event);
627 if (event.type == Expose &&
628 event.xexpose.window == welcome &&
629 event.xexpose.count == 0)
633 * Remove any other pending Expose events from the queue
635 while (XCheckTypedEvent(dpy, Expose, &event));
638 * Create the GC for drawing the box and painting the text.
642 gc = XCreateGC(dpy, welcome, (GCForeground | GCBackground), &gcv);
643 XClearWindow(dpy, welcome);
654 signal (SIGALRM, (void (*)()) CatchAlarm);
655 alarm (atoi(timeArg));
665 /* XNextEvent(dpy, &event); */
667 XtAppNextEvent(appcontext, &event);
669 if (event.type == ReparentNotify &&
670 event.xany.window == wmwin)
673 * this is our cue...exit, stage left
680 /* normal color serving process */
681 XtDispatchEvent(&event);
690 /*************************************<->*************************************
692 * ArgMatch (pch, arn)
697 * This function determines if a string matches a predefined switch.
701 * pch = candidate string
702 * arn = number of switch we are trying to match.
706 * Return = True if match succeeds.
710 * Would need work to be localized.
712 *************************************<->***********************************/
714 ArgMatch (char *pch, int arn)
718 if (!strncmp(pch, argSpecs[arn].name, argSpecs[arn].len))
727 /*************************************<->*************************************
729 * SkipWhitespace (*pch)
734 * This procedure scans a string and returns a pointer to the first
735 * non-whitespace character.
739 * pch = pointer to string to scan
743 * Return = pointer to first non-white character
747 * Skips blanks and horizontal tabs.
749 *************************************<->***********************************/
751 SkipWhitespace (unsigned char *pch)
757 while ((*pch != '\0') &&
758 ((chlen = mblen ((char *)pch, MB_CUR_MAX)) == 1) &&
759 ((*pch == '\t') || (*pch == ' ')))
769 /*************************************<->*************************************
771 * KillNewlines (*pch)
776 * This procedure scans a string and replaces the first newline
781 * pch = pointer to string to scan
790 *************************************<->***********************************/
792 KillNewlines (unsigned char *pch)
800 if (((chlen = mblen ((char *)pch, MB_CUR_MAX)) == 1) &&
812 /*************************************<->*************************************
814 * ReadInTextLines (fp, font, pMaxWidth)
819 * This procedure reads in lines from a file for the message to
824 * pchIn = pointer to message string
825 * font = font structure to be used to print with
826 * pMaxWidth = width of largest line
831 * modifies global numLines
835 * Global data ppchText is modified by this routine to contain
836 * copies of the text lines from pchIn. pchIn is not modified.
838 *************************************<->***********************************/
840 ReadInTextLines (FILE *fp, XFontSet fontset, unsigned int *pMaxWidth)
845 /* count the number of lines in the file */
846 allowedLines = (displayHeight - (2 * box_line_width))/ textHeight;
848 while (numLines < allowedLines)
850 ppchText[numLines] = (unsigned char *) malloc (1+MAX_COLUMNS);
851 if (!ppchText[numLines] ||
852 !fgets ((char *)ppchText[numLines], MAX_COLUMNS, fp))
856 KillNewlines (ppchText[numLines]);
857 #ifndef BLOCK_CENTER_FILES
858 ppchText[numLines] = SkipWhitespace (ppchText[numLines]);
859 #endif /* not BLOCK_CENTER_FILES */
860 width = XmbTextEscapement(fontset, (char *)(ppchText[numLines]),
861 strlen((char *)ppchText[numLines]));
862 if (width > *pMaxWidth)
871 /*************************************<->*************************************
873 * SeparateTextLines (pchIn)
878 * This procedure takes a message string and separates it into
879 * text lines based on the presence of new line characters.
883 * pchIn = pointer to message string
891 * Global data ppchText is modified by this routine to contain
892 * copies of the text lines from pchIn. pchIn is not modified.
894 *************************************<->***********************************/
896 SeparateTextLines (unsigned char *pchIn)
898 unsigned char *pch, *pch1, *pch2;
899 unsigned char *pchInEnd;
902 /* count the number of new line characters in the string */
905 for (pch = pchIn; *pch; )
907 if (((chlen = mblen ((char *)pch, MB_CUR_MAX)) == 1) &&
915 if ((chlen == 1) && (*(pch-1) == '\n'))
917 numLines--; /* don't count terminating newline */
921 pchInEnd = pchIn + strlen((char *)pchIn);
923 for (i = 0; (i < numLines) && (pch1 < pchInEnd); i++)
925 while ((*pch2 != '\0') &&
926 !(((chlen = mblen ((char *)pch2, MB_CUR_MAX)) == 1) &&
936 ppchText[i] = (unsigned char *) malloc (1+strlen ((char *)pch1));
939 strcpy ((char *)ppchText[i], (char *)pch1);
943 fprintf (stderr, (char *) GETMESSAGE (4, 10,
944 "%s: Insufficient memory (SeparateTextLines)\n"),
949 /* advance pointers */
957 /*************************************<->*************************************
964 * This function catches the SIG_ALRM signal generated when the
969 * sig = signal number
978 *************************************<->***********************************/
980 CatchAlarm ( int sig)
982 /* timer expired, exit */
987 /*************************************<->*************************************
989 * Cursor GetHourGlass ()
994 * Builds and returns the appropriate Hourglass cursor
1007 * None. (None doesn't count as a comment)
1009 *************************************<->***********************************/
1011 #define time32_width 32
1012 #define time32_height 32
1013 #define time32_x_hot 15
1014 #define time32_y_hot 15
1015 static unsigned char time32_bits[] = {
1016 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,
1017 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
1018 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
1019 0x8c, 0x00, 0x00, 0x31, 0x0c, 0x7f, 0xfe, 0x30, 0x0c, 0xfe, 0x7f, 0x30,
1020 0x0c, 0xfc, 0x3f, 0x30, 0x0c, 0xf8, 0x1f, 0x30, 0x0c, 0xe0, 0x07, 0x30,
1021 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x60, 0x06, 0x30,
1022 0x0c, 0x18, 0x18, 0x30, 0x0c, 0x04, 0x20, 0x30, 0x0c, 0x02, 0x40, 0x30,
1023 0x0c, 0x01, 0x80, 0x30, 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x80, 0x01, 0x32,
1024 0x4c, 0xc0, 0x03, 0x32, 0x4c, 0xf0, 0x1f, 0x32, 0x4c, 0xff, 0xff, 0x32,
1025 0xcc, 0xff, 0xff, 0x33, 0x8c, 0xff, 0xff, 0x31, 0xfe, 0xff, 0xff, 0x7f,
1026 0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00};
1028 #define time32m_width 32
1029 #define time32m_height 32
1030 static unsigned char time32m_bits[] = {
1031 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1032 0xcf, 0x00, 0x00, 0xf3, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
1033 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
1034 0xce, 0x00, 0x00, 0x73, 0x8e, 0x7f, 0xfe, 0x71, 0x0e, 0xff, 0xff, 0x70,
1035 0x0e, 0xfe, 0x7f, 0x70, 0x0e, 0xfc, 0x3f, 0x70, 0x0e, 0xf8, 0x1f, 0x70,
1036 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0x78, 0x1e, 0x70,
1037 0x0e, 0x1c, 0x38, 0x70, 0x0e, 0x06, 0x60, 0x70, 0x0e, 0x03, 0xc0, 0x70,
1038 0x8e, 0x01, 0x80, 0x71, 0xce, 0x00, 0x00, 0x73, 0x6e, 0x80, 0x01, 0x76,
1039 0x6e, 0xc0, 0x03, 0x76, 0x6e, 0xf0, 0x1f, 0x76, 0x6e, 0xff, 0xff, 0x76,
1040 0xee, 0xff, 0xff, 0x77, 0xcf, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff,
1041 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1044 #define time16_x_hot 7
1045 #define time16_y_hot 7
1046 #define time16_width 16
1047 #define time16_height 16
1048 static unsigned char time16_bits[] = {
1049 0x00, 0x00, 0xfe, 0x7f, 0x14, 0x28, 0x14, 0x28, 0x14, 0x28, 0x24, 0x24,
1050 0x44, 0x22, 0x84, 0x21, 0x84, 0x21, 0x44, 0x22, 0x24, 0x24, 0x14, 0x28,
1051 0x94, 0x29, 0xd4, 0x2b, 0xfe, 0x7f, 0x00, 0x00};
1053 #define time16m_width 16
1054 #define time16m_height 16
1055 static unsigned char time16m_bits[] = {
1056 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
1057 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
1058 0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff};
1061 Cursor GetHourGlass (Display *dpy)
1063 unsigned char *bits;
1064 unsigned char *maskBits;
1066 unsigned int height;
1067 unsigned int xHotspot;
1068 unsigned int yHotspot;
1072 unsigned int cWidth;
1073 unsigned int cHeight;
1074 int useLargeCursors = 0;
1077 if (XQueryBestCursor (dpy, DefaultRootWindow(dpy),
1078 32, 32, &cWidth, &cHeight))
1080 if ((cWidth >= 32) && (cHeight >= 32))
1082 useLargeCursors = 1;
1086 if (useLargeCursors)
1088 width = time32_width;
1089 height = time32_height;
1091 maskBits = time32m_bits;
1092 xHotspot = time32_x_hot;
1093 yHotspot = time32_y_hot;
1097 width = time16_width;
1098 height = time16_height;
1100 maskBits = time16m_bits;
1101 xHotspot = time16_x_hot;
1102 yHotspot = time16_y_hot;
1105 pixmap = XCreateBitmapFromData (dpy,
1106 DefaultRootWindow(dpy), (char *)bits,
1109 maskPixmap = XCreateBitmapFromData (dpy,
1110 DefaultRootWindow(dpy), (char *)maskBits,
1113 xcolors[0].pixel = BlackPixelOfScreen(DefaultScreenOfDisplay(dpy));
1114 xcolors[1].pixel = WhitePixelOfScreen(DefaultScreenOfDisplay(dpy));
1117 DefaultColormapOfScreen(DefaultScreenOfDisplay
1118 (dpy)), xcolors, 2);
1120 waitCursor = XCreatePixmapCursor (dpy, pixmap, maskPixmap,
1121 &(xcolors[0]), &(xcolors[1]),
1122 xHotspot, yHotspot);
1123 XFreePixmap (dpy, pixmap);
1124 XFreePixmap (dpy, maskPixmap);
1126 return (waitCursor);
1129 #ifndef NO_MESSAGE_CATALOG
1130 /*****************************************************************************
1132 * Function: GetMessage
1136 * int set - The message catalog set number.
1138 * int n - The message number.
1140 * char *s - The default message if the message is not
1141 * retrieved from a message catalog.
1143 * Returns: the string for set 'set' and number 'n'.
1145 *****************************************************************************/
1157 static int first = 1;
1158 static nl_catd nlmsg_fd;
1163 lang = (char *) getenv ("LANG");
1165 if (!lang || !(strcmp (lang, "C")))
1167 * If LANG is not set or if LANG=C, then there
1168 * is no need to open the message catalog - just
1169 * return the built-in string "s".
1171 nlmsg_fd = (nl_catd)-1;
1173 nlmsg_fd = catopen("dthello", NL_CAT_LOCALE);
1175 msg=catgets(nlmsg_fd,set,n,s);
1181 /*************************************<->*************************************
1183 * void VhGetResources
1188 * Gets the resources for the client
1200 *************************************<->***********************************/
1203 VhGetResources(Display *dpy, char *name, char *class,
1204 VhResourceEntry *res, int num)
1206 #define INIT_SIZE 256
1207 #define SRCH_SIZE 20
1210 XrmQuark Qtype, Qstring, Qname, Qclass;
1211 XrmQuark Qnres[4], Qcres[4];
1212 XrmHashTable searchList[SRCH_SIZE];
1215 * We only deal with string-type resources
1218 Qstring = XrmStringToQuark (XtRString);
1221 * Get resource search list for "dthello"
1223 XrmStringToQuarkList (name, Qnres);
1224 XrmStringToQuarkList (class, Qcres);
1226 if (XrmQGetSearchList(XtDatabase(dpy), Qnres, Qcres, searchList,
1230 * Look for all resources at this level
1233 for (i = 0; i < num; i++)
1235 Qname = XrmStringToQuark (res[i].resname);
1236 Qclass = XrmStringToQuark (res[i].resclass);
1238 if ((XrmQGetSearchResource (searchList, Qname, Qclass,
1242 *(res[i].ppvalue) = (char *) xrmv.addr;
1243 *res[i].size = (int) xrmv.size;
1253 XFontSetExtents *extents;
1256 * Paint the string onto the screen
1260 y = (displayHeight - totalHeight) / 2;
1266 /* adjust origin by font metric */
1267 extents = XExtentsOfFontSet(fontset);
1268 y += -(extents->max_logical_extent.y);
1270 x = box_line_width + x_offset;
1272 for (i = 0; i < numLines; i++)
1274 /* draw the string */
1275 XmbDrawString (dpy, welcome, fontset, gc, x, y,
1276 (char *)(ppchText[i]), strlen((char *)ppchText[i]));
1278 /* move to next "line" */
1285 int LTX, LTY, RTX, RTY, LBX, LBY, RBX, RBY;
1286 int L_middle; /* pixels to the midpoint of the line width */
1288 Boolean useDecoration = True;
1290 /* compute the height of the font */
1291 totalHeight = textHeight * numLines;
1296 if ((( 2 * box_line_width ) + x_offset + maxWidth) > displayWidth)
1298 useDecoration = False;
1305 L_middle = box_line_width / 2;
1306 /********************************************************
1307 +----------------------------------------------+
1308 | (LTX, LTY) (RTX, RTY) |
1310 | (Draw counterclockwise, beginning from |
1318 | (LBX, LBY) (RBX, RBY) |
1319 +----------------------------------------------+
1320 ********************************************************/
1328 LBY = displayHeight;
1330 RBX = displayWidth ;
1331 RBY = displayHeight;
1333 XSetLineAttributes(dpy, gc, box_line_width, LineSolid, CapButt, JoinMiter);
1334 XDrawLine(dpy, welcome, gc,
1335 LTX, LTY + L_middle,
1336 RTX, RTY + L_middle);
1338 XDrawLine(dpy, welcome, gc,
1339 RTX - L_middle, RTY,
1340 RBX - L_middle, RBY);
1342 XDrawLine(dpy, welcome, gc,
1343 RBX, RBY - L_middle,
1344 LBX, LBY - L_middle);
1346 XDrawLine(dpy, welcome, gc,
1347 LBX + L_middle, LBY,
1348 LTX + L_middle, LTY);
1353 Xestrcmp(const char * const s1, const char * const s2)
1355 if (s1 == s2) return 0;
1357 const char * p1 = (s1) ? s1 : "";
1358 const char * p2 = (s2) ? s2 : "";
1360 return strcmp((char *)p1, (char *)p2);
1364 /************** eof ******************/