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
23 /* $TOG: vgutil.c /main/11 1998/11/03 19:17:12 mgreess $ */
25 * (c) Copyright 1993, 1994 Hewlett-Packard Company *
26 * (c) Copyright 1993, 1994 International Business Machines Corp. *
27 * (c) Copyright 1993, 1994 Sun Microsystems, Inc. *
28 * (c) Copyright 1993, 1994 Novell, Inc. *
30 /************************************<+>*************************************
31 ****************************************************************************
35 ** Project: HP Visual User Environment (DT)
37 ** Description: Utility file for Dtgreet application.
39 ** This file contains global data declarations, resource
40 ** declarations, and various utility routines.
43 ** (c) Copyright 1987, 1988, 1989 by Hewlett-Packard Company
47 ****************************************************************************
48 ************************************<+>*************************************/
51 /***************************************************************************
55 ***************************************************************************/
61 #include <sys/signal.h>
63 #define Va_start(a,b) va_start(a,b)
65 #include <X11/Xlibint.h>
71 /****************************************************************************
75 ****************************************************************************/
76 #define NLSPATH_ENV "NLSPATH=" \
77 CDE_INSTALLATION_TOP "/nls/msg/%L/%N.cat:" \
78 CDE_INSTALLATION_TOP "/lib/nls/msg/%L/%N.cat:" \
79 CDE_INSTALLATION_TOP "/lib/nls/msg/%l/%t/%c/%N.cat:" \
80 CDE_INSTALLATION_TOP "/lib/nls/msg/%l/%c/%N.cat"
82 #define NLS_CATALOG "dtlogin"
84 /***************************************************************************
86 * Procedure declarations
88 ***************************************************************************/
89 static SIGVAL syncTimeout( int arg ) ;
91 /***************************************************************************
95 ***************************************************************************/
96 static nl_catd nl_fd; /* message catalog file descriptor */
98 /***************************************************************************
102 * turn the keyboard bell on/off
105 ***************************************************************************/
108 ChangeBell( char *string )
110 static int percent = -1;
112 XKeyboardControl control;
113 XKeyboardState state;
115 if ( strcmp (string, "on" ) == 0 )
116 control.bell_percent = percent;
118 if ( strcmp (string, "off") == 0 ) {
119 XGetKeyboardControl(dpyinfo.dpy, &state);
120 percent = state.bell_percent;
121 control.bell_percent = 0;
125 XChangeKeyboardControl(dpyinfo.dpy, KBBellPercent, &control);
131 /***************************************************************************
135 * Initialize the wiget argument list before creating the widget. These
136 * are resources the user cannot override.
138 * The values chosen for these resources are not necessarily the Motif
139 * defaults, but rather those that are most common for all the widgets. A
140 * particular widget may override any of these choices before creation.
141 ***************************************************************************/
143 static XmTextScanType sarray[] = {XmSELECT_POSITION};
146 InitArg( WidgetType wtype )
154 * Core resource set...
157 /* bug workaround in toolkit */
158 if (wtype == DrawingA ||
161 wtype == MessageBox ||
165 XtSetArg(argt[i], XmNaccelerators, NULL ); i++;
169 if (wtype == DrawingA ||
173 wtype == MessageBox ||
177 XtSetArg(argt[i], XmNancestorSensitive, True ); i++;
178 /* XmNbackground, (set by user) */
179 /* XmNbackgroundPixmap, (set by user) */
180 /* XmNborderColor, (set by user) */
181 /* XmNborderPixmap, (set by user) */
182 XtSetArg(argt[i], XmNborderWidth, 0 ); i++;
183 /* XmNcolormap, (default) */
184 /* XmNdepth, (set by Xt) */
185 XtSetArg(argt[i], XmNdestroyCallback, NULL ); i++;
186 /* XmNheight, (set by user) */
187 XtSetArg(argt[i], XmNmappedWhenManaged, True ); i++;
188 /* XmNscreen, (default) */
189 XtSetArg(argt[i], XmNsensitive, True ); i++;
190 /* XmNtranslations, (default) */
191 /* XmNwidth, (set by user) */
192 /* XmNx, (set by user) */
193 /* XmNy, (set by user) */
199 * Object resource set...
202 if (wtype == CascadeBG ||
205 wtype == SeparatorG ||
206 wtype == ToggleBG ) {
208 XtSetArg(argt[i], XmNdestroyCallback, NULL ); i++;
214 * RectObj resource set...
217 if (wtype == CascadeBG ||
220 wtype == SeparatorG ||
221 wtype == ToggleBG ) {
223 XtSetArg(argt[i], XmNancestorSensitive, True ); i++;
224 XtSetArg(argt[i], XmNborderWidth, 0 ); i++;
225 /* XmNheight, (set by user) */
226 XtSetArg(argt[i], XmNsensitive, True ); i++;
227 /* XmNwidth, (set by user) */
228 /* XmNx, (set by user) */
229 /* XmNy, (set by user) */
235 * XmGadget resource set...
238 if (wtype == CascadeBG ||
241 wtype == SeparatorG ||
242 wtype == ToggleBG ) {
244 XtSetArg(argt[i], XmNhelpCallback, NULL ); i++;
245 XtSetArg(argt[i], XmNhighlightOnEnter, True ); i++;
246 /* XmNhighlightThickness,(set by user) */
247 /* XmNshadowThickness, (set by user) */
248 XtSetArg(argt[i], XmNtraversalOn, True ); i++;
249 XtSetArg(argt[i], XmNunitType, appInfo.unitType ); i++;
250 XtSetArg(argt[i], XmNuserData, NULL ); i++;
257 * Composite resource set...
260 if (wtype == DrawingA ||
263 wtype == MessageBox ) {
265 XtSetArg(argt[i], XmNinsertPosition, NULL ); i++;
271 * XmPrimitive resource set...
274 if (wtype == Label ||
278 /* XmNbottomShadowColor, (set by user) */
279 /* XmNbottomShadowPixmap,(set by user) */
280 /* XmNforeground, (set by user) */
281 XtSetArg(argt[i], XmNhelpCallback, NULL ); i++;
282 /* XmNhighlightColor, (set by user) */
283 XtSetArg(argt[i], XmNhighlightOnEnter, False ); i++;
284 /* XmNhighlightPixmap, (set by user) */
285 /* XmNhighlightThickness,(set by user) */
286 /* XmNshadowThickness, (set by user) */
287 /* XmNtopShadowColor, (set by user) */
288 /* XmNtopShadowPixmap, (set by user) */
289 XtSetArg(argt[i], XmNtraversalOn, True ); i++;
290 XtSetArg(argt[i], XmNunitType, appInfo.unitType ); i++;
291 XtSetArg(argt[i], XmNuserData, NULL ); i++;
297 * XmForm Constraint resource set...
302 XtSetArg(argt[i], XmNbottomAttachment, XmATTACH_NONE ); i++;
303 XtSetArg(argt[i], XmNleftAttachment, XmATTACH_NONE ); i++;
304 XtSetArg(argt[i], XmNresizable, False ); i++;
305 XtSetArg(argt[i], XmNrightAttachment, XmATTACH_NONE ); i++;
306 XtSetArg(argt[i], XmNtopAttachment, XmATTACH_NONE ); i++;
311 * XmManager resource set...
314 if (wtype == DrawingA ||
317 wtype == MessageBox ) {
319 /* XmNbottomShadowColor, (set by user) */
320 /* XmNbottomShadowPixmap,(set by user) */
321 /* XmNforeground, (set by user) */
322 XtSetArg(argt[i], XmNhelpCallback, NULL ); i++;
323 /* XmNhighlightColor, (set by user) */
324 /* XmNhighlightPixmap, (set by user) */
325 /* XmNshadowThickness, (set by user) */
326 /* XmNtopShadowColor, (set by user) */
327 /* XmNtopShadowPixmap, (set by user) */
328 XtSetArg(argt[i], XmNunitType, appInfo.unitType ); i++;
329 XtSetArg(argt[i], XmNuserData, NULL ); i++;
335 * XmBulletinBoard resource set...
339 wtype == MessageBox ) {
341 XtSetArg(argt[i], XmNallowOverlap, True ); i++;
342 XtSetArg(argt[i], XmNautoUnmanage, True ); i++;
343 XtSetArg(argt[i], XmNbuttonFontList, appInfo.labelFont ); i++;
344 /* XmNcancelButton, (set by Xm) */
345 /* XmNdefaultButton, (set by Xm) */
346 XtSetArg(argt[i], XmNdefaultPosition, True ); i++;
347 XtSetArg(argt[i], XmNdialogStyle, XmDIALOG_MODELESS ); i++;
348 XtSetArg(argt[i], XmNdialogTitle, NULL ); i++;
349 XtSetArg(argt[i], XmNfocusCallback, NULL ); i++;
350 /*XtSetArg(argt[i], XmNlabelFontList, appInfo.textFont ); i++; */
351 XtSetArg(argt[i], XmNmapCallback, NULL ); i++;
352 XtSetArg(argt[i], XmNmarginHeight, FromMM(10) ); i++;
353 XtSetArg(argt[i], XmNmarginWidth, FromMM(10) ); i++;
354 XtSetArg(argt[i], XmNmapCallback, NULL ); i++;
355 XtSetArg(argt[i], XmNnoResize, True ); i++;
356 XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_ANY ); i++;
357 XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT ); i++;
358 XtSetArg(argt[i], XmNstringDirection, XmSTRING_DIRECTION_L_TO_R );i++;
359 XtSetArg(argt[i], XmNtextFontList, appInfo.textFont ); i++;
360 XtSetArg(argt[i], XmNtextTranslations, NULL ); i++;
361 XtSetArg(argt[i], XmNunmapCallback, NULL ); i++;
367 * XmCascadeButtonGadget resource set...
370 if (wtype == CascadeBG) {
372 XtSetArg(argt[i], XmNactivateCallback, NULL ); i++;
373 XtSetArg(argt[i], XmNcascadePixmap, XmUNSPECIFIED_PIXMAP ); i++;
374 XtSetArg(argt[i], XmNcascadingCallback, NULL ); i++;
375 XtSetArg(argt[i], XmNmappingDelay, 100 ); i++;
376 XtSetArg(argt[i], XmNsubMenuId, 0 ); i++;
382 * XmDrawingArea resource set...
385 if (wtype == DrawingA) {
387 XtSetArg(argt[i], XmNexposeCallback, NULL ); i++;
388 XtSetArg(argt[i], XmNinputCallback, NULL ); i++;
389 XtSetArg(argt[i], XmNmarginHeight, 0 ); i++;
390 XtSetArg(argt[i], XmNmarginWidth, 0 ); i++;
391 XtSetArg(argt[i], XmNresizeCallback, NULL ); i++;
392 XtSetArg(argt[i], XmNresizePolicy, XmRESIZE_NONE ); i++;
398 * XmForm resource set...
403 XtSetArg(argt[i], XmNfractionBase, 100 ); i++;
404 XtSetArg(argt[i], XmNhorizontalSpacing, 0 ); i++;
405 XtSetArg(argt[i], XmNrubberPositioning, False ); i++;
406 XtSetArg(argt[i], XmNverticalSpacing, 0 ); i++;
412 * XmFrame resource set...
415 if (wtype == Frame) {
417 XtSetArg(argt[i], XmNmarginHeight, 0 ); i++;
418 XtSetArg(argt[i], XmNmarginWidth, 0 ); i++;
419 XtSetArg(argt[i], XmNshadowType, XmSHADOW_OUT ); i++;
425 * XmLabel/XmLabelGadget resource set...
428 if (wtype == CascadeBG ||
433 wtype == ToggleBG ) {
435 XtSetArg(argt[i], XmNaccelerator, NULL ); i++;
436 XtSetArg(argt[i], XmNacceleratorText, NULL ); i++;
437 /* XtSetArg(argt[i], XmNalignment, XmALIGNMENT_CENTER ); i++;*/
438 /* XmNalignment, (default) */
439 XtSetArg(argt[i], XmNfontList, appInfo.labelFont ); i++;
440 XtSetArg(argt[i], XmNlabelInsensitivePixmap,
441 XmUNSPECIFIED_PIXMAP ); i++;
442 XtSetArg(argt[i], XmNlabelPixmap, XmUNSPECIFIED_PIXMAP ); i++;
443 XtSetArg(argt[i], XmNlabelString, NULL ); i++;
444 XtSetArg(argt[i], XmNlabelType, XmSTRING ); i++;
445 /* XmNmarginBottom, (default) */
446 /* XmNmarginHeight, (default) */
447 /* XmNmarginLeft, (default) */
448 /* XmNmarginRight, (default) */
449 /* XmNmarginTop, (default) */
450 /* XmNmarginWidth, (default) */
451 XtSetArg(argt[i], XmNmnemonic, NULL ); i++;
452 XtSetArg(argt[i], XmNrecomputeSize, False ); i++;
453 XtSetArg(argt[i], XmNuserData, NULL ); i++;
454 XtSetArg(argt[i], XmNstringDirection, XmSTRING_DIRECTION_L_TO_R ); i++;
460 * XmMessageBox resource set...
463 if (wtype == MessageBox) {
465 XtSetArg(argt[i], XmNcancelCallback, NULL ); i++;
466 XtSetArg(argt[i], XmNcancelLabelString, NULL ); i++;
467 XtSetArg(argt[i], XmNdefaultButtonType, XmDIALOG_OK_BUTTON ); i++;
468 XtSetArg(argt[i], XmNdialogType, XmDIALOG_MESSAGE ); i++;
469 XtSetArg(argt[i], XmNhelpLabelString, NULL ); i++;
470 XtSetArg(argt[i], XmNmessageAlignment, XmALIGNMENT_BEGINNING ); i++;
471 XtSetArg(argt[i], XmNmessageString, NULL ); i++;
472 XtSetArg(argt[i], XmNminimizeButtons, FALSE ); i++;
473 XtSetArg(argt[i], XmNokCallback, NULL ); i++;
474 XtSetArg(argt[i], XmNokLabelString, NULL ); i++;
475 /* XmNsymbolPixmap, (set by Xm) */
481 * XmPushButton/XmPushButtonGadget resource set...
484 if (wtype == PushB ||
487 XtSetArg(argt[i], XmNactivateCallback, NULL ); i++;
488 XtSetArg(argt[i], XmNarmCallback, NULL ); i++;
489 /* XmNarmColor, (set by user) */
490 /* XmNarmPixmap, (set by user) */
491 XtSetArg(argt[i], XmNdisarmCallback, NULL ); i++;
492 XtSetArg(argt[i], XmNfillOnArm, True ); i++;
493 XtSetArg(argt[i], XmNshowAsDefault, 0 ); i++;
499 * XmSeparatorGadget resource set...
502 if (wtype == SeparatorG) {
504 XtSetArg(argt[i], XmNmargin, 0 ); i++;
505 XtSetArg(argt[i], XmNorientation, XmHORIZONTAL ); i++;
506 XtSetArg(argt[i], XmNseparatorType, XmSHADOW_ETCHED_IN ); i++;
512 * XmText resource set...
515 if (wtype == Text ) {
517 XtSetArg(argt[i], XmNactivateCallback, NULL ); i++;
518 XtSetArg(argt[i], XmNautoShowCursorPosition, True ); i++;
519 XtSetArg(argt[i], XmNcursorPosition, 0 ); i++;
520 XtSetArg(argt[i], XmNeditable, True ); i++;
521 XtSetArg(argt[i], XmNeditMode, XmSINGLE_LINE_EDIT ); i++;
522 XtSetArg(argt[i], XmNfocusCallback, NULL ); i++;
523 XtSetArg(argt[i], XmNlosingFocusCallback, NULL ); i++;
524 XtSetArg(argt[i], XmNmarginHeight, TEXT_MARGIN_HEIGHT ); i++;
525 XtSetArg(argt[i], XmNmarginWidth, TEXT_MARGIN_WIDTH ); i++;
526 XtSetArg(argt[i], XmNmaxLength, 20 ); i++;
527 XtSetArg(argt[i], XmNmodifyVerifyCallback, NULL ); i++;
528 XtSetArg(argt[i], XmNmotionVerifyCallback, NULL ); i++;
529 /* XmNtopPosition, (default) */
530 /* XmNvalue, (set by ??) */
532 /* XmText Input Resource Set */
533 XtSetArg(argt[i], XmNpendingDelete, True ); i++;
534 XtSetArg(argt[i], XmNselectionArray, sarray ); i++;
535 XtSetArg(argt[i], XmNselectThreshold, 1000 ); i++;
537 /* XmText Output Resource Set */
538 /* XmNblinkRate, (set by user) */
539 XtSetArg(argt[i], XmNfontList, appInfo.labelFont ); i++;
540 XtSetArg(argt[i], XmNcursorPositionVisible, True ); i++;
541 XtSetArg(argt[i], XmNresizeHeight, False ); i++;
542 XtSetArg(argt[i], XmNresizeWidth, False ); i++;
543 /* XmNrows, (ignored) */
544 /* XmNwordWrap, (ignored) */
550 * XmToggleButtonGadget resource set...
553 if (wtype == ToggleBG) {
555 XtSetArg(argt[i], XmNarmCallback, NULL ); i++;
556 XtSetArg(argt[i], XmNdisarmCallback, NULL ); i++;
557 XtSetArg(argt[i], XmNfillOnSelect, True ); i++;
558 XtSetArg(argt[i], XmNindicatorOn, True ); i++;
559 XtSetArg(argt[i], XmNindicatorType, XmONE_OF_MANY ); i++;
560 /* XmNselectColor, (set by user) */
561 XtSetArg(argt[i], XmNselectInsensitivePixmap,
562 XmUNSPECIFIED_PIXMAP ); i++;
563 XtSetArg(argt[i], XmNselectPixmap, XmUNSPECIFIED_PIXMAP ); i++;
564 XtSetArg(argt[i], XmNset, False ); i++;
565 /* XmNspacing, (default) */
566 XtSetArg(argt[i], XmNvalueChangedCallback,
568 XtSetArg(argt[i], XmNvisibleWhenOff, False ); i++;
578 /***************************************************************************
582 * Convert from 100th Millimeter units into the widget's units.
584 * This routine does NOT use the Motif Resolution Independence mechanism.
585 * Unless the user informs the X-server as to the current monitor size (or
586 * the monitor happens to be the default), it is possible that the
587 * millimeter screen size returned by the X-server is incorrect. This
588 * causes the Motif Resolution Independence mechanism to generate incorrect
589 * values and skew the visuals.
591 * For ease of specification, all sizes internal to Dtgreet are specified
592 * in a generic unit (approx. 100th Millimeters) and then converted to an
593 * equivalent pixel value by this routine. All Dtgreet widgets default
594 * to pixel unit type. Displays of the same resolution will contain
595 * identical pixel values, but the actual size on the screen may vary
596 * depending on the monitor size.
598 * There are three conversion values, one each for LowRes (640x480), MedRes
599 * (1024x768), and HiRes (1280x1024) displays. They are calculated to
600 * produce the same pixel values as does the Motif R.I. mechanism on the
601 * HP 13" Low Res. display, 16" Med. Res. display and 19" Hi Res. display,
602 * all pleasing visuals.
604 * If the user specifies the widgets unit type to be 100TH_MILLIMETERS, the
605 * Motif Resolution Independence mechanism is reactivated and can be used by
606 * the user. The internal sizes specified will not be converted by this
607 * routine but rather internally by Motif.
609 ***************************************************************************/
616 if ( appInfo.unitType == Xm100TH_MILLIMETERS )
621 * convert 100thMillimeters to Pixels. Do not round up to the next
626 pixel = (mm * 0.035854); /* HiRes */
629 pixel = (mm * 0.033574); /* MedRes */
632 pixel = (mm * 0.026016); /* LowRes */
641 /***************************************************************************
645 * Convert from pixel units into the widget's units
646 ***************************************************************************/
649 FromPixel( Widget w, int orientation, int pixel )
652 unsigned char unit_type;
654 XtSetArg(argt[0], XmNunitType, &unit_type);
655 XtGetValues(w, argt, 1);
657 if (unit_type == XmPIXELS)
660 return(XmConvertUnits(w,
670 /***************************************************************************
674 * Utility function to help determine largest of a set of widgets.
675 ***************************************************************************/
679 GetBiggest( Widget widget, Dimension *width, Dimension *height )
681 Dimension new_width, new_height;
683 XtSetArg(argt[0], XmNwidth, &new_width);
684 XtSetArg(argt[1], XmNheight, &new_height);
686 XtGetValues(widget, argt, 2);
688 if (width != NULL && new_width > *width)
690 if (height != NULL && new_height > *height)
691 *height = new_height;
697 /***************************************************************************
701 * send errors to the error log. This routine accepts a variable number
703 ***************************************************************************/
706 LogError( unsigned char *fmt, ...)
713 if (errorLogFile && errorLogFile[0] &&
714 (freopen(errorLogFile, "a", stderr) != NULL)) {
717 fprintf(stderr, "\n%s", ctime(&timer));
718 fprintf (stderr, "error (pid %ld): ", (long)getpid());
720 vfprintf (stderr, (char *)fmt, args);
728 /***************************************************************************
732 ***************************************************************************/
740 /***************************************************************************
744 ***************************************************************************/
749 static int initialized = 0;
750 char *nlspath, *newnlspath;
752 if (initialized) return;
755 nlspath = getenv("NLSPATH");
757 if (NULL == nlspath || 0 == strlen(nlspath))
759 newnlspath = malloc(8 + strlen(NLSPATH_ENV) + 1);
760 sprintf(newnlspath, "NLSPATH=%s", NLSPATH_ENV);
764 newnlspath = malloc(8 + strlen(nlspath) + 1 + strlen(NLSPATH_ENV) + 1);
765 sprintf(newnlspath, "NLSPATH=%s:%s", nlspath, NLSPATH_ENV);
771 * open the message catalog. If the language_specific version cannot
772 * be opened, try the default...
776 nl_fd = catopen(NLS_CATALOG, NL_CAT_LOCALE);
778 LogError((unsigned char*) MC_DEF_LOG_NO_MSGCAT, langenv);
783 /***************************************************************************
787 * read a string from the message catalog and convert to unsigned char *
788 ***************************************************************************/
791 ReadCatalog(int setn, int msgn, char *dflt)
795 return (unsigned char*) dflt;
797 return (unsigned char*) catgets(nl_fd, setn, msgn, dflt);
800 /***************************************************************************
804 * read a string from the message catalog and convert to compound string
805 ***************************************************************************/
808 ReadCatalogXms(int setn, int msgn, char *dflt)
812 return XmStringCreateLocalized(dflt);
814 return XmStringCreateLocalized((char*) ReadCatalog(setn, msgn, dflt));
819 /***************************************************************************
821 * SecureDisplay/UnsecureDisplay
823 * grab/release the server and keyboard
824 ***************************************************************************/
826 static jmp_buf syncJump;
827 static int grabServer; /* Boolean on grabbing server */
828 static int grabTimeout; /* timeout to grab server */
831 syncTimeout( int arg )
833 longjmp (syncJump, 1);
837 SecureDisplay( void )
844 * get grab values from the environment...
847 grabServer = ((t = (char *)getenv(GRABSERVER)) == NULL ? 0 : atoi(t));
848 grabTimeout = ((t = (char *)getenv(GRABTIMEOUT)) == NULL ? 0 : atoi(t));
852 * grab server then the keyboard...
854 signal (SIGALRM, syncTimeout);
855 if (setjmp (syncJump)) {
856 LogError(ReadCatalog(MC_LOG_SET,MC_LOG_NO_SECDPY,MC_DEF_LOG_NO_SECDPY),
860 alarm ((unsigned int) grabTimeout);
861 XGrabServer (dpyinfo.dpy);
862 if (XGrabKeyboard (dpyinfo.dpy,
863 DefaultRootWindow (dpyinfo.dpy),
867 CurrentTime) != GrabSuccess) {
869 signal (SIGALRM, SIG_DFL);
870 LogError(ReadCatalog(MC_LOG_SET,MC_LOG_NO_SECKEY,MC_DEF_LOG_NO_SECKEY),
876 signal (SIGALRM, SIG_DFL);
877 /* pseudoReset (dpy);*/
880 * release server if grab not requested...
884 XUngrabServer (dpyinfo.dpy);
885 XSync (dpyinfo.dpy, 0);
893 UnsecureDisplay( void )
895 XUngrabKeyboard(dpyinfo.dpy, CurrentTime);
897 XUngrabServer (dpyinfo.dpy);
898 XSync (dpyinfo.dpy, 0);
904 /***************************************************************************
906 * SetResourceDatabase
909 * set up display's resource database with defaults and user values
911 * Starting with DT 3.0, the widget's unit type defaults to XmPIXELS
912 * rather than Xm100TH_MILLIMETERS. For backwards compatibility, it is
913 * necessary to determine if the user has specified Xm100TH_MILLIMETERS
914 * for the widget's unit type.
916 ***************************************************************************/
919 SetResourceDatabase( void )
929 char defaultWidth[32], defaultHeight[32];
930 char *rmtype; /* for XrmGetResource() */
931 XrmValue rmvalue; /* for XrmGetResource() */
933 static XrmDatabase defDb;
937 static DefResource defResource[] = {
938 { "*unitType", XmNPIXELS },
939 { "*matte.x", "-1" },
940 { "*matte.y", "-1" },
941 { "*login_matte.topPosition", LOGIN_TOP_POSITION },
942 { "*login_matte.bottomPosition", LOGIN_BOTTOM_POSITION },
943 { "*login_matte.leftPosition", LOGIN_LEFT_POSITION },
944 { "*login_matte.rightPosition", LOGIN_RIGHT_POSITION },
945 { "*table.background", TABLE_BACKGROUND },
946 { "*login_text.foreground", TEXT_FOREGROUND },
947 { "*passwd_text.foreground", TEXT_FOREGROUND },
950 # define NUM_RESOURCES (sizeof defResource / sizeof defResource[0])
953 static DefResource defResourceBW[] = {
954 { "*background", BW_BACKGROUND },
955 { "*foreground", BW_FOREGROUND },
956 { "*login_text.background", BW_TEXT_BACKGROUND },
957 { "*passwd_text.background", BW_TEXT_BACKGROUND },
960 # define NUM_BW_RESOURCES (sizeof defResourceBW / sizeof defResourceBW[0])
963 static DefResource defResourceGS[] = {
964 { "*logo*Background", BW_LOGO_BACKGROUND },
967 # define NUM_GS_RESOURCES (sizeof defResourceGS / sizeof defResourceGS[0])
970 static DefResource defResourceCO[] = {
971 { "*background", CO_BACKGROUND },
972 { "*foreground", CO_FOREGROUND },
973 { "*login_text.background", CO_TEXT_BACKGROUND },
974 { "*passwd_text.background", CO_TEXT_BACKGROUND },
975 { "*highlightColor", CO_HIGHLIGHT },
976 { "*XmToggleButtonGadget*selectColor",
980 # define NUM_CO_RESOURCES (sizeof defResourceCO / sizeof defResourceCO[0])
984 vg_TRACE_EXECUTION("SetResourceDatabase ...");
985 #endif /* VG_TRACE */
988 * check if user specified 100TH_MILLIMETERS as the unit type...
990 * initialize the local control variable "appInfo.unitType" to the
994 appInfo.unitType = XmPIXELS;
996 if ( XrmGetResource(XtDatabase(dpyinfo.dpy),
997 VnNmatteUnitType, VnCMatteUnitType,
998 &rmtype, &rmvalue ) ) {
1000 if ( strcmp (rmvalue.addr, XmN100TH_MILLIMETERS) == 0 )
1001 appInfo.unitType = Xm100TH_MILLIMETERS;
1006 * build new resource database with default values....
1009 defDb = XtDatabase(dpyinfo.dpy);
1011 sprintf(defaultWidth, "%d", FromMM(MATTE_WIDTH));
1012 sprintf(defaultHeight, "%d", FromMM(MATTE_HEIGHT));
1015 XrmPutStringResource(&defDb, VnNmatteWidth, defaultWidth);
1016 XrmPutStringResource(&defDb, VnNmatteHeight, defaultHeight);
1019 if(!XrmGetResource(defDb, "*labelFont", "*LabelFont",
1021 XrmPutStringResource(&defDb, "*labelFont",
1022 ( HIRES ? LABEL_FONT_HRES : LABEL_FONT));
1024 if(!XrmGetResource(defDb, "*textFont", "*TextFont",
1026 XrmPutStringResource(&defDb, "*textFont",
1027 ( LOWRES ? TEXT_FONT_LRES : TEXT_FONT));
1029 if(!XrmGetResource(defDb, "*greeting.fontList",
1030 "*Greeting.FontList", &rmtype, &rmvalue))
1031 XrmPutStringResource(&defDb, "*greeting.fontList", GREET_FONT);
1034 for (i = 0; i < NUM_RESOURCES; i++)
1035 XrmPutStringResource(&defDb,
1036 defResource[i].name,
1037 defResource[i].value);
1039 if ( dpyinfo.depth < 4 )
1040 for (i = 0; i < NUM_BW_RESOURCES; i++)
1041 XrmPutStringResource(&defDb,
1042 defResourceBW[i].name,
1043 defResourceBW[i].value);
1045 for (i = 0; i < NUM_CO_RESOURCES; i++)
1046 XrmPutStringResource(&defDb,
1047 defResourceCO[i].name,
1048 defResourceCO[i].value);
1050 if ( dpyinfo.visual->class == GrayScale )
1051 for (i = 0; i < NUM_GS_RESOURCES; i++)
1052 XrmPutStringResource(&defDb,
1053 defResourceGS[i].name,
1054 defResourceGS[i].value);
1059 * merge user's specifications with program defaults...
1064 * replace display's resource database with merged database...
1069 * Try to compensate if the user specifies the matte dimensions in
1070 * 100TH_MILLIMETERS, but forgets to also specify that unit type...
1073 userDb = XtDatabase(dpyinfo.dpy);
1075 if ( XrmGetResource(userDb, VnNmatteWidth, VnCMatteWidth,
1076 &rmtype, &rmvalue ) ) {
1078 sscanf(rmvalue.addr, "%d", &i);
1079 if ( appInfo.unitType == XmPIXELS && i >= dpyinfo.width ) {
1080 XrmPutStringResource(&userDb, VnNmatteWidth, defaultWidth);
1082 ReadCatalog(MC_LOG_SET,MC_LOG_BAD_MATTE,MC_DEF_LOG_BAD_MATTE),
1087 if ( XrmGetResource(userDb, VnNmatteHeight, VnCMatteHeight,
1088 &rmtype, &rmvalue ) ) {
1090 sscanf(rmvalue.addr, "%d", &i);
1091 if ( appInfo.unitType == XmPIXELS && i >= dpyinfo.height ) {
1092 XrmPutStringResource(&userDb, VnNmatteHeight, defaultHeight);
1094 ReadCatalog(MC_LOG_SET,MC_LOG_BAD_HMATTE,MC_DEF_LOG_BAD_HMATTE),
1104 /***************************************************************************
1108 * Convert from the widget's units into pixel units
1109 ***************************************************************************/
1112 ToPixel( Widget w, int orientation, int pixel )
1115 unsigned char unit_type;
1117 XtSetArg(argt[0], XmNunitType, &unit_type);
1118 XtGetValues(w, argt, 1);
1120 if (unit_type == XmPIXELS)
1123 return(XmConvertUnits(w,
1134 /***************************************************************************
1136 * _DtMessage Catalog Stubs
1138 * These stub routines can be used for porting to systems that do not yet
1139 * support message catalogs. Replace the above "0" with an appropriate
1140 * define for your target system. Do the same for the external defines
1142 ***************************************************************************/
1145 catopen(name, oflag)
1164 catgets(catd, set_num, msg_num, def_str)