/* * CDE - Common Desktop Environment * * Copyright (c) 1993-2012, The Open Group. All rights reserved. * * These libraries and programs are free software; you can * redistribute them and/or modify them under the terms of the GNU * Lesser General Public License as published by the Free Software * Foundation; either version 2 of the License, or (at your option) * any later version. * * These libraries and programs are distributed in the hope that * they will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU Lesser General Public License for more * details. * * You should have received a copy of the GNU Lesser General Public * License along with these libraries and programs; if not, write * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth * Floor, Boston, MA 02110-1301 USA */ /************************************<+>*************************************/ /****************************************************************************/ /** **/ /** File: Screen.c **/ /** **/ /** Project: DT 1.0 **/ /** **/ /** Description: Controls the Dtstyle Screen dialog **/ /** **/ /** **/ /** **/ /** **/ /****************************************************************************/ /************************************<+>*************************************/ /*$TOG: Screen.c /main/9 1997/07/14 17:44:42 samborn $*/ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include
#include
#include
#include
#include
#include
#include
#include
#include "Help.h" #include "Main.h" #include "SaveRestore.h" #include "Protocol.h" /*+++++++++++++++++++++++++++++++++++++++*/ /* include extern functions */ /*+++++++++++++++++++++++++++++++++++++++*/ #include "Screen.h" /*+++++++++++++++++++++++++++++++++++++++*/ /* Local #defines */ /*+++++++++++++++++++++++++++++++++++++++*/ #ifndef MIN #define MIN(X, Y) ((X) < (Y) ? (X) : (Y)) #endif #define TIMEOUT_MIN 1 #define TIMEOUT_MAX 120 #define CYCLETIME_MIN 0 #define CYCLE_DEFAULT 3 /* 1-120 */ #define LOCK_DEFAULT 30 /* 1-120 */ #define SAVER_DEFAULT 10 /* 0-120 */ #define SAVER_HEIGHT 238 #define SAVER_WIDTH 298 /*+++++++++++++++++++++++++++++++++++++++*/ /* Internal Functions */ /*+++++++++++++++++++++++++++++++++++++++*/ static Widget build_screenDialog( Widget shell) ; static void formLayoutCB(Widget w, XtPointer client_data, XtPointer call_data) ; static void no_svr_ext_formLayoutCB(Widget w, XtPointer client_data, XtPointer call_data) ; static void _DtmapCB_screenDialog(Widget w, XtPointer client_data, XtPointer call_data) ; static void no_svr_ext_DtmapCB_screenDialog(Widget w, XtPointer client_data, XtPointer call_data) ; static void timeOutvalueChangedCB(Widget w, XtPointer client_data, XtPointer call_data) ; static void no_svr_ext_timeOutvalueChangedCB(Widget w, XtPointer client_data, XtPointer call_data) ; static void saverToggleCB(Widget w, XtPointer client_data, XtPointer call_data) ; static void no_svr_ext_saverToggleCB(Widget w, XtPointer client_data, XtPointer call_data) ; static void saversToggleCB(Widget w, XtPointer client_data, XtPointer call_data) ; static void lockToggleCB(Widget w, XtPointer client_data, XtPointer call_data) ; static void systemDefaultCB(Widget w, XtPointer client_data, XtPointer call_data) ; static void no_svr_ext_systemDefaultCB(Widget w, XtPointer client_data, XtPointer call_data) ; static void ButtonCB(Widget w, XtPointer client_data, XtPointer call_data) ; static void no_svr_ext_ButtonCB(Widget w, XtPointer client_data, XtPointer call_data) ; static XmString * MakeListStrings(char **list ) ; static void FreeListStrings(XmString *xmlist, int count) ; static void ListCB(Widget w, XtPointer client_data, XtPointer call_data) ; static void IconHandler(Widget shell, XtPointer client_data, XEvent *event, Boolean *dispatch) ; static void UnmapCB(Widget w, XtPointer client_data, XtPointer call_data) ; /*+++++++++++++++++++++++++++++++++++++++*/ /* Internal Variables */ /*+++++++++++++++++++++++++++++++++++++++*/ typedef struct { Widget pictLabel; Widget systemDefault; Widget saverFrame; Widget saverForm; Widget saverArea; Widget saverAreaFrame; Widget saverLabel; Widget prevLabel; Widget saverOn; Widget saverOff; Widget saverRadioBox; Widget saverList; Widget timeOutLabel; Widget timeOutScale; Widget saverMinutesLabel; Widget cycleTimeLabel; Widget cycleTimeScale; Widget cycleMinutesLabel; Widget lockFrame; Widget lockForm; Widget lockLabel; Widget lockOn; Widget lockOff; Widget lockRadioBox; Widget lockingRadioBox; Widget lockOutLabel; Widget lockOutScale; Widget lockMinutesLabel; Widget useSaversOn; /* used for graying saverList and saverArea in no saver extn mode */ Widget useSaversOff; /* used for graying saverList and saverArea in no saver extn mode */ int interval; int blanking; int exposures; int newTimeout; /* the min value of savertimeout and locktimeout */ int origTimeout; /* the original value of the min of savertimeout and locktimeout */ int xTimeout; /* the value of the timeout extracted from the X server */ Boolean timeMismatch; /* use to keep track of mismatch between xTimeout and newTimeout */ int saverTimeout; /* the value of savertimeout */ int lockTimeout; /* the value of locktimeout */ int cycleTimeout; /* the value of cycletimeout */ int saverTimeout_xrdb; /* the value of savertimeout from xrdb, in case saver is off */ int lockTimeout_xrdb; /* the value of locktimeout from xrdb, in case lock is off */ int new_blanking; Boolean systemDefaultFlag; } ScreenData; /* using the savers toggle when the saver extn is not present */ static ScreenData screen; static saveRestore save = {FALSE, 0,}; typedef struct { char *saversList; /* list of available savers */ char *selsaversList; /* list of selected savers */ char **saverActionNames; /* array of saver names */ char **saverActionDesc; /* array of saver action descriptions */ char **selsaverActionNames; /* array of originally selected saver names */ int *selPositions; /* array of currently selected saver positions */ int *origSelPositions; /* array of originally selected saver positions */ int saverCount; /* number of available savers */ int selsaverCount; /* number of currently selected screen savers */ int orig_selsaverCount; /* number of originally selected screen savers */ int previous_selsaverCount; /* number of previously selected screen savers */ char *current_saver; /* name of current screen saver actions */ char *current_saverDesc; /* description of current screen saver actions */ int current_position; /* the clicked on position in the scrolled list */ int shadow; /* shadow width of saver area */ Pixel bg; /* bg color of the style manager dialogs */ Pixel black; /* value of the black pixel */ void *saverstate; /* current running screen saver state */ } Savers, *SaversPtr; static Savers savers; /*++++++++++++++++++++++++++++++++++++++++*/ /* build_saverList */ /* parses a space separated list of */ /* savers to build a an array of saver */ /* names. Returns the array and the saver */ /* count. */ /*++++++++++++++++++++++++++++++++++++++++*/ char ** build_saverList(char * str, int * count) { char tokenSep[] = " "; char * token; char ** saverList = NULL; int i = 0; char * tmpStr, *tmpStr2; int len = strlen(str); *count = 0; tmpStr = (char *)XtCalloc(1, len + 1); tmpStr2 = tmpStr; strcpy(tmpStr, str); token = strtok(tmpStr, tokenSep); while(token != NULL) { ++(i); token = strtok(NULL, tokenSep); } if (i == 0) return (NULL); saverList = (char **) XtCalloc(1, i * sizeof(char *)); if( saverList ) { strcpy(tmpStr, str); while (isspace(*tmpStr)) tmpStr++; token = strtok(tmpStr, tokenSep); *count=0; while(token != NULL) { if (DtActionExists(token)) { saverList[*count] = (char *) XtCalloc(1, strlen( token ) + 1); strcpy(saverList[*count], token); ++(*count); } tmpStr += strlen(token); if (tmpStr >= tmpStr2 + len ) token = NULL; else { do tmpStr++; while (isspace(*tmpStr)); token = strtok(tmpStr, tokenSep); } } } if (tmpStr2) XtFree ((char *) tmpStr2); return(saverList); } /*+++++++++++++++++++++++++++++++++++++++*/ /* build_selsaverList */ /*+++++++++++++++++++++++++++++++++++++++*/ char ** build_selsaverList(char * envStr, int * count) { char tokenSep[] = " "; char * token; char ** saverList = NULL; int i = 0; char * tmpStr; int len = strlen(envStr); *count = 0; tmpStr = (char *)XtCalloc(1, len + 1); strcpy(tmpStr, envStr); token = strtok(tmpStr, tokenSep); while(token != NULL) { ++(i); token = strtok(NULL, tokenSep); } if (i == 0) return (NULL); saverList = (char **) XtCalloc(1, i * sizeof(char *)); if( saverList ) { strcpy(tmpStr, envStr); token = strtok(tmpStr, tokenSep); *count=0; while(token != NULL) { saverList[*count] = (char *) XtCalloc(1, strlen( token ) + 1); strcpy(saverList[*count], token); token = strtok(NULL, tokenSep); ++(*count); } } XtFree ((char *) tmpStr); return(saverList); } /*+++++++++++++++++++++++++++++++++++++++*/ /* build_saverDesc */ /*+++++++++++++++++++++++++++++++++++++++*/ char ** build_saverDesc(char ** names, int count) { char **saverDesc = NULL; char *tmpstr; int i; saverDesc = (char **) XtCalloc(1, count * sizeof(char *)); for (i=0; i MaxLabelWidth) MaxLabelWidth = LabelWidth; if ((LabelWidth = XtWidth(screen.timeOutLabel)) > MaxLabelWidth) MaxLabelWidth = LabelWidth; if ((LabelWidth = XtWidth(screen.cycleTimeLabel)) > MaxLabelWidth) MaxLabelWidth = LabelWidth; if (style.smState.smLockOnTimeoutStatus) { if ((LabelWidth = XtWidth(screen.lockLabel)) > MaxLabelWidth) MaxLabelWidth = LabelWidth; if ((LabelWidth = XtWidth(screen.lockOutLabel)) > MaxLabelWidth) MaxLabelWidth = LabelWidth; } XtVaSetValues(screen.saverLabel, XmNwidth, MaxLabelWidth, NULL); XtVaSetValues(screen.timeOutLabel, XmNwidth, MaxLabelWidth, NULL); XtVaSetValues(screen.cycleTimeLabel, XmNwidth, MaxLabelWidth, NULL); if (style.smState.smLockOnTimeoutStatus) { XtVaSetValues(screen.lockLabel, XmNwidth, MaxLabelWidth, NULL); XtVaSetValues(screen.lockOutLabel, XmNwidth, MaxLabelWidth, NULL); } /* manage widgets */ XtManageChildren(widget_list1,list1_count); XtManageChild(form); XtManageChild(screen.saverForm); XtManageChild(screen.cycleTimeLabel); XtManageChild(screen.cycleTimeScale); XtManageChild(screen.saverLabel); XtManageChild(screen.prevLabel); XtManageChild(screen.saverRadioBox); XtManageChild(screen.saverOn); XtManageChild(screen.saverOff); XtManageChild(screen.timeOutLabel); XtManageChild(screen.timeOutScale); XtManageChild(screen.saverMinutesLabel); XtManageChild(screen.saverList); XtManageChild(screen.saverAreaFrame); XtManageChild(screen.saverArea); XtManageChild(screen.cycleMinutesLabel); XtManageChild(screen.saverList); XtManageChild(screen.lockForm); /* manage the lock label, scale and minutes label only if */ /* saver extensions are present */ if (style.smState.smLockOnTimeoutStatus) { XtManageChild(screen.lockLabel); XtManageChild(screen.lockRadioBox); XtManageChild(screen.lockOn); XtManageChild(screen.lockOff); XtManageChild(screen.lockOutLabel); XtManageChild(screen.lockOutScale); XtManageChild(screen.lockMinutesLabel); } else { XtManageChild(screen.lockingRadioBox); XtManageChild(screen.useSaversOn); XtManageChild(screen.useSaversOff); } XtAddEventHandler(style.shell, StructureNotifyMask, False, IconHandler, NULL); return(style.screenDialog); } /*+++++++++++++++++++++++++++++++++++++++*/ /* formLayoutCB */ /*+++++++++++++++++++++++++++++++++++++++*/ static void formLayoutCB( Widget w, XtPointer client_data, XtPointer call_data ) { int n; Arg args[MAX_ARGS]; Dimension ScaleHeight; Dimension LabelHeight; Dimension RadioHeight; Dimension RadioOffset, ScaleOffset; /* calculate width and height information */ ScaleHeight = XtHeight(screen.timeOutScale); LabelHeight = XtHeight(screen.timeOutLabel); RadioHeight = XtHeight(screen.saverRadioBox); RadioOffset = ((Dimension) (RadioHeight - LabelHeight) / 2) - 2; ScaleOffset = 0; /* do form attachments */ /* Picture Label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++; XtSetValues (screen.pictLabel, args, n); /* system Default */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.systemDefault, args, n); /* lock titlebox */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.lockFrame, args, n); /* lock label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg (args[n], XmNtopOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++; XtSetValues (screen.lockLabel, args, n); /* lock Radiobox */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, screen.lockLabel); n++; XtSetArg(args[n], XmNtopOffset, -RadioOffset); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNleftWidget, screen.lockLabel); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++; XtSetValues (screen.lockRadioBox, args, n); /* lockOut Label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, screen.lockLabel); n++; XtSetArg(args[n], XmNtopOffset, style.verticalSpacing + ScaleHeight - LabelHeight); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++; XtSetValues (screen.lockOutLabel, args, n); /* lockOut Scale */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNbottomWidget, screen.lockOutLabel);n++; XtSetArg(args[n], XmNbottomOffset, ScaleOffset); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNleftWidget, screen.lockOutLabel);n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNrightWidget, screen.lockMinutesLabel);n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.lockOutScale, args, n); /* Minutes label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNbottomWidget, screen.lockOutLabel);n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.lockMinutesLabel, args, n); /* saver titlebox */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, screen.pictLabel); n++; XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNbottomWidget, screen.lockFrame); n++; XtSetArg(args[n], XmNbottomOffset, 2*style.verticalSpacing); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.saverFrame, args, n); /* cycleTime Label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++; XtSetValues (screen.cycleTimeLabel, args, n); /* cycleTime Scale */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNbottomWidget, screen.cycleTimeLabel);n++; XtSetArg(args[n], XmNbottomOffset, ScaleOffset);n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNleftWidget, screen.cycleTimeLabel);n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNrightWidget, screen.cycleMinutesLabel);n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.cycleTimeScale, args, n); /* Minutes label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNbottomWidget, screen.cycleTimeLabel);n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.cycleMinutesLabel, args, n); /* TimeOut Label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNbottomWidget, screen.cycleTimeLabel);n++; XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing + ScaleHeight - LabelHeight); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++; XtSetValues (screen.timeOutLabel, args, n); /* Minutes label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNbottomWidget, screen.timeOutLabel);n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.saverMinutesLabel, args, n); /* TimeOut Scale */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNbottomWidget, screen.timeOutLabel);n++; XtSetArg(args[n], XmNbottomOffset, ScaleOffset); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNleftWidget, screen.timeOutLabel);n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNrightWidget, screen.saverMinutesLabel);n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.timeOutScale, args, n); /* saver label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++; XtSetValues (screen.saverLabel, args, n); /* saver Radiobox */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, screen.saverLabel); n++; XtSetArg(args[n], XmNtopOffset, -RadioOffset); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNleftWidget, screen.saverLabel); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++; XtSetValues (screen.saverRadioBox, args, n); /* preview label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, screen.saverLabel); n++; XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.prevLabel, args, n); /* scrolled list */ n = 0; XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg (args[n], XmNtopWidget, screen.prevLabel); n++; XtSetArg (args[n], XmNtopOffset, style.verticalSpacing/2); n++; XtSetArg (args[n], XmNrightAttachment, XmATTACH_NONE); n++; XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNbottomWidget, screen.timeOutLabel); n++; XtSetArg(args[n], XmNbottomOffset, 5*style.verticalSpacing); n++; XtSetValues (XtParent(screen.saverList), args, n); /* saverArea */ n=0; XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, XtParent(screen.saverList)); n++; XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNleftWidget, XtParent(screen.saverList)); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetArg (args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNbottomWidget, XtParent(screen.saverList)); n++; XtSetValues (screen.saverAreaFrame, args, n); XtRemoveCallback(style.screenDialog, XmNmapCallback, formLayoutCB, NULL); } /*+++++++++++++++++++++++++++++++++++++++*/ /* no_svr_ext_formLayoutCB */ /*+++++++++++++++++++++++++++++++++++++++*/ static void no_svr_ext_formLayoutCB( Widget w, XtPointer client_data, XtPointer call_data ) { int n; Arg args[MAX_ARGS]; Dimension ScaleHeight; Dimension LabelHeight; Dimension RadioHeight; Dimension RadioOffset, ScaleOffset; /* calculate width and height information */ ScaleHeight = XtHeight(XtParent(screen.timeOutScale)); LabelHeight = XtHeight(screen.timeOutLabel); RadioHeight = XtHeight(screen.saverRadioBox); RadioOffset = ((Dimension) (RadioHeight - LabelHeight) / 2) - 2; ScaleOffset = 0; /* do form attachments */ /* Picture Label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++; XtSetValues (screen.pictLabel, args, n); /* system Default */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.systemDefault, args, n); /* saver titlebox */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, screen.pictLabel); n++; XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.saverFrame, args, n); /* saver label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++; XtSetValues (screen.saverLabel, args, n); /* saver Radiobox */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, screen.saverLabel); n++; XtSetArg(args[n], XmNtopOffset, -RadioOffset); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNleftWidget, screen.saverLabel); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++; XtSetValues (screen.saverRadioBox, args, n); /* TimeOut Label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, screen.saverLabel); n++; XtSetArg(args[n], XmNtopOffset, style.verticalSpacing + ScaleHeight - LabelHeight); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++; XtSetValues (screen.timeOutLabel, args, n); /* TimeOut Scale */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNbottomWidget, screen.timeOutLabel);n++; XtSetArg(args[n], XmNbottomOffset, ScaleOffset); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNleftWidget, screen.timeOutLabel);n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNrightWidget, screen.saverMinutesLabel);n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.timeOutScale, args, n); /* Minutes label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNbottomWidget, screen.timeOutLabel);n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.saverMinutesLabel, args, n); /* lock titlebox */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, screen.saverFrame); n++; XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.lockFrame, args, n); /* locking radiobox */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++; XtSetValues (screen.lockingRadioBox, args, n); /* preview label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, screen.lockingRadioBox); n++; XtSetArg(args[n], XmNtopOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.prevLabel, args, n); /* cycleTime Label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNbottomOffset, style.verticalSpacing); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_NONE); n++; XtSetValues (screen.cycleTimeLabel, args, n); /* cycleTime Scale */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNbottomWidget, screen.cycleTimeLabel);n++; XtSetArg(args[n], XmNbottomOffset, ScaleOffset); n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNleftWidget, screen.cycleTimeLabel);n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNrightWidget, screen.cycleMinutesLabel);n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.cycleTimeScale, args, n); /* Minutes label */ n=0; XtSetArg(args[n], XmNtopAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNbottomWidget, screen.cycleTimeLabel);n++; XtSetArg(args[n], XmNleftAttachment, XmATTACH_NONE); n++; XtSetArg(args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetValues (screen.cycleMinutesLabel, args, n); /* scrolled list */ n = 0; XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++; XtSetArg (args[n], XmNtopWidget, screen.prevLabel); n++; XtSetArg (args[n], XmNtopOffset, style.verticalSpacing); n++; XtSetArg (args[n], XmNrightAttachment, XmATTACH_NONE); n++; XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg (args[n], XmNbottomAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNbottomWidget, screen.cycleTimeLabel); n++; XtSetArg(args[n], XmNbottomOffset, 5*style.verticalSpacing); n++; XtSetValues (XtParent(screen.saverList), args, n); /* saverArea */ n=0; XtSetArg (args[n], XmNtopAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNtopWidget, XtParent(screen.saverList)); n++; XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++; XtSetArg(args[n], XmNleftWidget, XtParent(screen.saverList)); n++; XtSetArg(args[n], XmNleftOffset, style.horizontalSpacing); n++; XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++; XtSetArg(args[n], XmNrightOffset, style.horizontalSpacing); n++; XtSetArg (args[n], XmNbottomAttachment, XmATTACH_OPPOSITE_WIDGET); n++; XtSetArg(args[n], XmNbottomWidget, XtParent(screen.saverList)); n++; XtSetValues (screen.saverAreaFrame, args, n); XtRemoveCallback(style.screenDialog, XmNmapCallback, no_svr_ext_formLayoutCB, NULL); } /*+++++++++++++++++++++++++++++++++++++++*/ /* _DtmapCB_screenDialog */ /*+++++++++++++++++++++++++++++++++++++++*/ static void _DtmapCB_screenDialog( Widget w, XtPointer client_data, XtPointer call_data ) { static int first_time = 1; int n; Arg args[MAX_ARGS]; XmString string; Boolean lock_on, saver_on; if (first_time) { DtWsmRemoveWorkspaceFunctions(style.display, XtWindow(XtParent(w))); if (!save.restoreFlag) putDialog ((Widget)client_data, w); /* Retrieve the value for the saver slider from xrdb */ screen.saverTimeout_xrdb = atoi((char *)style.xrdb.timeoutScale); if (screen.saverTimeout_xrdb < 1) screen.saverTimeout_xrdb = 10; /* Retrieve the value for the lock slider from xrdb */ screen.lockTimeout_xrdb = atoi((char *)style.xrdb.lockoutScale); if (screen.lockTimeout_xrdb < 1) screen.lockTimeout_xrdb = 30; /* initialize the value of savertimeout and locktimeout and cycle time to the */ /* initial state or to the values retrieved from xrdb if the corresponding*/ /* initial state is zero */ if (style.smState.smSaverTimeout) screen.saverTimeout = style.smState.smSaverTimeout / 60; else screen.saverTimeout = screen.saverTimeout_xrdb; if (style.smState.smLockTimeout) screen.lockTimeout = style.smState.smLockTimeout / 60; else screen.lockTimeout = screen.lockTimeout_xrdb; if (style.smState.smCycleTimeout) screen.cycleTimeout = style.smState.smCycleTimeout / 60; else screen.cycleTimeout = 0; /* set the value of the scales */ XtVaSetValues(screen.timeOutScale, XmNvalue, screen.saverTimeout, NULL); XtVaSetValues(screen.lockOutScale, XmNvalue, screen.lockTimeout, NULL); XtVaSetValues(screen.cycleTimeScale, XmNvalue, screen.cycleTimeout , NULL); /* set the value of the saver toggles */ XmToggleButtonGadgetSetState(screen.saverOn, style.smState.smSaverTimeout ? True : False, False); XmToggleButtonGadgetSetState(screen.saverOff, !style.smState.smSaverTimeout ? True : False, False ); XmToggleButtonGadgetSetState(screen.lockOn, style.smState.smLockTimeout ? True : False, False); XmToggleButtonGadgetSetState(screen.lockOff, !style.smState.smLockTimeout ? True : False, False); /* make saver widgets insensitive if screen saver is off */ /* also blank out the preview label widget */ if (XmToggleButtonGadgetGetState(screen.saverOff)) { XtSetSensitive(screen.saverList, False); XtSetSensitive(screen.saverArea, False); XtSetSensitive(screen.timeOutLabel, False); XtSetSensitive(screen.timeOutScale, False); XtSetSensitive(screen.saverMinutesLabel, False); XtSetSensitive(screen.cycleTimeLabel, False); XtSetSensitive(screen.cycleTimeScale, False); XtSetSensitive(screen.cycleMinutesLabel, False); XtUnmanageChild(screen.prevLabel); } /* make saver widgets sensitive if screen saver is on */ /* also manage the preview label widget */ if (XmToggleButtonGadgetGetState(screen.saverOn)) { XtSetSensitive(screen.saverList, True); XtSetSensitive(screen.saverArea, True); XtSetSensitive(screen.timeOutLabel, True); XtSetSensitive(screen.timeOutScale, True); XtSetSensitive(screen.saverMinutesLabel, True); XtManageChild(screen.prevLabel); /* make cycletime scale sensitive if selected savers are more than 1 */ if (savers.selsaverCount > 1) { XtSetSensitive(screen.cycleTimeLabel, True); XtSetSensitive(screen.cycleTimeScale, True); XtSetSensitive(screen.cycleMinutesLabel, True); } else { XtSetSensitive(screen.cycleTimeLabel, False); XtSetSensitive(screen.cycleTimeScale, False); XtSetSensitive(screen.cycleMinutesLabel, False); } } /* make lock widgets insensitive if lock screen is off */ if (XmToggleButtonGadgetGetState(screen.lockOff)) { XtSetSensitive(screen.lockOutLabel, False); XtSetSensitive(screen.lockOutScale, False); XtSetSensitive(screen.lockMinutesLabel, False); } /* make lock widgets sensitive if lock screen is on */ if (XmToggleButtonGadgetGetState(screen.lockOn)) { XtSetSensitive(screen.lockOutLabel, True); XtSetSensitive(screen.lockOutScale, True); XtSetSensitive(screen.lockMinutesLabel, True); } if (!style.smState.smSaverTimeout) screen.origTimeout = screen.newTimeout = style.smState.smLockTimeout; else if (!style.smState.smLockTimeout) screen.origTimeout = screen.newTimeout = style.smState.smSaverTimeout; else screen.origTimeout = screen.newTimeout = MIN(style.smState.smSaverTimeout, style.smState.smLockTimeout); first_time = 0; } /* check the saver values from X - need to do this everytime dialog is mapped because */ /* the user may have changed settings thru X while style manager has been running */ /* if the value of the timeout retrieved from X is not equal to the new timeout set in the */ /* style manager interface, then set both lock time and saver time scales to value retrieved from */ /* X, otherwise leave them alone */ XGetScreenSaver(style.display, &screen.xTimeout, &screen.interval, &screen.blanking, &screen.exposures); screen.new_blanking = DontPreferBlanking; if (screen.xTimeout < 0) screen.xTimeout = 0; else if ((screen.xTimeout < 60) && (screen.xTimeout > 1)) screen.xTimeout = 60; else if (screen.xTimeout > TIMEOUT_MAX * 60) screen.xTimeout = TIMEOUT_MAX * 60; if (screen.xTimeout < 0) screen.xTimeout = 0; else if ((screen.xTimeout < 60) && (screen.xTimeout > 1)) screen.xTimeout = 60; else if (screen.xTimeout > TIMEOUT_MAX * 60) screen.xTimeout = TIMEOUT_MAX * 60; screen.timeMismatch = False; if (screen.xTimeout != screen.newTimeout) { screen.timeMismatch = True; screen.newTimeout = screen.xTimeout; if (screen.xTimeout) { screen.saverTimeout = screen.xTimeout / 60; screen.lockTimeout = screen.xTimeout / 60; } else { screen.saverTimeout = screen.saverTimeout_xrdb; screen.lockTimeout = screen.lockTimeout_xrdb; } /* set the value of the saver widgets */ XmToggleButtonGadgetSetState(screen.saverOn, screen.xTimeout ? True : False, False); XmToggleButtonGadgetSetState(screen.saverOff, !screen.xTimeout ? True : False, False); XmToggleButtonGadgetSetState(screen.lockOn, screen.xTimeout ? True : False, False); XmToggleButtonGadgetSetState(screen.lockOff, !screen.xTimeout ? True : False, False); /* set the value of the scales */ XtVaSetValues(screen.timeOutScale, XmNvalue, screen.saverTimeout, NULL); XtVaSetValues(screen.lockOutScale, XmNvalue, screen.lockTimeout_xrdb, NULL); /* make saver widgets insensitive if screen saver is off */ /* also blankout the preview label widget */ if (XmToggleButtonGadgetGetState(screen.saverOff)) { XtSetSensitive(screen.saverList, False); XtSetSensitive(screen.saverArea, False); XtSetSensitive(screen.timeOutLabel, False); XtSetSensitive(screen.timeOutScale, False); XtSetSensitive(screen.saverMinutesLabel, False); XtSetSensitive(screen.cycleTimeLabel, False); XtSetSensitive(screen.cycleTimeScale, False); XtSetSensitive(screen.cycleMinutesLabel, False); XtUnmanageChild(screen.prevLabel); } /* make saver widgets sensitive if screen saver is on */ /* also manage the preview label widget */ if (XmToggleButtonGadgetGetState(screen.saverOn)) { XtSetSensitive(screen.saverList, True); XtSetSensitive(screen.saverArea, True); XtSetSensitive(screen.timeOutLabel, True); XtSetSensitive(screen.timeOutScale, True); XtSetSensitive(screen.saverMinutesLabel, True); XtManageChild(screen.prevLabel); /* make cycletime scale sensitive if selected savers are more than 1 */ if (savers.selsaverCount > 1) { XtSetSensitive(screen.cycleTimeLabel, True); XtSetSensitive(screen.cycleTimeScale, True); XtSetSensitive(screen.cycleMinutesLabel, True); } else { XtSetSensitive(screen.cycleTimeLabel, False); XtSetSensitive(screen.cycleTimeScale, False); XtSetSensitive(screen.cycleMinutesLabel, False); } } /* make lock widgets insensitive if lock screen is off */ if (XmToggleButtonGadgetGetState(screen.lockOff)) { XtSetSensitive(screen.lockOutLabel, False); XtSetSensitive(screen.lockOutScale, False); XtSetSensitive(screen.lockMinutesLabel, False); } /* make lock widgets sensitive if lock screen is on */ if (XmToggleButtonGadgetGetState(screen.lockOn)) { XtSetSensitive(screen.lockOutLabel, True); XtSetSensitive(screen.lockOutScale, True); XtSetSensitive(screen.lockMinutesLabel, True); } } /* run the current screen saver only if screen saver is turned on and a valid saver exists*/ if (XmToggleButtonGadgetGetState(screen.saverOn) && savers.saverCount && !savers.saverstate) { XtVaSetValues(screen.saverArea, XmNbackground, savers.black, NULL); savers.saverstate = _DtSaverStart(style.display, &screen.saverArea, 1, savers.current_saver, style.screenDialog); string = XmStringCreateLocalized (savers.current_saverDesc); XtVaSetValues(screen.prevLabel, XmNlabelString, string, NULL); XmStringFree(string); } } /*+++++++++++++++++++++++++++++++++++++++*/ /* no_svr_ext_DtmapCB_screenDialog */ /*+++++++++++++++++++++++++++++++++++++++*/ static void no_svr_ext_DtmapCB_screenDialog( Widget w, XtPointer client_data, XtPointer call_data ) { static int first_time = 1; int n; Arg args[MAX_ARGS]; XmString string; int mintime; if (first_time) { DtWsmRemoveWorkspaceFunctions(style.display, XtWindow(XtParent(w))); if (!save.restoreFlag) putDialog ((Widget)client_data, w); /* Retrieve the value for the saver slider from xrdb */ screen.saverTimeout_xrdb = atoi((char *)style.xrdb.timeoutScale); if (screen.saverTimeout_xrdb < 1) screen.saverTimeout_xrdb = 10; if (style.smState.smCycleTimeout) screen.cycleTimeout = style.smState.smCycleTimeout / 60; else screen.cycleTimeout = 0; /* set the value of the cycle time scale */ XtVaSetValues(screen.cycleTimeScale, XmNvalue, screen.cycleTimeout , NULL); /* set the initial condition for the locking RadioBoxes */ XmToggleButtonGadgetSetState(screen.useSaversOn, style.smState.smSaverTimeout ? True : False, False); XmToggleButtonGadgetSetState(screen.useSaversOff, style.smState.smSaverTimeout ? False : True, False); if (style.smState.smSaverTimeout) { XtSetSensitive(screen.saverList, True); XtSetSensitive(screen.saverArea, True); if (savers.selsaverCount > 1) { XtSetSensitive(screen.cycleTimeLabel, True); XtSetSensitive(screen.cycleTimeScale, True); XtSetSensitive(screen.cycleMinutesLabel, True); } else { XtSetSensitive(screen.cycleTimeLabel, False); XtSetSensitive(screen.cycleTimeScale, False); XtSetSensitive(screen.cycleMinutesLabel, False); } XtManageChild(screen.prevLabel); SmNewSaverTime(60); } else { XtSetSensitive(screen.saverList, False); XtSetSensitive(screen.saverArea, False); XtSetSensitive(screen.cycleTimeLabel, False); XtSetSensitive(screen.cycleTimeScale, False); XtSetSensitive(screen.cycleMinutesLabel, False); XtUnmanageChild(screen.prevLabel); SmNewSaverTime(0); } screen.newTimeout = screen.origTimeout = 0; first_time = 0; } /* check the saver values from X - need to do this everytime dialog is mapped because */ /* the user may have changed settings thru X while style manager has been running */ /* if the value of the timeout retrieved from X is not equal to the new timeout set in the */ /* style manager interface, then set both lock time and saver time scales to value retrieved from */ /* X, otherwise leave them alone */ XGetScreenSaver(style.display, &screen.xTimeout, &screen.interval, &screen.blanking, &screen.exposures); screen.new_blanking = PreferBlanking; if (screen.xTimeout < 0) screen.xTimeout = 0; else if ((screen.xTimeout < 60) && (screen.xTimeout > 1)) screen.xTimeout = 60; else if (screen.xTimeout > TIMEOUT_MAX * 60) screen.xTimeout = TIMEOUT_MAX * 60; if (screen.xTimeout != screen.newTimeout) { screen.origTimeout = screen.newTimeout = screen.xTimeout; screen.saverTimeout = screen.xTimeout / 60; } /* set the value of the saver widgets */ XmToggleButtonGadgetSetState(screen.saverOn, screen.newTimeout ? True : False, False); XmToggleButtonGadgetSetState(screen.saverOff, !screen.newTimeout ? True : False, False); if (!screen.saverTimeout) screen.saverTimeout = screen.saverTimeout_xrdb; XtVaSetValues(screen.timeOutScale, XmNvalue, screen.saverTimeout, NULL); /* make saver widgets insensitive if screen saver is off */ if (XmToggleButtonGadgetGetState(screen.saverOff)) { XtSetSensitive(screen.timeOutLabel, False); XtSetSensitive(screen.timeOutScale, False); XtSetSensitive(screen.saverMinutesLabel, False); } /* make saver widgets sensitive if screen saver is on */ if (XmToggleButtonGadgetGetState(screen.saverOn)) { XtSetSensitive(screen.timeOutLabel, True); XtSetSensitive(screen.timeOutScale, True); XtSetSensitive(screen.saverMinutesLabel, True); } /* run the current screen saver only if the useSaversOn toggle is enabled and valid saver exist*/ if (XmToggleButtonGadgetGetState(screen.useSaversOn) && savers.saverCount && !savers.saverstate) { XtVaSetValues(screen.saverArea, XmNbackground, savers.black, NULL); savers.saverstate = _DtSaverStart(style.display, &screen.saverArea, 1, savers.current_saver, style.screenDialog); string = XmStringCreateLocalized (savers.current_saverDesc); XtVaSetValues(screen.prevLabel, XmNlabelString, string, NULL); XmStringFree(string); } } /*****************************************/ /* timeOutvalueChangedCB */ /* set the timeout to be the minimum of */ /* the lock scale and timeout scale */ /*****************************************/ static void timeOutvalueChangedCB( Widget w, XtPointer client_data, XtPointer call_data ) { int n; Arg args[MAX_ARGS]; n=0; XtSetArg(args[n], XmNvalue, &screen.saverTimeout); n++; XtGetValues(screen.timeOutScale, args, n); n=0; XtSetArg(args[n], XmNvalue, &screen.lockTimeout); n++; XtGetValues(screen.lockOutScale, args, n); /* set newTimeout to the min value of lock scale and saver scale */ /* unless either screen saver or lock is off */ if (!XmToggleButtonGadgetGetState(screen.lockOn)) screen.newTimeout = screen.saverTimeout * 60; else if (!XmToggleButtonGadgetGetState(screen.saverOn)) screen.newTimeout = screen.lockTimeout * 60; else screen.newTimeout = MIN(screen.saverTimeout, screen.lockTimeout) * 60; /* register new timeout with X */ XSetScreenSaver(style.display, screen.newTimeout, screen.interval, screen.new_blanking, screen.exposures); screen.systemDefaultFlag = False; } /*****************************************/ /* no_svr_ext_timeOutvalueChangedCB */ /* set the timeout to be the minimum of */ /* the lock scale and timeout scale */ /*****************************************/ static void no_svr_ext_timeOutvalueChangedCB( Widget w, XtPointer client_data, XtPointer call_data ) { int n; Arg args[MAX_ARGS]; n=0; XtSetArg(args[n], XmNvalue, &screen.saverTimeout); n++; XtGetValues(screen.timeOutScale, args, n); /* set newTimeout to the value of saver scale */ screen.newTimeout = screen.saverTimeout * 60; /* register new timeout with X */ XSetScreenSaver(style.display, screen.newTimeout, screen.interval, screen.new_blanking, screen.exposures); screen.systemDefaultFlag = False; } /*+++++++++++++++++++++++++++++++++++++++*/ /* saverToggleCB */ /*+++++++++++++++++++++++++++++++++++++++*/ static void saverToggleCB( Widget w, XtPointer client_data, XtPointer call_data ) { int n; Arg args[MAX_ARGS]; Boolean set; XmString string; XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)call_data; set = (Boolean) cb->set; if (w == screen.saverOff && !set ) { return; } if (w == screen.saverOff && set) { /* Terminate the screen saver that is currently running */ if (savers.saverstate) { _DtSaverStop(style.display, savers.saverstate); savers.saverstate = NULL; XSync(style.display, False); XClearWindow(style.display, XtWindow(screen.saverArea)); } XtSetSensitive(screen.saverList, False); XtSetSensitive(screen.saverArea, False); XtSetSensitive(screen.timeOutLabel, False); XtSetSensitive(screen.timeOutScale, False); XtSetSensitive(screen.saverMinutesLabel, False); XtSetSensitive(screen.cycleTimeLabel, False); XtSetSensitive(screen.cycleTimeScale, False); XtSetSensitive(screen.cycleMinutesLabel, False); /* do not display preview string */ XtUnmanageChild(screen.prevLabel); /* set the background color of the saver window to the */ /* secondary color ID */ XSync(style.display, False); XtVaSetValues(screen.saverArea, XmNbackground, savers.bg, NULL); XClearWindow(style.display, XtWindow(screen.saverArea)); /* set the new timeout for the X server - note that since */ /* screen saver is disabled, the new timeout is now the value of the */ /* lock slider or zero if lock is disabled */ if (XmToggleButtonGadgetGetState(screen.lockOn)) screen.newTimeout = screen.lockTimeout * 60; else screen.newTimeout = 0; /* let the session manger know not to run any savers */ SmNewSaverTime(0); } if (w == screen.saverOn && !set) { return; } if (w == screen.saverOn && set) { XtSetSensitive(screen.saverList, True); XtSetSensitive(screen.saverArea, True); XtSetSensitive(screen.timeOutLabel, True); XtSetSensitive(screen.timeOutScale, True); XtSetSensitive(screen.saverMinutesLabel , True); if (savers.selsaverCount > 1) { XtSetSensitive(screen.cycleTimeLabel, True); XtSetSensitive(screen.cycleTimeScale, True); XtSetSensitive(screen.cycleMinutesLabel, True ); } else { XtSetSensitive(screen.cycleTimeLabel, False); XtSetSensitive(screen.cycleTimeScale, False); XtSetSensitive(screen.cycleMinutesLabel, False); } if (savers.saverCount) { /* display the preview label */ XtManageChild(screen.prevLabel); /* Restart the screen saver that is is currently selected */ if (!savers.saverstate) { XtVaSetValues(screen.saverArea, XmNbackground, savers.black, NULL); savers.saverstate = _DtSaverStart(style.display, &screen.saverArea, 1, savers.current_saver, style.screenDialog); } /* set the new timeout for the X server - note that since */ /* screen saver is enabled, the new timeout is now the value of the */ /* saver slider or the minimum of the timeout sliders */ } if (!XmToggleButtonGadgetGetState(screen.lockOn)) screen.newTimeout = screen.saverTimeout * 60; else screen.newTimeout = MIN(screen.saverTimeout, screen.lockTimeout) * 60; /* let the session manger know to run savers */ SmNewSaverTime(screen.newTimeout); } XSetScreenSaver(style.display, screen.newTimeout, screen.interval, screen.new_blanking, screen.exposures); screen.systemDefaultFlag = False; } /*+++++++++++++++++++++++++++++++++++++++*/ /* no_svr_ext_saverToggleCB */ /*+++++++++++++++++++++++++++++++++++++++*/ static void no_svr_ext_saverToggleCB( Widget w, XtPointer client_data, XtPointer call_data ) { int n; Arg args[MAX_ARGS]; Boolean set; XmString string; XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)call_data; set = (Boolean) cb->set; if (w == screen.saverOff && !set ) { return; } if (w == screen.saverOff && set) { XtSetSensitive(screen.timeOutLabel, False); XtSetSensitive(screen.timeOutScale, False); XtSetSensitive(screen.saverMinutesLabel, False); /* set the new timeout for the X server - note that since */ /* screen saver is disabled, the new timeout is now zero */ screen.newTimeout = 0; } if (w == screen.saverOn && !set) { return; } if (w == screen.saverOn && set) { XtSetSensitive(screen.timeOutLabel, True); XtSetSensitive(screen.timeOutScale, True); XtSetSensitive(screen.saverMinutesLabel , True); /* register the new timeout with the X server - note that since */ /* screen saver is enabled, the new timeout is now the value of the */ /* saver slider */ screen.newTimeout = screen.saverTimeout * 60; } XSetScreenSaver(style.display, screen.newTimeout, screen.interval, screen.new_blanking, screen.exposures); screen.systemDefaultFlag = False; } /*+++++++++++++++++++++++++++++++++++++++*/ /* lock ToggleCB */ /*+++++++++++++++++++++++++++++++++++++++*/ static void lockToggleCB( Widget w, XtPointer client_data, XtPointer call_data ) { int n; Arg args[MAX_ARGS]; Boolean set; XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)call_data; set = (Boolean) cb->set; if (w == screen.lockOff && !set ) { return; } if (w == screen.lockOff && set) { XtSetSensitive(screen.lockOutLabel, False); XtSetSensitive(screen.lockOutScale, False); XtSetSensitive(screen.lockMinutesLabel, False); /* register the new timeout with the X server - note that since */ /* lock is disabled, the new timeout is now the value of the */ /* saver slider or zero if saver is disabled */ if (XmToggleButtonGadgetGetState(screen.saverOn)) screen.newTimeout = screen.saverTimeout * 60; else screen.newTimeout = 0; XSetScreenSaver(style.display, screen.newTimeout, screen.interval, screen.new_blanking, screen.exposures); } if (w == screen.lockOn && !set) { return; } if (w == screen.lockOn && set) { XtSetSensitive(screen.lockOutLabel, True); XtSetSensitive(screen.lockOutScale, True); XtSetSensitive(screen.lockMinutesLabel, True); /* register the new timeout with the X server - note that since */ /* lock is disabled, the new timeout is now the value of the */ /* lock slider or the minimum of the two timeout sliders */ if (!XmToggleButtonGadgetGetState(screen.saverOn)) screen.newTimeout = screen.lockTimeout * 60; else screen.newTimeout = MIN(screen.saverTimeout, screen.lockTimeout) * 60; XSetScreenSaver(style.display, screen.newTimeout, screen.interval, screen.new_blanking, screen.exposures); } screen.systemDefaultFlag = False; } /*+++++++++++++++++++++++++++++++++++++++*/ /* saversToggleCB */ /*+++++++++++++++++++++++++++++++++++++++*/ static void saversToggleCB( Widget w, XtPointer client_data, XtPointer call_data ) { int n; Arg args[MAX_ARGS]; Boolean set; XmString string; XmToggleButtonCallbackStruct *cb = (XmToggleButtonCallbackStruct *)call_data; set = (Boolean) cb->set; if (w == screen.useSaversOff && !set ) { return; } if (w == screen.useSaversOff && set) { /* Terminate the screen saver that is currently running */ if (savers.saverstate) { _DtSaverStop(style.display, savers.saverstate); savers.saverstate = NULL; XSync(style.display, False); XClearWindow(style.display, XtWindow(screen.saverArea)); } XtSetSensitive(screen.saverList, False); XtSetSensitive(screen.saverArea, False); XtSetSensitive(screen.cycleTimeLabel, False); XtSetSensitive(screen.cycleTimeScale, False); XtSetSensitive(screen.cycleMinutesLabel, False); /* do not display preview string */ XtUnmanageChild(screen.prevLabel); /* set the background color of the saver window to the */ /* secondary color ID */ XSync(style.display, False); XtVaSetValues(screen.saverArea, XmNbackground, savers.bg, NULL); XClearWindow(style.display, XtWindow(screen.saverArea)); /* let the session manger know not to run any savers */ SmNewSaverTime(0); } if (w == screen.useSaversOn && !set) { return; } if (w == screen.useSaversOn && set) { XtSetSensitive(screen.saverList, True); XtSetSensitive(screen.saverArea, True); if (savers.selsaverCount > 1) { XtSetSensitive(screen.cycleTimeLabel, True); XtSetSensitive(screen.cycleTimeScale, True); XtSetSensitive(screen.cycleMinutesLabel, True); } if (savers.saverCount) { /* display the preview label */ XtManageChild(screen.prevLabel); /* Restart the screen saver that is is currently selected */ if (!savers.saverstate) { XtVaSetValues(screen.saverArea, XmNbackground, savers.black, NULL); savers.saverstate = _DtSaverStart(style.display, &screen.saverArea, 1, savers.current_saver, style.screenDialog); } } /* let the session manger know to run the savers */ SmNewSaverTime(screen.saverTimeout*60); } } /*+++++++++++++++++++++++++++++++++++++++*/ /* systemDefaultCB */ /*+++++++++++++++++++++++++++++++++++++++*/ static void systemDefaultCB( Widget w, XtPointer client_data, XtPointer call_data ) { int n; Arg args[MAX_ARGS]; screen.saverTimeout = SAVER_DEFAULT; n=0; XtSetArg(args[n], XmNvalue, screen.saverTimeout); n++; XtSetValues(screen.timeOutScale, args, n); screen.lockTimeout = LOCK_DEFAULT; n=0; XtSetArg(args[n], XmNvalue, screen.lockTimeout); n++; XtSetValues(screen.lockOutScale, args, n); XmToggleButtonGadgetSetState(screen.lockOff, True, True); screen.cycleTimeout = CYCLE_DEFAULT; n=0; XtSetArg(args[n], XmNvalue, screen.cycleTimeout); n++; XtSetValues(screen.cycleTimeScale, args, n); XmToggleButtonGadgetSetState(screen.saverOn, True, True); screen.newTimeout = MIN(SAVER_DEFAULT, LOCK_DEFAULT) * 60; /* register new timeout with X */ XSetScreenSaver(style.display, screen.newTimeout, screen.interval, screen.new_blanking, screen.exposures); screen.systemDefaultFlag = True; } /*+++++++++++++++++++++++++++++++++++++++*/ /* no_svr_ext_systemDefaultCB */ /*+++++++++++++++++++++++++++++++++++++++*/ static void no_svr_ext_systemDefaultCB( Widget w, XtPointer client_data, XtPointer call_data ) { int n; Arg args[MAX_ARGS]; screen.saverTimeout = SAVER_DEFAULT; n=0; XtSetArg(args[n], XmNvalue, screen.saverTimeout); n++; XtSetValues(screen.timeOutScale, args, n); screen.cycleTimeout = CYCLE_DEFAULT; n=0; XtSetArg(args[n], XmNvalue, screen.cycleTimeout); n++; XtSetValues(screen.cycleTimeScale, args, n); XmToggleButtonGadgetSetState(screen.saverOn, True, True); XmToggleButtonGadgetSetState(screen.useSaversOn, True, True); screen.newTimeout = SAVER_DEFAULT * 60; /* register new timeout with X */ XSetScreenSaver(style.display, screen.newTimeout, screen.interval, screen.new_blanking, screen.exposures); screen.systemDefaultFlag = True; } /*+++++++++++++++++++++++++++++++++++++++*/ /* ButtonCB */ /* callback for PushButtons in DialogBox */ /*+++++++++++++++++++++++++++++++++++++++*/ static void ButtonCB( Widget w, XtPointer client_data, XtPointer call_data ) { int i, n, m; Arg args[MAX_ARGS]; Boolean sel_matched = False; Boolean lockset; Boolean saverset; Boolean flag; static char screenres[48]; int mintime; XtArgVal scratch; DtDialogBoxCallbackStruct *cb = (DtDialogBoxCallbackStruct *) call_data; switch (cb->button_position) { case OK_BUTTON: XtUnmanageChild (w); /* terminate the saver that is currently running */ if (savers.saverstate) { _DtSaverStop(style.display, savers.saverstate); savers.saverstate = NULL; } /* write saver timeout resource to xrdb to save scale value */ /* when screen saver is turned off */ saverset = XmToggleButtonGadgetGetState(screen.saverOn); if (!saverset) { sprintf (screenres, "Dtstyle*timeoutScale: %d\n", screen.saverTimeout); _DtAddToResource (style.display, screenres); } /* write lock timeout resource to xrdb to save scale value */ /* when lock is turned off */ lockset = XmToggleButtonGadgetGetState(screen.lockOn); if (!lockset) { sprintf (screenres, "Dtstyle*lockoutScale: %d\n", screen.lockTimeout); _DtAddToResource (style.display, screenres); } /* if sendSettings is true send message to Session Manager */ if(style.smState.smSendSettings) { if(screen.systemDefaultFlag) { SmDefaultScreenSettings(); } else { SmNewScreenSettings(saverset||lockset ? screen.newTimeout : 0, screen.new_blanking, screen.interval, screen.exposures); } } if (savers.saverCount) { savers.selsaverActionNames = (char **) XtMalloc(sizeof(char *) * savers.selsaverCount); for (i=0; ibutton_position) { case OK_BUTTON: XtUnmanageChild (w); /* terminate the saver that is currently running */ if (savers.saverstate) { _DtSaverStop(style.display, savers.saverstate); savers.saverstate = NULL; } /* write saver timeout resource to xrdb to save scale value */ /* when screen saver is turned off */ saverset = XmToggleButtonGadgetGetState(screen.saverOn); if (!saverset) { sprintf (screenres, "Dtstyle*timeoutScale: %d\n", screen.saverTimeout); _DtAddToResource (style.display, screenres); } /* if sendSettings is true send message to Session Manager */ if(style.smState.smSendSettings) { if(screen.systemDefaultFlag) { SmDefaultScreenSettings(); } else { SmNewScreenSettings(saverset ? screen.newTimeout : 0, screen.new_blanking, screen.interval, screen.exposures); } } if (savers.saverCount) { savers.selsaverActionNames = (char **) XtMalloc(sizeof(char *) * savers.selsaverCount); for (i=0; i 1) { XtSetSensitive(screen.cycleTimeLabel, True); XtSetSensitive(screen.cycleTimeScale, True); XtSetSensitive(screen.cycleMinutesLabel, True); } if (savers.saverCount) /* display the preview label */ XtManageChild(screen.prevLabel); /* let the session manger know to run the savers */ SmNewSaverTime(screen.saverTimeout*60); } else { XmToggleButtonGadgetSetState(screen.useSaversOff, True, False); XmToggleButtonGadgetSetState(screen.useSaversOn, False, False); XtSetSensitive(screen.saverList, False); XtSetSensitive(screen.saverArea, False); XtSetSensitive(screen.cycleTimeLabel, False); XtSetSensitive(screen.cycleTimeScale, False); XtSetSensitive(screen.cycleMinutesLabel, False); /* do not display preview string */ XtUnmanageChild(screen.prevLabel); /* set the background color of the saver window to the */ /* secondary color ID */ XSync(style.display, False); XtVaSetValues(screen.saverArea, XmNbackground, savers.bg, NULL); XClearWindow(style.display, XtWindow(screen.saverArea)); /* let the session manger know not to run any savers */ SmNewSaverTime(0); } /* reset the X timeout */ screen.newTimeout = screen.origTimeout; XSetScreenSaver(style.display, screen.origTimeout, screen.interval, screen.blanking,screen.exposures); if (savers.saverCount) { /* reset the list selection back to the current state */ /* first deselect all items */ XmListDeselectAllItems(screen.saverList); for (i=0; i 0) { savers.selPositions = (int *) XtMalloc(sizeof(int) * savers.orig_selsaverCount); for (i=0; iwidget; x -= vendorExt->vendor.xOffset; y -= vendorExt->vendor.yOffset; sprintf(bufr, "%s*Screen.x: %d\n", bufr, x); sprintf(bufr, "%s*Screen.y: %d\n", bufr, y); if(-1 == write (fd, bufr, strlen(bufr))) { perror(strerror(errno)); } } } /************************************************************************/ /* MakeListStrings() */ /* Make XmStrings from the saver names, to pass into list. */ /************************************************************************/ static XmString * MakeListStrings( char ** list ) { int i; XmString *xmList; xmList = (XmString *) XtMalloc(savers.saverCount * sizeof(XmString)); for (i = 0; i < savers.saverCount; i++) { xmList[i] = XmStringCreateLocalized (list[i]); } return (xmList); } /************************************************************************/ /* FreeListStrings() */ /************************************************************************/ static void FreeListStrings(XmString *xmlist, int count) { int i; for (i = 0; i < count; i++) { if (xmlist[i]) XmStringFree(xmlist[i]); } XtFree ((char *)xmlist); } /************************************************************************/ /* ListCB() */ /* Get the lastly selected Screen saver client running in the preview */ /* area. For a multiple selection by dragging, the last item in the */ /* selection is the client that is previewed. */ /************************************************************************/ static void ListCB( Widget w, XtPointer client_data, XtPointer call_data ) { XmListCallbackStruct *cb = (XmListCallbackStruct *)call_data; int i; Boolean runsaver = False; XmString string; /* If no items are left in the selection (i.e. the last selected item */ /* was deselected) then force the previously selected item to remain */ /* selected */ if (cb->selected_item_count == 0) { XmListSelectPos(screen.saverList, cb->item_position, False); savers.selsaverCount = 1; if (savers.selPositions != NULL) XtFree ((char *) savers.selPositions); savers.selPositions = (int *) XtMalloc(sizeof(int)); savers.selPositions[0] = cb->item_position; savers.current_saver = savers.saverActionNames[savers.selPositions[0] - 1]; savers.current_saverDesc = savers.saverActionDesc[savers.selPositions[0] - 1]; return; } /* make a copy of the selected item positions for later use */ if (savers.selPositions != NULL) XtFree ((char *) savers.selPositions); savers.selPositions = (int *) XtMalloc(sizeof(int) * cb->selected_item_count); for (i=0; i< cb->selected_item_count; i++) { savers.selPositions[i] = cb->selected_item_positions[i]; } savers.selsaverCount = cb->selected_item_count; if (savers.selsaverCount < 2) { XtSetSensitive(screen.cycleTimeScale, False); XtSetSensitive(screen.cycleTimeLabel, False); XtSetSensitive(screen.cycleMinutesLabel, False); } else if (savers.previous_selsaverCount < 2) { XtSetSensitive(screen.cycleTimeScale, True); XtSetSensitive(screen.cycleTimeLabel, True); XtSetSensitive(screen.cycleMinutesLabel, True); } savers.previous_selsaverCount = savers.selsaverCount; /* Find out if the item is selected or deselected. When an item */ /* is deselected item_position is set to the deselected item which has */ /* the keyboard focus. However, the deselected screen saver must not be */ /* previewed. Therfore before a screen saver is started, its position must */ /* exist in the selected_item_positions array. If not then just return without */ /* altering the current (previewed) saver unless the deselected saver was the */ /* current saver. In that case kill the current saver and preview the last */ /* item from the selected list. */ for (i=0; iselected_item_count; i++) { if(cb->selected_item_positions[i] == cb->item_position) runsaver=True; } if (!runsaver) { i = cb->selected_item_positions[(cb->selected_item_count-1)]; if (savers.current_position == cb->item_position) { if (savers.saverstate) { /* Terminate the screen saver that is currently running */ _DtSaverStop(style.display, savers.saverstate); XSync(style.display, False); savers.saverstate = NULL; } savers.current_saver = savers.saverActionNames[i-1]; savers.current_saverDesc = savers.saverActionDesc[i-1]; savers.current_position = i; XtVaSetValues(screen.saverArea, XmNbackground, savers.black, NULL); savers.saverstate = _DtSaverStart(style.display, &screen.saverArea, 1, savers.current_saver, style.screenDialog); string = XmStringCreateLocalized (savers.current_saverDesc); XtVaSetValues(screen.prevLabel, XmNlabelString, string, NULL); XmStringFree(string); } return; } /* The item position returned is the selcted item */ /* Start screen saver. _DtSaverStop() must be called to terminate the */ /* screen saver. */ if (savers.saverstate) { /* Terminate the screen saver that is currently running */ _DtSaverStop(style.display, savers.saverstate); XSync(style.display, False); savers.saverstate = NULL; } XSync(style.display, False); XClearWindow(style.display, XtWindow(screen.saverArea)); XSync(style.display, False); XtVaSetValues(screen.saverArea, XmNbackground, savers.black, NULL); savers.current_position = cb->item_position; savers.current_saver = savers.saverActionNames[savers.current_position - 1]; savers.current_saverDesc = savers.saverActionDesc[savers.current_position - 1]; savers.saverstate = _DtSaverStart(style.display, &screen.saverArea, 1, savers.current_saver, style.screenDialog); /* update the preview label with the current running saver */ XtVaSetValues(screen.prevLabel, XmNlabelString, cb->item, NULL); } /************************************************************************/ /* IconHandler() */ /* Kills the currently previewed saver when the user iconifies the */ /* style manager. An XtEventHandler. */ /************************************************************************/ static void IconHandler( Widget shell, XtPointer client_data, XEvent *event, Boolean *dispatch) { XmString string; if (event->type == UnmapNotify) { /* terminate the saver that is currently running */ if (savers.saverstate) { _DtSaverStop(style.display, savers.saverstate); savers.saverstate = NULL; } } /* run the current screen saver only if the useSaversOn/saverOn toggle is enabled and valid saver exist and one is not already running*/ else if (savers.saverCount && event->type == 19 && !savers.saverstate) if (style.smState.smLockOnTimeoutStatus) { if (XmToggleButtonGadgetGetState(screen.saverOn) && savers.saverCount) { XtVaSetValues(screen.saverArea, XmNbackground, savers.black, NULL); savers.saverstate = _DtSaverStart(style.display, &screen.saverArea, 1, savers.current_saver, style.screenDialog); string = XmStringCreateLocalized (savers.current_saverDesc); XtVaSetValues(screen.prevLabel, XmNlabelString, string, NULL); XmStringFree(string); } } else { if (XmToggleButtonGadgetGetState(screen.useSaversOn) && savers.saverCount) { XtVaSetValues(screen.saverArea, XmNbackground, savers.black, NULL); savers.saverstate = _DtSaverStart(style.display, &screen.saverArea, 1, savers.current_saver, style.screenDialog); string = XmStringCreateLocalized (savers.current_saverDesc); XtVaSetValues(screen.prevLabel, XmNlabelString, string, NULL); XmStringFree(string); } } } /************************************************************************/ /* UnmapCB() */ /* Kills the currently previewed saver when the user iconifies the */ /* style manager or unmaps the screen dialog. */ /************************************************************************/ static void UnmapCB( Widget w, XtPointer client_data, XtPointer call_data ) { /* terminate the saver that is currently running */ if (savers.saverstate) { _DtSaverStop(style.display, savers.saverstate); savers.saverstate = NULL; } }