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.
71 #include <X11/Intrinsic.h>
72 #include <X11/StringDefs.h>
73 #include <X11/Xutil.h>
74 #include <Xm/MwmUtil.h>
75 #include <sys/signal.h>
77 #include <Dt/GetDispRes.h>
79 #include </sys5/usr/include/limits.h>
84 #ifndef NO_MESSAGE_CATALOG
85 # include <nl_types.h>
88 #include <Dt/EnvControlP.h>
91 #ifndef NO_MESSAGE_CATALOG
92 # define GETMESSAGE(set, number, string) GetMessage(set, number, string)
94 # define GETMESSAGE(set, number, string) string
97 #if !defined(NL_CAT_LOCALE)
98 #define NL_CAT_LOCALE 0
104 Window welcome; /* Welcome window ID */
105 Display *dpy; /* X server connection */
106 struct globalStruct vhGD;
107 int x_offset = 0; /* for left-justifying text */
108 int box_line_width = 0; /* for drawing a box */
109 XFontSet fontset; /* Font descriptor for ILS */
110 unsigned long textHeight; /* Font size parameters */
111 unsigned long fg, bg; /* Pixel values */
112 Boolean colorSuccess = True; /* Success at allocating colors */
113 XGCValues gcv; /* Struct for creating GC */
114 unsigned int totalHeight; /* total Height used for text */
115 unsigned int displayHeight; /* height of display in pixels */
116 int maxWidth; /* max width of lines read in from file */
117 unsigned int displayWidth; /* width of display in pixels */
118 GC gc; /* GC to draw with */
120 static XrmOptionDescRec optTable[] = {
121 {"-font", "*vfont", XrmoptionSepArg, (XtPointer) NULL},
122 {"-fnt", "*vfont", XrmoptionSepArg, (XtPointer) NULL},
124 static int noptTable = sizeof(optTable)/sizeof(optTable[0]);
128 {"-bground", 8}, /* background color */
131 {"-fground", 8}, /* foreground color */
134 {"-string", 7}, /* string to display */
137 {"-fnt", 4}, /* font to use */
140 {"-timeout", 8}, /* timeout amount in seconds*/
143 {"-file", 5}, /* file */
148 char *ppchFileNames[MAX_FILES]; /* names of files to print */
149 unsigned char *ppchText[MAX_LINES]; /* text lines to print out */
150 int numFiles; /* number of files to print */
151 int numLines; /* number of text lines to print out */
152 #ifdef BLOCK_CENTER_FILES
153 int centerLines; /* number of text lines to print centered */
154 #endif /* BLOCK_CENTER_FILES */
155 char *progName; /* who we are */
156 char *fontArg; /* font argument */
158 char *stringArg; /* string argument */
160 char *bgArg; /* background argument */
162 char *fgArg; /* foreground argument */
164 char *xoffsetArg; /* text x_offset argument */
166 char *timeArg; /* timeout argument, in seconds */
169 Boolean Done; /* while painting text */
171 static VhResourceEntry restable[] = {
172 { vNbackground, vCBackground, &bgArg, &sizeBgArg },
173 { vNforeground, vCForeground, &fgArg, &sizeFgArg },
174 { vNfont, vCFont, &fontArg, &sizeFontArg },
175 { vNxoffset, vCXoffset, &xoffsetArg, &sizeXoffsetArg },
176 { vNstring, vCString, &stringArg, &sizeStringArg },
177 { vNfile, vCFile, &ppchFileNames[0], &sizeFileArg },
178 { vNtimeout, vCTimeout, &timeArg, &sizeTimeArg },
184 fprintf(stderr, (char *) GETMESSAGE (4, 4,
185 "usage: %s [-display <display>] [-bground <color>] [-fground <color>]\n"),
187 fprintf(stderr, (char *) GETMESSAGE (4, 5,
188 "\t[-font <font>] [-string <message>] [-timeout <seconds>] [-file <name>]\n"));
192 /*************************************<->*************************************
199 * This is the main routine that does almost all the work.
203 * argc = Std C argument count
204 * argv = Std C argument vector
212 * This works by creating an override-redirect window the size of
213 * the screen and painting a message on it. At the same time, a
214 * 1x1 window is created that will be picked up by the window
215 * manager. When the window manager reparents the little window,
216 * this program exits.
220 * dthello [-display <display>] [-fground <color>] [-bground <color>]
221 * [-font <fontname>] [-string <message>] [-file <filename>]
222 * [-timeout <seconds>]
224 *************************************<->***********************************/
225 main (int argc, char **argv)
227 Window wmwin; /* Window ID for wm */
228 XEvent event; /* Event received */
229 unsigned long mask; /* mask for window attribs */
230 XSetWindowAttributes xwa; /* Set Window Attribute struct */
231 int argn; /* temp for parsing args */
232 XColor colorDef; /* for parsing/allocating colors */
233 Colormap colormap; /* color map of screen */
234 Atom xaMwmHints; /* mwm hints atom */
235 PropMotifWmHints mwmHints; /* mwm hints structure */
236 Visual *pdv; /* X visual structure */
237 FILE *fp; /* file pointer */
238 int i; /* loop index */
239 char *default_string; /* default message */
240 XtAppContext appcontext;
241 int n; /* for Arglist processing */
245 char **missing_clist;
247 XFontSetExtents *extents;
249 XtSetLanguageProc( NULL, NULL, NULL );
255 * Set up NLSPATH, app-defaults, etc. for this DT client.
257 _DtEnvControl(DT_ENV_SET);
260 * Process command line arguments
263 /* fontArg = DEFAULT_FONT; */
266 timeArg = DEFAULT_TIME;
271 * Initialize Toolkit, open display
273 XtToolkitInitialize();
274 appcontext = XtCreateApplicationContext();
276 dpy = XtOpenDisplay (appcontext, NULL, argv[0], DTHELLO_CLASS_NAME,
277 optTable, noptTable, (int *)(&argc), argv);
281 setlocale(LC_ALL, "");
282 fprintf(stderr, (char *)
283 GETMESSAGE(4, 1, "%s: can't open display\n"), progName);
287 default_string = strdup (
288 ((char *)GETMESSAGE(2, 3,
289 "Starting the\nCommon Desktop Environment\n\n")));
291 stringArg = default_string;
294 * Find appropriate default font
295 * and offset from the left side of the screen
298 switch (_DtGetDisplayResolution(dpy, XDefaultScreen(dpy)))
300 case LOW_RES_DISPLAY:
301 fontArg = DEFAULT_FONT_SMALL;
302 x_offset = DEFAULT_XOFFSET_SMALL;
303 box_line_width = BOX_LINE_WIDTH_SMALL;
306 case MED_RES_DISPLAY:
307 fontArg = DEFAULT_FONT_MEDIUM;
308 x_offset = DEFAULT_XOFFSET_MEDIUM;
309 box_line_width = BOX_LINE_WIDTH_MEDIUM;
312 case HIGH_RES_DISPLAY:
313 fontArg = DEFAULT_FONT_LARGE;
314 x_offset = DEFAULT_XOFFSET_LARGE;
315 box_line_width = BOX_LINE_WIDTH_LARGE;
318 fontArg = DEFAULT_FONT_SMALL;
319 x_offset = DEFAULT_XOFFSET_SMALL;
320 box_line_width = BOX_LINE_WIDTH_SMALL;
327 VhGetResources (dpy, progName, DTHELLO_CLASS,
328 restable, XtNumber(restable));
330 /* assign the x_offset to the value set in the resource list if given by the user */
332 if( xoffsetArg != NULL)
333 x_offset = atoi(xoffsetArg);
336 x_offset = -x_offset;
339 if (sizeFileArg != 0)
345 * Parse remaining command line arguments
347 for (argn = 1; argn < argc; argn++)
349 if ((*argv[argn] == '-') &&
352 if (ArgMatch (argv[argn], BG_ARG))
354 bgArg = argv[++argn];
358 else if (ArgMatch (argv[argn], FG_ARG))
360 fgArg = argv[++argn];
364 else if (ArgMatch (argv[argn], STRING_ARG))
366 stringArg = argv[++argn];
370 else if (ArgMatch (argv[argn], FONT_ARG))
372 fontArg = argv[++argn];
376 else if (ArgMatch (argv[argn], TIME_ARG))
378 timeArg = argv[++argn];
379 if (atoi(timeArg) <= 0)
381 fprintf (stderr, (char *)
382 GETMESSAGE(4, 2, "%s: timeout must be positive\n"),
384 timeArg = DEFAULT_TIME;
389 else if (ArgMatch (argv[argn], FILE_ARG))
392 if (numFiles < MAX_FILES)
394 ppchFileNames[numFiles] = (char *) argv[argn];
399 fprintf(stderr, (char *) GETMESSAGE(4, 3,
400 "%1$s: Maxiumum of %2$d files allowed, skipping %3$s\n"),
401 argv[0], MAX_FILES, argv[argn]);
420 displayHeight = XDisplayHeight (dpy, XDefaultScreen(dpy));
421 displayWidth = XDisplayWidth (dpy, XDefaultScreen(dpy));
424 * Set default fg/bg colors if not specified.
425 * (adjust for low-color systems)
428 pdv = XDefaultVisual(dpy, XDefaultScreen(dpy));
431 * Set default colors if not specified on command line.
433 if ((XDefaultDepth(dpy, XDefaultScreen(dpy)) <= 4) ||
434 (pdv->class == StaticGray) ||
435 (pdv->class == GrayScale))
438 * B&W, GrayScale, or low-color systems
442 bgArg = DEFAULT_LOW_BG;
447 fgArg = DEFAULT_LOW_FG;
453 * Medium- to High-color systems
469 if ((fontset = XCreateFontSet(dpy, fontArg, &missing_clist, &missing_count,
472 fprintf(stderr, (char *)
473 GETMESSAGE (4, 6, "%1$s: display %2$s doesn't know font %3$s\n"),
474 argv[0], DisplayString(dpy), fontArg);
476 if ((fontset = XCreateFontSet(dpy, DEFAULT_FONT, &missing_clist,
477 &missing_count, &def_str)) == NULL)
479 fprintf(stderr, (char *)
480 GETMESSAGE (4, 6, "%1$s: display %2$s doesn't know font %3$s\n"),
481 argv[0], DisplayString(dpy), DEFAULT_FONT);
484 if ((NULL == fontset) &&
485 (fontset = XCreateFontSet(dpy, FIXED_FONT, &missing_clist,
486 &missing_count, &def_str)) == NULL)
488 fprintf(stderr, (char *)
489 GETMESSAGE (4, 6, "%1$s: display %2$s doesn't know font %3$s\n"),
490 argv[0], DisplayString(dpy), FIXED_FONT);
494 extents = XExtentsOfFontSet(fontset);
495 textHeight = extents->max_ink_extent.height;
498 * Print the copyright file by default if no other file
504 ppchFileNames[numFiles] = (char *) DEFAULT_FILE;
510 * Break the text string up into separate lines
511 * and place into message buffer.
513 SeparateTextLines ((unsigned char *)stringArg);
515 #ifdef BLOCK_CENTER_FILES
516 centerLines = numLines;
517 #endif /* BLOCK_CENTER_FILES */
519 for (i = 0; i < numFiles; i++)
522 if (!(fp = fopen ((char *)ppchFileNames[i], "r")))
524 fprintf (stderr, (char *)
525 GETMESSAGE (4, 7, "%1$s: unable to open file %2$s\n"),
526 argv[0], ppchFileNames[i]);
533 ReadInTextLines (fp, fontset, (unsigned int *)&maxWidth);
540 colormap = XDefaultColormap (dpy, XDefaultScreen(dpy));
543 * Get background color
545 if (!XParseColor (dpy, colormap, bgArg, &colorDef))
547 /* failed to get background color, try low color default */
548 colorSuccess = False;
549 fprintf(stderr, (char *) GETMESSAGE (4, 8,
550 "%1$s: can't set background to %2$s, using %3$s.\n"),
551 argv[0], bgArg, DEFAULT_LOW_BG);
552 XParseColor (dpy, colormap, DEFAULT_LOW_BG, &colorDef);
554 XAllocColor (dpy, colormap, &colorDef);
559 * Get foreground color
561 if (!XParseColor (dpy, colormap, fgArg, &colorDef))
563 /* failed to get foreground color, try low color default */
564 colorSuccess = False;
565 fprintf(stderr, (char *) GETMESSAGE (4, 9,
566 "%1$s: can't set foreground to %2$s, using %3$s.\n"),
567 argv[0], fgArg, DEFAULT_LOW_FG);
568 XParseColor (dpy, colormap, DEFAULT_LOW_FG, &colorDef);
570 XAllocColor (dpy, colormap, &colorDef);
575 * Create 1x1 window to catch reparenting action of window manager
576 * Request no mwm decoration to reduce flash.
577 * Request no mwm functions to avoid icon in icon box.
579 wmwin = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
580 0, 0, 1, 1, 0, bg, bg);
582 xaMwmHints = XInternAtom (dpy, _XA_MOTIF_WM_HINTS, 0);
584 mwmHints.flags = MWM_HINTS_DECORATIONS | MWM_HINTS_FUNCTIONS;
585 mwmHints.decorations = 0;
586 mwmHints.functions = 0;
588 XChangeProperty (dpy, wmwin, xaMwmHints, xaMwmHints, 32,
589 PropModeReplace, (unsigned char *) &mwmHints,
590 sizeof(PropMotifWmHints)/sizeof(long));
592 XSelectInput (dpy, wmwin, StructureNotifyMask);
594 XMapWindow(dpy, wmwin);
597 * Create override-redirect window for display of transition
601 welcome = XCreateSimpleWindow (dpy, DefaultRootWindow (dpy), 0, 0,
602 displayWidth, displayHeight, 0, bg, bg);
604 mask = CWOverrideRedirect | CWEventMask | CWCursor;
606 xwa.override_redirect = 1;
608 xwa.event_mask = ExposureMask | VisibilityChangeMask;
610 xwa.event_mask = ExposureMask;
611 #endif /* AUTO_TOP */
612 xwa.cursor = GetHourGlass (dpy);
614 XChangeWindowAttributes (dpy, welcome, mask, &xwa);
616 XMapWindow(dpy, welcome);
618 * Event loop for painting text
628 /* XNextEvent(dpy, &event); */
630 XtAppNextEvent(appcontext, &event);
632 if (event.type == Expose &&
633 event.xexpose.window == welcome &&
634 event.xexpose.count == 0)
638 * Remove any other pending Expose events from the queue
640 while (XCheckTypedEvent(dpy, Expose, &event));
643 * Create the GC for drawing the box and painting the text.
647 gc = XCreateGC(dpy, welcome, (GCForeground | GCBackground), &gcv);
648 XClearWindow(dpy, welcome);
659 signal (SIGALRM, (void (*)()) CatchAlarm);
660 alarm (atoi(timeArg));
670 /* XNextEvent(dpy, &event); */
672 XtAppNextEvent(appcontext, &event);
674 if (event.type == ReparentNotify &&
675 event.xany.window == wmwin)
678 * this is our cue...exit, stage left
685 /* normal color serving process */
686 XtDispatchEvent(&event);
695 /*************************************<->*************************************
697 * ArgMatch (pch, arn)
702 * This function determines if a string matches a predefined switch.
706 * pch = candidate string
707 * arn = number of switch we are trying to match.
711 * Return = True if match succeeds.
715 * Would need work to be localized.
717 *************************************<->***********************************/
719 ArgMatch (char *pch, int arn)
723 if (!strncmp(pch, argSpecs[arn].name, argSpecs[arn].len))
732 /*************************************<->*************************************
734 * SkipWhitespace (*pch)
739 * This procedure scans a string and returns a pointer to the first
740 * non-whitespace character.
744 * pch = pointer to string to scan
748 * Return = pointer to first non-white character
752 * Skips blanks and horizontal tabs.
754 *************************************<->***********************************/
756 SkipWhitespace (unsigned char *pch)
762 while ((*pch != NULL) &&
763 ((chlen = mblen ((char *)pch, MB_CUR_MAX)) == 1) &&
764 ((*pch == '\t') || (*pch == ' ')))
774 /*************************************<->*************************************
776 * KillNewlines (*pch)
781 * This procedure scans a string and replaces the first newline
786 * pch = pointer to string to scan
795 *************************************<->***********************************/
797 KillNewlines (unsigned char *pch)
805 if (((chlen = mblen ((char *)pch, MB_CUR_MAX)) == 1) &&
817 /*************************************<->*************************************
819 * ReadInTextLines (fp, font, pMaxWidth)
824 * This procedure reads in lines from a file for the message to
829 * pchIn = pointer to message string
830 * font = font structure to be used to print with
831 * pMaxWidth = width of largest line
836 * modifies global numLines
840 * Global data ppchText is modified by this routine to contain
841 * copies of the text lines from pchIn. pchIn is not modified.
843 *************************************<->***********************************/
845 ReadInTextLines (FILE *fp, XFontSet fontset, unsigned int *pMaxWidth)
850 /* count the number of lines in the file */
851 allowedLines = (displayHeight - (2 * box_line_width))/ textHeight;
853 while (numLines < allowedLines)
855 ppchText[numLines] = (unsigned char *) malloc (1+MAX_COLUMNS);
856 if (!ppchText[numLines] ||
857 !fgets ((char *)ppchText[numLines], MAX_COLUMNS, fp))
861 KillNewlines (ppchText[numLines]);
862 #ifndef BLOCK_CENTER_FILES
863 ppchText[numLines] = SkipWhitespace (ppchText[numLines]);
864 #endif /* not BLOCK_CENTER_FILES */
865 width = XmbTextEscapement(fontset, (char *)(ppchText[numLines]),
866 strlen((char *)ppchText[numLines]));
867 if (width > *pMaxWidth)
876 /*************************************<->*************************************
878 * SeparateTextLines (pchIn)
883 * This procedure takes a message string and separates it into
884 * text lines based on the presence of new line characters.
888 * pchIn = pointer to message string
896 * Global data ppchText is modified by this routine to contain
897 * copies of the text lines from pchIn. pchIn is not modified.
899 *************************************<->***********************************/
901 SeparateTextLines (unsigned char *pchIn)
903 unsigned char *pch, *pch1, *pch2;
904 unsigned char *pchInEnd;
907 /* count the number of new line characters in the string */
910 for (pch = pchIn; *pch; )
912 if (((chlen = mblen ((char *)pch, MB_CUR_MAX)) == 1) &&
920 if ((chlen == 1) && (*(pch-1) == '\n'))
922 numLines--; /* don't count terminating newline */
926 pchInEnd = pchIn + strlen((char *)pchIn);
928 for (i = 0; (i < numLines) && (pch1 < pchInEnd); i++)
930 while ((*pch2 != NULL) &&
931 !(((chlen = mblen ((char *)pch2, MB_CUR_MAX)) == 1) &&
941 ppchText[i] = (unsigned char *) malloc (1+strlen ((char *)pch1));
944 strcpy ((char *)ppchText[i], (char *)pch1);
948 fprintf (stderr, (char *) GETMESSAGE (4, 10,
949 "%s: Insufficient memory (SeparateTextLines)\n"),
954 /* advance pointers */
962 /*************************************<->*************************************
969 * This function catches the SIG_ALRM signal generated when the
974 * sig = signal number
983 *************************************<->***********************************/
985 CatchAlarm ( int sig)
987 /* timer expired, exit */
992 /*************************************<->*************************************
994 * Cursor GetHourGlass ()
999 * Builds and returns the appropriate Hourglass cursor
1012 * None. (None doesn't count as a comment)
1014 *************************************<->***********************************/
1016 #define time32_width 32
1017 #define time32_height 32
1018 #define time32_x_hot 15
1019 #define time32_y_hot 15
1020 static unsigned char time32_bits[] = {
1021 0x00, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0x7f,
1022 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
1023 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32, 0x4c, 0x00, 0x00, 0x32,
1024 0x8c, 0x00, 0x00, 0x31, 0x0c, 0x7f, 0xfe, 0x30, 0x0c, 0xfe, 0x7f, 0x30,
1025 0x0c, 0xfc, 0x3f, 0x30, 0x0c, 0xf8, 0x1f, 0x30, 0x0c, 0xe0, 0x07, 0x30,
1026 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x80, 0x01, 0x30, 0x0c, 0x60, 0x06, 0x30,
1027 0x0c, 0x18, 0x18, 0x30, 0x0c, 0x04, 0x20, 0x30, 0x0c, 0x02, 0x40, 0x30,
1028 0x0c, 0x01, 0x80, 0x30, 0x8c, 0x00, 0x00, 0x31, 0x4c, 0x80, 0x01, 0x32,
1029 0x4c, 0xc0, 0x03, 0x32, 0x4c, 0xf0, 0x1f, 0x32, 0x4c, 0xff, 0xff, 0x32,
1030 0xcc, 0xff, 0xff, 0x33, 0x8c, 0xff, 0xff, 0x31, 0xfe, 0xff, 0xff, 0x7f,
1031 0xfe, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00};
1033 #define time32m_width 32
1034 #define time32m_height 32
1035 static unsigned char time32m_bits[] = {
1036 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1037 0xcf, 0x00, 0x00, 0xf3, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
1038 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76, 0x6e, 0x00, 0x00, 0x76,
1039 0xce, 0x00, 0x00, 0x73, 0x8e, 0x7f, 0xfe, 0x71, 0x0e, 0xff, 0xff, 0x70,
1040 0x0e, 0xfe, 0x7f, 0x70, 0x0e, 0xfc, 0x3f, 0x70, 0x0e, 0xf8, 0x1f, 0x70,
1041 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0xe0, 0x07, 0x70, 0x0e, 0x78, 0x1e, 0x70,
1042 0x0e, 0x1c, 0x38, 0x70, 0x0e, 0x06, 0x60, 0x70, 0x0e, 0x03, 0xc0, 0x70,
1043 0x8e, 0x01, 0x80, 0x71, 0xce, 0x00, 0x00, 0x73, 0x6e, 0x80, 0x01, 0x76,
1044 0x6e, 0xc0, 0x03, 0x76, 0x6e, 0xf0, 0x1f, 0x76, 0x6e, 0xff, 0xff, 0x76,
1045 0xee, 0xff, 0xff, 0x77, 0xcf, 0xff, 0xff, 0xf3, 0xff, 0xff, 0xff, 0xff,
1046 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
1049 #define time16_x_hot 7
1050 #define time16_y_hot 7
1051 #define time16_width 16
1052 #define time16_height 16
1053 static unsigned char time16_bits[] = {
1054 0x00, 0x00, 0xfe, 0x7f, 0x14, 0x28, 0x14, 0x28, 0x14, 0x28, 0x24, 0x24,
1055 0x44, 0x22, 0x84, 0x21, 0x84, 0x21, 0x44, 0x22, 0x24, 0x24, 0x14, 0x28,
1056 0x94, 0x29, 0xd4, 0x2b, 0xfe, 0x7f, 0x00, 0x00};
1058 #define time16m_width 16
1059 #define time16m_height 16
1060 static unsigned char time16m_bits[] = {
1061 0xff, 0xff, 0xff, 0xff, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
1062 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f, 0xfe, 0x7f,
1063 0xfe, 0x7f, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff};
1066 Cursor GetHourGlass (Display *dpy)
1068 unsigned char *bits;
1069 unsigned char *maskBits;
1071 unsigned int height;
1072 unsigned int xHotspot;
1073 unsigned int yHotspot;
1078 unsigned int cWidth;
1079 unsigned int cHeight;
1080 int useLargeCursors = 0;
1083 if (XQueryBestCursor (dpy, DefaultRootWindow(dpy),
1084 32, 32, &cWidth, &cHeight))
1086 if ((cWidth >= 32) && (cHeight >= 32))
1088 useLargeCursors = 1;
1092 if (useLargeCursors)
1094 width = time32_width;
1095 height = time32_height;
1097 maskBits = time32m_bits;
1098 xHotspot = time32_x_hot;
1099 yHotspot = time32_y_hot;
1103 width = time16_width;
1104 height = time16_height;
1106 maskBits = time16m_bits;
1107 xHotspot = time16_x_hot;
1108 yHotspot = time16_y_hot;
1111 pixmap = XCreateBitmapFromData (dpy,
1112 DefaultRootWindow(dpy), (char *)bits,
1115 maskPixmap = XCreateBitmapFromData (dpy,
1116 DefaultRootWindow(dpy), (char *)maskBits,
1119 xcolors[0].pixel = BlackPixelOfScreen(DefaultScreenOfDisplay(dpy));
1120 xcolors[1].pixel = WhitePixelOfScreen(DefaultScreenOfDisplay(dpy));
1123 DefaultColormapOfScreen(DefaultScreenOfDisplay
1124 (dpy)), xcolors, 2);
1126 waitCursor = XCreatePixmapCursor (dpy, pixmap, maskPixmap,
1127 &(xcolors[0]), &(xcolors[1]),
1128 xHotspot, yHotspot);
1129 XFreePixmap (dpy, pixmap);
1130 XFreePixmap (dpy, maskPixmap);
1132 return (waitCursor);
1135 #ifndef NO_MESSAGE_CATALOG
1136 /*****************************************************************************
1138 * Function: GetMessage
1142 * int set - The message catalog set number.
1144 * int n - The message number.
1146 * char *s - The default message if the message is not
1147 * retrieved from a message catalog.
1149 * Returns: the string for set 'set' and number 'n'.
1151 *****************************************************************************/
1163 static int first = 1;
1164 static nl_catd nlmsg_fd;
1169 lang = (char *) getenv ("LANG");
1171 if (!lang || !(strcmp (lang, "C")))
1173 * If LANG is not set or if LANG=C, then there
1174 * is no need to open the message catalog - just
1175 * return the built-in string "s".
1177 nlmsg_fd = (nl_catd)-1;
1179 nlmsg_fd = catopen("dthello", NL_CAT_LOCALE);
1181 msg=catgets(nlmsg_fd,set,n,s);
1187 /*************************************<->*************************************
1189 * void VhGetResources
1194 * Gets the resources for the client
1206 *************************************<->***********************************/
1209 VhGetResources(Display *dpy, char *name, char *class,
1210 VhResourceEntry *res, int num)
1212 #define INIT_SIZE 256
1213 #define SRCH_SIZE 20
1216 XrmQuark Qtype, Qstring, Qname, Qclass;
1217 XrmQuark Qnres[4], Qcres[4];
1218 XrmHashTable searchList[SRCH_SIZE];
1221 * We only deal with string-type resources
1224 Qstring = XrmStringToQuark (XtRString);
1227 * Get resource search list for "dthello"
1229 XrmStringToQuarkList (name, Qnres);
1230 XrmStringToQuarkList (class, Qcres);
1232 if (XrmQGetSearchList(XtDatabase(dpy), Qnres, Qcres, searchList,
1236 * Look for all resources at this level
1239 for (i = 0; i < num; i++)
1241 Qname = XrmStringToQuark (res[i].resname);
1242 Qclass = XrmStringToQuark (res[i].resclass);
1244 if ((XrmQGetSearchResource (searchList, Qname, Qclass,
1248 *(res[i].ppvalue) = (char *) xrmv.addr;
1249 *res[i].size = (int) xrmv.size;
1259 XFontSetExtents *extents;
1262 * Paint the string onto the screen
1266 y = (displayHeight - totalHeight) / 2;
1272 /* adjust origin by font metric */
1273 extents = XExtentsOfFontSet(fontset);
1274 y += -(extents->max_logical_extent.y);
1276 x = box_line_width + x_offset;
1278 for (i = 0; i < numLines; i++)
1280 /* draw the string */
1281 XmbDrawString (dpy, welcome, fontset, gc, x, y,
1282 (char *)(ppchText[i]), strlen((char *)ppchText[i]));
1284 /* move to next "line" */
1291 int LTX, LTY, RTX, RTY, LBX, LBY, RBX, RBY;
1292 int L_middle; /* pixels to the midpoint of the line width */
1294 Boolean useDecoration = True;
1296 /* compute the height of the font */
1297 totalHeight = textHeight * numLines;
1302 if ((( 2 * box_line_width ) + x_offset + maxWidth) > displayWidth)
1304 useDecoration = False;
1311 L_middle = box_line_width / 2;
1312 /********************************************************
1313 +----------------------------------------------+
1314 | (LTX, LTY) (RTX, RTY) |
1316 | (Draw counterclockwise, beginning from |
1324 | (LBX, LBY) (RBX, RBY) |
1325 +----------------------------------------------+
1326 ********************************************************/
1334 LBY = displayHeight;
1336 RBX = displayWidth ;
1337 RBY = displayHeight;
1339 XSetLineAttributes(dpy, gc, box_line_width, LineSolid, CapButt, JoinMiter);
1340 XDrawLine(dpy, welcome, gc,
1341 LTX, LTY + L_middle,
1342 RTX, RTY + L_middle);
1344 XDrawLine(dpy, welcome, gc,
1345 RTX - L_middle, RTY,
1346 RBX - L_middle, RBY);
1348 XDrawLine(dpy, welcome, gc,
1349 RBX, RBY - L_middle,
1350 LBX, LBY - L_middle);
1352 XDrawLine(dpy, welcome, gc,
1353 LBX + L_middle, LBY,
1354 LTX + L_middle, LTY);
1359 Xestrcmp(const char * const s1, const char * const s2)
1361 if (s1 == s2) return 0;
1363 const char * p1 = (s1) ? s1 : "";
1364 const char * p2 = (s2) ? s2 : "";
1366 return strcmp((char *)p1, (char *)p2);
1370 /************** eof ******************/