Initial import of the CDE 2.1.30 sources from the Open Group.

This commit is contained in:
Peter Howkins
2012-03-10 18:21:40 +00:00
commit 83b6996daa
18978 changed files with 3945623 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
# $XConsortium: Makefile.hp /main/2 1996/05/13 11:53:35 drk $
##########################################################################
#
# Makefile for dtwidget examples (HP)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM1 = occupy
SOURCES1 = occupy.c
OBJECTS1 = occupy.o
PROGRAM2 = wsinfo
SOURCES2 = wsinfo.c
OBJECTS2 = wsinfo.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Aa -z $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include/X11R5
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -ltt -lXm
X11LIBS = -L/usr/lib/X11R5 -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
${CC} -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM1) $(PROGRAM2)
$(PROGRAM1):: $(OBJECTS1)
$(CC) -o $(PROGRAM1) $(LDFLAGS) $(OBJECTS1) $(LIBRARIES)
$(PROGRAM2):: $(OBJECTS2)
$(CC) -o $(PROGRAM2) $(LDFLAGS) $(OBJECTS2) $(LIBRARIES)
clean::
$(RM) $(PROGRAM1) $(OBJECTS1)
$(RM) $(PROGRAM2) $(OBJECTS2)

View File

@@ -0,0 +1,53 @@
# $XConsortium: Makefile.ibm /main/2 1996/05/13 11:53:53 drk $
##########################################################################
#
# Makefile for dtwidget examples (IBM)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM1 = occupy
SOURCES1 = occupy.c
OBJECTS1 = occupy.o
PROGRAM2 = wsinfo
SOURCES2 = wsinfo.c
OBJECTS2 = wsinfo.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -ltt -lXm
X11LIBS = -L/usr/lib -lXt -lX11
SYSLIBS =
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM1) $(PROGRAM2)
$(PROGRAM1):: $(OBJECTS1)
$(CC) -o $(PROGRAM1) $(LDFLAGS) $(OBJECTS1) $(LIBRARIES)
$(PROGRAM2):: $(OBJECTS2)
$(CC) -o $(PROGRAM2) $(LDFLAGS) $(OBJECTS2) $(LIBRARIES)
clean::
$(RM) $(PROGRAM1) $(OBJECTS1)
$(RM) $(PROGRAM2) $(OBJECTS2)

View File

@@ -0,0 +1,53 @@
# $XConsortium: Makefile.novell /main/2 1996/05/13 11:54:13 drk $
##########################################################################
#
# Makefile for dtwidget examples (Novell)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM1 = occupy
SOURCES1 = occupy.c
OBJECTS1 = occupy.o
PROGRAM2 = wsinfo
SOURCES2 = wsinfo.c
OBJECTS2 = wsinfo.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/X/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
X11LIBS = -L/usr/X/lib -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket -lXIM
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM1) $(PROGRAM2)
$(PROGRAM1):: $(OBJECTS1)
$(CC) -o $(PROGRAM1) $(LDFLAGS) $(OBJECTS1) $(LIBRARIES)
$(PROGRAM2):: $(OBJECTS2)
$(CC) -o $(PROGRAM2) $(LDFLAGS) $(OBJECTS2) $(LIBRARIES)
clean::
$(RM) $(PROGRAM1) $(OBJECTS1)
$(RM) $(PROGRAM2) $(OBJECTS2)

View File

@@ -0,0 +1,53 @@
# $XConsortium: Makefile.sun /main/2 1996/05/13 11:54:29 drk $
##########################################################################
#
# Makefile for dtwidget examples (SUN)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM1 = occupy
SOURCES1 = occupy.c
OBJECTS1 = occupy.o
PROGRAM2 = wsinfo
SOURCES2 = wsinfo.c
OBJECTS2 = wsinfo.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
X11INCLUDE = -I/usr/openwin/include
INCLUDES = $(DTINCLUDE) $(X11INCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -lXm
X11LIBS = -L/usr/openwin/lib -lXt -lX11
SYSLIBS = -ldl -lw -lgen
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS = -R/usr/dt/lib:/usr/openwin/lib
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM1) $(PROGRAM2)
$(PROGRAM1):: $(OBJECTS1)
$(CC) -o $(PROGRAM1) $(LDFLAGS) $(OBJECTS1) $(LIBRARIES)
$(PROGRAM2):: $(OBJECTS2)
$(CC) -o $(PROGRAM2) $(LDFLAGS) $(OBJECTS2) $(LIBRARIES)
clean::
$(RM) $(PROGRAM1) $(OBJECTS1)
$(RM) $(PROGRAM2) $(OBJECTS2)

View File

@@ -0,0 +1,54 @@
# $XConsortium: Makefile.uxp /main/2 1996/05/13 11:54:50 drk $
##########################################################################
#
# Makefile for dtwidget examples (UXP)
#
# (Fujitsu.patch applied)
#
# (c) Copyright 1993, 1994 Hewlett-Packard Company
# (c) Copyright 1993, 1994 International Business Machines Corp.
# (c) Copyright 1993, 1994 Sun Microsystems, Inc.
# (c) Copyright 1993, 1994 Novell, Inc.
#
##########################################################################
CC = cc
RM = rm -f
PROGRAM1 = occupy
SOURCES1 = occupy.c
OBJECTS1 = occupy.o
PROGRAM2 = wsinfo
SOURCES2 = wsinfo.c
OBJECTS2 = wsinfo.o
DEFINES =
CDEBUGFLAGS = -O
CFLAGS = -Xc $(DEFINES) $(CDEBUGFLAGS)
DTINCLUDE = -I/usr/dt/include
INCLUDES = $(DTINCLUDE)
DTLIBS = -L/usr/dt/lib -lDtSvc -ltt -lXm
X11LIBS = -lXt -lX11
SYSLIBS = -lw -lgen -lnsl -lresolv -lsocket
LIBRARIES = $(DTLIBS) $(X11LIBS) $(SYSLIBS)
LDFLAGS =
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
all:: $(PROGRAM1) $(PROGRAM2)
$(PROGRAM1):: $(OBJECTS1)
$(CC) -o $(PROGRAM1) $(LDFLAGS) $(OBJECTS1) $(LIBRARIES)
$(PROGRAM2):: $(OBJECTS2)
$(CC) -o $(PROGRAM2) $(LDFLAGS) $(OBJECTS2) $(LIBRARIES)
clean::
$(RM) $(PROGRAM1) $(OBJECTS1)
$(RM) $(PROGRAM2) $(OBJECTS2)

11
cde/examples/dtwsm/README Normal file
View File

@@ -0,0 +1,11 @@
/* $XConsortium: README /main/2 1996/07/15 14:03:12 drk $ */
This directory contains demonstrations of the DtWsm API.
occupy - Examples of setting and querying an application's presence
in CDE workspaces.
wsinfo - Examples of querying information about the attributes of the
applications current workspace.

463
cde/examples/dtwsm/occupy.c Normal file
View File

@@ -0,0 +1,463 @@
/* $XConsortium: occupy.c /main/3 1995/10/27 10:41:19 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company
* (c) Copyright 1993, 1994 International Business Machines Corp.
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
* (c) Copyright 1993, 1994 Novell, Inc.
*/
/* Demonstrate the DtWsm Workspace API. */
/*
* include files
*/
#include <stdio.h>
#include <Xm/XmAll.h>
#include <Dt/Wsm.h>
/*
* functions
*/
void main();
static void quitCB();
static void setCB();
static void showCB();
static void wsCB();
static void allWsCB();
static void SetupWorkspaceButtons ();
static void ShowWorkspaceOccupancy();
static void SetWorkspaceOccupancy();
/*
* global variables
*/
static XmString xms;
static Widget toplevel;
static Widget wChildren [20];
static Widget *wWs;
static Atom *paWsSet = NULL;
static Boolean *pbOccupy;
static unsigned long numWorkspaces;
static Atom *paWs;
/*
* button assignments
*/
#define QUIT_BUTTON (wChildren[0])
#define SEPARATOR (wChildren[1])
#define SET_BUTTON (wChildren[2])
#define SHOW_BUTTON (wChildren[3])
#define ALL_WS_BUTTON (wChildren[4])
#define NUM_CHILDREN 5
/*
* main - main logic for program
*/
void main (argc,argv)
int argc;
char **argv;
{
Widget frame;
Widget form;
Widget top;
XtAppContext app_context;
Arg args[10];
int n;
int i;
/*
* initialize toolkit
*/
n = 0;
XtSetArg (args[n], XmNallowShellResize, True); n++;
toplevel = XtAppInitialize (&app_context, "Dtoccupy", NULL, 0, &argc, argv,
NULL, args, n);
n = 0;
XtSetArg (args[n], XmNmarginWidth, 10); n++;
XtSetArg (args[n], XmNmarginHeight, 10); n++;
frame = XmCreateFrame (toplevel, "frame", args, n);
XtManageChild (frame);
/*
* manager widget
*/
n = 0;
form = XmCreateForm (frame, "form", args, n);
XtManageChild (form);
/*
* create compound string for the button text
*/
xms = XmStringCreateLocalized("Quit");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
/*
* create button
*/
top = QUIT_BUTTON = XtCreateWidget ("button", xmPushButtonWidgetClass,
form, args, n);
XmStringFree(xms);
/*
* add callback
*/
XtAddCallback (QUIT_BUTTON, XmNactivateCallback, quitCB, NULL);
/*
* create compound string for the button text
*/
xms = XmStringCreateLocalized("Set Occupancy");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create button
*/
top = SET_BUTTON = XtCreateWidget ("button", xmPushButtonWidgetClass,
form, args, n);
XmStringFree(xms);
/*
* add callback
*/
XtAddCallback (SET_BUTTON, XmNactivateCallback, setCB, NULL);
/*
* create compound string for the button text
*/
xms = XmStringCreateLocalized("Occupy All Workspaces");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create button
*/
top = ALL_WS_BUTTON = XtCreateWidget ("button", xmPushButtonWidgetClass,
form, args, n);
XmStringFree(xms);
/*
* add callback
*/
XtAddCallback (ALL_WS_BUTTON, XmNactivateCallback, allWsCB, NULL);
/*
* create compound string for the button text
*/
xms = XmStringCreateLocalized("Show Occupancy");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create button
*/
top = SHOW_BUTTON = XtCreateWidget ("button", xmPushButtonWidgetClass,
form, args, n);
XmStringFree(xms);
/*
* add callback
*/
XtAddCallback (SHOW_BUTTON, XmNactivateCallback, showCB, NULL);
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create separator
*/
top = SEPARATOR = (Widget)
XmCreateSeparatorGadget (form, "separator", args, n);
/*
* set up workspace buttons
*/
SetupWorkspaceButtons (form, top);
/*
* manage children
*/
XtManageChildren (wChildren, NUM_CHILDREN);
XtManageChildren (wWs, numWorkspaces);
/*
* realize widgets
*/
XtRealizeWidget (toplevel);
/*
* set up initial workspace occupancy info
*/
pbOccupy = (Boolean *) XtMalloc (numWorkspaces * sizeof (Boolean));
for (i=0; i<numWorkspaces; i++)
{
pbOccupy[i] = False;
}
ShowWorkspaceOccupancy ();
/*
* process events
*/
XtAppMainLoop (app_context);
}
/*-------------------------------------------------------------
* Create a set of buttons for the current set of workspaces
*/
static void SetupWorkspaceButtons (form, top)
Widget form;
Widget top;
{
Window root;
Arg args[10]; /* arg list */
register int n; /* arg count */
register int i;
DtWsmWorkspaceInfo *pWsInfo;
char *pchWs;
Widget left = None;
Widget *pWid;
/*
* get workspace information
*/
root = XRootWindowOfScreen(XtScreen(form));
if (DtWsmGetWorkspaceList (XtDisplay(form), root,
&paWs, (int *)&numWorkspaces) == Success)
{
wWs = (Widget *) XtMalloc (numWorkspaces * sizeof (Widget));
pWid = wWs;
for (i=0; i<numWorkspaces; i++, pWid++)
{
DtWsmGetWorkspaceInfo (XtDisplay(form), root, paWs[i],
&pWsInfo);
pchWs = (char *) XmGetAtomName (XtDisplay(form),
pWsInfo->workspace);
/*
* create compound string for the button text
*/
xms = XmStringCreateLocalized(pchWs);
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNindicatorOn, True); n++;
XtSetArg (args[n], XmNindicatorType, XmN_OF_MANY); n++;
if (left == None)
{
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
}
else
{
XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNleftWidget, left); n++;
}
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create button
*/
*pWid = XtCreateWidget ("button", xmToggleButtonWidgetClass,
form, args, n);
XmStringFree(xms);
/*
* add callback
*/
XtAddCallback (*pWid, XmNvalueChangedCallback, wsCB,
(XtPointer) i);
left = *pWid;
}
}
else
{
fprintf(stderr, "Failed to get workspace info -- dtwm not running!\n");
exit (1);
}
}
/*-------------------------------------------------------------
* Update the workspace buttons with where we are now.
*/
static void ShowWorkspaceOccupancy ()
{
Arg args[10]; /* arg list */
register int n; /* arg count */
int i,j;
Atom *paWsIn = NULL;
unsigned long numWsIn;
int rval;
rval = DtWsmGetWorkspacesOccupied(XtDisplay(toplevel),
XtWindow(toplevel), &paWsIn, &numWsIn );
if (rval == Success)
{
for (i = 0; i<numWorkspaces; i++)
{
pbOccupy[i] = False;
for (j=0; j<numWsIn; j++)
{
if (paWs[i] == paWsIn[j])
{
pbOccupy[i] = True;
break;
}
}
}
for (i = 0; i<numWorkspaces; i++)
{
n = 0;
if (pbOccupy[i])
{
XtSetArg (args[n], XmNset, True); n++;
}
else
{
XtSetArg (args[n], XmNset, False); n++;
}
XtSetValues (wWs[i], args, n);
}
if (paWsIn) XFree ((char *) paWsIn);
}
}
/*-------------------------------------------------------------
* quitCB - callback for button
*/
static void quitCB (w, client_data, call_data)
Widget w; /* widget id */
XtPointer client_data; /* data from application */
XtPointer call_data; /* data from widget class */
{
exit (0);
}
/*-------------------------------------------------------------
* showCB - callback for show occupancy button
*/
static void showCB (w, client_data, call_data)
Widget w; /* widget id */
XtPointer client_data; /* data from application */
XtPointer call_data; /* data from widget class */
{
ShowWorkspaceOccupancy();
}
/*-------------------------------------------------------------
* setCB - callback for set occupancy button
*/
static void setCB (w, client_data, call_data)
Widget w; /* widget id */
XtPointer client_data; /* data from application */
XtPointer call_data; /* data from widget class */
{
int numSet;
int i;
if (!paWsSet)
{
paWsSet = (Atom *) XtMalloc (numWorkspaces * sizeof(Atom));
}
for (i=0, numSet=0; i<numWorkspaces; i++)
{
if (pbOccupy[i])
{
paWsSet[numSet++] = paWs[i];
}
}
DtWsmSetWorkspacesOccupied (XtDisplay(toplevel),
XtWindow(toplevel), paWsSet, numSet);
}
/*-------------------------------------------------------------
* wsCB - callback for set occupancy button
*/
static void wsCB (w, client_data, call_data)
Widget w; /* widget id */
XtPointer client_data; /* data from application */
XtPointer call_data; /* data from widget class */
{
int i = (Atom) client_data; /* ws array index */
XmToggleButtonCallbackStruct *ptb =
(XmToggleButtonCallbackStruct *) call_data;
if (ptb->reason == XmCR_VALUE_CHANGED)
{
if (ptb->set)
{
pbOccupy[i] = True;
}
else
{
pbOccupy[i] = False;
}
}
}
/*-------------------------------------------------------------
* allWsCB - callback for occupy all button
*/
static void allWsCB (w, client_data, call_data)
Widget w; /* widget id */
XtPointer client_data; /* data from application */
XtPointer call_data; /* data from widget class */
{
DtWsmOccupyAllWorkspaces (XtDisplay(toplevel), XtWindow(toplevel));
}

618
cde/examples/dtwsm/wsinfo.c Normal file
View File

@@ -0,0 +1,618 @@
/* $XConsortium: wsinfo.c /main/3 1995/10/27 10:41:27 rswiston $ */
/*
* (c) Copyright 1993, 1994 Hewlett-Packard Company
* (c) Copyright 1993, 1994 International Business Machines Corp.
* (c) Copyright 1993, 1994 Sun Microsystems, Inc.
* (c) Copyright 1993, 1994 Novell, Inc.
*/
/* Demonstrate the CDE Workspace API. */
/*
* include files
*/
#include <stdio.h>
#include <Xm/XmAll.h>
#include <Dt/Wsm.h>
/*
* functions
*/
void main();
static void quitCB();
static void updateCB();
static void ShowCurrentWorkspaceInfo();
static DtWsmWsChangeProc wschangecb();
static void InstallXErrorHandler();
/*
* global variables
*/
static Widget toplevel;
static Widget wChildren[20];
/*
* button assignments
*/
#define QUIT_BUTTON (wChildren[0])
#define UPDATE_BUTTON (wChildren[1])
#define SEPARATOR (wChildren[2])
#define WS_LABEL (wChildren[3])
#define WS_VALUE (wChildren[4])
#define TITLE_LABEL (wChildren[5])
#define TITLE_VALUE (wChildren[6])
#define BACKDROP_LABEL (wChildren[7])
#define BACKDROP_VALUE (wChildren[8])
#define COLORSET_LABEL (wChildren[9])
#define COLORSET_VALUE (wChildren[10])
#define SEPARATOR2 (wChildren[11])
#define NUM_CHILDREN 12
/*
* main - main logic for program
*/
void main (argc,argv)
int argc;
char **argv;
{
Widget frame;
Widget form;
Widget top;
XtAppContext app_context;
Arg args[10];
register int n;
register int i;
XmString xms, xmsBlank;
/*
* initialize toolkit
*/
n = 0;
XtSetArg (args[n], XmNallowShellResize, True); n++;
toplevel = XtAppInitialize (&app_context, "Dtwsinfo", NULL, 0, &argc, argv,
NULL, args, n);
/*
* Set up X error handling
*/
InstallXErrorHandler ();
n = 0;
XtSetArg (args[n], XmNmarginWidth, 10); n++;
XtSetArg (args[n], XmNmarginHeight, 10); n++;
frame = XmCreateFrame (toplevel, "frame", args, n);
XtManageChild (frame);
/*
* manager widget
*/
n = 0;
form = XmCreateForm (frame, "form", args, n);
XtManageChild (form);
/*
* create compound string for blank labels
*/
xmsBlank = XmStringCreateLocalized(" ");
/*******************************************
* QUIT BUTTON
******************************************/
/*
* create compound string for the button text
*/
xms = XmStringCreateLocalized("Quit");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_FORM); n++;
/*
* create button
*/
top = QUIT_BUTTON = XtCreateWidget ("button", xmPushButtonWidgetClass,
form, args, n);
XmStringFree(xms);
/*
* add callback
*/
XtAddCallback (QUIT_BUTTON, XmNactivateCallback, quitCB, NULL);
/*******************************************
* UPDATE WORKSPACE INFO BUTTON
******************************************/
/*
* create compound string for the button text
*/
xms = XmStringCreateLocalized("Get workspace info");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create button
*/
top = UPDATE_BUTTON = XtCreateWidget ("button", xmPushButtonWidgetClass,
form, args, n);
XmStringFree(xms);
/*
* add callback
*/
XtAddCallback (UPDATE_BUTTON, XmNactivateCallback, updateCB, NULL);
/*******************************************
* SEPARATOR
******************************************/
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create separator
*/
top = SEPARATOR = (Widget)
XmCreateSeparatorGadget (form, "separator", args, n);
/*******************************************
* LABEL FOR CURRENT WORKSPACE
******************************************/
/*
* NOTE: We assume this is the longest label and lay out the
* other fields based on this assumption.
*/
/*
* create compound string for the label text
*/
xms = XmStringCreateLocalized("Current workspace: ");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create label
*/
WS_LABEL = XtCreateWidget ("label", xmLabelWidgetClass,
form, args, n);
XmStringFree (xms);
/*******************************************
* VALUE FOR CURRENT WORKSPACE
******************************************/
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xmsBlank); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNleftWidget, WS_LABEL); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create value
*/
top = WS_VALUE = XtCreateWidget ("label", xmLabelWidgetClass,
form, args, n);
/*******************************************
* LABEL FOR WORKSPACE TITLE
******************************************/
/*
* create compound string for the label text
*/
xms = XmStringCreateLocalized(" title: ");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
XtSetArg (args[n], XmNrightWidget, WS_LABEL); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create label
*/
TITLE_LABEL = XtCreateWidget ("label", xmLabelWidgetClass,
form, args, n);
XmStringFree(xms);
/*******************************************
* VALUE FOR WORKSPACE TITLE
******************************************/
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xmsBlank); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNleftWidget, TITLE_LABEL); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create value
*/
top = TITLE_VALUE = XtCreateWidget ("label", xmLabelWidgetClass,
form, args, n);
/*******************************************
* LABEL FOR WORKSPACE BACKDROP
******************************************/
/*
* create compound string for the label text
*/
xms = XmStringCreateLocalized(" backdrop: ");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
XtSetArg (args[n], XmNrightWidget, WS_LABEL); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create label
*/
BACKDROP_LABEL = XtCreateWidget ("label", xmLabelWidgetClass,
form, args, n);
XmStringFree (xms);
/*******************************************
* VALUE FOR WORKSPACE BACKDROP
******************************************/
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xmsBlank); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNleftWidget, BACKDROP_LABEL); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create value
*/
top = BACKDROP_VALUE = XtCreateWidget ("label", xmLabelWidgetClass,
form, args, n);
/*******************************************
* LABEL FOR WORKSPACE COLORSET ID
******************************************/
/*
* create compound string for the label text
*/
xms = XmStringCreateLocalized(" color set id: ");
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_OPPOSITE_WIDGET); n++;
XtSetArg (args[n], XmNrightWidget, WS_LABEL); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create label
*/
COLORSET_LABEL = XtCreateWidget ("label", xmLabelWidgetClass,
form, args, n);
XmStringFree (xms);
/*******************************************
* VALUE FOR WORKSPACE COLORSET ID
******************************************/
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNlabelType, XmSTRING); n++;
XtSetArg (args[n], XmNlabelString, xmsBlank); n++;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNleftWidget, COLORSET_LABEL); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create value
*/
top = COLORSET_VALUE = XtCreateWidget ("label", xmLabelWidgetClass,
form, args, n);
/*******************************************
* SEPARATOR
******************************************/
/*
* set up arglist
*/
n = 0;
XtSetArg (args[n], XmNleftAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNrightAttachment, XmATTACH_FORM); n++;
XtSetArg (args[n], XmNtopAttachment, XmATTACH_WIDGET); n++;
XtSetArg (args[n], XmNtopWidget, top); n++;
/*
* create separator
*/
top = SEPARATOR2 = (Widget)
XmCreateSeparatorGadget (form, "separator", args, n);
/*
* manage children
*/
XtManageChildren (wChildren, NUM_CHILDREN);
/*
* Show info on current workspace
*/
ShowCurrentWorkspaceInfo ();
/*
* realize widgets
*/
XtRealizeWidget (toplevel);
/*
* Do these calls after the shell is realized.
* They need a window created for the top level shell.
*
* HINT: See XtSetMappedWhenManaged(1) if you want to
* realize a widget to get a window, but need to
* control when the map of the window occurs.
*/
(void) DtWsmAddCurrentWorkspaceCallback (toplevel,
(DtWsmWsChangeProc) wschangecb, NULL);
DtWsmOccupyAllWorkspaces (XtDisplay(toplevel), XtWindow(toplevel));
/*
* process events
*/
XtAppMainLoop (app_context);
}
/*-------------------------------------------------------------
* Update the information for the current workspace
*/
static void ShowCurrentWorkspaceInfo ()
{
Arg args[10]; /* arg list */
register int n; /* arg count */
Atom aWs;
int rval;
Display *dpy;
Window root;
DtWsmWorkspaceInfo *pWsInfo;
XmString xms;
char pch[512];
char *pchName;
dpy = XtDisplay(toplevel);
root = XDefaultRootWindow(dpy);
rval = DtWsmGetCurrentWorkspace(dpy, root, &aWs);
if (rval == Success)
{
rval = DtWsmGetWorkspaceInfo (dpy, root, aWs, &pWsInfo);
if (rval == Success)
{
/* workspace name */
pchName = XmGetAtomName (dpy, pWsInfo->workspace);
xms = XmStringCreateLocalized(pchName);
n = 0;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetValues (WS_VALUE, args, n);
XmStringFree (xms);
XtFree (pchName);
/* workspace title */
xms = XmStringCreateLocalized(pWsInfo->pchTitle);
n = 0;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetValues (TITLE_VALUE, args, n);
XmStringFree (xms);
/* workspace backdrop name */
if (pWsInfo->backdropName != None)
pchName = XmGetAtomName (dpy, pWsInfo->backdropName);
else
pchName = "<failed to load!>";
xms = XmStringCreateLocalized(pchName);
n = 0;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetValues (BACKDROP_VALUE, args, n);
XmStringFree (xms);
if (pWsInfo->backdropName != None)
XtFree (pchName);
/* workspace colorset id */
sprintf (pch, "%d", pWsInfo->colorSetId);
xms = XmStringCreateLocalized(pch);
n = 0;
XtSetArg (args[n], XmNlabelString, xms); n++;
XtSetValues (COLORSET_VALUE, args, n);
XmStringFree (xms);
DtWsmFreeWorkspaceInfo (pWsInfo);
}
}
if (rval != Success)
{
fprintf (stderr, "Failed to get workspace information.\n");
fprintf (stderr, "Is dtwm running?\n");
exit (1);
}
}
/*-------------------------------------------------------------
* quitCB - callback for button
*/
static void quitCB (w, client_data, call_data)
Widget w; /* widget id */
XtPointer client_data; /* data from application */
XtPointer call_data; /* data from widget class */
{
exit (0);
}
/*-------------------------------------------------------------
* updateCB - callback for show current workspace info
*/
static void updateCB (w, client_data, call_data)
Widget w; /* widget id */
XtPointer client_data; /* data from application */
XtPointer call_data; /* data from widget class */
{
ShowCurrentWorkspaceInfo ();
}
/*-------------------------------------------------------------
** wschangecb - callback for workspace switch
*/
static DtWsmWsChangeProc
wschangecb (w, atom, client_data)
Widget w;
Atom atom;
XtPointer client_data;
{
ShowCurrentWorkspaceInfo ();
}
/*-------------------------------------------------------------
** data for X error handler
*/
#define E_MAJOR_CODE 0
#define E_MINOR_CODE 1
#define E_RESOURCE_ID 2
#define E_ERROR_SERIAL 3
#define E_CURRENT_SERIAL 4
#define NUM_E_STRINGS 5
static char *pchErrorFormatNames [NUM_E_STRINGS] = {
"MajorCode",
"MinorCode",
"ResourceID",
"ErrorSerial",
"CurrentSerial"
};
static char *pchErrorFormat [NUM_E_STRINGS];
/*-------------------------------------------------------------
** HandleXErrors - catch X protocol errors
*/
static int
_HandleXErrors (display, errorEvent)
Display *display;
XErrorEvent *errorEvent;
{
char buffer[BUFSIZ];
char message[BUFSIZ];
XGetErrorText (display, errorEvent->error_code, buffer, BUFSIZ);
fprintf (stderr, "\n*** X error occurred ***\n");
fprintf (stderr, "Description = '%s'\n ", buffer);
fprintf (stderr, pchErrorFormat[E_MAJOR_CODE], errorEvent->request_code);
sprintf(message, "%d", errorEvent->request_code);
XGetErrorDatabaseText (display, "XRequest", message, " ", buffer, BUFSIZ);
fprintf (stderr, " (%s)\n ", buffer);
fprintf (stderr, pchErrorFormat[E_MINOR_CODE], errorEvent->minor_code);
fprintf (stderr, "\n ");
fprintf (stderr, pchErrorFormat[E_RESOURCE_ID], errorEvent->resourceid);
fprintf (stderr, "\n ");
fprintf (stderr, pchErrorFormat[E_ERROR_SERIAL], errorEvent->serial);
fprintf (stderr, "\n ");
fprintf (stderr, pchErrorFormat[E_CURRENT_SERIAL],
LastKnownRequestProcessed(display));
fprintf (stderr, "\n");
return (0);
}
/*-------------------------------------------------------------
** Setup the X error handler
*/
static void
InstallXErrorHandler ( display )
Display *display;
{
char buffer[BUFSIZ];
int i;
/*
* Fetch the X error format strings from XErrorDB
*/
for (i = 0; i< NUM_E_STRINGS; i++)
{
XGetErrorDatabaseText (display, "XlibMessage",
pchErrorFormatNames[i], " %d ", buffer, BUFSIZ);
pchErrorFormat[i] = (char *) XtMalloc (1+strlen(buffer));
strcpy(pchErrorFormat[i], buffer);
}
XSetErrorHandler (_HandleXErrors);
}